From 17fb7e2e010e775cc61e1d9d30c882b33f5d274f Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Aug 2024 08:10:21 -0400 Subject: [PATCH 1/2] Potential fix for 839 --- lib_com/ivas_prot_fx.h | 7 ++++++- lib_com/options.h | 2 ++ lib_dec/ivas_core_dec.c | 6 +++++- lib_dec/ivas_stereo_icbwe_dec.c | 17 ++++++++++++++++- lib_dec/swb_tbe_dec_fx.c | 4 ++++ 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index bceefbb76..1a10c3a8d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1412,7 +1412,12 @@ void stereo_icBWE_dec_fx( const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz */ const Word16 *voice_factors_fx, /* i : voicing factors */ const Word16 output_frame, /* i : frame length */ - Word16 *Q_syn ); + Word16 *Q_syn +#ifdef FIX_tmp_buffer_2 + , + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ +#endif +); void decoder_tcx_tns_fx( Decoder_State *st, /* i/o: coder memory state */ diff --git a/lib_com/options.h b/lib_com/options.h index e87c8d257..1fbc63cc6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -159,6 +159,8 @@ #define FIX_833_CORRECTION_to_826 /* VA : fix indexing error introduced in 826 */ #endif #define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/ +#define FIX_839_FB_CONTENT_SOMETIME_MISSING /* VA : Fix scaling error for FB TB BWE */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 17a1fcce2..7b07f2783 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1255,8 +1255,12 @@ ivas_error ivas_core_dec_fx( hCPE->hStereoDft->td_gain_fx[0] = 1; move32(); } - Scale_sig( tmp_buffer_fx, L_FRAME48k, sub( Q11, Q_white_exc ) ); +#ifndef FIX_839_FB_CONTENT_SOMETIME_MISSING + Scale_sig( tmp_buffer_fx, L_FRAME48k, sub( Q11, Q_white_exc ) ); // for small value, this was just mostly p stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); +#else + stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); +#endif #ifdef MSAN_FIX test(); test(); diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index 89faf3559..e6dc104dd 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -556,10 +556,14 @@ void stereo_icBWE_dec_fx( CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ Word32 *synthRef_fx, /* i/o: Reference channel HB synthesis at output Fs Q11 */ Word32 *synth_fx, /* o : Non reference channel HB synthesis at output Fs Q11 */ - const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz Q11 */ + const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz fb_synth_ref_fx */ const Word16 *voice_factors_fx, /* i : voicing factors Q15 */ const Word16 output_frame, /* i : frame length */ Word16 *Q_syn /* i : Q of synth and synthRef buffers */ +#ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING + , + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ +#endif ) { Word16 i, j, k, nbSubFr; @@ -1330,11 +1334,22 @@ void stereo_icBWE_dec_fx( { // v_add( fb_synth_nonref_fx, synth_fx, synth_fx, L_FRAME48k, 0 ); +#ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING + tmp = shl_sat( 1, sub( Q11 + 15, Q_white_exc ) ); + IF ( tmp != 0 ) + { + FOR( i = 0; i < L_FRAME48k; i++ ) + { + synth_fx[i] = L_mac( synth_fx[i], fb_synth_nonref_fx[i], tmp ); + } + } +#else FOR( i = 0; i < L_FRAME48k; i++ ) { synth_fx[i] = L_add( synth_fx[i], L_deposit_l( fb_synth_nonref_fx[i] ) ); move32(); } +#endif } /* copy to outputHB and reset hb_synth values */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 091915667..eceaa1eaf 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4957,7 +4957,11 @@ void fb_tbe_dec_ivas_fx( test(); IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) ) { +#ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING + Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, add( hb_synth_exp, 16 ) ) ); // scaling is required +#else Copy_Scale_sig( fb_synth, fb_synth_ref, L_FRAME48k, sub( Q_fb_synth_ref, hb_synth_exp ) ); // scaling is required +#endif } /* add the fb_synth component to the hb_synth component */ /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ -- GitLab From 949771fe1bffef8005fd30bc2780667c76b98f0a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 9 Aug 2024 08:38:58 -0400 Subject: [PATCH 2/2] Fix clang-format --- lib_com/ivas_prot_fx.h | 8 ++++---- lib_dec/ivas_core_dec.c | 2 +- lib_dec/ivas_stereo_icbwe_dec.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 1a10c3a8d..43a0375fe 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1412,11 +1412,11 @@ void stereo_icBWE_dec_fx( const Word16 *fb_synth_ref_fx, /* i : ref. high-band synthesis 16-20 kHz */ const Word16 *voice_factors_fx, /* i : voicing factors */ const Word16 output_frame, /* i : frame length */ - Word16 *Q_syn -#ifdef FIX_tmp_buffer_2 + Word16 *Q_syn +#ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING , - const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ -#endif + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ +#endif ); void decoder_tcx_tns_fx( diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 7b07f2783..95839cc7a 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -1256,7 +1256,7 @@ ivas_error ivas_core_dec_fx( move32(); } #ifndef FIX_839_FB_CONTENT_SOMETIME_MISSING - Scale_sig( tmp_buffer_fx, L_FRAME48k, sub( Q11, Q_white_exc ) ); // for small value, this was just mostly p + Scale_sig( tmp_buffer_fx, L_FRAME48k, sub( Q11, Q_white_exc ) ); // for small value, this was just mostly p stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q ); #else stereo_icBWE_dec_fx( hCPE, hb_synth_32_fx[0], hb_synth_32_fx[1], tmp_buffer_fx /*fb_synth_ref*/, voice_factors_fx[0], output_frame, &q, Q_white_exc ); diff --git a/lib_dec/ivas_stereo_icbwe_dec.c b/lib_dec/ivas_stereo_icbwe_dec.c index e6dc104dd..47da57810 100644 --- a/lib_dec/ivas_stereo_icbwe_dec.c +++ b/lib_dec/ivas_stereo_icbwe_dec.c @@ -562,7 +562,7 @@ void stereo_icBWE_dec_fx( Word16 *Q_syn /* i : Q of synth and synthRef buffers */ #ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING , - const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ + const Word16 Q_white_exc /* i : Q of fb_synth_ref_fx */ #endif ) { @@ -1336,7 +1336,7 @@ void stereo_icBWE_dec_fx( // v_add( fb_synth_nonref_fx, synth_fx, synth_fx, L_FRAME48k, 0 ); #ifdef FIX_839_FB_CONTENT_SOMETIME_MISSING tmp = shl_sat( 1, sub( Q11 + 15, Q_white_exc ) ); - IF ( tmp != 0 ) + IF( tmp != 0 ) { FOR( i = 0; i < L_FRAME48k; i++ ) { -- GitLab