diff --git a/lib_com/options.h b/lib_com/options.h index 131188e6513ce3e9efdd996ae8318c3d97f00b3c..5ef2fe4f5c4e6d683cec5c0b337ef01707234237 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -77,12 +77,15 @@ #define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ #define FIX_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */ #define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */ + #define FIX_1978_SAT_MISSING_IN_GAIN_ENC /* VA: Fix add saturation missing that lead to a crash in P800-10 */ #define FIX_1979_SAT_MISSING_IN_LSF_ENC /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */ #define FIX_1946_CRASH_JBM_PROCESSING /* FhG: Increased guard bits of DFT_fx */ #define FIX_1980_CRASH_FDCNG_ENCODESID /* FhG: Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() */ #define FIX_1987_CRASH_OMASA_ENERGY /* FhG: Replace cldfbAnalysis_ts_fx_fix_q() with cldfbAnalysis_ts_fx_var_q() to avoid assertion error */ +#define FIX_1985_SBA_714_HF_LOSS /* Dlb: Fix for issue 1985, improved dirac ref pow precision*/ + /* #################### Start BASOP porting switches ############################ */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 38ffe53d1d222d2b235a7fc0992aae3db5b664af..8cfb7d18eb30b5a4d5d4bf7e65fd6ddf3608ac86 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -2632,10 +2632,48 @@ void protoSignalComputation4_fx( Word32 sq_tmp_fx; Word32 *p_proto_buffer_fx; Word16 min_q_shift, q_shift; +#ifndef FIX_1985_SBA_714_HF_LOSS Word16 min_q_shift2, q_shift2; +#endif Word32 re, im; Word16 proto_power_smooth_fx_q, sq_tmp_q; +#ifdef FIX_1985_SBA_714_HF_LOSS + Word64 ref_pow64[CLDFB_NO_CHANNELS_MAX], re64; + Word16 sf1, sf2; +#endif + +#ifdef FIX_1985_SBA_714_HF_LOSS + FOR( l = 0; l < num_freq_bands; l++ ) + { + re64 = W_mult_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ); + re64 = W_mac_32_32( re64, ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] ); + ref_pow64[l] = W_shr( re64, 1 ); // 2*q_cldfb +1 + move64(); + } + FOR( k = 1; k < 4; k++ ) + { + FOR( l = 0; l < num_freq_bands; l++ ) + { + re64 = W_mult_32_32( RealBuffer_fx[k][0][l], RealBuffer_fx[k][0][l] ); + re64 = W_mac_32_32( re64, ImagBuffer_fx[k][0][l], ImagBuffer_fx[k][0][l] ); + ref_pow64[l] = W_add( ref_pow64[l], W_shr( re64, 1 ) ); // 2*q_cldfb +1 + move64(); + } + } + sf1 = W_norm_arr( ref_pow64, s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ) ); + FOR( l = 0; l < s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ); l++ ) + { + reference_power_fx[l] = W_extract_h( W_shl( ref_pow64[l], sf1 ) ); + } + reference_power_q[0] = sub( add( shl( q_cldfb, 1 ), sf1 ), 31 ); + sf2 = W_norm_arr( &ref_pow64[CLDFB_NO_CHANNELS_HALF], s_max( 0, sub( num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ); + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + reference_power_fx[l] = W_extract_h( W_shl( ref_pow64[l], sf2 ) ); + } + reference_power_q[1] = sub( add( shl( q_cldfb, 1 ), sf2 ), 31 ); +#else min_q_shift = Q31; move16(); q_shift = Q31; @@ -2695,8 +2733,22 @@ void protoSignalComputation4_fx( sq_tmp_q = sub( add( add( q_cldfb, min_q_shift2 ), add( q_cldfb, min_q_shift2 ) ), 31 ); reference_power_q[1] = sq_tmp_q; move16(); +#endif +#ifdef FIX_1985_SBA_714_HF_LOSS + min_q_shift = Q31; + /* calculate the shift possible for both RealBuffer_fx and ImagBuffer_fx buffers*/ + FOR( k = 0; k < s_max( 4, nchan_transport ); k++ ) + { + q_shift = L_norm_arr( RealBuffer_fx[k][0], num_freq_bands ); + min_q_shift = s_min( q_shift, min_q_shift ); + q_shift = L_norm_arr( ImagBuffer_fx[k][0], num_freq_bands ); + min_q_shift = s_min( q_shift, min_q_shift ); + } + min_q_shift = sub( min_q_shift, find_guarded_bits_fx( 2 ) ); +#else min_q_shift = sub( s_min( q_shift, q_shift2 ), find_guarded_bits_fx( 2 ) ); +#endif /*For decorrelated diffuseness*/ FOR( l = 0; l < num_outputs_diff; l++ )