From bd946cddd827c1f704ad835df13db27fb028899e Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 1 Sep 2025 21:29:08 +1000 Subject: [PATCH 1/3] impove ref power precision --- lib_com/options.h | 3 +- lib_rend/ivas_dirac_rend_fx.c | 60 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 53d58f113..0651a5305 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -77,8 +77,9 @@ #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_1946_CRASH_JBM_PROCESSING /* FhG: Increased guard bits of DFT_fx */ +#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 38ffe53d1..2c0b19590 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -2632,10 +2632,56 @@ 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 + sf1 = 63; + sf2 = 63; + 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(); + } + } + FOR( l = 0; l < s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ); l++ ) + { + sf1 = s_min( sf1, W_norm( ref_pow64[l] ) ); + } + 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 ); + FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) + { + sf2 = s_min( sf2, W_norm( ref_pow64[l] ) ); + } + 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[l] = sub( add( shl( q_cldfb, 1 ), sf2 ), 31 ); +#else min_q_shift = Q31; move16(); q_shift = Q31; @@ -2695,8 +2741,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++ ) -- GitLab From 0b4e8bd6864dd325a5af3929c6d5ebe3c5cdf7ca Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 1 Sep 2025 22:30:44 +1000 Subject: [PATCH 2/3] fix a typo --- lib_rend/ivas_dirac_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 2c0b19590..c67b1b5bc 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -2680,7 +2680,7 @@ void protoSignalComputation4_fx( { reference_power_fx[l] = W_extract_h( W_shl( ref_pow64[l], sf2 ) ); } - reference_power_q[l] = sub( add( shl( q_cldfb, 1 ), sf2 ), 31 ); + reference_power_q[1] = sub( add( shl( q_cldfb, 1 ), sf2 ), 31 ); #else min_q_shift = Q31; move16(); -- GitLab From 2c4415888379bd6ecfa1dda1ec5a96a074ce9267 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 2 Sep 2025 22:20:06 +1000 Subject: [PATCH 3/3] use W_norm_arr to normalize the array --- lib_rend/ivas_dirac_rend_fx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index c67b1b5bc..8cfb7d18e 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -2643,8 +2643,6 @@ void protoSignalComputation4_fx( #endif #ifdef FIX_1985_SBA_714_HF_LOSS - sf1 = 63; - sf2 = 63; FOR( l = 0; l < num_freq_bands; l++ ) { re64 = W_mult_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ); @@ -2662,20 +2660,14 @@ void protoSignalComputation4_fx( move64(); } } - FOR( l = 0; l < s_min( CLDFB_NO_CHANNELS_HALF, num_freq_bands ); l++ ) - { - sf1 = s_min( sf1, W_norm( ref_pow64[l] ) ); - } + 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 ); - FOR( l = CLDFB_NO_CHANNELS_HALF; l < num_freq_bands; l++ ) - { - sf2 = s_min( sf2, W_norm( ref_pow64[l] ) ); - } + 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 ) ); -- GitLab