diff --git a/lib_com/options.h b/lib_com/options.h index 4abd6c6ccd97341e59d097fbe0e7108108209d99..7405871614626c75b830e1bcdc05d0b976140862 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,6 +110,7 @@ #define MSAN_FIX #define FIX_818_COMPLEXITY_IMPROV /* Fix for issue 818 */ #define FIX_805_VERIFICATION /* Fix for issue 805 */ +#define FIX_827_HIGH_MLD /* Fix for issue 827 */ #endif #define ISM_DISABLE #define FIX_TMP_714 diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 994954f092cb62f7410419aa303c1d5832225521..2d158a705122c7b4651dcc61654a6ed91ecf9bf8 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -1722,7 +1722,11 @@ Word16 computeMixingMatrices_fx( matrix_product_mant_exp_fx( Q_fx, Q_e, lengthCy, lengthCx, 0, Cx_fx, Cx_fx_e, lengthCx, lengthCx, 0, Q_Cx_fx, &Q_Cx_e ); Word16 guard_bits; +#ifdef FIX_827_HIGH_MLD + guard_bits = find_guarded_bits_fx( lengthCx ); +#else guard_bits = find_guarded_bits_fx( lengthCx + 1 ); +#endif FOR( i = 0; i < lengthCy * lengthCx; ++i ) { @@ -1760,11 +1764,18 @@ Word16 computeMixingMatrices_fx( move16(); } +#ifndef FIX_827_HIGH_MLD L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); limit_fx = L_add( L_tmp, EPSILON_FX ); limit_e = add( limit_e, reg_ghat_e ); move16(); +#endif } +#ifdef FIX_827_HIGH_MLD + L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); + limit_fx = L_add( L_tmp, EPSILON_FX ); + limit_e = add( limit_e, reg_ghat_e ); +#endif FOR( i = 0; i < lengthCy; ++i ) @@ -2532,8 +2543,13 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { +#ifdef FIX_827_HIGH_MLD + L_tmp = Mpy_32_32( mat_mult_buffer1_fx[add( j, imult1616( i, extract_l( num_outputs ) ) )], fac_fx ); + mixing_matrix_fx[add( j, imult1616( i, extract_l( num_outputs ) ) )] = L_tmp; +#else L_tmp = Mpy_32_32( mat_mult_buffer1_fx[add( j, imult1616( j, extract_l( num_outputs ) ) )], fac_fx ); mixing_matrix_fx[add( j, imult1616( j, extract_l( num_outputs ) ) )] = L_tmp; +#endif move32(); mixing_matrix_e = add( mat_mult_buffer1_e, Kx_reg_inv_fx_e ); move16(); @@ -2548,7 +2564,12 @@ Word16 computeMixingMatricesResidual_fx( matrix_diag_product_fx( mixing_matrix_fx, mixing_matrix_e, lengthCy, lengthCx, 0, Cx_fx, Cx_e, lengthCx, mat_mult_buffer1_fx, &mat_mult_buffer1_e ); +#ifdef FIX_827_HIGH_MLD + Word16 guard_bits; + guard_bits = find_guarded_bits_fx( lengthCx ); +#else Word16 guard_bits = find_guarded_bits_fx( lengthCx + 1 ); +#endif FOR( i = 0; i < lengthCy * lengthCx; ++i ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index eb231f065409df0114aa65662aea55fdf79784d9..4caadd0fd71e2bed905ac4bc1894418b8b8e8d3b 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -151,6 +151,8 @@ static ivas_error allocate_CoreCoder_TCX_fx( // st->hTcxDec->CngLevelBackgroundTrace_bfi = 0; //initializing to avoid garbage overflow; set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + st->hTcxDec->q_old_synth = 0; + move16(); set16_fx( st->hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME48k ); } diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 9156aa7180b1b50b99c907d55a22652226c227b9..6a07d026c7163d132bd9b998218fe46211069a11 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -714,7 +714,11 @@ static Word16 BidagonalDiagonalisation_fx( } ELSE { +#ifdef FIX_827_HIGH_MLD + IF( GE_16( iteration, SVD_MAX_NUM_ITERATION ) ) +#else IF( GT_16( iteration, SVD_MAX_NUM_ITERATION ) ) +#endif { IF( LT_32( singularValues_fx[iCh], 0 ) ) { @@ -1416,7 +1420,11 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ } r = BASOP_Util_Add_Mant32Exp( Mpy_32_32( ( *g ), singularVectors[currChannel][idx] ), sing_exp[currChannel], -norm_x, norm_x_e, &r_e ); +#ifdef FIX_827_HIGH_MLD + singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[currChannel], -( *g ), 0, &sing_exp[currChannel] ); +#else singularVectors[currChannel][idx] = BASOP_Util_Add_Mant32Exp( singularVectors[currChannel][idx], sing_exp[idx], -( *g ), 0, &sing_exp[currChannel] ); +#endif move32(); FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 519f50a2ed9bdccab3bc210d6eea2c6a87cf5c18..107aea626782a972a4c8f2cb44074979f32685e5 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1007,7 +1007,7 @@ void ivas_updt_dec_common_fx( IF( EQ_16( st_fx->core, HQ_CORE ) ) { - st_fx->stab_fac_fx = extract_l( L_min( MAX_16, L_add( L_shr( STAB_FAC_EST1_FX, Q15 ), Madd_32_32( L_shr( Mpy_32_16_1( STAB_FAC_EST2_FX, st_fx->hHQ_core->mem_env_delta ), Q15 ), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx ) ) ) ); + st_fx->stab_fac_fx = extract_l( L_min( MAX_16, L_add( L_shr( STAB_FAC_EST1_FX, Q15 ), Madd_32_32( Mpy_32_16_1( STAB_FAC_EST2_FX, st_fx->hHQ_core->mem_env_delta ), STAB_FAC_EST3_FX, st_fx->log_energy_diff_lt_fx ) ) ) ); st_fx->stab_fac_fx = s_max( 0, st_fx->stab_fac_fx ); } st_fx->stab_fac_smooth_lt_fx = extract_h( L_add( L_mult( ENV_SMOOTH_FAC_FX, st_fx->stab_fac_fx ), diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 9d1f6720cf405dbfc6323527345cc10c9c135ad7..415c6bbc9da6888c44ce046ce2dcac04b69efe08 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -7805,7 +7805,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( /* CLDFB Analysis of input */ - Word16 q_cldfb = Q11; FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) { FOR( ch = 0; ch < numInChannels; ch++ ) @@ -7813,6 +7812,8 @@ static void ivas_masa_ext_rend_parambin_internal_fx( test(); IF( ch == 0 || EQ_16( nchan_transport, 2 ) ) { + Word16 q_cldfb = Q11; + move16(); cldfbAnalysis_ts_fx_fixed_q( &( output_fx[ch][nBins * slot] ), Cldfb_RealBuffer_in_fx[ch][slot], @@ -7823,8 +7824,8 @@ static void ivas_masa_ext_rend_parambin_internal_fx( { /* At mono input duplicate the channel to dual-mono, and apply gain correction to ensure same overall level as in stereo mode */ - v_multc_fixed( Cldfb_RealBuffer_in_fx[0][slot], 151800249 /* INV_SQRT_2 in Q31 */, Cldfb_RealBuffer_in_fx[0][slot], nBins ); - v_multc_fixed( Cldfb_ImagBuffer_in_fx[0][slot], 151800249 /* INV_SQRT_2 in Q31 */, Cldfb_ImagBuffer_in_fx[0][slot], nBins ); + v_multc_fixed( Cldfb_RealBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_RealBuffer_in_fx[0][slot], nBins ); + v_multc_fixed( Cldfb_ImagBuffer_in_fx[0][slot], 1518500224 /* INV_SQRT_2 in Q31 */, Cldfb_ImagBuffer_in_fx[0][slot], nBins ); Copy32( Cldfb_RealBuffer_in_fx[0][slot], Cldfb_RealBuffer_in_fx[1][slot], nBins ); Copy32( Cldfb_ImagBuffer_in_fx[0][slot], Cldfb_ImagBuffer_in_fx[1][slot], nBins ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec.c b/lib_rend/ivas_dirac_output_synthesis_dec.c index 2eae9eb9457545ae118ac06338a68e084f7316d3..60299777727ce4108f021ff790623770b71e346f 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec.c @@ -3483,6 +3483,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( /*-----------------------------------------------------------------* * gain interpolation and output streams *-----------------------------------------------------------------*/ + Word16 q_align = sub( h_dirac_output_synthesis_state->proto_direct_buffer_f_q, h_dirac_output_synthesis_state->proto_power_diff_smooth_q ); + if ( h_dirac_output_synthesis_params->max_band_decorr != 0 ) + { + q_align = sub( h_dirac_output_synthesis_state->proto_direct_buffer_f_q, h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q ); + } FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) { @@ -3521,10 +3526,10 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q RealBuffer[k][buf_idx][l] = L_add( L_shr( RealBuffer[k][buf_idx][l], Q1 ), - L_shr( Mpy_32_32( g, ( *( p_power_smooth_diff++ ) ) ), Q1 ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 + L_shr( Mpy_32_32( g, ( *( p_power_smooth_diff++ ) ) ), sub( Q1, q_align ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 move32(); ImagBuffer[k][buf_idx][l] = L_add( L_shr( ImagBuffer[k][buf_idx][l], Q1 ), - L_shr( Mpy_32_32( g, ( *( p_power_smooth_diff++ ) ) ), Q1 ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 + L_shr( Mpy_32_32( g, ( *( p_power_smooth_diff++ ) ) ), sub( Q1, q_align ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) >> Q1 -> gains_diff_prev_q + q_proto_direct_buffer - 32 move32(); } diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index fca18ac05eb154c2a15611b8f9783f82384e7feb..1f230806be18e00babea4d972a62ee2d8d20ab87 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -609,7 +609,7 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { - Scale_sig32( output_fx[i], L_FRAME48k, -4 ); + scale_sig32( output_fx[i], L_FRAME48k, -4 ); } IF( NE_32( ( error = ivas_reverb_process_fx( hReverb, transport_config, 0, output_fx, p_reverb_signal_fx, subframe_idx ) ), IVAS_ERR_OK ) ) @@ -619,12 +619,12 @@ ivas_error ivas_td_binaural_renderer_unwrap_fx( FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i ) { - Scale_sig32( output_fx[i], L_FRAME48k, 4 ); + scale_sig32( output_fx[i], L_FRAME48k, 4 ); } FOR( i = 0; i < BINAURAL_CHANNELS; ++i ) { - Scale_sig32( p_reverb_signal_fx[i] + subframe_idx * hReverb->full_block_size, hReverb->full_block_size, 2 ); + scale_sig32( p_reverb_signal_fx[i] + subframe_idx * hReverb->full_block_size, hReverb->full_block_size, 2 + 4 ); } } diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 55dfd98082cde954f1609b39939b0a329df73ed6..22465911abf8b22d04d642718926a446ba8c2fbb 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -12623,8 +12623,8 @@ static ivas_error renderInputMasa( FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ ) { - scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state ) ); - masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11; + scale_sig32( masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_state_fx, masaInput->hMasaExtRend->cldfbSynRend[ch]->cldfb_size, sub( Q11, masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state ) ); + masaInput->hMasaExtRend->cldfbSynRend[ch]->Q_cldfb_state = Q11; } intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 ); diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 653149eb06089a85e34c48481851855fefb9fd91..11178d54c378ed1e88ec3a3185e61cc704ea9924 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -253,6 +253,10 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { hMeta->common_meta.surround_coherence[j][b] = ( (float) readOther[b] ) / UINT8_MAX; +#ifdef IVAS_FLOAT_FIXED + hMeta->common_meta.surround_coherence_fx[j][b] = shl( (Word16) readOther[b], 7 ); // Q8->Q15 + move16(); +#endif } /* Remainder-to-total ratio */