From 90dfd9a30148b489d7665d322c52e6b14e08e812 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 4 Nov 2024 17:58:05 +0530 Subject: [PATCH] Fix for 3GPP issue 970: Major waveform discrepency in decoding SBA packets with 15% FER [x] Changed implementation of decoder_tcx_post_ivas_fx to accomodate variable Q instead of -2 --- lib_com/prot_fx.h | 1 + lib_dec/dec_tcx_fx.c | 22 +++++++++------------- lib_dec/ivas_mdct_core_dec.c | 2 +- lib_dec/ivas_tcx_core_dec.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bfe439692..1fac038c8 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9818,6 +9818,7 @@ UWord32 mvl2s_r( void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, Word16 *synth, Word16 *synthFB, + Word16 Q_syn, Word16 *A, Word16 bfi, Word16 MCT_flag ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 35a417a6c..100b49de8 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -1613,9 +1613,10 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, #ifdef IVAS_FLOAT_FIXED void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, - Word16 *synth, // Qx - Word16 *synthFB, // Qx - Word16 *A, // Q: 14 - norm_s(A[0]) + Word16 *synth, // Q_syn + Word16 *synthFB, // Q_syn + Word16 Q_syn, + Word16 *A, // Q: 14 - norm_s(A[0]) Word16 bfi, Word16 MCT_flag ) { @@ -1684,7 +1685,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, { tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ #ifdef BASOP_NOGLOB - synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); // Qx + synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); // Q_syn #else synthFB[i] = round_fx( L_shl( Mpy_32_16_1( tmp32, synthFB[i] ), 16 ) ); #endif @@ -1696,8 +1697,8 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, tmp32_2 /*stepCompensate*/ = L_shl_r( L_deposit_h( hTcxDec->stepCompensate ), sub( hTcxDec->stepCompensate_e, 31 - 28 ) ); /*Q28*/ FOR( i = 0; i < st_fx->L_frame; i++ ) { - tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ - xn_buf[i] = extract_l( Mpy_32_16_1( tmp32, xn_buf[i] ) ); // Qx + tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ + xn_buf[i] = extract_h( L_shl_sat( Mpy_32_16_1( tmp32, xn_buf[i] ), 16 ) ); // Q_syn move16(); tmp32_1 = L_sub( tmp32_1, tmp32_2 ); } @@ -1726,7 +1727,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, tmp1 = round_fx( L_shl( tmp32, tmp2 ) ); #endif // s = sub(sub(sub(1, shl(s, 1)), 6/*table lookup for inverse framelength*/), tmp2); - s = sub( 25, add( shl( add( -2, s ), 1 ), tmp2 ) ); + s = sub( 25, add( shl( add( Q_syn, s ), 1 ), tmp2 ) ); tmp1 = Sqrt16( tmp1, &s ); move16(); level_syn = tmp1; /*Q0*/ @@ -1878,7 +1879,7 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) { tmp_shift = conceal_eof_gainFB_e; - synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), tmp_shift ) ); // Qx + synthFB[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( conceal_eof_gainFB, synthFB[i] ), tmp_shift ) ); // Q_syn move16(); conceal_eof_gainFB = BASOP_Util_Add_Mant32Exp( conceal_eof_gainFB, conceal_eof_gainFB_e, L_negate( stepFB ), stepFB_e, &conceal_eof_gainFB_e ); // Q: 31 - conceal_eof_gainFB_e } @@ -1890,11 +1891,6 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, hTcxDec->conceal_eof_gain32 = BASOP_Util_Add_Mant32Exp( hTcxDec->conceal_eof_gain32, hTcxDec->conceal_eof_gain_e, L_negate( step ), step_e, &hTcxDec->conceal_eof_gain_e ); move32(); } - Word32 temp = 0; - FOR( i = 0; i < hTcxDec->L_frameTCX; i++ ) - { - temp = L_add_sat( temp, abs( synthFB[i] ) ); - } /* run lpc gain compensation not for waveform adjustment */ test(); diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 7201bad8c..caa01e7de 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -2121,7 +2121,7 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig( synthFB_fx, synth_tmp, st->hTonalMDCTConc->nSamples, 2 ); TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synth_tmp, L_frameTCX[ch] ); } - decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, NULL, bfi, MCT_flag ); + decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_win, NULL, bfi, MCT_flag ); sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) ); IF( LT_16( sf, 2 ) ) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 7930720f3..407f6d68d 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -733,7 +733,7 @@ void stereo_tcx_core_dec_fx( TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB_fx, hTcxDec->L_frameTCX ); } - decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, Aq_fx, bfi, 0 ); + decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, 0, Aq_fx, bfi, 0 ); IF( EQ_16( st->core, TCX_20_CORE ) ) { -- GitLab