Skip to content
......@@ -2975,9 +2975,11 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in
Word16 sfb;
Word16 tmp;
Word16 delta;
#ifndef ISSUE_1796_replace_shl_o
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move16();
#endif
#endif
set16_fx( a, 0, IGF_MAX_SFB + 1 );
......@@ -2992,7 +2994,11 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in
move16();
tmp = add( tmp, 1 );
delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] );
#ifdef ISSUE_1796_replace_shl_o
delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) );
#else
delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) );
#endif
a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) );
move16();
IF( s_and( a[tmp], 1 ) != 0 )
......@@ -3023,9 +3029,11 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han
Word16 sfb;
Word16 tmp;
Word16 delta;
#ifndef ISSUE_1796_replace_shl_o
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
Flag Overflow = 0;
move16();
#endif
#endif
set16_fx( a, 0, IGF_MAX_SFB + 1 );
......@@ -3040,7 +3048,11 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han
move16();
tmp = add( tmp, 1 );
delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] );
#ifdef ISSUE_1796_replace_shl_o
delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) );
#else
delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) );
#endif
a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) );
move16();
// Rounding off delta values >=t+0.5 to t+1
......
......@@ -49,6 +49,21 @@
#define NUM_TAPS_F0_5 ( Word16 )( 48 ) // (Word16) ceil( 0.5f * hBinRenConvModule->numTaps )
#define NUM_TAPS_F0_4 ( Word16 )( 39 ) // (Word16) ceil( 0.4f * hBinRenConvModule->numTaps )
#define NUM_TAPS_F0_3 ( Word16 )( 29 ) // (Word16) ceil( 0.3f * hBinRenConvModule->numTaps )
#ifdef FIX_1053_REVERB_RECONFIGURATION
/*----------------------------------------------------------------------------------*
* Local constants
*----------------------------------------------------------------------------------*/
#define REVERB_INPUT_DOWNMIX_CHANNELS ( 11 )
/* Downmix table for sparse frequency domain reverberator*/
const Word32 dmxmtx_table_fx[BINAURAL_CHANNELS][REVERB_INPUT_DOWNMIX_CHANNELS] = {
// Q31
{ 0x7fffffff, 0, 1518485623, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0 },
{ 0, 0x7fffffff, 1518485623, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff },
};
#endif
/*-------------------------------------------------------------------------
* ivas_binRenderer_filterModule_fx()
*
......@@ -999,8 +1014,12 @@ static void ivas_binaural_obtain_DMX_fx(
FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ )
{
#ifdef FIX_1053_REVERB_RECONFIGURATION
Word32 dmxConst = dmxmtx_table_fx[chOutIdx][chIdx];
#else
Word32 dmxConst = hBinRenderer->hReverb->dmxmtx_fx[chOutIdx][chIdx];
move32();
#endif
FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ )
{
......@@ -1249,7 +1268,11 @@ ivas_error ivas_binRenderer_open_fx(
)
{
BINAURAL_RENDERER_HANDLE hBinRenderer;
#ifdef FIX_1053_REVERB_RECONFIGURATION
Word16 convBand, k;
#else
Word16 convBand, chIdx, k;
#endif
ivas_error error;
error = IVAS_ERR_OK;
......@@ -1414,13 +1437,12 @@ ivas_error ivas_binRenderer_open_fx(
IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
#endif
{
IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) )
{
IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ){
return error;
}
/* initialize the dmx matrix */
#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM
#ifndef FIX_1053_REVERB_RECONFIGURATION
IF( NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) )
{
FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
......@@ -1432,15 +1454,6 @@ ivas_error ivas_binRenderer_open_fx(
}
}
}
#else
FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
{
FOR( k = 0; k < hBinRenderer->nInChannels; k++ )
{
hBinRenderer->hReverb->dmxmtx_fx[chIdx][k] = dmxmtx_table_fx[chIdx][k];
move32();
}
}
#endif
}
ELSE
......@@ -1450,19 +1463,11 @@ ivas_error ivas_binRenderer_open_fx(
hBinRenderer->hEFAPdata = NULL;
#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM
IF( hBinRenderer->hReverb != NULL && NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) )
#else
IF( hBinRenderer->hReverb != NULL )
#endif
{
test();
test();
#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM
IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 )
#else
IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) )
#endif
{
FOR( k = 0; k < 11; k++ )
{
......@@ -1568,6 +1573,10 @@ static void ivas_binRenderer_convModuleClose_fx(
free( hBinRenConvModule->filterStatesLeftImag_fx );
hBinRenConvModule->filterStatesLeftImag_fx = NULL;
#ifdef FIX_1844_MISSING_FREE
free( hBinRenConvModule->Q_filterStates );
hBinRenConvModule->Q_filterStates = NULL;
#endif
free( ( *hBinRenderer )->hBinRenConvModule );
( *hBinRenderer )->hBinRenConvModule = NULL;
......@@ -1784,19 +1793,6 @@ void ivas_binRenderer_fx(
/* Compute Convolution */
/* memory reset for the binaural output */
#ifndef OPT_SBA_DEC_V2_BE
FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
{
FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ )
{
FOR( k = 0; k < numTimeSlots; k++ )
{
set32_fx( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
set32_fx( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], 0, CLDFB_NO_CHANNELS_MAX );
}
}
}
#endif /* OPT_SBA_DEC_V2_BE */
/* Note: on main, this nested for loop was removed under a "bit-exact optimization" under switch OPT_SBA_DEC_V2_BE */
/* this was found to clash with split rendering, so kept here. WMOPS impact should be assessed */
......@@ -1968,7 +1964,6 @@ void ivas_binRenderer_fx(
}
}
#ifdef OPT_SBA_DEC_V2_BE
Word16 len = sub( CLDFB_NO_CHANNELS_MAX, hBinRenderer->conv_band );
FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
......@@ -1981,7 +1976,6 @@ void ivas_binRenderer_fx(
set32_fx( &Cldfb_ImagBuffer_Binaural_fx[pos_idx][1][k][hBinRenderer->conv_band], 0, len );
}
}
#endif /* OPT_SBA_DEC_V2_BE */
pop_wmops();
return;
......
......@@ -342,7 +342,11 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
}
ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) )
{
#ifdef NONBE_FIX_ISM_XOVER_BR
IF( NE_32( ( error = mct_dec_reconfigure_fx( st_ivas, (UWord16) NE_16( nchan_transport_real, nchan_transport_old ) ) ), IVAS_ERR_OK ) )
#else
IF( NE_32( ( error = mct_dec_reconfigure_fx( st_ivas, (UWord16) NE_16( st_ivas->nchan_transport, nchan_transport_old ) ) ), IVAS_ERR_OK ) )
#endif
{
return error;
}
......@@ -444,7 +448,13 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
*-----------------------------------------------------------------*/
test();
IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
#ifdef NONBE_FIX_ISM_XOVER_BR
test();
test();
IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
#else
if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
#endif
{
ivas_sba_set_cna_cng_flag( st_ivas );
}
......@@ -567,7 +577,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
hDecoderConfig = st_ivas->hDecoderConfig;
ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
/* special case, if there was one transport channel in the previous frame and more than one in the current frame,
remove the second CLDFB here, it was for CNA/CNG */
......
......@@ -1246,6 +1246,9 @@ void ivas_dirac_dec_read_BS_fx(
Word16 *nb_bits, /* o : number of bits read */
const Word16 last_bit_pos, /* i : last read bitstream position */
const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */
#ifdef NONBE_FIX_1052_SBA_EXT
const Word16 nchan_transport, /* i : number of transport channels */
#endif
Word16 *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */
)
{
......@@ -1289,9 +1292,13 @@ void ivas_dirac_dec_read_BS_fx(
set32_fx( hQMetaData->q_direction[0].band_data[b].elevation_fx, 0, MAX_PARAM_SPATIAL_SUBFRAMES );
}
}
#ifdef NONBE_FIX_1052_SBA_EXT
*nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ) );
move16();
#else
*nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ) );
move16();
#endif
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
......@@ -1351,7 +1358,12 @@ void ivas_dirac_dec_read_BS_fx(
/* subtract mode signaling bits, since bitstream was moved after mode reading */
iDiv_and_mod_32( ivas_total_brate, FRAMES_PER_SEC, &quo, &rem, 0 );
#ifdef NONBE_FIX_1052_SBA_EXT
st->next_bit_pos = extract_l( L_sub( L_sub( quo, 1 ), SID_FORMAT_NBITS + SBA_PLANAR_BITS + SBA_ORDER_BITS ) );
#else
st->next_bit_pos = extract_l( L_sub( L_sub( quo, 1 ), SID_FORMAT_NBITS ) );
#endif
move16();
/* 1 bit flag for signaling metadata to read */
b = st->bit_stream[( st->next_bit_pos )--];
......@@ -1374,8 +1386,13 @@ void ivas_dirac_dec_read_BS_fx(
}
}
}
#ifdef NONBE_FIX_1052_SBA_EXT
*nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), nchan_transport, NULL, SBA_FORMAT ) );
move16();
#else
*nb_bits = add( *nb_bits, ivas_qmetadata_dec_sid_decode( hQMetaData, st->bit_stream, &( st->next_bit_pos ), 0, NULL, SBA_FORMAT ) );
move16();
#endif
FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
{
hQMetaData->q_direction[0].band_data[orig_dirac_bands - 1].azimuth_fx[i] = hQMetaData->q_direction[0].band_data[1].azimuth_fx[0];
......@@ -1779,67 +1796,36 @@ void ivas_qmetadata_to_dirac_fx(
}
ELSE
{
#ifndef OPT_SBA_DEC_PATH
Word16 tmp1, tmp4;
#endif /* OPT_SBA_DEC_PATH */
Word16 a, b_tmp;
Word16 exp_factor = 0;
move16();
a = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor
#ifndef OPT_SBA_DEC_PATH
tmp1 = mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5
Word32 tmp1_32 = L_deposit_h( tmp1 );
#else /* OPT_SBA_DEC_PATH */
Word32 tmp1_32 = L_mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5
#endif /* OPT_SBA_DEC_PATH */
Word16 final_1_exp;
Word32 final_1_32;
#ifndef OPT_SBA_DEC_PATH
final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, add( exp_factor, 5 ), &final_1_exp );
#else /* OPT_SBA_DEC_PATH */
Word16 norm_op1 = norm_l( azimuth_fx );
Word16 norm_op2 = norm_l( tmp1_32 );
Word16 op2_e = add( exp_factor, 5 );
final_1_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom
final_1_32 = L_add( L_shr( azimuth_fx, sub( final_1_exp, 9 ) ), L_shr( tmp1_32, sub( final_1_exp, op2_e ) ) );
#endif /* OPT_SBA_DEC_PATH */
b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor
#ifndef OPT_SBA_DEC_PATH
tmp4 = mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4
Word32 tmp4_32 = L_deposit_h( tmp4 );
#else /* OPT_SBA_DEC_PATH */
Word32 tmp4_32 = L_mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4
#endif /* OPT_SBA_DEC_PATH */
Word16 final_2_exp;
Word32 final_2_32;
#ifndef OPT_SBA_DEC_PATH
final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, add( exp_factor, 4 ), &final_2_exp );
#else /* OPT_SBA_DEC_PATH */
norm_op1 = norm_l( elevation_fx );
norm_op2 = norm_l( tmp4_32 );
op2_e = add( exp_factor, 4 );
final_2_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom
final_2_32 = L_add( L_shr( elevation_fx, sub( final_2_exp, 9 ) ), L_shr( tmp4_32, sub( final_2_exp, op2_e ) ) );
#endif /* OPT_SBA_DEC_PATH */
#ifndef OPT_SBA_DEC_PATH
final_1_32 = BASOP_Util_Add_Mant32Exp( final_1_32, final_1_exp, ONE_IN_Q30, 0, &final_1_exp ); /*0.5 in q31*/
final_2_32 = BASOP_Util_Add_Mant32Exp( final_2_32, final_2_exp, ONE_IN_Q30, 0, &final_2_exp );
azi = extract_h( L_shr( final_1_32, sub( sub( 31, final_1_exp ), 16 ) ) );
ele = extract_h( L_shr( final_2_32, sub( sub( 31, final_2_exp ), 16 ) ) );
#else /* OPT_SBA_DEC_PATH */
final_1_32 = L_add( final_1_32, L_shl( 1, sub( 30, final_1_exp ) ) ); /*0.5 in q31*/
final_2_32 = L_add( final_2_32, L_shl( 1, sub( 30, final_2_exp ) ) );
azi = extract_h( L_shr( final_1_32, sub( 15, final_1_exp ) ) );
ele = extract_h( L_shr( final_2_32, sub( 15, final_2_exp ) ) );
#endif /* OPT_SBA_DEC_PATH */
/*addition of one to compensate precision loss*/
......@@ -2038,11 +2024,7 @@ void ivas_dirac_dec_set_md_map(
tmp_fx = W_add_nosat( tmp_fx, W_deposit32_l( L_deposit_l( hSpatParamRendCom->render_to_md_map[slot_idx_abs] ) ) );
slot_idx_abs = add( slot_idx_abs, 1 );
}
#ifdef FIX_1735_W_SHL_SAT_L
iDiv_and_mod_32( W_shl_sat_l( tmp_fx, 16 ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 );
#else
iDiv_and_mod_32( W_extract_l( W_shl_nosat( tmp_fx, 16 ) ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 );
#endif
hSpatParamRendCom->render_to_md_map[sf_idx] = add( round_fx( quo ), hSpatParamRendCom->dirac_read_idx ) % hSpatParamRendCom->dirac_md_buffer_length;
move16();
}
......@@ -2332,12 +2314,8 @@ void ivas_dirac_dec_render_sf_fx(
DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params;
DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state;
Word16 num_channels_dir, exp;
#ifdef FIX_867_CLDFB_NRG_SCALE
Word16 q_diffuseness_vector = Q31, q_reference_power_smooth[2] = { Q31, Q31 };
move16();
#else
Word16 q_diffuseness_vector = Q31, q_reference_power_smooth = Q31;
#endif
move16();
move16();
Word16 proto_power_smooth_len = 0;
......@@ -2588,7 +2566,6 @@ void ivas_dirac_dec_render_sf_fx(
scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1)
hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp1 );
move16();
#ifdef FIX_867_CLDFB_NRG_SCALE
tmp1 = 31;
move16();
FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
......@@ -2613,12 +2590,6 @@ void ivas_dirac_dec_render_sf_fx(
}
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], tmp1 );
move16();
#else
tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ) );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, imult1616( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1)
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, tmp1 );
move16();
#endif
IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 )
{
tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) );
......@@ -2940,11 +2911,7 @@ void ivas_dirac_dec_render_sf_fx(
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q,
#ifdef FIX_867_CLDFB_NRG_SCALE
reference_power_fx, DirAC_mem.reference_power_q,
#else
reference_power_fx, &DirAC_mem.reference_power_q,
#endif
slot_idx, nchan_transport,
hDirACRend->num_outputs_diff,
hSpatParamRendCom->num_freq_bands,
......@@ -2957,11 +2924,7 @@ void ivas_dirac_dec_render_sf_fx(
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q,
#ifdef FIX_867_CLDFB_NRG_SCALE
reference_power_fx, DirAC_mem.reference_power_q,
#else
reference_power_fx, &DirAC_mem.reference_power_q,
#endif
slot_idx, nchan_transport,
hDirACRend->num_outputs_diff,
hSpatParamRendCom->num_freq_bands,
......@@ -2980,17 +2943,9 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
reference_power_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
DirAC_mem.reference_power_q,
#else
&DirAC_mem.reference_power_q,
#endif
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#else
&hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#endif
0, slot_idx, hSpatParamRendCom->num_freq_bands, hDirACRend->masa_stereo_type_detect,
q_cldfb );
......@@ -3014,17 +2969,9 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
reference_power_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
DirAC_mem.reference_power_q,
#else
&DirAC_mem.reference_power_q,
#endif
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#else
&hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#endif
slot_idx, hDirACRend->num_outputs_diff,
hSpatParamRendCom->num_freq_bands,
hDirACRend->hoa_decoder,
......@@ -3039,17 +2986,9 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
reference_power_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
DirAC_mem.reference_power_q,
#else
&DirAC_mem.reference_power_q,
#endif
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#else
&hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#endif
hDirACRend->hOutSetup.is_loudspeaker_setup,
slot_idx,
hSpatParamRendCom->num_freq_bands,
......@@ -3072,17 +3011,9 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_fx,
&hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q,
reference_power_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
DirAC_mem.reference_power_q,
#else
&DirAC_mem.reference_power_q,
#endif
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#else
&hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q,
#endif
slot_idx,
hDirACRend->num_protos_diff,
hSpatParamRendCom->num_freq_bands, q_cldfb );
......@@ -3145,12 +3076,8 @@ void ivas_dirac_dec_render_sf_fx(
num_freq_bands, azimuth, elevation );
Copy32( reference_power_fx, &( hDirACRend->buffer_energy_fx[i_mult( sub( index, 1 ), num_freq_bands )] ), num_freq_bands );
#ifdef FIX_867_CLDFB_NRG_SCALE
Scale_sig32( &( hDirACRend->buffer_energy_fx[add( i_mult( sub( index, 1 ), num_freq_bands ), CLDFB_NO_CHANNELS_HALF )] ), s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[0], DirAC_mem.reference_power_q[1] ) );
hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q[0];
#else
hDirACRend->q_buffer_energy[index - 1] = DirAC_mem.reference_power_q;
#endif
move16();
computeDiffuseness_fixed( hDirACRend->buffer_intensity_real_fx, hDirACRend->buffer_energy_fx, num_freq_bands, hSpatParamRendCom->diffuseness_vector_fx[md_idx], hDirACRend->q_buffer_intensity_real, hDirACRend->q_buffer_energy, &hSpatParamRendCom->q_diffuseness_vector );
......@@ -3334,10 +3261,16 @@ void ivas_dirac_dec_render_sf_fx(
IF( hDirAC->hConfig->dec_param_estim )
{
Word16 fac;
#ifndef ISSUE_1796_replace_shl_o
Flag flag = 0;
move32();
#endif
fac = BASOP_Util_Divide3232_Scale( 1, hSpatParamRendCom->subframe_nbslots[subframe_idx], &exp );
#ifdef ISSUE_1796_replace_shl_o
fac = shl_sat( fac, exp );
#else
fac = shl_o( fac, exp, &flag );
#endif
IF( LT_16( q_diffuseness_vector, hSpatParamRendCom->q_diffuseness_vector ) )
{
......@@ -3356,7 +3289,6 @@ void ivas_dirac_dec_render_sf_fx(
IF( NE_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
{
#ifdef FIX_867_CLDFB_NRG_SCALE
v_add_fixed_me( reference_power_fx, sub( 31, DirAC_mem.reference_power_q[0] ),
reference_power_smooth_fx, sub( 31, q_reference_power_smooth[0] ),
reference_power_smooth_fx, &temp_q,
......@@ -3367,50 +3299,6 @@ void ivas_dirac_dec_render_sf_fx(
reference_power_smooth_fx + CLDFB_NO_CHANNELS_HALF, &temp_q,
s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), 1 );
q_reference_power_smooth[1] = sub( 31, temp_q );
#else
IF( LT_16( q_reference_power_smooth, DirAC_mem.reference_power_q ) )
{
Word32 temp;
FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ )
{
temp = L_shl( reference_power_fx[i], sub( q_reference_power_smooth, DirAC_mem.reference_power_q ) );
test();
IF( temp == 0 && ( reference_power_fx[i] != 0 ) )
{
reference_power_fx[i] = 1;
}
ELSE
{
reference_power_fx[i] = temp;
}
move32();
}
DirAC_mem.reference_power_q = q_reference_power_smooth;
move16();
}
ELSE
{
Word32 temp;
FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ )
{
temp = L_shl( reference_power_smooth_fx[i], sub( DirAC_mem.reference_power_q, q_reference_power_smooth ) );
test();
IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) )
{
reference_power_smooth_fx[i] = 1;
}
ELSE
{
reference_power_smooth_fx[i] = temp;
}
move32();
}
q_reference_power_smooth = DirAC_mem.reference_power_q;
move16();
}
v_add_fixed( reference_power_fx, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 1 );
q_reference_power_smooth = sub( q_reference_power_smooth, 1 );
#endif
}
}
......@@ -3609,7 +3497,6 @@ void ivas_dirac_dec_render_sf_fx(
Scale_sig32( hDirACRend->h_output_synthesis_psd_state.direct_responses_square_fx, i_mult( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands ), sub( Q31, hDirACRend->h_output_synthesis_psd_state.direct_responses_square_q ) ); // Q31
}
#ifdef FIX_867_CLDFB_NRG_SCALE
exp = L_norm_arr( reference_power_smooth_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) );
scale_sig32( reference_power_smooth_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), exp ); // q_reference_power_smooth[0] + exp
q_reference_power_smooth[0] = add( q_reference_power_smooth[0], exp );
......@@ -3653,38 +3540,6 @@ void ivas_dirac_dec_render_sf_fx(
q_reference_power_smooth[1] = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1];
move16();
}
#else
exp = L_norm_arr( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands );
scale_sig32( reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, exp ); // q_reference_power_smooth + exp
q_reference_power_smooth = add( q_reference_power_smooth, exp );
IF( LT_16( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) )
{
scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, hSpatParamRendCom->num_freq_bands, sub( q_reference_power_smooth, hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q ) ); // q_reference_power_smooth
hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q = q_reference_power_smooth;
move16();
}
ELSE
{
Word32 temp;
FOR( i = 0; i < hSpatParamRendCom->num_freq_bands; i++ )
{
temp = L_shl( reference_power_smooth_fx[i], sub( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, q_reference_power_smooth ) );
test();
IF( temp == 0 && ( reference_power_smooth_fx[i] != 0 ) )
{
reference_power_smooth_fx[i] = 1;
}
ELSE
{
reference_power_smooth_fx[i] = temp;
}
move32();
}
q_reference_power_smooth = hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q;
move16();
}
#endif
IF( hDirACRend->masa_stereo_type_detect != NULL )
{
......@@ -3704,7 +3559,6 @@ void ivas_dirac_dec_render_sf_fx(
}
}
#ifdef FIX_867_CLDFB_NRG_SCALE
exp = 31;
move16();
FOR( i = 0; proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) )
......@@ -3766,24 +3620,6 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1];
move16();
}
#else
exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, proto_power_smooth_len, exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q + exp)
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, exp );
move16();
IF( LT_16( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) )
{
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) ); // proto_power_smooth_q
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q;
move16();
}
ELSE
{
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx, i_mult( hDirACRend->num_protos_dir, hSpatParamRendCom->num_freq_bands ), sub( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) ); // proto_power_smooth_prev_q
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q;
move16();
}
#endif
exp = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) );
scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_fx, i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), exp ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_q + exp)
......@@ -3827,16 +3663,11 @@ void ivas_dirac_dec_render_sf_fx(
hSpatParamRendCom->subframe_nbslots[subframe_idx],
diffuseness_vector_fx,
reference_power_smooth_fx,
#ifdef FIX_867_CLDFB_NRG_SCALE
q_reference_power_smooth,
#else
&q_reference_power_smooth,
#endif
qualityBasedSmFactor_fx,
hDirAC->hConfig->enc_param_start_band,
&q_Cldfb );
#ifdef FIX_867_CLDFB_NRG_SCALE
Word16 allZero = 1;
move16();
FOR( i = 0; i < proto_power_smooth_len; i++ )
......@@ -3857,20 +3688,6 @@ void ivas_dirac_dec_render_sf_fx(
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = 31;
move16();
}
#else
Word16 sh = hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q;
move16();
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = 31;
move16();
FOR( i = 0; i < proto_power_smooth_len; i++ )
{
IF( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx[i] != 0 )
{
hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q = sh;
move16();
}
}
#endif
FOR( ch = 0; ch < hDirACRend->hOutSetup.nchan_out_woLFE; ch++ )
{
......@@ -3983,10 +3800,10 @@ void ivas_dirac_dec_render_sf_fx(
g_fx = Madd_32_16( Mpy_32_16_1( gain_fx, *w1_fx ), prev_gain_fx, w2_fx ); // Q15
FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ )
{
Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_re_fx );
Cldfb_RealBuffer_fx[j2][k][l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][k][l], g_fx, *tc_re_fx );
move32();
tc_re_fx++;
Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_im_fx );
Cldfb_ImagBuffer_fx[j2][k][l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][k][l], g_fx, *tc_im_fx );
move32();
tc_re_fx++;
}
......
......@@ -31,6 +31,8 @@
*******************************************************************************************************/
#include "basop_util.h"
#include "enh32.h"
#include <stdint.h>
#include <string.h>
#include <stdio.h>
......@@ -50,6 +52,13 @@
#include "rom_dec.h"
#include "ivas_prot_fx.h"
#ifdef NONBE_FIX_1091_PMC_LOW_SIGNAL_BURSTS
/*-----------------------------------------------------------------------*
* Local constants
*-----------------------------------------------------------------------*/
#define SQRT_EPSILON_FX 68 /* Q31 square root of EPSILON */
#endif
/*-------------------------------------------------------------------*
* ivas_dirac_dec_output_synthesis_cov_open()
......@@ -591,15 +600,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
/* apply residual mixing */
{
Word16 shifter;
#ifdef OPT_SBA_DEC_V2_NBE
shifter = sub( mixing_matrix_res_smooth_e, 32 );
#else /* OPT_SBA_DEC_V2_NBE */
#ifdef OPT_SBA_DEC_V2_BE
shifter = sub( mixing_matrix_res_smooth_e, 31 );
#else /* OPT_SBA_DEC_V2_BE */
shifter = 31 - mixing_matrix_res_smooth_e;
#endif /* OPT_SBA_DEC_V2_NBE */
#endif /* OPT_SBA_DEC_V2_BE */
FOR( ch_idx = 0; ch_idx < nY; ch_idx++ )
{
int i;
......@@ -614,22 +615,12 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
move64();
for ( i = 0; i < nY; i++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
temp_real = W_mac_32_32( temp_real, mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] );
temp_imag = W_mac_32_32( temp_imag, mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] );
#else /* OPT_SBA_DEC_V2_NBE */
temp_real = W_add( temp_real, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ) );
temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ) );
#endif /* OPT_SBA_DEC_V2_NBE */
idx += nY;
}
#ifdef OPT_SBA_DEC_V2_BE
Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_real, shifter );
Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_imag, shifter );
#else /* OPT_SBA_DEC_V2_BE */
Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_real, shifter ) );
Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_imag, shifter ) );
#endif /* OPT_SBA_DEC_V2_BE */
}
}
}
......@@ -886,11 +877,7 @@ Word16 computeMixingMatrices_fx(
move16();
FOR( i = 1; i < lengthCx; i++ )
{
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( svd_s_buffer_fx[i], L_shl_sat( limit_fx, sub( limit_e, svd_s_buffer_e[i] ) ) ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) > 0 )
#endif /* OPT_MCH_DEC_V1_NBE */
{
limit_fx = svd_s_buffer_fx[i];
move32();
......@@ -900,21 +887,22 @@ Word16 computeMixingMatrices_fx(
}
limit_e = add( limit_e, reg_Sx_e );
#ifdef OPT_MCH_DEC_V1_BE
#ifdef NONBE_FIX_1091_PMC_LOW_SIGNAL_BURSTS
limit_fx = Mpy_32_32( limit_fx, reg_Sx_fx );
IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, SQRT_EPSILON_FX /* Q31 */, 0 ) < 0 )
{
limit_fx = SQRT_EPSILON_FX;
move32();
limit_e = 0;
move16();
}
#else /* NONBE_FIX_1091_PMC_LOW_SIGNAL_BURSTS */
limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_Sx_fx );
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx );
limit_fx = L_add( L_tmp, EPSILON_FX );
#endif /* OPT_MCH_DEC_V1_BE */
#endif
FOR( i = 0; i < lengthCx; ++i )
{
#ifdef OPT_MCH_DEC_V1_NBE
IF( LT_32( L_shl_sat( svd_s_buffer_fx[i], sub( svd_s_buffer_e[i], limit_e ) ), limit_fx ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) < 0 )
#endif /* OPT_MCH_DEC_V1_NBE */
{
svd_s_buffer_fx[i] = limit_fx;
move32();
......@@ -959,16 +947,10 @@ Word16 computeMixingMatrices_fx(
matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e );
#ifdef OPT_MCH_DEC_V1_NBE
Word16 com_e = sub( limit_e, Cy_hat_diag_e );
#endif /* OPT_MCH_DEC_V1_NBE */
FOR( i = 0; i < lengthCy; ++i )
{
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 )
#endif /* OPT_MCH_DEC_V1_NBE */
{
limit_fx = Cy_hat_diag_fx[i];
move32();
......@@ -976,27 +958,16 @@ Word16 computeMixingMatrices_fx(
move16();
}
}
#ifdef OPT_MCH_DEC_V1_BE
limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e
limit_fx = L_add( L_tmp, EPSILON_FX );
#endif /* OPT_MCH_DEC_V1_BE */
limit_e = add( limit_e, reg_ghat_e );
#ifdef OPT_MCH_DEC_V1_NBE
com_e = sub( Cy_hat_diag_e, limit_e );
#endif /* OPT_MCH_DEC_V1_NBE */
FOR( i = 0; i < lengthCy; ++i )
{
Cy_hat_diag_buff_e[i] = Cy_hat_diag_e;
move16();
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_buff_e[i] ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */
#endif /* OPT_MCH_DEC_V1_NBE */
{
Cy_hat_diag_fx[i] = limit_fx;
move32();
......@@ -1416,11 +1387,7 @@ Word16 computeMixingMatricesResidual_fx(
FOR( i = 0; i < lengthCx; ++i )
{
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( Kx_fx[i], L_shl_sat( limit_fx, sub( limit_e, Kx_fx_e[i] ) ) ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 )
#endif /* OPT_MCH_DEC_V1_NBE */
{
div_tmp = Kx_fx[i];
move32();
......@@ -1461,16 +1428,10 @@ Word16 computeMixingMatricesResidual_fx(
Cy_hat_diag_e = Cx_e;
move16();
#ifdef OPT_MCH_DEC_V1_NBE
Word16 com_e = sub( limit_e, Cy_hat_diag_e );
#endif /* OPT_MCH_DEC_V1_NBE */
FOR( i = 0; i < lengthCy; ++i )
{
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) )
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 )
#endif /* OPT_MCH_DEC_V1_NBE */
{
limit_fx = Cy_hat_diag_fx[i];
move32();
......@@ -1479,28 +1440,17 @@ Word16 computeMixingMatricesResidual_fx(
}
}
#ifdef OPT_MCH_DEC_V1_BE
limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e)
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e)
limit_fx = L_add( L_tmp, EPSILON_FX );
#endif /* OPT_MCH_DEC_V1_BE */
limit_e = add( limit_e, reg_ghat_e );
/* Computing G_hat */
#ifdef OPT_MCH_DEC_V1_NBE
com_e = sub( Cy_hat_diag_e, limit_e );
#endif /* OPT_MCH_DEC_V1_NBE */
FOR( i = 0; i < lengthCy; ++i )
{
Cy_hat_diag_fx_e[i] = Cy_hat_diag_e;
move16();
#ifdef OPT_MCH_DEC_V1_NBE
IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */
#else /* OPT_MCH_DEC_V1_NBE */
IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_e ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */
#endif /* OPT_MCH_DEC_V1_NBE */
{
Cy_hat_diag_fx[i] = limit_fx;
move32();
......@@ -1523,12 +1473,7 @@ Word16 computeMixingMatricesResidual_fx(
FOR( i = 0; i < num_outputs; i++ )
{
#ifdef OPT_MCH_DEC_V1_BE
Kx_fx[i] = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e))
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e))
Kx_fx[i] = L_tmp;
#endif /* OPT_MCH_DEC_V1_BE */
move32();
Kx_fx_e[i] = add( Kx_fx_e[i], G_hat_e[i] );
move16();
......@@ -1542,18 +1487,10 @@ Word16 computeMixingMatricesResidual_fx(
FOR( j = 0; j < num_outputs; j++ )
{
#ifdef OPT_MCH_DEC_V1_BE
mat_mult_buffer1_fx[i + j * num_outputs] = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e));
move32();
mat_mult_buffer1_buff_e[i + j * num_outputs] = add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] );
move16();
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e))
mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp;
move32();
mat_mult_buffer1_buff_e[i + j * num_outputs] = extract_l( L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ) );
move16();
#endif /* OPT_MCH_DEC_V1_BE */
}
}
......@@ -1609,14 +1546,8 @@ Word16 computeMixingMatricesResidual_fx(
FOR( j = 0; j < num_outputs; j++ )
{
#ifdef OPT_MCH_DEC_V1_BE
mixing_matrix_fx[j + i * num_outputs] = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e);
move32();
#else /* OPT_MCH_DEC_V1_BE */
L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e)
mixing_matrix_fx[j + i * num_outputs] = L_tmp;
move32();
#endif /* OPT_MCH_DEC_V1_BE */
mixing_matrix_fx_e[j + i * num_outputs] = add( mat_mult_buffer1_buff_e[j + i * num_outputs], Kx_reg_inv_e[i] );
move16();
}
......
......@@ -55,6 +55,10 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_re
static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas );
#ifdef NONBE_FIX_1052_SBA_EXT
static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const Word16 sba_order );
#endif
static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas );
......@@ -257,6 +261,29 @@ static ivas_error ivas_dec_init_split_rend(
return error;
}
#ifdef NONBE_FIX_1052_SBA_EXT
static AUDIO_CONFIG ivas_set_output_config_from_sba_order( const Word16 sba_order )
{
AUDIO_CONFIG output_config;
output_config = IVAS_AUDIO_CONFIG_HOA3;
switch ( sba_order )
{
case SBA_FOA_ORDER:
output_config = IVAS_AUDIO_CONFIG_FOA;
break;
case SBA_HOA2_ORDER:
output_config = IVAS_AUDIO_CONFIG_HOA2;
break;
case SBA_HOA3_ORDER:
output_config = IVAS_AUDIO_CONFIG_HOA3;
break;
default:
assert( 0 );
}
return output_config;
}
#endif
/*-------------------------------------------------------------------*
* ivas_dec_setup()
*
......@@ -351,6 +378,14 @@ ivas_error ivas_dec_setup(
move16();
st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
move16();
#ifdef NONBE_FIX_1052_SBA_EXT
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order );
st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config );
}
#endif
num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
test();
test();
......@@ -392,6 +427,25 @@ ivas_error ivas_dec_setup(
IF( GT_16( st_ivas->nchan_ism, 0 ) )
{
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
/* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */
/* info about the number of objects:
'00' - MASA format at the encoder
'01' - MASA_ISM_FORMAT at the encoder, with 4 objects
'10' - MASA_ISM_FORMAT at the encoder, with 3 objects
'11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects
reading if 1 or 2 objects is performed later
*/
st_ivas->nchan_ism = sub( 5, st_ivas->nchan_ism );
test();
IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) )
{
st_ivas->nchan_ism = 1;
move16();
}
/* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/
#else
/* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */
test();
IF( EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( st_ivas->nchan_ism, 3 ) )
......@@ -400,6 +454,7 @@ ivas_error ivas_dec_setup(
move16();
}
/* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 */
#endif
st_ivas->nchan_transport = 2;
element_mode_flag = 1;
move16();
......@@ -476,15 +531,20 @@ ivas_error ivas_dec_setup(
st_ivas->nchan_ism = add( add( shl( st_ivas->bit_stream[res_dec - 1], 1 ), st_ivas->bit_stream[res_dec - 2] ), 1 );
move16();
#ifndef NONBE_FIX_SBA_SIGNALING_BITS_B
test();
IF( LT_32( ivas_total_brate, IVAS_24k4 ) || GE_32( ivas_total_brate, IVAS_256k ) )
{
#endif
/* read Ambisonic (SBA) planar flag */
st_ivas->sba_planar = st_ivas->bit_stream[num_bits_read];
move16();
num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );
#ifndef NONBE_FIX_SBA_SIGNALING_BITS_B
}
#endif
/* read Ambisonic (SBA) order (0 for signaling OSBA format at low bitrates)*/
st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
move16();
st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );
......@@ -492,11 +552,21 @@ ivas_error ivas_dec_setup(
num_bits_read = add( num_bits_read, SBA_ORDER_BITS );
/* read Ambisonic (SBA) order */
#ifdef NONBE_FIX_SBA_SIGNALING_BITS_B
/* read the real Ambisonic order when the above bits are used to signal OSBA format */
if ( LT_32( ivas_total_brate, IVAS_24k4 ) )
{
st_ivas->sba_order = st_ivas->bit_stream[num_bits_read + 1];
st_ivas->sba_order += 2 * st_ivas->bit_stream[num_bits_read];
num_bits_read += SBA_ORDER_BITS;
}
#else
if ( LT_32( ivas_total_brate, IVAS_256k ) )
{
st_ivas->sba_order = 3;
move16();
}
#endif
test();
IF( st_ivas->ini_frame > 0 && NE_32( ivas_total_brate, st_ivas->last_active_ivas_total_brate ) )
......@@ -517,13 +587,27 @@ ivas_error ivas_dec_setup(
/*correct number of CPEs for discrete ISM coding*/
test();
IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
#ifdef NONBE_FIX_ISM_XOVER_BR
{
Word16 n;
n = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
st_ivas->nCPE = shr_r( n, 1 );
}
#else
{
st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
move16();
}
#endif
}
#ifdef NONBE_FIX_ISM_XOVER_BR
IF( EQ_16( ivas_osba_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism ), ISM_SBA_MODE_DISC ) )
#else
IF( GE_32( ivas_total_brate, IVAS_256k ) )
#endif
{
st_ivas->ism_mode = ISM_SBA_MODE_DISC;
move32();
......@@ -631,6 +715,14 @@ ivas_error ivas_dec_setup(
BREAK;
}
#ifdef NONBE_FIX_1052_SBA_EXT
IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) && EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
st_ivas->hDecoderConfig->output_config = ivas_set_output_config_from_sba_order( st_ivas->sba_order );
st_ivas->hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->hDecoderConfig->output_config );
}
#endif
test();
IF( st_ivas->ini_frame > 0 && EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
......@@ -969,6 +1061,21 @@ static ivas_error ivas_read_format(
IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) )
{
#ifdef NONBE_FIX_1052_SBA_EXT
/* read Ambisonic (SBA) planar flag */
st_ivas->sba_planar = st_ivas->bit_stream[*num_bits_read];
move16();
*num_bits_read = add( *num_bits_read, SBA_PLANAR_BITS );
move16();
/* read Ambisonic (SBA) order */
st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 1];
move16();
st_ivas->sba_order = add( st_ivas->sba_order, shl( st_ivas->bit_stream[*num_bits_read], 1 ) );
move16();
*num_bits_read = add( *num_bits_read, SBA_ORDER_BITS );
move16();
#endif
if ( st_ivas->sba_analysis_order == 0 )
{
st_ivas->sba_analysis_order = SBA_FOA_ORDER;
......@@ -1228,7 +1335,11 @@ ivas_error ivas_init_decoder_fx(
Word16 numCldfbAnalyses, numCldfbSyntheses;
Word16 granularity, n_channels_transport_jbm;
Word32 output_Fs, ivas_total_brate;
#ifdef NONBE_FIX_MC_LFE_LPF
Word32 delay_ns;
#else
Word32 binauralization_delay_ns;
#endif
AUDIO_CONFIG output_config;
DECODER_CONFIG_HANDLE hDecoderConfig;
ivas_error error;
......@@ -1255,7 +1366,19 @@ ivas_error ivas_init_decoder_fx(
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
test();
#endif
#ifdef FIX_1052_EXT_OUTPUT
IF( EQ_32( st_ivas->ivas_format, STEREO_FORMAT ) )
{
hDecoderConfig->nchan_out = CPE_CHANNELS;
}
ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
hDecoderConfig->nchan_out = audioCfg2channels( st_ivas->transport_config );
}
ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
#else
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
#endif
{
hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 );
move16();
......@@ -1287,7 +1410,22 @@ ivas_error ivas_init_decoder_fx(
st_ivas->intern_config = output_config;
move32();
#ifdef FIX_1052_EXT_OUTPUT
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->ivas_format, MC_FORMAT ) )
{
ivas_output_init( &( st_ivas->hOutSetup ), st_ivas->transport_config );
st_ivas->intern_config = st_ivas->transport_config;
move32();
}
ELSE
{
ivas_output_init( &( st_ivas->hOutSetup ), output_config );
}
#else
ivas_output_init( &( st_ivas->hOutSetup ), output_config );
#endif
test();
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
{
......@@ -1493,7 +1631,7 @@ ivas_error ivas_init_decoder_fx(
}
}
IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nSCE, element_brate_tmp ) ), IVAS_ERR_OK ) )
IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -1803,8 +1941,17 @@ ivas_error ivas_init_decoder_fx(
{
st_ivas->nCPE_old = st_ivas->nCPE;
move16();
#ifdef NONBE_FIX_ISM_XOVER_BR
{
Word16 n_all;
n_all = add( st_ivas->nchan_transport, st_ivas->nchan_ism );
st_ivas->nCPE = shr( add( n_all, 1 ), 1 );
}
#else
st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) );
move16();
#endif
st_ivas->element_mode_init = IVAS_CPE_MDCT;
move16();
}
......@@ -1892,6 +2039,7 @@ ivas_error ivas_init_decoder_fx(
move16();
ism_total_brate = sep_object_brate[k - 2][0];
move32();
IF( NE_32( ( error = create_sce_dec( st_ivas, 0, ism_total_brate ) ), IVAS_ERR_OK ) )
{
return error;
......@@ -1899,11 +2047,21 @@ ivas_error ivas_init_decoder_fx(
reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] );
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
if ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
}
else
{
IF( NE_32( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ) ), IVAS_ERR_OK ) )
{
return error;
}
}
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
Word32 temp_brate[MAX_SCE];
......@@ -2411,7 +2569,6 @@ ivas_error ivas_init_decoder_fx(
SrcSpatial_p->q_Pos_p = Q31;
move16();
}
#ifdef NONBE_FIX_1075
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
......@@ -2419,7 +2576,6 @@ ivas_error ivas_init_decoder_fx(
return error;
}
}
#endif
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
IF( NE_32( ( error = ivas_omasa_separate_object_renderer_open( st_ivas ) ), IVAS_ERR_OK ) )
......@@ -2536,7 +2692,6 @@ ivas_error ivas_init_decoder_fx(
SrcSpatial_p->q_Pos_p = Q31;
move16();
}
#ifdef NONBE_FIX_1075
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
......@@ -2544,12 +2699,14 @@ ivas_error ivas_init_decoder_fx(
return error;
}
}
#endif
}
}
#ifndef NONBE_FIX_MC_LFE_LPF
/*-----------------------------------------------------------------*
* LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay
* LFE handles for rendering after rendering to adjust LFE delay to filter delay
*-----------------------------------------------------------------*/
test();
IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
......@@ -2581,12 +2738,13 @@ ivas_error ivas_init_decoder_fx(
set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
}
#endif
/*-----------------------------------------------------------------*
* CLDFB handles for rendering
*-----------------------------------------------------------------*/
ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
FOR( i = 0; i < numCldfbAnalyses; i++ )
{
......@@ -2638,6 +2796,49 @@ ivas_error ivas_init_decoder_fx(
move16();
}
#ifdef NONBE_FIX_MC_LFE_LPF
/*-----------------------------------------------------------------*
* LFE handles for rendering after rendering to adjust LFE delay to filter delay
*-----------------------------------------------------------------*/
test();
IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
{
delay_ns = st_ivas->binaural_latency_ns;
move32();
IF( st_ivas->hBinRenderer != NULL )
{
IF( st_ivas->hBinRenderer->render_lfe )
{
IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
/* Account for filterbank delay */
delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
}
}
ELSE
{
delay_ns = 0;
move32();
}
}
ELSE
{
IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
{
delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
}
}
IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, output_Fs, delay_ns ) ), IVAS_ERR_OK ) )
{
return error;
}
set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
}
#endif
/*-----------------------------------------------------------------*
* Allocate and initialize limiter struct
*-----------------------------------------------------------------*/
......@@ -2671,8 +2872,8 @@ ivas_error ivas_init_decoder_fx(
return error;
}
}
IF( st_ivas->hJbmMetadata == NULL )
test();
IF( st_ivas->hJbmMetadata == NULL && st_ivas->hDecoderConfig->Opt_tsm )
{
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
......@@ -2686,9 +2887,9 @@ ivas_error ivas_init_decoder_fx(
/*-----------------------------------------------------------------*
* Allocate floating-point output audio buffers
*-----------------------------------------------------------------*/
st_ivas->p_out_len = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
st_ivas->p_out_len = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
move16();
FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
{
/* note: these are intra-frame heap memories */
IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL )
......@@ -3198,7 +3399,7 @@ void ivas_destroy_dec_fx(
*-------------------------------------------------------------------*/
/*! r: number of cldfb instances */
void ivas_init_dec_get_num_cldfb_instances(
void ivas_init_dec_get_num_cldfb_instances_fx(
Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */
Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */
......@@ -3443,286 +3644,12 @@ void ivas_init_dec_get_num_cldfb_instances(
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
move16();
move16();
break;
case RENDERER_OMASA_MIX_EXT:
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
*numCldfbSyntheses = 0;
move16();
break;
#endif
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
}
test();
test();
IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
{
test();
test();
IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
{
*numCldfbAnalyses = s_max( MC_PARAMUPMIX_MAX_INPUT_CHANS, *numCldfbAnalyses );
move16();
}
ELSE
{
*numCldfbAnalyses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbAnalyses );
move16();
}
*numCldfbSyntheses = s_max( MC_PARAMUPMIX_MIN_CLDFB, *numCldfbSyntheses );
move16();
}
return;
}
void ivas_init_dec_get_num_cldfb_instances_ivas_fx(
Decoder_Struct *st_ivas, /* i : IVAS decoder structure */
Word16 *numCldfbAnalyses, /* o : number of needed CLDFB analysis instances */
Word16 *numCldfbSyntheses /* o : number of needed CLDFB synthesis instances */
)
{
IVAS_FORMAT ivas_format;
*numCldfbAnalyses = st_ivas->nchan_transport;
move16();
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
move16();
ivas_format = st_ivas->ivas_format;
move32();
test();
IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) )
{
ivas_format = SBA_FORMAT; /* treat ISM_SBA_MODE_NONE just like SBA_FORMAT */
move32();
}
SWITCH( st_ivas->renderer_type )
{
case RENDERER_BINAURAL_PARAMETRIC:
case RENDERER_BINAURAL_PARAMETRIC_ROOM:
case RENDERER_STEREO_PARAMETRIC:
IF( EQ_16( st_ivas->nchan_transport, 1 ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
move16();
}
test();
IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->hOutSetup.separateChannelEnabled )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
move16();
}
IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
move16();
}
}
IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) )
{
test();
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, st_ivas->nchan_ism );
move16();
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
move16();
}
}
IF( st_ivas->hDiracDecBin[0]->useTdDecorr )
{
*numCldfbAnalyses = add( *numCldfbAnalyses, 2 );
move16();
}
BREAK;
case RENDERER_NON_DIEGETIC_DOWNMIX:
case RENDERER_MONO_DOWNMIX:
test();
test();
IF( EQ_32( ivas_format, ISM_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
}
BREAK;
case RENDERER_DIRAC:
IF( EQ_32( ivas_format, SBA_FORMAT ) )
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
move16();
test();
IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
move16();
}
ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
move16();
}
}
IF( NE_32( ivas_format, SBA_FORMAT ) )
{
test();
test();
IF( GT_16( st_ivas->nchan_transport, 2 ) && ( st_ivas->sba_planar != 0 ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
move16();
}
ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
move16();
}
}
BREAK;
case RENDERER_MC_PARAMMC:
IF( LE_16( st_ivas->hDecoderConfig->nchan_out, 2 ) )
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
}
ELSE
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
move16();
}
BREAK;
case RENDERER_PARAM_ISM:
/* Already correct with no exception */
BREAK;
case RENDERER_DISABLE:
/* CLDFB not used */
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
BREAK;
case RENDERER_MC:
case RENDERER_SBA_LINEAR_DEC:
case RENDERER_TD_PANNING:
case RENDERER_BINAURAL_OBJECTS_TD:
case RENDERER_MCMASA_MONO_STEREO:
case RENDERER_BINAURAL_MIXER_CONV:
case RENDERER_BINAURAL_MIXER_CONV_ROOM:
case RENDERER_BINAURAL_FASTCONV:
case RENDERER_BINAURAL_FASTCONV_ROOM:
case RENDERER_OSBA_STEREO:
case RENDERER_OSBA_AMBI:
case RENDERER_OSBA_LS:
test();
IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) )
{
IF( st_ivas->sba_dirac_stereo_flag != 0 )
{
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
}
ELSE
{
*numCldfbAnalyses = st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans;
move16();
test();
IF( st_ivas->hOutSetup.is_loudspeaker_setup && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) )
{
*numCldfbSyntheses = st_ivas->hOutSetup.nchan_out_woLFE;
move16();
}
ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
{
*numCldfbSyntheses = st_ivas->hSpar->hFbMixer->fb_cfg->num_out_chans;
move16();
}
ELSE
{
*numCldfbSyntheses = MAX_OUTPUT_CHANNELS;
move16();
}
test();
IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
*numCldfbAnalyses = add( st_ivas->nchan_ism, st_ivas->hSpar->hFbMixer->fb_cfg->num_in_chans );
move16();
}
}
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
/* do nothing for ParamMC */
}
ELSE
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
}
BREAK;
case RENDERER_SBA_LINEAR_ENC:
IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
{
*numCldfbSyntheses = param_mc_get_num_cldfb_syntheses_fx( st_ivas );
move16();
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
{
*numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
move16();
}
ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
*numCldfbAnalyses = st_ivas->nchan_transport;
move16();
*numCldfbSyntheses = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );
move16();
}
ELSE
{
/* CLDFB not used in rendering */
*numCldfbAnalyses = 0;
move16();
*numCldfbSyntheses = 0;
move16();
}
BREAK;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
case RENDERER_OMASA_OBJECT_EXT:
*numCldfbAnalyses = st_ivas->nchan_transport;
*numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out;
move16();
move16();
break;
case RENDERER_OMASA_MIX_EXT:
*numCldfbAnalyses = add( st_ivas->nchan_transport, 1 );
*numCldfbSyntheses = 0;
move16();
break;
BREAK;
#endif
default:
assert( 0 && "Renderer not handled for CLDFB reservation." );
......@@ -3800,11 +3727,26 @@ static ivas_error doSanityChecks_IVAS(
test();
test();
test();
#ifdef FIX_1052_EXT_OUTPUT
test();
IF( NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && NE_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
#else
IF( NE_32( output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) && NE_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
#endif
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Wrong output configuration specified for Stereo!" );
}
}
#ifdef FIX_1052_EXT_OUTPUT
/* Verify output configuration for other formats */
ELSE
{
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_INVALID ) )
{
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified!" );
}
}
#else
ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) )
{
/* Verify ISM output configuration */
......@@ -3837,6 +3779,7 @@ static ivas_error doSanityChecks_IVAS(
return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for Multi-channel" );
}
}
#endif
IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) )
{
......
......@@ -78,10 +78,10 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
move16();
st_ivas->ism_mode = last_ism_mode;
move16();
ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
st_ivas->ism_mode = ism_mode;
move16();
nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
{
......@@ -142,16 +142,9 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
{
test();
test();
#ifndef NONBE_FIX_1056_ISM_RATE_SWITCH
test();
#endif
/* transfer subframe info from DirAC or ParamMC to central tc buffer */
#ifdef NONBE_FIX_1056_ISM_RATE_SWITCH
/* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */
IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
#else
IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) ) )
#endif
{
st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
move16();
......@@ -278,17 +271,13 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
}
/* Close the TD Binaural renderer */
IF( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM == TRUE )
{
ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
st_ivas->hHrtfTD = NULL;
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
ivas_reverb_close( &st_ivas->hReverb );
}
}
}
ELSE
{
/* Close the ISM renderer */
......@@ -331,7 +320,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
*-----------------------------------------------------------------*/
{
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
......
......@@ -781,6 +781,51 @@ ivas_error ivas_ism_metadata_dec_fx(
}
/*-------------------------------------------------------------------*
* ivas_ism_reset_metadata_handle_dec()
*
* Reset ISM decoder metadata handle
*-------------------------------------------------------------------*/
void ivas_ism_reset_metadata_handle_dec_fx(
ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */
)
{
hIsmMeta->last_ism_metadata_flag = 0;
move16();
hIsmMeta->position_angle.last_angle1_idx = 0;
move16();
hIsmMeta->position_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
move16();
hIsmMeta->orientation_angle.last_angle1_idx = 0;
move16();
hIsmMeta->orientation_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
move16();
hIsmMeta->last_radius_idx = 8; /* Init to radius 1.0 */
move16();
hIsmMeta->last_true_azimuth_fx = 0;
move32();
hIsmMeta->last_true_elevation_fx = 0;
move32();
hIsmMeta->last_azimuth_fx = 0;
move32();
hIsmMeta->last_elevation_fx = 0;
move32();
hIsmMeta->ism_imp = -1;
move16();
hIsmMeta->ism_md_null_flag = 0;
move16();
hIsmMeta->ism_md_lowrate_flag = 0;
move16();
ivas_ism_reset_metadata( hIsmMeta );
return;
}
/*-------------------------------------------------------------------------
* ivas_ism_metadata_dec_create()
*
......@@ -789,7 +834,7 @@ ivas_error ivas_ism_metadata_dec_fx(
ivas_error ivas_ism_metadata_dec_create_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const Word16 n_ISms, /* i : number of objects */
const Word16 n_ISms, /* i : number of separately coded objects */
Word32 element_brate_tmp[] /* o : element bitrate per object */
)
{
......@@ -797,43 +842,27 @@ ivas_error ivas_ism_metadata_dec_create_fx(
ivas_error error;
/* allocate ISM metadata handles */
FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ )
FOR( ch = 0; ch < n_ISms; ch++ )
{
IF( st_ivas->hIsmMetaData[ch] == NULL ) /* note: the handle can be allocated in OMASA bitrate switching from ISM_MASA_MODE_xxx_ONE_OBJ to ISM_MASA_MODE_DISC mode for 'ch==0' */
{
IF( ( st_ivas->hIsmMetaData[ch] = (ISM_METADATA_HANDLE) malloc( sizeof( ISM_METADATA_FRAME ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for ISM MetaData\n" ) );
}
}
st_ivas->hIsmMetaData[ch]->last_ism_metadata_flag = 0;
move16();
st_ivas->hIsmMetaData[ch]->position_angle.last_angle1_idx = 0;
move16();
st_ivas->hIsmMetaData[ch]->position_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
move16();
st_ivas->hIsmMetaData[ch]->orientation_angle.last_angle1_idx = 0;
move16();
st_ivas->hIsmMetaData[ch]->orientation_angle.last_angle2_idx = 1 << ( ISM_ELEVATION_NBITS - 1 );
move16();
st_ivas->hIsmMetaData[ch]->last_radius_idx = 8; /* Init to radius 1.0 */
move16();
st_ivas->hIsmMetaData[ch]->last_true_azimuth_fx = 0;
move32();
st_ivas->hIsmMetaData[ch]->last_true_elevation_fx = 0;
move32();
st_ivas->hIsmMetaData[ch]->last_azimuth_fx = 0;
move32();
st_ivas->hIsmMetaData[ch]->last_elevation_fx = 0;
move32();
st_ivas->hIsmMetaData[ch]->ism_imp = -1;
move16();
st_ivas->hIsmMetaData[ch]->ism_md_null_flag = 0;
move16();
st_ivas->hIsmMetaData[ch]->ism_md_lowrate_flag = 0;
move16();
ivas_ism_reset_metadata_handle_dec_fx( st_ivas->hIsmMetaData[ch] );
}
ivas_ism_reset_metadata( st_ivas->hIsmMetaData[ch] );
/* sanity freeing - it can happen only in reconfiguration when a smaller number of handles than before is requested */
FOR( ; ch < MAX_NUM_OBJECTS; ch++ )
{
IF( st_ivas->hIsmMetaData[ch] != NULL )
{
free( st_ivas->hIsmMetaData[ch] );
st_ivas->hIsmMetaData[ch] = NULL;
}
}
IF( element_brate_tmp != NULL )
......
......@@ -124,12 +124,12 @@ ivas_error ivas_jbm_dec_tc_fx(
IF( st_ivas->hDecoderConfig->Opt_tsm == 0 )
{
FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
{
set_zero_fx( st_ivas->p_output_fx[n], L_FRAME48k );
st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n];
}
st_ivas->hTcBuffer->no_channels = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
st_ivas->hTcBuffer->no_channels = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate );
move16();
}
......@@ -288,7 +288,8 @@ ivas_error ivas_jbm_dec_tc_fx(
return error;
}
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
test();
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm )
{
ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
}
......@@ -617,11 +618,7 @@ ivas_error ivas_jbm_dec_tc_fx(
move16();
FOR( ch = 0; ch < nchan_transport; ch++ )
{
#ifdef FIX_ISSUE_1792
temp_min = L_norm_arr( p_output_fx[ch], output_frame );
#else
temp_min = getScaleFactor32( p_output_fx[ch], output_frame );
#endif
Q_p_output = s_min( Q_p_output, temp_min );
}
Q_p_output = sub( Q_p_output, 2 );
......@@ -830,9 +827,11 @@ ivas_error ivas_jbm_dec_tc_fx(
ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame );
#endif
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
}
}
IF( NE_16( output_q, Q11 ) )
{
FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ )
......@@ -1337,11 +1336,16 @@ ivas_error ivas_jbm_dec_tc_fx(
test();
test();
test();
#ifdef FIX_1052_EXT_OUTPUT
test();
/* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) )
EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
#else
/* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */
IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) )
#endif
{
ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL );
}
......@@ -1618,7 +1622,8 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
test();
test();
IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
test();
IF( ( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) || EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm )
{
ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
}
......@@ -1739,8 +1744,11 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) )
{
ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas );
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
}
}
ELSE
{
#endif
......@@ -2619,7 +2627,7 @@ ivas_error ivas_jbm_dec_render_fx(
IF( st_ivas->hTcBuffer->n_samples_discard > 0 )
{
FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ )
FOR( n = 0; n < s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ )
{
p_output_fx[n] += st_ivas->hTcBuffer->n_samples_discard;
}
......@@ -2788,6 +2796,23 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
{
IF( EQ_16( mc_mode_old, MC_MODE_MCT ) )
{
#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT
int16_t crendInPlaceRotation = FALSE;
test();
test();
test();
IF( NE_16( st_ivas->transport_config, intern_config_old ) && ( EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( intern_config_old, IVAS_AUDIO_CONFIG_HOA3 ) ) )
{
IF( GT_16( sub( add( hIntSetupOld->nchan_out_woLFE, hIntSetupOld->num_lfe ), add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ) ), 0 ) )
{
crendInPlaceRotation = TRUE;
move16();
ivas_mc2sba_fx( st_ivas->hTransSetup, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE_FX );
}
}
#endif
test();
IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( renderer_type_old, RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
{
......@@ -2804,9 +2829,15 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
*st_ivas->hCrendWrapper->p_io_qfactor = 11;
move16();
#ifdef NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT
IF( NE_32( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : st_ivas->hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ),
IVAS_ERR_OK ) )
#else
IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ),
IVAS_ERR_OK ) )
#endif
{
return error;
}
......@@ -3617,6 +3648,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
{
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
/* note: the maximum buffer length is for OSBA DISC mode with ISMs -> 15*(1920+239)=32385 samples */
IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) );
......@@ -3659,7 +3691,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx(
* open and initialize JBM transport channel buffer
*--------------------------------------------------------------------------*/
ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */
......@@ -3676,7 +3707,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
hTcBuffer = st_ivas->hTcBuffer;
move16();
/* if granularity changes, adapt subframe_nb_slots */
IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
{
......@@ -3729,6 +3759,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
n_samp_residual = 0;
move16();
}
nsamp_to_allocate = imult1616( hTcBuffer->nchan_buffer_full, n_samp_full );
nsamp_to_allocate = add( nsamp_to_allocate, imult1616( nchan_residual, n_samp_residual ) );
......@@ -3744,7 +3775,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
{
IF( st_ivas->hDecoderConfig->Opt_tsm )
{
IF( ( hTcBuffer->tc_buffer_fx = (Word32 *) malloc( nsamp_to_allocate * sizeof( Word32 ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR JBM TC Buffer\n" ) );
......@@ -3767,20 +3797,6 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
{
hTcBuffer->tc_fx[ch_idx] = NULL;
}
hTcBuffer->tc_buff_len = nsamp_to_allocate;
move16();
offset = 0;
move16();
FOR( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ )
{
offset = add( offset, n_samp_full );
}
FOR( ; ch_idx < hTcBuffer->nchan_transport_internal; ch_idx++ )
{
offset = add( offset, n_samp_residual );
}
}
ELSE
{
......
......@@ -295,6 +295,28 @@ static Word16 ivas_lfe_dec_dequant_fx(
}
#ifdef NONBE_FIX_MC_LFE_LPF
/*-------------------------------------------------------------------------
* ivas_create_lfe_lpf_dec_fx()
*
* Create, allocate and initialize IVAS decoder LFE low pass filter state handle
*-------------------------------------------------------------------------*/
static void ivas_create_lfe_lpf_dec_fx(
ivas_filters_process_state_t *hLfeLpf, /* o : LFE LPF handle */
const Word32 input_Fs /* i : input sampling rate */
)
{
const Word32 *filt_coeff; // 31 - filt_coeff_e
const Word16 *filt_coeff_e = NULL;
ivas_lfe_lpf_select_filt_coeff_fx( input_Fs, IVAS_FILTER_ORDER_4, &filt_coeff, &filt_coeff_e );
ivas_filters_init_fx( hLfeLpf, filt_coeff, filt_coeff_e, IVAS_FILTER_ORDER_4 );
return;
}
#endif
/*-----------------------------------------------------------------------------------------*
* Function ivas_lfe_dec_fx()
*
......@@ -380,6 +402,9 @@ void ivas_lfe_dec_fx(
move32();
j = add( j, shr( output_frame, 5 ) );
}
#ifdef NONBE_FIX_MC_LFE_LPF
q_out = Q9;
#endif
}
IF( hLFE->filter_state.order > 0 )
......@@ -408,7 +433,11 @@ void ivas_lfe_dec_fx(
ivas_error ivas_create_lfe_dec_fx(
LFE_DEC_HANDLE *hLFE_out, /* o : IVAS LFE decoder structure */
const Word32 output_Fs, /* i : output sampling rate Q0*/
#ifdef NONBE_FIX_MC_LFE_LPF
const Word32 delay_ns /* i : additional LFE delay to sync other channel outputs */
#else
const Word32 binauralization_delay_ns /* i : additional LFE delay to sync with binaural renderer */
#endif
)
{
Word16 low_pass_delay_dec_out, block_offset_s;
......@@ -466,6 +495,16 @@ ivas_error ivas_create_lfe_dec_fx(
move16();
low_pass_delay_dec_out = 0; // Q15
move16();
#ifdef NONBE_FIX_MC_LFE_LPF
if ( delay_ns > ivas_lfe_lpf_delay_ns[IVAS_FILTER_ORDER_4 - 3] )
{
filt_order = 4;
low_pass_delay_dec_out = ivas_lfe_lpf_delay_Q15[IVAS_FILTER_ORDER_4 - 3];
ivas_create_lfe_lpf_dec_fx( &( hLFE->filter_state ), output_Fs );
}
#endif
hLFE->filter_state.order = filt_order;
move16();
hLFE->lfe_block_delay_s_fx = add( hLFE->lfe_block_delay_s_fx, low_pass_delay_dec_out ); // Q15
......@@ -495,7 +534,11 @@ ivas_error ivas_create_lfe_dec_fx(
lfe_addl_delay_s = sub( block_offset_s, hLFE->lfe_block_delay_s_fx ); // Q15
lfe_addl_delay_s = s_max( 0, lfe_addl_delay_s );
#ifdef NONBE_FIX_MC_LFE_LPF
add_delay_sa = (Word16) W_round64_L( W_mult0_32_32( L_shl( delay_ns, 1 ), output_fs_fx ) ); // Q0
#else
add_delay_sa = (Word16) W_round64_L( W_mult0_32_32( L_shl( binauralization_delay_ns, 1 ), output_fs_fx ) ); // Q0
#endif
move16();
hLFE->lfe_addl_delay = add( (Word16) L_shr( imult3216( output_Fs, lfe_addl_delay_s ), 15 ), add_delay_sa ); // Q0
move16();
......
......@@ -184,6 +184,62 @@ ivas_error ivas_masa_decode_fx(
test();
IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
{
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
Word16 bits_per_frame = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
IF( EQ_32( ivas_format, MASA_FORMAT ) )
{
/* re-read the number of objects, needed in case of bad frame */
st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], shl( st_ivas->bit_stream[bits_per_frame - 2], 1 ) ) );
}
test();
IF( EQ_32( ivas_format, MASA_FORMAT ) && NE_16( st_ivas->nchan_ism, 5 ) )
{
/* there was OMASA in the input */
hMasa->config.input_ivas_format = MASA_ISM_FORMAT;
move32();
IF( LT_16( st_ivas->nchan_ism, 3 ) )
{
/* was read in ivas_init_dec() to distinguish between 1 and 2 objects */
IF( EQ_16( st_ivas->bit_stream[bits_per_frame - 1], 0 ) )
{
st_ivas->nchan_ism = 1;
move16();
}
st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS );
*nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS );
/* the two reserved bits were already read in ivas_init_dec()*/
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
move16();
*nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS );
/* read number of directions */
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
*nb_bits_read = add( *nb_bits_read, 1 );
hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
}
ELSE
{
/* if there are 3 or 4 objects the number of transport channels bit is given to MASA format
and used to read number of directions*/
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
*nb_bits_read = add( *nb_bits_read, 1 );
hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
/* the two reserved bits were already read in ivas_init_dec()*/
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
byteBuffer = st->bit_stream[( st->next_bit_pos )--];
move16();
move16();
*nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS );
}
}
ELSE
{
#endif
IF( NE_32( ivas_format, MASA_ISM_FORMAT ) )
{
/* number of transport channels is always 2 for MASA_ISM format */
......@@ -322,6 +378,7 @@ ivas_error ivas_masa_decode_fx(
}
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
#ifndef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
/* read 2 bits:
'00' - MASA format at the encoder
'01' - MASA_ISM_FORMAT at the encoder, with 1 object
......@@ -329,6 +386,7 @@ ivas_error ivas_masa_decode_fx(
'11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects
reading if 3 or 4 object is performed later
*/
#endif
byteBuffer = st->bit_stream[st->next_bit_pos];
move16();
st->next_bit_pos = sub( st->next_bit_pos, 1 );
......@@ -373,6 +431,9 @@ ivas_error ivas_masa_decode_fx(
move16();
hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
move16();
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
}
#endif
}
ELSE
{
......@@ -532,7 +593,13 @@ ivas_error ivas_masa_decode_fx(
hMasa->config.coherencePresent = !hQMetaData->all_coherence_zero;
move16();
#ifdef FIX_1052_EXT_OUTPUT
test();
test();
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MASA_ISM_FORMAT ) ) )
#else
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
#endif
{
index_16bits_fx( hQMetaData, hMasa->data.sph_grid16 );
}
......@@ -825,7 +892,13 @@ ivas_error ivas_masa_dec_open_fx(
move16();
/* Create spherical grid only for external output */
#ifdef FIX_1052_EXT_OUTPUT
test();
test();
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) )
#else
IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
#endif
{
IF( ( hMasa->data.sph_grid16 = (SPHERICAL_GRID_DATA *) malloc( sizeof( SPHERICAL_GRID_DATA ) ) ) == NULL )
{
......@@ -1366,6 +1439,17 @@ static ivas_error init_lfe_synth_data_fx(
test();
test();
test();
#ifdef FIX_1052_EXT_OUTPUT
test();
IF( st_ivas->hOutSetup.separateChannelEnabled &&
( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA2 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ||
( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && ( st_ivas->hOutSetup.num_lfe > 0 ) ) ) )
#else
IF( st_ivas->hOutSetup.separateChannelEnabled &&
( EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_7_1 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) ||
......@@ -1373,6 +1457,7 @@ static ivas_error init_lfe_synth_data_fx(
EQ_16( output_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA2 ) ||
EQ_16( output_config, IVAS_AUDIO_CONFIG_HOA3 ) ||
( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && ( st_ivas->hOutSetup.num_lfe > 0 ) ) ) )
#endif
{
Word16 bufferSize;
Word16 i;
......@@ -1678,7 +1763,7 @@ ivas_error ivas_masa_dec_reconfigure_fx(
move16();
}
ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
/* renderer might have changed, reselect */
ivas_renderer_select( st_ivas );
......@@ -1943,7 +2028,11 @@ ivas_error ivas_masa_dec_reconfigure_fx(
{
IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
{
#ifdef FIX_1222_OMASA_DEC_CHANNEL_BUFFERS
tc_nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism );
#else
tc_nchan_to_allocate = add( shl( BINAURAL_CHANNELS, 1 ), 2 );
#endif
}
ELSE
{
......
......@@ -165,7 +165,11 @@ ivas_error ivas_param_mc_dec_open_fx(
test();
test();
test();
#ifdef FIX_1052_EXT_OUTPUT
IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || EQ_32( st_ivas->transport_config, output_config ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
#else
IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || EQ_32( st_ivas->transport_config, output_config ) )
#endif
{
hParamMC->synthesis_conf = PARAM_MC_SYNTH_DIRECT;
move32();
......@@ -2374,21 +2378,13 @@ static void param_mc_protoSignalComputation_fx(
FOR( band = 0; band < num_freq_bands; band++ )
{
#ifdef FIX_1737_proto_fac_overflow
Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5
#else
Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5
#endif
*( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x );
move32();
p_proto_frame_fx++;
#ifdef FIX_1737_proto_fac_overflow
tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5
#else
tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5
#endif
*( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x );
move32();
......@@ -3614,11 +3610,7 @@ static ivas_error param_mc_get_diff_proto_info_fx(
{
p_diff_proto_info->source_chan_idx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = cur_transport_ch;
move16();
#ifdef FIX_1737_proto_fac_overflow
p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; // (proto_fac_fx)Q26 = Q26
#else
p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = L_shl( *proto_fac_ptr, 4 ); // (proto_fac_fx)Q26 + 4 = Q30
#endif
move16();
p_diff_proto_info->num_source_chan_diff[cur_diff_proto] = add( p_diff_proto_info->num_source_chan_diff[cur_diff_proto], 1 );
move16();
......
......@@ -287,7 +287,7 @@ void ivas_mc_paramupmix_dec_render(
ivas_mc_paramupmix_dec_sf( st_ivas, output_local_fx );
Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ) );
Word16 num_ch = s_min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ) );
FOR( ch = 0; ch < num_ch; ch++ )
{
output_local_fx[ch] += n_samples_sf;
......
......@@ -199,9 +199,6 @@ void ivas_mct_core_dec(
Word16 tcx_offsetFB;
Word16 left_rect;
Word16 L_spec;
#ifndef OPT_SBA_DEC_PATH
Word16 scale, tmp1, tmp2;
#endif /* OPT_SBA_DEC_PATH */
#ifdef DEBUG_MCT
float nrg[MCT_MAX_CHANNELS];
#endif
......@@ -221,18 +218,10 @@ void ivas_mct_core_dec(
move16();
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
#ifndef OPT_SBA_DEC_PATH
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
i = add( i, 1 );
}
#else /* OPT_SBA_DEC_PATH */
FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) )
{
sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
}
#endif /* OPT_SBA_DEC_PATH */
}
i = 0;
......@@ -256,11 +245,7 @@ void ivas_mct_core_dec(
move16();
x_fx[ch][0] = signal_out_fx[ch];
x_fx[ch][1] = signal_out_fx[ch] + ( L_FRAME48k / 2 );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
......@@ -282,7 +267,6 @@ void ivas_mct_core_dec(
{
CONTINUE;
}
#ifdef OPT_SBA_DEC_PATH
IF( EQ_16( st->core, TCX_10_CORE ) )
{
Word16 L_frame_2 = shr( st->L_frame, 1 );
......@@ -300,22 +284,14 @@ void ivas_mct_core_dec(
/* mono or dual mono IGF decoding */
x_e = sub( 31, q_x[ch] );
decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
FOR( i = 0; i < x_len; i++ )
{
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
}
......@@ -333,70 +309,17 @@ void ivas_mct_core_dec(
/* mono or dual mono IGF decoding */
x_e = sub( 31, q_x[ch] );
decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
FOR( i = 0; i < x_len; i++ )
{
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
}
#else /* OPT_SBA_DEC_PATH */
IF( EQ_16( st->core, TCX_10_CORE ) )
{
nSubframes = NB_DIV;
}
ELSE
{
nSubframes = 1;
}
move16();
FOR( k = 0; k < nSubframes; k++ )
{
L_spec = BASOP_Util_Divide1616_Scale( st->hTcxCfg->tcx_coded_lines, nSubframes, &scale );
L_spec = shr( L_spec, sub( 15, scale ) );
tmp1 = BASOP_Util_Divide1616_Scale( st->L_frame, nSubframes, &scale );
tmp1 = shr( tmp1, sub( 15, scale ) );
tmp2 = BASOP_Util_Divide1616_Scale( st->hTcxDec->L_frameTCX, nSubframes, &scale );
tmp2 = shr( tmp1, sub( 15, scale ) );
init_tcx_info_fx( st, tmp1, tmp2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
Word16 x_e, x_len;
/* mono or dual mono IGF decoding */
x_e = sub( 31, q_x[ch] );
decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k );
q_x[ch] = sub( 31, x_e );
move16();
FOR( i = 0; i < x_len; i++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q11 ) );
#else /* OPT_SBA_DEC_V2_NBE */
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q12 ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
#endif /* OPT_SBA_DEC_PATH */
}
}
ELSE
......@@ -411,32 +334,7 @@ void ivas_mct_core_dec(
* MCT processing
*--------------------------------------------------------------------------------*/
#ifdef OPT_SBA_DEC_PATH
apply_MCT_dec_fx( hMCT, sts, x_fx );
#else /* OPT_SBA_DEC_PATH */
apply_MCT_dec_fx( hMCT, sts, x_fx, q_x );
FOR( ch = 0; ch < nChannels; ch++ )
{
FOR( i = 0; i < L_FRAME48k / 2; i++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q11 ) );
x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q11 ) );
#else /* OPT_SBA_DEC_V2_NBE */
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q12 ) );
x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q12 ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
#endif /* OPT_SBA_DEC_PATH */
}
pop_wmops();
......
......@@ -79,10 +79,6 @@ ivas_error ivas_mct_dec_fx(
Word16 n, i;
Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e)
#ifndef OPT_SBA_DEC_V2_NBE
Word16 x_e[MAX_CICP_CHANNELS][NB_DIV];
Word16 ch, k;
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 x_len[CPE_CHANNELS][NB_DIV];
set16_fx( x_len[0], 0, NB_DIV );
set16_fx( x_len[1], 0, NB_DIV );
......@@ -185,49 +181,17 @@ ivas_error ivas_mct_dec_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][0] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][1] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 );
set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 );
}
#ifndef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id],
fUseTns[cpe_id], tnsData[cpe_id], x_fx, x_e, x_fx, x_e, x_len, Aq_fx[cpe_id], NULL, 1 );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id],
fUseTns[cpe_id], tnsData[cpe_id], x_fx, 20, x_fx, 20, x_len, Aq_fx[cpe_id], NULL, 1 );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
Word16 subFrames;
IF( EQ_16( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core, TCX_10_CORE ) )
{
subFrames = NB_DIV;
}
ELSE
{
subFrames = 1;
}
move16();
FOR( k = 0; k < subFrames; ++k )
{
Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); // Scaling back to Q11
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect );
move16();
......@@ -238,22 +202,8 @@ ivas_error ivas_mct_dec_fx(
/* MCT core decoder */
Word16 q_x[MAX_TRANSPORT_CHANNELS];
#ifndef OPT_SBA_DEC_V2_NBE
set16_fx( q_x, Q12, MAX_TRANSPORT_CHANNELS );
// Scaling output buffer to q_x
FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i )
{
Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); // Q11 -> Q12
}
#endif /* OPT_SBA_DEC_V2_NBE */
ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x );
// Scaling output buffer back to Q11
#ifndef OPT_SBA_DEC_V2_NBE
FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i )
{
Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); // Q12 -> Q11
}
#endif /* OPT_SBA_DEC_V2_NBE */
/* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/
......@@ -281,44 +231,11 @@ ivas_error ivas_mct_dec_fx(
Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16
x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][0] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
move16();
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][1] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
}
#ifndef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, x_e );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( Word16 ind = 0; ind < 2; ind++ )
{
Word16 nSubFrames;
IF( EQ_16( hCPE->hCoreCoder[ind]->core, TCX_20_CORE ) )
{
nSubFrames = 1;
}
ELSE
{
nSubFrames = NB_DIV;
}
move16();
Scale_sig32( x_fx[ind][0], shr( L_FRAME48k, sub( nSubFrames, 1 ) ), sub( x_e[ind][0], 20 ) ); // Q11
IF( EQ_16( nSubFrames, 2 ) )
{
Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); // Q11
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
}
......@@ -375,37 +292,21 @@ ivas_error ivas_mct_dec_fx(
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig );
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
Word16 hdrm;
#else
Word16 hdrm, sh;
#endif
hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
IF( hdrm != 0 )
{
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
hdrm = sub( hdrm, 1 );
Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm );
e_sig[0] = sub( e_sig[0], hdrm );
#else
sh = s_min( sub( e_sig[0], 16 ), hdrm );
Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sh );
e_sig[0] = sub( e_sig[0], sh );
#endif
move16();
}
hdrm = getScaleFactor16( synth_fx[1], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
IF( hdrm != 0 )
{
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
hdrm = sub( hdrm, 1 );
Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm );
e_sig[1] = sub( e_sig[1], hdrm );
#else
sh = s_min( sub( e_sig[1], 16 ), hdrm );
Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sh );
e_sig[1] = sub( e_sig[1], sh );
#endif
move16();
}
......@@ -948,7 +849,11 @@ ivas_error ivas_mc_dec_config_fx(
IF( st_ivas->ini_frame != 0 )
{
test();
#ifdef FIX_1052_EXT_OUTPUT
IF( NE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate ) || last_mc_mode != st_ivas->mc_mode )
#else
IF( NE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate ) || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode )
#endif
{
IF( st_ivas->hRenderConfig )
{
......@@ -1014,7 +919,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
move32();
nchan_transport_old = st_ivas->nchan_transport;
move16();
nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
/* temporally set the current mc_mode back to the previous one to make sure the following call to
......@@ -1023,7 +928,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
move32();
st_ivas->mc_mode = last_mc_mode;
move32();
ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
st_ivas->mc_mode = mc_mode;
move32();
......@@ -1435,23 +1340,48 @@ static ivas_error ivas_mc_dec_reconfig_fx(
test();
IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) && st_ivas->hLFE == NULL )
{
#ifdef NONBE_FIX_MC_LFE_LPF
Word32 delay_ns = st_ivas->binaural_latency_ns;
#else
Word32 binauralization_delay_ns = st_ivas->binaural_latency_ns;
#endif
move32();
IF( st_ivas->hBinRenderer != NULL )
{
IF( st_ivas->hBinRenderer->render_lfe )
{
/* Account for filterbank delay */
#ifdef NONBE_FIX_MC_LFE_LPF
delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
#else
binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS );
#endif
}
ELSE
{
#ifdef NONBE_FIX_MC_LFE_LPF
delay_ns = 0;
#else
binauralization_delay_ns = 0;
#endif
move32();
}
}
#ifdef NONBE_FIX_MC_LFE_LPF
ELSE
{
IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
{
delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
}
}
#endif
#ifdef NONBE_FIX_MC_LFE_LPF
IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ), IVAS_ERR_OK ) )
#else
IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
#endif
{
return error;
}
......@@ -1520,6 +1450,13 @@ static ivas_error ivas_mc_dec_reconfig_fx(
IF( st_ivas->hBinRenderer != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) )
{
ivas_binRenderer_close_fx( &st_ivas->hBinRenderer );
#ifdef FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR
test();
IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
{
efap_free_data_fx( &st_ivas->hEFAPdata );
}
#endif
}
test();
......@@ -1534,12 +1471,8 @@ static ivas_error ivas_mc_dec_reconfig_fx(
test();
IF( st_ivas->hBinRendererTd != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) )
{
IF( EQ_16( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM, TRUE ) )
{
ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
st_ivas->hHrtfTD = NULL;
}
}
IF( st_ivas->hDiracDecBin[0] != NULL )
......@@ -1571,7 +1504,6 @@ static ivas_error ivas_mc_dec_reconfig_fx(
{
return error;
}
#ifdef NONBE_FIX_1075
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
......@@ -1579,7 +1511,6 @@ static ivas_error ivas_mc_dec_reconfig_fx(
return error;
}
}
#endif
IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK )
......@@ -1714,7 +1645,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
* floating-point output audio buffers
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
......
......@@ -165,12 +165,7 @@ void ivas_mct_dec_mct_fx(
static void applyGlobalILD_fx(
Decoder_State **sts,
MCT_DEC_HANDLE hMCT,
Word32 *x[MCT_MAX_CHANNELS][NB_DIV]
#ifndef OPT_SBA_DEC_PATH
,
Word16 q_x[MCT_MAX_CHANNELS]
#endif /* OPT_SBA_DEC_PATH */
)
Word32 *x[MCT_MAX_CHANNELS][NB_DIV] )
{
Word16 ch, k;
Word16 nSubframes, L_subframeTCX;
......@@ -211,14 +206,8 @@ static void applyGlobalILD_fx(
FOR( k = 0; k < nSubframes; k++ )
{
v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio
#ifdef OPT_SBA_DEC_PATH
scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) );
#endif /* OPT_SBA_DEC_PATH */
}
#ifndef OPT_SBA_DEC_PATH
q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio );
move16();
#endif /* OPT_SBA_DEC_PATH */
}
ELSE
{
......@@ -240,10 +229,6 @@ void apply_MCT_dec_fx(
MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
Decoder_State **sts, /* i/o: decoder state structure */
Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */
#ifndef OPT_SBA_DEC_PATH
,
Word16 q_x[MCT_MAX_CHANNELS]
#endif /* OPT_SBA_DEC_PATH */
)
{
Word16 pair;
......@@ -253,18 +238,10 @@ void apply_MCT_dec_fx(
{
hBlock = hMCT->hBlockData[pair];
#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0, &q_x[hBlock->ch2], &q_x[hBlock->ch1] );
#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 );
#endif /* OPT_SBA_DEC_PATH */
}
#ifndef OPT_SBA_DEC_PATH
applyGlobalILD_fx( sts, hMCT, x, q_x );
#else /* OPT_SBA_DEC_PATH */
applyGlobalILD_fx( sts, hMCT, x );
#endif /* OPT_SBA_DEC_PATH */
return;
}
......@@ -323,13 +300,8 @@ void mctStereoIGF_dec_fx(
move16();
// Using input Q-factor as 12
#ifdef OPT_SBA_DEC_V2_NBE
set16_fx( p_x_e[0], 31 - Q11, CPE_CHANNELS ); // Q12
set16_fx( p_x_e[1], 31 - Q11, CPE_CHANNELS ); // Q12
#else /* OPT_SBA_DEC_V2_NBE */
set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); // Q12
set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); // Q12
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( k = 0; k < nSubframes; k++ )
{
......@@ -358,21 +330,13 @@ void mctStereoIGF_dec_fx(
decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ );
// Shifting output with variable exponent back to Q12
#ifdef OPT_SBA_DEC_V2_NBE
shr_k = sub( 31 - Q11, p_x_e[0][k] );
#else /* OPT_SBA_DEC_V2_NBE */
shr_k = sub( 31 - Q12, p_x_e[0][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( Word16 i = 0; i < p_x_len[0][k]; i++ )
{
p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
shr_k = sub( 31 - Q11, p_x_e[1][k] );
#else /* OPT_SBA_DEC_V2_NBE */
shr_k = sub( 31 - Q12, p_x_e[1][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( Word16 i = 0; i < p_x_len[1][k]; i++ )
{
p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k );
......@@ -405,11 +369,7 @@ void mctStereoIGF_dec_fx(
/* mono or dual mono IGF decoding */
#ifdef OPT_SBA_DEC_V2_NBE
x_e = 31 - Q11; // input q-factor of x[p_ch[ch]][k] is Q12
#else /* OPT_SBA_DEC_V2_NBE */
x_e = 31 - Q12; // input q-factor of x[p_ch[ch]][k] is Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
decoder_tcx_IGF_mono_fx( st, x[p_ch[ch]][k], &x_e, &x_len, L_frame[ch], left_rect[ch], bfi, k );
......@@ -417,11 +377,7 @@ void mctStereoIGF_dec_fx(
FOR( Word16 i = 0; i < x_len; i++ )
{
// Converting from variable exponent to Fixed q-factor (Q12)
#ifdef OPT_SBA_DEC_V2_NBE
x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q11, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q12, x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
}
......@@ -473,11 +429,7 @@ void mctStereoIGF_dec_fx(
init_tcx_info_fx( st, L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] );
/* mono or dual mono IGF decoding */
#ifdef OPT_SBA_DEC_V2_NBE
x_e = 31 - Q11; // Input Q-factor is Q12.
#else /* OPT_SBA_DEC_V2_NBE */
x_e = 31 - Q12; // Input Q-factor is Q12.
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
decoder_tcx_IGF_mono_fx( st, x[ch][k], &x_e, &x_len, L_frame[0], left_rect[0], bfi, k );
......@@ -485,11 +437,7 @@ void mctStereoIGF_dec_fx(
FOR( Word16 i = 0; i < x_len; i++ )
{
// Converting from variable exponent to Fixed q-factor (Q12)
#ifdef OPT_SBA_DEC_V2_NBE
x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q11, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q12, x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
}
......
......@@ -630,17 +630,9 @@ void ivas_mdct_core_invQ_fx(
Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */
STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */
Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_0_e,
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_0_e[CPE_CHANNELS][NB_DIV],
#endif /* OPT_SBA_DEC_V2_NBE */
Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e,
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_e[CPE_CHANNELS][NB_DIV],
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 x_len[CPE_CHANNELS][NB_DIV],
Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients Q12*/
Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
......@@ -745,11 +737,7 @@ void ivas_mdct_core_invQ_fx(
q_r = sub( 30, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp );
/* both input in same Q */
#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l );
#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 );
#endif /* OPT_SBA_DEC_PATH */
Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15
Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15
......@@ -971,11 +959,6 @@ void ivas_mdct_core_invQ_fx(
IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
#ifndef OPT_SBA_DEC_V2_NBE
set32_fx( x[ch][0], 0, st->hTcxCfg->tcx_coded_lines );
x_e[ch][0] = 31;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
/* usually set in decoder_tcx_invQ(), needed for concealment */
st->hTcxDec->damping = 0;
move16();
......@@ -1007,10 +990,8 @@ void ivas_mdct_core_invQ_fx(
FOR( k = 0; k < nSubframes[ch]; k++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e_local = x_e;
Word16 j, diff;
#endif /* OPT_SBA_DEC_V2_NBE */
/* Stability Factor */
IF( !bfi )
{
......@@ -1045,7 +1026,6 @@ void ivas_mdct_core_invQ_fx(
nf_seed = 0;
move16();
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k );
diff = sub( x_e_local, x_0_e );
......@@ -1061,22 +1041,10 @@ void ivas_mdct_core_invQ_fx(
{
Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] );
}
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k );
#endif /* OPT_SBA_DEC_V2_NBE */
shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] );
move16();
Scale_sig32( x[ch][k], L_frameTCX[ch], shift );
#ifdef OPT_SBA_DEC_V2_NBE
x_e_local = sub( x_e_local, shift );
#else /* OPT_SBA_DEC_V2_NBE */
x_e[ch][k] = sub( x_e[ch][k], shift );
move16();
Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] );
x_0_e[ch][k] = x_e[ch][k];
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
// PLC to be done
test();
......@@ -1085,29 +1053,17 @@ void ivas_mdct_core_invQ_fx(
TonalMdctConceal_create_concealment_noise_ivas_fx( concealment_noise_fx[ch], &concealment_noise_e[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi );
}
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k );
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k );
#endif /* OPT_SBA_DEC_V2_NBE */
shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] );
move16();
Scale_sig32( x[ch][k], L_frameTCX[ch], shift );
#ifdef OPT_SBA_DEC_V2_NBE
x_e_local = sub( x_e_local, shift );
#else /* OPT_SBA_DEC_V2_NBE */
x_e[ch][k] = sub( x_e[ch][k], shift );
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e_local, &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi );
Scale_sig32( x[ch][k], L_frameTCX[ch], sub( x_e_local, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e[ch][k], &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi );
#endif /* OPT_SBA_DEC_V2_NBE */
}
}
}
......@@ -1652,11 +1608,7 @@ void ivas_mdct_core_tns_ns_fx(
Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS Q(31 - x_e)*/
Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients Q16*/
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e )
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_e[CPE_CHANNELS][NB_DIV] )
#endif /* OPT_SBA_DEC_V2_NBE */
{
Word16 ch, k, bfi;
Decoder_State **sts, *st;
......@@ -1730,11 +1682,7 @@ void ivas_mdct_core_tns_ns_fx(
&tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
Word16 q_x;
#ifdef OPT_SBA_DEC_V2_NBE
q_x = sub( 31, x_e );
#else /* OPT_SBA_DEC_V2_NBE */
q_x = sub( 31, x_e[ch][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
IF( bfi == 0 )
{
sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); // Q16
......@@ -1753,11 +1701,7 @@ void ivas_mdct_core_tns_ns_fx(
scf_e[ind] = sub( 15, q_shift );
move16();
}
#ifdef OPT_SBA_DEC_V2_NBE
TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
#else /* OPT_SBA_DEC_V2_NBE */
TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
#endif /* OPT_SBA_DEC_V2_NBE */
}
}
ELSE
......@@ -1819,10 +1763,6 @@ void ivas_mdct_core_tns_ns_fx(
norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 q_sns_int_scf;
Word16 q_2;
......@@ -1849,10 +1789,6 @@ void ivas_mdct_core_tns_ns_fx(
Scale_sig32( &x_fx[ch][k][0] + length, sub( length2, length ), sub( add( q_x, 1 ), q_2 ) );
q_x = add( q_x, 1 );
}
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) );
......@@ -1860,10 +1796,6 @@ void ivas_mdct_core_tns_ns_fx(
Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) );
q_x = q_2;
move16();
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
q_x = sub( q_x, 5 );
length = L_frameTCX[ch];
......@@ -1880,52 +1812,18 @@ void ivas_mdct_core_tns_ns_fx(
}
Scale_sig32( &x_fx[ch][k][0], length, -5 );
decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0, &length );
#ifndef OPT_SBA_DEC_V2_NBE
norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
x_e[ch][k] = sub( 31, q_x );
move16();
#else /* OPT_SBA_DEC_V2_NBE */
Scale_sig32( &x_fx[ch][k][0], length, sub( sub( 31, q_x ), x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
}
IF( ( bfi != 0 ) && ( st->tonal_mdct_plc_active != 0 ) )
{
#ifndef OPT_SBA_DEC_V2_NBE
Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 i;
FOR( i = 0; i < FDNS_NPTS; i++ )
{
st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] );
}
#ifndef OPT_SBA_DEC_V2_NBE
set16_fx( tmp_x_fx_exp, x_e[ch][0], L_FRAME48k );
TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent );
#else /* OPT_SBA_DEC_V2_NBE */
TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], x_e, st->hTcxCfg->psychParamsCurrent );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( i = 0; i < L_FRAME48k; i++ )
{
temp = s_max( temp, tmp_x_fx_exp[i] );
}
{
x_e[ch][0] = temp;
move16();
FOR( i = 0; i < L_FRAME48k; i++ )
{
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( temp, tmp_x_fx_exp[i] ) );
move32();
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
}
test();
......
......@@ -59,7 +59,11 @@ ivas_error ivas_td_binaural_open_fx(
*num_src = st_ivas->nchan_ism;
move16();
}
#ifdef CONF_DISTATT
return ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, *num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity_fx, st_ivas->hRenderConfig->distAtt_fx, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns, SrcInd );
#else
return ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD, st_ivas->hDecoderConfig->output_Fs, *num_src, st_ivas->ivas_format, st_ivas->transport_config, st_ivas->hRenderConfig->directivity_fx, st_ivas->hTransSetup, &st_ivas->hBinRendererTd, &st_ivas->binaural_latency_ns, SrcInd );
#endif
}
......@@ -328,7 +332,19 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
{
continue;
}
#ifdef CONF_DISTATT
IF( ( error = ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD,
st_ivas->hDecoderConfig->output_Fs,
st_ivas->nchan_transport,
st_ivas->ivas_format,
st_ivas->transport_config,
st_ivas->hRenderConfig->directivity_fx,
st_ivas->hRenderConfig->distAtt_fx,
st_ivas->hTransSetup,
&st_ivas->hTdRendHandles[i],
&st_ivas->binaural_latency_ns,
SrcInd ) ) != IVAS_ERR_OK )
#else
IF( ( error = ivas_td_binaural_open_unwrap_fx( &st_ivas->hHrtfTD,
st_ivas->hDecoderConfig->output_Fs,
st_ivas->nchan_transport,
......@@ -339,6 +355,7 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural(
&st_ivas->hTdRendHandles[i],
&st_ivas->binaural_latency_ns,
SrcInd ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
......
......@@ -462,8 +462,8 @@ ivas_error ivas_omasa_dec_config_fx(
move16();
st_ivas->ivas_format = st_ivas->last_ivas_format;
move16();
ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
move16();
st_ivas->ivas_format = ivas_format_orig;
......@@ -569,18 +569,20 @@ ivas_error ivas_omasa_dec_config_fx(
IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
{
/* the full number of hIsmMetaData are needed for EXT output */
move16();
n_MD = st_ivas->nchan_ism;
ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL );
move32();
IF( NE_32( error, IVAS_ERR_OK ) )
IF( st_ivas->hIsmMetaData[0] == NULL )
{
IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK )
{
return error;
}
ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD );
}
ELSE
{
FOR( k = 0; k < st_ivas->nchan_ism; k++ )
{
ivas_ism_reset_metadata_handle_dec_fx( st_ivas->hIsmMetaData[k] );
}
}
}
ELSE
{
......@@ -599,14 +601,16 @@ ivas_error ivas_omasa_dec_config_fx(
return error;
}
}
ELSE
{
ivas_ism_reset_metadata_handle_dec_fx( st_ivas->hIsmMetaData[0] );
}
}
ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
n_MD = st_ivas->nchan_ism;
move16();
ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL );
move32();
IF( NE_32( error, IVAS_ERR_OK ) )
......@@ -647,6 +651,7 @@ ivas_error ivas_omasa_dec_config_fx(
ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD );
#endif
st_ivas->hCPE[0]->element_brate = L_sub( ivas_total_brate, ism_total_brate );
/*-----------------------------------------------------------------*
......@@ -692,11 +697,12 @@ ivas_error ivas_omasa_dec_config_fx(
IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) )
{
/* Allocate TD renderer for the objects in DISC mode */
IF( st_ivas->hBinRendererTd == NULL ){
IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, num_src ) ), IVAS_ERR_OK ) ){
IF( st_ivas->hBinRendererTd == NULL )
{
IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, num_src ) ), IVAS_ERR_OK ) )
{
return error;
}
#ifdef NONBE_FIX_1075
IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
{
IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
......@@ -704,7 +710,6 @@ ivas_error ivas_omasa_dec_config_fx(
return error;
}
}
#endif
}
/* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */
......@@ -715,15 +720,11 @@ ivas_error ivas_omasa_dec_config_fx(
}
ELSE
{
/* TD renderer handle */
test();
IF( st_ivas->hBinRendererTd != NULL && EQ_16( st_ivas->hBinRendererTd->HrFiltSet_p->ModelParams.modelROM, TRUE ) )
if ( st_ivas->hBinRendererTd != NULL )
{
/* TD renderer handle */
ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
st_ivas->hHrtfTD = NULL;
}
/* ISM renderer handle + ISM data handle */
ivas_omasa_separate_object_renderer_close( st_ivas );
}
......@@ -820,7 +821,7 @@ IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, 2, numCldfbAnalyses_ol
* floating-point output audio buffers
*-----------------------------------------------------------------*/
nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
{
return error;
......
......@@ -160,6 +160,9 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx(
return error;
}
#ifdef NONBE_FIX_ISM_XOVER_BR
ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
#endif
IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
Word16 slot_idx, num_cldfb_bands, b, nchan_transport_orig;
......