From 836824fdda922f165ad6ca47051bc9347298c6bc Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 24 Mar 2025 10:45:20 +0100 Subject: [PATCH 001/394] Added FIX_732, still work in progress --- lib_com/options.h | 1 + lib_dec/fd_cng_dec_fx.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 76bfee2ae..988f46280 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -66,6 +66,7 @@ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif +#define FIX_732 /* Eri: Fix for precision issue in CNG generation -- still work in progress */ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index c1289b8a3..574b63ab2 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1625,8 +1625,11 @@ Word16 ApplyFdCng_ivas_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } - +#ifdef FIX_732 + s2 = ( sub( WORD32_BITS, 1 ) ); +#else s2 = -( ( WORD32_BITS - 1 ) ); +#endif move16(); /* Shape the SID noise levels in each FFT bin */ j = 0; @@ -1666,7 +1669,11 @@ Word16 ApplyFdCng_ivas_fx( facTabExp[k] = -( ( WORD32_BITS - 1 ) ); move16(); } +#ifdef FIX_732 + s2 = s_min( s2, facTabExp[k] ); +#else s2 = s_max( s2, facTabExp[k] ); +#endif } if ( EQ_16( s2, -31 ) ) { @@ -1679,7 +1686,11 @@ Word16 ApplyFdCng_ivas_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { +#ifdef FIX_732 + cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } @@ -1701,7 +1712,11 @@ Word16 ApplyFdCng_ivas_fx( { IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { +#ifdef FIX_732 + s2 = ( sub( WORD32_BITS, 1 ) ); +#else s2 = -( ( WORD32_BITS - 1 ) ); +#endif /* Shape the SID noise levels in each FFT bin */ j = 0; move16(); @@ -1740,7 +1755,11 @@ Word16 ApplyFdCng_ivas_fx( facTabExp[k] = -( WORD32_BITS - 1 ); move16(); } +#ifdef FIX_732 + s2 = s_min( s2, facTabExp[k] ); +#else s2 = s_max( s2, facTabExp[k] ); +#endif } IF( EQ_16( s2, -31 ) ) { @@ -1753,7 +1772,11 @@ Word16 ApplyFdCng_ivas_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { +#ifdef FIX_732 + cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } -- GitLab From c30db7ccc5f31879c9bc68d757c2a5973fb8bffe Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 10:21:57 +0200 Subject: [PATCH 002/394] Fix for 3GPP issue 1348: Increased noise level in BASOP decoder for band-limited input from float encoder Link #1348 --- lib_com/options.h | 3 +- lib_dec/dec_tcx_fx.c | 79 ++++++++++++++++++++++++++++++++- lib_dec/hq_core_dec_fx.c | 4 ++ lib_dec/ivas_mdct_core_dec_fx.c | 12 +++++ lib_dec/stat_dec.h | 4 ++ 5 files changed, 99 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4f818e0c3..8fb6cf9df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -69,6 +69,5 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ //#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ +#define FIX_1348_BIT_PRECISION_IMPROVEMENT #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index af80ee1f5..7a8a24185 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2601,6 +2601,9 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 *q_old_out_fx, +#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, @@ -2862,9 +2865,16 @@ void IMDCT_ivas_fx( move16(); Word16 diff = sub( q_tmp_fx_32, q_win ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); +#endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); +#else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); +#endif move32(); } @@ -2872,7 +2882,11 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); +#else old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); +#endif xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); move16(); move16(); @@ -2880,7 +2894,12 @@ void IMDCT_ivas_fx( } ELSE { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Scale_sig32( x_fx, L_frame, 1 ); + q_xn_buf_fx_32 ++; +#else Word16 q_old_out = q_win; +#endif move16(); edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); Word16 res_m, res_e; @@ -2904,15 +2923,21 @@ void IMDCT_ivas_fx( move16(); } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, q_old_out_fx, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); +#else window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, &q_old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); q_diff = sub( q_old_out, q_win ); +#endif Word16 diff = sub( q_tmp_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); move16(); +#endif xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); move16(); } @@ -3004,9 +3029,18 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 tmp_old_out; + Word16 q_diff = sub( *q_old_out_fx, q_win ); +#endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // Q(-2) +#else xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) +#endif move16(); } @@ -3019,17 +3053,32 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // Q(-2) +#else xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) +#endif move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) +#else xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) +#endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) +#else xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) +#endif move16(); } } @@ -3037,12 +3086,22 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) +#else xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) +#endif move16(); } FOR( ; i < overlap; i++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) +#else xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) +#endif move16(); } } @@ -3091,7 +3150,9 @@ void IMDCT_ivas_fx( /* Compute windowed synthesis in case of switching to ALDO windows in next frame */ Copy( xn_buf_fx + sub( L_frame, nz ), old_out_fx, add( nz, overlap ) ); set16_fx( old_out_fx + add( nz, overlap ), 0, nz ); - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + *q_old_out_fx = q_win; +#endif tcx_windowing_synthesis_past_frame( old_out_fx + nz, tcx_aldo_window_1_trunc_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, hTcxCfg->tcx_curr_overlap_mode ); /* If current overlap mode = FULL_OVERLAP -> ALDO_WINDOW */ @@ -5196,7 +5257,11 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#endif } /* Generate additional comfort noise to mask potential coding artefacts */ @@ -5218,7 +5283,11 @@ void decoder_tcx_imdct_fx( Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); +#endif } FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) @@ -5235,13 +5304,21 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#endif } ELSE { IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); +#endif } FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 4d1ef6774..c4bbc3128 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1202,6 +1202,10 @@ void HQ_core_dec_init_fx( hHQ_core->Q_old_wtda = 15; hHQ_core->Q_old_postdec = 0; hHQ_core->Q_old_wtda_LB = 0; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->q_old_out_fx = 0; + hHQ_core->q_old_out_LB_fx = 0; +#endif move16(); move16(); move16(); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index fabebede4..6126ef44c 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1098,7 +1098,11 @@ void ivas_mdct_core_reconstruct_fx( Word16 *synthFB_fx; Word16 q_syn = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 q_win = -1; +#else Word16 q_win = -2; +#endif move16(); /* TCX */ Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2) @@ -1174,8 +1178,10 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_old_syn_Overl = q_win; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win +#endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win @@ -1206,6 +1212,10 @@ void ivas_mdct_core_reconstruct_fx( /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hHQ_core->q_old_out_LB_fx = 0; + st->hHQ_core->q_old_out_fx = 0; +#endif set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_OverlFB[0], 0, shr( L_frameTCX[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_Overl_TDAC[0], 0, shr( L_frame[ch], 1 ) ); @@ -1246,8 +1256,10 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn +#endif st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index fcd5142a4..62ffa15b5 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -702,6 +702,10 @@ typedef struct hq_dec_structure Word16 exp_old_out; Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ Word32 old_out_LB_fx32[L_FRAME32k]; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 q_old_out_LB_fx; + Word16 q_old_out_fx; +#endif Word16 q_old_outLB_fx; Word16 Q_old_wtda_LB; Word16 Q_old_wtda; -- GitLab From 2a410ea1499da320a900a8317e8ae681cd03719d Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 11:43:06 +0200 Subject: [PATCH 003/394] Applied formatting-fix.patch --- lib_dec/dec_tcx_fx.c | 14 +++++++------- lib_dec/ivas_mdct_core_dec_fx.c | 14 +++++++------- lib_dec/stat_dec.h | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 7a8a24185..e0dfcf2cb 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2872,7 +2872,7 @@ void IMDCT_ivas_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); -#else +#else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); #endif move32(); @@ -2896,7 +2896,7 @@ void IMDCT_ivas_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig32( x_fx, L_frame, 1 ); - q_xn_buf_fx_32 ++; + q_xn_buf_fx_32++; #else Word16 q_old_out = q_win; #endif @@ -3039,7 +3039,7 @@ void IMDCT_ivas_fx( tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // Q(-2) #else - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) #endif move16(); } @@ -3057,7 +3057,7 @@ void IMDCT_ivas_fx( tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // Q(-2) #else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) #endif move16(); } @@ -3067,7 +3067,7 @@ void IMDCT_ivas_fx( tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) #else - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) #endif move16(); } @@ -3090,7 +3090,7 @@ void IMDCT_ivas_fx( tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #endif move16(); } @@ -3100,7 +3100,7 @@ void IMDCT_ivas_fx( tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #else - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( old_out_fx[( i + nz )], tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #endif move16(); } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 6126ef44c..7459b3789 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1176,11 +1176,11 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win #endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win @@ -1213,7 +1213,7 @@ void ivas_mdct_core_reconstruct_fx( set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - st->hHQ_core->q_old_out_LB_fx = 0; + st->hHQ_core->q_old_out_LB_fx = 0; st->hHQ_core->q_old_out_fx = 0; #endif set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) ); @@ -1257,8 +1257,8 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn #endif st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 62ffa15b5..a32bcfd6e 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -702,7 +702,7 @@ typedef struct hq_dec_structure Word16 exp_old_out; Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ Word32 old_out_LB_fx32[L_FRAME32k]; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_old_out_LB_fx; Word16 q_old_out_fx; #endif -- GitLab From 59c183c9a1a4a3c4aaf4393b2ac487a68e48387f Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 12:03:46 +0200 Subject: [PATCH 004/394] Changed IMDCT_ivas_fx() declaration. --- lib_com/prot_fx.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ffd1d6032..114cc431c 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9848,6 +9848,9 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 *q_old_out_fx, +#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, -- GitLab From aafc14a191f2b7d81aaddfd5d10fc71a2b715b6d Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 13:52:20 +0200 Subject: [PATCH 005/394] Removed calculations using the dynamic q_old_out to check its effect on the pipeline tests. --- lib_com/options.h | 1 + lib_com/prot_fx.h | 2 +- lib_dec/dec_tcx_fx.c | 39 +++++++++++++++++---------------- lib_dec/hq_core_dec_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 6 ++--- lib_dec/stat_dec.h | 2 +- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 37634456b..b5a3bbb3e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,4 +79,5 @@ #define HARM_ENC_INIT //#define HARM_SCE_INIT #define FIX_1348_BIT_PRECISION_IMPROVEMENT +//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 114cc431c..78e9f96c9 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9848,7 +9848,7 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 *q_old_out_fx, #endif const Word16 FB_flag, diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e0dfcf2cb..f3c84770f 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2601,7 +2601,7 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, // Q(-2) -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 *q_old_out_fx, #endif const Word16 FB_flag, @@ -2865,12 +2865,12 @@ void IMDCT_ivas_fx( move16(); Word16 diff = sub( q_tmp_fx_32, q_win ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); #endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); #else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); @@ -2882,7 +2882,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); #else old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); @@ -2897,7 +2897,8 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig32( x_fx, L_frame, 1 ); q_xn_buf_fx_32++; -#else +#endif +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out = q_win; #endif move16(); @@ -2923,7 +2924,7 @@ void IMDCT_ivas_fx( move16(); } -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, q_old_out_fx, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); #else window_ola_fx( tmp_fx_32, xn_buf_fx, &q_tmp_fx_32, old_out_fx, &q_old_out, L_frame, hTcxCfg->tcx_last_overlap_mode, hTcxCfg->tcx_curr_overlap_mode, 0, 0, NULL ); @@ -2934,7 +2935,7 @@ void IMDCT_ivas_fx( Word16 diff = sub( q_tmp_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); move16(); #endif @@ -3029,13 +3030,13 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 tmp_old_out; Word16 q_diff = sub( *q_old_out_fx, q_win ); #endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // Q(-2) #else @@ -3053,7 +3054,7 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // Q(-2) #else @@ -3063,7 +3064,7 @@ void IMDCT_ivas_fx( } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) #else @@ -3073,7 +3074,7 @@ void IMDCT_ivas_fx( } FOR( ; i < tcx_mdct_window_min_length; i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) #else @@ -3086,7 +3087,7 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #else @@ -3096,7 +3097,7 @@ void IMDCT_ivas_fx( } FOR( ; i < overlap; i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #else @@ -3150,7 +3151,7 @@ void IMDCT_ivas_fx( /* Compute windowed synthesis in case of switching to ALDO windows in next frame */ Copy( xn_buf_fx + sub( L_frame, nz ), old_out_fx, add( nz, overlap ) ); set16_fx( old_out_fx + add( nz, overlap ), 0, nz ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD *q_old_out_fx = q_win; #endif tcx_windowing_synthesis_past_frame( old_out_fx + nz, tcx_aldo_window_1_trunc_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, hTcxCfg->tcx_curr_overlap_mode ); @@ -5257,7 +5258,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); @@ -5283,7 +5284,7 @@ void decoder_tcx_imdct_fx( Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); @@ -5304,7 +5305,7 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); @@ -5314,7 +5315,7 @@ void decoder_tcx_imdct_fx( { IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index c4bbc3128..7d2a3c7a5 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1202,7 +1202,7 @@ void HQ_core_dec_init_fx( hHQ_core->Q_old_wtda = 15; hHQ_core->Q_old_postdec = 0; hHQ_core->Q_old_wtda_LB = 0; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD hHQ_core->q_old_out_fx = 0; hHQ_core->q_old_out_LB_fx = 0; #endif diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 7459b3789..af37ce751 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1178,7 +1178,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_old_syn_Overl = q_win; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win #endif @@ -1212,7 +1212,7 @@ void ivas_mdct_core_reconstruct_fx( /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD st->hHQ_core->q_old_out_LB_fx = 0; st->hHQ_core->q_old_out_fx = 0; #endif @@ -1256,7 +1256,7 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn #endif diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index a32bcfd6e..84f8d83bd 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -702,7 +702,7 @@ typedef struct hq_dec_structure Word16 exp_old_out; Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ Word32 old_out_LB_fx32[L_FRAME32k]; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out_LB_fx; Word16 q_old_out_fx; #endif -- GitLab From c8695f623da545bf0acd7c6deea6cb33b268755e Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 14:30:19 +0200 Subject: [PATCH 006/394] Removed scaling of input in IMDCT_ivas_fx(). Activated dynamic q_old_out. Restored q_win to its previous value. --- lib_com/options.h | 4 ++-- lib_dec/dec_tcx_fx.c | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b5a3bbb3e..2b0a2ad0e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,6 +78,6 @@ #define HARM_PUSH_BIT #define HARM_ENC_INIT //#define HARM_SCE_INIT -#define FIX_1348_BIT_PRECISION_IMPROVEMENT -//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +//#define FIX_1348_BIT_PRECISION_IMPROVEMENT +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f3c84770f..f97455c65 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2894,10 +2894,6 @@ void IMDCT_ivas_fx( } ELSE { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig32( x_fx, L_frame, 1 ); - q_xn_buf_fx_32++; -#endif #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out = q_win; #endif -- GitLab From 384150d0cd440d404fa8fc264556268a084144c7 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 3 Apr 2025 15:18:59 +0200 Subject: [PATCH 007/394] Deactivated all changes to check the pipeline results. --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2b0a2ad0e..90138fe5e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,5 +79,5 @@ #define HARM_ENC_INIT //#define HARM_SCE_INIT //#define FIX_1348_BIT_PRECISION_IMPROVEMENT -#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #endif -- GitLab From 7e4ed16664a0de6dbddb31bd5f549d5e9280146e Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 4 Apr 2025 08:47:55 +0200 Subject: [PATCH 008/394] Activated q_win modification. --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 90138fe5e..b5a3bbb3e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,6 +78,6 @@ #define HARM_PUSH_BIT #define HARM_ENC_INIT //#define HARM_SCE_INIT -//#define FIX_1348_BIT_PRECISION_IMPROVEMENT +#define FIX_1348_BIT_PRECISION_IMPROVEMENT //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #endif -- GitLab From 9d4e2a2efa9dbcf38fd0f3ee9a35b1a4b91f62af Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 10 Apr 2025 11:49:14 +0200 Subject: [PATCH 009/394] Fixed an error in the transition from MDCT to ACELP --- lib_dec/ivas_mdct_core_dec_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index af37ce751..177f49180 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1264,6 +1264,9 @@ void ivas_mdct_core_reconstruct_fx( move16(); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Scale_sig( st->mem_syn2_fx, M, -1 ); // -1 should be calculated from q_win. +#endif } ELSE /*ACELP core for ACELP-PLC */ { -- GitLab From 8a71640db2e9a2f8f628f0e8254d0fbfb863c3b8 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 10 Apr 2025 11:54:03 +0200 Subject: [PATCH 010/394] Applied Clang formatting patch. --- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 177f49180..77673c3bb 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1265,7 +1265,7 @@ void ivas_mdct_core_reconstruct_fx( st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( st->mem_syn2_fx, M, -1 ); // -1 should be calculated from q_win. + Scale_sig( st->mem_syn2_fx, M, -1 ); // -1 should be calculated from q_win. #endif } ELSE /*ACELP core for ACELP-PLC */ -- GitLab From 8ddf7cffc690abab7f0c07a0f9cd849f8157536a Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 17 Apr 2025 10:48:53 +0200 Subject: [PATCH 011/394] Applied rounding to old_out. Deactivated q_win change and dynamic_q_old_out. --- lib_com/options.h | 3 ++- lib_dec/dec_tcx_fx.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8ee484111..e4ee8714b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -84,6 +84,7 @@ //#define HARM_SCE_INIT #define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ #define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ -#define FIX_1348_BIT_PRECISION_IMPROVEMENT +//#define FIX_1348_BIT_PRECISION_IMPROVEMENT //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f97455c65..e9d34660f 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2932,7 +2932,12 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF + old_out_fx[ind] = shr_r( old_out_fx[ind], q_diff ); +#else old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); +#endif move16(); #endif xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); -- GitLab From c703a1f62500154dc54f176bf33ca1fd69144076 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 17 Apr 2025 11:30:26 +0200 Subject: [PATCH 012/394] Replaced shr_r with shr_r_sat. Deactivated all changes. --- lib_com/options.h | 2 +- lib_dec/dec_tcx_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5caec3cdf..8540a9300 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,5 +99,5 @@ //#define FIX_1348_BIT_PRECISION_IMPROVEMENT //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD -#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF +//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index e9d34660f..56f2b2e6b 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2934,7 +2934,7 @@ void IMDCT_ivas_fx( #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF - old_out_fx[ind] = shr_r( old_out_fx[ind], q_diff ); + old_out_fx[ind] = shr_r_sat( old_out_fx[ind], q_diff ); #else old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); #endif -- GitLab From 6c3c58e60b677cdd1a2b4b9dd339c3c4c44f1fcf Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 23 Apr 2025 10:42:57 +0200 Subject: [PATCH 013/394] Make q_win dependent on multichannel mode to avoid saturation of downmix signals. --- lib_com/options.h | 4 ++-- lib_com/prot_fx.h | 3 +++ lib_dec/ivas_mct_dec_fx.c | 4 ++++ lib_dec/ivas_mdct_core_dec_fx.c | 10 +++++++++- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 62cf19b7c..1f0f7c641 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,7 +98,7 @@ #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ -//#define FIX_1348_BIT_PRECISION_IMPROVEMENT -//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#define FIX_1348_BIT_PRECISION_IMPROVEMENT +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 924a9955b..42fa6da76 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10004,6 +10004,9 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + const Word16 isParamMC, +#endif Word16 q_x, Word16 e_sig[CPE_CHANNELS] ); diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 32403b11a..058b57593 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -346,7 +346,11 @@ ivas_error ivas_mct_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, st_ivas->mc_mode == MC_MODE_PARAMMC, q_output, e_sig ); +#else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); +#endif Word16 hdrm, sh; hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 77673c3bb..6c527e9ce 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1083,6 +1083,9 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + const Word16 isParamMC, +#endif Word16 q_x, Word16 e_sig[CPE_CHANNELS] ) { @@ -1122,6 +1125,11 @@ void ivas_mdct_core_reconstruct_fx( bfi = sts[0]->bfi; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + if ( isParamMC ) + q_win = -2; +#endif + /* TNS, ITF, IMDCT and updates */ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -1265,7 +1273,7 @@ void ivas_mdct_core_reconstruct_fx( st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - Scale_sig( st->mem_syn2_fx, M, -1 ); // -1 should be calculated from q_win. + Scale_sig( st->mem_syn2_fx, M, sub( negate( q_win ), 2 ) ); #endif } ELSE /*ACELP core for ACELP-PLC */ diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 890e5fc9e..fd9398769 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -550,7 +550,11 @@ void stereo_mdct_core_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, st_ivas->mc_mode == MC_MODE_PARAMMC, Q11, e_sigFB ); +#else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, e_sigFB ); +#endif Copy32( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k ); /* Q11 */ Copy32( signal_out_tmp_fx[1], signal_out_fx[1], L_FRAME48k ); /* Q11 */ -- GitLab From 88b7a0ddcb1027f59e41c5fe146c96f0466fd8cb Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 23 Apr 2025 19:16:09 +0200 Subject: [PATCH 014/394] Change st->hHQ_core->Q_old_wtda_LB to st->hHQ_core->q_old_out_LB_fx since with FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD active it is not st->Q_syn anymore. Fixes TCX to ACELP transition. --- lib_dec/dec_tcx_fx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 56f2b2e6b..070d129c5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3686,10 +3686,17 @@ void decoder_tcx_ivas_fx( Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + st->hHQ_core->Q_old_wtda = st->hHQ_core->q_old_out_fx; + // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); + st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->q_old_out_LB_fx; + // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); +#else st->hHQ_core->Q_old_wtda = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); +#endif Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 st->hTcxDec->Q_old_syn_Overl = -2; } -- GitLab From 1b02d8c28c0816e04778013bce56b2dcaa8c7144 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 24 Apr 2025 23:54:38 +0200 Subject: [PATCH 015/394] Remove all q_old_out_something variables and use Q_old_wtda/Q_old_wtda_LB instead. Cleanup some not needed rescaling of old_out buffers. Resolves some regression cases. --- lib_dec/dec_tcx_fx.c | 21 +++++++++------------ lib_dec/hq_core_dec_fx.c | 4 ---- lib_dec/ivas_core_dec_fx.c | 2 ++ lib_dec/ivas_cpe_dec_fx.c | 2 ++ lib_dec/ivas_jbm_dec_fx.c | 7 ++++++- lib_dec/ivas_mdct_core_dec_fx.c | 16 ++++++++++------ lib_dec/ivas_post_proc_fx.c | 4 ++++ lib_dec/stat_dec.h | 10 ++++------ 8 files changed, 37 insertions(+), 29 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 070d129c5..fc8fda9ad 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3665,12 +3665,14 @@ void decoder_tcx_ivas_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDAC ) ); // Scaling to Q_syn st->hTcxDec->Q_syn_Overl_TDAC = st->Q_syn; move16(); - Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) ); // Scaling to Q_syn - Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q_syn +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, negate( st->hHQ_core->Q_old_wtda ) ); // Scaling to Q0 + Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, negate( st->hHQ_core->Q_old_wtda_LB ) ); // Scaling to Q0 st->hHQ_core->Q_old_wtda = 0; move16(); st->hHQ_core->Q_old_wtda_LB = 0; move16(); +#endif Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn st->hTcxDec->Q_old_syn_Overl = st->Q_syn; @@ -3686,12 +3688,7 @@ void decoder_tcx_ivas_fx( Scale_sig( synth_fx, L_frame_glob, negate( st->Q_syn ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, negate( st->Q_syn ) ); // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - st->hHQ_core->Q_old_wtda = st->hHQ_core->q_old_out_fx; - // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); - st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->q_old_out_LB_fx; - // Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); -#else +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD st->hHQ_core->Q_old_wtda = st->Q_syn; // Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, ( sub( st->hHQ_core->Q_old_wtda, st->Q_syn ) ) ); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; @@ -5267,7 +5264,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #endif @@ -5293,7 +5290,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->q_old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #endif @@ -5314,7 +5311,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif @@ -5324,7 +5321,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->q_old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 7d2a3c7a5..4d1ef6774 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1202,10 +1202,6 @@ void HQ_core_dec_init_fx( hHQ_core->Q_old_wtda = 15; hHQ_core->Q_old_postdec = 0; hHQ_core->Q_old_wtda_LB = 0; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - hHQ_core->q_old_out_fx = 0; - hHQ_core->q_old_out_LB_fx = 0; -#endif move16(); move16(); move16(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 320d9d4bc..12259f395 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -578,12 +578,14 @@ ivas_error ivas_core_dec_fx( /* TCX decoder */ Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, -st->hHQ_core->Q_old_wtda_LB ); // Q0 Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, -st->hHQ_core->Q_old_wtda ); // Q0 st->hHQ_core->Q_old_wtda_LB = 0; move16(); st->hHQ_core->Q_old_wtda = 0; move16(); +#endif IF( st_ivas == NULL ) { diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index c10c6beda..dcec695f3 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -132,7 +132,9 @@ ivas_error ivas_cpe_dec_fx( IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; +#endif move16(); } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3f67962dc..33d11d380 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -434,8 +434,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); +#endif } IF( hCPE->hStereoDft != NULL ) { @@ -950,8 +952,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); +#endif } IF( hCPE->hStereoDft != NULL ) { @@ -996,7 +1000,6 @@ ivas_error ivas_jbm_dec_tc_fx( IF( hCPE->hCoreCoder[0] != NULL ) { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda } @@ -1386,8 +1389,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); +#endif } IF( hCPE->hStereoDft != NULL ) { diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 6c527e9ce..243f6733b 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1186,9 +1186,13 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_old_syn_Overl = q_win; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + st->hHQ_core->Q_old_wtda = q_win; + move16(); + st->hHQ_core->Q_old_wtda_LB = q_win; + move16(); #endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win @@ -1220,9 +1224,9 @@ void ivas_mdct_core_reconstruct_fx( /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - st->hHQ_core->q_old_out_LB_fx = 0; - st->hHQ_core->q_old_out_fx = 0; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO + st->hHQ_core->Q_old_wtda = Q15; + st->hHQ_core->Q_old_wtda_LB = Q15; #endif set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) ); set16_fx( &st->hTcxDec->syn_OverlFB[0], 0, shr( L_frameTCX[ch], 1 ) ); @@ -1267,12 +1271,12 @@ void ivas_mdct_core_reconstruct_fx( #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn -#endif st->hHQ_core->Q_old_wtda = st->Q_syn; move16(); st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->mem_syn2_fx, M, sub( negate( q_win ), 2 ) ); #endif } diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index c0e69b916..b82cc1d00 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -588,7 +588,11 @@ void stereo_dft_dec_core_switching_fx( Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_wtda_LB; +#else hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx; +#endif move16(); test(); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 84f8d83bd..9d6f49436 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -698,15 +698,13 @@ typedef struct hq_nbfec_structure typedef struct hq_dec_structure { Word32 old_out_fx32[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ - Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA */ + Word16 old_out_fx[L_FRAME48k]; /* HQ core - previous synthesis for OLA. Q_old_wtda */ Word16 exp_old_out; - Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band */ + Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band. Q_old_wtda_LB */ Word32 old_out_LB_fx32[L_FRAME32k]; -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Word16 q_old_out_LB_fx; - Word16 q_old_out_fx; -#endif +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_old_outLB_fx; +#endif Word16 Q_old_wtda_LB; Word16 Q_old_wtda; Word16 Q_old_postdec; /*scaling of the output of core_switching_post_dec_fx() */ -- GitLab From e3ee7268a49054531e72ed23706a7a6596b03920 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Fri, 25 Apr 2025 00:41:17 +0200 Subject: [PATCH 016/394] clang format --- lib_dec/ivas_core_dec_fx.c | 4 ++-- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 12259f395..e4d54a72c 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -576,8 +576,8 @@ ivas_error ivas_core_dec_fx( move32(); /* TCX decoder */ - Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 - Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 + Scale_sig( st->hPFstat->mem_stp, L_SUBFR, -Qsyn_temp ); // Q0 + Scale_sig( st->hPFstat->mem_pf_in, L_SUBFR, -Qsyn_temp ); // Q0 #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, -st->hHQ_core->Q_old_wtda_LB ); // Q0 Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, -st->hHQ_core->Q_old_wtda ); // Q0 diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 243f6733b..fc757feec 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1184,8 +1184,8 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD -- GitLab From 868dd2439660c01d806e5264ee392e873ce51a35 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Apr 2025 17:12:17 +0200 Subject: [PATCH 017/394] add DISABLE_LIMITER switch and framesize-be test --- .gitlab-ci.yml | 46 +++++++++++++++++++++++++++++++++++++++++++++ lib_com/options.h | 2 ++ lib_rend/lib_rend.c | 4 ++++ 3 files changed, 52 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a00af3162..36768312d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -998,6 +998,52 @@ check-regressions-short-dec--10db: # -10dB LEVEL_SCALING: "0.3162" +check-be-between-renderer-framesizes: + extends: + - .test-job-linux + - .rules-pytest-to-main-short + stage: test + needs: ["build-codec-linux-cmake", "build-codec-linux-make", "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] + script: + - *print-common-info + - *disable-limiter + - *build-float-ref-and-dut-binaries + - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" + + - python3 -m pytest --update_ref 1 "$pytest_args" + + - exit_code=0 + - exit_code5=0 + - exit_code10=0 + - python3 -m pytest $pytest_args --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? + - python3 -m pytest $pytest_args --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only || exit_code10=$? + + - zero_errors5=$(cat report-junit-5ms.xml | grep -c 'errors="0"') || true + - zero_errors10=$(cat report-junit-10ms.xml | grep -c 'errors="0"') || true + - zero_errors=1 + + - if [ $zero_errors5 != 1 ]; then echo "run error in with 5ms rendering encountered"; zero_errors=0 ; fi + - if [ $zero_errors10 != 1 ]; then echo "run error in with 10ms rendering encountered"; zero_errors=0 ; fi + - if [ $zero_errors != 1 ]; then exit $EXIT_CODE_FAIL; fi + - if [ $exit_code5 -ne 0 ]; then echo "Non-bitexact cases encountered with 5ms rendering!"; exit_code=1; fi + - if [ $exit_code10 -ne 0 ]; then echo "Non-bitexact cases encountered with 10ms rendering!"; exit_code=1; fi + - if [ $exit_code -ne 0 ]; then exit $EXIT_CODE_FAIL; fi + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" + expire_in: 1 week + when: always + expose_as: "pytest 5ms and 10ms vs 20ms results" + paths: + - report-junit-5ms.xml + - report-5ms.html + - report-junit-10ms.xml + - report-10ms.html + reports: + junit: + - report-junit-5ms.xml + - report-junit-10ms.xml + + # --------------------------------------------------------------- # Short test jobs for running from web interface or schedule # --------------------------------------------------------------- diff --git a/lib_com/options.h b/lib_com/options.h index cbc77b6e7..646bb3ff2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -61,6 +61,8 @@ /*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif +#define DISABLE_LIMITER + /* #################### End DEBUGGING switches ############################ */ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e39b9a61e..6f85b8fa0 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -350,6 +350,7 @@ static void accumulate2dArrayToBuffer_fx( * In-place saturation control for multichannel buffers with adaptive release time *-------------------------------------------------------------------*/ +#ifndef DISABLE_LIMITER /*! r: number of clipped output samples */ static Word32 limitRendererOutput_fx( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ @@ -393,6 +394,7 @@ static Word32 limitRendererOutput_fx( return numClipping; } +#endif /*-------------------------------------------------------------------* * validateOutputAudioConfig() @@ -7361,7 +7363,9 @@ static ivas_error getSamplesInternal( test(); Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); +#ifndef DISABLE_LIMITER limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); +#endif /* update global cominbed orientation start index */ ivas_combined_orientation_update_start_index( hIvasRend->hCombinedOrientationData, outAudio.config.numSamplesPerChannel ); -- GitLab From 7f31b3174b49885e497b851597fff9d564358bea Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Apr 2025 17:16:35 +0200 Subject: [PATCH 018/394] fix CI setup --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36768312d..41a138d6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1003,7 +1003,7 @@ check-be-between-renderer-framesizes: - .test-job-linux - .rules-pytest-to-main-short stage: test - needs: ["build-codec-linux-cmake", "build-codec-linux-make", "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] + needs: ["build-codec-linux-make"] script: - *print-common-info - *disable-limiter -- GitLab From 662aeb4527ead3e2234e0f3da87cccc0dcd284ed Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Apr 2025 17:23:28 +0200 Subject: [PATCH 019/394] deactivate DISABLE_LIMITER --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 646bb3ff2..673fcae4d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -61,7 +61,7 @@ /*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif -#define DISABLE_LIMITER +/*#define DISABLE_LIMITER*/ /* #################### End DEBUGGING switches ############################ */ -- GitLab From 4c94d705e6fa65644ee7c3cfa96abb203bab1326 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Apr 2025 17:13:52 +0200 Subject: [PATCH 020/394] [revert-me] point to wip branch in ci repo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 41a138d6a..53ec5f6e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 4eb4c0dfbdc845280a9994b5f7540f69c737537b + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF framesize-be-test-to-basop include: - local: .gitlab-ci/variables.yml -- GitLab From 415250fa874a2d32b875482cc3f8a252dda0d047 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Apr 2025 17:15:53 +0200 Subject: [PATCH 021/394] use snippets instead of yaml anchors --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 53ec5f6e5..e4c552cde 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1005,9 +1005,9 @@ check-be-between-renderer-framesizes: stage: test needs: ["build-codec-linux-make"] script: - - *print-common-info - - *disable-limiter - - *build-float-ref-and-dut-binaries + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" - python3 -m pytest --update_ref 1 "$pytest_args" -- GitLab From 464e2f9c571f72e814b6a2285a94b75b66d9faec Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Apr 2025 19:02:02 +0200 Subject: [PATCH 022/394] use commit sha instead of branch name --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4c552cde..f3adb0c7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF framesize-be-test-to-basop + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 74a8d426730ed21183fe047503e7097262fcb796 include: - local: .gitlab-ci/variables.yml -- GitLab From a0344f22fb0744054e98f0a5c142e302e4cea783 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Sun, 27 Apr 2025 11:25:35 +0200 Subject: [PATCH 023/394] Add changes back and forth to q_old_outLB_fx/Q_old_wtda_LB again, the assumption that this does not have an effect was wrong. --- lib_dec/ivas_jbm_dec_fx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 33d11d380..e313304e2 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -434,7 +434,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; + move16(); +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); #endif @@ -952,7 +955,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; + move16(); +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); #endif @@ -1389,7 +1395,10 @@ ivas_error ivas_jbm_dec_tc_fx( { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; + move16(); +#else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; move16(); #endif -- GitLab From 7d21ca8a794b7ff59fa8b2b2ec43c102e0d52f38 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 28 Apr 2025 07:23:59 +0200 Subject: [PATCH 024/394] fix build for framesize-be-test --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3adb0c7a..8589c4094 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1007,7 +1007,8 @@ check-be-between-renderer-framesizes: script: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh + - make clean + - make -j "${nproc}" - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" - python3 -m pytest --update_ref 1 "$pytest_args" -- GitLab From 9c50097157b901617b3818c75a642b40e2bb6461 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 27 Apr 2025 09:46:59 +0200 Subject: [PATCH 025/394] Attempt to fix missing rules and missing fetch of ci scripts --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8589c4094..5b77d3bb8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,8 @@ workflow: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" IMAGES_ARTIFACT_SPLIT: "images_split_$CI_JOB_NAME" script: + - !reference [ .job-linux, before_script ] + - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh @@ -318,6 +320,7 @@ workflow: .check-be-job: extends: - .test-job-linux + - .rules-pytest-to-main-short before_script: - !reference [ .test-job-linux, before_script ] - rm -rf tests/dut tests/ref -- GitLab From 0fd4d559f75ae967d5631610db971302b2d42596 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 27 Apr 2025 20:59:49 +0200 Subject: [PATCH 026/394] Add fix to pages job --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b77d3bb8..596c973b9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1977,6 +1977,8 @@ pages: rules: - if: $UPDATE_PAGES script: + - !reference [ .job-linux, before_script ] + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - python3 ci/setup_pages.py -- GitLab From 0987e660e150af270960c3918893964a01d4be6e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 25 Apr 2025 11:57:02 +0530 Subject: [PATCH 027/394] Fix for 3GPP issue 1508: BASOP decoder asserts in ivas_wb_tbe_dec_fx with OMASA FER bitstream from BASOP encoder Link #1508 --- lib_com/swb_tbe_com_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 5f391b271..5631dfa94 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -1645,7 +1645,12 @@ void GenShapedWBExcitation_ivas_fx( } } - Syn_filt_s( 0, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); + Scale_sig( state_lpc_syn, LPC_SHB_ORDER, -Q2 ); /* Q(Q_bwe_exc) -> Q(Q_bwe_exc - 2) */ + + Syn_filt_s( Q2, lpc_shb, LPC_SHB_ORDER_WB, exc4kWhtnd, excSHB, L_FRAME16k / 4, state_lpc_syn, 1 ); + + Scale_sig( state_lpc_syn, LPC_SHB_ORDER, Q2 ); /* Q(Q_bwe_exc - 2) -> Q(Q_bwe_exc) */ + Scale_sig( excSHB, L_FRAME16k / 4, Q2 ); /* Q(Q_bwe_exc - 2) -> Q(Q_bwe_exc) */ return; } -- GitLab From 9cc2505f643f0a6f765e283f4ab2939cca604134 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 28 Apr 2025 08:50:42 +0530 Subject: [PATCH 028/394] Fix for renderer crashes in CI ltv test --- lib_rend/ivas_dirac_rend_fx.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 2540426cc..06b37ff5a 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -5007,10 +5007,20 @@ static void ivas_masa_ext_dirac_render_sf_fx( ELSE { /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ + /* cldfb_state_fx should be in 1 less q-factor compared to cld buffers for cldfbSynthesis_ivas_fx function */ Word16 q_out = sub( q_cldfb, 1 ); - scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); // q_out - hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out; - move16(); + Word16 max_shift = L_norm_arr( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length ); + IF( GT_16( max_shift, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ) ) + { + scale_sig32( hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_fx, hMasaExtRend->cldfbSynRend[idx_in]->cldfb_state_length, sub( q_out, hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state ) ); // q_out + hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state = q_out; + move16(); + } + ELSE + { + scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + } FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { RealBuffer_fx[i] = Cldfb_RealBuffer_fx[idx_in][i]; // q_cldfb -- GitLab From 877a75aace513c106243d92e10938e4c034d516b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 28 Apr 2025 08:12:38 +0200 Subject: [PATCH 029/394] remove nproc again --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 596c973b9..945de8500 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1011,7 +1011,7 @@ check-be-between-renderer-framesizes: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh - make clean - - make -j "${nproc}" + - make -j - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" - python3 -m pytest --update_ref 1 "$pytest_args" -- GitLab From f17a648cd92bad1c20c46971eb9fd9b98097f182 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 28 Apr 2025 17:37:40 +0530 Subject: [PATCH 030/394] Fix for 3GPP issue 1524: BASOP decoder asserts in ivas_dirac_dec_binaural_determine_processing_matrices_fx with OMASA BASOP encoder bitstream using rate switching Link #1524 --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 922a4ef12..412b8c226 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2096,6 +2096,21 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( exp = sub( get_min_scalefactor( resultMtxRe_fx[0][0], resultMtxRe_fx[1][1] ), 2 ); tmp2 = L_add( L_shl( resultMtxRe_fx[0][0], exp ), L_shl( resultMtxRe_fx[1][1], exp ) ); q_tmp2 = add( q_res, exp ); + + /*Limiting value to Q63*/ + IF( GT_16( q_tmp2, 63 ) ) + { + tmp2 = L_shl( tmp2, sub( 63, q_tmp2 ) ); + q_tmp2 = 63; + move16(); + IF( EQ_32( tmp2, -1 ) ) + { + tmp2 = 0; + move32(); + q_tmp2 = 31; + move16(); + } + } IF( LT_16( q_CrEne, q_tmp2 ) ) { realizedOutputEne_fx = L_add( tmp1, L_shr( tmp2, sub( q_tmp2, q_CrEne ) ) ); -- GitLab From f612e8ac248e91898b76604b7e77fef0e9f900af Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 28 Apr 2025 17:23:12 +0530 Subject: [PATCH 031/394] Complexity measure crash fix for ltv48_STEREO_StereoDmxEvs_b07_16_dtx_wb_rs_fer_ep_10pct_fer_g192 --- lib_dec/igf_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 0010b9466..aa3f35b26 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -244,7 +244,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15 - g = shl( g, 1 ); // Q16 + g = shl_sat( g, 1 ); // Q16 FOR( sb = start; sb < stop; sb++ ) { -- GitLab From 9da25323dad175bfcd4f8324dfb806f16ec9cc02 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 28 Apr 2025 17:28:03 +0530 Subject: [PATCH 032/394] Clang formatting changes --- lib_dec/igf_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index aa3f35b26..511d8a977 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -244,7 +244,7 @@ static void IGF_replaceTCXNoise_2( Word32 *in, /**< in g = getSqrtWord32( L_mult( divide3232( totalNoiseNrg, rE ), 8192 /*1.0f / 4.0f Q15*/ ) ); // ((Q15 + Q15 + Q1) / 2) -> Q15 - g = shl_sat( g, 1 ); // Q16 + g = shl_sat( g, 1 ); // Q16 FOR( sb = start; sb < stop; sb++ ) { -- GitLab From 46b0f8045f18cf29b007a5a72378eac94f8b9552 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 28 Apr 2025 19:24:51 +0530 Subject: [PATCH 033/394] Q related fixed for encoder transition and decoder msan fixes --- lib_dec/ivas_mct_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 2 ++ lib_enc/acelp_enc_util_fx.c | 12 ++++++------ lib_enc/enc_tran_fx.c | 3 ++- lib_enc/ivas_core_pre_proc_fx.c | 7 ++----- lib_enc/transition_enc_fx.c | 16 ++-------------- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 058b57593..bb985ac7b 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -402,7 +402,7 @@ ivas_error ivas_mct_dec_fx( test(); IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) ) { - Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], L_FRAME48k, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11 + Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], output_frame, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11 Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) ); ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 ); Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( sub( 15, e_sig[n] ), Q11 ) ); // Q0 diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index e82005965..8035af217 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -102,6 +102,8 @@ void stereo_dft_unify_dmx_fx( Word16 num_plocs; Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX]; + set32_fx( DFT_PRED_RES, 0, STEREO_DFT32MS_N_32k ); + output_frame = extract_l( Mult_32_16( st0->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */ samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); diff --git a/lib_enc/acelp_enc_util_fx.c b/lib_enc/acelp_enc_util_fx.c index 181583e91..7f57b55da 100644 --- a/lib_enc/acelp_enc_util_fx.c +++ b/lib_enc/acelp_enc_util_fx.c @@ -180,9 +180,9 @@ void E_ACELP_conv( } void E_ACELP_conv_ivas_fx( - const Word16 xn2[], /* i Qx*/ + const Word16 xn2[], /* i Qnew - 1*/ const Word16 h2[], /* i Q12*/ - Word16 cn2[] /* o Q0*/ + Word16 cn2[] /* o Qnew*/ ) { Word16 i, k; @@ -194,14 +194,14 @@ void E_ACELP_conv_ivas_fx( { /*cn2[k] = xn2[k]; */ Word64 L_tmp_64; - L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* 4Q11 */ + L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) ); /* Qnew -1 + 12 */ FOR( i = 0; i < k; i++ ) { /*cn2[k]-=cn2[i]*h2[k-i];*/ - L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/ + L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*Qnew + 11*/ } - L_tmp = W_sat_l( L_tmp_64 ); /* 4Q11 */ - cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Q0*/ + L_tmp = W_sat_l( L_tmp_64 ); /* Qnew + 11 */ + cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow ); /* Qnew*/ move16(); } } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 394b22c30..f308e9e87 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -545,7 +545,7 @@ Word16 encod_tran_ivas_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ - find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); @@ -555,6 +555,7 @@ Word16 encod_tran_ivas_fx( #else Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) ); #endif + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 6fe6b6720..5853e2739 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1174,11 +1174,8 @@ ivas_error ivas_compute_core_buffers_fx( ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); - IF( Q_new ) - { - st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) - move16(); - } + st->exp_old_inp_16k = sub(Q16, *Q_new); //(*Q_new - 1) + move16(); } ELSE IF( GT_32( input_Fs, 8000 ) ) { diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 5e50cac15..c724ffd6c 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -924,8 +924,6 @@ void transition_enc_ivas_fx( /* set limit_flag to 0 for restrained limits, and 1 for extended limits */ limit_flag = 0; move16(); - Word16 h1_fx_q15[L_SUBFR + ( M + 1 )]; - Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 0 ); pit_start = PIT_MIN; move16(); @@ -1443,12 +1441,7 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) ); move16(); -#ifdef TEST_HR - Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) ); -#else - Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); -#endif - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) @@ -1684,12 +1677,7 @@ void transition_enc_ivas_fx( *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new ); move16(); -#ifdef TEST_HR - Copy( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ) ); -#else - Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 ); -#endif - lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15, + lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx, xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag ); IF( EQ_16( lp_flag, NORMAL_OPERATION ) ) { -- GitLab From a0f7b9ad985fb60dfa47e5057f2afb1b76ccad9d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 29 Apr 2025 08:11:58 +0530 Subject: [PATCH 034/394] Clang formatting changes --- lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 2 +- lib_enc/enc_tran_fx.c | 2 +- lib_enc/ivas_core_pre_proc_fx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 8035af217..cdb64e46c 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -103,7 +103,7 @@ void stereo_dft_unify_dmx_fx( Word32 plocsi[STEREO_DFT_RES_N_PEAKS_MAX]; set32_fx( DFT_PRED_RES, 0, STEREO_DFT32MS_N_32k ); - + output_frame = extract_l( Mult_32_16( st0->output_Fs, INV_FRAME_PER_SEC_Q15 ) ); /* Q0 */ samp_ratio = BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index f308e9e87..865972819 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -546,7 +546,7 @@ Word16 encod_tran_ivas_fx( Copy( &res_fx[i_subfr], &exc_fx[i_subfr], L_SUBFR ); /* Q_new */ find_targets_ivas_new_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 5853e2739..e2c099cd2 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1174,7 +1174,7 @@ ivas_error ivas_compute_core_buffers_fx( ELSE IF( GT_32( input_Fs, 8000 ) && EQ_32( sr_core, INT_FS_16k ) ) { Copy( &old_inp_16k_fx[L_frame_tmp], st->old_inp_16k_fx, L_INP_MEM ); - st->exp_old_inp_16k = sub(Q16, *Q_new); //(*Q_new - 1) + st->exp_old_inp_16k = sub( Q16, *Q_new ); //(*Q_new - 1) move16(); } ELSE IF( GT_32( input_Fs, 8000 ) ) -- GitLab From 9585f03fd4c0c025d93f27d25a928098c5413bc5 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 29 Apr 2025 08:22:37 +0200 Subject: [PATCH 035/394] update CI ref --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 364e522aa..59c8d2b72 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 4eb4c0dfbdc845280a9994b5f7540f69c737537b + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 7c6b6f261883e282ebe050e18d48c00ce623b8be include: - local: .gitlab-ci/variables.yml -- GitLab From 7748c9d9bb56bbaedff4f11201382a04a6215546 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 29 Apr 2025 08:50:20 +0200 Subject: [PATCH 036/394] update commit to point to CI repo main --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59c8d2b72..4b7d05c7b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 7c6b6f261883e282ebe050e18d48c00ce623b8be + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF f5e61349c22ededcdfe1cc54e533dea477f2d003 include: - local: .gitlab-ci/variables.yml -- GitLab From ac17f4d1fe6fa8764b0b681ccacf6e0fd15a3372 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 29 Apr 2025 08:01:15 +0200 Subject: [PATCH 037/394] add missing reference to common before_script section --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b7d05c7b..1f5a98321 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1596,6 +1596,7 @@ voip-be-on-merge-request: GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: + - !reference [ .job-linux, before_script ] - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh -- GitLab From d2434f48518de163574aec2ab0e3dc8d9497464f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Tue, 29 Apr 2025 01:21:37 +0200 Subject: [PATCH 038/394] Inherit before_script from .test-job-linux --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f5a98321..bb2259810 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1596,7 +1596,7 @@ voip-be-on-merge-request: GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: - - !reference [ .job-linux, before_script ] + - !reference [ .test-job-linux, before_script ] - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh -- GitLab From e5640c2b37ba403cd4195e4468de87561facdde4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 29 Apr 2025 14:54:13 +0530 Subject: [PATCH 039/394] Fix for 3GPP issue 1525: Second channel of BASOP decoder MASA format output to FOA has missing energy or wrong signal Link #1525 --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 509eec6e2..37b5f1e05 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2134,9 +2134,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); } - subtract_power_y = masa_stereo_type_detect->subtract_power_y_fx; // q_subtract_power_y - move32(); - a = 858993; /* ( 0.0004f in Q31 ); Temporal smoothing coefficient */ move32(); b = L_sub( ONE_IN_Q31, a ); /* Temporal smoothing coefficient */ @@ -2152,24 +2149,42 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); masa_stereo_type_detect->q_target_power_y_smooth = q_com; move16(); - masa_stereo_type_detect->subtract_power_y_smooth_fx = - L_add( Mpy_32_32( a, subtract_power_y ), - Mpy_32_32( b, masa_stereo_type_detect->subtract_power_y_smooth_fx ) ); //(Q31, q_subtract_power_y) -> q_subtract_power_y + + IF( NE_16( masa_stereo_type_detect->q_subtract_power_y, masa_stereo_type_detect->q_subtract_power_y_smooth ) ) + { + exp = s_min( add( masa_stereo_type_detect->q_subtract_power_y, norm_l( masa_stereo_type_detect->subtract_power_y_fx ) ), add( masa_stereo_type_detect->q_subtract_power_y_smooth, norm_l( masa_stereo_type_detect->subtract_power_y_smooth_fx ) ) ); + masa_stereo_type_detect->subtract_power_y_fx = L_shl( masa_stereo_type_detect->subtract_power_y_fx, sub( exp, masa_stereo_type_detect->q_subtract_power_y ) ); + move32(); + masa_stereo_type_detect->subtract_power_y_smooth_fx = L_shl( masa_stereo_type_detect->subtract_power_y_smooth_fx, sub( exp, masa_stereo_type_detect->q_subtract_power_y_smooth ) ); + move32(); + masa_stereo_type_detect->q_subtract_power_y = exp; + move16(); + masa_stereo_type_detect->q_subtract_power_y_smooth = exp; + move16(); + } + subtract_power_y = masa_stereo_type_detect->subtract_power_y_fx; // q_subtract_power_y move32(); + W_temp = W_add( W_mult0_32_32( a, subtract_power_y ), W_mult0_32_32( b, masa_stereo_type_detect->subtract_power_y_smooth_fx ) ); // Q31 + masa_stereo_type_detect->q_subtract_power_y_smooth + exp = W_norm( W_temp ); + masa_stereo_type_detect->subtract_power_y_smooth_fx = W_extract_h( W_shl( W_temp, exp ) ); // Q31 + masa_stereo_type_detect->q_subtract_power_y_smooth + exp - 32 + move32(); + masa_stereo_type_detect->q_subtract_power_y_smooth = sub( add( masa_stereo_type_detect->q_subtract_power_y_smooth, exp ), 1 ); + move16(); + exp = 0; move16(); IF( masa_stereo_type_detect->target_power_y_smooth_fx != 0 ) { subtract_target_ratio = L_sub( BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ), BASOP_Util_Log2( masa_stereo_type_detect->target_power_y_smooth_fx ) ); // Q25 - exp = sub( masa_stereo_type_detect->q_subtract_power_y, q_com ); + exp = sub( masa_stereo_type_detect->q_subtract_power_y_smooth, q_com ); L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ); // Q25 } ELSE { subtract_target_ratio = BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ); // Q25 - exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y ); + exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y_smooth ); L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25 } subtract_target_ratio_db = Mpy_32_32( 1342177280 /* 10.0f * in Q27*/, L_tmp ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21 @@ -2178,6 +2193,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move32(); masa_stereo_type_detect->subtract_power_y_fx = 0; move32(); + masa_stereo_type_detect->q_subtract_power_y = Q31; + move16(); } /*-----------------------------------------------------------------* -- GitLab From 9b20d04ce34cdf85e5e838a3ac26daba4d05e418 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 29 Apr 2025 23:34:46 +0200 Subject: [PATCH 040/394] Correct value of q_ap_fade_mem_fx. Add Q_old_out_fx32 to represent Q of 32 bit versions of out_old buffers and avoid mixing it with 16 bit versions. --- lib_dec/hq_core_dec_fx.c | 4 ++++ lib_dec/ivas_core_dec_fx.c | 8 ++++++++ lib_dec/ivas_cpe_dec_fx.c | 6 ++++-- lib_dec/ivas_jbm_dec_fx.c | 15 ++++++--------- lib_dec/ivas_mdct_core_dec_fx.c | 3 ++- lib_dec/ivas_post_proc_fx.c | 2 +- lib_dec/ivas_stereo_switching_dec_fx.c | 3 +++ lib_dec/stat_dec.h | 4 +++- 8 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lib_dec/hq_core_dec_fx.c b/lib_dec/hq_core_dec_fx.c index 4d1ef6774..453b89924 100644 --- a/lib_dec/hq_core_dec_fx.c +++ b/lib_dec/hq_core_dec_fx.c @@ -1205,6 +1205,10 @@ void HQ_core_dec_init_fx( move16(); move16(); move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif hHQ_core->last_hq_core_type = -1; /* Q0 */ move16(); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 6ca2982f5..a27213b6e 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -337,6 +337,10 @@ ivas_error ivas_core_dec_fx( Copy_Scale_sig_16_32_no_sat( sts[0]->hHQ_core->old_out_LB_fx, sts[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, sts[0]->hHQ_core->Q_old_wtda_LB ) ); // Q11 L_lerp_fx_q11( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->L_frame, sts[0]->last_L_frame ); Copy_Scale_sig_32_16( sts[0]->hHQ_core->old_out_LB_fx32, sts[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( sts[0]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + sts[0]->hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif } IF( NE_16( sts[0]->L_frame, L_FRAME16k ) ) { @@ -1403,6 +1407,10 @@ ivas_error ivas_core_dec_fx( { Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, st->hHQ_core->Q_old_wtda_LB ) ); // Q11 Copy_Scale_sig_16_32_no_sat( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_fx32, L_FRAME48k, sub( Q11, st->hHQ_core->Q_old_wtda ) ); // Q11 +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hHQ_core->Q_old_out_fx32 = Q11; + move16(); +#endif } IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index dcec695f3..ba63d8e8a 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -132,7 +132,9 @@ ivas_error ivas_cpe_dec_fx( IF( hCPE->hCoreCoder[ind1]->hHQ_core ) { Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( Q11, hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB ) ); // Q11 -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_out_fx32 = Q11; +#else hCPE->hCoreCoder[ind1]->hHQ_core->q_old_outLB_fx = Q11; #endif move16(); @@ -157,7 +159,7 @@ ivas_error ivas_cpe_dec_fx( test(); IF( hCPE->hCoreCoder[ind1] && hCPE->hCoreCoder[ind1]->hHQ_core ) { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda + Copy_Scale_sig_32_16( hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[ind1]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[ind1]->hHQ_core->Q_old_wtda_LB, Q11 ) ); // Q_old_wtda_LB } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e313304e2..22c9423bf 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -435,12 +435,11 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; - move16(); + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; #else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - move16(); #endif + move16(); } IF( hCPE->hStereoDft != NULL ) { @@ -956,12 +955,11 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; - move16(); + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; #else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - move16(); #endif + move16(); } IF( hCPE->hStereoDft != NULL ) { @@ -1396,12 +1394,11 @@ ivas_error ivas_jbm_dec_tc_fx( Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB = q; - move16(); + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; #else hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; - move16(); #endif + move16(); } IF( hCPE->hStereoDft != NULL ) { diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index fc757feec..c180426f1 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1277,7 +1277,8 @@ void ivas_mdct_core_reconstruct_fx( move16(); #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Scale_sig( st->mem_syn2_fx, M, sub( negate( q_win ), 2 ) ); + Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); + //Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index b82cc1d00..4232116fa 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -589,7 +589,7 @@ void stereo_dft_dec_core_switching_fx( Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_wtda_LB; + hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32; #else hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx; #endif diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 677c91ef0..454395648 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -418,6 +418,7 @@ ivas_error stereo_memory_dec_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { + assert( hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 == hCPE->hCoreCoder[1]->hHQ_core->Q_old_out_fx32 ); v_add_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[1]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ @@ -2149,6 +2150,8 @@ void stereo_td2dft_update_fx( move16(); /* update buffers used for fading when switching to DFT Stereo */ + assert( sts[0]->hHQ_core->Q_old_out_fx32 == sts[1]->hHQ_core->Q_old_out_fx32 ); + v_add_fx( sts[0]->hHQ_core->old_out_LB_fx32 + nsLB, sts[1]->hHQ_core->old_out_LB_fx32 + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); FOR( i = 0; i < old_outLB_len; i++ ) diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 9d6f49436..2749c06b4 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -702,7 +702,9 @@ typedef struct hq_dec_structure Word16 exp_old_out; Word16 old_out_LB_fx[L_FRAME32k]; /* HQ core - previous synthesis for OLA for Low Band. Q_old_wtda_LB */ Word32 old_out_LB_fx32[L_FRAME32k]; -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Word16 Q_old_out_fx32; /* Q for both old_out_fx32 and old_out_LB_fx32 */ +#else Word16 q_old_outLB_fx; #endif Word16 Q_old_wtda_LB; -- GitLab From aecbdde8f450dfaa1f8d679190175a0f29cf28c8 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 29 Apr 2025 23:40:04 +0200 Subject: [PATCH 041/394] clang format --- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index c180426f1..d8c64d516 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1278,7 +1278,7 @@ void ivas_mdct_core_reconstruct_fx( #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); - //Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn + // Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ -- GitLab From 5c45d51c5ba179a99a9e56f371ab255fcf3f87ac Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 10:52:28 +0200 Subject: [PATCH 042/394] Add macro FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN to make q_win value variable for the ivas_mdct_core_reconstruct_fx() data path, but not decoder_tcx_ivas_fx() for now. --- lib_com/ivas_prot_fx.h | 4 + lib_com/options.h | 1 + lib_com/prot_fx.h | 13 +- lib_dec/dec_tcx_fx.c | 545 ++++++++++++++++++++++++- lib_dec/er_dec_acelp_fx.c | 8 +- lib_dec/er_dec_tcx_fx.c | 10 + lib_dec/ivas_mct_dec_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 42 +- lib_dec/ivas_post_proc_fx.c | 1 + lib_dec/ivas_stereo_mdct_core_dec_fx.c | 2 +- 10 files changed, 617 insertions(+), 11 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 17566e3cb..5dd11390a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1582,7 +1582,11 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], Word16 q_x, Word16 xn_buf_fx[], +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_win, +#else Word16 q_win, +#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], /* i/o: synth[-M..L_frame] */ diff --git a/lib_com/options.h b/lib_com/options.h index 63fe353e0..d86502dfd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,6 +100,7 @@ #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ #define FIX_1348_BIT_PRECISION_IMPROVEMENT +#define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN #define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 3c07b8140..8602a331f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9886,8 +9886,15 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T void IMDCT_ivas_fx( Word32 *x_fx, Word16 q_x, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, +#else + Word16 *old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, +#endif Word16 *xn_buf_fx, const Word16 *tcx_aldo_window_1_fx, const PWord16 *tcx_aldo_window_1_trunc_fx, @@ -9916,7 +9923,11 @@ void IMDCT_ivas_fx( Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_win); +#else Word16 q_win ); +#endif void v_mult16_fixed( const Word16 x1[], /* i : Input vector 1 */ @@ -10022,7 +10033,7 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) const Word16 isParamMC, #endif Word16 q_x, diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index fc8fda9ad..7bbe93ad8 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2575,11 +2575,349 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +static +Word16 IMDCT_ivas_fx_adjust_qwin( + Word16 Q_syn_Overl_TDAC, + Word16 Q_syn_Overl, + Word16 Q_old_syn_Overl, + Word16 Q_old_wtda, + Word16 q_win) +{ + //q_win = s_min( s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ), q_win ); + q_win = s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ); + q_win = s_min ( q_win, -1 ); + q_win = s_max ( q_win, -2 ); + + return q_win; +} + +static +void IMDCT_ivas_fx_rescale( + Word16 *syn_Overl_TDAC, + Word16 *Q_syn_Overl_TDAC, + Word16 *syn_Overl, + Word16 *Q_syn_Overl, + Word16 *old_syn_Overl, + Word16 *Q_old_syn_Overl, + Word16 *old_out_fx, + Word16 *Q_old_wtda, + Word16 q_win, + const Word16 FB_flag +#if 0 + Word16 *synth_buf_fx, + Word16 q_syn +#endif + ) +{ + Word16 oldLength; + + oldLength = L_FRAME32k; + move16(); + if ( FB_flag ) { + oldLength = L_FRAME48k; + move16(); + } + +#if 1 + Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win + *Q_syn_Overl = q_win; + move16(); + Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + *Q_syn_Overl_TDAC = q_win; + move16(); + Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + *Q_old_syn_Overl = q_win; + move16(); + + Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + *Q_old_wtda = q_win; + move16(); +#endif + //Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win +} + +static Word16 TCX_MDCT_Inverse_GetScaleFactor( + const Word16 L, /* Q0 */ + Word16 *factor_e /* Q0 */ +) +{ + + Word16 factor; + + IF( EQ_16( L, NORM_MDCT_FACTOR ) ) + { + factor = 32767; + move16(); + *factor_e = 0; + move16(); + } + ELSE IF( EQ_16( L, 2 * NORM_MDCT_FACTOR ) ) + { + factor = 23170; + move16(); + *factor_e = 1; + move16(); + } + ELSE IF( EQ_16( L, 4 * NORM_MDCT_FACTOR ) ) + { + factor = 32767; + move16(); + *factor_e = 1; + move16(); + } + ELSE + { + factor = mult_r( shl( L, 4 ), 26214 /*128.f / NORM_MDCT_FACTOR*/ ); /* 4Q11 */ + *factor_e = 4; + move16(); + + factor = Sqrt16( factor, factor_e ); + } + + return factor; +} + +static +void TCX_MDCT_Inverse_qwin_fx( + Word32 *x, // Q( 31 - x_e ) + Word16 x_e, + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode,/* Q0 */ + Word16 *q_win +) +{ + + Word16 i, fac, negfac, s; + Word16 L2 = l, R2 = r; + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 fac_e; + (void) element_mode; + L2 = shr( l, 1 ); + R2 = shr( r, 1 ); + + x_e = sub( 15, x_e ); + edct_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); + x_e = sub( 15, x_e ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); /* exp(fac_e) */ + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + +#if 1 + IF ( *q_win == -2 ) { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + *q_win = s_min( sub( s, x_e ), *q_win ); + } +#else + assert( *q_win == 0 || *q_win == -2 ); +#endif + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + + move16(); + } + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], fac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + Word16 f; + + f = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + y[L2 + i] = round_fx_sat( L_shl_sat( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + y[l + m + R2 - 1 - i] = f; + move16(); + } +} + +static +void TCX_MDST_Inverse_qwin_fx( + Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + Word16 *q_win +) +{ + + Word16 i, fac, negfac, s; + Word16 L2 = l, R2 = r; + move16(); + move16(); + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 fac_e; + + L2 = shr( l, 1 ); + R2 = shr( r, 1 ); + + x_e = sub( 15, x_e ); + edst_fx( x, tmp_buf + L2, add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &x_e ); + x_e = sub( 15, x_e ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + +#if 1 + IF ( *q_win == -2 ) { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + *q_win = s_min( sub( s, x_e ), *q_win ); + } +#else + assert( *q_win == 0 || *q_win == -2 ); +#endif + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); /* fold out right end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], negfac ), s ) ); /* negate, fold out left end of DCT exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + Word16 f; + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], fac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + + y[l + m + R2 - 1 - i] = negate( f ); + move16(); + } +} + +/*-------------------------------------------------------------------* + * TCX_MDXT_Inverse_fx() + * + * + *-------------------------------------------------------------------*/ +static +void TCX_MDXT_Inverse_qwin_fx( + const Word32 *x, /* exp(x_e) */ + Word16 x_e, + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type,/* Q0 */ + Word16 *q_win +) +{ + Word16 signLeft; + Word16 signRight; + Word16 i, fac, negfac, s, fac_e; + const Word16 L2 = shr( l, 1 ), R2 = shr( r, 1 ); + Word32 tmp_buf[N_MAX + L_MDCT_OVLP_MAX / 2]; + Word16 f; + + set32_fx( tmp_buf, 0, N_MAX + L_MDCT_OVLP_MAX / 2 ); + + edxt_fx( x, tmp_buf + L2, add( add( L2, m ), R2 ), kernel_type, TRUE ); + + fac = TCX_MDCT_Inverse_GetScaleFactor( add( add( shr( l, 1 ), m ), shr( r, 1 ) ), &fac_e ); + x_e = add( x_e, fac_e ); + + negfac = negate( fac ); + IF( GE_16( kernel_type, MDCT_II ) ) + { + signLeft = negfac; + } + ELSE + { + signLeft = fac; + } + // signRight = ( kernel_type & 1 ? fac : negfac ); + IF( L_and( kernel_type, 1 ) ) + { + signRight = fac; + } + ELSE + { + signRight = negfac; + } + +#if 1 + IF ( *q_win == -2 ) { + // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); + // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; + s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + *q_win = s_min( sub( s, x_e ), *q_win ); + } +#else + assert( *q_win == 0 || *q_win == -2 ); +#endif + s = add( x_e, *q_win ); + move16(); + + FOR( i = 0; i < L2; i++ ) + { + y[i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + m + R2 + i], signLeft ), s ) ); /* fold out the left end exp(fac_e)*/ + } + + FOR( i = 0; i < R2; i++ ) + { + y[l + m + R2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], signRight ), s ) ); /* ...and right end exp(fac_e)*/ + move16(); + } + + FOR( i = 0; i < ( ( L2 + m + R2 ) >> 1 ); i++ ) + { + + f = round_fx( L_shl( Mpy_32_16_1( tmp_buf[L2 + i], negfac ), s ) ); + + y[L2 + i] = round_fx( L_shl( Mpy_32_16_1( tmp_buf[l + m + R2 - 1 - i], negfac ), s ) ); /* time-reverse mid of DCT exp(fac_e)*/ + move16(); + + y[l + m + R2 - 1 - i] = f; + move16(); + } + + return; +} + +#endif + void IMDCT_ivas_fx( Word32 *x_fx, // Q(q_x) Word16 q_x, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *old_syn_overl_fx, // *Q_old_syn_overl_fx + Word16 *Q_old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, // *Q_syn_Overl_TDAC_fx + Word16 *Q_syn_Overl_TDAC_fx, +#else Word16 *old_syn_overl_fx, // Q(-2) Word16 *syn_Overl_TDAC_fx, // Q(-2) +#endif Word16 *xn_buf_fx, // Q(-2) const Word16 *tcx_aldo_window_1_fx, // Q(15) const PWord16 *tcx_aldo_window_1_trunc_fx, // Q(15) @@ -2608,7 +2946,11 @@ void IMDCT_ivas_fx( Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *pq_win) +#else Word16 q_win ) // Q(-2) +#endif { Word16 i, nz, aldo, w, L_win, L_ola; Word16 win_fx[( L_FRAME_PLUS + L_MDCT_OVLP_MAX ) / 2]; @@ -2617,7 +2959,16 @@ void IMDCT_ivas_fx( Word16 x_e_hdrm; Word32 c; Word16 exp; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win = *pq_win; + move16(); + x_e_hdrm = sub( Q16, q_x ); + IF ( q_win == -2 ) { + q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); + } +#else x_e_hdrm = add( q_win, sub( Q16, q_x ) ); +#endif aldo = 0; move16(); @@ -2691,11 +3042,37 @@ void IMDCT_ivas_fx( Word16 L_spec_TCX5_tmp = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win_prev; +#endif + FOR( w = 0; w < 2; w++ ) { test(); test(); L_spec_TCX5_tmp = imult1616( w, L_spec_TCX5 ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win ); + } + ELSE IF( ( kernel_type != 0 ) && ( w == 0 ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, kernel_type, &q_win ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win ); + } + + if ( w > 0 ) { + assert( q_win_prev == q_win ); + } else { + q_win_prev = q_win; + } + + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); @@ -2708,6 +3085,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); } +#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); @@ -2746,6 +3124,23 @@ void IMDCT_ivas_fx( set16_fx( win_fx, 0, shr( add( L_FRAME_PLUS, L_MDCT_OVLP_MAX ), 1 ) ); /* 1st TCX-5 window, special MDCT with minimum overlap on right side */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win_prev; + + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, &q_win ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, kernel_type, &q_win ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode, &q_win ); + } + q_win_prev = q_win; +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola ); @@ -2758,6 +3153,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode ); } +#endif set16_fx( xn_buf_fx, 0, shr( overlap, 1 ) ); @@ -2765,6 +3161,20 @@ void IMDCT_ivas_fx( Copy( win_fx + L_win, xn_buf_fx + shr( overlap, 1 ), add( L_win, shr( L_ola, 1 ) ) ); /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( s_and( kernel_type, 1 ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win ); + } + + assert( q_win_prev == q_win ); + + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( s_and( kernel_type, 1 ) ) { TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); @@ -2773,6 +3183,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode ); } +#endif tcx_windowing_synthesis_current_frame( win_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, 0, /* left_rect */ MIN_OVERLAP, /* left_mode */ acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, L_win, ( tcx_offset < 0 ) ? -tcx_offset : 0, 1, /* st->last_mode_bfi */ 0, /* st->last_is_cng */ fullbandScale ); @@ -2807,6 +3218,22 @@ void IMDCT_ivas_fx( ELSE { /* default, i.e. maximum overlap, single transform, no grouping */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, &q_win ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, kernel_type, &q_win ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win ); + } + + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap ); @@ -2819,6 +3246,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode ); } +#endif tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && NE_16( st->last_core, ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), ( tcx_offset < 0 ) ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); @@ -2864,6 +3292,10 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = q_xn_buf_fx_32; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#endif + Word16 diff = sub( q_tmp_fx_32, q_win ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); @@ -2871,6 +3303,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + assert( L_shr(L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); #else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); @@ -2884,10 +3317,12 @@ void IMDCT_ivas_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); + assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 ); #else old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); #endif xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); + assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 ); move16(); move16(); } @@ -2896,8 +3331,8 @@ void IMDCT_ivas_fx( { #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out = q_win; -#endif move16(); +#endif edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); Word16 res_m, res_e; res_e = 0; @@ -2913,9 +3348,15 @@ void IMDCT_ivas_fx( q_tmp_fx_32 = sub( q_xn_buf_fx_32, res_e ); // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + // L_norm_arr( xn_buf_fx, L_frame ) + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#endif + Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { + assert( extract_h( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ) == -1 ); xn_buf_fx[( ind + ( overlap / 2 ) ) + nz] = extract_l( L_shr( xn_buf_fx_32[( ind + ( overlap / 2 ) ) + nz], q_diff ) ); move16(); } @@ -2961,7 +3402,23 @@ void IMDCT_ivas_fx( acelp_mem_len = 0; move16(); } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( EQ_16( kernel_type, MDST_IV ) ) + { + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, &q_win ); + } + ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ + { + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, kernel_type, &q_win ); + } + ELSE + { + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win ); + } + // xn_buf_fx, NULL, L_frame, + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); +#else IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap ); @@ -2974,7 +3431,7 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode ); } - +#endif /*-----------------------------------------------------------* * Windowing, overlap and add * *-----------------------------------------------------------*/ @@ -3228,6 +3685,10 @@ void IMDCT_ivas_fx( } } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + *pq_win = q_win; + move16(); +#endif return; } @@ -3647,6 +4108,52 @@ void decoder_tcx_ivas_fx( decoder_tcx_tns_fx( st, L_frame_glob, L_spec, L_frame, L_frameTCX, x_fx, fUseTns, &tnsData, bfi, frame_cnt, 0, NULL ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn + x_e = sub( 31, 11 ); + + IF( st->igf != 0 ) + { + Scale_sig32( st->hIGFDec->virtualSpec, ( N_MAX_TCX - IGF_START_MN ), ( sub( st->hIGFDec->virtualSpec_e, x_e ) ) ); + st->hIGFDec->virtualSpec_e = x_e; + move16(); + } + +#if 1 + /* Scaling down buffers for decoder_tcx_imdct_fx*/ + Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // Scaling to Q_syn + st->hTcxDec->Q_syn_Overl_TDACFB = st->Q_syn; + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDAC ) ); // Scaling to Q_syn + st->hTcxDec->Q_syn_Overl_TDAC = st->Q_syn; + Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn + st->hTcxDec->Q_old_syn_Overl = st->Q_syn; +#endif + +#if 1 + Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn + Scale_sig( synthFB_fx, L_frameTCX_glob, st->Q_syn ); // Scaling to Q_syn +#endif + + Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); + + Word16 q_win; + q_win = st->Q_syn; + + decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, MDCT_IV, + fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); + + assert( q_win == 0 ); + + /* Scaling up again */ + Scale_sig( synth_fx, L_frame_glob, sub( st->Q_syn, q_win ) ); + Scale_sig( synthFB_fx, L_frameTCX_glob, sub( st->Q_syn, q_win ) ); + // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); + + Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 + st->hTcxDec->Q_old_syn_Overl = -2; + +#else Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn x_e = sub( 31, 11 ); @@ -3696,6 +4203,7 @@ void decoder_tcx_ivas_fx( #endif Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 st->hTcxDec->Q_old_syn_Overl = -2; +#endif } /*-------------------------------------------------------------------* @@ -5082,7 +5590,11 @@ void decoder_tcx_imdct_fx( Word32 x_fx[N_MAX], // Q(11) Word16 q_x, Word16 xn_buf_fx[], // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_win, +#else Word16 q_win, +#endif const UWord16 kernelType, /* i : TCX transform kernel type */ const Word16 fUseTns, /* i : flag that is set if TNS data is present */ Word16 synth_fx[], // Q(-2) /* i/o: synth[-M..L_frame] */ @@ -5108,7 +5620,9 @@ void decoder_tcx_imdct_fx( Word16 q_a_itf = 15; Word16 x_e = sub( 31, q_x ); move16(); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 shift_q = sub( q_x, q_win ); +#endif /*-----------------------------------------------------------------* * Initializations @@ -5261,7 +5775,11 @@ void decoder_tcx_imdct_fx( IF( NE_16( st->element_mode, IVAS_CPE_DFT ) && !sba_dirac_stereo_flag ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, +#else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, +#endif hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); @@ -5287,8 +5805,11 @@ void decoder_tcx_imdct_fx( IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) || ( sba_dirac_stereo_flag != 0 ) ) { Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, +#endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); #else @@ -5296,6 +5817,10 @@ void decoder_tcx_imdct_fx( #endif } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 shift_q = sub( q_x, *q_win ); +#endif + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x @@ -5308,7 +5833,11 @@ void decoder_tcx_imdct_fx( IF( st->element_mode != EVS_MONO ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, +#else IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, +#endif hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); @@ -5318,14 +5847,22 @@ void decoder_tcx_imdct_fx( } ELSE { - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#else IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, +#endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif } + +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + shift_q = sub( q_x, *q_win ); +#endif + FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index e30553d38..e1321d9aa 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1057,10 +1057,10 @@ void con_acelp_fx( move16(); } set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); - +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); - +#endif FOR( i = 0; i < W2; i++ ) { @@ -1105,6 +1105,10 @@ void con_acelp_fx( move16(); lerp( hTcxDec->syn_Overl, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ), shr( st->L_frame, 1 ) ); lerp( hHQ_core->old_out_LB_fx, hHQ_core->old_out_fx, hTcxDec->L_frameTCX, st->L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; + move16(); +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index e804d2009..e64eb9c38 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1057,6 +1057,10 @@ void con_tcx_fx( hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_wtda_LB = hHQ_core->Q_old_wtda; + move16(); +#endif st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); @@ -1947,6 +1951,10 @@ void con_tcx_ivas_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_old_syn_Overl = Q_syn; + move16(); +#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ FOR( i = 0; i < W12; i++ ) @@ -2035,8 +2043,10 @@ void con_tcx_ivas_fx( /* update memory for low band */ st->Q_syn = Q_syn; move16(); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ st->hTcxDec->Q_old_syn_Overl = -1; +#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index bb985ac7b..4c3b8b782 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -346,7 +346,7 @@ ivas_error ivas_mct_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, st_ivas->mc_mode == MC_MODE_PARAMMC, q_output, e_sig ); #else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index d8c64d516..e3ece34ed 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1083,7 +1083,7 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) const Word16 isParamMC, #endif Word16 q_x, @@ -1101,12 +1101,16 @@ void ivas_mdct_core_reconstruct_fx( Word16 *synthFB_fx; Word16 q_syn = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win = -2; +#else #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_win = -1; #else Word16 q_win = -2; #endif move16(); +#endif /* TCX */ Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2) Word16 tcx_offset[CPE_CHANNELS]; @@ -1125,9 +1129,11 @@ void ivas_mdct_core_reconstruct_fx( bfi = sts[0]->bfi; move16(); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT if ( isParamMC ) q_win = -2; +#endif #endif /* TNS, ITF, IMDCT and updates */ @@ -1180,10 +1186,16 @@ void ivas_mdct_core_reconstruct_fx( set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win + st->hTcxDec->Q_syn_Overl_TDACFB = q_win; + move16(); Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + st->hTcxDec->Q_syn_Overl_TDAC = q_win; + move16(); Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; + move16(); Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win @@ -1197,6 +1209,13 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win +#endif +#if 0 + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win +#endif + FOR( k = 0; k < nSubframes[ch]; k++ ) { init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], @@ -1206,6 +1225,18 @@ void ivas_mdct_core_reconstruct_fx( { test(); test(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) + { + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, + MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); + } + ELSE + { + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, + st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); + } +#else IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, @@ -1216,9 +1247,14 @@ void ivas_mdct_core_reconstruct_fx( decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } +#endif } ELSE { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + q_win = -2; + move16(); +#endif set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] ); /* Note: these buffers are not subframe-based, hence no indexing with k */ @@ -1267,7 +1303,9 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + st->hTcxDec->Q_syn_Overl = st->Q_syn; #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn @@ -1278,7 +1316,7 @@ void ivas_mdct_core_reconstruct_fx( #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); - // Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn + //Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 4232116fa..01182a493 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -112,6 +112,7 @@ void ivas_post_proc_fx( { Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/ move16(); + assert( sts[n]->hHQ_core->Q_old_out_fx32 == Q11 ); Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/ } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index fd9398769..e70b1c137 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -550,7 +550,7 @@ void stereo_mdct_core_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, st_ivas->mc_mode == MC_MODE_PARAMMC, Q11, e_sigFB ); #else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, e_sigFB ); -- GitLab From 6d0bec24880a27f4ee832068dc59b1df82d6c40c Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 10:59:36 +0200 Subject: [PATCH 043/394] clang format --- lib_com/prot_fx.h | 2 +- lib_dec/dec_tcx_fx.c | 114 ++++++++++++++++---------------- lib_dec/ivas_mdct_core_dec_fx.c | 8 +-- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 5d15327a1..a84d0d8dc 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9840,7 +9840,7 @@ void IMDCT_ivas_fx( const Word16 fullbandScale, Word16 *acelp_zir_fx, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 *q_win); + Word16 *q_win ); #else Word16 q_win ); #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 63820a2a9..9ea271b39 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2573,24 +2573,22 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -static -Word16 IMDCT_ivas_fx_adjust_qwin( +static Word16 IMDCT_ivas_fx_adjust_qwin( Word16 Q_syn_Overl_TDAC, Word16 Q_syn_Overl, Word16 Q_old_syn_Overl, Word16 Q_old_wtda, - Word16 q_win) + Word16 q_win ) { - //q_win = s_min( s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ), q_win ); - q_win = s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ); - q_win = s_min ( q_win, -1 ); - q_win = s_max ( q_win, -2 ); + // q_win = s_min( s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ), q_win ); + q_win = s_min( s_min( s_min( Q_syn_Overl_TDAC, Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ); + q_win = s_min( q_win, -1 ); + q_win = s_max( q_win, -2 ); return q_win; } -static -void IMDCT_ivas_fx_rescale( +static void IMDCT_ivas_fx_rescale( Word16 *syn_Overl_TDAC, Word16 *Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2605,33 +2603,34 @@ void IMDCT_ivas_fx_rescale( Word16 *synth_buf_fx, Word16 q_syn #endif - ) +) { Word16 oldLength; oldLength = L_FRAME32k; move16(); - if ( FB_flag ) { + if ( FB_flag ) + { oldLength = L_FRAME48k; move16(); } #if 1 - Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win + Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win *Q_syn_Overl = q_win; move16(); - Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win *Q_syn_Overl_TDAC = q_win; move16(); - Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win *Q_old_syn_Overl = q_win; move16(); - Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win *Q_old_wtda = q_win; move16(); #endif - //Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win + // Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win } static Word16 TCX_MDCT_Inverse_GetScaleFactor( @@ -2675,17 +2674,15 @@ static Word16 TCX_MDCT_Inverse_GetScaleFactor( return factor; } -static -void TCX_MDCT_Inverse_qwin_fx( +static void TCX_MDCT_Inverse_qwin_fx( Word32 *x, // Q( 31 - x_e ) Word16 x_e, - Word16 *y, /* Qy */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const Word16 element_mode,/* Q0 */ - Word16 *q_win -) + Word16 *y, /* Qy */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const Word16 element_mode, /* Q0 */ + Word16 *q_win ) { Word16 i, fac, negfac, s; @@ -2706,10 +2703,11 @@ void TCX_MDCT_Inverse_qwin_fx( negfac = negate( fac ); #if 1 - IF ( *q_win == -2 ) { + IF( *q_win == -2 ) + { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; - s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } #else @@ -2743,16 +2741,14 @@ void TCX_MDCT_Inverse_qwin_fx( } } -static -void TCX_MDST_Inverse_qwin_fx( +static void TCX_MDST_Inverse_qwin_fx( Word32 *x, /* exp(x_e) */ Word16 x_e, Word16 *y, /* Qx */ const Word16 l, /* Q0 */ const Word16 m, /* Q0 */ const Word16 r, /* Q0 */ - Word16 *q_win -) + Word16 *q_win ) { Word16 i, fac, negfac, s; @@ -2775,10 +2771,11 @@ void TCX_MDST_Inverse_qwin_fx( negfac = negate( fac ); #if 1 - IF ( *q_win == -2 ) { + IF( *q_win == -2 ) + { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; - s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } #else @@ -2817,17 +2814,15 @@ void TCX_MDST_Inverse_qwin_fx( * * *-------------------------------------------------------------------*/ -static -void TCX_MDXT_Inverse_qwin_fx( +static void TCX_MDXT_Inverse_qwin_fx( const Word32 *x, /* exp(x_e) */ Word16 x_e, - Word16 *y, /* Qx */ - const Word16 l, /* Q0 */ - const Word16 m, /* Q0 */ - const Word16 r, /* Q0 */ - const UWord16 kernel_type,/* Q0 */ - Word16 *q_win -) + Word16 *y, /* Qx */ + const Word16 l, /* Q0 */ + const Word16 m, /* Q0 */ + const Word16 r, /* Q0 */ + const UWord16 kernel_type, /* Q0 */ + Word16 *q_win ) { Word16 signLeft; Word16 signRight; @@ -2863,10 +2858,11 @@ void TCX_MDXT_Inverse_qwin_fx( } #if 1 - IF ( *q_win == -2 ) { + IF( *q_win == -2 ) + { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; - s = L_norm_arr( tmp_buf + L2, m + R2 + L2); + s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } #else @@ -2907,13 +2903,13 @@ void IMDCT_ivas_fx( Word32 *x_fx, // Q(q_x) Word16 q_x, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 *old_syn_overl_fx, // *Q_old_syn_overl_fx + Word16 *old_syn_overl_fx, // *Q_old_syn_overl_fx Word16 *Q_old_syn_overl_fx, - Word16 *syn_Overl_TDAC_fx, // *Q_syn_Overl_TDAC_fx + Word16 *syn_Overl_TDAC_fx, // *Q_syn_Overl_TDAC_fx Word16 *Q_syn_Overl_TDAC_fx, #else - Word16 *old_syn_overl_fx, // Q(-2) - Word16 *syn_Overl_TDAC_fx, // Q(-2) + Word16 *old_syn_overl_fx, // Q(-2) + Word16 *syn_Overl_TDAC_fx, // Q(-2) #endif Word16 *xn_buf_fx, // Q(-2) const Word16 *tcx_aldo_window_1_fx, // Q(15) @@ -2944,9 +2940,9 @@ void IMDCT_ivas_fx( const Word16 fullbandScale, Word16 *acelp_zir_fx, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 *pq_win) + Word16 *pq_win ) #else - Word16 q_win ) // Q(-2) + Word16 q_win ) // Q(-2) #endif { Word16 i, nz, aldo, w, L_win, L_ola; @@ -2960,7 +2956,8 @@ void IMDCT_ivas_fx( Word16 q_win = *pq_win; move16(); x_e_hdrm = sub( Q16, q_x ); - IF ( q_win == -2 ) { + IF( q_win == -2 ) + { q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); } #else @@ -3062,9 +3059,12 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win ); } - if ( w > 0 ) { + if ( w > 0 ) + { assert( q_win_prev == q_win ); - } else { + } + else + { q_win_prev = q_win; } @@ -3300,7 +3300,7 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - assert( L_shr(L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); + assert( L_shr( L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); #else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); @@ -3413,7 +3413,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win ); } - // xn_buf_fx, NULL, L_frame, + // xn_buf_fx, NULL, L_frame, IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) @@ -4151,8 +4151,8 @@ void decoder_tcx_ivas_fx( st->hTcxDec->Q_old_syn_Overl = -2; #else - Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 - Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn + Scale_sig32( x_fx, N_MAX, sub( x_e, 20 ) ); // Scaling x_fx to Q11 + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( st->Q_syn, 14 ) ); // Scaling xn_buf_fx to Q_syn x_e = sub( 31, 11 ); IF( st->igf != 0 ) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index e3ece34ed..b1a78b1a8 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1190,10 +1190,10 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win st->hTcxDec->Q_syn_Overl_TDACFB = q_win; move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win st->hTcxDec->Q_syn_Overl_TDAC = q_win; move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win st->hTcxDec->Q_old_syn_Overl = q_win; move16(); Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win @@ -1304,7 +1304,7 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_OverlFB = st->Q_syn; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn @@ -1316,7 +1316,7 @@ void ivas_mdct_core_reconstruct_fx( #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); - //Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn + // Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ -- GitLab From d674b7d856e3957e822e76cb06cc1bca57369820 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 11:34:54 +0200 Subject: [PATCH 044/394] Correct assert checking for overflow for negative values. --- lib_dec/dec_tcx_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 9ea271b39..cbc5579b6 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3314,12 +3314,12 @@ void IMDCT_ivas_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); - assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 ); + assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == -1 ); #else old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); #endif xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); - assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 ); + assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == -1 ); move16(); move16(); } -- GitLab From 4b492033ebd8e2f8991d4c4275a86de83889ad41 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 15:15:42 +0200 Subject: [PATCH 045/394] Avoid throwing assert, the actual problems will be fixed in a next change. --- lib_dec/dec_tcx_fx.c | 130 ++++++++++++++++++++++++++++++++----------- 1 file changed, 98 insertions(+), 32 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index cbc5579b6..807e39202 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2588,6 +2588,41 @@ static Word16 IMDCT_ivas_fx_adjust_qwin( return q_win; } +static Word16 IMDCT_ivas_fx_calc_qwin( + Word16 *syn_Overl_TDAC, + Word16 Q_syn_Overl_TDAC, + Word16 *syn_Overl, + Word16 Q_syn_Overl, + Word16 *old_syn_Overl, + Word16 Q_old_syn_Overl, + Word16 *old_out_fx, + Word16 Q_old_out_fx, + const Word16 FB_flag, + Word16 q_win ) +{ + Word16 oldLength; + + oldLength = L_FRAME32k; + move16(); + if ( FB_flag ) + { + oldLength = L_FRAME48k; + move16(); + } + q_win = 2; + move16(); + + // q_win == norm + Q_syn_Overl_TDAC + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC); + q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); + q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); + + //q_win = sub( q_win, 1 ); + + return q_win; +} + static void IMDCT_ivas_fx_rescale( Word16 *syn_Overl_TDAC, Word16 *Q_syn_Overl_TDAC, @@ -2596,7 +2631,7 @@ static void IMDCT_ivas_fx_rescale( Word16 *old_syn_Overl, Word16 *Q_old_syn_Overl, Word16 *old_out_fx, - Word16 *Q_old_wtda, + Word16 *Q_old_out_fx, Word16 q_win, const Word16 FB_flag #if 0 @@ -2616,18 +2651,17 @@ static void IMDCT_ivas_fx_rescale( } #if 1 - Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win - *Q_syn_Overl = q_win; - move16(); Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win *Q_syn_Overl_TDAC = q_win; move16(); + Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win + *Q_syn_Overl = q_win; + move16(); Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win *Q_old_syn_Overl = q_win; move16(); - - Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win - *Q_old_wtda = q_win; + Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_out_fx ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win + *Q_old_out_fx = q_win; move16(); #endif // Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win @@ -2682,7 +2716,8 @@ static void TCX_MDCT_Inverse_qwin_fx( const Word16 m, /* Q0 */ const Word16 r, /* Q0 */ const Word16 element_mode, /* Q0 */ - Word16 *q_win ) + Word16 *q_win, + Word16 allow_qwin_change ) { Word16 i, fac, negfac, s; @@ -2703,7 +2738,7 @@ static void TCX_MDCT_Inverse_qwin_fx( negfac = negate( fac ); #if 1 - IF( *q_win == -2 ) + IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; @@ -2748,7 +2783,8 @@ static void TCX_MDST_Inverse_qwin_fx( const Word16 l, /* Q0 */ const Word16 m, /* Q0 */ const Word16 r, /* Q0 */ - Word16 *q_win ) + Word16 *q_win, + Word16 allow_qwin_change ) { Word16 i, fac, negfac, s; @@ -2771,7 +2807,7 @@ static void TCX_MDST_Inverse_qwin_fx( negfac = negate( fac ); #if 1 - IF( *q_win == -2 ) + IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; @@ -2822,7 +2858,8 @@ static void TCX_MDXT_Inverse_qwin_fx( const Word16 m, /* Q0 */ const Word16 r, /* Q0 */ const UWord16 kernel_type, /* Q0 */ - Word16 *q_win ) + Word16 *q_win, + Word16 allow_qwin_change ) { Word16 signLeft; Word16 signRight; @@ -2858,7 +2895,7 @@ static void TCX_MDXT_Inverse_qwin_fx( } #if 1 - IF( *q_win == -2 ) + IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); // q_win = L_norm_arr(tmp_buf, , *q_win ) - x_e; @@ -2954,11 +2991,19 @@ void IMDCT_ivas_fx( Word16 exp; #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win = *pq_win; + Word16 allow_qwin_change = 1; + move16(); move16(); x_e_hdrm = sub( Q16, q_x ); - IF( q_win == -2 ) + IF( *pq_win == 0 ) { - q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); + allow_qwin_change = 0; + } + IF ( allow_qwin_change ) + { + //q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); + q_win = IMDCT_ivas_fx_calc_qwin( syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, + hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, FB_flag, q_win ); } #else x_e_hdrm = add( q_win, sub( Q16, q_x ) ); @@ -3038,6 +3083,14 @@ void IMDCT_ivas_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win_prev; +#if 0 + IF ( allow_qwin_change ) { + q_win = -2; + move16(); + allow_qwin_change = 0; + move16(); + } +#endif #endif FOR( w = 0; w < 2; w++ ) @@ -3048,20 +3101,24 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win ); + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); } ELSE IF( ( kernel_type != 0 ) && ( w == 0 ) ) /* type 1 or 2 */ { - TCX_MDXT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, kernel_type, &q_win ); + TCX_MDXT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, kernel_type, &q_win, allow_qwin_change ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win ); + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } if ( w > 0 ) { - assert( q_win_prev == q_win ); + //assert( q_win_prev == q_win ); + if ( q_win_prev != q_win ) { + extern int frame; + printf("\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); + } } else { @@ -3126,15 +3183,15 @@ void IMDCT_ivas_fx( IF( EQ_16( kernel_type, MDST_IV ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, &q_win ); + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, &q_win, allow_qwin_change ); } ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ { - TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, kernel_type, &q_win ); + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, kernel_type, &q_win, allow_qwin_change ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode, &q_win ); + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } q_win_prev = q_win; #else @@ -3161,11 +3218,11 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( s_and( kernel_type, 1 ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win ); + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, 0 ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win ); + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, 0 ); } assert( q_win_prev == q_win ); @@ -3218,15 +3275,15 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( EQ_16( kernel_type, MDST_IV ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, &q_win ); + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, &q_win, allow_qwin_change ); } ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ { - TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, kernel_type, &q_win ); + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, kernel_type, &q_win, allow_qwin_change ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win ); + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win, allow_qwin_change ); } IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); @@ -3290,6 +3347,7 @@ void IMDCT_ivas_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + // L_norm_arr(xn_buf_fx_32, ) IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif @@ -3346,7 +3404,16 @@ void IMDCT_ivas_fx( // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - // L_norm_arr( xn_buf_fx, L_frame ) + if ( allow_qwin_change) { +#if 1 + // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) + // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) + // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 1 ); +#else + q_win = -2; +#endif + } IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif @@ -3402,18 +3469,17 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( EQ_16( kernel_type, MDST_IV ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, &q_win ); + TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, &q_win, allow_qwin_change ); } ELSE IF( NE_16( kernel_type, MDCT_IV ) ) /* type 1 or 2 */ { - TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, kernel_type, &q_win ); + TCX_MDXT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, kernel_type, &q_win, allow_qwin_change ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win ); + TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win, allow_qwin_change ); } - // xn_buf_fx, NULL, L_frame, IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) -- GitLab From 5efbe4bdf5f5c6bad2f6fcafd3c7ed6e02fb236d Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 15:27:02 +0200 Subject: [PATCH 046/394] clang format --- lib_dec/dec_tcx_fx.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 807e39202..d506b508e 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2613,12 +2613,12 @@ static Word16 IMDCT_ivas_fx_calc_qwin( move16(); // q_win == norm + Q_syn_Overl_TDAC - q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC); + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC ); q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); - //q_win = sub( q_win, 1 ); + // q_win = sub( q_win, 1 ); return q_win; } @@ -2999,9 +2999,9 @@ void IMDCT_ivas_fx( { allow_qwin_change = 0; } - IF ( allow_qwin_change ) + IF( allow_qwin_change ) { - //q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); + // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); q_win = IMDCT_ivas_fx_calc_qwin( syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, FB_flag, q_win ); } @@ -3114,10 +3114,11 @@ void IMDCT_ivas_fx( if ( w > 0 ) { - //assert( q_win_prev == q_win ); - if ( q_win_prev != q_win ) { + // assert( q_win_prev == q_win ); + if ( q_win_prev != q_win ) + { extern int frame; - printf("\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); + printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); } } else @@ -3404,7 +3405,8 @@ void IMDCT_ivas_fx( // v_multc_fixed( xn_buf_fx_32 + overlap / 2 + nz, (float) sqrt( (float) L_frame / NORM_MDCT_FACTOR ), tmp_fx_32, L_frame ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - if ( allow_qwin_change) { + if ( allow_qwin_change ) + { #if 1 // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) -- GitLab From c5db649c54963696a26009fbb76b9997968f0fa0 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 16:32:39 +0200 Subject: [PATCH 047/394] Fix warning, causing error in pipeline. --- lib_dec/dec_tcx_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d506b508e..9b45460d5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2573,6 +2573,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +#if 0 static Word16 IMDCT_ivas_fx_adjust_qwin( Word16 Q_syn_Overl_TDAC, Word16 Q_syn_Overl, @@ -2587,6 +2588,7 @@ static Word16 IMDCT_ivas_fx_adjust_qwin( return q_win; } +#endif static Word16 IMDCT_ivas_fx_calc_qwin( Word16 *syn_Overl_TDAC, -- GitLab From 93c1ca20e5f1379866686d2805462f6fb19d6b17 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 16:37:24 +0200 Subject: [PATCH 048/394] Fix error in debug printf that happens in pipeline but not locally. --- lib_dec/dec_tcx_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 9b45460d5..051d03828 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3116,12 +3116,13 @@ void IMDCT_ivas_fx( if ( w > 0 ) { - // assert( q_win_prev == q_win ); +#if 0 if ( q_win_prev != q_win ) { extern int frame; printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); } +#endif } else { -- GitLab From 317c692ac28e249f58792b12c4f706958bd711dc Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 16:41:44 +0200 Subject: [PATCH 049/394] Fix warning, causing error in pipeline. --- lib_dec/dec_tcx_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 051d03828..1702a5fb5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3116,13 +3116,12 @@ void IMDCT_ivas_fx( if ( w > 0 ) { -#if 0 if ( q_win_prev != q_win ) { - extern int frame; - printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); + // extern int frame; + // printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); + printf( "\nWarning: q_win changed in TCX5. Frame X, q_win %d %d\n", q_win_prev, q_win ); } -#endif } else { -- GitLab From a4db18ff59700dd91b92e6cb01e6b71d396b36f2 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 12 May 2025 10:51:16 +0200 Subject: [PATCH 050/394] Fix assert becaus of ininitialized hTcxDec->Q_syn_OverlFB --- lib_dec/core_dec_init_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index eb34e1bc1..3ddecdbd5 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -2090,6 +2090,11 @@ void reset_tcx_overl_buf_fx( set16_fx( hTcxDec->syn_Overl, 0, L_FRAME32k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl = 0; move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#endif set16_fx( hTcxDec->syn_Overl_TDACFB, 0, L_FRAME_MAX / 2 ); /*HQ-CORE(bfi)->TCX don't need it*/ hTcxDec->Q_syn_Overl_TDACFB = 0; move16(); -- GitLab From e6a26d0b423fa365fcea4cb29449b557a48a7176 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 12 May 2025 17:56:28 +0200 Subject: [PATCH 051/394] Add 2 bits headroom to dynamic q_win calculation as the default static value of q_win did. --- lib_dec/dec_tcx_fx.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1702a5fb5..0f3688a58 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2611,7 +2611,7 @@ static Word16 IMDCT_ivas_fx_calc_qwin( oldLength = L_FRAME48k; move16(); } - q_win = 2; + q_win = 4; move16(); // q_win == norm + Q_syn_Overl_TDAC @@ -2620,12 +2620,13 @@ static Word16 IMDCT_ivas_fx_calc_qwin( q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); - // q_win = sub( q_win, 1 ); + q_win = s_max( -3, sub( q_win, 2 ) ); return q_win; } static void IMDCT_ivas_fx_rescale( + Decoder_State *st, Word16 *syn_Overl_TDAC, Word16 *Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2666,6 +2667,8 @@ static void IMDCT_ivas_fx_rescale( *Q_old_out_fx = q_win; move16(); #endif + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win + // Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win } @@ -3084,8 +3087,9 @@ void IMDCT_ivas_fx( Word16 L_spec_TCX5_tmp = 0; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 q_win_prev; #if 0 + Word16 q_win_prev; +#else IF ( allow_qwin_change ) { q_win = -2; move16(); @@ -3114,6 +3118,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } +#if 0 if ( w > 0 ) { if ( q_win_prev != q_win ) @@ -3122,13 +3127,15 @@ void IMDCT_ivas_fx( // printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); printf( "\nWarning: q_win changed in TCX5. Frame X, q_win %d %d\n", q_win_prev, q_win ); } + // Rescale both subframes some how ? } else { q_win_prev = q_win; } +#endif - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { @@ -3230,7 +3237,7 @@ void IMDCT_ivas_fx( assert( q_win_prev == q_win ); - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( s_and( kernel_type, 1 ) ) { @@ -3289,7 +3296,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win, allow_qwin_change ); } - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3351,7 +3358,7 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN // L_norm_arr(xn_buf_fx_32, ) - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 diff = sub( q_tmp_fx_32, q_win ); @@ -3418,7 +3425,7 @@ void IMDCT_ivas_fx( q_win = -2; #endif } - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); @@ -3484,7 +3491,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win, allow_qwin_change ); } - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -4187,7 +4194,7 @@ void decoder_tcx_ivas_fx( move16(); } -#if 1 +#if 0 /* Scaling down buffers for decoder_tcx_imdct_fx*/ Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // Scaling to Q_syn st->hTcxDec->Q_syn_Overl_TDACFB = st->Q_syn; @@ -4197,7 +4204,7 @@ void decoder_tcx_ivas_fx( st->hTcxDec->Q_old_syn_Overl = st->Q_syn; #endif -#if 1 +#if 0 Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn Scale_sig( synthFB_fx, L_frameTCX_glob, st->Q_syn ); // Scaling to Q_syn #endif -- GitLab From 0b43f51ad30f134bb73ae4218af27bdb0c6b2610 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 12 May 2025 18:04:18 +0200 Subject: [PATCH 052/394] clang format --- lib_dec/dec_tcx_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 0f3688a58..fd9e0ff30 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3090,7 +3090,8 @@ void IMDCT_ivas_fx( #if 0 Word16 q_win_prev; #else - IF ( allow_qwin_change ) { + IF( allow_qwin_change ) + { q_win = -2; move16(); allow_qwin_change = 0; -- GitLab From 36bbe074068be90ed62402797f52b1b0ec3b8574 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 13 May 2025 19:36:04 +0200 Subject: [PATCH 053/394] Separate q_win into q_win and q_winFB for low band / high band, because these can be different. Correct q_win calculation for TCX20, which fixes assert fail. --- lib_com/ivas_prot_fx.h | 1 + lib_dec/dec_tcx_fx.c | 87 ++++++++++----------------------- lib_dec/ivas_mdct_core_dec_fx.c | 51 ++++++++++++++++--- 3 files changed, 72 insertions(+), 67 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5a19dcc41..904aaf090 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1584,6 +1584,7 @@ void decoder_tcx_imdct_fx( Word16 xn_buf_fx[], #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_win, + Word16 *q_winFB, #else Word16 q_win, #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index fd9e0ff30..037f2e3cb 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2626,7 +2626,6 @@ static Word16 IMDCT_ivas_fx_calc_qwin( } static void IMDCT_ivas_fx_rescale( - Decoder_State *st, Word16 *syn_Overl_TDAC, Word16 *Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2637,10 +2636,6 @@ static void IMDCT_ivas_fx_rescale( Word16 *Q_old_out_fx, Word16 q_win, const Word16 FB_flag -#if 0 - Word16 *synth_buf_fx, - Word16 q_syn -#endif ) { Word16 oldLength; @@ -2660,16 +2655,15 @@ static void IMDCT_ivas_fx_rescale( Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win *Q_syn_Overl = q_win; move16(); - Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win - *Q_old_syn_Overl = q_win; - move16(); + if ( FB_flag == 0 ) { + Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win + *Q_old_syn_Overl = q_win; + move16(); + } Scale_sig( old_out_fx, oldLength, sub( q_win, *Q_old_out_fx ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win *Q_old_out_fx = q_win; move16(); #endif - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win - - // Scale_sig( synth_buf_fx, add( add( old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win } static Word16 TCX_MDCT_Inverse_GetScaleFactor( @@ -3087,9 +3081,6 @@ void IMDCT_ivas_fx( Word16 L_spec_TCX5_tmp = 0; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -#if 0 - Word16 q_win_prev; -#else IF( allow_qwin_change ) { q_win = -2; @@ -3097,7 +3088,6 @@ void IMDCT_ivas_fx( allow_qwin_change = 0; move16(); } -#endif #endif FOR( w = 0; w < 2; w++ ) @@ -3119,24 +3109,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } -#if 0 - if ( w > 0 ) - { - if ( q_win_prev != q_win ) - { - // extern int frame; - // printf( "\nWarning: q_win changed in TCX5. Frame %d, q_win %d %d\n", frame, q_win_prev, q_win ); - printf( "\nWarning: q_win changed in TCX5. Frame X, q_win %d %d\n", q_win_prev, q_win ); - } - // Rescale both subframes some how ? - } - else - { - q_win_prev = q_win; - } -#endif - - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { @@ -3238,7 +3211,7 @@ void IMDCT_ivas_fx( assert( q_win_prev == q_win ); - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( s_and( kernel_type, 1 ) ) { @@ -3297,7 +3270,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win, allow_qwin_change ); } - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3358,8 +3331,9 @@ void IMDCT_ivas_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - // L_norm_arr(xn_buf_fx_32, ) - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + // q_win < norm + q_tmp_fx_32 - 16 + q_win = s_min( q_win, L_norm_arr( tmp_fx_32, L_frame ) + q_tmp_fx_32 - 16 ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 diff = sub( q_tmp_fx_32, q_win ); @@ -3370,7 +3344,7 @@ void IMDCT_ivas_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD assert( L_shr( L_shl( old_out_fx[ind], q_old_out_diff ), q_old_out_diff ) == old_out_fx[ind] ); - old_out_fx_32[ind] = L_shl( old_out_fx[ind], q_old_out_diff ); + old_out_fx_32[ind] = L_shl( L_deposit_l( old_out_fx[ind] ), q_old_out_diff ); #else old_out_fx_32[ind] = L_shl( old_out_fx[ind], diff ); #endif @@ -3382,9 +3356,10 @@ void IMDCT_ivas_fx( FOR( Word16 ind = 0; ind < L_frame; ind++ ) { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); assert( extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], q_old_out_diff ) ) == -1 ); + old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], q_old_out_diff ) ); #else + assert( extract_h( L_shr( old_out_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], diff ) ) == -1 ); old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); #endif xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); @@ -3426,7 +3401,7 @@ void IMDCT_ivas_fx( q_win = -2; #endif } - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); @@ -3492,7 +3467,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win, allow_qwin_change ); } - IMDCT_ivas_fx_rescale( st, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -4195,30 +4170,21 @@ void decoder_tcx_ivas_fx( move16(); } -#if 0 - /* Scaling down buffers for decoder_tcx_imdct_fx*/ - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // Scaling to Q_syn - st->hTcxDec->Q_syn_Overl_TDACFB = st->Q_syn; - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl_TDAC ) ); // Scaling to Q_syn - st->hTcxDec->Q_syn_Overl_TDAC = st->Q_syn; - Scale_sig( st->hTcxDec->old_syn_Overl, 320, st->Q_syn - st->hTcxDec->Q_old_syn_Overl ); // Scaling to Q_syn - st->hTcxDec->Q_old_syn_Overl = st->Q_syn; -#endif - -#if 0 - Scale_sig( synth_fx, L_frame_glob, st->Q_syn ); // Scaling to Q_syn - Scale_sig( synthFB_fx, L_frameTCX_glob, st->Q_syn ); // Scaling to Q_syn -#endif - Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); - Word16 q_win; + Word16 q_win, q_winFB; q_win = st->Q_syn; + move16(); + q_winFB = st->Q_syn; + move16(); + + assert( q_win == 0 ); - decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, MDCT_IV, + decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, &q_winFB, MDCT_IV, fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); assert( q_win == 0 ); + assert( q_win == q_winFB ); /* Scaling up again */ Scale_sig( synth_fx, L_frame_glob, sub( st->Q_syn, q_win ) ); @@ -5667,6 +5633,7 @@ void decoder_tcx_imdct_fx( Word16 xn_buf_fx[], // Q(-2) #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *q_win, + Word16 *q_winFB, #else Word16 q_win, #endif @@ -5915,7 +5882,7 @@ void decoder_tcx_imdct_fx( #endif hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_winFB ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif @@ -5928,7 +5895,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_winFB ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index b1a78b1a8..3ae1a5036 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1103,6 +1103,7 @@ void ivas_mdct_core_reconstruct_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win = -2; + Word16 q_winFB = -2; #else #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_win = -1; @@ -1210,11 +1211,6 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win #endif -#if 0 - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win -#endif FOR( k = 0; k < nSubframes[ch]; k++ ) { @@ -1228,14 +1224,16 @@ void ivas_mdct_core_reconstruct_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { - decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } ELSE { - decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, + decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } + + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win #else IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { @@ -1254,6 +1252,8 @@ void ivas_mdct_core_reconstruct_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN q_win = -2; move16(); + q_winFB = -2; + move16(); #endif set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] ); @@ -1270,7 +1270,43 @@ void ivas_mdct_core_reconstruct_fx( set16_fx( &st->hTcxDec->syn_Overl_TDACFB[0], 0, shr( L_frameTCX[ch], 1 ) ); } } +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + test(); + IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) + { + TonalMDCTConceal_SaveTimeSignal_ivas_fx( st->hTonalMDCTConc, synthFB_fx, q_winFB, L_frameTCX[ch] ); + } + decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_winFB, 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 ) ) + { + q_syn = sub( sf, 2 ); + st->Q_syn = q_syn; + move16(); + } + sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); + IF( LT_16( sf, sub( st->Q_syn, q_win ) ) ) + { + st->Q_syn = add( q_win, sf ); + } + Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDACFB ) ); // q_winFB -> Q(-1 - st->Q_syn) + st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); + move16(); + Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDAC ) ); // q_win -> Q(-1 - st->Q_syn) + st->hTcxDec->Q_syn_Overl_TDAC = sub( -1, st->Q_syn ); + move16(); + Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) + st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // q_win -> q_syn + Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); + Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_OverlFB ) ); // q_winFB -> st->Q_syn + st->hTcxDec->Q_syn_OverlFB = st->Q_syn; + Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn + st->hTcxDec->Q_syn_Overl = st->Q_syn; +#else test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) { @@ -1314,6 +1350,7 @@ void ivas_mdct_core_reconstruct_fx( st->hHQ_core->Q_old_wtda_LB = st->Q_syn; move16(); #endif +#endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); // Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn -- GitLab From dd49640f2b28b53196c4ba39266ba19aaeb0e9f1 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 13 May 2025 19:38:32 +0200 Subject: [PATCH 054/394] clang format --- lib_dec/dec_tcx_fx.c | 6 +++--- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 037f2e3cb..2f8bf396f 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2635,8 +2635,7 @@ static void IMDCT_ivas_fx_rescale( Word16 *old_out_fx, Word16 *Q_old_out_fx, Word16 q_win, - const Word16 FB_flag -) + const Word16 FB_flag ) { Word16 oldLength; @@ -2655,7 +2654,8 @@ static void IMDCT_ivas_fx_rescale( Scale_sig( syn_Overl, oldLength / 2, sub( q_win, *Q_syn_Overl ) ); // st->hTcxDec->Q_syn_Overl -> q_win *Q_syn_Overl = q_win; move16(); - if ( FB_flag == 0 ) { + if ( FB_flag == 0 ) + { Scale_sig( old_syn_Overl, oldLength / 2, sub( q_win, *Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win *Q_old_syn_Overl = q_win; move16(); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 3ae1a5036..995aa70e1 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1233,7 +1233,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win + Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win #else IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { @@ -1299,7 +1299,7 @@ void ivas_mdct_core_reconstruct_fx( move16(); Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // q_win -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_OverlFB ) ); // q_winFB -> st->Q_syn -- GitLab From d6a5545a87cf88d7866d7e4bb7db26f9e4efee29 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 14 May 2025 14:39:40 +0200 Subject: [PATCH 055/394] Correct scaling of synth_buf_fx/synth_bufFB_fx. Cleanup of obsolete code. --- lib_com/prot_fx.h | 3 - lib_dec/dec_tcx_fx.c | 79 +++++++++++++------------- lib_dec/ivas_mct_dec_fx.c | 4 -- lib_dec/ivas_mdct_core_dec_fx.c | 22 +++---- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 -- 5 files changed, 46 insertions(+), 66 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a84d0d8dc..704049d9f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9949,9 +9949,6 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - const Word16 isParamMC, -#endif Word16 q_x, Word16 e_sig[CPE_CHANNELS] ); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 2f8bf396f..1eee95a3b 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2573,22 +2573,6 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -#if 0 -static Word16 IMDCT_ivas_fx_adjust_qwin( - Word16 Q_syn_Overl_TDAC, - Word16 Q_syn_Overl, - Word16 Q_old_syn_Overl, - Word16 Q_old_wtda, - Word16 q_win ) -{ - // q_win = s_min( s_min( s_min( s_min( Q_syn_Overl_TDAC , Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ), q_win ); - q_win = s_min( s_min( s_min( Q_syn_Overl_TDAC, Q_syn_Overl ), Q_old_syn_Overl ), Q_old_wtda ); - q_win = s_min( q_win, -1 ); - q_win = s_max( q_win, -2 ); - - return q_win; -} -#endif static Word16 IMDCT_ivas_fx_calc_qwin( Word16 *syn_Overl_TDAC, @@ -2599,9 +2583,12 @@ static Word16 IMDCT_ivas_fx_calc_qwin( Word16 Q_old_syn_Overl, Word16 *old_out_fx, Word16 Q_old_out_fx, - const Word16 FB_flag, - Word16 q_win ) + Word16 q_win, + const Word16 L_frame, + const Word16 L_frameTCX, + const Word16 FB_flag ) { +#if 0 Word16 oldLength; oldLength = L_FRAME32k; @@ -2611,6 +2598,18 @@ static Word16 IMDCT_ivas_fx_calc_qwin( oldLength = L_FRAME48k; move16(); } +#else + Word16 oldLength; + + oldLength = L_frame; + move16(); + if ( FB_flag ) + { + oldLength = L_frameTCX; + move16(); + } +#endif + q_win = 4; move16(); @@ -2736,7 +2735,6 @@ static void TCX_MDCT_Inverse_qwin_fx( negfac = negate( fac ); -#if 1 IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); @@ -2744,9 +2742,7 @@ static void TCX_MDCT_Inverse_qwin_fx( s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } -#else - assert( *q_win == 0 || *q_win == -2 ); -#endif + s = add( x_e, *q_win ); move16(); @@ -2805,7 +2801,6 @@ static void TCX_MDST_Inverse_qwin_fx( negfac = negate( fac ); -#if 1 IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); @@ -2813,9 +2808,7 @@ static void TCX_MDST_Inverse_qwin_fx( s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } -#else - assert( *q_win == 0 || *q_win == -2 ); -#endif + s = add( x_e, *q_win ); move16(); @@ -2893,7 +2886,6 @@ static void TCX_MDXT_Inverse_qwin_fx( signRight = negfac; } -#if 1 IF( allow_qwin_change ) { // x_e + q_win == L_norm_arr(tmp_buf, , *q_win ); @@ -2901,9 +2893,7 @@ static void TCX_MDXT_Inverse_qwin_fx( s = L_norm_arr( tmp_buf + L2, m + R2 + L2 ); *q_win = s_min( sub( s, x_e ), *q_win ); } -#else - assert( *q_win == 0 || *q_win == -2 ); -#endif + s = add( x_e, *q_win ); move16(); @@ -2932,7 +2922,6 @@ static void TCX_MDXT_Inverse_qwin_fx( return; } - #endif void IMDCT_ivas_fx( @@ -3002,7 +2991,7 @@ void IMDCT_ivas_fx( { // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); q_win = IMDCT_ivas_fx_calc_qwin( syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, - hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, FB_flag, q_win ); + hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, L_frame, L_frameTCX, FB_flag ); } #else x_e_hdrm = add( q_win, sub( Q16, q_x ) ); @@ -3083,6 +3072,7 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change ) { + /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ q_win = -2; move16(); allow_qwin_change = 0; @@ -3165,6 +3155,17 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win_prev; +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change ) + { + /* Use fixed q_win to avoid the need to adapt scaling of two TCX5 blocks (less effort with maybe not ideal scaling) */ + q_win = -2; + move16(); + allow_qwin_change = 0; + move16(); + } +#endif + IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, win_fx + L_win, 0, sub( L_win, shr( L_ola, 1 ) ), L_ola, &q_win, allow_qwin_change ); @@ -3202,11 +3203,11 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( s_and( kernel_type, 1 ) ) { - TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, 0 ); + TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); } ELSE { - TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, 0 ); + TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } assert( q_win_prev == q_win ); @@ -3392,14 +3393,10 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN if ( allow_qwin_change ) { -#if 1 // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 1 ); -#else - q_win = -2; -#endif } IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif @@ -4188,7 +4185,7 @@ void decoder_tcx_ivas_fx( /* Scaling up again */ Scale_sig( synth_fx, L_frame_glob, sub( st->Q_syn, q_win ) ); - Scale_sig( synthFB_fx, L_frameTCX_glob, sub( st->Q_syn, q_win ) ); + Scale_sig( synthFB_fx, L_frameTCX_glob, sub( st->Q_syn, q_winFB ) ); // Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, 1 ); Scale_sig( st->hTcxDec->old_syn_Overl, 320, ( -2 - st->hTcxDec->Q_old_syn_Overl ) ); // Scaling to Q-2 @@ -5860,7 +5857,7 @@ void decoder_tcx_imdct_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 shift_q = sub( q_x, *q_win ); + Word16 shift_q = sub( q_x, *q_winFB ); #endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) @@ -5902,7 +5899,7 @@ void decoder_tcx_imdct_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - shift_q = sub( q_x, *q_win ); + shift_q = sub( q_x, *q_winFB ); #endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 4c3b8b782..b34ce0c56 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -346,11 +346,7 @@ ivas_error ivas_mct_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, st_ivas->mc_mode == MC_MODE_PARAMMC, q_output, e_sig ); -#else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); -#endif Word16 hdrm, sh; hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 995aa70e1..56cd70609 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1083,9 +1083,6 @@ void ivas_mdct_core_reconstruct_fx( /* o : synthesis @output_FS */ // e_sig Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - const Word16 isParamMC, -#endif Word16 q_x, Word16 e_sig[CPE_CHANNELS] ) { @@ -1103,7 +1100,9 @@ void ivas_mdct_core_reconstruct_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win = -2; + move16(); Word16 q_winFB = -2; + move16(); #else #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_win = -1; @@ -1130,13 +1129,6 @@ void ivas_mdct_core_reconstruct_fx( bfi = sts[0]->bfi; move16(); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - if ( isParamMC ) - q_win = -2; -#endif -#endif - /* TNS, ITF, IMDCT and updates */ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -1233,7 +1225,9 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } - Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win + // Need to rescale for each subframe, because q_win/q_winFB might change for the next subframe. Other OLA buffers are rescaled each time. + Scale_sig( &synth_fx[k * L_frame[ch]], add( L_frame[ch], M ), sub( st->hTcxDec->q_old_synth, q_win ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( &synthFB_fx[k * L_frameTCX[ch]], add( L_frameTCX[ch], M ), sub( st->hTcxDec->q_old_synth, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth #else IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { @@ -1299,13 +1293,13 @@ void ivas_mdct_core_reconstruct_fx( move16(); Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // q_win -> q_syn - Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_OverlFB ) ); // q_winFB -> st->Q_syn st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); #else test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index e70b1c137..890e5fc9e 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -550,11 +550,7 @@ void stereo_mdct_core_dec_fx( } Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, M + 1, sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); /* Q28 */ -#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) - ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, st_ivas->mc_mode == MC_MODE_PARAMMC, Q11, e_sigFB ); -#else ivas_mdct_core_reconstruct_fx( hCPE, x_fx, signal_outFB_tmp_fx, fUseTns, 0, Q11, e_sigFB ); -#endif Copy32( signal_out_tmp_fx[0], signal_out_fx[0], L_FRAME48k ); /* Q11 */ Copy32( signal_out_tmp_fx[1], signal_out_fx[1], L_FRAME48k ); /* Q11 */ -- GitLab From 85a0fa2eae5acd675c251603a3f733ce51244dfb Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 14 May 2025 14:43:03 +0200 Subject: [PATCH 056/394] clang format --- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 56cd70609..bd20c26d0 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1226,7 +1226,7 @@ void ivas_mdct_core_reconstruct_fx( } // Need to rescale for each subframe, because q_win/q_winFB might change for the next subframe. Other OLA buffers are rescaled each time. - Scale_sig( &synth_fx[k * L_frame[ch]], add( L_frame[ch], M ), sub( st->hTcxDec->q_old_synth, q_win ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( &synth_fx[k * L_frame[ch]], add( L_frame[ch], M ), sub( st->hTcxDec->q_old_synth, q_win ) ); // q_win -> st->hTcxDec->q_old_synth Scale_sig( &synthFB_fx[k * L_frameTCX[ch]], add( L_frameTCX[ch], M ), sub( st->hTcxDec->q_old_synth, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth #else IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) @@ -1297,7 +1297,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); #else -- GitLab From 3292aa1527b10f3dce273c9393a3ffe2dc54a4b6 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 14 May 2025 17:22:24 +0200 Subject: [PATCH 057/394] Small improvement of synth_buf scaling and get rid of some magic constants that are not the right ones anymore. --- lib_dec/ivas_mdct_core_dec_fx.c | 75 +++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index bd20c26d0..5720da8bb 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1099,10 +1099,8 @@ void ivas_mdct_core_reconstruct_fx( Word16 q_syn = 0; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 q_win = -2; - move16(); - Word16 q_winFB = -2; - move16(); + Word16 q_win; + Word16 q_winFB; #else #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_win = -1; @@ -1171,15 +1169,19 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->q_old_synth = 0; move16(); } +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth +#endif q_syn = st->hTcxDec->q_old_synth; move16(); set16_fx( synth_fx, 0, L_FRAME_PLUS + M ); set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M ); IF( st->core != ACELP_CORE ) { -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_win0, q_winFB0; +#else Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win st->hTcxDec->Q_syn_Overl_TDACFB = q_win; move16(); @@ -1209,11 +1211,23 @@ void ivas_mdct_core_reconstruct_fx( init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch], &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + assert( nSubframes[ch] <= 2 ); + q_win0 = q_win; + move16(); + q_winFB0 = q_winFB; + move16(); + q_win = -2; + move16(); + q_winFB = -2; + move16(); +#endif + IF( !skip_decoding ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN test(); test(); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, @@ -1224,11 +1238,9 @@ void ivas_mdct_core_reconstruct_fx( decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB, st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 ); } - - // Need to rescale for each subframe, because q_win/q_winFB might change for the next subframe. Other OLA buffers are rescaled each time. - Scale_sig( &synth_fx[k * L_frame[ch]], add( L_frame[ch], M ), sub( st->hTcxDec->q_old_synth, q_win ) ); // q_win -> st->hTcxDec->q_old_synth - Scale_sig( &synthFB_fx[k * L_frameTCX[ch]], add( L_frameTCX[ch], M ), sub( st->hTcxDec->q_old_synth, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth #else + test(); + test(); IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) { decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win, @@ -1265,6 +1277,26 @@ void ivas_mdct_core_reconstruct_fx( } } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + + IF ( nSubframes[ch] > 1 ) { + Word16 q_winN, q_winFBN; + + q_winN = s_min( q_win, q_win0 ); + q_winFBN = s_min( q_winFB, q_winFB0 ); + // Need to rescale for each subframe, because q_win/q_winFB might had changed for the next subframe. Other OLA buffers are rescaled each time. + Scale_sig( synth_fx, L_frame[ch], sub( q_winN, q_win0 ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synthFB_fx, L_frameTCX[ch], sub( q_winFBN, q_winFB0 ) ); // q_winFB -> st->hTcxDec->q_old_synth + Scale_sig( synth_fx + L_frame[ch], add( L_frame[ch], M ), sub( q_winN, q_win ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synthFB_fx + L_frameTCX[ch], add( L_frameTCX[ch], M ), sub( q_winFBN, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth + q_win = q_winN; + move16(); + q_winFB = q_winFBN; + move16(); + } + + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); + test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) { @@ -1272,18 +1304,17 @@ void ivas_mdct_core_reconstruct_fx( } decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_winFB, NULL, bfi, MCT_flag ); + // norm(synth_buf) >= q_syn - q_win + // norm(synth_buf) + q_win >= q_syn 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 ) ) - { - q_syn = sub( sf, 2 ); - st->Q_syn = q_syn; - move16(); - } + q_syn = add( sf, s_min( q_win, q_winFB ) ); + st->Q_syn = q_syn; + move16(); + + // norm(old_out) >= st->Q_syn - q_win + // norm(old_out) + q_win >= st->Q_syn sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); - IF( LT_16( sf, sub( st->Q_syn, q_win ) ) ) - { - st->Q_syn = add( q_win, sf ); - } + st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDACFB ) ); // q_winFB -> Q(-1 - st->Q_syn) st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); @@ -1297,8 +1328,8 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn - Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, st->hTcxDec->q_old_synth ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); #else test(); -- GitLab From c1f1d26f60d97674df28fbe160514a335cca2ad6 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 14 May 2025 17:25:01 +0200 Subject: [PATCH 058/394] clang format --- lib_dec/ivas_mdct_core_dec_fx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 5720da8bb..0e36179e4 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1278,15 +1278,16 @@ void ivas_mdct_core_reconstruct_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IF ( nSubframes[ch] > 1 ) { + IF( nSubframes[ch] > 1 ) + { Word16 q_winN, q_winFBN; q_winN = s_min( q_win, q_win0 ); q_winFBN = s_min( q_winFB, q_winFB0 ); // Need to rescale for each subframe, because q_win/q_winFB might had changed for the next subframe. Other OLA buffers are rescaled each time. - Scale_sig( synth_fx, L_frame[ch], sub( q_winN, q_win0 ) ); // q_win -> st->hTcxDec->q_old_synth - Scale_sig( synthFB_fx, L_frameTCX[ch], sub( q_winFBN, q_winFB0 ) ); // q_winFB -> st->hTcxDec->q_old_synth - Scale_sig( synth_fx + L_frame[ch], add( L_frame[ch], M ), sub( q_winN, q_win ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synth_fx, L_frame[ch], sub( q_winN, q_win0 ) ); // q_win -> st->hTcxDec->q_old_synth + Scale_sig( synthFB_fx, L_frameTCX[ch], sub( q_winFBN, q_winFB0 ) ); // q_winFB -> st->hTcxDec->q_old_synth + Scale_sig( synth_fx + L_frame[ch], add( L_frame[ch], M ), sub( q_winN, q_win ) ); // q_win -> st->hTcxDec->q_old_synth Scale_sig( synthFB_fx + L_frameTCX[ch], add( L_frameTCX[ch], M ), sub( q_winFBN, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth q_win = q_winN; move16(); @@ -1294,7 +1295,7 @@ void ivas_mdct_core_reconstruct_fx( move16(); } - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); test(); @@ -1328,7 +1329,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; - Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); #else -- GitLab From 0f73e249c0a13909a13d4814b07640956c66c1fe Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 14 May 2025 18:03:21 +0200 Subject: [PATCH 059/394] Fix uninitialized memory in BFI case. --- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 0e36179e4..1776f82e8 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1384,6 +1384,10 @@ void ivas_mdct_core_reconstruct_fx( } ELSE /*ACELP core for ACELP-PLC */ { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth +#endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ IF( MCT_flag != 0 ) -- GitLab From 0bab7023b415c556ad5ba898472b6ce2cad2347f Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 15 May 2025 10:40:04 +0200 Subject: [PATCH 060/394] Increase headroom for ACELP ZIR in TCX/ACELP transition. --- lib_dec/dec_tcx_fx.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1eee95a3b..1553664d5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3450,7 +3450,18 @@ void IMDCT_ivas_fx( acelp_mem_len = 0; move16(); } + #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || st->last_core == ACELP_CORE ) && ( fullbandScale == 0 ) ) + { + /* Increase headroom because if the ACELP ZIR is used below, the synthesis filter gain is unknown. */ + IF ( allow_qwin_change ) { + allow_qwin_change = 0; + move16(); + q_win = s_max( -2, sub( q_win, 2 ) ); + } + } + IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, &q_win, allow_qwin_change ); -- GitLab From f67e5519cf5d942a4064961c1cc638d8a12b7215 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 15 May 2025 10:47:14 +0200 Subject: [PATCH 061/394] clang format --- lib_dec/dec_tcx_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1553664d5..2637f52d7 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3455,7 +3455,8 @@ void IMDCT_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || st->last_core == ACELP_CORE ) && ( fullbandScale == 0 ) ) { /* Increase headroom because if the ACELP ZIR is used below, the synthesis filter gain is unknown. */ - IF ( allow_qwin_change ) { + IF( allow_qwin_change ) + { allow_qwin_change = 0; move16(); q_win = s_max( -2, sub( q_win, 2 ) ); -- GitLab From 3fa130bab9a069fe719266955e142002ab8e3253 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 15 May 2025 15:17:39 +0200 Subject: [PATCH 062/394] Correct asignments of Q_syn_OverlFB which was wrong or missing at some places. --- lib_dec/core_dec_init_fx.c | 17 ++++++++++++++++- lib_dec/er_dec_acelp_fx.c | 4 ++++ lib_dec/er_dec_tcx_fx.c | 20 ++++++++++++++++++++ lib_dec/evs_dec_fx.c | 2 +- lib_dec/ivas_core_dec_fx.c | 3 ++- lib_dec/ivas_mdct_core_dec_fx.c | 12 ++++++------ lib_dec/ivas_stereo_switching_dec_fx.c | 4 ++++ 7 files changed, 53 insertions(+), 9 deletions(-) diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 3ddecdbd5..b83fa8398 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -396,8 +396,15 @@ void open_decoder_LPD_fx( move16(); Copy( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ) ); /* hHQ_core->Q_fer_samples*/ - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_OverlFB = hHQ_core->Q_fer_samples; + move16(); +#endif lerp( hHQ_core->fer_samples_fx + delay_comp, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( hTcxDec->L_frameTCX, 1 ) ); /*Q0: ACELP(bfi)->TCX(rect)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hHQ_core->Q_fer_samples; + move16(); +#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ hHQ_core->Q_old_wtda = -1; @@ -1070,7 +1077,15 @@ void acelp_plc_mdct_transition_fx( move16(); /*CLDFB delay*/ Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_OverlFB = st->hHQ_core->Q_fer_samples; + move16(); +#endif lerp( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( st->hTcxDec->L_frameTCX, 1 ) ); /*ACELP(bfi)->TCX(rect)*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_Overl = st->hHQ_core->Q_fer_samples; + move16(); +#endif /*old_out needed for MODE1 routine and syn_Overl_TDAC for MODE2 routine*/ st->hHQ_core->Q_old_wtda = -1; move16(); diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index e1321d9aa..bcbff9b76 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1104,6 +1104,10 @@ void con_acelp_fx( st->hTcxDec->Q_syn_Overl_TDACFB = st->hTcxDec->Q_syn_Overl_TDAC; move16(); lerp( hTcxDec->syn_Overl, hTcxDec->syn_OverlFB, shr( hTcxDec->L_frameTCX, 1 ), shr( st->L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_OverlFB = hTcxDec->Q_syn_Overl; + move16(); +#endif lerp( hHQ_core->old_out_LB_fx, hHQ_core->old_out_fx, hTcxDec->L_frameTCX, st->L_frame ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index f5b8a1359..912bd9e9d 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -910,7 +910,13 @@ void con_tcx_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#else Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -973,6 +979,10 @@ void con_tcx_fx( /* update memory for low band */ Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; + move16(); +#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); @@ -1865,7 +1875,13 @@ void con_tcx_ivas_fx( bufferCopyFx( syn, synth, L_frame, Q_syn, 0, 0, 0 ); /*Q_syn*/ BASOP_SATURATE_WARNING_ON_EVS +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), sub( 0, Q_syn ) ); /*Q0*/ + hTcxDec->Q_syn_OverlFB = 0; + move16(); +#else Copy_Scale_sig( syn + L_frame, hTcxDec->syn_OverlFB, shr( L_frame, 1 ), negate( Q_syn ) ); /*Q0*/ +#endif /* copy total excitation exc2 as 16kHz for acelp mode1 decoding */ IF( st->hWIDec != NULL ) @@ -1934,6 +1950,10 @@ void con_tcx_ivas_fx( st->hTcxDec->Q_old_syn_Overl = -1; #endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; + move16(); +#endif lerp( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 9f08a281b..38bd7de24 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -167,7 +167,7 @@ ivas_error evs_dec_fx( tmp1 = extract_l( L_shr_r( f, s ) ); /*Q14 - s*/ FOR( i = 0; i < st_fx->hTcxCfg->tcx_mdct_window_lengthFB; i++ ) { - hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); /*hTcxDec->Q_syn_Overl*/ + hTcxDec->syn_OverlFB[i] = shl_sat( mult_sat( tmp1, hTcxDec->syn_OverlFB[i] ), add( s, 1 ) ); /*hTcxDec->Q_syn_OverlFB*/ move16(); } s = norm_l( f ); diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index a27213b6e..e4fb48f4a 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -707,6 +707,7 @@ ivas_error ivas_core_dec_fx( st->hHQ_core->Q_fer_samples = 0; move16(); } +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT IF( NE_16( st->core, st->last_core ) ) { IF( st->hTcxDec ) @@ -716,7 +717,7 @@ ivas_error ivas_core_dec_fx( st->Q_syn = 0; move16(); } - +#endif st->prev_Q_syn = st->Q_syn; move16(); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 1776f82e8..e66704cd2 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1295,8 +1295,8 @@ void ivas_mdct_core_reconstruct_fx( move16(); } - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth - Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // q_win + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); // q_winFB test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) @@ -1331,7 +1331,8 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_Overl = st->Q_syn; Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn - Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); + //Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); + Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); #else test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) @@ -1377,9 +1378,8 @@ void ivas_mdct_core_reconstruct_fx( move16(); #endif #endif -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Scale_sig( st->mem_syn2_fx, M, sub( -2, q_win ) ); - // Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn #endif } ELSE /*ACELP core for ACELP-PLC */ diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 454395648..706b9b568 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -68,6 +68,10 @@ static ivas_error allocate_CoreCoder_TCX_fx( reset_tcx_overl_buf_fx( st->hTcxDec ); // st->hTcxDec->CngLevelBackgroundTrace_bfi = 0; //initializing to avoid garbage overflow; set16_fx( st->hTcxDec->syn_OverlFB, 0, L_FRAME48k / 2 ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_syn_OverlFB = 0; + move16(); +#endif set16_fx( st->hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); st->hTcxDec->q_old_synth = 0; move16(); -- GitLab From dfc50802bda62c6b840317904bc9b11c45ff1c16 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 15 May 2025 15:20:32 +0200 Subject: [PATCH 063/394] clang format --- lib_dec/core_dec_init_fx.c | 2 +- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index b83fa8398..d5a1dfeb0 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1076,7 +1076,7 @@ void acelp_plc_mdct_transition_fx( delay_comp = NS2SA_FX2( st->output_Fs, DELAY_CLDFB_NS ); move16(); /*CLDFB delay*/ - Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ + Copy( st->hHQ_core->fer_samples_fx + delay_comp, st->hTcxDec->syn_OverlFB, shr( st->hTcxDec->L_frameTCX, 1 ) ); /* Q_fer_samples */ #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT st->hTcxDec->Q_syn_OverlFB = st->hHQ_core->Q_fer_samples; move16(); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index e66704cd2..2940a169b 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1331,7 +1331,7 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_Overl = st->Q_syn; Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn - //Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); + // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); #else test(); -- GitLab From 9794aa2354b81a26a823e6d62f76051849667e8b Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 15 May 2025 17:28:28 +0200 Subject: [PATCH 064/394] Increase headroom in q_win calculation. Fixes regression for MASA_2dir_2TC_bitrate_switching_from_13_2_kbps_to_512_kbps_48kHz_in_48kHz_out_EXT_out_JBM_Prof_5 --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 2637f52d7..b51493262 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3396,7 +3396,7 @@ void IMDCT_ivas_fx( // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 - q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 1 ); + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); } IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif -- GitLab From 701d1978b19ceae4fce47a162ae9816f690320d0 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 30 Apr 2025 10:52:39 +0530 Subject: [PATCH 065/394] Optimizations for SBA path functions --- lib_com/cldfb.c | 450 +++++++++- lib_com/ivas_dirac_com_fx.c | 25 + lib_com/ivas_prot_fx.h | 20 +- lib_com/ivas_transient_det_fx.c | 19 +- lib_com/options.h | 2 + lib_com/rom_com.c | 773 ++++++++++++++++++ lib_com/rom_com_fx.h | 21 +- lib_com/stat_com.h | 7 +- lib_dec/ivas_dirac_dec_fx.c | 47 +- lib_dec/ivas_mct_core_dec_fx.c | 71 +- lib_dec/ivas_mct_dec_mct_fx_fx.c | 33 +- lib_dec/ivas_mdct_core_dec_fx.c | 4 + lib_dec/ivas_stereo_mdct_core_dec_fx.c | 6 + lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 20 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 345 +++++++- 15 files changed, 1779 insertions(+), 64 deletions(-) diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index bf832b640..607d1bf9f 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -104,8 +104,12 @@ void cldfbAnalysis_ivas_fx( Word32 iBuffer_fx[2 * CLDFB_NO_CHANNELS_MAX]; const Word32 *rot_vctr_re_fx; const Word32 *rot_vctr_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -147,8 +151,12 @@ void cldfbAnalysis_ivas_fx( rot_vctr_re_fx = h_cldfb->rot_vec_ana_re_fx; rot_vctr_im_fx = h_cldfb->rot_vec_ana_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -156,6 +164,32 @@ void cldfbAnalysis_ivas_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx @@ -180,10 +214,11 @@ void cldfbAnalysis_ivas_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // Qx - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // Qx - 1 @@ -207,6 +242,31 @@ void cldfbAnalysis_ivas_fx( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // Qx + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // Qx + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // Qx + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // Qx +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // Qx r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // Qx @@ -235,6 +295,7 @@ void cldfbAnalysis_ivas_fx( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // Qx - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // Qx - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // Qx - 1 @@ -323,8 +384,12 @@ void cldfbAnalysis_ts_fx( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -371,8 +436,12 @@ void cldfbAnalysis_ts_fx( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -380,6 +449,31 @@ void cldfbAnalysis_ts_fx( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[L2 - M2 - 1 - ( 2 * k ) + 0 * L2] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -404,10 +498,11 @@ void cldfbAnalysis_ts_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 @@ -417,8 +512,8 @@ void cldfbAnalysis_ts_fx( rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 #else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -431,8 +526,8 @@ void cldfbAnalysis_ts_fx( iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 #else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -441,6 +536,31 @@ void cldfbAnalysis_ts_fx( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -465,10 +585,11 @@ void cldfbAnalysis_ts_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 @@ -640,8 +761,12 @@ void cldfbAnalysis_ts_fx_var_q( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize; @@ -705,8 +830,12 @@ void cldfbAnalysis_ts_fx_var_q( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -714,6 +843,31 @@ void cldfbAnalysis_ts_fx_var_q( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -738,10 +892,11 @@ void cldfbAnalysis_ts_fx_var_q( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 @@ -765,6 +920,32 @@ void cldfbAnalysis_ts_fx_var_q( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -793,6 +974,7 @@ void cldfbAnalysis_ts_fx_var_q( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 @@ -911,8 +1093,12 @@ void cldfbAnalysis_ts_fx_fixed_q( const Word32 *rot_vctr_im_fx; const Word32 *rot_vctr_delay_re_fx; const Word32 *rot_vctr_delay_im_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *ptr_pf_fx; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *ptr_pf_fx; Word16 ptr_pf_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )]; Word16 offset, frameSize, gb, hr, shift; @@ -958,8 +1144,12 @@ void cldfbAnalysis_ts_fx_fixed_q( rot_vctr_delay_re_fx = h_cldfb->rot_vec_ana_delay_re_fx; // q = 31 rot_vctr_delay_im_fx = h_cldfb->rot_vec_ana_delay_im_fx; // q = 31 +#ifdef OPT_IVAS_FILTER_ROM + ptr_pf_fx = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ ptr_pf_fx = h_cldfb->p_filter; - ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 + ptr_pf_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); FOR( i = 0; i < no_col; i++ ) @@ -967,6 +1157,31 @@ void cldfbAnalysis_ts_fx_fixed_q( FOR( k = 0; k < M4; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -991,10 +1206,11 @@ void cldfbAnalysis_ts_fx_fixed_q( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 @@ -1018,6 +1234,31 @@ void cldfbAnalysis_ts_fx_fixed_q( FOR( k = M4; k < M2; k++ ) { /* prototype filter */ +#ifdef OPT_IVAS_FILTER_ROM + r1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + r1_fx = Msub_32_32( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + r2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + r2_fx = Msub_32_32( r2_fx, timeBuffer_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 5 * M2 + ( 2 * k ) + 4 * L2 )] ); // q + + i1_fx = Msub_32_32( 0, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 3 * L2 )] ); // q + i1_fx = Msub_32_32( i1_fx, timeBuffer_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 + M2 - 1 - ( 2 * k ) + 4 * L2 )] ); // q + + i2_fx = Msub_32_32( 0, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 0 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 1 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 2 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q + i2_fx = Msub_32_32( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q +#else /* OPT_IVAS_FILTER_ROM */ r1_fx = Msub_32_16( 0, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 0 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 1 * L2 )] ); // q r1_fx = Msub_32_16( r1_fx, timeBuffer_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )], ptr_pf_fx[( L2 - M2 - 1 - ( 2 * k ) + 2 * L2 )] ); // q @@ -1046,6 +1287,7 @@ void cldfbAnalysis_ts_fx_fixed_q( r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 +#endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 @@ -1203,8 +1445,12 @@ void cldfbSynthesis_ivas_fx( Word32 new_samples_fx[2 * CLDFB_NO_CHANNELS_MAX]; Word32 *ptr_time_out_fx; +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ const Word16 *p_filter; Word16 p_filter_sf; +#endif /* OPT_IVAS_FILTER_ROM */ Word32 accu0, accu1, accu2, accu3, accu4; Word16 no_col = h_cldfb->no_col; @@ -1234,9 +1480,12 @@ void cldfbSynthesis_ivas_fx( synthesisBuffer_fx = buffer_fx; Copy32( h_cldfb->cldfb_state_fx, synthesisBuffer_fx + i_mult( M1, no_col ), h_cldfb->p_filter_length ); +#ifdef OPT_IVAS_FILTER_ROM + p_filter_32 = h_cldfb->p_filter_32; +#else /* OPT_IVAS_FILTER_ROM */ p_filter = h_cldfb->p_filter; - p_filter_sf = h_cldfb->p_filter_sf; // Q14 - move16(); + p_filter_sf = h_cldfb->p_filter_sf; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ ptr_time_out_fx = timeOut_fx; /*synthesisBuffer += M1 * h_cldfb->no_col;*/ @@ -1347,11 +1596,19 @@ void cldfbSynthesis_ivas_fx( { FOR( i = 0; i < L2; i++ ) { +#ifdef OPT_IVAS_FILTER_ROM + accu0 = Madd_32_32( synthesisBuffer_fx[i], new_samples_fx[L2 - 1 - i], p_filter_32[i] ); // Qx - 1 + accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 1 * L2 + i )] ); // Qx - 1 + accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 2 * L2 + i )] ); // Qx - 1 + accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 3 * L2 + i )] ); // Qx - 1 + accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], new_samples_fx[L2 - 1 - i], p_filter_32[( 4 * L2 + i )] ); // Qx - 1 +#else /* OPT_IVAS_FILTER_ROM */ accu0 = Madd_32_16( synthesisBuffer_fx[i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[i] ), p_filter_sf ); // Qx - 1 accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 1 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 2 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 3 * L2 + i )] ), p_filter_sf ); // Qx - 1 accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter[( 4 * L2 + i )] ), p_filter_sf ); // Qx - 1 +#endif /* OPT_IVAS_FILTER_ROM */ synthesisBuffer_fx[i] = accu0; move32(); @@ -1370,12 +1627,21 @@ void cldfbSynthesis_ivas_fx( FOR( i = 0; i < L2; i++ ) { +#ifdef OPT_IVAS_FILTER_ROM + Word32 prod = L_shl_sat( ( new_samples_fx[L2 - 1 - i] ), shift ); + accu0 = Madd_32_32( synthesisBuffer_fx[i], prod, p_filter_32[i] ); // Qx -1 + shift + accu1 = Madd_32_32( synthesisBuffer_fx[1 * L2 + i], prod, p_filter_32[( 1 * L2 + i )] ); // Qx -1 + shift + accu2 = Madd_32_32( synthesisBuffer_fx[2 * L2 + i], prod, p_filter_32[( 2 * L2 + i )] ); // Qx -1 + shift + accu3 = Madd_32_32( synthesisBuffer_fx[3 * L2 + i], prod, p_filter_32[( 3 * L2 + i )] ); // Qx -1 + shift + accu4 = Madd_32_32( synthesisBuffer_fx[4 * L2 + i], prod, p_filter_32[( 4 * L2 + i )] ); // Qx -1 + shift +#else /* OPT_IVAS_FILTER_ROM */ Word32 prod = L_shl_sat( Mpy_32_16_1( new_samples_fx[L2 - 1 - i], p_filter_sf ), shift ); accu0 = Madd_32_16( synthesisBuffer_fx[i], prod, p_filter[i] ); // Qx -1 + shift accu1 = Madd_32_16( synthesisBuffer_fx[1 * L2 + i], prod, p_filter[( 1 * L2 + i )] ); // Qx -1 + shift accu2 = Madd_32_16( synthesisBuffer_fx[2 * L2 + i], prod, p_filter[( 2 * L2 + i )] ); // Qx -1 + shift accu3 = Madd_32_16( synthesisBuffer_fx[3 * L2 + i], prod, p_filter[( 3 * L2 + i )] ); // Qx -1 + shift accu4 = Madd_32_16( synthesisBuffer_fx[4 * L2 + i], prod, p_filter[( 4 * L2 + i )] ); // Qx -1 + shift +#endif /* OPT_IVAS_FILTER_ROM */ synthesisBuffer_fx[i] = accu0; move32(); @@ -1848,8 +2114,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; - hs->p_filter_sf = (Word16) 17036; // Q14 +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_10_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1860,8 +2130,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_10_SCALE_FX_Q8; } BREAK; @@ -1879,8 +2153,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_16_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1891,8 +2169,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_16_SCALE_FX_Q8; } BREAK; @@ -1910,8 +2192,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_20_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1922,8 +2208,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15390; // Q14 hs->p_filter = LDQMF_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_20_SCALE_FX_Q8; } BREAK; @@ -1941,8 +2231,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_30_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_30_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1953,8 +2247,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_30_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_30_SCALE_FX_Q8; } BREAK; @@ -1972,8 +2270,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_32_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -1984,8 +2286,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15392; // Q14 hs->p_filter = LDQMF_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_32_SCALE_FX_Q8; } BREAK; @@ -2003,8 +2309,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_40_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -2015,8 +2325,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_40_SCALE_FX_Q8; } BREAK; @@ -2034,8 +2348,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_60_SCALE_FX_Q8; } ELSE IF( EQ_32( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) @@ -2046,8 +2364,12 @@ static void cldfb_init_proto_and_twiddles( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = LDQMF_60_SCALE_FX_Q8; } BREAK; @@ -2094,11 +2416,15 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17036; // Q14 hs->scale = cldfb_scale_2_5ms[0]; move16(); move16(); +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ } ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { @@ -2110,8 +2436,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_10_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_10_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[0]; move16(); move16(); @@ -2139,8 +2469,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[1]; move16(); move16(); @@ -2155,8 +2489,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_16_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15388; // Q14 hs->p_filter = LDQMF_16_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[1]; move16(); move16(); @@ -2191,8 +2529,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[2]; move16(); move16(); @@ -2207,8 +2549,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_20_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15390; // Q14 hs->p_filter = LDQMF_20_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[2]; move16(); move16(); @@ -2242,9 +2588,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17051; // Q14 hs->scale = cldfb_scale_2_5ms[6]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = CLDFB80_30_fx; + hs->p_filter_sf = (Word16) 17051; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ } ELSE IF( EQ_16( hs->prototype, CLDFB_PROTOTYPE_5_00MS ) ) { @@ -2256,9 +2606,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_sf = (Word16) 15388; // Q14 hs->scale = cldfb_scale_5_0ms[6]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_30_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = LDQMF_30_fx; + hs->p_filter_sf = (Word16) 15388; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2285,8 +2639,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17050; // Q14 hs->p_filter = CLDFB80_32_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[3]; move16(); move16(); @@ -2301,9 +2659,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; - hs->p_filter_sf = (Word16) 15392; // Q14 hs->scale = cldfb_scale_5_0ms[3]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_32_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = LDQMF_32_fx; + hs->p_filter_sf = (Word16) 15392; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2336,9 +2698,13 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; - hs->p_filter_sf = (Word16) 17051; // Q14 hs->scale = cldfb_scale_2_5ms[4]; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter = CLDFB80_40_fx; + hs->p_filter_sf = (Word16) 17051; // Q14 +#endif /* OPT_IVAS_FILTER_ROM */ move16(); move16(); } @@ -2352,8 +2718,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_40_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_40_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[4]; move16(); move16(); @@ -2387,8 +2757,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = NULL; hs->rot_vec_syn_delay_re_fx = NULL; hs->rot_vec_syn_delay_im_fx = NULL; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = CLDFB80_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 17051; // Q14 hs->p_filter = CLDFB80_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_2_5ms[5]; move16(); move16(); @@ -2403,8 +2777,12 @@ static void cldfb_init_proto_and_twiddles_enc_fx( hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx; hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx; hs->rot_vec_syn_delay_im_fx = rot_vec_delay_im_LDQMF_fx; +#ifdef OPT_IVAS_FILTER_ROM + hs->p_filter_32 = LDQMF_60_fx; +#else /* OPT_IVAS_FILTER_ROM */ hs->p_filter_sf = (Word16) 15391; // Q14 hs->p_filter = LDQMF_60_fx; +#endif /* OPT_IVAS_FILTER_ROM */ hs->scale = cldfb_scale_5_0ms[5]; move16(); move16(); diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 4279065b0..eb5de9460 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -1026,6 +1026,7 @@ void computeDiffuseness_fixed( q_intensity_slow = sub( add( q_intensity, q_intensity ), 31 ); /* Compute Diffuseness */ +#ifndef OPT_SBA_DEC_PATH p_tmp = intensity_slow_abs; exp2 = 0; move16(); @@ -1064,6 +1065,30 @@ void computeDiffuseness_fixed( move32(); } } +#else /* OPT_SBA_DEC_PATH */ + Word16 diff = sub( 62, q_ene ); + p_tmp = intensity_slow_abs; + FOR( i = 0; i < num_freq_bands; ++i ) + { + + exp1 = sub( 31, q_intensity_slow ); + tmp = Sqrt32( p_tmp[i], &exp1 ); + + tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); + q_tmp = sub( diff, add( exp1, exp2 ) ); + // bring to Q30 + tmp = L_shl_sat( tmp, sub( Q30, q_tmp ) ); + diffuseness[i] = L_sub( ONE_IN_Q30, tmp ); + move32(); + + if ( LT_32( diffuseness[i], 0 ) ) + { + diffuseness[i] = 0; + move32(); + } + } + +#endif /* OPT_SBA_DEC_PATH */ *q_diffuseness = Q30; move16(); diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 8b6cdcac9..10d6b1629 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1092,10 +1092,14 @@ void ivas_mct_dec_mct_fx( ); void apply_MCT_dec_fx( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */ - Word16 q_x[MCT_MAX_CHANNELS] ); + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + Decoder_State **sts, /* i/o: decoder state structure */ + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +); void mctStereoIGF_dec_fx( MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ @@ -1129,9 +1133,13 @@ void stereo_decoder_tcx_fx( const Word16 mct_on, /* i : flag mct block (1) or stereo (0) */ const Word16 last_core_l, /* i : last core for left channel */ const Word16 last_core_r, /* i : last core for right channel */ - const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision */ + const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision */ +#ifndef OPT_SBA_DEC_PATH + , Word16 *q_x_ch2, - Word16 *q_x_ch1 ); + Word16 *q_x_ch1 +#endif /* OPT_SBA_DEC_PATH */ +); void v_multc_acc_32_16( const Word32 x[], /* i : Input vector */ diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index fb8679ebc..02f8713a8 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -43,8 +43,12 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 +#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#ifndef OPT_SBA_DEC_PATH +#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 +#else /* OPT_SBA_DEC_PATH */ +#define IVAS_TDET_PARM_ENV_EPS_fx ( 1407374884 ) // Q47 +#endif /* OPT_SBA_DEC_PATH */ #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 @@ -403,8 +407,19 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ +#ifndef OPT_SBA_DEC_PATH e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); move32(); +#else /* OPT_SBA_DEC_PATH */ + Word32 tmp = L_abs( e_fast_fx[i] ); + Word16 nrm = norm_l( tmp ); + Word16 max_e = s_max( sub( e_fast_e[i], nrm ), 31 - 47 ); + max_e = add( max_e, 1 ); // 1 for headroom + e_fast_fx[i] = L_add( L_shr( tmp, sub( max_e, e_fast_e[i] ) ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, sub( max_e, 31 - 47 ) ) ); + move32(); + e_fast_e[i] = max_e; + move16(); +#endif /* OPT_SBA_DEC_PATH */ e_slow_fx[i] = e_fast_fx[i]; move32(); e_slow_e[i] = e_fast_e[i]; diff --git a/lib_com/options.h b/lib_com/options.h index 75323cf13..cfa652ea7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -76,6 +76,8 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ #define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ +#define OPT_SBA_DEC_PATH /* Optimization made in SBA decoding path */ +#define OPT_IVAS_FILTER_ROM /* Optimization made in IVAS filter table */ #define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ #define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ /* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index a5c8a3b7c..d1a1564cb 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -5197,6 +5197,7 @@ const Word16 freqTable[2] = {20, 40}; // Q0 /* SNR: 109.44, PHASE: 3.500000000000000 */ /* SNR: 109.44, PHASE: 3.500000000000000 */ +#ifndef OPT_IVAS_FILTER_ROM const Word16 CLDFB80_10_fx[100] = // q = 15 sf = 17036 qsf = 14 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, -2, 0, 0, 0, -1, 0, 0, 0, -8, -31, @@ -5432,6 +5433,778 @@ const Word16 LDQMF_60_fx[] = // q = 15 sf = 15391 qsf = 14 -142, -123, -104, -88, -72, -57, -44, -28, }; +#else /* OPT_IVAS_FILTER_ROM */ + +const Word32 CLDFB80_10_fx[100] = // q = 30 +{ + 3584, -2500, -706, 157, -1170, -1037, +-11, -1944, -1380, 1837, 14726, -9095, +-1690, -266, 3897, -4704, 419, 4651, +5274, -6638, -243746, -72520, -17070, 14830, +-23631, -38285, 18452, -20884, -6244, -281514, +-1070487, -153328, -20195, -4337, -209847, 194011, +24972, -5105, -34468, 1151401, -2164680, -832327, +376719, 1686598, 1844777, 1697324, 2356307, 3037446, +3248821, 1779295, -1533240, -1713947, 833815, 2751562, +2421811, 284255, -3540922, -6991555, -10248264, -14642952, +20031906, 26043234, 34417552, 45928496, 60756732, 78698864, +98151832, 116245496, 129823136, 136344976, 134601568, 122059576, +95304000, 53433792, -3371364, -74987256, -160511088, -258343120, +-366360320, -481533344, 599091264, 714631872, 823505600, 920768896, +1001735168, 1062249792, 1100603392, 1116473216, 1114030976, 1091249536, +1031959808, 939413760, 835792512, 727712064, 614651648, 499141824, +382288320, 266885408, 148867680, 44714176 +}; + + +/* SNR: 292.49, PHASE: 2.000000000000000 */ +const Word32 CLDFB80_16_fx[160] = // q = 30 +{ 591, -823, -251, 103, 63, -1, +-19, 2357, 3221, -17, -2, 75, +36, -82, -596, 808, 2242, -3034, +-755, 254, 126, -434, 106, -19349, +26445, -100, 482, -149, -90, 246, +2196, -3062, -344116, -158536, -67239, -47926, +-21714, 16230, 6227, 48320, 46493, 5448, +17932, -33783, -26258, -13467, -97910, -469416, +-1317170, -563405, -199455, -118497, -43264, 11679, +-61886, 64705, -248885, 55868, 3767, 67210, +64791, 39611, 345777, 1796799, -2314105, -1658357, +-815220, -115680, 761412, 1616442, 1931089, 1230669, +1712205, 1949652, 2418775, 2970521, 3179526, 3272215, +2739045, 1383590, -1186344, -2091283, -1594461, -20541, +1561481, 2685864, 2822045, 2243697, 1007269, -1321111, +-3774214, -5979353, -7970746, -10025660, -12576468, -15588057, +19092548, 22464968, 26489252, 31480652, 37681832, 45115060, +53868456, 63884792, 75139712, 87185504, 99355152, 110921760, +121117896, 129158840, 134480400, 136595408, 135565040, 130704096, +120827352, 105296200, 83827480, 56486836, 23319760, -15680647, +-60454808, -110775264, -166285472, -226570624, -291114656, -359358976, +-430528992, -503583200, 577127680, 650096768, 721690560, 790528896, +855345280, 915113088, 968648896, 1014713216, 1052549440, 1081848192, +1102232576, 1113723648, 1117499392, 1114694144, 1104247168, 1084392960, +1047294336, 993703296, 933123072, 868665920, 802559168, 734628416, +664562240, 593135168, 520952544, 448011680, 375024864, 302909728, +230463232, 156264608, 85568040, 29877076 +}; + + +/* SNR: 89.77, PHASE: 1.500000000000000 */ +const Word32 CLDFB80_20_fx[200] = // q = 30 +{ 1767, -5031, -87, -195, 25, 203, +-253, -754, -8, 5224, 7568, 3, +160, -101, 462, -84, -114, 1650, +-2693, 4754, 4945, -22236, -523, -657, +64, 468, -401, -1020, 719, -9361, +12272, -827, -312, 169, -1088, 201, +406, -7057, 12038, -3892, -327043, -222151, +-35479, -70712, -44739, -22286, -4949, 10391, +-6975, 55398, 27634, -7373, 3144, -22480, +-20585, -25326, -30792, 63870, -118589, -531211, +-1262671, -706692, -140674, -191397, -107626, -49945, +-20211, 30609, -145958, 302171, -516943, 139837, +-27637, 62098, 52143, 58316, 81974, -160536, +375017, 1963205, -2140127, -2009648, -925313, -652848, +-36271, 664399, 1339893, 1799274, 1945125, 831664, +1777055, 1828829, 2078398, 2585600, 2993432, 3154609, +3289692, 3034094, 2356141, 1146722, -993260, -1911081, +-2021484, -1182252, 157140, 1427332, 2466904, 2979249, +2692828, 2193128, 1283653, -616498, -2589952, -4472528, +-6187298, -7776616, -9380603, -11192438, -13438549, -15899665, +18725886, 21392202, 24336266, 27874318, 32044188, 37006492, +42749912, 49318540, 56747120, 64938688, 73960840, 83528888, +93302528, 102923904, 112017456, 120184144, 127010856, 132191136, +135478896, 136610544, 135791440, 132663544, 126439184, 116783968, +103416816, 86239880, 65299188, 40633116, 12229525, -19893306, +-55715672, -95119752, -137902624, -183892768, -232841840, -284483936, +-338536576, -394642624, -452297696, -510956224, 569805312, 628294144, +686151296, 742695360, 797209408, 849073920, 897777728, 942743488, +983299712, 1018874944, 1049145600, 1073975296, 1093176448, 1106582656, +1114420736, 1117424512, 1116238848, 1110577792, 1099271424, 1081958528, +1052270720, 1010577920, 964128448, 914037760, 862118336, 809238464, +755241024, 699830528, 643231744, 585949312, 528205504, 469954944, +411440896, 353300032, 295721536, 237791168, 178588864, 119772248, +66882256, 25081918 +}; + + +/* SNR: 89.29, PHASE: 0.833333333333333 */ +const Word32 CLDFB80_30_fx[300] = // q = 30 +{ -297, 3584, 1941, -855, -2500, -17, +107, -706, 30, 15, 157, 303, +45, -1170, 5206, 7620, -1037, 38, +475, -11, -28, -11, -1944, 58, +-3, -1380, -659, 1052, 1837, -2898, +-12991, 14726, 8111, -3475, -9095, -22, +265, -1690, 45, -32, -266, 592, +210, 3897, 9064, -12976, -4704, -177, +-1102, 419, 158, 60, 4651, -142, +-10, 5274, 2753, -4425, -6638, 19638, +-341194, -243746, -157895, -76328, -72520, -65718, +-49274, -17070, -21325, -4817, 14830, 27865, +-1521, -23631, 5019, -51348, -38285, -877, +59535, 18452, -11250, -36821, -20884, -26546, +-28596, -6244, -16612, -92408, -281514, -679649, +-1089988, -1070487, -687312, -252029, -153328, -178006, +-122647, -20195, -41359, -29532, -4337, 53190, +-112252, -209847, 617831, -803951, 194011, 106900, +-106998, 24972, 64775, 70953, -5105, 66493, +77725, -34468, 24004, 399486, 1151401, 2091330, +-1945866, -2164680, -1871141, -1133489, -832327, -560634, +-144700, 376719, 793102, 1258629, 1686598, 1843271, +1942367, 1844777, 286874, 1790714, 1697324, 1882734, +2048236, 2356307, 2670961, 2960783, 3037446, 3187787, +3282833, 3248821, 2972460, 2561469, 1779295, 779689, +-670109, -1533240, -2023874, -2068453, -1713947, -979306, +-79111, 833815, 1606493, 2311180, 2751562, 2948542, +2758276, 2421811, 2144317, 1669907, 284255, -925660, +-2240403, -3540922, -4767758, -5909822, -6991555, -8035796, +-9103931, -10248264, -11549851, -13052389, -14642952, -16334399, +18220558, 20031906, 21872604, 23814234, 26043234, 28516756, +31295850, 34417552, 37909524, 41736344, 45928496, 50500180, +55453996, 60756732, 66352956, 72392624, 78698864, 85151696, +91671536, 98151832, 104484224, 110553528, 116245496, 121424144, +125981624, 129823136, 132872256, 135069696, 136344976, 136548112, +135995744, 134601568, 131846392, 127706624, 122059576, 114818808, +105909512, 95304000, 83010216, 69049472, 53433792, 36159948, +17222988, -3371364, -25594396, -49478012, -74987256, -102019216, +-130543792, -160511088, -191851984, -224489536, -258343120, -293333280, +-329374368, -366360320, -404158112, -442603456, -481533344, -520813312, +560055680, 599091264, 637996480, 676579264, 714631872, 751940864, +788293056, 823505600, 857424640, 889902848, 920768896, 949826944, +976873792, 1001735168, 1024295104, 1044475456, 1062249792, 1077572608, +1090377088, 1100603392, 1108260608, 1113474048, 1116473216, 1117510400, +1116725248, 1114030976, 1109119488, 1101598848, 1091249536, 1078932736, +1059134272, 1031959808, 1003169408, 972174976, 939413760, 905472960, +870845632, 835792512, 800328576, 764335744, 727712064, 690466496, +652724672, 614651648, 576357376, 537862912, 499141824, 460206112, +421184800, 382288320, 343676096, 305305440, 266885408, 228014720, +188521408, 148867680, 110353960, 74971128, 44714176, 18455688 +}; + + +const Word32 CLDFB80_32_fx[320] = // q = 30 +{ + -1093, 2019, -1499, 75, -3258, -199, +1, 86, -306, -6, -371, -406, +685, 39, -1685, 4713, 6814, -1488, +47, 777, -40, -130, 24, -872, +225, -4, -115, -555, -123, -750, +1333, -5815, -17695, 8208, -6988, 238, +-11912, -668, 1, 205, -738, 0, +-579, -811, 1616, 569, 3827, 10109, +-14334, -4600, -627, -1934, 179, 185, +-69, 2086, -538, 14, 407, 1523, +584, 3600, -4501, 26170, -348871, -274412, +-191283, -101650, -55022, -71745, -57838, -39469, +-16489, -17154, -4617, 1541, 27531, -4837, +-24078, -6040, -61575, -45938, -4350, 52992, +-21466, -30551, -47623, -16878, -16327, -28525, +-30774, 45781, -47860, -103960, -321282, -704887, +-1065517, -1123684, -707166, -371532, -86308, -196314, +-147629, -95796, -26567, -30200, -12084, -23645, +30175, -133296, -186725, 644643, -823105, 165913, +127128, -77847, 76138, 59764, 84596, 13695, +44920, 72596, 82826, -180229, 163870, 385659, +1272551, 2097219, -1940583, -2216917, -1963534, -1312194, +-811283, -684818, -332127, 81208, 566323, 995811, +1374732, 1743252, 1885232, 1944745, 1791356, 230889, +1776037, 1693754, 1848743, 2021967, 2237951, 2554531, +2866857, 3010232, 3111818, 3235821, 3289504, 3179983, +2912034, 2438977, 1724392, 733946, -625865, -1486531, +-1958889, -2094027, -1863598, -1255187, -454123, 425746, +1212702, 1901282, 2517749, 2869908, 2908450, 2719155, +2384774, 2140991, 1717492, 398306, -731735, -1939479, +-3196994, -4359654, -5453402, -6492968, -7485700, -8462297, +-9485345, -10586349, -11872517, -13293064, -14799378, -16391634, +18159074, 19878216, 21572990, 23372214, 25384474, 27638258, +30127980, 32911950, 36012916, 39421380, 43135868, 47172528, +51552328, 56259572, 61272356, 66530936, 72196904, 78102488, +84136944, 90243120, 96340328, 102334376, 108124720, 113633800, +118743656, 123354504, 127384760, 130768192, 133428752, 135331936, +136411184, 136532064, 136012736, 134791376, 132367184, 128735088, +123803096, 117494272, 109734136, 100486232, 89749032, 77539936, +63866580, 48743548, 32160198, 14114131, -5387418, -26313940, +-48704924, -72531920, -97696000, -124178280, -151940320, -180929216, +-211078752, -242327632, -274608448, -307853568, -341987136, -376916512, +-412518528, -448658976, -485200704, -522047808, 558838528, 595432000, +631934592, 668176768, 703995904, 739213504, 773652800, 807151808, +839574912, 870801792, 900704320, 929133248, 955922048, 980906240, +1003949120, 1024962240, 1043881152, 1060686784, 1075342592, 1087794688, +1097989248, 1105913344, 1111637504, 1115325568, 1117191552, 1117410816, +1116024960, 1112890624, 1107711872, 1100166016, 1090143104, 1078585600, +1060024128, 1034545088, 1007817280, 979127552, 948772416, 917237312, +884973248, 852271488, 819225472, 785777536, 751820160, 717295872, +682246976, 646793792, 611070144, 575157504, 539069056, 502781984, +466300064, 429718016, 393203360, 356913536, 320878656, 284927936, +248740064, 212036736, 174863904, 137843808, 102263632, 69872776, +42173520, 17586372 +}; + + +/* SNR: 81.55, PHASE: 0.500000000000000 */ +const Word32 CLDFB80_40_fx[400] = // q = 30 +{ +-4459, -418, -3626, 1423, -337, -2077, +302, 18, 81, 158, -711, 8, +12, -288, -781, 598, -25, 260, +-439, 2799, 3757, -185, 230, -43, +681, -21, -75, -28, -54, -1949, +416, 55, 15, 232, 886, -479, +680, -2718, -568, -16447, -33103, -1653, +-16423, 6274, -1401, -7536, 1255, 81, +201, 378, -1703, -5, -26, -664, +-1194, 1294, -17, 118, -11444, 11395, +-15922, 16042, 174, 77, -1654, 102, +374, 132, 160, 4663, -995, -137, +-67, -969, -4392, 2058, -3082, 11738, +-993, 52507, -372469, -339964, -238019, -154668, +-91226, -39704, -68193, -63465, -52270, -36720, +-12971, -20430, -6924, 7426, -2360, 29241, +919, -11368, 13935, -42083, -90219, 4459, +-7455, 294, 60570, -36065, -9835, -23629, +-40549, -22838, -11572, -27316, -28142, -21798, +74246, -37442, -94760, -175260, -418504, -781460, +-995764, -1274141, -822204, -644197, -320592, -79371, +-211045, -170431, -131251, -90675, -8614, -38864, +-25805, 10490, -21114, 43834, -93771, -212051, +-80066, 687823, -841077, -28318, 196054, 89800, +-98757, 81412, 22561, 71309, 76947, -1234, +38817, 69236, 75947, 74312, -220677, 108139, +388007, 614410, 1602908, 2104013, -1945961, -2345233, +-2073810, -1788973, -1237041, -801096, -773094, -511060, +-205271, 126459, 548962, 854331, 1215259, 1516757, +1754372, 1867886, 1938796, 1938331, 1525725, 104198, +1696967, 1687207, 1745904, 1910501, 2033618, 2194667, +2472077, 2712787, 2937868, 3012595, 3095693, 3204092, +3274807, 3283756, 3148591, 2939051, 2641685, 2031331, +1549502, 597843, -490013, -1328870, -1713435, -2059616, +-2084878, -1903964, -1464478, -873102, -195310, 513855, +1135792, 1697317, 2228107, 2629045, 2909610, 2926213, +2785542, 2569873, 2293849, 2134484, 1852516, 752396, +-164139, -1082527, -2067571, -3082100, -4010647, -4913512, +-5770452, -6592736, -7388101, -8166445, -8966356, -9806266, +-10700961, -11733450, -12861255, -14030459, -15273330, -16566203, +17977196, 19420796, 20683474, 22109952, 23560036, 25167814, +26942868, 28845886, 30930688, 33206692, 35686848, 38368864, +41237952, 44313740, 47594052, 51099240, 54815852, 58726668, +62834600, 67067844, 71610536, 76321632, 81103048, 85964624, +90855304, 95735248, 100552568, 105257896, 109812680, 114164760, +118253480, 122029112, 125449296, 128468360, 131068744, 133194984, +134844544, 135983552, 136548480, 136476080, 136056288, 135290432, +133727152, 131405624, 128303264, 124356992, 119537688, 113797504, +107116320, 99479544, 90889712, 81356080, 70886368, 59482072, +47150368, 33884192, 19681098, 4546189, -11521655, -28482206, +-46395036, -65246120, -84945856, -105504280, -126897840, -149107856, +-172107808, -195862240, -220341504, -245510512, -271335616, -297782912, +-324814976, -352387008, -380449280, -408931776, -437767552, -466890752, +-496221408, -525752320, 555187200, 584450368, 613710272, 642840512, +671780800, 700438528, 728721728, 756541312, 783807872, 810444608, +836384512, 861566464, 885927424, 909395008, 931888896, 953321728, +973609216, 992677120, 1010468928, 1026949632, 1042084096, 1055868544, +1068286464, 1079312512, 1088916480, 1097072128, 1103772032, 1109042176, +1112948608, 1115590912, 1117080960, 1117511680, 1116923264, 1115280512, +1112471040, 1108330880, 1102691712, 1095455872, 1086748672, 1077537920, +1062688064, 1042243712, 1021432192, 999408768, 976158720, 951869952, +926793472, 901173760, 875200384, 848982208, 822546624, 795860992, +768868224, 741522368, 713812928, 685772416, 657463808, 628958848, +600314432, 571556608, 542686272, 513690592, 484561600, 455329056, +426060320, 396846880, 367771776, 338869952, 310096864, 281325184, +252379520, 223109248, 193485184, 163693120, 134192648, 105710896, +79151352, 55383672, 34725716, 14899882 +}; + + +/* SNR: 85.15, PHASE: 0.166666666666667 */ +const Word32 CLDFB80_60_fx[600] = // q = 30 +{ -11637, 1767, -122, 1627, -5031, -195, +160, -87, -3544, 136, -195, 20, +35, 25, 131, -1128, 203, 11, +-29, -253, -96, -286, -754, 688, +-55, -8, 214, -1583, 5224, -169, +-595, 7568, -1361, 190, 3, -67, +788, 160, -43, -19, -101, -32, +-9, 462, -3064, 321, -84, 23, +12, -114, 150, -968, 1650, -22, +-258, -2693, -28, 67, 4754, -32802, +-51846, 4945, -595, 6085, -22236, -387, +577, -523, -12973, 672, -657, 65, +91, 64, 313, -2699, 468, 12, +-68, -401, -518, -689, -1020, 1669, +-23, 719, 448, -2322, -9361, 9537, +-13566, 12272, 3729, -157, -827, 60, +-1977, -312, 206, 461, 169, 83, +40, -1088, 7330, -767, 201, -59, +-41, 406, -660, 3231, -7057, 161, +770, 12038, 198, -1291, -3892, 106546, +-387363, -327043, -319712, -213952, -222151, -158503, +-105318, -35479, -59682, -66732, -70712, -61609, +-55170, -44739, -31711, -9899, -22286, -19251, +-9917, -4949, 14171, 3110, 10391, 26566, +4085, -6975, -13331, -9891, 55398, -89244, +-120821, 27634, -30750, -9362, -7373, 2810, +49557, 3144, -15960, 10651, -22480, -39334, +-43080, -20585, -29742, -8097, -25326, -28070, +-28127, -30792, -15878, 36413, 63870, -51034, +-98422, -118589, -196780, -380752, -531211, -867079, +-924260, -1262671, -1211187, -909700, -706692, -590140, +-387712, -140674, -90592, -207147, -191397, -163115, +-139419, -107626, -77449, 8619, -49945, -36329, +-21445, -20211, 13294, -23388, 30609, 24764, +-73158, -145958, -228347, -136170, 302171, 622362, +-742756, -516943, 79532, 208728, 139837, 68780, +-69176, -27637, 72365, 6203, 62098, 78719, +81230, 52143, -15435, 27781, 58316, 71170, +74613, 81974, 55367, -164495, -160536, 180917, +362005, 375017, 795458, 1461875, 1963205, 2095155, +-1983049, -2140127, -2301660, -2078197, -2009648, -1702454, +-1336745, -925313, -815553, -803612, -652848, -461550, +-265137, -36271, 196856, 518313, 664399, 915382, +1166217, 1339893, 1585569, 1738976, 1799274, 1890534, +1933937, 1945125, 1923994, 1665860, 831664, 77564, +1488037, 1777055, 1688417, 1721974, 1828829, 1937199, +2017936, 2078398, 2252451, 2437196, 2585600, 2754364, +2909841, 2993432, 3016599, 3074265, 3154609, 3219375, +3265044, 3289692, 3277126, 3189837, 3034094, 2902601, +2709098, 2356141, 1938985, 1632226, 1146722, 418214, +-305018, -993260, -1403823, -1653091, -1911081, -2083225, +-2096448, -2021484, -1849083, -1552143, -1182252, -764155, +-310624, 157140, 627282, 1032600, 1427332, 1788413, +2142931, 2466904, 2666628, 2856089, 2979249, 2902476, +2810289, 2692828, 2523008, 2330295, 2193128, 2132549, +2001086, 1283653, 592122, -15236, -616498, -1241114, +-1897102, -2589952, -3235046, -3852857, -4472528, -5058432, +-5630303, -6187298, -6725205, -7257094, -7776616, -8297674, +-8829816, -9380603, -9952123, -10548511, -11192438, -11919065, +-12671172, -13438549, -14232061, -15062200, -15899665, -16802572, +17739412, 18725886, 19625418, 20458448, 21392202, 22346532, +23310144, 24336266, 25457146, 26639572, 27874318, 29180440, +30570936, 32044188, 33604364, 35257056, 37006492, 38833420, +40745368, 42749912, 44846596, 47032812, 49318540, 51704112, +54183000, 56747120, 59397304, 62137772, 64938688, 67793344, +70831448, 73960840, 77111768, 80298224, 83528888, 86778376, +90039080, 93302528, 96541856, 99755032, 102923904, 106027616, +109066040, 112017456, 114866184, 117592440, 120184144, 122624224, +124905544, 127010856, 128931552, 130666344, 132191136, 133505016, +134605360, 135478896, 136120576, 136498544, 136610544, 136390896, +136106368, 135791440, 135081680, 134039064, 132663544, 130943336, +128876128, 126439184, 123615464, 120403880, 116783968, 112750168, +108296544, 103416816, 98114136, 92387688, 86239880, 79676032, +72697184, 65299188, 57491652, 49271324, 40633116, 31582262, +22113356, 12229525, 1933214, -8779568, -19893306, -31396530, +-43338216, -55715672, -68469528, -81601800, -95119752, -109012544, +-123274624, -137902624, -152887216, -168220960, -183892768, -199892672, +-216212560, -232841840, -249770272, -266987040, -284483936, -302248800, +-320270592, -338536576, -357031680, -375740448, -394642624, -413715328, +-432939744, -452297696, -471766976, -491319872, -510956224, -530689568, +550314688, 569805312, 589331520, 608841280, 628294144, 647679424, +666974528, 686151296, 705180416, 724037376, 742695360, 761126400, +779305216, 797209408, 814818048, 832112192, 849073920, 865685504, +881927232, 897777728, 913213888, 928211072, 942743488, 956784768, +970310720, 983299712, 995732352, 1007593856, 1018874944, 1029566592, +1039655360, 1049145600, 1058033856, 1066312576, 1073975296, 1081012992, +1087415680, 1093176448, 1098289920, 1102755712, 1106582656, 1109785856, +1112388096, 1114420736, 1115916544, 1116907776, 1117424512, 1117484800, +1117091968, 1116238848, 1114897920, 1113026048, 1110577792, 1107500160, +1103739520, 1099271424, 1094099328, 1088271360, 1081958528, 1076012800, +1066112832, 1052270720, 1038832960, 1024980800, 1010577920, 995613248, +980113280, 964128448, 947737280, 931017344, 914037760, 896864896, +879548544, 862118336, 844591360, 826968768, 809238464, 791384896, +773390848, 755241024, 736928896, 718455680, 699830528, 681070912, +662197568, 643231744, 624193216, 605096768, 585949312, 566752640, +547506176, 528205504, 508844544, 489425088, 469954944, 450450944, +430937408, 411440896, 391989376, 372605984, 353300032, 334067616, +314888448, 295721536, 276517248, 257224080, 237791168, 218193616, +198443888, 178588864, 158737840, 139063920, 119772248, 101121944, +83411368, 66882256, 51724928, 38009000, 25081918, 11097560 +}; + + +/* 5ms delay prototype */ +const Word32 LDQMF_10_fx[] = // q = 30 +{ + 136778, 68195, -70890, -226890, -352352, -420071, +-436801, -444542, -506660, -672814, -980067, -1367880, +-1747442, -2041058, -2171766, -2084001, -1756845, -1205000, +-470032, 391658, -1352314, -2311011, -3225024, -4068759, +-4825636, -5483930, -6033974, -6472204, -6808584, -7075060, +-7325811, -7636334, -8074046, -8676456, -9424478, -10219283, +-10865228, -11073811, -10475044, -8652076, 5180200, -339903, +-8224782, -18673422, -31726070, -47229416, -64809980, -83846512, +-103451368, -122477480, -139540384, -153063904, -161342016, -162639632, +-155309920, -137908720, -109304704, -68777832, -16099735, 48410956, +-123867744, -208812656, -301278944, -398795360, -498505440, -597277184, +-691834048, -778907776, -855407232, -918606592, -966152640, -996390080, +-1008509056, -1002265344, -978191040, -937540800, -882190336, -814525888, +-737309056, -653527872, 566225280, 478344672, 392910464, 312395584, +238918544, 174094816, 118926376, 73749168, 38239292, 11438051, +-6809585, -17473586, -23179288, -24893300, -23497172, -19904868, +-15070633, -9938406, -5364480, -2000461 +}; + + +const Word32 LDQMF_16_fx[] = // q = 30 +{ +135840, 119104, 61025, -23300, -120395, -217571, +-303688, -369787, -411985, -431913, -436959, -439365, +-455120, -500073, -585815, -716338, -910646, -1146409, +-1392576, -1634244, -1852284, -2026745, -2138911, -2173115, +-2118583, -1970210, -1728614, -1399459, -992562, -520339, +3268, 562388, -1169899, -1774887, -2369780, -2945925, +-3497147, -4018445, -4506031, -4956920, -5368525, -5738269, +-6064625, -6347063, -6587229, -6790047, -6964111, -7121373, +-7276727, -7449879, -7659373, -7920485, -8244153, -8633965, +-9083566, -9574508, -10074442, -10534940, -10894573, -11076715, +-10992408, -10543848, -9627864, -8139160, 5976363, 3037886, +-760648, -5491840, -11209240, -17943616, -25700144, -34454400, +-44150032, -54695840, -65964980, -77789648, -89960896, -102229872, +-114308392, -125871952, -136561440, -145990880, -153753088, -159424128, +-162577504, -162794960, -159676832, -152853360, -141995744, -126825840, +-107126032, -82747424, -53617472, -19744928, 18775524, 61761592, +-108947912, -159965984, -214394832, -271716064, -331337920, -392605120, +-454808224, -517194272, -578978880, -639359104, -697528768, -752693376, +-804086912, -850989824, -892747136, -928791232, -958536704, -981563328, +-997684800, -1006698432, -1008520640, -1003187328, -990852800, -971782976, +-946346880, -915003328, -878295040, -836832960, -791284544, -742359104, +-690793664, -637338560, 582754624, 527645440, 472906400, 419190784, +367113152, 317241312, 270082016, 226065808, 185534960, 148735312, +115810224, 86800312, 61646000, 40190228, 22181636, 7245162, +-4169366, -12156084, -17964338, -21866804, -24101958, -24886370, +-24433336, -22962478, -20701850, -17885954, -14749119, -11519968, +-8412224, -5619924, -3298610, -1524160 +}; + + +const Word32 LDQMF_20_fx[] = // q = 30 +{ +132094, 130053, 94117, 37811, -32618, -110470, +-188996, -262715, -325880, -375095, -408842, -427924, +-435582, -437285, -440061, -452481, -482692, -537287, +-620380, -731564, -887814, -1074239, -1268925, -1466394, +-1657422, -1832122, -1980123, -2091723, -2157945, -2171781, +-2128229, -2024637, -1860817, -1638684, -1362085, -1036417, +-668022, -263993, 167951, 619488, -1109006, -1594302, +-2074062, -2544891, -3002258, -3443306, -3865449, -4266665, +-4645247, -4999899, -5329217, -5631868, -5906959, -6153951, +-6372928, -6565000, -6732690, -6880012, -7012400, -7136776, +-7260809, -7394870, -7549042, -7731643, -7949918, -8208793, +-8510223, -8852171, -9227619, -9624792, -10025312, -10404401, +-10731825, -10971712, -11081824, -11015548, -10722771, -10150872, +-9246198, -7954791, 6226193, 4006048, 1251053, -2079213, +-6018495, -10592059, -15815707, -21694928, -28223572, -35382820, +-43140436, -51449560, -60249600, -69462792, -78994976, -88734976, +-98555328, -108312432, -117847120, -126986608, -135542896, -143318016, +-150106768, -155693424, -159859744, -162387488, -163062224, -161676800, +-158034768, -151954128, -143271408, -131843832, -117553208, -100308496, +-80048728, -56744644, -30400730, -1056327, 31212950, 66296312, +-104051416, -144280880, -186784688, -231313168, -277585056, -325290400, +-374093504, -423635840, -473540064, -523412928, -572850304, -621440576, +-668770368, -714429248, -758014656, -799138176, -837430848, -872549376, +-904183040, -932063424, -955866112, -975368256, -990502784, -1001141248, +-1007204608, -1008661952, -1005531712, -997881088, -985824192, -969518976, +-949164608, -924995776, -897283008, -866326016, -832450624, -796003264, +-757347840, -716859456, -674920448, -631918336, 588261568, 544170240, +500187776, 456655456, 413899520, 372230592, 331939808, 293293792, +256529792, 221851008, 189423392, 159373024, 131783696, 106697088, +84113256, 63991576, 46252108, 30775584, 17400960, 5897691, +-3242831, -10003035, -15315395, -19324048, -22161874, -23947232, +-24790774, -24801182, -24088950, -22768174, -20956786, -18774960, +-16343248, -13780261, -11200397, -8711802, -6413877, -4393110, +-2713517, -1364254 +}; + + +const Word32 LDQMF_30_fx[] = // q = 30 +{ +121571, 136778, 125654, 101703, 68195, 26874, +-20212, -70890, -123705, -176137, -226890, -274105, +-316252, -352352, -381787, -404296, -420071, -429892, +-434876, -436801, -437431, -439162, -444542, -456065, +-476087, -506660, -549090, -604537, -672814, -752813, +-858037, -980067, -1106184, -1235997, -1367880, -1498944, +-1626464, -1747442, -1858910, -1957741, -2041058, -2106142, +-2150372, -2171766, -2168618, -2139642, -2084001, -2001494, +-1892254, -1756845, -1596235, -1411744, -1205000, -977797, +-732072, -470032, -193707, 94398, 391658, 694988, +-1028102, -1352314, -1674660, -1994502, -2311011, -2622127, +-2927092, -3225024, -3515027, -3796479, -4068759, -4331383, +-4583784, -4825636, -5056603, -5276176, -5483930, -5679644, +-5863044, -6033974, -6192384, -6338347, -6472204, -6594554, +-6706284, -6808584, -6902958, -6991107, -7075060, -7157331, +-7239857, -7325811, -7418950, -7521576, -7636334, -7765374, +-7910813, -8074046, -8256088, -8457071, -8676456, -8912695, +-9163169, -9424478, -9691922, -9959316, -10219283, -10463412, +-10682245, -10865228, -11000298, -11074417, -11073811, -10983892, +-10789539, -10475044, -10024687, -9422374, -8652076, -7698110, +6547449, 5180200, 3585184, 1749124, -339903, -2692689, +-5318486, -8224782, -11417230, -14899579, -18673422, -22738288, +-27091010, -31726070, -36635292, -41807760, -47229416, -52884028, +-58751904, -64809980, -71032152, -77388632, -83846512, -90369776, +-96918936, -103451368, -109921528, -116280640, -122477480, -128458624, +-134165992, -139540384, -144523760, -149052944, -153063904, -156492352, +-159273296, -161342016, -162634320, -163087360, -162639632, -161231616, +-158806368, -155309920, -150691824, -144905568, -137908720, -129663752, +-120138088, -109304704, -97142448, -83636416, -68777832, -52564528, +-35001268, -16099735, 4121304, 25635912, 48410956, 72407360, +-97584200, -123867744, -151213264, -179552912, -208812656, -238912112, +-269764832, -301278944, -333357440, -365898336, -398795360, -431938528, +-465214080, -498505440, -531693760, -564658432, -597277184, -629427584, +-660987072, -691834048, -721848128, -750911168, -778907776, -805726528, +-831260224, -855407232, -878071616, -899164800, -918606592, -936328128, +-952202112, -966152640, -978197888, -988289792, -996390080, -1002471040, +-1006513664, -1008509056, -1008457600, -1006369728, -1002265344, -996173888, +-988133504, -978191040, -966401920, -952828672, -937540800, -920615360, +-902135488, -882190336, -860873664, -838284672, -814525888, -789704064, +-763927872, -737309056, -709960000, -681994880, -653527872, -624673024, +595607552, 566225280, 536822976, 507495872, 478344672, 449466912, +420958208, 392910464, 365412224, 338547584, 312395584, 287029856, +262517344, 238918544, 216286160, 194665808, 174094816, 154602160, +136208672, 118926376, 102759984, 87704592, 73749168, 60872400, +49048000, 38239292, 28404982, 19492542, 11438051, 4150852, +-1959298, -6809585, -10983833, -14524688, -17473586, -19875174, +-21764768, -23179288, -24150308, -24711158, -24893300, -24729546, +-24252922, -23497172, -22497182, -21287720, -19904868, -18383770, +-16760795, -15070633, -13348427, -11626766, -9938406, -8313092, +-6779951, -5364480, -4088470, -2966834, -2000461, -1134160 +}; + + +const Word32 LDQMF_32_fx[] = // q = 30 +{ +119696, 137151, 128519, 107723, 78399, 41835, +-441, -46740, -95596, -145201, -193804, -240597, +-283800, -322315, -355411, -382593, -403699, -418861, +-428699, -434120, -436480, -437237, -438149, -441391, +-449044, -463039, -485346, -517325, -560091, -614347, +-679871, -755579, -854378, -968457, -1086190, -1207328, +-1330798, -1454135, -1575271, -1691703, -1801098, -1900762, +-1988262, -2061316, -2117677, -2155275, -2172542, -2168110, +-2140952, -2090356, -2016155, -1918413, -1797518, -1654211, +-1489464, -1304576, -1100939, -880095, -643754, -393647, +-131597, 140302, 419876, 704519, -1017921, -1322020, +-1624457, -1924757, -2222508, -2515834, -2804014, -3086295, +-3361992, -3630425, -3891163, -4143615, -4387486, -4622276, +-4847760, -5063642, -5269495, -5464962, -5649875, -5823970, +-5987171, -6139337, -6280536, -6410931, -6530942, -6641149, +-6742438, -6835854, -6922708, -7004444, -7082802, -7159902, +-7237255, -7317480, -7403833, -7498177, -7602711, -7719257, +-7849651, -7995244, -8157012, -8335468, -8530447, -8741283, +-8966383, -9203373, -9449370, -9700315, -9951033, -10195449, +-10426707, -10637019, -10818085, -10960053, -11052529, -11084311, +-11043675, -10918394, -10695736, -10362793, -9906464, -9313511, +-8570674, -7665161, 6586646, 5317833, 3849978, 2171971, +273875, -1853534, -4218327, -6827111, -9685347, -12796811, +-16163952, -19787344, -23665996, -27796800, -32174812, -36793016, +-41642268, -46710992, -51985904, -57451192, -63088408, -68876552, +-74792144, -80808992, -86898528, -93029584, -99168576, -105279432, +-111323816, -117260928, -123048216, -128641440, -133992400, -139052160, +-143773440, -148104208, -151991888, -155383600, -158225792, -160465072, +-162048320, -162923104, -163038096, -162343200, -160789920, -158332016, +-154925376, -150528912, -145104496, -138617152, -131035664, -122332640, +-112485024, -101474136, -89286032, -75911456, -61346324, -45591780, +-28653996, -10544916, 8718141, 29112362, 50609392, 73176464, +-96780680, -121357544, -146873168, -173272304, -200494976, -228475968, +-257145792, -286430368, -316251616, -346527296, -377172096, -408096800, +-439210240, -470417824, -501623072, -532727936, -563632832, -594237184, +-624439872, -654140096, -683237312, -711632192, -739226496, -765924288, +-791632320, -816260416, -839722176, -861935360, -882823040, -902313408, +-920341952, -936853184, -951735680, -964924736, -976443584, -986251200, +-994314944, -1000609792, -1005117952, -1007828864, -1008739392, -1007854080, +-1005185024, -1000751488, -994580096, -986704064, -977163328, -966004416, +-953279168, -939044864, -923364608, -906306368, -887942656, -868349888, +-847608448, -825801792, -803016512, -779341120, -754867072, -729686080, +-703891520, -677576896, -650837184, -623766656, 596524928, 568982144, +541414592, 513899552, 486520032, 459356832, 432489472, 405994688, +379947008, 354417408, 329473600, 305178976, 281592608, 258768368, +236754960, 215594992, 195325728, 175977920, 157575920, 140137536, +123674336, 108191456, 93687496, 80154992, 67580128, 55943780, +45219876, 35377480, 26377892, 18179138, 10724362, 3937154, +-1793746, -6383128, -10375463, -13802420, -16701194, -19108980, +-21056298, -22573612, -23687536, -24425978, -24814642, -24880884, +-24650790, -24152456, -23413234, -22462376, -21328340, -20040900, +-18629038, -17122794, -15550818, -13942058, -12323783, -10723672, +-9166937, -7678114, -6278687, -4990172, -3829056, -2807490, +-1918387, -1103400 +}; + + +const Word32 LDQMF_40_fx[] = // q = 30 +{ +113205, 137253, 134424, 123146, 105210, 81666, +53560, 21301, -14069, -51498, -90644, -130324, +-169687, -208132, -245092, -279677, -311295, -339564, +-364227, -384972, -401866, -414904, -424383, -430758, +-434461, -436342, -437085, -437525, -438797, -441921, +-448028, -458055, -473038, -493888, -521095, -555299, +-596905, -645667, -701530, -764070, -843494, -933719, +-1026834, -1122238, -1219597, -1318430, -1417239, -1515132, +-1610824, -1702996, -1790556, -1872014, -1946187, -2011805, +-2067737, -2112858, -2146050, -2166538, -2173557, -2166437, +-2144725, -2108000, -2056210, -1989294, -1907357, -1810627, +-1699503, -1574446, -1436053, -1285027, -1122102, -948052, +-763729, -570120, -367947, -158283, 57836, 279329, +505114, 733496, -987128, -1230885, -1473412, -1714779, +-1954662, -2192913, -2428355, -2660606, -2889345, -3114178, +-3334741, -3550687, -3761781, -3967792, -4168400, -4363502, +-4552805, -4736194, -4913551, -5084693, -5249383, -5407420, +-5558752, -5703240, -5840789, -5971350, -6094838, -6211307, +-6320773, -6423390, -6519395, -6609078, -6692852, -6771221, +-6844809, -6914280, -6980362, -7043920, -7105964, -7167615, +-7229469, -7292853, -7359780, -7431208, -7508135, -7591745, +-7682926, -7782628, -7891679, -8010673, -8140087, -8280181, +-8430924, -8592083, -8763179, -8943293, -9131195, -9325472, +-9524332, -9725493, -9926142, -10123188, -10313198, -10492333, +-10656603, -10801577, -10922158, -11013175, -11068951, -11083709, +-11051345, -10965628, -10820070, -10607987, -10322919, -9958035, +-9506509, -8961670, -8316717, -7565183, 6702942, 5718827, +4609516, 3369112, 1992224, 473872, -1190731, -3005819, +-4975066, -7101637, -9388180, -11836610, -14448347, -17224060, +-20163764, -23266722, -26531342, -29955288, -33535422, -37267720, +-41147260, -45168140, -49323552, -53606284, -58007508, -62517548, +-67125584, -71820016, -76587808, -81415152, -86287160, -91187832, +-96100320, -101006496, -105887512, -110723520, -115493552, -120176040, +-124748632, -129188288, -133469680, -137567456, -141458352, -145116032, +-148513808, -151624560, -154421360, -156876704, -158963328, -160653808, +-161921024, -162738128, -163078752, -162916896, -162227280, -160985216, +-159167008, -156749920, -153712208, -150033328, -145694224, -140676912, +-134964928, -128543672, -121399776, -113521832, -104900488, -95527920, +-85398544, -74508560, -62856444, -50442808, -37270156, -23343566, +-8670189, 6740501, 22876916, 39724980, 57268860, 75490816, +-94376496, -113883272, -134001320, -154702832, -175958544, -197737504, +-220006032, -242729312, -265870144, -289389664, -313247648, -337401888, +-361809024, -386424256, -411201216, -436093120, -461051360, -486026816, +-510969600, -535829088, -560554240, -585093440, -609395008, -633407296, +-657078592, -680357568, -703193408, -725535424, -747334272, -768541184, +-789108672, -808990656, -828142272, -846520832, -864084928, -880795968, +-896616960, -911514304, -925457216, -938417536, -950324992, -961141376, +-970896128, -979566976, -987136576, -993587776, -998908288, -1003088128, +-1006120192, -1008000960, -1008729280, -1008307648, -1006741504, -1004039168, +-1000212096, -995274560, -989243584, -982139008, -973983296, -964801472, +-954620608, -943470016, -931381312, -918388608, -904527488, -889835648, +-874352128, -858117568, -841174400, -823565824, -805336512, -786531904, +-767198144, -747382720, -727132672, -706495808, -685520512, -664254656, +-642746560, -621047616, 599273536, 577248256, 555196416, 533150944, +511154144, 489249568, 467478368, 445881248, 424498464, 403368608, +382529632, 362017792, 341868224, 322114240, 302787552, 283917824, +265532592, 247657504, 230315568, 213527440, 197311648, 181683920, +166657488, 152242496, 138447232, 125276624, 112733328, 100817520, +89526080, 78854768, 68795096, 59337532, 50469688, 42175888, +34440516, 27241264, 20558124, 14361678, 8619497, 3303076, +-1288525, -5070930, -8454926, -11459781, -14115485, -16433949, +-18436136, -20138626, -21555150, -22702724, -23593500, -24242222, +-24662498, -24867088, -24870766, -24686354, -24328404, -23811232, +-23148884, -22356736, -21449164, -20441404, -19348716, -18185774, +-16968062, -15710186, -14426756, -13132428, -11840736, -10565599, +-9320040, -8115961, -6965903, -5879984, -4867949, -3939392, +-3097321, -2346408, -1680051, -1007770 +}; + + +const Word32 LDQMF_60_fx[] = // q = 30 +{ 102335, 132094, 137435, 135348, 130053, 120487, +108540, 94117, 77296, 58569, 37811, 15642, +-7974, -32618, -57896, -84046, -110470, -136942, +-163210, -188996, -214437, -239090, -262715, -285164, +-306246, -325880, -343923, -360378, -375095, -388053, +-399325, -408842, -416724, -423037, -427924, -431547, +-433999, -435582, -436522, -437004, -437285, -437643, +-438481, -440061, -442702, -446766, -452481, -460181, +-470154, -482692, -497967, -516093, -537287, -561714, +-589463, -620380, -654511, -691824, -731564, -775910, +-829205, -887814, -949147, -1011178, -1074239, -1138340, +-1203245, -1268925, -1334920, -1400801, -1466394, -1531259, +-1595081, -1657422, -1717943, -1776349, -1832122, -1884920, +-1934396, -1980123, -2021834, -2059138, -2091723, -2119241, +-2141377, -2157945, -2168655, -2173352, -2171781, -2163852, +-2149388, -2128229, -2100421, -2065895, -2024637, -1976676, +-1922047, -1860817, -1793098, -1719007, -1638684, -1552285, +-1460012, -1362085, -1258675, -1150049, -1036417, -918024, +-795131, -668022, -536993, -402188, -263993, -122679, +21420, 167951, 316689, 467104, 619488, 773429, +-945238, -1109006, -1271451, -1433049, -1594302, -1754861, +-1914784, -2074062, -2232362, -2389327, -2544891, -2698989, +-2851488, -3002258, -3151251, -3298295, -3443306, -3586211, +-3726943, -3865449, -4001599, -4135335, -4266665, -4395461, +-4521664, -4645247, -4766175, -4884419, -4999899, -5112604, +-5222403, -5329217, -5433113, -5533999, -5631868, -5726641, +-5818340, -5906959, -5992421, -6074745, -6153951, -6230036, +-6303010, -6372928, -6439842, -6503844, -6565000, -6623434, +-6679269, -6732690, -6783803, -6832855, -6880012, -6925505, +-6969547, -7012400, -7054335, -7095679, -7136776, -7177903, +-7219119, -7260809, -7303731, -7348340, -7394870, -7443617, +-7494881, -7549042, -7606393, -7667166, -7731643, -7800141, +-7872826, -7949918, -8031500, -8117778, -8208793, -8304569, +-8405066, -8510223, -8619935, -8734017, -8852171, -8974106, +-9099397, -9227619, -9358364, -9490965, -9624792, -9759051, +-9892867, -10025312, -10155439, -10282162, -10404401, -10520844, +-10630426, -10731825, -10823502, -10903968, -10971712, -11025073, +-11062346, -11081824, -11081759, -11060277, -11015548, -10945697, +-10848751, -10722771, -10565739, -10375810, -10150872, -9888970, +-9588053, -9246198, -8861297, -8431401, -7954791, -7429283, +6854949, 6226193, 5542799, 4803353, 4006048, 3149248, +2231398, 1251053, 206699, -902968, -2079213, -3323232, +-4636016, -6018495, -7471561, -8995894, -10592059, -12260527, +-14001671, -15815707, -17702624, -19662438, -21694928, -23799650, +-25976100, -28223572, -30541232, -32928052, -35382820, -37904240, +-40490688, -43140436, -45851544, -48621904, -51449560, -54331840, +-57266136, -60249600, -63279032, -66351236, -69462792, -72609920, +-75788648, -78994976, -82224448, -85472704, -88734976, -92006232, +-95281520, -98555328, -101822272, -105076584, -108312432, -111523680, +-114704032, -117847120, -120946376, -123995120, -126986608, -129913560, +-132768248, -135542896, -138230992, -140825344, -143318016, -145701104, +-147966688, -150106768, -152113232, -153978192, -155693424, -157250816, +-158642336, -159859744, -160895152, -161740352, -162387488, -162828688, +-163056176, -163062224, -162839296, -162379936, -161676800, -160722816, +-159511024, -158034768, -156287280, -154262480, -151954128, -149356496, +-146464032, -143271408, -139773568, -135965808, -131843832, -127403488, +-122641048, -117553208, -112136840, -106389392, -100308496, -93892368, +-87139520, -80048728, -72619504, -64851416, -56744644, -48299972, +-39518100, -30400730, -20949652, -11167261, -1056327, 9379870, +20137698, 31212950, 42601076, 54297248, 66296312, 78593112, +-91185600, -104051416, -117194704, -130607064, -144280880, -158207776, +-172378736, -186784688, -201415824, -216262032, -231313168, -246558128, +-261985952, -277585056, -293343616, -309249600, -325290400, -341453376, +-357725472, -374093504, -390543744, -407062432, -423635840, -440249504, +-456889088, -473540064, -490187584, -506816896, -523412928, -539960640, +-556444864, -572850304, -589161600, -605363456, -621440576, -637377600, +-653159232, -668770368, -684195712, -699420352, -714429248, -729207616, +-743740992, -758014656, -772014784, -785727168, -799138176, -812234496, +-825002880, -837430848, -849505856, -861215872, -872549376, -883495616, +-894043456, -904183040, -913905152, -923200640, -932063424, -940477696, +-948417216, -955866112, -962841216, -969345024, -975368256, -980905536, +-985952256, -990502784, -994553344, -998100544, -1001141248, -1003673344, +-1005694720, -1007204608, -1008202304, -1008687808, -1008661952, -1008125952, +-1007081664, -1005531712, -1003479040, -1000927424, -997881088, -994344832, +-990323904, -985824192, -980852096, -975414528, -969518976, -963173312, +-956385600, -949164608, -941519424, -933459776, -924995776, -916137728, +-906896448, -897283008, -887308928, -876985984, -866326016, -855341824, +-844045696, -832450624, -820569472, -808415936, -796003264, -783345088, +-770455104, -757347840, -744036608, -730535808, -716859456, -703022272, +-689038016, -674920448, -660685696, -646345600, -631918336, -617424704, +602927232, 588261568, 573575488, 558872576, 544170240, 529480224, +514815008, 500187776, 485610624, 471095904, 456655456, 442301536, +428045760, 413899520, 399874240, 385981024, 372230592, 358633472, +345199872, 331939808, 318862624, 305977728, 293293792, 280819232, +268562016, 256529792, 244729552, 233167968, 221851008, 210784624, +199973840, 189423392, 179137440, 169119664, 159373024, 149900064, +140703152, 131783696, 123142424, 114780232, 106697088, 98892400, +91364808, 84113256, 77135992, 70429688, 63991576, 57819020, +51907328, 46252108, 40848248, 35691672, 30775584, 26091894, +21637068, 17400960, 13374445, 9548629, 5897691, 2475271, +-592184, -3242831, -5659969, -7917455, -10003035, -11926348, +-13696880, -15315395, -16789184, -18123694, -19324048, -20394110, +-21338122, -22161874, -22868630, -23462238, -23947232, -24327810, +-24607834, -24790774, -24881324, -24883598, -24801182, -24638338, +-24399474, -24088950, -23710470, -23268668, -22768174, -22213084, +-21607820, -20956786, -20264828, -19536176, -18774960, -17986262, +-17174228, -16343248, -15497611, -14641749, -13780261, -12916498, +-12055168, -11200397, -10355588, -9525147, -8711802, -7920384, +-7153631, -6413877, -5706098, -5031208, -4393110, -3792571, +-3230785, -2713517, -2227976, -1784735, -1364254, -871386 +}; + +#endif /* OPT_IVAS_FILTER_ROM */ + const Word32 rot_vec_delay_re_LDQMF_fx[60] = // q = 31 { -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, 1518500224, -1518500224, -1518500224, 1518500224, diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h index 29e763757..9bf335aac 100644 --- a/lib_com/rom_com_fx.h +++ b/lib_com/rom_com_fx.h @@ -70,7 +70,7 @@ extern const Word16 sin_twiddle_table_25_5_5[25]; // Q15 extern const Word16 cos_twiddle_table_16_8_2[16]; // Q15 extern const Word16 sin_twiddle_table_16_8_2[16]; // Q15 - +#ifndef OPT_IVAS_FILTER_ROM extern const Word16 CLDFB80_10_fx[100]; // Q15 extern const Word16 CLDFB80_16_fx[160]; // Q15 extern const Word16 CLDFB80_20_fx[200]; // Q15 @@ -87,6 +87,25 @@ extern const Word16 LDQMF_30_fx[300]; // Q15 extern const Word16 LDQMF_32_fx[320]; // Q15 extern const Word16 LDQMF_40_fx[400]; // Q15 extern const Word16 LDQMF_60_fx[600]; // Q15 +#else /* OPT_IVAS_FILTER_ROM */ + +extern const Word32 CLDFB80_10_fx[100]; // Q30 +extern const Word32 CLDFB80_16_fx[160]; // Q30 +extern const Word32 CLDFB80_20_fx[200]; // Q30 +extern const Word32 CLDFB80_30_fx[300]; // Q30 +extern const Word32 CLDFB80_32_fx[320]; // Q30 +extern const Word32 CLDFB80_40_fx[400]; // Q30 +extern const Word32 CLDFB80_60_fx[600]; // Q30 + +/*5ms delay*/ +extern const Word32 LDQMF_10_fx[100]; // Q30 +extern const Word32 LDQMF_16_fx[160]; // Q30 +extern const Word32 LDQMF_20_fx[200]; // Q30 +extern const Word32 LDQMF_30_fx[300]; // Q30 +extern const Word32 LDQMF_32_fx[320]; // Q30 +extern const Word32 LDQMF_40_fx[400]; // Q30 +extern const Word32 LDQMF_60_fx[600]; // Q30 +#endif /* OPT_IVAS_FILTER_ROM */ /* Not used anywhere extern const Word16 LDQMF_10_enc_fx[100]; extern const Word16 LDQMF_16_enc_fx[160]; diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index f99d49802..8603beb49 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -617,8 +617,11 @@ typedef struct cldfb_filter_bank_struct Word16 da; /* delay analysis */ CLDFB_PROTOTYPE prototype; const Word16 *p_filter; /*!< Pointer to filter coefficients */ // Q15 - Word16 p_filter_sf; // Q0 - +#ifdef OPT_IVAS_FILTER_ROM + const Word32 *p_filter_32; /*!< Pointer to filter coefficients */ // Q15 +#else /* OPT_IVAS_FILTER_ROM */ + Word16 p_filter_sf; // Q0 +#endif /* OPT_IVAS_FILTER_ROM */ /* rotation vectors */ const Word32 *rot_vec_syn_re_fx; // Q29 diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 7fecb7ca7..1ff772953 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1750,31 +1750,68 @@ void ivas_qmetadata_to_dirac_fx( } ELSE { +#ifndef OPT_SBA_DEC_PATH Word16 tmp1, tmp4; +#endif /* OPT_SBA_DEC_PATH */ Word16 a, b_tmp; Word16 exp_factor = 0; move16(); a = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor +#ifndef OPT_SBA_DEC_PATH tmp1 = mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5 Word32 tmp1_32 = L_deposit_h( tmp1 ); +#else /* OPT_SBA_DEC_PATH */ + Word32 tmp1_32 = L_mult( a, dirac_dithering_azi_scale_fx[diff_idx] ); // exp_factor + 5 +#endif /* OPT_SBA_DEC_PATH */ Word16 final_1_exp; - Word32 final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, exp_factor + 5, &final_1_exp ); - b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor + Word32 final_1_32; +#ifndef OPT_SBA_DEC_PATH + final_1_32 = BASOP_Util_Add_Mant32Exp( azimuth_fx, 9, tmp1_32, add( exp_factor, 5 ), &final_1_exp ); +#else /* OPT_SBA_DEC_PATH */ + Word16 norm_op1 = norm_l( azimuth_fx ); + Word16 norm_op2 = norm_l( tmp1_32 ); + Word16 op2_e = add( exp_factor, 5 ); + final_1_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom + final_1_32 = L_add( L_shr( azimuth_fx, sub( final_1_exp, 9 ) ), L_shr( tmp1_32, sub( final_1_exp, op2_e ) ) ); + +#endif /* OPT_SBA_DEC_PATH */ + b_tmp = rand_triangular_signed_fx( seed_ptr, &exp_factor ); // q = exp_factor +#ifndef OPT_SBA_DEC_PATH tmp4 = mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4 Word32 tmp4_32 = L_deposit_h( tmp4 ); - Word16 final_2_exp; - Word32 final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, exp_factor + 4, &final_2_exp ); - +#else /* OPT_SBA_DEC_PATH */ + Word32 tmp4_32 = L_mult( b_tmp, dirac_dithering_ele_scale_fx[diff_idx] ); // exp_factor + 4 +#endif /* OPT_SBA_DEC_PATH */ + Word16 final_2_exp; + Word32 final_2_32; +#ifndef OPT_SBA_DEC_PATH + final_2_32 = BASOP_Util_Add_Mant32Exp( elevation_fx, 9, tmp4_32, add( exp_factor, 4 ), &final_2_exp ); +#else /* OPT_SBA_DEC_PATH */ + norm_op1 = norm_l( elevation_fx ); + norm_op2 = norm_l( tmp4_32 ); + op2_e = add( exp_factor, 4 ); + final_2_exp = add( s_max( s_max( sub( 9, norm_op1 ), sub( op2_e, norm_op2 ) ), 0 ), 2 ); // 2 for headroom + final_2_32 = L_add( L_shr( elevation_fx, sub( final_2_exp, 9 ) ), L_shr( tmp4_32, sub( final_2_exp, op2_e ) ) ); +#endif /* OPT_SBA_DEC_PATH */ + +#ifndef OPT_SBA_DEC_PATH final_1_32 = BASOP_Util_Add_Mant32Exp( final_1_32, final_1_exp, ONE_IN_Q30, 0, &final_1_exp ); /*0.5 in q31*/ final_2_32 = BASOP_Util_Add_Mant32Exp( final_2_32, final_2_exp, ONE_IN_Q30, 0, &final_2_exp ); azi = extract_h( L_shr( final_1_32, sub( sub( 31, final_1_exp ), 16 ) ) ); ele = extract_h( L_shr( final_2_32, sub( sub( 31, final_2_exp ), 16 ) ) ); +#else /* OPT_SBA_DEC_PATH */ + final_1_32 = L_add( final_1_32, L_shl( 1, sub( 30, final_1_exp ) ) ); /*0.5 in q31*/ + final_2_32 = L_add( final_2_32, L_shl( 1, sub( 30, final_2_exp ) ) ); + azi = extract_h( L_shr( final_1_32, sub( 15, final_1_exp ) ) ); + ele = extract_h( L_shr( final_2_32, sub( 15, final_2_exp ) ) ); +#endif /* OPT_SBA_DEC_PATH */ + /*addition of one to compensate precision loss*/ if ( azi < 0 ) diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index b42eb534b..08359826a 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -198,7 +198,10 @@ void ivas_mct_core_dec( Word16 tcx_offset; Word16 tcx_offsetFB; Word16 left_rect; - Word16 L_spec, scale, tmp1, tmp2; + Word16 L_spec; +#ifndef OPT_SBA_DEC_PATH + Word16 scale, tmp1, tmp2; +#endif /* OPT_SBA_DEC_PATH */ #ifdef DEBUG_MCT float nrg[MCT_MAX_CHANNELS]; #endif @@ -218,11 +221,18 @@ void ivas_mct_core_dec( move16(); FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) { +#ifndef OPT_SBA_DEC_PATH FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; i = add( i, 1 ); } +#else /* OPT_SBA_DEC_PATH */ + FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) ) + { + sts[i] = hCPE[cpe_id]->hCoreCoder[ch]; + } +#endif /* OPT_SBA_DEC_PATH */ } i = 0; @@ -268,7 +278,61 @@ void ivas_mct_core_dec( { CONTINUE; } +#ifdef OPT_SBA_DEC_PATH + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + Word16 L_frame_2 = shr( st->L_frame, 1 ); + Word16 L_frameTCX_2 = shr( st->hTcxDec->L_frameTCX, 1 ); + nSubframes = NB_DIV; // assuming NB_DIV is 2. Below logic needs to be modified if NB_DIV changes. + move16(); + FOR( k = 0; k < nSubframes; k++ ) + { + L_spec = shr( st->hTcxCfg->tcx_coded_lines, 1 ); + move32(); + init_tcx_info_fx( st, L_frame_2, L_frameTCX_2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); + + Word16 x_e, x_len; + /* mono or dual mono IGF decoding */ + x_e = sub( 31, q_x[ch] ); + decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k ); + q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 + move16(); + FOR( i = 0; i < x_len; i++ ) + { + x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] ); + move32(); + } + q_x[ch] = Q12; + move16(); + } + } + ELSE + { + nSubframes = 1; + move16(); + { + L_spec = st->hTcxCfg->tcx_coded_lines; + move32(); + + init_tcx_info_fx( st, st->L_frame, st->hTcxDec->L_frameTCX, 0, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec ); + + Word16 x_e, x_len; + /* mono or dual mono IGF decoding */ + x_e = sub( 31, q_x[ch] ); + decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 ); + q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 + move16(); + FOR( i = 0; i < x_len; i++ ) + { + x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] ); + move32(); + } + q_x[ch] = Q12; + move16(); + } + } +#else /* OPT_SBA_DEC_PATH */ IF( EQ_16( st->core, TCX_10_CORE ) ) { nSubframes = NB_DIV; @@ -304,6 +368,7 @@ void ivas_mct_core_dec( q_x[ch] = Q12; move16(); } +#endif /* OPT_SBA_DEC_PATH */ } } ELSE @@ -318,6 +383,9 @@ void ivas_mct_core_dec( * MCT processing *--------------------------------------------------------------------------------*/ +#ifdef OPT_SBA_DEC_PATH + apply_MCT_dec_fx( hMCT, sts, x_fx ); +#else /* OPT_SBA_DEC_PATH */ apply_MCT_dec_fx( hMCT, sts, x_fx, q_x ); FOR( ch = 0; ch < nChannels; ch++ ) { @@ -331,6 +399,7 @@ void ivas_mct_core_dec( q_x[ch] = Q12; move16(); } +#endif /* OPT_SBA_DEC_PATH */ } pop_wmops(); diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 0f20c1ec0..0d998b355 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -165,8 +165,12 @@ void ivas_mct_dec_mct_fx( static void applyGlobalILD_fx( Decoder_State **sts, MCT_DEC_HANDLE hMCT, - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], - Word16 q_x[MCT_MAX_CHANNELS] ) + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 ch, k; Word16 nSubframes, L_subframeTCX; @@ -207,9 +211,14 @@ static void applyGlobalILD_fx( FOR( k = 0; k < nSubframes; k++ ) { v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio +#ifdef OPT_SBA_DEC_PATH + scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) ); +#endif /* OPT_SBA_DEC_PATH */ } +#ifndef OPT_SBA_DEC_PATH q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio ); move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE { @@ -228,10 +237,14 @@ static void applyGlobalILD_fx( *----------------------------------------------------------*/ void apply_MCT_dec_fx( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */ - Word16 q_x[MCT_MAX_CHANNELS] ) + MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ + Decoder_State **sts, /* i/o: decoder state structure */ + Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ +#ifndef OPT_SBA_DEC_PATH + , + Word16 q_x[MCT_MAX_CHANNELS] +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 pair; MCT_DEC_BLOCK_DATA_HANDLE hBlock; @@ -240,10 +253,18 @@ void apply_MCT_dec_fx( { hBlock = hMCT->hBlockData[pair]; +#ifndef OPT_SBA_DEC_PATH stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0, &q_x[hBlock->ch2], &q_x[hBlock->ch1] ); +#else /* OPT_SBA_DEC_PATH */ + stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 ); +#endif /* OPT_SBA_DEC_PATH */ } +#ifndef OPT_SBA_DEC_PATH applyGlobalILD_fx( sts, hMCT, x, q_x ); +#else /* OPT_SBA_DEC_PATH */ + applyGlobalILD_fx( sts, hMCT, x ); +#endif /* OPT_SBA_DEC_PATH */ return; } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index fabebede4..4e90792fb 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -737,7 +737,11 @@ void ivas_mdct_core_invQ_fx( q_r = sub( 30, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp ); /* both input in same Q */ +#ifndef OPT_SBA_DEC_PATH stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l ); +#else /* OPT_SBA_DEC_PATH */ + stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 ); +#endif /* OPT_SBA_DEC_PATH */ Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15 Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15 diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 89cb92a4d..85ae00c90 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -465,9 +465,11 @@ void stereo_mdct_core_dec_fx( test(); IF( ( !bfi || ( sts[0]->core != ACELP_CORE || sts[1]->core != ACELP_CORE ) ) && !hCPE->hStereoMdct->isSBAStereoMode ) { +#ifndef OPT_SBA_DEC_PATH Word16 q_x_1 = 11, q_x_0 = 11; move16(); move16(); +#endif /* OPT_SBA_DEC_PATH */ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -477,7 +479,11 @@ void stereo_mdct_core_dec_fx( move16(); } } +#ifdef OPT_SBA_DEC_PATH + stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 ); +#else /* OPT_SBA_DEC_PATH */ stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 ); +#endif /* OPT_SBA_DEC_PATH */ } ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, x_e ); diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 8842a6792..492060a67 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -313,9 +313,13 @@ void stereo_decoder_tcx_fx( const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ const Word16 last_core_l, /* i : last core for left channel Q0*/ const Word16 last_core_r, /* i : last core for right channel Q0*/ - const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision Q0*/ + const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/ +#ifndef OPT_SBA_DEC_PATH + , Word16 *q_x_ch2, - Word16 *q_x_ch1 ) + Word16 *q_x_ch1 +#endif /* OPT_SBA_DEC_PATH */ +) { Word16 i, k, sfb, nSubframes; STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL; @@ -361,10 +365,12 @@ void stereo_decoder_tcx_fx( } } inverseMS_fx( sfbConf->sfbOffset[sfbConf->nBandsStereoCore], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( EQ_16( mdct_stereo_mode[k], SMDCT_BW_MS ) ) { @@ -381,10 +387,12 @@ void stereo_decoder_tcx_fx( } } inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } @@ -402,10 +410,12 @@ void stereo_decoder_tcx_fx( } } inverseMS_fx( sub( sfbConf->sfbOffset[sfbConf->sfbCnt], sfbConf->sfbOffset[sfbConf->nBandsStereoCore] ), &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) ) { @@ -422,10 +432,12 @@ void stereo_decoder_tcx_fx( } } inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED ); +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } @@ -483,8 +495,10 @@ void stereo_decoder_tcx_fx( nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */ v_multc_fixed( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */ Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */ +#ifndef OPT_SBA_DEC_PATH *q_x_ch2 = *q_x_ch2; move16(); +#endif /* OPT_SBA_DEC_PATH */ } ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) ) { @@ -492,8 +506,10 @@ void stereo_decoder_tcx_fx( shift = sub( 5, tmp_e ); v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */ Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */ +#ifndef OPT_SBA_DEC_PATH *q_x_ch1 = *q_x_ch1; move16(); +#endif /* OPT_SBA_DEC_PATH */ } } } /* for k */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 622ebf89a..093fdf7c3 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -663,7 +663,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 num_freq_bands_diff, num_channels_diff; Word16 ch_idx; Word32 aux_buf[CLDFB_NO_CHANNELS_MAX]; - Word16 diff_start_band, tmp16; + Word16 diff_start_band; DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params; DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state; @@ -816,12 +816,341 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( ONE_IN_Q29 /*0.25f Q31*/, h_dirac_output_synthesis_state->diffuse_power_factor_fx, num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ +#ifdef OPT_SBA_DEC_PATH + /*Direct gain*/ + + Word16 *exp_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); + Word16 cy_cross_dir_smooth_e = sub( 31, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ); + + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + exp_temp_cy_cross_dir_smooth_fx[kk] = cy_cross_dir_smooth_e; // h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; + move16(); + } + + Word16 q_temp = sub( add( shl( h_dirac_output_synthesis_state->direct_responses_q, 1 ), q_diffuseness ), 62 ); + Word32 one_in_qdiff = L_shl( 1, q_diffuseness ); + Word32 c1 = Madd_32_16( ONE_IN_Q29 /*1 Q29*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ), 5461 /*1.0 / 6.0 Q15*/ ); /*Diffuseness modellling nrg compensation*/ /*Q29*/ + Word16 q_diff_c = sub( q_diffuseness, 2 ); + + FOR( ch_idx = 0; ch_idx < s_min( 4, nchan_transport ); ch_idx++ ) + { + Word16 k; + IF( ch_idx != 0 ) + { + Word32 a, c; + Word16 b, b_exp, sqr_exp, q_diff_aab; // , q_diff_c; + Word32 mpy_a_a_b, mpy_diff_c, mpy_diff_aab; + Word32 sqr_inp, sqr; + + /*Directonal sound gain nrg compensation*/ + FOR( k = 0; k < num_freq_bands_diff; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + + + b_exp = 0; + move16(); + + b = 0; + move16(); + + if ( 0 == reference_power[k + ( ch_idx + 1 ) * num_freq_bands] ) + { + b = MAX_16; + move16(); + } + + test(); + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] && reference_power[k + num_freq_bands] ) + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*Q(15-b_exp)*/ + } + + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q(q_diff_aab) = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c1 ); // Q(q_diff_c) = q_diffuseness - 2 + + q_diff_aab = sub( q_temp, b_exp ); // add( sub( add( h_dirac_output_synthesis_state->direct_responses_q, sub( 15, b_exp ) ), 15 ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + + Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 ); + Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) ); + Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) ); + sqr_inp = L_add( op1, op2 ); + sqr_exp = sub( 31, minq ); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth-> (31-sqr_exp) */ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; // L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*31-sqr_exp*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + } + c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ + Word16 diff_c_exp = sub( q_diffuseness, 4 ); +#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot + FOR( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + IF( reference_power[k + num_freq_bands] == 0 ) + { + sqr_inp = Mpy_32_32( diffuseness[k], c ); + sqr_exp = sub( 31 + 4, q_diffuseness ); + } + ELSE + { + Word16 diff_aab_exp; + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) + { + mpy_a_a_b = Mpy_32_32( a, a ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = q_temp; + move16(); + } + ELSE + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( one_in_qdiff, diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 + diff_aab_exp = sub( q_temp, b_exp ); // sub(sub(add(sub(31 + 62, h_dirac_output_synthesis_state->direct_responses_q), b_exp), h_dirac_output_synthesis_state->direct_responses_q), q_diffuseness); + } + Word16 minq = sub( s_min( diff_aab_exp, diff_c_exp ), 1 ); + Word32 op1 = L_shr( mpy_diff_aab, sub( diff_aab_exp, minq ) ); + Word32 op2 = L_shr( mpy_diff_c, sub( diff_c_exp, minq ) ); + sqr_inp = L_add( op1, op2 ); + sqr_exp = sub( 31, minq ); + } + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + + + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; + move16(); + } + } + +#else + FOR( ; k < num_freq_bands; k++ ) + { + a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses + move32(); + IF( reference_power[k + num_freq_bands] == 0 ) + { + b = 0; + move16(); + b_exp = 0; + move16(); + } + ELSE + { + IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) + { + b = MAX_16; + move16(); + b_exp = 0; + move16(); + } + ELSE + { + b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ + } + } + + mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 + mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 + mpy_diff_c = Mpy_32_32( diffuseness[k], c2 ); // Q = q_diffuseness - 4 + + q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); + q_diff_c = sub( q_diffuseness, 4 ); + Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 ); + Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) ); + Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) ); + sqr_inp = L_add( op1, op2 ); + sqr_exp = sub( 31, minq ); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ + move32(); + Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + } +#endif + } + ELSE + { + Word32 sqr_inp, sqr; + Word16 sqr_exp; + Word32 One_in_qdiff = L_shl( 1, sub( q_diffuseness, 1 ) ); + Word32 diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx /*q29=0.5 * q30*/, ONE_IN_Q29 /*0.5 Q30*/ ); // Q30 + Word16 sq_e = sub( 32, q_diffuseness ); // 31-(q_diffuseness-1) + /*Diffuseness modellling nrg compensation*/ + FOR( k = 0; k < num_freq_bands_diff; k++ ) + { + /*diffuseness[k] * 0.5f * ( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr - 1.f ) )*/ + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1 + sqr_exp = sq_e; + move16(); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( LT_16( cy_cross_dir_smooth_e, sqr_exp ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q(31- sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31-sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr; /*Q(31-sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + } + FOR( ; k < num_freq_bands; k++ ) + { + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 + sqr_exp = sq_e; + move16(); + sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ + sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ + IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) + { + IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, Q( 31- sqr_exp )*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); + move16(); + } + ELSE + { + sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q( 31- sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ + } + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ + move32(); + } + ELSE + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31-sqr_exp)*/ + move32(); + exp_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; + move16(); + } + } + } + } + Word16 temp = exp_temp_cy_cross_dir_smooth_fx[0]; /*q0*/ + move16(); + FOR( Word16 kk = 1; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + temp = s_max( exp_temp_cy_cross_dir_smooth_fx[kk], temp ); + } + + /*Directional gain (panning)*/ + Word16 temp_q = sub( add( h_dirac_output_synthesis_state->direct_power_factor_q, h_dirac_output_synthesis_state->direct_responses_q ), 31 ); + Word16 temp_exp = sub( 31, temp_q ); + + IF( LT_16( temp, temp_exp ) ) + { + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp_exp ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ->temp_q*/ + move32(); + } + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; + move16(); + } + ELSE + { + FOR( Word16 kk = 0; kk < ( num_freq_bands * num_channels_dir ); kk++ ) + { + h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk] = L_shl( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[kk], sub( exp_temp_cy_cross_dir_smooth_fx[kk], temp ) ); /*exp_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + move32(); + } + h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = sub( 31, temp ); + move16(); + } + free( exp_temp_cy_cross_dir_smooth_fx ); +#else /* OPT_SBA_DEC_PATH */ /*Direct gain*/ Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); - tmp16 = imult1616( num_freq_bands, num_channels_dir ); + Word16 tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; @@ -1175,6 +1504,8 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp_q; move16(); } +#endif /* OPT_SBA_DEC_PATH */ + Word16 temp_q1 = sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, temp_q ); FOR( ch_idx = s_min( 4, nchan_transport ); ch_idx < num_channels_dir; ch_idx++ ) { @@ -1570,7 +1901,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( } q_shift = sub( 26, h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev ); - move16(); /* Direct gains */ IF( hodirac_flag ) @@ -1686,11 +2016,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_gain_shd_fx( /*Direct input->output*/ p_gains_dir = h_dirac_output_synthesis_state.cy_cross_dir_smooth_prev_fx; // (p_gains_dir_q) p_gains_dir_prev = h_dirac_output_synthesis_state.gains_dir_prev_fx; +#ifdef OPT_SBA_DEC_PATH + q_shift = sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ); +#endif /* OPT_SBA_DEC_PATH */ FOR( ch_idx = 0; ch_idx < num_channels_dir; ch_idx++ ) { +#ifdef OPT_SBA_DEC_PATH + Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], + num_freq_bands, + q_shift ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#else /* OPT_SBA_DEC_PATH */ Scale_sig32( &h_dirac_output_synthesis_state.gains_dir_prev_fx[ch_idx * num_freq_bands], num_freq_bands, sub( h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev, h_dirac_output_synthesis_state.gains_dir_prev_q ) ); /*h_dirac_output_synthesis_state.gains_dir_prev_q->h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev*/ +#endif /* OPT_SBA_DEC_PATH */ } h_dirac_output_synthesis_state.gains_dir_prev_q = h_dirac_output_synthesis_state.q_cy_cross_dir_smooth_prev; move16(); -- GitLab From 533f0fbb9e54249bb09f3c2a5cad76a30f9309d8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 16:04:25 +0530 Subject: [PATCH 066/394] Fix for spectral hole issue --- lib_com/rom_com.c | 718 +++++++++++++++++++++++----------------------- 1 file changed, 359 insertions(+), 359 deletions(-) diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index d1a1564cb..2b18d8254 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -5437,19 +5437,19 @@ const Word16 LDQMF_60_fx[] = // q = 15 sf = 15391 qsf = 14 const Word32 CLDFB80_10_fx[100] = // q = 30 { - 3584, -2500, -706, 157, -1170, -1037, --11, -1944, -1380, 1837, 14726, -9095, --1690, -266, 3897, -4704, 419, 4651, -5274, -6638, -243746, -72520, -17070, 14830, --23631, -38285, 18452, -20884, -6244, -281514, --1070487, -153328, -20195, -4337, -209847, 194011, -24972, -5105, -34468, 1151401, -2164680, -832327, -376719, 1686598, 1844777, 1697324, 2356307, 3037446, -3248821, 1779295, -1533240, -1713947, 833815, 2751562, -2421811, 284255, -3540922, -6991555, -10248264, -14642952, + 3584, -2501, -707, 157, -1170, -1038, +-11, -1944, -1380, 1837, 14727, -9096, +-1691, -267, 3897, -4705, 419, 4651, +5275, -6639, -243747, -72521, -17071, 14831, +-23632, -38285, 18452, -20885, -6245, -281515, +-1070487, -153329, -20195, -4338, -209848, 194011, +24972, -5106, -34468, 1151402, -2164680, -832327, +376720, 1686598, 1844777, 1697325, 2356308, 3037447, +3248821, 1779296, -1533240, -1713947, 833816, 2751563, +2421812, 284255, -3540922, -6991555, -10248264, -14642952, 20031906, 26043234, 34417552, 45928496, 60756732, 78698864, 98151832, 116245496, 129823136, 136344976, 134601568, 122059576, -95304000, 53433792, -3371364, -74987256, -160511088, -258343120, +95304000, 53433792, -3371365, -74987256, -160511088, -258343120, -366360320, -481533344, 599091264, 714631872, 823505600, 920768896, 1001735168, 1062249792, 1100603392, 1116473216, 1114030976, 1091249536, 1031959808, 939413760, 835792512, 727712064, 614651648, 499141824, @@ -5459,22 +5459,22 @@ const Word32 CLDFB80_10_fx[100] = // q = 30 /* SNR: 292.49, PHASE: 2.000000000000000 */ const Word32 CLDFB80_16_fx[160] = // q = 30 -{ 591, -823, -251, 103, 63, -1, --19, 2357, 3221, -17, -2, 75, -36, -82, -596, 808, 2242, -3034, --755, 254, 126, -434, 106, -19349, -26445, -100, 482, -149, -90, 246, -2196, -3062, -344116, -158536, -67239, -47926, --21714, 16230, 6227, 48320, 46493, 5448, -17932, -33783, -26258, -13467, -97910, -469416, --1317170, -563405, -199455, -118497, -43264, 11679, --61886, 64705, -248885, 55868, 3767, 67210, -64791, 39611, 345777, 1796799, -2314105, -1658357, --815220, -115680, 761412, 1616442, 1931089, 1230669, -1712205, 1949652, 2418775, 2970521, 3179526, 3272215, -2739045, 1383590, -1186344, -2091283, -1594461, -20541, -1561481, 2685864, 2822045, 2243697, 1007269, -1321111, --3774214, -5979353, -7970746, -10025660, -12576468, -15588057, +{ 592, -824, -251, 104, 64, -2, +-19, 2357, 3222, -18, -2, 75, +37, -82, -596, 808, 2242, -3035, +-755, 254, 126, -435, 107, -19350, +26445, -100, 482, -149, -91, 247, +2196, -3062, -344117, -158537, -67240, -47926, +-21715, 16231, 6227, 48320, 46494, 5449, +17932, -33783, -26258, -13467, -97911, -469416, +-1317171, -563405, -199456, -118497, -43264, 11679, +-61886, 64706, -248886, 55869, 3768, 67211, +64791, 39611, 345778, 1796799, -2314105, -1658358, +-815220, -115680, 761413, 1616443, 1931089, 1230669, +1712206, 1949652, 2418775, 2970521, 3179526, 3272216, +2739046, 1383591, -1186345, -2091284, -1594461, -20541, +1561481, 2685864, 2822045, 2243697, 1007270, -1321111, +-3774214, -5979353, -7970747, -10025660, -12576468, -15588057, 19092548, 22464968, 26489252, 31480652, 37681832, 45115060, 53868456, 63884792, 75139712, 87185504, 99355152, 110921760, 121117896, 129158840, 134480400, 136595408, 135565040, 130704096, @@ -5491,26 +5491,26 @@ const Word32 CLDFB80_16_fx[160] = // q = 30 /* SNR: 89.77, PHASE: 1.500000000000000 */ const Word32 CLDFB80_20_fx[200] = // q = 30 -{ 1767, -5031, -87, -195, 25, 203, --253, -754, -8, 5224, 7568, 3, -160, -101, 462, -84, -114, 1650, --2693, 4754, 4945, -22236, -523, -657, -64, 468, -401, -1020, 719, -9361, -12272, -827, -312, 169, -1088, 201, -406, -7057, 12038, -3892, -327043, -222151, --35479, -70712, -44739, -22286, -4949, 10391, --6975, 55398, 27634, -7373, 3144, -22480, --20585, -25326, -30792, 63870, -118589, -531211, --1262671, -706692, -140674, -191397, -107626, -49945, --20211, 30609, -145958, 302171, -516943, 139837, --27637, 62098, 52143, 58316, 81974, -160536, -375017, 1963205, -2140127, -2009648, -925313, -652848, --36271, 664399, 1339893, 1799274, 1945125, 831664, -1777055, 1828829, 2078398, 2585600, 2993432, 3154609, -3289692, 3034094, 2356141, 1146722, -993260, -1911081, --2021484, -1182252, 157140, 1427332, 2466904, 2979249, -2692828, 2193128, 1283653, -616498, -2589952, -4472528, --6187298, -7776616, -9380603, -11192438, -13438549, -15899665, +{ 1767, -5032, -88, -196, 26, 203, +-254, -755, -8, 5224, 7569, 3, +161, -101, 462, -85, -115, 1651, +-2694, 4755, 4946, -22236, -524, -658, +65, 469, -402, -1021, 719, -9362, +12273, -828, -312, 170, -1089, 201, +407, -7058, 12038, -3893, -327043, -222151, +-35479, -70712, -44739, -22286, -4950, 10391, +-6975, 55398, 27635, -7373, 3144, -22481, +-20586, -25326, -30793, 63871, -118589, -531211, +-1262671, -706692, -140675, -191397, -107627, -49946, +-20212, 30609, -145958, 302172, -516943, 139838, +-27637, 62099, 52144, 58317, 81974, -160536, +375017, 1963206, -2140127, -2009648, -925313, -652848, +-36271, 664400, 1339893, 1799274, 1945125, 831665, +1777056, 1828829, 2078398, 2585601, 2993432, 3154609, +3289693, 3034094, 2356141, 1146722, -993260, -1911082, +-2021484, -1182252, 157141, 1427332, 2466905, 2979250, +2692828, 2193128, 1283653, -616499, -2589952, -4472529, +-6187298, -7776617, -9380603, -11192438, -13438549, -15899665, 18725886, 21392202, 24336266, 27874318, 32044188, 37006492, 42749912, 49318540, 56747120, 64938688, 73960840, 83528888, 93302528, 102923904, 112017456, 120184144, 127010856, 132191136, @@ -5530,35 +5530,35 @@ const Word32 CLDFB80_20_fx[200] = // q = 30 /* SNR: 89.29, PHASE: 0.833333333333333 */ const Word32 CLDFB80_30_fx[300] = // q = 30 -{ -297, 3584, 1941, -855, -2500, -17, -107, -706, 30, 15, 157, 303, -45, -1170, 5206, 7620, -1037, 38, -475, -11, -28, -11, -1944, 58, --3, -1380, -659, 1052, 1837, -2898, --12991, 14726, 8111, -3475, -9095, -22, -265, -1690, 45, -32, -266, 592, -210, 3897, 9064, -12976, -4704, -177, +{ -298, 3584, 1941, -855, -2501, -18, +108, -707, 31, 15, 157, 303, +46, -1170, 5206, 7621, -1038, 39, +476, -11, -29, -11, -1944, 58, +-3, -1380, -660, 1053, 1837, -2898, +-12992, 14727, 8112, -3476, -9096, -22, +265, -1691, 46, -32, -267, 593, +210, 3897, 9064, -12976, -4705, -177, -1102, 419, 158, 60, 4651, -142, --10, 5274, 2753, -4425, -6638, 19638, --341194, -243746, -157895, -76328, -72520, -65718, --49274, -17070, -21325, -4817, 14830, 27865, --1521, -23631, 5019, -51348, -38285, -877, -59535, 18452, -11250, -36821, -20884, -26546, --28596, -6244, -16612, -92408, -281514, -679649, --1089988, -1070487, -687312, -252029, -153328, -178006, --122647, -20195, -41359, -29532, -4337, 53190, --112252, -209847, 617831, -803951, 194011, 106900, --106998, 24972, 64775, 70953, -5105, 66493, -77725, -34468, 24004, 399486, 1151401, 2091330, --1945866, -2164680, -1871141, -1133489, -832327, -560634, --144700, 376719, 793102, 1258629, 1686598, 1843271, -1942367, 1844777, 286874, 1790714, 1697324, 1882734, -2048236, 2356307, 2670961, 2960783, 3037446, 3187787, -3282833, 3248821, 2972460, 2561469, 1779295, 779689, --670109, -1533240, -2023874, -2068453, -1713947, -979306, --79111, 833815, 1606493, 2311180, 2751562, 2948542, -2758276, 2421811, 2144317, 1669907, 284255, -925660, --2240403, -3540922, -4767758, -5909822, -6991555, -8035796, +-11, 5275, 2753, -4425, -6639, 19639, +-341195, -243747, -157895, -76329, -72521, -65719, +-49275, -17071, -21325, -4817, 14831, 27866, +-1522, -23632, 5019, -51348, -38285, -878, +59536, 18452, -11251, -36822, -20885, -26546, +-28596, -6245, -16613, -92408, -281515, -679650, +-1089989, -1070487, -687312, -252030, -153329, -178007, +-122647, -20195, -41359, -29533, -4338, 53191, +-112253, -209848, 617831, -803951, 194011, 106901, +-106999, 24972, 64775, 70954, -5106, 66493, +77725, -34468, 24005, 399486, 1151402, 2091330, +-1945866, -2164680, -1871142, -1133490, -832327, -560635, +-144700, 376720, 793103, 1258629, 1686598, 1843272, +1942367, 1844777, 286874, 1790714, 1697325, 1882734, +2048236, 2356308, 2670961, 2960784, 3037447, 3187788, +3282834, 3248821, 2972461, 2561469, 1779296, 779690, +-670109, -1533240, -2023874, -2068454, -1713947, -979306, +-79112, 833816, 1606493, 2311180, 2751563, 2948543, +2758276, 2421812, 2144318, 1669907, 284255, -925661, +-2240403, -3540922, -4767759, -5909822, -6991555, -8035796, -9103931, -10248264, -11549851, -13052389, -14642952, -16334399, 18220558, 20031906, 21872604, 23814234, 26043234, 28516756, 31295850, 34417552, 37909524, 41736344, 45928496, 50500180, @@ -5567,7 +5567,7 @@ const Word32 CLDFB80_30_fx[300] = // q = 30 125981624, 129823136, 132872256, 135069696, 136344976, 136548112, 135995744, 134601568, 131846392, 127706624, 122059576, 114818808, 105909512, 95304000, 83010216, 69049472, 53433792, 36159948, -17222988, -3371364, -25594396, -49478012, -74987256, -102019216, +17222988, -3371365, -25594396, -49478012, -74987256, -102019216, -130543792, -160511088, -191851984, -224489536, -258343120, -293333280, -329374368, -366360320, -404158112, -442603456, -481533344, -520813312, 560055680, 599091264, 637996480, 676579264, 714631872, 751940864, @@ -5585,37 +5585,37 @@ const Word32 CLDFB80_30_fx[300] = // q = 30 const Word32 CLDFB80_32_fx[320] = // q = 30 { - -1093, 2019, -1499, 75, -3258, -199, -1, 86, -306, -6, -371, -406, -685, 39, -1685, 4713, 6814, -1488, -47, 777, -40, -130, 24, -872, -225, -4, -115, -555, -123, -750, -1333, -5815, -17695, 8208, -6988, 238, --11912, -668, 1, 205, -738, 0, --579, -811, 1616, 569, 3827, 10109, --14334, -4600, -627, -1934, 179, 185, --69, 2086, -538, 14, 407, 1523, -584, 3600, -4501, 26170, -348871, -274412, --191283, -101650, -55022, -71745, -57838, -39469, --16489, -17154, -4617, 1541, 27531, -4837, --24078, -6040, -61575, -45938, -4350, 52992, --21466, -30551, -47623, -16878, -16327, -28525, --30774, 45781, -47860, -103960, -321282, -704887, --1065517, -1123684, -707166, -371532, -86308, -196314, --147629, -95796, -26567, -30200, -12084, -23645, -30175, -133296, -186725, 644643, -823105, 165913, -127128, -77847, 76138, 59764, 84596, 13695, -44920, 72596, 82826, -180229, 163870, 385659, -1272551, 2097219, -1940583, -2216917, -1963534, -1312194, --811283, -684818, -332127, 81208, 566323, 995811, -1374732, 1743252, 1885232, 1944745, 1791356, 230889, -1776037, 1693754, 1848743, 2021967, 2237951, 2554531, -2866857, 3010232, 3111818, 3235821, 3289504, 3179983, -2912034, 2438977, 1724392, 733946, -625865, -1486531, --1958889, -2094027, -1863598, -1255187, -454123, 425746, -1212702, 1901282, 2517749, 2869908, 2908450, 2719155, -2384774, 2140991, 1717492, 398306, -731735, -1939479, --3196994, -4359654, -5453402, -6492968, -7485700, -8462297, + -1093, 2020, -1500, 75, -3259, -200, +2, 86, -307, -6, -372, -406, +686, 39, -1685, 4713, 6814, -1488, +47, 778, -40, -130, 24, -872, +225, -5, -116, -556, -123, -751, +1334, -5815, -17696, 8208, -6989, 239, +-11912, -669, 1, 206, -738, 0, +-579, -811, 1617, 569, 3828, 10109, +-14335, -4601, -628, -1935, 180, 186, +-69, 2086, -538, 14, 408, 1524, +585, 3601, -4502, 26170, -348871, -274413, +-191283, -101650, -55023, -71745, -57839, -39470, +-16489, -17154, -4618, 1542, 27531, -4838, +-24078, -6041, -61576, -45939, -4350, 52992, +-21467, -30551, -47624, -16879, -16327, -28526, +-30774, 45781, -47861, -103961, -321282, -704888, +-1065517, -1123685, -707166, -371532, -86309, -196314, +-147630, -95796, -26567, -30201, -12085, -23646, +30175, -133297, -186726, 644643, -823106, 165914, +127129, -77847, 76139, 59764, 84597, 13696, +44921, 72597, 82827, -180230, 163871, 385660, +1272552, 2097220, -1940583, -2216918, -1963534, -1312195, +-811283, -684818, -332127, 81208, 566324, 995811, +1374732, 1743252, 1885233, 1944746, 1791356, 230889, +1776037, 1693755, 1848743, 2021967, 2237951, 2554532, +2866858, 3010232, 3111818, 3235821, 3289505, 3179984, +2912034, 2438977, 1724392, 733947, -625866, -1486531, +-1958890, -2094028, -1863598, -1255187, -454123, 425746, +1212702, 1901282, 2517750, 2869908, 2908450, 2719155, +2384774, 2140992, 1717492, 398307, -731735, -1939480, +-3196994, -4359654, -5453402, -6492968, -7485701, -8462297, -9485345, -10586349, -11872517, -13293064, -14799378, -16391634, 18159074, 19878216, 21572990, 23372214, 25384474, 27638258, 30127980, 32911950, 36012916, 39421380, 43135868, 47172528, @@ -5624,7 +5624,7 @@ const Word32 CLDFB80_32_fx[320] = // q = 30 118743656, 123354504, 127384760, 130768192, 133428752, 135331936, 136411184, 136532064, 136012736, 134791376, 132367184, 128735088, 123803096, 117494272, 109734136, 100486232, 89749032, 77539936, -63866580, 48743548, 32160198, 14114131, -5387418, -26313940, +63866580, 48743548, 32160198, 14114131, -5387419, -26313940, -48704924, -72531920, -97696000, -124178280, -151940320, -180929216, -211078752, -242327632, -274608448, -307853568, -341987136, -376916512, -412518528, -448658976, -485200704, -522047808, 558838528, 595432000, @@ -5645,45 +5645,45 @@ const Word32 CLDFB80_32_fx[320] = // q = 30 /* SNR: 81.55, PHASE: 0.500000000000000 */ const Word32 CLDFB80_40_fx[400] = // q = 30 { --4459, -418, -3626, 1423, -337, -2077, -302, 18, 81, 158, -711, 8, -12, -288, -781, 598, -25, 260, --439, 2799, 3757, -185, 230, -43, -681, -21, -75, -28, -54, -1949, -416, 55, 15, 232, 886, -479, -680, -2718, -568, -16447, -33103, -1653, --16423, 6274, -1401, -7536, 1255, 81, -201, 378, -1703, -5, -26, -664, --1194, 1294, -17, 118, -11444, 11395, --15922, 16042, 174, 77, -1654, 102, -374, 132, 160, 4663, -995, -137, --67, -969, -4392, 2058, -3082, 11738, --993, 52507, -372469, -339964, -238019, -154668, --91226, -39704, -68193, -63465, -52270, -36720, --12971, -20430, -6924, 7426, -2360, 29241, -919, -11368, 13935, -42083, -90219, 4459, --7455, 294, 60570, -36065, -9835, -23629, --40549, -22838, -11572, -27316, -28142, -21798, -74246, -37442, -94760, -175260, -418504, -781460, --995764, -1274141, -822204, -644197, -320592, -79371, --211045, -170431, -131251, -90675, -8614, -38864, --25805, 10490, -21114, 43834, -93771, -212051, --80066, 687823, -841077, -28318, 196054, 89800, --98757, 81412, 22561, 71309, 76947, -1234, -38817, 69236, 75947, 74312, -220677, 108139, -388007, 614410, 1602908, 2104013, -1945961, -2345233, --2073810, -1788973, -1237041, -801096, -773094, -511060, --205271, 126459, 548962, 854331, 1215259, 1516757, -1754372, 1867886, 1938796, 1938331, 1525725, 104198, -1696967, 1687207, 1745904, 1910501, 2033618, 2194667, -2472077, 2712787, 2937868, 3012595, 3095693, 3204092, -3274807, 3283756, 3148591, 2939051, 2641685, 2031331, -1549502, 597843, -490013, -1328870, -1713435, -2059616, --2084878, -1903964, -1464478, -873102, -195310, 513855, -1135792, 1697317, 2228107, 2629045, 2909610, 2926213, -2785542, 2569873, 2293849, 2134484, 1852516, 752396, --164139, -1082527, -2067571, -3082100, -4010647, -4913512, --5770452, -6592736, -7388101, -8166445, -8966356, -9806266, +-4459, -419, -3627, 1424, -337, -2077, +303, 18, 81, 159, -711, 9, +12, -289, -782, 599, -26, 261, +-439, 2799, 3758, -185, 230, -43, +682, -21, -75, -29, -55, -1950, +416, 56, 16, 233, 887, -479, +680, -2718, -569, -16448, -33103, -1653, +-16424, 6275, -1401, -7536, 1256, 82, +202, 378, -1703, -5, -27, -665, +-1194, 1295, -18, 118, -11445, 11396, +-15922, 16043, 175, 78, -1655, 102, +374, 132, 161, 4663, -995, -137, +-67, -970, -4393, 2058, -3082, 11739, +-993, 52507, -372470, -339964, -238020, -154668, +-91227, -39704, -68193, -63466, -52270, -36721, +-12972, -20431, -6925, 7426, -2361, 29241, +920, -11369, 13936, -42084, -90219, 4460, +-7456, 295, 60570, -36066, -9836, -23630, +-40550, -22839, -11573, -27317, -28142, -21799, +74247, -37443, -94761, -175261, -418504, -781461, +-995765, -1274142, -822204, -644197, -320592, -79371, +-211045, -170432, -131251, -90676, -8615, -38865, +-25806, 10490, -21115, 43834, -93771, -212052, +-80067, 687824, -841077, -28319, 196054, 89800, +-98757, 81413, 22561, 71310, 76947, -1234, +38817, 69237, 75947, 74313, -220677, 108139, +388007, 614410, 1602908, 2104013, -1945962, -2345233, +-2073811, -1788974, -1237042, -801097, -773094, -511061, +-205272, 126459, 548962, 854332, 1215260, 1516757, +1754373, 1867886, 1938796, 1938332, 1525725, 104199, +1696967, 1687208, 1745905, 1910502, 2033618, 2194668, +2472078, 2712787, 2937869, 3012596, 3095693, 3204093, +3274808, 3283756, 3148592, 2939051, 2641685, 2031332, +1549503, 597843, -490013, -1328870, -1713436, -2059616, +-2084878, -1903964, -1464478, -873102, -195311, 513856, +1135793, 1697317, 2228107, 2629045, 2909611, 2926214, +2785543, 2569874, 2293850, 2134485, 1852516, 752397, +-164140, -1082527, -2067571, -3082101, -4010647, -4913513, +-5770452, -6592737, -7388101, -8166445, -8966356, -9806266, -10700961, -11733450, -12861255, -14030459, -15273330, -16566203, 17977196, 19420796, 20683474, 22109952, 23560036, 25167814, 26942868, 28845886, 30930688, 33206692, 35686848, 38368864, @@ -5694,7 +5694,7 @@ const Word32 CLDFB80_40_fx[400] = // q = 30 134844544, 135983552, 136548480, 136476080, 136056288, 135290432, 133727152, 131405624, 128303264, 124356992, 119537688, 113797504, 107116320, 99479544, 90889712, 81356080, 70886368, 59482072, -47150368, 33884192, 19681098, 4546189, -11521655, -28482206, +47150368, 33884192, 19681098, 4546190, -11521655, -28482206, -46395036, -65246120, -84945856, -105504280, -126897840, -149107856, -172107808, -195862240, -220341504, -245510512, -271335616, -297782912, -324814976, -352387008, -380449280, -408931776, -437767552, -466890752, @@ -5717,64 +5717,64 @@ const Word32 CLDFB80_40_fx[400] = // q = 30 /* SNR: 85.15, PHASE: 0.166666666666667 */ const Word32 CLDFB80_60_fx[600] = // q = 30 -{ -11637, 1767, -122, 1627, -5031, -195, -160, -87, -3544, 136, -195, 20, -35, 25, 131, -1128, 203, 11, --29, -253, -96, -286, -754, 688, --55, -8, 214, -1583, 5224, -169, --595, 7568, -1361, 190, 3, -67, -788, 160, -43, -19, -101, -32, --9, 462, -3064, 321, -84, 23, -12, -114, 150, -968, 1650, -22, --258, -2693, -28, 67, 4754, -32802, --51846, 4945, -595, 6085, -22236, -387, -577, -523, -12973, 672, -657, 65, -91, 64, 313, -2699, 468, 12, --68, -401, -518, -689, -1020, 1669, --23, 719, 448, -2322, -9361, 9537, --13566, 12272, 3729, -157, -827, 60, --1977, -312, 206, 461, 169, 83, -40, -1088, 7330, -767, 201, -59, --41, 406, -660, 3231, -7057, 161, -770, 12038, 198, -1291, -3892, 106546, --387363, -327043, -319712, -213952, -222151, -158503, --105318, -35479, -59682, -66732, -70712, -61609, --55170, -44739, -31711, -9899, -22286, -19251, --9917, -4949, 14171, 3110, 10391, 26566, -4085, -6975, -13331, -9891, 55398, -89244, --120821, 27634, -30750, -9362, -7373, 2810, -49557, 3144, -15960, 10651, -22480, -39334, --43080, -20585, -29742, -8097, -25326, -28070, --28127, -30792, -15878, 36413, 63870, -51034, --98422, -118589, -196780, -380752, -531211, -867079, +{ -11638, 1767, -122, 1628, -5032, -196, +161, -88, -3545, 137, -196, 21, +36, 26, 132, -1128, 203, 12, +-29, -254, -97, -286, -755, 689, +-55, -8, 215, -1583, 5224, -169, +-595, 7569, -1361, 190, 3, -67, +788, 161, -43, -20, -101, -32, +-10, 462, -3064, 321, -85, 24, +12, -115, 151, -968, 1651, -22, +-258, -2694, -28, 68, 4755, -32803, +-51846, 4946, -596, 6086, -22236, -388, +578, -524, -12974, 673, -658, 65, +91, 65, 314, -2699, 469, 12, +-69, -402, -518, -689, -1021, 1669, +-23, 719, 449, -2322, -9362, 9537, +-13566, 12273, 3730, -157, -828, 61, +-1978, -312, 206, 462, 170, 84, +41, -1089, 7330, -768, 201, -60, +-41, 407, -660, 3231, -7058, 161, +771, 12038, 198, -1291, -3893, 106546, +-387363, -327043, -319712, -213953, -222151, -158504, +-105319, -35479, -59682, -66733, -70712, -61610, +-55171, -44739, -31711, -9900, -22286, -19252, +-9917, -4950, 14172, 3111, 10391, 26566, +4086, -6975, -13332, -9892, 55398, -89244, +-120822, 27635, -30751, -9363, -7373, 2810, +49557, 3144, -15960, 10651, -22481, -39335, +-43081, -20586, -29742, -8098, -25326, -28071, +-28128, -30793, -15878, 36414, 63871, -51035, +-98423, -118589, -196780, -380753, -531211, -867079, -924260, -1262671, -1211187, -909700, -706692, -590140, --387712, -140674, -90592, -207147, -191397, -163115, --139419, -107626, -77449, 8619, -49945, -36329, --21445, -20211, 13294, -23388, 30609, 24764, --73158, -145958, -228347, -136170, 302171, 622362, --742756, -516943, 79532, 208728, 139837, 68780, --69176, -27637, 72365, 6203, 62098, 78719, -81230, 52143, -15435, 27781, 58316, 71170, -74613, 81974, 55367, -164495, -160536, 180917, -362005, 375017, 795458, 1461875, 1963205, 2095155, --1983049, -2140127, -2301660, -2078197, -2009648, -1702454, --1336745, -925313, -815553, -803612, -652848, -461550, --265137, -36271, 196856, 518313, 664399, 915382, -1166217, 1339893, 1585569, 1738976, 1799274, 1890534, -1933937, 1945125, 1923994, 1665860, 831664, 77564, -1488037, 1777055, 1688417, 1721974, 1828829, 1937199, -2017936, 2078398, 2252451, 2437196, 2585600, 2754364, -2909841, 2993432, 3016599, 3074265, 3154609, 3219375, -3265044, 3289692, 3277126, 3189837, 3034094, 2902601, -2709098, 2356141, 1938985, 1632226, 1146722, 418214, --305018, -993260, -1403823, -1653091, -1911081, -2083225, --2096448, -2021484, -1849083, -1552143, -1182252, -764155, --310624, 157140, 627282, 1032600, 1427332, 1788413, -2142931, 2466904, 2666628, 2856089, 2979249, 2902476, -2810289, 2692828, 2523008, 2330295, 2193128, 2132549, -2001086, 1283653, 592122, -15236, -616498, -1241114, --1897102, -2589952, -3235046, -3852857, -4472528, -5058432, --5630303, -6187298, -6725205, -7257094, -7776616, -8297674, +-387713, -140675, -90592, -207147, -191397, -163116, +-139419, -107627, -77449, 8620, -49946, -36329, +-21446, -20212, 13295, -23389, 30609, 24765, +-73159, -145958, -228347, -136170, 302172, 622362, +-742756, -516943, 79533, 208728, 139838, 68780, +-69177, -27637, 72365, 6204, 62099, 78720, +81230, 52144, -15436, 27781, 58317, 71170, +74613, 81974, 55368, -164496, -160536, 180918, +362005, 375017, 795458, 1461875, 1963206, 2095155, +-1983049, -2140127, -2301661, -2078197, -2009648, -1702455, +-1336746, -925313, -815553, -803613, -652848, -461551, +-265137, -36271, 196856, 518314, 664400, 915382, +1166217, 1339893, 1585569, 1738976, 1799274, 1890535, +1933937, 1945125, 1923994, 1665861, 831665, 77564, +1488037, 1777056, 1688417, 1721975, 1828829, 1937199, +2017937, 2078398, 2252451, 2437196, 2585601, 2754365, +2909842, 2993432, 3016599, 3074266, 3154609, 3219375, +3265044, 3289693, 3277126, 3189837, 3034094, 2902602, +2709099, 2356141, 1938986, 1632226, 1146722, 418214, +-305018, -993260, -1403823, -1653092, -1911082, -2083225, +-2096449, -2021484, -1849083, -1552144, -1182252, -764155, +-310625, 157141, 627282, 1032601, 1427332, 1788414, +2142931, 2466905, 2666629, 2856089, 2979250, 2902477, +2810289, 2692828, 2523008, 2330296, 2193128, 2132550, +2001086, 1283653, 592123, -15236, -616499, -1241115, +-1897102, -2589952, -3235046, -3852858, -4472529, -5058432, +-5630304, -6187298, -6725206, -7257095, -7776617, -8297675, -8829816, -9380603, -9952123, -10548511, -11192438, -11919065, -12671172, -13438549, -14232061, -15062200, -15899665, -16802572, 17739412, 18725886, 19625418, 20458448, 21392202, 22346532, @@ -5791,7 +5791,7 @@ const Word32 CLDFB80_60_fx[600] = // q = 30 128876128, 126439184, 123615464, 120403880, 116783968, 112750168, 108296544, 103416816, 98114136, 92387688, 86239880, 79676032, 72697184, 65299188, 57491652, 49271324, 40633116, 31582262, -22113356, 12229525, 1933214, -8779568, -19893306, -31396530, +22113356, 12229525, 1933215, -8779568, -19893306, -31396530, -43338216, -55715672, -68469528, -81601800, -95119752, -109012544, -123274624, -137902624, -152887216, -168220960, -183892768, -199892672, -216212560, -232841840, -249770272, -266987040, -284483936, -302248800, @@ -5822,14 +5822,14 @@ const Word32 CLDFB80_60_fx[600] = // q = 30 /* 5ms delay prototype */ const Word32 LDQMF_10_fx[] = // q = 30 -{ - 136778, 68195, -70890, -226890, -352352, -420071, --436801, -444542, -506660, -672814, -980067, -1367880, --1747442, -2041058, -2171766, -2084001, -1756845, -1205000, --470032, 391658, -1352314, -2311011, -3225024, -4068759, --4825636, -5483930, -6033974, -6472204, -6808584, -7075060, --7325811, -7636334, -8074046, -8676456, -9424478, -10219283, --10865228, -11073811, -10475044, -8652076, 5180200, -339903, +{ + 136778, 68195, -70890, -226890, -352352, -420072, +-436802, -444543, -506661, -672815, -980068, -1367880, +-1747442, -2041059, -2171766, -2084001, -1756846, -1205000, +-470033, 391658, -1352314, -2311012, -3225024, -4068760, +-4825637, -5483931, -6033975, -6472204, -6808585, -7075060, +-7325812, -7636335, -8074047, -8676456, -9424478, -10219283, +-10865228, -11073811, -10475044, -8652076, 5180201, -339904, -8224782, -18673422, -31726070, -47229416, -64809980, -83846512, -103451368, -122477480, -139540384, -153063904, -161342016, -162639632, -155309920, -137908720, -109304704, -68777832, -16099735, 48410956, @@ -5839,24 +5839,24 @@ const Word32 LDQMF_10_fx[] = // q = 30 -737309056, -653527872, 566225280, 478344672, 392910464, 312395584, 238918544, 174094816, 118926376, 73749168, 38239292, 11438051, -6809585, -17473586, -23179288, -24893300, -23497172, -19904868, --15070633, -9938406, -5364480, -2000461 +-15070633, -9938406, -5364481, -2000462 }; const Word32 LDQMF_16_fx[] = // q = 30 { -135840, 119104, 61025, -23300, -120395, -217571, --303688, -369787, -411985, -431913, -436959, -439365, --455120, -500073, -585815, -716338, -910646, -1146409, --1392576, -1634244, -1852284, -2026745, -2138911, -2173115, --2118583, -1970210, -1728614, -1399459, -992562, -520339, -3268, 562388, -1169899, -1774887, -2369780, -2945925, --3497147, -4018445, -4506031, -4956920, -5368525, -5738269, --6064625, -6347063, -6587229, -6790047, -6964111, -7121373, --7276727, -7449879, -7659373, -7920485, -8244153, -8633965, +135840, 119105, 61025, -23300, -120396, -217572, +-303688, -369787, -411986, -431913, -436960, -439365, +-455121, -500073, -585815, -716339, -910646, -1146410, +-1392576, -1634245, -1852285, -2026746, -2138911, -2173116, +-2118583, -1970211, -1728614, -1399460, -992562, -520340, +3268, 562389, -1169900, -1774888, -2369781, -2945925, +-3497147, -4018445, -4506032, -4956920, -5368526, -5738270, +-6064626, -6347064, -6587229, -6790047, -6964112, -7121373, +-7276728, -7449880, -7659373, -7920485, -8244154, -8633965, -9083566, -9574508, -10074442, -10534940, -10894573, -11076715, --10992408, -10543848, -9627864, -8139160, 5976363, 3037886, --760648, -5491840, -11209240, -17943616, -25700144, -34454400, +-10992408, -10543848, -9627864, -8139161, 5976364, 3037887, +-760649, -5491840, -11209240, -17943616, -25700144, -34454400, -44150032, -54695840, -65964980, -77789648, -89960896, -102229872, -114308392, -125871952, -136561440, -145990880, -153753088, -159424128, -162577504, -162794960, -159676832, -152853360, -141995744, -126825840, @@ -5869,34 +5869,34 @@ const Word32 LDQMF_16_fx[] = // q = 30 -690793664, -637338560, 582754624, 527645440, 472906400, 419190784, 367113152, 317241312, 270082016, 226065808, 185534960, 148735312, 115810224, 86800312, 61646000, 40190228, 22181636, 7245162, --4169366, -12156084, -17964338, -21866804, -24101958, -24886370, +-4169367, -12156084, -17964338, -21866804, -24101958, -24886370, -24433336, -22962478, -20701850, -17885954, -14749119, -11519968, --8412224, -5619924, -3298610, -1524160 +-8412224, -5619924, -3298610, -1524161 }; const Word32 LDQMF_20_fx[] = // q = 30 { -132094, 130053, 94117, 37811, -32618, -110470, --188996, -262715, -325880, -375095, -408842, -427924, --435582, -437285, -440061, -452481, -482692, -537287, --620380, -731564, -887814, -1074239, -1268925, -1466394, --1657422, -1832122, -1980123, -2091723, -2157945, -2171781, --2128229, -2024637, -1860817, -1638684, -1362085, -1036417, --668022, -263993, 167951, 619488, -1109006, -1594302, --2074062, -2544891, -3002258, -3443306, -3865449, -4266665, --4645247, -4999899, -5329217, -5631868, -5906959, -6153951, --6372928, -6565000, -6732690, -6880012, -7012400, -7136776, --7260809, -7394870, -7549042, -7731643, -7949918, -8208793, +132095, 130054, 94118, 37811, -32619, -110471, +-188997, -262715, -325880, -375095, -408842, -427924, +-435582, -437285, -440062, -452482, -482692, -537287, +-620381, -731564, -887814, -1074239, -1268925, -1466394, +-1657422, -1832122, -1980124, -2091724, -2157946, -2171782, +-2128230, -2024638, -1860817, -1638685, -1362085, -1036418, +-668022, -263994, 167952, 619489, -1109006, -1594302, +-2074063, -2544892, -3002259, -3443307, -3865450, -4266665, +-4645248, -4999899, -5329217, -5631869, -5906959, -6153951, +-6372928, -6565001, -6732690, -6880012, -7012401, -7136777, +-7260809, -7394870, -7549043, -7731644, -7949919, -8208793, -8510223, -8852171, -9227619, -9624792, -10025312, -10404401, -10731825, -10971712, -11081824, -11015548, -10722771, -10150872, --9246198, -7954791, 6226193, 4006048, 1251053, -2079213, --6018495, -10592059, -15815707, -21694928, -28223572, -35382820, +-9246198, -7954792, 6226194, 4006049, 1251053, -2079213, +-6018496, -10592059, -15815707, -21694928, -28223572, -35382820, -43140436, -51449560, -60249600, -69462792, -78994976, -88734976, -98555328, -108312432, -117847120, -126986608, -135542896, -143318016, -150106768, -155693424, -159859744, -162387488, -163062224, -161676800, -158034768, -151954128, -143271408, -131843832, -117553208, -100308496, --80048728, -56744644, -30400730, -1056327, 31212950, 66296312, +-80048728, -56744644, -30400730, -1056328, 31212950, 66296312, -104051416, -144280880, -186784688, -231313168, -277585056, -325290400, -374093504, -423635840, -473540064, -523412928, -572850304, -621440576, -668770368, -714429248, -758014656, -799138176, -837430848, -872549376, @@ -5906,38 +5906,38 @@ const Word32 LDQMF_20_fx[] = // q = 30 -757347840, -716859456, -674920448, -631918336, 588261568, 544170240, 500187776, 456655456, 413899520, 372230592, 331939808, 293293792, 256529792, 221851008, 189423392, 159373024, 131783696, 106697088, -84113256, 63991576, 46252108, 30775584, 17400960, 5897691, --3242831, -10003035, -15315395, -19324048, -22161874, -23947232, +84113256, 63991576, 46252108, 30775584, 17400960, 5897692, +-3242832, -10003035, -15315395, -19324048, -22161874, -23947232, -24790774, -24801182, -24088950, -22768174, -20956786, -18774960, --16343248, -13780261, -11200397, -8711802, -6413877, -4393110, --2713517, -1364254 +-16343248, -13780261, -11200397, -8711802, -6413878, -4393110, +-2713518, -1364255 }; const Word32 LDQMF_30_fx[] = // q = 30 { -121571, 136778, 125654, 101703, 68195, 26874, --20212, -70890, -123705, -176137, -226890, -274105, --316252, -352352, -381787, -404296, -420071, -429892, --434876, -436801, -437431, -439162, -444542, -456065, --476087, -506660, -549090, -604537, -672814, -752813, --858037, -980067, -1106184, -1235997, -1367880, -1498944, --1626464, -1747442, -1858910, -1957741, -2041058, -2106142, --2150372, -2171766, -2168618, -2139642, -2084001, -2001494, --1892254, -1756845, -1596235, -1411744, -1205000, -977797, --732072, -470032, -193707, 94398, 391658, 694988, --1028102, -1352314, -1674660, -1994502, -2311011, -2622127, --2927092, -3225024, -3515027, -3796479, -4068759, -4331383, --4583784, -4825636, -5056603, -5276176, -5483930, -5679644, --5863044, -6033974, -6192384, -6338347, -6472204, -6594554, --6706284, -6808584, -6902958, -6991107, -7075060, -7157331, --7239857, -7325811, -7418950, -7521576, -7636334, -7765374, --7910813, -8074046, -8256088, -8457071, -8676456, -8912695, + 121571, 136778, 125655, 101704, 68195, 26875, +-20212, -70890, -123705, -176138, -226890, -274106, +-316253, -352352, -381787, -404297, -420072, -429892, +-434876, -436802, -437431, -439163, -444543, -456066, +-476087, -506661, -549091, -604538, -672815, -752814, +-858037, -980068, -1106184, -1235998, -1367880, -1498945, +-1626464, -1747442, -1858910, -1957741, -2041059, -2106142, +-2150372, -2171766, -2168618, -2139643, -2084001, -2001495, +-1892255, -1756846, -1596236, -1411745, -1205000, -977797, +-732072, -470033, -193708, 94399, 391658, 694989, +-1028102, -1352314, -1674661, -1994503, -2311012, -2622127, +-2927093, -3225024, -3515027, -3796480, -4068760, -4331384, +-4583784, -4825637, -5056603, -5276176, -5483931, -5679645, +-5863044, -6033975, -6192384, -6338348, -6472204, -6594554, +-6706284, -6808585, -6902959, -6991107, -7075060, -7157331, +-7239857, -7325812, -7418951, -7521577, -7636335, -7765375, +-7910813, -8074047, -8256089, -8457071, -8676456, -8912695, -9163169, -9424478, -9691922, -9959316, -10219283, -10463412, -10682245, -10865228, -11000298, -11074417, -11073811, -10983892, --10789539, -10475044, -10024687, -9422374, -8652076, -7698110, -6547449, 5180200, 3585184, 1749124, -339903, -2692689, --5318486, -8224782, -11417230, -14899579, -18673422, -22738288, +-10789539, -10475044, -10024687, -9422374, -8652076, -7698111, +6547450, 5180201, 3585185, 1749124, -339904, -2692689, +-5318487, -8224782, -11417230, -14899579, -18673422, -22738288, -27091010, -31726070, -36635292, -41807760, -47229416, -52884028, -58751904, -64809980, -71032152, -77388632, -83846512, -90369776, -96918936, -103451368, -109921528, -116280640, -122477480, -128458624, @@ -5960,40 +5960,40 @@ const Word32 LDQMF_30_fx[] = // q = 30 420958208, 392910464, 365412224, 338547584, 312395584, 287029856, 262517344, 238918544, 216286160, 194665808, 174094816, 154602160, 136208672, 118926376, 102759984, 87704592, 73749168, 60872400, -49048000, 38239292, 28404982, 19492542, 11438051, 4150852, --1959298, -6809585, -10983833, -14524688, -17473586, -19875174, +49048000, 38239292, 28404982, 19492542, 11438051, 4150853, +-1959299, -6809585, -10983833, -14524688, -17473586, -19875174, -21764768, -23179288, -24150308, -24711158, -24893300, -24729546, -24252922, -23497172, -22497182, -21287720, -19904868, -18383770, -16760795, -15070633, -13348427, -11626766, -9938406, -8313092, --6779951, -5364480, -4088470, -2966834, -2000461, -1134160 +-6779951, -5364481, -4088471, -2966834, -2000462, -1134160 }; const Word32 LDQMF_32_fx[] = // q = 30 { -119696, 137151, 128519, 107723, 78399, 41835, --441, -46740, -95596, -145201, -193804, -240597, --283800, -322315, -355411, -382593, -403699, -418861, +119697, 137151, 128520, 107723, 78400, 41836, +-442, -46740, -95597, -145201, -193804, -240598, +-283800, -322316, -355411, -382593, -403699, -418862, -428699, -434120, -436480, -437237, -438149, -441391, --449044, -463039, -485346, -517325, -560091, -614347, --679871, -755579, -854378, -968457, -1086190, -1207328, --1330798, -1454135, -1575271, -1691703, -1801098, -1900762, --1988262, -2061316, -2117677, -2155275, -2172542, -2168110, --2140952, -2090356, -2016155, -1918413, -1797518, -1654211, --1489464, -1304576, -1100939, -880095, -643754, -393647, --131597, 140302, 419876, 704519, -1017921, -1322020, --1624457, -1924757, -2222508, -2515834, -2804014, -3086295, --3361992, -3630425, -3891163, -4143615, -4387486, -4622276, --4847760, -5063642, -5269495, -5464962, -5649875, -5823970, --5987171, -6139337, -6280536, -6410931, -6530942, -6641149, --6742438, -6835854, -6922708, -7004444, -7082802, -7159902, --7237255, -7317480, -7403833, -7498177, -7602711, -7719257, --7849651, -7995244, -8157012, -8335468, -8530447, -8741283, +-449045, -463039, -485346, -517326, -560092, -614348, +-679872, -755580, -854379, -968457, -1086190, -1207329, +-1330799, -1454135, -1575271, -1691704, -1801098, -1900763, +-1988263, -2061316, -2117677, -2155275, -2172543, -2168111, +-2140952, -2090356, -2016155, -1918414, -1797519, -1654212, +-1489464, -1304576, -1100939, -880095, -643755, -393648, +-131597, 140303, 419876, 704520, -1017921, -1322020, +-1624457, -1924758, -2222508, -2515835, -2804014, -3086295, +-3361992, -3630425, -3891163, -4143616, -4387487, -4622276, +-4847761, -5063642, -5269495, -5464963, -5649876, -5823971, +-5987172, -6139337, -6280537, -6410931, -6530943, -6641149, +-6742439, -6835855, -6922708, -7004445, -7082802, -7159902, +-7237256, -7317480, -7403834, -7498178, -7602711, -7719257, +-7849652, -7995245, -8157013, -8335469, -8530447, -8741283, -8966383, -9203373, -9449370, -9700315, -9951033, -10195449, -10426707, -10637019, -10818085, -10960053, -11052529, -11084311, -11043675, -10918394, -10695736, -10362793, -9906464, -9313511, --8570674, -7665161, 6586646, 5317833, 3849978, 2171971, -273875, -1853534, -4218327, -6827111, -9685347, -12796811, +-8570674, -7665161, 6586647, 5317833, 3849979, 2171972, +273875, -1853535, -4218327, -6827112, -9685347, -12796811, -16163952, -19787344, -23665996, -27796800, -32174812, -36793016, -41642268, -46710992, -51985904, -57451192, -63088408, -68876552, -74792144, -80808992, -86898528, -93029584, -99168576, -105279432, @@ -6019,45 +6019,45 @@ const Word32 LDQMF_32_fx[] = // q = 30 236754960, 215594992, 195325728, 175977920, 157575920, 140137536, 123674336, 108191456, 93687496, 80154992, 67580128, 55943780, 45219876, 35377480, 26377892, 18179138, 10724362, 3937154, --1793746, -6383128, -10375463, -13802420, -16701194, -19108980, +-1793747, -6383129, -10375463, -13802420, -16701194, -19108980, -21056298, -22573612, -23687536, -24425978, -24814642, -24880884, -24650790, -24152456, -23413234, -22462376, -21328340, -20040900, -18629038, -17122794, -15550818, -13942058, -12323783, -10723672, --9166937, -7678114, -6278687, -4990172, -3829056, -2807490, --1918387, -1103400 +-9166937, -7678115, -6278687, -4990172, -3829056, -2807491, +-1918388, -1103400 }; const Word32 LDQMF_40_fx[] = // q = 30 { -113205, 137253, 134424, 123146, 105210, 81666, -53560, 21301, -14069, -51498, -90644, -130324, --169687, -208132, -245092, -279677, -311295, -339564, +113206, 137254, 134425, 123146, 105211, 81666, +53560, 21302, -14069, -51499, -90644, -130324, +-169687, -208133, -245093, -279677, -311296, -339564, -364227, -384972, -401866, -414904, -424383, -430758, --434461, -436342, -437085, -437525, -438797, -441921, --448028, -458055, -473038, -493888, -521095, -555299, --596905, -645667, -701530, -764070, -843494, -933719, --1026834, -1122238, -1219597, -1318430, -1417239, -1515132, --1610824, -1702996, -1790556, -1872014, -1946187, -2011805, --2067737, -2112858, -2146050, -2166538, -2173557, -2166437, --2144725, -2108000, -2056210, -1989294, -1907357, -1810627, --1699503, -1574446, -1436053, -1285027, -1122102, -948052, --763729, -570120, -367947, -158283, 57836, 279329, +-434462, -436342, -437086, -437526, -438798, -441921, +-448029, -458055, -473038, -493889, -521096, -555299, +-596905, -645667, -701531, -764070, -843495, -933719, +-1026835, -1122239, -1219597, -1318430, -1417239, -1515133, +-1610824, -1702996, -1790556, -1872015, -1946188, -2011806, +-2067738, -2112859, -2146050, -2166539, -2173557, -2166437, +-2144725, -2108000, -2056211, -1989295, -1907357, -1810628, +-1699503, -1574446, -1436054, -1285028, -1122103, -948052, +-763730, -570121, -367947, -158284, 57837, 279329, 505114, 733496, -987128, -1230885, -1473412, -1714779, --1954662, -2192913, -2428355, -2660606, -2889345, -3114178, --3334741, -3550687, -3761781, -3967792, -4168400, -4363502, --4552805, -4736194, -4913551, -5084693, -5249383, -5407420, --5558752, -5703240, -5840789, -5971350, -6094838, -6211307, --6320773, -6423390, -6519395, -6609078, -6692852, -6771221, --6844809, -6914280, -6980362, -7043920, -7105964, -7167615, --7229469, -7292853, -7359780, -7431208, -7508135, -7591745, --7682926, -7782628, -7891679, -8010673, -8140087, -8280181, +-1954662, -2192913, -2428356, -2660607, -2889345, -3114179, +-3334742, -3550687, -3761781, -3967793, -4168400, -4363503, +-4552806, -4736194, -4913551, -5084693, -5249383, -5407420, +-5558753, -5703241, -5840790, -5971350, -6094838, -6211308, +-6320774, -6423390, -6519396, -6609079, -6692852, -6771222, +-6844809, -6914280, -6980363, -7043921, -7105964, -7167616, +-7229469, -7292854, -7359781, -7431209, -7508135, -7591745, +-7682927, -7782628, -7891680, -8010673, -8140087, -8280182, -8430924, -8592083, -8763179, -8943293, -9131195, -9325472, -9524332, -9725493, -9926142, -10123188, -10313198, -10492333, -10656603, -10801577, -10922158, -11013175, -11068951, -11083709, -11051345, -10965628, -10820070, -10607987, -10322919, -9958035, --9506509, -8961670, -8316717, -7565183, 6702942, 5718827, -4609516, 3369112, 1992224, 473872, -1190731, -3005819, +-9506509, -8961670, -8316717, -7565184, 6702942, 5718827, +4609517, 3369113, 1992225, 473872, -1190731, -3005819, -4975066, -7101637, -9388180, -11836610, -14448347, -17224060, -20163764, -23266722, -26531342, -29955288, -33535422, -37267720, -41147260, -45168140, -49323552, -53606284, -58007508, -62517548, @@ -6069,7 +6069,7 @@ const Word32 LDQMF_40_fx[] = // q = 30 -159167008, -156749920, -153712208, -150033328, -145694224, -140676912, -134964928, -128543672, -121399776, -113521832, -104900488, -95527920, -85398544, -74508560, -62856444, -50442808, -37270156, -23343566, --8670189, 6740501, 22876916, 39724980, 57268860, 75490816, +-8670189, 6740502, 22876916, 39724980, 57268860, 75490816, -94376496, -113883272, -134001320, -154702832, -175958544, -197737504, -220006032, -242729312, -265870144, -289389664, -313247648, -337401888, -361809024, -386424256, -411201216, -436093120, -461051360, -486026816, @@ -6089,61 +6089,62 @@ const Word32 LDQMF_40_fx[] = // q = 30 265532592, 247657504, 230315568, 213527440, 197311648, 181683920, 166657488, 152242496, 138447232, 125276624, 112733328, 100817520, 89526080, 78854768, 68795096, 59337532, 50469688, 42175888, -34440516, 27241264, 20558124, 14361678, 8619497, 3303076, +34440516, 27241264, 20558124, 14361678, 8619497, 3303077, -1288525, -5070930, -8454926, -11459781, -14115485, -16433949, -18436136, -20138626, -21555150, -22702724, -23593500, -24242222, -24662498, -24867088, -24870766, -24686354, -24328404, -23811232, -23148884, -22356736, -21449164, -20441404, -19348716, -18185774, -16968062, -15710186, -14426756, -13132428, -11840736, -10565599, --9320040, -8115961, -6965903, -5879984, -4867949, -3939392, --3097321, -2346408, -1680051, -1007770 +-9320040, -8115962, -6965903, -5879984, -4867950, -3939393, +-3097321, -2346408, -1680052, -1007771 }; const Word32 LDQMF_60_fx[] = // q = 30 -{ 102335, 132094, 137435, 135348, 130053, 120487, -108540, 94117, 77296, 58569, 37811, 15642, --7974, -32618, -57896, -84046, -110470, -136942, --163210, -188996, -214437, -239090, -262715, -285164, --306246, -325880, -343923, -360378, -375095, -388053, --399325, -408842, -416724, -423037, -427924, -431547, --433999, -435582, -436522, -437004, -437285, -437643, --438481, -440061, -442702, -446766, -452481, -460181, --470154, -482692, -497967, -516093, -537287, -561714, --589463, -620380, -654511, -691824, -731564, -775910, --829205, -887814, -949147, -1011178, -1074239, -1138340, --1203245, -1268925, -1334920, -1400801, -1466394, -1531259, --1595081, -1657422, -1717943, -1776349, -1832122, -1884920, --1934396, -1980123, -2021834, -2059138, -2091723, -2119241, --2141377, -2157945, -2168655, -2173352, -2171781, -2163852, --2149388, -2128229, -2100421, -2065895, -2024637, -1976676, --1922047, -1860817, -1793098, -1719007, -1638684, -1552285, --1460012, -1362085, -1258675, -1150049, -1036417, -918024, --795131, -668022, -536993, -402188, -263993, -122679, -21420, 167951, 316689, 467104, 619488, 773429, --945238, -1109006, -1271451, -1433049, -1594302, -1754861, --1914784, -2074062, -2232362, -2389327, -2544891, -2698989, --2851488, -3002258, -3151251, -3298295, -3443306, -3586211, --3726943, -3865449, -4001599, -4135335, -4266665, -4395461, --4521664, -4645247, -4766175, -4884419, -4999899, -5112604, --5222403, -5329217, -5433113, -5533999, -5631868, -5726641, +{ + 102336, 132095, 137435, 135349, 130054, 120487, +108540, 94118, 77297, 58570, 37811, 15643, +-7974, -32619, -57897, -84046, -110471, -136942, +-163210, -188997, -214438, -239091, -262715, -285164, +-306247, -325880, -343923, -360378, -375095, -388054, +-399325, -408842, -416725, -423037, -427924, -431547, +-434000, -435582, -436522, -437005, -437285, -437644, +-438481, -440062, -442703, -446767, -452482, -460182, +-470154, -482692, -497967, -516093, -537287, -561715, +-589463, -620381, -654511, -691825, -731564, -775911, +-829205, -887814, -949148, -1011179, -1074239, -1138341, +-1203246, -1268925, -1334921, -1400802, -1466394, -1531260, +-1595082, -1657422, -1717943, -1776350, -1832122, -1884921, +-1934396, -1980124, -2021834, -2059138, -2091724, -2119241, +-2141378, -2157946, -2168655, -2173353, -2171782, -2163852, +-2149388, -2128230, -2100421, -2065896, -2024638, -1976676, +-1922048, -1860817, -1793099, -1719008, -1638685, -1552286, +-1460012, -1362085, -1258676, -1150050, -1036418, -918024, +-795131, -668022, -536993, -402188, -263994, -122679, +21420, 167952, 316690, 467104, 619489, 773430, +-945239, -1109006, -1271451, -1433050, -1594302, -1754861, +-1914784, -2074063, -2232363, -2389328, -2544892, -2698989, +-2851488, -3002259, -3151251, -3298296, -3443307, -3586211, +-3726943, -3865450, -4001599, -4135335, -4266665, -4395461, +-4521664, -4645248, -4766175, -4884420, -4999899, -5112604, +-5222404, -5329217, -5433113, -5533999, -5631869, -5726641, -5818340, -5906959, -5992421, -6074745, -6153951, -6230036, --6303010, -6372928, -6439842, -6503844, -6565000, -6623434, --6679269, -6732690, -6783803, -6832855, -6880012, -6925505, --6969547, -7012400, -7054335, -7095679, -7136776, -7177903, --7219119, -7260809, -7303731, -7348340, -7394870, -7443617, --7494881, -7549042, -7606393, -7667166, -7731643, -7800141, --7872826, -7949918, -8031500, -8117778, -8208793, -8304569, +-6303010, -6372928, -6439843, -6503845, -6565001, -6623435, +-6679269, -6732690, -6783804, -6832855, -6880012, -6925506, +-6969547, -7012401, -7054336, -7095680, -7136777, -7177903, +-7219120, -7260809, -7303731, -7348340, -7394870, -7443617, +-7494881, -7549043, -7606393, -7667166, -7731644, -7800142, +-7872827, -7949919, -8031501, -8117779, -8208793, -8304570, -8405066, -8510223, -8619935, -8734017, -8852171, -8974106, -9099397, -9227619, -9358364, -9490965, -9624792, -9759051, -9892867, -10025312, -10155439, -10282162, -10404401, -10520844, -10630426, -10731825, -10823502, -10903968, -10971712, -11025073, -11062346, -11081824, -11081759, -11060277, -11015548, -10945697, -10848751, -10722771, -10565739, -10375810, -10150872, -9888970, --9588053, -9246198, -8861297, -8431401, -7954791, -7429283, -6854949, 6226193, 5542799, 4803353, 4006048, 3149248, -2231398, 1251053, 206699, -902968, -2079213, -3323232, --4636016, -6018495, -7471561, -8995894, -10592059, -12260527, +-9588053, -9246198, -8861297, -8431401, -7954792, -7429283, +6854949, 6226194, 5542800, 4803353, 4006049, 3149248, +2231398, 1251053, 206700, -902968, -2079213, -3323232, +-4636016, -6018496, -7471561, -8995894, -10592059, -12260527, -14001671, -15815707, -17702624, -19662438, -21694928, -23799650, -25976100, -28223572, -30541232, -32928052, -35382820, -37904240, -40490688, -43140436, -45851544, -48621904, -51449560, -54331840, @@ -6159,7 +6160,7 @@ const Word32 LDQMF_60_fx[] = // q = 30 -146464032, -143271408, -139773568, -135965808, -131843832, -127403488, -122641048, -117553208, -112136840, -106389392, -100308496, -93892368, -87139520, -80048728, -72619504, -64851416, -56744644, -48299972, --39518100, -30400730, -20949652, -11167261, -1056327, 9379870, +-39518100, -30400730, -20949652, -11167261, -1056328, 9379870, 20137698, 31212950, 42601076, 54297248, 66296312, 78593112, -91185600, -104051416, -117194704, -130607064, -144280880, -158207776, -172378736, -186784688, -201415824, -216262032, -231313168, -246558128, @@ -6190,8 +6191,8 @@ const Word32 LDQMF_60_fx[] = // q = 30 140703152, 131783696, 123142424, 114780232, 106697088, 98892400, 91364808, 84113256, 77135992, 70429688, 63991576, 57819020, 51907328, 46252108, 40848248, 35691672, 30775584, 26091894, -21637068, 17400960, 13374445, 9548629, 5897691, 2475271, --592184, -3242831, -5659969, -7917455, -10003035, -11926348, +21637068, 17400960, 13374445, 9548629, 5897692, 2475272, +-592184, -3242832, -5659970, -7917455, -10003035, -11926348, -13696880, -15315395, -16789184, -18123694, -19324048, -20394110, -21338122, -22161874, -22868630, -23462238, -23947232, -24327810, -24607834, -24790774, -24881324, -24883598, -24801182, -24638338, @@ -6199,10 +6200,9 @@ const Word32 LDQMF_60_fx[] = // q = 30 -21607820, -20956786, -20264828, -19536176, -18774960, -17986262, -17174228, -16343248, -15497611, -14641749, -13780261, -12916498, -12055168, -11200397, -10355588, -9525147, -8711802, -7920384, --7153631, -6413877, -5706098, -5031208, -4393110, -3792571, --3230785, -2713517, -2227976, -1784735, -1364254, -871386 +-7153632, -6413878, -5706099, -5031208, -4393110, -3792571, +-3230785, -2713518, -2227977, -1784736, -1364255, -871387 }; - #endif /* OPT_IVAS_FILTER_ROM */ const Word32 rot_vec_delay_re_LDQMF_fx[60] = // q = 31 -- GitLab From 5203c88f1e2dde214c63cb3811ff6160652c3042 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 20 May 2025 10:04:03 +0200 Subject: [PATCH 067/394] Increase headroom for Q_syn, fixes regression in +10dB case Multi_channel_5_1_at_384_kbps_48kHz_in_48kHz_out_7_1_4_out_JBM_Prof_5. --- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 2940a169b..0cec3dd72 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1308,7 +1308,7 @@ void ivas_mdct_core_reconstruct_fx( // norm(synth_buf) >= q_syn - q_win // norm(synth_buf) + q_win >= q_syn 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 ) ) ); - q_syn = add( sf, s_min( q_win, q_winFB ) ); + q_syn = add( sub( sf, 1 ), s_min( q_win, q_winFB ) ); st->Q_syn = q_syn; move16(); -- GitLab From e8218c37649e47fd0e6579797e0a522c86f85c6c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 17 Apr 2025 15:49:28 +0200 Subject: [PATCH 068/394] accept REMOVE_EVS_DUPLICATES --- Workspace_msvc/lib_dec.vcxproj | 3 - Workspace_msvc/lib_dec.vcxproj.filters | 3 - lib_com/bits_alloc_fx.c | 1313 +-------------- lib_com/gs_inact_switching_fx.c | 134 +- lib_com/gs_noisefill_fx.c | 10 +- lib_com/ivas_prot_fx.h | 2 +- lib_com/lsf_tools_fx.c | 220 +-- lib_com/options.h | 2 +- lib_com/prot_fx.h | 577 ++----- lib_com/swb_tbe_com_fx.c | 247 +-- lib_dec/FEC_fx.c | 15 +- lib_dec/FEC_scale_syn_fx.c | 574 +------ lib_dec/acelp_core_dec_fx.c | 2075 +++++++++++++++++------- lib_dec/acelp_core_dec_ivas_fx.c | 107 +- lib_dec/acelp_core_switch_dec_fx.c | 12 +- lib_dec/amr_wb_dec_fx.c | 33 +- lib_dec/cng_dec_fx.c | 683 +------- lib_dec/dec_LPD_fx.c | 4 - lib_dec/dec_ace_fx.c | 22 +- lib_dec/dec_amr_wb_fx.c | 6 +- lib_dec/dec_gen_voic_fx.c | 534 +----- lib_dec/dec_pit_exc_fx.c | 432 +---- lib_dec/dec_post_fx.c | 241 +-- lib_dec/dec_ppp_fx.c | 17 +- lib_dec/dec_tran_fx.c | 12 +- lib_dec/dec_uv_fx.c | 100 +- lib_dec/evs_dec_fx.c | 12 +- lib_dec/fd_cng_dec_fx.c | 485 +----- lib_dec/gain_dec_fx.c | 390 +---- lib_dec/gs_dec_fx.c | 693 +------- lib_dec/ivas_core_dec_fx.c | 2 +- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 +- lib_dec/ivas_tcx_core_dec_fx.c | 7 +- lib_dec/ivas_td_low_rate_dec_fx.c | 20 +- lib_dec/lsf_dec_fx.c | 276 +--- lib_dec/pit_dec_fx.c | 256 +-- lib_dec/post_dec_fx.c | 18 +- lib_enc/acelp_core_enc_fx.c | 40 +- lib_enc/acelp_core_switch_enc_fx.c | 37 +- lib_enc/analy_lp_fx.c | 150 +- lib_enc/cod_ace_fx.c | 11 +- lib_enc/enc_gen_voic_fx.c | 23 +- lib_enc/enc_tran_fx.c | 15 +- lib_enc/ivas_core_pre_proc_front_fx.c | 7 +- lib_enc/ivas_core_pre_proc_fx.c | 13 +- lib_enc/ivas_front_vad_fx.c | 6 +- lib_enc/ivas_td_low_rate_enc_fx.c | 4 +- lib_enc/lsf_enc_fx.c | 7 +- lib_enc/pre_proc_fx.c | 14 +- lib_enc/prot_fx_enc.h | 104 +- lib_enc/transition_enc_fx.c | 41 +- 51 files changed, 2129 insertions(+), 7884 deletions(-) diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 2d06d29aa..2839a5812 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -139,9 +139,6 @@ false - - false - diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index 8a4fc4605..ebf15bd4c 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -119,9 +119,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index e9abb7651..3bfcd0c20 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -434,174 +434,12 @@ static Word16 fcb_table( } /*-------------------------------------------------------------------* - * acelp_FCB_allocator() + * acelp_FCB_allocator_fx() * * Routine to allocate fixed innovation codebook bit-budget *--------------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES -static ivas_error acelp_FCB_allocator( - Word16 *nBits, /* i/o: available bit-budget */ - Word16 fixed_cdk_index[], /* o : codebook index Q0 */ - Word16 nb_subfr, /* i : number of subframes */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 coder_type, /* i : coder type */ - const Word16 tc_subfr, /* i : TC subframe index */ - const Word16 fix_first /* i : flag to indicate whether the first subframe bit-budget was fixed */ -) -{ - Word16 cdbk, sfr, step; - Word16 nBits_tmp; - Word16 *p_fixed_cdk_index; - Word16 max_n; - ivas_error error; - // PMT("Not floating point computation, but fixed point operator are still missing ") - - error = IVAS_ERR_OK; - move32(); - - cdbk = coder_type; /* just to avoid warning when DEBUGGING is deactivated */ - move16(); - - p_fixed_cdk_index = fixed_cdk_index; - - /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse not in the first subframe */ - test(); - IF( GE_16( tc_subfr, L_SUBFR ) && fix_first ) - { - Word16 i; - - FOR( i = 0; i < nb_subfr; i++ ) - { - *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[i] ) ); - move16(); - } - return error; - } - - /* TRANSITION coding: first subframe bit-budget was already fixed, glottal pulse in the first subframe */ - sfr = 0; - move16(); - IF( fix_first ) - { - *nBits = sub( *nBits, ACELP_FIXED_CDK_BITS( fixed_cdk_index[0] ) ); - move16(); - sfr = 1; - move16(); - p_fixed_cdk_index++; - nb_subfr = 3; - move16(); - } - - /* distribute the bit-budget equally between subframes */ - IF( GT_16( L_subfr, L_SUBFR ) ) /* access fast_FCB_bits_2sfr */ - { - max_n = 6; - move16(); - } - ELSE - { - max_n = ACELP_FIXED_CDK_NB; - move16(); - } - FOR( cdbk = 0; cdbk < max_n; cdbk++ ) - { - IF( GT_32( L_mult0( fcb_table( cdbk, L_subfr ), nb_subfr ), L_deposit_l( *nBits ) ) ) - { - BREAK; - } - } - cdbk = sub( cdbk, 1 ); - -#ifdef DEBUGGING - if ( cdbk < 0 && coder_type != TRANSITION ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" ); - } - if ( ( L_subfr == L_SUBFR && cdbk >= ACELP_FIXED_CDK_NB ) || ( L_subfr == 2 * L_SUBFR && fcb_table( cdbk, L_subfr ) == 128 /*stop value*/ ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bit-budget for fixed innovation codebook (frame = %d). Exiting! \n" ); - } -#endif - - set16_fx( p_fixed_cdk_index, cdbk, nb_subfr ); - nBits_tmp = 0; - move16(); - IF( cdbk >= 0 ) - { - nBits_tmp = fcb_table( cdbk, L_subfr ); - } - ELSE - { - nBits_tmp = 0; - move16(); - } - *nBits = sub( *nBits, i_mult( nBits_tmp, nb_subfr ) ); - move16(); - - /* try to increase the FCB bit-budget of the first subframe(s) */ - IF( LT_16( cdbk, ACELP_FIXED_CDK_NB - 1 ) ) - { - step = sub( fcb_table( add( cdbk, 1 ), L_subfr ), nBits_tmp ); - WHILE( *nBits >= step ) - { - ( *p_fixed_cdk_index )++; - *nBits = sub( *nBits, step ); - move16(); - p_fixed_cdk_index++; - } - - /* try to increase the FCB of the first subframe in cases when the next step is lower than the current step */ - step = sub( fcb_table( add( fixed_cdk_index[sfr], 1 ), L_subfr ), fcb_table( fixed_cdk_index[sfr], L_subfr ) ); - test(); - IF( GE_16( *nBits, step ) && cdbk >= 0 ) - { - fixed_cdk_index[sfr] = add( fixed_cdk_index[sfr], 1 ); - move16(); - *nBits = sub( *nBits, step ); - move16(); - test(); - IF( GE_16( *nBits, step ) && EQ_16( fixed_cdk_index[sfr + 1], sub( fixed_cdk_index[sfr], 1 ) ) ) - { - sfr = add( sfr, 1 ); - fixed_cdk_index[sfr] = add( fixed_cdk_index[sfr], 1 ); - move16(); - *nBits = sub( *nBits, step ); - move16(); - } - } - } - /* TRANSITION coding: allocate highest FCBQ bit-budget to the subframe with the glottal-shape codebook */ - IF( GE_16( tc_subfr, L_SUBFR ) ) - { - Word16 tempr; - - SWAP( fixed_cdk_index[0], fixed_cdk_index[tc_subfr / L_SUBFR] ); - - /* TRANSITION coding: allocate second highest FCBQ bit-budget to the last subframe */ - IF( idiv1616( tc_subfr, L_SUBFR ) < sub( nb_subfr, 1 ) ) - { - SWAP( fixed_cdk_index[( tc_subfr - L_SUBFR ) / L_SUBFR], fixed_cdk_index[nb_subfr - 1] ); - } - } - - /* when subframe length > L_SUBFR, number of bits instead of codebook index is signalled */ - IF( GT_16( L_subfr, L_SUBFR ) ) - { - Word16 i, j; - FOR( i = 0; i < nb_subfr; i++ ) - { - j = fixed_cdk_index[i]; - move16(); - fixed_cdk_index[i] = fast_FCB_bits_2sfr[j]; - move16(); - } - } - - return error; -} -#endif -static ivas_error acelp_FCB_allocator_ivas( +static ivas_error acelp_FCB_allocator_fx( Word16 *nBits, /* i/o: available bit-budget */ Word16 fixed_cdk_index[], /* o : codebook index Q0 */ Word16 nb_subfr, /* i : number of subframes */ @@ -754,1141 +592,16 @@ static ivas_error acelp_FCB_allocator_ivas( return error; } + /*-------------------------------------------------------------------* - * config_acelp1() + * config_acelp1_fx() * * Configure ACELP bit allocation * - should be in range of <6700; 24350> for ACELP@12.8kHz * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz *--------------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES -ivas_error config_acelp1( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signalling_bits, /* i : number of signalling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 active_cnt, /* i : Active frame counter */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -) -{ - Word16 i, bits, nb_subfr; - Word16 flag_hardcoded, coder_type_sw, fix_first; - Word32 core_brate; -#ifdef DEBUGGING - (void) active_cnt; -#endif - ivas_error error; - - error = IVAS_ERR_OK; - move32(); - // PMT("Not floating point computation, but fixed point operator are still missing ") - /*-----------------------------------------------------------------* - * Set the flag indicating two-stage Unvoiced (UC) frame - *-----------------------------------------------------------------*/ - - *uc_two_stage_flag = 0; - move16(); - IF( EQ_16( coder_type, UNVOICED ) ) - { - test(); - test(); - test(); - test(); - test(); - if ( GE_32( total_brate, MIN_UNVOICED_TWO_STAGE_BRATE ) && element_mode > EVS_MONO && ( idchan == 0 || ( ( GE_32( total_brate, 8500 ) || extl_brate == 0 ) && EQ_16( tdm_LRTD_flag, 1 ) ) ) ) - { - *uc_two_stage_flag = 1; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Set the number of subframes - *-----------------------------------------------------------------*/ - - IF( EQ_16( L_frame, L_FRAME ) ) - { - nb_subfr = NB_SUBFR; - move16(); - -#ifdef DEBUGGING - if ( ( ( core_brate_inp < 5900 && coder_type > UNVOICED ) && !( core_brate_inp < MIN_TC_BRATE && coder_type == TRANSITION ) ) && !( idchan > 0 && element_mode == IVAS_CPE_TD ) && !( element_mode == IVAS_SCE && tdm_low_rate_mode ) ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp ); - } - - if ( core_brate_inp > ACELP_12k8_HIGH_LIMIT && core == ACELP_CORE ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too high bitrate (%d bps) for ACELP@12k8 in frame %d. Exiting!\n", core_brate_inp ); - } -#endif - } - ELSE /* L_frame == L_FRAME16k */ - { - nb_subfr = NB_SUBFR16k; - move16(); - -#ifdef DEBUGGING - if ( core_brate_inp < ACELP_16k_LOW_LIMIT && core == ACELP_CORE ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Too low bitrate (%d bps) for ACELP@16k in frame %d. Exiting!\n", core_brate_inp ); - } -#endif - } - - coder_type_sw = coder_type; - move16(); - IF( core != ACELP_CORE ) - { - /* used in acelp_core_switch_enc() */ - nb_subfr = 1; - move16(); - if ( EQ_16( L_frame, L_FRAME ) ) - { - coder_type_sw = TRANSITION; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Check if the core_brate is hard coded (to keep BE for mono core) or not - *-----------------------------------------------------------------*/ - - flag_hardcoded = 0; - move16(); - i = 0; - move16(); - - WHILE( i < SIZE_BRATE_INTERMED_TBL ) - { - IF( EQ_32( core_brate_inp, brate_intermed_tbl[i] ) ) - { - flag_hardcoded = 1; - move16(); - BREAK; - } - - IF( LT_32( core_brate_inp, brate_intermed_tbl[i] ) ) - { - flag_hardcoded = 0; - move16(); - BREAK; - } - - i = add( i, 1 ); - } - - test(); - test(); - test(); - IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( coder_type, AUDIO ) && - LE_32( core_brate_inp, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */ - { - i = sub( i, 1 ); - } - - core_brate = brate_intermed_tbl[i]; - move32(); - - if ( element_mode > EVS_MONO ) - { - flag_hardcoded = 0; /* use automatic and flexible ACELP bit-budget allocation */ - move16(); - } - - test(); - if ( ( core != ACELP_CORE ) && ( element_mode == EVS_MONO ) ) /* needed for mode1 core switching in EVS mono */ - { - flag_hardcoded = 1; - move16(); - } - - /*-----------------------------------------------------------------* - * ACELP bit allocation - *-----------------------------------------------------------------*/ - test(); - test(); - IF( !( EQ_16( coder_type, TRANSITION ) && NE_16( tc_subfr, -1 ) ) || EQ_16( enc_dec, DEC ) ) - { - /* Set the bit-budget */ - bits = extract_l( Mpy_32_32( core_brate_inp, ONE_BY_FRAMES_PER_SEC_Q31 ) ); // Q0 - - test(); - test(); - IF( EQ_16( coder_type, TRANSITION ) && EQ_16( enc_dec, DEC ) && EQ_16( tc_call, 1 ) ) - { - bits = add( bits, *nBits_es_Pred ); /* equalize for 4th signaling bit estimated at the encoder in TC_0_192 */ - } - - /* Subtract signalling bits */ - test(); - test(); - IF( EQ_16( enc_dec, DEC ) && EQ_16( idchan, 1 ) && element_mode > EVS_MONO ) - { - bits = sub( bits, TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS ); - - IF( EQ_16( tdm_LRTD_flag, 1 ) ) - { - bits = add( bits, STEREO_BITS_TCA ); - } - - /* subtract TBE/BWE flag */ - test(); - test(); - test(); - test(); - test(); - test(); - IF( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) ) - { - bits = sub( bits, 1 ); - } - } - ELSE - { - /* Subtract signalling bits */ - bits = sub( bits, signalling_bits ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( extl_brate > 0 && ( EQ_16( extl, WB_TBE ) || EQ_16( extl, SWB_TBE ) || EQ_16( extl, FB_TBE ) || EQ_16( extl, WB_BWE ) || EQ_16( extl, SWB_BWE ) || EQ_16( extl, FB_BWE ) ) ) - { - /* extension layer signalling bit is counted in the extension layer bitbudget */ - bits = add( bits, 1 ); - } - - /*-----------------------------------------------------------------* - * LSF Q bit-budget - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( !tdm_lp_reuse_flag || idchan == 0 ) - { - /* LSF Q bit-budget */ - acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; - move16(); - - IF( !flag_hardcoded ) - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode ) - { - acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; - move16(); - } - ELSE IF( ( LT_32( total_brate, 7200 ) || coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( idchan, 1 ) ) - { - /* TD stereo, secondary channel: do nothing */ - acelp_cfg->lsf_bits = LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; - move16(); - } - ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) && LT_32( brate_intermed_tbl[i], ACELP_9k60 ) ) - { - /* primary channel: do nothing */ - } - ELSE IF( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] >= ACELP_9k60*/ ) - { - acelp_cfg->lsf_bits = 42; - move16(); - } - ELSE IF( LE_32( total_brate, 9600 ) || EQ_16( coder_type, UNVOICED ) ) - { - acelp_cfg->lsf_bits = 31; - move16(); - } - ELSE IF( LE_32( total_brate, 20000 ) ) - { - acelp_cfg->lsf_bits = 36; - move16(); - } - ELSE - { - acelp_cfg->lsf_bits = 41; - move16(); - } - } - ELSE /* L_frame == L_FRAME16k */ - { - acelp_cfg->lsf_bits = 41; - move16(); - } - } - - bits = sub( bits, acelp_cfg->lsf_bits ); - - /* mid-LSF Q bit-budget */ - acelp_cfg->mid_lsf_bits = mid_LSF_bits_tbl[LSF_BIT_ALLOC_IDX_fx( core_brate, coder_type )]; - move16(); - - test(); - if ( element_mode > EVS_MONO && EQ_16( coder_type, AUDIO ) /*&& brate_intermed_tbl[i] < ACELP_9k60*/ ) - { - acelp_cfg->mid_lsf_bits = 5; - move16(); - /* primary channel: do nothing */ - } - - bits = sub( bits, acelp_cfg->mid_lsf_bits ); - } - ELSE IF( EQ_16( tdm_lp_reuse_flag, 1 ) && EQ_16( idchan, 1 ) && NE_16( active_cnt, 1 ) ) - { - bits = sub( bits, TDM_IC_LSF_PRED_BITS ); - } - /* gain Q bit-budget - part 1: 'Es_pred' of memory-less gain Q */ - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( NE_16( coder_type, UNVOICED ) && NE_16( coder_type, AUDIO ) && coder_type != INACTIVE && !( LE_32( core_brate, ACELP_8k00 ) && NE_16( coder_type, TRANSITION ) ) ) /* mid bitrates in GC and VC, low+mid bitrates in TC */ || - ( coder_type == INACTIVE && !inactive_coder_type_flag ) /* AVQ inactive */ - ) - { - *nBits_es_Pred = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, -1 )]; - move16(); - bits = sub( bits, *nBits_es_Pred ); - } - ELSE IF( *uc_two_stage_flag ) - { - *nBits_es_Pred = 4; - move16(); - bits = sub( bits, *nBits_es_Pred ); - } - } - ELSE - { - bits = *unbits; - move16(); - } - - test(); - IF( EQ_16( coder_type, TRANSITION ) && tc_call == 0 ) - { - *unbits = bits; - return error; - } - - /*-----------------------------------------------------------------* - * Low-rate mode - bits are allocated in tdm_low_rate_enc() - *-----------------------------------------------------------------*/ - test(); - IF( EQ_16( element_mode, IVAS_SCE ) && tdm_low_rate_mode ) - { - acelp_cfg->FEC_mode = 0; - acelp_cfg->ltf_mode = FULL_BAND; - *nBits_es_Pred = 0; - *unbits = 0; - acelp_cfg->ubits = 0; - move16(); - move16(); - move16(); - move16(); - move16(); - - return error; - } - - /*-----------------------------------------------------------------* - * Supplementary information for FEC - *-----------------------------------------------------------------*/ - - acelp_cfg->FEC_mode = 0; - move16(); - test(); - test(); - IF( GE_32( core_brate, ACELP_11k60 ) && ( idchan == 0 || element_mode == EVS_MONO ) ) - { - acelp_cfg->FEC_mode = 1; - move16(); - - test(); - test(); - IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && NE_16( coder_type, VOICED ) ) - { - bits = sub( bits, FEC_BITS_CLS ); - } - - IF( NE_16( coder_type, TRANSITION ) ) - { - IF( GE_32( total_brate, ACELP_16k40 ) ) - { - acelp_cfg->FEC_mode = 2; - move16(); - test(); - IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) ) - { - bits = sub( bits, FEC_BITS_ENR ); - } - } - - IF( GE_32( total_brate, ACELP_32k ) ) - { - acelp_cfg->FEC_mode = 3; - move16(); - - test(); - IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) ) - { - bits = sub( bits, FEC_BITS_POS ); - } - } - } - } - - /*-----------------------------------------------------------------* - * LP filtering of the adaptive excitation - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - test(); - test(); - IF( idchan > 0 && element_mode > EVS_MONO ) - { - acelp_cfg->ltf_mode = FULL_BAND; - move16(); - } - ELSE IF( EQ_16( coder_type, UNVOICED ) ) - { - acelp_cfg->ltf_mode = FULL_BAND; - move16(); - } - ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) && LT_32( core_brate, ACELP_11k60 ) ) - { - acelp_cfg->ltf_mode = LOW_PASS; - move16(); - } - ELSE IF( GE_32( core_brate, ACELP_11k60 ) && ( NE_16( coder_type, AUDIO ) && !( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME ) ) ) ) - { - test(); - test(); - IF( coder_type == INACTIVE && EQ_16( L_frame, L_FRAME16k ) && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ - { - acelp_cfg->ltf_mode = FULL_BAND; - move16(); - } - ELSE - { - acelp_cfg->ltf_mode = NORMAL_OPERATION; - move16(); - IF( coder_type != TRANSITION ) - { - bits = sub( bits, nb_subfr ); - } - } - } - ELSE - { - acelp_cfg->ltf_mode = FULL_BAND; - move16(); - } - - /*-----------------------------------------------------------------* - * UC bit-budget - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_9k60 ) ) ) && ( idchan == 0 || element_mode == EVS_MONO ) ) - { - bits = sub( bits, NBITS_NOISENESS ); /* noiseness */ - } - IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) - { - bits = sub( bits, 3 * NB_SUBFR ); /* tilt factor */ - } - - /*-----------------------------------------------------------------* - * TC bit-budget - *-----------------------------------------------------------------*/ - - fix_first = 0; - move16(); - IF( EQ_16( coder_type, TRANSITION ) ) - { - if ( EQ_16( tc_call, 2 ) ) - { - fix_first = 1; - move16(); - } - - /* TC signalling */ - IF( EQ_16( L_frame, L_FRAME ) ) - { - IF( EQ_16( tc_subfr, TC_0_0 ) ) - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 1 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, 3 ); /* LP filtering flag */ - } - } - ELSE IF( EQ_16( tc_subfr, TC_0_64 ) ) - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 4 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, 3 ); /* LP filtering flag */ - } - } - ELSE IF( EQ_16( tc_subfr, TC_0_128 ) ) - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 4 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, 2 ); /* LP filtering flag */ - } - } - ELSE IF( EQ_16( tc_subfr, TC_0_192 ) ) - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 3 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, 1 ); /* LP filtering flag */ - } - } - ELSE IF( EQ_16( tc_subfr, L_SUBFR ) ) - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 3 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, idiv1616( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ - } - } - ELSE - { - IF( enc_dec == ENC ) - { - bits = sub( bits, 4 ); /* TC signalling */ - } - - IF( EQ_16( acelp_cfg->ltf_mode, NORMAL_OPERATION ) ) - { - bits = sub( bits, idiv1616_1( sub( L_FRAME - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ - } - } - } - ELSE /* L_frame == L_FRAME16k */ - { - IF( enc_dec == ENC ) - { - IF( LE_16( tc_subfr, 2 * L_SUBFR ) ) - { - bits = sub( bits, 2 ); /* TC signalling */ - } - ELSE - { - bits = sub( bits, 3 ); /* TC signalling */ - } - } - - // bits -= ( L_FRAME16k - tc_subfr - L_SUBFR ) / L_SUBFR; /* LP filtering flag */ - bits = sub( bits, idiv1616_1( sub( L_FRAME16k - L_SUBFR, tc_subfr ), L_SUBFR ) ); /* LP filtering flag */ - } - - /* glottal-shape codebook bits */ - bits = sub( bits, 3 + 6 + 1 + 3 ); - } - - /*-----------------------------------------------------------------* - * pitch, innovation, gains bit-budget - *-----------------------------------------------------------------*/ - - acelp_cfg->fcb_mode = 0; - move16(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( element_mode, IVAS_CPE_TD ) && EQ_16( tdm_low_rate_mode, 1 ) && ( coder_type != INACTIVE ) && NE_16( coder_type, UNVOICED ) ) /* GENERIC low rate mode for secondary channel */ - { - set16_fx( acelp_cfg->pitch_bits, 0, NB_SUBFR16k ); - set16_fx( acelp_cfg->gains_mode, 0, NB_SUBFR16k ); - - FOR( i = 0; i < 2; i++ ) - { - acelp_cfg->pitch_bits[i] = 0; - move16(); - IF( tdm_Pitch_reuse_flag == 0 ) - { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( 2 * L_SUBFR, i ), TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - bits = sub( bits, acelp_cfg->pitch_bits[i] ); - } - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, GENERIC, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - bits = sub( bits, acelp_cfg->gains_mode[i] ); - } - acelp_cfg->fcb_mode = 1; - move16(); - -#ifdef DEBUGGING - if ( bits >= 55 ) - { - printf( "too much bits -> %d, LPC = %d and pitch = %d\n", bits, tdm_lp_reuse_flag, tdm_Pitch_reuse_flag ); - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); - } - else -#endif - IF( GE_16( bits, 16 ) ) - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); - } - ELSE - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); - acelp_cfg->fixed_cdk_index[1] = -1; - move16(); - } - acelp_cfg->fixed_cdk_index[2] = -1; - move16(); - acelp_cfg->fixed_cdk_index[3] = -1; - move16(); - } - ELSE IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || /* @12.8kHz core except of GSC */ - ( EQ_16( nb_subfr, NB_SUBFR16k ) && ( !inactive_coder_type_flag || coder_type != INACTIVE ) ) /* @16kHz core GC, TC, AVQ inactive */ || - EQ_16( core, HQ_CORE ) /* ACELP -> HQ switching in EVS */ - ) - { - /* pitch Q & gain Q bit-budget - part 2*/ - FOR( i = 0; i < nb_subfr; i++ ) - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - test(); - IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) ) - { - acelp_cfg->pitch_bits[i] = 0; - move16(); - } - ELSE - { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - } - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - } - ELSE /* L_frame == L_FRAME16k */ - { - test(); - IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) && EQ_16( idchan, 1 ) ) - { - acelp_cfg->pitch_bits[i] = 0; - move16(); - } - ELSE - { - acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; - move16(); - } - acelp_cfg->gains_mode[i] = gain_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type_sw, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; - move16(); - } - - bits = sub( bits, acelp_cfg->pitch_bits[i] ); - - test(); - IF( coder_type == INACTIVE && EQ_16( acelp_cfg->gains_mode[i], 6 ) /* VQ vs. SQ threshold @32 kbps */ ) - { - bits = sub( bits, 5 ); - } - ELSE - { - if ( EQ_16( *uc_two_stage_flag, 1 ) ) - { - acelp_cfg->gains_mode[i] = 7; - move16(); - } - - bits = sub( bits, acelp_cfg->gains_mode[i] ); - } - } - - /* algebraic codebook bit-budget */ - test(); - test(); - test(); - test(); - test(); - test(); - IF( flag_hardcoded /* EVS */ || - ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ || - ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ ) - { - FOR( i = 0; i < nb_subfr; i++ ) - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - } - ELSE /* L_frame == L_FRAME16k */ - { - acelp_cfg->fixed_cdk_index[i] = FCB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; - move16(); - } - bits = sub( bits, acelp_cfg->fixed_cdk_index[i] ); - } - } - ELSE IF( !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) - { - test(); - IF( EQ_16( coder_type, UNVOICED ) && !( *uc_two_stage_flag ) ) - { - i = idiv1616( bits, NB_SUBFR ); - IF( s_and( i, 1 ) == 0 ) - { - i = sub( i, 1 ); /* must be odd */ - } - i = s_min( i, 13 ); -#ifdef DEBUG_MODE_TD - if ( i < 0 ) - IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR::: UC negative index should not happen at frame %d\n" ); -#endif - i = s_max( i, 0 ); /* If i == 0-> random noise generator will be used as FCB */ - set16_fx( acelp_cfg->fixed_cdk_index, i, NB_SUBFR ); - bits = sub( bits, i_mult( i, NB_SUBFR ) ); - } - ELSE - { - - acelp_cfg->fcb_mode = 1; - move16(); - test(); - test(); - IF( EQ_16( element_mode, IVAS_CPE_TD ) ) - { - IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), ( nb_subfr ) ) ) ) /* enough bits for all fcb */ - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); - } - ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) ) - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr - 1, L_SUBFR, coder_type, tc_subfr, fix_first ); - acelp_cfg->fixed_cdk_index[3] = -1; - move16(); - } - ELSE IF( GE_16( bits, i_mult( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) ) - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first ); - acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1]; - move16(); - acelp_cfg->fixed_cdk_index[1] = -1; - move16(); - acelp_cfg->fixed_cdk_index[3] = -1; - move16(); - } - ELSE IF( GE_16( bits, ACELP_FIXED_CDK_BITS( 0 ) ) ) - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first ); - acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0]; - move16(); - acelp_cfg->fixed_cdk_index[0] = -1; - move16(); - acelp_cfg->fixed_cdk_index[2] = -1; - move16(); - acelp_cfg->fixed_cdk_index[3] = -1; - move16(); - } - ELSE /* No FCB */ - { -#ifdef DEBUGGING - IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING!!!, No bit allocated to FCB, check frame %d\n" ); -#endif - acelp_cfg->fixed_cdk_index[0] = -1; - move16(); - acelp_cfg->fixed_cdk_index[1] = -1; - move16(); - acelp_cfg->fixed_cdk_index[2] = -1; - move16(); - acelp_cfg->fixed_cdk_index[3] = -1; - move16(); - } - } - ELSE IF( NE_16( element_mode, IVAS_CPE_TD ) && GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) - { - bits = 100; /* 9 kbps for fcb */ - move16(); - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); - } - ELSE - { - acelp_FCB_allocator( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); - } - } - } - - /* AVQ codebook */ - test(); - test(); - test(); - IF( ( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && coder_type != INACTIVE ) /* high-birate ACELP except IC */ || - ( !inactive_coder_type_flag && coder_type == INACTIVE ) /* AVQ inactive */ ) - { - FOR( i = 0; i < nb_subfr; i++ ) - { - IF( flag_hardcoded ) - { - acelp_cfg->AVQ_cdk_bits[i] = AVQ_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( core_brate, coder_type, i_mult( i, L_SUBFR ), TC_SUBFR2IDX_16KHZ_fx( tc_subfr ) )]; - move16(); - { - bits = sub( bits, acelp_cfg->AVQ_cdk_bits[i] ); - } - } - - bits = sub( bits, G_AVQ_BITS ); - } - - test(); - test(); - IF( GE_32( core_brate_inp, MIN_BRATE_AVQ_EXC ) && LE_32( core_brate_inp, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( coder_type, GENERIC ) ) - { - /* harm. flag ACELP AVQ */ - bits = sub( bits, 1 ); - } - - IF( !flag_hardcoded ) - { - Word16 bit_tmp; - - bit_tmp = idiv1616( bits, nb_subfr ); - set16_fx( acelp_cfg->AVQ_cdk_bits, bit_tmp, nb_subfr ); - bits = sub( bits, i_mult( bit_tmp, nb_subfr ) ); - - bit_tmp = bits % nb_subfr; - move16(); - acelp_cfg->AVQ_cdk_bits[0] = add( acelp_cfg->AVQ_cdk_bits[0], bit_tmp ); - move16(); - bits = sub( bits, bit_tmp ); - } - } - } - ELSE IF( ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) /* LBR secondary channel in TD stereo */ || - ( ( coder_type == INACTIVE || EQ_16( coder_type, AUDIO ) ) && EQ_16( nb_subfr, NB_SUBFR ) ) /* GSC @12.8kHz */ || - ( coder_type == INACTIVE && inactive_coder_type_flag ) /* AVQ inactive */ ) - { - Word32 Local_BR, Pitch_BR; - Word16 Pitch_CT; - - /* as defined at the beginning of [enc,dec]_pit_exc() */ - test(); - test(); - IF( GSC_IVAS_mode > 0 && ( GSC_noisy_speech || GT_32( core_brate, GSC_H_RATE_STG ) ) ) - { - Local_BR = ACELP_8k00; - move32(); - Pitch_CT = GENERIC; - move16(); - Pitch_BR = ACELP_8k00; - move32(); - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - Local_BR = ACELP_14k80; - move32(); - test(); - if ( GSC_IVAS_mode > 0 && LT_32( core_brate, IVAS_24k4 ) ) - { - Local_BR = ACELP_9k60; - move32(); - } - Pitch_BR = core_brate; - move32(); - } - } - ELSE IF( GSC_noisy_speech ) - { - Local_BR = ACELP_7k20; - move32(); - Pitch_CT = GENERIC; - move16(); - Pitch_BR = ACELP_7k20; - move32(); - if ( EQ_16( L_frame, L_FRAME16k ) ) - { - Pitch_BR = core_brate; - move32(); - } - } - ELSE - { - Local_BR = ACELP_7k20; - move32(); - Pitch_CT = AUDIO; - move16(); - Pitch_BR = core_brate; - move32(); - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - Local_BR = ACELP_13k20; - move32(); - Pitch_CT = GENERIC; - move16(); - } - } - - FOR( i = 0; i < nb_subfr; i++ ) - { - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - acelp_cfg->pitch_bits[i] = ACB_bits_16kHz_tbl[BIT_ALLOC_IDX_16KHZ_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )]; - move16(); - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; - move16(); - } - ELSE - { - acelp_cfg->pitch_bits[i] = ACB_bits_tbl[BIT_ALLOC_IDX_fx( Pitch_BR, Pitch_CT, i_mult( i, L_SUBFR ), 0 )]; - move16(); - acelp_cfg->fixed_cdk_index[i] = FCB_bits_tbl[BIT_ALLOC_IDX_fx( Local_BR, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; - move16(); - acelp_cfg->gains_mode[i] = gain_bits_tbl[BIT_ALLOC_IDX_fx( ACELP_7k20, LOCAL_CT, i_mult( i, L_SUBFR ), 0 )]; - move16(); - } - } - } - - test(); - test(); - test(); - IF( EQ_16( coder_type, TRANSITION ) && ( EQ_16( tc_call, 1 ) && tc_subfr == 0 && EQ_16( L_frame, L_FRAME ) ) ) - { - return error; - } - - /*-----------------------------------------------------------------* - * unused bits handling - *-----------------------------------------------------------------*/ - - acelp_cfg->ubits = 0; /* these bits could be reused for something else */ - move16(); - - test(); - IF( flag_hardcoded && NE_32( core_brate, PPP_NELP_2k80 ) ) - { - test(); - test(); - /* unused bits */ - IF( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE && LE_32( core_brate, ACELP_24k40 ) ) ) - { - acelp_cfg->ubits = 0; - move16(); - } - ELSE IF( EQ_16( L_frame, L_FRAME ) ) - { - acelp_cfg->ubits = reserved_bits_tbl[BIT_ALLOC_IDX_fx( core_brate, coder_type, -1, TC_SUBFR2IDX_fx( tc_subfr ) )]; - move16(); - } - ELSE - { - acelp_cfg->ubits = 0; - move16(); - } - - bits = sub( bits, acelp_cfg->ubits ); - } - - /* sanity check */ - test(); - test(); - test(); - IF( ( coder_type != INACTIVE && EQ_16( nb_subfr, NB_SUBFR ) && NE_16( coder_type, AUDIO ) ) || EQ_16( nb_subfr, NB_SUBFR16k ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( L_frame, L_FRAME16k ) && coder_type == INACTIVE && inactive_coder_type_flag ) /* GSC Inactive @16kHz */ || - ( GSC_IVAS_mode > 0 && EQ_16( L_frame, L_FRAME16k ) ) ) /* IVAS GSC @16kHz */ - { - acelp_cfg->ubits = 0; - move16(); - } - ELSE IF( flag_hardcoded && core == ACELP_CORE && bits != 0 ) - { -#ifdef DEBUGGING - IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits ); -#endif - } - ELSE IF( bits > 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) - { - test(); - test(); - test(); - test(); - IF( idchan > 0 && EQ_16( element_mode, IVAS_CPE_TD ) ) - { - IF( !tdm_lp_reuse_flag ) - { - acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */ - move16(); - bits = 0; - move16(); - } - ELSE - { - Word16 nb_prm = 4; - move16(); - if ( EQ_16( tdm_low_rate_mode, 1 ) ) - { - nb_prm = 2; - move16(); - } - /* First add remaining bits on gains */ - bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, GAINSPRM, acelp_cfg->gains_mode ) ); - - /* Then, Increase pitch bit budget */ - test(); - IF( tdm_Pitch_reuse_flag == 0 && bits > 0 ) - { - bits = sub( bits, allocate_unused( core_brate, coder_type, bits, nb_prm, 0, PITCHPRM, acelp_cfg->pitch_bits ) ); - } - - /* Increase mid-lsf bit budget */ - test(); - IF( tdm_lp_reuse_flag == 0 && bits > 0 ) - { - bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, MID_LSFSPRM, &acelp_cfg->mid_lsf_bits ) ); - bits = sub( bits, allocate_unused( core_brate, coder_type, bits, 1, 0, LSFPRM, &acelp_cfg->lsf_bits ) ); - } - } - -#ifdef DEBUGGING - if ( idchan > 0 && bits > 0 && ( coder_type > UNVOICED || tdm_low_rate_mode == 0 ) ) - { - IVAS_ERROR( IVAS_ERR_INTERNAL, "WARNING !! Unused bits in secondary channel at frame %d\n" ); - } -#endif - } - - ELSE IF( core == ACELP_CORE && GE_16( coder_type, UNVOICED ) && LE_16( coder_type, GENERIC ) && EQ_16( L_frame, L_FRAME ) ) - { - acelp_cfg->lsf_bits = add( acelp_cfg->lsf_bits, bits ); /* increase LSF Q bits */ - move16(); - - test(); - IF( GT_16( acelp_cfg->lsf_bits, 46 ) ) - { - acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 46 ); - move16(); - acelp_cfg->lsf_bits = 46; - move16(); - } - ELSE IF( GT_16( acelp_cfg->lsf_bits, 42 ) && EQ_16( L_frame, L_FRAME ) ) - { - acelp_cfg->ubits = sub( acelp_cfg->lsf_bits, 42 ); - move16(); - acelp_cfg->lsf_bits = 42; - move16(); - } - } - ELSE - { - acelp_cfg->ubits = bits; - move16(); - } - } - ELSE IF( bits < 0 && !( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) && EQ_16( element_mode, IVAS_CPE_TD ) ) ) - { -#ifdef DEBUGGING - IVAS_ERROR( IVAS_ERR_INTERNAL, "ERROR: bit-budget incorrect (%d bits) in frame %d.\n", (Word32) bits ); -#endif - } - } - - return error; -} - -/*-------------------------------------------------------------------* - * config_acelp1_IVAS() - * - * Configure ACELP bit allocation - * - should be in range of <6700; 24350> for ACELP@12.8kHz - * - per channel bitrate minimum is 13250 kbps for ACELP@16kHz - *--------------------------------------------------------------------*/ -#endif -ivas_error config_acelp1_IVAS( +ivas_error config_acelp1_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ const Word32 core_brate_inp, /* i : core bitrate */ @@ -2511,11 +1224,11 @@ ivas_error config_acelp1_IVAS( IF( GE_16( bits, 16 ) ) { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); } ELSE { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 2, 2 * L_SUBFR, GENERIC, -1, 0 ); acelp_cfg->fixed_cdk_index[1] = -1; move16(); } @@ -2634,17 +1347,17 @@ ivas_error config_acelp1_IVAS( { IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), nb_subfr ) ) ) /* enough bits for all fcb */ { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } ELSE IF( GE_16( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 1 ) ) ) ) { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 1 ), L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[3] = -1; move16(); } ELSE IF( GE_32( bits, imult1616( ACELP_FIXED_CDK_BITS( 0 ), sub( nb_subfr, 2 ) ) ) ) { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, sub( nb_subfr, 2 ), L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[2] = acelp_cfg->fixed_cdk_index[1]; move16(); acelp_cfg->fixed_cdk_index[1] = -1; @@ -2654,7 +1367,7 @@ ivas_error config_acelp1_IVAS( } ELSE IF( GE_32( bits, ACELP_FIXED_CDK_BITS( 0 ) ) ) { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, 1, L_SUBFR, coder_type, tc_subfr, fix_first ); acelp_cfg->fixed_cdk_index[1] = acelp_cfg->fixed_cdk_index[0]; move16(); acelp_cfg->fixed_cdk_index[0] = -1; @@ -2680,11 +1393,11 @@ ivas_error config_acelp1_IVAS( { bits = 100; /* 9 kbps for fcb */ move16(); - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } ELSE { - acelp_FCB_allocator_ivas( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); + acelp_FCB_allocator_fx( &bits, acelp_cfg->fixed_cdk_index, nb_subfr, L_SUBFR, coder_type, tc_subfr, fix_first ); } } } diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 582fd3c8a..119811275 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -33,144 +33,24 @@ /*------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /*------------------------------------------------------------------------*/ - /*------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES -void Inac_swtch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 L_frame, /* i : Frame lenght */ - const Word32 core_brate, /* i : Core bit rate */ - const Word16 Q_exc /* i : input and output format of exc2 */ - , - const Word16 bfi /* i : frame lost indicator */ - , - const Word16 last_core, /* i : Last core used */ - const Word16 last_codec_mode /* i : Last codec mode */ -) -{ - Word16 Ener_per_bd[MBANDS_GN]; - Word16 ftmp; - Word16 *pt_exc; - Word16 j, i; - - Word16 exp, frac; - Word32 L_tmp; - - /*-------------------------------------------------------------------------- - * average energy per band - *--------------------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( coder_type, AUDIO ) && bfi == 0 ) - { - Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 ); - - /* reset long-term energy per band */ - FOR( i = 0; i < MBANDS_GN; i++ ) - { - lt_ener_per_band[i] = Ener_per_bd[i]; - move16(); - } - } - ELSE IF( EQ_16( coder_type, VOICED ) || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || ( last_core != ACELP_CORE ) || NE_16( last_codec_mode, MODE1 ) ) - { - /* Find spectrum and energy per band for GC and VC frames */ - edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO ); - - Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 ); - - /* reset long-term energy per band */ - FOR( i = 0; i < MBANDS_GN; i++ ) - { - lt_ener_per_band[i] = Ener_per_bd[i]; - move16(); - } - } - ELSE IF( ( coder_type == INACTIVE ) && LE_32( core_brate, ACELP_24k40 ) ) - { - /* Find spectrum and energy per band for inactive frames */ - edct_16fx( exc2, dct_exc_tmp, L_frame, 5, EVS_MONO ); - Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 ); - - /* More agressive smoothing in the first 50 frames */ - pt_exc = dct_exc_tmp; - move16(); - FOR( i = 0; i < MBANDS_GN; i++ ) - { - /* Compute smoothing gain to apply with gain limitation */ - L_tmp = L_mult( ALPHA0_FX, lt_ener_per_band[i] ); /*Q(15+12+1)=Q(28) */ - L_tmp = L_mac( L_tmp, BETA0_FX, Ener_per_bd[i] ); /*Q28 */ - lt_ener_per_band[i] = round_fx( L_tmp ); /*Q12 */ - move16(); - - ftmp = sub( lt_ener_per_band[i], Ener_per_bd[i] ); /*Q12 */ - - /* ftmp = (float)pow(10, ftmp);= pow(2,3.321928*ftmp);*/ - - L_tmp = L_mult( 27213, ftmp ); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */ - L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of ftmp */ - ftmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - - exp = sub( exp, 14 ); - IF( LT_16( i, 2 ) ) - { - FOR( j = 0; j < 8; j++ ) - { - L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); - move16(); - pt_exc++; - } - } - ELSE - { - FOR( j = 0; j < 16; j++ ) - { - L_tmp = L_mult( *pt_exc, ftmp ); /* Q_exc*Q0 -> Q(Q_exc+1) */ - L_tmp = L_shl_sat( L_tmp, add( exp, 15 ) ); /* Q(Q_exc+1) -> Q(16+Q_exc)*/ - *pt_exc = round_fx_sat( L_tmp ); /*Q_exc*/ - move16(); - pt_exc++; - } - } - } - - /* Going back to time */ - edct_16fx( dct_exc_tmp, exc2, L_frame, 5, EVS_MONO ); - } - - return; -} -#endif -void Inac_switch_ematch_ivas_fx( +void Inac_switch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ const Word16 L_frame, /* i : Frame lenght */ const Word16 Q_exc, /* i : input and output format of exc2 */ const Word16 bfi, /* i : frame lost indicator */ const Word16 last_core, /* i : Last core used */ const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/ - const Word16 element_mode /* i : element mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ ) { Word16 Ener_per_bd[MBANDS_GN16k]; @@ -251,7 +131,6 @@ void Inac_switch_ematch_ivas_fx( exp = sub( exp, 14 ); IF( LT_16( i, 2 ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( element_mode, EVS_MONO ) ) { FOR( j = 0; j < 8; j++ ) @@ -264,7 +143,6 @@ void Inac_switch_ematch_ivas_fx( } } ELSE -#endif { FOR( j = 0; j < 8; j++ ) { @@ -278,7 +156,6 @@ void Inac_switch_ematch_ivas_fx( } ELSE { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( element_mode, EVS_MONO ) ) { FOR( j = 0; j < 16; j++ ) @@ -291,7 +168,6 @@ void Inac_switch_ematch_ivas_fx( } } ELSE -#endif { FOR( j = 0; j < 16; j++ ) { @@ -306,9 +182,7 @@ void Inac_switch_ematch_ivas_fx( } /* Going back to time */ -#ifdef REMOVE_EVS_DUPLICATES IF( GT_16( element_mode, EVS_MONO ) ) -#endif { Scale_sig( dct_exc_tmp, 240, 1 ); // Q_exc Scale_sig( exc2, 240, 1 ); // Q_exc diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 1198fb793..208f20569 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1332,8 +1332,6 @@ void highband_exc_dct_in_ivas_fx( } } - -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( element_mode, EVS_MONO ) ) { Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc ); @@ -1346,7 +1344,6 @@ void highband_exc_dct_in_ivas_fx( } ELSE { -#endif Word16 Q_tmp = *Q_exc; move16(); Word16 Q_old = *Q_exc; @@ -1373,9 +1370,7 @@ void highband_exc_dct_in_ivas_fx( { Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) ); } -#ifdef REMOVE_EVS_DUPLICATES } -#endif /*--------------------------------------------------------------------------------------* * add the correction layer to the LF bins, @@ -1416,13 +1411,10 @@ void highband_exc_dct_in_ivas_fx( Q_hb_exc = 0; move16(); envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, *Q_exc, &Q_hb_exc ); -#ifdef REMOVE_EVS_DUPLICATES + test(); test(); IF( GT_16( *Q_exc, Q_hb_exc ) && GT_16( element_mode, EVS_MONO ) && exc_wo_nf != NULL ) -#else - IF( GT_16( *Q_exc, Q_hb_exc ) ) -#endif { Scale_sig( exc_wo_nf, L_frame, sub( Q_hb_exc, *Q_exc ) ); *Q_exc = Q_hb_exc; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 48a28a397..e6afe35a2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3973,7 +3973,7 @@ ivas_error ivas_core_dec_fx( const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ); -void decod_gen_2sbfr_ivas_fx( +void decod_gen_2sbfr_fx( Decoder_State *st, /* i/o: decoder static memory */ const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/ const Word16 *Aq, /* i : LP filter coefficient Q12*/ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index d60d0e999..a41e10713 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2863,40 +2863,39 @@ Word16 qlsf_ARSN_tcvq_Dec_16k_fx( } /*======================================================================*/ -/* FUNCTION : lsf_syn_mem_backup_fx */ +/* FUNCTION : lsf_syn_mem_backup_fx */ /*----------------------------------------------------------------------*/ /* PURPOSE : back-up synthesis filter memory and LSF qunatizer memories */ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*) lsp_new : LSP vector to quantize */ -/* _ (Word16*) lsf_new : quantized LSF vector */ -/* _ (Word16*) lsp_mid : mid-frame LSP vector */ -/* _ (Encoder_State) st_fx : Encoder state Structure */ -/*-----------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16) clip_var : pitch clipping state var */ -/* _ (Word16*) mem_AR : quantizer memory for AR model */ -/* _ (Word16*) mem_MA : quantizer memory for MA model */ -/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */ -/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */ -/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */ +/* INPUT ARGUMENTS : */ +/* _ (Word16*) lsp_new : LSP vector to quantize */ +/* _ (Word16*) lsf_new : quantized LSF vector */ +/* _ (Word16*) lsp_mid : mid-frame LSP vector */ +/* _ (Encoder_State) st_fx : Encoder state Structure */ +/*----------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16) clip_var : pitch clipping state var */ +/* _ (Word16*) mem_AR : quantizer memory for AR model */ +/* _ (Word16*) mem_MA : quantizer memory for MA model */ +/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */ +/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */ +/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */ /* _ (Word16) mCb1 :counter for stationary frame after a transition frame */ -/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */ -/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */ -/* _ (Word16*) mem_syn_bck : synthesis filter memory */ -/* _ (Word16) mem_w0_bck : memory of the weighting filter */ -/* _ (Word16) streaklimit : LSF quantizer */ -/* _ (Word16) pstreaklen : LSF quantizer */ -/*-----------------------------------------------------------------------*/ - -/* _ None */ -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ +/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */ +/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */ +/* _ (Word16*) mem_syn_bck : synthesis filter memory */ +/* _ (Word16) mem_w0_bck : memory of the weighting filter */ +/* _ (Word16) streaklimit : LSF quantizer */ +/* _ (Word16) pstreaklen : LSF quantizer */ +/*----------------------------------------------------------------------*/ +/* _ None */ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*======================================================================*/ void lsf_syn_mem_backup_fx( Encoder_State *st_fx, /* o: state structure */ @@ -2904,23 +2903,22 @@ void lsf_syn_mem_backup_fx( Word32 *gc_threshold_fx, /* i: Q16 */ Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ Word16 *next_force_sf_bck_fx, /* i: */ - - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* i: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */ - Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 *mCb1, /* o: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */ - Word16 *mem_syn_bck, /* i: synthesis filter memory q */ - Word16 *mem_w0_bck, /* i: memory of the weighting filter q */ - Word16 *streaklimit, /* i:LSF quantizer Q15 */ - Word16 *pstreaklen /* i:LSF quantizer */ + Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ + Word16 *lsf_new, /* i: quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* i: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i: quantizer memory for AR model 2.56 */ + Word16 *mem_MA, /* i: quantizer memory for MA model 2.56 */ + Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* o: quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ + Word16 *mCb1, /* o: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets q_bin */ + Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets q_bin */ + Word16 *mem_syn_bck, /* i: synthesis filter memory q */ + Word16 *mem_w0_bck, /* i: memory of the weighting filter q */ + Word16 *streaklimit, /* i:LSF quantizer Q15 */ + Word16 *pstreaklen /* i:LSF quantizer */ ) { Word16 i; @@ -2985,25 +2983,31 @@ void lsf_syn_mem_backup_fx( return; } + +/*-------------------------------------------------------------------* + * lsf_syn_mem_backup_fx() + * + * + *--------------------------------------------------------------------*/ + void lsf_syn_mem_backup_ivas_fx( Encoder_State *st_fx, /* i: state structure */ Word16 *btilt_code_fx, /* i: tilt code Q15 */ Word32 *gc_threshold_fx, /* i: Q16 */ Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ Word16 *next_force_sf_bck_fx, /* o: */ - - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ Word16 *pstreaklen ) { Word16 i; @@ -3079,66 +3083,68 @@ void lsf_update_memory( move16(); mem_MA[i] = sub( sub( qlsf[i], lsf_means[narrowband][i] ), mult_r( MU_MA_FX, old_mem_MA[i] ) ); } + + return; } + /*======================================================================*/ -/* FUNCTION : lsf_syn_mem_restore_fx */ +/* FUNCTION : lsf_syn_mem_restore_fx */ /*----------------------------------------------------------------------*/ /* PURPOSE : restore synthesis filter memory and LSF quantizer memories*/ /*----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) clip_var : pitch clipping state var */ -/* _ (Word16*) mem_AR : quantizer memory for AR model */ -/* _ (Word16*) mem_MA : quantizer memory for MA model */ -/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */ -/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */ -/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */ +/* INPUT ARGUMENTS : */ +/* _ (Word16) clip_var : pitch clipping state var */ +/* _ (Word16*) mem_AR : quantizer memory for AR model */ +/* _ (Word16*) mem_MA : quantizer memory for MA model */ +/* _ (Word16*) lsp_new_bck : LSP vector to quantize- backup */ +/* _ (Word16*) lsf_new_bck : quantized LSF vector - backup */ +/* _ (Word16*) lsp_mid_bck : mid-frame LSP vector - backup */ /* _ (Word16) mCb1 :counter for stationary frame after a transition frame */ -/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */ -/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */ -/* _ (Word16*) mem_syn_bck : synthesis filter memory */ -/* _ (Word16) mem_w0_bck : memory of the weighting filter */ -/* _ (Word16) streaklimit : LSF quantizer */ -/* _ (Word16) pstreaklen : LSF quantizer */ -/*-----------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _None */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) lsp_new : LSP vector to quantize */ -/* _ (Word16*) lsf_new : quantized LSF vector */ -/* _ (Word16*) lsp_mid : mid-frame LSP vector */ -/* _ (Encoder_State) st_fx : Encoder state Structure */ -/*-----------------------------------------------------------------------*/ - -/* _ None */ -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*=======================================================================*/ +/* _ (Word32*) Bin_E : FFT Bin energy 128 *2 sets */ +/* _ (Word32*) Bin_E_old : FFT Bin energy 128 *2 sets */ +/* _ (Word16*) mem_syn_bck : synthesis filter memory */ +/* _ (Word16) mem_w0_bck : memory of the weighting filter */ +/* _ (Word16) streaklimit : LSF quantizer */ +/* _ (Word16) pstreaklen : LSF quantizer */ +/*----------------------------------------------------------------------*/ +/* INPUT/OUTPUT ARGUMENTS : */ +/* _None */ +/*----------------------------------------------------------------------*/ +/* OUTPUT ARGUMENTS : */ +/* _ (Word16*) lsp_new : LSP vector to quantize */ +/* _ (Word16*) lsf_new : quantized LSF vector */ +/* _ (Word16*) lsp_mid : mid-frame LSP vector */ +/* _ (Encoder_State) st_fx : Encoder state Structure */ +/*----------------------------------------------------------------------*/ +/* _ None */ +/*----------------------------------------------------------------------*/ +/* RETURN ARGUMENTS : */ +/* _ None */ +/*======================================================================*/ + void lsf_syn_mem_restore_fx( Encoder_State *st_fx, /* o: state structure */ Word16 btilt_code_fx, /* i: Q15 */ Word32 gc_threshold_fx, /* i: Q16 */ Word16 *clip_var_bck_fx, /* i: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ Word16 next_force_sf_bck_fx, /* i: */ - - Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ - Word16 *lsf_new, /* o: quantized LSF vector Q15 */ - Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ - Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ - Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ - Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ - Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ - Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ - Word16 mCb1, /* i: counter for stationary frame after a transition frame */ - Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 streaklimit, /* i:LSF quantizer Q15 */ - Word16 pstreaklen /* i:LSF quantizer */ + Word16 *lsp_new, /* o: LSP vector to quantize Q15 */ + Word16 *lsf_new, /* o: quantized LSF vector Q15 */ + Word16 *lsp_mid, /* o: mid-frame LSP vector Q15 */ + Word16 clip_var, /* i: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* i: quantizer memory for AR model Q15 */ + Word16 *mem_MA, /* i: quantizer memory for MA model Q15 */ + Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup Q15 */ + Word16 *lsf_new_bck, /* i: quantized LSF vector - backup Q15 */ + Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup Q15 */ + Word16 mCb1, /* i: counter for stationary frame after a transition frame */ + Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* i: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 mem_w0_bck, /* i: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 streaklimit, /* i:LSF quantizer Q15 */ + Word16 pstreaklen /* i:LSF quantizer */ ) { Word16 i; diff --git a/lib_com/options.h b/lib_com/options.h index 921d05b1c..bcee4b8fe 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,10 +99,10 @@ #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ #define TEST_HR -#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ #define FIX_1348_BIT_PRECISION_IMPROVEMENT #define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN #define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF + #endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 36cb671cc..43010af04 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3284,52 +3284,33 @@ void synthesise_fb_high_band_fx( #endif ); -#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - Word16 T0, /* i : integer pitch variables Q0 */ - Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - Word32 core_brate /* i :core bitrate */ -); -#endif - -void prep_tbe_exc_ivas_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - Word16 T0, /* i : integer pitch variables Q0 */ - Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ -); - -Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */ - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + Word16 T0, /* i : integer pitch variables Q0 */ + Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ +); + +/*! r: Formant filter strength [0,1] */ +Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory */ ); void wb_tbe_extras_reset_fx( @@ -4833,35 +4814,6 @@ Word16 BITS_ALLOC_config_acelp( const Word16 narrowband, const Word16 nb_subfr ); -#ifndef REMOVE_EVS_DUPLICATES -ivas_error config_acelp1( - const Word16 enc_dec, /* i : encoder/decoder flag */ - const Word32 total_brate, /* i : total bitrate */ - const Word32 core_brate_inp, /* i : core bitrate */ - const Word16 core, /* i : core */ - const Word16 extl, /* i : extension layer */ - const Word32 extl_brate, /* i : extension layer bitrate */ - const Word16 L_frame, /* i : frame length at internal Fs */ - const Word16 GSC_noisy_speech, /* i : GSC on SWB noisy speech flag */ - ACELP_config *acelp_cfg, /* i : ACELP bit-allocation */ - const Word16 signalling_bits, /* i : number of signalling bits */ - const Word16 coder_type, /* i : coder type */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ - const Word16 tc_subfr, /* i : TC subfr ID */ - const Word16 tc_call, /* i : TC call number (0,1,2,3,5(DEC)) */ - Word16 *nBits_es_Pred, /* o : number of bits for Es_pred Q */ - Word16 *unbits, /* o : number of unused bits */ - const Word16 element_mode, /* i : element mode */ - Word16 *uc_two_stage_flag, /* o : flag undicating two-stage UC */ - const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag (can be 1 only with secondary channel */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const Word16 idchan, /* i : stereo channel ID */ - const Word16 active_cnt, /* i : Active frame counter */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag*/ - const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ -); -#endif Word16 set_ACELP_flag( const Word16 element_mode, /* i : element mode */ const Word32 element_brate, /* i : element bitrate */ @@ -5808,35 +5760,19 @@ void tcx_ltp_post_fx32( Word32 *tcx_buf, /* sig_q */ Word16 sig_q ); -#ifndef REMOVE_EVS_DUPLICATES -// gs_inact_switching_fx.c -void Inac_swtch_ematch_fx( - Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ - Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ - Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ - const Word16 coder_type, /* i : Coding mode */ - const Word16 L_frame, /* i : Frame lenght */ - const Word32 core_brate, /* i : Core bit rate */ - const Word16 Q_exc, /* i : i and output format of exc2 */ - const Word16 bfi, /* i : frame lost indicator */ - const short last_core, /* i : Last core used */ - const short last_codec_mode /* i : Last codec mode */ -); -#endif - -void Inac_switch_ematch_ivas_fx( +void Inac_switch_ematch_fx( Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */ const Word16 coder_type, /* i : Coding mode */ - const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ + const Word16 inactive_coder_type_flag, /* i : AVQ (0) or GSC (1) IC flag */ const Word16 L_frame, /* i : Frame lenght */ const Word16 Q_exc, /* i : input and output format of exc2 */ const Word16 bfi, /* i : frame lost indicator */ const Word16 last_core, /* i : Last core used */ const Word16 last_codec_mode, /* i : Last codec mode */ - const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag*/ - const Word16 element_mode /* i : element mode */ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const Word16 element_mode /* i : element mode */ ); // igf_base_fx.c @@ -6069,32 +6005,16 @@ void td_bwe_dec_init_fx( const Word32 output_Fs /* i : output sampling rate */ ); -#ifndef REMOVE_EVS_DUPLICATES -// lsf_dec_fx.c void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/ - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -); -#endif -void lsf_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/ - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ); /*! r: index of the maximum value in the input vector */ @@ -6257,21 +6177,9 @@ void lsf_mid_dec_fx( Word16 lsp_mid[] /* o : quantized LSPs Q15*/ ); -#ifndef REMOVE_EVS_DUPLICATES -// cng_dec_fx.c void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ - Word32 *q_env ); -#endif -void CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ + const Word16 last_element_mode, /* i : last element mode Q0 */ Word16 Aq[], /* o : LP coefficients Q12 */ Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ @@ -6656,12 +6564,12 @@ void hf_synth_amr_wb_fx( // dec_post_fx void Init_post_filter_fx( PFSTAT_HANDLE hPFstat /* i : core decoder parameters */ -); /* (i) : core decoder parameters */ +); /* i : core decoder parameters */ void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *psf_lp_noise, /* i : Long term noise Q8 */ const Word16 tmp_noise, /* i : noise energy Q0 */ Word16 *Synth, /* i : 12k8 synthesis Qsyn */ @@ -6672,27 +6580,15 @@ void nb_post_filt_fx( const Word16 disable_hpf /* i : flag to diabled HPF */ ); -#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient */ - Word16 *synth_out, /* i/o: i signal */ - Word16 L_frame, - Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - Word32 rate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ -); -#endif -void formant_post_filt_ivas_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient */ - Word16 *synth_out, /* i/o: i signal */ - Word16 L_frame, - Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - Word32 rate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *synth_out, /* i/o: input signal */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ ); void Filt_mu_fx( Word16 *sig_in, /* i : signal (beginning at sample -1) */ @@ -6858,65 +6754,34 @@ void PulseResynchronization_fx( Word32 /*float*/ const pitchEnd /*i Q16*/ ); -#ifndef REMOVE_EVS_DUPLICATES -// gs_dec_fx.c void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ - , - Word16 *gain_buf /*Q14*/ -); -#endif -void decod_audio_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ - , - Word16 *gain_buf, /*Q14*/ + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6*/ ); -#ifndef REMOVE_EVS_DUPLICATES void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 Q_exc ); -#endif -void gsc_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ const Word16 coder_type, /* i : coding type Q0*/ Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ); void GSC_dec_init( @@ -6927,18 +6792,15 @@ void GSC_dec_init_ivas_fx( GSC_DEC_HANDLE hGSCDec /* i/o: GSC data handle */ ); - -// gain_dec_fx.c - void Es_pred_dec_fx( - Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ - const Word16 enr_idx, /* i : indice */ - const Word16 nb_bits, /* i : number of bits */ - const Word16 no_ltp /* i : no LTP flag */ + Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/ + const Word16 enr_idx, /* i : indice */ + const Word16 nb_bits, /* i : number of bits */ + const Word16 no_ltp /* i : no LTP flag */ ); void gain_dec_tc_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ + Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 *code_fx, /* i : algebraic code excitation */ const Word16 i_subfr_fx, /* i : subframe number */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ @@ -6973,7 +6835,6 @@ void gain_dec_mless_fx( Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/ ); -#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -6984,25 +6845,8 @@ void gain_dec_lbr_fx( Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */ - , - const Word16 L_subfr /* i : subfr lenght */ -); -#endif - -void gain_dec_lbr_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes */ - Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */ - , - const Word16 L_subfr /* i : subfr lenght */ + Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */ + const Word16 L_subfr /* i : subfr lenght */ ); void lp_gain_updt_fx( @@ -7023,13 +6867,14 @@ void lp_gain_updt_ivas_fx( const Word16 L_frame /* i : length of the frame */ ); -Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */ - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ +/*! r: quantized codebook gain Q16 */ +Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ ); void gain_dec_SQ_fx( @@ -7123,23 +6968,7 @@ void re8_PPV_fx( Word16 y[] /* o : point in RE8 (8-dimensional integer vector) Q0 */ ); -#ifndef REMOVE_EVS_DUPLICATES -// dec_pit_exc_fx.c void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -); -#endif -void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ const Word16 coder_type, /* i : coding type */ @@ -7149,7 +6978,7 @@ void dec_pit_exc_ivas_fx( Word16 *exc_fx, /* i/o: adapt. excitation exc */ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /*Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ); @@ -7193,24 +7022,8 @@ void Mode2_delta_pit_dec( Word16 **pt_indice /* i/o: pointer to Vector of Q indexes */ ); -#ifndef REMOVE_EVS_DUPLICATES -Word16 pit_decode_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr /* i : subframe length */ -); -#endif /* o : floating pitch value */ -Word16 pit_decode_ivas_fx( +Word16 pit_decode_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word32 core_brate, /* i : core bitrate */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ @@ -7571,9 +7384,8 @@ void configureFdCngDec_fx( const Word16 Last_L_frame, const Word16 element_mode ); -#ifndef REMOVE_EVS_DUPLICATES -/* Apply the CLDFB-based CNG */ Word16 ApplyFdCng_fx( +<<<<<<< HEAD Word16 *timeDomainInput, /* i : pointer to time domain i */ Word16 Q, Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer */ @@ -7584,6 +7396,8 @@ Word16 ApplyFdCng_fx( Word16 is_music ); #endif Word16 ApplyFdCng_ivas_fx( +======= +>>>>>>> 2afc0761 (accept REMOVE_EVS_DUPLICATES) Word16 *timeDomainInput, /* i : pointer to time domain input */ Word16 Q, Word32 *powerSpectrum, @@ -8172,14 +7986,11 @@ void FEC_pitch_estim_fx( const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */ Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */ Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */ - Word16 *upd_cnt /* i/o: update counter */ - , - const Word16 coder_type, /* i : coder_type */ - Word16 element_mode /* i : element mode */ + Word16 *upd_cnt, /* i/o: update counter */ + const Word16 coder_type, /* i : coder_type */ + Word16 element_mode /* i : element mode */ ); -#ifndef REMOVE_EVS_DUPLICATES -// FEC_scale_sync_fx.c void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -8206,69 +8017,37 @@ void FEC_scale_syn_fx( Word16 *mem_syn, /* o: initial synthesis filter states */ Word16 Q_exc, Word16 Q_syn, + const Word16 element_mode, /* i : element mode */ const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i: force scaling */ -); -#endif -void FEC_scale_syn_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */ - const Word16 *pitch, /* i: pitch values for each subframe */ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */ - Word16 *mem_syn, /* o: initial synthesis filter states */ - Word16 Q_exc, - Word16 Q_syn, -#ifdef REMOVE_EVS_DUPLICATES - const Word16 element_mode, /* i : element mode */ -#endif - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i: force scaling */ + const Word16 force_scaling /* i : force scaling */ ); // LD_music_post_filter_fx.c void LD_music_post_filter_fx( - MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ - const Word16 dtc_in[], /* i : i synthesis Qdct */ - Word16 dtc_out[], /* o : output synthesis Qdct */ - const Word32 core_brate, /* i : core bitrate Q0 */ - Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */ - const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ - const Word16 Last_coder_type, /* i : i scaling Q0 */ - const Word16 Qdct /* i : i scaling Q0 */ + MUSIC_POSTFILT_HANDLE hMusicPF, /* i/o: LD music postfilter handle */ + const Word16 dtc_in[], /* i : i synthesis Qdct */ + Word16 dtc_out[], /* o : output synthesis Qdct */ + const Word32 core_brate, /* i : core bitrate Q0 */ + Word16 *Old_ener_Q, /* i/o: Old energy scaling factor */ + const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */ + const Word16 Last_coder_type, /* i : i scaling Q0 */ + const Word16 Qdct /* i : i scaling Q0 */ ); void Prep_music_postP_fx( - Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ - Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ - Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ - const Word16 last_core, /* i : last core */ - const Word16 element_mode, /* i : element mode */ - const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ - Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ - const Word16 Q_exc, /* i : excitation scaling */ - Word16 *qdct /* o : Scaling factor of dct coefficient */ + Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/ + Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/ + Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */ + const Word16 last_core, /* i : last core */ + const Word16 element_mode, /* i : element mode */ + const Word16 *pitch_buf, /* i : current frame pitch information Q6*/ + Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/ + const Word16 Q_exc, /* i : excitation scaling */ + Word16 *qdct /* o : Scaling factor of dct coefficient */ ); void Post_music_postP_fx( - Word16 dct_buffer_in[], /* i/o: excitation buffer */ + Word16 dct_buffer_in[], /* i/o: excitation buffer */ Word16 *exc2, /* i/o: Current excitation to be overwriten */ const Word16 *mem_tmp, /* i : previous frame synthesis memory */ Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */ @@ -8278,15 +8057,14 @@ void Post_music_postP_fx( Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */ Word16 *Q_syn, /* i : Current frame synthesis scaling */ Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/ - const Word16 IsIO, /* i: Flag to indicate IO mode */ - Word16 *mem_deemph, /* i/o: speech deemph filter memory */ - Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ - Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ + const Word16 IsIO, /* i : Flag to indicate IO mode */ + Word16 *mem_deemph, /* i/o: speech deemph filter memory */ + Word16 *st_pst_old_syn_fx, /* i/o: psfiler */ + Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */ Word16 *mem_agc, - PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ - const Word16 *tmp_buffer /* tmp_buffer in Q-1 */ - , - Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ + PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */ + const Word16 *tmp_buffer, /* tmp_buffer in Q-1 */ + Word16 *mem_tmp2 /* Temporary memory used with scale_syn */ ); void music_postfilt_init( @@ -8503,29 +8281,17 @@ Word16 FEC_enhACB_fx( const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */ const Word16 bfi_pitch /* i : Q6 pitch used for concealment */ ); -Word16 FEC_synchro_exc_fx( /* o : do_WI flag */ - const Word16 L_frame, /* i : length of the frame */ - Word16 *exc, /* i/o: exc vector to modify */ - const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ - const Word16 true_puls_pos, /* i : Present pulse location */ - const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ + +/*! r: do_WI flag */ +Word16 FEC_synchro_exc_fx( + const Word16 L_frame, /* i : length of the frame */ + Word16 *exc, /* i/o: exc vector to modify */ + const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */ + const Word16 true_puls_pos, /* i : Present pulse location */ + const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */ ); -#ifndef REMOVE_EVS_DUPLICATES -// dec_uv_fx.c void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ); -#endif -void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ @@ -8568,38 +8334,20 @@ void gaus_L2_dec( Word16 *seed_acelp /*i/o : random seed Q0 */ ); -#ifndef REMOVE_EVS_DUPLICATES -// dec_gen_voic_fx.c ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf /*Q14*/ -); -#endif -ivas_error decod_gen_voic_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *voice_factors_fx, /* o : voicing factors */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ + Word16 *voice_factors_fx, /* o : voicing factors */ + Word16 *exc_fx, /* i/o: adapt. excitation exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ); @@ -9501,33 +9249,6 @@ void d_gain_pred_fx( Word16 **pt_indice /* i/o: pointer to the buffer of indices */ ); -#ifndef REMOVE_EVS_DUPLICATES -// acelp_core_dec_fx.c -ivas_error acelp_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 output[], /* o : synthesis @internal Fs */ - Word16 synth_out[], /* o : synthesis */ - Word16 save_hb_synth[], /* o : HB synthesis */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */ - Word16 *voice_factors, /* o : voicing factors */ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE */ - Word16 sharpFlag, - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw /* o : 0-NB/WB, 1-SWB SID */ - , - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ -); -#endif // evs_dec_fx.c ivas_error evs_dec_fx( Decoder_State *st_fx, /* i/o : Decoder state structure */ @@ -10617,7 +10338,7 @@ Word16 swb_bwe_dec_fx32( Word16 output_frame /* i : frame length */ ); -ivas_error acelp_core_dec_ivas_fx( +ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs */ Word16 synth_fx16[], /* o : synthesis */ @@ -10914,6 +10635,7 @@ Word16 ari_decode_14bits_pow_ivas( Word16 *res, Tastat *s, UWord16 base ); + Word16 ari_decode_14bits_sign_ivas( Word16 *ptr, Word16 bp, @@ -10927,22 +10649,21 @@ void lsf_syn_mem_backup_ivas_fx( Word32 *gc_threshold_fx, /* i: Q16 */ Word16 *clip_var_bck_fx, /* o: Q(2.56), Q14, Q7, Q0, Q14, Q14 */ Word16 *next_force_sf_bck_fx, /* o: */ - - Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ - Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ - Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ - Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ - Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ - Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ - Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ - Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ - Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ - Word16 *streaklimit, /* Q15 */ + Word16 *lsp_new, /* i: LSP vector to quantize Q15 */ + Word16 *lsp_mid, /* i: mid-frame LSP vector Q15 */ + Word16 *clip_var, /* o: pitch clipping state var Q(2.56) */ + Word16 *mem_AR, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *mem_MA, /* o: quantizer memory for AR model Q(2.56) */ + Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup Q15 */ + Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup Q15 */ + Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets Q_new + Q_SCALE - 2 */ + Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets Q_new + Q_SCALE - 2 */ + Word16 *mem_syn_bck, /* o: synthesis filter memory ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *mem_w0_bck, /* o: memory of the weighting filter ( 15 - st_fx->hLPDmem->e_mem_syn ) */ + Word16 *streaklimit, /* Q15 */ Word16 *pstreaklen ); -ivas_error config_acelp1_IVAS( +ivas_error config_acelp1_fx( const Word16 enc_dec, /* i : encoder/decoder flag */ const Word32 total_brate, /* i : total bitrate */ const Word32 core_brate_inp, /* i : core bitrate */ diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index d3f671631..08bbd6362 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7023,50 +7023,6 @@ void synthesise_fb_high_band_fx( tmp3 = add( sub( Qout, add( sub( 1, exp ), exp_tmp ) ), 16 ); /*Qout - (1 -exp +exp_tmp) + 16 */ FOR( i = 0; i < L_FRAME48k; i++ ) { -#ifdef FIX_1439_SPEEDUP_synthesise_fb_high_band_fx - L_tmp = Mult_32_16( ratio2, tmp[i] ); /* Q(16-exp+exp_tmp-15 = 1-exp+exp_tmp) */ - Word32 L_tmp32 = L_add( 0, 0 ); - Word16 tmp16 = add( 0, 0 ); - - // if (L_tmp < 0) - if ( L_tmp < 0 ) - { - L_tmp32 = L_negate( L_tmp ); - } - if ( L_tmp < 0 ) - { - L_tmp32 = L_shl_sat( L_tmp32, tmp3 ); - } - if ( L_tmp < 0 ) - { - tmp16 = extract_h( L_tmp32 ); - } - if ( L_tmp < 0 ) - { - tmp16 = negate( tmp16 ); - } - - // if (L_tmp == 0) - if ( L_tmp == 0 ) - { - tmp16 = 0; - move16(); - } - - // if (L_tmp > 0) - if ( L_tmp > 0 ) - { - L_tmp32 = L_shl_sat( L_tmp, tmp3 ); - } - if ( L_tmp > 0 ) - { - tmp16 = extract_h( L_tmp32 ); - } - - output[i] = tmp16; - move16(); - -#else L_tmp = Mult_32_16( ratio2, tmp[i] ); /* Q(16-exp+exp_tmp-15 = 1-exp+exp_tmp) */ IF( L_tmp < 0 ) { @@ -7078,7 +7034,6 @@ void synthesise_fb_high_band_fx( output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/ move16(); } -#endif } return; } @@ -7253,180 +7208,34 @@ void Estimate_mix_factors_fx( /* INPUT/OUTPUT ARGUMENTS : */ /* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */ /*--------------------------------------------------------------------------------------*/ - /* _ None */ /*--------------------------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void prep_tbe_exc_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - Word16 T0, /* i : integer pitch variables Q0 */ - Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - Word32 core_brate ) -{ - Word16 i; - Word16 tmp_code_fx[2 * L_SUBFR * HIBND_ACB_L_FAC]; - Word16 tmp_code_preInt_fx[L_SUBFR]; - Word16 gain_code16 = 0; - move16(); - Word16 tmp /*, tmp1, tmp2*/; - /*Word16 random_code[L_SUBFR * HIBND_ACB_L_FAC];*/ - Word16 pitch; - - Word32 L_tmp, Ltemp1, Ltemp2; - Word32 tempQ31; - Word16 tempQ15; - Word16 L_subfr = L_SUBFR; - move16(); -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - /**voice_factors = VF_0th_PARAM + VF_1st_PARAM * voice_fac + VF_2nd_PARAM * voice_fac * voice_fac; - = VF_0th_PARAM + voice_fac * (VF_1st_PARAM + VF_2nd_PARAM * voice_fac ) - *voice_factors = min( max_val(0.0f, *voice_factors), 1.0f); */ - tempQ31 = L_deposit_h( VF_1st_PARAM_FX ); - tempQ15 = mac_r( tempQ31, VF_2nd_PARAM_FX, voice_fac_fx ); - tempQ31 = L_deposit_h( VF_0th_PARAM_FX ); - *voice_factors_fx = mac_r( tempQ31, voice_fac_fx, tempQ15 ); - move16(); - tmp = MAX_16; - move16(); - - pitch = shl_o( add( shl_o( T0, 2, &Overflow ), T0_frac ), 5, &Overflow ); /* Q7 */ + const Word16 L_frame_fx, /* i : length of the frame */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : subframe index */ + const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ + const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ + const Word16 code_fx[], /* i : algebraic excitation Q9*/ + const Word16 voice_fac_fx, /* i : voicing factor Q15*/ + Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ + Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ + const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ + const Word16 code_preQ_fx[], /* i : prequantizer excitation */ + const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ + const Word16 T0, /* i : integer pitch variables Q0 */ + const Word16 T0_frac, /* i : Fractional pitch variables Q0*/ + const Word16 coder_type, /* i : coding type */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ - test(); - test(); - IF( ( ( EQ_16( coder_type, VOICED ) ) || ( GT_16( pitch, 14784 /* 115.5 in Q7 */ ) ) ) && ( GT_32( core_brate, ACELP_8k00 ) ) ) - { - tmp = MAX_16; - move16(); - *voice_factors_fx = mult_r( *voice_factors_fx, tmp ); - move16(); - } - - *voice_factors_fx = s_min( s_max( *voice_factors_fx, 0 ), MAX_16 ); - move16(); - IF( EQ_16( L_frame_fx, L_FRAME ) ) - { - interp_code_5over2_fx( code_fx, tmp_code_fx, L_subfr ); /* code: Q9, tmp_code: Q9 */ - gain_code16 = round_fx_o( L_shl_o( gain_code_fx, Q_exc, &Overflow ), &Overflow ); /*Q_exc */ - FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ ) - { - L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ - L_tmp = L_shl_sat( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ - L_tmp = L_mac_sat( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] ); /*Q15+Q_exc */ - L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ - bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ - move16(); - } - } - ELSE - { - IF( gain_preQ_fx != 0 ) - { - FOR( i = 0; i < L_subfr; i++ ) - { - /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */ - Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ - Ltemp2 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /*Q2 * Q10 -> Q12 */ - - Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ - Ltemp2 = L_shl_o( Ltemp2, add( Q_exc, 4 ) /*Q_exc+16-13*/, &Overflow ); /*Q_exc+16 */ - - tmp_code_preInt_fx[i] = round_fx_o( L_add_o( Ltemp1, Ltemp2, &Overflow ), &Overflow ); /* Q_exc */ - move16(); - } - } - ELSE - { - FOR( i = 0; i < L_subfr; i++ ) - { - /*code in the encoder is Q9 and there is no <<1 with Mult_32_16 Q16 * Q9 -> Q9 */ - Ltemp1 = Mult_32_16( gain_code_fx, code_fx[i] ); /* Q16 + Q9 + 1 - 16 = Q10 */ - Ltemp1 = L_shl_o( Ltemp1, add( Q_exc, 6 ) /*Q_exc+16-19*/, &Overflow ); /*Q_exc+16 */ - tmp_code_preInt_fx[i] = round_fx_o( Ltemp1, &Overflow ); /* Q_exc */ - move16(); - } - } - - interp_code_4over2_fx( tmp_code_preInt_fx, tmp_code_fx, L_subfr ); /* o: tmp_code in Q_exc */ - FOR( i = 0; i < L_subfr * 2; i++ ) - { - L_tmp = L_mult( gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * 2] ); /*Q14+Q_exc+1 */ - tmp = round_fx_o( L_shl_o( L_tmp, 1 /* (Q_exc+16)-(14+Q_exc+1)*/, &Overflow ), &Overflow ); /* tmp in Q_exc */ - bwe_exc_fx[i + i_subfr_fx * 2] = add_o( tmp, tmp_code_fx[i], &Overflow ); /*Q_exc */ - move16(); - } - } - - return; -} - -/*======================================================================================*/ -/* FUNCTION : prep_tbe_exc_ivas_fx() */ -/*--------------------------------------------------------------------------------------*/ -/* PURPOSE : Prepare TBE excitation */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) L_frame_fx : length of the frame */ -/* _ (Word16) i_subfr_fx : subframe index */ -/* _ (Word16) gain_pit_fx : Pitch gain (14) */ -/* _ (Word32) gain_code_fx : algebraic codebook gain (Q(16+Q_exc)) */ -/* _ (Word16*[]) code_fx : algebraic excitation (Q9) */ -/* _ (Word16) voice_fac_fx : voicing factor (Q15) */ -/* _ (Word16) gain_preQ_fx : prequantizer excitation gain */ -/* _ (Word16[]) code_preQ_fx : prequantizer excitation */ -/*--------------------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*[]) voice_factors_fx : TBE voicing factor (Q15) */ -/*--------------------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ (Word16[]) bwe_exc_fx : excitation for TBE (Q_exc) */ -/*--------------------------------------------------------------------------------------*/ - -/* _ None */ -/*--------------------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*======================================================================================*/ -#endif -void prep_tbe_exc_ivas_fx( - const Word16 L_frame_fx, /* i : length of the frame */ - const Word16 L_subfr, - const Word16 i_subfr_fx, /* i : subframe index */ - const Word16 gain_pit_fx, /* i : Pitch gain Q14*/ - const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/ - const Word16 code_fx[], /* i : algebraic excitation Q9*/ - const Word16 voice_fac_fx, /* i : voicing factor Q15*/ - Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/ - Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/ - const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */ - const Word16 code_preQ_fx[], /* i : prequantizer excitation */ - const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */ - Word16 T0, /* i : integer pitch variables Q0 */ - Word16 T0_frac, /* i : Fractional pitch variables Q0*/ - const Word16 coder_type, /* i : coding type */ - Word32 core_brate, /* i : core bitrate */ - const Word16 element_mode, /* i : element mode */ - const Word16 idchan, /* i : channel ID */ - const Word16 flag_TD_BWE, /* i : flag indicating whether hTD_BWE exists */ - const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ) { Word16 i; @@ -7543,6 +7352,7 @@ void prep_tbe_exc_ivas_fx( return; } + /*=============================================================================*/ /* FUNCTION : void swb_formant_fac_fx ( ) */ /*------------------------------------------------------------------------------*/ @@ -7562,9 +7372,10 @@ void prep_tbe_exc_ivas_fx( /* CALLED FROM : */ /*==============================================================================*/ -Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */ - const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ - Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */ +/*! r: Formant filter strength [0,1] */ +Word16 swb_formant_fac_fx( + const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */ + Word16 *tilt_mem /* i/o: Tilt smoothing memory (Q12) */ ) { Word16 formant_fac; @@ -7584,7 +7395,6 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength tmp = sub( tmp, SWB_TILT_LOW_FX ); /* Q12 */ formant_fac = mult_r( tmp, SWB_TILT_DELTA_FX ); /* Q12 */ - IF( GT_16( formant_fac, 4096 /* 1 in Q12 */ ) ) { formant_fac = 4096; /* 1 in Q12 */ @@ -7604,6 +7414,12 @@ Word16 swb_formant_fac_fx( /* o : Formant filter strength } +/*-------------------------------------------------------------------* + * wb_tbe_extras_reset_fx() + * + * + *-------------------------------------------------------------------*/ + void wb_tbe_extras_reset_fx( Word16 mem_genSHBexc_filt_down_wb2[], Word16 mem_genSHBexc_filt_down_wb3[] ) @@ -7620,7 +7436,6 @@ void wb_tbe_extras_reset_fx( * Determine TBE bit consumption per frame from bitrate * *-------------------------------------------------------------------*/ - Word16 get_tbe_bits_fx( const Word32 total_brate, /* o : TBE bit consumption per frame */ const Word16 bwidth, /* i : overall bitrate */ diff --git a/lib_dec/FEC_fx.c b/lib_dec/FEC_fx.c index a23c9aa90..48d91a87a 100644 --- a/lib_dec/FEC_fx.c +++ b/lib_dec/FEC_fx.c @@ -510,19 +510,10 @@ void FEC_exc_estim_fx( move16(); /* st_fx->L_frame / L_SUBFR */ tmp = shr( st_fx->L_frame, 6 ); + /* Replication of the last spectrum, with a slight downscaling of its dynamic */ -#ifdef REMOVE_EVS_DUPLICATES - gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); -#else - IF( st_fx->element_mode == EVS_MONO ) - { - gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc ); - } - ELSE - { - gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); - } -#endif + gsc_dec_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, &st_fx->Q_exc ); + *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ move16(); /* Transform back to time domain */ diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 714a60166..7f4586083 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -50,7 +50,6 @@ /* _ None */ /*========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void FEC_scale_syn_fx( const Word16 L_frame, /* i : length of the frame */ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ @@ -77,574 +76,7 @@ void FEC_scale_syn_fx( Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/ Word16 Q_exc, Word16 Q_syn, - const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ - const Word16 force_scaling /* i: force scaling */ -) -{ - Word16 i; - Word32 L_enr1, L_enr2; - Word16 gain1, gain2, enr_LP; - Word16 tmp, tmp2, exp, exp2; - Word16 tmp3; - Word32 L_tmp; - Word16 scaling; - Word32 ener_max, L_enr2_av, L_ener2_max; - Word16 h1[L_FRAME / 2], tilt, pitch_dist, mean_pitch; - Word16 k; - Word32 L_mean_pitch; - - enr_LP = 0; - move16(); - gain2 = 0; - move16(); - gain1 = 0; - move16(); - *update_flg = 0; - move16(); - L_enr_old = L_max( 1, L_enr_old ); /* to avoid division by zero (*L_enr_old is always >= 0) */ - scaling = 16384; - move16(); /* Q14*/ - - /*-----------------------------------------------------------------* - * Find the synthesis filter impulse response on voiced - *-----------------------------------------------------------------*/ - test(); - IF( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) - { - IF( EQ_16( L_frame, L_FRAME ) ) - { - enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR - 1 ) * ( M + 1 ), L_SUBFR ); - } - ELSE /* L_frame == L_FRAME16k */ - { - enr_LP = Enr_1_Az_fx( Aq + ( NB_SUBFR16k - 1 ) * ( M + 1 ), L_SUBFR ); /*Q3*/ - } - } - - /*-----------------------------------------------------------------* - * Define when to scale the synthesis - *-----------------------------------------------------------------*/ - - IF( bfi ) - { - *scaling_flag = 1; - move16(); /* Always check synthesis on bad frames */ - } - ELSE IF( prev_bfi ) - { - test(); - IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) || ( EQ_16( LSF_Q_prediction, MOVING_AVERAGE ) ) ) - { - *scaling_flag = 2; - move16(); /* Decoded LSFs affected */ - } - ELSE IF( NE_16( coder_type, TRANSITION ) ) - { - *scaling_flag = 1; - move16(); /* SN, but not TC mode - LSF still affected by the interpolation */ - } - ELSE - { - *scaling_flag = 0; - move16(); /* LSF still possibly affected due to interpolation */ - } - scaling = 24576; /*1.5 Q14*/ - move16(); - } - ELSE - { - test(); - IF( ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) && ( EQ_16( *scaling_flag, 2 ) ) ) - { - *scaling_flag = 2; - move16(); /* Continue with energy control till the end of AR prediction */ - } - ELSE IF( *scaling_flag > 0 ) - { - ( *scaling_flag ) = sub( *scaling_flag, 1 ); /* If scaling flag was equal to 2, add one control frame to account for the LSF interpolation */ - move16(); - } - scaling = 32767; /*2.0 Q14*/ - move16(); - } - - /*-----------------------------------------------------------------* - * Find the energy/gain at the end of the frame - *-----------------------------------------------------------------*/ - - frame_ener_fx( L_frame, clas, synth, pitch[( L_frame >> 6 ) - 1], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 ); - - - test(); - test(); - IF( bfi || ( EQ_32( total_brate, ACELP_7k20 ) ) || ( EQ_32( total_brate, ACELP_8k00 ) ) ) - { - /* previous frame erased and no TC frame */ - IF( *scaling_flag > 0 ) - { - /*enr2 += 0.01f;*/ - L_enr2 = L_max( L_enr2, 1 ); /* L_enr2 is in Q0 */ - - IF( bfi ) /* In all bad frames, limit the gain to 1 */ - { - /* gain2 = (float)sqrt( enr_old / enr2 );*/ - L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr2, 0, &exp2 ); - gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - - /*if( gain2 > 1.0f )gain2 = 1.0f;*/ - gain2 = s_min( gain2, 16384 ); - - /* find the energy/gain at the beginning of the frame */ - frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 ); - - /*enr1 += 0.1f;*/ - L_enr1 = L_max( L_enr1, 1 ); /* L_enr2 is in Q0 */ - - /*gain1 = (float)sqrt( enr_old / enr1 );*/ - L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); - gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - - /*if( gain1 > 1.0f )gain1 = 1.0f;*/ - gain1 = s_min( gain1, 16384 ); /*Q14*/ - } - ELSE /* good frame */ - { - IF( L_enr_q == 0 ) /* If E info (FEC protection bits) is not available in the bitstream */ - { - L_enr_q = L_enr2; /*Q0*/ - set16_fx( h1, 0, L_FRAME / 2 ); - h1[0] = 1024; /*1.0f in Q10*/ - move16(); - /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/ - E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M ); - - /*Compute tilt */ - /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ - /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ - /*tilt = rr1 / rr0;*/ - tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ - pitch_dist = 0; - move16(); - L_mean_pitch = L_mult( pitch[0], 8192 /*1.0f in Q13*/ ); /*Q14*/ - FOR( k = 0; k < ( NB_SUBFR - 1 ); k++ ) - { - pitch_dist = add( pitch_dist, abs_s( sub( pitch[k + 1], pitch[k] ) ) ); /*Q0*/ - L_mean_pitch = L_mac( L_mean_pitch, pitch[k + 1], 8192 ); /*Q14*/ - } - /*pitch_dist /= (float)(NB_SUBFR-1); */ - pitch_dist = mult_r( shl( pitch_dist, 4 ), 10923 /*1/(float)(NB_SUBFR-1) in Q15*/ ); /*Q4*/ - /*mean_pitch /= (float)(NB_SUBFR);*/ - mean_pitch = extract_h( L_shl( L_mean_pitch, 4 ) ); /*Q4*/ - - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */ - ( ( GT_16( pitch_dist, 8 << 4 ) ) || ( LT_16( mean_pitch, PIT_MIN << 4 ) ) ) && /* pitch unstable or very short */ - ( ( prev_bfi ) || ( ( EQ_16( coder_type, GENERIC ) ) && ( EQ_16( LSF_Q_prediction, AUTO_REGRESSIVE ) ) ) ) ) - { - /*if( enr_q > scaling * enr_old ){enr_q = scaling * enr_old;}*/ - L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ - } - ELSE - { - ener_max = *lp_ener_FEC_max; /*Q0*/ - move32(); - test(); - if ( EQ_16( clas, VOICED_TRANSITION ) || ( GE_16( clas, INACTIVE_CLAS ) ) ) - { - ener_max = *lp_ener_FEC_av; /*Q0*/ - move32(); - } - /*if( enr_old > ener_max )ener_max = enr_old;*/ - ener_max = L_max( ener_max, L_enr_old ); - - /*if( enr_q > scaling * ener_max ){enr_q = scaling * ener_max;}*/ - L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( ener_max, scaling ), 1 ) ); /* scaling in Q14*/ - } - } - /*gain2 = (float)sqrt( enr_q / enr2 );*/ - L_enr_q = L_max( L_enr_q, 1 ); /* L_enr2 is in Q0 */ - L_tmp = Sqrt_Ratio32( L_enr_q, 0, L_enr2, 0, &exp2 ); - gain2 = round_fx( L_shl( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - - /*-----------------------------------------------------------------* - * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s) - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) || - EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) && - prev_bfi ) - { - /* voiced -> unvoiced signal transition */ - /* CNG -> active signal transition */ - gain1 = gain2; /*Q14*/ - move16(); - } - ELSE - { - /* find the energy at the beginning of the frame */ - frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1 /*Q0*/, 1, Q_syn, 3, 0 ); - - /*enr1 += 0.1f;*/ - L_enr1 = L_max( L_enr1, 1 ); /* L_enr1 is in Q0 */ - - /*gain1 = (float)sqrt( enr_old / enr1 );*/ - L_tmp = Sqrt_Ratio32( L_enr_old, 0, L_enr1, 0, &exp2 ); - gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - - /*if( gain1 > 1.2f )gain1 = 1.2f;*/ - /* prevent clipping */ - gain1 = s_min( gain1, 19661 /*1.2f in Q14*/ ); - - /* prevent amplifying the unvoiced or inactive part of the frame in case an offset is followed by an onset */ - test(); - test(); - if ( EQ_16( clas, ONSET ) && GT_16( gain1, gain2 ) && prev_bfi ) - { - gain1 = gain2; /*Q14*/ - move16(); - } - } - - L_enr2 = L_enr_q; /*Q0*/ - move32(); /* Set the end frame energy to the scaled energy, to be used in the lp_ener_FEC */ - } - - /*------------------------------------------------------------------------------* - * Smooth the energy evolution by exponentially evolving from gain1 to gain2 - *------------------------------------------------------------------------------*/ - - /*gain2 *= ( 1.0f - AGC );*/ - L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) ); /*Q30*/ - FOR( i = 0; i < L_frame; i++ ) - { - /*gain1 = gain1 * AGC + gain2;*/ - gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */ - /*exc[i] *= gain1;*/ - exc[i] = mac_r( L_mult( exc[i], gain1 ), exc[i], gain1 ); - move16(); - /*exc2[i] *= gain1;*/ - exc2[i] = mac_r_sat( L_mult( exc2[i], gain1 ), exc2[i], gain1 ); - move16(); - } - /* smoothing is done in excitation domain, so redo synthesis */ - Copy( mem_tmp, mem_syn, M ); /* Q_syn */ - syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn ); - *update_flg = 1; - move16(); - } - } - ELSE - { - /* previous frame erased and no TC frame */ - test(); - IF( prev_bfi && NE_16( coder_type, TRANSITION ) ) - { - IF( L_enr_q == 0 ) - { - L_enr_q = L_max( 1, L_enr2 ); /* sets to 'L_enr2' in 1 clock */ - set16_fx( h1, 0, L_FRAME / 2 ); - h1[0] = 1024; /*1.0f in Q10*/ - move16(); - /*syn_filt( Aq+(3*(M+1)), M, h1, h1, L_FRAME/2, h1+(M+1), 0 );*/ - E_UTIL_synthesis( 1, Aq + ( 3 * ( M + 1 ) ), h1, h1, L_FRAME / 2, h1 + ( M + 1 ), 0, M ); - /*Compute tilt */ - /*rr0 = dotp( h1, h1, L_FRAME/2-1 ) + 0.1f;*/ - /*rr1 = dotp( h1, h1+1, L_FRAME/2-1 );*/ - /*tilt = rr1 / rr0;*/ - tilt = extract_h( L_shl_sat( get_gain( h1 + 1, h1, L_FRAME / 2 - 1 ), 15 ) ); /*Q15*/ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( ( EQ_32( total_brate, ACELP_13k20 ) ) || ( EQ_32( total_brate, ACELP_12k85 ) ) || ( EQ_32( total_brate, ACELP_12k15 ) ) || ( EQ_32( total_brate, ACELP_11k60 ) ) || - ( EQ_32( total_brate, ACELP_9k60 ) ) ) && - ( GT_16( tilt, 22938 ) ) && /* HF resonnant filter */ - ( ( ( clas == UNVOICED_CLAS ) ) || ( EQ_16( clas, INACTIVE_CLAS ) ) ) ) ) /* unvoiced classification */ - { - /*if( enr_q > scaling * enr_old )enr_q = scaling * enr_old;*/ - L_enr_q = L_min( L_enr_q, L_shl_sat( Mult_32_16( L_enr_old, scaling ), 1 ) ); /* scaling in Q14*/ - } - ELSE IF( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) - { - /* Voiced-voiced recovery */ - test(); - IF( *old_enr_LP != 0 && GT_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) - { - /* enr_q /= enr_LP */ - exp = norm_l( L_enr_q ); - tmp = extract_h( L_shl( L_enr_q, exp ) ); - - exp2 = norm_s( enr_LP ); - tmp2 = shl( enr_LP, exp2 ); - - exp = sub( exp2, exp ); - - tmp3 = sub( tmp, tmp2 ); - IF( tmp3 > 0 ) - { - tmp = shr( tmp, 1 ); - exp = add( exp, 1 ); - } - tmp = div_s( tmp, tmp2 ); - - /* L_enr_q *= 2 * *old_enr_LP */ - L_enr_q = L_shl( L_mult( tmp, shl( *old_enr_LP, 1 ) ), exp ); - } - - ELSE - { - test(); - IF( avoid_lpc_burst_on_recovery && GT_16( enr_LP, 160 /*20.0f in Q3*/ ) ) - { - exp = norm_s( enr_LP ); - tmp = shl( enr_LP, exp ); - - exp2 = 7; - move16(); - tmp2 = 160 << 7; /* 160 = 20.0f in Q3 */ - move16(); - exp = sub( exp2, exp ); - - IF( GT_16( tmp, tmp2 ) ) - { - tmp = shr( tmp, 1 ); - exp = add( exp, 1 ); - } - tmp = div_s( tmp, tmp2 ); /* tmp*2^exp = enr_LP/20.0 */ - L_tmp = Isqrt_lc( L_deposit_h( tmp ), &exp ); /* L_tmp*2^exp = sqrt(20.0/enr_LP) */ - L_enr_q = L_shl( Mpy_32_32( L_enr_q, L_tmp ), exp ); - } - } - } - - test(); - test(); - test(); - test(); - IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) || force_scaling ) - { - - IF( GT_32( L_enr_q, L_enr_old ) ) /* Prevent energy to increase on voiced */ - { - L_enr_q = L_add( Mpy_32_16_1( L_enr_old, 32767 - SCLSYN_LAMBDA ), Mpy_32_16_1( L_enr_q, SCLSYN_LAMBDA ) ); /*Q0*/ - } - } - } - - L_enr_q = L_max( 1, L_enr_q ); - - /* gain2 = (float)sqrt( enr_q / enr2 );*/ - exp = norm_l( L_enr_q ); - tmp = extract_h( L_shl( L_enr_q, exp ) ); - - exp2 = norm_l( L_enr2 ); - tmp2 = extract_h( L_shl( L_enr2, exp2 ) ); - - exp2 = sub( exp, exp2 ); /* Denormalize and substract */ - - tmp3 = sub( tmp2, tmp ); - IF( tmp3 > 0 ) - { - tmp2 = shr( tmp2, 1 ); - exp2 = add( exp2, 1 ); - } - - tmp = div_s( tmp2, tmp ); - - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp2 ); - gain2 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - /*-----------------------------------------------------------------* - * Clipping of the smoothing gain at the frame end - *-----------------------------------------------------------------*/ - - gain2 = s_min( gain2, 19661 /*1.2f in Q14*/ ); /* Gain modification clipping */ - if ( LT_32( L_enr_q, 2 ) ) - { - gain2 = s_min( gain2, 16384 /*1.0f in Q14*/ ); /* Gain modification clipping */ - } - - /*-----------------------------------------------------------------* - * Find the energy/gain at the beginning of the frame to ensure smooth transition after erasure(s) - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( clas, SIN_ONSET ) ) /* slow increase */ - { - gain1 = shr( gain2, 1 ); /*0.5f * gain2*/ - } - /*------------------------------------------------------------* - * voiced->unvoiced transition recovery - *------------------------------------------------------------*/ - ELSE IF( ( GE_16( last_good, VOICED_TRANSITION ) && LT_16( last_good, INACTIVE_CLAS ) && ( clas == UNVOICED_CLAS || EQ_16( clas, INACTIVE_CLAS ) ) ) || /* voiced->unvoiced transition recovery */ - EQ_32( last_core_brate, SID_1k75 ) || EQ_32( last_core_brate, SID_2k40 ) || last_core_brate == FRAME_NO_DATA ) /* CNG -> active signal transition */ - { - gain1 = gain2; /*Q14*/ - move16(); - } - ELSE - { - /*--------------------------------------------------------* - * Find the energy at the beginning of the frame - *--------------------------------------------------------*/ - tmp = frame_ener_fx( L_frame, clas, synth, pitch[0], &L_enr1, 0, Q_syn, 3, 0 ); - - /*gain1 = (float)sqrt( enr_old / enr1 );*/ - exp = norm_l( L_enr_old ); - tmp = extract_h( L_shl( L_enr_old, exp ) ); - exp2 = norm_l( L_enr1 ); - tmp2 = extract_h( L_shl( L_enr1, exp2 ) ); - - exp2 = sub( exp, exp2 ); /* Denormalize and substract */ - - tmp3 = sub( tmp2, tmp ); - - IF( tmp3 > 0 ) - { - tmp2 = shr( tmp2, 1 ); - exp2 = add( exp2, 1 ); - } - - tmp = div_s( tmp2, tmp ); - - L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp2 ); - gain1 = round_fx_sat( L_shl_sat( L_tmp, sub( exp2, 1 ) ) ); /* in Q14 */ - /* exp2 is always <= 1 */ - - gain1 = s_min( gain1, 19661 /*1.2F in Q14*/ ); - - test(); - test(); - if ( avoid_lpc_burst_on_recovery && ( GT_16( enr_LP, 160 ) ) && ( LE_16( enr_LP, shl_sat( *old_enr_LP, 1 ) ) ) ) - { - gain1 = s_min( gain1, 16384 /*1.0f in Q14*/ ); - } - - /*--------------------------------------------------------* - * Prevent a catastrophy in case of offset followed by onset - *--------------------------------------------------------*/ - test(); - if ( ( EQ_16( clas, ONSET ) ) && ( GT_16( gain1, gain2 ) ) ) - { - gain1 = gain2; /*Q14*/ - move16(); - } - } - /*-----------------------------------------------------------------* - * Smooth the energy evolution by exponentially evolving from - * gain1 to gain2 - *-----------------------------------------------------------------*/ - - L_tmp = L_mult( gain2, (Word16) ( 32768 /*Q15*/ - AGC_FX ) ); - - FOR( i = 0; i < L_frame; i++ ) - { - gain1 = mac_r( L_tmp, gain1, AGC_FX ); /* in Q14 */ - exc[i] = mac_r_sat( L_mult_sat( exc[i], gain1 ), exc[i], gain1 ); - move16(); - exc2[i] = mac_r_sat( L_mult_sat( exc2[i], gain1 ), exc2[i], gain1 ); - move16(); - } - - Copy( mem_tmp, mem_syn, M ); /* Q_syn */ - syn_12k8_fx( L_frame, Aq, exc2, synth, mem_syn, 1, Q_exc, Q_syn ); - *update_flg = 1; - move16(); - } - } - /*-----------------------------------------------------------------* - * Update low-pass filtered energy for voiced frames - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( !bfi && ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) ) - { - IF( EQ_16( clas, VOICED_TRANSITION ) ) - { - L_enr2_av = L_enr2; /*Q0*/ - move32(); - frame_ener_fx( L_frame, VOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_ener2_max /*Q0*/, 1, Q_syn, 3, 0 ); - } - ELSE - { - L_ener2_max = L_enr2; /*Q0*/ - move32(); - frame_ener_fx( L_frame, UNVOICED_CLAS, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2_av /*Q0*/, 1, Q_syn, 3, 0 ); - } - - /**lp_ener_FEC_av = 0.2f * enr2_av + 0.8f * *lp_ener_FEC_av; move32();*/ - *lp_ener_FEC_av = Madd_32_16( Mult_32_16( *lp_ener_FEC_av, 31130 /*0.95f in Q15*/ ), L_enr2_av, 1638 /*0.05F Q15*/ ); /*Q0*/ - move32(); - /**lp_ener_FEC_max = 0.2f * enr2_max + 0.8f * *lp_ener_FEC_max; move32();*/ - *lp_ener_FEC_max = Madd_32_16( Mult_32_16( *lp_ener_FEC_max, 31130 /*0.95f in Q15*/ ), L_ener2_max, 1638 /*0.05F Q15*/ ); /*Q0*/ - move32(); - } - - /*-----------------------------------------------------------------* - * Update the LP filter energy for voiced frames - *-----------------------------------------------------------------*/ - test(); - if ( GE_16( clas, VOICED_TRANSITION ) && LT_16( clas, INACTIVE_CLAS ) ) - { - *old_enr_LP = enr_LP; /*Q3*/ - move16(); - } - - return; -} -#endif -void FEC_scale_syn_ivas_fx( - const Word16 L_frame, /* i : length of the frame */ - Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/ - Word16 clas, /* i/o: frame classification */ - const Word16 last_good, /* i: last good frame classification */ - Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz Q_syn*/ - const Word16 *pitch, /* i: pitch values for each subframe Q0*/ - Word32 L_enr_old, /* i: energy at the end of previous frame */ - Word32 L_enr_q, /* i: transmitted energy for current frame */ - const Word16 coder_type, /* i: coder type */ - const Word16 LSF_Q_prediction, /* i : LSF prediction mode */ - Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */ - Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy Q0*/ - Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy Q0*/ - const Word16 bfi, /* i: current frame BFI */ - const Word32 total_brate, /* i: total bitrate */ - const Word16 prev_bfi, /* i: previous frame BFI */ - const Word32 last_core_brate, /* i: previous frame core bitrate */ - Word16 *exc, /* i/o: excitation signal without enhancement */ - Word16 *exc2, /* i/o: excitation signal with enhancement */ - Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) Q12*/ - Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame Q3*/ - const Word16 *mem_tmp, /* i: temp. initial synthesis filter states Q_syn*/ - Word16 *mem_syn, /* o: initial synthesis filter states Q_syn*/ - Word16 Q_exc, - Word16 Q_syn, -#ifdef REMOVE_EVS_DUPLICATES - const Word16 element_mode, /* i : element mode */ -#endif + const Word16 element_mode, /* i : element mode */ const Word16 avoid_lpc_burst_on_recovery, /* i : if true the excitation energy is limited if LP has big gain */ const Word16 force_scaling /* i: force scaling */ ) @@ -742,12 +174,8 @@ void FEC_scale_syn_ivas_fx( tmp = sub( 3, getScaleFactor16( synth, L_frame ) ); -#ifdef REMOVE_EVS_DUPLICATES test(); IF( tmp > 0 && GT_16( element_mode, EVS_MONO ) ) -#else - IF( tmp > 0 ) -#endif { Word16 synth_tmp[L_FRAME16k]; Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 3570ce86d..32aab2bb0 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1,57 +1,72 @@ +/****************************************************************************************************** + + (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + /*==================================================================================== - EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0 + EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 ====================================================================================*/ - #include #include -#include "options.h" /* Compilation switches */ -#include "rom_com.h" /* Static table prototypes */ -#include "prot_fx.h" /* Function prototypes */ +#include +#include "options.h" +#include "cnst.h" +#include "rom_com.h" +#include "prot_fx.h" +#include "ivas_cnst.h" +#include "ivas_rom_com.h" +#include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "ivas_cnst.h" /* Common constants */ -#include "cnst.h" /* Common constants */ - -#ifndef REMOVE_EVS_DUPLICATES -/*==========================================================================*/ -/* FUNCTION : void acelp_core_dec_fx () */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : ACELP core decoder */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ Word16 coder_type i : coder type */ - -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ Word16 *voice_factors o : voicing factors Q15 */ -/* _ Word16 old_syn_12k8_16k[] o : intermediate ACELP Q_syn2-1 */ -/* synthesis at 12.8kHz or 16kHz to be used by SWB BWE */ -/* _ Word16 synth_out[] o : synthesis Q_syn2-1 */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* _ Decoder_State_fx *st_fx: */ -/* _ Word16 bwe_exc_extended[] i/o: bandwidth extended excitation Q0*/ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------*/ -/* CALLED FROM : RX */ -/*==========================================================================*/ + + +/*-------------------------------------------------------------------* + * acelp_core_dec_fx() + * + * ACELP core decoder + *-------------------------------------------------------------------*/ ivas_error acelp_core_dec_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 output[], /* o : synthesis @internal Fs */ - Word16 synth_out[], /* o : synthesis Q_syn2-1*/ - Word16 save_hb_synth[], /* o : HB synthesis */ - Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation Q0*/ - Word16 *voice_factors, /* o : voicing factors Q15 */ - Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis for SWB BWE Q_syn2-1*/ - Word16 sharpFlag, - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ + Decoder_State *st, /* i/o: decoder state structure */ + Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ + Word16 synth_fx16[], /* o : synthesis Q_syn2*/ + Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ + Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ + Word16 *voice_factors_fx, /* o : voicing factors Q15*/ + Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/ + const Word16 sharpFlag, /* i : formant sharpening flag */ + Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/ Word16 *unbits, /* o : number of unused bits */ Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const Word16 tdm_lspQ_PCh[M], /* i : Q LSPs for primary channel */ - const Word16 tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ + STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/ + const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/ + const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const Word16 last_element_mode, /* i : last element mode */ const Word32 last_element_brate, /* i : last element bitrate */ @@ -61,96 +76,158 @@ ivas_error acelp_core_dec_fx( const Word16 read_sid_info /* i : read SID info flag */ ) { - Word16 old_exc_fx[L_EXC_DEC] = { 0 }, *exc_fx; /* excitation signal buffer (Q0) */ - Word16 syn_fx_tmp[L_FRAME_16k + L_SUBFR], *syn_fx; /* synthesis signal buffer */ - Word16 temp_buf[L_FRAME16k + L_SYN_MEM]; + Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; + Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ + Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ + Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ + Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ + Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ + Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ + Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ Word32 enr_q_fx; /* E information for FER protection */ Word16 tmp_noise_fx; /* Long term temporary noise energy */ - Word16 i, int_fs; - Word16 tc_subfr_fx; - Word16 allow_cn_step_fx; + Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ + Word16 FEC_pitch_fx; /* FEC pitch */ + Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ + Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ + Word16 i, j, int_fs; + Word16 tc_subfr; + Word16 allow_cn_step; Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; - - Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )] = { 0 }; /*Q12*/ - Word16 Es_pred_fx; /*Q8*/ - Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )] = { 0 }; /* excitation buffer Q_exc*/ - Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ - Word16 *bwe_exc_fx; - Word16 lsf_new_fx[M]; /* LSFs at the end of the frame */ - Word16 lsp_new_fx[M]; /* LSPs at the end of the frame */ - Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ - Word16 FEC_pitch_fx; /*Q6*/ Word16 last_pulse_pos; Word16 T0_tmp; - Word16 do_WI_fx; + Word16 do_WI; Word16 dct_buffer_fx[DCT_L_POST]; Word16 exc_buffer_fx[DCT_L_POST]; - Word16 dct_exc_tmp[L_FRAME16k]; - Word16 qdct; - Word16 delta_mem_scale; - Word16 bpf_error_signal[L_FRAME16k]; - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - Word32 q_env[20]; - Word16 exc3_fx[L_FRAME16k]; - Word16 syn1_fx_tmp[L_FRAME16k + 2], *syn1_fx; - Word32 *realBuffer[CLDFB_NO_COL_MAX], *imagBuffer[CLDFB_NO_COL_MAX]; - Word16 gain_buf[NB_SUBFR16k]; /*Q14*/ + Word16 dct_exc_tmp_fx[L_FRAME16k]; + Word16 nb_bits; /* number of bits */ + Word16 indice; /* parameter indices to write */ + Word16 gain_buf_fx[NB_SUBFR16k]; Word16 syn_fx_tmp2[L_FRAME_16k]; Word16 pitch_buf_tmp[NB_SUBFR16k]; - Word16 k; Word16 update_flg; - Word32 realBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 imagBufferTmp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word16 LSF_Q_prediction; /* o : LSF prediction mode */ + Word32 q_env_fx[20]; + Word16 exc3_fx[L_FRAME16k]; + Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx; + Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; + Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 LSF_Q_prediction; /* LSF prediction mode */ Word16 avoid_lpc_burst_on_recovery; - Word16 uc_two_stage_flag, dec; - Word16 nb_bits, indice; + Word16 tmpF_fx; + Word16 uc_two_stage_flag; Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; - MUSIC_POSTFILT_HANDLE hMusicPF; - BPF_DEC_HANDLE hBPF; - TD_BWE_DEC_HANDLE hBWE_TD; - FD_BWE_DEC_HANDLE hBWE_FD; - TCX_DEC_HANDLE hTcxDec; + Word16 *old_exc_s_fx; /* Start of last excitation frame */ + Word16 *p_tdm_Pri_pitch_buf_fx; + Word16 tmp, exp, local_element_mode; ivas_error error; - (void) ( tdm_lspQ_PCh ); - (void) ( tdm_lsfQ_PCh ); - (void) ( use_cldfb_for_dft ); - (void) ( last_element_mode ); - (void) ( last_element_brate ); - (void) ( flag_sec_CNA ); - (void) ( nchan_out ); - (void) ( save_hb_synth ); - (void) ( output ); - (void) ( read_sid_info ); - (void) hStereoCng; - hMusicPF = st_fx->hMusicPF; - hBPF = st_fx->hBPF; - hBWE_TD = st_fx->hBWE_TD; - hBWE_FD = st_fx->hBWE_FD; - hTcxDec = st_fx->hTcxDec; + Word32 bpf_error_signal_fx[L_FRAME16k]; + Word16 bpf_error_signal_16fx[L_FRAME16k]; + Word16 Q_real; + Word32 max_real, max_imag, max_val; + + set32_fx( bpf_error_signal_fx, 0, L_FRAME16k ); + set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k ); + set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) ); + set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) ); + error = IVAS_ERR_OK; move32(); - // IF ( EQ_16(st_fx->element_mode, IVAS_CPE_MDCT) && EQ_16(nchan_out, 1) && EQ_16(st_fx->idchan, 1) && LE_32(last_element_brate, IVAS_SID_4k4) ) + test(); test(); test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st_fx->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) { /* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */ return error; } + push_wmops( "acelp_core_dec" ); + + /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */ + output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); + + /*----------------------------------------------------------------* + * stereo SID and CNG frames processing + *----------------------------------------------------------------*/ + + test(); + test(); + IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) + { + IF( EQ_16( st->cng_type, FD_CNG ) ) + { + configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); + + Word16 old_NoiseEstExp; + old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; + move16(); + + /* Only run parameter decoding in SID frames */ + IF( EQ_32( st->core_brate, SID_2k40 ) ) + { + FdCng_decodeSID_ivas_fx( st ); + + Word16 n1, n2; + n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART ); + n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); + + Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) ); + scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) ); + scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) ); + st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e; + move16(); + } + + FOR( i = 0; i < NPART; i++ ) + { + st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), + STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); + move32(); + } + + ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); + } + ELSE + { + configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); + + /* decode CNG parameters */ + CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); + + /* comfort noise generation */ + CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); + + Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/ + + /* update old LSP and LSF vector */ + Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/ + Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/ + } + + set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ + set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ + + /* CN generation done in DFT domain */ + pop_wmops(); + + return error; + } + + /*----------------------------------------------------------------* + * Active frames processing + *----------------------------------------------------------------*/ + + /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) { - set32_fx( realBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer[i] = realBufferTmp[i]; - move32(); - imagBuffer[i] = imagBufferTmp[i]; - move32(); + set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); + realBuffer_fx[i] = realBufferTmp_fx[i]; + imagBuffer_fx[i] = imagBufferTmp_fx[i]; } /*----------------------------------------------------------------* @@ -159,54 +236,61 @@ ivas_error acelp_core_dec_fx( LSF_Q_prediction = -1; move16(); - set16_fx( syn_fx_tmp, 0, L_SUBFR ); - syn_fx = syn_fx_tmp + L_SUBFR; - syn1_fx_tmp[0] = 0; + set16_fx( syn_tmp_fx, 0, L_SUBFR ); + psyn_fx = syn_tmp_fx + L_SUBFR; + syn1_tmp_fx[0] = 0; move16(); - syn1_fx_tmp[1] = 0; + syn1_tmp_fx[1] = 0; move16(); - syn1_fx = syn1_fx_tmp + 2; - /*output_frame = (Word16)(st_fx->output_Fs_fx / 50); move16();*/ - output_frame = st_fx->output_frame_fx; - move16(); - st_fx->bpf_off = 0; + syn1_fx = syn1_tmp_fx + 2; + st->bpf_off = 0; move16(); + test(); test(); test(); test(); test(); test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) || EQ_16( st_fx->last_core, TCX_20_CORE ) || EQ_16( st_fx->last_core, TCX_10_CORE ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_DFT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) || ( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && LE_32( st_fx->last_core_brate, SID_2k40 ) ) ) + IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) ) { /* in case of HQ->ACELP switching, do not apply BPF */ - st_fx->bpf_off = 1; + st->bpf_off = 1; move16(); - /* in case of core switching, reset post-filter memories */ - if ( st_fx->hPFstat != NULL ) + if ( st->hPFstat != NULL ) { - st_fx->hPFstat->on = 0; + /* in case of core switching, reset post-filter memories */ + st->hPFstat->on = 0; move16(); } - /* reset the GSC pre echo energy threshold in case of switching */ - if ( st_fx->hGSCDec != NULL ) + if ( st->hGSCDec != NULL ) { - st_fx->hGSCDec->Last_frame_ener_fx = MAX_32; + /* reset the GSC pre echo energy threshold in case of switching */ + st->hGSCDec->Last_frame_ener_fx = MAX_32; move32(); } } - IF( st_fx->prev_bfi > 0 ) + + test(); + if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) ) { /* reset the GSC pre echo energy threshold in case of FEC */ - if ( st_fx->hGSCDec != NULL ) - { - st_fx->hGSCDec->Last_frame_ener_fx = MAX_32; + st->hGSCDec->Last_frame_ener_fx = MAX_32; move32(); } + + test(); + test(); + test(); + test(); + IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) ) + { + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); } - st_fx->clas_dec = st_fx->last_good; + st->clas_dec = st->last_good; move16(); enr_q_fx = 0; move32(); @@ -214,21 +298,22 @@ ivas_error acelp_core_dec_fx( move16(); tmp_noise_fx = 0; move16(); - Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc + Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/ exc_fx = old_exc_fx + L_EXC_MEM_DEC; - IF( st_fx->hWIDec != NULL ) + IF( st->hWIDec != NULL ) { - Copy( st_fx->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM ); + Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM ); } ELSE { set16_fx( old_exc2_fx, 0, L_EXC_MEM ); } exc2_fx = old_exc2_fx + L_EXC_MEM; - IF( st_fx->hBWE_TD != NULL ) + + IF( st->hBWE_TD != NULL ) { - Copy( hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); // Q_exc + Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/ bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; } ELSE @@ -238,271 +323,270 @@ ivas_error acelp_core_dec_fx( last_pulse_pos = 0; move16(); - do_WI_fx = 0; + do_WI = 0; move16(); - st_fx->GSC_noisy_speech = 0; + st->GSC_noisy_speech = 0; move16(); - st_fx->relax_prev_lsf_interp = 0; + st->relax_prev_lsf_interp = 0; move16(); + set16_fx( gain_buf_fx, 0, NB_SUBFR16k ); - set16_fx( gain_buf, 0, NB_SUBFR16k ); - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { - st_fx->gamma = GAMMA1; + st->gamma = GAMMA1; move16(); - st_fx->preemph_fac = PREEMPH_FAC; + st->inv_gamma = GAMMA1_INV; move16(); - int_fs = INT_FS_FX; + st->preemph_fac = PREEMPH_FAC; + move16(); + int_fs = INT_FS_12k8; move16(); } ELSE { - st_fx->gamma = GAMMA16k; + st->gamma = GAMMA16k; + move16(); + st->inv_gamma = GAMMA16k_INV; move16(); - st_fx->preemph_fac = PREEMPH_FAC_16k; + st->preemph_fac = PREEMPH_FAC_16k; move16(); int_fs = INT_FS_16k; move16(); } - /* reset post-filter in case post-filtering was off in previous frame */ - IF( st_fx->hPFstat != NULL ) - { - if ( st_fx->hPFstat->on == 0 ) + test(); + /* reset post-filter in case of switching */ + if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) { - st_fx->hPFstat->reset = 1; + st->hPFstat->reset = 1; move16(); } - } + avoid_lpc_burst_on_recovery = 0; move16(); test(); test(); - if ( st_fx->last_con_tcx && NE_16( st_fx->L_frameTCX_past, st_fx->L_frame ) && st_fx->last_core != 0 ) + if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) ) { avoid_lpc_burst_on_recovery = 1; move16(); } - /* TD stereo parameters */ test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->idchan == 1 ) + + /* TD stereo parameters */ + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) { tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; - tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; - tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - move16(); move16(); + tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; move16(); + tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; move16(); + p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; } ELSE { tdm_lp_reuse_flag = 0; - tdm_low_rate_mode = 0; move16(); + tdm_low_rate_mode = 0; move16(); test(); - if ( EQ_16( st_fx->element_mode, IVAS_SCE ) && st_fx->low_rate_mode ) + if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode ) { tdm_low_rate_mode = 1; move16(); } tdm_Pitch_reuse_flag = 0; move16(); + p_tdm_Pri_pitch_buf_fx = NULL; } + /*----------------------------------------------------------------* * Updates in case of internal sampling rate switching *----------------------------------------------------------------*/ + test(); test(); - IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) && ( st_fx->last_core == ACELP_CORE || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { - IF( st_fx->hPFstat->on != 0 ) + Word16 dec; + + IF( ( st->hPFstat->on != 0 ) ) { Word16 mem_syn_r_size_old, mem_syn_r_size_new; - - mem_syn_r_size_old = shr( st_fx->last_L_frame, 4 ); - mem_syn_r_size_new = shr( st_fx->L_frame, 4 ); - lerp( st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st_fx->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/ + mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/ + lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); } + /* convert quantized LSP vector */ - st_fx->rate_switching_reset = lsp_convert_poly_fx( st_fx->lsp_old_fx, st_fx->L_frame, 0 ); + st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); move16(); + /* convert old quantized LSF vector */ - lsp2lsf_fx( st_fx->lsp_old_fx, st_fx->lsf_old_fx, M, int_fs ); + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs ); /* FEC - update adaptive LSF mean vector */ - Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi1_fx, M ); // Qlog2(2.56) - Copy( st_fx->lsf_old_fx, st_fx->lsfoldbfi0_fx, M ); // Qlog2(2.56) - Copy( st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, M ); // Qlog2(2.56) + Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/ + Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/ + Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/ /* Reset LPC mem */ - IF( EQ_32( st_fx->sr_core, INT_FS_16k ) ) + IF( EQ_32( st->sr_core, INT_FS_16k ) ) { - Copy( GEWB2_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56) + Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/ } ELSE { - Copy( GEWB_Ave_fx, st_fx->mem_AR_fx, M ); // Qlog2(2.56) + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/ } - set16_fx( st_fx->mem_MA_fx, 0, M ); + set16_fx( st->mem_MA_fx, 0, M ); + /* update synthesis filter memories */ dec = DEC; move16(); - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + if ( st->element_mode != EVS_MONO ) { dec = DEC_IVAS; move16(); } - - /* update synthesis filter memories */ - synth_mem_updt2( st_fx->L_frame, st_fx->last_L_frame, st_fx->old_exc_fx, st_fx->mem_syn_r, st_fx->mem_syn2_fx, NULL, dec ); - - Copy( st_fx->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); // Q_exc - Copy_Scale_sig( st_fx->mem_syn2_fx, st_fx->mem_syn1_fx, M, sub( -1, st_fx->Q_syn ) ); /*Q-1*/ - - Copy( st_fx->mem_syn2_fx, st_fx->mem_syn3_fx, M ); + ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec ); + Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/ + Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ + Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/ } - IF( NE_16( st_fx->last_L_frame, st_fx->L_frame ) ) + /* update buffer of old subframe pitch values */ + IF( NE_16( st->last_L_frame, st->L_frame ) ) { - /* update buffer of old subframe pitch values */ - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { - - IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) ) + IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) { - /* (float)12800/(float)32000; */ - k = 13107; // Q15 + tmpF_fx = 13107; // Q15 move16(); } - ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) ) + ELSE IF( EQ_16( st->last_L_frame, 512 ) ) { - /* (float)12800/(float)25600; */ - k = 16384; // Q15 + tmpF_fx = 16384; // Q15 move16(); } ELSE /* st->last_L_frame == L_FRAME16k */ { - /* (float)12800/(float)16000; */ - k = 26214; // Q15 + tmpF_fx = 26214; // Q15 move16(); } FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ ) { - st_fx->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q(15+15+1-16) + st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16 move32(); } FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ ) { - st_fx->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ); // Q15 + st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16 move32(); } } ELSE { - - IF( EQ_16( st_fx->last_L_frame, L_FRAME32k ) ) + exp = 0; + move16(); + IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) { - /* (float)16000/(float)32000; */ - k = -16384; // -0.5 in Q15 + tmpF_fx = 16384; // Q15 move16(); } - ELSE IF( EQ_16( st_fx->last_L_frame, 512 ) ) + ELSE IF( EQ_16( st->last_L_frame, 512 ) ) { - /* tmpF = (float)16000/(float)25600; */ - k = -12288; //-0.375 in Q15 + tmpF_fx = 20480; // Q15 move16(); } ELSE /* st->last_L_frame == L_FRAME12k8 */ { - /* tmpF = (float)16000/(float)12800; */ - k = 8192; //.25 in Q15 + tmpF_fx = 20480; // Q14 + move16(); + exp = 1; move16(); } - FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- ) { - st_fx->old_pitch_buf_fx[i + 2] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15 + st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15 move32(); } - st_fx->old_pitch_buf_fx[NB_SUBFR + 1] = st_fx->old_pitch_buf_fx[NB_SUBFR + 2]; + st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2]; move32(); FOR( i = NB_SUBFR - 1; i >= 0; i-- ) { - st_fx->old_pitch_buf_fx[i + 1] = L_add( st_fx->old_pitch_buf_fx[i], Mpy_32_16_1( st_fx->old_pitch_buf_fx[i], k ) ); // Q15 + st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15 move32(); } - st_fx->old_pitch_buf_fx[0] = st_fx->old_pitch_buf_fx[1]; + st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1]; move32(); } } - IF( NE_16( st_fx->bfi_pitch_frame, st_fx->L_frame ) ) + IF( NE_16( st->bfi_pitch_frame, st->L_frame ) ) { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { - - IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) ) + IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) ) { - /* (float)12800/(float)32000; */ - k = 13107; // Q15 + tmpF_fx = 13107; // Q15 move16(); } - ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) ) + ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) ) { - /* (float)12800/(float)25600; */ - k = 16384; // Q15 + tmpF_fx = 16384; // Q15 move16(); } ELSE /* st->bfi_pitch_frame == L_FRAME16k */ { - /* (float)12800/(float)16000; */ - k = 26214; // Q15 + tmpF_fx = 26214; // Q15 move16(); } - st_fx->bfi_pitch_fx = mult_r( k, st_fx->bfi_pitch_fx ); + st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx ); move16(); - st_fx->bfi_pitch_frame = L_FRAME; + st->bfi_pitch_frame = L_FRAME; move16(); } ELSE { - - IF( EQ_16( st_fx->bfi_pitch_frame, L_FRAME32k ) ) + exp = 0; + move16(); + IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) ) { - /* (float)16000/(float)32000; */ - k = -16384; //-0.5 in Q15 + tmpF_fx = 16384; // Q15 move16(); } - ELSE IF( EQ_16( st_fx->bfi_pitch_frame, 512 ) ) + ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) ) { - /* tmpF = (float)16000/(float)25600; */ - k = -12288; // -0.375 in Q15 + tmpF_fx = 20480; // Q15 move16(); } ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */ { - /* tmpF = (float)16000/(float)12800; */ - k = 8192; // .25 in Q15 + tmpF_fx = 20480; // Q14 + move16(); + exp = 1; move16(); } - st_fx->bfi_pitch_fx = add( st_fx->bfi_pitch_fx, mult_r( st_fx->bfi_pitch_fx, k ) ); + + st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx ); move16(); - st_fx->bfi_pitch_frame = L_FRAME16k; + st->bfi_pitch_frame = L_FRAME16k; move16(); } } test(); test(); - if ( EQ_16( st_fx->last_bwidth, NB ) && NE_16( st_fx->bwidth, NB ) && st_fx->ini_frame != 0 ) + if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) ) { - st_fx->rate_switching_reset = 1; + st->rate_switching_reset = 1; move16(); } @@ -510,36 +594,35 @@ ivas_error acelp_core_dec_fx( * GOOD frame *----------------------------------------------------------------------*/ - IF( !st_fx->bfi ) + IF( !st->bfi ) { /*----------------------------------------------------------------* * Decoding of TC subframe classification *----------------------------------------------------------------*/ - tc_subfr_fx = -1; + tc_subfr = -1; move16(); - IF( EQ_16( st_fx->coder_type, TRANSITION ) ) + IF( EQ_16( st->coder_type, TRANSITION ) ) { - tc_subfr_fx = tc_classif_fx( st_fx, st_fx->L_frame ); + tc_subfr = tc_classif_fx( st, st->L_frame ); } /*----------------------------------------------------------------* * Decoding of GSC IVAS mode *----------------------------------------------------------------*/ - st_fx->GSC_IVAS_mode = 0; - move16(); + test(); test(); test(); test(); - IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 && !( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode ) + IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode ) { test(); test(); - IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->total_brate, MAX_GSC_INACTIVE_BRATE ) ) ) + IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) ) { - st_fx->GSC_IVAS_mode = get_next_indice( st_fx, 2 ); + st->GSC_IVAS_mode = get_next_indice_fx( st, 2 ); move16(); } } @@ -547,88 +630,215 @@ ivas_error acelp_core_dec_fx( /*----------------------------------------------------------------* * Decoding of inactive CNG frames *----------------------------------------------------------------*/ + test(); - IF( st_fx->core_brate == FRAME_NO_DATA || EQ_32( st_fx->core_brate, SID_2k40 ) ) + IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { /* decode CNG parameters */ - IF( st_fx->cng_type == LP_CNG ) + IF( st->cng_type == LP_CNG ) { - - CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step_fx, sid_bw, q_env ); + CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); + Copy( Aq_fx, st->Aq_cng, add( M, 1 ) ); /* comfort noise generation */ - CNG_exc_fx( st_fx->core_brate, st_fx->L_frame, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, - &st_fx->first_CNG, &( st_fx->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step_fx, &st_fx->hTdCngDec->last_allow_cn_step, st_fx->prev_Q_exc, st_fx->Q_exc, st_fx->hTdCngDec->num_ho, - q_env, st_fx->hTdCngDec->lp_env_fx, st_fx->hTdCngDec->old_env_fx, st_fx->hTdCngDec->exc_mem_fx, st_fx->hTdCngDec->exc_mem1_fx, sid_bw, &st_fx->hTdCngDec->cng_ener_seed1, exc3_fx, st_fx->Opt_AMR_WB, st_fx->element_mode ); + local_element_mode = st->element_mode; + move16(); - Copy( Aq_fx, st_fx->Aq_cng, M + 1 ); // Q12 + test(); + test(); + if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) ) + { + local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ + move16(); + } + CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode ); } ELSE { test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); + } + ELSE { - FdCng_decodeSID_fx( st_fx->hFdCngDec->hFdCngCom, st_fx ); + Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; + move16(); + + FdCng_decodeSID_ivas_fx( st ); + + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx + } + *sid_bw = 0; move16(); } - generate_comfort_noise_dec_fx( NULL, NULL, NULL, st_fx, &( st_fx->Q_exc ), 2, -1 ); + IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) + { + assert( nchan_out == 1 ); + + FOR( i = 0; i < NPART; i++ ) + { + st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), + STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); + move32(); + } + + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + + Word16 new_sidNoiseEstExp = 31 - Q4; + move16(); + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp) + Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp) + st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp; + move16(); + Word16 new_cngNoiseLevelExp = 31 - Q4; + move16(); + Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp) + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp; + move16(); + + test(); + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) ); + + IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) + { + Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp) + st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; + move16(); + } + } + + IF( !read_sid_info ) + { + Word32 noise_lvl_highest_fx; + + noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1]; + move32(); + + FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) + { + st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx; + move32(); + } + } + + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 ); + } + ELSE + { + generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); + } - FdCng_exc( st_fx->hFdCngDec->hFdCngCom, &st_fx->CNG_mode, st_fx->L_frame, st_fx->lsp_old_fx, st_fx->first_CNG, st_fx->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); + FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); - Copy( exc2_fx, exc3_fx, st_fx->L_frame ); + Copy( exc2_fx, exc3_fx, st->L_frame ); } - delta_mem_scale = 3; + Word16 delta_mem_scale = 3; move16(); test(); - if ( LT_32( st_fx->lp_ener_fx, 40 ) && ( st_fx->cng_type == LP_CNG ) ) /* very low energy frames, less than 0.3125 */ + if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */ { delta_mem_scale = 0; move16(); } - i = st_fx->Q_exc; + i = st->Q_exc; move16(); - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, - st_fx->L_frame * HIBND_ACB_L_FAC, 0, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, 0, INACTIVE ); - Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, delta_mem_scale, - &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 0, 0, NULL ); - Copy_Scale_sig( exc2_fx, exc2_fx, st_fx->L_frame, sub( st_fx->Q_exc, i ) ); // Q_exc + + test(); + IF( st->hMusicPF && st->hGSCDec ) + { + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS? + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } + ELSE + { + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, + L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); + } + } + + IF( st->hPFstat != NULL ) + { + Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, + &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL ); + } + ELSE + { + Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, + &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL ); + } + + Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc /* update past excitation signals for LD music post-filter */ - IF( hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { - Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); + Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); + Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); + /* Update music post processing values */ /* Filter energies update */ + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FOR( i = 0; i < DCT_L_POST; i++ ) + { + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); + move16(); + } + } + ELSE + { FOR( i = 0; i < DCT_L_POST; i++ ) { - /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/ - hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); + st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 move16(); } } + } + /* synthesis at 12.8kHz sampling rate */ - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc3_fx, syn1_fx, st_fx->mem_syn3_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); + move16(); + syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); + syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); /* reset the decoder */ - CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors ); + CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { /* update st_fx->mem_syn1 for ACELP core switching */ - Copy( st_fx->mem_syn3_fx, st_fx->mem_syn1_fx, M ); + Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); + } + ELSE + { + st->Q_syn_cng = st->Q_syn; + move16(); + st->Q_exc_cng = st->Q_exc; + move16(); - /* update old synthesis for classification */ - Copy( syn1_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); + /* update st->mem_syn1 for ACELP core switching */ + Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) + } + /* update old synthesis for classification */ + Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /* save and delay synthesis to be used by SWB BWE */ - Copy_Scale_sig( syn1_fx, temp_buf_fx, st_fx->L_frame, sub( -1, st_fx->Q_syn ) ); // Q_syn -> Q(-1) - IF( hBWE_FD != NULL ) + Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1) + IF( st->hBWE_FD != NULL ) { - save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); + save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } } @@ -638,21 +848,24 @@ ivas_error acelp_core_dec_fx( ELSE { + /*-----------------------------------------------------------------* * Configure ACELP bit allocation *-----------------------------------------------------------------*/ + nb_bits = 0; - st_fx->acelp_cfg.FEC_mode = 0; - uc_two_stage_flag = 0; move16(); + st->acelp_cfg.FEC_mode = 0; move16(); + uc_two_stage_flag = 0; move16(); + test(); - IF( !st_fx->nelp_mode_dec && !st_fx->ppp_mode_dec ) + IF( !st->nelp_mode_dec && !st->ppp_mode_dec ) { Word16 tc_subfr_tmp; - tc_subfr_tmp = tc_subfr_fx; + tc_subfr_tmp = tc_subfr; move16(); if ( LT_16( tc_subfr_tmp, L_SUBFR ) ) { @@ -660,19 +873,19 @@ ivas_error acelp_core_dec_fx( move16(); } - if ( EQ_16( tc_subfr_fx, TC_0_192 ) ) + if ( EQ_16( tc_subfr, TC_0_192 ) ) { nb_bits = -1; move16(); } - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); test(); test(); - IF( EQ_16( st_fx->coder_type, TRANSITION ) && LT_16( tc_subfr_fx, L_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) ) { - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, TRANSITION, -1, tc_subfr_fx, 2, &nb_bits, unbits, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } } @@ -682,51 +895,126 @@ ivas_error acelp_core_dec_fx( test(); test(); - IF( st_fx->hTdCngDec != NULL && ( st_fx->last_core_brate == FRAME_NO_DATA || EQ_32( st_fx->last_core_brate, SID_2k40 ) ) ) + IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) ) { - Copy( st_fx->lspCNG_fx, st_fx->lsp_old_fx, M ); // Q15 - - lsp2lsf_fx( st_fx->lspCNG_fx, st_fx->lsf_old_fx, M, int_fs ); + Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/ + lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs ); } /*-----------------------------------------------------------------* * Reset higher ACELP pre-quantizer in case of switching *-----------------------------------------------------------------*/ - IF( !st_fx->use_acelp_preq ) + IF( !st->use_acelp_preq ) { - st_fx->mem_preemp_preQ_fx = 0; + st->mem_preemp_preQ_fx = 0; + move16(); + st->last_nq_preQ = 0; move16(); - st_fx->last_nq_preQ = 0; + st->last_code_preq = 0; move16(); } - st_fx->use_acelp_preq = 0; + st->use_acelp_preq = 0; move16(); /*-----------------------------------------------------------------* * LSF de-quantization and interpolation *-----------------------------------------------------------------*/ - lsf_dec_fx( st_fx, tc_subfr_fx, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, - tdm_lsfQ_PCh ); + IF( !tdm_lp_reuse_flag ) + { + lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx ); + } + ELSE + { + const Word16 *pt_interp_2_fx; + + IF( NE_16( st->active_cnt, 1 ) ) + { + Word16 beta_index; + + beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS ); + tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index ); + } + ELSE + { + Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M ); + Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M ); + } + + IF( st->rate_switching_reset ) + { + /* extrapolation in case of unstable LSF convert */ + Copy( lsp_new_fx, st->lsp_old_fx, M ); + Copy( lsf_new_fx, st->lsf_old_fx, M ); + } + + pt_interp_2_fx = interpol_frac_fx; + test(); + if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) ) + { + pt_interp_2_fx = interpol_frac2_fx; + } + + IF( EQ_16( st->active_cnt, 1 ) ) + { + Copy( lsp_new_fx, st->lsp_old_fx, M ); + lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core ); + } + + /* LSP interpolation and conversion of LSPs to A(z) */ + int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 ); + + /* Check LSF stability (distance between old LSFs and current LSFs) */ + st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); + move16(); + } + + test(); + IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) + { + /* Prepare ACB memory from last HQ frame */ + old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ); + tmpF_fx = *old_exc_s_fx; + st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ + move16(); + PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); + Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); + Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ + Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); + Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */ + } + + test(); + IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) + { + /* Prepare ACB memory of old_bwe_exc */ + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); + } + ELSE + { + lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC << 1, L_EXC_MEM_DEC ); + } + } /*-----------------------------------------------------------------* * FEC - first good frame after lost frame(s) (possibility to correct the ACB) *-----------------------------------------------------------------*/ - IF( st_fx->acelp_cfg.FEC_mode > 0 ) + IF( st->acelp_cfg.FEC_mode > 0 ) { last_pulse_pos = 0; move16(); /* decode the last glottal pulse position */ - T0_tmp = FEC_pos_dec_fx( st_fx, &last_pulse_pos, &enr_q_fx, nb_bits ); - + T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits ); test(); test(); - IF( NE_16( st_fx->last_core, HQ_CORE ) || ( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->last_con_tcx ) ) + IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) ) { test(); test(); @@ -734,16 +1022,13 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - test(); - IF( EQ_16( st_fx->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st_fx->prev_bfi, 1 ) ) + IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) ) { - st_fx->Q_exc = - FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st_fx->L_frame, st_fx->Q_exc ); - move16(); + FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc ); } - ELSE IF( ( EQ_16( st_fx->coder_type, GENERIC ) || EQ_16( st_fx->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st_fx->old_bfi_cnt, 1 ) && EQ_16( output_frame, L_FRAME16k ) && st_fx->hWIDec != NULL ) + ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL ) { - do_WI_fx = FEC_enhACB_fx( st_fx->L_frame, st_fx->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st_fx->bfi_pitch_fx ); + do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx ); } } } @@ -752,16 +1037,16 @@ ivas_error acelp_core_dec_fx( * In case of first frame after an erasure and transition from voiced to unvoiced or inactive * redo the LPC interpolation *------------------------------------------------------------*/ + test(); test(); test(); test(); test(); test(); - IF( st_fx->stab_fac_fx == 0 && st_fx->old_bfi_cnt > 0 && NE_16( st_fx->clas_dec, VOICED_CLAS ) && NE_16( st_fx->clas_dec, ONSET ) && - st_fx->relax_prev_lsf_interp == 0 && !( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && EQ_16( st_fx->idchan, 1 ) ) ) + IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) ) { - int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); + int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); } /*---------------------------------------------------------------* @@ -770,7 +1055,7 @@ ivas_error acelp_core_dec_fx( IF( nb_bits > 0 ) { - indice = get_next_indice( st_fx, nb_bits ); + indice = get_next_indice_fx( st, nb_bits ); Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag ); } @@ -780,79 +1065,113 @@ ivas_error acelp_core_dec_fx( test(); test(); - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) + IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ { - /* SC-VBR - NELP frames */ - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 - st_fx->Q_exc = 0; + IF( LE_16( st->coder_type, UNVOICED ) ) + { + tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx ); + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ + } + ELSE /* GENERIC */ + { + decod_gen_2sbfr_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); + + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ + } + } + } + ELSE IF( st->nelp_mode_dec ) + { + Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 + st->Q_exc = 0; move16(); - decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf ); - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type ); + /* SC-VBR - NELP frames */ + decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); + + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } - ELSE IF( EQ_16( st_fx->coder_type, UNVOICED ) ) + ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames */ - decod_unvoiced_fx( st_fx, Aq_fx, st_fx->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, gain_buf ); + decod_unvoiced_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); + + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } - ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) + ELSE IF( st->ppp_mode_dec ) { - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 - st_fx->Q_exc = 0; + Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 + st->Q_exc = 0; move16(); + /* SC-VBR - PPP frames */ - IF( NE_32( ( error = decod_ppp_fx( st_fx, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st_fx->bfi, gain_buf, voice_factors, bwe_exc_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) ) { return error; } - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type ); + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } - ELSE IF( EQ_16( st_fx->coder_type, TRANSITION ) ) + ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) { - decod_tran_fx( st_fx, st_fx->L_frame, tc_subfr_fx, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf ); + decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx ); } - ELSE IF( EQ_16( st_fx->coder_type, AUDIO ) || ( ( st_fx->coder_type == INACTIVE ) && LE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) ) ) + ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) ) { - decod_audio_fx( st_fx, dct_exc_tmp, Aq_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf ); - tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ + /* AUDIO and INACTIVE frames (coded by GSC technology) */ + decod_audio_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, + tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); + + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE { - IF( NE_32( ( error = decod_gen_voic_fx( st_fx, st_fx->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI_fx, pitch_buf_fx, voice_factors, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf /*, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf*/ ) ), IVAS_ERR_OK ) ) + /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ + IF( NE_32( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) ) { return error; } - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { - tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } } /* synthesis for ACELP core switching and SWB BWE */ - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); + syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); + /* save and delay synthesis to be used by SWB BWE */ - IF( hBWE_FD != NULL ) + IF( st->hBWE_FD != NULL ) { - save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); + save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } /*-----------------------------------------------------------------* * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ - Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); + Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); + /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames *------------------------------------------------------------*/ + test(); test(); test(); test(); - IF( !( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) && NE_16( st_fx->nelp_mode_dec, 1 ) && !( EQ_16( st_fx->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) + IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) { - stat_noise_uv_dec_fx( st_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag ); + Word16 temp_q_exc = st->Q_exc; + move16(); + stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag ); + IF( NE_16( temp_q_exc, st->Q_exc ) ) + { + scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM + st->L_frame, sub( st->Q_exc, temp_q_exc ) ); + } } /*------------------------------------------------------------* @@ -861,80 +1180,92 @@ ivas_error acelp_core_dec_fx( *------------------------------------------------------------*/ /* update past excitation signals for LD music post-filter */ - IF( hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { - Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - Copy( hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); + Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); + Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); + Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); } + test(); test(); test(); - test(); - IF( hMusicPF != NULL && ( ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->L_frame, L_FRAME ) ) ) ) + IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) ) { - - Word16 last_coder_type = st_fx->last_coder_type; + Word16 last_coder_type = st->last_coder_type; move16(); + test(); test(); test(); - if ( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st_fx->GSC_IVAS_mode, 1 ) && st_fx->GSC_noisy_speech == 0 ) ) + if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) ) { last_coder_type = AUDIO; move16(); } - /* Extrapolation of the last future part, windowing and high resolution DCT transform */ - qdct = 0; + + Word16 qdct = 0; move16(); -#ifdef _DIFF_FLOAT_FIX_ /* FLoat point using last_core which fits with the inner part of the function */ - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_core, st_fx->element_mode, pitch_buf_fx, - hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct ); -#else - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, hMusicPF->filt_lfE_fx, st_fx->last_coder_type, st_fx->element_mode, pitch_buf_fx, - hMusicPF->LDm_enh_lp_gbin_fx, st_fx->Q_exc, &qdct ); -#endif + + /* Extrapolation of the last future part, windowing and high resolution DCT transform */ + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx, + st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } + ELSE + { + Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); + } + /* LD music post-filter */ - LD_music_post_filter_fx( hMusicPF, dct_buffer_fx, dct_buffer_fx, st_fx->core_brate, - &hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); + LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ - Post_music_postP_fx( dct_buffer_fx, exc2_fx, st_fx->mem_syn2_fx, st_fx->mem_syn2_fx, Aq_fx, syn_fx, &st_fx->Q_exc, &st_fx->prev_Q_syn, - &st_fx->Q_syn, st_fx->mem_syn_clas_estim_fx, 0, &st_fx->mem_deemph_fx, hBPF->pst_old_syn_fx, - &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, temp_buf_fx, mem_tmp_fx ); + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS + { + Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ + } + + Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn, + &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, + &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx ); } ELSE { /* Core synthesis at 12.8kHz or 16kHz */ i = 1; move16(); - if ( st_fx->coder_type == INACTIVE ) + test(); + if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO ) { i = 0; move16(); } + /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */ - k = 0; + Word16 k = 0; move16(); test(); test(); - if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) ) + if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) { k = 1; move16(); } - Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, - hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, i, k, temp_buf_fx ); - Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn + Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, + st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx ); + + Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ + syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); - IF( hMusicPF != NULL ) + IF( st->hMusicPF != NULL ) { FOR( i = 0; i < DCT_L_POST; i++ ) { - /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/ - hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); move16(); } } @@ -944,43 +1275,35 @@ ivas_error acelp_core_dec_fx( * FEC - Estimate the classification information *------------------------------------------------------------*/ - FEC_clas_estim_fx( st_fx, st_fx->Opt_AMR_WB, st_fx->L_frame, &st_fx->clas_dec, st_fx->coder_type, pitch_buf_fx, - syn_fx, &st_fx->lp_ener_FER_fx, &st_fx->decision_hyst, - NULL, NULL, NULL, NULL, 0, NULL, st_fx->Q_syn, temp_buf_fx, - st_fx->mem_syn_clas_estim_fx, &st_fx->classifier_Q_mem_syn, - 0, 0, 0, st_fx->last_core_brate, st_fx->acelp_cfg.FEC_mode ); + FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, + NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); + /*------------------------------------------------------------* * FEC - Estimate pitch *------------------------------------------------------------*/ - FEC_pitch_estim_fx( st_fx->Opt_AMR_WB, st_fx->last_core, st_fx->L_frame, st_fx->clas_dec, st_fx->last_good, pitch_buf_fx, st_fx->old_pitch_buf_fx, - &st_fx->bfi_pitch_fx, &st_fx->bfi_pitch_frame, &st_fx->upd_cnt, st_fx->coder_type, st_fx->element_mode ); + FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx, + &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode ); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - k = 0; - move16(); - FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR ) - { - pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9) - move16(); - k = add( k, 1 ); - } + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, - &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); + FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, + &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); test(); test(); test(); test(); - IF( ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && LE_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) ) + /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ + IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { - frame_ener_fx( st_fx->L_frame, st_fx->clas_dec, syn_fx, pitch_buf_tmp[sub( shr( st_fx->L_frame, 6 ), 1 )], &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); } } @@ -989,206 +1312,188 @@ ivas_error acelp_core_dec_fx( /*----------------------------------------------------------------* * BAD frame *----------------------------------------------------------------*/ + ELSE { /* SC-VBR */ - if ( EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) + if ( EQ_16( st->last_nelp_mode_dec, 1 ) ) { - st_fx->nelp_mode_dec = 1; + st->nelp_mode_dec = 1; move16(); } - /* long burst frame erasures */ test(); test(); - if ( GT_16( st_fx->nbLostCmpt, 5 ) && GE_16( st_fx->clas_dec, VOICED_CLAS ) && LT_16( st_fx->clas_dec, INACTIVE_CLAS ) ) + /* long burst frame erasures */ + if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) ) { - st_fx->last_good = VOICED_TRANSITION; + st->last_good = VOICED_TRANSITION; move16(); } /* LSF estimation and A(z) calculation */ - lsf_dec_bfi( MODE1, lsf_new_fx, st_fx->lsf_old_fx, st_fx->lsf_adaptive_mean_fx, NULL, st_fx->mem_MA_fx, st_fx->mem_AR_fx, - st_fx->stab_fac_fx, st_fx->last_coder_type, st_fx->L_frame, st_fx->last_good, - st_fx->nbLostCmpt, 0, NULL, NULL, NULL, st_fx->hGSCDec->Last_GSC_pit_band_idx, st_fx->Opt_AMR_WB, 0, st_fx->bwidth ); + lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth ); - FEC_lsf2lsp_interp( st_fx, st_fx->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx ); - - IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) + FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx ); + IF( EQ_16( st->nelp_mode_dec, 1 ) ) { /* SC-VBR */ - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st_fx->Q_exc ) ); // Q0 - st_fx->Q_exc = 0; + Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 + st->Q_exc = 0; move16(); - decod_nelp_fx( st_fx, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors, bwe_exc_fx, &st_fx->Q_exc, st_fx->bfi, gain_buf ); + decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); FEC_pitch_fx = pitch_buf_fx[3]; move16(); - - Rescale_exc( hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st_fx->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, L_FRAME, st_fx->coder_type ); + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); } ELSE { /* calculation of excitation signal */ + FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx ); - FEC_exc_estim_fx( st_fx, st_fx->L_frame, exc_fx, exc2_fx, dct_exc_tmp, pitch_buf_fx, voice_factors, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st_fx->Q_exc, &tmp_noise_fx ); - - Rescale_exc( NULL, exc_fx, bwe_exc_fx, st_fx->hGSCDec->last_exc_dct_in_fx, st_fx->L_frame, L_FRAME32k, (Word32) 0, - &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, st_fx->L_frame, st_fx->last_coder_type ); + Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0, + &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type ); - tmp_noise_fx = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/ + tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ /* SC-VBR */ - st_fx->prev_gain_pit_dec_fx = st_fx->lp_gainp_fx; - move16(); /*Q14*/ + st->prev_gain_pit_dec_fx = st->lp_gainp_fx; + move16(); } /* synthesis for ACELP core switching and SWB BWE */ - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc_fx, temp_buf_fx, st_fx->mem_syn1_fx, 1, st_fx->Q_exc, -1 ); /*old_syn_12k8_16k directly in q-1*/ + syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); /* save and delay synthesis to be used by SWB BWE */ - IF( hBWE_FD != NULL ) + IF( st->hBWE_FD != NULL ) { - save_old_syn_fx( st_fx->L_frame, temp_buf_fx, old_syn_12k8_16k, hBWE_FD->old_syn_12k8_16k_fx, st_fx->preemph_fac, &hBWE_FD->mem_deemph_old_syn_fx ); + save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); } + /* Apply energy matching when switching to inactive frames */ - Inac_swtch_ematch_fx( exc2_fx, dct_exc_tmp, st_fx->hGSCDec->lt_ener_per_band_fx, st_fx->coder_type, st_fx->L_frame, st_fx->core_brate, st_fx->Q_exc, st_fx->bfi, st_fx->last_core, st_fx->last_codec_mode ); + Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); - /* udate past excitation signals for LD music post-filter */ - IF( hMusicPF != NULL ) + /* update past excitation signals for LD music post-filter */ + IF( st->hMusicPF != NULL ) { - Copy( hMusicPF->dct_post_old_exc_fx + L_FRAME, hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); + Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); + Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); + /* Update music post processing values */ /* Filter energies update */ FOR( i = 0; i < DCT_L_POST; i++ ) { - /*st_fx->filt_lfE_fx[i] = 0.3f + 0.7f * st_fx->filt_lfE_fx[i];*/ - hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, hMusicPF->filt_lfE_fx[i] ) ); + st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) ); move16(); } + /* Update circular buffer, keep last energy difference unchanged */ FOR( i = 1; i < MAX_LT; i++ ) { - hMusicPF->LDm_lt_diff_etot_fx[i - 1] = hMusicPF->LDm_lt_diff_etot_fx[i]; + st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i]; move16(); } } + /* synthesis at 12k8 Hz sampling rate */ /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */ - k = 0; + Word16 k = 0; move16(); test(); test(); - if ( ( st_fx->coder_type == INACTIVE ) && st_fx->flag_cna && GE_16( round_fx( L_shl( st_fx->lp_noise, 1 ) ), 15 << 7 ) ) + if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) { k = 1; move16(); } - Rescale_mem( st_fx->Q_exc, &st_fx->prev_Q_syn, &st_fx->Q_syn, st_fx->mem_syn2_fx, st_fx->mem_syn_clas_estim_fx, 4, &st_fx->mem_deemph_fx, - hBPF->pst_old_syn_fx, &hBPF->pst_mem_deemp_err_fx, &st_fx->agc_mem_fx[1], st_fx->hPFstat, 1, k, temp_buf_fx ); + Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, + st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx ); test(); - IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) ) + IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) { - Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); // Q_syn + Copy( st->mem_syn2_fx, mem_tmp_fx, M ); } - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_fx, st_fx->mem_syn2_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); + syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); /* update buffer for classifier */ - IF( st_fx->hWIDec != NULL ) + IF( st->hWIDec != NULL ) { - Copy( exc2_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_exc2_fx, L_EXC_MEM ); - Copy( syn_fx + st_fx->L_frame - L_EXC_MEM, st_fx->hWIDec->old_syn2_fx, L_EXC_MEM ); + Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM ); + Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM ); } - st_fx->prev_Q_exc_fr = st_fx->Q_exc; - move16(); - st_fx->prev_Q_syn_fr = st_fx->Q_syn; - move16(); - - Copy( syn_fx + st_fx->L_frame - L_SYN_MEM_CLAS_ESTIM, st_fx->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); - - test(); - IF( ( EQ_32( st_fx->total_brate, ACELP_7k20 ) ) || ( EQ_32( st_fx->total_brate, ACELP_8k00 ) ) ) - { - k = 0; + st->prev_Q_exc_fr = st->Q_exc; move16(); - FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR ) - { - pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9) + st->prev_Q_syn_fr = st->Q_syn; move16(); - k = add( k, 1 ); - } + Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); /*------------------------------------------------------------* * FEC - Smooth the speech energy evolution when recovering after a BAD frame * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ - FEC_scale_syn_fx( st_fx->L_frame, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, enr_q_fx, st_fx->coder_type, LSF_Q_prediction, - &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); + test(); + IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) + { + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 + + FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, + &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - /* fer_energy( st_fx->L_frame, st_fx->last_good, syn_fx, FEC_pitch_fx, &st_fx->enr_old_fx, st_fx->L_frame ); */ - frame_ener_fx( st_fx->L_frame, st_fx->last_good, syn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st_fx->enr_old_fx, st_fx->L_frame, st_fx->Q_syn, 3, 0 ); + frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); - IF( st_fx->nelp_mode_dec != 1 ) + IF( NE_16( st->nelp_mode_dec, 1 ) ) { /* modify the excitation signal of stationary unvoiced frames */ - stat_noise_uv_mod_fx( st_fx->coder_type, 0, st_fx->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st_fx->Q_exc, 1, &st_fx->ge_sm_fx, - &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, - &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, + &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, + &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); + } } - /* SC-VBR */ - st_fx->hSC_VBR->FadeScale_fx = mult( st_fx->hSC_VBR->FadeScale_fx, 24576 ); /*24576 in Q15*/ - move16(); - } - IF( hBWE_TD != NULL ) + IF( st->hBWE_TD != NULL ) { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { - Copy( Aq_fx + 2 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12 + Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); } ELSE { - Copy( Aq_fx + 3 * ( M + 1 ), hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); // Q12 + Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); } } + /*--------------------------------------------------------* * Apply NB postfilter in case of 8kHz output *--------------------------------------------------------*/ + test(); - IF( EQ_16( st_fx->last_bwidth, NB ) && st_fx->hPFstat != NULL ) + IF( st->last_bwidth == NB && st->hPFstat != NULL ) { - k = 0; - move16(); - FOR( i = 0; i < st_fx->L_frame; i += L_SUBFR ) - { - pitch_buf_tmp[k] = mult_r( pitch_buf_fx[k], 512 ); // Q0(6+9-15) , (512 = 1.0f in Q9) - move16(); - k = add( k, 1 ); - } + Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - IF( EQ_16( st_fx->bwidth, NB ) ) + IF( st->bwidth == NB ) { - st_fx->hPFstat->on = 1; + st->hPFstat->on = 1; move16(); - nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, st_fx->coder_type, st_fx->BER_detect, 0 ); + nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 ); } ELSE { - st_fx->hPFstat->on = 0; + st->hPFstat->on = 0; move16(); - nb_post_filt_fx( st_fx->L_frame, st_fx->hPFstat, &st_fx->psf_lp_noise_fx, tmp_noise_fx, syn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st_fx->BER_detect, 0 ); + nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 ); } } ELSE { - st_fx->psf_lp_noise_fx = round_fx( L_shl( st_fx->lp_noise, 1 ) ); + st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); move16(); } @@ -1196,137 +1501,255 @@ ivas_error acelp_core_dec_fx( * Perform fixed deemphasis through 1/(1 - g*z^-1) *-----------------------------------------------------------------*/ - /* Update old synthesis buffer - needed for ACELP internal sampling rate switching */ - Copy( syn_fx + st_fx->L_frame - L_SYN_MEM, st_fx->mem_syn_r, L_SYN_MEM ); - deemph_fx( syn_fx, st_fx->preemph_fac, st_fx->L_frame, &( st_fx->mem_deemph_fx ) ); - unscale_AGC( syn_fx, st_fx->Q_syn, syn_fx_tmp2, st_fx->agc_mem_fx, st_fx->L_frame ); - Copy( syn_fx_tmp2, syn_fx, st_fx->L_frame ); - - /* Update MODE2 memories*/ - IF( hTcxDec != NULL ) + /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ + Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); + deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) ); + unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame ); + Copy( syn_fx_tmp2, psyn_fx, st->L_frame ); + IF( st->hTcxDec != NULL ) { - Copy_Scale_sig( syn_fx + shr( st_fx->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st_fx->L_frame, 1 ), sub( -1, st_fx->Q_syn ) ); /*Q-1*/ + Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ + st->hTcxDec->Q_old_syn_Overl = -1; } - Copy_Scale_sig( syn_fx + st_fx->L_frame - M - 1, st_fx->syn, M + 1, sub( 0, st_fx->Q_syn ) ); /*Q0*/ + Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ /*------------------------------------------------------------------* * Formant post-filter *-----------------------------------------------------------------*/ - IF( st_fx->hPFstat != NULL ) - { test(); test(); test(); - IF( GE_16( st_fx->last_bwidth, WB ) && ( GT_32( st_fx->core_brate, ACELP_24k40 ) || ( st_fx->element_mode > EVS_MONO ) ) && LE_32( st_fx->core_brate, ACELP_32k ) ) + test(); + IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) ) { - Copy( syn_fx, temp_buf + L_SYN_MEM, L_FRAME16k ); - st_fx->hPFstat->on = 1; + st->hPFstat->on = 1; move16(); - formant_post_filt_fx( st_fx->hPFstat, temp_buf + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME16k, st_fx->lp_noise, st_fx->total_brate, 0 ); + Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); + set16_fx( st->hPFstat->mem_zero, 0, M ); + + formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); } - ELSE IF( GE_16( st_fx->last_bwidth, WB ) ) + ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) ) { - IF( st_fx->hPFstat->on ) + IF( st->hPFstat->on ) { - Copy( st_fx->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf, M ); - Copy( syn_fx, temp_buf + M, L_SUBFR ); - Residu3_fx( Aq_fx, temp_buf + M, temp_buf + M + L_SUBFR, L_SUBFR, 1 ); - E_UTIL_synthesis( 1, Aq_fx, temp_buf + M + L_SUBFR, temp_buf, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); - scale_st_fx( syn_fx, temp_buf, &st_fx->hPFstat->gain_prec, L_SUBFR ); - Copy( temp_buf, syn_fx, L_SUBFR / 2 ); - blend_subfr2_fx( temp_buf + L_SUBFR / 2, syn_fx + L_SUBFR / 2, syn_fx + L_SUBFR / 2 ); + Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M ); + Copy( psyn_fx, temp_buf_fx + M, L_SUBFR ); + + Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 ); + E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); + scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); + Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) ); + blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 ); } - st_fx->hPFstat->on = 0; + st->hPFstat->on = 0; move16(); } - } + /*----------------------------------------------------------------* * Comfort noise addition *----------------------------------------------------------------*/ test(); test(); - IF( ( st_fx->hFdCngDec != NULL || EQ_16( st_fx->idchan, 1 ) ) && NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { test(); test(); test(); test(); test(); - IF( EQ_16( st_fx->element_mode, IVAS_CPE_TD ) || st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || ( ( st_fx->cng_type == LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) ) + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) { /*VAD only for non inactive frame*/ test(); - st_fx->VAD = st_fx->VAD && ( st_fx->coder_type != INACTIVE ); + st->VAD = st->VAD && st->coder_type != INACTIVE; move16(); test(); test(); test(); test(); test(); - IF( st_fx->idchan == 0 && ( st_fx->flag_cna || ( EQ_16( st_fx->cng_type, FD_CNG ) && LE_32( st_fx->total_brate, ACELP_32k ) ) || - ( EQ_16( st_fx->cng_type, LP_CNG ) && LE_32( st_fx->total_brate, SID_2k40 ) ) ) ) + IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) ) { /*Noisy speech detector*/ - noisy_speech_detection_fx( st_fx->hFdCngDec, st_fx->VAD, syn_fx, st_fx->Q_syn ); + noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn ); - st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); + st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); move16(); - IF( st_fx->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) + IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) { - st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st_fx->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); + st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); move16(); } + move32(); } - if ( st_fx->idchan == 0 ) + + if ( st->idchan == 0 ) { - st_fx->lp_noise = st_fx->hFdCngDec->lp_noise; + st->lp_noise = st->hFdCngDec->lp_noise; move32(); } - /*Noise estimate*/ - IF( NE_16( st_fx->element_mode, IVAS_CPE_TD ) /* && !st->cng_ism_flag IVAS_CODE */ ) + + test(); + IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag ) { - ApplyFdCng_fx( syn_fx, st_fx->Q_syn, realBuffer, imagBuffer, NULL, st_fx, 0, ( EQ_16( st_fx->coder_type, AUDIO ) && st_fx->GSC_noisy_speech == 0 ) ); - } - /* CNA: Generate additional comfort noise to mask potential coding artefacts */ + /* Noise estimate */ + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } + IF( !st->cna_dirac_flag ) + { + test(); + test(); test(); test(); test(); test(); - IF( st_fx->flag_cna && NE_16( st_fx->coder_type, AUDIO ) ) + test(); + test(); + test(); + /* CNA: Generate additional comfort noise to mask potential coding artefacts */ + IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) + { + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) + { + IF( hStereoCng->flag_cna_fade ) { - generate_masking_noise_fx( syn_fx, st_fx->Q_syn, st_fx->hFdCngDec->hFdCngCom, st_fx->hFdCngDec->hFdCngCom->frameSize, 0 ); + generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); + hStereoCng->flag_cna_fade = 0; + move16(); } - ELSE IF( st_fx->flag_cna && EQ_16( st_fx->coder_type, AUDIO ) && st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) + ELSE + { + test(); + IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) ) { - FOR( i = 0; i < st_fx->hFdCngDec->hFdCngCom->frameSize / 2; i++ ) + /* Clear memory for secondary channel CNA */ + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) ); + } + + generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); + } + } + ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { - syn_fx[i] = add( syn_fx[i], shr_r( mult_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->hFdCngDec->hFdCngCom->frameSize / 4], st_fx->hFdCngDec->hFdCngCom->fftlenFac ), -st_fx->Q_syn ) ); + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); + } + ELSE + { + IF( st->idchan == 0 ) + { + IF( NE_16( st->element_mode, last_element_mode ) ) + { + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + } + + Word32 psyn_32_fx[L_FRAME16k]; + Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 + Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 + + generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); + + Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn + Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 + } + } + } + } + ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) + { + test(); + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) + { + generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); + hStereoCng->flag_cna_fade = 1; + move16(); + } + ELSE + { + FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) ); + move16(); + } + } + } + ELSE + { + IF( hStereoCng != NULL ) + { + hStereoCng->flag_cna_fade = 1; + move16(); + hStereoCng->enableSecCNA = 0; move16(); } } + IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) + { + test(); + test(); + test(); + /*Noise estimate*/ + IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) ) + { + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + } + } + } + } + + IF( !st->cna_dirac_flag ) + { + test(); test(); test(); test(); test(); test(); - IF( st_fx->flag_cna == 0 && EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( st_fx->last_flag_cna, 1 ) && ( ( st_fx->last_core == ACELP_CORE && NE_16( st_fx->last_coder_type, AUDIO ) ) || EQ_16( st_fx->last_core, AMR_WB_CORE ) ) ) + test(); + IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) + { + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + // VE: TBV - is it correct in EVS? in FLP, it is: + // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); + // v_add( temp_buf, syn, syn, st->L_frame / 2 ); + FOR( i = 0; i < st->L_frame / 2; i++ ) + { + psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) ); + move16(); + } + } + ELSE { - FOR( i = 0; i < st_fx->L_frame / 2; i++ ) + FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) { - syn_fx[i] = add( syn_fx[i], shr_r( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st_fx->L_frame / 4], negate( st_fx->Q_syn ) ) ); + psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); move16(); } } + } test(); - IF( st_fx->flag_cna == 0 || EQ_16( st_fx->coder_type, AUDIO ) ) + test(); + test(); + IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) + { + IF( st->idchan == 0 ) + { + set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); + } + IF( hStereoCng != NULL && ( st->idchan == 0 ) ) { - set16_fx( st_fx->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st_fx->hFdCngDec->hFdCngCom->fftlen ); + set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); + } + } } } @@ -1335,45 +1758,44 @@ ivas_error acelp_core_dec_fx( * Bass post-filter *----------------------------------------------------------------*/ + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + CLDFB_SCALE_FACTOR scaleFactor; + Word32 workBuffer[128 * 3]; + /* check if the CLDFB works on the right sample rate */ - IF( ( st_fx->cldfbAna->usb * st_fx->cldfbAna->no_col ) != st_fx->L_frame ) + IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) { /* resample to ACELP internal sampling rate */ - Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st_fx->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb( st_fx->cldfbAna, newCldfbBands, st_fx->L_frame, 0 ); - resampleCldfb( st_fx->cldfbBPF, newCldfbBands, st_fx->L_frame, 0 ); + Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); + resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); - IF( st_fx->ini_frame > 0 ) + IF( st->ini_frame > 0 ) { - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); } } test(); - IF( !( EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->bpf_off ) ) + IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) { - test(); - IF( NE_16( st_fx->L_frame, st_fx->last_L_frame ) && NE_16( st_fx->last_codec_mode, MODE2 ) ) + IF( EQ_16( st->L_frame, L_FRAME ) ) { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - retro_interp5_4_fx( hBPF->pst_old_syn_fx ); + retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); } - ELSE IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) { - retro_interp4_5_fx( syn_fx, hBPF->pst_old_syn_fx ); + retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); } } - bass_psfilter_fx( st_fx->hBPF, st_fx->Opt_AMR_WB, syn_fx, st_fx->L_frame, pitch_buf_fx, st_fx->bpf_off, - st_fx->stab_fac_fx, &st_fx->stab_fac_smooth_fx, st_fx->coder_type, st_fx->Q_syn, bpf_error_signal ); - } - test(); - IF( NE_16( st_fx->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) - { + bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, + st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); + /* analysis of the synthesis at internal sampling rate */ - cldfbAnalysis_fx( st_fx->cldfbAna, realBuffer, imagBuffer, &scaleFactor, syn_fx, negate( st_fx->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); + cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); scaleFactor.hb_scale = scaleFactor.lb_scale; move16(); @@ -1381,25 +1803,26 @@ ivas_error acelp_core_dec_fx( /* analysis and add the BPF error signal */ i = 0; move16(); - if ( st_fx->bpf_off == 0 ) + if ( st->bpf_off == 0 ) { i = CLDFB_NO_COL_MAX; move16(); } - addBassPostFilter_fx( bpf_error_signal, realBuffer, imagBuffer, st_fx->cldfbBPF, workBuffer, negate( st_fx->Q_syn ), - i, st_fx->cldfbAna->no_col, st_fx->cldfbAna->no_channels, &scaleFactor ); + + addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ), + i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor ); /* set output mask for upsampling */ - IF( EQ_16( st_fx->bwidth, NB ) ) + IF( EQ_16( st->bwidth, NB ) ) { /* set NB mask for upsampling */ - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, 10 ); + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); move16(); } - ELSE IF( NE_16( st_fx->cldfbSyn->bandsToZero, sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ) ) ) + ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) { /* in case of BW switching, re-init to default */ - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->cldfbAna->no_channels ); + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); } @@ -1407,47 +1830,447 @@ ivas_error acelp_core_dec_fx( scaleFactor.hb_scale = scaleFactor.lb_scale; move16(); + test(); + test(); + test(); + IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + { + generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st ); + + st->cldfbSyn->bandsToZero = 0; + move16(); + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); + move16(); + } + st->cldfbSyn->lsb = st->cldfbAna->no_channels; + move16(); + } + + /* synthesis of the combined signal */ + st->Q_syn2 = st->Q_syn; + move16(); + cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); + + /* Bring CLDFB output to Q0 */ + Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) ); + st->Q_syn2 = 0; + move16(); + + /* save synthesis - needed in case of core switching */ + Copy( synth_fx16, st->previoussynth_fx, output_frame ); + } + ELSE + { + /* check if the CLDFB works on the right sample rate */ + IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) + { + resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); + + IF( st->ini_frame > 0 ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } + } + + /* analyze pitch coherence for bass post-filter */ + Word32 pitch_buf_fx_q20[12]; + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) + Word16 lim = shr( st->L_frame, 6 ); + FOR( Word16 lp = 0; lp < lim; lp++ ) + { + pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); + move32(); + } + bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); + Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx + + test(); + IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) + { + test(); + IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) + { + IF( EQ_16( st->L_frame, L_FRAME ) ) + { + retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); + } + ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) + { + retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); + } + } + + bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, + st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); + } + + Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; + set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); + syn_32_fx = syn_tmp_32_fx + L_SUBFR; + test(); + IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) + { + /* analysis of the synthesis at internal sampling rate */ + Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + pRealSave_fx[i] = realBufferSave_fx[i]; + pImagSave_fx[i] = imagBufferSave_fx[i]; + } + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } + + FOR( i = 0; i < st->L_frame; i++ ) + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 + move32(); + } + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; + move16(); + + cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); + + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; + move16(); + /* analysis and add the BPF error signal */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + q_bpf_error_signal = Q6; + move16(); + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + } + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; + move16(); + tmp = -1; + move16(); + if ( st->bpf_off ) + { + tmp = 0; + move16(); + } + + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; + move16(); + /* set output mask for upsampling */ + IF( EQ_16( st->bwidth, NB ) ) + { + /* set NB mask for upsampling */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); + move16(); + } + ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) + { + /* in case of BW switching, re-init to default */ + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); + move16(); + } test(); - IF( !st_fx->cng_sba_flag || EQ_16( st_fx->element_mode, IVAS_CPE_MDCT ) ) + IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { test(); test(); test(); - IF( ( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) && ( EQ_16( st_fx->cng_type, FD_CNG ) ) && ( LT_16( st_fx->hFdCngDec->hFdCngCom->numCoreBands, st_fx->cldfbSyn->no_channels ) ) ) + /*WB/SWB-FD_CNG*/ + IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) + { + Word16 tmpBufferScale = 0; + move16(); + generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); + + FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) { - generate_comfort_noise_dec_hf_fx( realBuffer, imagBuffer, &scaleFactor.hb_scale, st_fx ); + Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 + } - st_fx->cldfbSyn->bandsToZero = 0; + IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) + { + st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); move16(); - IF( LT_16( st_fx->hFdCngDec->hFdCngCom->regularStopBand, st_fx->cldfbSyn->no_channels ) ) + } + ELSE { - st_fx->cldfbSyn->bandsToZero = sub( st_fx->cldfbSyn->no_channels, st_fx->hFdCngDec->hFdCngCom->regularStopBand ); + st->cldfbSyn->bandsToZero = 0; move16(); } - st_fx->cldfbSyn->lsb = st_fx->cldfbAna->no_channels; + } + } + + IF( save_hb_synth_fx16 != NULL ) + { + /* save and then zero-out lowband */ + max_real = 0; + max_imag = 0; + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } +#ifndef OPT_AVOID_STATE_BUF_RESCALE +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) +#endif /* OPT_STEREO_32KBPS_V1 */ + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + realBufferSave_fx[i][j] = realBuffer_fx[i][j]; + imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; + move32(); + move32(); + IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) + { + realBuffer_fx[i][j] = 0; + imagBuffer_fx[i][j] = 0; + move32(); + move32(); + } + } + } + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE + Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + /* restore lowband */ + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + realBuffer_fx[i][j] = realBufferSave_fx[i][j]; + imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; + move32(); + move32(); } } +#ifndef OPT_AVOID_STATE_BUF_RESCALE + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 + st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); + move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); + Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSynHB->Q_cldfb_state = Q10; + move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + } + ELSE + { /* synthesis of the combined signal */ - st_fx->Q_syn2 = st_fx->Q_syn; + max_real = 0; + max_imag = 0; + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ + st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); + move16(); + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSyn->Q_cldfb_state = Q10; move16(); + } + + /* save synthesis - needed in case of core switching */ + Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 + } + ELSE { - cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate( st_fx->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); + Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ + + /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ + FOR( i = 0; i < st->L_frame; i++ ) + { + syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); + move32(); } - /* Bring CLDFB output to Q0 */ - Scale_sig( synth_out, output_frame, negate( st_fx->Q_syn2 ) ); - st_fx->Q_syn2 = 0; + + Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 + st->cldfbAna->Q_cldfb_state = Q12; + move16(); + + cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); + + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 + st->cldfbAna->Q_cldfb_state = Q11; + move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ + Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; + Word16 q_bpf_error_signal; + Word16 cldfb_state_offset; + cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); + + // Get Q-factor + q_bpf_error_signal = Q6; + move16(); + Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 + } + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) + st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; + move16(); + tmp = 0; + move16(); + if ( !st->bpf_off ) + { + tmp = nSamples; + move16(); + } + + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 + st->cldfbBPF->Q_cldfb_state = Q10; + move16(); + /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ + max_real = 0; + max_imag = 0; + move32(); + move32(); + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + { + max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); + max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); + } + } + max_val = L_max( max_real, max_imag ); + Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real + } +#ifndef OPT_AVOID_STATE_BUF_RESCALE +#ifdef OPT_STEREO_32KBPS_V1 + scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) +#else /* OPT_STEREO_32KBPS_V1 */ + scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) +#endif /* OPT_STEREO_32KBPS_V1 */ +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifdef OPT_AVOID_STATE_BUF_RESCALE + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); +#else /* OPT_AVOID_STATE_BUF_RESCALE */ + cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + +#ifndef OPT_AVOID_STATE_BUF_RESCALE + Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 + Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 + st->cldfbSyn->Q_cldfb_state = Q10; move16(); +#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 + Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - /* save synthesis - needed in case of core switching */ - Copy( synth_out, st_fx->previoussynth_fx, output_frame ); + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 + } + + set32_fx( synth_fx, 0, output_frame ); + } + + /* Copy output signal */ + Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 + IF( st->element_mode > EVS_MONO ) + { + Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ + } + + st->Q_syn2 = 0; + move16(); } /*-----------------------------------------------------------------* * Bandwidth extension 6kHz-7kHz *-----------------------------------------------------------------*/ - IF( st_fx->hBWE_zero != NULL ) + + IF( st->hBWE_zero != NULL ) { test(); test(); @@ -1456,14 +2279,27 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME ) && NE_16( st_fx->bwidth, NB ) && GE_16( output_frame, L_FRAME16k ) && - ( EQ_16( st_fx->extl, -1 ) || EQ_16( st_fx->extl, SWB_CNG ) || ( EQ_16( st_fx->extl, WB_BWE ) && st_fx->extl_brate == 0 && NE_16( st_fx->coder_type, AUDIO ) ) ) ) ) + IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && + ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { - hf_synth_fx( st_fx->hBWE_zero, st_fx->core_brate, output_frame, Aq_fx, exc2_fx, syn_fx, synth_out, st_fx->Q_exc, st_fx->Q_syn2 ); + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); + } + ELSE + { + Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); + Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); + } } ELSE { - hf_synth_reset_fx( st_fx->hBWE_zero ); + hf_synth_reset_fx( st->hBWE_zero ); + IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment + { + set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); + } } } @@ -1471,8 +2307,7 @@ ivas_error acelp_core_dec_fx( * Populate parameters for SWB TBE *-----------------------------------------------------------------*/ - /* Apply a non linearity to the SHB excitation */ - IF( hBWE_TD != NULL ) + IF( st->hBWE_TD != NULL ) { test(); test(); @@ -1486,11 +2321,11 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - IF( ( !st_fx->bfi && ( st_fx->prev_bfi ) ) || ( ( EQ_16( st_fx->last_vbr_hw_BWE_disable_dec, 1 ) ) && ( st_fx->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st_fx->extl, SWB_TBE ) || EQ_16( st_fx->extl, WB_TBE ) || EQ_16( st_fx->extl, FB_TBE ) ) && NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, WB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && !st_fx->tdm_LRTD_flag ) ) + IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) { - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); - set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); + set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); } test(); @@ -1498,42 +2333,70 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - IF( !st_fx->ppp_mode_dec && ( st_fx->idchan == 0 || NE_16( st_fx->element_mode, IVAS_CPE_TD ) || ( EQ_16( st_fx->idchan, 1 ) && EQ_16( st_fx->element_mode, IVAS_CPE_TD ) && st_fx->tdm_LRTD_flag ) ) ) + IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) + { + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + } + ELSE { - non_linearity_fx( bwe_exc_fx, bwe_exc_extended, L_FRAME32k, &hBWE_TD->bwe_non_lin_prev_scale_fx, st_fx->Q_exc, - st_fx->coder_type, voice_factors, st_fx->L_frame ); + Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc + } } test(); - IF( ( st_fx->core_brate == FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) + if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) { - hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move32(); } } + /*----------------------------------------------------------------------* * Updates *----------------------------------------------------------------------*/ - updt_dec_fx( st_fx, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors, old_bwe_exc_fx, gain_buf ); + updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); test(); test(); - IF( GT_32( st_fx->core_brate, SID_2k40 ) && st_fx->hTdCngDec != NULL && st_fx->hFdCngDec != NULL ) + IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ - cng_params_upd_fx( lsp_new_fx, exc_fx, st_fx->L_frame, &st_fx->hTdCngDec->ho_circ_ptr, st_fx->hTdCngDec->ho_ener_circ_fx, &st_fx->hTdCngDec->ho_circ_size, st_fx->hTdCngDec->ho_lsp_circ_fx, - st_fx->Q_exc, DEC, st_fx->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st_fx->last_active_brate ); + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, + st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); + } + ELSE + { + cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, + st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, + st->hFdCngDec->hFdCngCom->CngBandwidth ); + } + /* Set 16k LSP flag for CNG buffer */ - st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 0; + st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; move16(); - if ( NE_16( st_fx->L_frame, L_FRAME ) ) + if ( NE_16( st->L_frame, L_FRAME ) ) { - st_fx->hTdCngDec->ho_16k_lsp[st_fx->hTdCngDec->ho_circ_ptr] = 1; + st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1; move16(); } } - return IVAS_ERR_OK; + IF( NE_16( st->element_mode, EVS_MONO ) ) + { + IF( save_hb_synth_fx16 ) + { + Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 + } + Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 + } + + pop_wmops(); + return error; } -#endif diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index ad8ca9b50..2c72bba78 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -47,12 +47,12 @@ /*-------------------------------------------------------------------* - * acelp_core_dec_ivas_fx() + * acelp_core_dec_fx() * * ACELP core decoder *-------------------------------------------------------------------*/ -ivas_error acelp_core_dec_ivas_fx( +ivas_error acelp_core_dec_fx( Decoder_State *st, /* i/o: decoder state structure */ Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ Word16 synth_fx16[], /* o : synthesis Q_syn2*/ @@ -81,14 +81,14 @@ ivas_error acelp_core_dec_ivas_fx( Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ Word16 output_frame; /* frame length at output sampling freq. */ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ - Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ + Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ Word32 enr_q_fx; /* E information for FER protection */ Word16 tmp_noise_fx; /* Long term temporary noise energy */ - Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ + Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ Word16 FEC_pitch_fx; /* FEC pitch */ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ @@ -181,6 +181,7 @@ ivas_error acelp_core_dec_ivas_fx( st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e; move16(); } + FOR( i = 0; i < NPART; i++ ) { st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), @@ -188,14 +189,14 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } - ApplyFdCng_ivas_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); + ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); } ELSE { configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); /* decode CNG parameters */ - CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); + CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); /* comfort noise generation */ CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); @@ -636,7 +637,7 @@ ivas_error acelp_core_dec_ivas_fx( /* decode CNG parameters */ IF( st->cng_type == LP_CNG ) { - CNG_dec_ivas_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); + CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); Copy( Aq_fx, st->Aq_cng, add( M, 1 ) ); /* comfort noise generation */ @@ -657,13 +658,11 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); } ELSE -#endif { Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; move16(); @@ -689,7 +688,7 @@ ivas_error acelp_core_dec_ivas_fx( move32(); } - ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); Word16 new_sidNoiseEstExp = 31 - Q4; move16(); @@ -704,7 +703,7 @@ ivas_error acelp_core_dec_ivas_fx( move16(); test(); - ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) ); + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) ); IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) { @@ -728,13 +727,11 @@ ivas_error acelp_core_dec_ivas_fx( } } -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 ); } ELSE -#endif { generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); } @@ -758,7 +755,6 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( st->hMusicPF && st->hGSCDec ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS? @@ -766,7 +762,6 @@ ivas_error acelp_core_dec_ivas_fx( st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); } ELSE -#endif { Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); @@ -794,7 +789,6 @@ ivas_error acelp_core_dec_ivas_fx( /* Update music post processing values */ /* Filter energies update */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { FOR( i = 0; i < DCT_L_POST; i++ ) @@ -804,7 +798,6 @@ ivas_error acelp_core_dec_ivas_fx( } } ELSE -#endif { FOR( i = 0; i < DCT_L_POST; i++ ) { @@ -822,15 +815,12 @@ ivas_error acelp_core_dec_ivas_fx( /* reset the decoder */ CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); - -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* update st_fx->mem_syn1 for ACELP core switching */ Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); } ELSE -#endif { st->Q_syn_cng = st->Q_syn; move16(); @@ -889,13 +879,13 @@ ivas_error acelp_core_dec_ivas_fx( move16(); } - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); test(); test(); IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) ) { - config_acelp1_IVAS( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } } @@ -934,7 +924,7 @@ ivas_error acelp_core_dec_ivas_fx( IF( !tdm_lp_reuse_flag ) { - lsf_dec_ivas_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx ); + lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx ); } ELSE { @@ -1084,7 +1074,7 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE /* GENERIC */ { - decod_gen_2sbfr_ivas_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); + decod_gen_2sbfr_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) { @@ -1106,7 +1096,7 @@ ivas_error acelp_core_dec_ivas_fx( ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) { /* UNVOICED frames */ - decod_unvoiced_ivas_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); + decod_unvoiced_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } @@ -1131,15 +1121,15 @@ ivas_error acelp_core_dec_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ - decod_audio_ivas_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); + decod_audio_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, + tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ } ELSE { /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ - IF( NE_32( ( error = decod_gen_voic_ivas_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) ) { return error; } @@ -1163,7 +1153,7 @@ ivas_error acelp_core_dec_ivas_fx( * Apply energy matching when switching to inactive frames *-----------------------------------------------------------------*/ - Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); + Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); /*------------------------------------------------------------* * Decode information and modify the excitation signal of stationary unvoiced frames @@ -1212,7 +1202,6 @@ ivas_error acelp_core_dec_ivas_fx( move16(); /* Extrapolation of the last future part, windowing and high resolution DCT transform */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' @@ -1220,7 +1209,6 @@ ivas_error acelp_core_dec_ivas_fx( st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); } ELSE -#endif { Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); } @@ -1229,9 +1217,7 @@ ivas_error acelp_core_dec_ivas_fx( LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ -#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS -#endif { Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ } @@ -1300,13 +1286,9 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, - &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, -#ifdef REMOVE_EVS_DUPLICATES - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); -#else - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); -#endif + FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, + &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); test(); test(); @@ -1384,7 +1366,7 @@ ivas_error acelp_core_dec_ivas_fx( } /* Apply energy matching when switching to inactive frames */ - Inac_switch_ematch_ivas_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); + Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); /* update past excitation signals for LD music post-filter */ IF( st->hMusicPF != NULL ) @@ -1452,13 +1434,9 @@ ivas_error acelp_core_dec_ivas_fx( { Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, - &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, -#ifdef REMOVE_EVS_DUPLICATES - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); -#else - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, 0 ); -#endif + FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, + &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, + exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); } /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ @@ -1544,7 +1522,7 @@ ivas_error acelp_core_dec_ivas_fx( Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); set16_fx( st->hPFstat->mem_zero, 0, M ); - formant_post_filt_ivas_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); + formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); } ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) ) { @@ -1612,7 +1590,7 @@ ivas_error acelp_core_dec_ivas_fx( IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag ) { /* Noise estimate */ - ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } IF( !st->cna_dirac_flag ) @@ -1652,13 +1630,11 @@ ivas_error acelp_core_dec_ivas_fx( } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); } ELSE -#endif { IF( st->idchan == 0 ) { @@ -1666,10 +1642,13 @@ ivas_error acelp_core_dec_ivas_fx( { set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); } + Word32 psyn_32_fx[L_FRAME16k]; Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 + generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); + Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 } @@ -1713,7 +1692,7 @@ ivas_error acelp_core_dec_ivas_fx( /*Noise estimate*/ IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) ) { - ApplyFdCng_ivas_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); + ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); } } } @@ -1730,7 +1709,6 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { // VE: TBV - is it correct in EVS? in FLP, it is: @@ -1743,7 +1721,6 @@ ivas_error acelp_core_dec_ivas_fx( } } ELSE -#endif { FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) { @@ -1775,7 +1752,6 @@ ivas_error acelp_core_dec_ivas_fx( * Bass post-filter *----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { CLDFB_SCALE_FACTOR scaleFactor; @@ -1880,7 +1856,6 @@ ivas_error acelp_core_dec_ivas_fx( Copy( synth_fx16, st->previoussynth_fx, output_frame ); } ELSE -#endif { /* check if the CLDFB works on the right sample rate */ IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) @@ -1896,9 +1871,7 @@ ivas_error acelp_core_dec_ivas_fx( } /* analyze pitch coherence for bass post-filter */ - Word32 pitch_buf_fx_q20[12]; - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) Word16 lim = shr( st->L_frame, 6 ); FOR( Word16 lp = 0; lp < lim; lp++ ) @@ -1961,7 +1934,9 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 st->cldfbAna->Q_cldfb_state = Q12; move16(); + cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); + Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 st->cldfbAna->Q_cldfb_state = Q11; move16(); @@ -1990,6 +1965,7 @@ ivas_error acelp_core_dec_ivas_fx( } addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 st->cldfbBPF->Q_cldfb_state = Q10; move16(); @@ -2186,6 +2162,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 st->cldfbAna->Q_cldfb_state = Q12; move16(); + cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 @@ -2215,8 +2192,8 @@ ivas_error acelp_core_dec_ivas_fx( tmp = nSamples; move16(); } - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); + addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 st->cldfbBPF->Q_cldfb_state = Q10; @@ -2299,13 +2276,11 @@ ivas_error acelp_core_dec_ivas_fx( IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); } ELSE -#endif { Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); @@ -2315,9 +2290,7 @@ ivas_error acelp_core_dec_ivas_fx( ELSE { hf_synth_reset_fx( st->hBWE_zero ); -#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment -#endif { set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); } @@ -2356,13 +2329,11 @@ ivas_error acelp_core_dec_ivas_fx( test(); IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); } ELSE -#endif { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); @@ -2389,14 +2360,12 @@ ivas_error acelp_core_dec_ivas_fx( IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) { /* update CNG parameters in active frames */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); } ELSE -#endif { cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, @@ -2413,9 +2382,7 @@ ivas_error acelp_core_dec_ivas_fx( } } -#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( st->element_mode, EVS_MONO ) ) -#endif { IF( save_hb_synth_fx16 ) { diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 6d3d0b381..363db8202 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -128,11 +128,7 @@ ivas_error acelp_core_switch_dec_fx( * Excitation decoding *----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); -#else - config_acelp1( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); -#endif + config_acelp1_fx( DEC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &decode_bwe /* dummy */, &i, st_fx->element_mode, &i /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, 0, 0 ); decod_gen_voic_core_switch_fx( st_fx, L_frame_for_cs, 0, Aq, exc, cbrate, &st_fx->Q_exc ); @@ -920,11 +916,7 @@ static void decod_gen_voic_core_switch_fx( * Decode pitch lag *----------------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - pitch = pit_decode_ivas_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/ -#else - pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); /*Q6*/ -#endif + pitch = pit_decode_fx( st_fx, core_brate, 0, L_frame, 0, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*Q6*/ /*--------------------------------------------------------------* * Find the adaptive codebook vector. diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 971af2b56..96ae82dde 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -373,11 +373,7 @@ ivas_error amr_wb_dec_fx( IF( EQ_32( st_fx->core_brate, FRAME_NO_DATA ) || EQ_32( st_fx->core_brate, SID_1k75 ) ) { /* decode CNG parameters */ -#ifdef REMOVE_EVS_DUPLICATES - CNG_dec_ivas_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); -#else CNG_dec_fx( st_fx, EVS_MONO, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, &sid_bw, q_env ); -#endif /* comfort noise generation */ CNG_exc_fx( st_fx->core_brate, L_FRAME, &st_fx->hTdCngDec->Enew_fx, &st_fx->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st_fx->lp_ener_fx, st_fx->last_core_brate, @@ -630,15 +626,9 @@ ivas_error amr_wb_dec_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES - FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, - &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); -#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, avoid_lpc_burst_on_recovery, 0 ); -#endif + exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, 0 ); frame_ener_fx( L_FRAME, st_fx->clas_dec, syn_fx, pitch_buf_tmp[3], &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); } @@ -717,17 +707,10 @@ ivas_error amr_wb_dec_fx( * (smoothing is performed in the excitation domain and signal is resynthesized after) *------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - FEC_scale_syn_ivas_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, - MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, - st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, - st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 ); -#else FEC_scale_syn_fx( L_FRAME, &update_flg, st_fx->clas_dec, st_fx->last_good, syn_fx, pitch_buf_tmp, st_fx->enr_old_fx, L_enr_q_fx, -1, MOVING_AVERAGE, &st_fx->scaling_flag, &st_fx->lp_ener_FEC_av, &st_fx->lp_ener_FEC_max, st_fx->bfi, st_fx->total_brate, st_fx->prev_bfi, st_fx->last_core_brate, exc_fx, exc2_fx, Aq_fx, &st_fx->old_enr_LP, mem_tmp_fx, st_fx->mem_syn2_fx, - st_fx->Q_exc, st_fx->Q_syn, 0, 0 ); -#endif + st_fx->Q_exc, st_fx->Q_syn, EVS_MONO, 0, 0 ); /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ frame_ener_fx( L_FRAME, st_fx->last_good, syn_fx, shr( FEC_pitch_fx, 6 ), &st_fx->enr_old_fx, L_FRAME, st_fx->Q_syn, 3, 0 ); @@ -785,11 +768,7 @@ ivas_error amr_wb_dec_fx( st_fx->hPFstat->on = 1; move16(); test(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); -#else formant_post_filt_fx( st_fx->hPFstat, tmp_buffer_fx + L_SYN_MEM, Aq_fx, syn_fx, L_FRAME, L_shl( st_fx->psf_lp_noise_fx, 15 ), st_fx->total_brate, sub( amr_io_class, AUDIO_CLAS ) == 0 ); -#endif } /*----------------------------------------------------------------* @@ -813,11 +792,9 @@ ivas_error amr_wb_dec_fx( st_fx->VAD = 0; move16(); } -#ifdef REMOVE_EVS_DUPLICATES - ApplyFdCng_ivas_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 ); -#else - ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, NULL, NULL, st_fx, 0, 0 ); -#endif + + ApplyFdCng_fx( syn_fx, st_fx->Q_syn, NULL, 0, NULL, NULL, NULL, st_fx, 0, 0 ); + st_fx->hFdCngDec->hFdCngCom->frame_type_previous = st_fx->m_frame_type; move16(); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index ce6ad6568..fdb6488db 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -22,19 +22,19 @@ static void shb_CNG_decod_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word static void shb_CNG_decod_ivas_fx( Decoder_State *st_fx, const Word16 *synth_fx, Word16 *shb_synth_fx, const Word16 sid_bw, const Word16 Qsyn ); /*-----------------------------------------------------------------* + * CNG_dec_fx() + * * Decode residual signal energy *-----------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES void CNG_dec_fx( Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ + const Word16 last_element_mode, /* i : last element mode Q0 */ Word16 Aq[], /* o : LP coefficients Q12 */ Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */ - , + Word16 *sid_bw, /* i : 0-NB/WB, 1-SWB SID Q0 */ Word32 *q_env ) { Word16 istep; @@ -72,7 +72,6 @@ void CNG_dec_fx( Word16 exp_pow; Word16 tmp_loop; Word16 enr_new, Aq_tmp[M + 1]; - Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */ TD_CNG_DEC_HANDLE hTdCngDec; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -108,681 +107,9 @@ void CNG_dec_fx( } ELSE { - lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0, - NULL ); - /* check IF LSPs may trigger too much synthesis energy */ - - E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M ); - enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR ); - - IF( shr( enr_new, 14 ) > 0 ) - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */ - Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */ - } - } - } - ELSE - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */ - Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */ - } - - /* Initialize the CNG spectral envelope in case of the very first CNG frame */ - IF( st_fx->first_CNG == 0 ) - { - Copy( st_fx->lsp_old_fx, st_fx->lspCNG_fx, M ); /* Q15 */ - } - - /*-----------------------------------------------------------------* - * Decode residual signal energy - *-----------------------------------------------------------------*/ - - *allow_cn_step = 0; - move16(); - test(); - IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - istep = ISTEP_AMR_WB_SID_FX; /* Q15 */ - move16(); - if ( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - istep = ISTEP_SID_FX; /* Q15 */ - move16(); - } - - /* initialize the energy quantization parameters */ - num_bits = 6; - move16(); - if ( st_fx->Opt_AMR_WB == 0 ) - { - num_bits = 7; - move16(); - } - - /* decode the energy index */ - L_enr_index = get_next_indice_fx( st_fx, num_bits ); - - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) || EQ_16( st_fx->prev_bfi, 1 ) ) - { - tmp1 = add( hTdCngDec->old_enr_index, 20 ); - } - ELSE - { - tmp1 = add( hTdCngDec->old_enr_index, 40 ); - } - IF( GT_16( L_enr_index, tmp1 ) && hTdCngDec->old_enr_index >= 0 ) /* Likely bit error and not startup */ - { - L_enr_index = tmp1; - move16(); - L_enr_index = s_min( L_enr_index, 127 ); /* Q0 */ - IF( st_fx->Opt_AMR_WB ) - { - L_enr_index = s_min( L_enr_index, 63 ); /* Q0 */ - } - } - - test(); - test(); - test(); - IF( GT_32( st_fx->last_core_brate, SID_1k75 ) && - NE_16( st_fx->first_CNG, 0 ) && - GE_16( hTdCngDec->old_enr_index, 0 ) && - GT_16( L_enr_index, add( hTdCngDec->old_enr_index, 1 ) ) ) - { - *allow_cn_step = 1; - move16(); - } - - hTdCngDec->old_enr_index = L_enr_index; - move16(); - if ( !L_enr_index ) - { - L_enr_index = -5; - move16(); - } - /* st_fx->Enew = L_enr_index / step - 2.0f;*/ - L_ener = L_mult( L_enr_index, istep ); /* Q16 (0+15) */ - /* subtract by 2 not done to leave Energy in Q2 */ - - /* extract integral and fractional parts */ - ener_fra = L_Extract_lc( L_ener, &ener_int ); - ener_int = add( ener_int, 4 ); /* Q2 to Q6 */ - - /* find the new energy value */ - hTdCngDec->Enew_fx = Pow2( ener_int, ener_fra ); - move32(); - - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - burst_ho_cnt = get_next_indice_fx( st_fx, 3 ); /* 3bit */ - - *sid_bw = get_next_indice_fx( st_fx, 1 ); - move16(); - IF( *sid_bw == 0 ) - { - env_idx[0] = get_next_indice_fx( st_fx, 6 ); - move16(); - - /* get quantized res_env_details */ - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - q_env[i] = L_deposit_l( CNG_details_codebook_fx[env_idx[0]][i] ); - move32(); - } - } - } - /* Reset CNG history IF CNG frame length is changed */ - test(); - test(); - IF( EQ_16( st_fx->bwidth, WB ) && NE_16( st_fx->first_CNG, 0 ) && NE_16( st_fx->L_frame, st_fx->last_CNG_L_frame ) ) - { - hTdCngDec->ho_hist_size = 0; - move16(); - } - } - - /*---------------------------------------------------------------------* - * CNG spectral envelope update - * Find A(z) coefficients - *---------------------------------------------------------------------*/ - test(); - test(); - test(); - IF( LE_32( st_fx->last_core_brate, SID_2k40 ) ) - { - /* Reset hangover counter if not first SID period */ - if ( GT_32( st_fx->core_brate, FRAME_NO_DATA ) ) - { - hTdCngDec->num_ho = 0; - move16(); - } - /* Update LSPs IF last SID energy not outliers or insufficient number of hangover frames */ - test(); - IF( LT_16( hTdCngDec->num_ho, 3 ) || LT_32( Mult_32_16( hTdCngDec->Enew_fx, 21845 /*1/1.5f, Q15*/ ), st_fx->lp_ener_fx ) ) - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - st_fx->lspCNG_fx[i] = mac_r( L_mult( CNG_ISF_FACT_FX, st_fx->lspCNG_fx[i] ), 32768 - CNG_ISF_FACT_FX, lsp_new[i] ); - move16(); /* Q15 (15+15+1-16) */ - } - } - } - ELSE - { - /* Update CNG_mode IF allowed */ - test(); - test(); - test(); - IF( ( st_fx->Opt_AMR_WB || EQ_16( st_fx->bwidth, WB ) ) && ( !st_fx->first_CNG || GE_16( hTdCngDec->act_cnt2, MIN_ACT_CNG_UPD ) ) ) - { - IF( GT_32( st_fx->last_active_brate, ACELP_16k40 ) ) - { - st_fx->CNG_mode = -1; - move16(); - } - ELSE - { - st_fx->CNG_mode = get_cng_mode( st_fx->last_active_brate ); - move16(); - } - } - - /* If first sid after active burst update LSF history from circ buffer */ - burst_ho_cnt = s_min( burst_ho_cnt, hTdCngDec->ho_circ_size ); /* MODE1_DTX_IN_CODEC_B_FIX Q0*/ - hTdCngDec->act_cnt = 0; - move16(); - s_ptr = add( sub( hTdCngDec->ho_circ_ptr, burst_ho_cnt ), 1 ); - IF( s_ptr < 0 ) - { - s_ptr = add( s_ptr, hTdCngDec->ho_circ_size ); - } - - FOR( ll = burst_ho_cnt; ll > 0; ll-- ) - { - hTdCngDec->ho_hist_ptr = add( hTdCngDec->ho_hist_ptr, 1 ); /* Q0 */ - move16(); - if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngDec->ho_hist_ptr = 0; - move16(); - } - - /* Conversion between 12.8k and 16k LSPs */ - test(); - test(); - test(); - IF( ( EQ_16( st_fx->L_frame, L_FRAME16k ) && hTdCngDec->ho_16k_lsp[s_ptr] == 0 ) || ( EQ_16( st_fx->L_frame, L_FRAME ) && EQ_16( hTdCngDec->ho_16k_lsp[s_ptr], 1 ) ) ) - { - /* Conversion from 16k LPSs to 12k8 */ - lsp_convert_poly_fx( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), st_fx->L_frame, 0 ); - } - /* update the circular buffers */ - Copy( &( hTdCngDec->ho_lsp_circ_fx[s_ptr * M] ), &( hTdCngDec->ho_lsp_hist_fx[hTdCngDec->ho_hist_ptr * M] ), M ); /* Qx */ - Copy32( &( hTdCngDec->ho_ener_circ_fx[s_ptr] ), &( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ), 1 ); /* Q6 */ - hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); - move32(); - Copy32( &( hTdCngDec->ho_env_circ_fx[s_ptr * NUM_ENV_CNG] ), &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Qx */ - - hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 ); - move16(); - - if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngDec->ho_hist_size = HO_HIST_SIZE; - move16(); - } - - s_ptr = add( s_ptr, 1 ); - if ( EQ_16( s_ptr, hTdCngDec->ho_circ_size ) ) - { - s_ptr = 0; - move16(); - } - } - - IF( hTdCngDec->ho_hist_size > 0 ) /* can be -1 at init MODE1_DTX_IN_CODEC_B_FIX */ - { - /* *allow_cn_step |= ( st_fx->ho_ener_hist[st_fx->ho_hist_ptr] > 4.0f * st_fx->lp_ener );*/ - L_tmp1 = L_shr( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], 2 ); - L_tmp1 = L_sub( L_tmp1, st_fx->lp_ener_fx ); + lsf_dec_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0, NULL ); - test(); - test(); - IF( ( L_tmp1 > 0 && ( st_fx->first_CNG || st_fx->element_mode == EVS_MONO ) ) ) - { - *allow_cn_step = s_or( *allow_cn_step, 1 ); - move16(); - } - } - IF( EQ_16( last_element_mode, IVAS_CPE_TD ) ) - { - *allow_cn_step = 1; - move16(); - } - test(); - IF( EQ_16( *allow_cn_step, 0 ) && GT_16( hTdCngDec->ho_hist_size, 0 ) ) - { - /* Use average of energies below last energy */ - ptr = hTdCngDec->ho_hist_ptr; - move16(); - Copy( &( hTdCngDec->ho_lsp_hist_fx[ptr * M] ), tmp, M ); /* Qx */ - m1 = 0; - move16(); - IF( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x1 ) == 0 ) - { - Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], tmp_env, NUM_ENV_CNG ); - m1 = 1; - move16(); - } - L_enr = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[0] ); /* Q6+15-15->Q6 */ - - weights = W_DTX_HO_FX[0]; /* Q15 */ - move16(); - - m = 1; - move16(); - FOR( k = 1; k < hTdCngDec->ho_hist_size; k++ ) - { - ptr--; - if ( ptr < 0 ) - { - ptr = HO_HIST_SIZE - 1; - move16(); - } - - test(); - IF( LT_32( Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], ONE_OVER_BUF_H_NRG_FX ), hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] ) && - GT_32( hTdCngDec->ho_ener_hist_fx[ptr], Mult_32_16( hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr], BUF_L_NRG_FX ) ) ) - { - /*enr += W_DTX_HO[k] * st_fx->ho_ener_hist[ptr];*/ - L_tmp1 = Mult_32_16( hTdCngDec->ho_ener_hist_fx[ptr], W_DTX_HO_FX[k] ); /* Q6+15-15->Q6 */ - L_enr = L_add( L_enr, L_tmp1 ); /* Q6 */ - - /*weights += W_DTX_HO[k];*/ - weights = add( weights, W_DTX_HO_FX[k] ); /* Q15 */ - - Copy( &hTdCngDec->ho_lsp_hist_fx[ptr * M], &tmp[m * M], M ); /* Qx */ - IF( EQ_32( L_and( hTdCngDec->ho_sid_bw, L_shl( (Word32) 0x1, k ) ), 0 ) ) - { - Copy32( &hTdCngDec->ho_env_hist_fx[ptr * NUM_ENV_CNG], &tmp_env[m1 * NUM_ENV_CNG], NUM_ENV_CNG ); /* Qx */ - m1++; - } - m++; - } - } - - /*enr /= weights;*/ - exp = norm_s( weights ); - tmp1 = div_s( shl( 1, sub( 14, exp ) ), weights ); /* Q(15+14-exp-15) */ - L_tmp1 = Mult_32_16( L_enr, tmp1 ); /* Q(14-exp+6-15)->Q(5-exp) */ - L_enr = L_shl( L_tmp1, add( exp, 1 ) ); /* Q6 */ - - st_fx->lp_ener_fx = L_enr; /* Q6 */ - move32(); - set32_fx( max_val, 0, 2 ); - set16_fx( max_idx, 0, 2 ); - - FOR( i = 0; i < m; i++ ) - { - IF( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_FX ); - ftmp_fx = 964; - move16(); /*X2.56 */ - tmpv = sub( 16384, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/ - } - ELSE - { - lsp2lsf_fx( &tmp[i * M], lsf_tmp, M, INT_FS_16k_FX ); - ftmp_fx = 1205; - move16(); /*QX2.56*/ - tmpv = sub( 20480, add( lsf_tmp[M - 1], ftmp_fx ) ); /*QX2.56*/ - L_tmp = L_mult0( tmpv, tmpv ); /*QX6.5536*/ - } - - tmpv = sub( lsf_tmp[0], ftmp_fx ); /*QX2.56*/ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/ - FOR( j = 0; j < M - 1; j++ ) - { - tmpv = sub( sub( lsf_tmp[j + 1], lsf_tmp[j] ), ftmp_fx ); /*QX2.56*/ - L_tmp = L_mac0( L_tmp, tmpv, tmpv ); /*QX6.5536*/ - } - - C[i] = Mpy_32_16_1( L_tmp, 1928 ); /*QX6.5536*/ - move32(); - - IF( GT_32( C[i], max_val[0] ) ) - { - max_val[1] = max_val[0]; - move32(); - max_idx[1] = max_idx[0]; - move16(); - max_val[0] = C[i]; - move32(); - max_idx[0] = i; - move16(); - } - ELSE IF( GT_32( C[i], max_val[1] ) ) - { - max_val[1] = C[i]; - move32(); - max_idx[1] = i; - move16(); - } - } - - IF( EQ_16( m, 1 ) ) - { - Copy( tmp, lsp_tmp, M ); /* Qx */ - } - ELSE IF( LT_16( m, 4 ) ) - { - FOR( i = 0; i < M; i++ ) - { - L_tmp1 = 0; - move32(); - FOR( j = 0; j < m; j++ ) - { - L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp1 = L_sub( L_tmp1, L_deposit_l( tmp[max_idx[0] * M + i] ) ); - tmpv = div_s( 1, sub( m, 1 ) ); /*Q15*/ - L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/ - lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ - move16(); - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - L_tmp1 = 0; - move32(); - FOR( j = 0; j < m; j++ ) - { - L_tmp1 = L_add( L_tmp1, L_deposit_l( tmp[j * M + i] ) ); - } - - L_tmp1 = L_sub( L_tmp1, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15*/ - tmpv = div_s( 1, sub( m, 2 ) ); /*Q15*/ - L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/ - lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ - move16(); - } - } - - dist = 0; - move16(); /*Q15*/ - max_dev = 0; - move16(); /*Q15*/ - FOR( i = 0; i < M; i++ ) - { - dev = abs_s( sub( lsp_tmp[i], lsp_new[i] ) ); /*Q15*/ - dist = add_o( dist, dev, &Overflow ); /*Q15*/ - if ( GT_16( dev, max_dev ) ) - { - max_dev = dev; - move16(); - } - } - - test(); - IF( GT_16( dist, 13107 ) || GT_16( max_dev, 3277 ) ) /* 0.4 and 0.1 in Q15 */ - { - FOR( i = 0; i < M; i++ ) - { - st_fx->lspCNG_fx[i] = lsp_tmp[i]; - move16(); /*Q15*/ - } - } - ELSE - { - FOR( i = 0; i < M; i++ ) - { - /* AR low-pass filter */ - st_fx->lspCNG_fx[i] = add( mult_r( 26214, lsp_tmp[i] ), mult_r( 6554, lsp_new[i] ) ); /* Q15 */ - move16(); - } - } - IF( m1 > 0 ) - { - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - L_tmp = L_deposit_l( 0 ); - FOR( j = 0; j < m1; j++ ) - { - /* env[i] += tmp_env[j*NUM_ENV_CNG+i];*/ - L_tmp = L_add_sat( L_tmp, tmp_env[j * NUM_ENV_CNG + i] ); - } - /* env[i] /= (float)m1; */ - /* env[i] = env[i] - 2*st_fx->lp_ener_fx; */ - IF( EQ_16( m1, 1 ) ) - { - L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ - } - ELSE - { - tmp1 = div_s( 1, m1 ); - L_tmp = Mult_32_16( L_tmp, tmp1 ); /* Q6 */ - L_tmp = L_sub_sat( L_tmp, L_add_sat( st_fx->lp_ener_fx, st_fx->lp_ener_fx ) ); /* Q6 */ - } - env[i] = L_tmp; /* Q6 */ - move32(); - } - - Copy32( env, hTdCngDec->lp_env_fx, NUM_ENV_CNG ); /* Q6 */ - } - } - ELSE - { - Copy( lsp_new, st_fx->lspCNG_fx, M ); /* use newly analyzed ISFs */ /* Q15 */ - } - } - - test(); - IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* Update hangover memory during CNG */ - test(); - IF( ( *allow_cn_step == 0 ) && LT_32( hTdCngDec->Enew_fx, L_add_sat( st_fx->lp_ener_fx, L_shr( st_fx->lp_ener_fx, 1 ) ) ) ) - { - /* update the pointer to circular buffer of old LSP vectors */ - hTdCngDec->ho_hist_ptr++; - move16(); - if ( EQ_16( hTdCngDec->ho_hist_ptr, HO_HIST_SIZE ) ) - { - hTdCngDec->ho_hist_ptr = 0; - move16(); - } - - /* update the circular buffer of old LSP vectors with the new LSP vector */ - Copy( lsp_new, &( hTdCngDec->ho_lsp_hist_fx[( hTdCngDec->ho_hist_ptr ) * M] ), M ); /* Q15 */ - - /* update the hangover energy buffer */ - hTdCngDec->ho_ener_hist_fx[hTdCngDec->ho_hist_ptr] = hTdCngDec->Enew_fx; /* Q6 */ - move32(); - test(); - IF( EQ_32( st_fx->core_brate, SID_2k40 ) && ( *sid_bw == 0 ) ) - { - /* enr1 = (float)log10( st->Enew*L_frame + 0.1f ) / (float)log10( 2.0f );*/ - exp = norm_l( hTdCngDec->Enew_fx ); - L_tmp = L_shl( hTdCngDec->Enew_fx, exp ); /*Q(exp+6)*/ - L_tmp = Mult_32_16( L_tmp, shl( st_fx->L_frame, 5 ) ); /*Q(exp+6+5-15=exp-4)*/ - L_tmp = L_shr_sat( L_tmp, sub( exp, 10 ) ); /*Q6*/ - exp = norm_l( L_tmp ); - fra = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( sub( 30, exp ), 6 ); - L_tmp = L_Comp( exp, fra ); - enr1 = L_shr( L_tmp, 10 ); /* Q6 */ - - FOR( i = 0; i < NUM_ENV_CNG; i++ ) - { - /* get quantized envelope */ - /* env[i] = pow(2.0f,(enr1 - q_env[i])) + 2*st->Enew;*/ - L_tmp = L_sub( enr1, q_env[i] ); /* Q6 */ - L_tmp = L_shl( L_tmp, 10 ); /* 16 */ - temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); - - exp_pow = sub( 14, temp_hi_fx ); - L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ - env[i] = L_shl( L_tmp, sub( 6, exp_pow ) ); /* Q6 */ - move32(); - L_tmp = L_add( hTdCngDec->Enew_fx, hTdCngDec->Enew_fx ); - env[i] = L_add( env[i], L_tmp ); /* Q6 */ - move32(); - } - hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */ - move32(); - Copy32( env, &( hTdCngDec->ho_env_hist_fx[hTdCngDec->ho_hist_ptr * NUM_ENV_CNG] ), NUM_ENV_CNG ); /* Q6 */ - } - ELSE IF( ( *sid_bw != 0 ) ) - { - hTdCngDec->ho_sid_bw = L_shl( L_and( hTdCngDec->ho_sid_bw, (Word32) 0x3fffffffL ), 1 ); /* Q0 */ - move32(); - hTdCngDec->ho_sid_bw = L_or( hTdCngDec->ho_sid_bw, 0x1L ); /* Q0 */ - move32(); - } - - hTdCngDec->ho_hist_size = add( hTdCngDec->ho_hist_size, 1 ); - move16(); - if ( GT_16( hTdCngDec->ho_hist_size, HO_HIST_SIZE ) ) - { - hTdCngDec->ho_hist_size = HO_HIST_SIZE; - move16(); - } - } - /* Update the frame length memory */ - st_fx->last_CNG_L_frame = st_fx->L_frame; - move16(); - - if ( NE_32( st_fx->core_brate, SID_1k75 ) ) - { - hTdCngDec->num_ho = m; - move16(); - } - } - - IF( st_fx->element_mode == EVS_MONO ) - { - st_fx->last_CNG_L_frame = st_fx->L_frame; - move16(); - - IF( NE_32( st_fx->core_brate, SID_1k75 ) ) - { - hTdCngDec->num_ho = m; - move16(); - } - } - IF( st_fx->Opt_AMR_WB ) - { - E_LPC_f_isp_a_conversion( st_fx->lspCNG_fx, Aq, M ); - } - ELSE - { - E_LPC_f_lsp_a_conversion( st_fx->lspCNG_fx, Aq, M ); - } - - tmp_loop = shr( st_fx->L_frame, 6 ); - FOR( i = 1; i < tmp_loop; i++ ) /* L_frame/L_SUBFR */ - { - Copy( Aq, &Aq[i * ( M + 1 )], add( M, 1 ) ); /* Q12 */ - } - - return; -} -#endif -void CNG_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 last_element_mode, /* i : last element mode Q0 */ - Word16 Aq[], /* o : LP coefficients Q12 */ - Word16 *lsp_new, /* i/o: current frame LSPs Q15 */ - Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */ - Word16 *allow_cn_step, /* o : allow CN step Q0 */ - Word16 *sid_bw /* i : 0-NB/WB, 1-SWB SID Q0 */ - , - Word32 *q_env ) -{ - Word16 istep; - Word16 i, L_enr_index; - Word32 L_ener; - Word16 ener_fra, ener_int; - Word16 num_bits; - Word16 weights, ptr, j, k; - Word16 m1; - Word16 m = 0; - move16(); - Word16 tmp[HO_HIST_SIZE * M]; - Word16 burst_ho_cnt = 0; - move16(); - Word16 ll, s_ptr; - Word32 L_enr, L_tmp1; - Word16 tmp1, exp; - Word16 lsf_tmp[M]; - Word32 C[M]; - Word32 max_val[2]; - Word16 max_idx[2]; - Word16 ftmp_fx; - Word16 lsp_tmp[M]; - Word16 dev; - Word16 max_dev; - Word16 dist; - Word16 tmpv; - Word16 env_idx[2]; - Word32 enr1; - Word32 env[NUM_ENV_CNG]; - Word32 tmp_env[HO_HIST_SIZE * NUM_ENV_CNG]; - Word32 L_tmp; - Word16 fra; - Word16 temp_lo_fx, temp_hi_fx; - Word16 exp_pow; - Word16 tmp_loop; - Word16 enr_new, Aq_tmp[M + 1]; - - Word16 LSF_Q_prediction; /* o : LSF prediction mode - just temporary variable in CNG */ - TD_CNG_DEC_HANDLE hTdCngDec; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - hTdCngDec = st_fx->hTdCngDec; - - m = 0; - move16(); - /*-----------------------------------------------------------------* - * Decode CNG spectral envelope (only in SID frame) - *-----------------------------------------------------------------*/ - test(); - IF( EQ_32( st_fx->core_brate, SID_1k75 ) || EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* de-quantize the LSF vector */ - IF( st_fx->Opt_AMR_WB != 0 ) - { - /* Flt function */ - isf_dec_amr_wb_fx( st_fx, Aq, lsf_new, lsp_new ); - /* check IF ISPs may trigger too much synthesis energy */ - - E_LPC_f_isp_a_conversion( lsp_new, Aq_tmp, M ); - enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR ); - - IF( ( shr( enr_new, 14 ) > 0 ) ) - { - /* Use old LSP vector */ - Copy( st_fx->lsp_old_fx, lsp_new, M ); /* Q15 */ - Copy( st_fx->lsf_old_fx, lsf_new, M ); /* Q2.56 */ - } - } - ELSE - { - lsf_dec_ivas_fx( st_fx, 0, Aq, &LSF_Q_prediction, lsf_new, lsp_new, 0, 0, - NULL ); /* check IF LSPs may trigger too much synthesis energy */ - E_LPC_f_lsp_a_conversion( lsp_new, Aq_tmp, M ); enr_new = Enr_1_Az_fx( Aq_tmp, 2 * L_SUBFR ); diff --git a/lib_dec/dec_LPD_fx.c b/lib_dec/dec_LPD_fx.c index c04ee9dc5..b638a36e5 100644 --- a/lib_dec/dec_LPD_fx.c +++ b/lib_dec/dec_LPD_fx.c @@ -556,11 +556,7 @@ void decoder_LPD_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES int_lsp4_ivas_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#else - int_lsp4_fx( L_frame, &lsp[0], lspmid, &lsp[M], Aq, M, st->relax_prev_lsf_interp ); -#endif } ELSE { diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index ad89ca556..9c366e3f3 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -532,27 +532,24 @@ void decoder_acelp_fx( move16(); IF( st->igf != 0 ) { -#ifdef REMOVE_EVS_DUPLICATES - prep_tbe_exc_ivas_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, - gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 ); -#else - prep_tbe_exc_fx( st->L_frame, - i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, - gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate ); -#endif + prep_tbe_exc_fx( st->L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, st->voice_fac, &voice_factors[idx], bwe_exc, + gain_preQ, code_preQ, st->Q_exc, T0, T0_frac, st->coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, 0 ); } /*---------------------------------------------------------* * Enhance the excitation * *---------------------------------------------------------*/ + E_UTIL_enhancer( st->voice_fac, stab_fac, st->past_gcode, gain_inov, &( st->gc_threshold_fx ), code, &exc2[i_subfr], gain_pit, &st->dm_fx.prev_gain_code, st->dm_fx.prev_gain_pit, &st->dm_fx.prev_state, st->coder_type, acelp_cfg.fixed_cdk_index[idx], L_SUBFR, st->L_frame, st->Q_exc ); } /* !RF_NELP frame partial copy */ + /*----------------------------------------------------------* * - compute the synthesis speech * *----------------------------------------------------------*/ + rescale_mem( &st->Q_exc, &prev_Q_syn, &st->Q_syn, mem_syn, syn, M, i_subfr ); E_UTIL_synthesis( sub( st->Q_exc, st->Q_syn ), p_A, &exc2[i_subfr], &syn[i_subfr], L_SUBFR, mem_syn, 1, M ); @@ -678,16 +675,11 @@ void decoder_acelp_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES - FEC_scale_syn_ivas_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, - st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, - exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn ); -#else FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, syn, pBuf_scaleSyn, st->enr_old_fx, 0, st->coder_type, LSF_Q_prediction, &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, - exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, avoid_lpc_burst_on_recovery, force_scale_syn ); -#endif + exc, exc2, A, &( st->old_enr_LP ), mem_back, mem_syn, st->Q_exc, st->Q_syn, EVS_MONO, avoid_lpc_burst_on_recovery, force_scale_syn ); } + /* update ACELP synthesis memory */ Copy( mem_syn, st->mem_syn2_fx, M ); Copy( syn + st->L_frame - L_SYN_MEM, st->mem_syn_r, L_SYN_MEM ); diff --git a/lib_dec/dec_amr_wb_fx.c b/lib_dec/dec_amr_wb_fx.c index b03b6d69c..500fe34ba 100644 --- a/lib_dec/dec_amr_wb_fx.c +++ b/lib_dec/dec_amr_wb_fx.c @@ -71,11 +71,7 @@ void decod_amr_wb_fx( * Decode pitch lag *----------------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); -#else - *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR ); -#endif + *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 1, L_FRAME, i_subfr, -1, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, L_SUBFR, 0, NULL ); /*--------------------------------------------------------------* * Find the adaptive codebook vector diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 7411d59f2..3e42d9535 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -18,8 +18,7 @@ /*----------------------------------------------------------------------*/ /* GLOBAL INPUT ARGUMENTS : */ /* _ (Struct) st_fx : decoder static memory */ -/* _ (Word16) L_frame : length of the frame */ - +/* _ (Word16) L_frame : length of the frame */ /* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ /* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ /* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ @@ -29,503 +28,30 @@ /* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ /* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ /*----------------------------------------------------------------------*/ - - /*----------------------------------------------------------------------*/ /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES ivas_error decod_gen_voic_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe Q6 */ - Word16 *voice_factors_fx, /* o : voicing factors Q15 */ - Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf /*Q14*/ -) -{ - - - Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx = 0; /* pitch gain Q14 */ - move16(); - Word32 gain_code_fx = 0; /* gain/normalized gain of the algebraic excitation Q16 */ - move32(); - Word32 norm_gain_code_fx = 0; /* normalized gain of the algebraic excitation Q16 */ - move32(); - Word16 gain_inov_fx = 0; /* Innovation gain Q12 */ - move16(); - Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ - Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ - Word16 voice_fac_fx; /* voicing factor Q15 */ - Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */ - - const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ - Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */ - Word16 i_subfr_fx, i; /* tmp variables */ - Word16 error_fx = 0; - move16(); - Word16 gain_preQ_fx = 0; /* Gain of prequantizer excitation */ - move16(); - Word16 code_preQ_fx[L_SUBFR]; /* Prequantizer excitation */ - Word32 norm_gain_preQ_fx; - Word16 pitch_limit_flag_fx; - - Word16 tmp1_fx, gain_code16; - Word32 L_tmp_GC; - Word32 L_tmp; - - Word16 harm_flag_acelp; - - Word16 shft_prev, ph_offset_fx; - Word32 prev_res_nrg; - Word32 prev_spch_nrg; - Word32 curr_res_nrg; - Word32 curr_spch_nrg; - Word16 rint_bfi_pitch, rint_pitch; - Word16 fraca, fracb, expa, expb, scale, exp1; - Word16 *p_exc; - Word16 mem_tmp_fx[M]; - Word16 syn_tmp_fx[L_FRAME16k]; - Word16 shft_curr; - Word16 *p_syn; - Word16 sp_enratio, Qsp_enratio; - Word16 enratio, Qenratio; - DTFS_STRUCTURE *PREVP, *CURRP; - Word16 S_fx[PIT_MAX * 4 + 1], C_fx[PIT_MAX * 4 + 1]; - Word16 dummy2[2]; - Word16 out_fx[L_FRAME16k]; - - Word16 pf_temp1[MAXLAG_WI]; /*may not need more than MAXLAG_WI/2+1 */ - Word16 pf_temp2[MAXLAG_WI]; - Word16 pf_temp[MAXLAG_WI]; - Word16 pf_n2[MAXLAG_WI]; - MUSIC_POSTFILT_HANDLE hMusicPF; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif - - hMusicPF = st_fx->hMusicPF; - - GSC_DEC_HANDLE hGSCDec; - hGSCDec = st_fx->hGSCDec; - ivas_error error; - - error = IVAS_ERR_OK; - move32(); - - T0_fx = PIT_MIN; - move16(); - T0_frac_fx = 0; - move16(); - - /* read harmonicity flag */ - harm_flag_acelp = 0; - move16(); - test(); - test(); - IF( ( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) ) && EQ_16( st_fx->coder_type, GENERIC ) ) - { - harm_flag_acelp = (Word16) get_next_indice( st_fx, 1 ); - } - - /*------------------------------------------------------------------* - * ACELP subframe loop - *------------------------------------------------------------------*/ - - p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */ - pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ - norm_gain_preQ_fx = 0; - move32(); - gain_preQ_fx = 0; - move16(); - set16_fx( code_preQ_fx, 0, L_SUBFR ); - - FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR ) - { - /*----------------------------------------------------------------------* - * Decode pitch lag - *----------------------------------------------------------------------*/ - - *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, - &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR ); - move16(); /*Q6*/ - - /*--------------------------------------------------------------* - * Find the adaptive codebook vector - *--------------------------------------------------------------*/ - - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx ); - - /*--------------------------------------------------------------* - * LP filtering of the adaptive excitation - *--------------------------------------------------------------*/ - lp_filt_exc_dec_fx( st_fx, MODE1, i_subfr_fx, L_SUBFR, L_frame, st_fx->acelp_cfg.ltf_mode, exc_fx ); - /*-----------------------------------------------------------------* - * Transform-domain contribution decoding (active frames) - *-----------------------------------------------------------------*/ - - test(); - IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && ( st_fx->coder_type != INACTIVE ) ) - { - gain_code_fx = 0; - move16(); - transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits ); - } - - /*--------------------------------------------------------------* - * Innovation decoding - *--------------------------------------------------------------*/ - - inov_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, sharpFlag_fx, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_SUBFR ); - - /*--------------------------------------------------------------* - * Gain decoding - * Estimate spectrum tilt and voicing - *--------------------------------------------------------------*/ - - IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) - { - gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR ); - } - ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) - { - gain_dec_SQ_fx( st_fx, i_subfr_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } - ELSE - { - gain_dec_mless_fx( st_fx, L_frame, st_fx->coder_type, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - } - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, st_fx->Q_exc ); // Q15 - move16(); - - /*-----------------------------------------------------------------* - * Transform domain contribution decoding - *-----------------------------------------------------------------*/ - test(); - IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && ( st_fx->coder_type == INACTIVE ) ) - { - transf_cdbk_dec_fx( st_fx, harm_flag_acelp, i_subfr_fx, Es_pred_fx, gain_code_fx, &gain_preQ_fx, &norm_gain_preQ_fx, code_preQ_fx, unbits ); - } - - /* update LP filtered gains for the case of frame erasures */ - lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); - - /*----------------------------------------------------------------------* - * Find the total excitation - *----------------------------------------------------------------------*/ - - IF( EQ_16( L_frame, L_FRAME ) ) /* Rescaling for 12.8k core */ - { - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * HIBND_ACB_L_FAC], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * HIBND_ACB_L_FAC, gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type ); - } - ELSE /* Rescaling for 16k core */ - { - - L_tmp_GC = L_max( gain_code_fx, L_shl( gain_preQ_fx, 16 ) ); /* Chose the maximum of gain_code or the prequantizer excitation x4 to keep some room*/ - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[i_subfr_fx * 2], hGSCDec->last_exc_dct_in_fx, - L_SUBFR, L_SUBFR * 2, L_tmp_GC, &( st_fx->Q_exc ), st_fx->Q_subfr, exc2_fx, i_subfr_fx, st_fx->coder_type ); - } - - gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/ - - /*-----------------------------------------------------------------* - * Add the ACELP pre-quantizer contribution - *-----------------------------------------------------------------*/ - - IF( gain_preQ_fx != 0 ) - { - IF( st_fx->element_mode == EVS_MONO ) - { - tmp1_fx = add( 15 - Q_AVQ_OUT_DEC - 2, st_fx->Q_exc ); - } - ELSE - { - tmp1_fx = add( 15 - Q_AVQ_OUT - 2, st_fx->Q_exc ); - } - FOR( i = 0; i < L_SUBFR; i++ ) - { - Word32 Ltmp1; - /* Contribution from AVQ layer */ - Ltmp1 = L_mult( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/ - Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx ); /* Q16 + Q_exc */ - - /* Compute exc2 */ - L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); // Q_exc+Q14+1+1 - exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc - move16(); - /* gain_pit in Q14 */ - L_tmp = L_mult( gain_code16, code_fx[i] ); // Q_exc+Q9+1 - L_tmp = L_shl_sat( L_tmp, 5 ); // Q_exc+Q9+1+5 - L_tmp = L_mac_sat( L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); // Q_exc+Q15 +1 - L_tmp = L_shl_sat( L_tmp, 1 ); /* saturation can occur here */ - - exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( L_tmp, Ltmp1 ) ); // Q_exc - move16(); - } - } - ELSE - { - Acelp_dec_total_exc( exc_fx, exc2_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_SUBFR ); - } - - /*-----------------------------------------------------------------* - * Prepare TBE excitation - *-----------------------------------------------------------------*/ - - Word16 idx = 0; - move16(); - IF( i_subfr_fx != 0 ) - { - idx = idiv1616( i_subfr_fx, L_SUBFR ); - } - - prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); - - - /*----------------------------------------------------------------* - * Excitation enhancements (update of total excitation signal) - *----------------------------------------------------------------*/ - - test(); - IF( GT_32( st_fx->core_brate, ACELP_32k ) || ( st_fx->coder_type == INACTIVE ) ) - { - Copy( exc_fx + i_subfr_fx, exc2_fx + i_subfr_fx, L_SUBFR ); - } - ELSE - { - enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); - } - - p_Aq_fx += ( M + 1 ); - pt_pitch_fx++; - gain_buf[idx] = gain_pit_fx; // Q14 - move16(); - } - - /* FEC fast recovery */ - - IF( do_WI_fx ) - { - /* shft_prev = L_EXC_MEM - rint_new_fx(st_fx->bfi_pitch_fx);*/ - L_tmp = L_shl( L_deposit_l( st_fx->bfi_pitch_fx ), 10 ); /*Q16*/ - rint_bfi_pitch = rint_new_fx( L_tmp ); /*Q0*/ - shft_prev = sub( L_EXC_MEM, rint_bfi_pitch ); /*Q0*/ - - p_exc = st_fx->hWIDec->old_exc2_fx + shft_prev; - p_syn = st_fx->hWIDec->old_syn2_fx + shft_prev; - move16(); - move16(); - - prev_res_nrg = L_deposit_l( 1 ); - prev_spch_nrg = L_deposit_l( 1 ); - FOR( i = 0; i < rint_bfi_pitch; i++ ) - { - prev_res_nrg = L_mac0_sat( prev_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->prev_Q_exc_fr */ - prev_spch_nrg = L_mac0_sat( prev_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->prev_Q_syn_fr */ - p_exc++; - p_syn++; - } - - Copy( st_fx->mem_syn2_fx, mem_tmp_fx, M ); - - syn_12k8_fx( st_fx->L_frame, Aq_fx, exc2_fx, syn_tmp_fx, mem_tmp_fx, 1, st_fx->Q_exc, st_fx->Q_syn ); - - L_tmp = L_shl( L_deposit_l( pitch_buf_fx[NB_SUBFR16k - 1] ), 10 ); /*Q16*/ - rint_pitch = rint_new_fx( L_tmp ); /*Q0*/ - shft_curr = sub( st_fx->L_frame, rint_pitch ); /*Q0*/ - - p_exc = exc2_fx + shft_curr; - p_syn = syn_tmp_fx + shft_curr; - - curr_res_nrg = L_deposit_l( 1 ); - curr_spch_nrg = L_deposit_l( 1 ); - FOR( i = 0; i < rint_pitch; i++ ) - { - curr_res_nrg = L_mac0_sat( curr_res_nrg, *p_exc, *p_exc ); /* 2*st_fx->Q_exc */ - curr_spch_nrg = L_mac0_sat( curr_spch_nrg, *p_syn, *p_syn ); /* 2*st_fx->Q_syn */ - p_exc++; - p_syn++; - } - - /* enratio = (curr_res_nrg / prev_res_nrg); */ - IF( prev_res_nrg > 0 ) - { - expa = norm_l( prev_res_nrg ); - fraca = extract_h( L_shl( prev_res_nrg, expa ) ); /* 2*st_fx->prev_Q_exc_fr -16+expa +1*/ - expa = sub( 30, add( expa, ( shl( st_fx->prev_Q_exc_fr, 1 ) ) ) ); - - expb = norm_l( curr_res_nrg ); - fracb = round_fx_sat( L_shl_sat( curr_res_nrg, expb ) ); /* 2*st_fx->Q_exc +expb+1 -16*/ - expb = sub( 30, add( expb, shl( st_fx->Q_exc, 1 ) ) ); - - scale = shr( sub( fraca, fracb ), 15 ); - fracb = shl( fracb, scale ); // Q(15-expb)+scale - expb = sub( expb, scale ); - - enratio = div_s( fracb, fraca ); // Q(15-(expb-expa)) - exp1 = sub( expb, expa ); - Qenratio = sub( 15, exp1 ); - } - ELSE - { - enratio = 0; - move16(); - Qenratio = 0; - move16(); - } - - /* sp_enratio = curr_spch_nrg/prev_spch_nrg */ - IF( prev_spch_nrg > 0 ) - { - expa = norm_l( prev_spch_nrg ); - fraca = extract_h( L_shl( prev_spch_nrg, expa ) ); /* 2*st_fx->prev_Q_syn_fr +expa+1-16*/ - expa = sub( 30, add( expa, shl( st_fx->prev_Q_syn_fr, 1 ) ) ); - - expb = norm_l( curr_spch_nrg ); - fracb = round_fx_sat( L_shl_sat( curr_spch_nrg, expb ) ); /* 2*st_fx->Q_syn +expb-16 */ - expb = sub( 30, add( expb, shl( st_fx->Q_syn, 1 ) ) ); - - scale = shr( sub( fraca, fracb ), 15 ); - fracb = shl( fracb, scale ); // Q(15-expb) +scale - expb = sub( expb, scale ); - - sp_enratio = div_s( fracb, fraca ); // Q(15-(expb-expa)) - exp1 = sub( expb, expa ); - Qsp_enratio = sub( 15, exp1 ); - } - ELSE - { - sp_enratio = 0; - move16(); - Qsp_enratio = 0; - move16(); - } - - test(); - test(); - test(); - test(); - IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[NB_SUBFR16k - 1], 9600 ) ) /*Q6*/ - { - IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) - { - return error; - } - - IF( NE_32( ( error = DTFS_new_fx( &CURRP ) ), IVAS_ERR_OK ) ) - { - return error; - } - - GetSinCosTab_fx( rint_bfi_pitch, S_fx, C_fx ); - DTFS_to_fs_fx( st_fx->hWIDec->old_exc2_fx + shft_prev, rint_bfi_pitch, PREVP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); - PREVP->Q = add( PREVP->Q, st_fx->prev_Q_exc_fr ); - move16(); - - GetSinCosTab_fx( rint_pitch, S_fx, C_fx ); - DTFS_to_fs_fx( exc2_fx + shft_curr, rint_pitch, CURRP, (Word16) st_fx->output_Fs, do_WI_fx, S_fx, C_fx ); - CURRP->Q = add( CURRP->Q, st_fx->Q_exc ); - move16(); - - ph_offset_fx = 0; - move16(); - IF( NE_32( ( error = WIsyn_fx( *PREVP, CURRP, dummy2, &( ph_offset_fx ), out_fx, (Word16) st_fx->L_frame, 1, S_fx, C_fx, pf_temp1, pf_temp2, pf_temp, pf_n2 ) ), IVAS_ERR_OK ) ) - { - return error; - } - - - Copy_Scale_sig( out_fx, exc2_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc - Copy_Scale_sig( out_fx, exc_fx, st_fx->L_frame, st_fx->Q_exc ); // Q_exc - - /* update bwe_exc for SWB-TBE */ - FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR ) - { - interp_code_4over2_fx( exc_fx + i_subfr_fx, bwe_exc_fx + shl( i_subfr_fx, 1 ), L_SUBFR ); - } - - free( PREVP ); - free( CURRP ); - } - } - - /* SC-VBR */ - st_fx->prev_gain_pit_dec_fx = gain_pit_fx; - move16(); /*Q14*/ - st_fx->prev_tilt_code_dec_fx = st_fx->tilt_code_fx; - move16(); /*Q15*/ - - return error; -} - -/*======================================================================*/ -/* FUNCTION : decod_gen_voic_ivas_fx() */ -/*----------------------------------------------------------------------*/ -/* PURPOSE : Decode generic (GC), voiced (VC) and AMR-WB IO frames */ -/* */ -/*----------------------------------------------------------------------*/ -/* GLOBAL INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : decoder static memory */ -/* _ (Word16) L_frame : length of the frame */ - -/* _ (Word16[]) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) Es_pred_fx : predicted scaled innov. energy Q8 */ -/* _ (Word16[]) pitch_buf_fx : floating pitch values for each subframe Q6*/ -/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ -/*----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ -/*----------------------------------------------------------------------*/ - - -/*----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*======================================================================*/ -#endif -ivas_error decod_gen_voic_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 L_frame, /* i : length of the frame */ - const Word16 sharpFlag_fx, /* i : formant sharpening flag */ - const Word16 *Aq_fx, /* i : LP filter coefficient Q12*/ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */ - const Word16 do_WI_fx, /* i : do interpolation after a FER */ - Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15 */ - Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */ - Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */ - Word16 *unbits, /* number of unused bits */ - Word16 *gain_buf, - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 L_frame, /* i : length of the frame */ + const Word16 sharpFlag_fx, /* i : formant sharpening flag */ + const Word16 *Aq_fx, /* i : LP filter coefficient Q12 */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy Q8 */ + const Word16 do_WI_fx, /* i : do interpolation after a FER */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe Q6 */ + Word16 *voice_factors_fx, /* o : voicing factors Q15 */ + Word16 *exc_fx, /* i/o: adapt. excitation exc Q_exc */ + Word16 *exc2_fx, /* i/o: adapt. excitation/total exc Q_exc */ + Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_exc */ + Word16 *unbits, /* number of unused bits */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14 */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ ) { - - - Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ + Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ Word16 gain_pit_fx; /* pitch gain Q14 */ Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ @@ -536,7 +62,7 @@ ivas_error decod_gen_voic_ivas_fx( Word16 code_fx[L_SUBFR]; /* algebraic codevector Q12 */ const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ - Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ + Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ Word16 i_subfr_fx, i; /* tmp variables */ Word16 error_fx; Word16 gain_preQ_fx; /* Gain of prequantizer excitation */ @@ -633,10 +159,8 @@ ivas_error decod_gen_voic_ivas_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - /**pt_pitch_fx = pit_decode_fx(st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, - &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR);*/ - *pt_pitch_fx = pit_decode_ivas_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, - &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); + *pt_pitch_fx = pit_decode_fx( st_fx, st_fx->core_brate, 0, L_frame, i_subfr_fx, st_fx->coder_type, &pitch_limit_flag_fx, + &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); move16(); /*Q6*/ /*--------------------------------------------------------------* @@ -677,7 +201,7 @@ ivas_error decod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { - gain_dec_lbr_ivas_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR ); + gain_dec_lbr_fx( st_fx, st_fx->coder_type, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_SUBFR ); } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { @@ -700,13 +224,11 @@ ivas_error decod_gen_voic_ivas_fx( } /* update LP filtered gains for the case of frame erasures */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); } ELSE -#endif { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, L_add( norm_gain_code_fx, norm_gain_preQ_fx ), &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_frame ); } @@ -790,10 +312,6 @@ ivas_error decod_gen_voic_ivas_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ - /*prep_tbe_exc_fx(L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate);*/ - Word16 idx; idx = 0; move16(); @@ -802,10 +320,10 @@ ivas_error decod_gen_voic_ivas_fx( idx = idiv1616( i_subfr_fx, L_SUBFR ); } - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); + prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[idx], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, + st_fx->Q_exc, T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*----------------------------------------------------------------* @@ -819,14 +337,12 @@ ivas_error decod_gen_voic_ivas_fx( } ELSE { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { enhancer_fx( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); } ELSE -#endif { enhancer_ivas_fx2( st_fx->core_brate, 0, st_fx->coder_type, i_subfr_fx, L_frame, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index fe7d2daaf..a18029cdc 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -14,13 +14,13 @@ /*--------------------------------------------------------------------------*/ /* INPUT ARGUMENTS : */ /* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q0 */ +/* _ (Word16) coder_type : coding type Q0 */ /* _ (Word16) nb_subfr_fx :Number of subframe considered */ /* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ /*--------------------------------------------------------------------------*/ /* OUTPUT ARGUMENTS : */ /* _ (Word16*) pitch_buf_fx : floating pitch values for each subframe Q6 */ -/* _ (Word16*) code_fx : innovation Q12 */ +/* _ (Word16*) code_fx : innovation Q12 */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ /* Decoder_State_fx *st_fx : decoder state structure */ @@ -30,438 +30,29 @@ /* _ None */ /*==========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void dec_pit_exc_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* i : LP filter coefficient */ - const Word16 coder_type, /* i : coding type */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */ - Word16 *code_fx, /* o : innovation */ - Word16 *exc_fx, /* i/o: adapt. excitation exc */ - Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ - const Word16 nb_subfr_fx /* i : Number of subframe considered */ - , - Word16 *gain_buf /*Q14*/ -) -{ - Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx; /* pitch gain Q14 */ - Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ - Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ - Word16 gain_inov_fx; /* Innovation gain Q12 */ - Word16 voice_fac_fx; /* voicing factor Q15 */ - Word16 L_subfr_fx, pit_idx_fx; - const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ - Word16 *pt_pitch_fx; /* pointer to floating pitch Q6 */ - Word16 i_subfr_fx, i; /* tmp variables */ - Word32 Local_BR_fx, Pitch_BR_fx; - Word16 pitch_limit_flag, Pitch_CT_fx; - Word16 exc2_bidon[L_SUBFR]; - Word16 *pt_gain; /* Pointer to floating gain values for each subframe */ - - Word16 gain_code16, gain_pitx2; - Word32 L_tmp; - Word16 nbits; - GSC_DEC_HANDLE hGSCDec; - gain_pit_fx = 0; - move16(); - hGSCDec = st_fx->hGSCDec; - - MUSIC_POSTFILT_HANDLE hMusicPF; - hMusicPF = st_fx->hMusicPF; - - Word16 use_fcb; - Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ - Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move16(); -#endif - - use_fcb = 0; - move16(); - test(); - test(); - IF( ( st_fx->GSC_IVAS_mode > 0 ) && ( EQ_16( st_fx->GSC_noisy_speech, 1 ) || GT_32( st_fx->core_brate, GSC_H_RATE_STG ) ) ) - { - Local_BR_fx = ACELP_8k00; - Pitch_CT_fx = GENERIC; - Pitch_BR_fx = ACELP_8k00; - move32(); - move32(); - move16(); - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Local_BR_fx = ACELP_14k80; - move32(); - if ( st_fx->GSC_IVAS_mode > 0 ) - { - Local_BR_fx = ACELP_9k60; - move32(); - } - Pitch_BR_fx = st_fx->core_brate; - move32(); - } - } - ELSE IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - Local_BR_fx = ACELP_7k20; - move32(); - Pitch_CT_fx = GENERIC; - move16(); - Pitch_BR_fx = ACELP_7k20; - move32(); - if ( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Pitch_BR_fx = st_fx->core_brate; - move32(); - } - } - ELSE - { - Local_BR_fx = ACELP_7k20; - move32(); - Pitch_CT_fx = AUDIO; - move16(); - Pitch_BR_fx = st_fx->core_brate; - move32(); - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - Pitch_BR_fx = ACELP_13k20; - move32(); - Pitch_CT_fx = GENERIC; - move16(); - } - } - L_subfr_fx = mult_r( st_fx->L_frame, div_s( 1, nb_subfr_fx ) ); /* TV2Opt : this could be less complex with 2 ifs*/ - - - gain_code_fx = 0; - move16(); - pitch_limit_flag = 1; - move16(); /* always extended pitch Q range */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || ( EQ_16( st_fx->GSC_noisy_speech, 1 ) && ( ( EQ_16( st_fx->L_frame, L_FRAME ) && GE_32( st_fx->core_brate, ACELP_13k20 ) ) || ( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, GSC_H_RATE_STG ) ) || st_fx->GSC_IVAS_mode == 0 ) ) ) && EQ_16( L_subfr_fx, L_SUBFR ) ) ) - { - use_fcb = 1; - move16(); - } - ELSE IF( ( st_fx->GSC_IVAS_mode > 0 ) && EQ_16( L_subfr_fx, 2 * L_SUBFR ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) - { - use_fcb = 2; - st_fx->acelp_cfg.fcb_mode = 1; - move16(); - move16(); - set16_fx( st_fx->acelp_cfg.gains_mode, 6, 4 ); - set16_fx( st_fx->acelp_cfg.pitch_bits, 9, 4 ); - set16_fx( st_fx->acelp_cfg.fixed_cdk_index, 14, 5 ); - } - /*------------------------------------------------------------------* - * ACELP subframe loop - *------------------------------------------------------------------*/ - p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */ - pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ - pt_gain = gain_buf; /* pointer to the gain buffer */ - FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx ) - { - /*----------------------------------------------------------------------* - * Decode pitch lag - *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx ); - move16(); - - /*--------------------------------------------------------------* - * Find the adaptive codebook vector. - *--------------------------------------------------------------*/ - - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - - /*--------------------------------------------------------------* - * Innovation decoding - *--------------------------------------------------------------*/ - - IF( EQ_16( use_fcb, 1 ) ) - { - inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); - /*--------------------------------------------------------------* - * Gain decoding - * Estimate spectrum tilt and voicing - *--------------------------------------------------------------*/ - - gain_dec_mless_fx( st_fx, st_fx->L_frame, LOCAL_CT, i_subfr_fx, -1, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx ); - - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); - move16(); - } - ELSE IF( EQ_16( use_fcb, 2 ) ) /* IVAS only */ - { - inov_decode_fx( st_fx, Local_BR_fx, 0, st_fx->L_frame, 1, i_subfr_fx, p_Aq_fx, st_fx->tilt_code_fx, *pt_pitch_fx, code_fx, L_subfr_fx ); - /*--------------------------------------------------------------* - * Gain decoding - * Estimate spectrum tilt and voicing - *--------------------------------------------------------------*/ - - gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); - - st_fx->tilt_code_fx = est_tilt_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0 ); - move16(); - } - ELSE - { - nbits = 5; - move16(); - if ( LT_32( st_fx->core_brate, MIN_RATE_FCB ) ) - { - nbits = 4; - move16(); - } - - set16_fx( code_fx, 0, L_SUBFR ); - gain_code_fx = L_deposit_l( 0 ); - st_fx->tilt_code_fx = 0; - move16(); - pit_idx_fx = (Word16) get_next_indice( st_fx, nbits ); - move16(); - - gain_pit_fx = add( 9590, dic_gp_fx[pit_idx_fx] ); - move16(); /*Q14 0.5853 in Q14 9590*/ - - if ( st_fx->BER_detect ) /* Bitstream is corrupted, use the past pitch gain */ - { - gain_pit_fx = st_fx->lp_gainp_fx; - move16(); - } - gain_code_fx = L_mult0( s_max( sub( 32767, shl_o( gain_pit_fx, 1, &Overflow ) ), 16384 ), st_fx->lp_gainc_fx ); /* Use gain pitch and past gain code as an indicator to help finding the best scaling value. gain_code_fx used a temp var*/ - } - - /*----------------------------------------------------------------------* - * Find the total excitation - *----------------------------------------------------------------------*/ - - Rescale_exc( hMusicPF->dct_post_old_exc_fx, &exc_fx[i_subfr_fx], &bwe_exc_fx[( i_subfr_fx * ( 2 * HIBND_ACB_L_FAC ) ) / 2], hGSCDec->last_exc_dct_in_fx, - L_subfr_fx, shr( imult1616( L_subfr_fx, 2 * HIBND_ACB_L_FAC ), 1 ), gain_code_fx, &( st_fx->Q_exc ), st_fx->Q_subfr, NULL, i_subfr_fx, coder_type ); - - gain_code16 = round_fx( L_shl( gain_code_fx, st_fx->Q_exc ) ); /*Q_exc*/ - - IF( use_fcb != 0 ) - { - Acelp_dec_total_exc( exc_fx, exc2_bidon - i_subfr_fx, gain_code16, gain_pit_fx, i_subfr_fx, code_fx, L_subfr_fx ); - } - ELSE - { - IF( norm_s( s_or( gain_pit_fx, 1 ) ) == 0 ) - { - FOR( i = 0; i < L_subfr_fx; i++ ) - { - L_tmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 ); /*Q16+Q_exc*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ - move16(); - } - } - ELSE - { - gain_pitx2 = shl( gain_pit_fx, 1 ); /*Q15*/ - - FOR( i = 0; i < L_subfr_fx; i++ ) - { - L_tmp = L_mult( gain_pitx2, exc_fx[i + i_subfr_fx] ); /*Q16+Q_exc*/ - exc_fx[i + i_subfr_fx] = round_fx_sat( L_tmp ); /*Q_exc*/ - move16(); - } - } - } - - IF( EQ_16( L_subfr_fx, L_FRAME16k ) ) - { - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = gain_pit_fx; - move16(); - st_fx->lp_gainc_fx = 0; - move32(); - - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - move16(); - move16(); - move16(); - move16(); - p_Aq_fx += 5 * ( M + 1 ); - } - ELSE IF( EQ_16( L_subfr_fx, L_FRAME16k / 2 ) ) - { - IF( i_subfr_fx == 0 ) - { - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - p_Aq_fx += 2 * ( M + 1 ); - move16(); - - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = extract_h( L_mult( 6554, gain_pit_fx ) ); /*Q14 (3/15 in Q15 9830)*/ - st_fx->lp_gainc_fx = 0; - move16(); - move16(); - } - ELSE - { - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - pt_pitch_fx++; - p_Aq_fx += 3 * ( M + 1 ); - move16(); - move16(); - - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = extract_h( L_mult( 26214, gain_pit_fx ) ); /*Q14 (12/15 in Q15 9830)*/ - st_fx->lp_gainc_fx = 0; - move16(); - move16(); - } - } - ELSE IF( EQ_16( L_subfr_fx, 128 ) ) /*2*L_SUBFR*/ - { - p_Aq_fx += 2 * ( M + 1 ); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - move16(); - pt_pitch_fx++; - *pt_gain = gain_pit_fx; - move16(); - pt_gain++; - *pt_gain = *( pt_gain - 1 ); - move16(); - pt_gain++; - IF( i_subfr_fx == 0 ) - { - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = extract_h( L_mult( 9830, gain_pit_fx ) ); /*Q14 (3/10 in Q15 9830)*/ - st_fx->lp_gainc_fx = 0; - move16(); - move16(); - } - ELSE - { - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = extract_h( L_mult( 22938, gain_pit_fx ) ); /*Q14 (7/10 in Q15 22938)*/ - st_fx->lp_gainc_fx = 0; - move16(); - move16(); - } - } - ELSE IF( EQ_16( L_subfr_fx, 256 ) ) /*4*L_SUBFR*/ - { - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - move16(); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - move16(); - pt_pitch_fx++; - *pt_pitch_fx = *( pt_pitch_fx - 1 ); - move16(); - pt_pitch_fx++; - *pt_gain = gain_pit_fx; - move16(); - pt_gain++; - *pt_gain = *( pt_gain - 1 ); - move16(); - pt_gain++; - *pt_gain = *( pt_gain - 1 ); - move16(); - pt_gain++; - *pt_gain = *( pt_gain - 1 ); - move16(); - pt_gain++; - p_Aq_fx += 4 * ( M + 1 ); - - /* update gains for FEC - equivalent to lp_gain_updt() */ - st_fx->lp_gainp_fx = gain_pit_fx; - move16(); - st_fx->lp_gainc_fx = 0; - move16(); - } - ELSE - { - p_Aq_fx += ( M + 1 ); - move16(); - pt_pitch_fx++; - move16(); - *pt_gain = gain_pit_fx; - move16(); - pt_gain++; - - lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, 0, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, st_fx->L_frame ); - } - } - - return; -} - -/*==========================================================================*/ -/* FUNCTION : void dec_pit_exc_ivas_fx() */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Decode pitch only contribution */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16*) Aq_fx : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) nb_subfr_fx :Number of subframe considered */ -/* _ (Word16) Es_pred_fx :predicted scaled innov. energy */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) pitch_buf_fx : Word16 pitch values for each subframe Q6 */ -/* _ (Word16*) code_fx : innovation */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State_fx *st_fx : decoder state structure */ -/* _ (Word16*) exc_fx : adapt. excitation exc */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*==========================================================================*/ -#endif -void dec_pit_exc_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* i : LP filter coefficient */ const Word16 coder_type, /* i : coding type */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ + Word16 *pitch_buf_fx, /* o : Word16 pitch values for each subframe */ Word16 *code_fx, /* o : innovation */ Word16 *exc_fx, /* i/o: adapt. excitation exc */ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */ const Word16 nb_subfr_fx, /* i : Number of subframe considered */ - Word16 *gain_buf, /*Q14*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ) { - Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ - Word16 gain_pit_fx; /* pitch gain Q14 */ - Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ + Word16 T0_fx, T0_frac_fx, T0_min_fx, T0_max_fx; /* integer pitch variables */ + Word16 gain_pit_fx; /* pitch gain Q14 */ + Word32 gain_code_fx; /* gain/normalized gain of the algebraic excitation Q16 */ Word32 norm_gain_code_fx; /* normalized gain of the algebraic excitation Q16 */ - Word16 gain_inov_fx; /* Innovation gain Q12 */ + Word16 gain_inov_fx; /* Innovation gain Q12 */ Word16 voice_fac_fx; /* voicing factor Q15 */ Word16 L_subfr_fx, pit_idx_fx; - const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ + const Word16 *p_Aq_fx; /* Pointer to frame LP coefficient Q12 */ Word16 *pt_pitch_fx; /* pointer to Word16 pitch Q6 */ Word16 i_subfr_fx, i; /* tmp variables */ Word32 Local_BR_fx, Pitch_BR_fx; @@ -578,13 +169,14 @@ void dec_pit_exc_ivas_fx( p_Aq_fx = Aq_fx; /* pointer to interpolated LPC parameters */ pt_pitch_fx = pitch_buf_fx; /* pointer to the pitch buffer */ pt_gain = gain_buf; /* pointer to the gain buffer */ + FOR( i_subfr_fx = 0; i_subfr_fx < st_fx->L_frame; i_subfr_fx += L_subfr_fx ) { /*----------------------------------------------------------------------* * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch_fx = pit_decode_ivas_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); + *pt_pitch_fx = pit_decode_fx( st_fx, Pitch_BR_fx, 0, st_fx->L_frame, i_subfr_fx, Pitch_CT_fx, &pitch_limit_flag, &T0_fx, &T0_frac_fx, &T0_min_fx, &T0_max_fx, L_subfr_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); move16(); /*--------------------------------------------------------------* @@ -621,7 +213,7 @@ void dec_pit_exc_ivas_fx( * Estimate spectrum tilt and voicing *--------------------------------------------------------------*/ - gain_dec_lbr_ivas_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); + gain_dec_lbr_fx( st_fx, GENERIC, i_subfr_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, gc_mem, gp_mem, L_subfr_fx ); st_fx->tilt_code_fx = est_tilt_ivas_fx( exc_fx + i_subfr_fx, gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, 0, L_subfr_fx, 0 ); move16(); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 281281ed6..37d088a8f 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -33,10 +33,7 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor ); -#ifndef REMOVE_EVS_DUPLICATES static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); -#endif -static void Dec_formant_postfilt_ivas_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 ); static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl ); @@ -82,7 +79,7 @@ void Init_post_filter_fx( *--------------------------------------------------------------------------*/ void nb_post_filt_fx( const Word16 L_frame, /* i : frame length */ - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *psf_lp_noise, /* i : Long term noise Q8 */ const Word16 tmp_noise, /* i : noise energy Q0 */ Word16 *Synth, /* i : 12k8 synthesis Qsyn */ @@ -257,22 +254,20 @@ static void Dec_postfilt_fx( * Main routine to perform formant post filtering *--------------------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES void formant_post_filt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ + Word16 *Aq, /* i : LP filter coefficient Q12 */ Word16 *synth_out, /* i/o: input signal */ - Word16 L_frame, - Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ + const Word16 L_frame, /* i : frame length */ + const Word32 lp_noise, /* (i) : background noise energy (15Q16) */ + const Word32 brate, /* (i) : bit-rate */ + const Word16 off_flag /* i : off flag */ ) { Word16 i_subfr; Word16 *p_Aq; - Word16 post_G1, post_G2; // Q15 - + Word16 post_G1, post_G2; /*default parameter for noisy speech and high bit-rates*/ IF( EQ_16( L_frame, L_FRAME ) ) @@ -381,134 +376,13 @@ void formant_post_filt_fx( Dec_formant_postfilt_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); p_Aq += ( M + 1 ); } -} -#endif -void formant_post_filt_ivas_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *synth_in, /* i : 12k8 synthesis */ - Word16 *Aq, /* i : LP filter coefficient Q12 */ - Word16 *synth_out, /* i/o: input signal */ - Word16 L_frame, - Word32 lp_noise, /* (i) : background noise energy (15Q16) */ - Word32 brate, /* (i) : bit-rate */ - const Word16 off_flag /* i : off flag */ -) -{ - Word16 i_subfr; - Word16 *p_Aq; - Word16 post_G1, post_G2; - - - /*default parameter for noisy speech and high bit-rates*/ - IF( EQ_16( L_frame, L_FRAME ) ) - { - post_G2 = 22938 /*0.7f Q15*/; - move16(); - IF( LT_32( lp_noise, LP_NOISE_THRESH ) ) - { - /*Clean speech*/ - IF( LT_32( brate, ACELP_13k20 ) ) - { - /*Low rates*/ - - post_G1 = 26214 /*0.8f Q15*/; - move16(); - } - ELSE IF( LT_32( brate, ACELP_24k40 ) ) - { - /*Low rates*/ - - post_G1 = 24576 /*0.75f Q15*/; - move16(); - } - ELSE - { - post_G1 = 23593 /*0.72f Q15*/; - move16(); - } - } - ELSE /*Noisy speech*/ - { - post_G1 = 22938 /*0.7f Q15*/; - move16(); - if ( LT_32( brate, ACELP_15k85 ) ) - { - /*Low rates*/ - post_G1 = 24576 /*0.75f Q15*/; - move16(); - } - } - } - ELSE - { - post_G2 = 24904 /*0.76f Q15*/; - move16(); - test(); - IF( GE_32( lp_noise, LP_NOISE_THRESH ) ) - { - post_G1 = 24904 /*0.76f Q15*/; - } - ELSE IF( EQ_32( brate, ACELP_13k20 ) ) - { - post_G1 = 26870 /*0.82f Q15*/; - move16(); - } - ELSE IF( EQ_32( brate, ACELP_16k40 ) ) - { - post_G1 = 26214 /*0.80f Q15*/; - move16(); - } - ELSE IF( EQ_32( brate, ACELP_24k40 ) || EQ_32( brate, ACELP_32k ) ) - { - post_G1 = 25559 /*0.78f Q15*/; - move16(); - } - ELSE - { - post_G1 = 24904 /*0.76f Q15*/; - move16(); - } - } - /* Switch off post-filter */ - if ( off_flag != 0 ) - { - post_G1 = post_G2; - move16(); - } - - /* Reset post filter */ - IF( hPFstat->reset != 0 ) - { - post_G1 = MAX16B; - move16(); - post_G2 = MAX16B; - move16(); - hPFstat->reset = 0; - move16(); - Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); - Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_stp, L_SYN_MEM ); - hPFstat->gain_prec = 16384; // 1.Q14 - move16(); - Copy( synth_in, synth_out, L_frame ); - - return; - } + return; +} - /* input memory*/ - Copy( hPFstat->mem_pf_in, synth_in - L_SYN_MEM, L_SYN_MEM ); - Copy( &synth_in[L_frame - L_SYN_MEM], hPFstat->mem_pf_in, L_SYN_MEM ); - move16(); - p_Aq = Aq; // Q12 - FOR( i_subfr = 0; i_subfr < L_frame; i_subfr += L_SUBFR ) - { - Dec_formant_postfilt_ivas_fx( hPFstat, &synth_in[i_subfr], p_Aq, &synth_out[i_subfr], post_G1, post_G2 ); - p_Aq += ( M + 1 ); - } -} /*---------------------------------------------------------------------------- - * Dec_formant_postfilt_fx + * Dec_formant_postfilt_fx() * * Post - adaptive postfilter main function * Short term postfilter : @@ -522,93 +396,14 @@ void formant_post_filt_ivas_fx( * k1 = 1st parcor calculated on {hi} * gamma3 = gamma3_minus if k1<0, gamma3_plus if k1>0 *----------------------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES -static void Dec_formant_postfilt_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ - Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ - Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/ -) -{ - /* Local variables and arrays */ - Word16 apond1[M + 1]; /* s.t. denominator coeff. Q12*/ - Word16 apond2[LONG_H_ST]; // Q12 - Word16 res2[L_SUBFR]; // Q14 - Word16 resynth[L_SUBFR + 1]; // Qy - Word16 parcor0; // Q15 - Word16 i, max; - Word16 scale_down; - - /* Compute weighted LPC coefficients */ - weight_a_fx( coeff, apond1, gamma1, M ); - weight_a_fx( coeff, apond2, gamma2, M ); - set16_fx( &apond2[M + 1], 0, LONG_H_ST - ( M + 1 ) ); - max = abs_s( signal_ptr[0] ); // Q14 - FOR( i = 1; i < L_SUBFR; i++ ) - { - max = s_max( max, abs_s( signal_ptr[i] ) ); - } - scale_down = 0; - move16(); - if ( GT_16( max, 16384 /*1.Q14*/ ) ) - { - scale_down = 1; - move16(); - } - - /* Compute A(gamma2) residual */ - IF( !scale_down ) - { - Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 1 ); - } - ELSE - { - Residu3_fx( apond2, signal_ptr, res2, L_SUBFR, 0 ); - Scale_sig( hPFstat->mem_stp, L_SYN_MEM, -1 ); - } - - /* Controls short term pst filter gain and compute parcor0 */ - calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero ); - - /* 1/A(gamma1) filtering, mem_stp is updated */ - resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) ); - move16(); - - E_UTIL_synthesis( 1, apond1, res2, &( resynth[1] ), L_SUBFR, hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); - - IF( !scale_down ) - { - Copy( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM ); - } - ELSE - { - Copy_Scale_sig( &( resynth[1] ) + L_SUBFR - L_SYN_MEM, hPFstat->mem_stp, L_SYN_MEM, 1 ); - } - - /* Tilt filtering */ - Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR ); - IF( scale_down ) - { - Scale_sig( sig_out, L_SUBFR, 1 ); - } - - /* Gain control */ - scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR ); - - - return; -} -#endif -static void Dec_formant_postfilt_ivas_fx( - PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ - Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ - Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ - Word16 *sig_out, /* o : postfiltered output */ - Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ - Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/ +static void Dec_formant_postfilt_fx( + PFSTAT_HANDLE hPFstat, /* i : core decoder parameters */ + Word16 *signal_ptr, /* i : input signal (pointer to current subframe Q14*/ + Word16 *coeff, /* i : LPC coefficients for current subframe Q12 */ + Word16 *sig_out, /* o : postfiltered output */ + Word16 gamma1, /* i : short term postfilt. den. weighting factor Q15*/ + Word16 gamma2 /* i : short term postfilt. num. weighting factor Q15*/ ) { /* Local variables and arrays */ diff --git a/lib_dec/dec_ppp_fx.c b/lib_dec/dec_ppp_fx.c index 4849e147a..4b3f4f554 100644 --- a/lib_dec/dec_ppp_fx.c +++ b/lib_dec/dec_ppp_fx.c @@ -6,6 +6,7 @@ #include #include "options.h" /* Compilation switches */ #include "prot_fx.h" /* Function prototypes */ + /*===================================================================*/ /* FUNCTION : void decod_ppp_fx () */ /*-------------------------------------------------------------------*/ @@ -45,20 +46,20 @@ /*-------------------------------------------------------------------*/ /* CALLED FROM : RX */ /*===================================================================*/ + ivas_error decod_ppp_fx( - Decoder_State *st_fx, /* i/o: state structure */ - const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ - Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ - Word16 *exc_fx, /* i/o: current non-enhanced excitation */ - Word16 *exc2_fx, /* i/o: current enhanced excitation */ - Word16 bfi, /* i : bad frame indicator */ - Word16 *gain_buf, + Decoder_State *st_fx, /* i/o: state structure */ + const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */ + Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */ + Word16 *exc_fx, /* i/o: current non-enhanced excitation */ + Word16 *exc2_fx, /* i/o: current enhanced excitation */ + Word16 bfi, /* i : bad frame indicator */ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ Word16 *voice_factors, /* o : voicing factors */ Word16 *bwe_exc_fx /* o : excitation for SWB TBE */ ) { Word16 k; - Word16 LPC_de_curr_fx[M + 1], p_Aq_curr_fx[M], p_Aq_old_fx[M + 1]; Word16 excQ_ppp_fx[L_FRAME], pitch_fx[NB_SUBFR], LPC_de_old_fx[M + 1]; ivas_error error; diff --git a/lib_dec/dec_tran_fx.c b/lib_dec/dec_tran_fx.c index c5b06724a..de3a1ff3f 100644 --- a/lib_dec/dec_tran_fx.c +++ b/lib_dec/dec_tran_fx.c @@ -254,16 +254,10 @@ void decod_tran_fx( tmp_idx_2 = idiv1616( i_subfr, L_SUBFR ); } -#ifdef REMOVE_EVS_DUPLICATES - prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); -#else - prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[tmp_idx_2], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, - st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); -#endif + st_fx->Q_exc, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*----------------------------------------------------------------* * Excitation enhancements (update of total excitation signal) diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index fcc2600a3..f1ba21979 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -25,96 +25,7 @@ static void gain_dec_gacelp_uv_fx( * Decode unvoiced (UC) frames *-------------------------------------------------------------------*/ -#ifndef REMOVE_EVS_DUPLICATES void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ - Word16 *gain_buf ) -{ - Word16 gain_pit_fx; /* Quantized pitch gain */ - Word32 gain_code_fx; /* Quantized algebraic codeebook gain */ - Word16 gain_inov_fx; /* inovation gain */ - Word32 norm_gain_code_fx; /* normalized algebraic codeebook gain */ - Word16 voice_fac_fx; /* Voicing factor */ - Word16 code_fx[L_SUBFR]; /* algebraic codevector */ - Word16 i_subfr_fx; - const Word16 *p_Aq_fx; - Word16 *pt_pitch_fx; - - gain_pit_fx = 0; - move16(); - - test(); - IF( EQ_16( st_fx->last_ppp_mode_dec, 1 ) || EQ_16( st_fx->last_nelp_mode_dec, 1 ) ) - { - /* SC_VBR - reset the decoder, to avoid memory not updated issue for this unrealistic case */ - CNG_reset_dec_fx( st_fx, pitch_buf_fx, voice_factors_fx ); - } - - p_Aq_fx = Aq_fx; - move16(); /*Q12*/ /* pointer to interpolated LPC parameters */ - pt_pitch_fx = pitch_buf_fx; - move16(); /* pointer to the pitch buffer */ - - FOR( i_subfr_fx = 0; i_subfr_fx < L_FRAME; i_subfr_fx += L_SUBFR ) - { - /*----------------------------------------------------------------* - * Unvoiced subframe processing - *----------------------------------------------------------------*/ - - gaus_dec_fx( st_fx, i_subfr_fx, code_fx, &norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, &gain_inov_fx, &st_fx->tilt_code_fx, - &voice_fac_fx, &gain_pit_fx, pt_pitch_fx, exc_fx, &gain_code_fx, exc2_fx, bwe_exc_fx, &( st_fx->Q_exc ), st_fx->Q_subfr ); - - *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/ - move16(); - - /*----------------------------------------------------------------* - * Excitation enhancements (update of total excitation signal) - *----------------------------------------------------------------*/ - - enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, - norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); - - Word16 tmp_idx = 0; - move16(); - IF( i_subfr_fx != 0 ) - { - tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); - } - voice_factors_fx[tmp_idx] = 0; - move16(); - - interp_code_5over2_fx( &exc_fx[i_subfr_fx], &bwe_exc_fx[( ( i_subfr_fx * 2 * HIBND_ACB_L_FAC ) >> 1 )], L_SUBFR ); - - p_Aq_fx += ( M + 1 ); - pt_pitch_fx++; - st_fx->tilt_code_dec_fx[tmp_idx] = st_fx->tilt_code_fx; - move16(); - } - - /* SC-VBR */ - st_fx->prev_gain_pit_dec_fx = gain_pit_fx; - move16(); - - set16_fx( gain_buf, 0, NB_SUBFR ); - - return; -} - -/*-------------------------------------------------------------------* - * decod_unvoiced() - * - * Decode unvoiced (UC) frames - *-------------------------------------------------------------------*/ -#endif -void decod_unvoiced_ivas_fx( Decoder_State *st_fx, /* i/o: decoder static memory */ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ @@ -208,13 +119,11 @@ void decod_unvoiced_ivas_fx( move16(); /* update LP filtered gains for the case of frame erasures */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { lp_gain_updt_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); } ELSE -#endif { lp_gain_updt_ivas_fx( i_subfr_fx, gain_pit_fx, norm_gain_code_fx, &st_fx->lp_gainp_fx, &st_fx->lp_gainc_fx, L_FRAME ); } @@ -250,6 +159,7 @@ void decod_unvoiced_ivas_fx( } // Scale_sig(code_fx, L_SUBFR, 3); //Q12 } + *tmp_noise_fx = extract_h( norm_gain_code_fx ); /*Q16*/ move16(); @@ -257,14 +167,12 @@ void decod_unvoiced_ivas_fx( * Excitation enhancements (update of total excitation signal) *----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { enhancer_fx( st_fx->core_brate, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); } ELSE -#endif { enhancer_ivas_fx( MODE1, st_fx->core_brate, uc_two_stage_flag, 0, coder_type, i_subfr_fx, L_FRAME, voice_fac_fx, st_fx->stab_fac_fx, norm_gain_code_fx, gain_inov_fx, &st_fx->gc_threshold_fx, code_fx /*Q9/Q12?*/, exc2_fx, gain_pit_fx, &( st_fx->dm_fx ), st_fx->Q_exc ); @@ -276,12 +184,6 @@ void decod_unvoiced_ivas_fx( IF( i_subfr_fx != 0 ) { tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); -#ifdef REMOVE_EVS_DUPLICATES - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { - tmp_idx = idiv1616( i_subfr_fx, L_SUBFR ); - } -#endif } voice_factors_fx[tmp_idx] = 0; move16(); diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 38bd7de24..6411eb477 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -332,11 +332,7 @@ ivas_error evs_dec_fx( IF( EQ_16( st_fx->core, ACELP_CORE ) ) { /* ACELP core decoder */ -#ifdef REMOVE_EVS_DUPLICATES - IF( ( error = acelp_core_dec_ivas_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) -#else IF( ( error = acelp_core_dec_fx( st_fx, NULL, synth_fx, NULL, bwe_exc_extended_fx, voice_factors_fx, old_syn_12k8_16k_fx, sharpFlag, pitch_buf_fx, &unbits, &sid_bw, NULL, NULL, NULL, 0, EVS_MONO, 0, 0, 1, NULL, 1 ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -957,11 +953,9 @@ ivas_error evs_dec_fx( } st_fx->lp_noise = hFdCngDec->lp_noise; /*Q9.23*/ move32(); -#ifdef REMOVE_EVS_DUPLICATES - ApplyFdCng_ivas_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); -#else - ApplyFdCng_fx( output_sp, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); -#endif + + ApplyFdCng_fx( output_sp, 0, NULL, 0, realBuffer, imagBuffer, &st_fx->scaleFactor.hb_scale, st_fx, concealWholeFrame, 0 ); + /* Generate additional comfort noise to mask potential coding artefacts */ test(); IF( EQ_16( st_fx->m_frame_type, ACTIVE_FRAME ) && st_fx->flag_cna ) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 3fe93854e..cc83eeca3 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -555,463 +555,7 @@ void deleteFdCngDec_fx( HANDLE_FD_CNG_DEC *hFdCngDec ) error */ -#ifndef REMOVE_EVS_DUPLICATES Word16 ApplyFdCng_fx( - Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ - Word16 Q, - Word32 **cldfbBufferReal, /* i/o: real part of the CLDFB buffer cldfbBufferScale*/ - Word32 **cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer cldfbBufferScale*/ - Word16 *cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */ - Decoder_State *st, - const Word16 concealWholeFrame, /* i : binary flag indicating frame loss Q0*/ - Word16 is_music /*Q0*/ ) -{ - Word16 j, k, nBins; - Word16 s, s1, s2, num, denom; - Word32 *cngNoiseLevel; - Word16 *cngNoiseLevel_exp; - Word32 L_tmp; - Word16 L_tmp_exp; - Word16 facTab[NPART]; - Word16 facTabExp[NPART]; - Word16 tmp_loop; - Word32 L_c; - Word16 lsp_cng[M]; - HANDLE_FD_CNG_DEC hFdCngDec; - HANDLE_FD_CNG_COM hFdCngCom; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - Flag Carry = 0; - move16(); - move16(); -#endif - - hFdCngDec = st->hFdCngDec; - hFdCngCom = hFdCngDec->hFdCngCom; - - - if ( EQ_16( hFdCngCom->frame_type_previous, ACTIVE_FRAME ) ) - { - hFdCngCom->inactive_frame_counter = 0; - move16(); - } - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - hFdCngDec->flag_dtx_mode = hFdCngDec->flag_dtx_mode || st->first_CNG; - test(); - move16(); - } - cngNoiseLevel = hFdCngCom->cngNoiseLevel; /*Q31 - hFdCngCom->cngNoiseLevelExp*/ - move32(); - cngNoiseLevel_exp = &hFdCngCom->cngNoiseLevelExp; - move16(); - nBins = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - - SWITCH( st->m_frame_type ) - { - case ACTIVE_FRAME: - - /************************** - * ACTIVE_FRAME at DECODER * - **************************/ - - hFdCngCom->inactive_frame_counter = 0; - move16(); - hFdCngCom->sid_frame_counter = 0; - move16(); - - /* set noise estimation inactive during concealment, as no update with noise generated by concealment should be performed. */ - /* set noise estimation inactive during concealment, no update with noise generated by concealment should be performed. */ - - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( - ( concealWholeFrame == 0 ) && - ( LT_16( *timeDomainInput, MAXVAL_WORD16 ) ) && GT_16( *timeDomainInput, MINVAL_WORD16 ) && ( LT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MAXVAL_WORD16 ) ) && GT_16( *( timeDomainInput + sub( hFdCngCom->frameSize, 1 ) ), MINVAL_WORD16 ) && ( ( ( hFdCngDec->flag_dtx_mode == 0 ) && ( st->VAD != 0 ) ) == 0 ) && ( ( ( st->cng_type == LP_CNG ) && ( hFdCngDec->flag_dtx_mode != 0 ) ) == 0 ) && ( is_music == 0 ) && ( st->BER_detect == 0 ) ) - { - /* Perform noise estimation at the decoder */ - perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); - - /* Update the shaping parameters */ - test(); - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); - } - hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; - move16(); - - - /* Update CNG levels */ - test(); - IF( hFdCngDec->flag_dtx_mode != 0 && EQ_16( st->cng_type, FD_CNG ) ) - { - /* This needs to be done only once per inactive phase */ - bandcombinepow( - hFdCngDec->bandNoiseShape, - hFdCngDec->bandNoiseShape_exp, - nBins, - hFdCngCom->part, - hFdCngCom->nFFTpart, - hFdCngCom->psize_inv, - hFdCngDec->partNoiseShape, - &hFdCngDec->partNoiseShape_exp ); - - - j = 0; - move16(); - s2 = -( WORD32_BITS - 1 ); - move16(); - FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - assert( hFdCngDec->partNoiseShape[k] >= 0 ); - assert( hFdCngCom->sidNoiseEst[k] >= 0 ); - - /* add DELTA as it is done in FLC version, in order to avoid num > denom */ - facTab[k] = 0; - move16(); - IF( hFdCngDec->partNoiseShape[k] != 0 ) - { - s1 = norm_l( hFdCngCom->sidNoiseEst[k] ); - L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/ - L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp ); - L_tmp = L_shr( L_tmp, 1 ); - s = add( L_tmp_exp, 1 ); - num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/ - - s1 = norm_l( hFdCngDec->partNoiseShape[k] ); - L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/ - L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp ); - s = sub( s, L_tmp_exp ); - denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/ - - facTab[k] = div_s( num, denom ); /*Q15 - s*/ - move16(); - facTabExp[k] = s; - move16(); - } - /* Set unique exponent, if mantissa is equal to zero */ - if ( facTab[k] == 0 ) - { - facTabExp[k] = -( WORD32_BITS - 1 ); - move16(); - } - s2 = s_max( s2, facTabExp[k] ); - } - - FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - s = sub( facTabExp[k], s2 ); - s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) ); - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ - move32(); - } - } - - /* adapt scaling for rest of the buffer */ - IF( NE_16( s2, -( WORD32_BITS - 1 ) ) ) - { - s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); - FOR( ; k < hFdCngCom->npart; k++ ) - { - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ - move32(); - } - } - - *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); - move16(); - } - } - ELSE - { - /* This sets the new CNG levels until a SID update overwrites it */ - test(); - test(); - test(); - IF( !( EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( EQ_16( st->element_mode, IVAS_CPE_TD ) && !hFdCngDec->flag_dtx_mode && !st->VAD ) ) - { - Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, nBins ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ - *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; - move16(); - } - } - /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/ - tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - L_tmp = L_deposit_h( 0 ); - L_c = L_deposit_h( 0 ); - FOR( j = 0; j < tmp_loop; j++ ) - { - - Carry = 0; - move16(); - L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/ - Overflow = 0; - move16(); - - IF( *( cngNoiseLevel + j ) < 0 ) - { - L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/ - } - IF( *( cngNoiseLevel + j ) >= 0 ) - { - L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ - } - } - L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ - L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 ); - - L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/ - - L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/ - L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ - L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ - - st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/ - st->cngTDLevel_e = L_tmp_exp; - move16(); - } - ELSE IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - IF( hFdCngCom->active_frame_counter > 0 ) - { - /* Perform noise estimation in active frames in the decoder for downward updates */ - perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); - } - } - test(); - test(); - L_tmp = 0; - FOR( j = hFdCngCom->startBand; j < hFdCngCom->stopFFTbin; j++ ) - { - L_tmp = L_add( L_tmp, L_shr( cngNoiseLevel[j], 16 ) ); - } - L_tmp_exp = add( *cngNoiseLevel_exp, 16 ); - test(); - test(); - IF( EQ_16( concealWholeFrame, 1 ) && EQ_16( st->nbLostCmpt, 1 ) && ( GT_32( L_shl_o( L_tmp, L_tmp_exp, &Overflow ), 21474836 ) /*0.01f Q31*/ ) ) - { - /* update isf cng estimate for concealment. Do that during concealment, in order to avoid addition clean channel complexity*/ - lpc_from_spectrum( hFdCngCom, hFdCngCom->startBand, hFdCngCom->stopFFTbin, 0 ); - E_LPC_a_lsp_conversion( hFdCngCom->A_cng, lsp_cng, st->lspold_cng, M ); - Copy( lsp_cng, st->lspold_cng, M ); /*Q15*/ - - lsp2lsf_fx( lsp_cng, st->lsf_cng, M, st->sr_core ); - st->plcBackgroundNoiseUpdated = 1; - move16(); - } - BREAK; - - case SID_FRAME: - - hFdCngDec->flag_dtx_mode = 1; - move16(); - /* no break */ - - case ZERO_FRAME: - - test(); - IF( st != NULL && st->cng_type == LP_CNG ) - { - /* Perform noise estimation on inactive phase at the decoder */ - perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); - /* Update the shaping parameters */ - - test(); - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); - } - hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; - move16(); - /* This sets the new CNG levels until a SID update overwrites it */ - Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it Q31 - hFdCngDec->bandNoiseShape_exp*/ - *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; - move16(); - /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/ - tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ); - L_tmp = L_deposit_h( 0 ); - L_c = L_deposit_h( 0 ); - FOR( j = 0; j < tmp_loop; j++ ) - { - - Carry = 0; - move16(); - L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/ - Overflow = 0; - move16(); - - IF( *( cngNoiseLevel + j ) < 0 ) - { - L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ - } - IF( *( cngNoiseLevel + j ) >= 0 ) - { - L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/ - } - } - L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/ - L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 ); - - L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/ - - L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/ - L_tmp_exp = add( L_tmp_exp, -7 ); /*->Q16, L_tmp_exp */ - L_tmp_exp = add( L_tmp_exp, 31 - 16 ); /*->Q31, L_tmp_exp*/ - - st->cngTDLevel = round_fx_o( Sqrt32( L_tmp, &L_tmp_exp ), &Overflow ); /*Q15 - L_tmp_exp*/ - move16(); - st->cngTDLevel_e = L_tmp_exp; - move16(); - BREAK; - } - hFdCngCom->inactive_frame_counter = add( hFdCngCom->inactive_frame_counter, 1 ); - move16(); - - /************************************* - * SID_FRAME or ZERO_FRAME at DECODER * - *************************************/ - - /* Detect first non-active frame */ - IF( EQ_16( hFdCngCom->inactive_frame_counter, 1 ) ) - { - /* Compute the fine spectral structure of the comfort noise shape using the decoder-side noise estimates */ - bandcombinepow( - hFdCngDec->bandNoiseShape, - hFdCngDec->bandNoiseShape_exp, - nBins, - hFdCngCom->part, - hFdCngCom->nFFTpart, - hFdCngCom->psize_inv, - hFdCngDec->partNoiseShape, - &hFdCngDec->partNoiseShape_exp ); - } - - IF( EQ_16( st->m_frame_type, SID_FRAME ) ) - { - IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) - { - /* At initialization, interpolate the bin/band-wise levels from the partition levels */ - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); - *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; - move16(); - } - ELSE - { - if ( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - } - - /* Interpolate the CLDFB band levels from the SID (partition) levels */ - IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) - { - scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, - hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); - *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; - move16(); - } - - s2 = -( WORD32_BITS - 1 ); - move16(); - /* Shape the SID noise levels in each FFT bin */ - j = 0; - move16(); - FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - assert( hFdCngDec->partNoiseShape[k] >= 0 ); - - /* add DELTA as it is done in FLC version, in order to avoid num > denom */ - facTab[k] = 0; - move16(); - IF( hFdCngDec->partNoiseShape[k] != 0 ) - { - s1 = norm_l( hFdCngCom->sidNoiseEst[k] ); - L_tmp = L_shl( hFdCngCom->sidNoiseEst[k], s1 ); /*Q31 - hFdCngCom->sidNoiseEstExp + s1*/ - L_tmp_exp = sub( hFdCngCom->sidNoiseEstExp, s1 ); - L_tmp = BASOP_Util_Add_Mant32Exp( hFdCngCom->sidNoiseEst[k], hFdCngCom->sidNoiseEstExp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp ); - L_tmp = L_shr( L_tmp, 1 ); - s = add( L_tmp_exp, 1 ); - num = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/ - - s1 = norm_l( hFdCngDec->partNoiseShape[k] ); - L_tmp = L_shl( hFdCngDec->partNoiseShape[k], s1 ); /*Q31 - hFdCngDec->partNoiseShape_exp + s1*/ - L_tmp_exp = sub( hFdCngDec->partNoiseShape_exp, s1 ); - L_tmp = BASOP_Util_Add_Mant32Exp( L_tmp, L_tmp_exp, DELTA_MANTISSA_W32, DELTA_EXPONENT, &L_tmp_exp ); - s = sub( s, L_tmp_exp ); - denom = extract_h( L_tmp ); /*Q15 - L_tmp_exp*/ - - facTab[k] = div_s( num, denom ); /*Q15 - s*/ - move16(); - facTabExp[k] = s; - move16(); - } - /* Set unique exponent, if mantissa is equal to zero */ - if ( facTab[k] == 0 ) - { - facTabExp[k] = -( WORD32_BITS - 1 ); - move16(); - } - s2 = s_max( s2, facTabExp[k] ); - } - - FOR( k = 0; k < hFdCngCom->nFFTpart; k++ ) - { - s = sub( facTabExp[k], s2 ); - s = s_max( s_min( s, WORD32_BITS - 1 ), -( WORD32_BITS - 1 ) ); - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ - move32(); - } - } - /* adapt scaling for rest of the buffer */ - s = sub( *cngNoiseLevel_exp, add( hFdCngDec->bandNoiseShape_exp, s2 ) ); - FOR( ; k < hFdCngCom->npart; k++ ) - { - FOR( ; j <= hFdCngCom->part[k]; j++ ) - { - cngNoiseLevel[j] = L_shl( cngNoiseLevel[j], s ); /*Q31 - hFdCngDec->bandNoiseShape_exp + s*/ - move32(); - } - } - *cngNoiseLevel_exp = add( hFdCngDec->bandNoiseShape_exp, s2 ); - move16(); - } - } - - IF( EQ_16( st->codec_mode, MODE2 ) ) - { - /* Generate comfort noise during SID or zero frames */ - generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); - } - - BREAK; - - default: - return -1; - } - - - return 0; -} -#endif -Word16 ApplyFdCng_ivas_fx( Word16 *timeDomainInput, /* i : pointer to time domain input Q*/ Word16 Q, Word32 *powerSpectrum, /*Q_power_spectrum*/ @@ -1113,27 +657,22 @@ Word16 ApplyFdCng_ivas_fx( ( !st->BER_detect ) ) { /* Perform noise estimation at the decoder */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); } ELSE -#endif { perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); } /* Update the shaping parameters */ test(); -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } - ELSE -#endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, nBins, hFdCngDec->bandNoiseShape, 1 ); } @@ -1369,13 +908,11 @@ Word16 ApplyFdCng_ivas_fx( IF( hFdCngCom->active_frame_counter > 0 ) { /* Perform noise estimation in active frames in the decoder for downward updates */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); } ELSE -#endif { perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); } @@ -1436,44 +973,37 @@ Word16 ApplyFdCng_ivas_fx( IF( st != NULL && EQ_16( st->cng_type, LP_CNG ) ) { /* Perform noise estimation on inactive phase at the decoder */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { perform_noise_estimation_dec_fx( timeDomainInput, Q, hFdCngDec ); } ELSE -#endif { perform_noise_estimation_dec_ivas_fx( timeDomainInput, Q, powerSpectrum, Q_power_spectrum, hFdCngDec, st->element_mode, st->bwidth, L_frame, last_L_frame, st->last_core_brate, st->VAD ); } /* Update the shaping parameters */ - test(); -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } - ELSE -#endif - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) + ELSE IF( NE_16( st->element_mode, IVAS_CPE_TD ) && NE_16( st->element_mode, IVAS_CPE_DFT ) ) { scalebands_fx( hFdCngDec->msNoiseEst, hFdCngDec->part_shaping, hFdCngDec->nFFTpart_shaping, hFdCngDec->midband_shaping, hFdCngDec->nFFTpart_shaping, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), hFdCngDec->bandNoiseShape, 1 ); } hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; move16(); + /* This sets the new CNG levels until a SID update overwrites it */ Copy32( hFdCngDec->bandNoiseShape, cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); /* This sets the new CNG levels until a SID update overwrites it */ /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { *cngNoiseLevel_exp = hFdCngDec->bandNoiseShape_exp; move16(); } ELSE -#endif { Word16 shift1 = L_norm_arr( cngNoiseLevel, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ); Word16 shift2 = L_norm_arr( cngNoiseLevel + sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ), sub( FFTCLDFBLEN, sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand ) ) ); @@ -1554,16 +1084,15 @@ Word16 ApplyFdCng_ivas_fx( IF( LT_32( hFdCngCom->msFrCnt_init_counter, L_deposit_l( hFdCngCom->msFrCnt_init_thresh ) ) ) { /* At initialization, interpolate the bin/band-wise levels from the partition levels */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); } ELSE -#endif { scalebands_fx( hFdCngCom->sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 1 ); } + *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } @@ -1576,13 +1105,11 @@ Word16 ApplyFdCng_ivas_fx( /* Interpolate the CLDFB band levels from the SID (partition) levels */ IF( GT_16( hFdCngCom->regularStopBand, hFdCngCom->numCoreBands ) ) { -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { scalebands( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); } ELSE -#endif { scalebands_fx( sidNoiseEst, hFdCngCom->part, hFdCngCom->npart, hFdCngCom->midband, hFdCngCom->nFFTpart, sub( hFdCngCom->stopBand, hFdCngCom->startBand ), cngNoiseLevel, 0 ); } @@ -1649,7 +1176,6 @@ Word16 ApplyFdCng_ivas_fx( } } -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { /* adapt scaling for rest of the buffer */ @@ -1666,7 +1192,6 @@ Word16 ApplyFdCng_ivas_fx( move16(); } ELSE -#endif { Word16 shift1 = L_norm_arr( cngNoiseLevel, j ); Word16 shift2 = L_norm_arr( &cngNoiseLevel[j], sub( FFTCLDFBLEN, j ) ); @@ -1755,13 +1280,11 @@ Word16 ApplyFdCng_ivas_fx( IF( EQ_16( st->codec_mode, MODE2 ) ) { /* Generate comfort noise during SID or zero frames */ -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st->element_mode, EVS_MONO ) ) { generate_comfort_noise_dec_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); } ELSE -#endif { generate_comfort_noise_dec_ivas_fx( cldfbBufferReal, cldfbBufferImag, cldfbBufferScale, st, &( st->Q_exc ), 2, -1 ); } diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 00eca187d..db325cd80 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -602,7 +602,6 @@ void gain_dec_mless_fx( /* _ None */ /*==================================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void gain_dec_lbr_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ const Word16 coder_type, /* i : coding type */ @@ -653,375 +652,6 @@ void gain_dec_lbr_fx( ctype = shl( sub( coder_type, 1 ), 1 ); - /*-----------------------------------------------------------------* - * calculate prediction of gcode - * search for the best codeword - *-----------------------------------------------------------------*/ - IF( i_subfr == 0 ) - { - b_fx = b_1sfr_fx; - move16(); - n_pred = 2; - move16(); - cdbk_fx = gp_gamma_1sfr_6b_fx; - SWITCH( nBits ) - { - case 8: - { - cdbk_fx = gp_gamma_1sfr_8b_fx; /* Q14/Q9*/ - BREAK; - } - case 7: - { - cdbk_fx = gp_gamma_1sfr_7b_fx; /* Q14/Q9*/ - BREAK; - } - case 6: - { - cdbk_fx = gp_gamma_1sfr_6b_fx; /* Q14/Q9*/ - BREAK; - } - } - - /* calculate predicted gain */ - aux_fx[0] = 4096; /*Q12*/ - move16(); - aux_fx[1] = shl( ctype, 12 ); /*Q12*/ - move16(); - - /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode)); - gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); - gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */ - - e_tmp = norm_l( L_tmp2 ); - f_tmp = Log2_norm_lc( L_shl( L_tmp2, e_tmp ) ); /*Q15*/ - e_tmp = sub( expg2, add( 1, e_tmp ) ); - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 12330 ); /* Q13 */ /* 10*log10(2) in Q12*/ - - L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ - L_tmp = Mult_32_16( L_tmp, 160 ); /*Q13, 20 in Q3*/ - L_tmp = L_sub( L_tmp, L_tmp1 ); /*Q13*/ - - gcode0_fx = round_fx( L_shl( L_tmp, 11 ) ); /* Q8 */ - - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, gcode0/20) - * = pow(2, 3.321928*gcode0/20) - * = pow(2, 0.166096*gcode0) - *-----------------------------------------------------------------*/ - - L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ - L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - - /* retrieve the codebook index and calculate both gains */ - /*index = (Word16)get_indice( st_fx,"gain", i_subfr, ACELP_CORE);move16();*/ - index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ - move16(); - - *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/ - move16(); - - L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ - move16(); - - gc_mem[0] = *gain_code_fx; /*Q16*/ - move32(); - gp_mem[0] = *gain_pit_fx; /*Q14*/ - move16(); - } - ELSE IF( EQ_16( i_subfr, L_SUBFR ) || EQ_16( L_subfr, 2 * L_SUBFR ) ) - { - b_fx = b_2sfr_fx; /*Q12*/ - move16(); - n_pred = 4; - move16(); - - cdbk_fx = gp_gamma_1sfr_6b_fx; /*Q14/Q9 */ - SWITCH( nBits ) - { - case 7: - { - cdbk_fx = gp_gamma_2sfr_7b_fx; /* Q14/Q9*/ - BREAK; - } - case 6: - { - cdbk_fx = gp_gamma_2sfr_6b_fx; /* Q14/Q9*/ - BREAK; - } - } - - /* calculate predicted gain */ - aux_fx[0] = 4096; /*Q12*/ - move16(); - aux_fx[1] = shl( ctype, 12 ); /*Q12*/ - move16(); - - /*aux_fx[2] = (float)log10(gc_mem[0]); - = log2(gc_mem[0])*log10(2);*/ - e_tmp = norm_l( gc_mem[0] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - aux_fx[3] = shr( gp_mem[0], 2 ); /*Q12*/ - move16(); - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, dotp(b, aux, n_pred) - * = pow(2, 3.321928*dotp(b, aux, n_pred) - *-----------------------------------------------------------------*/ - L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ - L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ - L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - - /* retrieve the codebook index and calculate both gains */ - index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ - move16(); - - *gain_pit_fx = cdbk_fx[index * 2]; /*Q14*/ - move16(); - - L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ - move16(); - - gc_mem[1] = *gain_code_fx; /*Q16*/ - move32(); - gp_mem[1] = *gain_pit_fx; /*Q14*/ - move16(); - } - ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) ) - { - b_fx = b_3sfr_fx; - move16(); - n_pred = 6; - move16(); - - cdbk_fx = gp_gamma_3sfr_6b_fx; /*Q14/Q9 */ - - if ( EQ_16( nBits, 7 ) ) - { - cdbk_fx = gp_gamma_3sfr_7b_fx; /*Q14*/ - // PMT("verify if gp_gamma_3sfr_7b_fx is correct") - } - - /* calculate predicted gain */ - aux_fx[0] = 4096; /*Q12*/ - move16(); - aux_fx[1] = shl( ctype, 12 ); /*Q12*/ - move16(); - - /*aux_fx[2] = (float)log10(gc_mem[0]); - = log2(gc_mem[0])*log10(2);*/ - e_tmp = norm_l( gc_mem[0] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - /*aux[3] = (float)log10(gc_mem[1]); - = log2(gc_mem[1])*log10(2);*/ - e_tmp = norm_l( gc_mem[1] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - aux_fx[4] = shr( gp_mem[0], 2 ); /*Q12*/ - move16(); - aux_fx[5] = shr( gp_mem[1], 2 ); /*Q12*/ - move16(); - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, dotp(b, aux, n_pred) - * = pow(2, 3.321928*dotp(b, aux, n_pred) - *-----------------------------------------------------------------*/ - L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ - L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ - L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - - /* retrieve the codebook index and calculate both gains */ - index = (Word16) get_next_indice_fx( st_fx, nBits ); - move16(); - - *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/ - move16(); - - L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /* Q10 -> Q16*/ - move32(); - gc_mem[2] = *gain_code_fx; /*Q16*/ - move32(); - gp_mem[2] = *gain_pit_fx; /*Q14*/ - move16(); - } - ELSE IF( EQ_16( i_subfr, 3 * L_SUBFR ) ) - { - b_fx = b_4sfr_fx; /*Q12*/ - n_pred = 8; - move16(); - - - cdbk_fx = gp_gamma_4sfr_6b_fx; /*Q14*/ -#ifdef IVAS_GAIN_MOD - IF( EQ_16( nBits, 7 ) ) - { - cdbk_fx = gp_gamma_4sfr_7b_fx; - PMT( "verify if gp_gamma_4sfr_7b_fx is correct" ) - } -#endif - - /* calculate predicted gain */ - aux_fx[0] = 4096; /*Q12*/ - move16(); - aux_fx[1] = shl( ctype, 12 ); /*Q12*/ - move16(); - - /*aux[2] = (float)log10(gc_mem[0]); - = log2(gc_mem[0])*log10(2);*/ - e_tmp = norm_l( gc_mem[0] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[0], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[0])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[2] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - /*aux[3] = (float)log10(gc_mem[1]); - = log2(gc_mem[1])*log10(2);*/ - e_tmp = norm_l( gc_mem[1] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[1], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[1])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[3] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - /*aux[4] = (float)log10(gc_mem[2]); - = log2(gc_mem[2])*log10(2);*/ - e_tmp = norm_l( gc_mem[2] ); - f_tmp = Log2_norm_lc( L_shl( gc_mem[2], e_tmp ) ); /*Q15*/ - e_tmp = sub( sub( 30, e_tmp ), 16 ); /*Q_format(gc_mem[2])=16*/ - L_tmp1 = Mpy_32_16( e_tmp, f_tmp, 9864 ); /* Q16 */ - aux_fx[4] = round_fx( L_shl( L_tmp1, 12 ) ); /* Q12 */ - move16(); - - aux_fx[5] = shr( gp_mem[0], 2 ); /*Q12*/ - move16(); - aux_fx[6] = shr( gp_mem[1], 2 ); /*Q12*/ - move16(); - aux_fx[7] = shr( gp_mem[2], 2 ); /*Q12*/ - move16(); - - /*-----------------------------------------------------------------* - * gcode0 = pow(10.0, dotp(b, aux, n_pred) - * = pow(2, 3.321928*dotp(b, aux, n_pred) - *-----------------------------------------------------------------*/ - L_tmp = Dot_product( b_fx, aux_fx, n_pred ); /*Q25*/ - L_tmp = Mult_32_16( L_tmp, 27213 ); /* *3.321928 in Q13 -> Q23 */ - L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ - - gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ - exp_gcode0 = sub( exp_gcode0, 14 ); - - /* retrieve the codebook index and calculate both gains */ - index = (Word16) get_next_indice_fx( st_fx, nBits ); /*Q0*/ - move16(); - *gain_pit_fx = cdbk_fx[( index * 2 )]; /*Q14*/ - move16(); - - L_tmp = L_mult( cdbk_fx[( ( index * 2 ) + 1 )], gcode0_fx ); /* Q9*Q0 -> Q10 */ - *gain_code_fx = L_shl_sat( L_tmp, add( exp_gcode0, 6 ) ); /*Q16*/ - move32(); - } - - /* *norm_gain_code = *gain_code / *gain_inov; */ - expg = sub( norm_s( *gain_inov_fx ), 1 ); - expg = s_max( expg, 0 ); - - tmp_fx = div_s( shr( 8192, expg ), *gain_inov_fx ); /*Q15*/ - *norm_gain_code_fx = L_shr( Mult_32_16( *gain_code_fx, tmp_fx ), sub( 1, expg ) ); /*Q16*/ - move32(); - - return; -} -#endif -void gain_dec_lbr_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word16 coder_type, /* i : coding type */ - const Word16 i_subfr, /* i : subframe index */ - const Word16 *code_fx, /* i : algebraic excitation Q9 */ - Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/ - Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/ - Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/ - Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/ - Word32 gc_mem[], /* i/o: gain_code from previous subframes Q16*/ - Word16 gp_mem[], /* i/o: gain_pitch from previous subframes Q14*/ - const Word16 L_subfr /* i : subfr lenght */ -) -{ - Word16 index, nBits, n_pred, ctype; - Word16 gcode0_fx, aux_fx[10]; - Word32 L_tmp, L_tmp1, L_tmp2; - Word16 expg, expg2, e_tmp, exp_gcode0, f_tmp, frac, tmp_fx; - const Word16 *b_fx, *cdbk_fx = 0; - /* Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR; - *gain_inov = 1.0f / (float)sqrt(Ecode); */ - Word16 shift_L_subfr; - shift_L_subfr = 6; - move16(); // for *cdbk_fx - move16(); - if ( GT_16( L_subfr, L_SUBFR ) ) - { - shift_L_subfr = add( shift_L_subfr, 1 ); - } - L_tmp = Dot_product12( code_fx, code_fx, L_subfr, &expg ); /*Q31 - expg*/ - expg = sub( expg, add( 18, shift_L_subfr ) ); /* exp: -18 (code in Q9), -6 (/L_SUBFR) */ - - expg2 = expg; - move16(); - L_tmp2 = L_tmp; /* sets to 'L_tmp' in 1 clock */ - move32(); - L_tmp = Isqrt_lc( L_tmp, &expg ); /*Q31 - expg*/ - - *gain_inov_fx = extract_h( L_shl_sat( L_tmp, sub( expg, 3 ) ) ); /* gain_inov in Q12 */ - move16(); - - /*-----------------------------------------------------------------* - * select the codebook, size and number of bits - * set the gains searching range - *-----------------------------------------------------------------*/ - nBits = st_fx->acelp_cfg.gains_mode[shr( i_subfr, shift_L_subfr )]; - move16(); - - ctype = shl( sub( coder_type, 1 ), 1 ); - /*-----------------------------------------------------------------* * calculate prediction of gcode * search for the best codeword @@ -1583,24 +1213,28 @@ void lp_gain_updt_ivas_fx( } /*-------------------------------------------------* - * Gain_dec_gaus_vbr + * gain_dec_gaus_fx() * * Decode gains of purely unvoiced sounds *-------------------------------------------------*/ -Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */ - Word16 index, /* i : quantization index */ - const Word16 bits, /* i : number of bits to quantize */ - const Word16 lowBound, /* i : lower bound of quantizer (dB) */ - const Word16 topBound, /* i : upper bound of quantizer (dB) */ - const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ - Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ + +/*! r: quantized codebook gain Q16 */ +Word32 gain_dec_gaus_fx( + Word16 index, /* i : quantization index */ + const Word16 bits, /* i : number of bits to quantize */ + const Word16 lowBound, /* i : lower bound of quantizer (dB) */ + const Word16 topBound, /* i : upper bound of quantizer (dB) */ + const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */ + Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */ ) { Word16 stepSize, gain, expg, frac, expi, tmp_igi; Word32 L_tmp, L_enr_q, L_gain; Word16 stepSize_Exp; + stepSize_Exp = 14; move16(); + /*------------------------------------------------------------------------------------------* * Quantize linearly the log E *------------------------------------------------------------------------------------------*/ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index cf0fabc76..70639810c 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -23,7 +23,7 @@ /* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ /*--------------------------------------------------------------------------*/ /* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx : decoder memory structure */ +/* Decoder_State *st_fx : decoder memory structure */ /* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ /* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ /*--------------------------------------------------------------------------*/ @@ -31,439 +31,17 @@ /* _ None */ /*==========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void decod_audio_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : floating pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ - , - Word16 *gain_buf /*Q14*/ -) -{ - Word16 tmp_nb_bits_tot, pit_band_idx; - Word16 code[4 * L_SUBFR]; - Word16 Diff_len, nb_subfr, i; - Word16 nb_frame_flg; - Word16 Es_pred = 0; - Word16 Len, max_len; - Word16 gsc_attack_flag; - - Word16 low_pit; - Word16 last_bin; - Word16 nbits; - - Word16 exc_wo_nf[L_FRAME16k]; - GSC_DEC_HANDLE hGSCDec; - hGSCDec = st_fx->hGSCDec; - - - /*---------------------------------------------------------------* - * Initialization - *---------------------------------------------------------------*/ - move16(); // corresponding to initialization of Es_pred - Diff_len = 0; - move16(); - - /* decode GSC attack flag (used to reduce possible pre-echo) */ - gsc_attack_flag = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ - move16(); - - /* decode GSC SWB speech flag */ - test(); - IF( st_fx->coder_type != INACTIVE && GE_32( st_fx->total_brate, ACELP_13k20 ) ) - { - st_fx->GSC_noisy_speech = (Word16) get_next_indice_fx( st_fx, 1 ); /* Q0 */ - move16(); - } - - /* safety check in case of bit errors */ - test(); - test(); - IF( st_fx->GSC_noisy_speech && LT_16( st_fx->bwidth, SWB ) && st_fx->GSC_IVAS_mode == 0 ) - { - st_fx->BER_detect = 1; /* Q0 */ - move16(); - st_fx->GSC_noisy_speech = 0; /* Q0 */ - move16(); - } - - /* set bit-allocation */ -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#else - config_acelp1( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, 0, 0, st_fx->idchan, st_fx->active_cnt, 0, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); -#endif - - /*---------------------------------------------------------------* - * Decode energy dynamics - *---------------------------------------------------------------*/ - - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) ) - { - nb_subfr = NB_SUBFR; /* Q0 */ - move16(); - hGSCDec->cor_strong_limit = 0; - move16(); - hGSCDec->noise_lev = NOISE_LEVEL_SP3; /* Q0 */ - move16(); - } - ELSE - { - IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) - { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 2 ), NOISE_LEVEL_SP2 ); /* Q0 */ - move16(); - } - ELSE - { - hGSCDec->noise_lev = add( (Word16) get_next_indice_fx( st_fx, 3 ), NOISE_LEVEL_SP0 ); /* Q0 */ - move16(); - } - - /*---------------------------------------------------------------* - * Decode number of subframes - *---------------------------------------------------------------*/ - - - hGSCDec->cor_strong_limit = 1; /* Q0 */ - move16(); - nb_subfr = SWNB_SUBFR; - move16(); - - IF( GE_32( st_fx->core_brate, ACELP_9k60 ) ) - { - nbits = 1; - move16(); - nb_frame_flg = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ - move16(); - - IF( s_and( nb_frame_flg, 0x1 ) == 0 ) - { - nb_subfr = 2 * SWNB_SUBFR; /* Q0 */ - move16(); - hGSCDec->cor_strong_limit = 0; - move16(); - } - } - } - - /*---------------------------------------------------------------* - * Decode the last band where the adaptive (pitch) contribution is significant - *---------------------------------------------------------------*/ - - IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) - { - nbits = 3; /* Q0 */ - move16(); - test(); - if ( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type == INACTIVE ) - { - nbits = 1; /* Q0 */ - move16(); - } - } - ELSE - { - nbits = 4; /* Q0 */ - move16(); - } - test(); - IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE ) - { - pit_band_idx = 1; /* Q0 */ - move16(); - } - ELSE - { - pit_band_idx = (Word16) get_next_indice_fx( st_fx, nbits ); /* Q0 */ - move16(); - } - - IF( pit_band_idx != 0 ) - { - IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) - { - pit_band_idx = 7 + BAND1k2; /* Q0 */ - move16(); /* At low rate, if pitch model is chosen, then for to be use on extented and constant frequency range */ - } - ELSE - { - pit_band_idx = add( pit_band_idx, BAND1k2 ); /* Q0 */ - } - - /* detect bit errors in the bitstream */ - IF( GT_16( pit_band_idx, 13 ) ) /* The maximum decodable index is 10 + BAND1k2 (3) = 13 */ - { - pit_band_idx = 13; /* Q0 */ - move16(); - st_fx->BER_detect = 1; /* Q0 */ - move16(); - } - Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ - move16(); - } - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ - move16(); - - - /*--------------------------------------------------------------------------------------* - * Decode adaptive (pitch) excitation contribution - * Reset unvaluable part of the adaptive (pitch) excitation contribution - *--------------------------------------------------------------------------------------*/ - IF( GT_16( pit_band_idx, BAND1k2 ) ) - { - /*---------------------------------------------------------------* - * Decode adaptive (pitch) excitation contribution - *---------------------------------------------------------------*/ - test(); - IF( EQ_16( st_fx->GSC_noisy_speech, 1 ) && EQ_16( nb_subfr, NB_SUBFR ) ) - { - Word16 indice; - nbits = Es_pred_bits_tbl[BIT_ALLOC_IDX_fx( st_fx->core_brate, GENERIC, -1, -1 )]; /* Q0 */ - move16(); - if ( st_fx->element_mode > EVS_MONO ) - { - nbits = 5; - move16(); - } - - indice = get_next_indice_fx( st_fx, nbits ); /* Q0 */ - - Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); - } - - dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf ); - - IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) - { - minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); - low_pit = shr( low_pit, 6 ); /*Q6 -> Q0 */ - - IF( LT_16( low_pit, 64 ) ) - { - pit_band_idx = 9 + BAND1k2; /* Q0 */ - move16(); - if ( st_fx->bwidth == NB ) - { - pit_band_idx = 7 + BAND1k2; /* Q0 */ - move16(); - } - } - ELSE IF( LT_16( low_pit, 128 ) ) - { - pit_band_idx = 5 + BAND1k2; /* Q0 */ - move16(); - } - ELSE - { - pit_band_idx = 3 + BAND1k2; /* Q0 */ - move16(); - } - - Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ - move16(); - hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ - move16(); - } - - /*---------------------------------------------------------------* - * DCT transform - *---------------------------------------------------------------*/ - edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode ); - - /*---------------------------------------------------------------* - * Reset unvaluable part of the adaptive (pitch) excitation contribution - *---------------------------------------------------------------*/ - - max_len = sub( st_fx->L_frame, Diff_len ); /* Q0 */ - - if ( st_fx->bwidth == NB ) - { - max_len = sub( 160, Diff_len ); /* Q0 */ - } - - Len = 80; - move16(); - if ( LT_16( max_len, 80 ) ) - { - Len = max_len; /* Q0 */ - move16(); - } - - test(); - IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && NE_16( st_fx->bwidth, NB ) ) - { - FOR( i = 0; i < max_len; i++ ) - { - dct_epit[i + Diff_len] = 0; - move16(); - } - } - ELSE - { - FOR( i = 0; i < Len; i++ ) - { - dct_epit[i + Diff_len] = mult_r( dct_epit[i + Diff_len], sm_table_fx[i] ); /* Qx */ - move16(); - } - - FOR( ; i < max_len; i++ ) - { - dct_epit[i + Diff_len] = 0; - move16(); - } - } - // PMT("in the rare case of 4 subfr, bfi_pitch_fx might be wrong") - st_fx->bfi_pitch_fx = mean_fx( pitch_buf, nb_subfr ); /* Q6 */ - move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ - move16(); - - Diff_len = add( Diff_len, 1 ); /* Q0 */ - st_fx->bpf_off = 0; - move16(); - } - ELSE - { - /* No adaptive (pitch) excitation contribution */ - st_fx->bpf_off = 1; /* Q0 */ - move16(); - set16_fx( dct_epit, 0, st_fx->L_frame ); - - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - set16_fx( pitch_buf, L_SUBFR16k * 64, NB_SUBFR16k ); - } - ELSE - { - set16_fx( pitch_buf, L_SUBFR * 64, NB_SUBFR ); - } - - set16_fx( gain_buf, 0, NB_SUBFR16k ); - - st_fx->bfi_pitch_fx = L_SUBFR * 64; - move16(); - st_fx->bfi_pitch_frame = st_fx->L_frame; /* Q0 */ - move16(); - st_fx->lp_gainp_fx = 0; - move16(); - st_fx->lp_gainc_fx = 0; - move16(); - st_fx->tilt_code_fx = 0; - move16(); - pit_band_idx = 0; - move16(); - Diff_len = 0; - move16(); - } - - /*--------------------------------------------------------------------------------------* - * GSC decoder - *--------------------------------------------------------------------------------------*/ - - /* find the current total number of bits used */ - - tmp_nb_bits_tot = st_fx->next_bit_pos; /* Q0 */ - move16(); - - if ( st_fx->extl_brate > 0 ) - { - /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ - tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ - } - - test(); - if ( st_fx->coder_type == INACTIVE && LE_32( st_fx->core_brate, ACELP_9k60 ) ) - { - tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); /* Q0 */ - } - - gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, st_fx->Q_exc ); - /*--------------------------------------------------------------------------------------* - * iDCT transform - *--------------------------------------------------------------------------------------*/ - - edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); - edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); - /*----------------------------------------------------------------------* - * Remove potential pre-echo in case an onset has been detected - *----------------------------------------------------------------------*/ - - pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame ); - - /*--------------------------------------------------------------------------------------* - * Update BWE excitation - *--------------------------------------------------------------------------------------*/ - - IF( st_fx->hBWE_TD != NULL ) - { - set16_fx( voice_factors, 0, NB_SUBFR16k ); - IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) - { - interp_code_4over2_fx( exc, bwe_exc, st_fx->L_frame ); - } - ELSE - { - interp_code_5over2_fx( exc, bwe_exc, L_FRAME ); - } - } - /*--------------------------------------------------------------------------------------* - * Updates - *--------------------------------------------------------------------------------------*/ - - Copy( exc, exc2, st_fx->L_frame ); /* Q_exc */ - Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_exc */ - - /*--------------------------------------------------------------------------------------* - * Channel aware mode parameters - *--------------------------------------------------------------------------------------*/ - - set16_fx( st_fx->tilt_code_dec_fx, 0, NB_SUBFR16k ); - - return; -} - -/*=========================================================================*/ -/* FUNCTION : void decod_audio_ivas_fx(); */ -/*-------------------------------------------------------------------------*/ -/* PURPOSE : Decode audio (AC) frames */ -/*-------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16[]) Aq : LP filter coefficient Q12 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _(Word16) Q_exc :Q format of excitation */ -/*-------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16[]) pitch_buf_fx : Word16 pitch values for each subframe Q6*/ -/* _ (Word16[]) voice_factors_fx: frame error rate Q15 */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx : decoder memory structure */ -/* _ (Word16[]) exc_fx : adapt. excitation exc (Q_exc) */ -/* _ (Word16[]) exc2_fx : adapt. excitation/total exc (Q_exc) */ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*==========================================================================*/ -#endif -void decod_audio_ivas_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ - const Word16 *Aq, /* i : LP filter coefficient Q12*/ - Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ - Word16 *voice_factors, /* o : voicing factors Q15*/ - Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ - Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ - Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ - Word16 *lsf_new /* i : ISFs at the end of the frame Qx*/ - , - Word16 *gain_buf, /*Q14*/ + Decoder_State *st_fx, /* i/o: decoder static memory */ + Word16 dct_epit[], /* o : GSC excitation in DCT domain Qx*/ + const Word16 *Aq, /* i : LP filter coefficient Q12*/ + Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ + Word16 *voice_factors, /* o : voicing factors Q15*/ + Word16 *exc, /* i/o: adapt. excitation exc Q_exc*/ + Word16 *exc2, /* i/o: adapt. excitation/total exc Q_exc*/ + Word16 *bwe_exc, /* o : excitation for SWB TBE Q_exc*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *gain_buf, /* o : Word16 pitch gain for each subframe Q14*/ const Word16 tdm_lp_reuse_flag, /* i : LPC reuse flag Q0*/ const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/ @@ -525,7 +103,7 @@ void decod_audio_ivas_fx( } /* set bit-allocation */ - config_acelp1_IVAS( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( DEC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl_orig, st_fx->extl_brate_orig, st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), st_fx->next_bit_pos, st_fx->coder_type, st_fx->inactive_coder_type_flag, -1, 1, &nbits, NULL, st_fx->element_mode, &nbits /*dummy*/, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_cnt, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /*---------------------------------------------------------------* * Decode energy dynamics @@ -735,7 +313,7 @@ void decod_audio_ivas_fx( Es_pred_dec_fx( &Es_pred, indice, nbits, 0 ); } - dec_pit_exc_ivas_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); + dec_pit_exc_fx( st_fx, Aq, st_fx->coder_type, Es_pred, pitch_buf, code, exc, bwe_exc, nb_subfr, gain_buf, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) { @@ -894,7 +472,7 @@ void decod_audio_ivas_fx( Word16 Q_exc_old = st_fx->Q_exc; move16(); - gsc_dec_ivas_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); + gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); IF( NE_16( Q_exc_old, st_fx->Q_exc ) ) { @@ -976,250 +554,17 @@ void decod_audio_ivas_fx( /* _None */ /*==========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void gsc_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ - const Word16 pit_band_idx, /* i : bin position of the cut-off frequency Q0*/ - const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ - const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ - const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ - const Word16 coder_type, /* i : coding type Q0*/ - Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ - Word16 Q_exc ) -{ - Word16 i, j, bit, nb_subbands, pvq_len; - Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; - Word16 bitallocation_exc[2]; - Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; - Word16 max_ener_band[MBANDS_GN_BITALLOC16k]; - Word16 exc_diffQ[L_FRAME16k]; - Word16 bits_per_bands[MBANDS_GN_BITALLOC16k]; - Word16 concat_out[L_FRAME16k]; - Word16 inpulses_fx[NB_SFM]; - Word16 imaxpulse_fx[NB_SFM]; - Word16 mean_gain; - Word16 Mbands_gn = 16; - Word16 Qexc_diffQ = Q_PVQ_OUT; - Word32 L_tmp; - Word16 Q_tmp; - Word16 seed_init; - GSC_DEC_HANDLE hGSCDec; - hGSCDec = st_fx->hGSCDec; - move16(); - move16(); - - move16(); // for Mbands_gn - move16(); // for Qexc_diffQ - set16_fx( inpulses_fx, 0, NB_SFM ); - set16_fx( imaxpulse_fx, 0, NB_SFM ); - - /*--------------------------------------------------------------------------------------* - * Initialization - *--------------------------------------------------------------------------------------*/ - bit = bits_used; - move16(); - - set16_fx( exc_diffQ, 0, st_fx->L_frame ); - - /*--------------------------------------------------------------------------------------* - * Gain decoding - *--------------------------------------------------------------------------------------*/ - - test(); - IF( st_fx->bfi || st_fx->BER_detect ) - { - /* copy old gain */ - Copy( hGSCDec->old_y_gain_fx, Ener_per_bd_iQ, Mbands_gn ); /* Q_old_gain */ - mean_gain = mult_r( st_fx->lp_gainc_fx, 3277 ); /*Q3*/ - FOR( i = 0; i < Mbands_gn; i++ ) - { - Ener_per_bd_iQ[i] = add( Ener_per_bd_iQ[i], shl( mean_gain, 9 ) ); /*Q12*/ - move16(); - } - - st_fx->lp_gainc_fx = mult_r( st_fx->lp_gainc_fx, 32112 ); /*Q3*/ - move16(); - } - ELSE - { - mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, st_fx->core_brate, hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q12 */ - - st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */ - move16(); - } - - *last_bin = 0; - move16(); - test(); - IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB ) - { - bitallocation_exc[0] = 0; - move16(); - bitallocation_exc[1] = 0; - move16(); - } - - set16_fx( bitallocation_band, 0, MBANDS_GN ); - - test(); - IF( ( EQ_16( st_fx->bfi, 1 ) ) || st_fx->BER_detect ) - { - /*--------------------------------------------------------------------------------------* - * Copy old spectrum - * reduce spectral dynamic - * save spectrum - *--------------------------------------------------------------------------------------*/ - - test(); - IF( EQ_16( st_fx->last_good, INACTIVE_CLAS ) || EQ_16( st_fx->Last_GSC_noisy_speech_flag, 1 ) ) - { - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - L_tmp = L_shr( L_mult( Random( &hGSCDec->seed_tcx ), 26214 ), 5 ); /*Q10*/ - L_tmp = L_mac( L_tmp, hGSCDec->Last_GSC_spectrum_fx[i], 6554 ); /* Q10 */ - hGSCDec->Last_GSC_spectrum_fx[i] = round_fx( L_tmp ); /*Q10*/ - move16(); - } - } - - Copy( hGSCDec->Last_GSC_spectrum_fx, exc_diffQ, st_fx->L_frame ); /* Q10 */ - - FOR( i = 0; i < st_fx->L_frame; i++ ) - { - hGSCDec->Last_GSC_spectrum_fx[i] = mult_r( hGSCDec->Last_GSC_spectrum_fx[i], 24576 ); /*Q10*/ - move16(); - } - } - ELSE - { - /*--------------------------------------------------------------------------------------* - * PVQ decoder - *--------------------------------------------------------------------------------------*/ - - bands_and_bit_alloc_fx( hGSCDec->cor_strong_limit, hGSCDec->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, - max_ener_band, bits_per_bands, &nb_subbands, NULL, NULL, &pvq_len, coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, - st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - - { - pvq_core_dec_fx( st_fx, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, concat_out, &Q_tmp, bit, nb_subbands, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ - } - seed_init = 0; - move16(); - - /* Reorder Q bands */ - FOR( j = 0; j < nb_subbands; j++ ) - { - Copy( concat_out + shl( j, 4 ), exc_diffQ + shl( max_ener_band[j], 4 ), 16 ); /* Q_PVQ_OUT */ - - *last_bin = s_max( *last_bin, max_ener_band[j] ); /* Q0 */ - move16(); - - bitallocation_band[max_ener_band[j]] = 1; /* Q0 */ - move16(); - - seed_init = add( seed_init, inpulses_fx[j] ); /* Q0 */ - } - test(); - IF( NE_16( st_fx->last_coder_type, AUDIO ) /* First audio frame */ - && NE_16( st_fx->last_coder_type, UNVOICED ) ) /* last_coder_type == INACTIVE is overwritten in update_dec to UNVOICED */ - { - FOR( j = 0; j < nb_subbands * 16; j++ ) - { - IF( concat_out[j] > 0 ) - { - seed_init = extract_l( L_shl( seed_init, 3 ) ); /* Q0 */ - } - if ( concat_out[j] < 0 ) - { - seed_init = add( seed_init, 3 ); /* Q0 */ - move16(); - } - } - - hGSCDec->seed_tcx = seed_init; /* Q0 */ - move16(); - } - test(); - IF( EQ_32( st_fx->core_brate, ACELP_8k00 ) && st_fx->bwidth != NB ) - { - if ( exc_diffQ[L_FRAME8k - 2] != 0 ) - { - bitallocation_exc[0] = 1; /* Q0 */ - move16(); - } - - if ( exc_diffQ[L_FRAME8k - 1] != 0 ) - { - bitallocation_exc[1] = 1; /* Q0 */ - move16(); - } - } - - Copy( exc_diffQ, hGSCDec->Last_GSC_spectrum_fx, st_fx->L_frame ); /* Q_PVQ_OUT */ - - /*--------------------------------------------------------------------------------------* - * Skip adaptive (pitch) contribution frequency band (no noise added over the time contribution) - * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal - * Gain is based on the inter-correlation gain between the pulses found and residual signal - *--------------------------------------------------------------------------------------*/ - - freq_dnw_scaling_fx( hGSCDec->cor_strong_limit, st_fx->coder_type, hGSCDec->noise_lev, st_fx->core_brate, exc_diffQ, Qexc_diffQ, st_fx->L_frame ); - } - - /*--------------------------------------------------------------------------------------* - * Estimate noise level - *--------------------------------------------------------------------------------------*/ - - highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, - &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, - st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - - exc_dct_in[0] = 0; - move16(); - - return; -} - -/*==========================================================================*/ -/* FUNCTION : void gsc_dec_ivas_fx () */ -/*--------------------------------------------------------------------------*/ -/* PURPOSE : Generic audio signal decoder */ -/*--------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word16) pit_band_idx : bin position of the cut-off frequency Q0 */ -/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) bits_used : Number of bit used before frequency Q Q0 */ -/* _ (Word16) nb_subfr : Number of subframe considered Q0 */ -/* _ (Word16) Qexc : Q format of exc_dct_in */ -/*--------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ None */ -/*--------------------------------------------------------------------------*/ -/* INPUT/OUTPUT ARGUMENTS : */ -/* Decoder_State *st_fx:Decoder State Structure */ -/* _ (Word16[]) exc_dct_in : dctof pitch-only excitation / total excitation Qexc*/ -/*--------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _None */ -/*==========================================================================*/ -#endif -void gsc_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ + Decoder_State *st_fx, /* i/o: State structure */ + Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation Q_exc*/ const Word16 pit_band_idx, /* i : bin position of the cut-off frequency ` Q0*/ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral) Q0*/ const Word16 bits_used, /* i : Number of bit used before frequency Q Q0*/ const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ const Word16 coder_type, /* i : coding type Q0*/ Word16 *last_bin, /* i : last bin of bit allocation Q0*/ - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ - Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx*/ + Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *Q_exc ) { Word16 i, j, bit, nb_subbands, pvq_len; @@ -1310,13 +655,11 @@ void gsc_dec_ivas_fx( i--; } -#ifdef REMOVE_EVS_DUPLICATES IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ } ELSE -#endif { mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */ } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index e4fb48f4a..cf3d8c468 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -520,7 +520,7 @@ ivas_error ivas_core_dec_fx( Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, add( M, 1 ), sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 3 ) ); // Qx } - IF( NE_32( ( error = acelp_core_dec_ivas_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = acelp_core_dec_fx( st, output_16_fx[n], synth_16_fx[n], save_hb_synth_16_fx, bwe_exc_extended_fx[n], voice_factors_fx[n], old_syn_12k8_16k_fx_16, sharpFlag[n], pitch_buf_fx[n], &unbits[n], &sid_bw[n], hStereoTD, tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, use_cldfb_for_dft, last_element_mode, last_element_brate, flag_sec_CNA, nchan_out, hStereoCng, read_sid_info ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 890e5fc9e..89cb92a4d 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -1097,8 +1097,8 @@ static void run_min_stats_fx( { arr_tmp = power_spec; } - ApplyFdCng_ivas_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 ); - /*=================================================*/ + + ApplyFdCng_fx( NULL, 0, arr_tmp, power_spec_q, NULL, NULL, NULL, st, st->bfi, 0 ); } /* restore VAD (see above) */ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index aa5a379e8..0be01f7b8 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -875,11 +875,11 @@ void stereo_tcx_core_dec_fx( { Word16 buffer[L_FRAME16k]; lerp( signal_outFB_fx, buffer, st->L_frame, hTcxDec->L_frameTCX ); - ApplyFdCng_ivas_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); + ApplyFdCng_fx( buffer, 0 /* Q of buffer */, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); } ELSE { - ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); + ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); } } @@ -915,7 +915,7 @@ void stereo_tcx_core_dec_fx( test(); IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && st->idchan == 0 ) { - ApplyFdCng_ivas_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); + ApplyFdCng_fx( signal_out_fx, 0, NULL, 0, NULL, NULL, NULL, st, st->bfi, 0 ); } } @@ -923,6 +923,7 @@ void stereo_tcx_core_dec_fx( return; } + static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, /* i/o: decoder state structure */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 3191a8b4a..8f09c1c7d 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -127,7 +127,7 @@ void tdm_low_rate_dec_fx( tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); /* Q0 */ } - gsc_dec_ivas_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc ); + gsc_dec_fx( st, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st->coder_type, &last_bin, lsf_new, exc_wo_nf_fx, &st->Q_exc ); /*--------------------------------------------------------------------------------------* * iDCT transform @@ -193,14 +193,9 @@ void tdm_low_rate_dec_fx( * * Decode generic (GC), 2 subframes mode *---------------------------------------------------------------------*/ -/*---------------------------------------------------------------------* - * decod_gen_2sbfr_ivas_fx() - * - * Decode generic (GC), 2 subframes mode - *---------------------------------------------------------------------*/ -void decod_gen_2sbfr_ivas_fx( - Decoder_State *st, /* i/o: decoder static memory */ +void decod_gen_2sbfr_fx( + Decoder_State *st, /* i/o: decoder static memory */ const Word16 sharpFlag, /* i : formant sharpening flag `Q0*/ const Word16 *Aq, /* i : LP filter coefficient Q12*/ Word16 *pitch_buf, /* o : Word16 pitch values for each subframe Q6*/ @@ -263,7 +258,7 @@ void decod_gen_2sbfr_ivas_fx( * Decode pitch lag *----------------------------------------------------------------------*/ - *pt_pitch = pit_decode_ivas_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ + *pt_pitch = pit_decode_fx( st, st->core_brate, 0, L_frame, i_subfr, GENERIC, &pitch_limit_flag, &T0, &T0_frac, &T0_min, &T0_max, 2 * L_SUBFR, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */ test(); test(); @@ -295,7 +290,7 @@ void decod_gen_2sbfr_ivas_fx( * Estimate spectrum tilt and voicing *--------------------------------------------------------------*/ - gain_dec_lbr_ivas_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); + gain_dec_lbr_fx( st, GENERIC, i_subfr, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, gc_mem, gp_mem, 2 * L_SUBFR ); st->tilt_code_fx = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, gain_code, &voice_fac, st->Q_exc, 2 * L_SUBFR, 0 ); /* Q15 */ move16(); @@ -312,10 +307,12 @@ void decod_gen_2sbfr_ivas_fx( Word16 gain_code16 = round_fx( L_shl( gain_code, st->Q_exc ) ); /*Q_exc*/ Acelp_dec_total_exc( exc, exc2, gain_code16, gain_pit, i_subfr, code, 2 * L_SUBFR ); + /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ - prep_tbe_exc_ivas_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); + + prep_tbe_exc_fx( L_frame, 2 * L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/], bwe_exc, 0, NULL, st->Q_exc, T0, T0_frac, GENERIC, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR /*i_subfr / L_SUBFR*/]; /* Q15 */ move16(); @@ -323,6 +320,7 @@ void decod_gen_2sbfr_ivas_fx( * Excitation enhancements (update of total excitation signal) * called twice because adapting it to double the subfr length would need lot of modifications *----------------------------------------------------------------*/ + enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code, exc2, gain_pit, &st->dm_fx, st->Q_exc ); enhancer_ivas_fx2( st->core_brate, 0, GENERIC, i_subfr, L_frame, voice_fac, st->stab_fac_fx, norm_gain_code, gain_inov, &st->gc_threshold_fx, code + L_SUBFR, exc2 + L_SUBFR, gain_pit, &st->dm_fx, st->Q_exc ); diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 9b7f77c79..913543db8 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -8,9 +8,11 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * Local functions *-------------------------------------------------------------------*/ + static void dqlsf_CNG_fx( Decoder_State *st_fx, Word16 *lsf_q ); /*--------------------------------------------------------------------------------------* @@ -88,7 +90,6 @@ static void dqlsf_CNG_fx( /* _ (Word16*) lsp_new : LP filter coefficient Q15 */ /* _ (Word16*) lsp_mid : LP filter coefficient Q15 */ /*---------------------------------------------------------------------------*/ - /* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */ /* vector for FEC Q(x2.56) */ /* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */ @@ -99,271 +100,16 @@ static void dqlsf_CNG_fx( /* _ None */ /*===========================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES void lsf_dec_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/ - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ -) -{ - Word16 i; - Word16 no_param_lpc; - Word16 param_lpc[NPRM_LPC_NEW]; - Word32 L_tmp; - Word16 nBits = 0; - move16(); - Word16 tmp_old[M + 1], tmp_new[M + 1]; - Word16 enr_old = 0, enr_new = 0; - move16(); - move16(); - Word16 lsf_diff, coder_type; - - /* initialize */ - coder_type = st_fx->coder_type; - if ( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - coder_type = INACTIVE; /* Q0 */ - move16(); - } - test(); - if ( EQ_16( coder_type, AUDIO ) && st_fx->GSC_IVAS_mode > 0 ) - { - coder_type = GENERIC; /* Q0 */ - move16(); - } - no_param_lpc = 0; - nBits = 0; - move16(); - move16(); - - /* Find the number of bits for LSF quantization */ - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - nBits = LSF_BITS_CNG; /* Q0 */ - move16(); - } - ELSE - { - test(); - IF( st_fx->nelp_mode_dec == 0 && st_fx->ppp_mode_dec == 0 ) - { - nBits = st_fx->acelp_cfg.lsf_bits; /* Q0 */ - move16(); - } - ELSE IF( EQ_16( st_fx->nelp_mode_dec, 1 ) ) - { - IF( EQ_16( coder_type, UNVOICED ) ) - { - nBits = 30; /* Q0 */ - move16(); - if ( st_fx->bwidth == NB ) - { - nBits = 32; /* Q0 */ - move16(); - } - } - } - ELSE IF( EQ_16( st_fx->ppp_mode_dec, 1 ) ) - { - nBits = 26; /* Q0 */ - move16(); - } - } - - /* LSF de-quantization */ - lsf_end_dec_fx( st_fx, 0, coder_type, st_fx->bwidth, nBits, lsf_new, param_lpc, LSF_Q_prediction, &no_param_lpc, - tdm_lsfQ_PCh ); - - /* convert quantized LSFs to LSPs */ - - lsf2lsp_fx( lsf_new, lsp_new, M, st_fx->sr_core ); - /* set seed_acelp used in UC mode */ - test(); - IF( EQ_16( coder_type, UNVOICED ) && GT_16( st_fx->element_mode, EVS_MONO ) ) - { - st_fx->seed_acelp = 0; - move16(); - FOR( i = no_param_lpc - 1; i >= 0; i-- ) - { - /* rightshift before *seed_acelp+param_lpc[i] to avoid overflows*/ - st_fx->seed_acelp = extract_l( L_add( imult3216( 31821L /* Q0 */, add( shr( ( st_fx->seed_acelp ), 1 ), param_lpc[i] ) ), 13849L /* Q0 */ ) ); /* Q0 */ - move16(); - } - } - IF( EQ_32( st_fx->core_brate, SID_2k40 ) ) - { - /* return if SID frame (conversion to A(z) done in the calling function) */ - return; - } - - /*-------------------------------------------------------------------------------------* - * FEC - update adaptive LSF mean vector - *-------------------------------------------------------------------------------------*/ - - FOR( i = 0; i < M; i++ ) - { - L_tmp = L_mult( lsf_new[i], 10922 ); /*Q(x2.56+16)*/ - L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi1_fx[i], 10922 ); /*Q(x2.56+16)*/ - L_tmp = L_mac( L_tmp, st_fx->lsfoldbfi0_fx[i], 10922 ); /*Q(x2.56+16)*/ - st_fx->lsf_adaptive_mean_fx[i] = round_fx( L_tmp ); /*Q(x2.56)*/ - move16(); - } - - test(); - test(); - IF( ( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) ) - { - lsf_diff = 1205; - move16(); /*int_fs / (float)(2*(M+1)); = 470.588 -> 1205 in Q2.56 */ - if ( EQ_16( st_fx->L_frame, L_FRAME ) ) - { - lsf_diff = 964; - move16(); /*int_fs / (float)(2*(M+1)); = 376.47 -> 964 in Q2.56 */ - } - st_fx->lsf_old_fx[0] = lsf_diff; - move16(); - - FOR( i = 1; i < M; i++ ) - { - st_fx->lsf_old_fx[i] = add( st_fx->lsf_old_fx[i - 1], lsf_diff ); /* Q2.56 */ - move16(); - } - lsf2lsp_fx( st_fx->lsf_old_fx, st_fx->lsp_old_fx, M, st_fx->sr_core ); - } - /*-------------------------------------------------------------------------------------* - * Mid-frame LSF decoding - * LSP interpolation and conversion of LSPs to A(z) - *-------------------------------------------------------------------------------------*/ - IF( st_fx->rate_switching_reset ) - { - /*extrapolation in case of unstable LSF convert*/ - Copy( lsp_new, st_fx->lsp_old_fx, M ); /* Q15 */ - Copy( lsf_new, st_fx->lsf_old_fx, M ); /* Q2.56 */ - } - { - /* Mid-frame LSF decoding */ - lsf_mid_dec_fx( st_fx, lsp_new, coder_type, lsp_mid ); - } - test(); - test(); - IF( !( st_fx->prev_bfi && ( EQ_16( coder_type, TRANSITION ) ) && ( EQ_16( tc_subfr, sub( st_fx->L_frame, L_SUBFR ) ) ) ) ) - { - IF( st_fx->prev_bfi ) - { - /* check, if LSP interpolation can be relaxed */ - E_LPC_f_lsp_a_conversion( st_fx->lsp_old_fx, tmp_old, M ); - enr_old = Enr_1_Az_fx( tmp_old, 2 * L_SUBFR ); /* Q3 */ - - E_LPC_f_lsp_a_conversion( lsp_new, tmp_new, M ); - enr_new = Enr_1_Az_fx( tmp_new, 2 * L_SUBFR ); /* Q3 */ - - IF( LT_16( enr_new, mult_r( 9830 /*0.3 Q15*/, enr_old ) ) ) - { - /* OLD CODE : if( st->safety_net == 1), replaced with a decision similar to MODE2 */ - st_fx->relax_prev_lsf_interp = -1; - move16(); - test(); - test(); - test(); - test(); - if ( st_fx->clas_dec == UNVOICED_CLAS || EQ_16( st_fx->clas_dec, SIN_ONSET ) || st_fx->clas_dec == INACTIVE_CLAS || EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) ) - { - st_fx->relax_prev_lsf_interp = 1; - move16(); - } - } - } - } - test(); - IF( EQ_16( st_fx->last_core, HQ_CORE ) && st_fx->core == ACELP_CORE ) - { - /* update old LSPs/LSFs in case of HQ->ACELP core switching */ - Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */ - lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */ - } - test(); - IF( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( coder_type, UNVOICED ) ) - { - // PMT("To be verified") - IF( EQ_16( st_fx->active_cnt, 1 ) ) - { - Copy( lsp_mid, st_fx->lsp_old_fx, M ); /* Q15 */ - lsp2lsf_fx( lsp_mid, st_fx->lsf_old_fx, M, st_fx->sr_core ); /* Q15 */ - Copy( lsp_new, lsp_mid, M ); /* Q15 */ - } - - /* LSP interpolation and conversion of LSPs to A(z) - two-subframe mode */ - int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, -2 ); - } - ELSE - { - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, st_fx->relax_prev_lsf_interp ); - } - /*------------------------------------------------------------------* - * Check LSF stability (distance between old LSFs and current LSFs) - *------------------------------------------------------------------*/ - - IF( st_fx->element_mode == EVS_MONO ) - { - st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /*Q15*/ - move16(); - } - ELSE - { - st_fx->stab_fac_fx = lsf_stab_ivas_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); /* Q15 */ - move16(); - } - - return; -} - -/*===========================================================================*/ -/* FUNCTION : lsf_dec_ivas_fx() */ -/*---------------------------------------------------------------------------*/ -/* PURPOSE : LSF decoder */ -/*---------------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Struct) st_fx : decoder static memory */ -/* _ (Word16) L_frame : length of the frame */ -/* _ (Word16) coder_type : coding type */ -/* _ (Word16) bwidth : input signal bandwidth */ -/*---------------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16*) Aq : LP filter coefficient Q12 */ -/* _ (Word16*) lsf_new : LP filter coefficient Q(x2.56) */ -/* _ (Word16*) lsp_new : LP filter coefficient Q15 */ -/* _ (Word16*) lsp_mid : LP filter coefficient Q15 */ -/*---------------------------------------------------------------------------*/ - -/* _ (Word16[]) st_fx->lsf_adaptive_mean_fx : FEC - adaptive mean LSF */ -/* vector for FEC Q(x2.56) */ -/* _ (Word16[]) st_fx->mem_AR_fx : AR memory of LSF quantizer */ -/* (past quantized LSFs without mean) Q(x2.56) */ -/* _ (Word16) st_fx->stab_fac_fx : LSF stability factor Q15 */ -/*---------------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ None */ -/*===========================================================================*/ -#endif -void lsf_dec_ivas_fx( - Decoder_State *st_fx, /* i/o: State structure */ - const Word16 tc_subfr, /* i : TC subframe index Q0*/ - Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ - Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ - Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ - Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ - Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ - const Word16 tdm_low_rate_mode /* i : secondary channel low rate mode flag Q0*/ - , - const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ + Decoder_State *st_fx, /* i/o: State structure */ + const Word16 tc_subfr, /* i : TC subframe index Q0*/ + Word16 *Aq, /* o : quantized A(z) for 4 subframes Q12*/ + Word16 *LSF_Q_prediction, /* o : LSF prediction mode Q0*/ + Word16 *lsf_new, /* o : de-quantized LSF vector Q(x2.56)*/ + Word16 *lsp_new, /* o : de-quantized LSP vector Q15*/ + Word16 *lsp_mid, /* o : de-quantized mid-frame LSP vector Q15*/ + const Word16 tdm_low_rate_mode, /* i : secondary channel low rate mode flag Q0*/ + const Word16 tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel Qx*/ ) { Word16 i; diff --git a/lib_dec/pit_dec_fx.c b/lib_dec/pit_dec_fx.c index e8cebedbd..38ec41cb2 100644 --- a/lib_dec/pit_dec_fx.c +++ b/lib_dec/pit_dec_fx.c @@ -319,246 +319,22 @@ void Mode2_delta_pit_dec( /* _ (Word16 ) pitch : close loop integer pitch Q6 */ /*=======================================================================*/ -#ifndef REMOVE_EVS_DUPLICATES -Word16 pit_decode_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr /* i : subframe length */ -) -{ - Word16 pitch; /*Q2*/ - Word16 pitch_index, nBits, pit_flag; - - pitch_index = 0; - move16(); - - /*----------------------------------------------------------------* - * Set pit_flag = 0 for every subframe with absolute pitch search - *----------------------------------------------------------------*/ - pit_flag = i_subfr; - move16(); - - if ( EQ_16( i_subfr, PIT_DECODE_2XL_SUBFR ) ) - { - pit_flag = 0; - move16(); - } - - /*-------------------------------------------------------* - * Retrieve the pitch index - *-------------------------------------------------------*/ - IF( !Opt_AMR_WB ) - { - /*----------------------------------------------------------------* - * pitch Q: Set limit_flag to 0 for restrained limits, and 1 for extended limits - *----------------------------------------------------------------*/ - test(); - test(); - IF( i_subfr == 0 ) - { - *limit_flag = 1; - move16(); - - if ( EQ_16( coder_type, VOICED ) ) - { - *limit_flag = 2; - move16(); /* double-extended limits */ - } - test(); - if ( EQ_16( coder_type, GENERIC ) && EQ_32( core_brate, ACELP_7k20 ) ) - { - *limit_flag = 0; - move16(); - } - } - ELSE IF( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( coder_type, GENERIC ) && LE_32( core_brate, ACELP_13k20 ) ) - { - if ( GT_16( *T0, shr( add( PIT_FR1_EXTEND_8b, PIT_MIN ), 1 ) ) ) - { - *limit_flag = 0; - move16(); - } - } - - /*-------------------------------------------------------* - * Retrieve the number of Q bits - *-------------------------------------------------------*/ - - nBits = 0; - move16(); - IF( NE_16( coder_type, AUDIO ) ) - { - /* find the number of bits */ - nBits = st_fx->acelp_cfg.pitch_bits[shr( i_subfr, 6 )]; - move16(); - pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); - } - - /*-------------------------------------------------------* - * Pitch decoding in AUDIO mode - * (both ACELP@12k8 and ACELP@16k cores) - *-------------------------------------------------------*/ - IF( EQ_16( coder_type, AUDIO ) ) - { - test(); - if ( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 ) - { - pit_flag = L_SUBFR; - move16(); - } - if ( pit_flag == 0 ) - { - nBits = 10; - move16(); - } - if ( pit_flag != 0 ) - { - nBits = 6; - move16(); - } - - pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); - - test(); - test(); - IF( EQ_16( L_subfr, L_FRAME / 2 ) && i_subfr != 0 && GE_16( pitch_index, 32 ) ) /* safety check in case of bit errors */ - { - pitch_index = shr( pitch_index, 1 ); - st_fx->BER_detect = 1; - move16(); - } - - pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - ELSE IF( EQ_16( coder_type, VOICED ) ) - { - /*-------------------------------------------------------* - * Pitch decoding in VOICED mode - * (ACELP@12k8 core only) - *-------------------------------------------------------*/ - if ( EQ_16( i_subfr, 2 * L_SUBFR ) ) - { - pit_flag = i_subfr; - move16(); - } - - pit_Q_dec_fx( 0, pitch_index, nBits, 4, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - ELSE - { - /*-------------------------------------------------------* - * Pitch decoding in GENERIC mode - * (both ACELP@12k8 and ACELP@16k cores) - *-------------------------------------------------------*/ - IF( EQ_16( L_frame, L_FRAME ) ) - { - pit_Q_dec_fx( 0, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - ELSE - { - pit16k_Q_dec_fx( pitch_index, nBits, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - } - } - - /*-------------------------------------------------------* - * Pitch decoding in AMR-WB IO mode - *-------------------------------------------------------*/ - - ELSE - { - *limit_flag = 0; - move16(); - test(); - test(); - IF( i_subfr == 0 || ( EQ_16( i_subfr, 2 * L_SUBFR ) && EQ_32( core_brate, ACELP_8k85 ) ) ) - { - nBits = 8; - move16(); - } - ELSE - { - nBits = 5; - move16(); - } - IF( GT_32( core_brate, ACELP_8k85 ) ) - { - nBits = 6; - move16(); - test(); - if ( i_subfr == 0 || EQ_16( i_subfr, 2 * L_SUBFR ) ) - { - nBits = 9; - move16(); - } - } - - pitch_index = (Word16) get_next_indice_fx( st_fx, nBits ); - - pit_Q_dec_fx( 1, pitch_index, nBits, 8, pit_flag, *limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); - } - - /*-------------------------------------------------------* - * Compute floating pitch output - *-------------------------------------------------------*/ - - pitch = shl( add( shl( *T0, 2 ), *T0_frac ), 4 ); /* save subframe pitch values Q6 */ - - return pitch; -} - -/*======================================================================*/ -/* FUNCTION : pit_decode_ivas_fx() */ -/*-----------------------------------------------------------------------*/ -/* PURPOSE : calculate pitch value */ -/* */ -/*-----------------------------------------------------------------------*/ -/* INPUT ARGUMENTS : */ -/* _ (Word32) core_brate : Core bitrate Q0 */ -/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode Q0 */ -/* _ (Word16) L_frame : length of the frame Q0 */ -/* _ (Word16) i_subfr : length of the frame Q0 */ -/* _ (Word16) coder_type : coding type Q0 */ -/* _ (Word16) L_subfr : subframe length */ -/*-----------------------------------------------------------------------*/ -/* OUTPUT ARGUMENTS : */ -/* _ (Word16 *) T0 : close loop integer pitch */ -/* _ (Word16 *) T0_frac : close loop fractional part of the pitch */ -/* _ (Word16 ) pitch : pitch value Q6 */ -/*-----------------------------------------------------------------------*/ -/* INPUT OUTPUT ARGUMENTS */ -/* _ (Word16 *) T0_min : delta search min for sf 2 & 4 */ -/* _ (Word16 *) T0_max : delta search max for sf 2 & 4 */ -/*-----------------------------------------------------------------------*/ -/* RETURN ARGUMENTS : */ -/* _ (Word16 ) pitch : close loop integer pitch Q6 */ -/*=======================================================================*/ - -#endif -Word16 pit_decode_ivas_fx( /* o : floating pitch value */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - const Word32 core_brate, /* i : core bitrate */ - const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ - const Word16 L_frame, /* i : length of the frame */ - Word16 i_subfr, /* i : subframe index */ - const Word16 coder_type, /* i : coding type */ - Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ - Word16 *T0, /* o : close loop integer pitch */ - Word16 *T0_frac, /* o : close loop fractional part of the pitch */ - Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ - Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ - const Word16 L_subfr, /* i : subframe length */ - const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ +/*! r: floating pitch value */ +Word16 pit_decode_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + const Word32 core_brate, /* i : core bitrate */ + const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ + const Word16 L_frame, /* i : length of the frame */ + Word16 i_subfr, /* i : subframe index */ + const Word16 coder_type, /* i : coding type */ + Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */ + Word16 *T0, /* o : close loop integer pitch */ + Word16 *T0_frac, /* o : close loop fractional part of the pitch */ + Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */ + Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const Word16 tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer Q6 */ ) { Word16 pitch; /*Q2*/ diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index b5d56d8fb..cbcb225bc 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -139,21 +139,13 @@ void post_decoder( { st->hPFstat->on = 1; move16(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); -#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); -#endif } ELSE { st->hPFstat->on = 0; move16(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); -#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); -#endif } } @@ -176,10 +168,10 @@ void post_decoder( /* Update synth2 memory */ Copy( synth_buf2 + L_frame, hBPF->pst_old_syn_fx, NBPSF_PIT_MAX ); - return; } + void post_decoder_ivas_fx( Decoder_State *st, Word16 synth_buf[], // Q0 @@ -310,21 +302,13 @@ void post_decoder_ivas_fx( { st->hPFstat->on = 1; move16(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); -#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 0 ); -#endif } ELSE { st->hPFstat->on = 0; move16(); -#ifdef REMOVE_EVS_DUPLICATES - formant_post_filt_ivas_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); -#else formant_post_filt_fx( st->hPFstat, synth, st->mem_Aq, synth2, L_frame, st->lp_noise, bitrate, 1 ); -#endif } } diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 4c3f7152c..ceba860a1 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -394,14 +394,10 @@ ivas_error acelp_core_enc_fx( test(); IF( !nelp_mode && !ppp_mode ) { -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#endif - st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, - tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, - tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + st_fx->L_frame, st_fx->GSC_noisy_speech, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, + tc_subfr_fx, 0, &nb_bits, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, + tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } /*-----------------------------------------------------------------* @@ -464,19 +460,16 @@ ivas_error acelp_core_enc_fx( { tc_classif_enc_fx( Q_new, st_fx->L_frame, &tc_subfr_fx, &position, attack_flag, st_fx->pitch[0], res_fx ); -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#endif - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, - tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr_fx, 1, NULL, unbits_fx, st_fx->element_mode, &uc_two_stage_flag, + tdm_lp_reuse_flag, tdm_low_rate_mode, st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); } /*---------------------------------------------------------------* * Calculation of prediction for scaled innovation energy * (for memory-less gain quantizer) *---------------------------------------------------------------*/ + IF( nb_bits > 0 ) { Es_pred_enc_fx( &Es_pred_fx, &indice, st_fx->L_frame, res_fx, st_fx->voicing_fx, nb_bits, 0, Q_new ); @@ -521,13 +514,9 @@ ivas_error acelp_core_enc_fx( lsp_mid_bck_fx, mCb1_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen_fx ); /* Configure ACELP bit allocation */ -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, -#endif - -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, - st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, st_fx->L_frame, + -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, st_fx->coder_type, st_fx->inactive_coder_type_flag, tc_subfr_fx, 0, &nb_bits, unbits_fx, 0, &uc_two_stage_flag, 0, 0, + st_fx->idchan, st_fx->active_fr_cnt_fx, tdm_Pitch_reuse_flag, st_fx->tdm_LRTD_flag, st_fx->GSC_IVAS_mode ); /* redo LSF quantization */ lsf_enc_fx( st_fx, lsf_new_fx, lsp_new_fx, lsp_mid_fx, Aq_fx, st_fx->Nb_ACELP_frames, tdm_low_rate_mode, st_fx->GSC_IVAS_mode, Q_new ); @@ -1185,7 +1174,7 @@ ivas_error acelp_core_enc_ivas_fx( test(); IF( !nelp_mode && !ppp_mode ) { - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } /*-----------------------------------------------------------------* @@ -1322,7 +1311,7 @@ ivas_error acelp_core_enc_ivas_fx( { tc_classif_enc_fx( Q_new, st->L_frame, &tc_subfr, &position, attack_flag, st->pitch[0], res_fx ); - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, tc_subfr, 1, NULL, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); } /*---------------------------------------------------------------* @@ -1381,7 +1370,7 @@ ivas_error acelp_core_enc_ivas_fx( lsf_syn_mem_restore_ivas_fx( st, tilt_code_bck_fx, gc_threshold_bck_fx, clip_var_bck_fx, next_force_sf_bck, lsp_new, lsp_mid, clip_var_fx, mem_AR_fx, mem_MA_fx, lsp_new_bck_fx, lsp_mid_bck_fx, Bin_E_fx, Bin_E_old_fx, mem_syn_bck_fx, mem_w0_bck_fx, streaklimit_fx, pstreaklen ); /* Configure ACELP bit allocation */ - config_acelp1_IVAS( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); + config_acelp1_fx( ENC, st->total_brate, st->core_brate, st->core, st->extl, st->extl_brate, st->L_frame, -1, &( st->acelp_cfg ), hBstr->nb_bits_tot, st->coder_type, st->inactive_coder_type_flag, tc_subfr, 0, &nb_bits, unbits, 0, &uc_two_stage_flag, 0, 0, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); /* redo LSF quantization */ lsf_enc_ivas_fx( st, lsf_new_fx, lsp_new, lsp_mid, Aq, tdm_low_rate_mode, 0, NULL, Q_new ); @@ -1390,6 +1379,7 @@ ivas_error acelp_core_enc_ivas_fx( calc_residu_fx( st, inp, res_fx, Aq ); st->hTdCngEnc->burst_ho_cnt = 0; move16(); + /* VOICED frames in SC-VBR */ encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new ); } diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index bad70b08c..76fa6f151 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -10,32 +10,17 @@ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ #include "basop_util.h" /* Function prototypes */ + /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ -static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, - const Word16 L_frame_fx, - const Word16 inp_fx[], - const Word16 Aq_fx[], - const Word16 A_fx[], - const Word16 T_op[], - Word16 *exc_fx, - const Word32 core_bitrate_fx, - Word16 shift, - Word16 Q_new ); -static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, - const Word16 L_frame_fx, - const Word16 inp_fx[], - const Word16 Aq_fx[], - const Word16 A_fx[], - const Word16 T_op[], - Word16 *exc_fx, - const Word32 core_bitrate_fx, - Word16 shift, - Word16 Q_new ); +static void encod_gen_voic_core_switch_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); + +static void encod_gen_voic_core_switch_ivas_fx( Encoder_State *st_fx, const Word16 L_frame_fx, const Word16 inp_fx[], const Word16 Aq_fx[], const Word16 A_fx[], const Word16 T_op[], Word16 *exc_fx, const Word32 core_bitrate_fx, Word16 shift, Word16 Q_new ); static void bwe_switch_enc_fx( Encoder_State *st_fx, const Word16 *new_speech ); + static void bwe_switch_enc_ivas_fx( Encoder_State *st_fx, const Word16 *new_speech ); static Word16 dotprod_satcont( const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len, Word16 delta ); @@ -150,12 +135,8 @@ void acelp_core_switch_enc_fx( * Excitation encoding *----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, -#else - config_acelp1( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, -#endif - GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); + config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, + GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); @@ -278,8 +259,8 @@ void acelp_core_switch_enc_ivas_fx( * Excitation encoding *----------------------------------------------------------------*/ - config_acelp1_IVAS( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, - GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); + config_acelp1_fx( ENC, st_fx->total_brate, cbrate, st_fx->core, -1, -1, st_fx->last_L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, + GENERIC, st_fx->inactive_coder_type_flag, -1, -1, &j, &i, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, 0, 0 /*GSC_IVAS_mode*/ ); encod_gen_voic_core_switch_ivas_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); diff --git a/lib_enc/analy_lp_fx.c b/lib_enc/analy_lp_fx.c index 78a02eeec..9b6ff2108 100644 --- a/lib_enc/analy_lp_fx.c +++ b/lib_enc/analy_lp_fx.c @@ -3,17 +3,16 @@ ====================================================================================*/ #include -#include "options.h" /* Compilation switches */ -#include "cnst.h" /* Common constants */ -#include "rom_com_fx.h" /* Static table prototypes */ -#include "rom_com.h" /* Static table prototypes */ -#include "rom_enc.h" /* Static table prototypes */ -//#include "prot_fx.h" /* Function prototypes */ +#include "options.h" /* Compilation switches */ +#include "cnst.h" /* Common constants */ +#include "rom_com_fx.h" /* Static table prototypes */ +#include "rom_com.h" /* Static table prototypes */ +#include "rom_enc.h" /* Static table prototypes */ #include "prot_fx.h" /* Function prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ /*-------------------------------------------------------------------* - * analy_lp() + * analy_lp_fx() * * Perform LP analysis * @@ -23,26 +22,26 @@ * - find interpolated LSPs and convert back to A(z) for all subframes * - update LSPs for the next frame *-------------------------------------------------------------------*/ -void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ -#ifdef REMOVE_EVS_DUPLICATES - const Word16 element_mode, /* i : element mode */ -#endif - const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /*i: stores Q for speech*/ - Word16 *Q_r /*stores q for ener*/ ) + +void analy_lp_fx( + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 element_mode, /* i : element mode */ + const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ + Word16 Q_new, /* i : stores Q for speech */ + Word16 *Q_r /*stores q for ener*/ +) { Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */ Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */ @@ -77,9 +76,7 @@ void analy_lp_ivas_fx( /* Autocorrelations */ autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); -#ifdef REMOVE_EVS_DUPLICATES IF( NE_16( element_mode, EVS_MONO ) ) -#endif { /*if ( r[0] < 100.0f && no_thr == 0 )*/ /*r[0] = 100.0f*/ @@ -132,101 +129,6 @@ void analy_lp_ivas_fx( return; } -#ifndef REMOVE_EVS_DUPLICATES -void analy_lp_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_look, /* i : look-ahead Q0*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 lsp_new[], /* o : current frame LSPs Q15*/ - Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/ - Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/ - const Word16 Top[2], /* i : open loop pitch lag Q0*/ - const Word16 Tnc[2], /* i : open loop pitch gain Q15*/ - const Word32 Core_sr, /* i : Internal core sampling rate Q0*/ - const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/ - Word16 Q_new, - Word16 *Q_r ) -{ - Word16 r_h[M + 1]; /* Autocorrelations of windowed speech MSB */ - Word16 r_l[M + 1]; /* Autocorrelations of windowed speech LSB */ - Word32 LepsP[M + 1]; - Word16 i, i_subfr, wind_length = 0; - Word16 *lsp; - const Word16 *wind = NULL; - const Word16 *pt; - Word16 half_frame; - - IF( EQ_16( L_frame, L_FRAME ) ) - { - wind_length = L_LP; - move16(); - wind = Assym_window_W16fx; /* Q15 */ - } - ELSE /* L_frame == L_FRAME16k */ - { - wind_length = L_LP_16k; - move16(); - wind = assym_window_16k_fx; /* Q15 */ - } - lsp = lsp_mid; /* Q15 */ - half_frame = shr( L_frame, 1 ); - - FOR( i_subfr = 0; i_subfr <= 1; i_subfr++ ) - { - pt = speech + sub( add( half_frame, L_look ), wind_length ); - half_frame = shl( half_frame, 1 ); - - /* Autocorrelations */ - autocorr_fx( pt, M, r_h, r_l, &Q_r[1 - i_subfr], wind_length, wind, 0, 0 ); - - /* Lag windowing */ - adapt_lag_wind( r_h, r_l, M, Top[i_subfr], Tnc[i_subfr], Core_sr ); - - /* Levinson-Durbin */ - E_LPC_lev_dur( r_h, r_l, A, LepsP, M, NULL ); - FOR( i = 0; i <= M; i++ ) - { - L_Extract( LepsP[i], &epsP_h[i], &epsP_l[i] ); - } - /*Q_r[... might not be needed from external...*/ - Q_r[1 - i_subfr] = add( Q_r[1 - i_subfr], shl( Q_new, 1 ) ); - move16(); - - /* Conversion of A(z) to LSPs */ - E_LPC_a_lsp_conversion( A, lsp, lsp_old, M ); - - lsp = lsp_new; /* Q15 */ - } - IF( EQ_16( sec_chan_low_rate, 1 ) ) - { - /* LSP interpolation */ -#ifdef REMOVE_EVS_DUPLICATES - int_lsp4_ivas_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#else - int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, -2 ); -#endif - } - ELSE - { - /* LSP interpolation */ -#ifdef REMOVE_EVS_DUPLICATES - int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); -#else - int_lsp4_fx( L_frame, lsp_old, lsp_mid, lsp_new, A, M, 0 ); -#endif - } - Copy( lsp_new, lsp_old, M ); /* Q15 */ - *ener = L_Comp( epsP_h[M], epsP_l[M] ); /* Q_r */ - move32(); - - return; -} -#endif - /*-------------------------------------------------------------------* * analy_lp_AMR_WB() * diff --git a/lib_enc/cod_ace_fx.c b/lib_enc/cod_ace_fx.c index b5c18d44b..e1914aeb5 100644 --- a/lib_enc/cod_ace_fx.c +++ b/lib_enc/cod_ace_fx.c @@ -366,14 +366,9 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision * IF( st->igf != 0 ) { -#ifdef REMOVE_EVS_DUPLICATES - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate, - st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); -#else - prep_tbe_exc_fx( L_frame, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate ); -#endif + prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc, gain_preQ, code_preQ, Q_new, T0, T0_frac, st->coder_type, st->core_brate, + st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); } /*---------------------------------------------------------* diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 3ff99812f..a485a1bf3 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -363,20 +363,15 @@ void encod_gen_voic_fx( exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow ); /* Q0 */ } } + /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, - T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); -#else - prep_tbe_exc_fx( L_frame, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, - T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate ); -#endif + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. @@ -405,9 +400,11 @@ void encod_gen_voic_fx( hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */ move16(); } + return; } + void encod_gen_voic_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 speech_fx[], /* i : input speech Qnew -1 */ @@ -763,10 +760,10 @@ void encod_gen_voic_ivas_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, - &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, - T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); + prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr_fx, gain_pit_fx, gain_code_fx, code_fx, voice_fac_fx, + &voice_factors_fx[i_subfr_fx / L_SUBFR], bwe_exc_fx, gain_preQ_fx, code_preQ_fx, Q_new, + T0_fx, T0_frac_fx, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index dde834b2b..9802dc15b 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -308,13 +308,8 @@ Word16 encod_tran_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ -#ifdef REMOVE_EVS_DUPLICATES - prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); -#else - prep_tbe_exc_fx( L_frame_fx, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate ); -#endif + prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. @@ -719,9 +714,9 @@ Word16 encod_tran_ivas_fx( * Prepare TBE excitation *-----------------------------------------------------------------*/ - prep_tbe_exc_ivas_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], - bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, - st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); + prep_tbe_exc_fx( L_frame_fx, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], + bwe_exc_fx, gain_preQ, code_preQ, Q_new, T0, T0_frac, st_fx->coder_type, st_fx->core_brate, + st_fx->element_mode, st_fx->idchan, st_fx->hBWE_TD != NULL, st_fx->tdm_LRTD_flag ); /*-----------------------------------------------------------------* * Synthesize speech to update mem_syn[]. diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 76640e7a7..f1e6b2193 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1104,12 +1104,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); } -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r ); -#else - analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, - INT_FS_12k8, i, *Q_new, Q_r ); -#endif + analy_lp_fx( inp_12k8_fx, L_FRAME, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, element_mode, i, *Q_new, Q_r ); FOR( Word16 idx = 0; idx < M + 1; idx++ ) { diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 41e409456..938ab9964 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1140,20 +1140,11 @@ ivas_error ivas_compute_core_buffers_fx( IF( Q_new ) { -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r ); -#else - analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, sub( *Q_new, 1 ), Q_r ); -#endif + analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, sub( *Q_new, 1 ), Q_r ); } ELSE { -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); - -#else - analy_lp_ivas_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, 0, -1, Q_r ); -#endif + analy_lp_fx( inp_16k_fx, L_FRAME16k, L_look, ener_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lspold_enc_fx, st->pitch, st->voicing_fx, INT_FS_16k, element_mode, 0, -1, Q_r ); } /*--------------------------------------------------------------* diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index b3c563863..f2b3adece 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -629,11 +629,7 @@ ivas_error front_vad_spar_fx( hFrontVad->q_buffer_12k8 = Q_inp_12k8; move16(); -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r ); -#else - analy_lp_ivas_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, 0 /* <-- sec_chan_low_rate */, Q_inp_12k8, Q_r ); -#endif + analy_lp_fx( inp_12k8_fx, L_FRAME, L_LOOK_12k8, &res_energy_fx, A_fx, epsP_h, epsP_l, lsp_new_fx, lsp_mid_fx, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing_fx, INT_FS_12k8, st->element_mode, 0, Q_inp_12k8, Q_r ); FOR( Word16 i = 0; i <= M; i++ ) { diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 77ddb35aa..d10527a24 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -365,11 +365,12 @@ void encod_gen_2sbfr( move16(); move16(); } + /*-----------------------------------------------------------------* * Prepare TBE excitation *-----------------------------------------------------------------*/ - prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); + prep_tbe_exc_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag ); voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; /* Q15 */ move16(); @@ -378,6 +379,7 @@ void encod_gen_2sbfr( * Synthesize speech to update mem_syn_flt[]. * Update A(z) filters *-----------------------------------------------------------------*/ + Syn_filt_s( 1, p_Aq, M, &exc[i_subfr], &syn[i_subfr], 2 * L_SUBFR, hLPDmem->mem_syn, 1 ); p_Aw += 2 * ( M + 1 ); p_Aq += 2 * ( M + 1 ); diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index 8fe425d74..b26532b15 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -289,13 +289,16 @@ void lsf_enc_fx( { int_lsp4_fx( st_fx->L_frame, st_fx->lsp_old_fx, lsp_mid, lsp_new, Aq, M, 0 ); } + /*------------------------------------------------------------------* * Check LSF stability (distance between old LSFs and current LSFs) *------------------------------------------------------------------*/ + IF( NE_32( st_fx->core_brate, SID_2k40 ) ) { st_fx->stab_fac_fx = lsf_stab_fx( lsf_new, st_fx->lsf_old_fx, 0, st_fx->L_frame ); } + return; } @@ -1982,7 +1985,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2172,7 +2175,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index e8d4a0722..cc8b64ca4 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -213,7 +213,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* @@ -414,11 +414,7 @@ void pre_proc_fx( alw_voicing[1] = st->voicing_fx[2]; move16(); -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r ); -#else - analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); -#endif + analy_lp_fx( inp_12k8, L_FRAME, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lsp_old1_fx, alw_pitch_lag_12k8, alw_voicing, INT_FS_12k8, EVS_MONO, 0, *Q_new, Q_r ); lsp2lsf_fx( lsp_new, lsf_new, M, INT_FS_12k8 ); stab_fac = lsf_stab_fx( lsf_new, st->lsf_old1_fx, 0, L_FRAME ); @@ -1131,11 +1127,7 @@ void pre_proc_fx( Copy( st->lsp_old1_fx, st->lspold_enc_fx, M ); } -#ifdef REMOVE_EVS_DUPLICATES - analy_lp_ivas_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r ); -#else - analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, -1 /*IVAS_CODE !! LowRateFlag*/, *Q_new, Q_r ); -#endif + analy_lp_fx( inp_16k, L_FRAME16k, L_look, ener, A, epsP_h, epsP_l, lsp_new, lsp_mid, st->lspold_enc_fx, st->pitch, st->voicing_fx, 16000, EVS_MONO, 0, *Q_new, Q_r ); /*--------------------------------------------------------------* * Compute Weighted Input diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 1d85ae6de..968ab0082 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -41,9 +41,8 @@ #include "ivas_error_utils.h" #include "complex_basop.h" #include "ivas_stat_enc.h" -/*----------------------------------------------------------------------------------* - * Prototypes of RAM counting tool macros - *----------------------------------------------------------------------------------*/ + + ivas_error acelp_core_enc_fx( Encoder_State *st_fx, /* i/o: encoder state structure */ const Word16 inp_fx[], /* i : input signal of the current frame Q_new*/ @@ -68,57 +67,37 @@ ivas_error acelp_core_enc_fx( ); -void analy_lp_ivas_fx( - const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ - const Word16 L_frame, /* i :(q0) length of the frame */ - const Word16 L_look, /* i :(q0) look-ahead */ - Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ - Word16 A[], /* o :(q14) A(z) filter coefficients */ - Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ - Word16 lsp_new[], /* o :(q15) current frame LSPs */ - Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ - Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ - const Word16 Top[2], /* i :(q0) open loop pitch lag */ - const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ - const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ -#ifdef REMOVE_EVS_DUPLICATES - const Word16 element_mode, /* i : element mode */ -#endif - const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ - Word16 Q_new, /*i: stores Q for speech*/ - Word16 *Q_r /*stores q for ener*/ ); - -#ifndef REMOVE_EVS_DUPLICATES void analy_lp_fx( - const Word16 speech[], /* i : pointer to the speech frame Q_new*/ - const Word16 L_frame, /* i : length of the frame Q0*/ - const Word16 L_look, /* i : look-ahead Q0*/ - Word32 *ener, /* o : residual energy from Levinson-Durbin Q_r*/ - Word16 A[], /* o : A(z) filter coefficients Q14*/ - Word16 epsP_h[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 epsP_l[], /* o : LP analysis residual energies for each iteration Q_r*/ - Word16 lsp_new[], /* o : current frame LSPs Q15*/ - Word16 lsp_mid[], /* o : current mid-frame LSPs Q15*/ - Word16 lsp_old[], /* i/o: previous frame unquantized LSPs Q15*/ - const Word16 Top[2], /* i : open loop pitch lag Q0*/ - const Word16 Tnc[2], /* i : open loop pitch gain Q15*/ - const Word32 Core_sr, /* i : Internal core sampling rate Q0*/ - const Word16 sec_chan_low_rate, /* i : flag to signal second channel Q0*/ - Word16 Q_new, - Word16 *Q_r ); -#endif - -void AVQ_cod_fx( /* o: comfort noise gain factor */ - const Word16 xri[], /* i: vector to quantize */ - Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */ - const Word16 NB_BITS, /* i: number of allocated bits */ - const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */ - const Word16 Q_in_ref /* i: Scaling i */ + const Word16 speech[], /* i :(Q_new) pointer to the speech frame */ + const Word16 L_frame, /* i :(q0) length of the frame */ + const Word16 L_look, /* i :(q0) look-ahead */ + Word32 *ener, /* o :(Q_r) residual energy from Levinson-Durbin */ + Word16 A[], /* o :(q14) A(z) filter coefficients */ + Word16 epsP_h[], /* o :(high part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 epsP_l[], /* o :(low part of epsP(Q_r)) LP analysis residual energies for each iteration */ + Word16 lsp_new[], /* o :(q15) current frame LSPs */ + Word16 lsp_mid[], /* o :(q15) current mid-frame LSPs */ + Word16 lsp_old[], /* i/o:(q15) previous frame unquantized LSPs */ + const Word16 Top[2], /* i :(q0) open loop pitch lag */ + const Word16 Tnc[2], /* i :(q15) open loop pitch gain */ + const Word32 Core_sr, /* i :(q0) Internal core sampling rate */ + const Word16 element_mode, /* i : element mode */ + const Word16 sec_chan_low_rate, /* i :(q0) flag to signal second channel */ + Word16 Q_new, /* i : stores Q for speech */ + Word16 *Q_r /*stores q for ener*/ +); + +/*1 r: comfort noise gain factor */ +void AVQ_cod_fx( + const Word16 xri[], /* i: vector to quantize */ + Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */ + const Word16 NB_BITS, /* i: number of allocated bits */ + const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */ + const Word16 Q_in_ref /* i: Scaling i */ ); void AVQ_encmux_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 extl, /* i : extension layer */ Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ @@ -130,7 +109,7 @@ void AVQ_encmux_fx( ); void AVQ_encmux_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ const Word16 extl, /* i : extension layer */ Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */ @@ -151,15 +130,15 @@ void bw_detect_fx( const Word16 mct_on, /* i : flag MCT mode */ const Word16 Q_spec ); -void core_switching_post_enc_fx( /*done */ - Encoder_State *st_fx, /* i/o: encoder state structure */ - const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/ - const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/ - const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */ - Word16 Qshift, - Word16 Q_new, - const Word16 Qsp, /* i/o : Q from acelp synthsis */ - Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */ +void core_switching_post_enc_fx( + Encoder_State *st_fx, /* i/o: encoder state structure */ + const Word16 inp12k8[], /* i : i signal @12.8 kHz Qinp*/ + const Word16 inp16k[], /* i : i signal @16 kHz Qinp*/ + const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */ + Word16 Qshift, + Word16 Q_new, + const Word16 Qsp, /* i/o : Q from acelp synthsis */ + Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */ ); void core_switching_pre_enc_fx( @@ -170,8 +149,9 @@ void core_switching_pre_enc_fx( const Word16 last_element_mode /* i : last_element_mode Q0*/ ); -Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */ - const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */ +/*! r: noise dependent voicing correction Q15 */ +Word16 correlation_shift_fx( + const Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */ ); void dtx_fx( diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index c724ffd6c..d0d627697 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -212,13 +212,9 @@ void transition_enc_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { /* this is called only to compute unused bits */ -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#endif - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, sub( shift_wsp, 1 ) ); @@ -328,13 +324,9 @@ void transition_enc_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#endif - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* @@ -1040,14 +1032,9 @@ void transition_enc_ivas_fx( IF( EQ_16( *tc_subfr, TC_0_0 ) ) { /* this is called only to compute unused bits */ - -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#endif - L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, - st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + L_FRAME, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, TC_0_0, 3, NULL, unbits_ACELP, + st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } @@ -1158,13 +1145,9 @@ void transition_enc_ivas_fx( IF( LE_16( sub( i_subfr, *tc_subfr ), L_SUBFR ) ) { -#ifdef REMOVE_EVS_DUPLICATES - config_acelp1_IVAS( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#else - config_acelp1( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, -#endif - st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, - unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); + config_acelp1_fx( ENC, st_fx->total_brate, st_fx->core_brate, st_fx->core, st_fx->extl, st_fx->extl_brate, + st_fx->L_frame, -1, &( st_fx->acelp_cfg ), hBstr->nb_bits_tot, TRANSITION, -1, *tc_subfr, 2, NULL, + unbits_ACELP, st_fx->element_mode, &i /*dummy*/, 0 /*tdm_lp_reuse_flag*/, 0 /*tdm_low_rate_mode*/, st_fx->idchan, st_fx->active_fr_cnt_fx, 0 /*tdm_Pitch_reuse_flag*/, st_fx->tdm_LRTD_flag, 0 /*GSC_IVAS_mode*/ ); } /*-----------------------------------------------------------------* -- GitLab From ac901c58364fb528358a4f130523acb2d166a1a8 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 17 Apr 2025 15:52:49 +0200 Subject: [PATCH 069/394] rename file --- Workspace_msvc/lib_dec.vcxproj | 2 +- Workspace_msvc/lib_dec.vcxproj.filters | 6 +- lib_dec/acelp_core_dec_fx.c | 68 +- lib_dec/acelp_core_dec_ivas_fx.c | 2396 ------------------------ lib_dec/ivas_td_low_rate_dec_fx.c | 14 +- 5 files changed, 49 insertions(+), 2437 deletions(-) delete mode 100644 lib_dec/acelp_core_dec_ivas_fx.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 2839a5812..12f77b346 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -139,7 +139,7 @@ false - + diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters index ebf15bd4c..25079058c 100644 --- a/Workspace_msvc/lib_dec.vcxproj.filters +++ b/Workspace_msvc/lib_dec.vcxproj.filters @@ -119,9 +119,6 @@ decoder_all_c - - decoder_all_c - decoder_all_c @@ -515,6 +512,9 @@ decoder_ivas_c + + decoder_all_c + diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 32aab2bb0..f518ef712 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -79,7 +79,7 @@ ivas_error acelp_core_dec_fx( Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ - Word16 output_frame; /* frame length at output sampling freq. */ + Word16 output_frame; /* frame length at output sampling freq. */ Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ @@ -259,7 +259,7 @@ ivas_error acelp_core_dec_fx( move16(); if ( st->hPFstat != NULL ) { - /* in case of core switching, reset post-filter memories */ + /* in case of core switching, reset post-filter memories */ st->hPFstat->on = 0; move16(); } @@ -277,8 +277,8 @@ ivas_error acelp_core_dec_fx( { /* reset the GSC pre echo energy threshold in case of FEC */ st->hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - } + move32(); + } test(); test(); @@ -357,10 +357,10 @@ ivas_error acelp_core_dec_fx( test(); /* reset post-filter in case of switching */ if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) - { + { st->hPFstat->reset = 1; - move16(); - } + move16(); + } avoid_lpc_burst_on_recovery = 0; move16(); @@ -663,7 +663,7 @@ ivas_error acelp_core_dec_fx( FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); } ELSE - { + { Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; move16(); @@ -817,7 +817,7 @@ ivas_error acelp_core_dec_fx( IF( EQ_16( st->element_mode, EVS_MONO ) ) { - /* update st_fx->mem_syn1 for ACELP core switching */ + /* update st_fx->mem_syn1 for ACELP core switching */ Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); } ELSE @@ -1529,11 +1529,11 @@ ivas_error acelp_core_dec_fx( set16_fx( st->hPFstat->mem_zero, 0, M ); formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); - } + } ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) ) - { + { IF( st->hPFstat->on ) - { + { Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M ); Copy( psyn_fx, temp_buf_fx + M, L_SUBFR ); @@ -1604,9 +1604,9 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - test(); - test(); - test(); + test(); + test(); + test(); test(); test(); test(); @@ -1626,7 +1626,7 @@ ivas_error acelp_core_dec_fx( { test(); IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) ) - { + { /* Clear memory for secondary channel CNA */ set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) ); } @@ -1710,8 +1710,8 @@ ivas_error acelp_core_dec_fx( test(); test(); test(); - test(); - test(); + test(); + test(); test(); IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) { @@ -1746,7 +1746,7 @@ ivas_error acelp_core_dec_fx( set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); } IF( hStereoCng != NULL && ( st->idchan == 0 ) ) - { + { set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); } } @@ -1763,26 +1763,26 @@ ivas_error acelp_core_dec_fx( CLDFB_SCALE_FACTOR scaleFactor; Word32 workBuffer[128 * 3]; - /* check if the CLDFB works on the right sample rate */ + /* check if the CLDFB works on the right sample rate */ IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) - { - /* resample to ACELP internal sampling rate */ + { + /* resample to ACELP internal sampling rate */ Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); IF( st->ini_frame > 0 ) - { + { st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); + move16(); + } } - } - test(); + test(); IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) { + IF( EQ_16( st->L_frame, L_FRAME ) ) + { retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); } ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) @@ -2091,8 +2091,8 @@ ivas_error acelp_core_dec_fx( imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; move32(); move32(); - } - } + } + } #ifndef OPT_AVOID_STATE_BUF_RESCALE Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); @@ -2147,7 +2147,7 @@ ivas_error acelp_core_dec_fx( scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; - move16(); + move16(); } /* save synthesis - needed in case of core switching */ @@ -2159,10 +2159,10 @@ ivas_error acelp_core_dec_fx( /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ FOR( i = 0; i < st->L_frame; i++ ) - { + { syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); move32(); - } + } Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 @@ -2340,7 +2340,7 @@ ivas_error acelp_core_dec_fx( non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); } ELSE - { + { Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c deleted file mode 100644 index 2c72bba78..000000000 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ /dev/null @@ -1,2396 +0,0 @@ -/****************************************************************************************************** - - (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -/*==================================================================================== - EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0 - ====================================================================================*/ -#include -#include -#include -#include "options.h" -#include "cnst.h" -#include "rom_com.h" -#include "prot_fx.h" -#include "ivas_cnst.h" -#include "ivas_rom_com.h" -#include "wmc_auto.h" -#include "ivas_prot_fx.h" - - -/*-------------------------------------------------------------------* - * acelp_core_dec_fx() - * - * ACELP core decoder - *-------------------------------------------------------------------*/ - -ivas_error acelp_core_dec_fx( - Decoder_State *st, /* i/o: decoder state structure */ - Word16 output_fx[], /* o : synthesis @internal Fs Q_syn*/ - Word16 synth_fx16[], /* o : synthesis Q_syn2*/ - Word16 save_hb_synth_fx16[], /* o : HB synthesis Q0*/ - Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation 2*Q_exc*/ - Word16 *voice_factors_fx, /* o : voicing factors Q15*/ - Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE Q_syn2-1*/ - const Word16 sharpFlag, /* i : formant sharpening flag */ - Word16 pitch_buf_fx[NB_SUBFR16k], /* o : Word16 pitch for each subframe Q6*/ - Word16 *unbits, /* o : number of unused bits */ - Word16 *sid_bw, /* o : 0-NB/WB, 1-SWB SID */ - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle Qlog2(2.56)*/ - const Word16 tdm_lspQ_PCh_fx[M], /* i : Q LSPs for primary channel Q15*/ - const Word16 tdm_lsfQ_PCh_fx[M], /* i : Q LSFs for primary channel */ - const Word16 use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const Word16 last_element_mode, /* i : last element mode */ - const Word32 last_element_brate, /* i : last element bitrate */ - const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ - const Word16 nchan_out, /* i : number of output channels */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const Word16 read_sid_info /* i : read SID info flag */ -) -{ - Word32 synth_fx[960], save_hb_synth_fx[960] /*, bwe_exc_extended_fx[L_FRAME32k + NL_BUFF_OFFSET]*/; - Word16 old_exc_fx[L_EXC_DEC], *exc_fx; /* excitation signal buffer */ - Word16 syn_tmp_fx[L_FRAME16k + L_SUBFR], *psyn_fx; /* synthesis signal buffer */ - Word16 output_frame; /* frame length at output sampling freq. */ - Word16 lsf_new_fx[M]; /* LSFs at the end of the frame Qlog2(2.56) */ - Word16 lsp_new_fx[M]; /* LSPs at the end of the frame Q15 */ - Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ - Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ - Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ - Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ - Word32 enr_q_fx; /* E information for FER protection */ - Word16 tmp_noise_fx; /* Long term temporary noise energy */ - Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ - Word16 FEC_pitch_fx; /* FEC pitch */ - Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ - Word16 *bwe_exc_fx; /* Excitation for SWB TBE */ - Word16 i, j, int_fs; - Word16 tc_subfr; - Word16 allow_cn_step; - Word16 temp_buf_fx[L_FRAME16k + L_SYN_MEM]; - Word16 last_pulse_pos; - Word16 T0_tmp; - Word16 do_WI; - Word16 dct_buffer_fx[DCT_L_POST]; - Word16 exc_buffer_fx[DCT_L_POST]; - Word16 dct_exc_tmp_fx[L_FRAME16k]; - Word16 nb_bits; /* number of bits */ - Word16 indice; /* parameter indices to write */ - Word16 gain_buf_fx[NB_SUBFR16k]; - Word16 syn_fx_tmp2[L_FRAME_16k]; - Word16 pitch_buf_tmp[NB_SUBFR16k]; - Word16 update_flg; - Word32 q_env_fx[20]; - Word16 exc3_fx[L_FRAME16k]; - Word16 syn1_tmp_fx[L_FRAME16k + 2], *syn1_fx; - Word32 *realBuffer_fx[CLDFB_NO_COL_MAX], *imagBuffer_fx[CLDFB_NO_COL_MAX]; - Word32 realBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 imagBufferTmp_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word16 LSF_Q_prediction; /* LSF prediction mode */ - Word16 avoid_lpc_burst_on_recovery; - Word16 tmpF_fx; - Word16 uc_two_stage_flag; - Word16 tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag; - Word16 *old_exc_s_fx; /* Start of last excitation frame */ - Word16 *p_tdm_Pri_pitch_buf_fx; - Word16 tmp, exp, local_element_mode; - ivas_error error; - Word32 bpf_error_signal_fx[L_FRAME16k]; - Word16 bpf_error_signal_16fx[L_FRAME16k]; - Word16 Q_real; - Word32 max_real, max_imag, max_val; - - set32_fx( bpf_error_signal_fx, 0, L_FRAME16k ); - set16_fx( bpf_error_signal_16fx, 0, L_FRAME16k ); - set16_fx( Aq_fx, 0, NB_SUBFR16k * ( M + 1 ) ); - set16_fx( old_bwe_exc_fx, 0, ( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 ) ); - - error = IVAS_ERR_OK; - move32(); - - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( nchan_out, 1 ) && EQ_16( st->idchan, 1 ) && LE_32( last_element_brate, IVAS_SID_5k2 ) ) - { - /* In MDCT-Stereo DTX with mono output, we can skip CNG for the second channel, except for the first inactive frame following an active period */ - return error; - } - - push_wmops( "acelp_core_dec" ); - - /* output_frame = (int16_t) ( st->output_Fs / FRAMES_PER_SEC ); */ - output_frame = extract_l( Mpy_32_32( st->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - - /*----------------------------------------------------------------* - * stereo SID and CNG frames processing - *----------------------------------------------------------------*/ - - test(); - test(); - IF( LE_32( st->core_brate, SID_2k40 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) && EQ_16( nchan_out, 2 ) ) - { - IF( EQ_16( st->cng_type, FD_CNG ) ) - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - Word16 old_NoiseEstExp; - old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; - move16(); - - /* Only run parameter decoding in SID frames */ - IF( EQ_32( st->core_brate, SID_2k40 ) ) - { - FdCng_decodeSID_ivas_fx( st ); - - Word16 n1, n2; - n1 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART ); - n2 = L_norm_arr( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART ); - - Word16 common_e = s_max( sub( old_NoiseEstExp, n2 ), sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, n1 ) ); - scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, common_e ) ); - scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, common_e ) ); - st->hFdCngDec->hFdCngCom->sidNoiseEstExp = common_e; - move16(); - } - - FOR( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), - STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); - move32(); - } - - ApplyFdCng_fx( NULL, 0, NULL, 0, NULL, NULL, NULL, st, 0, 0 ); - } - ELSE - { - configureFdCngDec_fx( st->hFdCngDec, st->bwidth, ACELP_14k25, st->L_frame, st->last_L_frame, st->element_mode ); - - /* decode CNG parameters */ - CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); - - /* comfort noise generation */ - CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, NULL, NULL, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), NULL, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, NULL, st->Opt_AMR_WB, st->element_mode ); - - Copy( Aq_fx, st->Aq_cng, M + 1 ); /*Q12*/ - - /* update old LSP and LSF vector */ - Copy( lsf_new_fx, st->lsf_old_fx, M ); /*Qlog2(2.56)*/ - Copy( lsp_new_fx, st->lsp_old_fx, M ); /*Q15*/ - } - - set16_fx( output_fx, 0, output_frame ); /* output and synth are not used in DFT domain CNG generation and the decoder output is unaffected if they are left uninitalized */ - set16_fx( synth_fx16, 0, output_frame ); /* They are however read in a few places which causes errors in the valgrind tests. Simplest solution from a code perspective was to set them to zero. */ - - /* CN generation done in DFT domain */ - pop_wmops(); - - return error; - } - - /*----------------------------------------------------------------* - * Active frames processing - *----------------------------------------------------------------*/ - - /* open CLDFB buffer up to CLDFB_NO_CHANNELS_MAX bands for 48kHz */ - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - set32_fx( realBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( imagBufferTmp_fx[i], 0, CLDFB_NO_CHANNELS_MAX ); - realBuffer_fx[i] = realBufferTmp_fx[i]; - imagBuffer_fx[i] = imagBufferTmp_fx[i]; - } - - /*----------------------------------------------------------------* - * Initialization - *----------------------------------------------------------------*/ - - LSF_Q_prediction = -1; - move16(); - set16_fx( syn_tmp_fx, 0, L_SUBFR ); - psyn_fx = syn_tmp_fx + L_SUBFR; - syn1_tmp_fx[0] = 0; - move16(); - syn1_tmp_fx[1] = 0; - move16(); - syn1_fx = syn1_tmp_fx + 2; - st->bpf_off = 0; - move16(); - - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->last_core, HQ_CORE ) || EQ_16( st->last_core, TCX_20_CORE ) || EQ_16( st->last_core, TCX_10_CORE ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && LE_32( st->last_core_brate, SID_2k40 ) ) || ( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && LE_32( st->last_core_brate, SID_2k40 ) ) ) - { - /* in case of HQ->ACELP switching, do not apply BPF */ - st->bpf_off = 1; - move16(); - if ( st->hPFstat != NULL ) - { - /* in case of core switching, reset post-filter memories */ - st->hPFstat->on = 0; - move16(); - } - - if ( st->hGSCDec != NULL ) - { - /* reset the GSC pre echo energy threshold in case of switching */ - st->hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - } - } - - test(); - if ( st->hGSCDec != NULL && ( st->prev_bfi > 0 ) ) - { - /* reset the GSC pre echo energy threshold in case of FEC */ - st->hGSCDec->Last_frame_ener_fx = MAX_32; - move32(); - } - - test(); - test(); - test(); - test(); - IF( st->hFdCngDec != NULL && ( EQ_16( st->element_mode, IVAS_CPE_DFT ) || EQ_16( st->element_mode, IVAS_CPE_TD ) ) && ( EQ_32( st->last_core_brate, SID_2k40 ) || st->last_core_brate == FRAME_NO_DATA ) ) - { - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, FFTLEN ); - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, FFTLEN ); - } - - st->clas_dec = st->last_good; - move16(); - enr_q_fx = 0; - move32(); - Es_pred_fx = 0; - move16(); - tmp_noise_fx = 0; - move16(); - Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/ - exc_fx = old_exc_fx + L_EXC_MEM_DEC; - - IF( st->hWIDec != NULL ) - { - Copy( st->hWIDec->old_exc2_fx, old_exc2_fx, L_EXC_MEM ); - } - ELSE - { - set16_fx( old_exc2_fx, 0, L_EXC_MEM ); - } - exc2_fx = old_exc2_fx + L_EXC_MEM; - - IF( st->hBWE_TD != NULL ) - { - Copy( st->hBWE_TD->old_bwe_exc_fx, old_bwe_exc_fx, PIT16k_MAX * 2 ); /*Q_exc*/ - bwe_exc_fx = old_bwe_exc_fx + PIT16k_MAX * 2; - } - ELSE - { - bwe_exc_fx = NULL; - } - - last_pulse_pos = 0; - move16(); - do_WI = 0; - move16(); - st->GSC_noisy_speech = 0; - move16(); - st->relax_prev_lsf_interp = 0; - move16(); - set16_fx( gain_buf_fx, 0, NB_SUBFR16k ); - - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - st->gamma = GAMMA1; - move16(); - st->inv_gamma = GAMMA1_INV; - move16(); - st->preemph_fac = PREEMPH_FAC; - move16(); - int_fs = INT_FS_12k8; - move16(); - } - ELSE - { - st->gamma = GAMMA16k; - move16(); - st->inv_gamma = GAMMA16k_INV; - move16(); - st->preemph_fac = PREEMPH_FAC_16k; - move16(); - int_fs = INT_FS_16k; - move16(); - } - - test(); - /* reset post-filter in case of switching */ - if ( st->hPFstat != NULL && ( st->hPFstat->on == 0 ) ) - { - st->hPFstat->reset = 1; - move16(); - } - - avoid_lpc_burst_on_recovery = 0; - move16(); - test(); - test(); - if ( st->last_con_tcx && NE_16( st->L_frameTCX_past, st->L_frame ) && ( st->last_core != 0 ) ) - { - avoid_lpc_burst_on_recovery = 1; - move16(); - } - test(); - - /* TD stereo parameters */ - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) - { - tdm_lp_reuse_flag = hStereoTD->tdm_lp_reuse_flag; - move16(); - tdm_low_rate_mode = hStereoTD->tdm_low_rate_mode; - move16(); - tdm_Pitch_reuse_flag = hStereoTD->tdm_Pitch_reuse_flag; - move16(); - p_tdm_Pri_pitch_buf_fx = hStereoTD->tdm_Pri_pitch_buf_fx; - } - ELSE - { - tdm_lp_reuse_flag = 0; - move16(); - tdm_low_rate_mode = 0; - move16(); - test(); - if ( EQ_16( st->element_mode, IVAS_SCE ) && st->low_rate_mode ) - { - tdm_low_rate_mode = 1; - move16(); - } - tdm_Pitch_reuse_flag = 0; - move16(); - p_tdm_Pri_pitch_buf_fx = NULL; - } - - /*----------------------------------------------------------------* - * Updates in case of internal sampling rate switching - *----------------------------------------------------------------*/ - - test(); - test(); - IF( NE_16( st->last_L_frame, st->L_frame ) && ( st->last_core == ACELP_CORE || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - Word16 dec; - - IF( ( st->hPFstat->on != 0 ) ) - { - Word16 mem_syn_r_size_old, mem_syn_r_size_new; - mem_syn_r_size_old = mult_r( 2048, st->last_L_frame ); /* 1.25/20.f = 2048 (Q15)*/ - mem_syn_r_size_new = mult_r( 2048, st->L_frame ); /* 1.25/20.f = 2048 (Q15)*/ - lerp( st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_stp + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); - lerp( st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_old ), st->hPFstat->mem_pf_in + sub( L_SYN_MEM, mem_syn_r_size_new ), mem_syn_r_size_new, mem_syn_r_size_old ); - } - - /* convert quantized LSP vector */ - st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); - move16(); - - /* convert old quantized LSF vector */ - lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, int_fs ); - - /* FEC - update adaptive LSF mean vector */ - Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); /*Qlog2(2.56)*/ - Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); /*Qlog2(2.56)*/ - Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); /*Qlog2(2.56)*/ - - /* Reset LPC mem */ - IF( EQ_32( st->sr_core, INT_FS_16k ) ) - { - Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/ - } - ELSE - { - Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); /*Qlog2(2.56)*/ - } - set16_fx( st->mem_MA_fx, 0, M ); - - /* update synthesis filter memories */ - dec = DEC; - move16(); - if ( st->element_mode != EVS_MONO ) - { - dec = DEC_IVAS; - move16(); - } - ivas_synth_mem_updt2_fx( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, dec ); - Copy( st->old_exc_fx, old_exc_fx, L_EXC_MEM_DEC ); /*Q_exc*/ - Copy_Scale_sig( st->mem_syn2_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); /*Q-1*/ - Copy( st->mem_syn2_fx, st->mem_syn3_fx, M ); /*Q_syn*/ - } - - /* update buffer of old subframe pitch values */ - IF( NE_16( st->last_L_frame, st->L_frame ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) - { - tmpF_fx = 13107; // Q15 - move16(); - } - ELSE IF( EQ_16( st->last_L_frame, 512 ) ) - { - tmpF_fx = 16384; // Q15 - move16(); - } - ELSE /* st->last_L_frame == L_FRAME16k */ - { - tmpF_fx = 26214; // Q15 - move16(); - } - - FOR( i = NB_SUBFR16k - NB_SUBFR; i < NB_SUBFR16k; i++ ) - { - st->old_pitch_buf_fx[i - 1] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16 - move32(); - } - - FOR( i = 2 * NB_SUBFR16k - NB_SUBFR; i < 2 * NB_SUBFR16k; i++ ) - { - st->old_pitch_buf_fx[i - 2] = Mpy_32_16_1( st->old_pitch_buf_fx[i], tmpF_fx ); // Q16 - move32(); - } - } - ELSE - { - exp = 0; - move16(); - IF( EQ_16( st->last_L_frame, L_FRAME32k ) ) - { - tmpF_fx = 16384; // Q15 - move16(); - } - ELSE IF( EQ_16( st->last_L_frame, 512 ) ) - { - tmpF_fx = 20480; // Q15 - move16(); - } - ELSE /* st->last_L_frame == L_FRAME12k8 */ - { - tmpF_fx = 20480; // Q14 - move16(); - exp = 1; - move16(); - } - FOR( i = 2 * NB_SUBFR - 1; i >= NB_SUBFR; i-- ) - { - st->old_pitch_buf_fx[i + 2] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15 - move32(); - } - st->old_pitch_buf_fx[NB_SUBFR + 1] = st->old_pitch_buf_fx[NB_SUBFR + 2]; - move32(); - - FOR( i = NB_SUBFR - 1; i >= 0; i-- ) - { - st->old_pitch_buf_fx[i + 1] = Mpy_32_16_1( L_shl( st->old_pitch_buf_fx[i], exp ), tmpF_fx ); // Q15 - move32(); - } - st->old_pitch_buf_fx[0] = st->old_pitch_buf_fx[1]; - move32(); - } - } - - IF( NE_16( st->bfi_pitch_frame, st->L_frame ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) ) - { - tmpF_fx = 13107; // Q15 - move16(); - } - ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) ) - { - tmpF_fx = 16384; // Q15 - move16(); - } - ELSE /* st->bfi_pitch_frame == L_FRAME16k */ - { - tmpF_fx = 26214; // Q15 - move16(); - } - st->bfi_pitch_fx = mult_r( st->bfi_pitch_fx, tmpF_fx ); - move16(); - st->bfi_pitch_frame = L_FRAME; - move16(); - } - ELSE - { - exp = 0; - move16(); - IF( EQ_16( st->bfi_pitch_frame, L_FRAME32k ) ) - { - tmpF_fx = 16384; // Q15 - move16(); - } - ELSE IF( EQ_16( st->bfi_pitch_frame, 512 ) ) - { - tmpF_fx = 20480; // Q15 - move16(); - } - ELSE /* st->bfi_pitch_frame == L_FRAME12k8 */ - { - tmpF_fx = 20480; // Q14 - move16(); - exp = 1; - move16(); - } - - st->bfi_pitch_fx = mult_r( shl_sat( st->bfi_pitch_fx, exp ), tmpF_fx ); - move16(); - st->bfi_pitch_frame = L_FRAME16k; - move16(); - } - } - - test(); - test(); - if ( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && ( st->ini_frame != 0 ) ) - { - st->rate_switching_reset = 1; - move16(); - } - - /*----------------------------------------------------------------------* - * GOOD frame - *----------------------------------------------------------------------*/ - - IF( !st->bfi ) - { - - /*----------------------------------------------------------------* - * Decoding of TC subframe classification - *----------------------------------------------------------------*/ - - tc_subfr = -1; - move16(); - IF( EQ_16( st->coder_type, TRANSITION ) ) - { - tc_subfr = tc_classif_fx( st, st->L_frame ); - } - - /*----------------------------------------------------------------* - * Decoding of GSC IVAS mode - *----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( st->element_mode > EVS_MONO && st->idchan == 0 && !( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && !tdm_low_rate_mode ) - { - test(); - test(); - IF( EQ_16( st->coder_type, AUDIO ) || ( EQ_16( st->coder_type, INACTIVE ) && EQ_16( st->inactive_coder_type_flag, 1 ) ) ) - { - st->GSC_IVAS_mode = get_next_indice_fx( st, 2 ); - move16(); - } - } - - /*----------------------------------------------------------------* - * Decoding of inactive CNG frames - *----------------------------------------------------------------*/ - - test(); - IF( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) - { - /* decode CNG parameters */ - IF( st->cng_type == LP_CNG ) - { - CNG_dec_fx( st, last_element_mode, Aq_fx, lsp_new_fx, lsf_new_fx, &allow_cn_step, sid_bw, q_env_fx ); - Copy( Aq_fx, st->Aq_cng, add( M, 1 ) ); - - /* comfort noise generation */ - local_element_mode = st->element_mode; - move16(); - - test(); - test(); - if ( ( EQ_16( nchan_out, 1 ) && EQ_16( st->element_mode, IVAS_CPE_DFT ) ) || EQ_16( st->masa_sid_format, 1 ) ) - { - local_element_mode = IVAS_SCE; /* For DFT Stereo mono decoding, run CNG_exc as in SCE */ - move16(); - } - CNG_exc_fx( st->core_brate, st->L_frame, &st->hTdCngDec->Enew_fx, &st->hTdCngDec->cng_seed, exc_fx, exc2_fx, &st->lp_ener_fx, st->last_core_brate, &st->first_CNG, &( st->hTdCngDec->cng_ener_seed ), bwe_exc_fx, allow_cn_step, &st->hTdCngDec->last_allow_cn_step, st->prev_Q_exc, st->Q_exc, st->hTdCngDec->num_ho, q_env_fx, st->hTdCngDec->lp_env_fx, st->hTdCngDec->old_env_fx, st->hTdCngDec->exc_mem_fx, st->hTdCngDec->exc_mem1_fx, sid_bw, &st->hTdCngDec->cng_ener_seed1, exc3_fx, st->Opt_AMR_WB, local_element_mode ); - } - ELSE - { - test(); - IF( EQ_32( st->core_brate, SID_2k40 ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - FdCng_decodeSID_fx( st->hFdCngDec->hFdCngCom, st ); - } - ELSE - { - Word16 old_NoiseEstExp = st->hFdCngDec->hFdCngCom->sidNoiseEstExp; - move16(); - - FdCng_decodeSID_ivas_fx( st ); - - Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( old_NoiseEstExp, st->hFdCngDec->hFdCngCom->sidNoiseEstExp ) ); - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( st->hFdCngDec->hFdCngCom->A_cng[0] ), Q2 ) ); // Qx - } - - *sid_bw = 0; - move16(); - } - - IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) - { - assert( nchan_out == 1 ); - - FOR( i = 0; i < NPART; i++ ) - { - st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] = Madd_32_32( Mpy_32_32( STEREO_DFT_FD_FILT_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEstLp[i] ), - STEREO_DFT_FD_FILT_COMP_Q31, st->hFdCngDec->hFdCngCom->sidNoiseEst[i] ); - move32(); - } - - ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - - Word16 new_sidNoiseEstExp = 31 - Q4; - move16(); - Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEstLp, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp) - Scale_sig32( st->hFdCngDec->hFdCngCom->sidNoiseEst, NPART, sub( st->hFdCngDec->hFdCngCom->sidNoiseEstExp, new_sidNoiseEstExp ) ); // Q(31-sidNoiseEstExp) - st->hFdCngDec->hFdCngCom->sidNoiseEstExp = new_sidNoiseEstExp; - move16(); - Word16 new_cngNoiseLevelExp = 31 - Q4; - move16(); - Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, sub( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, new_cngNoiseLevelExp ) ); // Q(31-cngNoiseLevelExp) - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = new_cngNoiseLevelExp; - move16(); - - test(); - ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) ); - - IF( st->hFdCngDec->hFdCngCom->cngNoiseLevelExp < 0 ) - { - Scale_sig32( st->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, st->hFdCngDec->hFdCngCom->cngNoiseLevelExp ); // Q(31-cngNoiseLevelExp) - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = 0; - move16(); - } - } - - IF( !read_sid_info ) - { - Word32 noise_lvl_highest_fx; - - noise_lvl_highest_fx = st->hFdCngDec->hFdCngCom->cngNoiseLevel[( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ) - 1]; - move32(); - - FOR( Word16 b = ( st->hFdCngDec->hFdCngCom->stopFFTbin - st->hFdCngDec->hFdCngCom->startBand ); b < st->hFdCngDec->hFdCngCom->stopBand; b++ ) - { - st->hFdCngDec->hFdCngCom->cngNoiseLevel[b] = noise_lvl_highest_fx; - move32(); - } - } - - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - generate_comfort_noise_dec_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 2, -1 ); - } - ELSE - { - generate_comfort_noise_dec_ivas_fx( NULL, NULL, NULL, st, &( st->Q_exc ), 1, nchan_out ); - } - - FdCng_exc( st->hFdCngDec->hFdCngCom, &st->CNG_mode, st->L_frame, st->lsp_old_fx, st->first_CNG, st->lspCNG_fx, Aq_fx, lsp_new_fx, lsf_new_fx, exc_fx, exc2_fx, bwe_exc_fx ); - - Copy( exc2_fx, exc3_fx, st->L_frame ); - } - - Word16 delta_mem_scale = 3; - move16(); - test(); - if ( LT_32( st->lp_ener_fx, 40 ) && st->cng_type == LP_CNG ) /* very low energy frames, less than 0.3125 */ - { - delta_mem_scale = 0; - move16(); - } - i = st->Q_exc; - move16(); - - test(); - IF( st->hMusicPF && st->hGSCDec ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - // VE: TBV: should 'st_fx->L_frame * HIBND_ACB_L_FAC' be corrected in EVS? - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, - st->L_frame * HIBND_ACB_L_FAC, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); - } - ELSE - { - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, - L_FRAME32k, 0, &( st->Q_exc ), st->Q_subfr, NULL, 0, INACTIVE ); - } - } - - IF( st->hPFstat != NULL ) - { - Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, - &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 0, 0, NULL ); - } - ELSE - { - Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, delta_mem_scale, - &st->mem_deemph_fx, NULL, NULL, &st->agc_mem_fx[1], NULL, 0, 0, NULL ); - } - - Copy_Scale_sig( exc2_fx, exc2_fx, st->L_frame, sub( st->Q_exc, i ) ); // Q_exc - - /* update past excitation signals for LD music post-filter */ - IF( st->hMusicPF != NULL ) - { - Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - - /* Update music post processing values */ - /* Filter energies update */ - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - FOR( i = 0; i < DCT_L_POST; i++ ) - { - st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); - move16(); - } - } - ELSE - { - FOR( i = 0; i < DCT_L_POST; i++ ) - { - st->hMusicPF->filt_lfE_fx[i] = add( 9830, mult_r( 22937, st->hMusicPF->filt_lfE_fx[i] ) ); // Q15, 9830 =.3f in Q15, 22937=.7f in Q15 - move16(); - } - } - } - - /* synthesis at 12.8kHz sampling rate */ - move16(); - syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - syn_12k8_fx( st->L_frame, Aq_fx, exc3_fx, syn1_fx, st->mem_syn3_fx, 1, st->Q_exc, st->Q_syn ); - - /* reset the decoder */ - CNG_reset_dec_fx( st, pitch_buf_fx, voice_factors_fx ); - - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - /* update st_fx->mem_syn1 for ACELP core switching */ - Copy( st->mem_syn3_fx, st->mem_syn1_fx, M ); - } - ELSE - { - st->Q_syn_cng = st->Q_syn; - move16(); - st->Q_exc_cng = st->Q_exc; - move16(); - - /* update st->mem_syn1 for ACELP core switching */ - Copy_Scale_sig( st->mem_syn3_fx, st->mem_syn1_fx, M, sub( -1, st->Q_syn ) ); // Q(-1) - } - - /* update old synthesis for classification */ - Copy( syn1_fx + st->L_frame - L_SYN_MEM_CLAS_ESTIM, st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); - - /* save and delay synthesis to be used by SWB BWE */ - Copy_Scale_sig( syn1_fx, temp_buf_fx, st->L_frame, sub( -1, st->Q_syn ) ); // Q_syn -> Q(-1) - IF( st->hBWE_FD != NULL ) - { - save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } - } - - /*----------------------------------------------------------------* - * Decoding of all other frames - *----------------------------------------------------------------*/ - - ELSE - { - - /*-----------------------------------------------------------------* - * Configure ACELP bit allocation - *-----------------------------------------------------------------*/ - - nb_bits = 0; - move16(); - st->acelp_cfg.FEC_mode = 0; - move16(); - uc_two_stage_flag = 0; - move16(); - - test(); - IF( !st->nelp_mode_dec && !st->ppp_mode_dec ) - { - Word16 tc_subfr_tmp; - - tc_subfr_tmp = tc_subfr; - move16(); - if ( LT_16( tc_subfr_tmp, L_SUBFR ) ) - { - tc_subfr_tmp = 0; - move16(); - } - - if ( EQ_16( tc_subfr, TC_0_192 ) ) - { - nb_bits = -1; - move16(); - } - - config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, st->GSC_noisy_speech, &( st->acelp_cfg ), st->next_bit_pos, st->coder_type, st->inactive_coder_type_flag, tc_subfr_tmp, 1, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); - - test(); - test(); - IF( EQ_16( st->coder_type, TRANSITION ) && LT_16( tc_subfr, L_SUBFR ) && EQ_16( st->L_frame, L_FRAME ) ) - { - config_acelp1_fx( DEC, st->total_brate, st->core_brate, st->core, st->extl_orig, st->extl_brate_orig, st->L_frame, -1, &( st->acelp_cfg ), st->next_bit_pos, TRANSITION, -1, tc_subfr, 2, &nb_bits, unbits, st->element_mode, &uc_two_stage_flag, tdm_lp_reuse_flag, tdm_low_rate_mode, st->idchan, st->active_cnt, tdm_Pitch_reuse_flag, st->tdm_LRTD_flag, st->GSC_IVAS_mode ); - } - } - - /*-----------------------------------------------------------------* - * After CNG period, use the most up-to-date LSPs - *-----------------------------------------------------------------*/ - - test(); - test(); - IF( st->hTdCngDec != NULL && ( st->last_core_brate == FRAME_NO_DATA || EQ_32( st->last_core_brate, SID_2k40 ) ) ) - { - Copy( st->lspCNG_fx, st->lsp_old_fx, M ); /*Q15*/ - lsp2lsf_fx( st->lspCNG_fx, st->lsf_old_fx, M, int_fs ); - } - - /*-----------------------------------------------------------------* - * Reset higher ACELP pre-quantizer in case of switching - *-----------------------------------------------------------------*/ - - IF( !st->use_acelp_preq ) - { - st->mem_preemp_preQ_fx = 0; - move16(); - st->last_nq_preQ = 0; - move16(); - st->last_code_preq = 0; - move16(); - } - - st->use_acelp_preq = 0; - move16(); - - /*-----------------------------------------------------------------* - * LSF de-quantization and interpolation - *-----------------------------------------------------------------*/ - - IF( !tdm_lp_reuse_flag ) - { - lsf_dec_fx( st, tc_subfr, Aq_fx, &LSF_Q_prediction, lsf_new_fx, lsp_new_fx, lsp_mid_fx, tdm_low_rate_mode, tdm_lsfQ_PCh_fx ); - } - ELSE - { - const Word16 *pt_interp_2_fx; - - IF( NE_16( st->active_cnt, 1 ) ) - { - Word16 beta_index; - - beta_index = get_next_indice_fx( st, TDM_IC_LSF_PRED_BITS ); - tdm_SCh_lsf_reuse_fx( DEC, st->element_brate, lsf_new_fx, lsp_new_fx, tdm_lsfQ_PCh_fx, NULL, &beta_index ); - } - ELSE - { - Copy( tdm_lspQ_PCh_fx, lsp_new_fx, M ); - Copy( tdm_lsfQ_PCh_fx, lsf_new_fx, M ); - } - - IF( st->rate_switching_reset ) - { - /* extrapolation in case of unstable LSF convert */ - Copy( lsp_new_fx, st->lsp_old_fx, M ); - Copy( lsf_new_fx, st->lsf_old_fx, M ); - } - - pt_interp_2_fx = interpol_frac_fx; - test(); - if ( EQ_16( tdm_low_rate_mode, 1 ) && GT_16( st->coder_type, UNVOICED ) ) - { - pt_interp_2_fx = interpol_frac2_fx; - } - - IF( EQ_16( st->active_cnt, 1 ) ) - { - Copy( lsp_new_fx, st->lsp_old_fx, M ); - lsp2lsf_fx( lsp_new_fx, st->lsf_old_fx, M, st->sr_core ); - } - - /* LSP interpolation and conversion of LSPs to A(z) */ - int_lsp_fx( st->L_frame, st->lsp_old_fx, lsp_new_fx, Aq_fx, M, pt_interp_2_fx, 0 ); - - /* Check LSF stability (distance between old LSFs and current LSFs) */ - st->stab_fac_fx = lsf_stab_ivas_fx( lsf_new_fx, st->lsf_old_fx, 0, st->L_frame ); - move16(); - } - - test(); - IF( EQ_16( st->last_core, HQ_CORE ) && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory from last HQ frame */ - old_exc_s_fx = st->old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ); - tmpF_fx = *old_exc_s_fx; - st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ - move16(); - PREEMPH_FX( old_exc_s_fx, st->preemph_fac, L_FRAME16k, &tmpF_fx ); - Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); - Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ - Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); - Scale_sig( old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, st->Q_exc ); /* Q0 -> Q_exc */ - } - - test(); - IF( st->last_core != ACELP_CORE && st->element_mode > EVS_MONO ) - { - /* Prepare ACB memory of old_bwe_exc */ - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC * HIBND_ACB_L_FAC, L_EXC_MEM_DEC ); - } - ELSE - { - lerp( old_exc_fx, old_bwe_exc_fx, L_EXC_MEM_DEC << 1, L_EXC_MEM_DEC ); - } - } - - /*-----------------------------------------------------------------* - * FEC - first good frame after lost frame(s) (possibility to correct the ACB) - *-----------------------------------------------------------------*/ - - IF( st->acelp_cfg.FEC_mode > 0 ) - { - last_pulse_pos = 0; - move16(); - - /* decode the last glottal pulse position */ - T0_tmp = FEC_pos_dec_fx( st, &last_pulse_pos, &enr_q_fx, nb_bits ); - - test(); - test(); - IF( NE_16( st->last_core, HQ_CORE ) || ( EQ_16( st->last_core, HQ_CORE ) && st->last_con_tcx ) ) - { - test(); - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->clas_dec, SIN_ONSET ) && last_pulse_pos != 0 && EQ_16( st->prev_bfi, 1 ) ) - { - FEC_SinOnset_fx( old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, last_pulse_pos, T0_tmp, enr_q_fx, Aq_fx, st->L_frame, st->Q_exc ); - } - ELSE IF( ( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) ) && last_pulse_pos != 0 && EQ_16( st->old_bfi_cnt, 1 ) && st->hWIDec != NULL ) - { - do_WI = FEC_enhACB_fx( st->L_frame, st->last_L_frame, old_exc_fx + L_EXC_MEM_DEC - L_EXC_MEM, T0_tmp, last_pulse_pos, st->bfi_pitch_fx ); - } - } - } - - /*------------------------------------------------------------* - * In case of first frame after an erasure and transition from voiced to unvoiced or inactive - * redo the LPC interpolation - *------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->stab_fac_fx == 0 ) && ( st->old_bfi_cnt > 0 ) && NE_16( st->clas_dec, VOICED_CLAS ) && NE_16( st->clas_dec, ONSET ) && ( st->relax_prev_lsf_interp == 0 ) && !( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( st->idchan, 1 ) ) ) - { - int_lsp4_ivas_fx( st->L_frame, st->lsp_old_fx, lsp_mid_fx, lsp_new_fx, Aq_fx, M, 2 ); - } - - /*---------------------------------------------------------------* - * Decoding of the scaled predicted innovation energy - *---------------------------------------------------------------*/ - - IF( nb_bits > 0 ) - { - indice = get_next_indice_fx( st, nb_bits ); - Es_pred_dec_fx( &Es_pred_fx, indice, nb_bits, uc_two_stage_flag ); - } - - /*------------------------------------------------------------* - * Decode excitation according to coding type - *------------------------------------------------------------*/ - - test(); - test(); - IF( tdm_low_rate_mode ) /* tdm stereo low rate mode */ - { - IF( LE_16( st->coder_type, UNVOICED ) ) - { - tdm_low_rate_dec_fx( st, dct_exc_tmp_fx /*, &tmp_noise*/, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx ); - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - } - ELSE /* GENERIC */ - { - decod_gen_2sbfr_fx( st, sharpFlag, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); - - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - } - } - } - ELSE IF( st->nelp_mode_dec ) - { - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 - st->Q_exc = 0; - move16(); - - /* SC-VBR - NELP frames */ - decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); - - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); - } - ELSE IF( EQ_16( st->coder_type, UNVOICED ) ) - { - /* UNVOICED frames */ - decod_unvoiced_fx( st, Aq_fx, Es_pred_fx, uc_two_stage_flag, st->coder_type, &tmp_noise_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, gain_buf_fx ); - - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - } - ELSE IF( st->ppp_mode_dec ) - { - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 - st->Q_exc = 0; - move16(); - - /* SC-VBR - PPP frames */ - IF( NE_32( ( error = decod_ppp_fx( st, Aq_fx, pitch_buf_fx, exc_fx, exc2_fx, st->bfi, gain_buf_fx, voice_factors_fx, bwe_exc_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); - } - ELSE IF( EQ_16( st->coder_type, TRANSITION ) ) - { - decod_tran_fx( st, st->L_frame, tc_subfr, Aq_fx, Es_pred_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, sharpFlag, gain_buf_fx ); - } - ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( ( st->coder_type == INACTIVE ) && st->inactive_coder_type_flag ) ) - { - /* AUDIO and INACTIVE frames (coded by GSC technology) */ - decod_audio_fx( st, dct_exc_tmp_fx, Aq_fx, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, lsf_new_fx, gain_buf_fx, - tdm_lp_reuse_flag, tdm_low_rate_mode, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ); - - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - } - ELSE - { - /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */ - IF( NE_32( ( error = decod_gen_voic_fx( st, st->L_frame, sharpFlag, Aq_fx, Es_pred_fx, do_WI, pitch_buf_fx, voice_factors_fx, exc_fx, exc2_fx, bwe_exc_fx, unbits, gain_buf_fx, tdm_Pitch_reuse_flag, p_tdm_Pri_pitch_buf_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } - - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - } - } - - /* synthesis for ACELP core switching and SWB BWE */ - syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); - - /* save and delay synthesis to be used by SWB BWE */ - IF( st->hBWE_FD != NULL ) - { - save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } - - /*-----------------------------------------------------------------* - * Apply energy matching when switching to inactive frames - *-----------------------------------------------------------------*/ - - Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); - - /*------------------------------------------------------------* - * Decode information and modify the excitation signal of stationary unvoiced frames - *------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( !( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) && NE_16( st->nelp_mode_dec, 1 ) && !( EQ_16( st->element_mode, IVAS_SCE ) && tdm_low_rate_mode ) ) - { - stat_noise_uv_dec_fx( st, lsp_new_fx, lsp_mid_fx, Aq_fx, exc2_fx, uc_two_stage_flag ); - } - - /*------------------------------------------------------------* - * Save filter memory in case the synthesis is redone after scaling - * Synthesis at 12k8 Hz sampling rate - *------------------------------------------------------------*/ - - /* update past excitation signals for LD music post-filter */ - IF( st->hMusicPF != NULL ) - { - Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - Copy( st->hMusicPF->dct_post_old_exc_fx, exc_buffer_fx, DCT_L_POST - OFFSET2 ); - } - - test(); - test(); - test(); - IF( ( EQ_16( st->coder_type, AUDIO ) && !st->GSC_noisy_speech ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && EQ_16( st->L_frame, L_FRAME ) ) ) - { - Word16 last_coder_type = st->last_coder_type; - move16(); - - test(); - test(); - test(); - if ( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) ) || ( GE_16( st->GSC_IVAS_mode, 1 ) && ( st->GSC_noisy_speech == 0 ) ) ) - { - last_coder_type = AUDIO; - move16(); - } - - Word16 qdct = 0; - move16(); - - /* Extrapolation of the last future part, windowing and high resolution DCT transform */ - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - // VE: TBV: this is likely a bug in EVS - 'st->last_coder_type' should be replaced by 'st->core_brate' - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_coder_type, st->element_mode, pitch_buf_fx, - st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); - } - ELSE - { - Prep_music_postP_fx( exc_buffer_fx, dct_buffer_fx, st->hMusicPF->filt_lfE_fx, st->last_core, st->element_mode, pitch_buf_fx, st->hMusicPF->LDm_enh_lp_gbin_fx, st->Q_exc, &qdct ); - } - - /* LD music post-filter */ - LD_music_post_filter_fx( st->hMusicPF, dct_buffer_fx, dct_buffer_fx, st->core_brate, &st->hMusicPF->Old_ener_Q, AUDIO, last_coder_type, qdct ); - - /* Inverse DCT transform, retrieval of the aligned excitation, re-synthesis */ - IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBC whether needed in IVAS - { - Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ - } - - Post_music_postP_fx( dct_buffer_fx, exc2_fx, st->mem_syn2_fx, st->mem_syn2_fx, Aq_fx, psyn_fx, &st->Q_exc, &st->prev_Q_syn, - &st->Q_syn, st->mem_syn_clas_estim_fx, 0, &st->mem_deemph_fx, st->hBPF->pst_old_syn_fx, - &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, temp_buf_fx, mem_tmp_fx ); - } - ELSE - { - /* Core synthesis at 12.8kHz or 16kHz */ - i = 1; - move16(); - test(); - if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO ) - { - i = 0; - move16(); - } - - /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */ - Word16 k = 0; - move16(); - test(); - test(); - if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) - { - k = 1; - move16(); - } - - Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, - st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, i, k, temp_buf_fx ); - - Copy( st->mem_syn2_fx, mem_tmp_fx, M ); /*Q_syn*/ - syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - - IF( st->hMusicPF != NULL ) - { - FOR( i = 0; i < DCT_L_POST; i++ ) - { - st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( ( 1228 << ( 16 ) ), 22938, st->hMusicPF->filt_lfE_fx[i] ) ); - move16(); - } - } - } - - /*------------------------------------------------------------* - * FEC - Estimate the classification information - *------------------------------------------------------------*/ - - FEC_clas_estim_fx( st, st->Opt_AMR_WB, st->L_frame, &st->clas_dec, st->coder_type, pitch_buf_fx, psyn_fx, &st->lp_ener_FER_fx, &st->decision_hyst, - NULL, NULL, NULL, NULL, 0, NULL, st->Q_syn, temp_buf_fx, st->mem_syn_clas_estim_fx, &st->classifier_Q_mem_syn, 0, 0, 0, st->last_core_brate, st->acelp_cfg.FEC_mode ); - - /*------------------------------------------------------------* - * FEC - Estimate pitch - *------------------------------------------------------------*/ - - FEC_pitch_estim_fx( st->Opt_AMR_WB, st->last_core, st->L_frame, st->clas_dec, st->last_good, pitch_buf_fx, st->old_pitch_buf_fx, - &st->bfi_pitch_fx, &st->bfi_pitch_frame, &st->upd_cnt, st->coder_type, st->element_mode ); - - /*------------------------------------------------------------* - * FEC - Smooth the speech energy evolution when recovering after a BAD frame - * (smoothing is performed in the excitation domain and signal is resynthesized after) - *------------------------------------------------------------*/ - - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - - FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, - &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); - - test(); - test(); - test(); - test(); - /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - IF( ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && LE_32( st->total_brate, ACELP_7k20 ) ) || EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) - { - frame_ener_fx( st->L_frame, st->clas_dec, psyn_fx, pitch_buf_tmp[( ( st->L_frame ) >> 6 ) - 1], &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); - } - } - - } /* End of GOOD FRAME */ - - /*----------------------------------------------------------------* - * BAD frame - *----------------------------------------------------------------*/ - - ELSE - { - /* SC-VBR */ - if ( EQ_16( st->last_nelp_mode_dec, 1 ) ) - { - st->nelp_mode_dec = 1; - move16(); - } - - test(); - test(); - /* long burst frame erasures */ - if ( GT_16( st->nbLostCmpt, 5 ) && GE_16( st->clas_dec, VOICED_CLAS ) && LT_16( st->clas_dec, INACTIVE_CLAS ) ) - { - st->last_good = VOICED_TRANSITION; - move16(); - } - - /* LSF estimation and A(z) calculation */ - lsf_dec_bfi( MODE1, lsf_new_fx, st->lsf_old_fx, st->lsf_adaptive_mean_fx, NULL, st->mem_MA_fx, st->mem_AR_fx, st->stab_fac_fx, st->last_coder_type, st->L_frame, st->last_good, st->nbLostCmpt, 0, NULL, NULL, NULL, st->hGSCDec->Last_GSC_pit_band_idx, st->Opt_AMR_WB, 0, st->bwidth ); - - FEC_lsf2lsp_interp( st, st->L_frame, Aq_fx, lsf_new_fx, lsp_new_fx ); - IF( EQ_16( st->nelp_mode_dec, 1 ) ) - { - /* SC-VBR */ - Scale_sig( exc_fx - L_EXC_MEM, L_EXC_MEM, negate( st->Q_exc ) ); // Q0 - st->Q_exc = 0; - move16(); - - decod_nelp_fx( st, &tmp_noise_fx, pitch_buf_fx, exc_fx, exc2_fx, voice_factors_fx, bwe_exc_fx, &st->Q_exc, st->bfi, gain_buf_fx ); - FEC_pitch_fx = pitch_buf_fx[3]; - move16(); - Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, exc_fx, NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, 0, (Word32) 0, &( st->Q_exc ), st->Q_subfr, exc2_fx, L_FRAME, st->coder_type ); - } - ELSE - { - /* calculation of excitation signal */ - FEC_exc_estim_fx( st, st->L_frame, exc_fx, exc2_fx, dct_exc_tmp_fx, pitch_buf_fx, voice_factors_fx, &FEC_pitch_fx, bwe_exc_fx, lsf_new_fx, &st->Q_exc, &tmp_noise_fx ); - - Rescale_exc( NULL, exc_fx, bwe_exc_fx, st->hGSCDec->last_exc_dct_in_fx, st->L_frame, L_FRAME32k, (Word32) 0, - &( st->Q_exc ), st->Q_subfr, exc2_fx, st->L_frame, st->last_coder_type ); - - tmp_noise_fx = shr_r( st->lp_gainc_fx, 3 ); /*Q0*/ - - /* SC-VBR */ - st->prev_gain_pit_dec_fx = st->lp_gainp_fx; - move16(); - } - - /* synthesis for ACELP core switching and SWB BWE */ - syn_12k8_fx( st->L_frame, Aq_fx, exc_fx, temp_buf_fx, st->mem_syn1_fx, 1, st->Q_exc, -1 ); - - /* save and delay synthesis to be used by SWB BWE */ - IF( st->hBWE_FD != NULL ) - { - save_old_syn_fx( st->L_frame, temp_buf_fx, old_syn_12k8_16k_fx, st->hBWE_FD->old_syn_12k8_16k_fx, st->preemph_fac, &st->hBWE_FD->mem_deemph_old_syn_fx ); - } - - /* Apply energy matching when switching to inactive frames */ - Inac_switch_ematch_fx( exc2_fx, dct_exc_tmp_fx, st->hGSCDec->lt_ener_per_band_fx, st->coder_type, st->inactive_coder_type_flag, st->L_frame, st->Q_exc, st->bfi, st->last_core, st->last_codec_mode, tdm_low_rate_mode, st->element_mode ); - - /* update past excitation signals for LD music post-filter */ - IF( st->hMusicPF != NULL ) - { - Copy( st->hMusicPF->dct_post_old_exc_fx + L_FRAME, st->hMusicPF->dct_post_old_exc_fx, DCT_L_POST - L_FRAME - OFFSET2 ); - Copy( exc2_fx, st->hMusicPF->dct_post_old_exc_fx + ( DCT_L_POST - L_FRAME - OFFSET2 ), L_FRAME ); - - /* Update music post processing values */ - /* Filter energies update */ - FOR( i = 0; i < DCT_L_POST; i++ ) - { - st->hMusicPF->filt_lfE_fx[i] = round_fx( L_mac( 1228 << 16, 22938, st->hMusicPF->filt_lfE_fx[i] ) ); - move16(); - } - - /* Update circular buffer, keep last energy difference unchanged */ - FOR( i = 1; i < MAX_LT; i++ ) - { - st->hMusicPF->LDm_lt_diff_etot_fx[i - 1] = st->hMusicPF->LDm_lt_diff_etot_fx[i]; - move16(); - } - } - - /* synthesis at 12k8 Hz sampling rate */ - /* add extra headroom in case a CNA addition is likely (i.e. st_fx->psf_lp_noise_fx is close to the threshold) */ - Word16 k = 0; - move16(); - test(); - test(); - if ( st->coder_type == INACTIVE && st->flag_cna && GE_16( round_fx( L_shl( st->lp_noise, 1 ) ), 15 << 7 ) ) - { - k = 1; - move16(); - } - - Rescale_mem( st->Q_exc, &st->prev_Q_syn, &st->Q_syn, st->mem_syn2_fx, st->mem_syn_clas_estim_fx, 4, &st->mem_deemph_fx, - st->hBPF->pst_old_syn_fx, &st->hBPF->pst_mem_deemp_err_fx, &st->agc_mem_fx[1], st->hPFstat, 1, k, temp_buf_fx ); - - test(); - IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) - { - Copy( st->mem_syn2_fx, mem_tmp_fx, M ); - } - syn_12k8_fx( st->L_frame, Aq_fx, exc2_fx, psyn_fx, st->mem_syn2_fx, 1, st->Q_exc, st->Q_syn ); - - /* update buffer for classifier */ - IF( st->hWIDec != NULL ) - { - Copy( exc2_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_exc2_fx, L_EXC_MEM ); - Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM ); - } - st->prev_Q_exc_fr = st->Q_exc; - move16(); - st->prev_Q_syn_fr = st->Q_syn; - move16(); - Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); - - /*------------------------------------------------------------* - * FEC - Smooth the speech energy evolution when recovering after a BAD frame - * (smoothing is performed in the excitation domain and signal is resynthesized after) - *------------------------------------------------------------*/ - - test(); - IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) - { - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - - FEC_scale_syn_fx( st->L_frame, &update_flg, st->clas_dec, st->last_good, psyn_fx, pitch_buf_tmp, st->enr_old_fx, enr_q_fx, st->coder_type, LSF_Q_prediction, - &st->scaling_flag, &st->lp_ener_FEC_av, &st->lp_ener_FEC_max, st->bfi, st->total_brate, st->prev_bfi, st->last_core_brate, - exc_fx, exc2_fx, Aq_fx, &st->old_enr_LP, mem_tmp_fx, st->mem_syn2_fx, st->Q_exc, st->Q_syn, st->element_mode, avoid_lpc_burst_on_recovery, 0 ); - } - - /* estimate the pitch-synchronous speech energy per sample to be used when normal operation recovers */ - frame_ener_fx( st->L_frame, st->last_good, psyn_fx, shr( add( FEC_pitch_fx, 32 ), 6 ), &st->enr_old_fx, st->L_frame, st->Q_syn, 3, 0 ); - - IF( NE_16( st->nelp_mode_dec, 1 ) ) - { - /* modify the excitation signal of stationary unvoiced frames */ - stat_noise_uv_mod_fx( st->coder_type, 0, st->lsp_old_fx, lsp_new_fx, lsp_new_fx, Aq_fx, exc2_fx, st->Q_exc, 1, &st->ge_sm_fx, - &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, - &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); - } - } - - IF( st->hBWE_TD != NULL ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - Copy( Aq_fx + 2 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); - } - ELSE - { - Copy( Aq_fx + 3 * ( M + 1 ), st->hBWE_TD->cur_sub_Aq_fx, ( M + 1 ) ); - } - } - - /*--------------------------------------------------------* - * Apply NB postfilter in case of 8kHz output - *--------------------------------------------------------*/ - - test(); - IF( st->last_bwidth == NB && st->hPFstat != NULL ) - { - Copy_Scale_sig( pitch_buf_fx, pitch_buf_tmp, st->nb_subfr, -Q6 ); // Q0 - - IF( st->bwidth == NB ) - { - st->hPFstat->on = 1; - move16(); - nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, st->coder_type, st->BER_detect, 0 ); - } - ELSE - { - st->hPFstat->on = 0; - move16(); - nb_post_filt_fx( st->L_frame, st->hPFstat, &st->psf_lp_noise_fx, tmp_noise_fx, psyn_fx, Aq_fx, pitch_buf_tmp, AUDIO, st->BER_detect, 0 ); - } - } - ELSE - { - st->psf_lp_noise_fx = round_fx( L_shl( st->lp_noise, 1 ) ); - move16(); - } - - /*------------------------------------------------------------------* - * Perform fixed deemphasis through 1/(1 - g*z^-1) - *-----------------------------------------------------------------*/ - - /* update old synthesis buffer - needed for ACELP internal sampling rate switching */ - Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM ), st->mem_syn_r, L_SYN_MEM ); - deemph_fx( psyn_fx, st->preemph_fac, st->L_frame, &( st->mem_deemph_fx ) ); - unscale_AGC( psyn_fx, st->Q_syn, syn_fx_tmp2, st->agc_mem_fx, st->L_frame ); - Copy( syn_fx_tmp2, psyn_fx, st->L_frame ); - IF( st->hTcxDec != NULL ) - { - Copy_Scale_sig( psyn_fx + shr( st->L_frame, 1 ), st->hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, st->Q_syn ) ); /*Q-1*/ - st->hTcxDec->Q_old_syn_Overl = -1; - } - Copy_Scale_sig( psyn_fx + sub( st->L_frame, M + 1 ), st->syn, M + 1, sub( 0, st->Q_syn ) ); /*Q0*/ - - /*------------------------------------------------------------------* - * Formant post-filter - *-----------------------------------------------------------------*/ - - test(); - test(); - test(); - test(); - IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) ) - { - st->hPFstat->on = 1; - move16(); - Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); - set16_fx( st->hPFstat->mem_zero, 0, M ); - - formant_post_filt_fx( st->hPFstat, temp_buf_fx + L_SYN_MEM, Aq_fx, psyn_fx, st->L_frame, st->lp_noise, st->total_brate, 0 ); - } - ELSE IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) ) - { - IF( st->hPFstat->on ) - { - Copy( st->hPFstat->mem_pf_in + L_SYN_MEM - M, temp_buf_fx, M ); - Copy( psyn_fx, temp_buf_fx + M, L_SUBFR ); - - Residu3_fx( Aq_fx, temp_buf_fx + M, temp_buf_fx + M + L_SUBFR, L_SUBFR, 1 ); - E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); - scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); - Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) ); - blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 ); - } - st->hPFstat->on = 0; - move16(); - } - - /*----------------------------------------------------------------* - * Comfort noise addition - *----------------------------------------------------------------*/ - - test(); - test(); - IF( ( st->hFdCngDec != NULL || EQ_16( st->idchan, 1 ) ) && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - test(); - test(); - test(); - test(); - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) || st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) - { - /*VAD only for non inactive frame*/ - test(); - st->VAD = st->VAD && st->coder_type != INACTIVE; - move16(); - test(); - test(); - test(); - test(); - test(); - IF( st->idchan == 0 && ( st->flag_cna || ( EQ_16( st->cng_type, FD_CNG ) && LE_32( st->total_brate, ACELP_32k ) ) || ( st->cng_type == LP_CNG && LE_32( st->core_brate, SID_2k40 ) ) ) ) - { - /*Noisy speech detector*/ - noisy_speech_detection_fx( st->hFdCngDec, st->VAD, psyn_fx, st->Q_syn ); - - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = mult_r( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 32440 /*0.99 Q15*/ ); - move16(); - IF( st->hFdCngDec->hFdCngCom->flag_noisy_speech != 0 ) - { - st->hFdCngDec->hFdCngCom->likelihood_noisy_speech = add( st->hFdCngDec->hFdCngCom->likelihood_noisy_speech, 328 /*0.01 Q15*/ ); - move16(); - } - move32(); - } - - if ( st->idchan == 0 ) - { - st->lp_noise = st->hFdCngDec->lp_noise; - move32(); - } - - test(); - IF( NE_16( st->element_mode, IVAS_CPE_TD ) && !st->cng_ism_flag ) - { - /* Noise estimate */ - ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - } - - IF( !st->cna_dirac_flag ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - /* CNA: Generate additional comfort noise to mask potential coding artefacts */ - IF( st->flag_cna && !( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) - { - IF( hStereoCng->flag_cna_fade ) - { - generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 0; - move16(); - } - ELSE - { - test(); - IF( NE_16( st->element_mode, last_element_mode ) && ( st->idchan == 0 ) ) - { - /* Clear memory for secondary channel CNA */ - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, shr( st->hFdCngDec->hFdCngCom->frameSize, 1 ) ); - } - - generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 0, hStereoCng, nchan_out ); - } - } - ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); - } - ELSE - { - IF( st->idchan == 0 ) - { - IF( NE_16( st->element_mode, last_element_mode ) ) - { - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - } - - Word32 psyn_32_fx[L_FRAME16k]; - Copy_Scale_sig_16_32_no_sat( psyn_fx, psyn_32_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( Q6, st->Q_syn ) ); // Q6 - Copy_Scale_sig_16_32_no_sat( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), Q15 ); // Q15 - - generate_masking_noise_ivas_fx( psyn_32_fx, &exp, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0, 0, 0, st->element_mode, hStereoCng, nchan_out ); - - Copy_Scale_sig_32_16( psyn_32_fx, psyn_fx, st->hFdCngDec->hFdCngCom->frameSize, sub( st->Q_syn, exp ) ); // Q = st->Q_syn - Copy_Scale_sig_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth2_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->hFdCngDec->hFdCngCom->frameSize, 1 ), -Q15 ); // Q0 - } - } - } - } - ELSE IF( st->flag_cna && EQ_16( st->coder_type, AUDIO ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, TCX_20_CORE ) ) ) - { - test(); - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) && EQ_16( nchan_out, 2 ) ) - { - generate_stereo_masking_noise_fx( psyn_fx, st->Q_syn, st, hStereoTD, flag_sec_CNA, 1, hStereoCng, nchan_out ); - hStereoCng->flag_cna_fade = 1; - move16(); - } - ELSE - { - FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) - { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), negate( st->Q_syn ) ) ); - move16(); - } - } - } - ELSE - { - IF( hStereoCng != NULL ) - { - hStereoCng->flag_cna_fade = 1; - move16(); - hStereoCng->enableSecCNA = 0; - move16(); - } - } - - IF( EQ_16( st->element_mode, IVAS_CPE_TD ) ) - { - test(); - test(); - test(); - /*Noise estimate*/ - IF( ( st->idchan == 0 ) && ( EQ_16( nchan_out, 2 ) || ( st->core_brate != FRAME_NO_DATA && NE_32( st->core_brate, SID_2k40 ) ) ) ) - { - ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - } - } - } - } - - IF( !st->cna_dirac_flag ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( st->flag_cna == 0 ) && EQ_16( st->L_frame, L_FRAME16k ) && EQ_16( st->last_flag_cna, 1 ) && ( ( st->last_core == ACELP_CORE && !( EQ_16( st->last_coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->Last_GSC_noisy_speech_flag ) ) ) || EQ_16( st->last_core, AMR_WB_CORE ) ) ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - // VE: TBV - is it correct in EVS? in FLP, it is: - // v_multc( st->hFdCngDec->hFdCngCom->olapBufferSynth2 + 5 * st->L_frame / 4, 256.f, temp_buf, st->L_frame / 2 ); - // v_add( temp_buf, syn, syn, st->L_frame / 2 ); - FOR( i = 0; i < st->L_frame / 2; i++ ) - { - psyn_fx[i] = add( psyn_fx[i], shr_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * st->L_frame / 4], negate( st->Q_syn ) ) ); - move16(); - } - } - ELSE - { - FOR( i = 0; i < ( st->hFdCngDec->hFdCngCom->frameSize ) / 2; i++ ) - { - psyn_fx[i] = add( psyn_fx[i], shr_r( mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth2[i + 5 * ( st->hFdCngDec->hFdCngCom->frameSize / 4 )], st->hFdCngDec->hFdCngCom->fftlenFac ), -st->Q_syn ) ); - move16(); - } - } - } - - test(); - test(); - test(); - IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) - { - IF( st->idchan == 0 ) - { - set16_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth2, 0, st->hFdCngDec->hFdCngCom->fftlen ); - } - IF( hStereoCng != NULL && ( st->idchan == 0 ) ) - { - set16_fx( hStereoCng->olapBufferSynth22_fx, 0, st->hFdCngDec->hFdCngCom->fftlen ); - } - } - } - } - - /*----------------------------------------------------------------* - * Resample to the output sampling rate (8/16/32/48 kHz) - * Bass post-filter - *----------------------------------------------------------------*/ - - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - CLDFB_SCALE_FACTOR scaleFactor; - Word32 workBuffer[128 * 3]; - - /* check if the CLDFB works on the right sample rate */ - IF( ( st->cldfbAna->usb * st->cldfbAna->no_col ) != st->L_frame ) - { - /* resample to ACELP internal sampling rate */ - Word16 newCldfbBands = CLDFB_getNumChannels( L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb( st->cldfbAna, newCldfbBands, st->L_frame, 0 ); - resampleCldfb( st->cldfbBPF, newCldfbBands, st->L_frame, 0 ); - - IF( st->ini_frame > 0 ) - { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - } - - test(); - IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); - } - ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); - } - } - - bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, - st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); - - /* analysis of the synthesis at internal sampling rate */ - cldfbAnalysis_fx( st->cldfbAna, realBuffer_fx, imagBuffer_fx, &scaleFactor, psyn_fx, negate( st->Q_syn ), CLDFB_NO_COL_MAX, workBuffer ); - - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - /* analysis and add the BPF error signal */ - i = 0; - move16(); - if ( st->bpf_off == 0 ) - { - i = CLDFB_NO_COL_MAX; - move16(); - } - - addBassPostFilter_fx( bpf_error_signal_16fx, realBuffer_fx, imagBuffer_fx, st->cldfbBPF, workBuffer, negate( st->Q_syn ), - i, st->cldfbAna->no_col, st->cldfbAna->no_channels, &scaleFactor ); - - /* set output mask for upsampling */ - IF( EQ_16( st->bwidth, NB ) ) - { - /* set NB mask for upsampling */ - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); - move16(); - } - ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) - { - /* in case of BW switching, re-init to default */ - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - - /*WB/SWB-FD_CNG*/ - scaleFactor.hb_scale = scaleFactor.lb_scale; - move16(); - - test(); - test(); - test(); - IF( ( ( st->core_brate == FRAME_NO_DATA ) || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) - { - generate_comfort_noise_dec_hf_fx( realBuffer_fx, imagBuffer_fx, &scaleFactor.hb_scale, st ); - - st->cldfbSyn->bandsToZero = 0; - move16(); - IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) - { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); - } - st->cldfbSyn->lsb = st->cldfbAna->no_channels; - move16(); - } - - /* synthesis of the combined signal */ - st->Q_syn2 = st->Q_syn; - move16(); - cldfbSynthesis_fx( st->cldfbSyn, realBuffer_fx, imagBuffer_fx, &scaleFactor, synth_fx16, negate( st->Q_syn2 ), CLDFB_NO_COL_MAX, workBuffer ); - - /* Bring CLDFB output to Q0 */ - Scale_sig( synth_fx16, output_frame, negate( st->Q_syn2 ) ); - st->Q_syn2 = 0; - move16(); - - /* save synthesis - needed in case of core switching */ - Copy( synth_fx16, st->previoussynth_fx, output_frame ); - } - ELSE - { - /* check if the CLDFB works on the right sample rate */ - IF( NE_16( imult1616( st->cldfbAna->no_channels, st->cldfbAna->no_col ), st->L_frame ) ) - { - resampleCldfb_ivas_fx( st->cldfbAna, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - resampleCldfb_ivas_fx( st->cldfbBPF, L_mult0( st->L_frame, FRAMES_PER_SEC ) ); - - IF( st->ini_frame > 0 ) - { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - } - - /* analyze pitch coherence for bass post-filter */ - Word32 pitch_buf_fx_q20[12]; - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, Q4 ); // Q(x+4) - Word16 lim = shr( st->L_frame, 6 ); - FOR( Word16 lp = 0; lp < lim; lp++ ) - { - pitch_buf_fx_q20[lp] = L_shl( pitch_buf_fx[lp], Q14 ); - move32(); - } - bpf_pitch_coherence_ivas_fx( st, pitch_buf_fx_q20 ); - Scale_sig32( st->old_pitch_buf_fx, 2 * NB_SUBFR16k + 2, -Q4 ); // Qx - - test(); - IF( !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && st->bpf_off ) ) - { - test(); - IF( NE_16( st->L_frame, st->last_L_frame ) && NE_16( st->last_codec_mode, MODE2 ) ) - { - IF( EQ_16( st->L_frame, L_FRAME ) ) - { - retro_interp5_4_fx( st->hBPF->pst_old_syn_fx ); - } - ELSE IF( EQ_16( st->L_frame, L_FRAME16k ) ) - { - retro_interp4_5_fx( psyn_fx, st->hBPF->pst_old_syn_fx ); - } - } - - bass_psfilter_fx( st->hBPF, st->Opt_AMR_WB, psyn_fx, st->L_frame, pitch_buf_fx, st->bpf_off, - st->stab_fac_fx, &st->stab_fac_smooth_fx, st->coder_type, st->Q_syn, bpf_error_signal_16fx ); - } - - Word32 syn_tmp_32_fx[L_FRAME16k + L_SUBFR], *syn_32_fx; - set32_fx( syn_tmp_32_fx, 0, L_FRAME16k + L_SUBFR ); - syn_32_fx = syn_tmp_32_fx + L_SUBFR; - test(); - IF( NE_16( st->element_mode, IVAS_CPE_DFT ) || use_cldfb_for_dft ) - { - /* analysis of the synthesis at internal sampling rate */ - Word32 realBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 imagBufferSave_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; - Word32 *pRealSave_fx[CLDFB_NO_COL_MAX], *pImagSave_fx[CLDFB_NO_COL_MAX]; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - pRealSave_fx[i] = realBufferSave_fx[i]; - pImagSave_fx[i] = imagBufferSave_fx[i]; - } - IF( st->p_bpf_noise_buf_32 ) - { - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 - } - - FOR( i = 0; i < st->L_frame; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); // Q12 - move32(); - } - - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; - move16(); - - cldfbAnalysis_ivas_fx( syn_32_fx, realBuffer_fx, imagBuffer_fx, -1, st->cldfbAna ); - - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; - move16(); - /* analysis and add the BPF error signal */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - - q_bpf_error_signal = Q6; - move16(); - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, st->L_frame, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = -1; - move16(); - if ( st->bpf_off ) - { - tmp = 0; - move16(); - } - - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx, tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( ( sub( q_bpf_error_signal, Q10 ) ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; - move16(); - /* set output mask for upsampling */ - IF( EQ_16( st->bwidth, NB ) ) - { - /* set NB mask for upsampling */ - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, 10 ); - move16(); - } - ELSE IF( NE_16( st->cldfbSyn->bandsToZero, sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ) ) ) - { - /* in case of BW switching, re-init to default */ - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); - move16(); - } - test(); - IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - test(); - test(); - test(); - /*WB/SWB-FD_CNG*/ - IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) - { - Word16 tmpBufferScale = 0; - move16(); - generate_comfort_noise_dec_hf_ivas_fx( realBuffer_fx, imagBuffer_fx, /*realBuffer, imagBuffer,*/ &tmpBufferScale, st->hFdCngDec->hFdCngCom, st->cng_ism_flag ); - - FOR( i = 0; i < st->hFdCngDec->hFdCngCom->numSlots; i++ ) - { - Scale_sig32( realBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - Scale_sig32( imagBuffer_fx[i] + st->hFdCngDec->hFdCngCom->numCoreBands, sub( st->hFdCngDec->hFdCngCom->regularStopBand, st->hFdCngDec->hFdCngCom->numCoreBands ), sub( add( tmpBufferScale, 15 ), Q31 ) ); // Q0 - } - - IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) - { - st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); - } - ELSE - { - st->cldfbSyn->bandsToZero = 0; - move16(); - } - } - } - - IF( save_hb_synth_fx16 != NULL ) - { - /* save and then zero-out lowband */ - max_real = 0; - max_imag = 0; - move32(); - move32(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } - } - max_val = L_max( max_real, max_imag ); - Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) -#endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBufferSave_fx[i][j] = realBuffer_fx[i][j]; - imagBufferSave_fx[i][j] = imagBuffer_fx[i][j]; - move32(); - move32(); - IF( LT_16( j, st->hFdCngDec->hFdCngCom->numCoreBands ) && LT_16( i, st->hFdCngDec->hFdCngCom->numSlots ) ) - { - realBuffer_fx[i][j] = 0; - imagBuffer_fx[i][j] = 0; - move32(); - move32(); - } - } - } - -#ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - /* restore lowband */ - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - realBuffer_fx[i][j] = realBufferSave_fx[i][j]; - imagBuffer_fx[i][j] = imagBufferSave_fx[i][j]; - move32(); - move32(); - } - } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - } - ELSE - { - /* synthesis of the combined signal */ - max_real = 0; - max_imag = 0; - move32(); - move32(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } - } - max_val = L_max( max_real, max_imag ); - Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - } -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); - move16(); - -#ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); - } - - /* save synthesis - needed in case of core switching */ - Copy32( synth_fx, st->previoussynth_fx_32, output_frame ); // Q0 - } - ELSE - { - Word16 nSamples = NS2SA_FX2( i_mult( st->L_frame, FRAMES_PER_SEC ), FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ); /* IVAS-64: optimization is likely possible here (don't resample the whole frame) */ - - /* analysis of the synthesis at internal sampling rate - needed for DFT stereo -> TD stereo switching */ - FOR( i = 0; i < st->L_frame; i++ ) - { - syn_32_fx[i] = L_shr( L_deposit_h( psyn_fx[i] ), add( 4, st->Q_syn ) ); - move32(); - } - - Word16 offset = sub( st->cldfbAna->p_filter_length, st->cldfbAna->no_channels ); - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, 1 ); // Q12 - st->cldfbAna->Q_cldfb_state = Q12; - move16(); - - cldfbAnalysis_ivas_fx( syn_32_fx + sub( st->L_frame, nSamples ), realBuffer_fx, imagBuffer_fx, nSamples, st->cldfbAna ); - - Scale_sig32( st->cldfbAna->cldfb_state_fx, offset, -1 ); // Q11 - st->cldfbAna->Q_cldfb_state = Q11; - move16(); /* analysis and add the BPF error signal - needed for DFT stereo -> TD stereo switching */ - Word32 tmp_bpf_error_signal_fx[L_FRAME16k]; - Word16 q_bpf_error_signal; - Word16 cldfb_state_offset; - cldfb_state_offset = sub( st->cldfbBPF->p_filter_length, st->cldfbBPF->no_channels ); - - // Get Q-factor - q_bpf_error_signal = Q6; - move16(); - Copy_Scale_sig_16_32_no_sat( bpf_error_signal_16fx, tmp_bpf_error_signal_fx, L_FRAME16k, sub( q_bpf_error_signal, st->Q_syn ) ); // Q6 - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, -Q7 ); // Q0 - } - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, sub( q_bpf_error_signal, Q10 ) ); // q_bpf_error_signal (Q6) - st->cldfbBPF->Q_cldfb_state = q_bpf_error_signal; - move16(); - tmp = 0; - move16(); - if ( !st->bpf_off ) - { - tmp = nSamples; - move16(); - } - - addBassPostFilter_ivas_fx( tmp_bpf_error_signal_fx + sub( st->L_frame, nSamples ), tmp, realBuffer_fx, imagBuffer_fx, st->cldfbBPF ); - - Scale_sig32( st->cldfbBPF->cldfb_state_fx, cldfb_state_offset, negate( sub( q_bpf_error_signal, Q10 ) ) ); // Q10 - st->cldfbBPF->Q_cldfb_state = Q10; - move16(); - /* synthesis of the combined signal - needed for DFT stereo -> TD stereo switching */ - max_real = 0; - max_imag = 0; - move32(); - move32(); - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - max_real = L_max( max_real, L_abs( realBuffer_fx[i][j] ) ); - max_imag = L_max( max_imag, L_abs( imagBuffer_fx[i][j] ) ); - } - } - max_val = L_max( max_real, max_imag ); - Q_real = sub( norm_l( max_val ), 3 ) /* Guard bits */; - FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) - { - scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real - } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifdef OPT_AVOID_STATE_BUF_RESCALE - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - IF( st->p_bpf_noise_buf_32 ) - { - Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 - Copy32( bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame ); - - Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); // Q11 - } - - set32_fx( synth_fx, 0, output_frame ); - } - - /* Copy output signal */ - Scale_sig( syn_tmp_fx, add( st->L_frame, L_SUBFR ), negate( st->Q_syn ) ); // Q0 - IF( st->element_mode > EVS_MONO ) - { - Copy( psyn_fx, output_fx, st->L_frame ); /*Q_syn*/ - } - - st->Q_syn2 = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Bandwidth extension 6kHz-7kHz - *-----------------------------------------------------------------*/ - - IF( st->hBWE_zero != NULL ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( EQ_16( st->L_frame, L_FRAME ) && ( st->bwidth != NB ) && GE_16( output_frame, L_FRAME16k ) && - ( EQ_16( st->extl, -1 ) || EQ_16( st->extl, SWB_CNG ) || ( EQ_16( st->extl, WB_BWE ) && st->extl_brate == 0 && NE_16( st->coder_type, AUDIO ) ) ) ) ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); - } - ELSE - { - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q0 - hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2 ); - Copy_Scale_sig_16_32_DEPREC( synth_fx16, synth_fx, output_frame, 0 ); - } - } - ELSE - { - hf_synth_reset_fx( st->hBWE_zero ); - IF( NE_16( st->element_mode, EVS_MONO ) ) // VE: TBV: tmp hack - it is a bug in EVS but condition is here to keep EVS bit-exact for the moment - { - set16_fx( st->hBWE_zero->mem_hp400_fx, 0, 6 ); - } - } - } - - /*-----------------------------------------------------------------* - * Populate parameters for SWB TBE - *-----------------------------------------------------------------*/ - - IF( st->hBWE_TD != NULL ) - { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( ( !st->bfi && st->prev_bfi ) || ( EQ_16( st->last_vbr_hw_BWE_disable_dec, 1 ) && ( st->vbr_hw_BWE_disable_dec == 0 ) ) || ( ( EQ_16( st->extl, SWB_TBE ) || EQ_16( st->extl, WB_TBE ) || EQ_16( st->extl, FB_TBE ) ) && NE_16( st->last_extl, SWB_TBE ) && NE_16( st->last_extl, WB_TBE ) && NE_16( st->last_extl, FB_TBE ) ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && !st->tdm_LRTD_flag ) ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); - } - - test(); - test(); - test(); - test(); - test(); - IF( !st->ppp_mode_dec && ( st->idchan == 0 || NE_16( st->element_mode, IVAS_CPE_TD ) || ( EQ_16( st->idchan, 1 ) && EQ_16( st->element_mode, IVAS_CPE_TD ) && st->tdm_LRTD_flag ) ) ) - { - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - non_linearity_fx( bwe_exc_fx, bwe_exc_extended_fx, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - } - ELSE - { - Copy_Scale_sig_16_32_no_sat( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc - non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, negate( sub( shl( st->Q_exc, 1 ), sub( st->prev_Q_bwe_exc, 16 ) ) ) ); // prev_Q_bwe_exc - } - } - - test(); - if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) - { - st->hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - move32(); - } - } - - /*----------------------------------------------------------------------* - * Updates - *----------------------------------------------------------------------*/ - - updt_dec_fx( st, old_exc_fx, pitch_buf_fx, Es_pred_fx, Aq_fx, lsf_new_fx, lsp_new_fx, voice_factors_fx, old_bwe_exc_fx, gain_buf_fx ); - - test(); - test(); - IF( GT_32( st->core_brate, SID_2k40 ) && st->hTdCngDec != NULL && st->hFdCngDec != NULL ) - { - /* update CNG parameters in active frames */ - IF( EQ_16( st->element_mode, EVS_MONO ) ) - { - cng_params_upd_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, st->hTdCngDec->ho_lsp_circ_fx, - st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate ); - } - ELSE - { - cng_params_upd_ivas_fx( lsp_new_fx, exc_fx, st->L_frame, &st->hTdCngDec->ho_circ_ptr, st->hTdCngDec->ho_ener_circ_fx, &st->hTdCngDec->ho_circ_size, - st->hTdCngDec->ho_lsp_circ_fx, st->Q_exc, DEC, st->hTdCngDec->ho_env_circ_fx, NULL, NULL, NULL, NULL, st->last_active_brate, st->element_mode, - st->hFdCngDec->hFdCngCom->CngBandwidth ); - } - - /* Set 16k LSP flag for CNG buffer */ - st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 0; - move16(); - if ( NE_16( st->L_frame, L_FRAME ) ) - { - st->hTdCngDec->ho_16k_lsp[st->hTdCngDec->ho_circ_ptr] = 1; - move16(); - } - } - - IF( NE_16( st->element_mode, EVS_MONO ) ) - { - IF( save_hb_synth_fx16 ) - { - Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 ); // Q0 - } - Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 ); // Q_syn2 - } - - pop_wmops(); - return error; -} diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 8f09c1c7d..6419f8517 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -40,6 +40,13 @@ #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" + +/*-------------------------------------------------------------------* + * tdm_low_rate_dec_fx() + * + * Low-bitrate decoder + *-------------------------------------------------------------------*/ + void tdm_low_rate_dec_fx( Decoder_State *st, /* i/o: decoder static memory */ Word16 dct_epit[], /* o : GSC excitation in DCT domain Q_exc*/ @@ -188,6 +195,7 @@ void tdm_low_rate_dec_fx( return; } + /*---------------------------------------------------------------------* * decod_gen_2sbfr() * @@ -217,12 +225,12 @@ void decod_gen_2sbfr_fx( move32(); Word16 gain_inov = 0; /* Innovation gain */ move16(); - Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ - Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ + Word32 gc_mem[NB_SUBFR - 1]; /* gain_code from previous subframes */ + Word16 gp_mem[NB_SUBFR - 1]; /* gain_pitch from previous subframes */ Word16 voice_fac; /* voicing factor */ Word16 code[2 * L_SUBFR]; /* algebraic codevector */ const Word16 *p_Aq; /* Pointer to frame LP coefficient */ - Word16 *pt_pitch; /* pointer to Word16 pitch */ + Word16 *pt_pitch; /* pointer to Word16 pitch */ Word16 i_subfr; /* tmp variables */ Word16 L_frame; Word16 pitch_limit_flag; -- GitLab From ed6b68d54da95ac03180412a2185a155b8ee1a9c Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 17 Apr 2025 16:04:05 +0200 Subject: [PATCH 070/394] clang-format --- lib_enc/lsf_enc_fx.c | 4 ++-- lib_enc/pre_proc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/lsf_enc_fx.c b/lib_enc/lsf_enc_fx.c index b26532b15..23ed7d0c2 100644 --- a/lib_enc/lsf_enc_fx.c +++ b/lib_enc/lsf_enc_fx.c @@ -1985,7 +1985,7 @@ static void first_VQstages( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ @@ -2175,7 +2175,7 @@ static void first_VQstages_ivas_fx( dist[1] = dist_buf + maxC; move16(); - set16_fx( idx_buf, 0, (const Word16) ( 2 * stagesVQ * maxC ) ); + set16_fx( idx_buf, 0, ( const Word16 )( 2 * stagesVQ * maxC ) ); set16_fx( parents, 0, maxC ); /* Set up inital distance vector */ diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index cc8b64ca4..f7ebc8298 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -213,7 +213,7 @@ void pre_proc_fx( /*----------------------------------------------------------------* * Change the sampling frequency to 12.8 kHz *----------------------------------------------------------------*/ - modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, (const Word16) ( EQ_16( st->max_bwidth, NB ) ) ); + modify_Fs_fx( signal_in, input_frame, st->input_Fs, new_inp_12k8, INT_FS_12k8, st->mem_decim_fx, ( const Word16 )( EQ_16( st->max_bwidth, NB ) ) ); Copy( new_inp_12k8, st->buf_speech_enc + L_FRAME32k, L_FRAME ); Scale_sig( st->buf_speech_enc + L_FRAME32k, L_FRAME, 1 ); /*------------------------------------------------------------------* -- GitLab From 99e3a8baf5352b85a3355956f08fe26c0f6f7a62 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 13 May 2025 12:38:38 +0200 Subject: [PATCH 071/394] deactivcate FIX_1439_SPEEDUP_synthesise_fb_high_band_fx --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index bcee4b8fe..2d587c82a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,7 @@ #define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_synthesise_fb_high_band_fx /*FhG: reduces WMOPS - bit-exact*/ +//#define FIX_1439_SPEEDUP_synthesise_fb_high_band_fx /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic /*FhG: reduces maintenance complexity & reduces WMOPS & prepares STAGE2 patch*/ #define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/ #define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ -- GitLab From 378f5fab6bad83e506234a3d329864c8ea0660cd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 13 May 2025 14:40:11 +0200 Subject: [PATCH 072/394] delete FIX_1439_SPEEDUP_synthesise_fb_high_band_fx wrapped code --- lib_com/swb_tbe_com_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 08bbd6362..4dfaa0a5a 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7033,6 +7033,7 @@ void synthesise_fb_high_band_fx( { output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/ move16(); + } } return; -- GitLab From 0e507b7d884abe27cf73c197c59339377cbdf581 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 13 May 2025 15:31:17 +0200 Subject: [PATCH 073/394] apply clang patch --- lib_com/swb_tbe_com_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 4dfaa0a5a..08bbd6362 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7033,7 +7033,6 @@ void synthesise_fb_high_band_fx( { output[i] = extract_h( L_shl_sat( L_tmp, tmp3 ) ); /*Qout*/ move16(); - } } return; -- GitLab From 097eff41e0a3e169e135036e69a4f900ea5b3044 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 13 May 2025 14:57:45 +0000 Subject: [PATCH 074/394] delete FIX_1439_SPEEDUP_synthesise_fb_high_band_fx from options --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2d587c82a..2ddb2b138 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -//#define FIX_1439_SPEEDUP_synthesise_fb_high_band_fx /*FhG: reduces WMOPS - bit-exact*/ #define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic /*FhG: reduces maintenance complexity & reduces WMOPS & prepares STAGE2 patch*/ #define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/ #define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ -- GitLab From 98e06bacaad4879d0663e8b751973f92b7f5ae47 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 08:59:14 +0530 Subject: [PATCH 075/394] Fix for 3GPP issue 1583: Very high MLD for ParamMC 5.1+4 at 96kbps 16kHz input Link #1583 --- lib_enc/ivas_mc_param_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 3058f87f3..7f74f78f9 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -768,8 +768,8 @@ static void ivas_param_mc_param_est_enc_fx( #endif #ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE - sub35gb = sub( 35, find_guarded_bits_fx( l_ts ) ); - sub62gb = sub( 62, find_guarded_bits_fx( l_ts ) ); + sub35gb = sub( 32, sub( 11, find_guarded_bits_fx( l_ts ) ) ); // 31 - (((11 - gb) + 31 + norm) - 32) + sub62gb = sub( 63, shl( sub( 11, find_guarded_bits_fx( l_ts ) ), 1 ) ); // 31 - ((2*(11 - gb) + norm) - 32) #endif FOR( ts = start_ts; ts < num_time_slots; ts++ ) -- GitLab From 9600ad0128c5b0bfbc8b9a7c7c904111e2a501c4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 16:15:17 +0530 Subject: [PATCH 076/394] Fix for 3GPP issue 1533: Slightly high MLD for one case of MASA LTV EXT output in BASOP decoder Link #1533 --- lib_dec/ivas_stereo_cng_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 6b8a8f949..8ec147ff7 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -1368,8 +1368,8 @@ static void FindEmEs_fx( temp_q = 0; move16(); } - log_res = BASOP_Util_Log2( square_res ); - es_em_fx = Mpy_32_32( log_res, 1616107501 ); // 25+30-31 + log_res = L_add( BASOP_Util_Log2( square_res ), L_shl( temp_q, Q25 ) ); + es_em_fx = Mpy_32_32( log_res, 1616107501 /* 5 * (ln(2)/ln(10)) */ ); // 25+30-31 /* long-term estimate */ *lt_es_em_fx = L_add( Mpy_32_32( 858993459, *lt_es_em_fx ), Mpy_32_32( 1288490188, es_em_fx ) ); /* Q24 */ move32(); -- GitLab From d784008387fe458ba8f6c4fcd8a5943587e80718 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 12:26:14 +0530 Subject: [PATCH 077/394] Fix for 3GPP issue 1469: Somewhat high MLD on a single MASA selection test material case with BASOP decoder Link #1469 --- lib_com/prot_fx.h | 2 +- lib_com/stat_noise_uv_mod_fx.c | 58 +++++++++++++++++++--------------- lib_dec/stat_noise_uv_dec_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 5 +-- lib_enc/prot_fx_enc.h | 2 +- lib_enc/stat_noise_uv_enc_fx.c | 2 +- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 43010af04..d5e52e046 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8247,7 +8247,7 @@ void stat_noise_uv_mod_ivas_fx( const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index 67ca21cd2..c259745f2 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -330,7 +330,6 @@ void stat_noise_uv_mod_fx( } } } - /*--------------------------------------------------------------------* * stat_noise_uv_mod() * @@ -345,7 +344,7 @@ void stat_noise_uv_mod_ivas_fx( const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ @@ -370,8 +369,9 @@ void stat_noise_uv_mod_ivas_fx( Word16 oldlsp_mix[M]; Word16 midlsp_mix[M]; Word16 newlsp_mix[M]; - Word16 beta; /* Q15 */ - Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ + Word16 beta; /* Q15 */ + Word16 Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ + Word32 L_Noimix_fract; /* (noimix_fac - 1.0) in Q15 */ /* noimix_fax * x <-> x + Noimix_fract * x */ Word16 i_subfr; Word16 i, k; @@ -382,7 +382,8 @@ void stat_noise_uv_mod_ivas_fx( Word32 L_tmp_res, L_tmp, L_tmp3, L_Ge; Word16 En_shift, Tmp; - Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ + Word16 Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ + Word32 L_Exc2_local[L_FRAME]; /* local_copy in scaled Q_local*/ #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); @@ -437,9 +438,9 @@ void stat_noise_uv_mod_ivas_fx( Copy( exc2, Exc2_local, L_FRAME ); /* bound Q for internal use, optimization possible */ - Q_local = s_min( 11, s_max( -1, Q_exc ) ); + Q_local = s_min( 11, s_max( -1, *Q_exc ) ); /* local excitation Q and incoming excitation Q*/ - Qdiff = sub( Q_local, Q_exc ); + Qdiff = sub( Q_local, *Q_exc ); /* only shift if incoming Q is outside [11..-1] shift is done in energy calculations aswell */ Scale_sig( Exc2_local, L_FRAME, Qdiff ); /* current excitation Q and previous stat_noise states Q */ @@ -539,14 +540,11 @@ void stat_noise_uv_mod_ivas_fx( L_tmp_res = L_mac( 0, alpha, alpha ); L_tmp_res = L_mac( L_tmp_res, alpha_m1, alpha_m1 ); tmp_den = round_fx( L_Frac_sqrtQ31( L_tmp_res ) ); - - tmp_nom = sub( 32767, tmp_den ); - tmp_shift = norm_s( tmp_den ); - tmp_den = shl( tmp_den, tmp_shift ); - tmp_res = div_s( tmp_nom, tmp_den ); - - Noimix_fract = shr( tmp_res, tmp_shift ); /* float value is in range 0.0 to 0.42 */ - + Word16 exp_sqr = 0; + move16(); + tmp_res = BASOP_Util_Divide1616_Scale( 32767, tmp_den, &exp_sqr ); // 15-exp_sqr + Noimix_fract = tmp_res; // 15-exp_sqr + move16(); /* L_Ge might be 0 in unvoiced WB */ L_Ge = L_max( L_Ge, 1 ); tmp_shift = norm_l( L_Ge ); @@ -555,9 +553,7 @@ void stat_noise_uv_mod_ivas_fx( L_tmp_res = Mult_32_16( *ge_sm, tmp_res ); /* Q_stat_noise_ge+45-Q_local-Q_ge-tmp_shift-15 */ L_tmp_res = Mult_32_16( L_tmp_res, sub( 32767, beta ) ); /*30-Q_local-tmp_shift+15-15 */ L_tmp_res = L_add_sat( L_shl_sat( L_tmp_res, sub( add( Q_local, tmp_shift ), 15 ) ), beta ); /* Q15 */ - tmp_res = extract_h( L_shl_o( L_tmp_res, 15, &Overflow ) ); /* 15+15-16=14 */ - - Noimix_fract = extract_l( Mult_32_16( L_tmp_res, Noimix_fract ) ); /*15+15-15 */ + L_Noimix_fract = Mult_32_16( L_tmp_res, Noimix_fract ); /*15+15-exp_sqr-15 =15-exp_sqr */ FOR( i = 0; i < L_FRAME; i++ ) { @@ -573,18 +569,27 @@ void stat_noise_uv_mod_ivas_fx( randval = mult_r( 28378, randval ); /* Q downscaled by 2 bits ends up in Q14 */ /*sqrt(12.0f) in Q13*/ randval = extract_l( L_shl( Mult_32_16( L_Ge, randval ), sub( 1, *Q_stat_noise_ge ) ) ); /*Q_local+Q_ge+14-15+1-Q_ge=Q_local */ - L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ - L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ - L_tmp3 = Mult_32_16( L_tmp, Noimix_fract ); /* Q_local+16+15-15 */ - L_tmp = L_add_sat( L_tmp3, L_shl_sat( Mult_32_16( L_tmp, tmp_res ), 1 ) ); /* Q_local+16+14-15+1 */ - Exc2_local[i] = extract_h( L_tmp ); /*Q_local */ + L_tmp = L_mult( Exc2_local[i], alpha ); /* Q_local + 16 */ + L_tmp = L_mac( L_tmp, randval, alpha_m1 ); /* Q_local + 16 */ + L_tmp3 = Mult_32_32( L_tmp, L_Noimix_fract ); /* Q_local+16+15-exp_sqr-15 =Q_local +1 */ + L_Exc2_local[i] = L_add( L_shr( L_tmp3, 1 ), Mpy_32_32( L_tmp, L_tmp_res ) ); // Q_local + 16 +15 -31 = Q_local + move32(); + } + Word32 max_val; + maximum_abs_32_fx( L_Exc2_local, L_FRAME, &max_val ); + Word16 shift = 0; + move16(); + IF( GT_32( max_val, ONE_IN_Q15 ) ) + { + shift = norm_l( max_val ); + shift = sub( Q31 - Q15, shift ); + *Q_exc = sub( Q_local, shift ); // Q_exc = Q_local -shift move16(); } *Q_stat_noise = Q_local; /* update for next call, routine can only be called once every frame */ move16(); - Qdiff = sub( Q_exc, Q_local ); /* local excitation and incoming excitation */ - Scale_sig( Exc2_local, L_FRAME, Qdiff ); - Copy( Exc2_local, exc2, L_FRAME ); + + Copy_Scale_sig_32_16( L_Exc2_local, exc2, L_FRAME, negate( shift ) ); // Q_exc /*--------------------------------------------------------------------* * Generate low-pass filtered version of ISP coefficients @@ -635,6 +640,7 @@ void stat_noise_uv_mod_ivas_fx( } } } + /*---------------------------------------------------------------------------* * calc_tilt() * diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index d2fa36b9b..4e4d7ca30 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -76,7 +76,7 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { - stat_noise_uv_mod_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ceba860a1..6ba21136e 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1449,8 +1449,9 @@ ivas_error acelp_core_enc_ivas_fx( { /* exc2 buffer is needed only for updating of Aq[] which is needed for core switching */ Copy( exc_fx, exc2_fx, st->L_frame ); // Q_new - - stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, Q_new ); + Word16 q_exc2 = Q_new; + move16(); + stat_noise_uv_enc_ivas_fx( st, epsP, lsp_new, lsp_mid, Aq, exc2_fx, uc_two_stage_flag, &q_exc2 ); } /*-----------------------------------------------------------------* diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 968ab0082..72137bdce 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -2189,7 +2189,7 @@ void stat_noise_uv_enc_ivas_fx( Word16 *Aq, /* i : A(z) quantized for the 4 subframes Q=12 */ Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ - Word16 Q_new ); + Word16 *Q_new ); void analy_sp_fx( const Word16 element_mode, /* i : element mode */ diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 1445559a1..24932542c 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -118,7 +118,7 @@ void stat_noise_uv_enc_ivas_fx( Word16 *Aq, /* i : A(z) quantized for the 4 subframes Q=12 */ Word16 *exc2, /* i/o: excitation buffer Q=Q_stat_noise */ const Word16 uc_two_stage_flag, /* o : flag undicating two-stage UC */ - Word16 Q_new ) + Word16 *Q_new ) { Word16 noisiness = 0; move16(); -- GitLab From 9189bfaf27589723c02d76e3ce20751f18f9c5e3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 12:32:36 +0530 Subject: [PATCH 078/394] Clang formatting changes --- lib_com/prot_fx.h | 2 +- lib_dec/stat_noise_uv_dec_fx.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d5e52e046..85ece0cab 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8247,7 +8247,7 @@ void stat_noise_uv_mod_ivas_fx( const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr Q=15*/ Word16 *Aq, /* o : A(z) quantized for the 4 subframes Q=12*/ Word16 *exc2, /* i/o: excitation buffer Q=Q_exc*/ - Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ + Word16 *Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */ const Word16 bfi, /* i : Bad frame indicator */ Word32 *ge_sm, /* i/o: smoothed excitation gain Q=Q_stat_noise_ge (6)*/ Word16 *uv_count, /* i/o: unvoiced counter */ diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index 4e4d7ca30..e2dc1460e 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -77,9 +77,9 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, - st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, - &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, - &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, + &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, + &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); } -- GitLab From e4d93a77b8d75f4b46e2a9b4a0a9cf52b1e38c29 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 16 May 2025 14:45:18 +0530 Subject: [PATCH 079/394] Fix for EVS bitexactness issue --- lib_dec/stat_noise_uv_dec_fx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib_dec/stat_noise_uv_dec_fx.c b/lib_dec/stat_noise_uv_dec_fx.c index e2dc1460e..c87e30ffe 100644 --- a/lib_dec/stat_noise_uv_dec_fx.c +++ b/lib_dec/stat_noise_uv_dec_fx.c @@ -76,10 +76,20 @@ void stat_noise_uv_dec_fx( IF( !st_fx->Opt_AMR_WB ) { - stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, - st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, - &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, - &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + IF( st_fx->element_mode > EVS_MONO ) + { + stat_noise_uv_mod_ivas_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, &st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, + &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, + &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + } + ELSE + { + stat_noise_uv_mod_fx( coder_type, noisiness, st_fx->lsp_old_fx, lsp_new, lsp_mid, Aq, exc2, st_fx->Q_exc, 0, &st_fx->ge_sm_fx, &st_fx->uv_count, &st_fx->act_count, + st_fx->lspold_s_fx, &st_fx->noimix_seed, &st_fx->min_alpha_fx, + &st_fx->exc_pe_fx, st_fx->core_brate, st_fx->bwidth, + &st_fx->Q_stat_noise, &st_fx->Q_stat_noise_ge ); + } } -- GitLab From a9b30958a324d74b2ecc91462fa31d1a9b2dff1e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 15 May 2025 14:23:40 +0530 Subject: [PATCH 080/394] Fix for 3GPP issue 1531: Low-bitrate OMASA shows a bit high MLD (over 10) in BASOP decoder rendering to binaural Link #1531 --- lib_dec/FEC_clas_estim_fx.c | 16 ++++-- .../ivas_dirac_dec_binaural_functions_fx.c | 49 ++++++++++++++---- lib_rend/ivas_dirac_rend_fx.c | 51 ++++++++++++------- 3 files changed, 85 insertions(+), 31 deletions(-) diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index e56a77be1..2bd38153a 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -285,7 +285,17 @@ void FEC_clas_estim_fx( Corre( &pt1[pos], &pt1[pos - T0], T0, &cor_max[0] ); - T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + IF( LT_16( sub( pos, T0 ), sub( L_frame, L_SUBFR ) ) ) + { + T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); + } + } + ELSE + { + T0 = mult_r_sat( add_sat( pitch[2], pitch[3] ), 256 ); + } pos_limit = sub( L_frame, L_SUBFR ); j = s_min( 1, s_max( 0, sub( pos, pos_limit ) ) ); Ltmp = L_deposit_l( cor_max[0] ); @@ -725,8 +735,8 @@ void FEC_clas_estim_fx( } /* Do the classification only - - MODE1: when the class is not transmitted in the bitstream - - MODE2: on good frames (classifier is also called for bfi=1) */ + - MODE1: when the class is not transmitted in the bitstream + - MODE2: on good frames (classifier is also called for bfi=1) */ /* update the memory of synthesis for frame class estimation */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 16fefa3bb..c47052d5f 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3584,24 +3584,53 @@ static void matrixTransp1Mul_fx( Word16 chA, chB; Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word64 tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word64 tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 q_tmp_outRe_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word16 q_tmp_outIm_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; + Word64 tmp64_1, tmp64_2; + Word16 tmp16, q_common = 63; + move16(); + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { - outRe_fx[chA][chB] = Madd_32_32( Madd_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), - Are_fx[1][chA], Bre_fx[1][chB] ), - Aim_fx[0][chA], Bim_fx[0][chB] ), - Aim_fx[1][chA], Bim_fx[1][chB] ); + tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bre_fx[0][chB] ), Are_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) + tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bim_fx[0][chB] ), Aim_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) + tmp_outRe_fx[chA][chB] = W_add( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 ) + move64(); + tmp16 = W_norm( tmp_outRe_fx[chA][chB] ); + tmp_outRe_fx[chA][chB] = W_shl( tmp_outRe_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) ) + move64(); + q_tmp_outRe_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) ); + move16(); + q_common = s_min( q_tmp_outRe_fx[chA][chB], q_common ); + + + tmp64_1 = W_mac_32_32( W_mult_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), Are_fx[1][chA], Bim_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) + tmp64_2 = W_mac_32_32( W_mult_32_32( Aim_fx[0][chA], Bre_fx[0][chB] ), Aim_fx[1][chA], Bre_fx[1][chB] ); // Q: add( add( q_A, q_B ), 1 ) + tmp_outIm_fx[chA][chB] = W_sub( tmp64_1, tmp64_2 ); // Q: add( add( q_A, q_B ), 1 ) + move64(); + tmp16 = W_norm( tmp_outIm_fx[chA][chB] ); + tmp_outIm_fx[chA][chB] = W_shl( tmp_outIm_fx[chA][chB], tmp16 ); // Q:add( tmp16, add( add( q_A, q_B ), 1 ) ) + move64(); + q_tmp_outIm_fx[chA][chB] = add( tmp16, add( add( q_A, q_B ), 1 ) ); + move16(); + q_common = s_min( q_tmp_outIm_fx[chA][chB], q_common ); + } + } + FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) + { + FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) + { + outRe_fx[chA][chB] = W_extract_h( W_shl( tmp_outRe_fx[chA][chB], sub( q_common, q_tmp_outRe_fx[chA][chB] ) ) ); move32(); - outIm_fx[chA][chB] = Msub_32_32( Msub_32_32( Madd_32_32( Mpy_32_32( Are_fx[0][chA], Bim_fx[0][chB] ), - Are_fx[1][chA], Bim_fx[1][chB] ), - Aim_fx[0][chA], Bre_fx[0][chB] ), - Aim_fx[1][chA], Bre_fx[1][chB] ); + outIm_fx[chA][chB] = W_extract_h( W_shl( tmp_outIm_fx[chA][chB], sub( q_common, q_tmp_outIm_fx[chA][chB] ) ) ); move32(); } } - *q_out = sub( add( q_A, q_B ), 31 ); - + *q_out = sub( q_common, 32 ); move16(); if ( L_and( is_zero_arr( outRe_fx[0], size ), is_zero_arr( outIm_fx[0], size ) ) ) { diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 06b37ff5a..063c70f66 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1754,7 +1754,7 @@ void protoSignalComputation2_fx( Word32 RealSubtract_fx, ImagSubtract_fx; Word32 left_bb_power_fx, right_bb_power_fx, total_bb_power_fx, lr_bb_power_fx; Word32 left_hi_power_fx, right_hi_power_fx, total_hi_power_fx, lr_hi_power_fx; - Word32 sum_power_fx, Left_power_fx, Right_power_fx; + Word32 sum_power_fx, Left_power_fx, Right_power_fx, Total_power_fx; Word16 q_lr_bb_power, q_lr_hi_power; Word32 lr_total_bb_ratio_fx, lr_total_hi_ratio_fx; Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx; @@ -2120,7 +2120,10 @@ void protoSignalComputation2_fx( #else q_Left_Right_power = add( shl( add( q_cldfb, min_q_shift ), 1 ), sub( head_room, 32 ) ); #endif - + Word16 exp_left_hi_power = 0, exp_right_hi_power = 0, exp_total_hi_power = 0, exp_temppp; + move16(); + move16(); + move16(); FOR( l = 0; l < num_freq_bands; l++ ) { #ifdef FIX_867_CLDFB_NRG_SCALE @@ -2164,19 +2167,30 @@ void protoSignalComputation2_fx( left_bb_power_fx = L_add( left_bb_power_fx, Left_power_fx ); // q_Left_Right_power right_bb_power_fx = L_add( right_bb_power_fx, Right_power_fx ); // q_Left_Right_power // total_bb_power_fx = L_add( total_bb_power_fx, reference_power_fx[l] ); - total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power + total_bb_power_fx = L_add( total_bb_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power #endif - IF( GT_16( l, MASA_HI_FREQ_START_BIN ) ) { - left_hi_power_fx = L_add( left_hi_power_fx, Left_power_fx ); // q_Left_Right_power - right_hi_power_fx = L_add( right_hi_power_fx, Right_power_fx ); // q_Left_Right_power - // total_hi_power_fx = L_add( total_hi_power_fx, reference_power_fx[l] ); -#ifdef FIX_867_CLDFB_NRG_SCALE - total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], sub( head_room, total_shift[qidx] ) ) ) ); // q_Left_Right_power -#else - total_hi_power_fx = L_add( total_hi_power_fx, W_extract_h( W_shl( reference_power_64fx[l], head_room ) ) ); // q_Left_Right_power -#endif + W_tmp1 = W_add( W_mult0_32_32( RealBuffer_fx[0][0][l], RealBuffer_fx[0][0][l] ), W_mult0_32_32( ImagBuffer_fx[0][0][l], ImagBuffer_fx[0][0][l] ) ); + q_shift = W_norm( W_tmp1 ); + Left_power_fx = W_extract_h( W_shl( W_tmp1, q_shift ) ); + exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) ); + + left_hi_power_fx = BASOP_Util_Add_Mant32Exp( left_hi_power_fx, exp_left_hi_power, Left_power_fx, exp_temppp, &exp_left_hi_power ); // exp:exp_left_hi_power + + W_tmp2 = W_add( W_mult0_32_32( RealBuffer_fx[1][0][l], RealBuffer_fx[1][0][l] ), W_mult0_32_32( ImagBuffer_fx[1][0][l], ImagBuffer_fx[1][0][l] ) ); + q_shift = W_norm( W_tmp2 ); + Right_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) ); + exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) ); + + right_hi_power_fx = BASOP_Util_Add_Mant32Exp( right_hi_power_fx, exp_right_hi_power, Right_power_fx, exp_temppp, &exp_right_hi_power ); // exp:exp_right_hi_power + + W_tmp2 = W_add( W_tmp1, W_tmp2 ); + q_shift = W_norm( W_tmp2 ); + Total_power_fx = W_extract_h( W_shl( W_tmp2, q_shift ) ); + exp_temppp = sub( 31, sub( add( shl( q_cldfb, 1 ), q_shift ), 32 ) ); + + total_hi_power_fx = BASOP_Util_Add_Mant32Exp( total_hi_power_fx, exp_total_hi_power, Total_power_fx, exp_temppp, &exp_total_hi_power ); // exp:exp_total_hi_power } IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) @@ -2185,8 +2199,8 @@ void protoSignalComputation2_fx( re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift[0] ) ); // q_cldfb+temp_q_shift #else - re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift - im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift + re_aux = L_shl( Real_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift + im_aux = L_shl( Imag_aux_fx, sub( temp_q_shift, min_q_shift ) ); // q_cldfb+temp_q_shift #endif sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31 @@ -2216,7 +2230,7 @@ void protoSignalComputation2_fx( move32(); } #else - temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 + temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], 31 ) ) ); // 2*(q_cldfb+min_q_shift) -31 IF( LT_16( q_temp, stereo_type_detect->q_total_power ) ) { stereo_type_detect->total_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), sub( stereo_type_detect->q_total_power, q_temp ) ) ); // q_temp @@ -2704,15 +2718,16 @@ void protoSignalComputation2_fx( lr_total_bb_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 #ifdef FIX_867_CLDFB_NRG_SCALE - stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); + stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), exp_left_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); move32(); stereo_type_detect->q_left_hi_power = sub( 31, stereo_type_detect->q_left_hi_power ); move16(); - stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); + + stereo_type_detect->right_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, right_hi_power_fx ), exp_right_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->right_hi_power_fx ), sub( 31, stereo_type_detect->q_right_hi_power ), &stereo_type_detect->q_right_hi_power ); move32(); stereo_type_detect->q_right_hi_power = sub( 31, stereo_type_detect->q_right_hi_power ); move16(); - stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), sub( 31, q_temp_total ), Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); + stereo_type_detect->total_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, total_hi_power_fx ), exp_total_hi_power, Mpy_32_32( b2_fx, stereo_type_detect->total_hi_power_fx ), sub( 31, stereo_type_detect->q_total_hi_power ), &stereo_type_detect->q_total_hi_power ); move32(); #else stereo_type_detect->left_hi_power_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a2_fx, left_hi_power_fx ), sub( 31, q_temp ), Mpy_32_32( b2_fx, stereo_type_detect->left_hi_power_fx ), sub( 31, stereo_type_detect->q_left_hi_power ), &stereo_type_detect->q_left_hi_power ); -- GitLab From 6c05b75d00462181e32686beb85e777c53c5332f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 15 May 2025 17:49:55 +0530 Subject: [PATCH 081/394] Fix for 3GPP issue 1517: SBA Decoder: Differences for binaural rendered signals at 64 kbit/s Link #1517 --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c47052d5f..9ea964bcb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1265,12 +1265,14 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric temp64 = W_add( W_mult0_32_32( tempRe, tempRe ), W_mult0_32_32( tempIm, tempIm ) ); // 2q exp1 = W_norm( temp64 ); temp64 = W_shl( temp64, exp1 ); // 2q + exp1 - subFrameSumEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameSumEne_fx[bin], subFrameTotalEne_e[bin], W_extract_h( temp64 ), sub( exp /* 63 - 2q */, exp1 ) /*31 - (2q + exp1 - 32)*/, &subFrameTotalEne_e[bin] ); + subFrameSumEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameSumEne_fx[bin], subFrameSumEne_e[bin], W_extract_h( temp64 ), sub( exp /* 63 - 2q */, exp1 ) /*31 - (2q + exp1 - 32)*/, &subFrameSumEne_e[bin] ); move32(); } } FOR( bin = 0; bin < nBins; bin++ ) { + subFrameTotalEne_e[bin] = sub( subFrameTotalEne_e[bin], 1 ); + move16(); temp = L_shl_sat( subFrameTotalEne_fx[bin], sub( subFrameTotalEne_e[bin], subFrameSumEne_e[bin] ) ); // subFrameSumEne_e[bin] IF( GT_32( subFrameSumEne_fx[bin], temp ) ) { -- GitLab From 15b9ec52fb8fdfa82c596a8ac8764ef3bf86c44b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 19 May 2025 11:35:14 +0530 Subject: [PATCH 082/394] Removal of unused float functions and replacing C datatypes with Basop Datatypes --- lib_com/bitstream.c | 66 ++--- lib_com/core_com_config.c | 6 +- lib_com/ivas_cnst.h | 8 +- lib_com/longarith.c | 4 +- lib_com/prot_fx.h | 463 +++++++++++++------------------- lib_com/tns_base.c | 82 +----- lib_com/tools.c | 195 +++----------- lib_com/tools_fx.c | 14 +- lib_dec/dec_acelp_tcx_main_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 3 - lib_enc/evs_enc_fx.c | 2 +- lib_enc/prot_fx_enc.h | 1 - lib_enc/rom_enc.h | 1 - lib_rend/ivas_rom_rend.h | 4 - lib_rend/ivas_rom_rend_fx.c | 36 --- 15 files changed, 290 insertions(+), 597 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index d8d4563ed..385000139 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -100,7 +100,7 @@ static Word16 rate2AMRWB_IOmode( *-------------------------------------------------------------------*/ Word16 rate2EVSmode_float( const Word32 brate, /* i : bitrate */ - int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ ) { if ( is_amr_wb != NULL ) @@ -575,8 +575,8 @@ Word16 get_ivas_max_num_indices_fx( *-----------------------------------------------------------------------*/ /*! r: maximum number of indices */ -int16_t get_BWE_max_num_indices( - const int32_t extl_brate /* i : extensiona layer bitrate */ +Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ ) { /* set the maximum number of indices in the BWE */ @@ -787,10 +787,10 @@ Word16 get_ivas_max_num_indices_metadata_fx( void move_indices( INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const int16_t nb_indices /* i : number of moved indices */ + const Word16 nb_indices /* i : number of moved indices */ ) { - int16_t i; + Word16 i; if ( new_ind_list < old_ind_list ) { @@ -1092,14 +1092,14 @@ ivas_error push_next_bits( *-------------------------------------------------------------------*/ /*! r: result: index of the indice in the list, -1 if not found */ -int16_t find_indice( +Word16 find_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const int16_t id, /* i : ID of the indice */ - uint16_t *value, /* o : value of the quantized indice */ - int16_t *nb_bits /* o : number of bits used to quantize the indice */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ ) { - int16_t i; + Word16 i; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) { @@ -1122,12 +1122,12 @@ int16_t find_indice( *-------------------------------------------------------------------*/ /*! r: number of deleted indices */ -uint16_t delete_indice( +UWord16 delete_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const int16_t id /* i : ID of the indice */ + const Word16 id /* i : ID of the indice */ ) { - int16_t i, j; + Word16 i, j; j = 0; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) @@ -1168,14 +1168,14 @@ uint16_t delete_indice( *-------------------------------------------------------------------*/ /*! r: value of the indice */ -uint16_t get_next_indice( +UWord16 get_next_indice( Decoder_State *st, /* i/o: decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ) { - uint16_t value; - int16_t i; - int32_t nbits_total; + UWord16 value; + Word16 i; + Word32 nbits_total; assert( nb_bits <= 16 ); @@ -1207,11 +1207,11 @@ uint16_t get_next_indice( *-------------------------------------------------------------------*/ /*! r: value of the indice */ -uint16_t get_next_indice_1( +UWord16 get_next_indice_1( Decoder_State *st /* i/o: decoder state structure */ ) { - int32_t nbits_total; + Word32 nbits_total; nbits_total = st->total_brate / FRAMES_PER_SEC; /* detect corrupted bitstream */ if ( ( st->next_bit_pos + 1 > nbits_total && st->codec_mode == MODE1 ) || @@ -1233,7 +1233,7 @@ uint16_t get_next_indice_1( void get_next_indice_tmp( Decoder_State *st, /* o : decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ) { /* update the position in the bitstream */ @@ -1249,15 +1249,15 @@ void get_next_indice_tmp( *-------------------------------------------------------------------*/ /*! r: value of the indice */ -uint16_t get_indice( +UWord16 get_indice( Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos, /* i : absolute position in the bitstream (update after the read) */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 pos, /* i : absolute position in the bitstream (update after the read) */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ) { - uint16_t value; - int16_t i; - int32_t nbits_total; + UWord16 value; + Word16 i; + Word32 nbits_total; assert( nb_bits <= 16 ); @@ -1584,9 +1584,9 @@ ivas_error write_indices_ivas_fx( *-------------------------------------------------------------------*/ static void decoder_selectCodec( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t total_brate, /* i : total bitrate */ - const int16_t bit0 /* i : first bit */ + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 bit0 /* i : first bit */ ) { /* set the AMR-WB IO flag */ @@ -1724,7 +1724,7 @@ void ivas_set_bitstream_pointers( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - int16_t k, num_bits; + Word16 k, num_bits; Decoder_State **sts; num_bits = 0; @@ -1734,7 +1734,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hSCE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += (int16_t) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += (Word16) ( st_ivas->hSCE[k]->element_brate / FRAMES_PER_SEC ); } /* set bitstream pointers for CPEs */ @@ -1742,7 +1742,7 @@ void ivas_set_bitstream_pointers( { sts = st_ivas->hCPE[k]->hCoreCoder; sts[0]->bit_stream = st_ivas->bit_stream + num_bits; - num_bits += (int16_t) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); + num_bits += (Word16) ( st_ivas->hCPE[k]->element_brate / FRAMES_PER_SEC ); } return; diff --git a/lib_com/core_com_config.c b/lib_com/core_com_config.c index f75f28a18..152870be7 100644 --- a/lib_com/core_com_config.c +++ b/lib_com/core_com_config.c @@ -492,12 +492,12 @@ Word16 sr2fscale_fx( return extract_l( Mpy_32_16_1( sr_core, FSCALE_DENOM_BY_12800_Q15 ) ); /*Q0*/ } -int16_t sr2fscale( - const int32_t sr_core /* i : internal sampling rate */ +Word16 sr2fscale( + const Word32 sr_core /* i : internal sampling rate */ ) { - return (int16_t) ( ( FSCALE_DENOM * sr_core ) / 12800 ); + return (Word16) ( ( FSCALE_DENOM * sr_core ) / 12800 ); } Word32 getCoreSamplerateMode2( diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 9243b3f50..097ba1789 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -509,8 +509,8 @@ enum #define STEREO_DFT32MS_N_NS FRAME_SIZE_NS /* 20 ms */ #define STEREO_DFT32MS_OVL_NS 3125000L /* 3.125ms - Overlap for the outer edges of windows on decoder */ #define STEREO_DFT32MS_OVL2_NS 9375000L /* 9.375ms - Overlap for the inner edges of windows on decoder */ -#define STEREO_DFT32MS_WIN_CENTER_NS ( int32_t )( ( FRAME_SIZE_NS + STEREO_DFT32MS_OVL_NS ) * 0.5f ) /* 11.5625ms - mid point of the two windows wrt the left edge of overlap */ -#define STEREO_DFT32MS_ZP_NS ( int32_t )( 0.5f * ( STEREO_DFT32MS_N_NS - STEREO_DFT32MS_WIN_CENTER_NS - ( STEREO_DFT32MS_OVL2_NS * 0.5f ) ) ) /* 2 sided zp calculated such that window size is satisfied */ +#define STEREO_DFT32MS_WIN_CENTER_NS ( Word32 )( ( FRAME_SIZE_NS + STEREO_DFT32MS_OVL_NS ) * 0.5f ) /* 11.5625ms - mid point of the two windows wrt the left edge of overlap */ +#define STEREO_DFT32MS_ZP_NS ( Word32 )( 0.5f * ( STEREO_DFT32MS_N_NS - STEREO_DFT32MS_WIN_CENTER_NS - ( STEREO_DFT32MS_OVL2_NS * 0.5f ) ) ) /* 2 sided zp calculated such that window size is satisfied */ #define STEREO_DFT32MS_OVL_MAX NS2SA( 48000, STEREO_DFT32MS_OVL_NS ) #define STEREO_DFT32MS_OVL2_MAX NS2SA( 48000, STEREO_DFT32MS_OVL2_NS ) @@ -799,7 +799,7 @@ enum fea_names #define L_DEC_MEM_LEN_ICA L_NCSHIFTMAX + ( N_MAX_SHIFT_CHANGE + 1 ) + SINC_ORDER1 / INTERP_FACTOR1 #define L_FRAME_DS NS2SA( CORR_INTER_FS, FRAME_SIZE_NS ) #define L_XCORRMEM_DS NS2SA( CORR_INTER_FS, 2 * ( ACELP_LOOK_NS ) ) -#define L_NCSHIFT_DS ( int16_t )( ( ( int32_t )(CORR_INTER_FS) *L_NCSHIFTMAX ) / 48000L ) +#define L_NCSHIFT_DS ( Word16 )( ( ( Word32 )(CORR_INTER_FS) *L_NCSHIFTMAX ) / 48000L ) #define L_SAMPLES_LA_NS 625000L #define L_MEM_RECALC_TBE_16K NS2SA( 16000, L_MEM_RECALC_TBE_NS ) @@ -1446,7 +1446,7 @@ typedef struct { typedef struct { Word32 value[81]; - unsigned short length[81]; + UWord16 length[81]; } HUFF_ELEMENTS; typedef struct { diff --git a/lib_com/longarith.c b/lib_com/longarith.c index 72a763de3..c5ace652c 100644 --- a/lib_com/longarith.c +++ b/lib_com/longarith.c @@ -64,14 +64,14 @@ void longadd( assert( lena >= lenb ); for ( h = 0; h < lenb; h++ ) { - carry += ( (uint32_t) a[h] ) + ( (uint32_t) b[h] ); + carry += ( (UWord32) a[h] ) + ( (UWord32) b[h] ); a[h] = (UWord16) carry; carry = carry >> 16; } for ( ; h < lena; h++ ) { - carry = ( (uint32_t) a[h] ) + carry; + carry = ( (UWord32) a[h] ) + carry; a[h] = (UWord16) carry; carry = carry >> 16; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 85ece0cab..f833640e0 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -72,9 +72,6 @@ #define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) #endif -#define log_base_2( x ) ( (double) log( (double) ( x ) ) * 1.4426950408889634074f ) -#define round_f( x ) ( ( ( x ) > 0 ) ? (int32_t) ( ( x ) + 0.5f ) : ( -(int32_t) ( ( -x ) + 0.5f ) ) ) - #ifndef ABSVAL #define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) #endif @@ -1576,19 +1573,19 @@ Word16 gsc_gainQ_fx( ); Word16 gsc_gainQ_ivas_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ + BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ const Word16 y_gain4[], /* i : Energy per band */ // Q12 Word16 y_gainQ[], /* o : quantized energy per band */ // Q12 - const int32_t core_brate, /* i : Core rate */ - const int16_t coder_type, /* i : coding type */ - const int16_t bwidth, /* i : input signal bandwidth */ - const int16_t L_frame, /* i : frame length */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int32_t core_brate_inp /* i : true core bitrate */ + const Word32 core_brate, /* i : Core rate */ + const Word16 coder_type, /* i : coding type */ + const Word16 bwidth, /* i : input signal bandwidth */ + const Word16 L_frame, /* i : frame length */ + const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag */ + const Word32 core_brate_inp /* i : true core bitrate */ ); // frame_ener.c @@ -1779,7 +1776,7 @@ void Ener_per_band_comp_ivas_fx( const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag, /* i : flag of highest band */ - const int16_t L_frame /* i : frame length */ + const Word16 L_frame /* i : frame length */ ); void Ener_per_band_comp_ivas_fx_2( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ @@ -2633,7 +2630,7 @@ void Interpolate_allpass_steep_fx( void Interpolate_allpass_steep_fx32( const Word32 *in_fx, /* i : input array of size N */ Word32 *mem_fx, /* i/o: memory */ - const int16_t N, /* i : number of input samples */ + const Word16 N, /* i : number of input samples */ Word32 *out_fx /* o : output array of size 2*N */ ); @@ -2647,7 +2644,7 @@ void interpolate_3_over_2_allpass_fx( void interpolate_3_over_2_allpass_fx32( const Word32 *input, /* i : input signal Qx */ - const int16_t len, /* i : number of input samples */ + const Word16 len, /* i : number of input samples */ Word32 *out, /* o : output signal */ Word32 *mem /* i/o: memory */ ); @@ -2931,16 +2928,16 @@ void tbe_celp_exc( ); void tbe_celp_exc_ivas( - const int16_t element_mode, /* i : element mode */ - const int16_t idchan, /* i : channel ID */ - const Word16 L_frame_fx, /* i : Frame lenght */ - const int16_t L_subfr, /* i : subframe length */ - const Word16 i_subfr_fx, /* i : sub frame */ - const Word16 T0_fx, /* i : Integer pitch */ - const Word16 T0_frac_fx, /* i : Fractional part of the pitch */ - Word16 *error_fx, /* i/o: Error */ - Word16 *bwe_exc_fx, /* i/o: bandwitdh extension signal */ - const int16_t tdm_LRTD_flag /* i : LRTD stereo mode flag */ + const Word16 element_mode, /* i : element mode */ + const Word16 idchan, /* i : channel ID */ + const Word16 L_frame_fx, /* i : Frame lenght */ + const Word16 L_subfr, /* i : subframe length */ + const Word16 i_subfr_fx, /* i : sub frame */ + const Word16 T0_fx, /* i : Integer pitch */ + const Word16 T0_frac_fx, /* i : Fractional part of the pitch */ + Word16 *error_fx, /* i/o: Error */ + Word16 *bwe_exc_fx, /* i/o: bandwitdh extension signal */ + const Word16 tdm_LRTD_flag /* i : LRTD stereo mode flag */ ); void flip_and_downmix_generic_fx( @@ -3159,8 +3156,8 @@ void GenSHBSynth_fx32( Word32 *shb_syn_speech_32k, /* o : output highband component */ Word32 Hilbert_Mem[], /* i/o: memory */ Word32 state_lsyn_filt_shb_local[], /* i/o: memory */ - const int16_t L_frame, /* i : ACELP frame length */ - int16_t *syn_dm_phase ); + const Word16 L_frame, /* i : ACELP frame length */ + Word16 *syn_dm_phase ); void ScaleShapedSHB_fx( const Word16 length, /* i : SHB overlap length */ @@ -3245,7 +3242,7 @@ void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_ls #ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic void elliptic_bpf_48k_generic_fx( #ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 - const int16_t element_mode, + const Word16 element_mode, #endif Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ @@ -3280,7 +3277,7 @@ void synthesise_fb_high_band_fx( Word16 Qout #ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , - int16_t element_mode + Word16 element_mode #endif ); @@ -3747,8 +3744,8 @@ void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 void *SetTnsEnabledSingleFilter( void *p, const Word16 index, const Word16 value ); -void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); -void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); /*tns_base.h*/ /** Reset TNS data. @@ -4113,8 +4110,8 @@ void cng_params_upd_ivas_fx( const Word16 element_mode, /* i : Element mode */ const Word16 bwidth /* i : Audio bandwidth */ ); -int16_t get_cng_mode( - const int32_t last_active_brate /* i : last active bitrate */ +Word16 get_cng_mode( + const Word32 last_active_brate /* i : last active bitrate */ ); // core_com_config.c @@ -4301,12 +4298,12 @@ void lpc2mdct( void lpc2mdct_2( Word16 *lpcCoeffs, - const int16_t lpcOrder, + const Word16 lpcOrder, Word16 mdct_gains_fx[], Word16 mdct_gains_e[], Word16 mdct_inv_gains_fx[], Word16 mdct_inv_gains_e[], - const int16_t length ); + const Word16 length ); void mdct_shaping( Word32 x[], @@ -4941,25 +4938,25 @@ void cb_shape_fx( // longarith.c void longadd( - uint16_t a[], /* i/o: vector of the length lena */ - const uint16_t b[], /* i/o: vector of the length lenb */ - const int16_t lena, /* i/o: length of vector a[] */ - const int16_t lenb /* i/o: length of vector b[] */ + UWord16 a[], /* i/o: vector of the length lena */ + const UWord16 b[], /* i/o: vector of the length lenb */ + const Word16 lena, /* i/o: length of vector a[] */ + const Word16 lenb /* i/o: length of vector b[] */ ); void longshiftright( - uint16_t a[], /* i : vector of the length lena */ - const int16_t b, /* i : number of bit positions to shift right */ - uint16_t d[], /* o : vector of the length lend */ - int16_t lena, /* i : length of vector a[] */ - const int16_t lend /* i : length of vector d[] */ + UWord16 a[], /* i : vector of the length lena */ + const Word16 b, /* i : number of bit positions to shift right */ + UWord16 d[], /* o : vector of the length lend */ + Word16 lena, /* i : length of vector a[] */ + const Word16 lend /* i : length of vector d[] */ ); void longshiftleft( - const uint16_t a[], /* i : vector of the length len */ - const int16_t b, /* i : number of bit positions to shift left */ - uint16_t d[], /* o : vector of the length len */ - const int16_t len /* i : length of vector a[] and d[] */ + const UWord16 a[], /* i : vector of the length len */ + const Word16 b, /* i : number of bit positions to shift left */ + UWord16 d[], /* o : vector of the length len */ + const Word16 len /* i : length of vector a[] and d[] */ ); void longshr( @@ -5637,7 +5634,7 @@ void enhancer_fx( void enhancer_ivas_fx( const Word16 codec_mode, /* i : flag indicating Codec Mode */ const Word32 core_brate, /* i : decoder bitrate */ - const int16_t cbk_index, /* i : */ + const Word16 cbk_index, /* i : */ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ const Word16 coder_type, /* i : coder type */ const Word16 i_subfr, /* i : subframe number */ @@ -6398,11 +6395,11 @@ void ivas_RefineTonalComponents_fx( const PsychoacousticParameters *psychParamsCurrent ); ivas_error PsychoacousticParameters_Init( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t nBins, /* i : Number of bins (spectral lines) */ - const int8_t nBands, /* i : Number of spectrum subbands */ - const int16_t isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ - const int16_t isWarped, /* i : Flag indicating if the scale is linear or warped */ + const Word32 sr_core, /* i : sampling rate of core-coder */ + const Word16 nBins, /* i : Number of bins (spectral lines) */ + const Word8 nBands, /* i : Number of spectrum subbands */ + const Word16 isTCX20, /* i : Flag indicating if the subband division is for TCX20 or TCX10 */ + const Word16 isWarped, /* i : Flag indicating if the scale is linear or warped */ PsychoacousticParameters *pPsychParams ); // TonalIMDCTconcealment_fx.c @@ -8292,17 +8289,17 @@ Word16 FEC_synchro_exc_fx( ); void decod_unvoiced_fx( - Decoder_State *st_fx, /* i/o: decoder static memory */ - const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ - const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ - const int16_t uc_two_stage_flag, /* i : flag indicating two-stage UC */ - const Word16 coder_type, /* Q0 i : coding type */ - Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ - Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ - Word16 *voice_factors_fx, /* Q15 o : voicing factors */ - Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ - Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ - Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ + Decoder_State *st_fx, /* i/o: decoder static memory */ + const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */ + const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */ + const Word16 uc_two_stage_flag, /* i : flag indicating two-stage UC */ + const Word16 coder_type, /* Q0 i : coding type */ + Word16 *tmp_noise_fx, /* Q0 o : long term temporary noise energy */ + Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe*/ + Word16 *voice_factors_fx, /* Q15 o : voicing factors */ + Word16 *exc_fx, /* Q_X o : adapt. excitation exc */ + Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */ + Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */ Word16 *gain_buf ); // gaus_dec_fx.c @@ -8486,10 +8483,10 @@ void mode_switch_decoder_LPD_ivas_fx( // ari_hm_dec.c -int16_t DecodeIndex( +Word16 DecodeIndex( Decoder_State *st, - const int16_t Bandwidth, /* o : NB, 1: (S)WB */ - int16_t *PeriodicityIndex ); + const Word16 Bandwidth, /* o : NB, 1: (S)WB */ + Word16 *PeriodicityIndex ); Word16 DecodeIndex_fx( Decoder_State *st, @@ -8566,7 +8563,7 @@ void IGFSCFDecoderReset( void IGFSCFDecoderDecode( IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data or NULL in case there was no instance created */ Decoder_State *st, /* i/o: pointer to decoder state */ - int16_t *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ + Word16 *sfe, /* o : ptr to an array which will contain the decoded quantized coefficients */ const Word16 igfGridIdx, /* i : igf grid index see declaration of IGF_GRID_IDX for details */ const Word16 indepFlag /* i : if 1 on input the decoder will be forced to reset, if 0 on input the decoder will be forced to encode without a reset */ @@ -8694,11 +8691,11 @@ Word16 DecodeTnsData_ivas_fx( // parametr_bitmapping.c using ivas void GetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nParams, + const Word16 nParams, void const *pParameter, - int16_t **pStream, - int16_t *pnSize, - int16_t *pnBits ); + Word16 **pStream, + Word16 *pnSize, + Word16 *pnBits ); void GetParameters_fx( ParamsBitMap const *paramsBitMap, @@ -8718,10 +8715,10 @@ void EncodeTnsData_ivas_fx( void SetParameters( ParamsBitMap const *paramsBitMap, - const int16_t nParams, + const Word16 nParams, void *pParameter, - const int16_t **pStream, - int16_t *pnSize ); + const Word16 **pStream, + Word16 *pnSize ); void SetParameters_fx( ParamsBitMap const *paramsBitMap, @@ -8732,18 +8729,18 @@ void SetParameters_fx( void WriteToBitstream( ParamsBitMap const *paramsBitMap, - const int16_t nParams, - const int16_t **pStream, - int16_t *pnSize, + const Word16 nParams, + const Word16 **pStream, + Word16 *pnSize, BSTR_ENC_HANDLE hBstr, - int16_t *pnBits ); + Word16 *pnBits ); void ReadFromBitstream( ParamsBitMap const *paramsBitMap, - const int16_t nArrayLength, + const Word16 nArrayLength, Decoder_State *st, - int16_t **pStream, - int16_t *pnSize ); + Word16 **pStream, + Word16 *pnSize ); void ReadFromBitstream_fx( ParamsBitMap const *paramsBitMap, @@ -9302,7 +9299,7 @@ void v_add_fx( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ + const Word16 N /* i : Vector length */ ); void v_shr_16( @@ -9356,10 +9353,10 @@ void configureCldfb_ivas_fx( ); // dec4t64.c void dec_acelp_fast_fx( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - Word16 code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 cdk_index, /* i : codebook index */ + Word16 code[], /* o : algebraic (fixed) codebook excitation */ + const Word16 L_subfr /* i : subframe length */ ); // codec_tcx_common.c void tcx5SpectrumInterleaving_fx( @@ -9397,7 +9394,7 @@ void cldfbAnalysis_ivas_fx( const Word32 *timeIn_fx, /* i : time buffer Qx */ Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ Word32 **imagBuffer_fx, /* o : imag value buffer QX - 5*/ - const int16_t samplesToProcess, /* i : samples to process */ + const Word16 samplesToProcess, /* i : samples to process */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filterbank state */ ); @@ -9416,7 +9413,7 @@ void cldfbSynthesis_ivas_fx( // bass_psfilter.c void addBassPostFilter_ivas_fx( const Word32 *harm_timeIn_fx, - const int16_t samplesToProcess, + const Word16 samplesToProcess, Word32 **rAnalysis_fx, Word32 **iAnalysis_fx, HANDLE_CLDFB_FILTER_BANK cldfb ); @@ -9590,8 +9587,8 @@ void fd_bwe_dec_init_fx( void stereo_dft_dec_open( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t nchan_transport /* i : number of transport channels */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ ); void ivas_bw_switching_pre_proc_fx( @@ -10287,8 +10284,8 @@ void dctT2_N_apply_matrix_fx( ); Word32 sum2_f_32_fx( - const Word32 *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ + const Word32 *vec, /* i : input vector */ + const Word16 lvec, /* i : length of input vector */ Word16 gb ); Word32 sum2_32_fx( @@ -10438,10 +10435,10 @@ void generate_stereo_masking_noise_fx( Word16 Q_syn, Decoder_State *st, /* i/o: decoder state structure */ STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i : TD stereo structure */ - const int16_t flag_sec_CNA, /* i : CNA flag for secondary channel */ - const int16_t fadeOut, /* i : only fade out of previous state */ + const Word16 flag_sec_CNA, /* i : CNA flag for secondary channel */ + const Word16 fadeOut, /* i : only fade out of previous state */ STEREO_CNG_DEC_HANDLE hStereoCng, /* i : Stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ + const Word16 nchan_out /* i : number of output channels */ ); void SynthesisSTFT_fx( @@ -10449,10 +10446,10 @@ void SynthesisSTFT_fx( Word32 *timeDomainOutput, Word32 *olapBuffer, const Word16 *olapWin, - const int16_t tcx_transition, + const Word16 tcx_transition, HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t element_mode, /* i : element mode */ - const int16_t nchan_out /* i : number of output channels */ + const Word16 element_mode, /* i : element mode */ + const Word16 nchan_out /* i : number of output channels */ ); void FdCng_decodeSID_ivas_fx( @@ -10834,7 +10831,7 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx( const Word16 st1_syn_vec_e, /* i : exp for IDCT24 synthesis vectors */ const Word32 *u_fx, /* i : target signal */ const Word16 u_e, /* i : exp for target signal */ - const int16_t maxC_st1, /* i : number of candidates in stage1 */ + const Word16 maxC_st1, /* i : number of candidates in stage1 */ Word32 *dist_ptr_fx, /* i/o: updated MSE vector for stage1 */ Word16 *dist_ptr_e /* i/o: exp for updated MSE vector for stage1 */ ); @@ -10907,69 +10904,42 @@ void WriteToBitstream_ivas_fx( * MODE1 prototypes *----------------------------------------------------------------------------------*/ -/*! r: inverse square root of input value */ -float inv_sqrt( - const float x /* i : input value */ -); - /*! r: output random value */ -int16_t own_random( - int16_t *seed /* i/o: random seed */ -); - -/*! r: sign of x (+1/-1) */ -float sign( - const float x /* i : input value of x */ +Word16 own_random( + Word16 *seed /* i/o: random seed */ ); -/*! r: logarithm2 of x */ -float log2_f( - const float x /* i : input value of x */ -); - -int16_t norm_ul_float( - uint32_t UL_var1 ); +Word16 norm_ul_float( + UWord32 UL_var1 ); /*! r: sum of all vector elements */ -int16_t sum_s( - const int16_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ +Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ ); /*! r: sum of all vector elements */ -int32_t sum_l( - const int32_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: sum of all squared vector elements */ -float sum2_f( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ +Word32 sum_l( + const Word32 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ ); void set_c( - int8_t y[], /* i/o: Vector to set */ - const int8_t a, /* i : Value to set the vector to */ - const int32_t N /* i : Length of the vector */ + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ ); void set_s( - int16_t y[], /* i/o: Vector to set */ - const int16_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Lenght of the vector */ ); void set_l( - int32_t y[], /* i/o: Vector to set */ - const int32_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Length of the vector */ -); - -void set_f( - float y[], /* i/o: Vector to set */ - const float a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ ); void set_zero_fx( @@ -10986,52 +10956,26 @@ void set16_zero_fx( ); void set_zero( - float *vec, /* o : input vector */ - const int16_t lvec /* i : length of the vector */ + float *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ ); void mvr2r( const float x[], /* i : input vector */ float y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const Word16 n /* i : vector size */ ); void mvs2s( - const int16_t x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -uint32_t mvr2s( - const float x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -void mvs2r( - const int16_t x[], /* i : input vector */ - float y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ ); void mvl2l( - const int32_t x[], /* i : input vector */ - int32_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - - -/*! r: index of the maximum value in the input vector */ -int16_t maximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ -); -/*! r: index of the maximum value in the input vector */ -int16_t maximumAbs( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *max_val /* o : maximum value in the input vector */ + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ ); Word16 maximumAbs_l( @@ -11041,63 +10985,22 @@ Word16 maximumAbs_l( ); /*! r: index of the minimum value in the input vector */ -int16_t minimum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *min_val /* o : minimum value in the input vector */ -); - -/*! r: index of the minimum value in the input vector */ -int16_t minimum_s( - const int16_t *vec, /* i : Input vector */ - const int16_t lvec, /* i : Vector length */ - int16_t *min_val /* o : minimum value in the input vector */ -); - -/*! r: return index with max energy value in vector */ -int16_t emaximum( - const float *vec, /* i : input vector */ - const int16_t lvec, /* i : length of input vector */ - float *ener_max /* o : maximum energy value */ -); - -/*! r: vector mean */ -float mean( - const float *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ -); - -/*! r: dot product of x[] and y[] */ -float dotp( - const float x[], /* i : vector x[] */ - const float y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ -); - -void v_add( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 + vector 2 */ - const int16_t N /* i : Vector length */ -); - -void v_sub( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 - vector 2 */ - const int16_t N /* i : Vector length */ +Word16 minimum_s( + const Word16 *vec, /* i : Input vector */ + const Word16 lvec, /* i : Vector length */ + Word16 *min_val /* o : minimum value in the input vector */ ); /*! r: dequanzited gain */ float usdequant( - const int16_t idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ + const Word16 idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ ); void sort( - uint16_t *x, /* i/o: Vector to be sorted */ - uint16_t len /* i/o: vector length */ + UWord16 *x, /* i/o: Vector to be sorted */ + UWord16 len /* i/o: vector length */ ); void sort_l( @@ -11108,9 +11011,9 @@ void sort_l( ivas_error push_indice( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - int16_t id, /* i : ID of the indice */ - uint16_t value, /* i : value of the quantized indice */ - int16_t nb_bits /* i : number of bits used to quantize the indice */ + Word16 id, /* i : ID of the indice */ + UWord16 value, /* i : value of the quantized indice */ + Word16 nb_bits /* i : number of bits used to quantize the indice */ ); ivas_error push_next_indice( @@ -11132,8 +11035,8 @@ Word16 get_ivas_max_num_indices_fx( ); /*! r: maximum number of indices */ -int16_t get_BWE_max_num_indices( - const int32_t extl_brate /* i : extensiona layer bitrate */ +Word16 get_BWE_max_num_indices( + const Word32 extl_brate /* i : extensiona layer bitrate */ ); /*! r: maximum number of indices */ @@ -11142,9 +11045,9 @@ Word16 get_ivas_max_num_indices_metadata_fx( const Word32 ivas_total_brate /* i : IVAS total bitrate */ ); ivas_error ind_list_realloc( - INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ - const int16_t max_num_indices, /* i : new maximum number of allowed indices in the list */ - Encoder_Struct *st_ivas /* i : IVAS encoder structure */ + INDICE_HANDLE old_ind_list, /* i : pointer to the beginning of the old buffer of indices */ + const Word16 max_num_indices, /* i : new maximum number of allowed indices in the list */ + Encoder_Struct *st_ivas /* i : IVAS encoder structure */ ); ivas_error check_ind_list_limits( @@ -11154,44 +11057,44 @@ ivas_error check_ind_list_limits( void move_indices( INDICE_HANDLE old_ind_list, /* i/o: old location of indices */ INDICE_HANDLE new_ind_list, /* i/o: new location of indices */ - const int16_t nb_indices /* i : number of moved indices */ + const Word16 nb_indices /* i : number of moved indices */ ); /*! r: index of the indice in the list, -1 if not found */ -int16_t find_indice( +Word16 find_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ - const int16_t id, /* i : ID of the indice */ - uint16_t *value, /* o : value of the quantized indice */ - int16_t *nb_bits /* o : number of bits used to quantize the indice */ + const Word16 id, /* i : ID of the indice */ + UWord16 *value, /* o : value of the quantized indice */ + Word16 *nb_bits /* o : number of bits used to quantize the indice */ ); /*! r: number of deleted indices */ -uint16_t delete_indice( +UWord16 delete_indice( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t id /* i : ID of the indice */ + const Word16 id /* i : ID of the indice */ ); /*! r: value of the indice */ -uint16_t get_next_indice( +UWord16 get_next_indice( Decoder_State *st, /* i/o: decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); /*! r: value of the indice */ -uint16_t get_next_indice_1( +UWord16 get_next_indice_1( Decoder_State *st /* i/o: decoder state structure */ ); void get_next_indice_tmp( Decoder_State *st, /* o : decoder state structure */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); /*! r: value of the indice */ -uint16_t get_indice( +UWord16 get_indice( Decoder_State *st, /* i/o: decoder state structure */ - int16_t pos, /* i : absolute position in the bitstream */ - int16_t nb_bits /* i : number of bits that were used to quantize the indice */ + Word16 pos, /* i : absolute position in the bitstream */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); void reset_indices_dec( @@ -11200,7 +11103,7 @@ void reset_indices_dec( Word16 rate2EVSmode_float( const Word32 brate, /* i : bitrate */ - int16_t *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ + Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ ); @@ -11227,13 +11130,13 @@ void mdct_switching_dec_fx( Decoder_State *st /* i/o: decoder state structure */ ); -int16_t print_disclaimer( +Word16 print_disclaimer( FILE *fPtr ); void fft_rel( - float x[], /* i/o: input/output vector */ - const int16_t n, /* i : vector length */ - const int16_t m /* i : log2 of vector length */ + float x[], /* i/o: input/output vector */ + const Word16 n, /* i : vector length */ + const Word16 m /* i : log2 of vector length */ ); void preemph_ivas_fx( @@ -11246,8 +11149,8 @@ void preemph_ivas_fx( void create_offset( UWord32 *offset_scale1, UWord32 *offset_scale2, - const int16_t mode, - const int16_t prediction_flag ); + const Word16 mode, + const Word16 prediction_flag ); void BASOP_cfft_ivas( Word32 *re, /* i/o: real part */ @@ -11492,31 +11395,31 @@ void writeTCXWindowing_fx( ); void writeLPCparam( - Encoder_State *st, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - const int16_t param_lpc[], /* i : LPC parameters to write */ - const int16_t bits_param_lpc[], /* i : bits per LPC parameter */ - const int16_t no_param_lpc, /* i : number of LPC parameters */ - int16_t *nbits_lpc /* o : LPC bits written */ + Encoder_State *st, /* i/o: encoder state structure */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + const Word16 param_lpc[], /* i : LPC parameters to write */ + const Word16 bits_param_lpc[], /* i : bits per LPC parameter */ + const Word16 no_param_lpc, /* i : number of LPC parameters */ + Word16 *nbits_lpc /* o : LPC bits written */ ); -void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ); -void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ); -void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ); -void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ); +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ); +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ); +void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ); +void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ); -int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); -int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); +Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); -int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ); +Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ); -int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ); -int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ); +Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ); +Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ); void ResetTnsData_flt( STnsData *pTnsData ); @@ -11569,7 +11472,7 @@ void analysisCldfbEncoder_ivas_fx( ivas_error openCldfb_ivas( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle */ CLDFB_TYPE type, /* i : analysis or synthesis */ - const int32_t sampling_rate, /* i : sampling rate */ + const Word32 sampling_rate, /* i : sampling rate */ CLDFB_PROTOTYPE prototype /* i : CLDFB version (1.25ms/5ms delay) */ ); diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 82de45023..5e18430be 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -809,43 +809,19 @@ static Word16 DecodeUsingTable( Decoder_State *st, Word16 *pValue /*Q0*/, const /* TNS filter coefficients */ -int16_t DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeSWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); return DecodeUsingTable( st, pValue, codesTnsCoeffSWBTCX20[index], nTnsCoeffCodes ); } -// int16_t GetSWBTCX10TnsFilterCoeffBits_flt( const int16_t value, const int16_t index ) -//{ -// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); -// return GetBitsFromTable( value, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes ); -// } - -// int16_t EncodeSWBTCX10TnsFilterCoeff_flt( const int16_t value, const int16_t index ) -//{ -// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); -// return EncodeUsingTable( value, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes ); -// } - -int16_t DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeSWBTCX10TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); return DecodeUsingTable( st, pValue, codesTnsCoeffSWBTCX10[index], nTnsCoeffCodes ); } -// int16_t GetWBTCX20TnsFilterCoeffBits_flt( const int16_t value, const int16_t index ) -//{ -// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); -// return GetBitsFromTable( value, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes ); -// } - -// int16_t EncodeWBTCX20TnsFilterCoeff_flt( const int16_t value, const int16_t index ) -//{ -// assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); -// return EncodeUsingTable( value, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes ); -// } - -int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { assert( ( index >= 0 ) && ( index < nTnsCoeffTables ) ); return DecodeUsingTable( st, pValue, codesTnsCoeffWBTCX20[index], nTnsCoeffCodes ); @@ -854,49 +830,25 @@ int16_t DecodeWBTCX20TnsFilterCoeff_flt( Decoder_State *st, const int16_t index, /* TNS filter order */ -// void const *GetTnsFilterOrder_flt( void const *p, const int16_t index, int16_t *pValue ) -//{ -// *pValue = ( (STnsFilter const *) p )[index].order; -// return ( (STnsFilter const *) p )[index].coefIndex; -// } - -// void *SetTnsFilterOrder_flt( void *p, const int16_t index, const int16_t value ) -//{ -// ( (STnsFilter *) p )[index].order = value; -// return ( (STnsFilter *) p )[index].coefIndex; -// } - -// int16_t GetTnsFilterOrderBitsSWBTCX20_flt( const int16_t value, const int16_t index ) -//{ -// (void) index; -// return GetBitsFromTable( value - 1, codesTnsOrderTCX20, nTnsOrderCodes ); -// } - -// int16_t EncodeTnsFilterOrderSWBTCX20_flt( const int16_t value, const int16_t index ) -//{ -// (void) index; -// return EncodeUsingTable( value - 1, codesTnsOrderTCX20, nTnsOrderCodes ); -// } - -int16_t DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeTnsFilterOrderSWBTCX20_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { (void) index; return DecodeUsingTable( st, pValue, codesTnsOrderTCX20, nTnsOrderCodes ); } -int16_t GetTnsFilterOrderBitsSWBTCX10_flt( const int16_t value, const int16_t index ) +Word16 GetTnsFilterOrderBitsSWBTCX10_flt( const Word16 value, const Word16 index ) { (void) index; return GetBitsFromTable( value - 1, codesTnsOrderTCX10, nTnsOrderCodes ); } -int16_t EncodeTnsFilterOrderSWBTCX10_flt( const int16_t value, const int16_t index ) +Word16 EncodeTnsFilterOrderSWBTCX10_flt( const Word16 value, const Word16 index ) { (void) index; return EncodeUsingTable( value - 1, codesTnsOrderTCX10, nTnsOrderCodes ); } -int16_t DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeTnsFilterOrderSWBTCX10_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { (void) index; return DecodeUsingTable( st, pValue, codesTnsOrderTCX10, nTnsOrderCodes ); @@ -1105,42 +1057,36 @@ void *SetTnsEnabled( void *p, const Word16 index, const Word16 value ) /* Number of TNS filters */ -void const *GetNumOfTnsFilters_flt( void const *p, const int16_t index, int16_t *pValue ) +void const *GetNumOfTnsFilters_flt( void const *p, const Word16 index, Word16 *pValue ) { - *pValue = (int16_t) abs( ( (STnsData const *) p )[index].nFilters ); + *pValue = (Word16) abs( ( (STnsData const *) p )[index].nFilters ); return ( (STnsData const *) p )[index].filter; } -void *SetNumOfTnsFilters_flt( void *p, const int16_t index, const int16_t value ) +void *SetNumOfTnsFilters_flt( void *p, const Word16 index, const Word16 value ) { - ( (STnsData *) p )[index].nFilters = (int16_t) abs( value ); + ( (STnsData *) p )[index].nFilters = (Word16) abs( value ); return ( (STnsData *) p )[index].filter; } -int16_t DecodeTnsFilterOrder_flt( Decoder_State *st, const int16_t index, int16_t *pValue ) +Word16 DecodeTnsFilterOrder_flt( Decoder_State *st, const Word16 index, Word16 *pValue ) { (void) index; return DecodeUsingTable( st, pValue, codesTnsOrder, nTnsOrderCodes ); } /* TNS on whitened spectra flag */ -void const *GetTnsOnWhite( void const *p, const int16_t index, int16_t *pValue ) +void const *GetTnsOnWhite( void const *p, const Word16 index, Word16 *pValue ) { *pValue = ( (STnsData const *) p )[index].tnsOnWhitenedSpectra > 0 ? 1 : 0; return NULL; } -void *SetTnsOnWhite( void *p, const int16_t index, const int16_t value ) +void *SetTnsOnWhite( void *p, const Word16 index, const Word16 value ) { ( (STnsData *) p )[index].tnsOnWhitenedSpectra = value; return NULL; } -// void const *GetTnsEnabledSingleFilter( void const *p, const int16_t index, int16_t *pValue ) -//{ -// *pValue = ( (STnsData const *) p )[index].nFilters != 0 ? 1 : 0; -// return ( (STnsData const *) p )[index].filter; -// } - void const *GetTnsEnabledSingleFilter( void const *p, const Word16 index, Word16 *pValue ) { move16(); diff --git a/lib_com/tools.c b/lib_com/tools.c index f7303c6f3..9166d16eb 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -47,51 +47,23 @@ *------------------------------------------------------------------*/ /*! r: output random value */ -int16_t own_random( - int16_t *seed /* i/o: random seed */ +Word16 own_random( + Word16 *seed /* i/o: random seed */ ) { - *seed = (int16_t) ( *seed * 31821L + 13849L ); + *seed = (Word16) ( *seed * 31821L + 13849L ); return ( *seed ); } /*--------------------------------------------------------------------- - * sign() + * norm_ul_float() * *---------------------------------------------------------------------*/ -/*! r: sign of x (+1/-1) */ -float sign( - const float x /* i : input value of x */ -) +Word16 norm_ul_float( UWord32 UL_var1 ) { - if ( x < 0.0f ) - { - return -1.0f; - } - else - { - return 1.0f; - } -} - -/*--------------------------------------------------------------------- - * log2_f() - * - *---------------------------------------------------------------------*/ - -/*! r: logarithm2 of x */ -float log2_f( - const float x /* i : input value of x */ -) -{ - return (float) ( log( x ) / log( 2.0f ) ); -} - -int16_t norm_ul_float( uint32_t UL_var1 ) -{ - int16_t var_out; + Word16 var_out; if ( UL_var1 == 0 ) { @@ -99,7 +71,7 @@ int16_t norm_ul_float( uint32_t UL_var1 ) } else { - for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ ) + for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ ) { UL_var1 <<= 1; } @@ -118,13 +90,13 @@ int16_t norm_ul_float( uint32_t UL_var1 ) *---------------------------------------------------------------------*/ /*! r: sum of all vector elements */ -int16_t sum_s( - const int16_t *vec, /* i : input vector */ - const int16_t lvec /* i : length of input vector */ +Word16 sum_s( + const Word16 *vec, /* i : input vector */ + const Word16 lvec /* i : length of input vector */ ) { - int16_t i; - int16_t tmp; + Word16 i; + Word16 tmp; tmp = 0; for ( i = 0; i < lvec; i++ ) @@ -182,7 +154,7 @@ Word32 sum2_f_16_gb_fx( const Word16 lvec, /* i : length of input vector */ Word16 gb ) { - int16_t i; + Word16 i; Word32 tmp; tmp = 0; @@ -311,7 +283,6 @@ Word32 sum2_32_fx( /*-------------------------------------------------------------------* * set_c() * set_s() - * set_f() * set_l() * set_d() * @@ -319,12 +290,12 @@ Word32 sum2_32_fx( *-------------------------------------------------------------------*/ void set_c( - int8_t y[], /* i/o: Vector to set */ - const int8_t a, /* i : Value to set the vector to */ - const int32_t N /* i : Length of the vector */ + Word8 y[], /* i/o: Vector to set */ + const Word8 a, /* i : Value to set the vector to */ + const Word32 N /* i : Length of the vector */ ) { - int16_t i; + Word16 i; for ( i = 0; i < N; i++ ) { @@ -336,12 +307,12 @@ void set_c( void set_s( - int16_t y[], /* i/o: Vector to set */ - const int16_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Length of the vector */ + Word16 y[], /* i/o: Vector to set */ + const Word16 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ ) { - int16_t i; + Word16 i; for ( i = 0; i < N; i++ ) { @@ -353,28 +324,12 @@ void set_s( void set_l( - int32_t y[], /* i/o: Vector to set */ - const int32_t a, /* i : Value to set the vector to */ - const int16_t N /* i : Length of the vector */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = a; - } - - return; -} - -void set_f( - float y[], /* i/o: Vector to set */ - const float a, /* i : Value to set the vector to */ - const int16_t N /* i : Lenght of the vector */ + Word32 y[], /* i/o: Vector to set */ + const Word32 a, /* i : Value to set the vector to */ + const Word16 N /* i : Length of the vector */ ) { - int16_t i; + Word16 i; for ( i = 0; i < N; i++ ) { @@ -391,11 +346,11 @@ void set_f( *---------------------------------------------------------------------*/ void set_zero( - float *vec, /* o : input vector */ - const int16_t lvec /* i : length of the vector */ + float *vec, /* o : input vector */ + const Word16 lvec /* i : length of the vector */ ) { - int16_t i; + Word16 i; for ( i = 0; i < lvec; i++ ) { @@ -409,8 +364,6 @@ void set_zero( /*---------------------------------------------------------------------* * mvr2r() * mvs2s() - * mvr2s() - * mvs2r() * mvr2d() * mvd2r() * @@ -420,10 +373,10 @@ void set_zero( void mvr2r( const float x[], /* i : input vector */ float y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const Word16 n /* i : vector size */ ) { - int16_t i; + Word16 i; if ( n <= 0 ) { @@ -450,12 +403,12 @@ void mvr2r( } void mvs2s( - const int16_t x[], /* i : input vector */ - int16_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const Word16 x[], /* i : input vector */ + Word16 y[], /* o : output vector */ + const Word16 n /* i : vector size */ ) { - int16_t i; + Word16 i; if ( n <= 0 ) { @@ -482,12 +435,12 @@ void mvs2s( } void mvl2l( - const int32_t x[], /* i : input vector */ - int32_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ + const Word32 x[], /* i : input vector */ + Word32 y[], /* o : output vector */ + const Word16 n /* i : vector size */ ) { - int16_t i; + Word16 i; if ( n <= 0 ) { @@ -687,32 +640,6 @@ Word16 minimum_l( return ind; } -/*---------------------------------------------------------------------* - * dotp() - * - * Dot product of vector x[] and vector y[] - *---------------------------------------------------------------------*/ - -/*! r: dot product of x[] and y[] */ -float dotp( - const float x[], /* i : vector x[] */ - const float y[], /* i : vector y[] */ - const int16_t n /* i : vector length */ -) -{ - int16_t i; - float suma; - - suma = x[0] * y[0]; - - for ( i = 1; i < n; i++ ) - { - suma += x[i] * y[i]; - } - - return suma; -} - /*---------------------------------------------------------------------* * dotp() * @@ -800,20 +727,6 @@ Word32 dotp_fixed_32( return W_extract_l( suma ); } -/*---------------------------------------------------------------------* - * inv_sqrt() - * - * Find the inverse square root of the input value - *---------------------------------------------------------------------*/ - -/*! r: inverse square root of input value */ -float inv_sqrt( - const float x /* i : input value */ -) -{ - return (float) ( 1.0 / sqrt( x ) ); -} - /*-------------------------------------------------------------------* * v_add_w64() * @@ -839,32 +752,8 @@ void v_add_w64( return; } - -/*-------------------------------------------------------------------* - * v_sub() - * - * Subtraction of two vectors sample by sample - *-------------------------------------------------------------------*/ - -void v_sub( - const float x1[], /* i : Input vector 1 */ - const float x2[], /* i : Input vector 2 */ - float y[], /* o : Output vector that contains vector 1 - vector 2 */ - const int16_t N /* i : Vector length */ -) -{ - int16_t i; - - for ( i = 0; i < N; i++ ) - { - y[i] = x1[i] - x2[i]; - } - - return; -} - /*-------------------------------------------------------------------* - * v_sub() + * v_sub_fixed() * * Subtraction of two vectors sample by sample *-------------------------------------------------------------------*/ @@ -977,9 +866,9 @@ void v_multc_fixed_16_16( *-------------------------------------------------------------------*/ float usdequant( - const int16_t idx, /* i : quantizer index */ - const float qlow, /* i : lowest codebook entry (index 0) */ - const float delta /* i : quantization step */ + const Word16 idx, /* i : quantizer index */ + const float qlow, /* i : lowest codebook entry (index 0) */ + const float delta /* i : quantization step */ ) { float g; diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 14a97a034..77e779efd 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -241,9 +241,9 @@ void fix2f_16( Word16 *var_fix, float *var_flt, Word32 expo ) #undef WMC_TOOL_SKIP -int16_t norm_ul( uint32_t UL_var1 ) +Word16 norm_ul( UWord32 UL_var1 ) { - int16_t var_out; + Word16 var_out; if ( UL_var1 == 0 ) { @@ -251,7 +251,7 @@ int16_t norm_ul( uint32_t UL_var1 ) } else { - for ( var_out = 0; UL_var1 < (uint32_t) 0x80000000U; var_out++ ) + for ( var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++ ) { UL_var1 <<= 1; } @@ -997,7 +997,7 @@ void scale_sig( } /*---------------------------------------------------------------------* - * mean() + * mean_fx() * *---------------------------------------------------------------------*/ Word16 mean_fx( /* o : mean of vector */ @@ -2171,7 +2171,7 @@ Word16 own_random2_fx( Word16 seed ) } /*--------------------------------------------------------------------- - * sign() + * sign_fx() * *---------------------------------------------------------------------*/ @@ -4207,7 +4207,7 @@ Word16 lin_interp_ivas_fx( } /*--------------------------------------------------------------------- - * sign() + * sign_l() * *---------------------------------------------------------------------*/ @@ -4245,7 +4245,7 @@ void v_mult16_fixed( } /*---------------------------------------------------------------------* - * set_zero() + * set_zero_fx() * * Set a vector vec[] of dimension lvec to zero *---------------------------------------------------------------------*/ diff --git a/lib_dec/dec_acelp_tcx_main_fx.c b/lib_dec/dec_acelp_tcx_main_fx.c index 21bf7cf12..eea558914 100644 --- a/lib_dec/dec_acelp_tcx_main_fx.c +++ b/lib_dec/dec_acelp_tcx_main_fx.c @@ -364,7 +364,7 @@ Word16 dec_acelp_tcx_frame_fx( { /* Copy back parameters from previous frame, because there is a high risk they are corrupt * DO concealment with configuration used in previous frame */ - st->m_frame_type = (uint8_t) m_frame_type; + st->m_frame_type = (UWord8) m_frame_type; move16(); st->bwidth = bwidth; move16(); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 6ba21136e..f942a19ff 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -38,7 +38,6 @@ ivas_error acelp_core_enc_fx( Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, const Word16 shift ) { @@ -107,8 +106,6 @@ ivas_error acelp_core_enc_fx( * Initialization *------------------------------------------------------------------*/ - (void) tdm_lsfQ_PCh; - Es_pred_fx = 0; move16(); diff --git a/lib_enc/evs_enc_fx.c b/lib_enc/evs_enc_fx.c index 624ec20fc..8e9a82378 100644 --- a/lib_enc/evs_enc_fx.c +++ b/lib_enc/evs_enc_fx.c @@ -269,7 +269,7 @@ ivas_error evs_enc_fx( IF( EQ_16( st->core, ACELP_CORE ) ) { acelp_core_enc_fx( st, inp, ener, A, Aw, epsP_h, epsP_l, lsp_new, lsp_mid, vad_hover_flag, - attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, NULL, Q_new, shift ); + attack_flag, bwe_exc_extended, voice_factors, old_syn_12k8_16k, pitch_buf, &unbits, NULL, Q_new, shift ); } /*---------------------------------------------------------------------* * HQ core encoding diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 72137bdce..d3528370f 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -61,7 +61,6 @@ ivas_error acelp_core_enc_fx( Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe Q6*/ Word16 *unbits_fx, /* o : number of unused bits Q0*/ STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const float tdm_lsfQ_PCh[M], /* i : Q LSFs for primary channel */ const Word16 Q_new, const Word16 shift diff --git a/lib_enc/rom_enc.h b/lib_enc/rom_enc.h index 35fd3027d..7da1da92a 100644 --- a/lib_enc/rom_enc.h +++ b/lib_enc/rom_enc.h @@ -52,7 +52,6 @@ extern const Word16 W_HIST_S_FX[DTX_HIST_SIZE]; /* CNG & DTX - table for calcula extern const Word16 bwd_start_bin[]; // Q0 extern const Word16 bwd_end_bin[]; // Q0 -extern const float h_fir[]; /* 2nd order fir filter for wsp, decimation by 2 */ extern const Word16 h_fir_fx[]; /* 2nd order fir filter for wsp, decimation by 2 Q15*/ extern const Word16 preemphCompensation_fx[]; // Q11 diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index f62440749..7f9cfb57a 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -121,10 +121,6 @@ extern const Word32 ivas_reverb_default_fc_fx[]; /*Q-16*/ extern const Word32 ivas_reverb_default_RT60_fx[]; /*Q-26*/ extern const Word32 ivas_reverb_default_DSR_fx[]; /*Q-30*/ -extern const float ivas_reverb_default_fc[]; -extern const float ivas_reverb_default_RT60[]; -extern const float ivas_reverb_default_DSR[]; - extern const Word32 release_cnst_table[4][201]; // Q31 /*----------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 4f101582c..d14be4afe 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -561,42 +561,6 @@ const Word32 ivas_reverb_default_DSR_fx[IVAS_REVERB_DEFAULT_N_BANDS] /*Q30*/ = 66, 30, 28 }; -const float ivas_reverb_default_fc[IVAS_REVERB_DEFAULT_N_BANDS] = -{ - 20.0f, 25.0f, 31.5f, 40.0f, - 50.0f, 63.0f, 80.0f, 100.0f, - 125.0f, 160.0f, 200.0f, 250.0f, - 315.0f, 400.0f, 500.0f, 630.0f, - 800.0f, 1000.0f, 1250.0f, 1600.0f, - 2000.0f, 2500.0f, 3150.0f, 4000.0f, - 5000.0f, 6300.0f, 8000.0f, 10000.0f, - 12500.0f, 16000.0f, 20000.0f -}; - -const float ivas_reverb_default_RT60[IVAS_REVERB_DEFAULT_N_BANDS] = -{ - 1.3622f, 1.4486f, 1.3168f, 1.5787f, - 1.4766f, 1.3954f, 1.2889f, 1.3462f, - 1.0759f, 1.0401f, 1.097f, 1.085f, - 1.091f, 1.0404f, 1.0499f, 1.0699f, - 1.1028f, 1.1714f, 1.1027f, 1.0666f, - 1.055f, 1.0553f, 1.0521f, 1.0569f, - 1.0421f, 0.97822f, 0.80487f, 0.75944f, - 0.71945f, 0.61682f, 0.60031f -}; - -const float ivas_reverb_default_DSR[IVAS_REVERB_DEFAULT_N_BANDS] = -{ - 1.8811e-08f, 2.1428e-08f, 1.3972e-08f, 1.51e-08f, - 1.287e-08f, 1.8747e-08f, 2.413e-08f, 3.9927e-08f, - 8.9719e-08f, 1.902e-07f, 3.702e-07f, 6.1341e-07f, - 7.1432e-07f, 6.5331e-07f, 4.6094e-07f, 5.4683e-07f, - 7.0134e-07f, 6.856e-07f, 7.114e-07f, 6.9604e-07f, - 5.2939e-07f, 5.699e-07f, 6.1773e-07f, 5.7488e-07f, - 4.7748e-07f, 2.7213e-07f, 1.3681e-07f, 1.0941e-07f, - 6.2001e-08f, 2.8483e-08f, 2.6267e-08f -}; - const Word32 release_cnst_table[4][201] = // Q31 { { -- GitLab From b69b11e39f8edd19a63de476efb0648647896393 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 20 May 2025 10:23:30 +0200 Subject: [PATCH 083/394] Add missing assignment of Q values of overlap add buffers. --- lib_dec/dec_ace_fx.c | 4 ++++ lib_dec/er_dec_acelp_fx.c | 9 ++++++++- lib_dec/er_dec_tcx_fx.c | 10 ++++++++++ lib_dec/updt_dec_fx.c | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_ace_fx.c b/lib_dec/dec_ace_fx.c index 9c366e3f3..edc429459 100644 --- a/lib_dec/dec_ace_fx.c +++ b/lib_dec/dec_ace_fx.c @@ -690,6 +690,10 @@ void decoder_acelp_fx( E_UTIL_deemph2( st->Q_syn, syn, st->preemph_fac, st->L_frame, &tmp_deemph ); /* tmp_deemph and syn in Q0 starting from here*/ bufferCopyFx( syn + shr( st->L_frame, 1 ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); + move16(); +#endif Copy( syn + sub( st->L_frame, M + 1 ), st->syn, 1 + M ); /*Q0*/ diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index bcbff9b76..18c930269 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1018,6 +1018,10 @@ void con_acelp_fx( Copy( syn, synth, st->L_frame ); bufferCopyFx( syn + sub( st->L_frame, shr( st->L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( Qf_syn, 1 ); + move16(); +#endif /* save last half frame if next frame is TCX */ bufferCopyFx( syn + st->L_frame, hTcxDec->syn_Overl_TDAC, shr( st->L_frame, 1 ), 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); @@ -1057,7 +1061,10 @@ void con_acelp_fx( move16(); } set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_wtda_LB = st->Q_syn; + move16(); +#else hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); #endif diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 48e290217..a1907b44c 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -843,7 +843,15 @@ void con_tcx_fx( lerp( syn + sub( L_frame, shr( L_frame, 1 ) ), hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = Q_syn; + move16(); +#endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hHQ_core->Q_old_wtda = Q_syn; + move16(); +#endif FOR( i = 0; i < W12; i++ ) { @@ -934,7 +942,9 @@ void con_tcx_fx( move16(); /* update memory for low band */ +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ +#endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT hTcxDec->Q_syn_Overl = hTcxDec->Q_syn_OverlFB; diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 81046fb19..d1fe01b42 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -1207,6 +1207,10 @@ void update_decoder_LPD_cng( Copy( hTcxDec->old_synth + st->L_frame, hTcxDec->old_synth, sub( hTcxDec->old_synth_len, st->L_frame ) ); Copy( synth, hTcxDec->old_synth + sub( hTcxDec->old_synth_len, st->L_frame ), st->L_frame ); bufferCopyFx( synth + sub( st->L_frame, ( st->L_frame / 2 ) ), hTcxDec->old_syn_Overl, st->L_frame / 2, 0 /*Qf_syn*/, -1 /*Qf_old_xnq*/, 0, 0 /*Q_old_xnq*/ ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + st->hTcxDec->Q_old_syn_Overl = sub( st->Q_syn, 1 ); + move16(); +#endif hTcxDec->tcxltp_last_gain_unmodified = 0; move16(); -- GitLab From 25546392018d5ba6856a515ce08641b910fb7777 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 20 May 2025 10:54:07 +0200 Subject: [PATCH 084/394] clang format. --- lib_dec/acelp_core_dec_fx.c | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 0ba5d5caf..ef5c04774 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -85,9 +85,9 @@ ivas_error acelp_core_dec_fx( Word16 lsp_mid_fx[M]; /* LSPs in the middle of the frame */ Word16 Aq_fx[NB_SUBFR16k * ( M + 1 )]; /* A(q) quantized for the 4 subframes */ Word16 old_exc2_fx[L_FRAME16k + L_EXC_MEM], *exc2_fx; /* total excitation buffer */ - Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ - Word32 enr_q_fx; /* E information for FER protection */ - Word16 tmp_noise_fx; /* Long term temporary noise energy */ + Word16 mem_tmp_fx[M]; /* temporary synthesis filter memory */ + Word32 enr_q_fx; /* E information for FER protection */ + Word16 tmp_noise_fx; /* Long term temporary noise energy */ Word16 Es_pred_fx; /* predicted scaled innov. energy Q8 */ Word16 FEC_pitch_fx; /* FEC pitch */ Word16 old_bwe_exc_fx[( ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2 )]; /* excitation buffer */ @@ -266,7 +266,7 @@ ivas_error acelp_core_dec_fx( if ( st->hGSCDec != NULL ) { - /* reset the GSC pre echo energy threshold in case of switching */ + /* reset the GSC pre echo energy threshold in case of switching */ st->hGSCDec->Last_frame_ener_fx = MAX_32; move32(); } @@ -1425,15 +1425,15 @@ ivas_error acelp_core_dec_fx( Copy( psyn_fx + sub( st->L_frame, L_EXC_MEM ), st->hWIDec->old_syn2_fx, L_EXC_MEM ); } st->prev_Q_exc_fr = st->Q_exc; - move16(); + move16(); st->prev_Q_syn_fr = st->Q_syn; - move16(); + move16(); Copy( psyn_fx + sub( st->L_frame, L_SYN_MEM_CLAS_ESTIM ), st->mem_syn_clas_estim_fx, L_SYN_MEM_CLAS_ESTIM ); - /*------------------------------------------------------------* - * FEC - Smooth the speech energy evolution when recovering after a BAD frame - * (smoothing is performed in the excitation domain and signal is resynthesized after) - *------------------------------------------------------------*/ + /*------------------------------------------------------------* + * FEC - Smooth the speech energy evolution when recovering after a BAD frame + * (smoothing is performed in the excitation domain and signal is resynthesized after) + *------------------------------------------------------------*/ test(); IF( EQ_32( st->total_brate, ACELP_7k20 ) || EQ_32( st->total_brate, ACELP_8k00 ) ) @@ -1455,7 +1455,7 @@ ivas_error acelp_core_dec_fx( &st->uv_count, &st->act_count, st->lspold_s_fx, &st->noimix_seed, &st->min_alpha_fx, &st->exc_pe_fx, st->core_brate, st->bwidth, &st->Q_stat_noise, &st->Q_stat_noise_ge ); } - } + } IF( st->hBWE_TD != NULL ) { @@ -1517,14 +1517,14 @@ ivas_error acelp_core_dec_fx( * Formant post-filter *-----------------------------------------------------------------*/ - test(); - test(); - test(); + test(); + test(); + test(); test(); IF( st->hPFstat != NULL && GE_16( st->last_bwidth, WB ) && ( GT_32( st->core_brate, ACELP_24k40 ) || st->element_mode > EVS_MONO ) && LE_32( st->core_brate, ACELP_32k ) ) - { + { st->hPFstat->on = 1; - move16(); + move16(); Copy( psyn_fx, temp_buf_fx + L_SYN_MEM, L_FRAME16k ); set16_fx( st->hPFstat->mem_zero, 0, M ); @@ -1597,13 +1597,13 @@ ivas_error acelp_core_dec_fx( { /* Noise estimate */ ApplyFdCng_fx( psyn_fx, st->Q_syn, NULL, 0, realBuffer_fx, imagBuffer_fx, NULL, st, 0, ( st->coder_type == AUDIO && !st->GSC_noisy_speech ) ); - } + } IF( !st->cna_dirac_flag ) { test(); test(); - test(); + test(); test(); test(); test(); @@ -1635,7 +1635,7 @@ ivas_error acelp_core_dec_fx( } } ELSE IF( NE_16( st->element_mode, IVAS_CPE_DFT ) ) - { + { IF( EQ_16( st->element_mode, EVS_MONO ) ) { generate_masking_noise_fx( psyn_fx, st->Q_syn, st->hFdCngDec->hFdCngCom, st->hFdCngDec->hFdCngCom->frameSize, 0 ); @@ -1736,9 +1736,9 @@ ivas_error acelp_core_dec_fx( } } - test(); - test(); - test(); + test(); + test(); + test(); IF( ( st->flag_cna == 0 ) || ( EQ_16( st->coder_type, AUDIO ) && !( st->element_mode > EVS_MONO && st->GSC_noisy_speech ) ) ) { IF( st->idchan == 0 ) @@ -1988,12 +1988,12 @@ ivas_error acelp_core_dec_fx( st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->cldfbAna->no_channels ); move16(); } - test(); - IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) - { - test(); - test(); test(); + IF( !st->cng_sba_flag || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + test(); + test(); + test(); /*WB/SWB-FD_CNG*/ IF( ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) ) && ( EQ_16( st->cng_type, FD_CNG ) ) && ( LT_16( st->hFdCngDec->hFdCngCom->numCoreBands, st->cldfbSyn->no_channels ) ) ) { @@ -2010,13 +2010,13 @@ ivas_error acelp_core_dec_fx( IF( LT_16( st->hFdCngDec->hFdCngCom->regularStopBand, st->cldfbSyn->no_channels ) ) { st->cldfbSyn->bandsToZero = sub( st->cldfbSyn->no_channels, st->hFdCngDec->hFdCngCom->regularStopBand ); - move16(); + move16(); } ELSE - { + { st->cldfbSyn->bandsToZero = 0; - move16(); - } + move16(); + } } } @@ -2111,7 +2111,7 @@ ivas_error acelp_core_dec_fx( } ELSE { - /* synthesis of the combined signal */ + /* synthesis of the combined signal */ max_real = 0; max_imag = 0; move32(); -- GitLab From 9aea06c25b2c29176d923abc0b808b11f01c149f Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 20 May 2025 11:02:33 +0200 Subject: [PATCH 085/394] Restore changes lost because of merge conflict. --- lib_com/prot_fx.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 498be3137..2fc32b008 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9472,8 +9472,15 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T void IMDCT_ivas_fx( Word32 *x_fx, Word16 q_x, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 *old_syn_overl_fx, + Word16 *Q_old_syn_overl_fx, Word16 *syn_Overl_TDAC_fx, + Word16 *Q_syn_Overl_TDAC_fx, +#else + Word16 *old_syn_overl_fx, + Word16 *syn_Overl_TDAC_fx, +#endif Word16 *xn_buf_fx, const Word16 *tcx_aldo_window_1_fx, const PWord16 *tcx_aldo_window_1_trunc_fx, @@ -9495,11 +9502,18 @@ void IMDCT_ivas_fx( const Word16 frame_cnt, const Word16 bfi, Word16 *old_out_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD + Word16 *q_old_out_fx, +#endif const Word16 FB_flag, Decoder_State *st, const Word16 fullbandScale, Word16 *acelp_zir_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *pq_win ); +#else Word16 q_win ); +#endif void v_mult16_fixed( const Word16 x1[], /* i : Input vector 1 */ -- GitLab From 1ab5a24fd0b1dea352dc5122a22256a8ef0a3854 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 21 May 2025 17:59:39 +0200 Subject: [PATCH 086/394] Add scaling correction of xn_buf_fx, which was missing. --- lib_com/prot_fx.h | 3 + lib_dec/dec_tcx_fx.c | 131 +++++++++++++++++++------------- lib_dec/ivas_mdct_core_dec_fx.c | 7 +- 3 files changed, 87 insertions(+), 54 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2fc32b008..7d6f3e55e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9482,6 +9482,9 @@ void IMDCT_ivas_fx( Word16 *syn_Overl_TDAC_fx, #endif Word16 *xn_buf_fx, +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_xn_buf_fx, +#endif const Word16 *tcx_aldo_window_1_fx, const PWord16 *tcx_aldo_window_1_trunc_fx, const PWord16 *tcx_aldo_window_2_fx, diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b51493262..49886cecf 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2588,29 +2588,17 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { -#if 0 Word16 oldLength; - oldLength = L_FRAME32k; + oldLength = s_min( L_FRAME32k, L_frame ); move16(); if ( FB_flag ) { - oldLength = L_FRAME48k; + oldLength = s_min( L_FRAME48k, L_frameTCX ); move16(); } -#else - Word16 oldLength; - oldLength = L_frame; - move16(); - if ( FB_flag ) - { - oldLength = L_frameTCX; - move16(); - } -#endif - - q_win = 4; + q_win = 6; move16(); // q_win == norm + Q_syn_Overl_TDAC @@ -2625,6 +2613,8 @@ static Word16 IMDCT_ivas_fx_calc_qwin( } static void IMDCT_ivas_fx_rescale( + Word16 *xn_buf_fx, + Word16 *q_xn_buf_fx, Word16 *syn_Overl_TDAC, Word16 *Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2647,6 +2637,9 @@ static void IMDCT_ivas_fx_rescale( } #if 1 + Scale_sig(xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub ( q_win, *q_xn_buf_fx ) ); + *q_xn_buf_fx = q_win; + move16(); Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win *Q_syn_Overl_TDAC = q_win; move16(); @@ -2937,6 +2930,9 @@ void IMDCT_ivas_fx( Word16 *syn_Overl_TDAC_fx, // Q(-2) #endif Word16 *xn_buf_fx, // Q(-2) +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_xn_buf_fx, +#endif const Word16 *tcx_aldo_window_1_fx, // Q(15) const PWord16 *tcx_aldo_window_1_trunc_fx, // Q(15) const PWord16 *tcx_aldo_window_2_fx, // Q(15) @@ -2983,10 +2979,12 @@ void IMDCT_ivas_fx( move16(); move16(); x_e_hdrm = sub( Q16, q_x ); +#if 0 IF( *pq_win == 0 ) { allow_qwin_change = 0; } +#endif IF( allow_qwin_change ) { // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); @@ -3086,6 +3084,9 @@ void IMDCT_ivas_fx( test(); L_spec_TCX5_tmp = imult1616( w, L_spec_TCX5 ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + // Assume that xn_buf_fx has no headroom. + q_win = s_min( q_xn_buf_fx, q_win ); + IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); @@ -3099,7 +3100,7 @@ void IMDCT_ivas_fx( TCX_MDCT_Inverse_qwin_fx( x_fx + L_spec_TCX5_tmp, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, st->element_mode, &q_win, allow_qwin_change ); } - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) || s_and( kernel_type, w ) ) { @@ -3155,6 +3156,10 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_win_prev; +#if 0 + // Assume that xn_buf_fx has no headroom. + q_win = s_min( q_xn_buf_fx, q_win ); +#endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN IF( allow_qwin_change ) { @@ -3199,8 +3204,11 @@ void IMDCT_ivas_fx( /* copy new sub-window region not overlapping with previous window */ Copy( win_fx + L_win, xn_buf_fx + shr( overlap, 1 ), add( L_win, shr( L_ola, 1 ) ) ); - /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + q_xn_buf_fx = q_win; + move16(); + + /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ IF( s_and( kernel_type, 1 ) ) { TCX_MDST_Inverse_qwin_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola, &q_win, allow_qwin_change ); @@ -3212,8 +3220,9 @@ void IMDCT_ivas_fx( assert( q_win_prev == q_win ); - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else + /* 2nd TCX-5 window, regular MDCT with minimum overlap on both sides */ IF( s_and( kernel_type, 1 ) ) { TCX_MDST_Inverse_fx( x_fx + L_spec_TCX5, x_e_hdrm, win_fx, L_ola, sub( L_win, L_ola ), L_ola ); @@ -3270,8 +3279,11 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, st->element_mode, &q_win, allow_qwin_change ); } + // Because xn_buf_fx is overwritten above. + q_xn_buf_fx = q_win; + move16(); - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3334,7 +3346,7 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN // q_win < norm + q_tmp_fx_32 - 16 q_win = s_min( q_win, L_norm_arr( tmp_fx_32, L_frame ) + q_tmp_fx_32 - 16 ); - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 diff = sub( q_tmp_fx_32, q_win ); @@ -3363,8 +3375,8 @@ void IMDCT_ivas_fx( assert( extract_h( L_shr( old_out_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( old_out_fx_32[ind], diff ) ) == -1 ); old_out_fx[ind] = extract_l( L_shr( old_out_fx_32[ind], diff ) ); #endif - xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); assert( extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == 0 || extract_h( L_shr( xn_buf_fx_32[ind], diff ) ) == -1 ); + xn_buf_fx[ind] = extract_l( L_shr( xn_buf_fx_32[ind], diff ) ); move16(); move16(); } @@ -3398,7 +3410,7 @@ void IMDCT_ivas_fx( // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); } - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); @@ -3459,7 +3471,7 @@ void IMDCT_ivas_fx( { allow_qwin_change = 0; move16(); - q_win = s_max( -2, sub( q_win, 2 ) ); + q_win = s_max( -2, sub( q_win, 1 ) ); } } @@ -3475,8 +3487,11 @@ void IMDCT_ivas_fx( { TCX_MDCT_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, L_frame - overlap, overlap, st->element_mode, &q_win, allow_qwin_change ); } + // Because xn_buf_fx is overwritten above. + q_xn_buf_fx = q_win; + move16(); - IMDCT_ivas_fx_rescale( syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #else IF( EQ_16( kernel_type, MDST_IV ) ) { @@ -3547,15 +3562,15 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) Word16 tmp_old_out; Word16 q_diff = sub( *q_old_out_fx, q_win ); #endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // Q(-2) + xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // q_win #else xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], old_out_fx[( i + nz )] ); // Q(-2) #endif @@ -3571,31 +3586,31 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // q_win #else - xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // Q(-2) + xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], old_out_fx[( i + nz )] ); // q_win #endif move16(); } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win #else - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // Q(-2) + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win #endif move16(); } FOR( ; i < tcx_mdct_window_min_length; i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win #else - xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // Q(-2) + xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( old_out_fx[( ( i + nz ) + overlap )], tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win #endif move16(); } @@ -3604,7 +3619,7 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #else @@ -3614,7 +3629,7 @@ void IMDCT_ivas_fx( } FOR( ; i < overlap; i++ ) { -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #else @@ -4182,6 +4197,7 @@ void decoder_tcx_ivas_fx( Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( sub( 28, ( sub( 15, norm_s( sub( st->old_Aq_12_8_fx[0], 1 ) ) ) ) ) ) ); Word16 q_win, q_winFB; + q_win = st->Q_syn; move16(); q_winFB = st->Q_syn; @@ -4189,12 +4205,12 @@ void decoder_tcx_ivas_fx( assert( q_win == 0 ); + Scale_sig( synth_fx, L_frame_glob, sub( q_win, st->Q_syn ) ); // Scaling to Q_syn + Scale_sig( synthFB_fx, L_frameTCX_glob, sub( q_winFB, st->Q_syn ) ); // Scaling to Q_syn + decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, &q_winFB, MDCT_IV, fUseTns, &synth_fx[0], &synthFB_fx[0], bfi, frame_cnt, sba_dirac_stereo_flag ); - assert( q_win == 0 ); - assert( q_win == q_winFB ); - /* Scaling up again */ Scale_sig( synth_fx, L_frame_glob, sub( st->Q_syn, q_win ) ); Scale_sig( synthFB_fx, L_frameTCX_glob, sub( st->Q_syn, q_winFB ) ); @@ -5827,7 +5843,7 @@ void decoder_tcx_imdct_fx( { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, #else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, #endif @@ -5857,7 +5873,7 @@ void decoder_tcx_imdct_fx( { Copy32( x_fx, xn_bufFB_fx, s_max( L_spec, s_max( L_frame, L_frameTCX ) ) ); // q_x #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, + IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, &hTcxDec->Q_syn_Overl, hTcxDec->syn_Overl_TDAC, &hTcxDec->Q_syn_Overl_TDAC, xn_buf_fx, *q_win, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #else IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #endif @@ -5869,12 +5885,17 @@ void decoder_tcx_imdct_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 shift_q = sub( q_x, *q_winFB ); + Word16 shift_q, q_x16; + + shift_q = L_norm_arr( xn_bufFB_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); + shift_q = sub( 16, shift_q ); + q_x16 = sub( q_x, shift_q ); #endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x + assert( extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == -1 ); + xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x16 move16(); } @@ -5885,7 +5906,7 @@ void decoder_tcx_imdct_fx( IF( st->element_mode != EVS_MONO ) { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, + IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, #else IMDCT_ivas_fx( x_tmp_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, #endif @@ -5899,7 +5920,7 @@ void decoder_tcx_imdct_fx( ELSE { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, + IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, &hTcxDec->Q_syn_OverlFB, hTcxDec->syn_Overl_TDACFB, &hTcxDec->Q_syn_Overl_TDACFB, xn_bufFB_fx_16, q_x16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #else IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #endif @@ -5911,12 +5932,13 @@ void decoder_tcx_imdct_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - shift_q = sub( q_x, *q_winFB ); + shift_q = 16; + move16(); #endif FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { - xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // Q_x + xn_bufFB_fx[ind] = L_shl( L_deposit_l( xn_bufFB_fx_16[ind] ), shift_q ); // q_winFB } IF( ( bfi == 0 ) ) @@ -5958,18 +5980,21 @@ void decoder_tcx_imdct_fx( /* Update old_syn_overl */ IF( hTcxCfg->last_aldo == 0 ) { - Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // Q(-2) + Copy( xn_buf_fx + L_frame, hTcxDec->syn_Overl, overlap ); // q_win FOR( Word16 ind = 0; ind < overlapFB; ind++ ) { - hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_x + assert( extract_h( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ) == -1 ); + hTcxDec->syn_OverlFB[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + L_frameTCX )], shift_q ) ); // q_winFB } } /* Output */ - Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // Q(-2) + Copy( xn_buf_fx + sub( shr( overlap, 1 ), tcx_offset ), synth_fx, L_frame_glob ); // q_win FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) { - synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_x + assert( extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == 0 || + extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == -1 ); + synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_winFB } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 0cec3dd72..00946b77d 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1316,7 +1316,7 @@ void ivas_mdct_core_reconstruct_fx( // norm(old_out) + q_win >= st->Q_syn sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); - +#if 0 Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDACFB ) ); // q_winFB -> Q(-1 - st->Q_syn) st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); move16(); @@ -1329,6 +1329,11 @@ void ivas_mdct_core_reconstruct_fx( st->hTcxDec->Q_syn_OverlFB = st->Q_syn; Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; +#else + //Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( -2, st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) + //st->hTcxDec->Q_old_syn_Overl = -2; +#endif + Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); -- GitLab From 12f8828888afdfbc5d207497a210fa04634481e7 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 21 May 2025 18:04:13 +0200 Subject: [PATCH 087/394] clang format --- lib_dec/dec_tcx_fx.c | 22 +++++++++++----------- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 49886cecf..f5929c853 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2637,7 +2637,7 @@ static void IMDCT_ivas_fx_rescale( } #if 1 - Scale_sig(xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub ( q_win, *q_xn_buf_fx ) ); + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( q_win, *q_xn_buf_fx ) ); *q_xn_buf_fx = q_win; move16(); Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win @@ -2929,7 +2929,7 @@ void IMDCT_ivas_fx( Word16 *old_syn_overl_fx, // Q(-2) Word16 *syn_Overl_TDAC_fx, // Q(-2) #endif - Word16 *xn_buf_fx, // Q(-2) + Word16 *xn_buf_fx, // Q(-2) #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_xn_buf_fx, #endif @@ -3562,13 +3562,13 @@ void IMDCT_ivas_fx( IF( hTcxCfg->last_aldo != 0 ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) Word16 tmp_old_out; Word16 q_diff = sub( *q_old_out_fx, q_win ); #endif FOR( i = 0; i < sub( overlap, tcx_mdct_window_min_length ); i++ ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )], tmp_old_out ); // q_win #else @@ -3586,7 +3586,7 @@ void IMDCT_ivas_fx( // tested FOR( ; i < overlap; i++ ) /* perfectly reconstructing ALDO shortening */ { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], tmp_old_out ); // q_win #else @@ -3596,7 +3596,7 @@ void IMDCT_ivas_fx( } FOR( i = 0; i < ( tcx_mdct_window_min_length / 2 ); i++ ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[i].v.re ) ); // q_win #else @@ -3606,7 +3606,7 @@ void IMDCT_ivas_fx( } FOR( ; i < tcx_mdct_window_min_length; i++ ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( ( i + nz ) + overlap )], q_diff ); xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )] = add_sat( xn_buf_fx[( ( ( i + ( overlap / 2 ) ) - tcx_offset ) + overlap )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( tcx_mdct_window_min_length - ( 1 + i ) )].v.im ) ); // q_win #else @@ -3619,7 +3619,7 @@ void IMDCT_ivas_fx( { FOR( ; i < ( overlap - ( tcx_mdct_window_min_length / 2 ) ); i++ ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( ( tcx_mdct_window_min_length - overlap ) + i )].v.re ) ); // Q(-2) #else @@ -3629,7 +3629,7 @@ void IMDCT_ivas_fx( } FOR( ; i < overlap; i++ ) { -#if defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD) && !defined(FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN) +#if defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD ) && !defined( FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN ) tmp_old_out = shr_sat( old_out_fx[( i + nz )], q_diff ); xn_buf_fx[( i + ( ( overlap / 2 ) - tcx_offset ) )] = add_sat( xn_buf_fx[( ( i + ( overlap / 2 ) ) - tcx_offset )], mult_r( tmp_old_out, tcx_mdct_window_minimum_fx[( overlap - ( 1 + i ) )].v.im ) ); // Q(-2) #else @@ -4205,7 +4205,7 @@ void decoder_tcx_ivas_fx( assert( q_win == 0 ); - Scale_sig( synth_fx, L_frame_glob, sub( q_win, st->Q_syn ) ); // Scaling to Q_syn + Scale_sig( synth_fx, L_frame_glob, sub( q_win, st->Q_syn ) ); // Scaling to Q_syn Scale_sig( synthFB_fx, L_frameTCX_glob, sub( q_winFB, st->Q_syn ) ); // Scaling to Q_syn decoder_tcx_imdct_fx( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x_fx[0], q_x, xn_buf_fx, &q_win, &q_winFB, MDCT_IV, @@ -5993,7 +5993,7 @@ void decoder_tcx_imdct_fx( FOR( Word16 ind = 0; ind < L_frameTCX_glob; ind++ ) { assert( extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == 0 || - extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == -1 ); + extract_h( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ) == -1 ); synthFB_fx[ind] = extract_l( L_shr( xn_bufFB_fx[( ind + ( ( overlapFB >> 1 ) - tcx_offsetFB ) )], shift_q ) ); // q_winFB } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 00946b77d..dbfc46b7f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1330,8 +1330,8 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn st->hTcxDec->Q_syn_Overl = st->Q_syn; #else - //Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( -2, st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) - //st->hTcxDec->Q_old_syn_Overl = -2; + // Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( -2, st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) + // st->hTcxDec->Q_old_syn_Overl = -2; #endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn -- GitLab From 7c69312e25c9a50fe377c92041f935b774961d96 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 11:28:53 +0200 Subject: [PATCH 088/394] Undo wrong change to Q_old_wtda_LB. --- lib_dec/er_dec_acelp_fx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 18c930269..3ffbcd139 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1061,10 +1061,7 @@ void con_acelp_fx( move16(); } set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hHQ_core->Q_old_wtda_LB = st->Q_syn; - move16(); -#else +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); #endif -- GitLab From 9f805bb9f29a243e826083a07cd25290a810aad1 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 13:09:10 +0200 Subject: [PATCH 089/394] Fix asser failure (saturation alarm) for stereo_at_64_kbps_32kHz_in_32kHz_out_bandwidth_switching -10dB case. --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f5929c853..579d89968 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3351,7 +3351,7 @@ void IMDCT_ivas_fx( Word16 diff = sub( q_tmp_fx_32, q_win ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); + Word16 q_old_out_diff = s_max( sub( q_tmp_fx_32, *q_old_out_fx ), 0 ); #endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -- GitLab From cfe8d30d8c35295601e96369fae85f0a8caf431d Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 14:38:13 +0200 Subject: [PATCH 090/394] Fix EVS BE case stv8c_dtx_24400_8kHz.f06.COD stv8c_dtx_24400_8kHz.f06 --- lib_dec/er_dec_tcx_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index a1907b44c..775be6489 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -942,8 +942,10 @@ void con_tcx_fx( move16(); /* update memory for low band */ -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT Scale_sig( hTcxDec->old_syn_Overl, shr( st->L_frame, 1 ), sub( -1, Q_syn ) ); /*Q_syn*/ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + hTcxDec->Q_old_syn_Overl = -1; + move16(); #endif lerp( hTcxDec->syn_OverlFB, hTcxDec->syn_Overl, shr( st->L_frame, 1 ), shr( L_frame, 1 ) ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT @@ -954,7 +956,7 @@ void con_tcx_fx( hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_NO hHQ_core->Q_old_wtda_LB = hHQ_core->Q_old_wtda; move16(); #endif -- GitLab From f938177b94b9ecb1425468f5d4321ccad45a49b2 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 16:03:22 +0200 Subject: [PATCH 091/394] Add missing adaption of Q_syn_OverlFB for error concealment case. This is likely an old bug that only now become more visible. --- lib_dec/ivas_mdct_core_dec_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index dbfc46b7f..bc4482837 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1421,6 +1421,11 @@ void ivas_mdct_core_reconstruct_fx( st->Q_syn = q_syn; move16(); st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn ); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + move16(); + st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); + move16(); +#endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) { -- GitLab From f866ba3f8b09e41b6ba9c9e788e8b4cc953aa4df Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 26 May 2025 08:23:55 +0200 Subject: [PATCH 092/394] Remove unnecessary change. The assignment hHQ_core->Q_old_wtda = Q_syn to be excpected here is found a few lines further away. --- lib_dec/er_dec_tcx_fx.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 775be6489..374e4c3a6 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -848,10 +848,6 @@ void con_tcx_fx( move16(); #endif Copy( syn + sub( L_frame, n ), hHQ_core->old_out_fx, sub( L_frame, n ) ); /*Q_syn*/ -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT - hHQ_core->Q_old_wtda = Q_syn; - move16(); -#endif FOR( i = 0; i < W12; i++ ) { -- GitLab From e9f84b0b944f2405c3c498c6393ef8a053e4fe13 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 26 May 2025 13:54:32 +0200 Subject: [PATCH 093/394] Remove wrong change. --- lib_dec/er_dec_acelp_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 3ffbcd139..5f75b21bf 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -1061,10 +1061,8 @@ void con_acelp_fx( move16(); } set16_fx( &hHQ_core->old_out_LB_fx[( W1 + n )], 0, n ); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT hHQ_core->Q_old_wtda = hHQ_core->Q_old_wtda_LB; move16(); -#endif FOR( i = 0; i < W2; i++ ) { -- GitLab From 49308ae4d1d49b906de1a68bc35cbb0de68d3b6e Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 27 May 2025 17:55:01 +0200 Subject: [PATCH 094/394] Increase range for norm_arr() analysis for syn_Overl and old_out_fx. Skip scaling xn_buf_fx in cases where it is not applicable. --- lib_dec/dec_tcx_fx.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 579d89968..1d35db9cc 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2588,13 +2588,15 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { - Word16 oldLength; + Word16 oldLength, t; oldLength = s_min( L_FRAME32k, L_frame ); + t = L_FRAME32k; move16(); if ( FB_flag ) { oldLength = s_min( L_FRAME48k, L_frameTCX ); + t = L_FRAME48k; move16(); } @@ -2603,10 +2605,18 @@ static Word16 IMDCT_ivas_fx_calc_qwin( // q_win == norm + Q_syn_Overl_TDAC q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC ); - q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); + //q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, t / 2 ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); - q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); + //q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); + q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); +#if 0 + set16_zero_fx(syn_Overl_TDAC + oldLength / 2, (t-oldLength)/2 ); + //set16_zero_fx(syn_Overl + oldLength / 2, (t-oldLength)/2 ); + set16_zero_fx(old_syn_Overl + oldLength / 2, (t-oldLength)/2 ); + //set16_zero_fx(old_out_fx + oldLength, (t-oldLength) ); +#endif q_win = s_max( -3, sub( q_win, 2 ) ); return q_win; @@ -2637,9 +2647,11 @@ static void IMDCT_ivas_fx_rescale( } #if 1 - Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( q_win, *q_xn_buf_fx ) ); - *q_xn_buf_fx = q_win; - move16(); + IF ( xn_buf_fx != NULL ) { + Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( q_win, *q_xn_buf_fx ) ); + *q_xn_buf_fx = q_win; + move16(); + } Scale_sig( syn_Overl_TDAC, oldLength / 2, sub( q_win, *Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win *Q_syn_Overl_TDAC = q_win; move16(); @@ -3346,7 +3358,7 @@ void IMDCT_ivas_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN // q_win < norm + q_tmp_fx_32 - 16 q_win = s_min( q_win, L_norm_arr( tmp_fx_32, L_frame ) + q_tmp_fx_32 - 16 ); - IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( NULL, NULL, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 diff = sub( q_tmp_fx_32, q_win ); @@ -3410,7 +3422,7 @@ void IMDCT_ivas_fx( // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); } - IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( NULL, NULL, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); -- GitLab From 812204af885a47f6bb9cb07b2b9ada632c864f58 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 27 May 2025 17:58:06 +0200 Subject: [PATCH 095/394] clang format --- lib_dec/dec_tcx_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 1d35db9cc..172f32685 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2605,10 +2605,10 @@ static Word16 IMDCT_ivas_fx_calc_qwin( // q_win == norm + Q_syn_Overl_TDAC q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC ); - //q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); + // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( syn_Overl, t / 2 ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); - //q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); + // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); #if 0 @@ -2647,7 +2647,8 @@ static void IMDCT_ivas_fx_rescale( } #if 1 - IF ( xn_buf_fx != NULL ) { + IF( xn_buf_fx != NULL ) + { Scale_sig( xn_buf_fx, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX, sub( q_win, *q_xn_buf_fx ) ); *q_xn_buf_fx = q_win; move16(); -- GitLab From 3a4574860727f24356cd52fe6a5c20ab4fad68df Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 28 May 2025 10:42:02 +0200 Subject: [PATCH 096/394] Revert not rescaling of xn_buf_fx in case of MDCT TCX20. --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 172f32685..4ab18e102 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3423,7 +3423,7 @@ void IMDCT_ivas_fx( // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); } - IMDCT_ivas_fx_rescale( NULL, NULL, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); + IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif Word16 q_diff = sub( q_xn_buf_fx_32, q_win ); -- GitLab From a31c149eb178bd9c5938164fb31a67c5343ed6ab Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 30 May 2025 18:10:18 +0530 Subject: [PATCH 097/394] Fix for 3GPP issue 1123: MLD in the range of 5 to 12 between signals decoded from 256kbps encoded SBA bitstreams at input level -16LKFS Link #1123 --- lib_enc/tcx_utils_enc_fx.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 680a69fa5..2d3c7ce47 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1392,25 +1392,33 @@ void tcx_scalar_quantization_ivas_fx( s = sub( add( x_e, gain_e ), 15 ); } - /* substract 0x8000 to affect the mac_r in the following loop - so it acts like extract_h. the 0x4000 will be multiplied by 2 - by the mac_r to get to 0x8000 and disable the round. */ - offset = sub( offset, 0x4000 ); - FOR( ; i >= 0; i-- ) { - offs32 = Mpy_32_16_1( L_abs( x[i] ), gain ); /* multiply */ - offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ - tmp16 = mac_r_sat( offs32, offset, 1 ); /* add offset and truncate */ - IF( x[i] < 0 ) + offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */ + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + IF( x[i] > 0 ) { - tmp16 = negate( tmp16 ); /* restore sign */ + offs32 = L_add_sat( offs32, L_shl( offset, 1 ) ); + tmp16 = extract_h( offs32 ); + IF( GT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = sub( tmp16, 1 ); + } + } + ELSE + { + offs32 = L_add_sat( offs32, L_shl( negate( offset ), 1 ) ); + tmp16 = extract_h( offs32 ); + IF( LT_32( L_deposit_h( tmp16 ), offs32 ) ) + { + tmp16 = add( tmp16, 1 ); + } } - xq[i] = tmp16; move16(); } + IF( alfe_flag == 0 ) { AdaptLowFreqEmph_fx( x, x_e, xq, gain, gain_e, -- GitLab From dd2547843d55bebccc43249166d162daed28f9ca Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 2 Jun 2025 12:21:19 +0200 Subject: [PATCH 098/394] Remove asignment of Q value that leads to wrong old EXC and subsequently wrong BWE_TD EXC signals. --- lib_dec/ivas_core_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index cf3d8c468..4def2242a 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -604,8 +604,10 @@ ivas_error ivas_core_dec_fx( stereo_tcx_core_dec_fx( st, frameMode[n], output_16_fx[n], synth_16_fx[n], pitch_buf_fx[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hStereoCng, nchan_out, ivas_format ); +#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hHQ_core->Q_old_wtda_LB = st->hHQ_core->Q_old_wtda; move16(); +#endif Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], output_frame, Q11 ); // Q11 IF( st->hTcxDec ) -- GitLab From ca88578e2454e6d793b55193dcb6e85f40a41f50 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:26:43 +0200 Subject: [PATCH 099/394] Change FIX_732 to only address noise floor in msPeriodog calculation --- lib_dec/fd_cng_dec_fx.c | 56 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index a9965d601..ef4659552 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1117,11 +1117,7 @@ Word16 ApplyFdCng_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } -#ifdef FIX_732 - s2 = ( sub( WORD32_BITS, 1 ) ); -#else s2 = -( ( WORD32_BITS - 1 ) ); -#endif move16(); /* Shape the SID noise levels in each FFT bin */ j = 0; @@ -1161,11 +1157,7 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( ( WORD32_BITS - 1 ) ); move16(); } -#ifdef FIX_732 - s2 = s_min( s2, facTabExp[k] ); -#else s2 = s_max( s2, facTabExp[k] ); -#endif } if ( EQ_16( s2, -31 ) ) { @@ -1178,11 +1170,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_732 - cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } @@ -1220,11 +1208,7 @@ Word16 ApplyFdCng_fx( { IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { -#ifdef FIX_732 - s2 = ( sub( WORD32_BITS, 1 ) ); -#else s2 = -( ( WORD32_BITS - 1 ) ); -#endif /* Shape the SID noise levels in each FFT bin */ j = 0; move16(); @@ -1263,11 +1247,7 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( WORD32_BITS - 1 ); move16(); } -#ifdef FIX_732 - s2 = s_min( s2, facTabExp[k] ); -#else s2 = s_max( s2, facTabExp[k] ); -#endif } IF( EQ_16( s2, -31 ) ) { @@ -1280,11 +1260,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_732 - cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } @@ -1320,6 +1296,14 @@ Word16 ApplyFdCng_fx( } + dbgwrite( hFdCngDec->bandNoiseShape, sizeof( Word32 ), 320, 1, "bandNoiseShape.int" ); + dbgwrite( &hFdCngDec->bandNoiseShape_exp, sizeof( short ), 1, 1, "bandNoiseShape_exp.short" ); + + dbgwrite( cngNoiseLevel, sizeof( Word32 ), 340, 1, "cngNoiseLevel.int" ); + dbgwrite( cngNoiseLevel_exp, sizeof( short ), 1, 1, "cngNoiseLevel_exp.short" ); + dbgwrite( &frame, sizeof( int ), 1, 1, "frame.int" ); + + return 0; } @@ -1523,6 +1507,9 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; +#ifdef FIX_732 + Word32 msPeriodog_floor; +#endif Word32 *msNoiseEst; Word32 *reIter; Word32 rescale_fac = 0; @@ -1728,10 +1715,18 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); - +#ifdef FIX_732 + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); + IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) +#else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) +#endif { +#ifdef FIX_732 + msPeriodog[p] = msPeriodog_floor; +#else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ +#endif move32(); } } @@ -2105,6 +2100,13 @@ void perform_noise_estimation_dec_ivas_fx( /* Expand partitions into bins of power spectrum */ scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; + + dbgwrite( msNoiseEst, sizeof( int ), 62, 1, "msNoiseEst.int" ); + dbgwrite( &hFdCngDec->msNoiseEst_exp, sizeof( short ), 1, 1, "msNoiseEst_exp.short" ); + dbgwrite( msPeriodog, sizeof( int ), 62, 1, "msPeriodog.int" ); + dbgwrite( &hFdCngDec->msPeriodog_exp, sizeof( short ), 1, 1, "msPeriodog_exp.short" ); + + move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ hFdCngDec->smoothed_psd_exp = hFdCngDec->bandNoiseShape_exp; @@ -4739,9 +4741,9 @@ void generate_masking_noise_ivas_fx( { #ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ +#else /* VEC_ARITH_OPT_v1 */ v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ +#endif /* VEC_ARITH_OPT_v1 */ } return; -- GitLab From edbb3c704becbfa533e95a3995e342d323b01f55 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:34:38 +0200 Subject: [PATCH 100/394] Rename switch to FIX_732_MS_PERIODOG_FLOOR --- lib_com/options.h | 2 +- lib_dec/fd_cng_dec_fx.c | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index db3dc4a20..5a25cca53 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,7 +67,7 @@ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif -#define FIX_732 /* Eri: Fix for precision issue in CNG generation -- still work in progress */ +#define FIX_732_MS_PERIODOG_FLOOR /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */ #define FIX_867_CLDFB_NRG_SCALE diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index d9ffedf72..30164c404 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1117,6 +1117,7 @@ Word16 ApplyFdCng_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } + s2 = -( ( WORD32_BITS - 1 ) ); move16(); /* Shape the SID noise levels in each FFT bin */ @@ -1296,14 +1297,6 @@ Word16 ApplyFdCng_fx( } - dbgwrite( hFdCngDec->bandNoiseShape, sizeof( Word32 ), 320, 1, "bandNoiseShape.int" ); - dbgwrite( &hFdCngDec->bandNoiseShape_exp, sizeof( short ), 1, 1, "bandNoiseShape_exp.short" ); - - dbgwrite( cngNoiseLevel, sizeof( Word32 ), 340, 1, "cngNoiseLevel.int" ); - dbgwrite( cngNoiseLevel_exp, sizeof( short ), 1, 1, "cngNoiseLevel_exp.short" ); - dbgwrite( &frame, sizeof( int ), 1, 1, "frame.int" ); - - return 0; } @@ -1507,7 +1500,7 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR Word32 msPeriodog_floor; #endif Word32 *msNoiseEst; @@ -1715,14 +1708,14 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) #else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) #endif { -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog[p] = msPeriodog_floor; #else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ @@ -2100,13 +2093,6 @@ void perform_noise_estimation_dec_ivas_fx( /* Expand partitions into bins of power spectrum */ scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; - - dbgwrite( msNoiseEst, sizeof( int ), 62, 1, "msNoiseEst.int" ); - dbgwrite( &hFdCngDec->msNoiseEst_exp, sizeof( short ), 1, 1, "msNoiseEst_exp.short" ); - dbgwrite( msPeriodog, sizeof( int ), 62, 1, "msPeriodog.int" ); - dbgwrite( &hFdCngDec->msPeriodog_exp, sizeof( short ), 1, 1, "msPeriodog_exp.short" ); - - move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ hFdCngDec->smoothed_psd_exp = hFdCngDec->bandNoiseShape_exp; @@ -4752,9 +4738,9 @@ void generate_masking_noise_ivas_fx( { #ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ +#else /* VEC_ARITH_OPT_v1 */ v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ +#endif /* VEC_ARITH_OPT_v1 */ } return; -- GitLab From eb884a3884a78139685c0a34fc966397775f04ee Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:50:04 +0200 Subject: [PATCH 101/394] Clang format --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 30164c404..de5aa20bb 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1718,7 +1718,7 @@ void perform_noise_estimation_dec_ivas_fx( #ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog[p] = msPeriodog_floor; #else - msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ + msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ #endif move32(); } -- GitLab From 9ee4902bc29e6b5785e5d222aca54663b880afd8 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:51:47 +0200 Subject: [PATCH 102/394] Add missing comment --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index de5aa20bb..4855ab00e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1709,7 +1709,7 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); #ifdef FIX_732_MS_PERIODOG_FLOOR - msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/ IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) #else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) -- GitLab From 6ae2d5245bfa225979f06b9bdef6a7d76eda909c Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 2 Jun 2025 17:55:55 +0200 Subject: [PATCH 103/394] Change q_win values from -2 to Q15 for the case that a channel is skipped to avoid less precision in other channel of a CPE. --- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index bc4482837..a8e97b0cf 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1256,9 +1256,9 @@ void ivas_mdct_core_reconstruct_fx( ELSE { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - q_win = -2; + q_win = Q15; move16(); - q_winFB = -2; + q_winFB = Q15; move16(); #endif set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] ); -- GitLab From b23adcfa2a66c74e90e308ec043e079f178bb719 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 3 Jun 2025 14:37:51 +0200 Subject: [PATCH 104/394] port MR 1223 from float fix for JBM control getting the wrong info for non-20ms framesizes --- apps/decoder.c | 93 ++++++++++++++ lib_com/options.h | 3 + lib_dec/lib_dec_fx.c | 282 +++++++++++++++++++++++++++++-------------- 3 files changed, 286 insertions(+), 92 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 1c59a02e7..fdfc42054 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2462,7 +2462,14 @@ static ivas_error decodeVoIP( } vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len; frame++; +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + if ( vec_pos_update == 0 ) + { + systemTime_ms += vec_pos_len * systemTimeInc_ms; + } +#else systemTime_ms += systemTimeInc_ms; +#endif #ifdef WMOPS update_mem(); @@ -2470,6 +2477,92 @@ static ivas_error decodeVoIP( #endif } +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + int16_t nSamplesFlushed = 0; + + /* decode and get samples */ +#ifdef SPLIT_REND_WITH_HEAD_ROT + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( nSamplesFlushed ) + { + /* Write current frame */ + if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nOutput audio file writer error\n" ); + goto cleanup; + } + + /* Write ISm metadata to external file(s) */ + if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL ) + { + if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM ) + { + if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + for ( i = 0; i < numObj; ++i ) + { + IVAS_ISM_METADATA IsmMetadata; + + if ( ( error = IVAS_DEC_GetObjectMetadata( hIvasDec, &IsmMetadata, 0, i ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetObjectMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( ( IsmFileWriter_writeFrame( IsmMetadata, ismWriters[i] ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing ISM metadata to file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) ); + goto cleanup; + } + } + } + + if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM ) + { + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + int16_t fullDelayNumSamples[3]; + float delayMs; + + /* delayNumSamples is zeroed, and delayNumSamples_orig is updated only on first good frame, so need to re-fetch delay info */ + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + } +#endif + if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale ); + if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK ) +#else + if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) ); + goto cleanup; + } + } + } + } +#endif + /*------------------------------------------------------------------------------------------* * Add zeros at the end to have equal length of synthesized signals *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/options.h b/lib_com/options.h index a5d5a4846..26b572056 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -50,6 +50,7 @@ /*#define DEBUG_FORCE_DIR*/ /* Force modes/parameters by reading from external binary files */ /*#define DBG_WAV_WRITER*/ /* Enable dbgwrite_wav() function for generating ".wav" files */ #define SUPPORT_FORCE_TCX10_TCX20 /* VA: Enable -force tcx10|tcx20 command-line option */ +/*#define DEBUG_MODE_JBM */ /* define to output JBM relevant parameters */ #endif #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ @@ -106,4 +107,6 @@ #define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ +#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ + #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 421137631..d16f862ec 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -58,6 +58,9 @@ struct IVAS_DEC_VOIP UWord16 lastDecodedWasActive; JB4_DATAUNIT_HANDLE hCurrentDataUnit; /* Points to the currently processed data unit */ UWord16 *bs_conversion_buf; /* Buffer for bitstream conversion from packed to serial */ +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + Word16 nSamplesRendered20ms; /* how many samples have been rendered since the last 20ms render border*/ +#endif #ifdef SUPPORT_JBM_TRACEFILE IVAS_JBM_TRACE_DATA JbmTraceData; #endif @@ -79,6 +82,9 @@ struct IVAS_DEC bool Opt_VOIP; /* flag indicating VOIP mode with JBM */ Word16 tsm_scale; /* scale for TSM operation */ Word16 tsm_max_scaling; +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ +#endif Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ Word16 tsm_quality; /*Q14*/ PCMDSP_APA_HANDLE hTimeScaler; @@ -112,6 +118,9 @@ static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, cons static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const UWord16 nSamplesForRendering, UWord16 *nSamplesRendered, UWord16 *nSamplesAvailableNext, Word16 *pcmBuf ); static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, Word16 *nSamplesBuffered ); static Word16 get_render_frame_size_ms( IVAS_RENDER_FRAMESIZE render_framesize ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE +static void update_voip_rendered20ms( IVAS_DEC_HANDLE hIvasDec, const Word16 nSamplesRendered ); +#endif /*---------------------------------------------------------------------* @@ -149,6 +158,9 @@ ivas_error IVAS_DEC_Open( hIvasDec->tsm_scale = 100; hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = ONE_IN_Q14; /*1.f Q14*/ +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 0; +#endif hIvasDec->needNewFrame = false; hIvasDec->nTransportChannelsOld = 0; hIvasDec->nSamplesAvailableNext = 0; @@ -171,6 +183,9 @@ ivas_error IVAS_DEC_Open( move16(); move16(); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + move16(); +#endif hIvasDec->mode = mode; move16(); @@ -805,6 +820,10 @@ ivas_error IVAS_DEC_EnableVoIP( hIvasDec->hVoIP->hCurrentDataUnit = NULL; hIvasDec->hVoIP->nSamplesFrame = (UWord16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FRAME_PER_SEC_Q15 ); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->hVoIP->nSamplesRendered20ms = 0; + move16(); +#endif #define WMC_TOOL_SKIP /* Bitstream conversion is not counted towards complexity and memory usage */ @@ -1043,123 +1062,136 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ - return error; - } -} -{ - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) - { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) { return error; } } - - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - return error; - } - - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - return IVAS_ERR_UNKNOWN; - } + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) + { + return error; + } } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - return IVAS_ERR_UNKNOWN; + return error; + } + + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + } + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + } + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 1; + move16(); +#endif } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + ELSE { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) +#ifdef DEBUG_MODE_JBM + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); +#endif + + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) { - return IVAS_ERR_UNKNOWN; + return error; + } +#ifdef DEBUG_MODE_JBM + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); +#endif + + + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } } + hIvasDec->hasBeenFedFrame = false; + move16(); } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); - } - ELSE - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); - } - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) { - return IVAS_ERR_UNKNOWN; + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); } } - hIvasDec->hasBeenFedFrame = false; - move16(); - } - - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } - - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); } - ELSE - { - *needNewFrame = false; - move16(); - } -} -} -*nOutSamples = nSamplesRendered; -move16(); + *nOutSamples = nSamplesRendered; + move16(); -return IVAS_ERR_OK; + return IVAS_ERR_OK; } @@ -1559,6 +1591,9 @@ static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( if ( hIvasDec->st_ivas->hTcBuffer != NULL ) { *nSamplesBuffered = sub( hIvasDec->st_ivas->hTcBuffer->n_samples_buffered, hIvasDec->st_ivas->hTcBuffer->n_samples_rendered ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + *nSamplesBuffered = add( *nSamplesBuffered, hIvasDec->hVoIP->nSamplesRendered20ms ); +#endif move16(); } @@ -2685,7 +2720,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( UWord32 extBufferedTime_ms, scale, maxScaling; JB4_DATAUNIT_HANDLE dataUnit; UWord16 extBufferedSamples; +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE Word16 timeScalingDone; +#endif Word16 result; ivas_error error; Word16 nSamplesRendered; @@ -2694,7 +2731,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE timeScalingDone = 0; +#endif nOutChannels = (UWord8) st_ivas->hDecoderConfig->nchan_out; nSamplesRendered = 0; move16(); @@ -2745,19 +2784,31 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } maxScaling = Mult_32_32( imult3216( hDecoderConfig->output_Fs, (Word16) maxScaling ), INV_1000_Q31 ); +#ifdef DEBUG_MODE_JBM + dbgwrite( &extBufferedSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_extBufferedSamples.dat" ); + dbgwrite( &systemTimestamp_ms, sizeof( uint32_t ), 1, 1, "./res/JBM_systemTimestamp.dat" ); + dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); + dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); +#endif /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) { +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + IF( hIvasDec->timeScalingDone ) +#else IF( timeScalingDone ) +#endif { scale = 100; move32(); } +#ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE ELSE { timeScalingDone = 1; move16(); } +#endif } /* limit scale to range supported by time scaler */ @@ -2850,6 +2901,10 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); move16(); move16(); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); +#endif } ELSE { @@ -2864,12 +2919,40 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); +#endif } } return IVAS_ERR_OK; } +// #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + +/*---------------------------------------------------------------------* + * update_voip_rendered20ms( ) + * + * Function to flush remaining audio in VoIP + *---------------------------------------------------------------------*/ + +static void update_voip_rendered20ms( + IVAS_DEC_HANDLE hIvasDec, + const Word16 nSamplesRendered ) +{ + Word16 nSamplesRenderedTotal; + nSamplesRenderedTotal = add( hIvasDec->hVoIP->nSamplesRendered20ms, nSamplesRendered ); + /* we have crossed a 20ms border, reset the time scaling done flag */ + IF( GE_16( nSamplesRenderedTotal, hIvasDec->hVoIP->nSamplesFrame ) ) + { + hIvasDec->timeScalingDone = 0; + move16(); + } + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; +} + +#endif /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_Flush( ) @@ -2895,7 +2978,22 @@ ivas_error IVAS_DEC_Flush( move16(); /* render IVAS frames */ - error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + error = IVAS_ERR_OK; + + test(); + IF( GE_16( nSamplesToRender, 0 ) && NE_16( hIvasDec->st_ivas->ivas_format, MONO_FORMAT ) ) + { +#endif + error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + } + ELSE + { + *nSamplesFlushed = 0; + move16(); + } +#endif return error; } -- GitLab From 0be4d09161d0577eef1ac26aa707c29314ad83f0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 3 Jun 2025 14:45:14 +0200 Subject: [PATCH 105/394] apply formatting patch --- lib_dec/lib_dec_fx.c | 413 +++++++++++++++++++++---------------------- 1 file changed, 205 insertions(+), 208 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index d16f862ec..78d00bc34 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1062,136 +1062,134 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ + return error; + } +} +{ + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + { + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) { return error; } } + + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + return error; + } + + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + return IVAS_ERR_UNKNOWN; + } - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) - { - return error; - } + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 } - - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { - return error; + return IVAS_ERR_UNKNOWN; } - - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 - } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 - } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - hIvasDec->timeScalingDone = 1; - move16(); -#endif + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 } - ELSE + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); + return IVAS_ERR_UNKNOWN; } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 1; + move16(); +#endif + } + ELSE + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - hIvasDec->hasBeenFedFrame = false; - move16(); - } - - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } - - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) { - *needNewFrame = false; - move16(); + return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; + move16(); } - *nOutSamples = nSamplesRendered; - move16(); + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - return IVAS_ERR_OK; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } +} +} + +*nOutSamples = nSamplesRendered; +move16(); + +return IVAS_ERR_OK; } @@ -2791,142 +2789,141 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif /* avoid time scaling multiple times in one sound card slot */ - IF( NE_64( scale, 100U ) ) - { + IF( NE_64( scale, 100U ) ){ #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE IF( hIvasDec->timeScalingDone ) #else IF( timeScalingDone ) #endif - { - scale = 100; - move32(); - } + { + scale = 100; + move32(); + } #ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - ELSE - { - timeScalingDone = 1; - move16(); - } + ELSE + { + timeScalingDone = 1; + move16(); + } #endif - } + } - /* limit scale to range supported by time scaler */ - IF( LT_32( scale, APA_MIN_SCALE ) ) - { - scale = APA_MIN_SCALE; - move32(); - } - ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) - { - scale = APA_MAX_SCALE; - move32(); - } + /* limit scale to range supported by time scaler */ + IF( LT_32( scale, APA_MIN_SCALE ) ) + { + scale = APA_MIN_SCALE; + move32(); + } + ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) + { + scale = APA_MAX_SCALE; + move32(); + } - IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* copy bitstream into decoder state */ - IF( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + IF( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Decoder has been initialized with first good frame - do PLC */ - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Decoder has been initialized with first good frame - do PLC */ + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - test(); - IF( jbmWriterFn != NULL && jbmWriter != NULL ) - { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; - } - } + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + test(); + IF( jbmWriterFn != NULL && jbmWriter != NULL ) + { + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; + } + } #endif - IF( dataUnit ) - { - IF( dataUnit->partial_frame != 0 ) - { - hVoIP->lastDecodedWasActive = 1; - } - ELSE - { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; - } - move16(); + IF( dataUnit ) + { + IF( dataUnit->partial_frame != 0 ) + { + hVoIP->lastDecodedWasActive = 1; + } + ELSE + { + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + } + move16(); - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); - } + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); + } - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; - move16(); - move16(); - } - } + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; + move16(); + move16(); + } +} - /* decode */ - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); - nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); - move16(); - move16(); +/* decode */ +IF( !hIvasDec->hasBeenFedFirstGoodFrame ) +{ + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); + nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); + move16(); + move16(); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); #endif - } - ELSE - { - Word16 nSamplesToRender, nSamplesRendered_loop; - bool tmp; - nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); +} +ELSE +{ + Word16 nSamplesToRender, nSamplesRendered_loop; + bool tmp; + nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); - /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); #endif - } - } +} +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } // #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE -- GitLab From 267a755e431645aadc587910346391446055b1e9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 3 Jun 2025 15:17:37 +0200 Subject: [PATCH 106/394] fix typo --- lib_dec/lib_dec_fx.c | 415 ++++++++++++++++++++++--------------------- 1 file changed, 209 insertions(+), 206 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 78d00bc34..a77f2a632 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1062,134 +1062,136 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ - return error; - } -} -{ - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) - { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) { return error; } } - - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) - { - return error; - } - - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { - return IVAS_ERR_UNKNOWN; - } + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) + { + return error; + } } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - return IVAS_ERR_UNKNOWN; + return error; } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 + } + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) + { + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 + } + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 1; + move16(); +#endif } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) + ELSE { - return IVAS_ERR_UNKNOWN; + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - hIvasDec->timeScalingDone = 1; - move16(); -#endif - } - ELSE - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); - } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + hIvasDec->hasBeenFedFrame = false; + move16(); } - } - hIvasDec->hasBeenFedFrame = false; - move16(); - } - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE - { - *needNewFrame = false; - move16(); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } + } } -} -} -*nOutSamples = nSamplesRendered; -move16(); + *nOutSamples = nSamplesRendered; + move16(); -return IVAS_ERR_OK; + return IVAS_ERR_OK; } @@ -2789,144 +2791,145 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif /* avoid time scaling multiple times in one sound card slot */ - IF( NE_64( scale, 100U ) ){ + IF( NE_64( scale, 100U ) ) + { #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE IF( hIvasDec->timeScalingDone ) #else IF( timeScalingDone ) #endif - { - scale = 100; - move32(); - } + { + scale = 100; + move32(); + } #ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - ELSE - { - timeScalingDone = 1; - move16(); - } + ELSE + { + timeScalingDone = 1; + move16(); + } #endif - } + } - /* limit scale to range supported by time scaler */ - IF( LT_32( scale, APA_MIN_SCALE ) ) - { - scale = APA_MIN_SCALE; - move32(); - } - ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) - { - scale = APA_MAX_SCALE; - move32(); - } + /* limit scale to range supported by time scaler */ + IF( LT_32( scale, APA_MIN_SCALE ) ) + { + scale = APA_MIN_SCALE; + move32(); + } + ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) + { + scale = APA_MAX_SCALE; + move32(); + } - IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* copy bitstream into decoder state */ - IF( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + IF( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Decoder has been initialized with first good frame - do PLC */ - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Decoder has been initialized with first good frame - do PLC */ + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - test(); - IF( jbmWriterFn != NULL && jbmWriter != NULL ) - { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; - } - } + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + test(); + IF( jbmWriterFn != NULL && jbmWriter != NULL ) + { + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; + } + } #endif - IF( dataUnit ) - { - IF( dataUnit->partial_frame != 0 ) - { - hVoIP->lastDecodedWasActive = 1; - } - ELSE - { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; - } - move16(); + IF( dataUnit ) + { + IF( dataUnit->partial_frame != 0 ) + { + hVoIP->lastDecodedWasActive = 1; + } + ELSE + { + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + } + move16(); - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); - } + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); + } - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; - move16(); - move16(); - } -} + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; + move16(); + move16(); + } + } -/* decode */ -IF( !hIvasDec->hasBeenFedFirstGoodFrame ) -{ - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); - nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); - move16(); - move16(); + /* decode */ + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); + nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); + move16(); + move16(); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); #endif -} -ELSE -{ - Word16 nSamplesToRender, nSamplesRendered_loop; - bool tmp; - nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); + } + ELSE + { + Word16 nSamplesToRender, nSamplesRendered_loop; + bool tmp; + nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); - /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); #endif -} -} + } + } -return IVAS_ERR_OK; + return IVAS_ERR_OK; } -// #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) -- GitLab From dbce6e5deb7e531db0649a10fa10fea8ed1d24ca Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 3 Jun 2025 16:32:43 +0200 Subject: [PATCH 107/394] run formatter again --- lib_dec/lib_dec_fx.c | 413 +++++++++++++++++++++---------------------- 1 file changed, 205 insertions(+), 208 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a77f2a632..abb182425 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1062,136 +1062,134 @@ ivas_error IVAS_DEC_GetSamples( { /* check if we need to run the setup function */ test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) - { + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ){ /* setup */ - IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &nSamplesRendered_loop, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ){ + return error; + } +} +{ + /* check if we need to run the setup function, tc decoding and feeding the renderer */ + test(); + IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + { + Word16 nResidualSamples, nSamplesTcsScaled; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + + test(); + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + { + IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) { return error; } } + + /* IVAS decoder */ + IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) { - /* check if we need to run the setup function, tc decoding and feeding the renderer */ - test(); - IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) + return error; + } + + /* JBM */ + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) { - Word16 nResidualSamples, nSamplesTcsScaled; - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + return IVAS_ERR_UNKNOWN; + } - test(); - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && NE_16( (Word16) nTransportChannels, hIvasDec->nTransportChannelsOld ) ) + // tmp apaExecBuffer + IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) + { + Word16 tmp_apaExecBuffer[APA_BUF]; + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( NE_32( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ), IVAS_ERR_OK ) ) - { - return error; - } + tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 } - - /* IVAS decoder */ - IF( NE_32( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer_fx, &nOutSamplesElse ) ), IVAS_ERR_OK ) ) + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) { - return error; + return IVAS_ERR_UNKNOWN; } - - /* JBM */ - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) { - IF( apa_set_scale_fx( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - // tmp apaExecBuffer - IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) - { - Word16 tmp_apaExecBuffer[APA_BUF]; - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - tmp_apaExecBuffer[i] = extract_l( L_shr( hIvasDec->apaExecBuffer_fx[i], Q11 ) ); // Q0 - } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - FOR( Word32 i = 0; i < APA_BUF_PER_CHANNEL * nTransportChannels; ++i ) - { - hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 - } - } - ELSE - { - IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); - nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); -#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - hIvasDec->timeScalingDone = 1; - move16(); -#endif + hIvasDec->apaExecBuffer_fx[i] = L_shl( tmp_apaExecBuffer[i], Q11 ); // Q11 } - ELSE + } + ELSE + { + IF( apa_exec_ivas_fx( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer_fx, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer_fx, &nTimeScalerOutSamples ) != 0 ) { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - move16(); + return IVAS_ERR_UNKNOWN; } + } + assert( LE_32( (Word32) nTimeScalerOutSamples, APA_BUF ) ); + nSamplesTcsScaled = idiv1616U( extract_l( nTimeScalerOutSamples ), nTransportChannels ); +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + hIvasDec->timeScalingDone = 1; + move16(); +#endif + } + ELSE + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + move16(); + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); + dbgwrite( &nTimeScalerOutSamples, sizeof( uint16_t ), 1, 1, "./res/JBM_nTimeScaleOutSamples.dat" ); #endif - /* Feed decoded transport channels samples to the renderer */ - IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* Feed decoded transport channels samples to the renderer */ + IF( NE_32( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer_fx ) ), IVAS_ERR_OK ) ) + { + return error; + } #ifdef DEBUG_MODE_JBM - dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); + dbgwrite( &nResidualSamples, sizeof( int16_t ), 1, 1, "./res/JBM_nResidualSamples.dat" ); #endif - IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - hIvasDec->hasBeenFedFrame = false; - move16(); - } - - /* render IVAS frames directly to the output buffer */ - nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); - IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) - { - return error; - } - - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); - nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); - IF( hIvasDec->nSamplesAvailableNext == 0 ) - { - *needNewFrame = true; - hIvasDec->needNewFrame = true; - move16(); - move16(); - } - ELSE + IF( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + IF( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (UWord16) nResidualSamples ) != 0 ) { - *needNewFrame = false; - move16(); + return IVAS_ERR_UNKNOWN; } } + hIvasDec->hasBeenFedFrame = false; + move16(); } - *nOutSamples = nSamplesRendered; - move16(); + /* render IVAS frames directly to the output buffer */ + nSamplesToRender = sub( nSamplesAsked, nSamplesRendered ); + IF( NE_32( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hIvasDec->nSamplesAvailableNext, pcmBuf + imult3216( nSamplesRendered, nOutChannels ) ) ), IVAS_ERR_OK ) ) + { + return error; + } - return IVAS_ERR_OK; + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesToRender = sub( nSamplesToRender, nSamplesRendered_loop ); + IF( hIvasDec->nSamplesAvailableNext == 0 ) + { + *needNewFrame = true; + hIvasDec->needNewFrame = true; + move16(); + move16(); + } + ELSE + { + *needNewFrame = false; + move16(); + } +} +} + +*nOutSamples = nSamplesRendered; +move16(); + +return IVAS_ERR_OK; } @@ -2791,142 +2789,141 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif /* avoid time scaling multiple times in one sound card slot */ - IF( NE_64( scale, 100U ) ) - { + IF( NE_64( scale, 100U ) ){ #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE IF( hIvasDec->timeScalingDone ) #else IF( timeScalingDone ) #endif - { - scale = 100; - move32(); - } + { + scale = 100; + move32(); + } #ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - ELSE - { - timeScalingDone = 1; - move16(); - } + ELSE + { + timeScalingDone = 1; + move16(); + } #endif - } + } - /* limit scale to range supported by time scaler */ - IF( LT_32( scale, APA_MIN_SCALE ) ) - { - scale = APA_MIN_SCALE; - move32(); - } - ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) - { - scale = APA_MAX_SCALE; - move32(); - } + /* limit scale to range supported by time scaler */ + IF( LT_32( scale, APA_MIN_SCALE ) ) + { + scale = APA_MIN_SCALE; + move32(); + } + ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) + { + scale = APA_MAX_SCALE; + move32(); + } - IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* copy bitstream into decoder state */ - IF( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + IF( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Decoder has been initialized with first good frame - do PLC */ - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Decoder has been initialized with first good frame - do PLC */ + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - test(); - IF( jbmWriterFn != NULL && jbmWriter != NULL ) - { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; - } - } + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + test(); + IF( jbmWriterFn != NULL && jbmWriter != NULL ) + { + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; + } + } #endif - IF( dataUnit ) - { - IF( dataUnit->partial_frame != 0 ) - { - hVoIP->lastDecodedWasActive = 1; - } - ELSE - { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; - } - move16(); + IF( dataUnit ) + { + IF( dataUnit->partial_frame != 0 ) + { + hVoIP->lastDecodedWasActive = 1; + } + ELSE + { + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + } + move16(); - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); - } + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); + } - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; - move16(); - move16(); - } - } + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; + move16(); + move16(); + } +} - /* decode */ - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); - nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); - move16(); - move16(); +/* decode */ +IF( !hIvasDec->hasBeenFedFirstGoodFrame ) +{ + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); + nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); + move16(); + move16(); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); #endif - } - ELSE - { - Word16 nSamplesToRender, nSamplesRendered_loop; - bool tmp; - nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); +} +ELSE +{ + Word16 nSamplesToRender, nSamplesRendered_loop; + bool tmp; + nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); - /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); #endif - } - } +} +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE -- GitLab From 2282b282328e9c151b1d0e62d1650a509f2bb3e2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 4 Jun 2025 10:42:56 +0200 Subject: [PATCH 108/394] replace modulo operator with loop --- lib_dec/lib_dec_fx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index abb182425..80f7f9685 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2946,7 +2946,14 @@ static void update_voip_rendered20ms( hIvasDec->timeScalingDone = 0; move16(); } - hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; + + /* float code was: hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; */ + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal; + move16(); + WHILE( GE_16( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame ) ) + { + hIvasDec->hVoIP->nSamplesRendered20ms = sub( hIvasDec->hVoIP->nSamplesRendered20ms, hIvasDec->hVoIP->nSamplesFrame ); + } } #endif -- GitLab From 36fea33c8cea65cbb0b45c55de2f720f03657d83 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 4 Jun 2025 12:45:38 +0200 Subject: [PATCH 109/394] fix comparison typo --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 80f7f9685..ce7af9ef8 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2986,7 +2986,7 @@ ivas_error IVAS_DEC_Flush( error = IVAS_ERR_OK; test(); - IF( GE_16( nSamplesToRender, 0 ) && NE_16( hIvasDec->st_ivas->ivas_format, MONO_FORMAT ) ) + IF( GT_16( nSamplesToRender, 0 ) && NE_16( (Word16) hIvasDec->st_ivas->ivas_format, (Word16) MONO_FORMAT ) ) { #endif error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hIvasDec->nSamplesAvailableNext, pcmBuf ); -- GitLab From c3e19ed30cc04e5265ea976872bf5f4d5d3c0251 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 11:31:37 +0200 Subject: [PATCH 110/394] Add missing change from the corresponding float branch --- lib_dec/lib_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index ce7af9ef8..aa8b6c873 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2759,7 +2759,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } } +#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + extBufferedSamples = nSamplesBuffered; +#else extBufferedSamples = add( nSamplesRendered, nSamplesBuffered ); +#endif Word16 exp; extBufferedTime_ms = BASOP_Util_Divide3232_Scale( imult3216( extBufferedSamples, 1000 ), hDecoderConfig->output_Fs, &exp ); extBufferedTime_ms = (UWord32) W_shr( extBufferedTime_ms, sub( 15, exp ) ); // Q0 -- GitLab From 8c7ba7805ab6638db39d919ffc1e65c17c719288 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 11:44:05 +0200 Subject: [PATCH 111/394] Fix braces in if statement and indentation --- lib_dec/lib_dec_fx.c | 215 ++++++++++++++++++++++--------------------- 1 file changed, 108 insertions(+), 107 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index aa8b6c873..318129f6d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2793,141 +2793,142 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif /* avoid time scaling multiple times in one sound card slot */ - IF( NE_64( scale, 100U ) ){ + IF( NE_64( scale, 100U ) ) + { #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE IF( hIvasDec->timeScalingDone ) #else IF( timeScalingDone ) #endif - { - scale = 100; - move32(); - } + { + scale = 100; + move32(); + } #ifndef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - ELSE - { - timeScalingDone = 1; - move16(); - } + ELSE + { + timeScalingDone = 1; + move16(); + } #endif - } + } - /* limit scale to range supported by time scaler */ - IF( LT_32( scale, APA_MIN_SCALE ) ) - { - scale = APA_MIN_SCALE; - move32(); - } - ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) - { - scale = APA_MAX_SCALE; - move32(); - } + /* limit scale to range supported by time scaler */ + IF( LT_32( scale, APA_MIN_SCALE ) ) + { + scale = APA_MIN_SCALE; + move32(); + } + ELSE IF( GT_32( scale, APA_MAX_SCALE ) ) + { + scale = APA_MAX_SCALE; + move32(); + } - IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = IVAS_DEC_VoIP_SetScale( hIvasDec, (Word16) maxScaling, (Word16) scale ) ), IVAS_ERR_OK ) ) + { + return error; + } - /* copy bitstream into decoder state */ - IF( dataUnit ) - { - hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; + /* copy bitstream into decoder state */ + IF( dataUnit ) + { + hIvasDec->hVoIP->hCurrentDataUnit = dataUnit; - bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); + bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) - { - /* Decoder has been initialized with first good frame - do PLC */ - IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE IF( hIvasDec->hasDecodedFirstGoodFrame ) + { + /* Decoder has been initialized with first good frame - do PLC */ + IF( NE_32( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ), IVAS_ERR_OK ) ) + { + return error; + } + } #ifdef SUPPORT_JBM_TRACEFILE - /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ - test(); - IF( jbmWriterFn != NULL && jbmWriter != NULL ) - { - /* write JBM trace data entry */ - store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); - IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError writing JBM Trace data to file\n" ); - return IVAS_ERR_UNKNOWN; - } - } + /* jbmWriterFn and jbmWriter may be NULL if tracefile writing was not requested on CLI */ + test(); + IF( jbmWriterFn != NULL && jbmWriter != NULL ) + { + /* write JBM trace data entry */ + store_JbmData( hVoIP, dataUnit, systemTimestamp_ms, extBufferedSamples, hDecoderConfig->output_Fs ); + IF( ( jbmWriterFn( &hVoIP->JbmTraceData, jbmWriter ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError writing JBM Trace data to file\n" ); + return IVAS_ERR_UNKNOWN; + } + } #endif - IF( dataUnit ) - { - IF( dataUnit->partial_frame != 0 ) - { - hVoIP->lastDecodedWasActive = 1; - } - ELSE - { - hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; - } - move16(); + IF( dataUnit ) + { + IF( dataUnit->partial_frame != 0 ) + { + hVoIP->lastDecodedWasActive = 1; + } + ELSE + { + hVoIP->lastDecodedWasActive = !dataUnit->silenceIndicator; + } + move16(); - /* data unit memory is no longer used */ - JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); - } + /* data unit memory is no longer used */ + JB4_FreeDataUnit( hVoIP->hJBM, dataUnit ); + } - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; - hIvasDec->nSamplesRendered = 0; - move16(); - move16(); - } -} + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; + hIvasDec->nSamplesRendered = 0; + move16(); + move16(); + } + } -/* decode */ -IF( !hIvasDec->hasBeenFedFirstGoodFrame ) -{ - /* codec mode to use not known yet - simply output silence */ - /* directly set output zero */ - Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); - set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); - nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); - hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); - move16(); - move16(); + /* decode */ + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + /* codec mode to use not known yet - simply output silence */ + /* directly set output zero */ + Word16 nSamplesToZero = s_min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); + set16_fx( pcmBuf + imult1616( nSamplesRendered, nOutChannels ), 0, imult1616( nSamplesToZero, nOutChannels ) ); + nSamplesRendered = add( nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesRendered = add( hIvasDec->nSamplesRendered, nSamplesToZero ); + hIvasDec->nSamplesAvailableNext = sub( hIvasDec->nSamplesAvailableNext, nSamplesToZero ); + move16(); + move16(); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); + update_voip_rendered20ms( hIvasDec, nSamplesToZero ); #endif -} -ELSE -{ - Word16 nSamplesToRender, nSamplesRendered_loop; - bool tmp; - nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); + } + ELSE + { + Word16 nSamplesToRender, nSamplesRendered_loop; + bool tmp; + nSamplesToRender = sub( nSamplesPerChannel, nSamplesRendered ); - /* render IVAS frames directly to the output buffer */ - IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) - { - return error; - } + /* render IVAS frames directly to the output buffer */ + IF( NE_32( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmBuf + imult1616( nSamplesRendered, nOutChannels ), &nSamplesRendered_loop, &tmp ) ), IVAS_ERR_OK ) ) + { + return error; + } - nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); + nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); + update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); #endif -} -} + } + } -return IVAS_ERR_OK; + return IVAS_ERR_OK; } #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE -- GitLab From dea11c9dfa834a7625eb7cf65dfa558291b54e1a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 12:02:05 +0200 Subject: [PATCH 112/394] Whitespace changes to minimise diff wrt original changes --- apps/decoder.c | 2 ++ lib_dec/lib_dec_fx.c | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index fdfc42054..2cc639e6a 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2477,6 +2477,7 @@ static ivas_error decodeVoIP( #endif } + #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE int16_t nSamplesFlushed = 0; @@ -2563,6 +2564,7 @@ static ivas_error decodeVoIP( } #endif + /*------------------------------------------------------------------------------------------* * Add zeros at the end to have equal length of synthesized signals *------------------------------------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 318129f6d..e1989effe 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -85,8 +85,8 @@ struct IVAS_DEC #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE Word16 timeScalingDone; /* have we done already one TSM in a 20ms frame? */ #endif - Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ Word16 tsm_quality; /*Q14*/ + Word32 *apaExecBuffer_fx; /* Buffer for APA scaling */ PCMDSP_APA_HANDLE hTimeScaler; bool needNewFrame; bool hasBeenFedFrame; @@ -2792,6 +2792,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( dbgwrite( &scale, sizeof( uint32_t ), 1, 1, "./res/JBM_scale.dat" ); dbgwrite( &maxScaling, sizeof( uint32_t ), 1, 1, "./res/JBM_maxScale.dat" ); #endif + /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) { @@ -2904,7 +2905,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( move16(); move16(); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesToZero ); #endif } @@ -2922,7 +2922,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( nSamplesRendered = add( nSamplesRendered, nSamplesRendered_loop ); #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - update_voip_rendered20ms( hIvasDec, nSamplesRendered_loop ); #endif } @@ -2932,7 +2931,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE - /*---------------------------------------------------------------------* * update_voip_rendered20ms( ) * -- GitLab From 57d62ec2f79460805c660881288008c1962adae1 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 12:07:07 +0200 Subject: [PATCH 113/394] Add missing move16 counter --- lib_dec/lib_dec_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index e1989effe..5c8f8ac08 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2761,6 +2761,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE extBufferedSamples = nSamplesBuffered; + move16(); #else extBufferedSamples = add( nSamplesRendered, nSamplesBuffered ); #endif -- GitLab From 23d04da560255d17065a42947911b5382614e1a4 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 13:13:19 +0200 Subject: [PATCH 114/394] Try to prevent clang-format from breaking indentation --- lib_dec/lib_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 5c8f8ac08..10c90f5a9 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2796,10 +2796,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* avoid time scaling multiple times in one sound card slot */ IF( NE_64( scale, 100U ) ) - { #ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE + { IF( hIvasDec->timeScalingDone ) #else + { IF( timeScalingDone ) #endif { -- GitLab From ddb4020390f158ea1611a013ff6d87829b76b508 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 13:21:44 +0200 Subject: [PATCH 115/394] Apply formatting patch --- lib_dec/lib_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 10c90f5a9..9a60d024f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2800,8 +2800,8 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { IF( hIvasDec->timeScalingDone ) #else - { - IF( timeScalingDone ) + { + IF( timeScalingDone ) #endif { scale = 100; -- GitLab From f06c3dbf256859248e191cda8423d9a820faf352 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 14:18:19 +0200 Subject: [PATCH 116/394] Modified the length calculation of the old_syn_Overl buffer in q_win computation. --- lib_dec/dec_tcx_fx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 4ab18e102..6b68ef930 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2575,6 +2575,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN static Word16 IMDCT_ivas_fx_calc_qwin( + Decoder_State *st, Word16 *syn_Overl_TDAC, Word16 Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2588,7 +2589,7 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { - Word16 oldLength, t; + Word16 oldLength, t, old_syn_Overl_len; oldLength = s_min( L_FRAME32k, L_frame ); t = L_FRAME32k; @@ -2600,14 +2601,20 @@ static Word16 IMDCT_ivas_fx_calc_qwin( move16(); } + old_syn_Overl_len = st->hTcxCfg->tcx_mdct_window_length; + IF( ( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) ) || EQ_16( st->last_core, ACELP_CORE ) ) + { + old_syn_Overl_len = shr( st->L_frame, 1 ); + } + q_win = 6; move16(); // q_win == norm + Q_syn_Overl_TDAC - q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, oldLength / 2 ) + Q_syn_Overl_TDAC ); + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, shr(oldLength, 1) ) + Q_syn_Overl_TDAC ); // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( syn_Overl, t / 2 ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( old_syn_Overl, oldLength / 2 ) + Q_old_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, shr(t, 1) ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); @@ -3001,7 +3008,7 @@ void IMDCT_ivas_fx( IF( allow_qwin_change ) { // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); - q_win = IMDCT_ivas_fx_calc_qwin( syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, + q_win = IMDCT_ivas_fx_calc_qwin( st, syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, L_frame, L_frameTCX, FB_flag ); } #else -- GitLab From d8a74f2a3593a5c61f259287dcd2a64bb240dce4 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 14:36:27 +0200 Subject: [PATCH 117/394] Applied clang formatting patch. --- lib_dec/dec_tcx_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 6b68ef930..60c5e078a 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2575,7 +2575,7 @@ void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_T #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN static Word16 IMDCT_ivas_fx_calc_qwin( - Decoder_State *st, + Decoder_State *st, Word16 *syn_Overl_TDAC, Word16 Q_syn_Overl_TDAC, Word16 *syn_Overl, @@ -2589,7 +2589,7 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { - Word16 oldLength, t, old_syn_Overl_len; + Word16 oldLength, t, old_syn_Overl_len; oldLength = s_min( L_FRAME32k, L_frame ); t = L_FRAME32k; @@ -2606,14 +2606,14 @@ static Word16 IMDCT_ivas_fx_calc_qwin( { old_syn_Overl_len = shr( st->L_frame, 1 ); } - + q_win = 6; move16(); // q_win == norm + Q_syn_Overl_TDAC - q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, shr(oldLength, 1) ) + Q_syn_Overl_TDAC ); + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, shr( oldLength, 1 ) ) + Q_syn_Overl_TDAC ); // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( syn_Overl, shr(t, 1) ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, shr( t, 1 ) ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); -- GitLab From 7a7d3f5bf0cdd7472472f5191dc903648368d073 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 16:44:43 +0200 Subject: [PATCH 118/394] Modified the length calculation of the Q_syn_Overl_TDAC and syn_Overl buffers in q_win computation. --- lib_dec/dec_tcx_fx.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 60c5e078a..62c06a2c5 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2589,7 +2589,7 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { - Word16 oldLength, t, old_syn_Overl_len; + Word16 oldLength, t, old_syn_Overl_len, syn_Overl_TDAC_len; oldLength = s_min( L_FRAME32k, L_frame ); t = L_FRAME32k; @@ -2602,18 +2602,26 @@ static Word16 IMDCT_ivas_fx_calc_qwin( } old_syn_Overl_len = st->hTcxCfg->tcx_mdct_window_length; + syn_Overl_TDAC_len = s_max( st->hTcxCfg->tcx_mdct_window_length_old, 0 ); + IF( ( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) ) || EQ_16( st->last_core, ACELP_CORE ) ) { old_syn_Overl_len = shr( st->L_frame, 1 ); + syn_Overl_TDAC_len = shr( st->last_L_frame, 1 ); + } + + IF( st->prev_bfi && ( st->last_core_bfi == ACELP_CORE ) ) + { + syn_Overl_TDAC_len = old_syn_Overl_len; } q_win = 6; move16(); // q_win == norm + Q_syn_Overl_TDAC - q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, shr( oldLength, 1 ) ) + Q_syn_Overl_TDAC ); + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ) + Q_syn_Overl_TDAC ); // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( syn_Overl, shr( t, 1 ) ) + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, old_syn_Overl_len ) + Q_syn_Overl ); q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); -- GitLab From b5b3ab48befebdd592664b32917923af91639974 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 16:50:01 +0200 Subject: [PATCH 119/394] Applied clang formatting patch. --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 62c06a2c5..3604fa633 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2609,7 +2609,7 @@ static Word16 IMDCT_ivas_fx_calc_qwin( old_syn_Overl_len = shr( st->L_frame, 1 ); syn_Overl_TDAC_len = shr( st->last_L_frame, 1 ); } - + IF( st->prev_bfi && ( st->last_core_bfi == ACELP_CORE ) ) { syn_Overl_TDAC_len = old_syn_Overl_len; -- GitLab From 2a7486511d2ecb39d5ddcd40d509e61545fbdd50 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 17:11:02 +0200 Subject: [PATCH 120/394] Removed unused variable to solve linux build failure. --- lib_dec/dec_tcx_fx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 3604fa633..602aa7bbb 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2589,14 +2589,12 @@ static Word16 IMDCT_ivas_fx_calc_qwin( const Word16 L_frameTCX, const Word16 FB_flag ) { - Word16 oldLength, t, old_syn_Overl_len, syn_Overl_TDAC_len; + Word16 t, old_syn_Overl_len, syn_Overl_TDAC_len; - oldLength = s_min( L_FRAME32k, L_frame ); t = L_FRAME32k; move16(); if ( FB_flag ) { - oldLength = s_min( L_FRAME48k, L_frameTCX ); t = L_FRAME48k; move16(); } -- GitLab From d43e90a0970fea160b9d20cae6ac4c6cee3592b4 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 17:24:24 +0200 Subject: [PATCH 121/394] Removed unused variable to solve linux build failure. --- lib_dec/dec_tcx_fx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 602aa7bbb..c705ebd7a 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2585,8 +2585,6 @@ static Word16 IMDCT_ivas_fx_calc_qwin( Word16 *old_out_fx, Word16 Q_old_out_fx, Word16 q_win, - const Word16 L_frame, - const Word16 L_frameTCX, const Word16 FB_flag ) { Word16 t, old_syn_Overl_len, syn_Overl_TDAC_len; @@ -3015,7 +3013,7 @@ void IMDCT_ivas_fx( { // q_win = IMDCT_ivas_fx_adjust_qwin( *Q_syn_Overl_TDAC_fx, *Q_old_syn_overl_fx, hTcxDec->Q_old_syn_Overl, *q_old_out_fx, q_win ); q_win = IMDCT_ivas_fx_calc_qwin( st, syn_Overl_TDAC_fx, *Q_syn_Overl_TDAC_fx, old_syn_overl_fx, *Q_old_syn_overl_fx, - hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, L_frame, L_frameTCX, FB_flag ); + hTcxDec->old_syn_Overl, hTcxDec->Q_old_syn_Overl, old_out_fx, *q_old_out_fx, q_win, FB_flag ); } #else x_e_hdrm = add( q_win, sub( Q16, q_x ) ); -- GitLab From 071e71bc8a0a221ae139d836bfc65c74b2981263 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 6 Jun 2025 16:40:25 +0530 Subject: [PATCH 122/394] Fix for 3GPP issue 1502: MC 512 decoder with headtracking has high frequency artifacts (issue not seen w/o headtracking) Link #1502 #1040 #1348 --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 883024002..0cb470adc 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2879,7 +2879,7 @@ void IMDCT_ivas_fx( { Word16 q_old_out = q_win; move16(); - edct_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); + edct_ivas_fx( x_fx, xn_buf_fx_32 + add( shr( overlap, 1 ), nz ), L_frame, &q_xn_buf_fx_32 ); Word16 res_m, res_e; res_e = 0; move16(); -- GitLab From 15838fc796dbe1c8f1bbfca869655d8ad5f9c122 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 11 Jun 2025 11:42:00 +0200 Subject: [PATCH 123/394] [renderer] add OSBA/OMASA CLI support and update printouts. see float MRs 1908 and 2146. --- apps/renderer.c | 149 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 49 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 47548d438..317713c05 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -149,7 +149,7 @@ typedef struct int32_t sampleRate; InputConfig inConfig; OutputConfig outConfig; - char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH]; + char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH]; int16_t numInMetadataFiles; char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -217,13 +217,13 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputFormat, .match = "input_format", .matchShort = "if", - .description = "Audio format of input file (e.g. 5_1 or HOA3 or META, use -l for a list)", + .description = "Audio format of input file (e.g. 5_1 or HOA3 or META,\nuse -l for a list)", }, { .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .matchShort = "im", - .description = "Space-separated list of path to metadata files for ISM or MASA inputs", + .description = "Space-separated list of path to metadata files for ISM/MASA/OMASA/\nOSBA inputs. \nFor OMASA, ISM files must be specified first.", }, { .id = CmdLnOptionId_outputFile, @@ -241,57 +241,59 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_sampleRate, .match = "sample_rate", .matchShort = "fs", - .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs", + .description = "Input sampling rate in kHz (16, 32, 48) - required only with raw\nPCM inputs", }, { .id = CmdLnOptionId_trajFile, .match = "trajectory_file", .matchShort = "T", - .description = "Head rotation trajectory file for simulation of head tracking (only for binaural outputs)", + .description = "Head rotation trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", .matchShort = "rf", - .description = "Reference rotation trajectory file for simulation of head tracking (only for binaural outputs)", + .description = "Reference rotation trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_customHrtfFile, .match = "custom_hrtf", .matchShort = "hrtf", - .description = "Custom HRTF file for binaural rendering (only for binaural outputs)", + .description = "Custom HRTF file for binaural rendering\n(only for binaural outputs)", }, { .id = CmdLnOptionId_renderConfigFile, .match = "render_config_parameters", .matchShort = "render_config", - .description = "Binaural renderer configuration parameters in file (only for binaural outputs)", + .description = "Binaural renderer configuration parameters in file\n(only for binaural outputs)", }, { .id = CmdLnOptionId_nonDiegeticPan, .match = "non_diegetic_panning", .matchShort = "non_diegetic_pan", - .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right, center or c or 0 ->middle\n", + .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right,\ncenter or c or 0 ->middle", }, { .id = CmdLnOptionId_orientationTracking, .match = "tracking_type", .matchShort = "otr", - .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for binaural outputs)", + .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec`\nor `ref_vec_lev` (only for binaural outputs)", }, { .id = CmdlnOptionId_lfePosition, .match = "lfe_position", .matchShort = "lp", - .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees.\nIf specified, overrides the default behavior which attempts to map input to output LFE channel(s)", + .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth,\nelevation] where gain is linear (like --gain, -g) and azimuth,\nelevation are in degrees. If specified, overrides the default\nbehavior which attempts to map input to output LFE channel(s)", + }, + { + .id = CmdlnOptionId_lfeMatrix, + .match = "lfe_matrix", + .matchShort = "lm", + .description = "LFE panning matrix. File (CSV table) containing a matrix of\ndimensions [ num_input_lfe x num_output_channels ] with elements\nspecifying linear routing gain (like --gain, -g). If specified,\noverrides the output LFE position option and the default\nbehavior which attempts to map input to output LFE channel(s)", }, - { .id = CmdlnOptionId_lfeMatrix, - .match = "lfe_matrix", - .matchShort = "lm", - .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)" }, { .id = CmdLnOptionId_noDelayCmp, - .match = "no_delay_comparison", + .match = "no_delay_compensation", .matchShort = "no_delay_cmp", .description = "[flag] Turn off delay compensation", }, @@ -299,7 +301,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_complexityLevel, .match = "complexity_level", .matchShort = "level", - .description = "Complexity level, level = (1, 2, 3), will be defined after characterisation.", + .description = "Complexity level, level = (1, 2, 3), will be defined after\ncharacterisation.", }, { .id = CmdLnOptionId_quietModeEnabled, @@ -323,13 +325,13 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_referenceVectorFile, .match = "reference_vector_file", .matchShort = "rvf", - .description = "Reference vector trajectory file for simulation of head tracking (only for binaural outputs)", + .description = "Reference vector trajectory file for simulation of head tracking\n(only for binaural outputs)", }, { .id = CmdLnOptionId_exteriorOrientationFile, .match = "exterior_orientation_file", .matchShort = "exof", - .description = "External orientation trajectory file for simulation of external orientations", + .description = "External orientation trajectory file for simulation of external\norientations", }, { .id = CmdLnOptionId_framing, @@ -341,19 +343,19 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_syncMdDelay, .match = "sync_md_delay", .matchShort = "smd", - .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by 5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)", + .description = "Metadata Synchronization Delay in ms, Default is 0. Quantized by\n5ms subframes for TDRenderer (13ms -> 10ms -> 2subframes)", }, { .id = CmdLnOptionId_directivityPatternId, .match = "ism_directivity_pattern_id", .matchShort = "dpid", - .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up to 4 numbers (unsigned integers) can be specified for BINAURAL and BINAURAL_ROOM_REVERB output configuration.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\nThis options needs to be accompanied by a render_config file, otherwise a default directivity pattern is used.", + .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated\nlist of up to 4 numbers (unsigned integers) can be specified for\nBINAURAL and BINAURAL_ROOM_REVERB output.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for\nISMs 1,2,3 and 4 respectively. \nThis option needs to be accompanied by a render_config file,\notherwise a default directivity pattern is used.", }, { .id = CmdLnOptionId_acousticEnvironmentId, .match = "acoustic_environment_id", .matchShort = "aeid", - .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration", + .description = "Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output.", }, }; @@ -368,6 +370,8 @@ static IVAS_AUDIO_CONFIG ambisonicsOrderToEnum( const int16_t order ); static void parseSceneDescriptionFile( char *path, char *audioFilePath, InputConfig *inConfig, IsmPositionProvider *positionProvider, MasaFileReader **masaReaders, LfeRoutingConfig **lfeRoutingConfigs ); +static void parseCombinedFormatInput( InputConfig *inConfig, char **configString ); + static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom ); static CmdlnArgs parseCmdlnArgs( const int argc, char **argv ); @@ -584,25 +588,7 @@ static void setupWithSingleFormatInput( strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 ); /* Depending on input format, prepare metadata reading for ISM or MASA */ - if ( args.inConfig.numMasaBuses != 0 ) - { - if ( args.inConfig.numMasaBuses != args.numInMetadataFiles ) - { - fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" ); - exit( -1 ); - } - - for ( int16_t i = 0; i < args.numInMetadataFiles; ++i ) - { - masaReaders[i] = MasaFileReader_open( args.inMetadataFilePaths[i] ); - if ( masaReaders[i] == NULL ) - { - fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] ); - exit( -1 ); - } - } - } - else if ( args.inConfig.numAudioObjects != 0 ) + if ( args.inConfig.numAudioObjects != 0 ) { positionProvider->numObjects = args.inConfig.numAudioObjects; for ( int16_t i = 0; i < positionProvider->numObjects; ++i ) @@ -625,6 +611,26 @@ static void setupWithSingleFormatInput( } } } + if ( args.inConfig.numMasaBuses != 0 ) + { + if ( args.inConfig.numMasaBuses != ( args.numInMetadataFiles - args.inConfig.numAudioObjects ) ) + { + fprintf( stderr, "Error: all MASA inputs must have a corresponding metadata file" ); + exit( -1 ); + } + + int16_t reader_idx = 0; + for ( int16_t i = args.inConfig.numAudioObjects; i < args.numInMetadataFiles; ++i ) + { + reader_idx = i - args.inConfig.numAudioObjects; + masaReaders[reader_idx] = MasaFileReader_open( args.inMetadataFilePaths[i] ); + if ( masaReaders[reader_idx] == NULL ) + { + fprintf( stderr, "Could not open MASA metadata file %s\n", args.inMetadataFilePaths[i] ); + exit( -1 ); + } + } + } return; } @@ -1804,16 +1810,11 @@ static bool parseInConfig( inConfig->masaBuses[0].gain_dB = 0.0f; break; case IVAS_AUDIO_CONFIG_OBA: - /* If input format is objects, parse the characters after "ISM" to get number of objects */ + /* If input format is objects, parse the characters after "ISM" to get + * number of objects and check for combined formats. */ { char *ptr = NULL; inConfig->numAudioObjects = (uint16_t) strtol( inFormatStr + 3, &ptr, 10 ); - if ( ptr == NULL || *ptr != '\0' ) - { - /* Failed to parse string as a number */ - fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr ); - return false; - } if ( inConfig->numAudioObjects > RENDERER_MAX_ISM_INPUTS ) { fprintf( stderr, "Too many objects at input. Max %d supported.", RENDERER_MAX_ISM_INPUTS ); @@ -1825,6 +1826,17 @@ static bool parseInConfig( inConfig->audioObjects[i].inputChannelIndex = i; inConfig->audioObjects[i].gain_dB = 0.0f; } + if ( *ptr != '\0' ) + { + /* Try to parse combined format */ + parseCombinedFormatInput( inConfig, &ptr ); + } + if ( ptr == NULL || *ptr != '\0' ) + { + /* Failed to parse string as a number */ + fprintf( stderr, "Cannot parse string \"%s\" as a valid input format", inFormatStr ); + return false; + } } break; case IVAS_AUDIO_CONFIG_INVALID: @@ -2255,7 +2267,7 @@ static void parseOption( } break; case CmdLnOptionId_inputMetadata: - assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS ); + assert( numOptionValues <= RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS ); for ( int16_t i = 0; i < numOptionValues; ++i ) { strncpy( args->inMetadataFilePaths[i], optionValues[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); @@ -3086,6 +3098,41 @@ static void parseMasa( return; } +static void parseCombinedFormatInput( + InputConfig *inConfig, + char **configString ) +{ + IVAS_AUDIO_CONFIG audioConfig; + audioConfig = parseAudioConfig( *configString ); + + if ( audioConfig == IVAS_AUDIO_CONFIG_FOA || audioConfig == IVAS_AUDIO_CONFIG_HOA2 || audioConfig == IVAS_AUDIO_CONFIG_HOA3 ) + { + /* OSBA */ + inConfig->numAmbisonicsBuses = 1; + inConfig->ambisonicsBuses[0].audioConfig = audioConfig; + inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects; + inConfig->ambisonicsBuses[0].gain_dB = -6.f; + *configString += 4; + + /* Modify input gain for objects too */ + for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i ) + { + inConfig->audioObjects[i].gain_dB = -6.f; + } + } + else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) + { + /* OMASA */ + inConfig->numMasaBuses = 1; + inConfig->masaBuses[0].audioConfig = audioConfig; + inConfig->masaBuses[0].inputChannelIndex = inConfig->numAudioObjects; + inConfig->masaBuses[0].gain_dB = 0.0f; + *configString += 5; + } + + return; +} + static ivas_error parseCustomLayoutFile( const char *filePath, IVAS_CUSTOM_LS_DATA *pLsSetupCustom ) @@ -3302,10 +3349,13 @@ static void printSupportedAudioConfigs( void ) "HOA2", "HOA3", "ISMx (input only)", + "ISMxSBAy (OSBA, input only)", + "ISMxMASAy (OMASA, input only)", "MASAx", "BINAURAL (output only)", "BINAURAL_ROOM_IR (output only)", "BINAURAL_ROOM_REVERB (output only)", + "META (Scene description, input only)", }; fprintf( stdout, "Supported audio formats:\n" ); @@ -3313,6 +3363,7 @@ static void printSupportedAudioConfigs( void ) { fprintf( stdout, "%s\n", supportedFormats[i] ); } + fprintf( stdout, "\n" ); return; } -- GitLab From cde20f9aded676ccd13799996d59e125c3dfe1d4 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 12 Jun 2025 10:59:38 +0200 Subject: [PATCH 124/394] Fix wrong s_min which should be s_max for cldfb band range of upper bands. Corrects wrong scaling of reference_power_fx and reference_power_smooth_fx vectors. --- lib_rend/ivas_dirac_rend_fx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 99a84bf52..6bbdd8a43 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4295,14 +4295,14 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4371,14 +4371,14 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q } DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4445,14 +4445,14 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4774,7 +4774,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4787,7 +4787,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4823,11 +4823,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) FOR( i = 0; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) - Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) } hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); move16(); @@ -4893,14 +4893,14 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } -- GitLab From 8b00348b339aa0f62577b9129991e33506a7c97f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 14:19:51 +0530 Subject: [PATCH 125/394] Fix for 3GPP issue 1742: High audio distortion in external rendering OMASA to MASA Link #1742 --- lib_rend/ivas_omasa_ana_fx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index d82346d34..84f1ff3dc 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -451,8 +451,8 @@ static void ivas_omasa_param_est_ana_fx( inp_q = data_f_q; cldfbAnalysis_ts_fx_var_q( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < nchan_ism; i++ ) @@ -697,25 +697,25 @@ static void ivas_omasa_dmx_fx( data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] ); move32(); } - } - max_e = in_e[0]; - move16(); - FOR( l = 1; l < L_FRAME48k; l++ ) - { - IF( LT_16( max_e, in_e[l] ) ) + max_e = in_e[0]; + move16(); + FOR( l = 1; l < L_FRAME48k; l++ ) { - max_e = in_e[l]; - move16(); + IF( LT_16( max_e, in_e[l] ) ) + { + max_e = in_e[l]; + move16(); + } } - } - FOR( l = 0; l < L_FRAME48k; l++ ) - { - data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) - move32(); + FOR( l = 0; l < L_FRAME48k; l++ ) + { + data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e ) + move32(); + } + data_e[j] = max_e; + move16(); } - data_e[j] = max_e; - move16(); prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31 move32(); -- GitLab From 8cfb2caf8f303f22c4c28f5e2f37907df4db149b Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 12 Jun 2025 17:23:46 +0200 Subject: [PATCH 126/394] Encapsulate changes under FIX_1737_FIX_867_CLDFB_NRG_SCALE. Fix additional scaling issues found. Use L_norm_arr instead of getScaleFactor32 for CLDFB normalization because getScaleFactor32 returns 0 for zero signal causing scale values out of range which lead to a crash. --- lib_com/options.h | 1 + lib_rend/ivas_dirac_rend_fx.c | 68 +++++++++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9dc7e7fd1..c5961b2a7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -69,6 +69,7 @@ #endif #define FIX_867_CLDFB_NRG_SCALE +#define FIX_1737_FIX_867_CLDFB_NRG_SCALE #define FIX_1378_ACELP_OUT_OF_BOUNDS diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 6bbdd8a43..1aa0fc587 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -986,7 +986,12 @@ ivas_error ivas_dirac_alloc_mem_fx( } hDirAC_mem->reference_power_len = imult1616( 5, num_freq_bands ); +#ifdef FIX_867_CLDFB_NRG_SCALE set16_fx( hDirAC_mem->reference_power_q, Q31, 2 ); +#else + hDirAC_mem->reference_power_q = Q31; + move16(); +#endif } IF( hDirACRend->proto_signal_decorr_on ) @@ -4295,14 +4300,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4371,14 +4384,26 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; +#else DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[1]; +#endif move16(); } ELSE { - Scale_sig32( reference_power_fix, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4445,14 +4470,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { - Scale_sig32( reference_power_fix, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4774,7 +4807,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) +#else + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4787,7 +4824,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) +#else + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); move16(); @@ -4823,11 +4864,19 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#else + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#endif FOR( i = 0; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#else + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) +#endif } hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); move16(); @@ -4893,14 +4942,22 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( i = hSpatParamRendCom->num_freq_bands; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q +#endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; move16(); } ELSE { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#else + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q +#endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); } @@ -4940,10 +4997,17 @@ static void ivas_masa_ext_dirac_render_sf_fx( { FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { +#ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + scale_factor = s_min( scale_factor, L_norm_arr( Cldfb_RealBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); + scale_factor = s_min( scale_factor, L_norm_arr( Cldfb_ImagBuffer_fx[ch][slot_idx], + hSpatParamRendCom->num_freq_bands ) ); +#else scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_RealBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ) ); scale_factor = s_min( scale_factor, getScaleFactor32( Cldfb_ImagBuffer_fx[ch][slot_idx], hSpatParamRendCom->num_freq_bands ) ); +#endif } } scale_factor = sub( scale_factor, find_guarded_bits_fx( hSpatParamRendCom->num_freq_bands ) ); // guard bits -- GitLab From 6086a910d7ef8950b5950ffd6f043f61f20f2f21 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 12 Jun 2025 17:26:35 +0200 Subject: [PATCH 127/394] clang format --- lib_rend/ivas_dirac_rend_fx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 1aa0fc587..2aa9eb605 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4303,7 +4303,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; @@ -4314,7 +4314,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); @@ -4402,7 +4402,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); @@ -4473,7 +4473,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; @@ -4484,7 +4484,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); @@ -4810,7 +4810,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) #else - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) #endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); @@ -4863,19 +4863,19 @@ static void ivas_masa_ext_dirac_render_sf_fx( /*Buffer rescaling*/ #ifdef FIX_867_CLDFB_NRG_SCALE - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #else - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #endif FOR( i = 0; DirAC_mem.reference_power_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) { - Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ), DirAC_mem.reference_power_q[0] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #else - Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) + Scale_sig32( DirAC_mem.reference_power_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] ), DirAC_mem.reference_power_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q, DirAC_mem.reference_power_q ) #endif } hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[0], DirAC_mem.reference_power_q[0] ); @@ -4945,7 +4945,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; @@ -4956,7 +4956,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); -- GitLab From 1876a8248085ce22bd7391de4d679cda9d567534 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 13 Jun 2025 09:42:59 +0200 Subject: [PATCH 128/394] in ivas_mc_param_enc_fx.c: initialize the proper arrays. In ivas_dirac_output_synthesis_cov_fx.c: remove the define which was supposed to be set in options.h --- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index caddb5c5c..378e4f435 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE #include #include diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 7f74f78f9..ac836b674 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -729,8 +729,8 @@ static void ivas_param_mc_param_est_enc_fx( #ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE set64_fx( Cy_sum_imag_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); #else - set32_fx( Cy_sum_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); - set16_fx( Cy_sum_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); + set32_fx( Cy_sum_imag_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); + set16_fx( Cy_sum_imag_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); #endif } -- GitLab From ff910e8916731097fa517825b87be81746e8b964 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 12:51:21 +0200 Subject: [PATCH 129/394] changes for fixing issue 1744, NON-BE, fixes several coding errors, should improve quality --- lib_com/options.h | 3 +++ lib_dec/ivas_spar_md_dec_fx.c | 22 +++++++++++++++++++--- lib_enc/ivas_dirac_enc_fx.c | 17 +++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9dc7e7fd1..de111668a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,4 +111,7 @@ #define FIX_1733_CLDFB_BUG #define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ +#define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */ +#define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */ + #endif diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 7f487a75c..3e7a4b3f5 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -44,6 +44,9 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC +#define INV_PI_DEG180_Q_22 ( (Word32) 0x394BB835 ) /* 2.0/PI in Q31 times DEGREE_180_Q_22) */ +#endif #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) @@ -2946,8 +2949,13 @@ void ivas_spar_to_dirac_fx( radius_fx = Sqrt32( temp, &q_temp ); Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/ - Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 azi_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_azi_fx ); +#else Word16 check_azi_fx_res; + Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ + IF( check_azi_fx_32 < 0 ) { check_azi_fx_res = negate( divide3232( L_negate( check_azi_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ @@ -2957,6 +2965,8 @@ void ivas_spar_to_dirac_fx( check_azi_fx_res = divide3232( check_azi_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/ +#endif + azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 azi_res; @@ -2970,9 +2980,14 @@ void ivas_spar_to_dirac_fx( } Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/ - Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ +#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC + Word32 ele_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_ele_fx ); +#else + Word16 check_ele_fx_res; - IF( check_azi_fx_32 < 0 ) + Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/ + + IF( check_ele_fx_32 < 0 ) { check_ele_fx_res = negate( divide3232( L_negate( check_ele_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/ } @@ -2981,6 +2996,7 @@ void ivas_spar_to_dirac_fx( check_ele_fx_res = divide3232( check_ele_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/ } Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/ +#endif ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 ele_res; diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index be15b5048..5e9a50497 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -660,8 +660,20 @@ static Word16 ivas_dirac_get_mono_flag_fx( move32(); move16(); } - - IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 0 ) +#ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31-16, Mpy_32_32(other_ch_band_power, threshold), threshold_e ) == 1 ) + /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ + { + any_mono_band = 1; + move16(); + } + ELSE + { + any_mc_band = 1; + move16(); + } +#else + IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 1 ) { any_mono_band = 1; move16(); @@ -671,6 +683,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( any_mc_band = 1; move16(); } +#endif } } } -- GitLab From 0ee162a3996b7bc58e7bc9ccc0011daef42df3d6 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 13:19:16 +0200 Subject: [PATCH 130/394] fix clang format issues --- lib_dec/ivas_spar_md_dec_fx.c | 4 ++-- lib_enc/ivas_dirac_enc_fx.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 3e7a4b3f5..be31cebbb 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -2967,7 +2967,7 @@ void ivas_spar_to_dirac_fx( Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/ #endif - azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ + azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 azi_res; IF( azi_intermediate < 0 ) @@ -2997,7 +2997,7 @@ void ivas_spar_to_dirac_fx( } Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/ #endif - ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ + ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/ Word16 ele_res; IF( ele_intermediate < 0 ) diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 5e9a50497..0941e0e85 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -661,7 +661,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG - IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31-16, Mpy_32_32(other_ch_band_power, threshold), threshold_e ) == 1 ) + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31 - 16, Mpy_32_32( other_ch_band_power, threshold ), threshold_e ) == 1 ) /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ { any_mono_band = 1; -- GitLab From df97c617fb4859bbee367cbf1ed1fc63a6f23a3f Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 20:08:58 +0200 Subject: [PATCH 131/394] fixed issue 1744 (mr 1778) with exponent setting for divide3232 --- lib_enc/ivas_dirac_enc_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 0941e0e85..4ad039fae 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -661,8 +661,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #ifdef FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG - IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, 31 - 16, Mpy_32_32( other_ch_band_power, threshold ), threshold_e ) == 1 ) - /* -16 is needed because divide3232() returned a 16-Bit value, and this 16-bit value was passed to an 32-bit mantissa argument*/ + IF( BASOP_Util_Cmp_Mant32Exp( W_band_power, W_band_power_e, Mpy_32_32( other_ch_band_power, threshold ), other_ch_band_power_e + threshold_e ) == 1 ) { any_mono_band = 1; move16(); @@ -673,7 +672,7 @@ static Word16 ivas_dirac_get_mono_flag_fx( move16(); } #else - IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 1 ) + IF( BASOP_Util_Cmp_Mant32Exp( divide3232( W_band_power, other_ch_band_power ), 31, threshold, threshold_e ) == 0 ) { any_mono_band = 1; move16(); -- GitLab From 7d3d159591efe93ed88799a3137b5ea66f11d472 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 09:58:12 +0530 Subject: [PATCH 132/394] Fix for 3GPP issue 1739: Crash in Stereo BASOP Enc -> Stereo BASOP Dec at 32 kbps with DTX, bandwidth switching and 5% FER Link #1739 The issue is caused due to deviations observed with msNoiseEst. Only for this test case, over-flow occurs. The root cause is as described in issue #859. Currently, to address the crash issue, saturation is being added. --- lib_dec/ivas_stereo_dft_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 914c7fad1..d3aeee455 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2608,7 +2608,7 @@ void stereo_dft_dec_fx( q_cna_level = hFdCngDec->smoothed_psd_exp; move16(); l_tmp = Sqrt32( cna_level, &q_cna_level ); - scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* q_cna_level */ + scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* Q = (31-q_cna_level) + Q15 - 31 */ /* scale_fact0 will be in Q15 by the time the above operation is performed so the q of scale_fact represented now by q_cna_level has to be updated @@ -2628,12 +2628,12 @@ void stereo_dft_dec_fx( l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ #endif /* OPT_STEREO_32KBPS_V1 */ - DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */ + DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); #ifdef OPT_STEREO_32KBPS_V1 l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ + DFT_R[2 * i] = L_add_sat( DFT_R[2 * i], l_tmp ); /* q_dft */ #else /* OPT_STEREO_32KBPS_V1 */ l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ -- GitLab From 486e2af24a4b9a094a6bb5e62d26d847998422cc Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 12:12:20 +0530 Subject: [PATCH 133/394] Fixed crash at another location having same issue --- lib_dec/ivas_stereo_dft_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index d3aeee455..11f266d2e 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2646,11 +2646,11 @@ void stereo_dft_dec_fx( #ifdef OPT_STEREO_32KBPS_V1 l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ + DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ move32(); l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ + DFT_R[2 * i + 1] = L_add_sat( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ move32(); #else /* OPT_STEREO_32KBPS_V1 */ l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ -- GitLab From 9460d05ac40a28d5439df34f66024da665fb93d4 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 24 Mar 2025 10:45:20 +0100 Subject: [PATCH 134/394] Added FIX_732, still work in progress --- lib_com/options.h | 1 + lib_dec/fd_cng_dec_fx.c | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8bbd89e87..eb296b843 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,6 +67,7 @@ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif +#define FIX_732 /* Eri: Fix for precision issue in CNG generation -- still work in progress */ #define FIX_867_CLDFB_NRG_SCALE diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 1d8185601..017c656e9 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1117,8 +1117,11 @@ Word16 ApplyFdCng_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } - +#ifdef FIX_732 + s2 = ( sub( WORD32_BITS, 1 ) ); +#else s2 = -( ( WORD32_BITS - 1 ) ); +#endif move16(); /* Shape the SID noise levels in each FFT bin */ j = 0; @@ -1158,7 +1161,11 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( ( WORD32_BITS - 1 ) ); move16(); } +#ifdef FIX_732 + s2 = s_min( s2, facTabExp[k] ); +#else s2 = s_max( s2, facTabExp[k] ); +#endif } if ( EQ_16( s2, -31 ) ) { @@ -1171,7 +1178,11 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { +#ifdef FIX_732 + cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } @@ -1209,7 +1220,11 @@ Word16 ApplyFdCng_fx( { IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { +#ifdef FIX_732 + s2 = ( sub( WORD32_BITS, 1 ) ); +#else s2 = -( ( WORD32_BITS - 1 ) ); +#endif /* Shape the SID noise levels in each FFT bin */ j = 0; move16(); @@ -1248,7 +1263,11 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( WORD32_BITS - 1 ); move16(); } +#ifdef FIX_732 + s2 = s_min( s2, facTabExp[k] ); +#else s2 = s_max( s2, facTabExp[k] ); +#endif } IF( EQ_16( s2, -31 ) ) { @@ -1261,7 +1280,11 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { +#ifdef FIX_732 + cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ +#endif move32(); } } -- GitLab From 3b9fb3d1f7e4ea75dbbc2592eee7de246b34ad07 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:26:43 +0200 Subject: [PATCH 135/394] Change FIX_732 to only address noise floor in msPeriodog calculation --- lib_dec/fd_cng_dec_fx.c | 56 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 017c656e9..d9ffedf72 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1117,11 +1117,7 @@ Word16 ApplyFdCng_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } -#ifdef FIX_732 - s2 = ( sub( WORD32_BITS, 1 ) ); -#else s2 = -( ( WORD32_BITS - 1 ) ); -#endif move16(); /* Shape the SID noise levels in each FFT bin */ j = 0; @@ -1161,11 +1157,7 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( ( WORD32_BITS - 1 ) ); move16(); } -#ifdef FIX_732 - s2 = s_min( s2, facTabExp[k] ); -#else s2 = s_max( s2, facTabExp[k] ); -#endif } if ( EQ_16( s2, -31 ) ) { @@ -1178,11 +1170,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_732 - cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } @@ -1220,11 +1208,7 @@ Word16 ApplyFdCng_fx( { IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) ) { -#ifdef FIX_732 - s2 = ( sub( WORD32_BITS, 1 ) ); -#else s2 = -( ( WORD32_BITS - 1 ) ); -#endif /* Shape the SID noise levels in each FFT bin */ j = 0; move16(); @@ -1263,11 +1247,7 @@ Word16 ApplyFdCng_fx( facTabExp[k] = -( WORD32_BITS - 1 ); move16(); } -#ifdef FIX_732 - s2 = s_min( s2, facTabExp[k] ); -#else s2 = s_max( s2, facTabExp[k] ); -#endif } IF( EQ_16( s2, -31 ) ) { @@ -1280,11 +1260,7 @@ Word16 ApplyFdCng_fx( s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) ); FOR( ; j <= hFdCngCom->part[k]; j++ ) { -#ifdef FIX_732 - cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#else cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ -#endif move32(); } } @@ -1320,6 +1296,14 @@ Word16 ApplyFdCng_fx( } + dbgwrite( hFdCngDec->bandNoiseShape, sizeof( Word32 ), 320, 1, "bandNoiseShape.int" ); + dbgwrite( &hFdCngDec->bandNoiseShape_exp, sizeof( short ), 1, 1, "bandNoiseShape_exp.short" ); + + dbgwrite( cngNoiseLevel, sizeof( Word32 ), 340, 1, "cngNoiseLevel.int" ); + dbgwrite( cngNoiseLevel_exp, sizeof( short ), 1, 1, "cngNoiseLevel_exp.short" ); + dbgwrite( &frame, sizeof( int ), 1, 1, "frame.int" ); + + return 0; } @@ -1523,6 +1507,9 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; +#ifdef FIX_732 + Word32 msPeriodog_floor; +#endif Word32 *msNoiseEst; Word32 *reIter; Word32 rescale_fac = 0; @@ -1728,10 +1715,18 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); - +#ifdef FIX_732 + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); + IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) +#else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) +#endif { +#ifdef FIX_732 + msPeriodog[p] = msPeriodog_floor; +#else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ +#endif move32(); } } @@ -2105,6 +2100,13 @@ void perform_noise_estimation_dec_ivas_fx( /* Expand partitions into bins of power spectrum */ scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; + + dbgwrite( msNoiseEst, sizeof( int ), 62, 1, "msNoiseEst.int" ); + dbgwrite( &hFdCngDec->msNoiseEst_exp, sizeof( short ), 1, 1, "msNoiseEst_exp.short" ); + dbgwrite( msPeriodog, sizeof( int ), 62, 1, "msPeriodog.int" ); + dbgwrite( &hFdCngDec->msPeriodog_exp, sizeof( short ), 1, 1, "msPeriodog_exp.short" ); + + move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ hFdCngDec->smoothed_psd_exp = hFdCngDec->bandNoiseShape_exp; @@ -4750,9 +4752,9 @@ void generate_masking_noise_ivas_fx( { #ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ +#else /* VEC_ARITH_OPT_v1 */ v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ +#endif /* VEC_ARITH_OPT_v1 */ } return; -- GitLab From 1b3a8fac486292448ee69a85582e65327dec648f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:34:38 +0200 Subject: [PATCH 136/394] Rename switch to FIX_732_MS_PERIODOG_FLOOR --- lib_com/options.h | 2 +- lib_dec/fd_cng_dec_fx.c | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index eb296b843..30044d7b7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -67,7 +67,7 @@ #ifndef BASOP_NOGLOB_DEV_USE_GLOBALS #define BASOP_NOGLOB_DECLARE_LOCAL #endif -#define FIX_732 /* Eri: Fix for precision issue in CNG generation -- still work in progress */ +#define FIX_732_MS_PERIODOG_FLOOR /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */ #define FIX_867_CLDFB_NRG_SCALE diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index d9ffedf72..30164c404 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1117,6 +1117,7 @@ Word16 ApplyFdCng_fx( *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp; move16(); } + s2 = -( ( WORD32_BITS - 1 ) ); move16(); /* Shape the SID noise levels in each FFT bin */ @@ -1296,14 +1297,6 @@ Word16 ApplyFdCng_fx( } - dbgwrite( hFdCngDec->bandNoiseShape, sizeof( Word32 ), 320, 1, "bandNoiseShape.int" ); - dbgwrite( &hFdCngDec->bandNoiseShape_exp, sizeof( short ), 1, 1, "bandNoiseShape_exp.short" ); - - dbgwrite( cngNoiseLevel, sizeof( Word32 ), 340, 1, "cngNoiseLevel.int" ); - dbgwrite( cngNoiseLevel_exp, sizeof( short ), 1, 1, "cngNoiseLevel_exp.short" ); - dbgwrite( &frame, sizeof( int ), 1, 1, "frame.int" ); - - return 0; } @@ -1507,7 +1500,7 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR Word32 msPeriodog_floor; #endif Word32 *msNoiseEst; @@ -1715,14 +1708,14 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) #else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) #endif { -#ifdef FIX_732 +#ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog[p] = msPeriodog_floor; #else msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ @@ -2100,13 +2093,6 @@ void perform_noise_estimation_dec_ivas_fx( /* Expand partitions into bins of power spectrum */ scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 ); hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp; - - dbgwrite( msNoiseEst, sizeof( int ), 62, 1, "msNoiseEst.int" ); - dbgwrite( &hFdCngDec->msNoiseEst_exp, sizeof( short ), 1, 1, "msNoiseEst_exp.short" ); - dbgwrite( msPeriodog, sizeof( int ), 62, 1, "msPeriodog.int" ); - dbgwrite( &hFdCngDec->msPeriodog_exp, sizeof( short ), 1, 1, "msPeriodog_exp.short" ); - - move16(); Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/ hFdCngDec->smoothed_psd_exp = hFdCngDec->bandNoiseShape_exp; @@ -4752,9 +4738,9 @@ void generate_masking_noise_ivas_fx( { #ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ +#else /* VEC_ARITH_OPT_v1 */ v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ +#endif /* VEC_ARITH_OPT_v1 */ } return; -- GitLab From de4a8862055cb6d1c693348bd83b6c54347b51f4 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:50:04 +0200 Subject: [PATCH 137/394] Clang format --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 30164c404..de5aa20bb 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1718,7 +1718,7 @@ void perform_noise_estimation_dec_ivas_fx( #ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog[p] = msPeriodog_floor; #else - msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ + msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ #endif move32(); } -- GitLab From fe9bb29260994a1d31ffeadd2d97c06b7b8b150d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 13:51:47 +0200 Subject: [PATCH 138/394] Add missing comment --- lib_dec/fd_cng_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index de5aa20bb..4855ab00e 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1709,7 +1709,7 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); #ifdef FIX_732_MS_PERIODOG_FLOOR - msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); + msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/ IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) #else IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) ) -- GitLab From 83928e2f89822be2c7a09a5b7c435763298e0f44 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 10:17:26 +0200 Subject: [PATCH 139/394] Reduced bit precision at the input of con_tcx_ivas_fx() as a temporary workaround to see the pipeline results. --- lib_dec/ivas_mdct_core_dec_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index a8e97b0cf..c818b7bf8 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1392,6 +1392,11 @@ void ivas_mdct_core_reconstruct_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth + + // Temporary workaround: con_tcx_ivas_fx() should be analyzed for potential issues. + Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); + Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); + /////////////////////////////////////////////////////////////////////////////////// #endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ -- GitLab From 33610b0cd69859e3d83aa905dcb746b67d5944ba Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 14:01:41 +0530 Subject: [PATCH 140/394] Fix for crash --- lib_dec/fd_cng_dec_fx.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 4855ab00e..d7ca74edb 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1500,18 +1500,20 @@ void perform_noise_estimation_dec_ivas_fx( Word32 enr, enr_tot, enr_tot0; Word16 enr_e, enr_ratio, alpha; Word32 *msPeriodog; + Word32 *msNoiseEst; #ifdef FIX_732_MS_PERIODOG_FLOOR Word32 msPeriodog_floor; #endif - Word32 *msNoiseEst; Word32 *reIter; Word32 rescale_fac = 0; Word64 W_tmp; Word16 tmp_s, tmp_q, min_q = 31; Word16 q_shift; Word32 max_l; - Word16 norm_shift; - +#ifdef FIX_732_MS_PERIODOG_FLOOR + Word16 norm_shift, check = 0; + move16(); +#endif /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ fftBuffer = hFdCngDec->hFdCngCom->fftBuffer; /*Q31 - hFdCngDec->hFdCngCom->fftBuffer_exp*/ @@ -1708,6 +1710,7 @@ void perform_noise_estimation_dec_ivas_fx( msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); + #ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ); /*Q31 - hFdCngDec->msPeriodog_exp*/ IF( LT_32( msPeriodog[p], msPeriodog_floor ) ) @@ -1717,12 +1720,29 @@ void perform_noise_estimation_dec_ivas_fx( { #ifdef FIX_732_MS_PERIODOG_FLOOR msPeriodog[p] = msPeriodog_floor; + move32(); #else - msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ -#endif + msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/ move32(); +#endif + } + } +#ifdef FIX_732_MS_PERIODOG_FLOOR + FOR( p = 0; p < npart; p++ ) + { + IF( GT_32( msPeriodog[p], 1 ) ) + { + check = 1; + move16(); + BREAK; } } + IF( check == 0 ) + { + hFdCngDec->msPeriodog_exp = 14; /* msPeriodog buffer will have minimum value as 1e-5f */ + move16(); + } +#endif } /* calculate total energy (short-term and long-term) */ -- GitLab From 0c10edbf4d33a44c0598f2f23377bc1a51f6f7e1 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 10:44:45 +0200 Subject: [PATCH 141/394] Fix invalid memory access. --- lib_rend/ivas_dirac_rend_fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 0927ce826..82c30cceb 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4826,11 +4826,13 @@ static void ivas_masa_ext_dirac_render_sf_fx( } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[0], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] ); move16(); - FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) - { #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) #else + FOR( i = 0; hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_len > i; i = add( i, hSpatParamRendCom->num_freq_bands ) ) + { Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q ) #endif } -- GitLab From ef476d35b5bd7ecbaf644e44b3eea232c2ab9d0b Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 11:02:48 +0200 Subject: [PATCH 142/394] clang format --- lib_rend/ivas_dirac_rend_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 82c30cceb..807b85fdf 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4406,7 +4406,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); @@ -4477,7 +4477,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #else - Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q + Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_q[1], DirAC_mem.reference_power_smooth_q[1] ) ); // DirAC_mem.reference_power_q #endif } DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1]; @@ -4488,7 +4488,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( reference_power_fix + CLDFB_NO_CHANNELS_HALF, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #else - Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q + Scale_sig32( reference_power_fix, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( DirAC_mem.reference_power_smooth_q[1], DirAC_mem.reference_power_q[1] ) ); // DirAC_mem.reference_power_smooth_q #endif DirAC_mem.reference_power_q[1] = DirAC_mem.reference_power_smooth_q[1]; move16(); @@ -4814,7 +4814,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( #ifdef FIX_1737_FIX_867_CLDFB_NRG_SCALE Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) #else - Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) + Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_fx + CLDFB_NO_CHANNELS_HALF + i, s_min( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), sub( s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ), hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] ) ); // s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q ) #endif } hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q[1], hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] ); -- GitLab From 7a3493b834bedeae4f573dc4d88c52e5b86d890e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 15:08:04 +0530 Subject: [PATCH 143/394] BASOPAddMantissa optimization removal in transient detection and compute_diffuseness --- lib_com/ivas_dirac_com_fx.c | 25 ------------------------- lib_com/ivas_transient_det_fx.c | 15 --------------- 2 files changed, 40 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index fa0e98996..14dd6c148 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -921,7 +921,6 @@ void computeDiffuseness_fixed( } /* Compute Diffuseness */ -#ifndef OPT_SBA_DEC_PATH p_tmp = intensity_slow_abs; exp2 = 0; move16(); @@ -960,30 +959,6 @@ void computeDiffuseness_fixed( move32(); } } -#else /* OPT_SBA_DEC_PATH */ - Word16 diff = sub( 62, q_ene ); - p_tmp = intensity_slow_abs; - FOR( i = 0; i < num_freq_bands; ++i ) - { - - exp1 = sub( 31, q_intensity_slow ); - tmp = Sqrt32( p_tmp[i], &exp1 ); - - tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); - q_tmp = sub( diff, add( exp1, exp2 ) ); - // bring to Q30 - tmp = L_shl_sat( tmp, sub( Q30, q_tmp ) ); - diffuseness[i] = L_sub( ONE_IN_Q30, tmp ); - move32(); - - if ( LT_32( diffuseness[i], 0 ) ) - { - diffuseness[i] = 0; - move32(); - } - } - -#endif /* OPT_SBA_DEC_PATH */ *q_diffuseness = Q30; move16(); diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 02f8713a8..0a56732fa 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -44,11 +44,7 @@ *------------------------------------------------------------------------------------------*/ #define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#ifndef OPT_SBA_DEC_PATH #define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 -#else /* OPT_SBA_DEC_PATH */ -#define IVAS_TDET_PARM_ENV_EPS_fx ( 1407374884 ) // Q47 -#endif /* OPT_SBA_DEC_PATH */ #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 @@ -407,19 +403,8 @@ void ivas_td_decorr_get_ducking_gains_fx( FOR( i = 0; i < frame_len; i++ ) { // e_fast_fx[i] = L_add( L_abs( e_fast_fx[i] ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, q_factor_diff ) ); /*Q14*/ -#ifndef OPT_SBA_DEC_PATH e_fast_fx[i] = BASOP_Util_Add_Mant32Exp( L_abs( e_fast_fx[i] ), e_fast_e[i], IVAS_TDET_PARM_ENV_EPS_fx, 0, &e_fast_e[i] ); move32(); -#else /* OPT_SBA_DEC_PATH */ - Word32 tmp = L_abs( e_fast_fx[i] ); - Word16 nrm = norm_l( tmp ); - Word16 max_e = s_max( sub( e_fast_e[i], nrm ), 31 - 47 ); - max_e = add( max_e, 1 ); // 1 for headroom - e_fast_fx[i] = L_add( L_shr( tmp, sub( max_e, e_fast_e[i] ) ), L_shr( IVAS_TDET_PARM_ENV_EPS_fx, sub( max_e, 31 - 47 ) ) ); - move32(); - e_fast_e[i] = max_e; - move16(); -#endif /* OPT_SBA_DEC_PATH */ e_slow_fx[i] = e_fast_fx[i]; move32(); e_slow_e[i] = e_fast_e[i]; -- GitLab From 31ee5c6ad2a57de89fb393398218b071b7778775 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 15:14:28 +0530 Subject: [PATCH 144/394] Clang formatting changes --- lib_com/cldfb_fx.c | 16 ++++++++-------- lib_com/ivas_transient_det_fx.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 5caa2b140..6c29d2a57 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -512,8 +512,8 @@ void cldfbAnalysis_ts_fx( rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 #else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -526,8 +526,8 @@ void cldfbAnalysis_ts_fx( iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 #else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 + iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 #endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -585,10 +585,10 @@ void cldfbAnalysis_ts_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 #endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 0a56732fa..fb8679ebc 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -43,8 +43,8 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) -#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 +#define IVAS_TDET_PARM_ENV_EPS ( 1e-5f ) +#define IVAS_TDET_PARM_ENV_EPS_fx 21474 // Q31 #define IVAS_TDET_DUCK_MULT_FAC ( 590558003 ) // Q29 #define IVAS_TDET_PARM_TRANS_THR ( 107374182 ) // Q30 -- GitLab From 075d0b6792fe92e533edf4b0b66fdfb8b63fa021 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 12:52:15 +0200 Subject: [PATCH 145/394] Modified Q_syn_Overl in the PLC calculation. Disabled temp. workaround for input of con_tcx_ivas_fx() --- lib_dec/ivas_mdct_core_dec_fx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index c818b7bf8..e64117a33 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1099,8 +1099,8 @@ void ivas_mdct_core_reconstruct_fx( Word16 q_syn = 0; move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 q_win; - Word16 q_winFB; + Word16 q_win = 0; + Word16 q_winFB = 0; #else #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT Word16 q_win = -1; @@ -1426,10 +1426,12 @@ void ivas_mdct_core_reconstruct_fx( st->Q_syn = q_syn; move16(); st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); move16(); + st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); + move16(); #endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) -- GitLab From ba44162ebc011720272e3bd83aa27baadadbd042 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 16:28:36 +0530 Subject: [PATCH 146/394] Fix for crash observed in complexity pipeline for stereo downmix --- lib_dec/er_dec_acelp_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index e30553d38..b6e5f3171 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -557,7 +557,7 @@ void con_acelp_fx( tmp_32 = Mpy_32_16_1( st->Mode2_lp_gainc /*Q16*/, alpha /*Q14*/ ); /*Q31-16 = Q15*/ s_32 = norm_l( tmp_32 ); tmp_32 = L_shl( tmp_32, s_32 ); - tmp_16 = round_fx( tmp_32 ); + tmp_16 = round_fx_sat( tmp_32 ); s_16 = negate( s_32 ); s_16 = sub( s_16, -1 - 15 ); /*->Q15*/ -- GitLab From 8a609b985dff27ddc74a901f8c0575259db7c782 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 16:34:06 +0530 Subject: [PATCH 147/394] Fix for 3GPP issue 1724: Renderer MASA output metadata difference - 2 Link #1724 --- lib_rend/ivas_masa_merge_fx.c | 107 ++++++++++++---------------------- lib_rend/ivas_prot_rend_fx.h | 4 +- lib_rend/ivas_stat_rend.h | 12 ++-- lib_rend/lib_rend_fx.c | 47 ++++++--------- 4 files changed, 60 insertions(+), 110 deletions(-) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 65829e1c8..d90076847 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -46,9 +46,25 @@ static void copy_masa_meta_tile_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, const UWord8 sf, const UWord8 band ); -static void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, Word32 inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne1_e, MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, Word32 inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne2_e ); +static void full_stream_merge_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); -static void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne_e, MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEneISM_e ); +static void diffuse_meta_merge_1x1_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ + Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ + Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); /*---------------------------------------------------------------------* @@ -144,14 +160,13 @@ void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ - Word16 *inEne_e, /* i : TF-energy of input 1 Exponent */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEneISM_e /* i : TF-energy of input 2 Exponent */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { Word8 sf, band; - Word16 max_e, in1_e[MASA_FREQUENCY_BANDS], i; FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) @@ -164,22 +179,13 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide1616_Scale( inMeta->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); energyTimesRatio_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - energyTimesRatio_e = add( inEne_e[sf], scale ); + energyTimesRatio_e = add( inEne_e[sf][band], scale ); + total_nrg_fx = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &total_nrg_e ); - IF( GT_16( inEne_e[sf], inEneISM_e[sf] ) ) - { - total_nrg_fx = L_add( L_shr( inEne_fx[sf][band], 1 ), L_shr( inEneISM_fx[sf][band], add( sub( inEne_e[sf], inEneISM_e[sf] ), 1 ) ) ); /* Q(30 - inEne_e[sf]) */ - total_nrg_e = add( inEne_e[sf], 1 ); - } - ELSE - { - total_nrg_fx = L_add( L_shr( inEneISM_fx[sf][band], 1 ), L_shr( inEne_fx[sf][band], add( sub( inEneISM_e[sf], inEne_e[sf] ), 1 ) ) ); /* Q(30 - inEneISM_e[sf]) */ - total_nrg_e = add( inEneISM_e[sf], 1 ); - } /* target is original MASA diffuseness */ tmp = BASOP_Util_Divide1616_Scale( inMeta->diffuseToTotalRatio[sf][band], UINT8_MAX, &scale ); total_diff_nrg_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - total_diff_nrg_e = add( inEne_e[sf], scale ); + total_diff_nrg_e = add( inEne_e[sf][band], scale ); /* criterion is mean of ISM ratio and new ratio */ dir_ratio_ism_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( inMetaISM->directToTotalRatio[0][sf][band], UINT8_MAX, &dir_ratio_ism_e ) ); @@ -191,7 +197,7 @@ void diffuse_meta_merge_1x1_fx( L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp ); L_tmp1 = L_shr( L_tmp1, 1 ); energyTimesRatioISM_fx = Mpy_32_32( L_tmp1, inEneISM_fx[sf][band] ); /* Q( 31 - ( tmp + inEneISM_e[sf] ) ) */ - energyTimesRatioISM_e = add( tmp, inEneISM_e[sf] ); + energyTimesRatioISM_e = add( tmp, inEneISM_e[sf][band] ); IF( ( BASOP_Util_Cmp_Mant32Exp( energyTimesRatioISM_fx, energyTimesRatioISM_e, energyTimesRatio_fx, energyTimesRatio_e ) > 0 ) ) { @@ -264,29 +270,9 @@ void diffuse_meta_merge_1x1_fx( outMeta->spreadCoherence[1][sf][band] = 0u; move16(); - inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf], inEneISM_fx[sf][band], inEneISM_e[sf], &in1_e[band] ); /* Update energy for subsequent mergings */ - move16(); - } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne_fx[sf][i] = L_shr( inEne_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q(31 - max_e) */ + inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &inEne_e[sf][band] ); /* Update energy for subsequent mergings */ move32(); } - - inEne_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -318,16 +304,15 @@ void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { UWord8 n_dirs_1, n_dirs_2; UWord8 sf, band; - Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e, max_e, i; - Word16 in1_e[MASA_FREQUENCY_BANDS]; + Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e; Word32 dir_nrg_1_fx, dir_nrg_2_fx, L_tmp; /* full stream select based on total direct energy */ @@ -340,17 +325,17 @@ void full_stream_merge_fx( { tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); dir_nrg_1_fx = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - dir_nrg_1_e = add( scale, inEne1_e[sf] ); + dir_nrg_1_e = add( scale, inEne1_e[sf][band] ); - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); + tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); dir_nrg_2_fx = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - dir_nrg_2_e = add( scale, inEne2_e[sf] ); + dir_nrg_2_e = add( scale, inEne2_e[sf][band] ); IF( EQ_16( n_dirs_1, 2 ) ) { tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - scale = add( scale, inEne1_e[sf] ); + scale = add( scale, inEne1_e[sf][band] ); dir_nrg_1_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_1_fx, dir_nrg_1_e, &dir_nrg_1_e ); } @@ -358,7 +343,7 @@ void full_stream_merge_fx( { tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - scale = add( scale, inEne2_e[sf] ); + scale = add( scale, inEne2_e[sf][band] ); dir_nrg_2_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_2_fx, dir_nrg_2_e, &dir_nrg_2_e ); } @@ -371,29 +356,9 @@ void full_stream_merge_fx( copy_masa_meta_tile_fx( outMeta, inMeta2, sf, band ); } - inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf], inEne2_fx[sf][band], inEne2_e[sf], &in1_e[band] ); + inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf][band], inEne2_fx[sf][band], inEne2_e[sf][band], &inEne1_e[sf][band] ); move32(); } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne1_fx[sf][i] = L_shr( inEne1_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q( 31 - max_e ) */ - move32(); - } - - inEne1_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -436,11 +401,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { /* mixing ISMs with non-ISM use different merge */ diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 7cd547cb8..8772b542e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1478,11 +1478,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ); ivas_error masaPrerendOpen_fx( diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ddf2b5942..bf13d40f8 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1565,9 +1565,8 @@ typedef struct ivas_mcmasa_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE; @@ -1601,10 +1600,8 @@ typedef struct ivas_omasa_ana_data_structure Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_q; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 interpolator_fx[L_FRAME48k]; Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS]; @@ -1645,7 +1642,6 @@ typedef struct ivas_dirac_ana_data_structure Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } DIRAC_ANA_DATA, *DIRAC_ANA_HANDLE; /*----------------------------------------------------------------------------------* @@ -1661,8 +1657,8 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b46d13610..3b800ed07 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6669,7 +6669,6 @@ static void renderMasaToMasa( Word16 mrange[2]; Word16 brange[2]; Word16 numAnalysisChannels; - Word16 tmp_energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_fx ); Word16 q_cldfb = *outAudio.pq_fact; Word16 q_cldfb_out = *outAudio.pq_fact; @@ -6692,6 +6691,7 @@ static void renderMasaToMasa( move16(); set_zero_fx( masaInput->hMasaPrerend->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS ); + set16_fx( masaInput->hMasaPrerend->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -6746,30 +6746,14 @@ static void renderMasaToMasa( FOR( i = 0; i < numAnalysisChannels; i++ ) { Word32 temp = L_add( Mpy_32_32( Chan_RealBuffer_fx[0][j], Chan_RealBuffer_fx[0][j] ), Mpy_32_32( Chan_ImagBuffer_fx[0][j], Chan_ImagBuffer_fx[0][j] ) ); /* 2 * Q(q_cldfb_out + scale_factor) - 31 */ - masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], tmp_energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &tmp_energy_e[block_m_idx][band_m_idx] ); + masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx] ); move32(); } } } } } - FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - Word16 max_e = MIN_16; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - max_e = s_max( max_e, tmp_energy_e[i][j] ); - } - masaInput->hMasaPrerend->energy_e[i] = max_e; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - masaInput->hMasaPrerend->energy_fx[i][j] = L_shr( masaInput->hMasaPrerend->energy_fx[i][j], sub( max_e, tmp_energy_e[i][j] ) ); /* Q(31 - max_e) */ - move32(); - } - } /* Copy audio channels if mismatch in number of transports */ test(); test(); @@ -7067,8 +7051,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 *inEne1_e; - Word16 *inEne2_e; + Word16( *inEne1_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16( *inEne2_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; IF( hIvasRend == NULL ) { @@ -7078,27 +7062,31 @@ ivas_error IVAS_REND_MergeMasaMetadata( /* Input1 metadata and energy */ IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { + *hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne1_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne1_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -7110,25 +7098,26 @@ ivas_error IVAS_REND_MergeMasaMetadata( { inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { inMeta2 = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { inMeta2 = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne2_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + inMeta2 = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne2_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -7136,7 +7125,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( } /* Merge metadata */ - ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e ); + ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, *inEne1_e, inMeta2, inputType2, *inEne2_fx, *inEne2_e ); IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) ) -- GitLab From a139264d27bfc6c877b0220d615059abfdc44304 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 16:50:28 +0530 Subject: [PATCH 148/394] Clang formatting --- lib_rend/ivas_stat_rend.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index bf13d40f8..f8dad9a66 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1600,7 +1600,7 @@ typedef struct ivas_omasa_ana_data_structure Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 interpolator_fx[L_FRAME48k]; Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS]; @@ -1657,7 +1657,7 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; -- GitLab From 621bd86289f297947a5d287895bcb6b8279001a1 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 13:40:01 +0200 Subject: [PATCH 149/394] Disabled temp. workaround for input of con_tcx_ivas_fx() --- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index e64117a33..23639d47c 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1394,8 +1394,8 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth // Temporary workaround: con_tcx_ivas_fx() should be analyzed for potential issues. - Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); - Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); + //Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); + //Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// #endif assert( EQ_16( st->bfi, 1 ) ); -- GitLab From 0d5df82909be067c36662ae04bb74611787a4d4e Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 13:44:35 +0200 Subject: [PATCH 150/394] Applied Clang patch. --- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 23639d47c..8beab3b3f 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1394,8 +1394,8 @@ void ivas_mdct_core_reconstruct_fx( Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth // Temporary workaround: con_tcx_ivas_fx() should be analyzed for potential issues. - //Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); - //Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); + // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); + // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// #endif assert( EQ_16( st->bfi, 1 ) ); -- GitLab From 005edb871fec4a89f392f799f978e1e8716f5a4f Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 15:02:51 +0200 Subject: [PATCH 151/394] Modified q_win calculation for the case when all memory buffers are zero. Disabled Q_syn_Overl modification in PLC mode. --- lib_dec/dec_tcx_fx.c | 20 ++++++++++++++++---- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 4558de515..d0c4b1de3 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2613,14 +2613,26 @@ static Word16 IMDCT_ivas_fx_calc_qwin( q_win = 6; move16(); + Word16 q_scale_syn_Overl_TDAC ,q_scale_syn_Overl, q_scale_old_syn_Overl, q_scale_old_out; // q_win == norm + Q_syn_Overl_TDAC - q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ) + Q_syn_Overl_TDAC ); + q_scale_syn_Overl_TDAC = norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ); + q_win = s_min( q_win, q_scale_syn_Overl_TDAC + Q_syn_Overl_TDAC ); + // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( syn_Overl, old_syn_Overl_len ) + Q_syn_Overl ); - q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); + q_scale_syn_Overl = norm_arr( syn_Overl, old_syn_Overl_len ); + q_win = s_min( q_win, q_scale_syn_Overl + Q_syn_Overl ); + + q_scale_old_syn_Overl = norm_arr( old_syn_Overl, old_syn_Overl_len ); + q_win = s_min( q_win, q_scale_old_syn_Overl + Q_old_syn_Overl ); + // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); - q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); + q_scale_old_out = norm_arr( old_out_fx, t ); + q_win = s_min( q_win, q_scale_old_out + Q_old_out_fx ); + + if ( q_scale_old_out == Q15 && q_scale_old_syn_Overl == Q15 && + q_scale_old_syn_Overl == Q15 && q_scale_syn_Overl_TDAC == Q15 ) + q_win = 0; #if 0 set16_zero_fx(syn_Overl_TDAC + oldLength / 2, (t-oldLength)/2 ); diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 8beab3b3f..a97589ddf 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1430,8 +1430,8 @@ void ivas_mdct_core_reconstruct_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); move16(); - st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); - move16(); + //st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions. + //move16(); #endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) -- GitLab From 2c4d19b0af211b502aea4e40ca4b794590417329 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 16 Jun 2025 15:18:53 +0200 Subject: [PATCH 152/394] Applied Clang formatting patch. --- lib_dec/dec_tcx_fx.c | 22 +++++++++++----------- lib_dec/ivas_mdct_core_dec_fx.c | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d0c4b1de3..bb2c64cad 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2613,25 +2613,25 @@ static Word16 IMDCT_ivas_fx_calc_qwin( q_win = 6; move16(); - Word16 q_scale_syn_Overl_TDAC ,q_scale_syn_Overl, q_scale_old_syn_Overl, q_scale_old_out; + Word16 q_shift_syn_Overl_TDAC, q_shift_syn_Overl, q_shift_old_syn_Overl, q_shift_old_out; // q_win == norm + Q_syn_Overl_TDAC - q_scale_syn_Overl_TDAC = norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ); - q_win = s_min( q_win, q_scale_syn_Overl_TDAC + Q_syn_Overl_TDAC ); + q_shift_syn_Overl_TDAC = norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ); + q_win = s_min( q_win, q_shift_syn_Overl_TDAC + Q_syn_Overl_TDAC ); // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_scale_syn_Overl = norm_arr( syn_Overl, old_syn_Overl_len ); - q_win = s_min( q_win, q_scale_syn_Overl + Q_syn_Overl ); + q_shift_syn_Overl = norm_arr( syn_Overl, old_syn_Overl_len ); + q_win = s_min( q_win, q_shift_syn_Overl + Q_syn_Overl ); - q_scale_old_syn_Overl = norm_arr( old_syn_Overl, old_syn_Overl_len ); - q_win = s_min( q_win, q_scale_old_syn_Overl + Q_old_syn_Overl ); + q_shift_old_syn_Overl = norm_arr( old_syn_Overl, old_syn_Overl_len ); + q_win = s_min( q_win, q_shift_old_syn_Overl + Q_old_syn_Overl ); // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); - q_scale_old_out = norm_arr( old_out_fx, t ); - q_win = s_min( q_win, q_scale_old_out + Q_old_out_fx ); + q_shift_old_out = norm_arr( old_out_fx, t ); + q_win = s_min( q_win, q_shift_old_out + Q_old_out_fx ); - if ( q_scale_old_out == Q15 && q_scale_old_syn_Overl == Q15 && - q_scale_old_syn_Overl == Q15 && q_scale_syn_Overl_TDAC == Q15 ) + if ( q_shift_syn_Overl_TDAC == Q15 && q_shift_syn_Overl == Q15 && + q_shift_old_syn_Overl == Q15 && q_shift_old_out == Q15 ) q_win = 0; #if 0 diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index a97589ddf..01569aa62 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1430,8 +1430,8 @@ void ivas_mdct_core_reconstruct_fx( #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn ); move16(); - //st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions. - //move16(); + // st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions. + // move16(); #endif IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) ) -- GitLab From f5ab4abf4abc6b62c93690c71f0681fa190585b8 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 15:33:08 +0200 Subject: [PATCH 153/394] Fix crash because of overflow of proto_fac_fx. --- lib_dec/ivas_mc_param_dec_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index c25ec972f..79c7b4d86 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2356,13 +2356,21 @@ static void param_mc_protoSignalComputation_fx( FOR( band = 0; band < num_freq_bands; band++ ) { +#ifdef FIX_1737_proto_fac_overflow + Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 +#else Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); move32(); p_proto_frame_fx++; +#ifdef FIX_1737_proto_fac_overflow + tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 +#else tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 +#endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); move32(); @@ -3596,7 +3604,11 @@ static ivas_error param_mc_get_diff_proto_info_fx( { p_diff_proto_info->source_chan_idx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = cur_transport_ch; move16(); +#ifdef FIX_1737_proto_fac_overflow + p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; // (proto_fac_fx)Q26 = Q26 +#else p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = L_shl( *proto_fac_ptr, 4 ); // (proto_fac_fx)Q26 + 4 = Q30 +#endif move16(); p_diff_proto_info->num_source_chan_diff[cur_diff_proto] = add( p_diff_proto_info->num_source_chan_diff[cur_diff_proto], 1 ); move16(); -- GitLab From 291381706b85e4f127520dfdc2c1e830248148a3 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 15:33:50 +0200 Subject: [PATCH 154/394] Fix crash because of overflow of proto_fac_fx. --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index de89753d3..b90f78325 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -70,6 +70,7 @@ #define FIX_867_CLDFB_NRG_SCALE #define FIX_1737_FIX_867_CLDFB_NRG_SCALE +#define FIX_1737_proto_fac_overflow #define FIX_1378_ACELP_OUT_OF_BOUNDS -- GitLab From b21540b59f1d6cac6a5aee2a763befde42d383b1 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 15:42:09 +0200 Subject: [PATCH 155/394] Use Q0 for synthFB_fx during PLC. Set Q_old_wtda and Q_old_wtdaLB to Q15 to avoid precision loss in case of zero signal for next frame. --- lib_dec/ivas_mdct_core_dec_fx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 01569aa62..34bcb28cf 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1266,7 +1266,7 @@ void ivas_mdct_core_reconstruct_fx( /* Note: these buffers are not subframe-based, hence no indexing with k */ set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] ); set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] ); -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD st->hHQ_core->Q_old_wtda = Q15; st->hHQ_core->Q_old_wtda_LB = Q15; #endif @@ -1390,6 +1390,7 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +#if 0 Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth @@ -1397,6 +1398,11 @@ void ivas_mdct_core_reconstruct_fx( // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// +#else + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub(0, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth -> Q0 + Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( 0, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth -> Q0 + q_syn = 0; +#endif #endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ -- GitLab From 640760180870e2ddff2916cb6da4b0a010f10f5e Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 15:43:08 +0200 Subject: [PATCH 156/394] clang format --- lib_dec/ivas_mc_param_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 79c7b4d86..2ba8c9c9e 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2359,7 +2359,7 @@ static void param_mc_protoSignalComputation_fx( #ifdef FIX_1737_proto_fac_overflow Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 #else - Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 + Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 #endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); @@ -2369,7 +2369,7 @@ static void param_mc_protoSignalComputation_fx( #ifdef FIX_1737_proto_fac_overflow tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 #else - tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 + tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5 #endif *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); -- GitLab From 30f647b1774771eb0d0fcb4d86b8b0c5c2af7668 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 16 Jun 2025 15:45:17 +0200 Subject: [PATCH 157/394] clang format --- lib_dec/ivas_mdct_core_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 34bcb28cf..74ba24767 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1399,7 +1399,7 @@ void ivas_mdct_core_reconstruct_fx( // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// #else - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub(0, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth -> Q0 + Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( 0, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth -> Q0 Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( 0, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth -> Q0 q_syn = 0; #endif -- GitLab From ae57ace8debbfb3d25e1c45045a2fa79037285a2 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 17 Jun 2025 11:05:24 +0200 Subject: [PATCH 158/394] cleanup --- lib_dec/fd_cng_dec_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 1b30cb2e5..adf838f42 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -1504,19 +1504,18 @@ void perform_noise_estimation_dec_ivas_fx( Word32 msPeriodog_floor; #endif Word32 *msNoiseEst; -#ifdef FIX_732_MS_PERIODOG_FLOOR - Word32 msPeriodog_floor; -#endif Word32 *reIter; Word32 rescale_fac = 0; Word64 W_tmp; Word16 tmp_s, tmp_q, min_q = 31; Word16 q_shift; Word32 max_l; + Word16 norm_shift; #ifdef FIX_732_MS_PERIODOG_FLOOR - Word16 norm_shift, check = 0; + Word16 check = 0; move16(); #endif + /* pointer initialization */ periodog = hFdCngDec->hFdCngCom->periodog; /*Q31 - hFdCngDec->hFdCngCom->periodog_exp*/ fftBuffer = hFdCngDec->hFdCngCom->fftBuffer; /*Q31 - hFdCngDec->hFdCngCom->fftBuffer_exp*/ -- GitLab From d762be63cbf7dd0192c755d44f72c488f31471a1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 14:04:08 +0530 Subject: [PATCH 159/394] Bit exact optimization changes for sba enc path ivas_calc_p_coeffs_per_band_enc_fx, Interpol_lc_fx, RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx, RCcontextMapping_encode2_estimate_bandWise_fx funtions basop optimizations Gain of ~4 WMOPS. --- lib_com/interpol_fx.c | 5 + lib_com/ivas_spar_com_fx.c | 88 +++++++++++- lib_com/options.h | 1 + lib_enc/ACcontextMapping_enc_fx.c | 213 +++++++++++++++++++++++------- 4 files changed, 261 insertions(+), 46 deletions(-) diff --git a/lib_com/interpol_fx.c b/lib_com/interpol_fx.c index a490a7552..030d41735 100644 --- a/lib_com/interpol_fx.c +++ b/lib_com/interpol_fx.c @@ -70,9 +70,14 @@ Word32 Interpol_lc_fx( /* o : interpolated value c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */ c1 += up_samp; } +#ifdef OPT_SBA_ENC_V2_BE + L_sum = W_shl_sat_l( L_sum64, 1 ); /*Q15*/ + } +#else L_sum = W_sat_l( L_sum64 ); /*Q14*/ } L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/ +#endif return L_sum; } diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index ef549a2ae..15a529149 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -2361,18 +2361,30 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( Word32 re1, re2; W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ pSparMd->band_coeffs[b_ts_idx].q_C_re_fx*/ +#ifdef OPT_SBA_ENC_V2_BE + q_tmp1 = sub( W_norm( W_tmp ), 32 ); + re1 = W_shl_sat_l( W_tmp, q_tmp1 ); /*q_cov_dd_re+ q_C_re+q_tmp1*/ + q_tmp1 = add( add( q_C_re, q_tmp1 ), q_cov_dd_re ); +#else q_tmp1 = W_norm( W_tmp ); re1 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); /*q_cov_dd_re+ q_C_re+q_tmp1-32*/ q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp1 = 31; move16(); } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ q_C_re*/ +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 32 ); + re2 = W_shl_sat_l( W_tmp, q_tmp ); /*q_cov_dd_re+ q_C_re+q_tmp*/ + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = W_norm( W_tmp ); re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); /*q_cov_dd_re+ q_C_re+q_tmp-32*/ q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2380,12 +2392,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1 ); // q_tmp1+q_C_re +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[0][0] = W_shl_sat_l( W_tmp, q_factor ); // q_tmp1+q_C_re+q_recon_uu_re[0][0] + move32(); + q_recon_uu_re[0][0] = add( add( q_C_re, q_factor ), q_tmp1 ); + move16(); +#else q_recon_uu_re[0][0] = W_norm( W_tmp ); move16(); recon_uu_re[0][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][0] ) ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]-32 move32(); q_recon_uu_re[0][0] = sub( add( add( q_C_re, q_recon_uu_re[0][0] ), q_tmp1 ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[0][0] = 31; @@ -2393,12 +2413,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ); // q_C_re+q_tmp1 +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[0][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp1+q_recon_uu_re[0][1] + move32(); + q_recon_uu_re[0][1] = add( add( q_C_re, q_factor ), q_tmp1 ); + move16(); +#else q_recon_uu_re[0][1] = W_norm( W_tmp ); move16(); recon_uu_re[0][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][1] ) ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]-32 move32(); q_recon_uu_re[0][1] = sub( add( add( q_C_re, q_recon_uu_re[0][1] ), q_tmp1 ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[0][1] = 31; @@ -2406,12 +2434,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ); // q_C_re+q_tmp +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[1][0] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][0] + move32(); + q_recon_uu_re[1][0] = add( add( q_C_re, q_factor ), q_tmp ); + move16(); +#else q_recon_uu_re[1][0] = W_norm( W_tmp ); move16(); recon_uu_re[1][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][0] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][0]-32 move32(); q_recon_uu_re[1][0] = sub( add( add( q_C_re, q_recon_uu_re[1][0] ), q_tmp ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[1][0] = 31; @@ -2419,12 +2455,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ); // q_C_re+q_tmp +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( W_tmp ), 32 ); + recon_uu_re[1][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][1] + move32(); + q_recon_uu_re[1][1] = add( add( q_C_re, q_factor ), q_tmp ); + move16(); +#else q_recon_uu_re[1][1] = W_norm( W_tmp ); move16(); recon_uu_re[1][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][1] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][1]-32 move32(); q_recon_uu_re[1][1] = sub( add( add( q_C_re, q_recon_uu_re[1][1] ), q_tmp ), 32 ); move16(); +#endif if ( W_tmp == 0 ) { q_recon_uu_re[1][1] = 31; @@ -2441,12 +2485,18 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } } q_tmp = sub( s_min( q_tmp, q_cov_uu_re ), 1 ); - +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( q_cov_uu_re, q_tmp ); +#endif FOR( i = 0; i < 2; i++ ) { FOR( j = 0; j < 2; j++ ) { +#ifdef OPT_SBA_ENC_V2_BE + cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], q_factor ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp +#else cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], sub( q_cov_uu_re, q_tmp ) ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp +#endif move32(); } } @@ -2466,9 +2516,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( { Word32 re; W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ); // q_C_re+q_cov_dd_re +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 33 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = sub( W_norm( W_tmp ), 1 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2492,9 +2548,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( } W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ); // q_C_re+q_re1[0] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 33 ); + re2 = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[0]+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_re1[0] ); +#else q_tmp = sub( W_norm( W_tmp ), 1 ); re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[0]+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[0] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2504,9 +2566,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( move32(); W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ); // q_C_re+q_re1[1] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp1 = sub( W_norm( W_tmp ), 33 ); + re2 = W_shl_sat_l( W_tmp, q_tmp1 ); // q_C_re+q_re1[1]+q_tmp1 + q_tmp1 = add( add( q_C_re, q_tmp1 ), q_re1[1] ); +#else q_tmp1 = sub( W_norm( W_tmp ), 1 ); re2 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); // q_C_re+q_re1[1]+q_tmp1-32 q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_re1[1] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp1 = 31; @@ -2585,9 +2653,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( FOR( k = 0; k < num_dmx - 1; k++ ) { W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ); // q_C_re+q_cov_dd_re +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 34 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re ); +#else q_tmp = sub( W_norm( W_tmp ), 2 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2627,9 +2701,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( FOR( m = 0; m < num_dmx - 1; m++ ) { W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ); // q_C_re+q_re1[m] +#ifdef OPT_SBA_ENC_V2_BE + q_tmp = sub( W_norm( W_tmp ), 34 ); + re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[m]+q_tmp + q_tmp = add( add( q_C_re, q_tmp ), q_re1[m] ); +#else q_tmp = sub( W_norm( W_tmp ), 2 ); re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[m]+q_tmp-32 q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[m] ), 32 ); +#endif if ( W_tmp == 0 ) { q_tmp = 31; @@ -2714,9 +2794,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx( move16(); IF( trace != 0 ) { +#ifdef OPT_SBA_ENC_V2_BE + q_factor = sub( W_norm( trace ), 32 ); + tmp = Mpy_32_32( p_norm_scaling, W_shl_sat_l( trace, q_factor ) ); // q_cov_uu_re+q_factor + q_factor = add( q_cov_uu_re, q_factor ); +#else q_factor = W_norm( trace ); tmp = Mpy_32_32( p_norm_scaling, W_extract_h( W_shl( trace, q_factor ) ) ); // q_cov_uu_re+q_factor-32 q_factor = sub( add( q_cov_uu_re, q_factor ), 32 ); +#endif IF( GT_16( q_factor, q_postpred_cov_re ) ) { tmp = L_shr( tmp, sub( q_factor, q_postpred_cov_re ) ); // q_postpred_cov_re diff --git a/lib_com/options.h b/lib_com/options.h index ec5b35f46..7996f8d41 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -80,6 +80,7 @@ #define OPT_SBA_REND_V1_BE #define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_DEC_V2_BE +#define OPT_SBA_ENC_V2_BE #define OPT_SBA_ENC_V1_BE #define OPT_BIN_RENDERER_V1 #define OPT_BIN_RENDERER_V2 diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 5003712b7..0bbc78912 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1249,6 +1249,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( k = 1; move16(); +#ifdef OPT_SBA_ENC_V2_BE + Word16 round_bit_estimate_fx; +#endif + WHILE( LT_16( k, nt / 2 ) ) { bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) ); @@ -1334,7 +1338,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( ctx = &c[L_or( p1, p2 )]; t = (UWord16) L_add( *ctx, rateFlag ); - IF( LT_16( nt_half, idx ) ) + if ( LT_16( nt_half, idx ) ) { t = add( t, ( 1 << NBITS_CONTEXT ) ); } @@ -1351,6 +1355,19 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) + { + pki = lookup[lev1]; /* ESC symbol */ + + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) ); + a1 = shr( a1, 1 ); + b1 = shr( b1, 1 ); + + lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); + } +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) { pki = lookup[lev1]; /* ESC symbol */ @@ -1364,14 +1381,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ } - +#endif pki = lookup[lev1]; symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); +#ifdef OPT_SBA_ENC_V2_BE + IF( GT_64( bit_estimate_fx, W_shl( target, Q23 ) ) ) // Q23 +#else /* Should we truncate? */ IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) +#endif { stop2 = 1; move16(); @@ -1393,6 +1414,13 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); +#ifdef OPT_SBA_ENC_V2_BE + t = add( 13, lev1 ); + IF( lev1 <= 0 ) + { + t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); + } +#else IF( lev1 <= 0 ) { t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); @@ -1401,6 +1429,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { t = add( 13, lev1 ); } +#endif *ctx = L_add( imult3216( L_and( *ctx, 0xf ), 16 ), t ); move32(); @@ -1425,15 +1454,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } } /*end of the 2-tuples loop*/ - - total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ - +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else + total_output_bits = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#endif IF( *stop ) { - total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else + total_output_bits = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ +#endif } - IF( stop2 ) + if ( stop2 ) { stop2 = total_output_bits; /* Q0 */ move16(); @@ -1455,8 +1490,11 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( hm_cfg->numPeakIndices = numPeakIndicesOrig; /* Q0 */ move16(); - +#ifdef OPT_SBA_ENC_V2_BE + return round_fx( L_add( W_shl_sat_l( nbits2_fx, -Q7 ), ONE_IN_Q14 ) ); /* Q0 */ +#else return round_fx( L_add( W_extract_l( W_shr( nbits2_fx, Q7 ) ), ONE_IN_Q14 ) ); /* Q0 */ +#endif } ELSE /* if (!hm_cfg) */ { @@ -1530,6 +1568,21 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) + { + pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ + + bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); + bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); + + a1 = shr( a1, 1 ); + b1 = shr( b1, 1 ); + + lev1 = add( lev1, 1 ); + esc_nb = s_min( lev1, 3 ); + } +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) { pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ @@ -1546,15 +1599,18 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* check while condition */ } - +#endif pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */ - move16(); symbol = add( a1, i_mult( A_THRES, b1 ) ); /* Q0 */ bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); /* Should we truncate? */ +#ifdef OPT_SBA_ENC_V2_BE + IF( GT_64( bit_estimate_fx, W_shl( target, Q23 ) ) ) // Q23 +#else IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) +#endif { overflow_flag = 1; move16(); @@ -1570,6 +1626,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( } } +#ifdef OPT_SBA_ENC_V2_BE + /* Update context for next 2-tuple */ + cp = add( 1, i_mult( add( a1, b1 ), add( esc_nb, 1 ) ) ); /* Q0 */ + if ( GE_16( esc_nb, 2 ) ) + { + cp = add( 12, esc_nb ); /* Q0 */ + } +#else /* Update context for next 2-tuple */ IF( LT_16( esc_nb, 2 ) ) { @@ -1579,59 +1643,94 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( { cp = add( 12, esc_nb ); /* Q0 */ } +#endif /*shift old bits and replace last 4 bits*/ s = (UWord16) L_add( L_shl( s, 4 ), cp ); t = s_and( s, 0xFF ); - } /*end of the 2-tuples loop*/ +#ifdef OPT_SBA_ENC_V2_BE + tot_bits2 = round_fx( W_shl_sat_l( nbits2_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ + round_bit_estimate_fx = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ +#else tot_bits2 = round_fx( W_extract_l( W_shr( nbits2_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ - IF( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ +#endif + if ( LT_16( lastnz2, lastnz ) ) /* Overflow occured because unable to code all tuples */ { overflow_flag = 1; move16(); } +#ifdef OPT_SBA_ENC_V2_BE + if ( EQ_16( mode, -1 ) ) + { + tot_bits2 = round_bit_estimate_fx; + move16(); + } +#else IF( EQ_16( mode, -1 ) ) { - tot_bits2 = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + tot_bits2 = round_fx( W_shl_sat_l( bit_estimate_fx, -Q7 ) ); /* Q23 -> Q16 -> Q0 */ + } +#endif +#ifdef OPT_SBA_ENC_V2_BE + if ( overflow_flag == 0 ) /* No overflow */ + { + *stop = 0; + move16(); } + IF( overflow_flag != 0 ) /* Overflow */ + { + IF( *stop ) + { + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE + { + *stop = round_bit_estimate_fx; + move16(); + } + } +#else IF( overflow_flag == 0 ) /* No overflow */ { *stop = 0; move16(); } ELSE /* Overflow */ + { + IF( *stop ) { - IF( *stop ){ - *stop = tot_bits2; /* Q0 */ + *stop = tot_bits2; /* Q0 */ + move16(); + } + ELSE + { + *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + move16(); + } + } +#endif + + *lastnz_out = lastnz; /* Q0 */ move16(); - } - ELSE - { - *stop = round_fx( W_extract_l( W_shr( bit_estimate_fx, Q7 ) ) ); /* Q23 -> Q16 -> Q0 */ + *nEncoded = lastnz2; /* Q0 */ move16(); - } -} + /* Safety mechanism to avoid overflow */ + test(); + IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) + { + FOR( k = 0; k < lastnz2; k++ ) + { + x[k] = 0; + move16(); + } + } -*lastnz_out = lastnz; /* Q0 */ -move16(); -*nEncoded = lastnz2; /* Q0 */ -move16(); -/* Safety mechanism to avoid overflow */ -test(); -IF( EQ_16( lastnz2, 2 ) && EQ_16( overflow_flag, 1 ) ) -{ - FOR( k = 0; k < lastnz2; k++ ) - { - x[k] = 0; - move16(); + return tot_bits2; } } -return tot_bits2; -} -} - /*-------------------------------------------------------------------* * RCcontextMapping_encode2_estimate_bandWise_start_fx() @@ -1743,6 +1842,15 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* Get context */ t = add( hContextMem->ctx, hContextMem->rateFlag ); /* Q0 */ +#ifdef OPT_SBA_ENC_V2_BE + tmp = ( 1 << NBITS_CONTEXT ); + move16(); + if ( GE_16( hContextMem->nt_half, idx ) ) + { + tmp = 0; + move16(); + } +#else IF( GE_16( hContextMem->nt_half, idx ) ) { tmp = 0; @@ -1751,6 +1859,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( { tmp = ( 1 << NBITS_CONTEXT ); } +#endif t = add( t, tmp ); /* Q0 */ @@ -1771,15 +1880,18 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( /* check while condition */ /* MSBs coding */ +#ifdef OPT_SBA_ENC_V2_BE + FOR( ; s_max( a1, b1 ) >= A_THRES; ) +#else WHILE( GE_16( s_max( a1, b1 ), A_THRES ) ) +#endif { pki = lookup[lev1]; /* Q0 */ - move16(); hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] ); hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 2, Q23 ) ); - move32(); - move32(); + move64(); + move64(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC]; @@ -1789,20 +1901,27 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( b1 = shr( b1, 1 ); lev1 = s_min( add( lev1, ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ) ), 2 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */ - /* check while condition */ + /* check while condition */ } pki = lookup[lev1]; /* Q0 */ - move16(); + symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol Q0*/ hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); - move32(); + move64(); // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol]; /* Update context */ lev1 = shr( lev1, NBITS_CONTEXT + NBITS_RATEQ ); +#ifdef OPT_SBA_ENC_V2_BE + t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */ + if ( lev1 > 0 ) + { + t = add( 13, lev1 ); /* Q0 */ + } +#else IF( lev1 <= 0 ) { t = add( 1, i_mult( add( a1, b1 ), add( lev1, 2 ) ) ); /* Q0 */ @@ -1811,12 +1930,16 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx( { t = add( 13, lev1 ); /* Q0 */ } - +#endif hContextMem->ctx = add( i_mult( s_and( hContextMem->ctx, 0xf ), 16 ), t ); /* Q0 */ move16(); - } /*end of the 2-tuples loop*/ + } /*end of the 2-tuples loop*/ +#ifdef OPT_SBA_ENC_V2_BE + total_output_bits = round_fx( W_shl_sat_l( hContextMem->bit_estimate_fx, -Q7 ) ); /* Q0 */ +#else total_output_bits = round_fx( W_extract_l( W_shr( hContextMem->bit_estimate_fx, Q7 ) ) ); /* Q0 */ +#endif // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f ); -- GitLab From 3d8604007ee24a30d923c1e6a0c491327479a860 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 17:12:13 +0530 Subject: [PATCH 160/394] Fix for SSNR deviation observed for one STV case --- lib_enc/ACcontextMapping_enc_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_enc/ACcontextMapping_enc_fx.c b/lib_enc/ACcontextMapping_enc_fx.c index 0bbc78912..a7944410b 100644 --- a/lib_enc/ACcontextMapping_enc_fx.c +++ b/lib_enc/ACcontextMapping_enc_fx.c @@ -1251,6 +1251,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( #ifdef OPT_SBA_ENC_V2_BE Word16 round_bit_estimate_fx; + Word32 target_Q15 = L_shl( target, Q15 ); // Q15 #endif WHILE( LT_16( k, nt / 2 ) ) @@ -1388,7 +1389,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( bit_estimate_fx = W_add( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] ); #ifdef OPT_SBA_ENC_V2_BE - IF( GT_64( bit_estimate_fx, W_shl( target, Q23 ) ) ) // Q23 + IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15 #else /* Should we truncate? */ IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) @@ -1607,7 +1608,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx( /* Should we truncate? */ #ifdef OPT_SBA_ENC_V2_BE - IF( GT_64( bit_estimate_fx, W_shl( target, Q23 ) ) ) // Q23 + IF( GT_32( W_shl_sat_l( bit_estimate_fx, -Q8 ), target_Q15 ) ) // Q15 #else IF( GT_32( W_extract_l( W_shr( bit_estimate_fx, Q8 ) ), L_shl( target, Q15 ) ) ) #endif -- GitLab From 2362d2922d4ccdace84d9b27c6bde875cd78174b Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 17 Jun 2025 15:14:26 +0200 Subject: [PATCH 161/394] Modified dynamic q_win calculation in IMDCT_ivas_fx() --- lib_dec/dec_tcx_fx.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index bb2c64cad..7025ee066 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2613,26 +2613,17 @@ static Word16 IMDCT_ivas_fx_calc_qwin( q_win = 6; move16(); - Word16 q_shift_syn_Overl_TDAC, q_shift_syn_Overl, q_shift_old_syn_Overl, q_shift_old_out; // q_win == norm + Q_syn_Overl_TDAC - q_shift_syn_Overl_TDAC = norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ); - q_win = s_min( q_win, q_shift_syn_Overl_TDAC + Q_syn_Overl_TDAC ); + q_win = s_min( q_win, norm_arr( syn_Overl_TDAC, syn_Overl_TDAC_len ) + Q_syn_Overl_TDAC ); // q_win = s_min( q_win, norm_arr( syn_Overl, oldLength / 2 ) + Q_syn_Overl ); - q_shift_syn_Overl = norm_arr( syn_Overl, old_syn_Overl_len ); - q_win = s_min( q_win, q_shift_syn_Overl + Q_syn_Overl ); + q_win = s_min( q_win, norm_arr( syn_Overl, old_syn_Overl_len ) + Q_syn_Overl ); - q_shift_old_syn_Overl = norm_arr( old_syn_Overl, old_syn_Overl_len ); - q_win = s_min( q_win, q_shift_old_syn_Overl + Q_old_syn_Overl ); + q_win = s_min( q_win, norm_arr( old_syn_Overl, old_syn_Overl_len ) + Q_old_syn_Overl ); // q_win = s_min( q_win, norm_arr( old_out_fx, oldLength ) + Q_old_out_fx ); - q_shift_old_out = norm_arr( old_out_fx, t ); - q_win = s_min( q_win, q_shift_old_out + Q_old_out_fx ); - - if ( q_shift_syn_Overl_TDAC == Q15 && q_shift_syn_Overl == Q15 && - q_shift_old_syn_Overl == Q15 && q_shift_old_out == Q15 ) - q_win = 0; + q_win = s_min( q_win, norm_arr( old_out_fx, t ) + Q_old_out_fx ); #if 0 set16_zero_fx(syn_Overl_TDAC + oldLength / 2, (t-oldLength)/2 ); @@ -3471,7 +3462,15 @@ void IMDCT_ivas_fx( q_diff = sub( q_old_out, q_win ); #endif - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + if ( allow_qwin_change ) + { + // sub( q_tmp_fx_32, q_win ) == -norm_arr( xn_buf_fx, L_frame ) + // q_tmp_fx_32 - q_win == -norm_arr( xn_buf_fx, L_frame ) + // q_win == q_tmp_fx_32 + norm_arr( xn_buf_fx, L_frame ) + q_win = s_min( q_win, add( q_tmp_fx_32, norm_arr( xn_buf_fx, L_frame ) ) ); + } +#endif Word16 diff = sub( q_tmp_fx_32, q_win ); FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -- GitLab From d45dfc4284e328e425dae1dd5bfa8496cae5220b Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 17 Jun 2025 15:28:39 +0200 Subject: [PATCH 162/394] Applied Clang formatting patch. --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 7025ee066..c808df560 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3464,7 +3464,7 @@ void IMDCT_ivas_fx( #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN if ( allow_qwin_change ) - { + { // sub( q_tmp_fx_32, q_win ) == -norm_arr( xn_buf_fx, L_frame ) // q_tmp_fx_32 - q_win == -norm_arr( xn_buf_fx, L_frame ) // q_win == q_tmp_fx_32 + norm_arr( xn_buf_fx, L_frame ) -- GitLab From 2e84f3f4edf07e2040c83909dc09457d43a326f4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 12:41:36 +0530 Subject: [PATCH 163/394] Fix for 3GPP issue 986: Stereo decoding, 16-20 kHz difference Link #986 Differences existed due to an addition with a factor (0.001f) missing in fixed point code. Changes added to address the same. --- lib_com/swb_tbe_com_fx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e4d84ef23..fcd4e12ee 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6935,7 +6935,10 @@ void synthesise_fb_high_band_fx( Word32 temp1; Word32 ratio2; Word32 L_tmp; - Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp; + Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp, sft, t_Q /* to store temporary Q for computations */; + Word64 P_ONE = 33; /* 0.001f in Q15 */ + move64(); + Word64 W_temp; /* Interpolate the white energy shaped gaussian excitation from 16 kHz to 48 kHz with zeros */ j = 0; @@ -6982,17 +6985,28 @@ void synthesise_fb_high_band_fx( elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); #endif } + /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); + t_Q = sub( shl( exp_tmp, 1 ), 8 ); + P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); + + W_temp = W_add( P_ONE, temp1 ); + + sft = W_norm( W_temp ); + W_temp = W_shl( W_temp, sft ); + + temp1 = W_extract_h( W_temp ); + t_Q = sub( add( t_Q, sft ), 32 ); + L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/ exp = norm_l( L_tmp ); tmp3 = extract_h( L_shl( L_tmp, exp ) ); tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/ exp = sub( sub( 31, tmp1 ), exp ); - exp2 = norm_l( temp1 ); - tmp2 = extract_h( L_shl( temp1, exp2 ) ); - exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + tmp2 = extract_h( temp1 ); + exp2 = sub( 31, t_Q ); exp = sub( exp2, exp ); /* Denormalize and substract */ IF( GT_16( tmp2, tmp3 ) ) -- GitLab From b3c03a1f9dde36299e6a4b6e6fcf14033cdac69a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 17:09:22 +0530 Subject: [PATCH 164/394] EVS bit exactness fix --- lib_com/swb_tbe_com_fx.c | 45 +++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index fcd4e12ee..2cb51ae93 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6935,10 +6935,7 @@ void synthesise_fb_high_band_fx( Word32 temp1; Word32 ratio2; Word32 L_tmp; - Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp, sft, t_Q /* to store temporary Q for computations */; - Word64 P_ONE = 33; /* 0.001f in Q15 */ - move64(); - Word64 W_temp; + Word16 tmp3, tmp1, tmp2, exp, exp2, exp_tmp; /* Interpolate the white energy shaped gaussian excitation from 16 kHz to 48 kHz with zeros */ j = 0; @@ -6988,25 +6985,39 @@ void synthesise_fb_high_band_fx( /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); - t_Q = sub( shl( exp_tmp, 1 ), 8 ); - P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); - - W_temp = W_add( P_ONE, temp1 ); - - sft = W_norm( W_temp ); - W_temp = W_shl( W_temp, sft ); - - temp1 = W_extract_h( W_temp ); - t_Q = sub( add( t_Q, sft ), 32 ); - L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/ exp = norm_l( L_tmp ); tmp3 = extract_h( L_shl( L_tmp, exp ) ); tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/ exp = sub( sub( 31, tmp1 ), exp ); - tmp2 = extract_h( temp1 ); - exp2 = sub( 31, t_Q ); + IF( element_mode != EVS_MONO ) + { + Word16 sft, t_Q; + Word64 P_ONE = 33; /* 0.001f in Q15 */ + move64(); + Word64 W_temp; + + t_Q = sub( shl( exp_tmp, 1 ), 8 ); + P_ONE = W_shl( P_ONE, sub( t_Q, 15 ) ); + + W_temp = W_add( P_ONE, temp1 ); + + sft = W_norm( W_temp ); + W_temp = W_shl( W_temp, sft ); + + temp1 = W_extract_h( W_temp ); + t_Q = sub( add( t_Q, sft ), 32 ); + + tmp2 = extract_h( temp1 ); + exp2 = sub( 31, t_Q ); + } + ELSE + { + exp2 = norm_l( temp1 ); + tmp2 = extract_h( L_shl( temp1, exp2 ) ); + exp2 = sub( sub( 31, sub( shl( exp_tmp, 1 ), 8 ) ), exp2 ); /* in Q15 (temp1 in Q9)*/ + } exp = sub( exp2, exp ); /* Denormalize and substract */ IF( GT_16( tmp2, tmp3 ) ) -- GitLab From 54a62ff95df0fbd04dcb3548d11fd8da304b9835 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 17 Jun 2025 17:22:45 +0530 Subject: [PATCH 165/394] Extension of #1593 fix into Encoder: plugged in pred_lt4_ivas_fx in encoder --- lib_com/rom_com.c | 29 +++++++-------------------- lib_com/rom_com.h | 18 ++++++++--------- lib_enc/acelp_core_switch_enc_fx.c | 4 ++-- lib_enc/enc_gen_voic_fx.c | 2 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/ivas_core_pre_proc_front_fx.c | 8 ++++---- lib_enc/ivas_td_low_rate_enc_fx.c | 2 +- lib_enc/pitch_ol2_fx.c | 12 +++++++++-- lib_enc/pitch_ol_fx.c | 8 ++++---- lib_enc/pre_proc_fx.c | 8 ++++---- lib_enc/prot_fx_enc.h | 7 ++++--- lib_enc/transition_enc_fx.c | 12 +++++------ 12 files changed, 53 insertions(+), 59 deletions(-) diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 5d0a7f303..a64b37f7b 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1273,28 +1273,6 @@ const Word16 sin_table256_fx[] = * 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2) *----------------------------------------------------------------------------------*/ - -const Word16 inter4_2_fx_Q15[65] = -{//Q15 - 30801, - 28062, 20718, 11061, 1935, - -4294, -6533, -5195, -1846, - 1559, 3497, 3398, 1705, - -497, -2087, -2413, -1523, - -32, 1252, 1741, 1312, - 305, -710, -1237, -1087, - -426, 350, 848, 862, - 452, -119, -550, -650, - -418, -17, 330, 462, - 349, 85, -175, -306, - -265, -104, 76, 184, - 182, 93, -20, -98, - -110, -66, -3, 43, - 55, 37, 8, -13, - -20, -14, -4, 2, - 3, 1, 0, 0, -}; - const Word16 inter4_2_fx[] = {//evs table , some mismatch in values compared to float is observed 0, 1, 2, 1, @@ -1366,6 +1344,13 @@ const Word16 pitch_inter4_2[PIT_FIR_SIZE2] = 3/*0.000098f Q15*/, 2/*0.000048f Q15*/, 0/*0.000007f Q15*/, 0/*0.000000f Q15*/ }; /* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ +const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = /* Q31 */ +{ + 1932735283, 1758701061, 1298905484, 711630983, 180298432, -162768528, + -280712608, -226956816, -100446400, 9592809, 59676424, 55065776, + 26996016, 4138201, -3373696, -1617055, 0 +}; +/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */ const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = { 29491/*0.900000F Q15*/, diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index a87ee8d0d..a0a388bc6 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -172,16 +172,16 @@ extern const Word32 crit_bands_fx[]; extern const float sincos_t_ext[]; // fft_rel dep extern const Word16 sincos_t_rad3_fx[]; // Q15 extern const Word16 fft256_read_indexes[]; /* FFT Q0*/ -extern const Word16 inter4_2_fx_Q15[]; // Q15 /* 1/4 resolution interpolation filter */ extern const Word16 inter4_2_fx[]; -extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ -extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ -extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/ -extern const Word16 Assym_window_W16fx[]; // Q15 -extern const Word16 assym_window_16k_fx[]; // Q15 -extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 -extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ +extern const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*1Q14*/ +extern const Word16 pitch_inter4_2[PIT_FIR_SIZE2]; /*Q15*/ +extern const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1]; /*Q31*/ +extern const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2]; /*Q31*/ +extern const Word16 Assym_window_W16fx[]; // Q15 +extern const Word16 assym_window_16k_fx[]; // Q15 +extern const Word16 grid50_fx[( GRID50_POINTS - 1 ) / 2 - 1]; // Q15 +extern const Word16 grid40_fx[( GRID40_POINTS - 1 ) / 2 - 1]; // Q15 +extern const Word32 crit_bands_fx[]; /* Table of critical bands Q0*/ extern const Word16 wind_sss_fx[LEN_WIN_SSS]; // Q15 /*window for modify_sf ana*/ extern const Word16 filter5_39s320_120_fx[]; // Q15 diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index 76fa6f151..aaaf08b26 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -632,7 +632,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure @@ -708,7 +708,7 @@ static void encod_gen_voic_core_switch_ivas_fx( * long term prediction on the 2nd sub frame *-----------------------------------------------------------------*/ - pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); FOR( i = L_SUBFR; i < 2 * L_SUBFR; i++ ) { diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index a485a1bf3..da3555cdb 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -578,7 +578,7 @@ void encod_gen_voic_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index bfdf46ea0..21cd474bd 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -744,7 +744,7 @@ void enc_pit_exc_ivas_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index fbd207e26..b378eabad 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1199,10 +1199,10 @@ ivas_error pre_proc_front_ivas_fx( IF( LE_32( element_brate, IVAS_32k ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[0], &voicing_fr_fx[0], 0, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr_fx[1], &voicing_fr_fx[1], L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[2], &voicing_fr_fx[2], 2 * L_SUBFR, wsp_fx, 7, element_mode ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr_fx[3], &voicing_fr_fx[3], 3 * L_SUBFR, wsp_fx, 7, element_mode ); } ELSE { diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index d10527a24..e2c12076d 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -285,7 +285,7 @@ void encod_gen_2sbfr( * Find adaptive exitation *-----------------------------------------------------------------*/ - pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index 7ca13171e..cbeea8f1d 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -36,7 +36,8 @@ void pitch_ol2_fx( const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ) { Word16 i, t, step, fraction, t0_min, t0_max, t_min, t_max; @@ -158,7 +159,14 @@ void pitch_ol2_fx( IF( NE_32( t1, 1L ) ) { - pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + IF( element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, L_pitch_inter4_1, 4, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( pt_wsp_fx, wsp_fr_fx, t0s, fraction, L_SUBFR, pitch_inter4_1, 4, PIT_UP_SAMP ); + } R0 = cor_max_fx; move16(); diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index fdadcd318..79c55821e 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -2425,8 +2425,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 0, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[0],voicing_fr[1]))>0 */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[0], 8192 ), voicing_fr[1], 8192 ) > 0 ) { @@ -2448,8 +2448,8 @@ void pitchDoubling_det_fx( IF( GE_16( T, PIT_MIN_12k8 ) ) { - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2 ); - pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2 ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[0] ), &new_voicing[0], 2 * L_SUBFR, wspeech, 2, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_SHORTER, T, &( new_op_fr[1] ), &new_voicing[1], 3 * L_SUBFR, wspeech, 2, EVS_MONO ); /* IF(sub(add(new_voicing[0],new_voicing[1]),add(voicing_fr[2],voicing_fr[3]))>0) */ IF( L_msu( L_msu( L_mac( L_mult( new_voicing[0], 8192 ), new_voicing[1], 8192 ), voicing_fr[2], 8192 ), voicing_fr[3], 8192 ) > 0 ) { diff --git a/lib_enc/pre_proc_fx.c b/lib_enc/pre_proc_fx.c index f7ebc8298..dc3ec020a 100644 --- a/lib_enc/pre_proc_fx.c +++ b/lib_enc/pre_proc_fx.c @@ -458,10 +458,10 @@ void pre_proc_fx( IF( LE_32( st->total_brate, ACELP_24k40 ) ) { /* 1/4 pitch precision improvement */ - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7 ); - pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7 ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[0], &voicing_fr[0], 0, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[0], &pitch_fr[1], &voicing_fr[1], L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[2], &voicing_fr[2], 2 * L_SUBFR, wsp, 7, EVS_MONO ); + pitch_ol2_fx( PIT_MIN_EXTEND, st->pitch[1], &pitch_fr[3], &voicing_fr[3], 3 * L_SUBFR, wsp, 7, EVS_MONO ); } ELSE { diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 6ef6991d4..dcdce25b6 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -437,13 +437,14 @@ void pitch_ol2_fx( const Word16 pit_min, /* i : minimum pitch value (20 or 29) */ const Word16 pitch_ol, /* i : pitch to be improved */ Word16 *pitch_fr_fx, - /* o : adjusted 1/4 fractional pitch */ /*Q7 */ + /* o : adjusted 1/4 fractional pitch */ /*Q7*/ Word16 *voicing_fr_fx, - /* o : adjusted 1/4 fractional voicing */ /*Q15 */ + /* o : adjusted 1/4 fractional voicing */ /*Q15*/ const Word16 pos, /* i : position in frame where to calculate the improv. */ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/ - const Word16 delta /* i : delta for pitch search (2 or 7) */ + const Word16 delta, /* i : delta for pitch search (2 or 7) */ + const Word16 element_mode /* i : EVS or IVAS */ ); void pitch_ol_ivas_fx( diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index d0d627697..82e41026d 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -1214,7 +1214,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1263,7 +1263,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1327,7 +1327,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1352,7 +1352,7 @@ void transition_enc_ivas_fx( push_indice( hBstr, IND_PITCH, index, nBits ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1388,7 +1388,7 @@ void transition_enc_ivas_fx( pit_Q_enc_ivas_fx( hBstr, 0, nBits, 8, pit_flag, limit_flag, *T0, *T0_frac, T0_min, T0_max ); /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = tbe_celp_exc_offset( *T0, *T0_frac, st_fx->L_frame ); @@ -1639,7 +1639,7 @@ void transition_enc_ivas_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4_ivas_fx( &exc_fx[i_subfr], &exc_fx[i_subfr], *T0, *T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); offset = L_deposit_l( 0 ); tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ -- GitLab From 866710036f0ed869162200391bbbea931f63b67a Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 18 Jun 2025 00:18:49 +0200 Subject: [PATCH 166/394] fixed typo --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cd71a7768..cf6c67104 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */ #define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */ -======= #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #endif -- GitLab From 554ca834e8b4838416978499f20294388a5dccdc Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 18 Jun 2025 14:19:21 +1000 Subject: [PATCH 167/394] spar com optimizations --- lib_com/ivas_spar_com_fx.c | 22 ++++++++++++++++++++++ lib_com/options.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 15a529149..60c9c8b79 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4257,10 +4257,19 @@ void ivas_get_spar_md_from_dirac_enc_fx( { Word32 norm_fx; Word16 norm_q; + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + Word16 num_ch_order; +#else Word16 num_ch_order, hoa2_ch_order; +#endif num_ch_order = ivas_sba_get_nchan_fx( order, 0 ); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 ); +#else + assert( order == 1 ); +#endif FOR( ch = 0; ch < num_ch_order; ch++ ) { @@ -4327,6 +4336,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( } } +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT + /*normalize 2nd order*/ norm_fx = 0; move32(); @@ -4426,6 +4437,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } +#endif } } @@ -4815,10 +4827,18 @@ void ivas_get_spar_md_from_dirac_fx( { Word32 norm_fx; Word16 norm_q; +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + Word16 num_ch_order; +#else Word16 num_ch_order, hoa2_ch_order; +#endif num_ch_order = ivas_sba_get_nchan_fx( order, 0 ); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT hoa2_ch_order = ivas_sba_get_nchan_fx( SBA_HOA2_ORDER, 0 ); +#else + assert( order == 1 ); +#endif FOR( ch = 0; ch < num_ch_order; ch++ ) { @@ -4885,6 +4905,7 @@ void ivas_get_spar_md_from_dirac_fx( } } +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT /*normalize 2nd order*/ norm_fx = 0; move32(); @@ -4984,6 +5005,7 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index 7996f8d41..ebb93fa2d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,4 +119,6 @@ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ +#define NONBE_FIX_1748_SPAR_DIV_OPT /*Dlb: issue 1748: SPAR common div optimizations*/ + #endif -- GitLab From 40543cfecfd5f2b2d816eec6739ec5fafcd10e73 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 07:23:45 +0200 Subject: [PATCH 168/394] ivas_dirac_output_synthesis_dec_fx.c: change shl_ro to shr_r, invert shift factor and delete overflow flag --- lib_dec/dec_gen_voic_fx.c | 10 +++------- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 +-- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 6 ++---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 14d9d1772..aa1a75b53 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -106,10 +106,6 @@ ivas_error decod_gen_voic_fx( gain_inov_fx = 0; error_fx = 0; gain_preQ_fx = 0; -#ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; - move32(); -#endif move16(); move32(); move32(); @@ -467,9 +463,9 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index cc13c0148..3c1e49f32 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -128,7 +128,6 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, IF( sqrtXY != 0 ) { - Flag Overflow = 0; move32(); normCC = 0; move16(); @@ -136,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); + cc = shr_r( cc, negate(add( normXY, normCC )) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ba0ab8953..e68473c1d 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4082,11 +4082,10 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &overFlow ); // Q15 + lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4095,11 +4094,10 @@ void ivas_lfe_synth_with_filters_fx( } ELSE { - Flag overFlow; transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &overFlow ); // Q15 + transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 } j = 0; move16(); -- GitLab From 37e55195a94799639de8e410686184eec0e13d51 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 07:38:26 +0200 Subject: [PATCH 169/394] apply format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index aa1a75b53..0ad876eb9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -466,8 +466,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 3c1e49f32..a7b9d75ad 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r( cc, negate(add( normXY, normCC )) ); + cc = shr_r( cc, negate( add( normXY, normCC ) ) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index e68473c1d..571fd6b92 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,8 +4084,8 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4096,8 +4096,8 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; move16(); -- GitLab From 7ed09264fd00973fe5d3b44b11581746319a5fa2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 06:14:02 +0000 Subject: [PATCH 170/394] change shr_r to shr_r_sat --- lib_dec/dec_gen_voic_fx.c | 6 +++--- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 0ad876eb9..297f61788 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,9 +463,9 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shr_r( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shr_r( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shr_r( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ + IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a7b9d75ad..72627a5a0 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 571fd6b92..ccdd172c7 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4085,7 +4085,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 + lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4097,7 +4097,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 + transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; move16(); -- GitLab From 88107f0fafbffbe7967623806426c84619c9b717 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 08:19:19 +0200 Subject: [PATCH 171/394] format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 297f61788..ac1df74b2 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -466,8 +466,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ccdd172c7..7d47ea681 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,7 +4084,7 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4096,7 +4096,7 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } j = 0; -- GitLab From b39ec53c0da752036872aac66ac2ba477466422d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 10:25:21 +0200 Subject: [PATCH 172/394] Added switch ISSUE_1751_replace_shl_ro, added casesensitive shl_sat or shr_r --- lib_com/options.h | 1 + lib_dec/dec_gen_voic_fx.c | 25 ++++++++++++++-- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 15 +++++++++- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 29 +++++++++++++++++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7996f8d41..b97f42247 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define VEC_ARITH_OPT_v1 #define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ #define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ +#define ISSUE_1751_replace_shl_ro #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index ac1df74b2..d003b9731 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,11 +463,30 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); - IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ +#ifdef ISSUE_1751_replace_shl_ro + Word16 op16_1 = sub( Qenratio, 15 ); + Word16 op16_2 = sub( Qenratio, 10 ); + Word16 op16_3 = sub( Qsp_enratio, 15 ); + +BASOP_SATURATE_WARNING_OFF + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate(op16_1) ); + op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); + op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); +BASOP_SATURATE_WARNING_ON + + IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#else + Flag Overflow; + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ +#endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 72627a5a0..34b75ed3e 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,20 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF - cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); +#ifdef ISSUE_1751_replace_shl_ro + Word16 op1 = add( normXY, normCC ); + if ( op1 >= 0 ) + { + cc = shl_sat( cc, add( normXY, normCC ) ); + } + else + { + cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + } +#else + Flag Overflow; + cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON *energy = L_shr_r( L_deposit_l( sqrtXY ), normXY ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7d47ea681..2384b3ea5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4085,7 +4085,19 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp - lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 +#ifdef ISSUE_1751_replace_shl_ro + if ( lfeGain_fx_exp >= 0 ) + { + lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 + } + else + { + lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + } +#else + Flag Overflow; + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp &Overflow); // Q15 +#endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) { @@ -4097,7 +4109,20 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp - transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 +#ifdef ISSUE_1751_replace_shl_ro + if ( transportGain_fx_exp >= 0 ) + { + transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 + } + else + { + transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + } +#else + Flag Overflow; + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp &Overflow); // Q15 +#endif + } j = 0; move16(); -- GitLab From aa0608609864633100221bb299ac8caa46f3fa8e Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 10:59:18 +0200 Subject: [PATCH 173/394] apply format patch --- lib_dec/dec_gen_voic_fx.c | 22 +++++++++---------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 13 +++++------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index d003b9731..74eb0f51f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,24 +468,24 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); -BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate(op16_1) ); + BASOP_SATURATE_WARNING_OFF + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); -BASOP_SATURATE_WARNING_ON + BASOP_SATURATE_WARNING_ON - IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ + IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; - IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ + IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shl_ro( enratio, sub( 10, Qenratio ), &Overflow ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shl_ro( sp_enratio, sub( 15, Qsp_enratio ), &Overflow ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #endif { IF( NE_32( ( error = DTFS_new_fx( &PREVP ) ), IVAS_ERR_OK ) ) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 2384b3ea5..5f69f0ec6 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4084,7 +4084,7 @@ void ivas_lfe_synth_with_filters_fx( { lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); - lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp + lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro if ( lfeGain_fx_exp >= 0 ) { @@ -4092,11 +4092,11 @@ void ivas_lfe_synth_with_filters_fx( } else { - lfeGain_fx = shr_r( lfeGain_fx, negate(lfeGain_fx_exp) ); // Q15 + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 } #else Flag Overflow; - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp &Overflow); // Q15 + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 #endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4108,7 +4108,7 @@ void ivas_lfe_synth_with_filters_fx( { transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); - transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp + transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro if ( transportGain_fx_exp >= 0 ) { @@ -4116,13 +4116,12 @@ void ivas_lfe_synth_with_filters_fx( } else { - transportGain_fx = shr_r( transportGain_fx, negate(transportGain_fx_exp) ); // Q15 + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 } #else Flag Overflow; - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp &Overflow); // Q15 + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 #endif - } j = 0; move16(); -- GitLab From 1508027f28c3dc08cf43aab7e680f020e57b6820 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 12:14:51 +0200 Subject: [PATCH 174/394] add asserts to catch all shl_sat, replacing shl_ro --- lib_dec/dec_gen_voic_fx.c | 4 ++++ lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 1 + lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 74eb0f51f..c61d3b56f 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,6 +468,10 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); + assert( op16_1 >= 0 ); + assert( op16_2 >= 0 ); + assert( op16_3 >= 0 ); + BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 34b75ed3e..dd50ac111 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,6 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); + assert( op1 >= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 5f69f0ec6..d8f256b57 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4086,6 +4086,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro + assert( lfeGain_fx_exp >= 0 ); if ( lfeGain_fx_exp >= 0 ) { lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 @@ -4110,6 +4111,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro + assert( transportGain_fx_exp >= 0 ); if ( transportGain_fx_exp >= 0 ) { transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 -- GitLab From 54d86d4ed995b750a84dc5b2fa33c556305ca12c Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 18 Jun 2025 20:52:04 +1000 Subject: [PATCH 175/394] simplify spherical harm response normalization, non-BE --- lib_com/ivas_spar_com_fx.c | 47 +++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 60c9c8b79..65e4b1c29 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4017,7 +4017,12 @@ void ivas_compute_spar_params_fx( Word32 diff_norm_order1_table[4] = { 0, 805306368, 402653184, 268435456 }; // q28 Word32 diff_norm_order2_table[6] = { 0, 1342177280, 671088640, 447392416, 335544320, 268435456 }; // q28 Word32 diff_norm_order3_table[8] = { 0, 1879048192, 939524096, 626349376, 469762048, 375809632, 313174688, 268435456 }; // q28 -#define EPSILON_FX_THR 70 +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT +#define EPSILON_FX_SHIFT 6 +#define EPSILON_FX_THR ( 1 << EPSILON_FX_SHIFT ) +#else +#define EPSILON_FX_THR 70 +#endif #define ONE_BY_THREE_Q31 715827882 #define ONE_BY_FIVE_Q31 429496729 #define ONE_BY_SEVEN_Q31 306783378 @@ -4310,6 +4315,25 @@ void ivas_get_spar_md_from_dirac_enc_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + IF( LT_32( norm_fx, EPSILON_FX_THR ) ) + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ + response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( Q30, EPSILON_FX_SHIFT ) ); // q30 + move32(); + } + } + ELSE + { + response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + move32(); + response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + move32(); + } +#else FOR( ch = 1; ch < foa_ch; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) @@ -4335,6 +4359,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( move32(); } } +#endif #ifndef NONBE_FIX_1748_SPAR_DIV_OPT @@ -4879,6 +4904,25 @@ void ivas_get_spar_md_from_dirac_fx( move16(); } norm_fx = L_shr( norm_fx, sub( 1, norm_q ) ); // q30 + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + IF( LT_32( norm_fx, EPSILON_FX_THR ) ) + { + FOR( ch = 1; ch < foa_ch; ch++ ) + { + /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ + response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( Q30, EPSILON_FX_SHIFT ) ); // q30 + move32(); + } + } + ELSE + { + response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + move32(); + response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + move32(); + } +#else FOR( ch = 1; ch < foa_ch; ch++ ) { IF( LT_32( norm_fx, EPSILON_FX_THR ) ) @@ -4904,6 +4948,7 @@ void ivas_get_spar_md_from_dirac_fx( move32(); } } +#endif #ifndef NONBE_FIX_1748_SPAR_DIV_OPT /*normalize 2nd order*/ -- GitLab From 1079d508be1e4cc6aad38c80828268594d19ef2c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 13:01:04 +0200 Subject: [PATCH 176/394] check asserts for shl_ro : insert asserts for other direction --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 ++- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index dd50ac111..1e1b33ff1 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,8 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); + // assert( op1 >= 0 ); FAILS + assert( op1 <= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index d8f256b57..17a821adb 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4086,7 +4086,8 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( lfeGain_fx_exp >= 0 ); + // assert( lfeGain_fx_exp >= 0 ); FAILS + assert( lfeGain_fx_exp <= 0 ); if ( lfeGain_fx_exp >= 0 ) { lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 -- GitLab From 0591e5765e735029061727ed1021d8d2e805784a Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:12:11 +0200 Subject: [PATCH 177/394] shl_ro: change asserts and run once again --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 17a821adb..b0c193006 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4112,7 +4112,8 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( transportGain_fx_exp >= 0 ); + //assert( transportGain_fx_exp >= 0 ); FAILS + assert( transportGain_fx_exp <= 0 ); if ( transportGain_fx_exp >= 0 ) { transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 -- GitLab From 6c14262bb9160ccee761365349d061b4f5b4c541 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:15:23 +0200 Subject: [PATCH 178/394] clang patch --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index b0c193006..9076dd2c2 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4112,7 +4112,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - //assert( transportGain_fx_exp >= 0 ); FAILS + // assert( transportGain_fx_exp >= 0 ); FAILS assert( transportGain_fx_exp <= 0 ); if ( transportGain_fx_exp >= 0 ) { -- GitLab From 0b03383556848ad4d5f5662cfd0b5a4383e97733 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:43:17 +0200 Subject: [PATCH 179/394] shl_ro: edit one more assert, run once more --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 1e1b33ff1..e07472aef 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); FAILS - assert( op1 <= 0 ); + //assert( op1 <= 0 ); FAILS --> twoway needed if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); -- GitLab From d2dee91e120afee46014166f97588ac8d72435d3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 15:56:25 +0200 Subject: [PATCH 180/394] clang patch --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index e07472aef..71e221a61 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); FAILS - //assert( op1 <= 0 ); FAILS --> twoway needed + // assert( op1 <= 0 ); FAILS --> twoway needed if ( op1 >= 0 ) { cc = shl_sat( cc, add( normXY, normCC ) ); -- GitLab From 08c6d6c328aad69ae9a2720444b1d7df87f7500e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 18 Jun 2025 21:20:46 +0530 Subject: [PATCH 181/394] Fix for 3GPP issue 1694: USAN in ivas_sba_dec_render_fx Link #1694 --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6b5023a70..dc75e00b8 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2617,7 +2617,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); - FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) + FOR( ch_idx = 0; ch_idx < (MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS); ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } -- GitLab From fce38af3bc45afc7d63a6e307447419ecd7f4aa0 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 18 Jun 2025 21:27:09 +0530 Subject: [PATCH 182/394] Clang formatting changes --- lib_dec/ivas_jbm_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index dc75e00b8..a36982777 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2617,7 +2617,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); - FOR( ch_idx = 0; ch_idx < (MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS); ch_idx++ ) + FOR( ch_idx = 0; ch_idx < ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } -- GitLab From fe4a6d04c40e1740707442dd637ec64d0ac0f6d3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 18 Jun 2025 21:32:07 +0530 Subject: [PATCH 183/394] Fix for 3GPP issue 1753: Renderer crash in OMASA to MASA (diffuse_meta_merge_1x1_fx) Link #1753 --- lib_rend/ivas_masa_merge_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index d90076847..e0dd57afb 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -192,6 +192,11 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( total_nrg_fx, EPSILON_FX ), &scale ); L_tmp1 = L_deposit_h( tmp ); /* Q( 31 - ( scale + total_nrg_e - total_diff_nrg_e ) ) */ scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); + if ( L_tmp1 == 0 ) + { + scale = 30; + move16(); + } L_tmp2 = L_sub( L_shl( 1, scale ), L_tmp1 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp ); -- GitLab From 8e294c8eef9ee5db708e054f8c040568e0617ca3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 19 Jun 2025 11:21:43 +1000 Subject: [PATCH 184/394] add missing loop line --- lib_com/ivas_spar_com_fx.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 65e4b1c29..02cc83d68 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4289,6 +4289,11 @@ void ivas_get_spar_md_from_dirac_enc_fx( } /*normalize 1st order*/ +#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT + Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 ); + norm_t = norm_t - 1; + scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t ); +#endif norm_fx = 0; move32(); norm_q = 0; @@ -4328,10 +4333,13 @@ void ivas_get_spar_md_from_dirac_enc_fx( } ELSE { - response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 - move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 - move32(); + FOR( ch = 1; ch < foa_ch; ch++ ) + { + response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + move32(); + response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + move32(); + } } #else FOR( ch = 1; ch < foa_ch; ch++ ) @@ -4878,6 +4886,11 @@ void ivas_get_spar_md_from_dirac_fx( } /*normalize 1st order*/ +#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT + Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 ); + norm_t = norm_t - 1; + scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t ); +#endif norm_fx = 0; move32(); norm_q = 0; @@ -4917,10 +4930,13 @@ void ivas_get_spar_md_from_dirac_fx( } ELSE { - response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 - move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 - move32(); + FOR( ch = 1; ch < foa_ch; ch++ ) + { + response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + move32(); + response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + move32(); + } } #else FOR( ch = 1; ch < foa_ch; ch++ ) -- GitLab From 91fed7387e7557d914211e69af8f3e60decabfca Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 19 Jun 2025 12:55:55 +1000 Subject: [PATCH 185/394] improve precision of average sph harm resp --- lib_com/ivas_spar_com_fx.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 02cc83d68..e1c216d00 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4264,7 +4264,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order; + Word16 num_ch_order, norm_t; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4289,21 +4289,28 @@ void ivas_get_spar_md_from_dirac_enc_fx( } /*normalize 1st order*/ -#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT - Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 ); - norm_t = norm_t - 1; - scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t ); +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); + move16(); + norm_t = sub( norm_t, 1 ); + move16(); + scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); #endif norm_fx = 0; move32(); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT norm_q = 0; move16(); +#endif FOR( ch = 1; ch < foa_ch; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) ); +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q +#else IF( norm_fx ) { norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q @@ -4313,6 +4320,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( norm_fx = EPSILON_FX; move32(); } +#endif IF( norm_q <= 0 ) { norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31 @@ -4861,7 +4869,7 @@ void ivas_get_spar_md_from_dirac_fx( Word32 norm_fx; Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order; + Word16 num_ch_order, norm_t; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4886,21 +4894,29 @@ void ivas_get_spar_md_from_dirac_fx( } /*normalize 1st order*/ -#if 0 // def NONBE_FIX_1748_SPAR_DIV_OPT - Word16 norm_t = L_norm_arr( &response_avg_fx[1], foa_ch - 1 ); - norm_t = norm_t - 1; - scale_sig32( &response_avg_fx[1], foa_ch - 1, norm_t ); +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); + move16(); + norm_t = sub( norm_t, 1 ); + move16(); + scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); #endif norm_fx = 0; move32(); +#ifndef NONBE_FIX_1748_SPAR_DIV_OPT norm_q = 0; move16(); +#endif FOR( ch = 1; ch < foa_ch; ch++ ) { norm_fx = L_add( norm_fx, Mpy_32_32( response_avg_fx[ch], response_avg_fx[ch] ) ); // q29 } norm_q = sub( 31, ( sub( add( 30, 30 ), 31 ) ) ); + +#ifdef NONBE_FIX_1748_SPAR_DIV_OPT + norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q +#else IF( norm_fx ) { norm_fx = Sqrt32( norm_fx, &norm_q ); // q=31-norm_q @@ -4910,6 +4926,8 @@ void ivas_get_spar_md_from_dirac_fx( norm_fx = EPSILON_FX; move32(); } +#endif + IF( norm_q <= 0 ) { norm_fx = L_shr( norm_fx, ( negate( norm_q ) ) ); // q=31 -- GitLab From 299255b69eeff0bfa8b2ef1b2035cb48c692a12c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 19 Jun 2025 09:35:02 +0530 Subject: [PATCH 186/394] Bug fix: tilt_code deviation fix Fix for the excdiffQ buffer deviating due to wrong value of tilt_code. tilt_code was deviating due to use of L_SUBFR as length instead of L_subfr. --- lib_enc/enc_pit_exc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 21cd474bd..548e3f904 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -814,7 +814,7 @@ void enc_pit_exc_ivas_fx( /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, + gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); @@ -823,7 +823,7 @@ void enc_pit_exc_ivas_fx( gcode16 = round_fx_sat( Lgcode ); IF( use_fcb != 0 ) { - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_SUBFR, 0 ); // Q15 + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); // Q15 move16(); } ELSE -- GitLab From 6608422911895b67948c8e6636224a22c61c7c4d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 19 Jun 2025 14:22:01 +0530 Subject: [PATCH 187/394] Fix for 3GPP issue 1752: Renderer crash for MC in META input in ivas_mcmasa_param_est_ana_fx Link #1752 --- lib_rend/ivas_mcmasa_ana_fx.c | 41 +++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index bce7a4a5a..b2b4039f3 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -952,7 +952,7 @@ void ivas_mcmasa_param_est_ana_fx( temp2 = L_add( temp2, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, temp2, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, temp2_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 stereoness_fx = Mult_32_32( stereoCoh_fx, lsEnergyRelation_fx ); stereoness_e = stereoCoh_e; move16(); @@ -1105,12 +1105,12 @@ void ivas_mcmasa_param_est_ana_fx( lsEnergySum_fx = L_add_sat( lsEnergySum_fx, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp1, lsEnergySum_fx, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp1_e, lsEnergySum_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 stereoRatio_fx = L_sub( Mult_32_32( L_shl_sat( stereoCoh_fx, stereoCoh_e ), lsEnergyRelation_fx ), surrCoh_fx ); // Q31 - + temp2 = L_sub( temp2, EPSILON_FX ); lsEnergyRelation_fx = BASOP_Util_Divide3232_Scale( temp2, lsEnergySum_fx, &lsEnergyRelation_e ); lsEnergyRelation_e = add( lsEnergyRelation_e, sub( temp2_e, lsEnergySum_e ) ); - lsEnergyRelation_fx = L_shl( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 + lsEnergyRelation_fx = L_shl_sat( lsEnergyRelation_fx, add( 16, lsEnergyRelation_e ) ); // Q31 cohPanRatio_fx = L_sub( Mult_32_32( cohPanCoh_fx, lsEnergyRelation_fx ), surrCoh_fx ); // Q31 IF( GT_32( stereoRatio_fx, cohPanRatio_fx ) ) @@ -1436,24 +1436,33 @@ static void computeVerticalDiffuseness_fx( { Word16 tmp_e1, tmp_e2; tmp = BASOP_Util_Divide3232_Scale( intensity_slow_abs[i], L_add( energy_slow[i], EPSILON_FX_SMALL ), &tmp_e1 ); - tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) ); - tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */ - tmp_e2 = add( tmp_e2, tmp_e1 ); - tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp ); - IF( tmp < 0 ) + IF( tmp != 0 ) { - tmp = 0; - move32(); + tmp_e1 = add( tmp_e1, sub( intensity_slow_e[i], energy_slow_e[i] ) ); + tmp = BASOP_Util_Divide3232_Scale( L_sub( tmp, L_shr( VERTICAL_ENERGY_RATIO_OFFSET_FX, tmp_e1 ) ), L_sub( ONE_IN_Q15, VERTICAL_ENERGY_RATIO_OFFSET_FX ), &tmp_e2 ); /* Tuned to avoid effect due to ambience of vertically un-even setups */ + tmp_e2 = add( tmp_e2, tmp_e1 ); + tmp = L_sub( L_shl( 1, sub( 15, tmp_e2 ) ), tmp ); + IF( tmp < 0 ) + { + tmp = 0; + move32(); + } + ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) ) + { + tmp = ONE_IN_Q31; // Q31 + move32(); + } + ELSE + { + tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31 + } } - ELSE IF( GE_32( tmp, L_shl( 1, sub( 15, tmp_e2 ) ) ) ) + ELSE { tmp = ONE_IN_Q31; // Q31 move32(); } - ELSE - { - tmp = L_shl( tmp, add( 16, tmp_e2 ) ); // Q31 - } + diffuseness[i] = tmp; // Q31 move32(); } -- GitLab From 65909d1b02e1ff2bf3c1a5528cbf9f6afe654a77 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 19 Jun 2025 17:24:01 +0530 Subject: [PATCH 188/394] Bug fix in E_ACELP_4tsearchx function --- lib_enc/enc_acelpx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 240f9859c..1a17a0f9c 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -623,7 +623,7 @@ void E_ACELP_4tsearchx_ivas_fx( /* Init to avoid crash when the search does not find a solution */ FOR( k = 0; k < nb_pulse; k++ ) { - codvec[k] = k; + codvec[k] = s_and( k, 3 ); move16(); } -- GitLab From 5a952a01ad9f232f646350b0aaef3a71f44d1689 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 23 Jun 2025 13:00:36 +1000 Subject: [PATCH 189/394] replace divide3232 with BASOP_Util_Divide3232_Scale_newton --- lib_com/ivas_spar_com_fx.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index e1c216d00..0d6b9ec03 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4264,7 +4264,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order, norm_t; + Word16 num_ch_order, norm_t, tmp_e; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4291,9 +4291,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( /*normalize 1st order*/ #ifdef NONBE_FIX_1748_SPAR_DIV_OPT norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); - move16(); norm_t = sub( norm_t, 1 ); - move16(); scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); #endif norm_fx = 0; @@ -4343,9 +4341,9 @@ void ivas_get_spar_md_from_dirac_enc_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + response_avg_fx[ch] = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ), &tmp_e ); // Q31 - tmp_e move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( tmp_e, Q1 ) ); // q30 move32(); } } @@ -4869,7 +4867,7 @@ void ivas_get_spar_md_from_dirac_fx( Word32 norm_fx; Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order, norm_t; + Word16 num_ch_order, norm_t, tmp_e; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4896,9 +4894,7 @@ void ivas_get_spar_md_from_dirac_fx( /*normalize 1st order*/ #ifdef NONBE_FIX_1748_SPAR_DIV_OPT norm_t = L_norm_arr( &response_avg_fx[1], sub( foa_ch, 1 ) ); - move16(); norm_t = sub( norm_t, 1 ); - move16(); scale_sig32( &response_avg_fx[1], sub( foa_ch, 1 ), norm_t ); #endif norm_fx = 0; @@ -4950,9 +4946,9 @@ void ivas_get_spar_md_from_dirac_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - response_avg_fx[ch] = divide3232( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ) ); // q15 + response_avg_fx[ch] = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ), &tmp_e ); // Q31 - tmp_e move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], 15 ); // q30 + response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( tmp_e, Q1 ) ); // q30 move32(); } } -- GitLab From b30ef4a883e416f71aa9c5e5f7f0e6961f824dce Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 23 Jun 2025 09:46:12 +0530 Subject: [PATCH 190/394] Fix for spectral holes by rearranging LPC to LSF conversion, LTV crash issue fix --- lib_enc/inov_enc_fx.c | 2 +- lib_enc/swb_tbe_enc_fx.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index d019bf474..01ba794ea 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -661,7 +661,7 @@ Word16 inov_encode_ivas_fx( { FOR( k = 0; k < L_SUBFR - i; k++ ) { - y2[i + k] = add_sat( y2[i + k], round_fx( L_shl( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked + y2[i + k] = add_sat( y2[i + k], round_fx_sat( L_shl_sat( L_mult( code[i], h2[k] ), sh ) ) ); // Q9 Added saturation: needs to be rechecked move16(); } } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index b001f8693..08c920c4a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3107,6 +3107,14 @@ void swb_tbe_enc_ivas_fx( /* stab_check = a2lsp( lsf_shb, lpc_shb, LPC_SHB_ORDER ); */ + /* LPC to LSP conversion */ + /* LPC: Q12, LSP: Q15 */ + E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); + + /* LSP to LSF conversion */ + /* LSP: Q15, LSF: Q15 */ + E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); + test(); test(); IF( ( NE_16( st_fx->last_extl, SWB_TBE ) && NE_16( st_fx->last_extl, FB_TBE ) ) || st_fx->ini_frame == 0 ) @@ -3124,14 +3132,6 @@ void swb_tbe_enc_ivas_fx( // mvr2r( hBWE_TD->prev_lsp_shb, lsf_shb, LPC_SHB_ORDER ); // } - /* LPC to LSP conversion */ - /* LPC: Q12, LSP: Q15 */ - E_LPC_a_lsp_conversion( lpc_shb_fx, lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); - - /* LSP to LSF conversion */ - /* LSP: Q15, LSF: Q15 */ - E_LPC_lsp_lsf_conversion( lsp_shb_fx, lsf_shb_fx, LPC_SHB_ORDER ); - Copy( lsp_shb_fx, hBWE_TD->prev_lsp_shb_fx, LPC_SHB_ORDER ); Copy( lsf_shb_fx, lsf_shb_orig_fx, LPC_SHB_ORDER ); -- GitLab From 2504797829935cbd23bfb4ca41b55c8a18abd0fa Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 23 Jun 2025 12:09:30 +0530 Subject: [PATCH 191/394] Bug fix: Updated the missed for loop for scaling in ivas_masa_ext_dirac_render_sf_fx --- lib_rend/ivas_dirac_rend_fx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 155524790..81db5703e 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4999,8 +4999,11 @@ static void ivas_masa_ext_dirac_render_sf_fx( } ELSE { - scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); - scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) + { + scale_sig32( Cldfb_RealBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + scale_sig32( Cldfb_ImagBuffer_fx[idx_in][i], hSpatParamRendCom->num_freq_bands, sub( hMasaExtRend->cldfbSynRend[idx_in]->Q_cldfb_state, q_out ) ); + } } FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { -- GitLab From 64042227c655ef786b5342fe48816a5a13b93447 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 23 Jun 2025 14:40:21 +0530 Subject: [PATCH 192/394] Reduce usage of BASOP_Util_Add_Mant32Exp in MCT path Changes are under macro OPT_MCT_ENC_V1_NBE WMOPs reduction of ~130. Tested config: Multi-Channel 7.1+4,48kbps FB --- lib_com/options.h | 1 + lib_enc/ivas_mcmasa_enc_fx.c | 37 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7996f8d41..b45e54671 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -77,6 +77,7 @@ #define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V1_NBE #define OPT_SBA_REND_V1_BE #define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_DEC_V2_BE diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 314424341..ab86efb8d 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2085,6 +2085,41 @@ static void compute_cov_mtx_fx( ) { Word16 i, j; +#ifdef OPT_MCT_ENC_V1_NBE + Word64 temp64_1, temp64_2; + Word16 tmp_16, max_exp; + Word16 temp_exp = shl( inp_exp, 1 ); + FOR( i = 0; i < N; i++ ) + { + FOR( j = i; j < N; j++ ) + { + temp64_1 = W_mac_32_32( W_mult_32_32( sr[i][freq], sr[j][freq] ), si[i][freq], si[j][freq] ); // exp:2*inp_exp + temp64_2 = W_deposit32_h( COVls->xr_fx[i][j] ); // exp:COVls->xr_e[i][j] + max_exp = s_max( COVls->xr_e[i][j], temp_exp ); + temp64_2 = W_shl( temp64_2, sub( COVls->xr_e[i][j], max_exp ) ); // exp:max_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp + tmp_16 = W_norm( temp64_1 ); + + COVls->xr_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xr_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + move16(); + + temp64_1 = W_sub( W_mult_32_32( si[i][freq], sr[j][freq] ), W_mult_32_32( sr[i][freq], si[j][freq] ) ); // exp :2*inp_exp + temp64_2 = W_deposit32_h( COVls->xi_fx[i][j] ); // exp:COVls->xi_e[i][j] + max_exp = s_max( COVls->xi_e[i][j], temp_exp ); + temp64_2 = W_shl( temp64_2, sub( COVls->xi_e[i][j], max_exp ) ); // exp:max_exp + temp64_1 = W_shl( temp64_1, sub( temp_exp, max_exp ) ); // exp:max_exp + temp64_1 = W_add( temp64_1, temp64_2 ); // exp:max_exp + tmp_16 = W_norm( temp64_1 ); + + COVls->xi_fx[i][j] = W_extract_h( W_shl( temp64_1, tmp_16 ) ); // exp:max_exp-tmp_16 + COVls->xi_e[i][j] = sub( max_exp, tmp_16 ); + move32(); + } + } +#else Word32 a, b, c, d; Word32 temp; Word16 norm_a, norm_b, norm_c, norm_d; @@ -2117,7 +2152,7 @@ static void compute_cov_mtx_fx( move32(); } } - +#endif return; } -- GitLab From b8a4ceba02f3f9d1216fc82592fc15aec4488308 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 23 Jun 2025 12:20:52 +0200 Subject: [PATCH 193/394] Corrected the scaling of st->mem_syn2_fx. --- lib_dec/ivas_mdct_core_dec_fx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 74ba24767..d09eb4574 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1338,6 +1338,15 @@ void ivas_mdct_core_reconstruct_fx( Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn // Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) ); Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) ); + + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, st->prev_Q_syn ) ); // st->Q_syn gets a new value, but st->mem_syn2_fx got its value from E_UTIL_f_preemph3 with st->Q_syn = st->prev_Q_syn + } + ELSE + { + Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, add( q_win, 2 ) ) ); // q_win+2 -> st->Q_syn: in this case, E_UTIL_f_preemph2 shifts st->mem_syn2_fx by 2 bits + } #else test(); IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL ) -- GitLab From 1d1b53a5a5552a746d563bc9ada69810c20cd0da Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 23 Jun 2025 18:16:41 +0200 Subject: [PATCH 194/394] Avoid rescale of Q_syn_Overl_TDACFB in TCX PLC, just copy it with current Q value. Also add comment on Q value asignment so it is clear where it comes from after lerp(). --- lib_dec/er_dec_tcx_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 374e4c3a6..5c9b4dcbf 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1860,9 +1860,14 @@ void con_tcx_ivas_fx( move16(); /* create aliasing and windowing need for transition to TCX10/5 */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT + Copy( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ) ); + hTcxDec->Q_syn_Overl_TDACFB = Q_syn; +#else // bufferCopyFx( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), Q_syn, 0, -1, 0 ); Copy_Scale_sig( syn + L_frame, hTcxDec->syn_Overl_TDACFB, shr( L_frame, 1 ), sub( Q_syn, 1 ) ); hTcxDec->Q_syn_Overl_TDACFB = sub( Q_syn, 1 ); +#endif move16(); FOR( i = 0; i < W12; i++ ) @@ -1922,7 +1927,7 @@ void con_tcx_ivas_fx( hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); - st->hHQ_core->Q_old_wtda_LB = Q_syn; + st->hHQ_core->Q_old_wtda_LB = Q_syn; // st->hHQ_core->Q_old_wtda st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); -- GitLab From 1f09e81bea4eed7d404af5ce613f8366fa9c35fd Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 23 Jun 2025 18:20:31 +0200 Subject: [PATCH 195/394] clang format --- lib_dec/er_dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 5c9b4dcbf..37465bc29 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -1927,7 +1927,7 @@ void con_tcx_ivas_fx( hTcxDec->Q_syn_Overl_TDAC = hTcxDec->Q_syn_Overl_TDACFB; move16(); lerp( st->hHQ_core->old_out_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, L_frame ); - st->hHQ_core->Q_old_wtda_LB = Q_syn; // st->hHQ_core->Q_old_wtda + st->hHQ_core->Q_old_wtda_LB = Q_syn; // st->hHQ_core->Q_old_wtda st->old_enr_LP = Enr_1_Az_fx( A_local, L_SUBFR ); /*Q3*/ move16(); -- GitLab From 66578364d370196d64f463f92ee3c84f01e0adad Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:07:39 +0200 Subject: [PATCH 196/394] update CI repo sHA --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e110e0aed..40d84a699 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 41186736915f5c0a857ac92e8ab438c434e5247d + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF a31272de16bd1b556269a50bc179321a60f2a500 include: - local: .gitlab-ci/variables.yml -- GitLab From c809bdea7674b8f96f09ffc3b843be6af3d4f854 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:32:21 +0200 Subject: [PATCH 197/394] add reference to before_script --- .gitlab-ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 40d84a699..a39762643 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1066,13 +1066,14 @@ check-be-between-renderer-framesizes: stage: test needs: ["build-codec-linux-make"] script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - !reference [ .test-job-linux, before_script ] - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh - make clean - make -j + - echo "$SHORT_TEST_SUITE" - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" - - python3 -m pytest --update_ref 1 "$pytest_args" + - python3 -m pytest "$pytest_args" --update_ref 1 - exit_code=0 - exit_code5=0 -- GitLab From fb5d39168462c39caeec259c5d062e099454b8bd Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:33:54 +0200 Subject: [PATCH 198/394] [revert-me] temporarily disable some jobs --- .gitlab-ci.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a39762643..5548bb308 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -850,7 +850,7 @@ build-codec-linux-make: - make -j # ensure that codec builds on linux with instrumentation active -build-codec-linux-instrumented-make: +.build-codec-linux-instrumented-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -867,7 +867,7 @@ build-codec-linux-instrumented-make: - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR -build-codec-linux-debugging-make: +.build-codec-linux-debugging-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -885,7 +885,7 @@ build-codec-linux-debugging-make: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh - make -j -build-codec-windows-msbuild: +.build-codec-windows-msbuild: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -908,7 +908,7 @@ build-codec-windows-msbuild: # --------------------------------------------------------------- ### jobs that check for bitexactness of fx encoder and decoder -check-be-to-target-short-enc-0db: +.check-be-to-target-short-enc-0db: extends: - .check-be-to-target-job variables: @@ -919,7 +919,7 @@ check-be-to-target-short-enc-0db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-be-to-target-short-enc-+10db: +.check-be-to-target-short-enc-+10db: extends: - .check-be-to-target-job variables: @@ -930,7 +930,7 @@ check-be-to-target-short-enc-+10db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-be-to-target-short-enc--10db: +.check-be-to-target-short-enc--10db: extends: - .check-be-to-target-job variables: @@ -941,7 +941,7 @@ check-be-to-target-short-enc--10db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-be-to-target-short-dec-0db: +.check-be-to-target-short-dec-0db: extends: - .check-be-to-target-job variables: @@ -952,7 +952,7 @@ check-be-to-target-short-dec-0db: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -check-be-to-target-short-dec-+10db: +.check-be-to-target-short-dec-+10db: extends: - .check-be-to-target-job variables: @@ -963,7 +963,7 @@ check-be-to-target-short-dec-+10db: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -check-be-to-target-short-dec--10db: +.check-be-to-target-short-dec--10db: extends: - .check-be-to-target-job variables: @@ -975,7 +975,7 @@ check-be-to-target-short-dec--10db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" ### jobs that check for regressions on non-BE testcases -check-regressions-short-enc-0db: +.check-regressions-short-enc-0db: extends: - .check-regressions-pytest-job needs: @@ -989,7 +989,7 @@ check-regressions-short-enc-0db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-regressions-short-enc-+10db: +.check-regressions-short-enc-+10db: extends: - .check-regressions-pytest-job needs: @@ -1003,7 +1003,7 @@ check-regressions-short-enc-+10db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-regressions-short-enc--10db: +.check-regressions-short-enc--10db: extends: - .check-regressions-pytest-job needs: @@ -1017,7 +1017,7 @@ check-regressions-short-enc--10db: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -check-regressions-short-dec-0db: +.check-regressions-short-dec-0db: extends: - .check-regressions-pytest-job needs: @@ -1031,7 +1031,7 @@ check-regressions-short-dec-0db: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -check-regressions-short-dec-+10db: +.check-regressions-short-dec-+10db: extends: - .check-regressions-pytest-job needs: @@ -1045,7 +1045,7 @@ check-regressions-short-dec-+10db: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -check-regressions-short-dec--10db: +.check-regressions-short-dec--10db: extends: - .check-regressions-pytest-job needs: @@ -1540,7 +1540,7 @@ coverage-test-on-main-scheduled: # --------------------------------------------------------------- # check bitexactness to EVS -be-2-evs-26444: +.be-2-evs-26444: extends: - .test-job-linux rules: -- GitLab From 9daed1624511bb5e2e79454fa7c7955a77477261 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:49:01 +0200 Subject: [PATCH 199/394] fix obsolete reference call and add dbg output --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5548bb308..36ae9e0cd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1066,13 +1066,15 @@ check-be-between-renderer-framesizes: stage: test needs: ["build-codec-linux-make"] script: - - !reference [ .test-job-linux, before_script ] - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh - make clean - make -j - echo "$SHORT_TEST_SUITE" - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" + - ls -l + - echo "$pytest_args" + - set euxo - python3 -m pytest "$pytest_args" --update_ref 1 - exit_code=0 -- GitLab From 9b60e5901202deddb2609df16ed19ca839796ec0 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:59:07 +0200 Subject: [PATCH 200/394] try direct putting the command --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 36ae9e0cd..ddb15f700 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1075,7 +1075,8 @@ check-be-between-renderer-framesizes: - ls -l - echo "$pytest_args" - set euxo - - python3 -m pytest "$pytest_args" --update_ref 1 + - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 + # - python3 -m pytest "$pytest_args" --update_ref 1 - exit_code=0 - exit_code5=0 -- GitLab From 6ea8b19de1a60324c8f9d053d936a86cad07bfc2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 11:45:07 +0200 Subject: [PATCH 201/394] add missing build --- .gitlab-ci.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddb15f700..b477d0852 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1070,19 +1070,15 @@ check-be-between-renderer-framesizes: - make clean - make -j - echo "$SHORT_TEST_SUITE" - - pytest_args="$SHORT_TEST_SUITE --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec" - - ls -l - - echo "$pytest_args" - - set euxo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 - # - python3 -m pytest "$pytest_args" --update_ref 1 - exit_code=0 - exit_code5=0 - exit_code10=0 - - python3 -m pytest $pytest_args --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? - - python3 -m pytest $pytest_args --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only || exit_code10=$? + - python3 -m pytest $tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? + - python3 -m pytest $tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only || exit_code10=$? - zero_errors5=$(cat report-junit-5ms.xml | grep -c 'errors="0"') || true - zero_errors10=$(cat report-junit-10ms.xml | grep -c 'errors="0"') || true -- GitLab From 724af1624dd863a2a61a849ac030cdea5b4a6d2e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 12:14:11 +0200 Subject: [PATCH 202/394] remove unsupported testcases before running --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b477d0852..f36594e12 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1072,9 +1072,12 @@ check-be-between-renderer-framesizes: - echo "$SHORT_TEST_SUITE" - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - exit_code=0 + - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 || exit_code=$? + - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors." exit 1; fi + - exit_code5=0 - exit_code10=0 - python3 -m pytest $tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? -- GitLab From 8d1d97234e5a270fcc66c5aec279cdca6a771f4e Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 24 Jun 2025 12:24:04 +0200 Subject: [PATCH 203/394] Modify q_old_out_diff calculation in IMDCT_ivas_fx for TCX-20 and not TCX-only frames. --- lib_dec/dec_tcx_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index d12eabe4f..9e28adeb6 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3385,7 +3385,8 @@ void IMDCT_ivas_fx( Word16 diff = sub( q_tmp_fx_32, q_win ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - Word16 q_old_out_diff = s_max( sub( q_tmp_fx_32, *q_old_out_fx ), 0 ); + // Word16 q_old_out_diff = s_max( sub( q_tmp_fx_32, *q_old_out_fx ), 0 ); + Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); #endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -- GitLab From 9674041d1ad58fae460e7e18c5cf1fdfec2a140d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 13:00:09 +0200 Subject: [PATCH 204/394] change asserts --- lib_dec/dec_gen_voic_fx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index c61d3b56f..fdabd0a3d 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,9 +468,12 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - assert( op16_1 >= 0 ); + //assert( op16_1 >= 0 ); /*FAILS*/ + assert( op16_1 <= 0 ); + assert( op16_2 >= 0 ); - assert( op16_3 >= 0 ); + //assert( op16_3 >= 0 ); /*FAILS*/ + assert( op16_3 <= 0 ); BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); -- GitLab From ef91f515af7630c98ccf1f25144f0dcc0b019baf Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 13:05:20 +0200 Subject: [PATCH 205/394] clang patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index fdabd0a3d..4c8543987 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,11 +468,11 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - //assert( op16_1 >= 0 ); /*FAILS*/ + // assert( op16_1 >= 0 ); /*FAILS*/ assert( op16_1 <= 0 ); assert( op16_2 >= 0 ); - //assert( op16_3 >= 0 ); /*FAILS*/ + // assert( op16_3 >= 0 ); /*FAILS*/ assert( op16_3 <= 0 ); BASOP_SATURATE_WARNING_OFF -- GitLab From aafdfa1096689fa4c1e6368c4ae51dd4a76a88f6 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:09:49 +0200 Subject: [PATCH 206/394] change asserts --- lib_dec/dec_gen_voic_fx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 4c8543987..53ccc4586 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -469,11 +469,13 @@ ivas_error decod_gen_voic_fx( Word16 op16_3 = sub( Qsp_enratio, 15 ); // assert( op16_1 >= 0 ); /*FAILS*/ - assert( op16_1 <= 0 ); + //assert( op16_1 <= 0 ); /*FAILS*/ + + //assert( op16_2 >= 0 ); /*FAILS*/ + assert( op16_2 <= 0 ); - assert( op16_2 >= 0 ); // assert( op16_3 >= 0 ); /*FAILS*/ - assert( op16_3 <= 0 ); + // assert( op16_3 <= 0 ); /*FAILS*/ BASOP_SATURATE_WARNING_OFF op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); -- GitLab From a4d1c5451a340fd0e53f970f63674aecea17e091 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 24 Jun 2025 14:11:31 +0200 Subject: [PATCH 207/394] Modify q_old_out_diff calculation in IMDCT_ivas_fx for TCX-20 and not TCX-only frames. --- lib_dec/dec_tcx_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 9e28adeb6..0e0c6b436 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3385,8 +3385,13 @@ void IMDCT_ivas_fx( Word16 diff = sub( q_tmp_fx_32, q_win ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - // Word16 q_old_out_diff = s_max( sub( q_tmp_fx_32, *q_old_out_fx ), 0 ); Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); + IF( q_old_out_diff < 0) + { + Scale_sig( old_out_fx, L_frame, q_old_out_diff ); + *q_old_out_fx = add( *q_old_out_fx, q_old_out_diff ); + q_old_out_diff = 0; + } #endif FOR( Word16 ind = 0; ind < L_frame; ind++ ) { -- GitLab From e85ff0c6d01baf89d55de20c062c4ed0ee7e11a5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:12:33 +0200 Subject: [PATCH 208/394] clang patch --- lib_dec/dec_gen_voic_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 53ccc4586..e836718d5 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -469,10 +469,10 @@ ivas_error decod_gen_voic_fx( Word16 op16_3 = sub( Qsp_enratio, 15 ); // assert( op16_1 >= 0 ); /*FAILS*/ - //assert( op16_1 <= 0 ); /*FAILS*/ + // assert( op16_1 <= 0 ); /*FAILS*/ - //assert( op16_2 >= 0 ); /*FAILS*/ - assert( op16_2 <= 0 ); + // assert( op16_2 >= 0 ); /*FAILS*/ + assert( op16_2 <= 0 ); // assert( op16_3 >= 0 ); /*FAILS*/ // assert( op16_3 <= 0 ); /*FAILS*/ -- GitLab From 7a097aea15847416726d624fe5cafae68ad5addd Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 24 Jun 2025 14:15:46 +0200 Subject: [PATCH 209/394] Applied Clang formatting patch. --- lib_dec/dec_tcx_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 0e0c6b436..b993f6753 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3386,9 +3386,9 @@ void IMDCT_ivas_fx( Word16 diff = sub( q_tmp_fx_32, q_win ); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD Word16 q_old_out_diff = sub( q_tmp_fx_32, *q_old_out_fx ); - IF( q_old_out_diff < 0) + IF( q_old_out_diff < 0 ) { - Scale_sig( old_out_fx, L_frame, q_old_out_diff ); + Scale_sig( old_out_fx, L_frame, q_old_out_diff ); *q_old_out_fx = add( *q_old_out_fx, q_old_out_diff ); q_old_out_diff = 0; } -- GitLab From 69d1b54024f672dcad5bcbb1e61b8753ac966c0a Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 24 Jun 2025 22:45:28 +1000 Subject: [PATCH 210/394] reduce precision of normalized response to avoid magnitude overshoot --- lib_com/ivas_spar_com_fx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 0d6b9ec03..6dea0a20d 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4265,6 +4265,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( #ifdef NONBE_FIX_1748_SPAR_DIV_OPT Word16 num_ch_order, norm_t, tmp_e; + Word32 tmp_norm_out; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4341,9 +4342,9 @@ void ivas_get_spar_md_from_dirac_enc_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - response_avg_fx[ch] = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ), &tmp_e ); // Q31 - tmp_e - move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( tmp_e, Q1 ) ); // q30 + tmp_norm_out = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ), &tmp_e ); // Q31 - tmp_e + tmp_norm_out = L_shl( tmp_norm_out, sub( tmp_e, Q1 ) ); // q30 + response_avg_fx[ch] = L_and( tmp_norm_out, 0xffff8000 ); // q30 move32(); } } @@ -4868,6 +4869,7 @@ void ivas_get_spar_md_from_dirac_fx( Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT Word16 num_ch_order, norm_t, tmp_e; + Word32 tmp_norm_out; #else Word16 num_ch_order, hoa2_ch_order; #endif @@ -4946,9 +4948,9 @@ void ivas_get_spar_md_from_dirac_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - response_avg_fx[ch] = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, response_avg_fx[ch] ), &tmp_e ); // Q31 - tmp_e - move32(); - response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( tmp_e, Q1 ) ); // q30 + tmp_norm_out = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ), &tmp_e ); // Q31 - tmp_e + tmp_norm_out = L_shl( tmp_norm_out, sub( tmp_e, Q1 ) ); // q30 + response_avg_fx[ch] = L_and( tmp_norm_out, 0xffff8000 ); // q30 move32(); } } -- GitLab From 3c20196fc000eacc787c62cecc5c6bba9ea1aaa2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:46:52 +0200 Subject: [PATCH 211/394] change asserts --- lib_dec/dec_gen_voic_fx.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index e836718d5..557ad9be3 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -468,17 +468,9 @@ ivas_error decod_gen_voic_fx( Word16 op16_2 = sub( Qenratio, 10 ); Word16 op16_3 = sub( Qsp_enratio, 15 ); - // assert( op16_1 >= 0 ); /*FAILS*/ - // assert( op16_1 <= 0 ); /*FAILS*/ - - // assert( op16_2 >= 0 ); /*FAILS*/ - assert( op16_2 <= 0 ); - - // assert( op16_3 >= 0 ); /*FAILS*/ - // assert( op16_3 <= 0 ); /*FAILS*/ - + /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); + op16_1 = op16_1 >= 0 ? shr_r( enratio , op16_1 ) : shl_sat( enratio , negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); BASOP_SATURATE_WARNING_ON -- GitLab From 24f64f6ac6cd3ad7e6083a4f2d511ae0140d1b85 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:50:07 +0200 Subject: [PATCH 212/394] clang patch --- lib_dec/dec_gen_voic_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 557ad9be3..935200eea 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -470,7 +470,7 @@ ivas_error decod_gen_voic_fx( /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio , op16_1 ) : shl_sat( enratio , negate( op16_1 ) ); + op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); BASOP_SATURATE_WARNING_ON -- GitLab From 45c49362a025bf9b6ca1c3b49789acb232ac0bab Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:59:37 +0200 Subject: [PATCH 213/394] cleanup --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index ef780724e..1ef10382e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4428,16 +4428,9 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - // assert( lfeGain_fx_exp >= 0 ); FAILS assert( lfeGain_fx_exp <= 0 ); - if ( lfeGain_fx_exp >= 0 ) - { - lfeGain_fx = shl_sat( lfeGain_fx, lfeGain_fx_exp ); // Q15 - } - else - { - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 - } + /*if assert is thrown, shl_sat can handle the left shift*/ + lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 @@ -4454,16 +4447,9 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - // assert( transportGain_fx_exp >= 0 ); FAILS assert( transportGain_fx_exp <= 0 ); - if ( transportGain_fx_exp >= 0 ) - { - transportGain_fx = shl_sat( transportGain_fx, transportGain_fx_exp ); // Q15 - } - else - { - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 - } + /*if assert is thrown, shl_sat can handle the left shift*/ + transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 -- GitLab From bce58b11c1edef4fea5faf4311f89a874df5d7ad Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 14:59:54 +0200 Subject: [PATCH 214/394] asserts change --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 71e221a61..5743064f2 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,15 +137,14 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - // assert( op1 >= 0 ); FAILS - // assert( op1 <= 0 ); FAILS --> twoway needed + assert( op1 >= 0 ); if ( op1 >= 0 ) { - cc = shl_sat( cc, add( normXY, normCC ) ); + cc = shl_sat( cc, op1 ); } else { - cc = shr_r( cc, negate( add( normXY, normCC ) ) ); + cc = shr_r( cc, negate( op1 ) ); } #else Flag Overflow; -- GitLab From e1ee6cb34676976ee4065492669485e1e1c9278a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 24 Jun 2025 15:07:39 +0200 Subject: [PATCH 215/394] fix for issue 1762 --- lib_com/options.h | 2 ++ lib_enc/analy_sp_fx.c | 4 ++++ lib_enc/find_tilt_fx.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 81300af69..01f7df13f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,4 +122,6 @@ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ +#define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ + #endif diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index dbd656dec..8541decd8 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -642,7 +642,11 @@ void ivas_analy_sp_fx( move32(); /* PS[i] = ( Bin_E[i] + 1e-5f + Bin_E[i + L_FFT / 2] + 1e-5f ) / 2.0f; */ +#ifndef FIX_1762_COMPILER_ISSUE PS[i] = W_extract_h( W_add( W_mac_32_32( W_mult_32_32( Bin_E[i], ONE_IN_Q30 ), Bin_E[i + L_FFT / 2], ONE_IN_Q30 ), W_shr( W_shl( add_const, 32 ), sub( 31, *q_Bin_E ) ) ) ); // *q_Bin_E +#else + PS[i] = W_extract_h( W_add( W_shl( W_add( W_deposit32_l( Bin_E[i] ), W_deposit32_l( Bin_E[i + L_FFT / 2] ) ), 31 ), W_shr( W_shl( add_const, 32 ), sub( 31, *q_Bin_E ) ) ) ); // *q_Bin_E +#endif move32(); /* Bin_E[i] = (float) ( 10.0f * log( PS[i] ) ); */ diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index dc78719d2..d40000434 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -324,7 +324,11 @@ void find_tilt_ivas_fx( } lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ +#ifndef FIX_1762_COMPILER_ISSUE hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr +#else + hp_bckr = W_extract_h( W_shl( W_add( W_deposit32_l( bckr[max_band - 1] ), W_deposit32_l( bckr[max_band] ) ), 31 ) ); // q_bckr +#endif if ( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l( 1 ); -- GitLab From cebd2e3f5d372a71479f8b06258566fcbaec097d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:17:12 +0200 Subject: [PATCH 216/394] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 5743064f2..a04703388 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,8 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); + assert( op1 >= 0 ); /*FAILED*/ + assert( op1 <= 0 ); if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From 0233735aa9281e43dda0737436f97835e58dcd2b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:17:28 +0200 Subject: [PATCH 217/394] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a04703388..a6e735252 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - assert( op1 >= 0 ); /*FAILED*/ + //assert( op1 >= 0 ); /*FAILED*/ assert( op1 <= 0 ); if ( op1 >= 0 ) { -- GitLab From 97bae97b70ac31c2e9893cf06e7244a3f37eb5ed Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 24 Jun 2025 15:18:29 +0200 Subject: [PATCH 218/394] formatting --- lib_enc/find_tilt_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index d40000434..a49955e6c 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -322,14 +322,14 @@ void find_tilt_ivas_fx( { sum = W_mac_32_16( sum, pt_bckr[i], inv_bands ); // q_bckr+16 } - lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr - /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ + lp_bckr = W_shl_sat_l( sum, -16 ); // q_bckr + /*hp_bckr = 0.5f * (bckr[max_band-1] + bckr[max_band]);*/ /* estimated noise E in last 2 critical bands */ #ifndef FIX_1762_COMPILER_ISSUE hp_bckr = W_extract_h( W_mac_32_32( W_mult_32_32( bckr[max_band - 1], ONE_IN_Q30 ), bckr[max_band], ONE_IN_Q30 ) ); // q_bckr #else hp_bckr = W_extract_h( W_shl( W_add( W_deposit32_l( bckr[max_band - 1] ), W_deposit32_l( bckr[max_band] ) ), 31 ) ); // q_bckr #endif - if ( hp_bckr == 0 ) /* Avoid division by zero. */ + if ( hp_bckr == 0 ) /* Avoid division by zero. */ { hp_bckr = L_deposit_l( 1 ); } -- GitLab From 7aa883744d7f335a5cf2247d58c446ffe4e4ad74 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:19:33 +0200 Subject: [PATCH 219/394] clang patch --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index a6e735252..5930f9870 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,7 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - //assert( op1 >= 0 ); /*FAILED*/ + // assert( op1 >= 0 ); /*FAILED*/ assert( op1 <= 0 ); if ( op1 >= 0 ) { -- GitLab From a8f56457e553c93c45c923f8cc7af693cc769846 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 14:34:25 +0200 Subject: [PATCH 220/394] fix typos --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f36594e12..3a3a4b728 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1080,8 +1080,8 @@ check-be-between-renderer-framesizes: - exit_code5=0 - exit_code10=0 - - python3 -m pytest $tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? - - python3 -m pytest $tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only || exit_code10=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only || exit_code5=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only || exit_code10=$? - zero_errors5=$(cat report-junit-5ms.xml | grep -c 'errors="0"') || true - zero_errors10=$(cat report-junit-10ms.xml | grep -c 'errors="0"') || true -- GitLab From 2ad939bc7a179df772a916c85a68e609f5600736 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 24 Jun 2025 23:38:33 +1000 Subject: [PATCH 221/394] roll back to divide3232 to retain q15 precision --- lib_com/ivas_spar_com_fx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 6dea0a20d..2be38b4bc 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4264,7 +4264,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order, norm_t, tmp_e; + Word16 num_ch_order, norm_t; Word32 tmp_norm_out; #else Word16 num_ch_order, hoa2_ch_order; @@ -4342,9 +4342,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - tmp_norm_out = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ), &tmp_e ); // Q31 - tmp_e - tmp_norm_out = L_shl( tmp_norm_out, sub( tmp_e, Q1 ) ); // q30 - response_avg_fx[ch] = L_and( tmp_norm_out, 0xffff8000 ); // q30 + tmp_norm_out = divide3232( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ) ); // q15 + response_avg_fx[ch] = L_shl( tmp_norm_out, 15 ); // q30 move32(); } } @@ -4868,7 +4867,7 @@ void ivas_get_spar_md_from_dirac_fx( Word32 norm_fx; Word16 norm_q; #ifdef NONBE_FIX_1748_SPAR_DIV_OPT - Word16 num_ch_order, norm_t, tmp_e; + Word16 num_ch_order, norm_t; Word32 tmp_norm_out; #else Word16 num_ch_order, hoa2_ch_order; @@ -4948,9 +4947,8 @@ void ivas_get_spar_md_from_dirac_fx( { FOR( ch = 1; ch < foa_ch; ch++ ) { - tmp_norm_out = BASOP_Util_Divide3232_Scale_newton( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ), &tmp_e ); // Q31 - tmp_e - tmp_norm_out = L_shl( tmp_norm_out, sub( tmp_e, Q1 ) ); // q30 - response_avg_fx[ch] = L_and( tmp_norm_out, 0xffff8000 ); // q30 + tmp_norm_out = divide3232( response_avg_fx[ch], L_max( norm_fx, L_abs( response_avg_fx[ch] ) ) ); // q15 + response_avg_fx[ch] = L_shl( tmp_norm_out, 15 ); // q30 move32(); } } -- GitLab From 4d365ea0f650ed5d7895f26267ff9ac5ced4371f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:44:31 +0200 Subject: [PATCH 222/394] change asserts --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index 5930f9870..c2ec4dc83 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -138,7 +138,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); // assert( op1 >= 0 ); /*FAILED*/ - assert( op1 <= 0 ); + // assert( op1 <= 0 ); /*FAILED*/ if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From 36428363d0a13a68c761d476413e3c9ef76c5a0a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 24 Jun 2025 19:42:20 +0530 Subject: [PATCH 223/394] Fix for 3GPP issue 1759: Decoder crash for OSBA ISM4SBA3 at 32kbps FER in cldfbAnalysis_ts() Link #1759 --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c92f800af..7c83143c3 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -596,7 +596,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } - + Word16 q_cldfb_temp = sub( q_input, 1 ); DIRAC_DEC_BIN_HANDLE hDiracDecBin; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; PARAMBIN_REND_CONFIG config_data; @@ -616,7 +616,7 @@ static void ivas_dirac_dec_binaural_internal_fx( nBins = hSpatParamRendCom->num_freq_bands; move16(); offsetSamples = imult1616( hSpatParamRendCom->slots_rendered, nBins ); - + Word32 tmp_arr[CLDFB_NO_CHANNELS_MAX]; /* Setup internal config */ config_data.separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; move16(); @@ -713,13 +713,21 @@ static void ivas_dirac_dec_binaural_internal_fx( test(); IF( ch == 0 || EQ_16( nchan_transport, 2 ) ) { - q_cldfb[ch][slot] = q_input; + q_cldfb[ch][slot] = q_cldfb_temp; move16(); + Copy_Scale_sig32( &( st_ivas->hTcBuffer->tc_fx[ch][nBins * slot + offsetSamples] ), tmp_arr, nBins, -1 ); + scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( q_cldfb_temp, st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); cldfbAnalysis_ts_fx_fixed_q( - &( st_ivas->hTcBuffer->tc_fx[ch][add( imult1616( nBins, slot ), offsetSamples )] ), + tmp_arr, Cldfb_RealBuffer_in_fx[ch][slot], Cldfb_ImagBuffer_in_fx[ch][slot], nBins, st_ivas->cldfbAnaDec[ch], &q_cldfb[ch][slot] ); + scale_sig32( st_ivas->cldfbAnaDec[ch]->cldfb_state_fx, sub( st_ivas->cldfbAnaDec[ch]->p_filter_length, st_ivas->cldfbAnaDec[ch]->no_channels ), sub( q_input, st_ivas->cldfbAnaDec[ch]->Q_cldfb_state ) ); + st_ivas->cldfbAnaDec[ch]->Q_cldfb_state = q_input; + scale_sig32( Cldfb_RealBuffer_in_fx[ch][slot], nBins, 1 ); // Q6 + scale_sig32( Cldfb_ImagBuffer_in_fx[ch][slot], nBins, 1 ); // Q6 + q_cldfb[ch][slot] = add( q_cldfb[ch][slot], 1 ); + move16(); } ELSE IF( EQ_16( config_data.nchan_transport, 2 ) ) /* Stereo signal transmitted as mono with DFT stereo */ { @@ -814,7 +822,6 @@ static void ivas_dirac_dec_binaural_internal_fx( IF( hDiracDecBin->useTdDecorr ) { - Word32 tmp_arr[60]; FOR( ch = BINAURAL_CHANNELS; ch < ( 2 * BINAURAL_CHANNELS ); ch++ ) { q_cldfb[ch][slot] = sub( q_input, 1 ); -- GitLab From e80085b399d251aafa8945397a899cd86319c644 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 24 Jun 2025 19:51:43 +0530 Subject: [PATCH 224/394] Bug fix in gain_enc_lbr_ivas_fx Corrects the calculation of log10(Ecode) and maintenance of Q factor of this which then corrects the gcode0 value. --- lib_enc/gain_enc_fx.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 0ccb31ccf..5e2a11169 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -2525,8 +2525,8 @@ void gain_enc_lbr_ivas_fx( /*Ecode = ( dotp( code, code, L_SUBFR ) + 0.01f ) / L_SUBFR; *gain_inov = 1.0f / (float)sqrt(Ecode);*/ - L_tmp = Dot_product12( code, code, L_subfr, &exp_code ); - L_inov = L_tmp; /* sets to 'L_tmp' in 1 clock */ + L_tmp = Dot_product12( code, code, L_subfr, &exp_code ); /* Q9 + Q9 + 1 + (30-exp_code)*/ + L_inov = L_tmp; /* sets to 'L_tmp' in 1 clock */ move32(); /* exp_code: -18 (code in Q9), -6 (/L_SUBFR), -31 (L_tmp Q31->Q0) */ /* output gain_inov*/ @@ -2599,12 +2599,15 @@ void gain_enc_lbr_ivas_fx( /* gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.5f * (float)log10(Ecode)); gcode0 = (float)pow(10, dotp(b, aux, n_pred) - 0.05f * 10 * (float)log10(Ecode)); gcode0 = (float)pow(10, 0.05(20 * dotp(b, aux, n_pred) - 10 * (float)log10(Ecode))); */ - - exp_code = sub( exp_code, 18 + 6 + 1 ); + // Ecode = (Ecode / L_subfr) + L_tmp = L_shr( L_tmp, L_subfr_sf ); // Q19 + (Q30-exp_code) + /* Calculation for log10(Ecode) exponent for applying log10 = Q31 - q = Q31 - Q19 - Q30 + exp_code = exp_code - Q18*/ + L_tmp = BASOP_Util_Log10( L_tmp, sub( exp_code, 18 ) ); // new q = Q25 exp = norm_l( L_tmp ); - frac = Log2_norm_lc( L_shl( L_tmp, exp ) ); - exp = sub( exp_code, exp ); - L_tmp1 = Mpy_32_16( exp, frac, 24660 ); /* Q14 */ /* 10*log10(2) in Q13*/ + L_tmp = L_shl( L_tmp, exp ); // Q25 + exp + // 10 in Q27 , ( 10 * log10( Ecode ) ) + L_tmp1 = Mpy_32_32( L_tmp, 1342177280 ); // Q25 + exp + 1 + Q27 - 32 = Q21 + exp + L_tmp1 = L_shr( L_tmp1, add( 7, exp ) ); // Q21 + exp - 7 - exp = Q14 L_tmp = Dot_product( b, aux, n_pred ); /*Q25*/ L_tmp = Mult_32_16( L_tmp, 320 ); /*Q14, 20 in Q4*/ -- GitLab From 8e52b02399b8d598483dcf01252807f44e82bd99 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 16:51:37 +0200 Subject: [PATCH 225/394] cleanup --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index c2ec4dc83..c817bd1b3 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -137,8 +137,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro Word16 op1 = add( normXY, normCC ); - // assert( op1 >= 0 ); /*FAILED*/ - // assert( op1 <= 0 ); /*FAILED*/ + /*Both shift directiosn possible*/ if ( op1 >= 0 ) { cc = shl_sat( cc, op1 ); -- GitLab From bbc0239477818535ded11a5abed0b446b35e7753 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 24 Jun 2025 17:56:30 +0200 Subject: [PATCH 226/394] Remove old unused code (no change), the purpose is to retrigger the pipeline because the reports are empty. --- lib_dec/ivas_mdct_core_dec_fx.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index f119a8c1f..7f17bb0fc 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1320,23 +1320,6 @@ void ivas_mdct_core_reconstruct_fx( // norm(old_out) + q_win >= st->Q_syn sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) ); st->Q_syn = add( sf, s_min( q_win, q_winFB ) ); -#if 0 - Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDACFB ) ); // q_winFB -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_syn_Overl_TDACFB = sub( -1, st->Q_syn ); - move16(); - Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_syn_Overl_TDAC ) ); // q_win -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_syn_Overl_TDAC = sub( -1, st->Q_syn ); - move16(); - Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( sub( -1, st->Q_syn ), st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) - st->hTcxDec->Q_old_syn_Overl = sub( -1, st->Q_syn ); - Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_OverlFB ) ); // q_winFB -> st->Q_syn - st->hTcxDec->Q_syn_OverlFB = st->Q_syn; - Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, st->hTcxDec->Q_syn_Overl ) ); // q_win -> st->Q_syn - st->hTcxDec->Q_syn_Overl = st->Q_syn; -#else - // Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( -2, st->hTcxDec->Q_old_syn_Overl ) ); // q_win -> Q(-1 - st->Q_syn) - // st->hTcxDec->Q_old_syn_Overl = -2; -#endif Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn -- GitLab From dc36cb5ba921e36be19089ce8e890a80a7b6f0e7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 10:50:15 +0530 Subject: [PATCH 227/394] Cleanup macros in options.h Cleared up below macros: FIX_1378_ACELP_OUT_OF_BOUNDS , FIX_1379_MASA_ANGLE_ROUND , OPT_BIN_RENDERER_V1 , OPT_BIN_RENDERER_V2 , OPT_STEREO_32KBPS_V1 , OPT_AVOID_STATE_BUF_RESCALE , FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx , FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot , IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE , HARM_PUSH_BIT , HARM_ENC_INIT , DIV32_OPT_NEWTON , IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE , MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE , MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE , FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat , FIX_1439_SPEEDUP_stereo_icBWE_dec_fx , FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx , FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic , FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , FIX_1481_HARDCODE_DIV , VEC_ARITH_OPT_v1 , FIX_1486_IND_SHB_RES , FIX_1511_POC_RENORM , TEST_HR , REMOVE_EVS_DUPLICATES , FIX_1713_EXP , FIX_1733_CLDFB_BUG --- lib_com/basop_util.c | 2 - lib_com/basop_util.h | 2 - lib_com/bitstream_fx.c | 334 --------- lib_com/cldfb_fx.c | 59 -- lib_com/cnst.h | 8 - lib_com/fft_fx.c | 383 ---------- lib_com/hp50_fx.c | 20 - lib_com/ivas_prot_fx.h | 2 - lib_com/ivas_rom_com_fx.c | 14 - lib_com/ivas_spar_com_fx.c | 2 - lib_com/modif_fs_fx.c | 102 --- lib_com/mslvq_com_fx.c | 44 -- lib_com/options.h | 31 +- lib_com/prot_fx.h | 21 - lib_com/scale_mem_fx.c | 4 - lib_com/swb_tbe_com_fx.c | 250 ------- lib_com/tools.c | 2 - lib_com/tools_fx.c | 12 - lib_com/trans_inv_fx.c | 30 - lib_dec/acelp_core_dec_fx.c | 61 +- lib_dec/acelp_core_switch_dec_fx.c | 15 - lib_dec/core_switching_dec_fx.c | 8 - lib_dec/dec_acelp_fx.c | 12 - lib_dec/fd_cng_dec_fx.c | 4 - lib_dec/ivas_binRenderer_internal_fx.c | 139 ---- lib_dec/ivas_dirac_dec_fx.c | 60 -- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 51 +- lib_dec/ivas_ism_param_dec_fx.c | 4 - lib_dec/ivas_jbm_dec_fx.c | 4 - lib_dec/ivas_mc_param_dec_fx.c | 20 - lib_dec/ivas_mc_paramupmix_dec_fx.c | 33 - lib_dec/ivas_sba_rendering_internal_fx.c | 18 - lib_dec/ivas_spar_decoder_fx.c | 12 - lib_dec/ivas_stereo_cng_dec_fx.c | 17 - lib_dec/ivas_stereo_dft_dec_fx.c | 176 ----- lib_dec/ivas_stereo_icbwe_dec_fx.c | 9 - lib_dec/ivas_stereo_switching_dec_fx.c | 89 --- lib_dec/ivas_stereo_td_dec_fx.c | 21 - lib_dec/swb_tbe_dec_fx.c | 15 - lib_enc/acelp_core_switch_enc_fx.c | 17 - lib_enc/cng_enc_fx.c | 5 - lib_enc/dtx_fx.c | 4 - lib_enc/enc_gen_voic_fx.c | 17 - lib_enc/enc_ppp_fx.c | 8 - lib_enc/enc_tran_fx.c | 24 - lib_enc/eval_pit_contr_fx.c | 21 - lib_enc/igf_enc.c | 59 -- lib_enc/igf_enc_fx.c | 27 - lib_enc/init_enc_fx.c | 4 - lib_enc/ivas_init_enc_fx.c | 664 ------------------ lib_enc/ivas_mc_param_enc_fx.c | 248 ------- lib_enc/ivas_qmetadata_enc_fx.c | 16 - lib_enc/ivas_sce_enc_fx.c | 6 - lib_enc/ivas_sns_enc_fx.c | 4 - lib_enc/ivas_stereo_dmx_evs_fx.c | 18 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 8 - lib_enc/lib_enc_fx.c | 414 ----------- lib_enc/speech_music_classif_fx.c | 4 - lib_enc/stat_enc.h | 4 - lib_enc/swb_pre_proc_fx.c | 4 - lib_enc/swb_tbe_enc_fx.c | 34 - lib_enc/tcx_utils_enc_fx.c | 20 - lib_enc/transition_enc_fx.c | 4 - lib_rend/ivas_dirac_ana_fx.c | 4 - .../ivas_dirac_dec_binaural_functions_fx.c | 171 ----- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 165 ----- lib_rend/ivas_dirac_rend_fx.c | 12 - lib_rend/ivas_efap_fx.c | 21 - lib_rend/ivas_omasa_ana_fx.c | 5 - lib_rend/ivas_reverb_fx.c | 41 -- lib_rend/ivas_sba_rendering_fx.c | 58 -- lib_rend/lib_rend_fx.c | 8 - 72 files changed, 5 insertions(+), 4204 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 3d6324783..7903d3580 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1062,7 +1062,6 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s ) return z; } -#ifdef DIV32_OPT_NEWTON Word32 div_w_newton( Word32 num, Word32 den ); /* Table of 256 precalculated estimates to be used by the "div_w_newton" @@ -1462,7 +1461,6 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) return z; } -#endif /* DIV32_OPT_NEWTON */ Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s ) { diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index b1d4b5fc1..b5c69e1dd 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -333,11 +333,9 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ -#ifdef DIV32_OPT_NEWTON Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, /*!< i : Numerator*/ Word32 y, /*!< i : Denominator*/ Word16 *s ); /*!< o : Additional scalefactor difference*/ -#endif /************************************************************************/ diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 2b66f92cd..02b0a8fa1 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -242,130 +242,6 @@ Word16 rate2EVSmode( * * Push a new indice into the buffer *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void push_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - Word16 id, /* i : ID of the indice */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -) -{ - Word16 i; - - - IF( EQ_16( hBstr->last_ind_fx, id ) ) - { - /* indice with the same name as the previous one */ - i = hBstr->next_ind_fx; - move16(); - } - ELSE - { - /* new indice - find an empty slot in the list */ - i = id; - move16(); - WHILE( hBstr->ind_list[i].nb_bits != -1 ) - { - i = add( i, 1 ); - } - } - - /* store the values in the list */ - hBstr->ind_list[i].value = value; - move16(); - hBstr->ind_list[i].nb_bits = nb_bits; - move16(); - - /* updates */ - hBstr->next_ind_fx = add( i, 1 ); - move16(); - hBstr->last_ind_fx = id; - move16(); - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); - - return; -} -/*-------------------------------------------------------------------* - * push_next_indice() * - * Push a new indice into the buffer at the next position - *-------------------------------------------------------------------*/ - -void push_next_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ -) -{ - - /* store the values in the list */ - hBstr->ind_list[hBstr->next_ind_fx].value = value; - move16(); - hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits; - move16(); - hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 ); - move16(); - - /* update the total number of bits already written */ - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); - - return; -} - - -/*-------------------------------------------------------------------* - * push_next_bits() - * Push a bit buffer into the buffer at the next position - *-------------------------------------------------------------------*/ - -void push_next_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - Word16 bits[], /* i : bit buffer to pack, sequence of single bits */ - Word16 nb_bits /* i : number of bits to pack */ -) -{ - UWord16 code; - Word16 i, nb_bits_m15; - Indice *ptr; - - ptr = &hBstr->ind_list[hBstr->next_ind_fx]; - nb_bits_m15 = sub( nb_bits, 15 ); - i = 0; - move16(); - IF( nb_bits_m15 > 0 ) - { - FOR( ; i < nb_bits_m15; i += 16 ) - { - code = s_or( lshl( bits[i], 15 ), s_or( lshl( bits[i + 1], 14 ), s_or( lshl( bits[i + 2], 13 ), s_or( lshl( bits[i + 3], 12 ), - s_or( lshl( bits[i + 4], 11 ), s_or( lshl( bits[i + 5], 10 ), s_or( lshl( bits[i + 6], 9 ), s_or( lshl( bits[i + 7], 8 ), - s_or( lshl( bits[i + 8], 7 ), s_or( lshl( bits[i + 9], 6 ), s_or( lshl( bits[i + 10], 5 ), s_or( lshl( bits[i + 11], 4 ), - s_or( lshl( bits[i + 12], 3 ), s_or( lshl( bits[i + 13], 2 ), s_or( lshl( bits[i + 14], 1 ), bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) ); - - ptr->value = code; - move16(); - ptr->nb_bits = 16; - move16(); - ++ptr; - } - } - IF( LT_16( i, nb_bits ) ) - { - FOR( ; i < nb_bits; ++i ) - { - ptr->value = bits[i]; - move16(); - ptr->nb_bits = 1; - move16(); - ++ptr; - } - } - hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list ); - move16(); - hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits ); - move16(); -} -#endif /*-------------------------------------------------------------------* * get_next_indice_fx( ) @@ -528,12 +404,6 @@ void reset_indices_enc_fx( move16(); hBstr->nb_bits_tot = 0; move16(); -#ifndef HARM_PUSH_BIT - hBstr->next_ind_fx = 0; - move16(); - hBstr->last_ind_fx = -1; - move16(); -#endif FOR( i = 0; i < max_num_indices; i++ ) { hBstr->ind_list[i].nb_bits = -1; @@ -564,215 +434,11 @@ void reset_indices_dec_fx( * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void write_indices_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - FILE *file /* i : output bitstream file */ - , - UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ - Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */ -) -{ - Word16 i, k; - Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream; - Word32 mask; - UWord8 header; - Word16 isAmrWb = 0; - move16(); - - IF( st_fx->bitstreamformat == G192 ) - { - /*-----------------------------------------------------------------* - * Encode Sync Header and Frame Length - *-----------------------------------------------------------------*/ - pt_stream = stream; - FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) - { - stream[i] = 0; - move16(); - } - *pt_stream++ = SYNC_GOOD_FRAME; - move16(); - *pt_stream++ = hBstr->nb_bits_tot; - move16(); - - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - * Writing the serial stream into file - *----------------------------------------------------------------*/ - - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) - { - /* mask from MSB to LSB */ - mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) ); - - /* write bit by bit */ - FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) - { - IF( L_and( hBstr->ind_list[i].value, mask ) ) - { - *pt_stream++ = G192_BIN1; - move16(); - } - ELSE - { - *pt_stream++ = G192_BIN0; - move16(); - } - - mask = L_shr( mask, 1 ); - } - } - } - } - ELSE - { - /* Create and write ToC header */ - /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ - header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) ); - move16(); - fwrite( &header, sizeof( UWord8 ), 1, file ); - /* Write speech bits */ - fwrite( pFrame, sizeof( UWord8 ), shr( add( pFrame_size, 7 ), 3 ), file ); - } - - /* Clearing of indices */ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - - IF( st_fx->bitstreamformat == G192 ) - { - /* write the serial stream into file */ - fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file ); - } - /* reset index pointers */ - hBstr->nb_bits_tot = 0; - move16(); - hBstr->next_ind_fx = 0; - move16(); - hBstr->last_ind_fx = -1; - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * write_indices_buf_fx() * * Write the buffer of indices to a file *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT -void write_indices_buf_fx( - Encoder_State *st_fx, /* i/o: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord16 *out_buf, /* i : output bitstream buf */ - UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */ - Word16 pFrame_size, /* i: size of the binary encoded access unit [bits] */ - UWord16 *num_bits ) -{ - Word16 i, k; - Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream; - Word32 mask; - UWord8 header; - Word16 isAmrWb = 0; - - IF( st_fx->bitstreamformat == G192 ) - { - /*-----------------------------------------------------------------* - * Encode Sync Header and Frame Length - *-----------------------------------------------------------------*/ - pt_stream = stream; - FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i ) - { - stream[i] = 0; - move16(); - } - //*pt_stream++ = (Word16) SYNC_GOOD_FRAME; - //*pt_stream++ = hBstr->nb_bits_tot; - *num_bits = hBstr->nb_bits_tot; - move16(); - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - * Writing the serial stream into file - *----------------------------------------------------------------*/ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) ) - { - /* mask from MSB to LSB */ - mask = L_shl( 1, ( sub( hBstr->ind_list[i].nb_bits, 1 ) ) ); - - /* write bit by bit */ - FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) - { - IF( L_and( hBstr->ind_list[i].value, mask ) ) - { - //*pt_stream++ = G192_BIN1; - *pt_stream++ = 1; - move16(); - } - ELSE - { - //*pt_stream++ = G192_BIN0; - *pt_stream++ = 0; - move16(); - } - - mask = L_shr( mask, 1 ); - } - } - } - } - ELSE - { - /* Create and write ToC header */ - /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */ - header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( i_mult( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) ); - // fwrite(&header, sizeof(UWord8), 1, file); - memcpy( out_buf, &header, sizeof( UWord8 ) ); - *num_bits += sizeof( UWord8 ); - /* Write speech bits */ - // fwrite(pFrame, sizeof(UWord8), (pFrame_size + 7) >> 3, file); - memcpy( out_buf, pFrame, sizeof( UWord8 ) * ( shr( add( pFrame_size, 7 ), 3 ) ) ); - *num_bits += sizeof( UWord8 ) * ( shr( ( add( pFrame_size, 7 ) ), 3 ) ); - } - - /* Clearing of indices */ - FOR( i = 0; i < MAX_NUM_INDICES; i++ ) - { - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - - - IF( st_fx->bitstreamformat == G192 ) - { - /* write the serial stream into file */ - // fwrite(stream, sizeof(unsigned short), 2 + stream[1], file); - // FILE *ftemp = fopen( "./output/bitstreams/out.COD", "ab" ); - // fwrite( stream, sizeof( unsigned short ), 2 + stream[1], ftemp ); - // fclose( ftemp ); - memcpy( out_buf, stream, sizeof( unsigned short ) * ( *num_bits ) ); - //*num_bits += sizeof( unsigned short ) * ( 2 + stream[1] ); - } - /* reset index pointers */ - hBstr->nb_bits_tot = 0; - hBstr->next_ind_fx = 0; - hBstr->last_ind_fx = -1; - move16(); - move16(); - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * indices_to_serial() * diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 6c29d2a57..edddcb272 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -508,13 +508,8 @@ void cldfbAnalysis_ts_fx( rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -522,13 +517,8 @@ void cldfbAnalysis_ts_fx( ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -595,13 +585,8 @@ void cldfbAnalysis_ts_fx( rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - rBuffer_fx[2 * k] = L_sub( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - rBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ri12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); @@ -609,13 +594,8 @@ void cldfbAnalysis_ts_fx( ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - iBuffer_fx[2 * k] = L_sub( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_im_fx[k] ) ); // q - 3 - iBuffer_fx[2 * k + 1] = L_add( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), Mpy_32_32( ii12_fx, rot_vctr_re_fx[k] ) ); // q - 3 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -640,22 +620,6 @@ void cldfbAnalysis_ts_fx( } fft_cldfb_fx( rBuffer_fx, M2 ); -#ifndef FIX_1733_CLDFB_BUG - /* post modulation of DST IV */ - FOR( k = 0; k < M2; k++ ) - { - /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 - realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - move32(); - move32(); - } -#endif *q_cldfb = sub( *q_cldfb, 2 ); move16(); @@ -676,35 +640,23 @@ void cldfbAnalysis_ts_fx( move32(); } -#ifdef FIX_1733_CLDFB_BUG /* post modulation of DST IV */ FOR( k = 0; k < M2; k++ ) { /*cplxMult(&realBuffer[M1-1-(2*k)],&realBuffer[2*k],rBuffer[2*k],rBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = Msub_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 realBuffer_fx[2 * k] = Madd_32_32( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - realBuffer_fx[( ( M1 - 1 ) - ( k * 2 ) )] = L_sub( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - realBuffer_fx[2 * k] = L_add( Mpy_32_32( rBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( rBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } -#endif /* post modulation of DCT IV */ FOR( k = 0; k < M2; k++ ) { /* do it inplace */ /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE imagBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ); // q - 5 imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - imagBuffer_fx[2 * k] = L_sub( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ) ); // q - 5 - imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_add( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), Mpy_32_32( iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ move32(); move32(); } @@ -725,13 +677,8 @@ void cldfbAnalysis_ts_fx( /*cplxMult(&realBuffer[k], &imagBuffer[k], realBuffer[k], imagBuffer[k], rot_vctr_delay_re[k], rot_vctr_delay_im[k]);*/ /*realBuffer[k] = rBuffer[k]; imagBuffer[k] = iBuffer[k];*/ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cplx_aux_fx = Msub_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ); // q - 5 imagBuffer_fx[k] = Madd_32_32( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ); // q - 5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cplx_aux_fx = L_sub( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_re_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_im_fx[k] ) ); // q - 5 - imagBuffer_fx[k] = L_add( Mpy_32_32( realBuffer_fx[k], rot_vctr_delay_im_fx[k] ), Mpy_32_32( imagBuffer_fx[k], rot_vctr_delay_re_fx[k] ) ); // q - 5 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ realBuffer_fx[k] = cplx_aux_fx; move32(); move32(); @@ -1436,9 +1383,7 @@ void cldfbSynthesis_ivas_fx( Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ const Word16 samplesToProcess, /* i : number of processed samples */ const Word16 shift, /* i : scale for state buffer */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE const Word16 out_shift, /* i : scale for output buffer */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ) { @@ -1675,16 +1620,13 @@ void cldfbSynthesis_ivas_fx( } } -#ifdef OPT_AVOID_STATE_BUF_RESCALE IF( 0 == out_shift ) { -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( i = 0; i < M1; i++ ) { ptr_time_out_fx[( M1 - 1 ) - i] = synthesisBuffer_fx[4 * L2 + M1 + i]; move32(); } -#ifdef OPT_AVOID_STATE_BUF_RESCALE } ELSE { @@ -1694,7 +1636,6 @@ void cldfbSynthesis_ivas_fx( move32(); } } -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ ptr_time_out_fx += M1; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 17dbc31c4..6030b53bd 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -534,15 +534,7 @@ enum IND_STEREO_ICBWE_MSFLAG, IND_SHB_ENER_SF, IND_SHB_RES_GS, -#ifndef FIX_1486_IND_SHB_RES - IND_SHB_RES_GS1, - IND_SHB_RES_GS2, - IND_SHB_RES_GS3, - IND_SHB_RES_GS4, - IND_SHB_VF, -#else IND_SHB_VF = IND_SHB_RES_GS + 5, -#endif IND_SHB_LSF, IND_SHB_MIRROR = IND_SHB_LSF + 5, IND_SHB_GRID, diff --git a/lib_com/fft_fx.c b/lib_com/fft_fx.c index 40c978014..b1323e156 100644 --- a/lib_com/fft_fx.c +++ b/lib_com/fft_fx.c @@ -4725,7 +4725,6 @@ static void fft_len16( cmplx t[4]; cmplx y[16]; -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[0]; // Qx move64(); s[1] = x[4]; // Qx @@ -4734,16 +4733,6 @@ static void fft_len16( move64(); s[3] = x[12]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[0], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[4], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[8], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[12], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4763,7 +4752,6 @@ static void fft_len16( y[3] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[1]; // Qx move64(); s[1] = x[5]; // Qx @@ -4772,16 +4760,6 @@ static void fft_len16( move64(); s[3] = x[13]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[1], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[5], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[9], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[13], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4801,7 +4779,6 @@ static void fft_len16( y[7] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[2]; // Qx move64(); s[1] = x[6]; // Qx @@ -4810,16 +4787,6 @@ static void fft_len16( move64(); s[3] = x[14]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[2], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[6], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[10], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[14], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -4841,7 +4808,6 @@ static void fft_len16( y[11] = CL_add( t[1], t[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 s[0] = x[3]; // Qx move64(); s[1] = x[7]; // Qx @@ -4850,16 +4816,6 @@ static void fft_len16( move64(); s[3] = x[15]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - s[0] = CL_shr( x[3], SCALEFACTOR16 ); // Qx - move64(); - s[1] = CL_shr( x[7], SCALEFACTOR16 ); // Qx - move64(); - s[2] = CL_shr( x[11], SCALEFACTOR16 ); // Qx - move64(); - s[3] = CL_shr( x[15], SCALEFACTOR16 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ t[0] = CL_add( s[0], s[2] ); move64(); @@ -5020,7 +4976,6 @@ static void fft_len20_fx( cmplx tt[4]; cmplx y[20]; -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[0]; // Qx move64(); xx[1] = x[16]; // Qx @@ -5031,18 +4986,6 @@ static void fft_len20_fx( move64(); xx[4] = x[4]; // Qx move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[0], SCALEFACTOR20 ); // Qx - move64(); - xx[1] = CL_shr( x[16], SCALEFACTOR20 ); // Qx - move64(); - xx[2] = CL_shr( x[12], SCALEFACTOR20 ); // Qx - move64(); - xx[3] = CL_shr( x[8], SCALEFACTOR20 ); // Qx - move64(); - xx[4] = CL_shr( x[4], SCALEFACTOR20 ); // Qx - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5078,7 +5021,6 @@ static void fft_len20_fx( y[12] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[5]; move64(); xx[1] = x[1]; @@ -5089,18 +5031,6 @@ static void fft_len20_fx( move64(); xx[4] = x[9]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[5], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[1], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[17], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[13], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[9], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5136,7 +5066,6 @@ static void fft_len20_fx( y[13] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[10]; move64(); xx[1] = x[6]; @@ -5147,18 +5076,6 @@ static void fft_len20_fx( move64(); xx[4] = x[14]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[10], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[6], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[2], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[18], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[14], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -5194,7 +5111,6 @@ static void fft_len20_fx( y[14] = CL_msu_j( s[2], s[3] ); move64(); -#ifdef OPT_STEREO_32KBPS_V1 xx[0] = x[15]; move64(); xx[1] = x[11]; @@ -5205,18 +5121,6 @@ static void fft_len20_fx( move64(); xx[4] = x[19]; move64(); -#else /* OPT_STEREO_32KBPS_V1 */ - xx[0] = CL_shr( x[15], SCALEFACTOR20 ); - move64(); - xx[1] = CL_shr( x[11], SCALEFACTOR20 ); - move64(); - xx[2] = CL_shr( x[7], SCALEFACTOR20 ); - move64(); - xx[3] = CL_shr( x[3], SCALEFACTOR20 ); - move64(); - xx[4] = CL_shr( x[19], SCALEFACTOR20 ); - move64(); -#endif /* OPT_STEREO_32KBPS_V1 */ s[0] = CL_add( xx[1], xx[4] ); move64(); @@ -6595,7 +6499,6 @@ static void fft_lenN( cmplx s[8]; cmplx y[8]; -#ifdef OPT_STEREO_32KBPS_V1 y[1] = xx[1 * dim1]; move64(); y[2] = xx[2 * dim1]; @@ -6827,288 +6730,6 @@ static void fft_lenN( move64(); } } -#else /* OPT_STEREO_32KBPS_V1 */ - test(); - test(); - test(); - test(); - IF( EQ_16( dim1, 30 ) || EQ_16( dim1, 20 ) || EQ_16( dim1, 15 ) || EQ_16( dim1, 10 ) || EQ_16( dim1, 5 ) ) - { - FOR( i = 0; i < dim1; i++ ) - { - { - y[0] = xx[i]; // y[0] = xx[i + 0 * dim1] - move64(); - }; - IF( i == 0 ) - { - { - y[1] = xx[( i + ( 1 * dim1 ) )]; - move64(); - }; - { - y[2] = xx[( i + ( 2 * dim1 ) )]; - move64(); - }; - { - y[3] = xx[( i + ( 3 * dim1 ) )]; - move64(); - }; - { - y[4] = xx[( i + ( 4 * dim1 ) )]; - move64(); - }; - { - y[5] = xx[( i + ( 5 * dim1 ) )]; - move64(); - }; - { - y[6] = xx[( i + ( 6 * dim1 ) )]; - move64(); - }; - { - y[7] = xx[( i + ( 7 * dim1 ) )]; - move64(); - }; - } - ELSE - { - { - y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 1 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 2 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 3 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 4 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 5 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 6 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( ( sc * 7 ) * dim1 ) << 1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - } - - t[0] = CL_add( y[0], y[4] ); - move64(); - t[1] = CL_sub( y[0], y[4] ); - move64(); - t[2] = CL_add( y[1], y[5] ); - move64(); - t[3] = CL_sub( y[1], y[5] ); - move64(); - t[4] = CL_add( y[2], y[6] ); - move64(); - t[5] = CL_sub( y[2], y[6] ); - move64(); - t[6] = CL_add( y[3], y[7] ); - move64(); - t[7] = CL_sub( y[3], y[7] ); - move64(); - - s[0] = CL_add( t[0], t[4] ); - move64(); - s[2] = CL_sub( t[0], t[4] ); - move64(); - s[4] = CL_mac_j( t[1], t[5] ); - move64(); - s[5] = CL_msu_j( t[1], t[5] ); - move64(); - s[1] = CL_add( t[2], t[6] ); - move64(); - s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); - move64(); - - t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); - move64(); - t[1] = CL_sub( t[3], t[7] ); - move64(); - - s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx - move64(); - s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx - move64(); - s[7] = CL_conjugate( s[7] ); - move64(); - - x[i] = CL_add( s[0], s[1] ); /*x[add(i + i_mult(0 , dim1)] = CL_add( s[0], s[1] )*/ - move64(); - x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); - move64(); - x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); - move64(); - x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); - move64(); - x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); - move64(); - x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); - move64(); - x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); - move64(); - x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); - move64(); - } - } - ELSE - { - FOR( i = 0; i < dim1; i++ ) - { - { - y[0] = xx[i]; /* y[0] = xx[i + 0 * dim1] */ - move64(); - }; - IF( i == 0 ) - { - { - y[1] = xx[( i + ( 1 * dim1 ) )]; - move64(); - }; - { - y[2] = xx[( i + ( 2 * dim1 ) )]; - move64(); - }; - { - y[3] = xx[( i + ( 3 * dim1 ) )]; - move64(); - }; - { - y[4] = xx[( i + ( 4 * dim1 ) )]; - move64(); - }; - { - y[5] = xx[( i + ( 5 * dim1 ) )]; - move64(); - }; - { - y[6] = xx[( i + ( 6 * dim1 ) )]; - move64(); - }; - { - y[7] = xx[( i + ( 7 * dim1 ) )]; - move64(); - }; - } - ELSE - { - { - y[1] = CL_mac_j( CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 1 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 1 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[2] = CL_mac_j( CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 2 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 2 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[3] = CL_mac_j( CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 3 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 3 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[4] = CL_mac_j( CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 4 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 4 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[5] = CL_mac_j( CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 5 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 5 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[6] = CL_mac_j( CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 6 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 6 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - { - y[7] = CL_mac_j( CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) - Woff )] ), - CL_scale( xx[( i + ( 7 * dim1 ) )], W[( ( ( ( sc * i ) + ( ( sc * 7 ) * dim1 ) ) + 1 ) - Woff )] ) ); // Qx - move64(); - }; - } - - t[0] = CL_add( y[0], y[4] ); - move64(); - t[1] = CL_sub( y[0], y[4] ); - move64(); - t[2] = CL_add( y[1], y[5] ); - move64(); - t[3] = CL_sub( y[1], y[5] ); - move64(); - t[4] = CL_add( y[2], y[6] ); - move64(); - t[5] = CL_sub( y[2], y[6] ); - move64(); - t[6] = CL_add( y[3], y[7] ); - move64(); - t[7] = CL_sub( y[3], y[7] ); - move64(); - - s[0] = CL_add( t[0], t[4] ); - move64(); - s[2] = CL_sub( t[0], t[4] ); - move64(); - s[4] = CL_mac_j( t[1], t[5] ); - move64(); - s[5] = CL_msu_j( t[1], t[5] ); - move64(); - s[1] = CL_add( t[2], t[6] ); - move64(); - s[3] = CL_swap_real_imag( CL_sub( CL_conjugate( t[2] ), CL_conjugate( t[6] ) ) ); - move64(); - - t[0] = CL_swap_real_imag( CL_add( t[3], t[7] ) ); - move64(); - t[1] = CL_sub( t[3], t[7] ); - move64(); - - s[6] = CL_scale( CL_add( CL_conjugate( t[0] ), t[1] ), FFT_C81 ); // Qx - move64(); - s[7] = CL_scale( CL_sub( t[0], CL_conjugate( t[1] ) ), FFT_C81 ); // Qx - move64(); - s[7] = CL_conjugate( s[7] ); - move64(); - - x[i] = CL_add( s[0], s[1] ); /*x[i + 0 * dim1] = CL_add( s[0], s[1] )*/ - move64(); - x[( i + ( 1 * dim1 ) )] = CL_add( s[5], s[6] ); - move64(); - x[( i + ( 2 * dim1 ) )] = CL_sub( s[2], s[3] ); - move64(); - x[( i + ( 3 * dim1 ) )] = CL_add( s[4], s[7] ); - move64(); - x[( i + ( 4 * dim1 ) )] = CL_sub( s[0], s[1] ); - move64(); - x[( i + ( 5 * dim1 ) )] = CL_sub( s[5], s[6] ); - move64(); - x[( i + ( 6 * dim1 ) )] = CL_add( s[2], s[3] ); - move64(); - x[( i + ( 7 * dim1 ) )] = CL_sub( s[4], s[7] ); - move64(); - } - } -#endif /* OPT_STEREO_32KBPS_V1 */ BREAK; } @@ -7501,11 +7122,7 @@ void rfft_fx( move32(); x[( length - ( i << 1 ) )] = Mpy_32_16_1( L_add( t1, t3 ), 16384 /*0.5.Q15*/ ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_add( t2, t4 ), -16384 /*0.5.Q15*/ ); -#else /* OPT_STEREO_32KBPS_V1 */ - x[( ( length - ( i << 1 ) ) + 1 )] = Mpy_32_16_1( L_negate( L_add( t2, t4 ) ), 16384 /*0.5.Q15*/ ); -#endif /* OPT_STEREO_32KBPS_V1 */ move32(); } diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index f1864d7a7..4a055e073 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -532,11 +532,7 @@ void hp20_fx_32( move16(); } Qy1 = sub( Qy1, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R1 = W_mult0_32_32( W_shl_sat_l( y1_fx64, Qy1 ), a1_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R1 = W_mult0_32_32( W_extract_l( W_shl( y1_fx64, Qy1 ) ), a1_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qy1 = add( Qy1, Qprev_y1 ); Qy2 = W_norm( y2_fx64 ); @@ -546,11 +542,7 @@ void hp20_fx_32( move16(); } Qy2 = sub( Qy2, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R2 = W_mult0_32_32( W_shl_sat_l( y2_fx64, Qy2 ), a2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R2 = W_mult0_32_32( W_extract_l( W_shl( y2_fx64, Qy2 ) ), a2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qy2 = add( Qy2, Qprev_y2 ); Qx0 = W_norm( x0_fx64 ); @@ -560,11 +552,7 @@ void hp20_fx_32( move16(); } Qx0 = sub( Qx0, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R3 = W_mult0_32_32( W_shl_sat_l( x0_fx64, Qx0 ), b2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R3 = W_mult0_32_32( W_extract_l( W_shl( x0_fx64, Qx0 ) ), b2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qx1 = W_norm( x1_fx64 ); if ( x1_fx64 == 0 ) @@ -573,11 +561,7 @@ void hp20_fx_32( move16(); } Qx1 = sub( Qx1, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R4 = W_mult0_32_32( W_shl_sat_l( x1_fx64, Qx1 ), b1_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R4 = W_mult0_32_32( W_extract_l( W_shl( x1_fx64, Qx1 ) ), b1_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qx2 = W_norm( x2_fx64 ); if ( x2_fx64 == 0 ) @@ -586,11 +570,7 @@ void hp20_fx_32( move16(); } Qx2 = sub( Qx2, 34 ); -#ifdef OPT_STEREO_32KBPS_V1 R5 = W_mult0_32_32( W_shl_sat_l( x2_fx64, Qx2 ), b2_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - R5 = W_mult0_32_32( W_extract_l( W_shl( x2_fx64, Qx2 ) ), b2_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ Qmin = s_min( Qy1, Qy2 ); diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 71d090a53..e35cf648c 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4973,14 +4973,12 @@ void ivas_dirac_dec_get_response_fx( const Word16 ambisonics_order, Word16 Q_out ); -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/ void ivas_dirac_dec_get_response_fx_29( const Word16 azimuth, const Word16 elevation, Word32 *response_fx, /*Q_out=29*/ const Word16 ambisonics_order ); -#endif void calculate_hodirac_sector_parameters_fx( DIRAC_ENC_HANDLE hDirAC, /* i : DirAC handle */ diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index e7ee30e8d..6bb2eaa10 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -1545,19 +1545,6 @@ const Word16 ivas_param_mc_quant_icc_fx[PARAM_MC_SZ_ICC_QUANTIZER] = { /* from 1 to 11 bits*/ /*q factor = 8*/ const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = { -#ifndef FIX_1379_MASA_ANGLE_ROUND - { 1073741824 }, - { 536870912 }, - { 536870912, 1073741824 }, - { 268435456, 536870912 }, - { 178956970, 306783378, 1073741824, 2147483647 }, - { 153391689, 165191049, 238609294, 1073741824, 2147483647 }, - { 97612893, 102261126, 126322567, 195225786, 715827882, 2147483647 }, - { 65075262, 67108864, 74051160, 93368854, 126322567, 238609294, 2147483647 }, - { 44739242, 45691141, 47721858, 52377649, 61356675, 76695844, 107374182, 178956970, 1073741824, 2147483647 }, - { 35791394, 35791394, 37025580, 38347922, 39768215, 42949672, 46684427, 52377649, 59652323, 71582788, 93368854, 126322567, 214748364, 2147483647 }, - { 24129029, 24129029, 24403223, 24970740, 25565281, 26512143, 27889398, 29417584, 31580641, 34087042, 37675151, 42107522, 48806446, 56512727, 71582788, 93368854, 143165576, 268435456, 2147483647 } -#else { 1073741824 }, { 536870912 }, { 536870912, 1073741824 }, @@ -1569,7 +1556,6 @@ const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA] = { { 44739243, 45691141, 47721859, 52377650, 61356676, 76695845, 107374182, 178956971, 1073741824, 2147483647 }, { 35791394, 35791394, 37025580, 38347922, 39768216, 42949673, 46684427, 52377650, 59652324, 71582788, 93368854, 126322568, 214748365, 2147483647 }, { 24129030, 24129030, 24403223, 24970740, 25565282, 26512144, 27889398, 29417584, 31580642, 34087042, 37675152, 42107523, 48806447, 56512728, 71582788, 93368854, 143165577, 268435456, 2147483647 }, -#endif }; diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 15a529149..3805c9d36 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -7287,7 +7287,6 @@ void ivas_dirac_dec_get_response_fx( return; } -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*This is a derivate to ivas_dirac_dec_get_response_fx with fixed Q_out=29*/ void ivas_dirac_dec_get_response_fx_29( const Word16 azimuth, @@ -7413,7 +7412,6 @@ void ivas_dirac_dec_get_response_fx_29( } return; } -#endif /*FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx*/ /*-----------------------------------------------------------------------------------------* * Function ivas_get_bits_to_encode * diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 2e39af523..a9b6581ed 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -1059,7 +1059,6 @@ void Decimate_allpass_steep_fx32( /* upper allpass filter chain */ FOR( k = 0; k < N / 2; k++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[0], in[2 * k], AP1_STEEP_FX[0] ); // Qx move32(); mem[0] = Msub_32_16( in[2 * k], temp[0], AP1_STEEP_FX[0] ); // Qx @@ -1074,118 +1073,51 @@ void Decimate_allpass_steep_fx32( move32(); mem[ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[0], Mpy_32_16_1( in[2 * k], AP1_STEEP_FX[0] ) ); // Qx - move32(); - mem[0] = L_sub( in[2 * k], Mpy_32_16_1( temp[0], AP1_STEEP_FX[0] ) ); // Qx - move32(); - - temp[1] = L_add( mem[1], Mpy_32_16_1( temp[0], AP1_STEEP_FX[1] ) ); // Qx - move32(); - mem[1] = L_sub( temp[0], Mpy_32_16_1( temp[1], AP1_STEEP_FX[1] ) ); // Qx - move32(); - - out[k] = L_add( mem[ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( out[k], AP1_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* lower allpass filter chain */ -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( mem[2 * ALLPASSSECTIONS_STEEP], temp[0], AP2_STEEP_FX[0] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( mem[2 * ALLPASSSECTIONS_STEEP], AP2_STEEP_FX[0] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP] = L_sub( mem[2 * ALLPASSSECTIONS_STEEP], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP + 1] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx - move32(); - /*if ( fabs( temp[n] ) < 1e-12 ) - { - temp[n] = sign( temp[n] ) * 1e-12f; - }*/ - mem[ALLPASSSECTIONS_STEEP + 1] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - - mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ out[0] = W_round48_L( W_mac_32_16( W_mult_32_16( out[0], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); FOR( k = 1; k < N / 2; k++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[0] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP], in[2 * k - 1], AP2_STEEP_FX[0] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP] = Msub_32_16( in[2 * k - 1], temp[0], AP2_STEEP_FX[0] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[0] = L_add( mem[ALLPASSSECTIONS_STEEP], Mpy_32_16_1( in[sub( shl( k, 1 ), 1 )], AP2_STEEP_FX[0] ) ); // Qx - move32(); - mem[ALLPASSSECTIONS_STEEP] = L_sub( in[sub( shl( k, 1 ), 1 )], Mpy_32_16_1( temp[0], AP2_STEEP_FX[0] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* for better performance, unroll this loop */ FOR( n = 1; n < ALLPASSSECTIONS_STEEP - 1; n++ ) { -#ifdef OPT_STEREO_32KBPS_V1 temp[n] = Madd_32_16( mem[ALLPASSSECTIONS_STEEP + n], temp[n - 1], AP2_STEEP_FX[n] ); // Qx move32(); mem[ALLPASSSECTIONS_STEEP + n] = Msub_32_16( temp[n - 1], temp[n], AP2_STEEP_FX[n] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[n] = L_add( mem[ALLPASSSECTIONS_STEEP + n], Mpy_32_16_1( temp[n - 1], AP2_STEEP_FX[n] ) ); // Qx - move32(); - /*if ( fabs( temp[n] ) < 1e-12 ) - { - temp[n] = sign( temp[n] ) * 1e-12f; - }*/ - mem[ALLPASSSECTIONS_STEEP + n] = L_sub( temp[n - 1], Mpy_32_16_1( temp[n], AP2_STEEP_FX[n] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 temp[ALLPASSSECTIONS_STEEP - 1] = Madd_32_16( mem[2 * ALLPASSSECTIONS_STEEP - 1], temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); mem[2 * ALLPASSSECTIONS_STEEP - 1] = Msub_32_16( temp[ALLPASSSECTIONS_STEEP - 2], temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ); // Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - temp[ALLPASSSECTIONS_STEEP - 1] = L_add( mem[2 * ALLPASSSECTIONS_STEEP - 1], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 2], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); - mem[2 * ALLPASSSECTIONS_STEEP - 1] = L_sub( temp[ALLPASSSECTIONS_STEEP - 2], Mpy_32_16_1( temp[ALLPASSSECTIONS_STEEP - 1], AP2_STEEP_FX[ALLPASSSECTIONS_STEEP - 1] ) ); // Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ out[k] = W_round48_L( W_mac_32_16( W_mult_32_16( out[k], 16384 /*0.5 in Q15*/ ), temp[ALLPASSSECTIONS_STEEP - 1], 16384 /*0.5 in Q15*/ ) ); // Qx move32(); } @@ -1487,21 +1419,12 @@ void interpolate_3_over_2_allpass_fx32( FOR( i = 0; i < len; i++ ) { /* Upper branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vu[0] = Madd_32_16( mem[0], L_sub( input[i], mem[1] ), filt_coeff[0] ); // Qx + Q15 - Q15 -> Qx move32(); Vu[1] = Madd_32_16( mem[1], L_sub( Vu[0], mem[2] ), filt_coeff[1] ); // Qx + Q15 - Q15 -> Qx move32(); mem[3] = Madd_32_16( mem[2], L_sub( Vu[1], mem[3] ), filt_coeff[2] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vu[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[1] ), filt_coeff[0] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vu[1] = L_add( mem[1], Mpy_32_16_1( L_sub( Vu[0], mem[2] ), filt_coeff[1] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[3] = L_add( mem[2], Mpy_32_16_1( L_sub( Vu[1], mem[3] ), filt_coeff[2] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[1] = Vu[0]; // Qx move32(); @@ -1511,21 +1434,12 @@ void interpolate_3_over_2_allpass_fx32( move32(); /* Middle branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vm[0] = Madd_32_16( mem[0], L_sub( input[i], mem[4] ), filt_coeff[3] ); // Qx + Q15 - Q15 -> Qx move32(); Vm[1] = Madd_32_16( mem[4], L_sub( Vm[0], mem[5] ), filt_coeff[4] ); // Qx + Q15 - Q15 -> Qx move32(); mem[6] = Madd_32_16( mem[5], L_sub( Vm[1], mem[6] ), filt_coeff[5] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vm[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[4] ), filt_coeff[3] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vm[1] = L_add( mem[4], Mpy_32_16_1( L_sub( Vm[0], mem[5] ), filt_coeff[4] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[6] = L_add( mem[5], Mpy_32_16_1( L_sub( Vm[1], mem[6] ), filt_coeff[5] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[4] = Vm[0]; // Qx move32(); @@ -1535,21 +1449,12 @@ void interpolate_3_over_2_allpass_fx32( move32(); /* Lower branch */ -#ifdef OPT_STEREO_32KBPS_V1 Vl[0] = Madd_32_16( mem[0], L_sub( input[i], mem[7] ), filt_coeff[6] ); // Qx + Q15 - Q15 -> Qx move32(); Vl[1] = Madd_32_16( mem[7], L_sub( Vl[0], mem[8] ), filt_coeff[7] ); // Qx + Q15 - Q15 -> Qx move32(); mem[9] = Madd_32_16( mem[8], L_sub( Vl[1], mem[9] ), filt_coeff[8] ); // Qx + Q15 - Q15 -> Qx move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Vl[0] = L_add( mem[0], Mpy_32_16_1( L_sub( input[i], mem[7] ), filt_coeff[6] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - Vl[1] = L_add( mem[7], Mpy_32_16_1( L_sub( Vl[0], mem[8] ), filt_coeff[7] ) ); // Qx + Q15 - Q15 -> Qx - move32(); - mem[9] = L_add( mem[8], Mpy_32_16_1( L_sub( Vl[1], mem[9] ), filt_coeff[8] ) ); // Qx + Q15 - Q15 -> Qx - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ mem[0] = input[i]; // Qx move32(); @@ -1568,17 +1473,10 @@ void interpolate_3_over_2_allpass_fx32( { mem_temp = out1_buff[2 * i]; move32(); -#ifdef OPT_STEREO_32KBPS_V1 out[i] = Madd_32_16( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), L_add( mem[11], mem[14] ), -4965 ); // Qx + Q15 - Q15 -> Qx // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 out[i] = Madd_32_16( out[i], L_add( mem[12], mem[13] ), 20125 ); // 0.614152f in Q15 -> 20125 -#else /* OPT_STEREO_32KBPS_V1 */ - out[i] = L_add( Mpy_32_16_1( L_add( mem_temp, mem[10] ), 1550 ), Mpy_32_16_1( L_add( mem[11], mem[14] ), -4965 ) ); // Qx + Q15 - Q15 -> Qx - // 0.0473147f in Q15 -> 1550, -0.151521f in Q15 -> -4965 - out[i] = L_add( out[i], Mpy_32_16_1( L_add( mem[12], mem[13] ), 20125 ) ); - // 0.614152f in Q15 -> 20125 -#endif /* OPT_STEREO_32KBPS_V1 */ mem[10] = mem[11]; // Qx move32(); mem[11] = mem[12]; // Qx diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c index 8d5e8adf2..bbca86159 100644 --- a/lib_com/mslvq_com_fx.c +++ b/lib_com/mslvq_com_fx.c @@ -126,13 +126,10 @@ void init_lvq_fx( ) { Word16 i, j; -#ifdef OPT_STEREO_32KBPS_V1 Word16 k; -#endif /* OPT_STEREO_32KBPS_V1 */ /* safety-net mode */ FOR( i = 0; i < MAX_NO_MODES; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ ) { if ( no_lead_fx[i][j] > 0 ) @@ -162,31 +159,10 @@ void init_lvq_fx( } no_scales[i][1] = k; move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - j = 0; - move16(); - test(); - WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_fx[i][j] > 0 ) ) - { - j++; - } - no_scales[i][0] = j; - move16(); - j = MAX_NO_SCALES; - move16(); - test(); - WHILE( ( LT_16( j, shl( MAX_NO_SCALES, 1 ) ) ) && ( no_lead_fx[i][j] > 0 ) ) - { - j++; - } - no_scales[i][1] = sub( j, MAX_NO_SCALES ); - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* predictive mode */ FOR( i = 0; i < MAX_NO_MODES_p; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 FOR( ( j = 0, k = 0 ); j < MAX_NO_SCALES; j++ ) { if ( no_lead_p_fx[i][j] > 0 ) @@ -218,26 +194,6 @@ void init_lvq_fx( no_scales_p[i][1] = k; move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - j = 0; - move16(); - WHILE( ( LT_16( j, MAX_NO_SCALES ) ) && ( no_lead_p_fx[i][j] > 0 ) ) - { - test(); - j++; - } - no_scales_p[i][0] = j; - move16(); - j = MAX_NO_SCALES; - move16(); - WHILE( ( LT_16( j, shl( MAX_NO_SCALES, 1 ) ) ) && ( no_lead_p_fx[i][j] > 0 ) ) - { - test(); - j++; - } - no_scales_p[i][1] = sub( j, MAX_NO_SCALES ); - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ } /* index offsets for each truncation */ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p ); diff --git a/lib_com/options.h b/lib_com/options.h index 1cd99a80c..5f33170bf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -74,9 +74,7 @@ #define FIX_1737_FIX_867_CLDFB_NRG_SCALE #define FIX_1737_proto_fac_overflow -#define FIX_1378_ACELP_OUT_OF_BOUNDS -#define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCT_ENC_V1_NBE @@ -85,41 +83,16 @@ #define OPT_SBA_DEC_V2_BE #define OPT_SBA_ENC_V2_BE #define OPT_SBA_ENC_V1_BE -#define OPT_BIN_RENDERER_V1 -#define OPT_BIN_RENDERER_V2 -#define OPT_STEREO_32KBPS_V1 /* Optimization made in stereo decoding path for 32kbps decoding */ -#define OPT_AVOID_STATE_BUF_RESCALE /* Optimization made to avoid rescale of synth state buffer */ #define OPT_SBA_DEC_PATH /* Optimization made in SBA decoding path */ #define OPT_IVAS_FILTER_ROM /* Optimization made in IVAS filter table */ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ -#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot /*FhG: WMOPS tuning, nonbe*/ /* Both following 2 macros (IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST*) are independent from each other, they refer to different code blocks */ -#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE /* FhG: reduces WMOPS of param_mc_prm_est, bit-exact to previous version */ //#define IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE /* FhG: reduces WMOPS of param_mc_prm_est, not bit-exact to previous version. Obsoleted by MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define HARM_PUSH_BIT -#define HARM_ENC_INIT //#define HARM_SCE_INIT -#define DIV32_OPT_NEWTON /* FhG: faster 32 by 32 bit division */ -#define MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of Cy calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Obsoletes IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE. */ #define MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE /* FhG: reduce WMOPS of dmx calculation in ivas_param_mc_param_est_enc_fx() by using 64 Bit addition. Requires MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE. */ -#define MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE /* FhG: reduce WMOPS by inlining the matrix multiplications for the smoothing operation. */ -#define FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_stereo_icBWE_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx /*FhG: reduces WMOPS - bit-exact*/ -#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic /*FhG: reduces maintenance complexity & reduces WMOPS & prepares STAGE2 patch*/ -#define FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 /*FhG: reduces WMOPS*/ -#define FIX_1481_HARDCODE_DIV /* FhG: hardcode division results in stereo_dmx_evs_init_encoder_fx() */ -#define VEC_ARITH_OPT_v1 -#define FIX_1486_IND_SHB_RES /* VA: Fix for issue 1486: align the usage of IND_SHB_RES_GS indices with float code */ -#define FIX_1511_POC_RENORM /* NTT: Fix for issue 1511: Renorm for POC. */ - -#define TEST_HR -#define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ - -#define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ + + #define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */ -#define FIX_1733_CLDFB_BUG #define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index d533c5612..2d4ea1901 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3222,11 +3222,8 @@ void interp_code_4over2_fx( void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_lsyn_filt_dwn_shb[], Word16 state_32and48k_WB_upsample[], Word16 state_resamp_HB[] ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic void elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 const Word16 element_mode, -#endif Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ Word16 *Q_input_fx, @@ -3235,16 +3232,6 @@ void elliptic_bpf_48k_generic_fx( Word16 memory_fx_Q[], const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ ); -#else -void elliptic_bpf_48k_generic_fx( - const Word16 input_fx[], /* i : i signal Q_input_fx */ - Word16 *Q_input_fx, - Word16 output_fx[], /* o : output signal */ - Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory memory_fx_Q */ - Word16 memory_fx_Q[], - const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */ -); -#endif void synthesise_fb_high_band_fx( const Word16 excitation_in[], /* i : full band excitation */ @@ -3258,10 +3245,8 @@ void synthesise_fb_high_band_fx( Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], Word16 Qout -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , Word16 element_mode -#endif ); void prep_tbe_exc_fx( @@ -6028,14 +6013,12 @@ void v_add_fixed( const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ ); -#ifdef VEC_ARITH_OPT_v1 void v_add_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ Word32 y[], /* o : Output vector that contains vector 1 + vector 2 */ const Word16 N /* i : Vector length */ ); -#endif /* VEC_ARITH_OPT_v1 */ void v_add_fixed_me( const Word32 x1[], /* i : Input vector 1 */ @@ -6071,14 +6054,12 @@ void v_sub_fixed( const Word16 hdrm /* i : headroom for when subtraction result > 1 or < -1 */ ); -#ifdef VEC_ARITH_OPT_v1 void v_sub_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ Word32 y[], /* o : Output vector that contains vector 1 - vector 2 */ const Word16 N /* i : Vector length */ ); -#endif /* VEC_ARITH_OPT_v1 */ /*! r: dot product of x[] and y[] */ Word32 dotp_fixed( @@ -9385,9 +9366,7 @@ void cldfbSynthesis_ivas_fx( Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ const Word16 samplesToProcess, /* i : number of processed samples */ const Word16 shift, /* i : scale for state buffer */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE const Word16 out_shift, /* i : scale for output buffer */ -#endif HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ); diff --git a/lib_com/scale_mem_fx.c b/lib_com/scale_mem_fx.c index 2ce2ffd12..168a96011 100644 --- a/lib_com/scale_mem_fx.c +++ b/lib_com/scale_mem_fx.c @@ -307,12 +307,10 @@ void scale_sig32( /* saturation can occur here */ x[i] = L_shl( x[i], exp0 ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 if ( 0 == exp0 ) { i = lg; } -#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -329,12 +327,10 @@ void scale_sig32_r( /* saturation can occur here */ x[i] = L_shl_r( x[i], exp0 ); move32(); -#ifdef OPT_STEREO_32KBPS_V1 if ( 0 == exp0 ) { i = lg; } -#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 2cb51ae93..f37381b69 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6368,15 +6368,9 @@ void wb_tbe_extras_reset_synth_fx( *-------------------------------------------------------------------*/ void elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 const int16_t element_mode, -#endif -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 IsUpsampled3, Word16 input_fx[], /* i : input signal Q_input_fx*/ -#else - const Word16 input_fx[], /* i : input signal Q_input_fx*/ -#endif Word16 *Q_input_fx, Word16 output_fx[], /* o : output signal memory_fx_Q */ Word32 memory_fx2[][4], /* i/o: 4 arrays of 4 for memory */ @@ -6385,27 +6379,18 @@ void elliptic_bpf_48k_generic_fx( ) { Word16 i, j; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 memory_fx0, Q_temp, Q_temp2; Word32 L_tmp_buffer[L_FRAME48k + 4], L_tmp2_buffer[L_FRAME48k + 4], L_output_buffer[L_FRAME48k + 4], L_tmpX; Word32 L_tmpMax; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 Word64 W_tmpX; Word64 W_tmpY; -#endif Word32 *L_tmp = &L_tmp_buffer[4]; Word32 *L_tmp2 = &L_tmp2_buffer[4]; Word32 *L_output = &L_output_buffer[4]; -#else - Word16 memory_fx0[4][4], memory_fx[4][4], Q_temp, Q_temp2; - Word32 L_tmp[L_FRAME48k], L_tmp2[L_FRAME48k], L_output[L_FRAME48k], L_tmpX, memory2_fx[4][4], L_tmpMax; - Word32 memory2_fx_2[4], memory2_fx_3[4]; -#endif FOR( i = 0; i < 4; i++ ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic memory_fx0 = extract_l( memory_fx2[0][i] ); input_fx[i - 4] = shl_sat( memory_fx0, sub( *Q_input_fx, memory_fx_Q[0] ) ); L_tmp[i - 4] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); @@ -6416,24 +6401,11 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); -#else - memory_fx0[0][i] = extract_l( memory_fx2[0][i] ); - memory_fx[0][i] = shl_sat( memory_fx0[0][i], sub( *Q_input_fx, memory_fx_Q[0] ) ); - memory2_fx[1][i] = L_shl_sat( memory_fx2[1][i], sub( add( *Q_input_fx, 11 ), memory_fx_Q[1] ) ); - memory2_fx[2][i] = L_shl_sat( memory_fx2[2][i], sub( add( *Q_input_fx, 6 ), memory_fx_Q[2] ) ); - move32(); - move32(); - move32(); - move32(); - move32(); -#endif } -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); IF( !IsUpsampled3 ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6453,7 +6425,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6472,7 +6443,6 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ ELSE { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; ) @@ -6508,7 +6478,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; ) { @@ -6542,63 +6511,6 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( L_mult( memory_fx[0][0], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - - L_tmpX = L_shr( L_mult( memory_fx[0][1], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - - L_tmpX = L_shr( L_mult( memory_fx[0][2], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - L_tmpX = L_shr( L_mult( memory_fx[0][3], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[0], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[1], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[2], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add( L_shr( L_mult( input_fx[3], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[2], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[1], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[0], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmp[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( L_mult( input_fx[i - 4], full_band_bpf_fx[0][4] ), 3 ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 3], full_band_bpf_fx[0][3] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[3][1] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 2], full_band_bpf_fx[0][2] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[3][2] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i - 1], full_band_bpf_fx[0][1] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[3][3] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - L_tmpX = L_add_sat( L_shr( L_mult( input_fx[i], full_band_bpf_fx[0][0] ), 3 ), L_tmpX ); /*Q_input_fx + 13 + 1 - 3*/ - L_tmp[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[3][4] ), 2 ) ); /*Q_input_fx + 11 + 13 -15 +2*/ - move32(); - } -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ memory_fx2[0][0] = input_fx[L_FRAME48k - 4]; memory_fx2[0][1] = input_fx[L_FRAME48k - 3]; @@ -6610,9 +6522,7 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6632,7 +6542,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6649,66 +6558,6 @@ void elliptic_bpf_48k_generic_fx( L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) ); } } -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][0], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - L_tmp2[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][0], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2*/ - move32(); - L_tmpMax = L_abs( L_tmp2[0] ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][1], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][1], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[1] ) ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][2], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][2], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[2] ) ); - L_tmpX = L_shr( Mult_32_16( memory2_fx[1][3], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[0], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[1], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[2], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add( L_shr( Mult_32_16( L_tmp[3], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[2], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[1], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[0], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmp2[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx[2][3], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ /*14 + Q_input_fx - shift_flag*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[3] ) ); - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( Mult_32_16( L_tmp[i - 4], full_band_bpf_fx[1][4] ), 3 ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 3], full_band_bpf_fx[1][3] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[4][1] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 2], full_band_bpf_fx[1][2] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[4][2] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i - 1], full_band_bpf_fx[1][1] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[4][3] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp[i], full_band_bpf_fx[1][0] ), 3 ), L_tmpX ); /*Q_input_fx + 11 + 13 - 15 -3*/ - L_tmp2[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[4][4] ), 2 ) ); /*Q_input_fx + 6 +13 -15 +2 */ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_tmp2[i] ) ); - } -#endif Q_temp = norm_l( L_tmpMax ); @@ -6724,7 +6573,6 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic FOR( j = 0; j < 4; j++ ) { L_tmp2[j - 4] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); @@ -6733,19 +6581,7 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); } -#else - FOR( j = 0; j < 4; j++ ) - { - memory2_fx_2[j] = L_shl_sat( memory_fx2[2][j], sub( add( add( *Q_input_fx, 6 ), Q_temp ), memory_fx_Q[2] ) ); - memory2_fx_3[j] = L_shl_sat( memory_fx2[3][j], sub( add( add( *Q_input_fx, 1 ), Q_temp ), memory_fx_Q[3] ) ); - move32(); - move32(); - move32(); - } -#endif -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic L_tmpMax = L_add( 0, 0 ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 IF( element_mode ) { FOR( i = 0; i < L_FRAME48k; i++ ) @@ -6765,7 +6601,6 @@ void elliptic_bpf_48k_generic_fx( } } ELSE -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ { FOR( i = 0; i < L_FRAME48k; i++ ) { @@ -6786,73 +6621,6 @@ void elliptic_bpf_48k_generic_fx( } } -#else /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic*/ - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[0], full_band_bpf_fx[2][4] ), 3 ); /* *Q_input_fx+6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - L_output[0] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[0], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2 */ - move32(); - L_tmpMax = L_abs( L_output[0] ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[1], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx+Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - L_output[1] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[1], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +13 -15 + 2+Q_temp*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[1] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[2], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp+ 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx +Q_temp + 6 +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1+Q_temp +13 -15 + 2*/ - L_output[2] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[2], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[2] ) ); - - L_tmpX = L_shr( Mult_32_16( memory2_fx_2[3], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp +13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[0], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[1], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[2], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[3], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[2], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[1], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[0], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - L_output[3] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( memory2_fx_3[3], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[3] ) ); - - FOR( i = 4; i < L_FRAME48k; i++ ) - { - L_tmpX = L_shr( Mult_32_16( L_tmp2[i - 4], full_band_bpf_fx[2][4] ), 3 ); /*Q_input_fx + 6 +Q_temp+13 -15 -3 */ - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 3], full_band_bpf_fx[2][3] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 1], full_band_bpf_fx[5][1] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 2], full_band_bpf_fx[2][2] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp+13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 2], full_band_bpf_fx[5][2] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i - 1], full_band_bpf_fx[2][1] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_tmpX = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 3], full_band_bpf_fx[5][3] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - - L_tmpX = L_add_sat( L_shr( Mult_32_16( L_tmp2[i], full_band_bpf_fx[2][0] ), 3 ), L_tmpX ); /*Q_input_fx + 6 +Q_temp +13 -15 -3*/ - L_output[i] = L_sub_sat( L_tmpX, L_shl_sat( Mult_32_16( L_output[i - 4], full_band_bpf_fx[5][4] ), 2 ) ); /*Q_input_fx + 1 +Q_temp+13 -15 + 2*/ - move32(); - L_tmpMax = L_max( L_tmpMax, L_abs( L_output[i] ) ); - } -#endif memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4]; memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3]; @@ -6918,19 +6686,13 @@ void synthesise_fb_high_band_fx( Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], Word16 Qout -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , int16_t element_mode -#endif ) { Word16 i, j; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 excitation_in_interp3_buffer[L_FRAME48k + 4]; Word16 *excitation_in_interp3 = &excitation_in_interp3_buffer[0] + 4; -#else - Word16 excitation_in_interp3[L_FRAME48k]; -#endif Word16 tmp[L_FRAME48k]; Word32 temp1; Word32 ratio2; @@ -6955,32 +6717,20 @@ void synthesise_fb_high_band_fx( IF( EQ_16( L_frame, L_FRAME16k ) ) { /* for 16kHz ACELP core */ -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 element_mode, -#endif 1, // IsUpsampled3 excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx ); -#else - elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx ); -#endif } ELSE { /* for 12.8kHz ACELP core */ -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 element_mode, -#endif 1, // IsUpsampled3 excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); -#else - elliptic_bpf_48k_generic_fx( excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx ); -#endif } /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */ temp1 = sum2_fx_mod( tmp, L_FRAME48k ); diff --git a/lib_com/tools.c b/lib_com/tools.c index 9166d16eb..3cf11ea92 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -777,7 +777,6 @@ void v_sub_fixed( return; } -#ifdef VEC_ARITH_OPT_v1 void v_sub_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -795,7 +794,6 @@ void v_sub_fixed_no_hdrm( return; } -#endif /* VEC_ARITH_OPT_v1 */ /*-------------------------------------------------------------------* * v_multc_fixed() diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 137e2a40e..a83dfb56b 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -818,7 +818,6 @@ void Copy_Scale_sig_16_32_no_sat( } return; } -#ifdef FIX_1439_SPEEDUP_Copy_Scale_sig_16_32_no_sat L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); IF( L_tmp >= 0x7FFF ) @@ -840,15 +839,6 @@ void Copy_Scale_sig_16_32_no_sat( move32(); } } -#else - L_tmp = L_shl_o( 1, exp0 - 1, &Overflow ); - FOR( i = 0; i < lg; i++ ) - { - // y[i] = L_mult0(x[i], L_tmp); - y[i] = W_extract_l( W_mult_32_16( L_tmp, x[i] ) ); - move32(); /* Overflow can occur here */ - } -#endif } void Copy_Scale_sig_32_16( @@ -4600,7 +4590,6 @@ void v_add_fixed( return; } -#ifdef VEC_ARITH_OPT_v1 void v_add_fixed_no_hdrm( const Word32 x1[], /* i : Input vector 1 */ const Word32 x2[], /* i : Input vector 2 */ @@ -4618,7 +4607,6 @@ void v_add_fixed_no_hdrm( return; } -#endif /* VEC_ARITH_OPT_v1 */ void v_add_fixed_me( const Word32 x1[], /* i : Input vector 1 */ diff --git a/lib_com/trans_inv_fx.c b/lib_com/trans_inv_fx.c index 0683e266c..36678487a 100644 --- a/lib_com/trans_inv_fx.c +++ b/lib_com/trans_inv_fx.c @@ -84,9 +84,7 @@ void preecho_sb_fx( UWord16 tmp_u16; Word32 mean_prev_hb_fx_loc, mean_prev_nc_fx_loc, mean_prev_fx_loc; /* */ Word16 q16p1, qmemp1, qtmp; -#ifdef OPT_STEREO_32KBPS_V1 Word16 shift_q = sub( 15, q_sig32 ); -#endif /* OPT_STEREO_32KBPS_V1 */ q16p1 = add( q_sig16, 1 ); qmemp1 = q16p1; @@ -139,7 +137,6 @@ void preecho_sb_fx( /* len3xLp20 = framelength/2-(short)((float)framelength*N_ZERO_MDCT/FRAME_SIZE_MS); in float*/ fxptr1 = imdct_mem_fx; -#ifdef OPT_STEREO_32KBPS_V1 FOR( i = 0; i < len3xLp20; i++ ) { *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[len3xLp20 - 1 - i], shift_q ) ) ); /*Q-1*/ @@ -150,19 +147,6 @@ void preecho_sb_fx( *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], shift_q ) ) ); /*Q-1*/ move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ } -#else /* OPT_STEREO_32KBPS_V1 */ - fx32ptr1 = wtda_audio_fx + len3xLp20 - 1; /*q_sig32*/ - FOR( i = 0; i < len3xLp20; i++ ) - { - *fxptr1++ = negate( extract_h( L_shl_sat( *fx32ptr1--, sub( 15, q_sig32 ) ) ) ); /*Q-1*/ - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ - } - FOR( i = 0; i < L_shr( framelength, 1 ); i++ ) - { - *fxptr1++ = negate( extract_h( L_shl_sat( wtda_audio_fx[i], sub( 15, q_sig32 ) ) ) ); /*Q-1*/ - move16(); /*convert to Word16 Q-1 with saturation (saturation not a problem here) */ - } -#endif /* OPT_STEREO_32KBPS_V1 */ qmemp1 = 0; /*already in q-1*/ move16(); @@ -408,7 +392,6 @@ void preecho_sb_fx( move16(); FOR( i = 1; i <= NUMSF; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 max_es_hb_fx = L_max( max_es_hb_fx, es_mdct_hb_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ max_es_fx = L_max( max_es_fx, es_mdct_fx[i] ); /* max energy low band, 8 present and 1 future subframes */ @@ -418,19 +401,6 @@ void preecho_sb_fx( maxind = i; move16(); } -#else /* OPT_STEREO_32KBPS_V1 */ - IF( GE_32( es_mdct_hb_fx[i], max_es_hb_fx ) ) /* '=' to handle the first window*/ - { - max_es_hb_fx = L_add( es_mdct_hb_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ - } - - IF( GE_32( es_mdct_fx[i], max_es_fx ) ) /* '=' to handle the first window*/ - { - max_es_fx = L_add( es_mdct_fx[i], 0 ); /* max energy low band, 8 present and 1 future subframes */ - maxind = i; - move16(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ } cnt2 = cnt5 = 0; diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 847e16594..76bf9d622 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2042,15 +2042,6 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // (Q_real-1) -#endif /* OPT_STEREO_32KBPS_V1 */ - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2070,18 +2061,8 @@ ivas_error acelp_core_dec_fx( } } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSynHB ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, 0, st->cldfbSynHB ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( save_hb_synth_fx, L_FRAME48k, negate( ( sub( Q_real, 1 ) ) ) ); // Q0 - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) { @@ -2093,21 +2074,8 @@ ivas_error acelp_core_dec_fx( move32(); } } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); // Q_real-1 - st->cldfbSynHB->Q_cldfb_state = sub( Q_real, 1 ); - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, sub( Q11, Q_real ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pRealSave_fx, pImagSave_fx, synth_fx, -1, 0, st->cldfbSyn ); - Scale_sig32( synth_fx, L_FRAME48k, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSynHB->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -2131,19 +2099,11 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifdef OPT_STEREO_32KBPS_V1 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ st->cldfbSyn->Q_cldfb_state = sub( Q_real, 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx, -1, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 st->cldfbSyn->Q_cldfb_state = Q10; @@ -2224,26 +2184,9 @@ ivas_error acelp_core_dec_fx( scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real ); // Q_real } -#ifndef OPT_AVOID_STATE_BUF_RESCALE -#ifdef OPT_STEREO_32KBPS_V1 - scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q_real, Q11 ) ); // Q10 - > (Q_real-1) -#else /* OPT_STEREO_32KBPS_V1 */ - scale_sig32_r( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( sub( Q_real, 1 ), Q10 ) ); //(Q_real - 1) -#endif /* OPT_STEREO_32KBPS_V1 */ -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), sub( Q10, sub( Q_real, 1 ) ), -10, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, synth_fx /*dummy*/, NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS /*DELAY_CLDFB_NS*/ ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ - -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( synth_fx, output_frame, negate( sub( Q_real, 1 ) ) ); // Q0 - Scale_sig32( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, sub( Q10, sub( Q_real, 1 ) ) ); // Q10 - st->cldfbSyn->Q_cldfb_state = Q10; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ + IF( st->p_bpf_noise_buf_32 ) { Copy_Scale_sig_16_32_DEPREC( bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1 ); // Q_syn-1 diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index b12682385..109f360cb 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -832,25 +832,10 @@ ivas_error acelp_core_switch_dec_bfi_ivas_fx( } /*cldfbSynthesis_fx( st_fx->cldfbSyn, realBuffer, imagBuffer, &scaleFactor, synth_out, negate(st_fx->Q_syn), CLDFB_NO_COL_MAX_SWITCH_BFI, workBuffer );*/ -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, 1 ); // Q_cldfb_state+1 - st_fx->cldfbSyn->Q_cldfb_state = add( st_fx->cldfbSyn->Q_cldfb_state, 1 ); - move16(); - Copy_Scale_sig_16_32_DEPREC( synth_out, synth32, L_FRAME48k, 5 ); /*11-5-1*/ - - cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ), 0, st_fx->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 out_len = extract_l( Mpy_32_16_1( st_fx->output_Fs, 328 ) ); cldfbSynthesis_ivas_fx( realBuffer, imagBuffer, synth32, out_len, -1, 0, st_fx->cldfbSyn ); Copy_Scale_sig_32_16( synth32, synth_out, out_len, -4 ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifndef OPT_AVOID_STATE_BUF_RESCALE - Scale_sig32( st_fx->cldfbSyn->cldfb_state_fx, st_fx->cldfbSyn->cldfb_state_length, -1 ); // Q_cldfb_state-1 - st_fx->cldfbSyn->Q_cldfb_state = sub( st_fx->cldfbSyn->Q_cldfb_state, 1 ); - move16(); - Copy_Scale_sig_32_16( synth32, synth_out, L_FRAME48k, -5 ); // 11-5-1 -> 11 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scale_sig( synth_out, L_FRAME48k, negate( st_fx->Q_syn ) ); diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index ba7c73741..106cb0e60 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -2056,11 +2056,7 @@ static void core_switch_lb_upsamp_fx( } /* synthesis of the combined signal */ -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, output, i_mult( CLDFB_OVRLP_MIN_SLOTS, st->cldfbSyn->no_channels ), 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ /*rescaling whole buffer to a common Q*/ no_col = st->cldfbSyn->no_col; @@ -2368,11 +2364,7 @@ ivas_error core_switching_pre_dec_ivas_fx( return error; } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, 0, st->cldfbSyn ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBuffer_fx, imagBuffer_fx, fer_samples_fx, delay_comp, 0, st->cldfbSyn ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ cldfb_restore_memory_ivas_fx( st->cldfbSyn ); Copy_Scale_sig_32_16( syn_Overl_fx, st->hTcxDec->syn_Overl, 320, 15 ); Copy_Scale_sig_32_16( fer_samples_fx, st->hHQ_core->fer_samples_fx, 960, 9 ); diff --git a/lib_dec/dec_acelp_fx.c b/lib_dec/dec_acelp_fx.c index 51cbef624..e7f8c98ce 100644 --- a/lib_dec/dec_acelp_fx.c +++ b/lib_dec/dec_acelp_fx.c @@ -169,20 +169,9 @@ void D_ACELP_indexing_fx( pulses = pulsestrack[0]; move16(); -#ifndef FIX_1378_ACELP_OUT_OF_BOUNDS - /* safety check in case of bit errors */ - IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) - { - set16_fx( code, 0, L_SUBFR ); - *BER_detect = 1; - move16(); - return; - } -#endif IF( pulses ) { -#ifdef FIX_1378_ACELP_OUT_OF_BOUNDS /* safety check in case of bit errors */ IF( GE_64( s, pulsestostates[16][pulses - 1] ) ) { @@ -191,7 +180,6 @@ void D_ACELP_indexing_fx( move16(); return; } -#endif D_ACELP_decode_arithtrack_fx( code, s, pulses, num_tracks, 16 ); } ELSE diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index adf838f42..501276dfc 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -4758,11 +4758,7 @@ void generate_masking_noise_ivas_fx( } ELSE { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ) ); /*Q31 - *exp_out*/ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( maskingNoise_fx, timeDomainBuffer, timeDomainBuffer, s_min( hFdCngCom->frameSize, length ), 0 ); /*Q31 - *exp_out*/ -#endif /* VEC_ARITH_OPT_v1 */ } return; diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 908d3b79b..efd9d0c67 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -54,7 +54,6 @@ * * *-------------------------------------------------------------------------*/ -#ifdef OPT_BIN_RENDERER_V2 static void ivas_binRenderer_filterModule_fx( Word32 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q6 */ Word32 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q6 */ @@ -184,117 +183,6 @@ static void ivas_binRenderer_filterModule_fx( return; } -#else /* OPT_BIN_RENDERER_V2 */ -static void ivas_binRenderer_filterModule_fx( - Word64 out_Conv_CLDFB_real[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : real part of Binaural signals Q29 */ - Word64 out_Conv_CLDFB_imag[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : imag part of Binaural signals Q29 */ - Word32 CLDFB_real[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : real part of LS signals Q_curr*/ - Word32 CLDFB_imag[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : imag part of LS signals Q_curr*/ - const Word16 numTimeSlots, /* i : number of time slots to process */ - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ - Word16 Q_curr ) -{ - Word16 bandIdx, k, chIdx, tapIdx; - Word32 *filterStatesLeftRealPtr_fx, *filterStatesLeftImagPtr_fx; - Word16 Q_filterStates; - const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; - Word16 shift_q; - Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; - move16(); - - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); - filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); - - filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 - filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 - filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 - filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 - - FOR( k = 0; k < numTimeSlots; k++ ) - { - Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; - move64(); - move64(); - move64(); - move64(); - - FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) - { - filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; - move32(); - filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; - move32(); - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( filterStatesLeftImagPtr_fx[tapIdx] ), filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - } - - shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); - - IF( shift_q != 0 ) - { - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr - hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; - move16(); - } - - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); - - - /* Left Real and Imag */ - // Q29 + Q_curr - - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, L_negate( temp2 ), filterTapsLeftImagPtr_fx[0] ); - out_Conv_CLDFB_real[0][k][bandIdx] = W_add( out_Conv_CLDFB_real[0][k][bandIdx], outRealLeft_fx ); // Q29 - move64(); - - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - out_Conv_CLDFB_imag[0][k][bandIdx] = W_add( out_Conv_CLDFB_imag[0][k][bandIdx], outImagLeft_fx ); // Q29 - move64(); - - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, L_negate( temp2 ), filterTapsRightImagPtr_fx[0] ); - out_Conv_CLDFB_real[1][k][bandIdx] = W_add( out_Conv_CLDFB_real[1][k][bandIdx], outRealRight_fx ); // Q29 - move64(); - - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - out_Conv_CLDFB_imag[1][k][bandIdx] = W_add( out_Conv_CLDFB_imag[1][k][bandIdx], outImagRight_fx ); // Q29 - move64(); - } - } - } - - return; -} -#endif /* OPT_BIN_RENDERER_V2 */ /*------------------------------------------------------------------------- * ivas_binRenderer_convModuleOpen() @@ -1613,11 +1501,6 @@ void ivas_binRenderer_fx( ) { Word16 chIdx, i, j, k; -#ifndef OPT_BIN_RENDERER_V2 - // to be checked: feasibility with 32 bit buffers - Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word64 Cldfb_ImagBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif /* OPT_BIN_RENDERER_V2 */ push_wmops( "fastconv_binaural_rendering" ); /* Compute Convolution */ @@ -1629,10 +1512,6 @@ void ivas_binRenderer_fx( { set32_fx( Cldfb_RealBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#ifndef OPT_BIN_RENDERER_V2 - set64_fx( Cldfb_RealBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( Cldfb_ImagBuffer_Binaural_64fx[chIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); -#endif /* OPT_BIN_RENDERER_V2 */ } } #endif /* OPT_SBA_DEC_V2_BE */ @@ -1673,25 +1552,7 @@ void ivas_binRenderer_fx( ivas_sba2mc_cldfb_fixed( *( hBinRenderer->hInputSetup ), RealBuffer_fx, ImagBuffer_fx, hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } -#ifdef OPT_BIN_RENDERER_V2 ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); -#else /* OPT_BIN_RENDERER_V2 */ - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); - - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) - { - Cldfb_RealBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_RealBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - Cldfb_ImagBuffer_Binaural_fx[i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 - move32(); - } - } - } -#endif /* OPT_BIN_RENDERER_V2 */ /* Obtain the binaural dmx and compute the reverb */ IF( hBinRenderer->hReverb != NULL ) { diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index a778424dd..48fce8b95 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2314,16 +2314,6 @@ void ivas_dirac_dec_render_sf_fx( } } -#ifndef OPT_BIN_RENDERER_V2 - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif /* OPT_BIN_RENDERER_V2 */ hDirAC = st_ivas->hDirAC; hDirACRend = st_ivas->hDirACRend; @@ -3171,11 +3161,7 @@ void ivas_dirac_dec_render_sf_fx( v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ -#endif /* VEC_ARITH_OPT_v1 */ p_onset_filter_fx = onset_filter_subframe_fx; } ELSE @@ -3923,9 +3909,6 @@ void ivas_dirac_dec_render_sf_fx( { Word16 j, k, j2, l; Word16 num_objects, nchan_out_woLFE, lfe_index; -#ifndef FIX_1379_MASA_ANGLE_ROUND - Word16 az1, el1; -#endif Word16 n_slots_to_render; Word16 n_samples_to_render; Word16 interp_offset; @@ -3959,20 +3942,11 @@ void ivas_dirac_dec_render_sf_fx( Word16 el_q0 = extract_l( L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, Q22 ) ); Word32 az1_32, el1_32; rotateAziEle_fixed( az_q0, el_q0, &az1_32, &el1_32, st_ivas->hCombinedOrientationData->Rmat_fx[0], st_ivas->hIntSetup.is_planar_setup ); -#ifndef FIX_1379_MASA_ANGLE_ROUND - az1 = extract_h( az1_32 ); - el1 = extract_h( el1_32 ); -#endif IF( st_ivas->hEFAPdata != NULL ) { -#ifdef FIX_1379_MASA_ANGLE_ROUND const Word32 azi_fx = L_shl( az1_32, Q22 - Q16 ); // Q16 -> Q22 const Word32 ele_fx = L_shl( el1_32, Q22 - Q16 ); // Q16 -> Q22 -#else - const Word32 azi_fx = L_shl( az1, Q22 ); // Q0 -> Q22 - const Word32 ele_fx = L_shl( el1, Q22 ); // Q0 -> Q22 -#endif efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azi_fx, ele_fx, EFAP_MODE_EFAP ); } } @@ -4012,27 +3986,13 @@ void ivas_dirac_dec_render_sf_fx( { Word32 g_fx; w2_fx = sub( MAX16B, *w1_fx ); -#ifdef OPT_BIN_RENDERER_V2 g_fx = Madd_32_16( Mpy_32_16_1( gain_fx, *w1_fx ), prev_gain_fx, w2_fx ); // Q15 -#else /* OPT_BIN_RENDERER_V2 */ - g_fx = L_add( Mpy_32_16_1( gain_fx, *w1_fx ), Mpy_32_16_1( prev_gain_fx, w2_fx ) ); // Q15 -#endif /* OPT_BIN_RENDERER_V2 */ FOR( l = 0; l < hSpatParamRendCom->num_freq_bands; l++ ) { -#ifdef OPT_BIN_RENDERER_V2 Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_re_fx ); move32(); tc_re_fx++; Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = Madd_32_32( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], g_fx, *tc_im_fx ); -#else /* OPT_BIN_RENDERER_V2 */ - Word32 tmp; - tmp = Mpy_32_32( g_fx, *tc_re_fx ); - Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_RealBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); - move32(); - tc_re_fx++; - tmp = Mpy_32_32( g_fx, *tc_im_fx ); - Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l] = L_add( Cldfb_ImagBuffer_fx[j2][0][k * hSpatParamRendCom->num_freq_bands + l], tmp ); -#endif /* OPT_BIN_RENDERER_V2 */ move32(); tc_re_fx++; } @@ -4062,10 +4022,6 @@ void ivas_dirac_dec_render_sf_fx( Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); -#ifndef OPT_BIN_RENDERER_V2 - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 -#endif /* OPT_BIN_RENDERER_V2 */ /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) @@ -4086,11 +4042,7 @@ void ivas_dirac_dec_render_sf_fx( st_ivas->cldfbSynDec[ch]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, synth_fx, i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Word16 no_col = st_ivas->cldfbSynDec[ch]->no_col; move16(); @@ -4193,11 +4145,7 @@ void ivas_dirac_dec_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; move32(); } -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_buf_fx[ch][subframe_start_sample] ), num_samples_subframe, 0, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ IF( !st_ivas->hLsSetupCustom->separate_ch_found ) { @@ -4237,11 +4185,7 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[cldfbSynIdx]->cldfb_state_fx, st_ivas->cldfbSynDec[cldfbSynIdx]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state ) ); // Q6-1 st_ivas->cldfbSynDec[cldfbSynIdx]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[cldfbSynIdx] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE*/ // Calculating length of output Word16 no_col = st_ivas->cldfbSynDec[cldfbSynIdx]->no_col; @@ -4309,11 +4253,7 @@ void ivas_dirac_dec_render_sf_fx( scale_sig32( st_ivas->cldfbSynDec[idx_in]->cldfb_state_fx, st_ivas->cldfbSynDec[idx_in]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state ) ); st_ivas->cldfbSynDec[idx_in]->Q_cldfb_state = ( Q6 - 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, p_out, samplesToProcess, 0, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ // Scaling output from Q6-1 to Q11 Scale_sig32( p_out, out_len, ( Q11 - ( Q6 - 1 ) ) ); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 45c1a38a9..0d8e029d1 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -517,14 +517,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( Word16 mixing_matrix_buffer_e; Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 input_f_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS]; -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE - -#else - Word32 output_f_real_fx[MAX_CICP_CHANNELS]; - Word32 output_f_imag_fx[MAX_CICP_CHANNELS]; - Word16 output_f_real_e; - Word16 output_f_imag_e; -#endif + Word32 diff_f_real_fx[MAX_CICP_CHANNELS]; Word32 diff_f_imag_fx[MAX_CICP_CHANNELS]; @@ -532,12 +525,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( set_zero_fx( input_f_real_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero_fx( input_f_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS ); -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE -#else - set_zero_fx( output_f_real_fx, MAX_CICP_CHANNELS ); - set_zero_fx( output_f_imag_fx, MAX_CICP_CHANNELS ); -#endif set_zero_fx( diff_f_real_fx, MAX_CICP_CHANNELS ); set_zero_fx( diff_f_imag_fx, MAX_CICP_CHANNELS ); @@ -601,7 +589,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( } /* apply residual mixing */ -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE { Word16 shifter; #ifdef OPT_SBA_DEC_V2_BE @@ -638,23 +625,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( } -#else - - matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_real_fx, 25, nY, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, nY, sub( Q6, sub( Q31, output_f_real_e ) ) ); // Q6 - - - matrix_product_mant_exp_fx( mixing_matrix_res_smooth_fx, mixing_matrix_res_smooth_e, nY, nY, 0, diff_f_imag_fx, 25, nY, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, nY, sub( Q6, sub( Q31, output_f_imag_e ) ) ); // Q6 - - FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) - { - Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_real_fx[ch_idx]; // Q6 - move32(); - Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = output_f_imag_fx[ch_idx]; // Q6 - move32(); - } -#endif } ELSE { @@ -678,7 +648,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( } /* apply mixing matrix */ -#ifdef MERGE_REQUEST_1564_SPEEDUP_ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx_NONBE { Word16 shifter; shifter = 31 - mixing_matrix_smooth_e; @@ -707,24 +676,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move32(); } } -#else - - matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_real_fx, 25, nX, 1, 0, output_f_real_fx, &output_f_real_e ); - scale_sig32( output_f_real_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_real_e ) ) ); // Q6 - - - matrix_product_mant_exp_fx( mixing_matrix_smooth_fx, mixing_matrix_smooth_e, nY, nX, 0, input_f_imag_fx, 25, nX, 1, 0, output_f_imag_fx, &output_f_imag_e ); - scale_sig32( output_f_imag_fx, MAX_CICP_CHANNELS, sub( 6, sub( 31, output_f_imag_e ) ) ); // Q6 - - /* collect output */ - FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) - { - Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band], output_f_real_fx[ch_idx] ); - move32(); - Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = L_add( Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band], output_f_imag_fx[ch_idx] ); - move32(); - } -#endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 30a32c92c..f3e37c5c0 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1533,11 +1533,7 @@ static void ivas_ism_param_dec_render_sf_fx( Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 ); move16(); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a36982777..fefae52f9 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2137,11 +2137,7 @@ ivas_error ivas_jbm_dec_render_fx( /* add already rendered SBA part */ FOR( n = 0; n < nchan_out; n++ ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( p_output_fx[n], p_tc_fx[n + st_ivas->nchan_ism], p_output_fx[n], *nSamplesRendered, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 2ba8c9c9e..71c1b39fc 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2084,13 +2084,8 @@ void ivas_param_mc_dec_render_fx( { IF( hLsSetup.index_lfe[idx_lfe] != ch ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1 ); v_add_fixed_no_hdrm( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1, 0 ); - v_add_fixed( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } } @@ -2151,16 +2146,6 @@ void ivas_param_mc_dec_render_fx( } } -#ifndef OPT_BIN_RENDERER_V2 - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ ) - { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6 - } - } -#endif /* OPT_BIN_RENDERER_V2 */ /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2196,13 +2181,8 @@ void ivas_param_mc_dec_render_fx( Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); scale_sig32( output_f_fx[ch], len, 5 - 11 ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), - imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11 } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 7a1ef1126..5840cb08f 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -847,16 +847,6 @@ static void ivas_mc_paramupmix_dec_sf( Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); -#ifndef OPT_BIN_RENDERER_V2 - FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ ) - { - FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ ) - { - Scale_sig32( Cldfb_RealBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 - Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6 - } - } -#endif /* OPT_BIN_RENDERER_V2 */ /* Implement CLDFB synthesis */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -868,28 +858,10 @@ static void ivas_mc_paramupmix_dec_sf( RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5; - move16(); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5 -#else /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11 -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ -#ifndef OPT_AVOID_STATE_BUF_RESCALE - scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11 - st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; - move16(); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } -#ifndef OPT_AVOID_STATE_BUF_RESCALE - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); // Q5 -> Q11 - } -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } ELSE { @@ -915,13 +887,8 @@ static void ivas_mc_paramupmix_dec_sf( ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; // Q6 ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; // Q6 -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), hMCParamUpmix->num_freq_bands, 0, 0, st_ivas->cldfbSynDec[ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ), - hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6 -> Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index ba8c529d7..374efb593 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -77,11 +77,7 @@ void ivas_sba2mc_cldfb_fixed( FOR( m = 0; m < nb_channels_in; m++ ) { -#ifdef OPT_BIN_RENDERER_V2 g_fx = L_shl_sat( hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )], Q2 ); -#else /* OPT_BIN_RENDERER_V2 */ - g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 -#endif /* OPT_BIN_RENDERER_V2 */ p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; @@ -91,15 +87,9 @@ void ivas_sba2mc_cldfb_fixed( p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/ FOR( iBand = 0; iBand < nb_bands; iBand++ ) { -#ifdef OPT_BIN_RENDERER_V2 *p_realOut_fx = Madd_32_32( *p_realOut_fx, g_fx, *( p_real_fx++ ) ); // Q_real move32(); *p_imagOut_fx = Madd_32_32( *p_imagOut_fx, g_fx, *( p_imag_fx++ ) ); // Q_imag -#else /* OPT_BIN_RENDERER_V2 */ - *p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real - move32(); - *p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag -#endif /* OPT_BIN_RENDERER_V2 */ move32(); p_realOut_fx++; p_imagOut_fx++; @@ -177,11 +167,7 @@ void ivas_mc2sba_fx( /* Add LFE to omni W with gain*/ FOR( k = 0; k < output_frame; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 buffer_tmp_fx[0][k] = Madd_32_16( buffer_tmp_fx[0][k], L_shl( in_buffer_td_fx[i][k], 1 ), gain_lfe_fx ); /*Q+14-15+1==Q*/ -#else /* OPT_BIN_RENDERER_V2 */ - buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/ -#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } @@ -210,11 +196,7 @@ void ivas_mc2sba_fx( { FOR( k = 0; k < output_frame; k++ ) { -#ifdef OPT_BIN_RENDERER_V2 buffer_tmp_fx[j][k] = Madd_32_32( buffer_tmp_fx[j][k], L_shl_sat( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/ -#else /* OPT_BIN_RENDERER_V2 */ - buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/ -#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index fa5f6779f..abf953f37 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -787,11 +787,7 @@ void ivas_spar_get_cldfb_gains_fx( cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb ); cldfb_reset_memory_fx( cldfbSynDec0 ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, 0, cldfbSynDec0 ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, cldfbSynDec0 ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ FOR( sample = 0; sample < stride; sample++ ) { T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/ @@ -2104,11 +2100,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } @@ -2123,11 +2115,7 @@ void ivas_spar_dec_upmixer_sf_fx( { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[out_ch] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[out_ch] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ } } } diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 8ec147ff7..d48e035a6 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1446,11 +1446,7 @@ void stereo_cna_update_params_fx( { IF( EQ_16( hCPE->nchan_out, 1 ) ) { -#ifdef OPT_STEREO_32KBPS_V1 c_LR_fx = MAX_32; -#else /* OPT_STEREO_32KBPS_V1 */ - c_LR_fx = MAX_WORD16; -#endif /* OPT_STEREO_32KBPS_V1 */ move32(); c_ILD_fx = 0; move32(); @@ -1513,11 +1509,7 @@ void stereo_cna_update_params_fx( dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) ); dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */ /* estimate L/R correlation factor and ILD in time domain */ -#ifdef OPT_STEREO_32KBPS_V1 c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ -#else /* OPT_STEREO_32KBPS_V1 */ - c_LR_fx = extract_h( W_extract_l( dotLR_fx ) ); /* Q15 */ -#endif /* OPT_STEREO_32KBPS_V1 */ temp_res_q = 0; move16(); @@ -1556,24 +1548,15 @@ void stereo_cna_update_params_fx( /* update of long-term ILD and LR correlation factors for stereo CNA */ IF( !hFdCngDec->first_cna_noise_updated ) { -#ifdef OPT_STEREO_32KBPS_V1 hFdCngDec->cna_LR_LT_fx = extract_h( c_LR_fx ); -#else /* OPT_STEREO_32KBPS_V1 */ - hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx ); -#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx ); move16(); } ELSE { -#ifdef OPT_STEREO_32KBPS_V1 hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), Mpy_32_32( ONE_IN_Q31 - STEREO_CNA_LR_CORR_LT_FILT_FX, c_LR_fx ) ) ); /* Q31 */ -#else /* OPT_STEREO_32KBPS_V1 */ - hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ), - Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) ); /* Q31 */ -#endif /* OPT_STEREO_32KBPS_V1 */ move16(); hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ), diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 11f266d2e..4aebd5145 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -1881,10 +1881,6 @@ void stereo_dft_dec_fx( HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom; Word16 *cna_seed = &( hFdCngCom->seed ); Word32 DFT_W, DFT_Y; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 q_samp_ratio = Q15; - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 len; output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */ @@ -1893,12 +1889,7 @@ void stereo_dft_dec_fx( * Initialization *-----------------------------------------------------------------*/ -#ifdef OPT_STEREO_32KBPS_V1 samp_ratio = divide3232( st0->sr_core, st0->output_Fs ); // Q15 -#else /* OPT_STEREO_32KBPS_V1 */ - samp_ratio = (Word16) BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio ); - samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ stop = shr( STEREO_DFT32MS_N_32k, 1 ); @@ -2473,17 +2464,10 @@ void stereo_dft_dec_fx( /*Nyquist Freq.*/ IF( EQ_16( hStereoDft->band_limits[b], shr( hStereoDft->NFFT, 1 ) ) ) { -#ifdef OPT_STEREO_32KBPS_V1 DFT_L[1] = Madd_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ move32(); DFT_R[1] = Msub_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - DFT_L[1] = L_add( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ - move32(); - DFT_R[1] = L_sub( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ DFT_L[1] = Mpy_32_16_1( DFT_L[1], INV_SQRT2_FX_Q15 ); /* qDFT */ move32(); DFT_R[1] = Mpy_32_16_1( DFT_R[1], INV_SQRT2_FX_Q15 ); /* qDFT */ @@ -2616,34 +2600,20 @@ void stereo_dft_dec_fx( q_cna_level = sub( Q31, add( q_cna_level, Q16 ) ); /* generate comfort noise from gaussian noise and add to the decoded DFT spectrum */ -#ifdef OPT_STEREO_32KBPS_V1 Word16 shift = sub( q_cna_level, hStereoDft->q_dft ); -#endif /* OPT_STEREO_32KBPS_V1 */ N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ -#ifdef OPT_STEREO_32KBPS_V1 l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); -#ifdef OPT_STEREO_32KBPS_V1 l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ DFT_R[2 * i] = L_add_sat( DFT_R[2 * i], l_tmp ); /* q_dft */ -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ move32(); N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ -#ifdef OPT_STEREO_32KBPS_V1 l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ @@ -2652,16 +2622,6 @@ void stereo_dft_dec_fx( l_tmp = L_shr( l_tmp, shift ); /* q_dft */ DFT_R[2 * i + 1] = L_add_sat( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ - move32(); - l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */ - DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } @@ -2749,12 +2709,7 @@ static void stereo_dft_compute_td_stefi_params_fx( return; } -#ifdef OPT_STEREO_32KBPS_V1 bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - bin0 = extract_l( L_shr_r( Mpy_32_16_1( (Word32) hStereoDft->NFFT, samp_ratio ), 1 ) ); /* Q0 */ - bin0 = shl( bin0, Q3 ); -#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; /* Q0 */ move16(); @@ -2919,11 +2874,7 @@ static void stereo_dft_dequantize_ipd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ -#ifdef OPT_STEREO_32KBPS_V1 const Word16 samp_ratio, /* i : sampling ratio Q15*/ -#else /* OPT_STEREO_32KBPS_V1 */ - const Word16 samp_ratio, /* i : sampling ratio Q13*/ -#endif /* OPT_STEREO_32KBPS_V1 */ Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ Word32 *pPredGain, /* i : residual prediction gains Q31*/ @@ -2941,9 +2892,6 @@ void stereo_dft_generate_res_pred_fx( /* variables for enhanced stereo filling */ Word16 norm_fac, q_norm_fac; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 lim_norm_fac; -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 q_sqrt; Word16 alpha; // gain_limit; @@ -2957,12 +2905,7 @@ void stereo_dft_generate_res_pred_fx( Word32 pred_gain_avg; Word32 g2; Word16 nbands_respred; -#ifdef OPT_STEREO_32KBPS_V1 Word16 q_new, diff; -#else /* OPT_STEREO_32KBPS_V1 */ - q_norm_fac = 0; - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ Word16 len; push_wmops( "gen_respred" ); @@ -2985,12 +2928,7 @@ void stereo_dft_generate_res_pred_fx( /* In ACELP mode the downmix signal is not available in bandwidth extension area. * * Therefore, the downmix energy in the corresponding subbands is estimated. */ -#ifdef OPT_STEREO_32KBPS_V1 bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - bin0 = (Word16) ( L_shr( L_add( L_mult0( hStereoDft->NFFT, samp_ratio ), ONE_IN_Q12 ), Q12 + 1 ) ); /* Q0 */ - move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */ b = hStereoDft->nbands; move16(); @@ -3035,22 +2973,12 @@ void stereo_dft_generate_res_pred_fx( len = s_min( hStereoDft->band_limits[b + 1], bin0 ); FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ rev_nrg_64bit = W_mac_32_32( W_mac_32_32( rev_nrg_64bit, ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */ -#else /* OPT_STEREO_32KBPS_V1 */ - dmx_nrg_64bit = W_add( dmx_nrg_64bit, - W_add( W_mult0_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), - W_mult0_32_32( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ - rev_nrg_64bit = W_add( rev_nrg_64bit, - W_add( W_mult0_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ), - W_mult0_32_32( ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */ -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifdef OPT_STEREO_32KBPS_V1 q_new = add( shl( hStereoDft->q_dft, 1 ), 1 ); q_shift = W_norm( dmx_nrg_64bit ); dmx_nrg = W_shl_sat_l( dmx_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) @@ -3059,54 +2987,26 @@ void stereo_dft_generate_res_pred_fx( rev_nrg = W_shl_sat_l( rev_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32) rev_nrg_q = add( q_new, sub( q_shift, 32 ) ); move16(); -#else /* OPT_STEREO_32KBPS_V1 */ - q_shift = W_norm( dmx_nrg_64bit ); - dmx_nrg = W_extract_l( W_shl( dmx_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) - dmx_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); - q_shift = W_norm( rev_nrg_64bit ); - rev_nrg = W_extract_l( W_shl( rev_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32) - rev_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ /* Reach a common Q for dmx_nrg and rev_nrg */ q_com = s_min( dmx_nrg_q, rev_nrg_q ); dmx_nrg = L_shl( dmx_nrg, sub( q_com, dmx_nrg_q ) ); /* q_com */ rev_nrg = L_shl( rev_nrg, sub( q_com, rev_nrg_q ) ); /* q_com */ -#ifdef OPT_STEREO_32KBPS_V1 diff = sub( hStereoDft->q_smoothed_nrg, q_com ); IF( diff < 0 ) -#else /* OPT_STEREO_32KBPS_V1 */ - IF( LT_16( hStereoDft->q_smoothed_nrg, q_com ) ) -#endif /* OPT_STEREO_32KBPS_V1 */ { -#ifdef OPT_STEREO_32KBPS_V1 rev_nrg = L_shl( rev_nrg, shl( diff, 1 ) ); dmx_nrg = L_shl( dmx_nrg, shl( diff, 1 ) ); -#else /* OPT_STEREO_32KBPS_V1 */ - rev_nrg = L_shr( rev_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); - dmx_nrg = L_shr( dmx_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) ); -#endif /* OPT_STEREO_32KBPS_V1 */ q_com = hStereoDft->q_smoothed_nrg; move16(); } -#ifdef OPT_STEREO_32KBPS_V1 ELSE -#else /* OPT_STEREO_32KBPS_V1 */ - ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, q_com ) ) -#endif /* OPT_STEREO_32KBPS_V1 */ { -#ifdef OPT_STEREO_32KBPS_V1 hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ - move32(); - hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ q_smoothed_nrg_local[b] = q_com; move16(); } @@ -3116,15 +3016,12 @@ void stereo_dft_generate_res_pred_fx( hStereoDft->smooth_dmx_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_dmx_nrg_fx[b], alpha ), dmx_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); /* hStereoDft->q_smoothed_nrg */ move32(); -#ifdef OPT_STEREO_32KBPS_V1 // Compute norm_fac in Q14 norm_fac = MAX_16; move16(); -#endif /* OPT_STEREO_32KBPS_V1 */ /* normalization factor */ IF( hStereoDft->smooth_res_nrg_fx[b] != 0 ) { -#ifdef OPT_STEREO_32KBPS_V1 norm_fac = 0; move16(); IF( hStereoDft->smooth_dmx_nrg_fx[b] != 0 ) @@ -3147,88 +3044,15 @@ void stereo_dft_generate_res_pred_fx( norm_fac = extract_h( prod ); } -#else /* OPT_STEREO_32KBPS_V1 */ - norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */ - norm_fac = Sqrt16( norm_fac, &q_norm_fac ); - IF( norm_fac != 0 ) - { - /* gain compressor */ - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - IF( LE_16( q_norm_fac, -Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && GT_16( (Word16) 0x3333, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) ) - { - lim_norm_fac = (Word16) 0x5000; - move16(); - } - ELSE IF( GT_16( q_norm_fac, Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && LT_16( (Word16) 0x5000, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) ) - { - lim_norm_fac = (Word16) 0x3333; - move16(); - } - ELSE - { - lim_norm_fac = norm_fac; - move16(); - } - IF( EQ_16( lim_norm_fac, norm_fac ) ) - { - norm_fac = ONE_IN_Q14; - move16(); - q_norm_fac = Q1; - move16(); - } - ELSE - { - norm_fac = extract_l( L_shr( L_mult0( norm_fac, lim_norm_fac ), Q15 ) ); /* q_norm_fac */ - q_norm_fac = add( q_norm_fac, 1 ); - test(); - IF( q_norm_fac < 0 ) - { - norm_fac = shl( norm_fac, q_norm_fac ); - q_norm_fac = 0; - move16(); - } - ELSE IF( GT_16( q_norm_fac, 2 ) && LT_16( norm_s( norm_fac ), sub( q_norm_fac, Q1 ) ) ) - { - norm_fac = MAX_16; - move16(); - q_norm_fac = Q1; - move16(); - } - } - } -#endif /* OPT_STEREO_32KBPS_V1 */ } -#ifndef OPT_STEREO_32KBPS_V1 - ELSE - { - norm_fac = MAX_16; - move16(); - q_norm_fac = Q1; - move16(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ len = s_min( hStereoDft->band_limits[b + 1], bin0 ); FOR( i = hStereoDft->band_limits[b]; i < len; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */ move32(); DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), 1 ); /* q_dft */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac ); /* q_dft */ - move32(); - DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac ); /* q_dft */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 772eb2d7d..af31aea40 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -904,9 +904,7 @@ void stereo_icBWE_dec_fx( winSlope_fx = div_s( 1, winLen_fx ); /* Q15 */ alpha_fx = winSlope_fx; /* Q15 */ move16(); -#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx Word16 winSlope_fx_ = sub( 32767 /* 1.0 in Q15*/, winSlope_fx ); -#endif FOR( i = 0; i < winLen_fx; i++ ) { L_tmp = L_mult0( alpha_fx, icbweM2Ref_fx ); /* Q29 */ @@ -914,17 +912,10 @@ void stereo_icBWE_dec_fx( tmp = shl( round_fx( L_tmp ), 1 ); /* Q14 */ synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn - 1 */ move32(); -#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx if ( LE_16( alpha_fx, winSlope_fx_ ) ) { alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ } -#else - IF( LE_16( alpha_fx, sub( 32767 /* 1.0 in Q15*/, winSlope_fx ) ) ) - { - alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */ - } -#endif } FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ ) diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 522e741e8..b72a23f63 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -2306,19 +2306,10 @@ static Word32 ncross_corr_self_fx( Word64 c_c_fx; Word32 c_c_fx_return; Word64 energy_x_fx, energy_y_fx; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 c_c_fx_q; - Word64 energy_xy_fx; -#endif /* OPT_STEREO_32KBPS_V1 */ UWord16 j; Word32 *signal_a_fx, *signal_b_fx; Word32 temp_x, temp_y; Word16 headroom_left_x, headroom_left_y; -#ifndef OPT_STEREO_32KBPS_V1 - Word16 x_inv_q, y_inv_q; - Word16 x_q, y_q; - Word16 res_q; -#endif /* OPT_STEREO_32KBPS_V1 */ c_c_fx = 0; move64(); energy_x_fx = 0; @@ -2329,20 +2320,13 @@ static Word32 ncross_corr_self_fx( signal_b_fx = &signal_fx[y]; /* Q11 */ FOR( j = 0; j < corr_len; j += subsampling ) { -#ifdef OPT_STEREO_32KBPS_V1 c_c_fx = W_mac_32_32( c_c_fx, signal_a_fx[j], signal_b_fx[j] ); /* 2 * Q11 + 1*/ energy_x_fx = W_mac_32_32( energy_x_fx, signal_a_fx[j], signal_a_fx[j] ); /* 2 * Q11+ 1 */ energy_y_fx = W_mac_32_32( energy_y_fx, signal_b_fx[j], signal_b_fx[j] ); /* 2 * Q11+ 1 */ -#else /* OPT_STEREO_32KBPS_V1 */ - c_c_fx = W_add( c_c_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ - energy_x_fx = W_add( energy_x_fx, W_mult0_32_32( ( signal_a_fx[j] ), ( signal_a_fx[j] ) ) ); /* 2 * Q11 */ - energy_y_fx = W_add( energy_y_fx, W_mult0_32_32( ( signal_b_fx[j] ), ( signal_b_fx[j] ) ) ); /* 2 * Q11 */ -#endif /* OPT_STEREO_32KBPS_V1 */ } headroom_left_x = W_norm( energy_x_fx ); headroom_left_y = W_norm( energy_y_fx ); -#ifdef OPT_STEREO_32KBPS_V1 temp_x = W_extract_h( W_shl( energy_x_fx, headroom_left_x ) ); // Q23 + headroom_left_x -32 temp_y = W_extract_h( W_shl( energy_y_fx, headroom_left_y ) ); // Q23 + headroom_left_y -32 Word64 prod = W_mult0_32_32( temp_x, temp_y ); // Q(headroom_left_x + headroom_left_y - 18) @@ -2365,79 +2349,6 @@ static Word32 ncross_corr_self_fx( quo_e = add( sub( sub( 40, q_cc ), q_prod ), quo_e ); c_c_fx_return = L_shl_sat( num, quo_e ); // Q31 } -#else /* OPT_STEREO_32KBPS_V1 */ - IF( LT_16( headroom_left_x, 32 ) ) - { - energy_x_fx = W_shr( energy_x_fx, sub( 32, headroom_left_x ) ); /* 2 * Q11 - (32 -headroom_left_x) */ - x_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), sub( 32, headroom_left_x ) ) ) ); - } - ELSE - { - x_q = 31 - ( 2 * OUTPUT_Q ); - } - IF( LT_16( headroom_left_y, 32 ) ) - { - energy_y_fx = W_shr( energy_y_fx, sub( 32, headroom_left_y ) ); /* 2 * Q11 - (32 -headroom_left_y) */ - y_q = sub( 31, ( sub( ( 2 * OUTPUT_Q ), ( sub( 32, headroom_left_y ) ) ) ) ); - } - ELSE - { - y_q = 31 - ( 2 * OUTPUT_Q ); - } - - x_inv_q = x_q; - move16(); - y_inv_q = y_q; - move16(); - - temp_x = Sqrt32( W_extract_l( energy_x_fx ), &x_q ); - IF( x_q < 0 ) - { - temp_x = L_shr( temp_x, i_mult( -1, x_q ) ); /* Q0 */ - x_q = 0; - move16(); - } - - temp_y = Sqrt32( W_extract_l( energy_y_fx ), &y_q ); - IF( y_q < 0 ) - { - temp_y = L_shr( temp_y, i_mult( -1, y_q ) ); /* Q0 */ - y_q = 0; - move16(); - } - - energy_xy_fx = Mpy_32_32( temp_x, temp_y ); /* x_q + y_q - 31 */ - res_q = add( y_q, x_q ); - - IF( ( energy_xy_fx < L_shr( ONE_IN_Q31, res_q ) ) || energy_xy_fx == 0 ) - { - energy_xy_fx = ONE_IN_Q31; /* conceal silent frames */ - res_q = 0; - c_c_fx = W_shl( c_c_fx, 31 - ( 2 * OUTPUT_Q ) ); /* Q31 */ - } - ELSE - { - Word32 temp_x_inv = ISqrt32( W_extract_l( energy_x_fx ), &x_inv_q ); - Word32 temp_y_inv = ISqrt32( W_extract_l( energy_y_fx ), &y_inv_q ); - Word16 headroom_left_c_c; - energy_xy_fx = Mpy_32_32( temp_x_inv, temp_y_inv ); /* exp(x_inv_q + y_inv_q) */ - res_q = add( x_inv_q, y_inv_q ); - headroom_left_c_c = W_norm( c_c_fx ); - c_c_fx_q = OUTPUT_Q * 2; - move16(); - IF( LT_16( headroom_left_c_c, 32 ) ) - { - c_c_fx = W_shr( c_c_fx, extract_l( sub( 32, headroom_left_c_c ) ) ); /* c_c_fx_q - (32 - headroom_left_c_c) */ - c_c_fx_q = sub( c_c_fx_q, sub( 32, headroom_left_c_c ) ); - } - c_c_fx = W_deposit32_l( Mpy_32_32( W_extract_l( c_c_fx ), W_extract_l( energy_xy_fx ) ) ); /* c_c_fx_q + (31 - res_q) - 31 */ - c_c_fx_q = add( c_c_fx_q, sub( sub( 31, res_q ), 31 ) ); - c_c_fx = W_extract_l( W_shl_sat_l( c_c_fx, extract_l( sub( 31, c_c_fx_q ) ) ) ); /* Q31 */ - } - - c_c_fx_return = W_extract_l( c_c_fx ); /* Q31 */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ return c_c_fx_return; } diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index 023c9a2e5..6209d5684 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -355,26 +355,16 @@ void tdm_upmix_plain_fx( { FOR( i = start_index; i < end_index; i++ ) { -#ifdef OPT_STEREO_32KBPS_V1 Word32 temp_left = Madd_32_32( SCh_2_R_fx[i], L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ Left_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_left, inv_den_LR_ratio_fx ), -30 ); /* Qx */ move32(); Word32 temp_right = Msub_32_32( PCh_2_L_fx[i], L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ); /* Qx */ Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx ), -30 ); /* Qx */ move32(); -#else /* OPT_STEREO_32KBPS_V1 */ - Word32 temp_left = L_add( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ - Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - Word32 temp_right = L_add( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), L_negate( LR_ratio_fx ) ), PCh_2_L_fx[i] ); /* Qx */ - Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); -#endif /* OPT_STEREO_32KBPS_V1 */ } } ELSE { -#ifdef OPT_STEREO_32KBPS_V1 Word32 inv_den_LR_ratio_fx_neg = L_negate( inv_den_LR_ratio_fx ); FOR( i = start_index; i < end_index; i++ ) { @@ -385,17 +375,6 @@ void tdm_upmix_plain_fx( Right_fx[i] = W_shl_sat_l( W_mult0_32_32( temp_right, inv_den_LR_ratio_fx_neg ), -30 ); /* Qx */ move32(); } -#else /* OPT_STEREO_32KBPS_V1 */ - FOR( i = start_index; i < end_index; i++ ) - { - Word32 temp_left = L_sub( Mpy_32_32( L_add( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), SCh_2_R_fx[i] ); /* Qx */ - Left_fx[i] = L_shl_sat( Mpy_32_32( temp_left, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - Word32 temp_right = L_sub( Mpy_32_32( L_sub( PCh_2_L_fx[i], SCh_2_R_fx[i] ), LR_ratio_fx ), PCh_2_L_fx[i] ); /* Qx */ - Right_fx[i] = L_shl_sat( Mpy_32_32( temp_right, inv_den_LR_ratio_fx ), 1 ); /* Qx + 1 */ - move32(); - } -#endif /* OPT_STEREO_32KBPS_V1 */ } return; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 1234e2853..73d8ef11c 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4663,10 +4663,8 @@ void fb_tbe_dec_fx( /* FB TBE synthesis */ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , st->element_mode -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ ); /* add the fb_synth component to the hb_synth component */ @@ -4737,10 +4735,8 @@ void fb_tbe_dec_ivas_fx( /* FB TBE synthesis */ synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 , st->element_mode -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ ); test(); @@ -7045,23 +7041,12 @@ void ivas_swb_tbe_dec_fx( tmp1 = 0; move16(); -#ifdef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx Word32 idx32 = L_shr_r( 0x00333333, 10 ); /*NUM_SHB_SUBFR/L_FRAME16k*/ // Q16 -#endif FOR( i = 0; i < L_FRAME16k; i++ ) { -#ifndef FIX_1439_SPEEDUP_ivas_swb_tbe_dec_fx - Word16 idx = 0; - move16(); - IF( i != 0 ) - { - idx = idiv1616( i_mult( NUM_SHB_SUBFR, i ), L_FRAME16k ); - } -#else Word16 idx; idx = extract_h( imult3216( idx32, i ) ); /*Q0*/ -#endif L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ move16(); diff --git a/lib_enc/acelp_core_switch_enc_fx.c b/lib_enc/acelp_core_switch_enc_fx.c index aaaf08b26..8db68e089 100644 --- a/lib_enc/acelp_core_switch_enc_fx.c +++ b/lib_enc/acelp_core_switch_enc_fx.c @@ -46,10 +46,8 @@ void acelp_core_switch_enc_fx( Word16 Aq[2 * ( M + 1 )]; LPD_state_HANDLE hLPDmem; /* ACELP LPDmem memories */ BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef HARM_PUSH_BIT UWord16 value; Word16 nb_bits; -#endif hLPDmem = st_fx->hLPDmem; /* initializations */ @@ -140,7 +138,6 @@ void acelp_core_switch_enc_fx( encod_gen_voic_core_switch_fx( st_fx, st_fx->last_L_frame, inp, Aq, A, T_op, exc, cbrate, shift, Q_new ); -#ifdef HARM_PUSH_BIT i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); #ifdef DEBUGGING assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); @@ -151,20 +148,6 @@ void acelp_core_switch_enc_fx( i++; } delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); -#else - /*----------------------------------------------------------------* - * bit-stream: modify the layer of sub frame CELP - *----------------------------------------------------------------*/ - FOR( i = 0; i < 20; i++ ) - { - hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; /* Q0 */ - move16(); - hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; /* Q0 */ - move16(); - hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; /* Q0 */ - move16(); - } -#endif /*----------------------------------------------------------------* * BWE encoding *----------------------------------------------------------------*/ diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 9dea812a6..6dc3963f8 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -2455,12 +2455,7 @@ static void shb_CNG_encod_fx( push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener_fx, 4 ); push_indice( hBstr, IND_SID_BW, 1, 1 ); -#ifdef HARM_PUSH_BIT delete_indice( hBstr, IND_CNG_ENV1 ); -#else - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_CNG_ENV1].nb_bits ); - hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; -#endif move16(); move16(); diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 7966fc7d8..247dcbda3 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -838,11 +838,7 @@ void dtx_fx( /* reset the bitstream (IVAS format signalling was already written) */ IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL ) { -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( st_fx->hBstr, st_fx->hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); -#endif } } diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index da3555cdb..fc1f3e993 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -522,12 +522,10 @@ void encod_gen_voic_ivas_fx( set16_fx( code_preQ_fx, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef TEST_HR if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { shift_wsp = sub( shift_wsp, 1 ); } -#endif /* set and write harmonicity flag */ harm_flag_acelp = 0; move16(); @@ -630,33 +628,18 @@ void encod_gen_voic_ivas_fx( IF( LE_32( st_fx->core_brate, ACELP_8k00 ) ) { -#ifdef TEST_HR gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); -#else - gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR ); -#endif } ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { -#ifdef TEST_HR gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp ); -#else - gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) ); -#endif } ELSE { -#ifdef TEST_HR gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp, y2_fx, code_fx, Es_pred_fx, &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); -#else - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx, - &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx ); -#endif } IF( st_fx->Opt_SC_VBR ) { diff --git a/lib_enc/enc_ppp_fx.c b/lib_enc/enc_ppp_fx.c index 9d1ffad60..fca36f460 100644 --- a/lib_enc/enc_ppp_fx.c +++ b/lib_enc/enc_ppp_fx.c @@ -189,11 +189,7 @@ ivas_error encod_ppp_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); -#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } @@ -376,11 +372,7 @@ ivas_error encod_ppp_ivas_fx( /* We write signalling indices again only in case of bump_up */ /* delete previous indices */ -#ifdef HARM_PUSH_BIT reset_indices_enc_fx( hBstr, hBstr->nb_ind_tot ); -#else - reset_indices_enc_fx( hBstr, MAX_NUM_INDICES ); -#endif /* signalling matrix (writing of signalling bits) */ signalling_enc_fx( st_fx ); } diff --git a/lib_enc/enc_tran_fx.c b/lib_enc/enc_tran_fx.c index 9802dc15b..fb601aeba 100644 --- a/lib_enc/enc_tran_fx.c +++ b/lib_enc/enc_tran_fx.c @@ -520,12 +520,10 @@ Word16 encod_tran_ivas_fx( move16(); set16_fx( code_preQ, 0, L_SUBFR ); shift_wsp = add( Q_new, shift ); -#ifdef TEST_HR if ( LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { shift_wsp = sub( shift_wsp, 1 ); } -#endif /*----------------------------------------------------------------* * ACELP subframe loop *----------------------------------------------------------------*/ @@ -546,11 +544,7 @@ Word16 encod_tran_ivas_fx( q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/ -#ifdef TEST_HR Scale_sig( h1, L_SUBFR, sub( 14, q_h1 ) ); -#else - Scale_sig( h1, L_SUBFR, sub( 13, q_h1 ) ); -#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_SUBFR, shift ); @@ -569,9 +563,6 @@ Word16 encod_tran_ivas_fx( IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) ) { -#ifndef TEST_HR - Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ -#endif transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx, &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift ); } @@ -599,37 +590,22 @@ Word16 encod_tran_ivas_fx( IF( Jopt_flag == 0 ) { /* SQ gain_code */ -#ifdef TEST_HR gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, shift_wsp ); -#else - gain_enc_tc_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, sub( shift_wsp, 1 ) ); -#endif } ELSE { IF( GT_32( st_fx->core_brate, ACELP_32k ) ) { /* SQ gain_pit and gain_code */ -#ifdef TEST_HR gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, shift_wsp ); -#else - gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr, xn, y1, y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain, sub( shift_wsp, 1 ) ); -#endif } ELSE { /* VQ gain_pit and gain_code */ -#ifdef TEST_HR gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, shift_wsp, y2, code, Es_pred_fx, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); -#else - gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame_fx, i_subfr, tc_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred_fx, - &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); -#endif } } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 5e1c8dfe3..ce7f05968 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -379,7 +379,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k ); -#ifdef HARM_PUSH_BIT /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) { @@ -387,26 +386,6 @@ Word16 Pit_exc_contribution_len_fx( /* o : bin where pit } delete_indice( hBstr, IND_ES_PRED ); -#else - /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ - FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) - { - IF( hBstr->ind_list[i].nb_bits != -1 ) - { - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[i].nb_bits ); /* Q0 */ - hBstr->ind_list[i].nb_bits = -1; - move16(); - } - } - - IF( hBstr->ind_list[IND_ES_PRED].nb_bits != -1 ) - { - hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, hBstr->ind_list[IND_ES_PRED].nb_bits ); /* Q0 */ - move16(); - hBstr->ind_list[IND_ES_PRED].nb_bits = -1; - move16(); - } -#endif } IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 70b5166df..fe1ba10c1 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -2367,65 +2367,6 @@ void IGFEncSetMode_ivas_fx( * * IGF bitstream concatenation for TCX10 modes *-------------------------------------------------------------------*/ -#ifndef HARM_PUSH_BIT /* Float code */ -void IGFEncConcatenateBitstream( - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : instance handle of IGF Encoder */ - const Word16 bsBits, /* i : number of IGF bits written to list of indices */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -) -{ - Word16 i; - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - Indice *ind_list; - UWord8 *pFrame; /* byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size; /* number of bits in the binary encoded access unit [bits] */ - Word16 k, nb_bits_written; - Word32 imask; - UWord8 omask; - - hPrivateData = &hIGFEnc->igfData; - - ind_list = &hBstr->ind_list[sub( hBstr->nb_ind_tot, bsBits )]; /* here, we assume that each bit has been written as a single indice */ - pFrame = hPrivateData->igfBitstream; - pFrame_size = &hPrivateData->igfBitstreamBits; - nb_bits_written = 0; - move16(); - - omask = (UWord8) shr( 0x80, s_and( *pFrame_size, 0x7 ) ); - pFrame += shr( *pFrame_size, 3 ); - - /* bitstream packing (conversion of individual indices into a serial stream) */ - FOR( i = 0; i < bsBits; i++ ){ - IF( ind_list[i].nb_bits > 0 ){ - /* mask from MSB to LSB */ - imask = L_shl( 1, ( sub( ind_list[i].nb_bits, 1 ) ) ); - - /* write bit by bit */ - FOR( k = 0; k < ind_list[i].nb_bits; k++ ) - { - pack_bit( ind_list[i].value & imask, &pFrame, &omask ); - imask = L_shr( imask, 1 ); - } - nb_bits_written = add( nb_bits_written, ind_list[i].nb_bits ); - - /* delete the indice */ - ind_list[i].nb_bits = -1; - move16(); -} -} - -*pFrame_size = add( *pFrame_size, nb_bits_written ); -move16(); - -/* update list of indices */ -hBstr->nb_ind_tot = sub( hBstr->nb_ind_tot, bsBits ); -hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, nb_bits_written ); -move16(); -move16(); - -return; -} -#endif /*-------------------------------------------------------------------* * IGFEncResetTCX10BitCounter_ivas_fx() diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index a7b5eabb3..e0562467a 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -1627,33 +1627,6 @@ hBstr->nb_bits_tot = sub( hBstr->nb_bits_tot, nb_bits_written ); return; } -#ifndef HARM_PUSH_BIT /* old bitstream */ -/**********************************************************************/ /* - IGF bitsream concatenation for TCX10 modes - **************************************************************************/ -void IGFEncConcatenateBitstream_fx( const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */ - Word16 bsBits, /**< in: Q0 | number of IGF bits written to list of indices */ - Word16 *next_ind, /**< in/out: | pointer to actual bit indice */ - Word16 *nb_bits, /**< in/out: | total number of bits already written */ - Indice *ind_list_fx /**< in: | pointer to list of indices */ -) -{ - IGF_ENC_PRIVATE_DATA_HANDLE hPrivateData; - - hPrivateData = &hInstance->igfData; - *next_ind = *next_ind - bsBits; - move16(); - indices_to_serial_generic( - &ind_list_fx[*next_ind], - bsBits, - hPrivateData->igfBitstream, - &hPrivateData->igfBitstreamBits ); - - *nb_bits = sub( *nb_bits, bsBits ); - move16(); - return; -} -#endif /**********************************************************************/ /* IGF reset bitsream bit counter for TCX10 modes **************************************************************************/ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index ba1d47f79..9e3045be1 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -2163,13 +2163,9 @@ ivas_error init_encoder_ivas_fx( } ELSE { -#ifndef HARM_ENC_INIT - InitTransientDetection_ivas_fx( frame_length, NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 ); -#else InitTransientDetection_fx( extract_l( Mult_32_16( st->input_Fs, 0x0290 ) ), NS2SA_FX2( st->input_Fs, DELAY_FIR_RESAMPL_NS ), &st->transientDetection ); -#endif } /*-----------------------------------------------------------------* diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 7d88b1264..2285acc0c 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -272,59 +272,6 @@ Word16 getNumChanAnalysis_fx( return n; } -#ifndef HARM_ENC_INIT -/*-------------------------------------------------------------------* - * copy_encoder_config_ivas_fx() - * - * Copy configuration structrue to the state structrure - *-------------------------------------------------------------------*/ - -void copy_encoder_config_ivas_fx( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - Encoder_State *st, /* o : encoder state structure */ - const Word16 flag_all /* i : flag 1==update all, 0=partial update Q0*/ -) -{ - IF( flag_all ) - { - st->input_Fs = st_ivas->hEncoderConfig->input_Fs; /* Q0 */ - move32(); - - st->last_codec_mode = st_ivas->last_codec_mode; /* Q0 */ - move16(); - st->last_total_brate = st_ivas->hEncoderConfig->last_ivas_total_brate; /* Q0 */ - move32(); - - st->Opt_DTX_ON = st_ivas->hEncoderConfig->Opt_DTX_ON; /* Q0 */ - move16(); - - st->last_Opt_SC_VBR = st_ivas->hEncoderConfig->last_Opt_SC_VBR; /* Q0 */ - move16(); - } - - st->Opt_AMR_WB = st_ivas->hEncoderConfig->Opt_AMR_WB; /* Q0 */ - st->Opt_SC_VBR = st_ivas->hEncoderConfig->Opt_SC_VBR; /* Q0 */ - move16(); - move16(); - - st->codec_mode = st_ivas->codec_mode; /* Q0 */ - st->max_bwidth = st_ivas->hEncoderConfig->max_bwidth; /* Q0 */ - move16(); - move16(); - - st->Opt_RF_ON = st_ivas->hEncoderConfig->Opt_RF_ON; /* Q0 */ - st->rf_fec_offset = st_ivas->hEncoderConfig->rf_fec_offset; /* Q0 */ - st->rf_fec_indicator = st_ivas->hEncoderConfig->rf_fec_indicator; /* Q0 */ - move16(); - move16(); - move16(); - - st->element_mode = st_ivas->hEncoderConfig->element_mode_init; /* Q0 */ - move16(); - - return; -} -#endif /*-------------------------------------------------------------------* * copy_encoder_config_fx() * @@ -467,617 +414,6 @@ void ivas_initialize_handles_enc_fx( * * Initialize IVAS encoder state structure *-------------------------------------------------------------------*/ -#ifndef HARM_ENC_INIT -ivas_error ivas_init_encoder( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -) -{ - Word16 i, n; - Word16 nchan_inp_buff; - Word16 sce_id, cpe_id; - IVAS_FORMAT ivas_format; - Word32 input_Fs, ivas_total_brate; - Word32 element_brate_tmp[MAX_NUM_OBJECTS]; - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - - error = IVAS_ERR_OK; - - hEncoderConfig = st_ivas->hEncoderConfig; - ivas_format = hEncoderConfig->ivas_format; - input_Fs = hEncoderConfig->input_Fs; /* Q0 */ - ivas_total_brate = hEncoderConfig->ivas_total_brate; /* Q0 */ - move32(); - move32(); - - hEncoderConfig->last_ivas_total_brate = ivas_total_brate; /* Q0 */ - move32(); - - if ( NE_32( ivas_format, MONO_FORMAT ) ) - { - /* In IVAS, ensure that minimum coded bandwidth is WB */ - hEncoderConfig->max_bwidth = s_max( hEncoderConfig->max_bwidth, WB ); /* Q0 */ - move16(); - } - st_ivas->ism_mode = ISM_MODE_NONE; - st_ivas->mc_mode = MC_MODE_NONE; - move32(); - move32(); - - st_ivas->nchan_transport = -1; - move16(); - - /*-----------------------------------------------------------------* - * Allocate floating-point input audio buffers - *-----------------------------------------------------------------*/ - - nchan_inp_buff = hEncoderConfig->nchan_inp; /* Q0 */ - move16(); - - IF( EQ_32( ivas_format, MONO_FORMAT ) ) - { - nchan_inp_buff = 0; - move16(); - } - ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) - { - if ( EQ_32( sub( hEncoderConfig->nchan_inp, hEncoderConfig->nchan_ism ), 1 ) ) /* mono is duplicated in monoMASA */ - { - nchan_inp_buff = add( nchan_inp_buff, 1 ); - } - - nchan_inp_buff = add( nchan_inp_buff, 1 ); /* for *data_separated_object */ - } - - FOR( n = 0; n < nchan_inp_buff; n++ ) - { - /* note: these are intra-frame heap memories */ - IF( ( st_ivas->p_data_fx[n] = (Word32 *) malloc( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point input audio buffer!\n" ) ); - } - set32_fx( st_ivas->p_data_fx[n], 0, extract_l( Mpy_32_16_1( input_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); - } - st_ivas->q_data_fx = Q11; - move16(); - FOR( ; n < MAX_INPUT_CHANNELS + MAX_NUM_OBJECTS; n++ ) - { - st_ivas->p_data_fx[n] = NULL; - } - /*-----------------------------------------------------------------* - * Allocate and initialize buffer of indices - *-----------------------------------------------------------------*/ - - /* set the maximum allowed number of indices in the list */ - st_ivas->ivas_max_num_indices = get_ivas_max_num_indices_fx( ivas_format, ivas_total_brate ); /* Q0 */ - move16(); - - /* allocate buffer of indices */ - IF( ( st_ivas->ind_list = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices * sizeof( Indice ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) ); - } - - /* reset the list of indices */ - for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) - { - st_ivas->ind_list[i].nb_bits = -1; - move16(); - } - - /* set the maximum allowed number of metadata indices in the list */ - st_ivas->ivas_max_num_indices_metadata = get_ivas_max_num_indices_metadata_fx( st_ivas->hEncoderConfig->ivas_format, st_ivas->hEncoderConfig->ivas_total_brate ); /* Q0 */ - move16(); - - /* allocate buffer of metadata indices */ - IF( st_ivas->ivas_max_num_indices_metadata > 0 ) - { - IF( ( st_ivas->ind_list_metadata = (INDICE_HANDLE) malloc( st_ivas->ivas_max_num_indices_metadata * sizeof( Indice ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of metadata indices!\n" ) ); - } - - /* reset the list of metadata indices */ - for ( i = 0; i < st_ivas->ivas_max_num_indices_metadata; i++ ) - { - st_ivas->ind_list_metadata[i].nb_bits = -1; - move16(); - } - } - ELSE - { - st_ivas->ind_list_metadata = NULL; - } - - /*-----------------------------------------------------------------* - * Allocate and initialize SCE/CPE and other handles - *-----------------------------------------------------------------*/ - - IF( EQ_32( ivas_format, MONO_FORMAT ) ) - { - st_ivas->nSCE = 1; /* in mono, there is always only one SCE */ - move16(); - st_ivas->nCPE = 0; - move16(); - st_ivas->nchan_transport = 1; - move16(); - sce_id = 0; - move16(); - - test(); - IF( st_ivas->hEncoderConfig->element_mode_init != EVS_MONO ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - IF( NE_32( ( error = create_evs_sce_enc_fx( st_ivas, sce_id, ivas_total_brate ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - - /* prepare stereo downmix for EVS */ - IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) - { - IF( ( error = stereo_dmx_evs_init_encoder_fx( &( st_ivas->hStereoDmxEVS ), input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, STEREO_FORMAT ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = 1; /* in stereo, there is always only one CPE */ - st_ivas->nchan_transport = CPE_CHANNELS; - cpe_id = 0; - move16(); - move16(); - move16(); - move16(); - - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, ISM_FORMAT ) ) - { - st_ivas->ism_mode = ivas_ism_mode_select( hEncoderConfig->nchan_inp, ivas_total_brate ); - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_inp, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, element_brate_tmp[sce_id] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) - { - IF( ( error = ivas_param_ism_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( st_ivas->hEncoderConfig->Opt_DTX_ON ) - { - IF( ( error = ivas_ism_dtx_open( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, MASA_FORMAT ) ) - { - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( ivas_format, SBA_FORMAT ) ) - { - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); /* Q0 */ - move16(); - - IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE - { - st_ivas->nchan_transport = hEncoderConfig->nchan_inp; /* Q0 */ - move16(); - - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( EQ_32( ivas_format, SBA_FORMAT ) && st_ivas->hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hSCE[sce_id]->hCoreCoder[0]->dtx_sce_sba = 1; - move16(); - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - if ( hEncoderConfig->Opt_DTX_ON ) - { - st_ivas->hCPE[cpe_id]->hCoreCoder[n]->cng_sba_flag = 1; - move16(); - } - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) ) - { - Word32 ism_total_brate; - Word16 k; - - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, hEncoderConfig->nchan_ism ); /* Q0 */ - move32(); - st_ivas->nchan_transport = 2; - move16(); - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - k = 0; - move16(); - while ( k < SIZE_IVAS_BRATE_TBL && NE_32( ivas_total_brate, ivas_brate_tbl[k] ) ) - { - k++; - } - - ism_total_brate = 0; - move32(); - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - ism_total_brate = L_add( ism_total_brate, sep_object_brate[k - 2][st_ivas->nSCE - 1] ); - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, sep_object_brate[k - 2][st_ivas->nSCE - 1] ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - IF( ( error = ivas_omasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( GE_32( L_sub( ivas_total_brate, ism_total_brate ), MIN_BRATE_MDCT_STEREO ) ) - { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - else - { - st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - } - - IF( ( error = create_cpe_enc_fx( st_ivas, 0, L_sub( ivas_total_brate, ism_total_brate ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, SBA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ISM_MODE_NONE; - - if ( GE_32( ivas_total_brate, IVAS_256k ) ) - { - st_ivas->ism_mode = ISM_SBA_MODE_DISC; - } - - IF( ( error = ivas_ism_metadata_enc_create_fx( st_ivas, hEncoderConfig->nchan_ism, element_brate_tmp ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* allocate and initialize SBA handles */ - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); - move16(); - - IF( ( error = ivas_spar_enc_open_fx( st_ivas, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_dirac_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_NONE ) ) - { - /* allocate and initialize SBA core-coders */ - IF( EQ_16( st_ivas->nchan_transport, 1 ) ) - { - IF( ( error = create_sce_enc_fx( st_ivas, 0, ivas_total_brate ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE - { - /* allocate and initialize MCT core coder */ - st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->hEncoderConfig->nchan_ism, 1 ), 1 ) ); - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nchan_transport, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - IF( ( error = ivas_osba_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( ivas_format, MC_FORMAT ) ) - { - st_ivas->mc_mode = ivas_mc_mode_select_fx( hEncoderConfig->mc_input_setup, ivas_total_brate ); /* Q0 */ - - IF( ( error = ivas_create_lfe_lpf_enc_fx( &st_ivas->hLfeLpf, hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */ - move16(); - move16(); - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, sub( hEncoderConfig->nchan_inp, 1 ), &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, imult3216( res_dec, CPE_CHANNELS ) ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - - st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( st_ivas->hEncoderConfig->mc_input_setup ); /* Q0 */ - move16(); - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) - { - st_ivas->nSCE = 0; - st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2; - st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; - move16(); - move16(); - move16(); - - IF( ( error = ivas_mc_paramupmix_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, st_ivas->nCPE, &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_create_lfe_enc_fx( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) - { - IF( ( error = ivas_param_mc_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - Word32 res_dec, res_frac; - iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nCPE, st_ivas->nSCE ), &res_dec, &res_frac, 0 ); - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, res_dec ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( ( error = create_mct_enc_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) - { - Word32 brate_sce, brate_cpe; - - ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate ); - - IF( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( ( error = ivas_masa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - IF( ( error = ivas_mcmasa_enc_open_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - ivas_mcmasa_split_brate_fx( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); - - FOR( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) - { - IF( ( error = create_sce_enc_fx( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - - IF( ( error = create_cpe_enc_fx( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK ) - { - return error; - } - } - } - } - - /*-----------------------------------------------------------------* - * Allocate and initialize HP20 filter memories - *-----------------------------------------------------------------*/ - - /* set number of input channels used for analysis/coding */ - n = getNumChanAnalysis_fx( st_ivas ); /* Q0 */ - move16(); - - IF( n > 0 ) - { - IF( ( st_ivas->mem_hp20_in_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - } - } - ELSE - { - st_ivas->mem_hp20_in_fx = NULL; - } - - FOR( i = 0; i < n; i++ ) - { - IF( ( st_ivas->mem_hp20_in_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - } - - set32_fx( st_ivas->mem_hp20_in_fx[i], 0, L_HP20_MEM + 2 ); - } - return error; -} -#endif ivas_error ivas_init_encoder_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ) diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index ac836b674..8b09f3644 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -675,15 +675,10 @@ static void ivas_param_mc_param_est_enc_fx( #endif Word32 a_fx, b_fx, c_fx, d_fx; /* Tmp complex values */ Word16 a_e, b_e, c_e, d_e; /* Tmp complex values */ -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Word64 Cy_sum_real_64[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; Word64 Cy_sum_imag_64[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; Word16 sub62gb; Word16 sub35gb; -#else - Word32 Cy_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; - Word16 Cy_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; -#endif Word32 Cx_sum_imag_fx[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 Cx_sum_imag_e[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 real_part_fx, imag_part_fx; @@ -712,7 +707,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); band_step = 1; move16(); -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) { FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) @@ -720,18 +714,12 @@ static void ivas_param_mc_param_est_enc_fx( set64_fx( Cy_sum_real_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); } } -#endif FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC; cur_param_band++ ) { FOR( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE set64_fx( Cy_sum_imag_64[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); -#else - set32_fx( Cy_sum_imag_fx[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); - set16_fx( Cy_sum_imag_e[cur_param_band][ch_idx1], 0, MAX_CICP_CHANNELS ); -#endif } FOR( ch_idx1 = 0; ch_idx1 < PARAM_MC_MAX_TRANSPORT_CHANS; ch_idx1++ ) @@ -760,23 +748,16 @@ static void ivas_param_mc_param_est_enc_fx( } } -#if defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) || defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) Word16 gb = find_guarded_bits_fx( l_ts ); #ifndef MERGE_REQUEST_1472_SPEEDUP_ivas_mc_param_enc_fx_NONBE Word16 add20gb = add( 20, gb ); #endif -#endif -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE sub35gb = sub( 32, sub( 11, find_guarded_bits_fx( l_ts ) ) ); // 31 - (((11 - gb) + 31 + norm) - 32) sub62gb = sub( 63, shl( sub( 11, find_guarded_bits_fx( l_ts ) ), 1 ) ); // 31 - ((2*(11 - gb) + norm) - 32) -#endif FOR( ts = start_ts; ts < num_time_slots; ts++ ) { -#if !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE ) && !defined( IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE ) - Word16 gb = find_guarded_bits_fx( l_ts ); -#endif ivas_fb_mixer_get_windowed_fr_fx( hParamMC->hFbMixer, pcm_in_fx, p_slot_frame_f_real_fx, p_slot_frame_f_imag_fx, l_ts, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans, gb ); ivas_fb_mixer_update_prior_input_fx( hParamMC->hFbMixer, pcm_in_fx, l_ts, hParamMC->hFbMixer->fb_cfg->num_in_chans ); @@ -822,26 +803,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); move64(); -#else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - dmx_real_fx[ch_idx1] = 0; - move32(); - dmx_real_e[ch_idx1] = 0; - move16(); - dmx_imag_fx[ch_idx1] = 0; - move32(); - dmx_imag_e[ch_idx1] = 0; - move16(); - FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) - { - L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_real_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_real_fx[ch_idx1], dmx_real_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_real_e[ch_idx1] ); - move32(); - L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_imag_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_imag_fx[ch_idx1], dmx_imag_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_imag_e[ch_idx1] ); - move32(); - p_dmx_fac_fx++; - } #else Word32 real_fx = L_add( 0, 0 ); Word16 real_e = add( 0, 0 ); @@ -863,7 +824,6 @@ static void ivas_param_mc_param_est_enc_fx( move16(); move32(); move16(); -#endif #endif } @@ -910,7 +870,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); } } -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; @@ -930,65 +889,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); } } -#else - /* Cy for input channels */ - FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) - { -#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); - a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); - a_e = sub( add20gb, a_e ); - if ( a_fx == 0 ) - { - a_e = 0; - move16(); - } - b_e = norm_l( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band] ); - b_fx = L_shl( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], b_e ); - b_e = sub( add20gb, b_e ); - if ( b_fx == 0 ) - { - b_e = 0; - move16(); - } -#endif - FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) - { -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); - b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); - c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); - d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); -#else - c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); - c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); - c_e = sub( add20gb, c_e ); - if ( c_fx == 0 ) - { - c_e = 0; - move16(); - } - d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); - d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); - d_e = sub( add20gb, d_e ); - if ( d_fx == 0 ) - { - d_e = 0; - move16(); - } -#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - L_tmp, tmp_e, &Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, d_fx ), add( a_e, d_e ), L_negate( Mpy_32_32( b_fx, c_fx ) ), add( b_e, c_e ), &tmp_e ); - Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2], - L_tmp, tmp_e, &Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - } - } -#endif } } @@ -1026,27 +926,6 @@ static void ivas_param_mc_param_est_enc_fx( dmx_imag_64[ch_idx1] = imag_64; move64(); move64(); -#else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - dmx_real_fx[ch_idx1] = 0; - move32(); - dmx_real_e[ch_idx1] = 0; - move16(); - dmx_imag_fx[ch_idx1] = 0; - move32(); - dmx_imag_e[ch_idx1] = 0; - move16(); - - FOR( inp_ch = 0; inp_ch < nchan_input; inp_ch++ ) - { - L_tmp = Mpy_32_32( slot_frame_f_real_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_real_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_real_fx[ch_idx1], dmx_real_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_real_e[ch_idx1] ); - move32(); - L_tmp = Mpy_32_32( slot_frame_f_imag_fx[inp_ch][cur_cldfb_band], ( *p_dmx_fac_fx ) ); - dmx_imag_fx[ch_idx1] = BASOP_Util_Add_Mant32Exp( dmx_imag_fx[ch_idx1], dmx_imag_e[ch_idx1], L_tmp, add( 20, gb ), &dmx_imag_e[ch_idx1] ); - move32(); - p_dmx_fac_fx++; - } #else Word32 real_fx = L_add( 0, 0 ); Word16 real_e = 0; @@ -1071,7 +950,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); dmx_imag_e[ch_idx1] = imag_e; move16(); -#endif #endif } @@ -1083,7 +961,6 @@ static void ivas_param_mc_param_est_enc_fx( CONVERT_DMX( dmx_real_64[ch_idx1], a_fx, a_e ); CONVERT_DMX( dmx_imag_64[ch_idx1], b_fx, b_e ); #else -#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE a_fx = dmx_real_fx[ch_idx1]; move32(); a_e = dmx_real_e[ch_idx1]; @@ -1092,7 +969,6 @@ static void ivas_param_mc_param_est_enc_fx( move32(); b_e = dmx_imag_e[ch_idx1]; move16(); -#endif #endif FOR( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) @@ -1106,34 +982,10 @@ static void ivas_param_mc_param_est_enc_fx( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); #else -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_BE - a_fx = dmx_real_fx[ch_idx1]; - move32(); - a_e = dmx_real_e[ch_idx1]; - move16(); - b_fx = dmx_imag_fx[ch_idx1]; - move32(); - b_e = dmx_imag_e[ch_idx1]; - move16(); - c_fx = dmx_real_fx[ch_idx2]; - move32(); - c_e = dmx_real_e[ch_idx2]; - move16(); - d_fx = dmx_imag_fx[ch_idx2]; - move32(); - d_e = dmx_imag_e[ch_idx2]; - move16(); - - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, - &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); -#else /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, dmx_real_fx[ch_idx2] ), add( a_e, dmx_real_e[ch_idx2] ), Mpy_32_32( b_fx, dmx_imag_fx[ch_idx2] ), add( b_e, dmx_imag_e[ch_idx2] ), &tmp_e ); Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cx_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cx_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, &Cx_sum_e[cur_param_band][ch_idx1][ch_idx2] ); -#endif #endif move32(); } @@ -1142,7 +994,6 @@ static void ivas_param_mc_param_est_enc_fx( /* Cy for input channels */ FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { -#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); a_e = sub( add20gb, a_e ); @@ -1159,8 +1010,6 @@ static void ivas_param_mc_param_est_enc_fx( b_e = 0; move16(); } -#endif -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; b_fx = slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band]; move32(); @@ -1176,39 +1025,6 @@ static void ivas_param_mc_param_est_enc_fx( W_add( W_mult0_32_32( a_fx, c_fx ), W_mult0_32_32( b_fx, d_fx ) ) ); move64(); } -#else - FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) - { -#ifndef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE - a_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &a_e ); - b_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band], add( 20, gb ), 0, 0, &b_e ); - c_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &c_e ); - d_fx = BASOP_Util_Add_Mant32Exp( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], add( 20, gb ), 0, 0, &d_e ); -#else - c_e = norm_l( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band] ); - c_fx = L_shl( slot_frame_f_real_fx[ch_idx2][cur_cldfb_band], c_e ); - c_e = sub( add20gb, c_e ); - if ( c_fx == 0 ) - { - c_e = 0; - move16(); - } - d_e = norm_l( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band] ); - d_fx = L_shl( slot_frame_f_imag_fx[ch_idx2][cur_cldfb_band], d_e ); - d_e = sub( add20gb, d_e ); - if ( d_fx == 0 ) - { - d_e = 0; - move16(); - } -#endif - /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ - L_tmp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, c_fx ), add( a_e, c_e ), Mpy_32_32( b_fx, d_fx ), add( b_e, d_e ), &tmp_e ); - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], L_tmp, tmp_e, - &Cy_sum_e[cur_param_band][ch_idx1][ch_idx2] ); - move32(); - } -#endif } } } @@ -1222,7 +1038,6 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move64(); Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; @@ -1231,24 +1046,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); Cy_sum_imag_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move64(); -#else - Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); - Cy_sum_imag_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_imag_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_imag_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_imag_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); -#endif } } @@ -1256,21 +1053,10 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; move64(); Cy_sum_real_64[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; move64(); -#else - Cy_sum_fx[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move32(); - Cy_sum_e[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0; - move16(); - Cy_sum_fx[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move32(); - Cy_sum_e[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0; - move16(); -#endif } } } @@ -1307,16 +1093,9 @@ static void ivas_param_mc_param_est_enc_fx( /* get ICLDs */ FOR( k = 0; k < nchan_input; ++k ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE CONVERT_CY( Cy_sum_real_64[cur_param_band][k][k], Nrg_fx[k], Nrg_e[k] ); move32(); move16(); -#else - Nrg_fx[k] = Cy_sum_fx[cur_param_band][k][k]; - move32(); - Nrg_e[k] = Cy_sum_e[cur_param_band][k][k]; - move16(); -#endif } FOR( k = 0; k < num_ilds_to_code; ++k ) { @@ -1383,22 +1162,11 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); move64(); Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] ); move64(); -#else - Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); - Cy_sum_imag_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_imag_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_imag_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); -#endif } } } @@ -1422,14 +1190,7 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_real_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_real_64[cur_param_band][ch_idx1][ch_idx2] ); -#else - Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2] = BASOP_Util_Add_Mant32Exp( Cy_sum_fx[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2], - Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2], Cy_sum_e[cur_param_band][ch_idx1][ch_idx2], - &Cy_sum_e[cur_param_band - 1][ch_idx1][ch_idx2] ); - move32(); -#endif } } } @@ -1438,7 +1199,6 @@ static void ivas_param_mc_param_est_enc_fx( band_step = 2; move16(); } -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE { // convert the 64 bit fixpoint back into the 48 bit float format FOR( cur_param_band = 0; cur_param_band < PARAM_MC_MAX_PARAMETER_BANDS; cur_param_band++ ) @@ -1454,7 +1214,6 @@ static void ivas_param_mc_param_est_enc_fx( } } } -#endif /* map complex covariances to real values */ FOR( cur_param_band = 0; cur_param_band < hParamMC->max_param_band_abs_cov; cur_param_band += band_step ) @@ -1491,16 +1250,9 @@ static void ivas_param_mc_param_est_enc_fx( { FOR( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) { -#ifdef MERGE_REQUEST_1378_SPEEDUP_ivas_mc_param_enc_fx_NONBE CONVERT_CY( Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2], imag_part_fx, imag_part_e ); move32(); move16(); -#else - imag_part_fx = Cy_sum_imag_fx[cur_param_band][ch_idx1][ch_idx2]; - move32(); - imag_part_e = Cy_sum_imag_e[cur_param_band][ch_idx1][ch_idx2]; - move16(); -#endif real_part_fx = Cy_sum_fx[cur_param_band][ch_idx1][ch_idx2]; move32(); real_part_e = Cy_sum_e[cur_param_band][ch_idx1][ch_idx2]; diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 9a7c4038b..3040bc24a 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -1073,11 +1073,7 @@ void ivas_qmetadata_enc_sid_encode_fx( /*compute the average direction */ ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[m], q_direction->band_data[b].elevation_fx[m], direction_vector_fx ); scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3 ); // Q22 -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3, 0 ); // Q22 -#endif /* VEC_ARITH_OPT_v1 */ } ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector_fx, Q22, &avg_azimuth_fx[b], &avg_elevation_fx[b] ); @@ -2421,11 +2417,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( /*compute the average direction */ ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector ); scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } } @@ -2688,11 +2680,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( IF( LT_16( idx, 4 ) ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } /* project the quantized average azimuth angle to the same grid as the current sample */ @@ -2723,11 +2711,7 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx( ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[i].azimuth_fx[j], q_direction->band_data[i].elevation_fx[j], direction_vector ); scale_sig32( direction_vector, 3, -8 ); // Q30 -> Q22 -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( avg_direction_vector, direction_vector, avg_direction_vector, 3, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( avg_direction_vector, Q22, &avg_azimuth, &avg_elevation ); avg_azimuth_index_upd = quantize_phi_enc_fx( L_add( avg_azimuth, 180 << Q22 ), 0, &avg_azimuth, avg_azimuth_alphabet ); diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index f0811aea6..879a98246 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -612,7 +612,6 @@ ivas_error create_evs_sce_enc_fx( { return error; } -#ifdef HARM_PUSH_BIT /*-----------------------------------------------------------------* * Bitstream *-----------------------------------------------------------------*/ @@ -626,11 +625,6 @@ ivas_error create_evs_sce_enc_fx( st_fx->hBstr->nb_bits_tot = 0; move16(); st_fx->hBstr->st_ivas = st_ivas; -#else - st_fx->hBstr->ind_list = ind_list; - // st_fx->hBstr->ind_list_fx = st->hBstr->ind_list; - reset_indices_enc_fx( st_fx->hBstr, MAX_NUM_INDICES ); -#endif hSCE->hCoreCoder[0] = st_fx; diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 2eaefb483..e74e2297c 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -672,11 +672,7 @@ Word16 quantize_sns_fx( Word32 ener_side_fx; Word16 ener_side_q; -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( snsQ_out_fx[0][k], snsQ_out_fx[1][k], side_fx, M, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ Word64 L64_sum; L64_sum = 1; diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index f84f90e46..f82f8ac13 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -98,10 +98,8 @@ #define STEREO_DMX_EVS_TRNS_EGY_FORGETTING_Q15 24576 -#ifdef FIX_1511_POC_RENORM #define STEREO_DMX_EVS_POC_RENORM_TH 33554432 // 65536 << 9 #define STEREO_DMX_EVS_POC_RENORM_SHIFT 3 -#endif const Word32 ipd_ff_Q31[STEREO_DMX_EVS_NB_SUBBAND_MAX] = { 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, @@ -417,7 +415,6 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -428,7 +425,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -442,7 +438,6 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -453,7 +448,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -476,7 +470,6 @@ static void calc_poc_fx( Rr = L_add( L_add( specRr[i], Mpy_32_32_r( specLr[i], eps_cos ) ), Mpy_32_32_r( specLi[i], eps_sin ) ); Ri = L_add( L_sub( specRi[i], Mpy_32_32_r( specLr[i], eps_sin ) ), Mpy_32_32_r( specLi[i], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -487,7 +480,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -500,7 +492,6 @@ static void calc_poc_fx( Rr = L_add( L_sub( specRr[j], Mpy_32_32_r( specLr[j], eps_cos ) ), Mpy_32_32_r( specLi[j], eps_sin ) ); Ri = L_sub( L_sub( specRi[j], Mpy_32_32_r( specLr[j], eps_sin ) ), Mpy_32_32_r( specLi[j], eps_cos ) ); -#ifdef FIX_1511_POC_RENORM IF( ( LT_32( L_abs( Lr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Li ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && ( LT_32( L_abs( Rr ), STEREO_DMX_EVS_POC_RENORM_TH ) ) && @@ -511,7 +502,6 @@ static void calc_poc_fx( Rr = L_shl( Rr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); Ri = L_shl( Ri, STEREO_DMX_EVS_POC_RENORM_SHIFT ); } -#endif specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); @@ -2486,7 +2476,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_g = hStereoDmxEVS->hPHA->fad_g_fx; // fad_r = 1.0f / (float) ( fad_len + 1 ); -#ifdef FIX_1481_HARDCODE_DIV SWITCH( fad_len ) { case STEREO_DMX_EVS_FAD_LEN_16: @@ -2511,9 +2500,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e ); BREAK; } -#else - fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); -#endif fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) @@ -2631,7 +2617,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( move16(); fad_g = hStereoDmxEVS->hPHA->fad_g_prc_fx; // fad_r = 1.0f / (float) ( fad_len + 1 ); -#ifdef FIX_1481_HARDCODE_DIV SWITCH( fad_len ) { case STEREO_DMX_EVS_FADE_LEN_PRC_Q0 * 16: @@ -2656,9 +2641,6 @@ ivas_error stereo_dmx_evs_init_encoder_fx( fad_r = BASOP_Util_Divide3232_Scale_newton( 1, add( fad_len, 1 ), &tmp_e ); BREAK; } -#else - fad_r = BASOP_Util_Divide3232_Scale_cadence( 1, add( fad_len, 1 ), &tmp_e ); -#endif fad_r = L_shl_r( fad_r, tmp_e ); fad_len2 = shr( fad_len, 1 ); FOR( ( n = 0, m = ( fad_len - 1 ) ); n < fad_len2; ( n++, m-- ) ) diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 95c49aeae..ff5d67d6a 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -828,11 +828,7 @@ void stereo_icBWE_enc_ivas_fx( ELSE { -#ifndef FIX_1713_EXP - max_e = s_max( hStereoICBWE->mem_shb_speech_nonref_e, shb_speech_nonref_e ); -#else max_e = s_max( hStereoICBWE->mem_shb_speech_ref_e, shb_speech_ref_e ); -#endif Copy_Scale_sig( hStereoICBWE->mem_shb_speech_ref_fx, hStereoICBWE->mem_shb_speech_ref_fx, L_LOOK_16k, negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ) ); // mem_shb_speech_ref_e set32_fx( shb_frame_ref_fx, 0, L_LOOK_16k + L_FRAME16k ); @@ -858,11 +854,7 @@ void stereo_icBWE_enc_ivas_fx( /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */ Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */ -#ifndef FIX_1713_EXP - Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_ref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#else Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e -#endif /* core switching reset */ test(); diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 1771f875a..27de8ad87 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -609,53 +609,6 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( return error; } -#ifndef HARM_ENC_INIT -ivas_error IVAS_ENC_ConfigureForAmbisonics_fx( - IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - const Word32 inputFs, /* i : input sampling frequency */ - const Word32 bitrate, /* i : requested bitrate of the output bitstream */ - const bool max_bwidth_user, /* i : shows if bandwidth limitation was set by the user (true) or if default bandwidth was used (false) */ - const IVAS_ENC_BANDWIDTH maxBandwidth, /* i : bandwidth limitation */ - const IVAS_ENC_DTX_CONFIG dtxConfig, /* i : configuration of DTX, can by set to default by using IVAS_ENC_GetDefaultDtxConfig() */ - const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ - const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ - const bool Opt_PCA_ON /* i : PCA option flag */ -) -{ - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - - IF( ( error = doCommonConfigureChecks( hIvasEnc ) ) != IVAS_ERR_OK ) - { - return error; - } - - hEncoderConfig = hIvasEnc->st_ivas->hEncoderConfig; - - hEncoderConfig->ivas_format = SBA_FORMAT; - hEncoderConfig->element_mode_init = IVAS_SCE; /* Just needs to be something not mono, will be set later */ - hEncoderConfig->sba_planar = isPlanar; - hEncoderConfig->sba_order = order; - move16(); - move16(); - move16(); - - /* Input in ACN/SN3D in all cases (3D and planar): get number of channels */ - hEncoderConfig->nchan_inp = ivas_sba_get_nchan_fx( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ - move16(); - - - hEncoderConfig->Opt_PCA_ON = (Word16) Opt_PCA_ON; - move16(); - - hIvasEnc->maxBandwidthUser = max_bwidth_user; - - error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); - - - return error; -} -#endif /*---------------------------------------------------------------------* * IVAS_ENC_ConfigureForSBAObjects() * @@ -1213,340 +1166,6 @@ static ivas_error configureEncoder( return error; } -#ifndef HARM_ENC_INIT -static ivas_error configureEncoder_fx( - IVAS_ENC_HANDLE hIvasEnc, - const Word32 inputFs, - const Word32 initBitrate, - const IVAS_ENC_BANDWIDTH initBandwidth, - const IVAS_ENC_DTX_CONFIG dtxConfig, - const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ) -{ - Encoder_Struct *st_ivas; - ENCODER_CONFIG_HANDLE hEncoderConfig; - ivas_error error; - Word32 cpe_brate; - - error = IVAS_ERR_OK; - - st_ivas = hIvasEnc->st_ivas; - hEncoderConfig = st_ivas->hEncoderConfig; - - /*-----------------------------------------------------------------* - * Bandwidth limitation - *-----------------------------------------------------------------*/ - - IF( ( error = setBandwidth_fx( hIvasEnc, initBandwidth ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*-----------------------------------------------------------------* - * DTX/CNG - *-----------------------------------------------------------------*/ - - IF( dtxConfig.enabled ) - { - hEncoderConfig->Opt_DTX_ON = 1; - move16(); - - IF( dtxConfig.variable_SID_rate ) - { - hEncoderConfig->var_SID_rate_flag = 1; - hEncoderConfig->interval_SID = 0; - move16(); - move16(); - } - ELSE - { - hEncoderConfig->var_SID_rate_flag = 0; - move16(); - test(); - IF( GE_16( dtxConfig.SID_interval, 3 ) && LE_16( dtxConfig.SID_interval, 100 ) ) - { - hEncoderConfig->interval_SID = dtxConfig.SID_interval; - move16(); - } - ELSE - { - return IVAS_ERR_INVALID_DTX_UPDATE_RATE; - } - } - } - ELSE - { - hEncoderConfig->Opt_DTX_ON = 0; - move16(); - } - - /*-----------------------------------------------------------------* - * Bitrate - *-----------------------------------------------------------------*/ - - hEncoderConfig->ivas_total_brate = initBitrate; - move16(); - - /* SC-VBR at 5.90 kbps */ - IF( EQ_32( hEncoderConfig->ivas_total_brate, ACELP_5k90 ) ) - { - hEncoderConfig->ivas_total_brate = ACELP_7k20; - hEncoderConfig->Opt_SC_VBR = 1; - hEncoderConfig->last_Opt_SC_VBR = hEncoderConfig->Opt_SC_VBR; - move32(); - move16(); - move16(); - - IF( ( hEncoderConfig->max_bwidth != NB ) ) - { - hEncoderConfig->max_bwidth = WB; - move16(); - } - } - - /* check if the entered bitrate is supported */ - test(); - IF( NE_16( hEncoderConfig->ivas_format, UNDEFINED_FORMAT ) && NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) /* IVAS */ - { - IF( !is_IVAS_bitrate_fx( hEncoderConfig->ivas_total_brate ) ) - { - IF( hEncoderConfig->Opt_SC_VBR ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", ACELP_5k90 ); - } - ELSE - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", hEncoderConfig->ivas_total_brate ); - } - } - - IF( EQ_16( hEncoderConfig->ivas_format, STEREO_FORMAT ) ) - { - { - hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - IF( GE_32( hEncoderConfig->ivas_total_brate, MIN_BRATE_MDCT_STEREO ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - } - - test(); - test(); - IF( ( EQ_16( hEncoderConfig->element_mode_init, IVAS_CPE_TD ) || EQ_32( hEncoderConfig->element_mode_init, IVAS_CPE_DFT ) ) && GT_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for TD/DFT Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - - test(); - IF( EQ_16( hEncoderConfig->element_mode_init, IVAS_CPE_MDCT ) && LT_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for MDCT Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - - test(); - IF( LT_32( hEncoderConfig->ivas_total_brate, IVAS_256k ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too high bitrate for Stereo specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, ISM_FORMAT ) ) - { - IF( ( error = sanitizeBitrateISM_fx( hEncoderConfig, hIvasEnc->extMetadataApi ) ) != IVAS_ERR_OK ) - { - return error; - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) ) - { - /* nothing */ - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, MASA_FORMAT ) ) - { - /* adapt element_mode according to the bitrate */ - test(); - IF( EQ_16( hEncoderConfig->nchan_inp, 2 ) && NE_16( hEncoderConfig->element_mode_init, IVAS_SCE ) ) - { - IF( GE_32( hEncoderConfig->ivas_total_brate, IVAS_48k ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - ELSE IF( LT_32( hEncoderConfig->ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_DFT; - move16(); - } - } - } - ELSE IF( EQ_32( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); - - cpe_brate = calculate_cpe_brate_MASA_ISM_fx( st_ivas->ism_mode, st_ivas->hEncoderConfig->ivas_total_brate, hEncoderConfig->nchan_ism ); - - /*adapt element_mode according to the bit-rate*/ - IF( NE_16( hEncoderConfig->element_mode_init, IVAS_SCE ) ) - { - IF( GE_32( cpe_brate, IVAS_48k ) ) - { - hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; - move16(); - } - } - } - ELSE IF( EQ_16( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) ) - { - st_ivas->ism_mode = ISM_MODE_NONE; - } - } - ELSE /* EVS mono */ - { - hEncoderConfig->ivas_format = MONO_FORMAT; - hEncoderConfig->element_mode_init = EVS_MONO; - move16(); - - IF( !is_EVS_bitrate( hEncoderConfig->ivas_total_brate, &hEncoderConfig->Opt_AMR_WB ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in EVS mono: %d", hEncoderConfig->ivas_total_brate ); - } - - IF( EQ_16( hEncoderConfig->stereo_dmx_evs, 1 ) ) - { - hEncoderConfig->nchan_inp = 2; - move16(); - } - } - - /*-----------------------------------------------------------------* - * Input sampling frequency - *-----------------------------------------------------------------*/ - test(); - test(); - test(); - IF( NE_32( inputFs, 8000 ) && NE_32( inputFs, 16000 ) && NE_32( inputFs, 32000 ) && NE_32( inputFs, 48000 ) ) - { - return IVAS_ERR_INVALID_SAMPLING_RATE; - } - - hEncoderConfig->input_Fs = inputFs; - move32(); - - /*-----------------------------------------------------------------* - * Channel-aware mode - *-----------------------------------------------------------------*/ - - IF( ( error = setChannelAwareConfig_fx( hIvasEnc, caConfig ) ) != IVAS_ERR_OK ) - { - return error; - } - - /*-----------------------------------------------------------------* - * Set codec mode - *-----------------------------------------------------------------*/ - - st_ivas->codec_mode = MODE1; /* Note: in IVAS, set MODE1 */ - move16(); - - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) - { - IF( hEncoderConfig->Opt_AMR_WB ) - { - st_ivas->codec_mode = MODE1; - move16(); - } - ELSE - { - st_ivas->codec_mode = get_codec_mode( hEncoderConfig->ivas_total_brate ); - move16(); - } - } - - test(); - IF( EQ_32( hEncoderConfig->ivas_total_brate, IVAS_13k2 ) && EQ_16( hEncoderConfig->Opt_RF_ON, 1 ) ) - { - st_ivas->codec_mode = MODE2; - move16(); - } - - st_ivas->last_codec_mode = st_ivas->codec_mode; - move16(); - - /*-----------------------------------------------------------------* - * Sanity checks - *-----------------------------------------------------------------*/ - - assert( hEncoderConfig->ivas_format != UNDEFINED_FORMAT && "\n IVAS format undefined" ); - - test(); - test(); - IF( ( NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) || hEncoderConfig->stereo_dmx_evs ) && EQ_32( hEncoderConfig->input_Fs, 8000 ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "8kHz input sampling rate is not supported in IVAS." ); - } - - test(); - test(); - test(); - test(); - test(); - test(); - IF( hEncoderConfig->Opt_DTX_ON && NE_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && - ( ( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) && GT_32( ivas_get_sba_num_TCs_fx( hEncoderConfig->ivas_total_brate, 1 ), 2 ) ) || - EQ_16( hEncoderConfig->ivas_format, MC_FORMAT ) || EQ_16( hEncoderConfig->ivas_format, MASA_ISM_FORMAT ) || EQ_16( hEncoderConfig->ivas_format, SBA_ISM_FORMAT ) ) ) - { - return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); - } - - test(); - test(); - test(); - IF( hEncoderConfig->Opt_PCA_ON && !( EQ_16( hEncoderConfig->ivas_format, SBA_FORMAT ) && EQ_32( hEncoderConfig->ivas_total_brate, PCA_BRATE ) && EQ_16( hEncoderConfig->sba_order, SBA_FOA_ORDER ) ) ) - { - return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "PCA supported at SBA FOA 256 kbps only." ); - } - - IF( ( error = sanitizeBandwidth_fx( hIvasEnc ) ) != IVAS_ERR_OK ) - { - return error; - } - - test(); - test(); - test(); - IF( hEncoderConfig->is_binaural && !( ( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && hEncoderConfig->stereo_dmx_evs ) || EQ_16( hEncoderConfig->ivas_format, STEREO_FORMAT ) ) ) - { - return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "'-binaural' option is supported only with '-stereo' or '-stereo_dmx_evs'" ); - } - - /*-----------------------------------------------------------------* - * Finalize initialization - *-----------------------------------------------------------------*/ - - IF( ( error = ivas_init_encoder_fx( st_ivas ) ) != IVAS_ERR_OK ) - { - return error; - } - - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) ) - { - hIvasEnc->hCoreCoder = st_ivas->hSCE[0]->hCoreCoder[0]; /* Note: this is needed for switching in EVS mono */ - } - ELSE - { - hIvasEnc->hCoreCoder = NULL; - } - - hIvasEnc->Opt_RF_ON_loc = hEncoderConfig->Opt_RF_ON; - hIvasEnc->rf_fec_offset_loc = hEncoderConfig->rf_fec_offset; - move16(); - move16(); - - hIvasEnc->isConfigured = true; - - return error; -} -#endif /*---------------------------------------------------------------------* * IVAS_ENC_GetDelay() * @@ -1826,7 +1445,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /* set pointers to the new buffers of indices in each element */ FOR( n = 0; n < st_ivas->nSCE; n++ ) { -#ifdef HARM_PUSH_BIT st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ind_list = st_ivas->ind_list; st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; @@ -1835,23 +1453,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; } -#else - test(); - IF( !( hIvasEnc->hCoreCoder == NULL && EQ_32( hEncoderConfig->ivas_format, MONO_FORMAT ) ) ) - { - if ( ( hEncoderConfig->element_mode_init != EVS_MONO ) ) - { - st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ind_list = st_ivas->ind_list; - } - st_ivas->hSCE[n]->hCoreCoder[0]->hBstr->ivas_ind_list_zero = &st_ivas->ind_list; - } - - IF( st_ivas->hSCE[n]->hMetaData != NULL ) - { - st_ivas->hSCE[n]->hMetaData->ind_list = st_ivas->ind_list_metadata; - st_ivas->hSCE[n]->hMetaData->ivas_ind_list_zero = &st_ivas->ind_list_metadata; - } -#endif } FOR( n = 0; n < st_ivas->nCPE; n++ ) @@ -1916,21 +1517,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } /* write indices into bitstream buffer */ -#ifndef HARM_PUSH_BIT - IF( hEncoderConfig->element_mode_init == EVS_MONO ) - { - test(); - IF( EQ_16( hEncoderConfig->ivas_format, MONO_FORMAT ) && ( hCoreCoder->element_mode == EVS_MONO ) ) - { - /* write indices into bitstream file */ - UWord8 pFrame[( MAX_BITS_PER_FRAME + 7 ) >> 3]; - Word16 pFrame_size = 0; - move16(); - write_indices_buf_fx( hCoreCoder, hCoreCoder->hBstr, outputBitStream, pFrame, pFrame_size, numOutBits ); - } - } - ELSE -#endif { write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits #ifdef DBG_BITSTREAM_ANALYSIS diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index fd983741b..59f3b35f6 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2181,11 +2181,7 @@ Word16 ivas_smc_gmm_fx( } /* PCA */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( FV_fx, pca_mean_fx, FV_fx, N_SMC_FEATURES, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ v_mult_mat_fixed( FV_fx, FV_fx, pca_components_fx, N_SMC_FEATURES, N_PCA_COEF, 0 ); /*------------------------------------------------------------------* * Calculation of posterior probability diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 0647b6ebc..85261a3a7 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -95,10 +95,6 @@ typedef struct bitstream_enc_data_structure void *st_ivas; /* IVAS encoder structure */ // Word16 nb_bits_tot_fx; /* total number of bits already written */ // Indice *ind_list_fx; /* list of indices */ -#ifndef HARM_PUSH_BIT - Word16 next_ind_fx; /* pointer to the next empty slot in the list of indices */ - Word16 last_ind_fx; /* last written indice */ -#endif } BSTR_ENC_DATA, *BSTR_ENC_HANDLE; /*----------------------------------------------------------------------------------* diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index 0e89e16c1..85277e298 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1275,11 +1275,7 @@ void swb_pre_proc_ivas_fx( thr = icbwe_thr_TDM_fx; regV = icbwe_regressionValuesTDM_fx; -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, 0, st->cldfbSynTd ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( realBufferFlipped, imagBufferFlipped, shb_speech_fx_32, -1, 0, st->cldfbSynTd ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ Copy_Scale_sig_32_16( shb_speech_fx_32, shb_speech, L_FRAME16k, negate( sub( q_reImBuffer, 1 ) ) ); *Q_shb_spch = 0; move16(); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 08c920c4a..6b65f9afa 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -5697,11 +5697,7 @@ static void Quant_shb_res_gshape_fx( move16(); IF( NE_16( st_fx->codec_mode, MODE2 ) ) { -#ifdef FIX_1486_IND_SHB_RES push_indice( st_fx->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#else - push_indice( st_fx->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#endif } } } @@ -5737,11 +5733,7 @@ static void Quant_shb_res_gshape_ivas_fx( } ELSE { -#ifdef FIX_1486_IND_SHB_RES push_indice( st->hBstr, IND_SHB_RES_GS + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#else - push_indice( st->hBstr, IND_SHB_RES_GS1 + i, idxSubGain_fx[i], NUM_BITS_SHB_RES_GS ); -#endif } } } @@ -7321,12 +7313,8 @@ void fb_tbe_enc_fx( Word16 ratio; Word16 tmp_vec[L_FRAME48k]; Word16 idxGain; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 input_fhb_buffer[L_FRAME48k + 4]; Word16 *input_fhb = &input_fhb_buffer[0] + 4; -#else - Word16 input_fhb[L_FRAME48k]; -#endif Word16 Sample_Delay_HP; Word32 fb_exc_energy, temp2; Word32 L_tmp; @@ -7352,16 +7340,10 @@ void fb_tbe_enc_fx( Copy_Scale_sig( new_input, input_fhb, L_FRAME48k, exp_temp ); -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif Sample_Delay_HP = NS2SA( 48000, ACELP_LOOK_NS + DELAY_FD_BWE_ENC_12k8_NS + DELAY_FIR_RESAMPL_NS ) - L_FRAME48k / 2; IF( NE_16( st->last_extl, FB_TBE ) ) @@ -7459,12 +7441,8 @@ void fb_tbe_enc_ivas_fx( Word16 ratio; Word16 tmp_vec[L_FRAME48k]; Word16 idxGain; -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic Word16 input_fhb_new_buffer[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ) + 4]; Word16 *input_fhb_new = &input_fhb_new_buffer[0] + 4; -#else - Word16 input_fhb_new[L_FRAME48k + NS2SA( 48000, DELAY_FIR_RESAMPL_NS )]; -#endif Word16 input_fhb[L_FRAME48k]; Word16 Sample_Delay_HP; Word64 fb_exc_energy; @@ -7491,29 +7469,17 @@ void fb_tbe_enc_ivas_fx( exp_temp = add( exp_temp, Q_new_input ); IF( EQ_16( st->element_mode, IVAS_CPE_DFT ) ) { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb_new, &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif } ELSE { -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic elliptic_bpf_48k_generic_fx( -#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2 st->element_mode, -#endif /*FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2*/ 0, // IsUpsampled3 input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#else - elliptic_bpf_48k_generic_fx( input_fhb_new + NS2SA( 48000, DELAY_FIR_RESAMPL_NS ), &exp_temp, tmp_vec, hBWE_TD->elliptic_bpf_2_48k_mem_fx, hBWE_TD->elliptic_bpf_2_48k_mem_fx_Q, full_band_bpf_2_fx ); -#endif } test(); diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 29154688e..9a15cec28 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -3786,11 +3786,7 @@ void ProcessIGF_fx( Word16 igfGridIdx; Word16 isIndepFlag; Word16 bsBits; -#ifndef HARM_PUSH_BIT - Word16 bsStart, pBsStart; -#else Word16 pBsStart; -#endif BSTR_ENC_HANDLE hBstr = st->hBstr; IGF_ENC_INSTANCE_HANDLE hIGFEnc = st->hIGFEnc; @@ -3867,9 +3863,6 @@ void ProcessIGF_fx( } } -#ifndef HARM_PUSH_BIT - bsStart = hBstr->next_ind_fx; -#endif move16(); hInstance->infoTotalBitsPerFrameWritten = 0; move16(); @@ -3877,18 +3870,6 @@ void ProcessIGF_fx( { IGFEncWriteBitstream_fx( hInstance, NULL, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); } -#ifndef HARM_PUSH_BIT - ELSE - { - IGFEncWriteBitstream_fx( hInstance, st->hBstr, &hInstance->infoTotalBitsPerFrameWritten, igfGridIdx, isIndepFlag ); - } - - bsBits = sub( hBstr->next_ind_fx, bsStart ); - IF( !isTCX20 ) - { - IGFEncConcatenateBitstream_fx( hInstance, bsBits, &hBstr->next_ind_fx, &hBstr->nb_bits_tot, hBstr->ind_list ); - } -#else ELSE { pBsStart = hBstr->nb_ind_tot; @@ -3899,7 +3880,6 @@ void ProcessIGF_fx( bsBits = sub( hBstr->nb_ind_tot, pBsStart ); IGFEncConcatenateBitstream_ivas_fx( hIGFEnc, bsBits, hBstr ); } -#endif } void attenuateNbSpectrum_fx( Word16 L_frame, Word32 *spectrum ) diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 82e41026d..c1c032e4e 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -2081,11 +2081,7 @@ static void tc_enc_ivas_fx( /*--------------------------------------------------------------* * compute glottal-shape codebook excitation *--------------------------------------------------------------*/ -#ifdef TEST_HR Copy( h1, h1_fx, L_SUBFR + ( M + 1 ) ); -#else - Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 ); -#endif /* create filtered glottal codebook contribution */ conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR ); diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index df75d6d0a..e170afdc6 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -496,11 +496,7 @@ static void ivas_dirac_dmx_fx( v_add_fx( data_in_fx[0], data_in_fx[1], data_out_fx[0], input_frame ); v_multc_fixed( data_out_fx[0], ONE_IN_Q30, data_out_fx[0], input_frame ); // ONE_IN_Q30 = 0.5* ONE_IN_Q31 -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( data_in_fx[0], data_in_fx[1], data_out_fx[1], input_frame, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ v_multc_fixed( data_out_fx[1], ONE_IN_Q30, data_out_fx[1], input_frame ); FOR( i = 0; i < nchan_transport; i++ ) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c92f800af..656d8f732 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -694,9 +694,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); move32(); move32(); -#ifdef OPT_BIN_RENDERER_V1 Word16 ch_len = s_max( 4, numInChannels ); -#endif /* OPT_BIN_RENDERER_V1 */ FOR( i = 0; i < 6; i++ ) { FOR( j = 0; j < 4; j++ ) @@ -856,24 +854,11 @@ static void ivas_dirac_dec_binaural_internal_fx( Scale_sig( st_ivas->hSpar->hFbMixer->cldfb_cross_fade_fx, CLDFB_NO_COL_MAX, Q15 - st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q ); st_ivas->hSpar->hFbMixer->cldfb_cross_fade_q = Q15; move16(); -#ifndef OPT_BIN_RENDERER_V1 - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q31 - Q22 ); /*Q31 to Q22*/ - } -#endif /* OPT_BIN_RENDERER_V1 */ ivas_sba_prototype_renderer_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_cldfb, subframe ); -#ifndef OPT_BIN_RENDERER_V1 - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - Scale_sig32( st_ivas->hSpar->hFbMixer->pFb->fb_bin_to_band.pp_cldfb_weights_per_spar_band_fx[idx], IVAS_MAX_NUM_FB_BANDS, Q22 - Q31 ); /*Q31 to Q22*/ - } -#endif /* OPT_BIN_RENDERER_V1 */ } Word16 q_inp = Q6; move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 cha = 0; cha < ch_len; cha++ ) { FOR( slot = 0; slot < 4; slot++ ) @@ -888,18 +873,6 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 cha = 0; cha < 6; cha++ ) - { - FOR( slot = 0; slot < 4; slot++ ) - { - scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 - scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, sub( q_inp, q_cldfb[cha][slot] ) ); // Q6 - q_cldfb[cha][slot] = 6; - move16(); - } - } -#endif /* OPT_BIN_RENDERER_V1 */ test(); test(); @@ -1876,7 +1849,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( q_CrEne = Q31; move16(); -#ifdef OPT_BIN_RENDERER_V1 Word16 q_diff = sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ); IF( q_diff > 0 ) @@ -1945,67 +1917,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( move32(); move16(); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - IF( GT_16( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ) - { - hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], sub( hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_e[1][bin] ) ); - hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[0][bin] ); - hDiracDecBin->ChEne_e[1][bin] = hDiracDecBin->ChEne_e[0][bin]; - } - ELSE - { - hDiracDecBin->ChEne_fx[0][bin] = L_shr( hDiracDecBin->ChEne_fx[0][bin], sub( hDiracDecBin->ChEne_e[1][bin], hDiracDecBin->ChEne_e[0][bin] ) ); - hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[1][bin] ); - hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ) ) - { - hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ) ); - hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[0][bin] ); - hDiracDecBin->ChEneOut_e[1][bin] = hDiracDecBin->ChEneOut_e[0][bin]; - } - ELSE - { - hDiracDecBin->ChEneOut_fx[0][bin] = L_shr( hDiracDecBin->ChEneOut_fx[0][bin], sub( hDiracDecBin->ChEneOut_e[1][bin], hDiracDecBin->ChEneOut_e[0][bin] ) ); - hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[1][bin] ); - hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ) ) - { - hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ) ); - hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossRe_e[bin] ); - hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; - } - ELSE - { - hDiracDecBin->ChCrossRe_fx[bin] = L_shr( hDiracDecBin->ChCrossRe_fx[bin], sub( hDiracDecBin->ChCrossIm_e[bin], hDiracDecBin->ChCrossRe_e[bin] ) ); - hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossIm_e[bin] ); - hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; - } - move32(); - move16(); - - IF( GT_16( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ) ) - { - hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ) ); - hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossReOut_e[bin] ); - hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; - } - ELSE - { - hDiracDecBin->ChCrossReOut_fx[bin] = L_shr( hDiracDecBin->ChCrossReOut_fx[bin], sub( hDiracDecBin->ChCrossImOut_e[bin], hDiracDecBin->ChCrossReOut_e[bin] ) ); - hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossImOut_e[bin] ); - hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; - } - move32(); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, @@ -2515,10 +2426,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 *decSlotImPointer_fx; Word16 q_inp_mix, q_reverb = 31; move16(); -#ifdef OPT_BIN_RENDERER_V1 Word16 ch_len = s_max( 4, numInChannels ); Word16 eff_q; -#endif /* OPT_BIN_RENDERER_V1 */ IF( processReverb ) @@ -2532,11 +2441,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word16 shift = s_min( L_norm_arr( cldfbSynDec[0]->cldfb_state_fx, cldfbSynDec[0]->p_filter_length ), L_norm_arr( cldfbSynDec[1]->cldfb_state_fx, cldfbSynDec[1]->p_filter_length ) ); q_inp_mix = 31; move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2564,13 +2469,9 @@ static void ivas_dirac_dec_binaural_process_output_fx( } -#ifdef OPT_BIN_RENDERER_V1 eff_q = sub( add( q_inp_mix, q_mat ), 15 ); FOR( Word16 i = 0; i < ch_len; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -2580,13 +2481,8 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( processReverb && LT_16( i, 2 ) ) { -#ifdef OPT_BIN_RENDERER_V1 scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, eff_q ); /*q_inp_mix+q_mat-15*/ -#else /* OPT_BIN_RENDERER_V1 */ - scale_sig32( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ - scale_sig32( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( add( q_inp_mix, q_mat ), 15 ) ); /*q_inp_mix+q_mat-15*/ -#endif /* OPT_BIN_RENDERER_V1 */ } } } @@ -2713,11 +2609,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( outSlotRePr_fx = &( outSlotRe_fx[0] ); outSlotImPr_fx = &( outSlotIm_fx[0] ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, 0, cldfbSynDec[chA] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); } @@ -2748,11 +2640,7 @@ static void adaptTransportSignalsHeadtracked_fx( Word16 e_div, is_zero, i; move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -4389,18 +4277,11 @@ static void formulate2x2MixingMatrix_fx( Sx_fx[1] = Sqrt32( Sx_fx[1], &exp1 ); move32(); q_Sx = sub( 31, s_max( exp, exp1 ) ); -#ifdef OPT_BIN_RENDERER_V1 Word16 q_diff = sub( 31, q_Sx ); Sx_fx[0] = L_shr( Sx_fx[0], sub( q_diff, exp ) ); // q_Sx move32(); Sx_fx[1] = L_shr( Sx_fx[1], sub( q_diff, exp1 ) ); // q_Sx move32(); -#else /* OPT_BIN_RENDERER_V1 */ - Sx_fx[0] = L_shr( Sx_fx[0], sub( sub( 31, exp ), q_Sx ) ); // q_Sx - move32(); - Sx_fx[1] = L_shr( Sx_fx[1], sub( sub( 31, exp1 ), q_Sx ) ); // q_Sx - move32(); -#endif /* OPT_BIN_RENDERER_V1 */ matrixDiagMul_fx( Uxre_fx, Uxim_fx, q_Ux, Sx_fx, q_Sx, Kxre_fx, Kxim_fx, &q_Kx ); @@ -4468,18 +4349,11 @@ static void formulate2x2MixingMatrix_fx( move32(); q_Ghat = sub( 31, s_max( exp, exp1 ) ); -#ifdef OPT_BIN_RENDERER_V1 q_diff = sub( 31, q_Ghat ); Ghat_fx[0] = L_shr( Ghat_fx[0], sub( q_diff, exp ) ); // q_Ghat move32(); Ghat_fx[1] = L_shr( Ghat_fx[1], sub( q_diff, exp1 ) ); // q_Ghat move32(); -#else /* OPT_BIN_RENDERER_V1 */ - Ghat_fx[0] = L_shr( Ghat_fx[0], sub( sub( 31, exp ), q_Ghat ) ); // q_Ghat - move32(); - Ghat_fx[1] = L_shr( Ghat_fx[1], sub( sub( 31, exp1 ), q_Ghat ) ); // q_Ghat - move32(); -#endif /* OPT_BIN_RENDERER_V1 */ /* Matrix multiplication, tmp = Ky' * G_hat * Q */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4551,28 +4425,9 @@ static void formulate2x2MixingMatrix_fx( move32(); // 1310720000 = 10,000.0f in Q17 -#ifdef OPT_BIN_RENDERER_V1 Word32 thresh = L_shl_sat( 1310720000, sub( q_div, Q17 ) ); // q_div div_fx[0] = L_min( div_fx[0], thresh ); // q_div div_fx[1] = L_min( div_fx[1], thresh ); // q_div -#else /* OPT_BIN_RENDERER_V1 */ - IF( LT_16( q_div, Q17 ) ) - { - div_fx[0] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[0] ); // q_div - move32(); - div_fx[1] = L_min( L_shr( 1310720000, sub( Q17, q_div ) ), div_fx[1] ); // q_div - move32(); - } - ELSE - { - div_fx[0] = L_min( 1310720000, L_shr( div_fx[0], sub( q_div, Q17 ) ) ); - move32(); - div_fx[1] = L_min( 1310720000, L_shr( div_fx[1], sub( q_div, Q17 ) ) ); - move32(); - q_div = Q17; - move16(); - } -#endif /* OPT_BIN_RENDERER_V1 */ matrixMul_fx( Are_fx, Aim_fx, &q_A, Ure_fx, Uim_fx, &q_U, tmpRe_fx, tmpIm_fx, &q_temp ); @@ -4589,21 +4444,11 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpRe_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { -#ifdef OPT_BIN_RENDERER_V1 Word16 hdrm = sub( W_norm( W_tmp ), 32 ); tmpRe_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); move32(); hdrm_re[chA][chB] = add( add( q_temp, q_div ), hdrm ); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - hdrm_re[chA][chB] = sub( W_norm( W_tmp ), 0 ); - move16(); - W_tmp = W_shl( W_tmp, hdrm_re[chA][chB] ); - tmpRe_fx[chA][chB] = W_extract_h( W_tmp ); - move32(); - hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 ); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4614,22 +4459,12 @@ static void formulate2x2MixingMatrix_fx( W_tmp = W_mult0_32_32( tmpIm_fx[chA][chB], div_fx[chB] ); IF( W_tmp != 0 ) { -#ifdef OPT_BIN_RENDERER_V1 Word16 hdrm = sub( W_norm( W_tmp ), 32 ); move16(); tmpIm_fx[chA][chB] = W_shl_sat_l( W_tmp, hdrm ); move32(); hdrm_im[chA][chB] = add( add( q_temp, q_div ), hdrm ); move16(); -#else /* OPT_BIN_RENDERER_V1 */ - hdrm_im[chA][chB] = sub( W_norm( W_tmp ), 0 ); - move16(); - W_tmp = W_shl( W_tmp, hdrm_im[chA][chB] ); - tmpIm_fx[chA][chB] = W_extract_h( W_tmp ); - move32(); - hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 ); - move16(); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4644,9 +4479,7 @@ static void formulate2x2MixingMatrix_fx( move16(); minimum_s( hdrm_im[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_temp = s_min( q_temp, exp ); -#ifdef OPT_BIN_RENDERER_V1 q_temp = sub( q_temp, 1 ); -#endif /* OPT_BIN_RENDERER_V1 */ FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { @@ -4660,11 +4493,7 @@ static void formulate2x2MixingMatrix_fx( } matrixTransp2Mul_fx( tmpRe_fx, tmpIm_fx, &q_temp, Ure_fx, Uim_fx, &q_U, -#ifdef OPT_BIN_RENDERER_V1 0 /*int Ascale*/, -#else /* OPT_BIN_RENDERER_V1 */ - 1 /*int Ascale*/, -#endif /* OPT_BIN_RENDERER_V1 */ 0 /*int Bscale*/, Pre_fx, Pim_fx, &q_P ); /* Nearest orthonormal matrix P to matrix A formulated */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index c96878d55..8b54b80c7 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -919,7 +919,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ Word16 diff_c_exp = sub( q_diffuseness, 4 ); -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -984,71 +983,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } -#else - FOR( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses - move32(); - IF( reference_power[k + num_freq_bands] == 0 ) - { - b = 0; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) - { - b = MAX_16; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ - } - } - - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c2 ); // Q = q_diffuseness - 4 - - q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); - q_diff_c = sub( q_diffuseness, 4 ); - Word16 minq = sub( s_min( q_diff_aab, q_diff_c ), 1 ); - Word32 op1 = L_shr( mpy_diff_aab, sub( q_diff_aab, minq ) ); - Word32 op2 = L_shr( mpy_diff_c, sub( q_diff_c, minq ) ); - sqr_inp = L_add( op1, op2 ); - sqr_exp = sub( 31, minq ); - sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ - sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) - { - IF( GT_16( sqr_exp, cy_cross_dir_smooth_e ) ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( sqr_exp, cy_cross_dir_smooth_e ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ - move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); - move16(); - } - ELSE - { - sqr = L_shr( sqr, sub( cy_cross_dir_smooth_e, sqr_exp ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ - move32(); - } - ELSE - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ - move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sqr_exp; // sub( 31, sqr_exp ); - move16(); - } - } -#endif } ELSE { @@ -1262,7 +1196,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( } } c = Madd_32_16( ONE_IN_Q27 /*1 Q27*/, L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ), 5461 ); /*Diffuseness modellling nrg compensation*/ /* 1.0 / 6.0 = 5461 in Q15*/ /*Q27*/ -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot FOR( ; k < num_freq_bands; k++ ) { a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses @@ -1329,89 +1262,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } -#else - FOR( ; k < num_freq_bands; k++ ) - { - a = h_dirac_output_synthesis_state->direct_responses_fx[ch_idx * num_freq_bands + k]; // Q = h_dirac_output_synthesis_state->q_direct_responses - move32(); - IF( reference_power[k + num_freq_bands] == 0 ) - { - b = 0; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - IF( reference_power[k + ( ch_idx + 1 ) * num_freq_bands] == 0 ) - { - b = MAX_16; - move16(); - b_exp = 0; - move16(); - } - ELSE - { - b = BASOP_Util_Divide3232_Scale( reference_power[k + num_freq_bands], reference_power[k + ( ch_idx + 1 ) * num_freq_bands], &b_exp ); /*q(15-b_exp)*/ - } - } - - mpy_a_a_b = Mpy_32_32( a, Mpy_32_16_1( a, b ) ); // Q = (h_dirac_output_synthesis_state->q_direct_responses + (15 - b_exp) - 15) + (h_dirac_output_synthesis_state->q_direct_responses) - 31 - mpy_diff_aab = Mpy_32_32( L_sub( L_shl( 1, q_diffuseness ), diffuseness[k] ), mpy_a_a_b ); // Q = 2*(h_dirac_output_synthesis_state->q_direct_responses) - b_exp - 31 + q_diffuseness -31 - mpy_diff_c = Mpy_32_32( diffuseness[k], c ); // Q = q_diffuseness - 4 - - q_diff_aab = add( add( h_dirac_output_synthesis_state->direct_responses_q, sub( sub( 15, b_exp ), 15 ) ), add( sub( h_dirac_output_synthesis_state->direct_responses_q, 31 ), sub( q_diffuseness, 31 ) ) ); - q_diff_c = sub( q_diffuseness, 4 ); - - test(); - IF( mpy_diff_c != 0 && mpy_diff_aab != 0 ) - { - sqr_inp = BASOP_Util_Add_Mant32Exp( mpy_diff_c, sub( 31, q_diff_c ), mpy_diff_aab, sub( 31, q_diff_aab ), &sqr_exp ); /*q(31-sqr_exp)*/ - } - ELSE - { - IF( mpy_diff_c == 0 ) - { - sqr_inp = mpy_diff_aab; /*q_diff_aab*/ - move32(); - sqr_exp = sub( 31, q_diff_aab ); - } - ELSE - { - sqr_inp = mpy_diff_c; - move32(); - sqr_exp = sub( 31, q_diff_c ); /*q_diff_c*/ - } - } - sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ - sqr = L_shr( sqr, 2 ); /*Q(31-sqr_exp)*/ - IF( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] != 0 ) - { - IF( LT_16( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_shr( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sub( h_dirac_output_synthesis_state->q_cy_cross_dir_smooth, sub( 31, sqr_exp ) ) ); /*h_dirac_output_synthesis_state->q_cy_cross_dir_smooth->Q( 31- sqr_exp )*/ - move32(); - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); - move16(); - } - ELSE - { - sqr = L_shr( sqr, sub( sub( 31, sqr_exp ), h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ); /*Q(31- sqr_exp)->h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; - move16(); - } - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k]*/ - move32(); - } - ELSE - { - h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = L_add( h_dirac_output_synthesis_state->cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k], sqr ); /*Q(31- sqr_exp)*/ - move32(); - h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); - move16(); - } - } -#endif } ELSE { @@ -1568,17 +1418,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { Scale_sig32( aux_buf, num_freq_bands, sub( h_dirac_output_synthesis_state->q_cy_auto_diff_smooth, temp_q ) ); /*temp_q->(h_dirac_output_synthesis_state->q_cy_auto_diff_smooth)*/ } -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( aux_buf, &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], num_freq_bands_diff ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( aux_buf, - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], - &h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx[ch_idx * num_freq_bands_diff], - num_freq_bands_diff, 0 ); /*h_dirac_output_synthesis_state->q_cy_auto_diff_smooth*/ -#endif /* VEC_ARITH_OPT_v1 */ } return; @@ -3647,19 +3490,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( } ELSE { -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx ivas_dirac_dec_get_response_fx_29( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order ); -#else - ivas_dirac_dec_get_response_fx( azimuth[k], elevation[k], direct_response_hoa_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_hoa ); -#endif IF( hodirac_flag ) { -#ifdef FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx ivas_dirac_dec_get_response_fx_29( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order ); -#else - ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); -#endif } } diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 947d1943e..4b35bbd30 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4543,11 +4543,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_state ); v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands, 0 ); /* Q31 */ -#endif /* VEC_ARITH_OPT_v1 */ p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/ } ELSE @@ -4645,11 +4641,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( DirAC_mem.reference_power_smooth_q = DirAC_mem.reference_power_q; move16(); #endif -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands ); // DirAC_mem.reference_power_smooth_q -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( reference_power_fix, reference_power_smooth_fx, reference_power_smooth_fx, hSpatParamRendCom->num_freq_bands, 0 ); // DirAC_mem.reference_power_smooth_q -#endif /* VEC_ARITH_OPT_v1 */ } } /*Rescaling proto_direct_buffer_f*/ @@ -5077,11 +5069,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); -#ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); -#else /* OPT_AVOID_STATE_BUF_RESCALE */ - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, hMasaExtRend->cldfbSynRend[idx_in] ); -#endif /* OPT_AVOID_STATE_BUF_RESCALE */ scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 2ac397e2c..3a2092294 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -1525,11 +1525,7 @@ static void get_poly_gains_fx( A[1] = elePoly[i - 1]; // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/ -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/ -#endif /* VEC_ARITH_OPT_v1 */ FOR( j = i; j < numChan - 2 + i; ++j ) { @@ -1582,11 +1578,7 @@ static Word32 get_tri_gain_fx( tmpN[1] = L_sub( C[0], B[0] ); // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( B, A, tmpSub1, 2 ); // tmpSub1 q22 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22 -#endif /* VEC_ARITH_OPT_v1 */ tmpDot1 = dotp_fixed( tmpN, tmpSub1, 2 ); // Q13 @@ -2245,11 +2237,7 @@ static void sort_channels_vertex_fx( move32(); } -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( tmpV1, tmpV2, tmpV3, 3 ); // tmpV3 Q30 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( tmpV1, tmpV2, tmpV3, 3, 0 ); // tmpV3 Q30 -#endif /* VEC_ARITH_OPT_v1 */ Word16 exp2 = 2; move16(); normV = ISqrt32( dotp_fixed( tmpV3, tmpV3, 3 ) /*q29*/, &exp2 ); // q=31-exp2 @@ -2431,11 +2419,7 @@ static Word16 in_poly_fx( /* Angles are in Q22 */ A[1] = poly.polyEle[0]; // q22 move32(); -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( P, A, P_minus_A, 2 ); /* Precalculate value of (P-A) q22*/ -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( P, A, P_minus_A, 2, 0 ); /* Precalculate value of (P-A) q22*/ -#endif /* VEC_ARITH_OPT_v1 */ FOR( n = 1; n < sub( numVertices, 1 ); ++n ) { @@ -2504,13 +2488,8 @@ static Word16 in_tri_fx( I'll just compute the determinant and if it's equal to 0, that means the two vectors are colinear */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( B, A, tmpDot1, 2 ); // tmpDot1 q22 v_sub_fixed_no_hdrm( C, A, tmpDot2, 2 ); // tmpDot2 q22 -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( B, A, tmpDot1, 2, 0 ); // tmpDot1 q22 - v_sub_fixed( C, A, tmpDot2, 2, 0 ); // tmpDot2 q22 -#endif /* VEC_ARITH_OPT_v1 */ /* Verification of the non-colinearity : Q22 * Q22 = Q13 */ #ifdef OPT_SBA_REND_V1_BE diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 84f1ff3dc..1ef2805b5 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -489,13 +489,8 @@ static void ivas_omasa_param_est_ana_fx( FOR( i = 1; i < nchan_ism; i++ ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // Q: Chnl_RealBuffer_q v_add_fixed_no_hdrm( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // Q: Chnl_ImagBuffer_q -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( Chnl_RealBuffer_fx[i], Foa_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_RealBuffer_q - v_add_fixed( Chnl_ImagBuffer_fx[i], Foa_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins, 0 ); // Q: Chnl_ImagBuffer_q -#endif /* VEC_ARITH_OPT_v1 */ } /* Y */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index b9b897f4a..9ea501f10 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2177,23 +2177,13 @@ void ivas_binaural_reverb_processSubframe_fx( { IF( s_and( ch, 1 ) ) { -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins ); v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->preDelayBufferReal_fx[idx], inReal[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 ); - v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inImag[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } ELSE { -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins ); v_add_fixed_no_hdrm( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->preDelayBufferReal_fx[idx], inImag[ch][sample], hReverb->preDelayBufferReal_fx[idx], hReverb->numBins, 0 ); - v_add_fixed( hReverb->preDelayBufferImag_fx[idx], inReal[ch][sample], hReverb->preDelayBufferImag_fx[idx], hReverb->numBins, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } } idx = add( idx, 1 ) % hReverb->preDelayBufferLength; @@ -2223,40 +2213,20 @@ void ivas_binaural_reverb_processSubframe_fx( SWITCH( phaseShiftTypePr[tapIdx] ) { case 0: /* 0 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; case 1: /* 90 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_add_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_add_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; case 2: /* 180 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_sub_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_sub_fixed( hReverb->outputBufferReal_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; default: /* 270 degrees phase */ -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots ); v_sub_fixed_no_hdrm( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( hReverb->outputBufferReal_fx[bin][ch], tapImagPr_fx[tapIdx], hReverb->outputBufferReal_fx[bin][ch], numSlots, 0 ); - v_sub_fixed( hReverb->outputBufferImag_fx[bin][ch], tapRealPr_fx[tapIdx], hReverb->outputBufferImag_fx[bin][ch], numSlots, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ BREAK; } } @@ -2271,7 +2241,6 @@ void ivas_binaural_reverb_processSubframe_fx( { Word32 leftRe_fx, rightRe_fx, leftIm_fx, rightIm_fx; -#ifdef OPT_BIN_RENDERER_V2 leftRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ); // Q_in rightRe_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), @@ -2280,16 +2249,6 @@ void ivas_binaural_reverb_processSubframe_fx( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ); // Q_in rightIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ); // Q_in -#else /* OPT_BIN_RENDERER_V2 */ - leftRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ) ); // Q_in - rightRe_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferReal_fx[bin][1][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ) ); // Q_in - leftIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ) ); // Q_in - rightIm_fx = L_add( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][1][sample] ), - Mpy_32_32( hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ) ); // Q_in -#endif /* OPT_BIN_RENDERER_V2 */ hReverb->outputBufferReal_fx[bin][0][sample] = leftRe_fx; // Q_in move32(); diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index 896742151..ff077e63e 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -87,11 +87,7 @@ void ivas_sba_prototype_renderer_fx( Word16 norm_q = 31; // to handle overflow move16(); -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { @@ -100,38 +96,21 @@ void ivas_sba_prototype_renderer_fx( } norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow Word16 q_inp[2][CLDFB_SLOTS_PER_SUBFRAME]; -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { -#ifdef OPT_BIN_RENDERER_V1 q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], num_cldfb_bands ), L_norm_arr( inIm_fx[i][j], num_cldfb_bands ) ); -#else /* OPT_BIN_RENDERER_V1 */ - q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); -#endif /* OPT_BIN_RENDERER_V1 */ move16(); norm_q = s_min( q_inp[i][j], norm_q ); } } -#ifdef OPT_BIN_RENDERER_V1 FOR( Word16 i = 0; i < 2; i++ ) -#else /* OPT_BIN_RENDERER_V1 */ - FOR( Word16 i = 0; i < 6; i++ ) -#endif /* OPT_BIN_RENDERER_V1 */ { FOR( Word16 j = 0; j < CLDFB_SLOTS_PER_SUBFRAME; j++ ) { -#ifdef OPT_BIN_RENDERER_V1 scale_sig32( inRe_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q scale_sig32( inIm_fx[i][j], num_cldfb_bands, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q -#else /* OPT_BIN_RENDERER_V1 */ - scale_sig32( inRe_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q - scale_sig32( inIm_fx[i][j], CLDFB_NO_CHANNELS_MAX, sub( norm_q, 2 ) ); // q_cldfb -> q_cldfb + 2 -norm_q -#endif /* OPT_BIN_RENDERER_V1 */ q_cldfb[i][j] = sub( add( q_cldfb[i][j], norm_q ), 2 ); move16(); } @@ -199,21 +178,12 @@ void ivas_sba_prototype_renderer_fx( FOR( spar_band = bin2band->p_spar_start_bands[cldfb_band]; spar_band < num_spar_bands; spar_band++ ) { /* accumulate contributions from all SPAR bands */ -#ifdef OPT_BIN_RENDERER_V1 cldfb_par_fx = Madd_32_32( cldfb_par_fx, mixer_mat_fx[out_ch][in_ch][spar_band], L_shl_sat( bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band], 9 ) ); // hMdDec->Q_mixer_matrix -#else /* OPT_BIN_RENDERER_V1 */ - cldfb_par_fx = L_add( cldfb_par_fx, Mpy_32_32( mixer_mat_fx[out_ch][in_ch][spar_band], bin2band->pp_cldfb_weights_per_spar_band_fx[cldfb_band][spar_band] ) ); // hMdDec->Q_mixer_matrix -#endif /* OPT_BIN_RENDERER_V1 */ } } -#ifdef OPT_BIN_RENDERER_V1 out_re_fx[out_ch] = Madd_32_32( out_re_fx[out_ch], inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 out_im_fx[out_ch] = Madd_32_32( out_im_fx[out_ch], inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 -#else /* OPT_BIN_RENDERER_V1 */ - out_re_fx[out_ch] = L_add( out_re_fx[out_ch], Mpy_32_32( inRe_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 - out_im_fx[out_ch] = L_add( out_im_fx[out_ch], Mpy_32_32( inIm_fx[in_ch][ts][cldfb_band], cldfb_par_fx ) ); // hMdDec->Q_mixer_matrix+q_cldfb[i][j] -31 -#endif /* OPT_BIN_RENDERER_V1 */ move32(); move32(); } @@ -272,17 +242,11 @@ void ivas_sba_prototype_renderer_fx( { IF( EQ_16( st_ivas->nchan_transport, 1 ) ) /* Dual mono */ { -#ifdef OPT_BIN_RENDERER_V1 Copy32( inRe_fx[0][ts], inRe_fx[1][ts], num_cldfb_bands ); Copy32( inIm_fx[0][ts], inIm_fx[1][ts], num_cldfb_bands ); -#else /* OPT_BIN_RENDERER_V1 */ - Copy32( inRe_fx[0][ts], inRe_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); - Copy32( inIm_fx[0][ts], inIm_fx[1][ts], CLDFB_NO_CHANNELS_MAX ); -#endif /* OPT_BIN_RENDERER_V1 */ } ELSE IF( EQ_16( st_ivas->nchan_transport, 2 ) ) /* Opposing cardioids */ { -#ifdef OPT_BIN_RENDERER_V1 Word32 temp_signal_fx; FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ ) { @@ -306,28 +270,6 @@ void ivas_sba_prototype_renderer_fx( inIm_fx[0][ts][idx] = temp_signal_fx; move32(); } -#else /* OPT_BIN_RENDERER_V1 */ - Word32 temp_signal_fx[CLDFB_NO_CHANNELS_MAX]; - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - temp_signal_fx[idx] = L_add( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inRe_fx[1][ts][idx] = L_sub( L_shr( inRe_fx[0][ts][idx], 1 ), L_shr( inRe_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inRe_fx[0][ts][idx] = temp_signal_fx[idx]; - move32(); - } - - FOR( Word16 idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - temp_signal_fx[idx] = L_add( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inIm_fx[1][ts][idx] = L_sub( L_shr( inIm_fx[0][ts][idx], 1 ), L_shr( inIm_fx[1][ts][idx], 1 ) ); // q_cldfb[][]-1 - move32(); - inIm_fx[0][ts][idx] = temp_signal_fx[idx]; - move32(); - } -#endif /* OPT_BIN_RENDERER_V1 */ } } } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 3b800ed07..957aaee0d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5755,11 +5755,7 @@ static ivas_error renderLfeToBinaural_fx( { writePtr = getSmplPtr_fx( outAudio, ear_idx, 0 ); move32(); -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( writePtr, tmpLfeBuffer, writePtr, frame_size ); /* Q(out_q) */ -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ -#endif /* VEC_ARITH_OPT_v1 */ } pop_wmops(); @@ -6764,11 +6760,7 @@ static void renderMasaToMasa( ELSE IF( EQ_16( masaInput->base.inputBuffer.config.numChannels, 2 ) && EQ_16( outAudio.config.numChannels, 1 ) ) { // v_add( tmpBuffer[0], tmpBuffer[1], tmpBuffer[0], masaInput->base.inputBuffer.config.numSamplesPerChannel ); -#ifdef VEC_ARITH_OPT_v1 v_add_fixed_no_hdrm( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel ); -#else /* VEC_ARITH_OPT_v1 */ - v_add_fixed( tmpBuffer_fx[0], tmpBuffer_fx[1], tmpBuffer_fx[0], masaInput->base.inputBuffer.config.numSamplesPerChannel, 0 ); -#endif /* VEC_ARITH_OPT_v1 */ } /* Copy metadata */ -- GitLab From 81d0cb71e489fa477aa00582f0a324d97e604579 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 11:08:01 +0530 Subject: [PATCH 228/394] Clang formatting --- lib_com/cldfb_fx.c | 42 +++++++++---------- lib_com/prot_fx.h | 18 ++++---- lib_com/swb_tbe_com_fx.c | 6 +-- lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 2 - lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 - lib_dec/ivas_stereo_cng_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 28 ++++++------- lib_dec/swb_tbe_dec_fx.c | 14 +++---- lib_enc/ivas_mc_param_enc_fx.c | 1 - lib_enc/ivas_qmetadata_enc_fx.c | 2 +- lib_enc/ivas_stereo_icbwe_enc_fx.c | 2 +- lib_enc/lib_enc_fx.c | 31 +++++++------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 3 +- lib_rend/ivas_dirac_rend_fx.c | 2 +- 14 files changed, 70 insertions(+), 85 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index edddcb272..30b8d57d0 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -505,18 +505,18 @@ void cldfbAnalysis_ts_fx( #endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ - rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 - ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ + rr12_fx = L_sub( r1_fx, r2_fx ); // q -1 + ri12_fx = L_negate( L_add( i1_fx, i2_fx ) ); // q - 1 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 move32(); move32(); ///* folding + pre modulation of DCT IV */ - ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 - ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ + ir12_fx = L_add( r1_fx, r2_fx ); // q - 1 + ii12_fx = L_sub( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 move32(); @@ -575,25 +575,25 @@ void cldfbAnalysis_ts_fx( i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 3 * L2 )] ); // q i2_fx = Msub_32_16( i2_fx, timeBuffer_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )], ptr_pf_fx[( L2 - 3 * M2 + ( 2 * k ) + 4 * L2 )] ); // q - r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 - r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 - i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 - i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 + r1_fx = Mpy_32_16_1( r1_fx, ptr_pf_sf ); // q - 1 + r2_fx = Mpy_32_16_1( r2_fx, ptr_pf_sf ); // q - 1 + i1_fx = Mpy_32_16_1( i1_fx, ptr_pf_sf ); // q - 1 + i2_fx = Mpy_32_16_1( i2_fx, ptr_pf_sf ); // q - 1 #endif /* OPT_IVAS_FILTER_ROM */ /* folding + pre modulation of DST IV */ - rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 - ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ + rr12_fx = L_add( r1_fx, r2_fx ); // q - 1 + ri12_fx = L_sub( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&rBuffer[2*k],&rBuffer[2*k+1],rr12,ri12,rot_vctr_re[k],rot_vctr_im[k]);*/ rBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( rr12_fx, rot_vctr_re_fx[k] ), ri12_fx, rot_vctr_im_fx[k] ); // q - 3 rBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( rr12_fx, rot_vctr_im_fx[k] ), ri12_fx, rot_vctr_re_fx[k] ); // q - 3 move32(); move32(); /* folding + pre modulation of DCT IV */ - ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 - ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 - /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ + ir12_fx = L_sub( r1_fx, r2_fx ); // q - 1 + ii12_fx = L_add( i1_fx, i2_fx ); // q - 1 + /*cplxMult(&iBuffer[2*k],&iBuffer[2*k+1],ir12,ii12,rot_vctr_re[k],rot_vctr_im[k]);*/ iBuffer_fx[2 * k] = Msub_32_32( Mpy_32_32( ir12_fx, rot_vctr_re_fx[k] ), ii12_fx, rot_vctr_im_fx[k] ); // q - 3 iBuffer_fx[2 * k + 1] = Madd_32_32( Mpy_32_32( ir12_fx, rot_vctr_im_fx[k] ), ii12_fx, rot_vctr_re_fx[k] ); // q - 3 move32(); @@ -1378,11 +1378,11 @@ void cldfbAnalysis_ts_fx_fixed_q( * Conduct inverse multple overlap cmplex low delay MDCT *--------------------------------------------------------------------*/ void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ const Word16 out_shift, /* i : scale for output buffer */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 2d4ea1901..666484359 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -3244,10 +3244,8 @@ void synthesise_fb_high_band_fx( Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], - Word16 Qout - , - Word16 element_mode -); + Word16 Qout, + Word16 element_mode ); void prep_tbe_exc_fx( const Word16 L_frame_fx, /* i : length of the frame */ @@ -9361,12 +9359,12 @@ void cldfbAnalysis_ivas_fx( ); void cldfbSynthesis_ivas_fx( - Word32 **realBuffer_fx, /* i : real values Qx*/ - Word32 **imagBuffer_fx, /* i : imag values Qx*/ - Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ - const Word16 samplesToProcess, /* i : number of processed samples */ - const Word16 shift, /* i : scale for state buffer */ - const Word16 out_shift, /* i : scale for output buffer */ + Word32 **realBuffer_fx, /* i : real values Qx*/ + Word32 **imagBuffer_fx, /* i : imag values Qx*/ + Word32 *timeOut_fx, /* o : output time domain samples Qx - 1*/ + const Word16 samplesToProcess, /* i : number of processed samples */ + const Word16 shift, /* i : scale for state buffer */ + const Word16 out_shift, /* i : scale for output buffer */ HANDLE_CLDFB_FILTER_BANK h_cldfb /* i : filter bank state */ ); diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index f37381b69..8ddfa3e5f 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6685,10 +6685,8 @@ void synthesise_fb_high_band_fx( Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */ Word16 bpf_memory_Q[], - Word16 Qout - , - int16_t element_mode -) + Word16 Qout, + int16_t element_mode ) { Word16 i, j; Word16 excitation_in_interp3_buffer[L_FRAME48k + 4]; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 0d8e029d1..532ca0358 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -623,8 +623,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( #endif /* OPT_SBA_DEC_V2_BE */ } } - - } ELSE { diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 5840cb08f..46b28ec8c 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -859,9 +859,7 @@ static void ivas_mc_paramupmix_dec_sf( ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 } cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11 - } - } ELSE { diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index d48e035a6..463032467 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -1509,7 +1509,7 @@ void stereo_cna_update_params_fx( dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) ); dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */ /* estimate L/R correlation factor and ILD in time domain */ - c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ + c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */ temp_res_q = 0; move16(); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 4aebd5145..7d3bec07d 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2603,9 +2603,9 @@ void stereo_dft_dec_fx( Word16 shift = sub( q_cna_level, hStereoDft->q_dft ); N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */ + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */ move32(); l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ @@ -2614,9 +2614,9 @@ void stereo_dft_dec_fx( N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */ - l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ - l_tmp = L_shr( l_tmp, shift ); /* q_dft */ - DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ + l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ + l_tmp = L_shr( l_tmp, shift ); /* q_dft */ + DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */ move32(); l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */ l_tmp = L_shr( l_tmp, shift ); /* q_dft */ @@ -2874,14 +2874,14 @@ static void stereo_dft_dequantize_ipd_fx( *-------------------------------------------------------------------------*/ void stereo_dft_generate_res_pred_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word16 samp_ratio, /* i : sampling ratio Q15*/ - Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ - Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ - Word32 *pPredGain, /* i : residual prediction gains Q31*/ - const Word16 k, /* i : subframe index Q0*/ - Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ - Word16 *stop, /* o : last FD stereo filling bin Q0*/ - const Word16 bfi /* i : BFI flag Q0*/ + const Word16 samp_ratio, /* i : sampling ratio Q15*/ + Word32 *pDFT_DMX, /* i : downmix signal qDFT*/ + Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/ + Word32 *pPredGain, /* i : residual prediction gains Q31*/ + const Word16 k, /* i : subframe index Q0*/ + Word32 *ap_filt_DMX, /* i : enhanced stereo filling signal qDFT*/ + Word16 *stop, /* o : last FD stereo filling bin Q0*/ + const Word16 bfi /* i : BFI flag Q0*/ ) { /* general variables */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 73d8ef11c..679e206e0 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4662,10 +4662,8 @@ void fb_tbe_dec_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ - synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp - , - st->element_mode - ); + synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, + st->element_mode ); /* add the fb_synth component to the hb_synth component */ /* v_add_fx( hb_synth, fb_synth, hb_synth, L_FRAME48k );*/ @@ -4734,10 +4732,8 @@ void fb_tbe_dec_ivas_fx( fb_exc_energy = sum2_fx_mod( fb_exc, L_FRAME16k ); /* FB TBE synthesis */ - synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp - , - st->element_mode - ); + synthesise_fb_high_band_fx( fb_exc, Q_fb_exc, fb_synth, fb_exc_energy, ratio, st->L_frame, st->bfi, &( hBWE_TD->prev_fbbwe_ratio_fx ), hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, hb_synth_exp, + st->element_mode ); test(); IF( GE_16( st->element_mode, IVAS_CPE_DFT ) && ( st->idchan == 0 ) ) @@ -7046,7 +7042,7 @@ void ivas_swb_tbe_dec_fx( FOR( i = 0; i < L_FRAME16k; i++ ) { Word16 idx; - idx = extract_h( imult3216( idx32, i ) ); /*Q0*/ + idx = extract_h( imult3216( idx32, i ) ); /*Q0*/ L_tmp1 = Mult_32_16( L_tmp, GainShape_fx[idx] ); /* Q : 18 + tmp +15 -15*/ White_exc16k_fx[i] = round_fx( Mult_32_16( L_tmp1, White_exc16k_fx[i] ) ); /* 18 + tmp +*Q_white_exc -15 -16 */ move16(); diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 8b09f3644..226e7c164 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -1166,7 +1166,6 @@ static void ivas_param_mc_param_est_enc_fx( move64(); Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2] = W_add( Cy_sum_imag_64[cur_param_band - 1][ch_idx1][ch_idx2], Cy_sum_imag_64[cur_param_band][ch_idx1][ch_idx2] ); move64(); - } } } diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3040bc24a..15adcee9c 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -1072,7 +1072,7 @@ void ivas_qmetadata_enc_sid_encode_fx( { /*compute the average direction */ ivas_qmetadata_azimuth_elevation_to_direction_vector_fx( q_direction->band_data[b].azimuth_fx[m], q_direction->band_data[b].elevation_fx[m], direction_vector_fx ); - scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22 + scale_sig32( direction_vector_fx, 3, Q22 - Q30 ); // Q30 -> Q22 v_add_fixed_no_hdrm( avg_direction_vector_fx, direction_vector_fx, avg_direction_vector_fx, 3 ); // Q22 } diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index ff5d67d6a..67ba071a0 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -853,7 +853,7 @@ void stereo_icBWE_enc_ivas_fx( move16(); /* shb_frame_ref_ICBWE @ (8.75 - shb_speech_delay (=1.25) ms) after shb_speech */ - Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */ + Copy_Scale_sig32( shb_speech_nonref_fx, shb_frame_nonref_fx + L_LOOK_16k - nonRefMemLen, L_FRAME16k, negate( sub( max_e, shb_speech_nonref_e ) ) ); /* Q31-max_e */ Copy_Scale_sig_32_16( shb_frame_nonref_fx + L_FRAME16k, hStereoICBWE->mem_shb_speech_nonref_fx, L_LOOK_16k, sub( negate( sub( max_e, hStereoICBWE->mem_shb_speech_nonref_e ) ), Q16 ) ); // mem_shb_speech_ref_e /* core switching reset */ diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 27de8ad87..6c105228f 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1509,27 +1509,26 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( } } ELSE /* IVAS */ - { - IF( NE_32( ( error = ivas_enc_fx( st_ivas, inputBuffer, inputBufferSize ) ), IVAS_ERR_OK ) ) { - return error; - } - } + IF( NE_32( ( error = ivas_enc_fx( st_ivas, inputBuffer, inputBufferSize ) ), IVAS_ERR_OK ) ){ + return error; +} +} - /* write indices into bitstream buffer */ - { - write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits +/* write indices into bitstream buffer */ +{ + write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits #ifdef DBG_BITSTREAM_ANALYSIS - , - frame + , + frame #endif - ); - } - /* Reset switching flag before next call - can be set to "true" by some setters */ - hIvasEnc->switchingActive = false; - move16(); + ); +} +/* Reset switching flag before next call - can be set to "true" by some setters */ +hIvasEnc->switchingActive = false; +move16(); - return error; +return error; } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 8b54b80c7..eea8dffbb 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -982,7 +982,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } - } ELSE { @@ -1090,7 +1089,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } free( exp_temp_cy_cross_dir_smooth_fx ); -#else /* OPT_SBA_DEC_PATH */ +#else /* OPT_SBA_DEC_PATH */ /*Direct gain*/ Word16 *Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( num_freq_bands * num_channels_dir * sizeof( Word16 ) ); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 4b35bbd30..0535d2582 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4542,7 +4542,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( hDirACRend->h_freq_domain_decorr_ap_params, hDirACRend->h_freq_domain_decorr_ap_state ); - v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ + v_multc_fixed( onset_filter_fx, 536870912 /* 0.25f in Q31 */, onset_filter_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ v_add_fixed_no_hdrm( onset_filter_fx, onset_filter_subframe_fx, onset_filter_subframe_fx, hSpatParamRendCom->num_freq_bands ); /* Q31 */ p_onset_filter_fx = onset_filter_subframe_fx; /*q31*/ } -- GitLab From edeae1116cf183daed960d1bff67de35c8e7fb97 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 12:11:42 +0530 Subject: [PATCH 229/394] Revert changes related to one macro --- lib_enc/ivas_mc_param_enc_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 226e7c164..ba2c52073 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -994,6 +994,7 @@ static void ivas_param_mc_param_est_enc_fx( /* Cy for input channels */ FOR( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { +#ifdef IMPROVE_HIGH_COMPLEXITY_PARAM_MC_PRM_EST_NONBE a_e = norm_l( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band] ); a_fx = L_shl( slot_frame_f_real_fx[ch_idx1][cur_cldfb_band], a_e ); a_e = sub( add20gb, a_e ); @@ -1010,6 +1011,7 @@ static void ivas_param_mc_param_est_enc_fx( b_e = 0; move16(); } +#endif a_fx = slot_frame_f_real_fx[ch_idx1][cur_cldfb_band]; b_fx = slot_frame_f_imag_fx[ch_idx1][cur_cldfb_band]; move32(); -- GitLab From 99b3f1d116f25ddbb89cf2e5956c7944d54e499b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:24:00 +0200 Subject: [PATCH 230/394] change shr_r/shl_sat to shr_r_sat --- lib_dec/dec_gen_voic_fx.c | 21 +++++-------------- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 11 +--------- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++----- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 935200eea..492b32775 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -464,22 +464,11 @@ ivas_error decod_gen_voic_fx( test(); test(); #ifdef ISSUE_1751_replace_shl_ro - Word16 op16_1 = sub( Qenratio, 15 ); - Word16 op16_2 = sub( Qenratio, 10 ); - Word16 op16_3 = sub( Qsp_enratio, 15 ); - - /*Due to all shift directrions being possible, we need both possibilities, shl_sat and shr_r*/ - BASOP_SATURATE_WARNING_OFF - op16_1 = op16_1 >= 0 ? shr_r( enratio, op16_1 ) : shl_sat( enratio, negate( op16_1 ) ); - op16_2 = op16_2 >= 0 ? shr_r( sp_enratio, op16_2 ) : shl_sat( sp_enratio, negate( op16_2 ) ); - op16_3 = op16_3 >= 0 ? shr_r( sp_enratio, op16_3 ) : shl_sat( sp_enratio, negate( op16_3 ) ); - BASOP_SATURATE_WARNING_ON - - IF( GT_16( op16_1, 8192 ) && /*compare with 0.25 in Q15*/ - LT_16( op16_2, 15360 ) && /*compare with 15.0 in Q10*/ - GT_16( op16_3, 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ + LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ + GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index c817bd1b3..baad5c561 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -136,16 +136,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF #ifdef ISSUE_1751_replace_shl_ro - Word16 op1 = add( normXY, normCC ); - /*Both shift directiosn possible*/ - if ( op1 >= 0 ) - { - cc = shl_sat( cc, op1 ); - } - else - { - cc = shr_r( cc, negate( op1 ) ); - } + cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; cc = shl_ro( cc, add( normXY, normCC ), &Overflow ); diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 1ef10382e..e368e455c 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4428,9 +4428,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( lfeGain_fx_exp <= 0 ); - /*if assert is thrown, shl_sat can handle the left shift*/ - lfeGain_fx = shr_r( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 + lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 @@ -4447,9 +4445,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp #ifdef ISSUE_1751_replace_shl_ro - assert( transportGain_fx_exp <= 0 ); - /*if assert is thrown, shl_sat can handle the left shift*/ - transportGain_fx = shr_r( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 + transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 -- GitLab From b48e71bd74da31839b305b363852b3da3c2aee9b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:27:12 +0200 Subject: [PATCH 231/394] clang format patch --- lib_dec/dec_gen_voic_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 492b32775..a58cd19c9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -467,8 +467,8 @@ ivas_error decod_gen_voic_fx( IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ - LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ - LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ + LT_16( st_fx->bfi_pitch_fx, 9600 ) && /*Q6*/ + LT_16( pitch_buf_fx[( NB_SUBFR16k - 1 )], 9600 ) ) /*Q6*/ #else Flag Overflow; IF( GT_16( shl_ro( enratio, sub( 15, Qenratio ), &Overflow ), 8192 ) && /*compare with 0.25 in Q15*/ -- GitLab From dd70cef2abd8aab094e2a948daac856aa555eae4 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 07:36:54 +0000 Subject: [PATCH 232/394] deactivate all for testing --- lib_dec/dec_gen_voic_fx.c | 2 +- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index a58cd19c9..f311e6320 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,7 +463,7 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index baad5c561..f7b97f3f7 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index e368e455c..b56eace63 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4427,7 +4427,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; @@ -4444,7 +4444,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro +#ifdef ISSUE_1751_replace_shl_ro_ transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; -- GitLab From fb47da0dc6a30ad3a5fc32c94a2598bfaaf33573 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 09:52:51 +0200 Subject: [PATCH 233/394] buildfix --- lib_dec/dec_gen_voic_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index f311e6320..a58cd19c9 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -463,7 +463,7 @@ ivas_error decod_gen_voic_fx( test(); test(); test(); -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro IF( GT_16( shr_r_sat( enratio, sub( Qenratio, 15 ) ), 8192 ) && /*compare with 0.25 in Q15*/ LT_16( shr_r_sat( enratio, sub( Qenratio, 10 ) ), 15360 ) && /*compare with 15.0 in Q10*/ GT_16( shr_r_sat( sp_enratio, sub( Qsp_enratio, 15 ) ), 4915 ) && /*compare with 0.15 in Q15*/ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 8b772e13c..c826b72f0 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4265,7 +4265,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; - lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp & Overflow ); // Q15 + lfeGain_fx = shl_ro( lfeGain_fx, lfeGain_fx_exp, &Overflow ); // Q15 #endif } IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( hMasaLfeSynth->targetEneTransSmooth_fx, sub( Q31, hMasaLfeSynth->targetEneTransSmooth_q ), /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, sub( Q31, hMasaLfeSynth->transportEneSmooth_q ) ), 1 ) ) @@ -4282,7 +4282,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; - transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp & Overflow ); // Q15 + transportGain_fx = shl_ro( transportGain_fx, transportGain_fx_exp, &Overflow ); // Q15 #endif } j = 0; -- GitLab From ac6159c8b5cb574179f974501de2a2b2a7578e3d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 24 Jun 2025 19:45:13 +0530 Subject: [PATCH 234/394] Fix for 3GPP issue 1760: Decoder crash for OSBA ISM4SBA3 in apa_corrEnergy2dB_fx() Link #1760 --- lib_dec/ivas_jbm_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index fefae52f9..1404395cb 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1031,18 +1031,18 @@ ivas_error ivas_jbm_dec_tc_fx( { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 Q_p_output = 14; - move16(); Word16 nchan_transport; // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; move16(); nchan_out = nchan_transport; move16(); + Word16 Q_p_output = max( 3, sub( L_norm_arr( p_output_fx[sba_ch_idx], imult1616( output_frame, nchan_transport ) ), 1 ) ); FOR( ch = 0; ch < nchan_transport; ch++ ) { - Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); // Q_p_output + Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 } + Q_p_output = add( Q11, Q_p_output ); hSpar->hMdDec->Q_mixer_mat = 31; move16(); -- GitLab From 1b260941bd9e1db458633338094c817b9686a73c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 13:29:01 +0530 Subject: [PATCH 235/394] Fix for ltv crashes observed with -10dB files --- lib_dec/ivas_jbm_dec_fx.c | 3 ++- lib_dec/ivas_sba_rendering_internal_fx.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 1404395cb..e1ac2c1ff 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1037,7 +1037,8 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); nchan_out = nchan_transport; move16(); - Word16 Q_p_output = max( 3, sub( L_norm_arr( p_output_fx[sba_ch_idx], imult1616( output_frame, nchan_transport ) ), 1 ) ); + Word16 Q_p_output = s_max( 3, sub( L_norm_arr( p_output_fx[sba_ch_idx], imult1616( output_frame, nchan_transport ) ), 1 ) ); + Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 FOR( ch = 0; ch < nchan_transport; ch++ ) { Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 374efb593..7a96185b9 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -505,7 +505,7 @@ void ivas_sba_mix_matrix_determiner_fx( temp_fx = MAX16B; /*Q0*/ move32(); } - ELSE IF( LT_32( temp_fx, L_negate( PCM16_TO_FLT_FAC_FX ) ) ) + ELSE IF( LT_32( temp_fx, -( PCM16_TO_FLT_FAC_FX ) ) ) { temp_fx = -( PCM16_TO_FLT_FAC_FX ); /*Q0*/ move32(); -- GitLab From b1135facc34c6c6addfb2e5dcdef3295cd704e85 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 08:44:32 +0000 Subject: [PATCH 236/394] reactivate changes in ivas_dirac_output_synthesis_dec_fx.c --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index c826b72f0..19823d7c6 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -4261,7 +4261,7 @@ void ivas_lfe_synth_with_filters_fx( lfeGain_fx = extract_h( BASOP_Util_Divide3232_Scale_newton( hMasaLfeSynth->targetEneLfeSmooth_fx, L_add( EPSILON_FX, hMasaLfeSynth->transportEneSmooth_fx ), &lfeGain_fx_exp ) ); /*Q(31-(lfeGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneLfeSmooth_q))-16*/ lfeGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneLfeSmooth_q ), lfeGain_fx_exp ); lfeGain_fx = Sqrt16( lfeGain_fx, &lfeGain_fx_exp ); // Q15-lfeGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro lfeGain_fx = shr_r_sat( lfeGain_fx, negate( lfeGain_fx_exp ) ); // Q15 #else Flag Overflow; @@ -4278,7 +4278,7 @@ void ivas_lfe_synth_with_filters_fx( transportGain_fx = BASOP_Util_Divide3232_Scale( hMasaLfeSynth->targetEneTransSmooth_fx, /*EPSILON + */ hMasaLfeSynth->transportEneSmooth_fx, &transportGain_fx_exp ); /*Q=15-(transportGain_fx_exp+hMasaLfeSynth->transportEneSmooth_q-hMasaLfeSynth->targetEneTransSmooth_q)*/ transportGain_fx_exp = add( sub( hMasaLfeSynth->transportEneSmooth_q, hMasaLfeSynth->targetEneTransSmooth_q ), transportGain_fx_exp ); transportGain_fx = Sqrt16( transportGain_fx, &transportGain_fx_exp ); // q15-transportGain_fx_exp -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro transportGain_fx = shr_r_sat( transportGain_fx, negate( transportGain_fx_exp ) ); // Q15 #else Flag Overflow; -- GitLab From c862ad04ea5a08ef7e8b3927259f304facc7ea7e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 17 Jun 2025 13:26:57 +0200 Subject: [PATCH 237/394] fix voip be test job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59d11a2e9..d4e36a122 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -189,6 +189,7 @@ workflow: .test-job-linux-needs-testv-dir: extends: .test-job-linux before_script: + - !reference [ .job-linux, before_script ] - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - if [ ! -d "$TESTV_DIR" ]; then mkdir -p $TESTV_DIR; fi - cp -r scripts/testv/* $TESTV_DIR/ @@ -2042,7 +2043,6 @@ pages: - if: $UPDATE_PAGES script: - !reference [ .job-linux, before_script ] - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - python3 ci/setup_pages.py -- GitLab From 794393658fb27cf6866fadee4d00a3f01deaf075 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 10:10:45 +0000 Subject: [PATCH 238/394] lib_dec\jbm_pcmdsp_similarityestimation_fx.c : activate change --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index f7b97f3f7..baad5c561 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -135,7 +135,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normCC = add( normCC, 16 ); /* scale to Q15 with saturation */ BASOP_SATURATE_WARNING_OFF -#ifdef ISSUE_1751_replace_shl_ro_ +#ifdef ISSUE_1751_replace_shl_ro cc = shr_r_sat( cc, negate( add( normXY, normCC ) ) ); #else Flag Overflow; -- GitLab From fa6306a618ba00d3b2d3ec9896af90a52b76baa8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 25 Jun 2025 15:05:11 +0200 Subject: [PATCH 239/394] fix compiler warning --- lib_enc/ivas_omasa_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 0b0aa90c5..1d14eecc9 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -92,7 +92,7 @@ void computeIntensityVector_enc_fx( Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ); -static void computeReferencePower_omasa_ivas_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 *reference_power, const Word16 enc_param_start_band, const Word16 num_freq_bands, Word16 q_Cldfb, Word16 *ref_exp ); +static void computeReferencePower_omasa_ivas_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], Word32 *reference_power, const Word16 enc_param_start_band, const Word16 num_freq_bands, Word16 q_Cldfb, Word16 q_reference_power[CLDFB_NO_CHANNELS_MAX] ); /*--------------------------------------------------------------------------* * ivas_omasa_enc_open() * -- GitLab From 87caabb2da09f7113bf2d3c0ad9a86567e9d2d45 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 25 Jun 2025 17:02:37 +0200 Subject: [PATCH 240/394] Revert from change b21540b59f1d6cac6a5aee2a763befde42d383b1 Q0 for q_syn in PLC case. --- lib_dec/ivas_mdct_core_dec_fx.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 7f17bb0fc..1cce316f1 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1386,7 +1386,6 @@ void ivas_mdct_core_reconstruct_fx( ELSE /*ACELP core for ACELP-PLC */ { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN -#if 0 Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth @@ -1394,11 +1393,6 @@ void ivas_mdct_core_reconstruct_fx( // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 ); // Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 ); /////////////////////////////////////////////////////////////////////////////////// -#else - Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( 0, st->hTcxDec->q_old_synth ) ); // Q = st->hTcxDec->q_old_synth -> Q0 - Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( 0, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth -> Q0 - q_syn = 0; -#endif #endif assert( EQ_16( st->bfi, 1 ) ); /* PLC: [TCX: TD PLC] */ -- GitLab From f33e98ba734e2b6df1e4c859283009524ce52aed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 21:16:40 +0530 Subject: [PATCH 241/394] Non bit-exact optimizations in calculate_hodirac_sector_parameters_fx Reduction of ~10 WMOPS observed. --- lib_com/ivas_dirac_com_fx.c | 277 ++++++++++++++++++++++++++++++++++-- lib_com/options.h | 1 + 2 files changed, 263 insertions(+), 15 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 14dd6c148..befeb273c 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -1112,6 +1112,17 @@ void calculate_hodirac_sector_parameters_fx( Word16 i_sec, i_bin, i_band; Word32 p_real_fx, p_imag_fx, normI_fx, energy_fx, tmp_diff_fx; Word16 energy_exp, normI_exp, tmp_diff_exp; +#ifdef OPT_SBA_ENC_V2_NBE + Word16 tmp_exp_1 = sub( 33, shl( Qfac, 1 ) ); // 31 - (2 *Qfac - 2 ) + Word16 tmp_exp_2 = sub( 35, shl( Qfac, 1 ) ); // 31 - (2 *Qfac - 4 ) + Word32 tmp32_1, tmp32_2; + Word64 temp_x64 = 0, temp_y64 = 0, temp_z64 = 0; + Word16 tmp_scale = 0; + move64(); + move64(); + move64(); + move16(); +#endif Word32 sec_I_vec_x_fx[NUM_ANA_SECTORS]; Word32 sec_I_vec_y_fx[NUM_ANA_SECTORS]; @@ -1185,7 +1196,16 @@ void calculate_hodirac_sector_parameters_fx( move32(); energy_exp = 0; move16(); - +#ifdef OPT_SBA_ENC_V2_NBE + Word64 sec_I_vec_x_64_fx = 0; + Word64 sec_I_vec_y_64_fx = 0; + Word64 sec_I_vec_z_64_fx = 0; + Word64 energy_64_fx = 0; + move64(); + move64(); + move64(); + move64(); +#endif IF( i_sec == 0 ) { FOR( i_bin = band_grouping[i_band]; i_bin < band_grouping[i_band + 1]; i_bin++ ) @@ -1194,7 +1214,18 @@ void calculate_hodirac_sector_parameters_fx( move32(); Word32 sec_w_imag_fx, sec_x_imag_fx, sec_y_imag_fx, sec_z_imag_fx; Word32 sec_w_real_fx, sec_x_real_fx, sec_y_real_fx, sec_z_real_fx; - +#ifdef OPT_SBA_ENC_V2_NBE + sec_w_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ); // Qfac - 2 + sec_x_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_imag_fx = Msub_32_32( ( Msub_32_32( ( Madd_32_32( Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_imag_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_5_fx++ ) ); // Qfac - 2 + + sec_w_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_0_fx ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx ) ); // Qfac - 2 + sec_x_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_real_fx = Msub_32_32( ( Msub_32_32( Madd_32_32( Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ), HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_real_fx = Madd_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ); // Qfac - 2 + +#else sec_w_imag_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ) ); // Qfac - 2 sec_x_imag_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_imag_fx = L_sub( L_sub( L_add( Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ) ); // Qfac - 2 @@ -1204,14 +1235,17 @@ void calculate_hodirac_sector_parameters_fx( sec_x_real_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_real_fx = L_sub( L_sub( L_add( Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ) ); // Qfac - 2 sec_z_real_fx = L_add( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ) ); // Qfac - 2 +#endif +#ifndef OPT_SBA_ENC_V2_NBE Word16 p_q; Word32 tmp_x, tmp_y, tmp_z; Word16 n, n1, n2; - +#endif p_real_fx = Mpy_32_32( sec_w_real_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 p_imag_fx = Mpy_32_32( sec_w_imag_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 +#ifndef OPT_SBA_ENC_V2_NBE n1 = norm_l( p_real_fx ); n2 = norm_l( p_imag_fx ); @@ -1234,13 +1268,35 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_sec_I_vec_z_fx = BASOP_Util_Add_Mant32Exp( *p_sec_I_vec_z_fx, *p_sec_I_vec_z_exp, tmp_z, tmp_exp, p_sec_I_vec_z_exp ); move32(); - - Word32 tmp1; +#else + temp_x64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_x_real_fx ), p_imag_fx, sec_x_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_y64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_y_real_fx ), p_imag_fx, sec_y_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_z64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_z_real_fx ), p_imag_fx, sec_z_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + sec_I_vec_x_64_fx = W_add( sec_I_vec_x_64_fx, temp_x64 ); + sec_I_vec_y_64_fx = W_add( sec_I_vec_y_64_fx, temp_y64 ); + sec_I_vec_z_64_fx = W_add( sec_I_vec_z_64_fx, temp_z64 ); + + Word64 tmp1; +#endif Word64 tmp2, tmp3, tmp4, sec_sum64; +#ifndef OPT_SBA_ENC_V2_NBE + Word32 tmp1; Word32 tmp5, sec_sum; tmp_exp = sub( 62, add( p_q, p_q ) ); tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( p_real_fx, p_real_fx ), tmp_exp, Mpy_32_32( p_imag_fx, p_imag_fx ), tmp_exp, &tmp_exp ); +#endif +#ifdef OPT_SBA_ENC_V2_NBE + tmp1 = W_mac_32_32( W_mult_32_32( p_real_fx, p_real_fx ), p_imag_fx, p_imag_fx ); // 2 * (Qfac - 3) + 1 + tmp1 = W_shl( tmp1, 2 ); // 2 * (Qfac - 2) + 1 + tmp2 = W_mac_32_32( W_mult_32_32( sec_x_real_fx, sec_x_real_fx ), sec_x_imag_fx, sec_x_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp3 = W_mac_32_32( W_mult_32_32( sec_y_real_fx, sec_y_real_fx ), sec_y_imag_fx, sec_y_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp4 = W_mac_32_32( W_mult_32_32( sec_z_real_fx, sec_z_real_fx ), sec_z_imag_fx, sec_z_imag_fx ); // 2 * (Qfac - 2) + 1 + sec_sum64 = W_add( tmp1, W_add( W_add( tmp2, tmp3 ), tmp4 ) ); // 2 * (Qfac - 2) + 1 + + // instead dividing changed Q// + energy_64_fx = W_add( energy_64_fx, sec_sum64 ); // 2 * (Qfac - 2) + 1 + 1 +#else tmp2 = W_add( W_mult0_32_32( sec_x_real_fx, sec_x_real_fx ), W_mult0_32_32( sec_x_imag_fx, sec_x_imag_fx ) ); // 2 * (Qfac - 2) tmp3 = W_add( W_mult0_32_32( sec_y_real_fx, sec_y_real_fx ), W_mult0_32_32( sec_y_imag_fx, sec_y_imag_fx ) ); // 2 * (Qfac - 2) tmp4 = W_add( W_mult0_32_32( sec_z_real_fx, sec_z_real_fx ), W_mult0_32_32( sec_z_imag_fx, sec_z_imag_fx ) ); // 2 * (Qfac - 2) @@ -1256,7 +1312,51 @@ void calculate_hodirac_sector_parameters_fx( tmp5 = BASOP_Util_Add_Mant32Exp( tmp1, tmp_exp, sec_sum, sec_sum_exp, &tmp_exp ); energy_fx = BASOP_Util_Add_Mant32Exp( energy_fx, energy_exp, tmp5, tmp_exp, &energy_exp ); +#endif + } +#ifdef OPT_SBA_ENC_V2_NBE + tmp_scale = sub( W_norm( energy_64_fx ), 32 ); + energy_fx = W_shl_sat_l( energy_64_fx, tmp_scale ); + energy_exp = sub( tmp_exp_1, tmp_scale ); + if ( energy_fx == 0 ) + { + energy_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_x_64_fx ), 32 ); + *p_sec_I_vec_x_fx = W_shl_sat_l( sec_I_vec_x_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_x_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_x_fx == 0 ) + { + *p_sec_I_vec_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_y_64_fx ), 32 ); + *p_sec_I_vec_y_fx = W_shl_sat_l( sec_I_vec_y_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_y_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_y_fx == 0 ) + { + *p_sec_I_vec_y_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_z_64_fx ), 32 ); + *p_sec_I_vec_z_fx = W_shl_sat_l( sec_I_vec_z_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_z_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_z_fx == 0 ) + { + *p_sec_I_vec_z_exp = 0; + move16(); } +#endif } ELSE { @@ -1267,6 +1367,18 @@ void calculate_hodirac_sector_parameters_fx( Word32 sec_w_imag_fx, sec_x_imag_fx, sec_y_imag_fx, sec_z_imag_fx; Word32 sec_w_real_fx, sec_x_real_fx, sec_y_real_fx, sec_z_real_fx; +#ifdef OPT_SBA_ENC_V2_NBE + sec_w_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ); // Qfac - 2 + sec_x_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_imag_fx = Madd_32_32( ( Madd_32_32( ( Madd_32_32( Mpy_32_32( -HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_imag_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_ImagBuffer_5_fx++ ) ); // Qfac - 2 + + sec_w_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_0_fx ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx ) ); // Qfac - 2 + sec_x_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ); // Qfac - 2 + sec_y_real_fx = Madd_32_32( ( Madd_32_32( ( Madd_32_32( Mpy_32_32( -HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ); // Qfac - 2 + sec_z_real_fx = Msub_32_32( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ); // Qfac - 2 + +#else sec_w_imag_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_0_fx ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx ) ) ); // Qfac - 2 sec_x_imag_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_imag_fx = L_add( L_add( L_add( Mpy_32_32( -HODIRAC_FAC3, *( p_ImagBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_ImagBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_ImagBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_ImagBuffer_8_fx++ ) ) ); // Qfac - 2 @@ -1276,20 +1388,21 @@ void calculate_hodirac_sector_parameters_fx( sec_x_real_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_3_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_4_fx++ ) ) ); // Qfac - 2 sec_y_real_fx = L_add( L_add( L_add( Mpy_32_32( -HODIRAC_FAC3, *( p_RealBuffer_0_fx++ ) ), Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_1_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC3, *( p_RealBuffer_6_fx++ ) ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_8_fx++ ) ) ); // Qfac - 2 sec_z_real_fx = L_sub( Mpy_32_32( HODIRAC_FAC1, *( p_RealBuffer_2_fx++ ) ), Mpy_32_32( HODIRAC_FAC2, *( p_RealBuffer_5_fx++ ) ) ); // Qfac - 2 - +#endif +#ifndef OPT_SBA_ENC_V2_NBE Word16 p_q; + Word32 tmp_x, tmp_y, tmp_z; + Word16 n, n1, n2; +#endif p_real_fx = Mpy_32_32( sec_w_real_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 p_imag_fx = Mpy_32_32( sec_w_imag_fx, w_fx ); // ( Qfac - 2 ) + 30 - 31 = Qfac - 3 - Word32 tmp_x, tmp_y, tmp_z; - Word16 n, n1, n2; - +#ifndef OPT_SBA_ENC_V2_NBE n1 = norm_l( p_real_fx ); n2 = norm_l( p_imag_fx ); n = s_min( n1, n2 ); - p_real_fx = L_shl( p_real_fx, n ); p_imag_fx = L_shl( p_imag_fx, n ); @@ -1307,13 +1420,35 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_sec_I_vec_z_fx = BASOP_Util_Add_Mant32Exp( *p_sec_I_vec_z_fx, *p_sec_I_vec_z_exp, tmp_z, tmp_exp, p_sec_I_vec_z_exp ); move32(); - - Word32 tmp1; +#else + temp_x64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_x_real_fx ), p_imag_fx, sec_x_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_y64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_y_real_fx ), p_imag_fx, sec_y_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + temp_z64 = W_mac_32_32( W_mult_32_32( p_real_fx, sec_z_real_fx ), p_imag_fx, sec_z_imag_fx ); // ( Qfac - 3 ) + ( Qfac - 2 ) + 1 = 2 * Qfac - 4 + sec_I_vec_x_64_fx = W_add( sec_I_vec_x_64_fx, temp_x64 ); + sec_I_vec_y_64_fx = W_add( sec_I_vec_y_64_fx, temp_y64 ); + sec_I_vec_z_64_fx = W_add( sec_I_vec_z_64_fx, temp_z64 ); + + Word64 tmp1; +#endif Word64 tmp2, tmp3, tmp4, sec_sum64; +#ifndef OPT_SBA_ENC_V2_NBE + Word32 tmp1; Word32 tmp5, sec_sum; tmp_exp = sub( 62, add( p_q, p_q ) ); tmp1 = BASOP_Util_Add_Mant32Exp( Mpy_32_32( p_real_fx, p_real_fx ), tmp_exp, Mpy_32_32( p_imag_fx, p_imag_fx ), tmp_exp, &tmp_exp ); +#endif +#ifdef OPT_SBA_ENC_V2_NBE + tmp1 = W_mac_32_32( W_mult_32_32( p_real_fx, p_real_fx ), p_imag_fx, p_imag_fx ); // 2 * (Qfac - 3) + 1 + tmp1 = W_shl( tmp1, 2 ); // 2 * (Qfac - 2) + 1 + tmp2 = W_mac_32_32( W_mult_32_32( sec_x_real_fx, sec_x_real_fx ), sec_x_imag_fx, sec_x_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp3 = W_mac_32_32( W_mult_32_32( sec_y_real_fx, sec_y_real_fx ), sec_y_imag_fx, sec_y_imag_fx ); // 2 * (Qfac - 2) + 1 + tmp4 = W_mac_32_32( W_mult_32_32( sec_z_real_fx, sec_z_real_fx ), sec_z_imag_fx, sec_z_imag_fx ); // 2 * (Qfac - 2) + 1 + sec_sum64 = W_add( tmp1, W_add( W_add( tmp2, tmp3 ), tmp4 ) ); // 2 * (Qfac - 2) + 1 + + // instead dividing changed Q// + energy_64_fx = W_add( energy_64_fx, sec_sum64 ); // 2 * (Qfac - 2) + 1 + 1 +#else tmp2 = W_add( W_mult0_32_32( sec_x_real_fx, sec_x_real_fx ), W_mult0_32_32( sec_x_imag_fx, sec_x_imag_fx ) ); // 2 * (Qfac - 2) tmp3 = W_add( W_mult0_32_32( sec_y_real_fx, sec_y_real_fx ), W_mult0_32_32( sec_y_imag_fx, sec_y_imag_fx ) ); // 2 * (Qfac - 2) tmp4 = W_add( W_mult0_32_32( sec_z_real_fx, sec_z_real_fx ), W_mult0_32_32( sec_z_imag_fx, sec_z_imag_fx ) ); // 2 * (Qfac - 2) @@ -1322,14 +1457,56 @@ void calculate_hodirac_sector_parameters_fx( sec_sum64 = W_shl( sec_sum64, n ); // 2 * (Qfac - 2) + n sec_sum = W_extract_h( sec_sum64 ); // 2 * (Qfac - 2) + n - 32 = 2 * Qfac + n - 36 sec_sum_exp = sub( 67, add( shl( Qfac, 1 ), n ) ); - // divide by 2: tmp1 = L_shr( tmp1, 1 ); sec_sum = L_shr( sec_sum, 1 ); - tmp5 = BASOP_Util_Add_Mant32Exp( tmp1, tmp_exp, sec_sum, sec_sum_exp, &tmp_exp ); energy_fx = BASOP_Util_Add_Mant32Exp( energy_fx, energy_exp, tmp5, tmp_exp, &energy_exp ); +#endif + } +#ifdef OPT_SBA_ENC_V2_NBE + tmp_scale = sub( W_norm( energy_64_fx ), 32 ); + energy_fx = W_shl_sat_l( energy_64_fx, tmp_scale ); + energy_exp = sub( tmp_exp_1, tmp_scale ); + if ( energy_fx == 0 ) + { + energy_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_x_64_fx ), 32 ); + *p_sec_I_vec_x_fx = W_shl_sat_l( sec_I_vec_x_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_x_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_x_fx == 0 ) + { + *p_sec_I_vec_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( sec_I_vec_y_64_fx ), 32 ); + *p_sec_I_vec_y_fx = W_shl_sat_l( sec_I_vec_y_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_y_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_y_fx == 0 ) + { + *p_sec_I_vec_y_exp = 0; + move16(); } + + tmp_scale = sub( W_norm( sec_I_vec_z_64_fx ), 32 ); + *p_sec_I_vec_z_fx = W_shl_sat_l( sec_I_vec_z_64_fx, tmp_scale ); + move32(); + *p_sec_I_vec_z_exp = sub( tmp_exp_2, tmp_scale ); + move16(); + if ( *p_sec_I_vec_z_fx == 0 ) + { + *p_sec_I_vec_z_exp = 0; + move16(); + } +#endif } IF( hDirAC->firstrun_sector_params ) @@ -1354,7 +1531,62 @@ void calculate_hodirac_sector_parameters_fx( ELSE { Word32 w_fx = L_sub( ONE_IN_Q30, beta_fx ); // Q30 +#ifdef OPT_SBA_ENC_V2_NBE + Word32 tmp_1, tmp_2, tmp_3, tmp_sec_1, tmp_sec_2, tmp_sec_3; + Word16 e_x, e_y, e_z; + move16(); + + e_x = s_max( *p_sec_I_vec_x_exp, *p_sec_I_vec_smth_x_exp ); + e_y = s_max( *p_sec_I_vec_y_exp, *p_sec_I_vec_smth_y_exp ); + e_z = s_max( *p_sec_I_vec_z_exp, *p_sec_I_vec_smth_z_exp ); + + tmp_1 = L_shr( *p_sec_I_vec_x_fx, sub( e_x, *p_sec_I_vec_x_exp ) ); // e_x + tmp_2 = L_shr( *p_sec_I_vec_y_fx, sub( e_y, *p_sec_I_vec_y_exp ) ); // e_y + tmp_3 = L_shr( *p_sec_I_vec_z_fx, sub( e_z, *p_sec_I_vec_z_exp ) ); // e_z + tmp_sec_1 = L_shr( *p_sec_I_vec_smth_x_fx, sub( e_x, *p_sec_I_vec_smth_x_exp ) ); // e_x + tmp_sec_2 = L_shr( *p_sec_I_vec_smth_y_fx, sub( e_y, *p_sec_I_vec_smth_y_exp ) ); // e_y + tmp_sec_3 = L_shr( *p_sec_I_vec_smth_z_fx, sub( e_z, *p_sec_I_vec_smth_z_exp ) ); // e_z + + + temp_x64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_1 ), beta_fx, tmp_sec_1 ); // 31-e_x+30+1=62-e_x + temp_y64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_2 ), beta_fx, tmp_sec_2 ); // 31-e_y+30+1=62-e_y + temp_z64 = W_mac_32_32( W_mult_32_32( w_fx, tmp_3 ), beta_fx, tmp_sec_3 ); // 31-e_z+30+1=62-e_z + + tmp_scale = sub( W_norm( temp_x64 ), 32 ); + *p_sec_I_vec_smth_x_fx = W_shl_sat_l( temp_x64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_x_exp = sub( sub( e_x, 31 ), tmp_scale ); // 31-(62-e_x+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_x_fx == 0 ) + { + *p_sec_I_vec_smth_x_exp = 0; + move16(); + } + + tmp_scale = sub( W_norm( temp_y64 ), 32 ); + *p_sec_I_vec_smth_y_fx = W_shl_sat_l( temp_y64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_y_exp = sub( sub( e_y, 31 ), tmp_scale ); // 31-(62-e_z+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_y_fx == 0 ) + { + *p_sec_I_vec_smth_y_exp = 0; + move16(); + } + tmp_scale = sub( W_norm( temp_z64 ), 32 ); + *p_sec_I_vec_smth_z_fx = W_shl_sat_l( temp_z64, tmp_scale ); + move32(); + *p_sec_I_vec_smth_z_exp = sub( sub( e_z, 31 ), tmp_scale ); // 31-(62-e_z+tmp_scale)=e_x-tmp_scale-31 + move16(); + if ( *p_sec_I_vec_smth_z_fx == 0 ) + { + *p_sec_I_vec_smth_z_exp = 0; + move16(); + } + + *p_energy_smth_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, energy_fx ), add( energy_exp, 1 ), Mpy_32_32( beta_fx, *p_energy_smth_fx ), add( *p_energy_smth_exp, 1 ), p_energy_smth_exp ); +#else *p_sec_I_vec_smth_x_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_x_fx ), add( *p_sec_I_vec_x_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_x_fx ), add( *p_sec_I_vec_smth_x_exp, 1 ), p_sec_I_vec_smth_x_exp ); move32(); *p_sec_I_vec_smth_y_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_y_fx ), add( *p_sec_I_vec_y_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_y_fx ), add( *p_sec_I_vec_smth_y_exp, 1 ), p_sec_I_vec_smth_y_exp ); @@ -1362,6 +1594,8 @@ void calculate_hodirac_sector_parameters_fx( *p_sec_I_vec_smth_z_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, *p_sec_I_vec_z_fx ), add( *p_sec_I_vec_z_exp, 1 ), Mpy_32_32( beta_fx, *p_sec_I_vec_smth_z_fx ), add( *p_sec_I_vec_smth_z_exp, 1 ), p_sec_I_vec_smth_z_exp ); move32(); *p_energy_smth_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( w_fx, energy_fx ), add( energy_exp, 1 ), Mpy_32_32( beta_fx, *p_energy_smth_fx ), add( *p_energy_smth_exp, 1 ), p_energy_smth_exp ); +#endif + move32(); } IF( LT_32( energy_fx, EPSILON_FX_SMALL ) ) @@ -1404,7 +1638,7 @@ void calculate_hodirac_sector_parameters_fx( *p_ene_exp = *p_energy_smth_exp; move16(); - tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) ); + tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add_sat( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) ); tmp_e = add( tmp_e, sub( normI_exp, *p_energy_smth_exp ) ); tmp32 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( tmp32 ), tmp_e, &tmp_e ); *p_diff_fx = tmp32; @@ -1438,6 +1672,18 @@ void calculate_hodirac_sector_parameters_fx( } ELSE { +#ifdef OPT_SBA_ENC_V2_NBE + tmp32_1 = L_sub( ONE_IN_Q29, tmp_diff_fx ); + tmp32_2 = L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ); + + // *p_azi = 2.f * (1.f - tmp_diff) * *p_azi + (2.f * tmp_diff - 1.f) * *p_azi_prev + *p_azi_fx = L_shl( Madd_32_32( Mpy_32_32( tmp32_1, *p_azi_fx ), tmp32_2, *p_azi_prev_fx ), 3 ); // Q29 + Q23 - 31 + 2 = Q23 + move32(); + + // *p_ele = 2.f * (1.f - tmp_diff) * *p_ele + (2.f * tmp_diff - 1.f) * *p_ele_prev + *p_ele_fx = L_shl( Madd_32_32( Mpy_32_32( tmp32_1, *p_ele_fx ), tmp32_2, *p_ele_prev_fx ), 3 ); // Q29 + Q23 - 31 + 2 = Q23 + move32(); +#else *p_azi_fx = L_shl( L_add( Mpy_32_32( L_sub( ONE_IN_Q29, tmp_diff_fx ), *p_azi_fx ), Mpy_32_32( L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ), *p_azi_prev_fx ) ), 1 ); // Q29 + Q23 - 31 = Q21 move32(); *p_ele_fx = L_shl( L_add( Mpy_32_32( L_sub( ONE_IN_Q29, tmp_diff_fx ), *p_ele_fx ), Mpy_32_32( L_sub( tmp_diff_fx, ONE_IN_Q29 / 2 ), *p_ele_prev_fx ) ), 1 ); // Q29 + Q23 - 31 = Q21 @@ -1446,6 +1692,7 @@ void calculate_hodirac_sector_parameters_fx( move32(); *p_ele_fx = L_shl( *p_ele_fx, 2 ); // Q21 -> Q23; move32(); +#endif } } ELSE diff --git a/lib_com/options.h b/lib_com/options.h index 5f33170bf..bd73d566e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,6 +82,7 @@ #define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_DEC_V2_BE #define OPT_SBA_ENC_V2_BE +#define OPT_SBA_ENC_V2_NBE #define OPT_SBA_ENC_V1_BE #define OPT_SBA_DEC_PATH /* Optimization made in SBA decoding path */ #define OPT_IVAS_FILTER_ROM /* Optimization made in IVAS filter table */ -- GitLab From 5c841807a9b62dbce162183a7dd4e1e859f6f476 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 26 Jun 2025 11:45:48 +0530 Subject: [PATCH 242/394] Bug fix in front_vad_fx for lp_speech, precision improvements in msvq_enc --- lib_com/basop_util.c | 20 +++ lib_com/basop_util.h | 1 + lib_enc/ivas_front_vad_fx.c | 4 +- lib_enc/lsf_msvq_ma_enc_fx.c | 332 ++++++++++++++++++++++++++++++++++- lib_enc/prot_fx_enc.h | 16 ++ 5 files changed, 367 insertions(+), 6 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 7903d3580..4c7ebea26 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1916,6 +1916,26 @@ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len ) return indx; } +Word16 findIndexOfMinWord64( Word64 *x, const Word16 len ) +{ + Word16 i, indx; + + + indx = 0; + move16(); + FOR( i = 1; i < len; i++ ) + { + if ( LT_64( x[i], x[indx] ) ) + { + indx = i; + move16(); + } + } + + + return indx; +} + Word16 imult1616( Word16 x, Word16 y ) { diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index b5c69e1dd..c95bf8100 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -536,6 +536,7 @@ Word16 findIndexOfMinWord16( Word16 *x, const Word16 len ); \return index of min Word32 */ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len ); +Word16 findIndexOfMinWord64( Word64 *x, const Word16 len ); /****************************************************************************/ /*! diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 963e363b2..ec6a918b9 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -203,8 +203,6 @@ ivas_error front_vad_fx( move16(); FOR( n = 0; n < n_chan; n++ ) { - hFrontVads[n]->lp_speech_fx = shr( hFrontVads[n]->lp_speech_fx, 1 ); - move16(); scale_inp = s_min( sts[n]->q_inp, hCPE->hFrontVad[n]->q_mem_decim ); Scale_sig( sts[n]->input_fx, input_frame, sub( scale_inp, sts[n]->q_inp ) ); @@ -389,7 +387,7 @@ ivas_error front_vad_create_fx( } wb_vad_init_ivas_fx( hFrontVad->hVAD ); - hFrontVad->lp_speech_fx = 11520; // Q9/* Initialize the long-term active speech level in dB */ + hFrontVad->lp_speech_fx = 11520; // 45.0f in Q8 /* Initialize the long-term active speech level in dB */ move16(); hFrontVad->lp_noise_fx = 0; /* Initialize the long-term noise level in dB */ move16(); diff --git a/lib_enc/lsf_msvq_ma_enc_fx.c b/lib_enc/lsf_msvq_ma_enc_fx.c index cf855bd19..6056c0c46 100644 --- a/lib_enc/lsf_msvq_ma_enc_fx.c +++ b/lib_enc/lsf_msvq_ma_enc_fx.c @@ -468,6 +468,33 @@ static void depack_sub_values_fx( Word16 *pTmp, const Word16 *p1, const Word16 * } +static Word64 depack_mul_values_fx64( Word32 *Tmp, const Word16 *w, const Word16 *cbp, const Word16 N ) +{ + Word16 i, val0, val1, val2, val3; + Word64 en; + + en = 0; + move32(); + FOR( i = 0; i < N; i += 4 ) + { + depack_4_values( cbp + i_mult( shr( i, 2 ), 3 ), val0, val1, val2, val3 ) + Tmp[i + 0] = L_mult0( w[i + 0], val0 ); // Q8 * Q2.56 + move16(); + en = W_mac_32_16( en, Tmp[i + 0], val0 ); // Q8 * Q2.56 * 2.56 * Q1 + Tmp[i + 1] = L_mult0( w[i + 1], val1 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 1], val1 ); + Tmp[i + 2] = L_mult0( w[i + 2], val2 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 2], val2 ); + Tmp[i + 3] = L_mult0( w[i + 3], val3 ); + move16(); + en = W_mac_32_16( en, Tmp[i + 3], val3 ); + } + + return en; // Q8 * Q2.56 * 2.56 * Q1 +} + /*--------------------------------------------------------------------------* * msvq_enc_find_p_max_8() * @@ -522,6 +549,54 @@ static Word16 msvq_enc_find_p_max_8_fx( Word32 dist[] ) } +static Word16 msvq_enc_find_p_max_8_fx64( Word64 dist[] ) +{ + Word16 p_max; + + p_max = 0; + move16(); + + BASOP_SATURATE_WARNING_OFF_EVS + if ( GT_64( dist[1], dist[p_max] ) ) + { + p_max = 1; + move16(); + } + if ( GT_64( dist[2], dist[p_max] ) ) + { + p_max = 2; + move16(); + } + if ( GT_64( dist[3], dist[p_max] ) ) + { + p_max = 3; + move16(); + } + if ( GT_64( dist[4], dist[p_max] ) ) + { + p_max = 4; + move16(); + } + if ( GT_64( dist[5], dist[p_max] ) ) + { + p_max = 5; + move16(); + } + if ( GT_64( dist[6], dist[p_max] ) ) + { + p_max = 6; + move16(); + } + if ( GT_64( dist[7], dist[p_max] ) ) + { + p_max = 7; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + return p_max; +} + + /*--------------------------------------------------------------------------* * msvq_enc_find_p_max_6() * @@ -565,6 +640,43 @@ static Word16 msvq_enc_find_p_max_6_fx( Word32 dist[] ) return p_max; } +static Word16 msvq_enc_find_p_max_6_fx64( Word64 dist[] ) +{ + Word16 p_max; + + p_max = 0; + move16(); + + BASOP_SATURATE_WARNING_OFF_EVS + if ( GT_64( dist[1], dist[p_max] ) ) + { + p_max = 1; + move16(); + } + if ( GT_64( dist[2], dist[p_max] ) ) + { + p_max = 2; + move16(); + } + if ( GT_64( dist[3], dist[p_max] ) ) + { + p_max = 3; + move16(); + } + if ( GT_64( dist[4], dist[p_max] ) ) + { + p_max = 4; + move16(); + } + if ( GT_64( dist[5], dist[p_max] ) ) + { + p_max = 5; + move16(); + } + BASOP_SATURATE_WARNING_ON_EVS + return p_max; +} + /*--------------------------------------------------------------------------* * msvq_enc_fx() @@ -787,7 +899,222 @@ void msvq_enc_fx( return; } +void msvq_enc_lsf_fx64( + const Word16 *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) (10Q5 * 1.28) */ + const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const Word16 u[], /* i : Vector to be encoded (prediction and mean removed)(Q14Q1*1.28) */ + const Word16 *levels, /* i : Number of levels in each stage */ + const Word16 maxC, /* i : Tree search size (number of candidates kept from */ + /* one stage to the next == M-best) */ + const Word16 stages, /* i : Number of stages */ + const Word16 w[], /* i : Weights Q8*/ + const Word16 N, /* i : Vector dimension */ + const Word16 maxN, /* i : Codebook dimension */ + Word16 Idx[] /* o : Indices */ +) +{ + Word16 j; + const Word16 *cbp; + Word16 p2i; + Word16 resid_buf[2 * LSFMBEST_MAX * M_MAX], *resid[2]; + Word16 *pTmp, *p1; + Word16 *indices[2], m, s, c, c2, p_max, i; + Word32 Tmp32[M_MAX]; + Word16 idx_buf[2 * LSFMBEST_MAX * MAX_VQ_STAGES_USED], parents[LSFMBEST_MAX]; + Word64 *dist_64[2], en64, tmp64; + Word64 dist_buf_64[2 * LSFMBEST_MAX]; + Word16 ( *func_ptr64 )( Word64 * ); + Word16 N34; + Word16 n, maxn, start; + + /*----------------------------------------------------------------* + * Allocate memory for previous (parent) and current nodes. + * Parent node is indexed [0], current node is indexed [1]. + *----------------------------------------------------------------*/ + indices[0] = idx_buf; + indices[1] = idx_buf + maxC * stages; /*move16();*/ + /*vr_iset(0, idx_buf, 2*stages*maxC);*/ + set16_fx( idx_buf, 0, (Word16) ( 2 * stages * maxC ) ); + + resid[0] = resid_buf; + resid[1] = resid_buf + maxC * N; /*move16();*/ + + dist_64[0] = dist_buf_64; + dist_64[1] = dist_buf_64 + maxC; /*move16();*/ + + /*vr_iset(0, parents, maxC);*/ + set16_fx( parents, 0, maxC ); + + + func_ptr64 = msvq_enc_find_p_max_6_fx64; + move16(); + if ( EQ_16( maxC, 8 ) ) + { + func_ptr64 = msvq_enc_find_p_max_8_fx64; + move16(); + } + + /*----------------------------------------------------------------* + * LSF weights are normalized, so it is always better to multiply it first + * Set up inital distance vector + *----------------------------------------------------------------*/ + /* Q0/16 * Qw_norm/16 << 1 >> 16 => Qwnorm-15/16 * Q0/16 << 1 => Qwnorm-14/32 * 6.5536 */ + Word64 ss2_64; + ss2_64 = W_mult_32_16( L_mult0( u[0], w[0] ), u[0] ); + // Q8 * Q2.56 * 2.56 * Q1 + FOR( j = 1; j < N; j++ ) + { + ss2_64 = W_mac_32_16( ss2_64, L_mult0( u[j], w[j] ), u[j] ); + } + + /* Set up inital error (residual) vectors */ + pTmp = resid[1]; /*move16();*/ + FOR( c = 0; c < maxC; c++ ) + { + Copy( u, pTmp + c * N, N ); + dist_64[1][c] = ss2_64; + move64(); + } + + /* Loop over all stages */ + m = 1; + move16(); + FOR( s = 0; s < stages; s++ ) + { + /* codebook pointer is set to point to first stage */ + cbp = cb[s]; /*3Q12*1.28*/ + move16(); + + /* Set up pointers to parent and current nodes */ + swap( indices[0], indices[1], Word16 * ); + move16(); + move16(); + move16(); + move16(); + swap( resid[0], resid[1], Word16 * ); + move16(); + move16(); + move16(); + swap( dist_64[0], dist_64[1], Word64 * ); + move64(); + move64(); + move64(); + + /* p_max points to maximum distortion node (worst of best) */ + p_max = 0; + move16(); + + n = N; + move16(); + maxn = maxN; + move16(); + if ( dims ) + { + n = dims[s]; + move16(); + } + if ( dims ) + { + maxn = n; + move16(); + } + + assert( ( maxn % 4 ) == 0 ); + N34 = mult( maxn, 24576 /*0.75f Q15*/ ); + start = 0; + move16(); + if ( offs ) + { + start = offs[s]; + move16(); + } + + set32_fx( Tmp32, 0, start ); + set32_fx( Tmp32 + start + n, 0, sub( N, add( start, n ) ) ); + + /* Set distortions to a large value */ + FOR( j = 0; j < maxC; j++ ) + { + dist_64[1][j] = LLONG_MAX; + move64(); + } + + FOR( j = 0; j < levels[s]; j++ ) + { + /* Compute weighted codebook element and its energy */ + en64 = depack_mul_values_fx64( Tmp32 + start, w + start, cbp, n ); // Q8 + // en64: Q8 * Q2.56 * Q2.56 * q1 + // Tmp: 2.56 * Q8 + + cbp += N34; /* pointer is incremented */ + + /* Iterate over all parent nodes */ + FOR( c = 0; c < m; c++ ) + { + pTmp = &resid[0][c * N]; // this resid buffer is initial lsf values + /*tmp = (*pTmp++) * Tmp[0];*/ + Word64 t164 = 0; + move64(); + t164 = W_mult_32_16( Tmp32[0], pTmp[0] ); // 2.56 * Q8 * Q2.56 * Q1 + // Tmp32: Q8 * Q2.56 + FOR( i = 1; i < N; i++ ) + { + t164 = W_mac_32_16( t164, Tmp32[i], pTmp[i] ); // 2.56 * Q8 * Q2.56 * Q1 + } + + tmp64 = W_add( dist_64[0][c], W_sub( en64, W_shl( t164, 1 ) ) ); + t164 = W_sub( tmp64, dist_64[1][p_max] ); + IF( t164 <= 0 ) + { + /* Replace worst */ + dist_64[1][p_max] = tmp64; + move64(); + indices[1][p_max * stages + s] = j; + move16(); + parents[p_max] = c; + move16(); + + p_max = ( *func_ptr64 )( dist_64[1] ); + + } /*IF (L_sub(tmp,dist[1][p_max]) < 0) */ + } /* FOR (c=0; c Date: Thu, 26 Jun 2025 09:03:16 +0200 Subject: [PATCH 243/394] add ISSUE_1772_replace_shr_o macro --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 5f33170bf..b16792633 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -98,5 +98,6 @@ #define NONBE_FIX_864_JBM_RENDER_FRAMESIZE /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */ #define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ +#define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ #endif -- GitLab From c3b58b686f45914d97845af03668f1e7be7f97dd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 26 Jun 2025 09:03:39 +0200 Subject: [PATCH 244/394] replaced some shr_o by shr_sat --- lib_com/deemph_fx.c | 4 ++++ lib_com/low_rate_band_att_fx.c | 8 ++++++++ lib_com/syn_filt_fx.c | 10 ++++++++++ lib_dec/FEC_HQ_core_fx.c | 8 ++++++++ lib_dec/FEC_HQ_phase_ecu_fx.c | 6 ++++++ lib_enc/ari_hm_enc_fx.c | 4 ++++ lib_enc/cod_tcx_fx.c | 8 ++++++++ 7 files changed, 48 insertions(+) diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index 9bc20cb6f..b8e3a72cd 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -197,7 +197,11 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W { FOR( i = 0; i < L; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ +#else L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ +#endif x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ move16(); } diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index e51d2807b..d762d628d 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -97,7 +97,11 @@ void ivas_fine_gain_pred_fx( /*gp *= 1.0f - 0.05f / accuracy; */ tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ +#ifdef ISSUE_1772_replace_shr_o + tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ +#else tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ +#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ @@ -205,7 +209,11 @@ void fine_gain_pred_fx( /*gp *= 1.0f - 0.05f / accuracy; */ tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ +#ifdef ISSUE_1772_replace_shr_o + tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ +#else tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */ +#endif tmp = sub( 32767, tmp ); tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */ gp = mult_r( tmp, gp ); /*15+12+1-16=12 */ diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index ada0d243e..1216c4533 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -188,14 +188,20 @@ void syn_filt_fx( Word16 *yy; Word32 s; Word16 q; +#ifndef ISSUE_1772_replace_shr_o Flag Overflow = 0; move16(); +#endif Word16 a0; yy = &buf[0]; q = add( norm_s( a[0] ), 1 ); +#ifdef ISSUE_1772_replace_shr_o + a0 = shr_sat( a[0], shift ); /* input / 2^shift */ +#else a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ +#endif /*------------------------------------------------------------------* * copy initial filter states into synthesis buffer and do synthesis @@ -373,7 +379,11 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W *-----------------------------------------------------------------------*/ mem += m; /*move16();*/ +#ifdef ISSUE_1772_replace_shr_o + a0 = shr_sat( a[0], shift ); /* input / 2^shift */ +#else a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ +#endif /*-----------------------------------------------------------------------* * Do the filtering *-----------------------------------------------------------------------*/ diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index cc03dcf52..40e26df9c 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -638,7 +638,11 @@ void ivas_HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1772_replace_shr_o + *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); @@ -924,7 +928,11 @@ void HQ_FEC_Mem_update_fx( exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] ); tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) ); exp = add( 15, sub( exp1, exp2 ) ); +#ifdef ISSUE_1772_replace_shr_o + *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow ); +#else *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow ); +#endif move16(); } *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] ); diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index ad2f86073..5ac191836 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1164,9 +1164,11 @@ static Word16 imax_fx( /* o: The location, relative to the Word16 y1, y2, y3, man, expo, edge; const Word16 *pY; Word32 numer, denom, sign, acc, y3_y1; +#ifndef ISSUE_1772_replace_shr_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif /* Seek the extremum of the parabola P(x) defined by 3 consecutive points so that P([-1 0 1]) = [y1 y2 y3] */ @@ -1201,7 +1203,11 @@ static Word16 imax_fx( /* o: The location, relative to the /* Although the output of ratio() is in Q14, adding the missing factor of 2 (See above) * in the denominator, the output is now considered to be in Q15. */ man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ +#ifdef ISSUE_1772_replace_shr_o + posi = shr_sat( man, expo ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ +#else posi = shr_o( man, expo, &Overflow ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ +#endif if ( sign < 0 ) /* Restore the sign. */ { posi = negate( posi ); diff --git a/lib_enc/ari_hm_enc_fx.c b/lib_enc/ari_hm_enc_fx.c index 343f1890f..1172bd890 100644 --- a/lib_enc/ari_hm_enc_fx.c +++ b/lib_enc/ari_hm_enc_fx.c @@ -458,7 +458,11 @@ Word16 SearchPeriodicityIndex_fx( tmp = sub( norm_l( tmp32 ), 1 ); tmp2 = norm_l( AbsTotal ); tmp3 = div_s( round_fx_o( L_shl_o( tmp32, tmp, &Overflow ), &Overflow ), round_fx_o( L_shl_o( AbsTotal, tmp2, &Overflow ), &Overflow ) ); +#ifdef ISSUE_1772_replace_shr_o + *RelativeScore = shr_sat( tmp3, add( sub( tmp, tmp2 ), 2 ) ); /* -> 2Q13 */ +#else *RelativeScore = shr_o( tmp3, add( sub( tmp, tmp2 ), 2 ), &Overflow ); /* -> 2Q13 */ +#endif move16(); } ELSE diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 27f3d2aa6..c8fab11a9 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -2604,7 +2604,11 @@ void QuantizeSpectrum_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + xn_buf16[i] = shr_sat( xn_buf16[i], Q ); +#else xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); +#endif move16(); } @@ -4523,7 +4527,11 @@ void InternalTCXDecoder_fx( /* scale output */ FOR( i = 0; i < L_frame; i++ ) { +#ifdef ISSUE_1772_replace_shr_o + xn_buf16[i] = shr_sat( xn_buf16[i], Q ); +#else xn_buf16[i] = shr_o( xn_buf16[i], Q, &Overflow ); +#endif move16(); } -- GitLab From afa29a47dbcc59391030766e0d6eb2b1ae9c5982 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 26 Jun 2025 09:45:04 +0200 Subject: [PATCH 245/394] replaced some shr_o by shr_sat --- lib_enc/enc_gen_voic_rf_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index e9c9d87f7..79dc33d82 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -449,7 +449,11 @@ void coder_acelp_rf_fx( Ltmp = L_add_o( Ltmp, Ltmp2, &Overflow ); /* Q15 + Q_xn */ hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */ move16(); +#ifdef ISSUE_1772_replace_shr_o + hRF->rf_mem_w0 = shr_sat( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ +#else hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ +#endif /*-------------------------------------------------------* -- GitLab From 4542ebc70f732c58bbf35a046b30d78be1de5875 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 26 Jun 2025 10:55:44 +0200 Subject: [PATCH 246/394] add 20ms run report to artifacts and do not stop if there was an error --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 814f08372..7dcfbab05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1076,8 +1076,8 @@ check-be-between-renderer-framesizes: - python3 ci/remove_unsupported_testcases.py $PRM_FILES - exit_code=0 - - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 || exit_code=$? - - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors." exit 1; fi + - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml || exit_code=$? + - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors."; fi - exit_code5=0 - exit_code10=0 @@ -1104,10 +1104,13 @@ check-be-between-renderer-framesizes: - report-5ms.html - report-junit-10ms.xml - report-10ms.html + - report-junit-20ms.xml + - report-20ms.html reports: junit: - report-junit-5ms.xml - report-junit-10ms.xml + - report-junit-20ms.xml # --------------------------------------------------------------- -- GitLab From 0e71dd31a8ddd83829d51928cc82973a81f14f80 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 26 Jun 2025 11:06:25 +0200 Subject: [PATCH 247/394] make framesize-be test manual only --- .gitlab-ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7dcfbab05..832e5af6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1063,7 +1063,9 @@ build-codec-linux-make: check-be-between-renderer-framesizes: extends: - .test-job-linux - - .rules-pytest-to-main-short + # - .rules-pytest-to-main-short + rules: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "renderer-framesize-be" stage: test needs: ["build-codec-linux-make"] script: @@ -1077,7 +1079,6 @@ check-be-between-renderer-framesizes: - exit_code=0 - python3 -m pytest tests/codec_be_on_mr_nonselection --tb=no -v --ref_encoder_path ./IVAS_cod_ref --ref_decoder_path ./IVAS_dec --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml || exit_code=$? - - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors."; fi - exit_code5=0 - exit_code10=0 @@ -1088,8 +1089,11 @@ check-be-between-renderer-framesizes: - zero_errors10=$(cat report-junit-10ms.xml | grep -c 'errors="0"') || true - zero_errors=1 - - if [ $zero_errors5 != 1 ]; then echo "run error in with 5ms rendering encountered"; zero_errors=0 ; fi - - if [ $zero_errors10 != 1 ]; then echo "run error in with 10ms rendering encountered"; zero_errors=0 ; fi + - *print-results-banner + - echo "!! Encoder command lines are in the 20ms log files only !!!" + - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors."; zero_errors=0 fi + - if [ $zero_errors5 != 1 ]; then echo "run error with 5ms rendering encountered"; zero_errors=0 ; fi + - if [ $zero_errors10 != 1 ]; then echo "run error with 10ms rendering encountered"; zero_errors=0 ; fi - if [ $zero_errors != 1 ]; then exit $EXIT_CODE_FAIL; fi - if [ $exit_code5 -ne 0 ]; then echo "Non-bitexact cases encountered with 5ms rendering!"; exit_code=1; fi - if [ $exit_code10 -ne 0 ]; then echo "Non-bitexact cases encountered with 10ms rendering!"; exit_code=1; fi -- GitLab From f305131ca8123c51b5dc370f46180527420d471e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 26 Jun 2025 11:07:40 +0200 Subject: [PATCH 248/394] Revert "[revert-me] temporarily disable some jobs" This reverts commit fb5d39168462c39caeec259c5d062e099454b8bd. --- .gitlab-ci.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 832e5af6c..47ca66996 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -851,7 +851,7 @@ build-codec-linux-make: - make -j # ensure that codec builds on linux with instrumentation active -.build-codec-linux-instrumented-make: +build-codec-linux-instrumented-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -868,7 +868,7 @@ build-codec-linux-make: - bash scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR -.build-codec-linux-debugging-make: +build-codec-linux-debugging-make: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -886,7 +886,7 @@ build-codec-linux-make: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh - make -j -.build-codec-windows-msbuild: +build-codec-windows-msbuild: rules: - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -909,7 +909,7 @@ build-codec-linux-make: # --------------------------------------------------------------- ### jobs that check for bitexactness of fx encoder and decoder -.check-be-to-target-short-enc-0db: +check-be-to-target-short-enc-0db: extends: - .check-be-to-target-job variables: @@ -920,7 +920,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-be-to-target-short-enc-+10db: +check-be-to-target-short-enc-+10db: extends: - .check-be-to-target-job variables: @@ -931,7 +931,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-be-to-target-short-enc--10db: +check-be-to-target-short-enc--10db: extends: - .check-be-to-target-job variables: @@ -942,7 +942,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-be-to-target-short-dec-0db: +check-be-to-target-short-dec-0db: extends: - .check-be-to-target-job variables: @@ -953,7 +953,7 @@ build-codec-linux-make: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -.check-be-to-target-short-dec-+10db: +check-be-to-target-short-dec-+10db: extends: - .check-be-to-target-job variables: @@ -964,7 +964,7 @@ build-codec-linux-make: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -.check-be-to-target-short-dec--10db: +check-be-to-target-short-dec--10db: extends: - .check-be-to-target-job variables: @@ -976,7 +976,7 @@ build-codec-linux-make: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" ### jobs that check for regressions on non-BE testcases -.check-regressions-short-enc-0db: +check-regressions-short-enc-0db: extends: - .check-regressions-pytest-job needs: @@ -990,7 +990,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-regressions-short-enc-+10db: +check-regressions-short-enc-+10db: extends: - .check-regressions-pytest-job needs: @@ -1004,7 +1004,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-regressions-short-enc--10db: +check-regressions-short-enc--10db: extends: - .check-regressions-pytest-job needs: @@ -1018,7 +1018,7 @@ build-codec-linux-make: DUT_DECODER_PATH: "$REF_DECODER_PATH" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" -.check-regressions-short-dec-0db: +check-regressions-short-dec-0db: extends: - .check-regressions-pytest-job needs: @@ -1032,7 +1032,7 @@ build-codec-linux-make: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -.check-regressions-short-dec-+10db: +check-regressions-short-dec-+10db: extends: - .check-regressions-pytest-job needs: @@ -1046,7 +1046,7 @@ build-codec-linux-make: DUT_ENCODER_PATH: "$REF_ENCODER_PATH" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" -.check-regressions-short-dec--10db: +check-regressions-short-dec--10db: extends: - .check-regressions-pytest-job needs: @@ -1550,7 +1550,7 @@ coverage-test-on-main-scheduled: # --------------------------------------------------------------- # check bitexactness to EVS -.be-2-evs-26444: +be-2-evs-26444: extends: - .test-job-linux rules: -- GitLab From 427770e1b92497a448280f5adf4d3aac171e2087 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 26 Jun 2025 11:10:54 +0200 Subject: [PATCH 249/394] allow to start framesize test from web interface --- .gitlab-ci.yml | 3 +++ .gitlab-ci/variables.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 47ca66996..2ec72727a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,6 +62,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'voip-be-test' variables: IVAS_PIPELINE_NAME: 'Voip BE test on $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'renderer-framesize-be' + variables: + IVAS_PIPELINE_NAME: 'Renderer framesize BE test on $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' variables: IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 0c212d312..d91866b86 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -63,4 +63,5 @@ variables: - 'complexity' - 'coverage' - 'voip-be-test' + - 'renderer-framesize-be' - 'peaq-enc-passthrough' -- GitLab From 17e116c917760be2cdd07f802e667d8fff0b8ea7 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 10:19:09 +0200 Subject: [PATCH 250/394] remove extra frame argument under DBG_BITSTRREAM_ANALYSIS and make the debugging code explicitly dependent on DEBUGGING --- apps/encoder.c | 7 +-- lib_com/bitstream.c | 63 +++++++++--------------- lib_com/prot_fx.h | 14 +++--- lib_enc/ivas_corecoder_enc_reconfig_fx.c | 8 +-- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 10 ++-- lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/lib_enc.h | 8 --- lib_enc/lib_enc_fx.c | 13 +---- lib_enc/prot_fx_enc.h | 4 -- lib_enc/stat_enc.h | 2 +- 11 files changed, 46 insertions(+), 87 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 0d557ede8..af9554589 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -758,12 +758,7 @@ int main( } /* *** Encode one frame *** */ - if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_ENC_EncodeFrameToSerial( hIvasEnc, pcmBuf, pcmBufSize, bitStream, &numBits ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nencodeFrame failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 8ebfd6fa7..9a164636b 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -48,9 +48,12 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#ifdef DEBUGGING +#include "debug.h" +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif +#endif #define STEP_MAX_NUM_INDICES 100 /* increase the maximum number of allowed indices in the list by this amount */ @@ -201,7 +204,7 @@ ivas_error ind_list_realloc( { new_ind_list[i].id = old_ind_list[i].id; new_ind_list[i].value = old_ind_list[i].value; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif move16(); @@ -215,7 +218,7 @@ ivas_error ind_list_realloc( FOR( ; i < max_num_indices; i++ ) { new_ind_list[i].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( new_ind_list[i].function_name, "RESET in ind_list_realloc" ); #endif move16(); @@ -808,7 +811,7 @@ void move_indices( new_ind_list[i].value = old_ind_list[i].value; new_ind_list[i].nb_bits = old_ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif old_ind_list[i].nb_bits = -1; @@ -821,12 +824,12 @@ void move_indices( new_ind_list[i].id = old_ind_list[i].id; new_ind_list[i].value = old_ind_list[i].value; new_ind_list[i].nb_bits = old_ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( new_ind_list[i].function_name, old_ind_list[i].function_name, 100 ); #endif old_ind_list[i].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( old_ind_list[i].function_name, "RESET in move_indices" ); #endif } @@ -897,7 +900,7 @@ ivas_error check_ind_list_limits( return error; } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *named_indices_table[] = { "IND_IVAS_FORMAT", "IND_SMODE_OMASA", @@ -2817,7 +2820,7 @@ ivas_error push_indice( hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id; hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits; hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[j - 1].function_name, 100 ); #endif move16(); @@ -2831,7 +2834,7 @@ ivas_error push_indice( hBstr->ind_list[i].id = id; hBstr->ind_list[i].value = value; hBstr->ind_list[i].nb_bits = nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[i].function_name, named_indices_table[id], 100 ); #endif move16(); @@ -2852,12 +2855,12 @@ ivas_error push_indice( * * Push a new indice into the buffer at the next position *-------------------------------------------------------------------*/ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( #else ivas_error push_next_indice( #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -2897,7 +2900,7 @@ ivas_error push_next_indice( move16(); move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[hBstr->nb_ind_tot].function_name, caller, 100 ); #endif @@ -2914,12 +2917,12 @@ ivas_error push_next_indice( * push_next_bits() * Push a bit buffer into the buffer at the next position *-------------------------------------------------------------------*/ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( #else ivas_error push_next_bits( #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -2965,7 +2968,7 @@ ivas_error push_next_bits( ptr->value = code; ptr->nb_bits = 16; ptr->id = prev_id; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( ptr->function_name, caller, 100 ); #endif hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 ); @@ -2989,7 +2992,7 @@ ivas_error push_next_bits( ptr->value = bits[i]; ptr->nb_bits = 1; ptr->id = prev_id; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( ptr->function_name, caller, 100 ); #endif hBstr->nb_ind_tot = add( hBstr->nb_ind_tot, 1 ); @@ -3066,7 +3069,7 @@ UWord16 delete_indice( hBstr->ind_list[j].id = hBstr->ind_list[i].id; hBstr->ind_list[j].value = hBstr->ind_list[i].value; hBstr->ind_list[j].nb_bits = hBstr->ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hBstr->ind_list[j].function_name, hBstr->ind_list[i].function_name, 100 ); #endif } @@ -3080,7 +3083,7 @@ UWord16 delete_indice( { /* reset the shifted indices at the end of the list */ hBstr->ind_list[j].nb_bits = -1; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hBstr->ind_list[j].function_name, "RESET in delete_indice" ); #endif } @@ -3319,10 +3322,6 @@ static ivas_error write_indices_element_fx( UWord16 **pt_stream, /* i : pointer to bitstream buffer */ const Word16 is_SCE, /* i : flag to distingusih SCE and CPE */ const Word16 element_id /* i : id of the SCE or CPE */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Word16 ch; @@ -3429,7 +3428,7 @@ static ivas_error write_indices_element_fx( } } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) if ( is_SCE ) /* EVS and SCE */ { static FILE *f1 = 0; @@ -3539,10 +3538,6 @@ ivas_error write_indices_ivas_fx( Encoder_Struct *st_ivas, /* i/o: encoder state structure */ UWord16 *bit_stream, /* i/o: output bitstream */ UWord16 *num_bits /* i : number of indices written to output */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Word16 i, n; @@ -3566,22 +3561,12 @@ ivas_error write_indices_ivas_fx( FOR( n = 0; n < st_ivas->nSCE; n++ ) { - write_indices_element_fx( st_ivas, &pt_stream, 1, n -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); + write_indices_element_fx( st_ivas, &pt_stream, 1, n ); } FOR( n = 0; n < st_ivas->nCPE; n++ ) { - write_indices_element_fx( st_ivas, &pt_stream, 0, n -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); + write_indices_element_fx( st_ivas, &pt_stream, 0, n ); } *num_bits = (UWord16) ( pt_stream - bit_stream ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 666484359..9950ac9bd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10638,17 +10638,17 @@ ivas_error config_acelp1_fx( const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #define push_next_indice( ... ) push_next_indice_( __func__, __VA_ARGS__ ) #define push_next_bits( ... ) push_next_bits_( __func__, __VA_ARGS__ ); #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( #else ivas_error push_next_indice( #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, @@ -10656,12 +10656,12 @@ ivas_error push_next_indice( Word16 nb_bits /* i : number of bits used to quantize the indice */ ); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( #else ivas_error push_next_bits( #endif -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ @@ -10986,7 +10986,7 @@ ivas_error push_indice( ); ivas_error push_next_indice_( -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, @@ -10995,7 +10995,7 @@ ivas_error push_next_indice_( ); ivas_error push_next_bits_( -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index 6a2748e1c..40ee8b95b 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -39,7 +39,7 @@ #include "ivas_prot_fx.h" #include "math.h" #include "wmc_auto.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif /*-------------------------------------------------------------------* @@ -196,7 +196,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); temp_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( temp_ind_list[i].function_name, hBstr->ind_list[i].function_name, 100 ); #endif hBstr->ind_list[i].nb_bits = -1; /* Q0 */ @@ -552,7 +552,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( st_ivas->hSCE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 ); #endif } @@ -579,7 +579,7 @@ ivas_error ivas_corecoder_enc_reconfig_fx( move16(); st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].nb_bits = temp_ind_list[i].nb_bits; /* Q0 */ move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( st_ivas->hCPE[0]->hCoreCoder[0]->hBstr->ind_list[i].function_name, temp_ind_list[i].function_name, 100 ); #endif } diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 2285acc0c..bfaf80fc6 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -41,7 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 15adcee9c..34af5a727 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -43,7 +43,7 @@ #include "basop_util.h" #include "ivas_rom_com_fx.h" -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif @@ -1191,7 +1191,7 @@ void reset_metadata_spatial_fx( { hMetaData->ind_list[i].nb_bits = -1; move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" ); #endif } @@ -1200,12 +1200,12 @@ void reset_metadata_spatial_fx( { hMetaData->ind_list[j].value = hMetaData->ind_list[i].value; hMetaData->ind_list[j].nb_bits = hMetaData->ind_list[i].nb_bits; -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) strncpy( hMetaData->ind_list[j].function_name, hMetaData->ind_list[i].function_name, 100 ); #endif hMetaData->nb_bits_tot = add( hMetaData->nb_bits_tot, hMetaData->ind_list[j].nb_bits ); hMetaData->ind_list[i].nb_bits = -1; -#ifdef BISTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in reset_metadata_spatial" ); #endif move16(); @@ -2015,7 +2015,7 @@ void restore_metadata_buffer_fx( { hMetaData->ind_list[i].nb_bits = -1; move16(); -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) sprintf( hMetaData->ind_list[i].function_name, "RESET in restore_metadata_buffer" ); #endif } diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index a293b870a..1a2f5aff0 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -439,7 +439,7 @@ static void write_metadata_buffer_fx( FOR( i = 0; i < hMetaData_tmp->nb_ind_tot; i++ ) { -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) push_next_indice_( hMetaData_tmp->ind_list[i].function_name, hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits ); #else push_next_indice( hMetaData, hMetaData_tmp->ind_list[i].value, hMetaData_tmp->ind_list[i].nb_bits ); diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 16fc9fe4b..8cf6be1cd 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -302,10 +302,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME */ UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); /*! r: error code */ @@ -315,10 +311,6 @@ ivas_error IVAS_ENC_EncodeFrameToCompact( const Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() */ UWord8 *outputBitStream, /* o : pointer to compact output bitstream. The array must already be allocated. */ UWord16 *numOutBits /* o : number of bits written to output bitstream */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); /* Setter functions - apply changes to encoder configuration */ diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 6c105228f..a7592e2ca 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1279,10 +1279,6 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( Word16 inputBufferSize, /* i : total number of samples in the input buffer. Related function: IVAS_ENC_GetInputBufferSize() Q0*/ UWord16 *outputBitStream, /* o : pointer to serial output bitstream. The array must already be allocated and be of size at least IVAS_MAX_BITS_PER_FRAME Q0*/ UWord16 *numOutBits /* o : number of bits written to output bitstream. Each bit is stored as a single uint16_t value Q0*/ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ) { Encoder_Struct *st_ivas; @@ -1406,7 +1402,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( st_ivas->ind_list[i].nb_bits = -1; move16(); } -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) for ( i = 0; i < st_ivas->ivas_max_num_indices; i++ ) { memset( st_ivas->ind_list[i].function_name, 'A', 100 * sizeof( char ) ); @@ -1517,12 +1513,7 @@ ivas_error IVAS_ENC_EncodeFrameToSerial( /* write indices into bitstream buffer */ { - write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits -#ifdef DBG_BITSTREAM_ANALYSIS - , - frame -#endif - ); + write_indices_ivas_fx( st_ivas, outputBitStream, numOutBits ); } /* Reset switching flag before next call - can be set to "true" by some setters */ hIvasEnc->switchingActive = false; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 992087413..8631a3f51 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -4839,9 +4839,5 @@ ivas_error write_indices_ivas_fx( Encoder_Struct *st_ivas, /* i/o: encoder state structure */ UWord16 *bit_stream, /* i/o: output bitstream */ UWord16 *num_bits /* i : number of indices written to output */ -#ifdef DBG_BITSTREAM_ANALYSIS - , - int32_t frame -#endif ); #endif diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 85261a3a7..3839e3ec5 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -54,7 +54,7 @@ typedef struct Word16 id; /* id of the indice */ UWord16 value; /* value of the quantized indice */ Word16 nb_bits; /* number of bits used for the quantization of the indice */ -#ifdef DBG_BITSTREAM_ANALYSIS +#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) char function_name[100]; #endif } Indice, *INDICE_HANDLE; -- GitLab From 876dfec07bfe91091fd33aa7d98feb6547ce82b5 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 26 Jun 2025 11:34:44 +0200 Subject: [PATCH 251/394] simplify function headers --- lib_com/bitstream.c | 10 +++------- lib_com/prot_fx.h | 8 ++------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 9a164636b..ed82754b5 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -50,7 +50,7 @@ #include "prot_fx_enc.h" #ifdef DEBUGGING #include "debug.h" -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) +#ifdef DBG_BITSTREAM_ANALYSIS #include #endif #endif @@ -2857,11 +2857,9 @@ ivas_error push_indice( *-------------------------------------------------------------------*/ #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( -#endif -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ UWord16 value, /* i : value of the quantized indice */ @@ -2919,11 +2917,9 @@ ivas_error push_next_indice( *-------------------------------------------------------------------*/ #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( -#endif -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 9950ac9bd..9675c6ce5 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10645,11 +10645,9 @@ ivas_error config_acelp1_fx( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_indice_( + const char *caller, #else ivas_error push_next_indice( -#endif -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, #endif BSTR_ENC_HANDLE hBstr, UWord16 value, /* i : value of the quantized indice */ @@ -10658,11 +10656,9 @@ ivas_error push_next_indice( #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) ivas_error push_next_bits_( + const char *caller, #else ivas_error push_next_bits( -#endif -#if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) - const char *caller, #endif BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const UWord16 bits[], /* i : bit buffer to pack, sequence of single bits */ -- GitLab From 4f55bfb6f2b7af9c4a9ba6c529a2521613f2a2aa Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 26 Jun 2025 11:41:44 +0200 Subject: [PATCH 252/394] change shr_o -> shr_sat --- lib_enc/gaus_enc_fx.c | 8 ++++++++ lib_enc/multi_harm_fx.c | 8 ++++++++ lib_enc/set_impulse_fx.c | 4 ++++ lib_enc/stat_noise_uv_enc_fx.c | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 2aa9a5dff..d002d5206 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -362,7 +362,11 @@ void gauss2v_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); +#ifdef ISSUE_1772_replace_shr_o + delta = shr_sat( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ +#else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ +#endif delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -823,7 +827,11 @@ void gauss2v_ivas_fx( exp_den = norm_l( Lden ); Den = extract_h( L_shl( Lden, exp_den ) ); +#ifdef ISSUE_1772_replace_shr_o + delta = shr_sat( div_s( Num, Den ), sub( exp_num, exp_den ) ); /* Q15 */ +#else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ +#endif delta = i_mult2( delta, m_sign ); /* Apply sign */ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); diff --git a/lib_enc/multi_harm_fx.c b/lib_enc/multi_harm_fx.c index 1bae597b6..c49c405b5 100644 --- a/lib_enc/multi_harm_fx.c +++ b/lib_enc/multi_harm_fx.c @@ -238,7 +238,11 @@ Word16 multi_harm_fx( /* o : frame multi-harmonicity corxy = shl( corxy, cor ); /* cor = corxy * corxy / (corx2 * cory2) */ corxy = div_s( corxy, corx2 ); +#ifdef ISSUE_1772_replace_shr_o + cor = shr_sat( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */ +#else cor = shr_o( corxy, sub( shl( tmp16, 1 ), Expx2 ), &Overflow ); /* Q15 */ +#endif } ELSE { @@ -575,7 +579,11 @@ Word16 multi_harm_ivas_fx( /* o : frame multi-harmoni corxy = shl( corxy, cor ); /* cor = corxy * corxy / (corx2 * cory2) */ corxy = div_s( corxy, corx2 ); +#ifdef ISSUE_1772_replace_shr_o + cor = shr_sat( corxy, sub( shl( tmp16, 1 ), Expx2 ) ); /* Q15 */ +#else cor = shr_o( corxy, sub( shl( tmp16, 1 ), Expx2 ), &Overflow ); /* Q15 */ +#endif } ELSE { diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index d4dd73abe..f6f7b6dd5 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -201,7 +201,11 @@ void set_impulse_fx( den = extract_h( L_shl( rr_fx[i], exp_den ) ); num = div_s( num, den ); +#ifdef ISSUE_1772_replace_shr_o + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ +#else krit_fx = shr_o( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ +#endif IF( GT_16( krit_fx, krit_max_fx ) ) { diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 24932542c..8d4f899da 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -69,7 +69,11 @@ void stat_noise_uv_enc_fx( expd = norm_l( LepsP[1] ); den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ num = div_s( num, den ); /*expn-expd+15*/ +#ifdef ISSUE_1772_replace_shr_o + num = shr_sat( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ +#else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ +#endif num = sub( num, 1024 ); /*num - 1*/ test(); @@ -142,7 +146,11 @@ void stat_noise_uv_enc_ivas_fx( expd = norm_l( LepsP[1] ); den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ num = div_s( num, den ); /*expn-expd+15*/ +#ifdef ISSUE_1772_replace_shr_o + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ +#else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ +#endif num = sub( num, 1024 ); /*num - 1*/ test(); -- GitLab From 2b7051e4a9ff44cc0b35834b64bc999fb349acee Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 26 Jun 2025 15:15:56 +0530 Subject: [PATCH 253/394] Fix for 3GPP issue 1757: Sudden drop in comfort noise for fx enc at 24.4kbps stereo DTX Link #1757 --- lib_enc/ivas_core_pre_proc_front_fx.c | 25 ++----------- lib_enc/ivas_front_vad_fx.c | 12 ++---- lib_enc/nois_est_fx.c | 53 +++++++++++++++++++++------ lib_enc/prot_fx_enc.h | 3 +- lib_enc/vad_fx.c | 4 +- 5 files changed, 52 insertions(+), 45 deletions(-) diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index b378eabad..fff73a248 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1228,16 +1228,7 @@ ivas_error pre_proc_front_ivas_fx( /*------------------------------------------------------------------* * Update estimated noise energy and voicing cut-off frequency *-----------------------------------------------------------------*/ - - Word16 scale = s_min( Q31, s_min( add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ), add( st->hNoiseEst->q_bckr, L_norm_arr( st->hNoiseEst->bckr_fx, NB_BANDS ) ) ) ); - scale = sub( scale, 1 ); // guard bits - scale_sig32( st->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, st->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) ); - st->hNoiseEst->q_bckr = q_tmpN = scale; - move16(); - move16(); - - scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); + Word16 scale = s_min( Q31, add( st->hNoiseEst->ave_enr_q, s_min( L_norm_arr( st->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( st->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ) ); scale = s_min( scale, add( q_tmpE, L_norm_arr( tmpE_fx, NB_BANDS ) ) ); scale = sub( scale, 1 ); // guard bits scale_sig32( tmpE_fx, NB_BANDS, sub( scale, q_tmpE ) ); @@ -1256,7 +1247,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); move16(); - noise_est_ivas_fx( st, old_pitch1, tmpN_fx, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_fx, q_tmpN, epsP_fx, extract_h( Etot_fx ), *relE_fx, corr_shift_fx, tmpE_fx, q_tmpE, fr_bands_fx, fr_bands_fx_q, cor_map_sum_fx, &ncharX_fx, &sp_div_fx, &q_sp_div, &non_staX_fx, loc_harm, lf_E_fx, q_lf_E_fx, &st->hNoiseEst->harm_cor_cnt, extract_h( st->hNoiseEst->Etot_l_lp_32fx ), st->hNoiseEst->Etot_v_h2_32fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame ); @@ -1265,14 +1256,6 @@ ivas_error pre_proc_front_ivas_fx( { FOR( Word16 j = 0; j < 2; j++ ) { - scale = s_min( add( q_tmpN_LR[j], L_norm_arr( tmpN_LR_fx[j], NB_BANDS ) ), add( hCPE->hFrontVad[j]->hNoiseEst->q_bckr, L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS ) ) ); - scale = sub( s_min( Q31, scale ), 1 ); - scale_sig32( hCPE->hFrontVad[j]->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hCPE->hFrontVad[j]->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_LR_fx[j], NB_BANDS, sub( scale, q_tmpN_LR[j] ) ); - hCPE->hFrontVad[j]->hNoiseEst->q_bckr = q_tmpN_LR[j] = scale; - move16(); - move16(); - scale = add( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_q, s_min( L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr_fx, NB_BANDS ), L_norm_arr( hCPE->hFrontVad[j]->hNoiseEst->ave_enr2_fx, NB_BANDS ) ) ); scale = s_min( scale, add( q_tmpE_LR[j], L_norm_arr( tmpE_LR_fx[j], NB_BANDS ) ) ); scale = sub( s_min( Q31, scale ), 1 ); @@ -1297,14 +1280,14 @@ ivas_error pre_proc_front_ivas_fx( move16(); /* Run noise_est for Left and Right channel */ - noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[0], q_tmpN_LR[0], epsP_fx, Etot_LR_fx[0], sub( Etot_LR_fx[0], hCPE->hFrontVad[0]->lp_speech_fx ), corr_shiftL_fx, tmpE_LR_fx[0], q_tmpE_LR[0], fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], &cor_map_sum_LR_fx[0], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[0], lf_E_LR_fx_q, &hCPE->hFrontVad[0]->hNoiseEst->harm_cor_cnt, extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[0]->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[0], hCPE->hFrontVad[0]->ini_frame ); /* Note: the index [0] in the last argument is intended, the ini_frame counter is only maintained in the zero-th channel's VAD handle */ - noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, + noise_est_ivas_fx( st, old_pitch1, tmpN_LR_fx[1], q_tmpN_LR[1], epsP_fx, Etot_LR_fx[1], sub( Etot_LR_fx[1], hCPE->hFrontVad[1]->lp_speech_fx ), corr_shiftR_fx, tmpE_LR_fx[1], q_tmpE_LR[1], fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], &cor_map_sum_LR_fx[1], &ncharX_LR_fx, &sp_div_LR_fx, &q_sp_div_LR, &non_staX_LR_fx, loc_harmLR_fx, lf_E_LR_fx[1], lf_E_LR_fx_q, &hCPE->hFrontVad[1]->hNoiseEst->harm_cor_cnt, extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_l_lp_32fx ), hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx, &hCPE->hFrontVad[1]->hNoiseEst->bg_cnt, diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index ec6a918b9..1f62b6854 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -720,13 +720,6 @@ ivas_error front_vad_spar_fx( hFrontVad->hNoiseEst->ave_enr_q = scale; move16(); - scale = s_min( add( hFrontVad->hNoiseEst->q_bckr, L_norm_arr( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS ) ), add( q_tmpN, L_norm_arr( tmpN_fx, NB_BANDS ) ) ); - scale = sub( s_min( Q31, scale ), 1 ); // guard bits - scale_sig32( hFrontVad->hNoiseEst->bckr_fx, NB_BANDS, sub( scale, hFrontVad->hNoiseEst->q_bckr ) ); - scale_sig32( tmpN_fx, NB_BANDS, sub( scale, q_tmpN ) ); - hFrontVad->hNoiseEst->q_bckr = scale; - move16(); - scale = add( hFrontVad->hNoiseEst->fr_bands_fx_q, s_min( L_norm_arr( hFrontVad->hNoiseEst->fr_bands1_fx, NB_BANDS ), L_norm_arr( hFrontVad->hNoiseEst->fr_bands2_fx, NB_BANDS ) ) ); scale = s_min( scale, add( q_fr_bands[0], L_norm_arr( fr_bands_fx[0], 2 * NB_BANDS ) ) ); scale = s_min( Q31, scale ); @@ -737,7 +730,7 @@ ivas_error front_vad_spar_fx( move16(); move16(); - noise_est_ivas_fx( st, old_pitch, tmpN_fx, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx, + noise_est_ivas_fx( st, old_pitch, tmpN_fx, q_tmpN, epsP_fx, Etot_fx[0], sub( Etot_fx[0], hFrontVad->lp_speech_fx ), corr_shift_fx, tmpE_fx, hFrontVad->hNoiseEst->ave_enr_q, fr_bands_fx[0], q_fr_bands[0], &cor_map_sum_fx, NULL, &sp_div_fx, &Q_sp_div, &non_staX_fx, &loc_harm, lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame ); @@ -765,7 +758,8 @@ ivas_error front_vad_spar_fx( move16(); hSpar->front_vad_dtx_flag = 1; move16(); - if ( st->core_brate == SID_2k40 || st->core_brate == FRAME_NO_DATA ) + test(); + if ( EQ_32( st->core_brate, SID_2k40 ) || st->core_brate == FRAME_NO_DATA ) { hSpar->front_vad_dtx_flag = 0; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 676696fd6..9a4829121 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2208,7 +2208,8 @@ void noise_est_fx( void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ - const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */ + const Word32 tmpN[], /* i : temporary noise update q_tmpN */ + const Word16 q_tmpN, /* i : Q-factor of tmpN buffer */ const Word32 epsP[], /* i : msb prediction error energies Qx */ const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */ const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */ @@ -2221,7 +2222,7 @@ void noise_est_ivas_fx( Word16 *ncharX, /* o : Q11 */ Word16 *sp_div, /* o : Q_sp_div */ Word16 *Q_sp_div, /* o : Q factor for sp_div */ - Word32 *non_staX, /* o : non-stationarity for sp/mus classifier Q20 */ + Word32 *non_staX, /* o : non-stationarity for sp/mus classifier */ Word16 *loc_harm, /* o : multi-harmonicity flag for UV classifier */ const Word32 *lf_E, /* i : per bin energy for low frequencies q_lf_E */ const Word16 q_lf_E, /* i : Q of lf_E Q0 */ @@ -2264,7 +2265,7 @@ void noise_est_ivas_fx( Word16 non_staB; /* Q8 */ Word32 L_tmp_enr, L_tmp_ave, L_tmp_ave2; - Word16 tmp, tmp2; /* general temp registers */ + Word16 tmp, tmp2, diff; /* general temp registers */ Word16 tmp_enr, tmp_floor; /* constants in Q8 */ Word16 vad_bwidth_fx; /* vad ns control variabel for input bwidth from teh BWD */ /* for DTX operation */ @@ -2775,10 +2776,16 @@ void noise_est_ivas_fx( move16(); IF( hNoiseEst->bckr_fx[i] != 0 ) { - Ltmp1 = L_add( hNoiseEst->bckr_fx[i], L_shl( 1, hNoiseEst->q_bckr ) ); // hNoiseEst->q_bckr + diff = 0; + move16(); + IF( GT_16( hNoiseEst->q_bckr, 30 ) ) + { + diff = sub( hNoiseEst->q_bckr, 30 ); + } + Ltmp1 = L_add( L_shr( hNoiseEst->bckr_fx[i], diff ), L_shl( 1, sub( hNoiseEst->q_bckr, diff ) ) ); // hNoiseEst->q_bckr - diff e_ener = norm_l( Ltmp1 ); f_ener = Log2_norm_lc( L_shl( Ltmp1, e_ener ) ); - e_ener = sub( sub( 30, e_ener ), hNoiseEst->q_bckr ); + e_ener = sub( sub( 30, e_ener ), sub( hNoiseEst->q_bckr, diff ) ); Ltmp1 = L_mac( f_ener, e_ener, ONE_IN_Q14 ); // Q15 Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 tmp_floor = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ @@ -3499,6 +3506,8 @@ void noise_est_ivas_fx( hNoiseEst->bckr_fx[i] = tmpN[i]; move32(); } + hNoiseEst->q_bckr = q_tmpN; + move16(); } /* else if ( ( ( st->act_pred < 0.80f ) && ( aE_bgd || PAU ) && st->lt_haco_ev < 0.10f ) || ( ( st->act_pred < 0.70f ) && ( aE_bgd || non_staB < 17.0f ) && PAU && st->lt_haco_ev < 0.15f ) @@ -3536,14 +3545,34 @@ void noise_est_ivas_fx( hNoiseEst->first_noise_updt = 1; move16(); - FOR( i = 0; i < NB_BANDS; i++ ) + IF( LT_16( q_tmpN, hNoiseEst->q_bckr ) ) { - /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ - /* 32 bit state update */ - Ltmp = L_sub( tmpN[i], hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr - Ltmp = Mult_32_16( Ltmp, updt_step ); - hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr - move32(); + diff = sub( hNoiseEst->q_bckr, q_tmpN ); + FOR( i = 0; i < NB_BANDS; i++ ) + { + /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ + /* 32 bit state update */ + Ltmp1 = L_shr( hNoiseEst->bckr_fx[i], diff ); + Ltmp = L_sub( tmpN[i], Ltmp1 ); // q_tmpN + Ltmp = Mult_32_16( Ltmp, updt_step ); + hNoiseEst->bckr_fx[i] = L_add( Ltmp, Ltmp1 ); // q_tmpN + move32(); + } + hNoiseEst->q_bckr = q_tmpN; + move16(); + } + ELSE + { + diff = sub( q_tmpN, hNoiseEst->q_bckr ); + FOR( i = 0; i < NB_BANDS; i++ ) + { + /* st->bckr[i] = st->bckr[i] + updt_step * (tmpN[i]-st->bckr[i]);*/ + /* 32 bit state update */ + Ltmp = L_sub( L_shr( tmpN[i], diff ), hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr + Ltmp = Mult_32_16( Ltmp, updt_step ); + hNoiseEst->bckr_fx[i] = L_add( Ltmp, hNoiseEst->bckr_fx[i] ); // hNoiseEst->q_bckr + move32(); + } } } /*else if (aE_bgd || st->harm_cor_cnt > 100 )*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 992087413..691ce7004 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -385,7 +385,8 @@ void noise_est_fx( void noise_est_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ const Word16 old_pitch1, /* i : previous frame OL pitch[1] */ - const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */ + const Word32 tmpN[], /* i : temporary noise update q_tmpN */ + const Word16 q_tmpN, /* i : Q-factor of tmpN buffer */ const Word32 epsP[], /* i : msb prediction error energies Qx */ const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */ const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */ diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 1cf7a5de8..8f1fb6985 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -2369,10 +2369,10 @@ Word16 wb_vad_ivas_fx( } norm_tmp = norm_l( ftmp1 ); - scaled_tmp = L_shl( ftmp1, norm_tmp ); /*13+norm_tmp*/ + scaled_tmp = L_shl( ftmp1, norm_tmp ); /*16+norm_tmp*/ L_msnr = scaled_tmp; move32(); - L_msnr_e = sub( 18, norm_tmp ); + L_msnr_e = sub( 15, norm_tmp ); FOR( j = 1; j < stmp; j++ ) { L_msnr = Mult_32_32( L_msnr, scaled_tmp ); /*L_msnr_e msnr *= ftmp1;*/ -- GitLab From 4c57143ed42a9f0f4ba23d35c934d552d1af1122 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 26 Jun 2025 12:18:33 +0200 Subject: [PATCH 254/394] Added q_acelp_zir_fx to scale acelp_zir_fx in dynamic q_win cases --- lib_dec/dec_tcx_fx.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b993f6753..b544ba417 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2988,6 +2988,7 @@ void IMDCT_ivas_fx( const Word16 fullbandScale, Word16 *acelp_zir_fx, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_acelp_zir_fx, Word16 *pq_win ) #else Word16 q_win ) // Q(-2) @@ -3301,6 +3302,11 @@ void IMDCT_ivas_fx( { /* default, i.e. maximum overlap, single transform, no grouping */ #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change && fullbandScale ) + { + q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); + } + IF( EQ_16( kernel_type, MDST_IV ) ) { TCX_MDST_Inverse_qwin_fx( x_fx, x_e_hdrm, xn_buf_fx, overlap, sub( L_frame, overlap ), overlap, &q_win, allow_qwin_change ); @@ -3333,6 +3339,16 @@ void IMDCT_ivas_fx( } #endif +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( !fullbandScale ) + { + *q_acelp_zir_fx = q_xn_buf_fx; + } + ELSE + { + scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); + } +#endif tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && NE_16( st->last_core, ACELP_CORE ) ? MIN_OVERLAP : index, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), ( tcx_offset < 0 ) ? -tcx_offset : 0, ( frame_cnt > 0 /*|| (st->last_con_tcx )*/ ) ? 1 : st->last_core_bfi, ( frame_cnt > 0 ) ? 0 : (Word8) st->last_is_cng, fullbandScale ); } /* tcx_last_overlap_mode != FULL_OVERLAP */ @@ -3512,6 +3528,10 @@ void IMDCT_ivas_fx( } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF( allow_qwin_change && fullbandScale ) + { + q_win = s_min( q_win, norm_arr( acelp_zir_fx, shr( L_frame_glob, 1 ) ) + *q_acelp_zir_fx ); + } IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && ( LE_32( st->last_core_brate, SID_2k40 ) || st->last_core == ACELP_CORE ) && ( fullbandScale == 0 ) ) { /* Increase headroom because if the ACELP ZIR is used below, the synthesis filter gain is unknown. */ @@ -3585,7 +3605,17 @@ void IMDCT_ivas_fx( move16(); } } - +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + IF(!fullbandScale) + { + *q_acelp_zir_fx = q_xn_buf_fx; + } + ELSE + { + scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); + } +#endif + //scale_sig( acelp_zir_fx, L_FRAME_MAX / 2, sub( q_xn_buf_fx, q_win0 ) ); /* Window current frame */ tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), acelp_mem_len, st->last_core_bfi, (Word8) st->last_is_cng, fullbandScale ); } @@ -5738,7 +5768,7 @@ void decoder_tcx_imdct_fx( Word32 x_tmp_fx[L_FRAME_PLUS]; Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; - Word16 acelp_zir_fx[L_FRAME_MAX / 2]; + Word16 acelp_zir_fx[L_FRAME_MAX / 2], q_acelp_zir_fx = 0; Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; Word16 index, proc = 0; TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; @@ -5911,7 +5941,7 @@ void decoder_tcx_imdct_fx( #endif hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #endif @@ -5940,7 +5970,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( xn_bufFB_fx, q_x, hTcxDec->syn_Overl, hTcxDec->syn_Overl_TDAC, xn_buf_fx, hTcxCfg->tcx_aldo_window_1, hTcxCfg->tcx_aldo_window_1_trunc, hTcxCfg->tcx_aldo_window_2, hTcxCfg->tcx_mdct_window_half, hTcxCfg->tcx_mdct_window_minimum, hTcxCfg->tcx_mdct_window_trans, hTcxCfg->tcx_mdct_window_half_length, hTcxCfg->tcx_mdct_window_min_length, index, #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, q_win ); + kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, &st->hHQ_core->Q_old_wtda_LB, 0, st, 0, acelp_zir_fx, &q_acelp_zir_fx, q_win ); #else kernelType, left_rect, tcx_offset, overlap, L_frame, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frame_glob, frame_cnt, bfi, st->hHQ_core->old_out_LB_fx, 0, st, 0, acelp_zir_fx, q_win ); #endif @@ -5974,7 +6004,7 @@ void decoder_tcx_imdct_fx( #endif hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_winFB ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif @@ -5987,7 +6017,7 @@ void decoder_tcx_imdct_fx( IMDCT_ivas_fx( x_fx, q_x, hTcxDec->syn_OverlFB, hTcxDec->syn_Overl_TDACFB, xn_bufFB_fx_16, hTcxCfg->tcx_aldo_window_1_FB, hTcxCfg->tcx_aldo_window_1_FB_trunc, hTcxCfg->tcx_aldo_window_2_FB, hTcxCfg->tcx_mdct_window_halfFB, hTcxCfg->tcx_mdct_window_minimumFB, hTcxCfg->tcx_mdct_window_transFB, hTcxCfg->tcx_mdct_window_half_lengthFB, hTcxCfg->tcx_mdct_window_min_lengthFB, index, #endif #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD - kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, q_winFB ); + kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, &st->hHQ_core->Q_old_wtda, 1, st, ratio, acelp_zir_fx, &q_acelp_zir_fx, q_winFB ); #else kernelType, left_rect, tcx_offsetFB, overlapFB, L_frameTCX, L_frameTCX, shr( s_max( L_frameTCX, L_spec ), 1 ), L_frameTCX_glob, frame_cnt, bfi, st->hHQ_core->old_out_fx, 1, st, ratio, acelp_zir_fx, q_win ); #endif -- GitLab From 66465ef3e2925af99a7cd98aac18e8e2bcbe650c Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 26 Jun 2025 12:46:41 +0200 Subject: [PATCH 255/394] Applied Clang formating patch. --- lib_dec/dec_tcx_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b544ba417..33dd3dfd3 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3606,7 +3606,7 @@ void IMDCT_ivas_fx( } } #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - IF(!fullbandScale) + IF( !fullbandScale ) { *q_acelp_zir_fx = q_xn_buf_fx; } @@ -3615,7 +3615,6 @@ void IMDCT_ivas_fx( scale_sig( acelp_zir_fx, shr( L_frame_glob, 1 ), sub( q_xn_buf_fx, *q_acelp_zir_fx ) ); } #endif - //scale_sig( acelp_zir_fx, L_FRAME_MAX / 2, sub( q_xn_buf_fx, q_win0 ) ); /* Window current frame */ tcx_windowing_synthesis_current_frame( xn_buf_fx, tcx_aldo_window_2_fx, tcx_mdct_window_half_fx, tcx_mdct_window_minimum_fx, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, left_rect, hTcxCfg->tcx_last_overlap_mode, acelp_zir_fx, hTcxDec->old_syn_Overl, syn_Overl_TDAC_fx, st->old_Aq_12_8_fx, tcx_mdct_window_trans_fx, shr( L_frame_glob, 1 ), acelp_mem_len, st->last_core_bfi, (Word8) st->last_is_cng, fullbandScale ); } -- GitLab From 24c6246d773789d0d80a81ce1be946775f07e813 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 26 Jun 2025 13:16:38 +0200 Subject: [PATCH 256/394] Added *q_acelp_zir_fx as a parameter to IMDCT_ivas_fx() in prot_fx.h. --- lib_com/prot_fx.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 684dfa377..c49c0dfb7 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -9484,6 +9484,7 @@ void IMDCT_ivas_fx( const Word16 fullbandScale, Word16 *acelp_zir_fx, #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 *q_acelp_zir_fx, Word16 *pq_win ); #else Word16 q_win ); -- GitLab From 70100607fc5d002d937ce5f8d940c01d8dc17cee Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 26 Jun 2025 21:39:42 +0530 Subject: [PATCH 257/394] Fix for stv crashes --- lib_enc/nois_est_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 9a4829121..7fb58941b 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2776,11 +2776,11 @@ void noise_est_ivas_fx( move16(); IF( hNoiseEst->bckr_fx[i] != 0 ) { - diff = 0; + diff = 1; move16(); IF( GT_16( hNoiseEst->q_bckr, 30 ) ) { - diff = sub( hNoiseEst->q_bckr, 30 ); + diff = add( diff, sub( hNoiseEst->q_bckr, 30 ) ); } Ltmp1 = L_add( L_shr( hNoiseEst->bckr_fx[i], diff ), L_shl( 1, sub( hNoiseEst->q_bckr, diff ) ) ); // hNoiseEst->q_bckr - diff e_ener = norm_l( Ltmp1 ); -- GitLab From 2b64e7a6a9362d7b2f65461181ac1356ff7a5d72 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 15:50:12 +0200 Subject: [PATCH 258/394] replace ahr_ro ba shr_r_sat --- lib_com/options.h | 1 + lib_com/tools_fx.c | 8 ++++++++ lib_enc/find_uv_fx.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4badd652f..4fcc4a03e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,5 +100,6 @@ #define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ +#define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #endif diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index a83dfb56b..3d5b13938 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3144,7 +3144,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( x1[i], shr_r_sat( x2[i], Qyx2 ), &Overflow ); +#else y[i] = add_o( x1[i], shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } @@ -3152,7 +3156,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#else y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 61de9ca7d..462b7580d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -32,9 +32,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum Word16 wtmp0, wtmp1; Word32 maxEnr, minEnr; Word16 dE2, exp0, exp1; +#ifndef ISSUE_1770_replace_shr_ro #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif dE2 = 0; @@ -76,7 +78,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum exp1 = sub( norm_l( maxEnr ), 1 ); wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); +#ifdef ISSUE_1770_replace_shr_ro + dE2 = shr_r_Sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ +#else dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ +#endif return dE2; } -- GitLab From 54a3b922b83f90b4a37c29f8a4b6e6d0c13603c5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 15:54:22 +0200 Subject: [PATCH 259/394] replace shr_ro ba shr_r_sat oe more + buildfix --- lib_com/tools_fx.c | 2 +- lib_enc/find_uv_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 3d5b13938..b2974696a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3157,7 +3157,7 @@ void add_vec_fx( FOR( i = 0; i < N; i++ ) { #ifdef ISSUE_1770_replace_shr_ro - y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); + y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_r_sat( x2[i], Qyx2 ), &Overflow ); #else y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 462b7580d..9dcd8386b 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -79,7 +79,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); #ifdef ISSUE_1770_replace_shr_ro - dE2 = shr_r_Sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ + dE2 = shr_r_sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ #else dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ #endif -- GitLab From 6c4e581f0537b22f07d8857cb50808450775a079 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 27 Jun 2025 10:55:19 +0530 Subject: [PATCH 260/394] Fix for ASAN error in decoder --- lib_dec/ivas_jbm_dec_fx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e1ac2c1ff..008093a89 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1037,7 +1037,18 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); nchan_out = nchan_transport; move16(); - Word16 Q_p_output = s_max( 3, sub( L_norm_arr( p_output_fx[sba_ch_idx], imult1616( output_frame, nchan_transport ) ), 1 ) ); + Word16 Q_p_output; + Word16 min_norm = 31; + move16(); + + FOR( ch = 0; ch < nchan_transport; ++ch ) + { + Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel + min_norm = s_min( norm, min_norm ); + } + + Q_p_output = s_max( 3, sub( min_norm, 1 ) ); + Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 FOR( ch = 0; ch < nchan_transport; ch++ ) { -- GitLab From 1175563c9537990c3f2458509ec13f3d6cbb59e8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 27 Jun 2025 14:25:22 +0530 Subject: [PATCH 261/394] Fix for 3GPP issue 1749: Use of divide1616 and idivide1616 with constant denominator Link #1749 --- lib_com/cnst.h | 8 +++++++- lib_com/ivas_cnst.h | 7 +++++++ lib_com/ivas_transient_det_fx.c | 6 ++++-- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_spar_md_dec_fx.c | 2 +- lib_dec/swb_tbe_dec_fx.c | 8 ++++---- lib_dec/tonalMDCTconcealment_fx.c | 15 +++++++++++---- lib_enc/ext_sig_ana_fx.c | 6 +++++- lib_enc/inov_enc_fx.c | 2 +- lib_enc/ivas_dirac_enc_fx.c | 2 +- lib_enc/ivas_init_enc_fx.c | 2 +- lib_enc/ivas_ism_metadata_enc_fx.c | 5 +++-- lib_enc/ivas_masa_enc_fx.c | 2 +- lib_enc/ivas_mc_paramupmix_enc_fx.c | 2 +- lib_enc/ivas_mcmasa_enc_fx.c | 4 ++-- lib_enc/ivas_mct_enc_fx.c | 18 +++++++++--------- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_qmetadata_enc_fx.c | 4 ++-- lib_enc/ivas_spar_encoder_fx.c | 2 +- lib_enc/ivas_spar_md_enc_fx.c | 8 +++++--- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 4 ++-- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- 23 files changed, 72 insertions(+), 43 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 6030b53bd..792df3946 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -226,6 +226,7 @@ enum{ #define ONE_BY_L_FRAME32k_Q31 3355443 #define ONE_BY_L_FRAME25_6k_Q31 4194304 #define ONE_BY_L_FRAME16k_Q31 6710886 +#define ONE_BY_L_FRAME16k_Q15 102 #define ONE_BY_L_FRAME_Q31 8388608 #define ONE_BY_240_Q31 8947849 #define ONE_BY_L_FRAME8k_Q31 13421772 @@ -680,6 +681,7 @@ enum #define NUM_DCT_LENGTH 24 #define NB_DIV 2 /* number of division (subframes) per 20ms frame */ +#define NB_DIV_LOG2 1 /* To be used for shift operation instead of division */ #define L_MDCT_HALF_OVLP_MAX L_MDCT_OVLP_MAX - 48000 / 200 /* Size of HALF overlap window slope @ 48 kHz */ #define L_MDCT_MIN_OVLP_MAX 60 /* Size of the MDCT minimal overlap @ 48 kHz - 1.25ms */ #define L_MDCT_TRANS_OVLP_MAX NS2SA( 48000, ACELP_TCX_TRANS_NS ) /* Size of the ACELP->MDCT transition overlap - 1.25ms */ @@ -708,6 +710,7 @@ enum #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ +#define L_SUBFR_LOG2 6 /* To be used for shift operation instead of division */ #define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ #define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ @@ -788,6 +791,7 @@ enum #endif #define CLDFB_NO_CHANNELS_MAX_FX 30720 /*Q9*/ #define CLDFB_NO_COL_MAX 16 /* CLDFB resampling - max number of CLDFB col., == IVAS_CLDFB_NO_COL_MAX */ +#define CLDFB_NO_COL_MAX_LOG2 4 /* To be used for shift operation instead of division */ #define CLDFB_NO_COL_MAX_SWITCH 6 /* CLDFB resampling - max number of CLDFB col. for switching */ #define CLDFB_NO_COL_MAX_SWITCH_BFI 10 /* CLDFB resampling - max number of CLDFB col. for switching, BFI */ #define CLDFB_OVRLP_MIN_SLOTS 3 /* CLDFB resampling - minimize processing to minimum required for transition frame ACELP->TCX/HQ */ @@ -1533,6 +1537,7 @@ enum #define INTERP_3_2_MEM_LEN 15 #define L_SHB_LAHEAD 20 /* Size of lookahead for SHB */ #define NUM_SHB_SUBFR 16 +#define NUM_SHB_SUBFR_LOG2 4 /* To be used for shift operation instead of division */ #define LPC_SHB_ORDER 10 #define LPC_WHTN_ORDER 4 /* Order of whitening filter for SHB excitation */ #define SHB_OVERLAP_LEN ( L_FRAME16k - L_SHB_LAHEAD ) / ( NUM_SHB_SUBFR - 1 ) @@ -3092,7 +3097,8 @@ extern const Word16 Idx2Freq_Tbl[]; #define FS_32K_IN_NS_Q31 68719 #define FS_16K_IN_NS_Q31 34360 -#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ #define THREE_Q21 6291456 #define SIX_Q21 12582912 diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index d3e52ec16..18816a94a 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -166,6 +166,7 @@ typedef enum #define BINAURAL_CHANNELS 2 /* number of channels for binaural output configuration */ #define CPE_CHANNELS 2 /* number of CPE (stereo) channels */ +#define CPE_CHANNELS_LOG2 1 /* To be used for the shift operation instead of division */ #define FOA_CHANNELS 4 /* number of FOA channels */ #define HOA2_CHANNELS 9 #define HOA3_CHANNELS 16 @@ -198,6 +199,7 @@ typedef enum #define MAX_JBM_SUBFRAMES_5MS 8 #define DEFAULT_JBM_SUBFRAMES_5MS 4 #define JBM_CLDFB_SLOTS_IN_SUBFRAME 4 +#define JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 2 /* To be used for shift operation instead of division */ #define MAX_JBM_CLDFB_TIMESLOTS 32 #define DEFAULT_JBM_CLDFB_TIMESLOTS 16 #define MAX_JBM_L_FRAME48k 1920 @@ -934,12 +936,14 @@ typedef enum { #define MDFT_FB_BANDS_240 240 #define CLDFB_TO_MDFT_FAC 4 #define MDFT_NO_COL_MAX 4 +#define MDFT_NO_COL_MAX_LOG2 2 /* To be used for shift operation instead of division */ /*----------------------------------------------------------------------------------* * General Parametric Coding Constants *----------------------------------------------------------------------------------*/ #define MAX_PARAM_SPATIAL_SUBFRAMES 4 /* Maximum number of subframes for parameteric spatial coding */ +#define MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 2 /* To be used for shift operation instead of division */ #define L_SPATIAL_SUBFR_48k (L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES) #define CLDFB_SLOTS_PER_SUBFRAME ( CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES ) /* Number of CLDFB slots per subframe */ @@ -970,6 +974,7 @@ typedef enum { #define DIRAC_MAX_NBANDS 12 /* Maximum number of frequency bands for the DirAC Side Parameter decoding */ #define DIRAC_LOW_BANDRES_STEP 2 /* always combine two bands for low band resolution in the DirAC parameter coding */ #define DIRAC_NO_COL_AVG_DIFF 32 /* Number of slots for averaging intensity vector for diffuseness computation */ +#define DIRAC_NO_COL_AVG_DIFF_LOG2 5 /* To be used for shift operation instead of division */ #define DIRAC_DIFFUSE_LEVELS 8 /* Size of the diffuseness alphabet (constant value) */ #define INV_DIRAC_DIFFUSE_LEVELS_Q13 1170 /* 1/(DIRAC_DIFFUSE_LEVELS - 1) in Q13 */ #define DIRAC_DITH_SEED 29680 @@ -1687,6 +1692,7 @@ typedef enum #define DEG_180_IN_Q22 ( 180 << Q22 ) // Q22 #define DEG_90_IN_Q22 ( 90 << Q22 ) // Q22 #define ONE_BY_360_Q31 ( 5965232 ) // Q31 +#define ONE_BY_360_Q15 ( 91 ) // Q15 #define ONE_BY_180_Q31 ( 11930465 ) // Q31 /* ----- Enums - TD Renderer ----- */ @@ -1860,6 +1866,7 @@ typedef enum #define SPAR_DIRAC_SPLIT_START_BAND 8 #define DIRAC_TO_SPAR_HBR_PRED_CHS (FOA_CHANNELS - 1) #define SPAR_DTX_BANDS 2 +#define SPAR_DTX_BANDS_LOG2 1 /* To be used for shift operation instead of division */ #define DIRAC_DTX_BANDS 2 #define SPAR_DIRAC_DTX_BANDS ( SPAR_DTX_BANDS + DIRAC_DTX_BANDS ) #define CLDFB_PAR_WEIGHT_START_BAND 7 diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index fb8679ebc..cc1b1771b 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -292,7 +292,7 @@ void ivas_transient_det_process_fx( ) { Word32 in_duck_gain[L_FRAME48k]; - Word16 num_sf, sf, sf_samp, idx; + Word16 num_sf, sf, sf_samp, idx, num_sf_log2; Word32 mem = hTranDet->in_duck_gain; /*Q30*/ move32(); @@ -309,7 +309,9 @@ void ivas_transient_det_process_fx( num_sf = 16; /*Q0*/ move16(); - sf_samp = idiv1616( frame_len, num_sf ); /*Q0*/ + num_sf_log2 = 4; /* To be used for shift operation instead of division */ + move16(); + sf_samp = shr( frame_len, num_sf_log2 ); /*Q0*/ FOR( sf = 1; sf <= num_sf; sf++ ) { idx = sub( imult1616( sf_samp, sf ), 1 ); diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 48fce8b95..ba7741712 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -3102,7 +3102,7 @@ void ivas_dirac_dec_render_sf_fx( } ELSE { - hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( idiv1616( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ + hDirACRend->index_buffer_intensity = add( sub( hDirACRend->index_buffer_intensity, i_mult( shr( hDirACRend->index_buffer_intensity, DIRAC_NO_COL_AVG_DIFF_LOG2 ), DIRAC_NO_COL_AVG_DIFF ) ), 1 ); /* averaging_length = 32 */ move16(); } diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e61e51262..457c040c3 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -2042,7 +2042,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( } ELSE { - sf = idiv1616( hSpar->render_to_md_map[slot_idx + slot_idx_start], JBM_CLDFB_SLOTS_IN_SUBFRAME ); + sf = shr( hSpar->render_to_md_map[slot_idx + slot_idx_start], JBM_CLDFB_SLOTS_IN_SUBFRAME_LOG2 ); } IF( LT_16( sf, SPAR_META_DELAY_SUBFRAMES ) ) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 36b77732a..ad1fb4c3a 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -1715,7 +1715,7 @@ static void ivas_spar_dec_parse_md_bs_fx( { *nB = SPAR_DTX_BANDS; move16(); - *bands_bw = idiv1616( num_bands, *nB ); /*Q0*/ + *bands_bw = shr( num_bands, SPAR_DTX_BANDS_LOG2 ); /*Q0*/ move16(); FOR( i = 0; i < *nB; i++ ) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 679e206e0..06da2a83d 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -4269,7 +4269,7 @@ void ivas_dequantizeSHBparams_fx_9_1( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } Q_subgain[i] = Q_subgain[idx]; move16(); @@ -4597,7 +4597,7 @@ static void dequantizeSHBparams_fx_9_1( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } Q_subgain[i] = Q_subgain[idx]; move16(); @@ -6644,7 +6644,7 @@ void ivas_swb_tbe_dec_fx( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } GainShape_fx[i] = GainShape_tmp_fx[idx]; move16(); @@ -6688,7 +6688,7 @@ void ivas_swb_tbe_dec_fx( move16(); IF( i != 0 ) { - idx = idiv1616( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR ); + idx = shr( i_mult( i, NUM_SHB_SUBGAINS ), NUM_SHB_SUBFR_LOG2 ); } GainShape_fx[i] = GainShape_fx[idx]; move16(); diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index fd6cf7835..f61fe276e 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -2886,7 +2886,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( HANDLE_FD_CNG_COM hFdCngCom; Word16 *rnd_c, *rnd; Word16 crossOverFreq, i, save_rnd_c, max_noise_line; - Word16 c, c_inv, inc; + Word16 c, c_inv, inc, inc_log2; Word32 noise_shape_buffer[L_FRAME48k]; Word16 noise_shape_buffer_e[L_FRAME48k]; Word16 start_idx, stop_idx, noise_shape_buffer_common_exp = MIN16B_FLT_FX, last_scf_e, temp_e; @@ -2994,14 +2994,21 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( IF( GT_16( st->core, TCX_20_CORE ) ) { inc = 2; + inc_log2 = 1; + move16(); + move16(); + start_idx = shr( hFdCngCom->startBand, inc_log2 ); + stop_idx = shr( hFdCngCom->stopFFTbin, inc_log2 ); } ELSE { inc = 1; + start_idx = hFdCngCom->startBand; + stop_idx = hFdCngCom->stopFFTbin; + move16(); + move16(); + move16(); } - move16(); - start_idx = idiv1616( hFdCngCom->startBand, inc ); - stop_idx = idiv1616( hFdCngCom->stopFFTbin, inc ); FOR( i = 0; i < start_idx; i++ ) { diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 49d757be3..87fa6a451 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1031,7 +1031,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { Word16 scale; - L_subframe = idiv1616( L_frameTCX, nSubframes ); /* Q0 */ + L_subframe = L_frameTCX; /* Q0 */ /* L_subframe = idiv1616( L_frameTCX, nSubframes ); */ + IF( EQ_16( nSubframes, 2 ) ) + { + L_subframe = shr( L_frameTCX, 1 ); + } test(); IF( EQ_16( transform_type[frameno], TCX_20 ) && NE_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) ) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 01ba794ea..216ca3860 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -597,7 +597,7 @@ Word16 inov_encode_ivas_fx( IF( i_subfr != 0 ) { idx = idiv1616( i_subfr, L_subfr ); - idx2 = idiv1616( i_subfr, L_SUBFR ); + idx2 = shr( i_subfr, L_SUBFR_LOG2 ); } IF( LT_16( st_fx->acelp_cfg.fixed_cdk_index[idx], ACELP_FIXED_CDK_NB ) ) diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index be15b5048..3aa010d42 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -998,7 +998,7 @@ void ivas_dirac_param_est_enc_fx( diffuseness_vector_q = 0; move16(); - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); /* Q0 */ + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); /* Q0 */ IF( useLowerRes ) { q_direction->cfg.nblocks = 1; diff --git a/lib_enc/ivas_init_enc_fx.c b/lib_enc/ivas_init_enc_fx.c index 2285acc0c..ddbea7b40 100644 --- a/lib_enc/ivas_init_enc_fx.c +++ b/lib_enc/ivas_init_enc_fx.c @@ -874,7 +874,7 @@ ivas_error ivas_init_encoder_fx( { st_ivas->nSCE = 0; move16(); - st_ivas->nCPE = idiv1616( hEncoderConfig->nchan_inp, CPE_CHANNELS ); /* Q0 */ + st_ivas->nCPE = shr( hEncoderConfig->nchan_inp, CPE_CHANNELS_LOG2 ); /* Q0 */ move16(); FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 594871b29..d7751aa4d 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -48,7 +48,8 @@ * Local constants *-----------------------------------------------------------------------*/ -#define ISM_NUM_PARAM 5 /* number of coded metadata parameters */ +#define ISM_NUM_PARAM 5 /* number of coded metadata parameters */ +#define ONE_BY_ISM_NUM_PARAM_Q15 6554 /* To be used for shift operation instead of division */ #define ISM_MAX_AZIMUTH_DIFF_IDX ( ISM_AZIMUTH_NBITS - 1 /*zero*/ - 1 /*sign*/ ) #define ISM_MAX_ELEVATION_DIFF_IDX ( ISM_ELEVATION_NBITS - 1 /*zero*/ - 1 /*sign*/ ) @@ -613,7 +614,7 @@ ivas_error ivas_ism_metadata_enc_fx( pos_zero = add( pos_zero, 1 ); } - ch = idiv1616( abs_next, ISM_NUM_PARAM ); + ch = mult( abs_next, ONE_BY_ISM_NUM_PARAM_Q15 ); IF( abs_next % ISM_NUM_PARAM == 0 ) { diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index fb86dee7a..35c57c42b 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -786,7 +786,7 @@ void ivas_masa_estimate_energy_fx( move16(); Word16 q_buf; maxBin = extract_l( Mpy_32_32( 134217728 /*CLDFB_NO_CHANNELS_MAX / L_FRAME48k in Q31*/, input_frame ) ); - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index cad29b146..c1f735704 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -855,7 +855,7 @@ static ivas_error ivas_mc_paramupmix_param_est_enc_fx( } // l_ts = input_frame / MAX_PARAM_SPATIAL_SUBFRAMES; - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); move16(); Word16 gb = find_guarded_bits_fx( l_ts ); diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index ab86efb8d..7d261d4e4 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -957,10 +957,10 @@ void ivas_mcmasa_param_est_enc_fx( set_zero_fx( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX ); } - num_freq_bins = idiv1616( input_frame, MDFT_NO_COL_MAX ); + num_freq_bins = shr( input_frame, MDFT_NO_COL_MAX_LOG2 ); num_freq_bands = hMcMasa->nbands; move16(); - l_ts = idiv1616( input_frame, MDFT_NO_COL_MAX ); + l_ts = shr( input_frame, MDFT_NO_COL_MAX_LOG2 ); set16_fx( q_vdv, 31, MASA_FREQUENCY_BANDS ); set16_fx( out_exp, 30, MASA_FREQUENCY_BANDS ); diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index ee9353379..23a70ef97 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -287,11 +287,11 @@ ivas_error ivas_mct_enc_fx( Word16 length, ch, nCPE; IF( ( hMCT->nchan_out_woLFE % 2 ) == 0 ) { - nCPE = idiv1616( hMCT->nchan_out_woLFE, 2 ); + nCPE = shr( hMCT->nchan_out_woLFE, 1 ); } ELSE { - nCPE = add( idiv1616( hMCT->nchan_out_woLFE, 2 ), 1 ); + nCPE = add( shr( hMCT->nchan_out_woLFE, 1 ), 1 ); } FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ ) @@ -313,12 +313,12 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); // st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX / NB_DIV } IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } IF( hMCT->p_orig_spectrum_long_fx[cpe_id][ch] ) { @@ -359,11 +359,11 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } Word16 norm = L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ); q_spec = s_min( q_spec, add( sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ), norm ) ); @@ -391,7 +391,7 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } scale_sig32( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX, sub( q_spec, sub( 31, st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_e ) ) ); // q_spec @@ -404,7 +404,7 @@ ivas_error ivas_mct_enc_fx( IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) { - length = add( length, idiv1616( length, 4 ) ); + length = add( length, shr( length, 2 ) ); } FOR( Word16 k = 0; k <= ( ( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->core == TCX_20_CORE ) ? 1 : NB_DIV ) - 1; k++ ) @@ -433,7 +433,7 @@ ivas_error ivas_mct_enc_fx( } ELSE { - length = idiv1616( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV ); + length = shr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->L_frameTCX, NB_DIV_LOG2 ); } Word16 e_spec = sub( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_e[0], L_norm_arr( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->hTcxEnc->spectrum_long_fx, N_MAX ) ); IF( st_ivas->hCPE[cpe_id]->hCoreCoder[ch]->last_core == ACELP_CORE ) diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 1d14eecc9..e09a1fb36 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -1046,7 +1046,7 @@ static void ivas_omasa_param_est_enc_fx( dir_v_e = MIN_16; num_freq_bins = hOMasa->cldfbAnaEnc[0]->no_channels; num_freq_bands = hOMasa->nbands; - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); move16(); move16(); move16(); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 15adcee9c..68695120e 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -370,7 +370,7 @@ ivas_error ivas_qmetadata_enc_encode_fx( { no_TF = add( imult1616( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ), imult1616( hQMetaData->q_direction[1].cfg.nbands, hQMetaData->q_direction[1].cfg.nblocks ) ); test(); - IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), idiv1616( imult1616( 43, no_TF ), 10 ) ), sum16_fx( bits_diff, ndirections ) ), MASA_MIN_BITS_SURR_COH ) ) + IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), mult( imult1616( 43, no_TF ), ONE_BY_TEN_Q15 ) ), sum16_fx( bits_diff, ndirections ) ), MASA_MIN_BITS_SURR_COH ) ) { bits_surround_coh = encode_surround_coherence_fx( hQMetaData, hMetaData ); } @@ -396,7 +396,7 @@ ivas_error ivas_qmetadata_enc_encode_fx( { no_TF = imult1616( hQMetaData->q_direction[0].cfg.nbands, hQMetaData->q_direction[0].cfg.nblocks ); test(); - IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), idiv1616( imult1616( 43, no_TF ), 10 ) ), bits_diff[0] ), MASA_MIN_BITS_SURR_COH ) ) + IF( EQ_16( all_coherence_zero, 0 ) && GE_16( sub( sub( sub( hQMetaData->metadata_max_bits, bits_no_dirs_coh ), mult( imult1616( 43, no_TF ), ONE_BY_TEN_Q15 ) ), bits_diff[0] ), MASA_MIN_BITS_SURR_COH ) ) { bits_surround_coh = encode_surround_coherence_fx( hQMetaData, hMetaData ); } diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 3b380f2eb..8143a8c33 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -788,7 +788,7 @@ static ivas_error ivas_spar_enc_process_fx( shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); } - l_ts = idiv1616( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES ); + l_ts = shr( input_frame, MAX_PARAM_SPATIAL_SUBFRAMES_LOG2 ); Word16 gb = find_guarded_bits_fx( l_ts ); FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ ) diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index a293b870a..28a0dc9a4 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -479,7 +479,7 @@ ivas_error ivas_spar_md_enc_process_fx( Word32 pred_coeffs_re_local_fx[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; Word16 k, bwidth, num_bands, num_bands_full, num_bands_bw; Word16 active_w, nchan_transport, dmx_switch, strat; - Word16 nB, bands_bw, packed_ok = 0; + Word16 nB, bands_bw, bands_bw_log2, packed_ok = 0; move16(); ivas_strats_t cs[MAX_CODING_STRATS]; Word16 code_strat; @@ -585,7 +585,7 @@ ivas_error ivas_spar_md_enc_process_fx( { nB = SPAR_DTX_BANDS; move16(); - bands_bw = idiv1616( num_bands, nB ); + bands_bw = shr( num_bands, SPAR_DTX_BANDS_LOG2 ); ivas_band_mixer_fx( cov_real_fx, cov_real_q, num_ch, &num_bands, bands_bw ); } @@ -593,7 +593,9 @@ ivas_error ivas_spar_md_enc_process_fx( { bands_bw = 2; move16(); - nB = idiv1616( num_bands, bands_bw ); + bands_bw_log2 = 1; + move16(); + nB = shr( num_bands, bands_bw_log2 ); ivas_band_mixer_fx( cov_real_fx, cov_real_q, num_ch, &num_bands, bands_bw ); } diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 19823d7c6..a0fa343a2 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -3100,7 +3100,7 @@ static void ivas_dirac_dec_get_response_split_order_fx( } ELSE { - tmp = idiv1616( add( azimuth, 180 ), 360 ); + tmp = mult( add( azimuth, 180 ), ONE_BY_360_Q15 ); /* idiv1616( add( azimuth, 180 ), 360 ) */ } index_azimuth = sub( add( azimuth, 180 ), i_mult( tmp, 360 ) ); // index_azimuth = (azimuth + 180) % 360 index_elevation = add( elevation, 90 ); @@ -3226,7 +3226,7 @@ static void ivas_dirac_dec_get_response_split_order_fx( } ELSE { - tmp = idiv1616( add( index_azimuth, 180 ), 360 ); + tmp = mult( add( index_azimuth, 180 ), ONE_BY_360_Q15 ); } index_azimuth = sub( add( index_azimuth, 180 ), i_mult( tmp, 360 ) ); // index_azimuth = (index_azimuth + 180) % 360 diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index b2b4039f3..a0d6beb26 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -575,7 +575,7 @@ void ivas_mcmasa_param_est_ana_fx( move16(); num_freq_bands = hMcMasa->nbands; move16(); - l_ts = idiv1616( input_frame, CLDFB_NO_COL_MAX ); + l_ts = shr( input_frame, CLDFB_NO_COL_MAX_LOG2 ); numAnalysisChannels = sub( nchan_inp, 1 ); set16_fx( q_vdv, 31, MASA_FREQUENCY_BANDS ); -- GitLab From c69147d53447df41898e6119d90aca451fa1e761 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 27 Jun 2025 14:31:02 +0530 Subject: [PATCH 262/394] Clang formatting changes --- lib_com/ivas_transient_det_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index cc1b1771b..39dee9314 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -309,7 +309,7 @@ void ivas_transient_det_process_fx( num_sf = 16; /*Q0*/ move16(); - num_sf_log2 = 4; /* To be used for shift operation instead of division */ + num_sf_log2 = 4; /* To be used for shift operation instead of division */ move16(); sf_samp = shr( frame_len, num_sf_log2 ); /*Q0*/ FOR( sf = 1; sf <= num_sf; sf++ ) -- GitLab From 8bc8bd6059f086ef1cdd517f6da5d69e1252968e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 27 Jun 2025 15:16:53 +0530 Subject: [PATCH 263/394] Fix for 3GPP issue 1724: Renderer MASA output metadata difference - 2 Link #1724 --- lib_rend/ivas_dirac_ana_fx.c | 23 ++++++++++++----------- lib_rend/ivas_masa_merge_fx.c | 24 ++++++++++++++++-------- lib_rend/ivas_mcmasa_ana_fx.c | 8 ++++---- lib_rend/ivas_omasa_ana_fx.c | 8 ++++---- lib_rend/ivas_prot_rend_fx.h | 7 ++++--- lib_rend/lib_rend_fx.c | 20 ++++++++++---------- 6 files changed, 50 insertions(+), 40 deletions(-) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index e170afdc6..fcea6a6eb 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -43,7 +43,7 @@ /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, Word32 data_f[][L_FRAME48k], Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 input_frame ); +static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, Word32 data_f[][L_FRAME48k], Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], const Word16 input_frame, const Word16 data_q ); static void ivas_dirac_dmx_fx( Word32 data_in_fx[][L_FRAME48k], const Word16 input_frame, const Word16 nchan_transport ); @@ -247,8 +247,8 @@ void ivas_dirac_ana_fx( DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ Word32 data_fx[][L_FRAME48k], /* i/o: Input / transport audio signals, Q7 */ const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport /* i : Number of transport channels */ -) + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 data_q ) { Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; @@ -256,7 +256,7 @@ void ivas_dirac_ana_fx( Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /* Estimate MASA parameters from the SBA signals */ - ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame ); + ivas_dirac_param_est_ana_fx( hDirAC, data_fx, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, input_frame, data_q ); /* Create MASA metadata buffer from the estimated values */ ivas_create_masa_out_meta_fx( hDirAC->hMasaOut, hDirAC->sph_grid16, nchan_transport, elevation_m_values, azimuth_m_values, energyRatio, spreadCoherence, surroundingCoherence, Q31, Q31, Q31 ); @@ -281,7 +281,8 @@ static void ivas_dirac_param_est_ana_fx( Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q30 */ Word32 spreadCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ Word32 surroundingCoherence_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ - const Word16 input_frame ) + const Word16 input_frame, + const Word16 data_q ) { Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 ts, i, d, j; @@ -356,23 +357,23 @@ static void ivas_dirac_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; - inp_q = Q7; // Input Q of data_fx + inp_q = data_q; // Input Q of data_fx move16(); move16(); move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - inp_q = Q7; + inp_q = data_q; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][l_ts * ts] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, getScaleFactor32( Foa_ImagBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < numAnalysisChannels; i++ ) { - scale_sig32( Foa_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Foa_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Foa_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Foa_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); c_e = sub( 31, inp_q ); diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index e0dd57afb..892927d37 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -192,12 +192,17 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( total_nrg_fx, EPSILON_FX ), &scale ); L_tmp1 = L_deposit_h( tmp ); /* Q( 31 - ( scale + total_nrg_e - total_diff_nrg_e ) ) */ scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); - if ( L_tmp1 == 0 ) + IF( L_tmp1 == 0 ) { - scale = 30; + scale = 31; move16(); + L_tmp2 = 1; + move32(); + } + ELSE + { + L_tmp2 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q31, 0, L_negate( L_tmp1 ), scale, &scale ); } - L_tmp2 = L_sub( L_shl( 1, scale ), L_tmp1 ); L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp ); L_tmp1 = L_shr( L_tmp1, 1 ); @@ -220,13 +225,16 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( EPSILON_FX, total_nrg_fx ), &scale ); scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); - dir_nrg_ratio_fx = L_sub( L_shl_sat( 1, sub( 31, scale ) ), L_deposit_h( tmp ) ); + Word32 temp32 = L_shr( L_deposit_h( tmp ), sub( sub( 31, scale ), Q30 ) ); // Q30 + scale = 1; + move16(); + dir_nrg_ratio_fx = L_sub( ONE_IN_Q30, temp32 ); dir_nrg_ratio_e = scale; move16(); - new_dir_ratio_fx = dir_nrg_ratio_fx; + new_dir_ratio_fx = dir_ratio_ism_fx; move32(); - new_dir_ratio_e = dir_nrg_ratio_e; + new_dir_ratio_e = dir_ratio_ism_e; move16(); tmp = BASOP_Util_Cmp_Mant32Exp( dir_nrg_ratio_fx, dir_nrg_ratio_e, dir_ratio_ism_fx, dir_ratio_ism_e ); IF( tmp <= 0 ) @@ -237,7 +245,7 @@ void diffuse_meta_merge_1x1_fx( move16(); } - outMeta->directToTotalRatio[0][sf][band] = (UWord8) imult1616( extract_l( L_shr( new_dir_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX ); + outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( new_dir_ratio_fx, sub( sub( 31, new_dir_ratio_e ), 8 ) ) ); move16(); IF( GT_16( sub( 31, new_dir_ratio_e ), Q30 ) ) { @@ -250,7 +258,7 @@ void diffuse_meta_merge_1x1_fx( { new_diff_ratio_fx = L_sub( L_shl( 1, sub( 31, new_dir_ratio_e ) ), new_dir_ratio_fx ); /* Q(31 - new_dir_ratiio_e) */ } - outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX ); + outMeta->diffuseToTotalRatio[sf][band] = (UWord8) extract_l( L_shr( new_diff_ratio_fx, sub( sub( 31, new_dir_ratio_e ), 8 ) ) ); move16(); } ELSE diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index a0d6beb26..3cb2c4fcf 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -635,14 +635,14 @@ void ivas_mcmasa_param_est_ana_fx( inp_q = q_data; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, getScaleFactor32( Chnl_RealBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < numAnalysisChannels; i++ ) { - scale_sig32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); c_e = sub( 31, inp_q ); diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 1ef2805b5..c9ed32d26 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -451,14 +451,14 @@ static void ivas_omasa_param_est_ana_fx( inp_q = data_f_q; cldfbAnalysis_ts_fx_var_q( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &inp_q ); - cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); - ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ); + cr_q = s_min( cr_q, L_norm_arr( Chnl_ImagBuffer_fx[i], l_ts ) ); + ci_q = s_min( ci_q, L_norm_arr( Chnl_RealBuffer_fx[i], l_ts ) ); } sf = sub( s_min( cr_q, ci_q ), 4 ); FOR( i = 0; i < nchan_ism; i++ ) { - scale_sig32( Chnl_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf - scale_sig32( Chnl_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_RealBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf + scale_sig32( Chnl_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); c_e = sub( 31, inp_q ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 8772b542e..7c5c02c71 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1464,10 +1464,11 @@ ivas_error ivas_dirac_ana_open_fx( void ivas_dirac_ana_fx( DIRAC_ANA_HANDLE hDirAC, /* i/o: DIRAC analysis handle */ - Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals, Q7 */ + Word32 data_in_fx[][L_FRAME48k], /* i/o: Input / transport audio signals */ const Word16 input_frame, /* i : Input frame size */ - const Word16 nchan_transport /* i : Number of transport channels */ -); + const Word16 nchan_transport, /* i : Number of transport channels */ + const Word16 data_q /*i : Q of data_in_fx*/ + ); void ivas_dirac_ana_close_fx( DIRAC_ANA_HANDLE ( *hDirAC ) /* i/o: analysis DIRAC handle */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 957aaee0d..78c6acf4d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5656,7 +5656,7 @@ static ivas_error renderActiveInputsIsm( Word16 i; input_ism *pCurrentInput; ivas_error error; - Word16 input_q = Q8; + Word16 input_q = outAudio.q_factor; move16(); FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { @@ -5666,7 +5666,7 @@ static ivas_error renderActiveInputsIsm( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = input_q; move16(); IF( NE_32( ( error = renderInputIsm( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -6240,7 +6240,7 @@ static ivas_error renderActiveInputsMc( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputMc( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -6501,7 +6501,7 @@ static void renderSbaToMasa( push_wmops( "renderMcToMasa" ); copyBufferTo2dArray_fx( sbaInput->base.inputBuffer, tmpRendBuffer ); - ivas_dirac_ana_fx( sbaInput->hDirAC, tmpRendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels ); + ivas_dirac_ana_fx( sbaInput->hDirAC, tmpRendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, *outAudio.pq_fact ); accumulate2dArrayToBuffer_fx( tmpRendBuffer, &outAudio ); pop_wmops(); @@ -6580,7 +6580,7 @@ static ivas_error renderActiveInputsSba( /* Skip inactive inputs */ CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputSba( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) { @@ -6700,10 +6700,10 @@ static void renderMasaToMasa( move16(); move16(); cldfbAnalysis_ts_fx_fixed_q( &( tmpBuffer_fx[i][l_ts * ts] ), Chan_RealBuffer_fx[i], Chan_ImagBuffer_fx[i], l_ts, masaInput->hMasaPrerend->cldfbAnaEnc[i], &q_cldfb_out ); - scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ), getScaleFactor32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX ) ) ); + scale_factor = s_min( scale_factor, s_min( getScaleFactor32( Chan_RealBuffer_fx[i], l_ts ), getScaleFactor32( Chan_ImagBuffer_fx[i], l_ts ) ) ); scale_factor = sub( scale_factor, 1 ); - scale_sig32( Chan_RealBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ - scale_sig32( Chan_ImagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ + scale_sig32( Chan_RealBuffer_fx[i], l_ts, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ + scale_sig32( Chan_ImagBuffer_fx[i], l_ts, scale_factor ); /* Q(q_cldfb_out + scale_factor) */ scale_fac_arr[i] = scale_factor; move16(); } @@ -6719,7 +6719,7 @@ static void renderMasaToMasa( { IF( NE_16( scale_factor, scale_fac_arr[i] ) ) { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) + FOR( j = 0; j < l_ts; j++ ) { Chan_RealBuffer_fx[i][j] = L_shr( Chan_RealBuffer_fx[i][j], sub( scale_fac_arr[i], scale_factor ) ); /* Q(q_cldfb_out+scale_factor) */ move32(); @@ -6976,7 +6976,7 @@ static ivas_error renderActiveInputsMasa( CONTINUE; } - *outAudio.pq_fact = Q8; + *outAudio.pq_fact = outAudio.q_factor; move16(); IF( NE_32( ( error = renderInputMasa( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) -- GitLab From 4f89e38130f04dc71f72be03322ca68f5d0a3c7a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 29 Jun 2025 20:02:29 +0200 Subject: [PATCH 264/394] usage of W_shl_sat_l() --- lib_com/options.h | 2 ++ lib_dec/ivas_dirac_dec_fx.c | 4 ++++ lib_enc/ivas_enc_cov_handler_fx.c | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4fcc4a03e..405a71cc0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,4 +102,6 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ +#define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ + #endif diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index ba7741712..69983cbf2 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2009,7 +2009,11 @@ void ivas_dirac_dec_set_md_map( tmp_fx = W_add_nosat( tmp_fx, W_deposit32_l( L_deposit_l( hSpatParamRendCom->render_to_md_map[slot_idx_abs] ) ) ); slot_idx_abs = add( slot_idx_abs, 1 ); } +#ifdef FIX_1735_W_SHL_SAT_L + iDiv_and_mod_32( W_shl_sat_l( tmp_fx, 16 ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); +#else iDiv_and_mod_32( W_extract_l( W_shl_nosat( tmp_fx, 16 ) ), hSpatParamRendCom->subframe_nbslots[sf_idx], &quo, &rem, 0 ); +#endif hSpatParamRendCom->render_to_md_map[sf_idx] = add( round_fx( quo ), hSpatParamRendCom->dirac_read_idx ) % hSpatParamRendCom->dirac_md_buffer_length; move16(); } diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 495e6caa1..db2125de7 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -224,7 +224,11 @@ static Word16 ivas_spar_get_activeW_flag_fx( q_shift = Q31; move16(); q_shift = W_norm( bb_var_64bit[ch] ); +#ifdef FIX_1735_W_SHL_SAT_L + bb_var[ch] = W_shl_sat_l( bb_var_64bit[ch], sub( q_shift, 32 ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */ +#else bb_var[ch] = W_extract_l( W_shl_nosat( bb_var_64bit[ch], sub( q_shift, 32 ) ) ); /* q_bb_var[ch] + sub( q_shift, 32 ) */ +#endif move32(); q_bb_var[ch] = add( q_bb_var[ch], sub( q_shift, 32 ) ); move16(); -- GitLab From b49b11c8b9097eacb19f403a644caaf9fcf209f0 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 29 Jun 2025 20:07:08 +0200 Subject: [PATCH 265/394] formatting --- lib_enc/ivas_enc_cov_handler_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index db2125de7..8b4509f49 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -568,7 +568,7 @@ static void ivas_band_cov_fx( pV_re[k] = W_shl_sat_l( pV_re_64bit[k], q_shift_tmp ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); #else - pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) + pV_re[k] = W_extract_l( W_shl_nosat( pV_re_64bit[k], q_shift_tmp ) ); //(q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32) move32(); #endif /* perform rounding towards lower value for negative results */ -- GitLab From f4db1967eb63c8a491be62cbebdad2efee565cf8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 30 Jun 2025 13:38:02 +0530 Subject: [PATCH 266/394] Optimizations for multi-channel functions - 2 --- lib_com/ivas_fb_mixer_fx.c | 30 ++++++++++++-- lib_com/ivas_tools_fx.c | 8 ++++ lib_com/options.h | 1 + lib_com/tns_base.c | 17 ++++++-- lib_enc/ivas_mcmasa_enc_fx.c | 80 ++++++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index 0d8a74514..c40f65ad6 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -614,13 +614,21 @@ void ivas_fb_mixer_get_windowed_fr_fx( Word16 n_new_samples; Word32 fr_in_block_fx[L_FRAME48k * 2]; const Word16 *win_ptr_fx; - +#ifdef OPT_MCT_ENC_V1_BE + Word16 two_mdft_len = shl( mdft_len, 1 ); + Word16 tmp = sub( shl( mdft_len, 1 ), length ); + Word16 gb_neg = negate( gb ); + + n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), two_mdft_len ); + offset = sub( tmp, hFbMixer->ana_window_offset ); + rev_offset = sub( two_mdft_len, hFbMixer->ana_window_offset ); +#else n_old_samples = s_min( ( sub( hFbMixer->fb_cfg->prior_input_length, hFbMixer->fb_cfg->windowed_fr_offset ) ), ( shl( mdft_len, 1 ) ) ); - n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) ); offset = sub( sub( shl( mdft_len, 1 ), length ), hFbMixer->ana_window_offset ); rev_offset = sub( shl( mdft_len, 1 ), hFbMixer->ana_window_offset ); +#endif set32_fx( fr_in_block_fx, 0, offset ); - + n_new_samples = s_max( 0, sub( shl( length, 1 ), n_old_samples ) ); FOR( ch_idx = 0; ch_idx < nchan_fb_in; ch_idx++ ) { Copy32( &hFbMixer->ppFilterbank_prior_input_fx[ch_idx][offset + hFbMixer->fb_cfg->windowed_fr_offset], &fr_in_block_fx[offset], sub( n_old_samples, offset ) ); // Qx @@ -628,25 +636,41 @@ void ivas_fb_mixer_get_windowed_fr_fx( win_ptr_fx = hFbMixer->pAna_window_fx; /*Q15*/ +#ifdef OPT_MCT_ENC_V1_BE + FOR( j = offset; j < tmp; j++ ) +#else FOR( j = offset; j < sub( shl( mdft_len, 1 ), length ); j++ ) +#endif { fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( win_ptr_fx++ ) ) ); // Qx + 15 - 15 = Qx move32(); } +#ifdef OPT_MCT_ENC_V1_BE + FOR( j = rev_offset; j < two_mdft_len; j++ ) +#else FOR( j = rev_offset; j < shl( mdft_len, 1 ); j++ ) +#endif { fr_in_block_fx[j] = Mpy_32_16_1( fr_in_block_fx[j], ( *( --win_ptr_fx ) ) ); // Qx + 15 - 15 = Qx move32(); } +#ifdef OPT_MCT_ENC_V1_BE + scale_sig32( fr_in_block_fx, two_mdft_len, gb_neg ); +#else FOR( Word16 i = 0; i < shl( mdft_len, 1 ); i++ ) { fr_in_block_fx[i] = L_shr( fr_in_block_fx[i], gb ); // Qx - gb move32(); } +#endif +#ifdef OPT_MCT_ENC_V1_BE + ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], two_mdft_len, mdft_len ); +#else ivas_mdft_fx( fr_in_block_fx, frame_f_real_fx[ch_idx], frame_f_imag_fx[ch_idx], shl( mdft_len, 1 ), mdft_len ); +#endif } return; diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index ca8dec276..e334a8cda 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -1955,7 +1955,11 @@ void v_multc_acc_32_16( FOR( i = 0; i < N; i++ ) { +#ifdef OPT_MCT_ENC_V1_BE + y[i] = Madd_32_16( y[i], x[i], c ); +#else y[i] = L_add( y[i], Mpy_32_16_1( x[i], c ) ); +#endif move32(); } @@ -1972,7 +1976,11 @@ void v_multc_acc_32_32( FOR( i = 0; i < N; i++ ) { +#ifdef OPT_MCT_ENC_V1_BE + y[i] = Madd_32_32( y[i], x[i], c ); /*Qx*/ +#else y[i] = L_add( y[i], Mpy_32_32( x[i], c ) ); /*Qx*/ +#endif move32(); } diff --git a/lib_com/options.h b/lib_com/options.h index 4fcc4a03e..1a9f8ab84 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,6 +78,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCT_ENC_V1_NBE +#define OPT_MCT_ENC_V1_BE #define OPT_SBA_REND_V1_BE #define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_DEC_V2_BE diff --git a/lib_com/tns_base.c b/lib_com/tns_base.c index 5e18430be..376e2813d 100644 --- a/lib_com/tns_base.c +++ b/lib_com/tns_base.c @@ -1207,17 +1207,26 @@ static Word32 FIRLattice( move32(); FOR( i = 0; i < order - 1; i++ ) { - tmp = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) ); /*Q0*/ - x = L_add( x, Mpy_32_16_1( state[i], parCoeff[i] ) ); /* exponent: 31+0 */ - state[i] = tmpSave; /*Q0*/ +#ifdef OPT_MCT_ENC_V1_BE + tmp = Madd_32_16( state[i], x, parCoeff[i] ); /*Q0*/ + x = Madd_32_16( x, state[i], parCoeff[i] ); /* exponent: 31+0 */ +#else + tmp = L_add( state[i], Mpy_32_16_1( x, parCoeff[i] ) ); /*Q0*/ + x = L_add( x, Mpy_32_16_1( state[i], parCoeff[i] ) ); /* exponent: 31+0 */ +#endif + state[i] = tmpSave; /*Q0*/ move32(); tmpSave = tmp; /*Q0*/ move32(); } /* last stage: only need half operations */ +#ifdef OPT_MCT_ENC_V1_BE + x = Madd_32_16( x, state[order - 1], parCoeff[order - 1] ); /*Q0*/ +#else x = L_add( x, Mpy_32_16_1( state[order - 1], parCoeff[order - 1] ) ); /*Q0*/ - state[order - 1] = tmpSave; /*Q0*/ +#endif + state[order - 1] = tmpSave; /*Q0*/ move32(); return x; /*Q0*/ diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index 7d261d4e4..fb4ea608a 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -2156,6 +2156,85 @@ static void compute_cov_mtx_fx( return; } +#ifdef OPT_MCT_ENC_V1_BE +static void computeIntensityVector_enc_fx( + const Word16 *band_grouping, + Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ + const Word16 enc_param_start_band, /* i : first band to process */ + const Word16 num_frequency_bands, + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ) +{ + Word16 i, j; + Word32 real, img; + Word16 brange[2]; + Word16 shift_value = add( shl( inp_q, 1 ), 1 ); + Word16 tmp_norm; + FOR( i = 0; i < num_frequency_bands; i++ ) + { + brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */ + move16(); + brange[1] = band_grouping[i + enc_param_start_band + 1]; /* Q0 */ + move16(); + Word16 num_bins = sub( brange[1], brange[0] ); + Word16 gb = find_guarded_bits_fx( num_bins ); + Word16 norm; + + Word64 tmp_1 = 0, tmp_2 = 0, tmp_3 = 0; + move64(); + move64(); + move64(); + + FOR( j = brange[0]; j < brange[1]; j++ ) + { + real = Cldfb_RealBuffer[0][j]; + move32(); + img = Cldfb_ImagBuffer[0][j]; + move32(); + Word64 t1, t2, t3; + t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */ + t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */ + t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */ + t1 = W_shr( t1, gb ); + t2 = W_shr( t2, gb ); + t3 = W_shr( t3, gb ); + /* Intensity is XYZ order, audio is WYZX order. */ + tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */ + tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */ + tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */ + } + norm = 63; + move16(); + tmp_norm = W_norm( tmp_1 ); + if ( tmp_1 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + tmp_norm = W_norm( tmp_2 ); + if ( tmp_2 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + tmp_norm = W_norm( tmp_3 ); + if ( tmp_3 != 0 ) + { + norm = s_min( norm, tmp_norm ); + } + norm = sub( norm, 32 ); + intensity_real[0][i] = W_shl_sat_l( tmp_1, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[1][i] = W_shl_sat_l( tmp_2, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[2][i] = W_shl_sat_l( tmp_3, norm ); // shift_value - (gb - norm) + q_intensity_real[i] = sub( shift_value, sub( gb, norm ) ); + move16(); + } + + return; +} +#else static void computeIntensityVector_enc_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][DIRAC_NO_FB_BANDS_MAX], /*inp_q*/ @@ -2240,6 +2319,7 @@ static void computeIntensityVector_enc_fx( return; } +#endif static void computeVerticalDiffuseness_fx( Word32 **buffer_intensity, /* i : Intensity vectors */ -- GitLab From b1bbee2105e14cef6ca90e0f851ee3e0eef3a680 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 30 Jun 2025 11:07:16 +0200 Subject: [PATCH 267/394] also address lib_enc/analy_sp_fx.c --- lib_enc/analy_sp_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 8541decd8..6a55bff93 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -320,8 +320,12 @@ static void find_enr_dft_ivas_fx( bin_cnt = add( bin_cnt, 1 ); } - /* normalization per frequency bin */ + /* normalization per frequency bin */ +#ifdef FIX_1735_W_SHL_SAT_L + band_fx[i] = W_shl_sat_l( band_ener, -add( 32 - Q16, shift ) ); // *q_band +#else band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); /* per band energy without E_MIN */ -- GitLab From 7a3f492790180d2eb1ba153f5656d1032214a927 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 30 Jun 2025 11:21:15 +0200 Subject: [PATCH 268/394] formatting --- lib_enc/analy_sp_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6a55bff93..8e18883c7 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -320,11 +320,11 @@ static void find_enr_dft_ivas_fx( bin_cnt = add( bin_cnt, 1 ); } - /* normalization per frequency bin */ + /* normalization per frequency bin */ #ifdef FIX_1735_W_SHL_SAT_L - band_fx[i] = W_shl_sat_l( band_ener, -add( 32 - Q16, shift ) ); // *q_band + band_fx[i] = W_shl_sat_l( band_ener, -add( 32 - Q16, shift ) ); // *q_band #else - band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band + band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band #endif move32(); -- GitLab From 742401242c6018b7c9cd1a68f7416eb194b6b485 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 30 Jun 2025 15:39:43 +0530 Subject: [PATCH 269/394] Fix for 3GPP issue 1780: ParamISM4 at 32kbps EXT Decoder output at 16kHz is zero Link #1780 --- lib_dec/ivas_ism_param_dec_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index f3e37c5c0..c8f6694e7 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1339,14 +1339,14 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( { gain_fx = 0; move16(); - tmp_e1 = 31; + tmp_e1 = 0; move16(); } - ELSE - { /*handling denominator equals to zero*/ - gain_fx = 1; + ELSE /*handling denominator equals to zero*/ + { + gain_fx = 32767; //(max value of Word16 in Q0) move16(); - tmp_e1 = -32767; //(-1.0f in Q15) + 1 + tmp_e1 = 15; move16(); } } -- GitLab From 8d81abe6086ba0e333492b39c59a4a5ede87c0fe Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 30 Jun 2025 15:46:59 +0530 Subject: [PATCH 270/394] Fix for 3GPP issue 1777: McMASA LFE Gains codebooks precision Link #1777 --- lib_com/ivas_rom_com_fx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 6bb2eaa10..1cfe1ff6c 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -485,14 +485,14 @@ const Word32 dft_res_gains_q_fx[][2] = { // Q13 const Word16 McMASA_LFEGain_vectors_fx_q13[64] = { - 3112, 2703, 1556, 1638, -1310, -1802, -2867, -2785, - 4096, 4096, 4096, 4096, -6553, -3276, 8355, 819, - -4096, -4096, -4096, -4096, -4587, -983, -6389, 11141, - -8355, 9666, -4669, 2703, 5898, -9256, 7946, -5079, - -7454, 7618, 8192, -9011, 14172, -1884, -6389, -6881, - 7782, -13107, -2785, 7618, 7127, 3850, -15564, 4259, - 5488, 11632, -7946, -10158, 6799, 4751, 4997, -16711, - -6553, -12943, 6717, 11632, -17530, 2129, 6881, 8355 + 3113, 2703, 1556, 1638, -1311, -1802, -2867, -2785, + 4096, 4096, 4096, 4096, -6554, -3277, 8356, 819, + -4096, -4096, -4096, -4096, -4588, -983, -6390, 11141, + -8356, 9667, -4669, 2703, 5898, -9257, 7946, -5079, + -7455, 7619, 8192, -9011, 14172, -1884, -6390, -6881, + 7782, -13107, -2785, 7619, 7127, 3850, -15565, 4260, + 5489, 11633, -7946, -10158, 6799, 4751, 4997, -16712, + -6554, -12943, 6717, 11633, -17531, 2130, 6881, 8356 }; // Q25 -- GitLab From b6dbf27abe0e2f1d0a8c657e024ce1e453171619 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 30 Jun 2025 13:19:55 +0200 Subject: [PATCH 271/394] fix missing ; --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2ec72727a..0c61cf5b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1094,7 +1094,7 @@ check-be-between-renderer-framesizes: - *print-results-banner - echo "!! Encoder command lines are in the 20ms log files only !!!" - - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors."; zero_errors=0 fi + - if [ $exit_code -ne 0 ]; then echo "20 ms framesize run already failed with errors."; zero_errors=0; fi - if [ $zero_errors5 != 1 ]; then echo "run error with 5ms rendering encountered"; zero_errors=0 ; fi - if [ $zero_errors10 != 1 ]; then echo "run error with 10ms rendering encountered"; zero_errors=0 ; fi - if [ $zero_errors != 1 ]; then exit $EXIT_CODE_FAIL; fi -- GitLab From 66d76646f1ca553f966b22429530449f81bfc55b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 30 Jun 2025 17:06:41 +0530 Subject: [PATCH 272/394] Optimization for tcx_scalar_quantization_ivas_fx function changes are under macro: OPT_MCT_ENC_V2_NBE stream used: IVAS_cod -mc 7_1_4 -max_band fb 192000 48 stv714MC48c.wav mc_7_1_4.bit (MCT_714_192kbps_FB) Around 18 WMOPs reduced --- lib_com/options.h | 1 + lib_enc/tcx_utils_enc_fx.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 1a9f8ab84..dd32167b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -77,6 +77,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V2_NBE #define OPT_MCT_ENC_V1_NBE #define OPT_MCT_ENC_V1_BE #define OPT_SBA_REND_V1_BE diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 9a15cec28..9ca9eb82a 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1355,23 +1355,37 @@ void tcx_scalar_quantization_ivas_fx( { Word16 i, tmp16, s; Word32 tmp32, offs32; +#ifdef OPT_MCT_ENC_V2_NBE + Word32 offs32_1; + Word32 offset_Q16 = L_shl( offset, 1 ); // Q16 +#endif /* common exponent for x and gain for comparison */ tmp16 = sub( gain_e, x_e ); +#ifdef OPT_MCT_ENC_V2_NBE + tmp32 = L_shl_sat( L_deposit_h( gain ), tmp16 ); // exp:x_e +#else tmp32 = L_shl( L_deposit_h( gain ), s_max( -31, s_min( tmp16, 0 ) ) ); tmp16 = negate( s_max( tmp16, 0 ) ); +#endif i = sub( L_frame, 1 ); IF( memQuantZeros_fx != NULL ) { test(); +#ifdef OPT_MCT_ENC_V2_NBE + FOR( ; ( ( memQuantZeros_fx[i] != 0 ) && ( L_abs( x[i] ) < tmp32 ) ); i-- ) +#else WHILE( ( memQuantZeros_fx[i] != 0 ) && ( LT_32( L_abs( L_shl( x[i], tmp16 ) ), tmp32 ) ) ) +#endif { test(); xq[i] = 0; move16(); +#ifndef OPT_MCT_ENC_V2_NBE i = sub( i, 1 ); +#endif } } @@ -1394,6 +1408,22 @@ void tcx_scalar_quantization_ivas_fx( FOR( ; i >= 0; i-- ) { +#ifdef OPT_MCT_ENC_V2_NBE + offs32 = Mpy_32_16_1( x[i], gain ); + offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ + + offs32_1 = L_add_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32_1 ); + IF( x[i] < 0 ) + { + offs32 = L_sub_sat( offs32, offset_Q16 ); /*15Q16 */ + tmp16 = extract_h( offs32 ); + if ( L_mac_sat( offs32, tmp16, -ONE_IN_Q15 ) > 0 ) + { + tmp16 = add( tmp16, 1 ); + } + } +#else offs32 = Mpy_32_16_1( x[i], gain ); /* multiply */ offs32 = L_shl_sat( offs32, s ); /* convert to 15Q16 */ IF( x[i] > 0 ) @@ -1414,6 +1444,7 @@ void tcx_scalar_quantization_ivas_fx( tmp16 = add( tmp16, 1 ); } } +#endif xq[i] = tmp16; move16(); } -- GitLab From 938ce84fd228dbdb1c92f4d271fbb19afe85ae8c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 30 Jun 2025 20:02:05 +0200 Subject: [PATCH 273/394] addressing comment --- lib_enc/analy_sp_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 8e18883c7..0d42e5ff2 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -322,7 +322,7 @@ static void find_enr_dft_ivas_fx( /* normalization per frequency bin */ #ifdef FIX_1735_W_SHL_SAT_L - band_fx[i] = W_shl_sat_l( band_ener, -add( 32 - Q16, shift ) ); // *q_band + band_fx[i] = W_shl_sat_l( band_ener, sub( Q16 - 32, shift ) ); // *q_band #else band_fx[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band #endif -- GitLab From 9de72e763fce51bf41ddccc0457504c4a1148318 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 30 Jun 2025 20:12:10 +0200 Subject: [PATCH 274/394] fix i_mult_o(), i_mult() --- lib_com/basop32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/basop32.c b/lib_com/basop32.c index fbe08a11f..6a34cff43 100644 --- a/lib_com/basop32.c +++ b/lib_com/basop32.c @@ -3582,13 +3582,13 @@ Word16 i_mult_o( Word16 a, Word16 b, Flag *Overflow ) #ifdef ORIGINAL_G7231 return a * b; #else - register Word32 c = a * b; + register Word32 c = (Word32) a * b; return saturate_o( c, Overflow ); #endif } Word16 i_mult( Word16 a, Word16 b ) { - return i_mult_o( a, b, NULL ); + return i_mult_sat( a, b ); } Word16 i_mult_sat( Word16 a, Word16 b ) { -- GitLab From 79ac8b76148a0927c7605d5c03723f5b27e187b3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 1 Jul 2025 06:55:34 +0200 Subject: [PATCH 275/394] clang format patch --- lib_com/deemph_fx.c | 2 +- lib_com/low_rate_band_att_fx.c | 4 ++-- lib_dec/FEC_HQ_phase_ecu_fx.c | 4 ++-- lib_enc/gaus_enc_fx.c | 4 ++-- lib_enc/stat_noise_uv_enc_fx.c | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c index b8e3a72cd..523061b98 100644 --- a/lib_com/deemph_fx.c +++ b/lib_com/deemph_fx.c @@ -202,7 +202,7 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W #else L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/ #endif - x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ + x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/ move16(); } } diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index d762d628d..186074445 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -96,7 +96,7 @@ void ivas_fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ #ifdef ISSUE_1772_replace_shr_o tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ #else @@ -208,7 +208,7 @@ void fine_gain_pred_fx( exp = add( exp, exp2 ); /*gp *= 1.0f - 0.05f / accuracy; */ - tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ + tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */ #ifdef ISSUE_1772_replace_shr_o tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */ #else diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 5ac191836..7c4c91936 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1202,13 +1202,13 @@ static Word16 imax_fx( /* o: The location, relative to the } /* Although the output of ratio() is in Q14, adding the missing factor of 2 (See above) * in the denominator, the output is now considered to be in Q15. */ - man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ + man = ratio( numer, denom, &expo ); /* The mantissa is considered in Q15 */ #ifdef ISSUE_1772_replace_shr_o posi = shr_sat( man, expo ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ #else posi = shr_o( man, expo, &Overflow ); /* in Q15 (Due to saturation, it is automatically bound inside [-1.0,1.0].) */ #endif - if ( sign < 0 ) /* Restore the sign. */ + if ( sign < 0 ) /* Restore the sign. */ { posi = negate( posi ); } diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index d002d5206..1efe1f656 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -367,7 +367,7 @@ void gauss2v_fx( #else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ #endif - delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ + delta = i_mult2( delta, m_sign ); /* Apply sign Q0*/ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); @@ -832,7 +832,7 @@ void gauss2v_ivas_fx( #else delta = shr_o( div_s( Num, Den ), sub( exp_num, exp_den ), &Overflow ); /* Q15 */ #endif - delta = i_mult2( delta, m_sign ); /* Apply sign */ + delta = i_mult2( delta, m_sign ); /* Apply sign */ /* index_delta = (short)(FAC_DELTA * fdelta) */ index_delta = shr( delta, SFAC_DELTA ); diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 8d4f899da..5dcb6d444 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -67,14 +67,14 @@ void stat_noise_uv_enc_fx( expn = sub( norm_l( LepsP[0] ), 1 ); num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ expd = norm_l( LepsP[1] ); - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ #ifdef ISSUE_1772_replace_shr_o num = shr_sat( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ #else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ #endif - num = sub( num, 1024 ); /*num - 1*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) @@ -144,14 +144,14 @@ void stat_noise_uv_enc_ivas_fx( expn = sub( norm_l( LepsP[0] ), 1 ); num = extract_h( L_shl_o( LepsP[0], expn, &Overflow ) ); /*expn-16*/ expd = norm_l( LepsP[1] ); - den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ - num = div_s( num, den ); /*expn-expd+15*/ + den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ + num = div_s( num, den ); /*expn-expd+15*/ #ifdef ISSUE_1772_replace_shr_o num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ #else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ #endif - num = sub( num, 1024 ); /*num - 1*/ + num = sub( num, 1024 ); /*num - 1*/ test(); IF( NE_16( st_fx->bwidth, NB ) ) -- GitLab From ff28a5814d5d7af413ec11e5b8d217acf8f90133 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 1 Jul 2025 11:32:01 +0530 Subject: [PATCH 276/394] Fix for 3GPP issue 1782: Assert in IVAS_rend with MASA + MC input to MASA output Link #1782 --- lib_rend/ivas_mcmasa_ana_fx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 3cb2c4fcf..99af8a0af 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -959,29 +959,27 @@ void ivas_mcmasa_param_est_ana_fx( IF( LT_16( i1, i2 ) ) { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - tempCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i2], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); + tempCoh_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i1][i2], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); tempCoh_e = add( tempCoh_e, sub( absCOVls_e[i1][i2], temp_e ) ); } ELSE { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - tempCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i2][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); + tempCoh_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i2][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_e ) ), &tempCoh_e ); tempCoh_e = add( tempCoh_e, sub( absCOVls_e[i2][i1], temp_e ) ); } - tempCoh_fx = L_shl( tempCoh_fx, 16 ); IF( LT_16( i1, i3 ) ) { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i3] ); - tempCoh2_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i3], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); + tempCoh2_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i1][i3], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); tempCoh2_e = add( tempCoh2_e, sub( absCOVls_e[i1][i3], temp_e ) ); } ELSE { temp_e = add( lsEnergy_e[i1], lsEnergy_e[i3] ); - tempCoh2_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i3][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); + tempCoh2_fx = BASOP_Util_Divide3232_Scale_newton( absCOVls_fx[i3][i1], ( Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ) ), &tempCoh2_e ); tempCoh2_e = add( tempCoh2_e, sub( absCOVls_e[i3][i1], temp_e ) ); } - tempCoh2_fx = L_shl( tempCoh2_fx, 16 ); IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tempCoh_fx, tempCoh_e, tempCoh2_fx, tempCoh2_e ), -1 ) ) { cohPanCoh_fx = tempCoh_fx; -- GitLab From 9e299235f6a74d62147a87ed46d79cf2fcd9e6c6 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 1 Jul 2025 08:09:24 +0200 Subject: [PATCH 277/394] buildfix --- lib_enc/enc_gen_voic_rf_fx.c | 2 +- lib_enc/set_impulse_fx.c | 2 +- lib_enc/stat_noise_uv_enc_fx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/enc_gen_voic_rf_fx.c b/lib_enc/enc_gen_voic_rf_fx.c index 79dc33d82..8d9e1e1a1 100644 --- a/lib_enc/enc_gen_voic_rf_fx.c +++ b/lib_enc/enc_gen_voic_rf_fx.c @@ -450,7 +450,7 @@ void coder_acelp_rf_fx( hRF->rf_mem_w0 = sub_o( xn[L_SUBFR - 1], round_fx_o( L_shl_o( Ltmp, 1, &Overflow ), &Overflow ), &Overflow ); /* Q_xn */ move16(); #ifdef ISSUE_1772_replace_shr_o - hRF->rf_mem_w0 = shr_sat( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ + hRF->rf_mem_w0 = shr_sat( hRF->rf_mem_w0, shift ); /*Qnew-1*/ #else hRF->rf_mem_w0 = shr_o( hRF->rf_mem_w0, shift, &Overflow ); /*Qnew-1*/ #endif diff --git a/lib_enc/set_impulse_fx.c b/lib_enc/set_impulse_fx.c index f6f7b6dd5..364d78f97 100644 --- a/lib_enc/set_impulse_fx.c +++ b/lib_enc/set_impulse_fx.c @@ -202,7 +202,7 @@ void set_impulse_fx( num = div_s( num, den ); #ifdef ISSUE_1772_replace_shr_o - krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ + krit_fx = shr_sat( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ) ); /* Q18 */ #else krit_fx = shr_o( num, sub( sub( shl_o( exp_num, 1, &Overflow ), exp_den ), 2 ), &Overflow ); /* Q18 */ #endif diff --git a/lib_enc/stat_noise_uv_enc_fx.c b/lib_enc/stat_noise_uv_enc_fx.c index 5dcb6d444..8dfb40738 100644 --- a/lib_enc/stat_noise_uv_enc_fx.c +++ b/lib_enc/stat_noise_uv_enc_fx.c @@ -70,7 +70,7 @@ void stat_noise_uv_enc_fx( den = extract_h( L_shl_o( LepsP[1], expd, &Overflow ) ); /*expd-16*/ num = div_s( num, den ); /*expn-expd+15*/ #ifdef ISSUE_1772_replace_shr_o - num = shr_sat( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ + num = shr_sat( num, add( sub( expn, expd ), 5 ) ); /*Q10*/ #else num = shr_o( num, add( sub( expn, expd ), 5 ), &Overflow ); /*Q10*/ #endif -- GitLab From 9332ccdec7af282aceb93b5841e2ec7d358dee7d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 27 Jun 2025 10:58:14 +0530 Subject: [PATCH 278/394] Non bit exact optimizations in sba dec path Max MLD deviation observed < 0.1 normalizePanningGains_fx, dirac_out_synth_sfr, ivas_mdct_core_tns_ns_fx, ivas_mct_dec functions changed --- lib_com/ivas_prot_fx.h | 15 +++- lib_com/options.h | 1 + lib_com/prot_fx.h | 8 +- lib_dec/dec_tcx_fx.c | 6 ++ lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 9 +++ lib_dec/ivas_mct_core_dec_fx.c | 25 +++++- lib_dec/ivas_mct_dec_fx.c | 32 +++++++- lib_dec/ivas_mct_dec_mct_fx_fx.c | 29 +++++++ lib_dec/ivas_mdct_core_dec_fx.c | 84 +++++++++++++++++++- lib_dec/ivas_stereo_mdct_core_dec_fx.c | 21 ++++- lib_dec/tonalMDCTconcealment_fx.c | 14 +++- 11 files changed, 231 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index e35cf648c..9e9e65bb7 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1575,7 +1575,12 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - Word16 x_e[CPE_CHANNELS][NB_DIV] ); +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e +#else /* OPT_SBA_DEC_V2_NBE */ + Word16 x_e[CPE_CHANNELS][NB_DIV] +#endif /* OPT_SBA_DEC_V2_NBE */ +); void decoder_tcx_imdct_fx( Decoder_State *st, /* i/o: coder memory state */ @@ -1936,9 +1941,17 @@ void ivas_mdct_core_invQ_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_0_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_0_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV], Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ diff --git a/lib_com/options.h b/lib_com/options.h index baac02d0d..450b94c16 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,6 +78,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCT_ENC_V2_NBE +#define OPT_SBA_DEC_V2_NBE #define OPT_MCT_ENC_V1_NBE #define OPT_MCT_ENC_V1_BE #define OPT_SBA_REND_V1_BE diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 666484359..3144c16dd 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6412,9 +6412,13 @@ void TonalMDCTConceal_Apply( ); void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, /*IN/OUT*/ + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, /*IN/OUT*/ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 mdctSpectrum_exp, /*IN */ +#else /* OPT_SBA_DEC_V2_NBE */ Word16 mdctSpectrum_exp[L_FRAME48k], /*IN */ +#endif /* OPT_SBA_DEC_V2_NBE */ const PsychoacousticParameters *psychParamsCurrent ); void TonalMDCTConceal_InsertNoise_ivas_fx( diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 41c3f9740..6590d4b43 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -4761,14 +4761,19 @@ void decoder_tcx_noiseshaping_igf_fx( test(); IF( bfi && st->tonal_mdct_plc_active && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifndef OPT_SBA_DEC_V2_NBE Word16 tmp_x_fx_exp[L_FRAME48k], temp; temp = -MAX_16; move16(); set16_fx( tmp_x_fx_exp, *x_e, L_frameTCX ); TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx, tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent ); +#else /* OPT_SBA_DEC_V2_NBE */ + TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx, *x_e, st->hTcxCfg->psychParamsCurrent ); +#endif /* OPT_SBA_DEC_V2_NBE */ /* If exponent has been updated after TonalMDCTConceal_Apply, then shift the spectrum to common exponent. */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < L_frameTCX; i++ ) { temp = s_max( temp, tmp_x_fx_exp[i] ); @@ -4783,6 +4788,7 @@ void decoder_tcx_noiseshaping_igf_fx( move32(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ } test(); diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 532ca0358..4869f8d1c 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -591,10 +591,14 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( /* apply residual mixing */ { Word16 shifter; +#ifdef OPT_SBA_DEC_V2_NBE + shifter = sub( mixing_matrix_res_smooth_e, 32 ); +#else /* OPT_SBA_DEC_V2_NBE */ #ifdef OPT_SBA_DEC_V2_BE shifter = sub( mixing_matrix_res_smooth_e, 31 ); #else /* OPT_SBA_DEC_V2_BE */ shifter = 31 - mixing_matrix_res_smooth_e; +#endif /* OPT_SBA_DEC_V2_NBE */ #endif /* OPT_SBA_DEC_V2_BE */ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) { @@ -610,8 +614,13 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( move64(); for ( i = 0; i < nY; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + temp_real = W_mac_32_32( temp_real, mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ); + temp_imag = W_mac_32_32( temp_imag, mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ); +#else /* OPT_SBA_DEC_V2_NBE */ temp_real = W_add( temp_real, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_real_fx[i] ) ); temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ idx += nY; } #ifdef OPT_SBA_DEC_V2_BE diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 08359826a..87c139f9c 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -256,7 +256,11 @@ void ivas_mct_core_dec( move16(); x_fx[ch][0] = signal_out_fx[ch]; x_fx[ch][1] = signal_out_fx[ch] + ( L_FRAME48k / 2 ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } @@ -332,7 +336,7 @@ void ivas_mct_core_dec( move16(); } } -#else /* OPT_SBA_DEC_PATH */ +#else /* OPT_SBA_DEC_PATH */ IF( EQ_16( st->core, TCX_10_CORE ) ) { nSubframes = NB_DIV; @@ -362,10 +366,18 @@ void ivas_mct_core_dec( move16(); FOR( i = 0; i < x_len; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q11 ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q12 ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } #endif /* OPT_SBA_DEC_PATH */ @@ -385,18 +397,27 @@ void ivas_mct_core_dec( #ifdef OPT_SBA_DEC_PATH apply_MCT_dec_fx( hMCT, sts, x_fx ); -#else /* OPT_SBA_DEC_PATH */ +#else /* OPT_SBA_DEC_PATH */ apply_MCT_dec_fx( hMCT, sts, x_fx, q_x ); FOR( ch = 0; ch < nChannels; ch++ ) { FOR( i = 0; i < L_FRAME48k / 2; i++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q11 ) ); + x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q11 ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q12 ) ); x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q12 ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } #endif /* OPT_SBA_DEC_PATH */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index ec7b8c697..ccc515b03 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -64,7 +64,7 @@ ivas_error ivas_mct_dec_fx( const Word16 nb_bits_metadata /* i : number of metadata bits */ ) { - Word16 ch, nCPE, cpe_id; + Word16 nCPE, cpe_id; MCT_DEC_HANDLE hMCT; CPE_DEC_HANDLE hCPE; Word16 param[MCT_MAX_BLOCKS][CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV]; @@ -76,10 +76,13 @@ ivas_error ivas_mct_dec_fx( Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; // Q12 Word32 output_lfe_ch_fx[L_FRAME48k]; Word16 q_output = 11; - Word16 n, k, i; + Word16 n, i; Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e) +#ifndef OPT_SBA_DEC_V2_NBE Word16 x_e[MAX_CICP_CHANNELS][NB_DIV]; + Word16 ch, k; +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV]; set16_fx( x_len[0], 0, NB_DIV ); set16_fx( x_len[1], 0, NB_DIV ); @@ -182,21 +185,31 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][0] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][1] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 ); set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 ); } +#ifndef OPT_SBA_DEC_V2_NBE ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], fUseTns[cpe_id], tnsData[cpe_id], x_fx, x_e, x_fx, x_e, x_len, Aq_fx[cpe_id], NULL, 1 ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], + fUseTns[cpe_id], tnsData[cpe_id], x_fx, 20, x_fx, 20, x_len, Aq_fx[cpe_id], NULL, 1 ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { Word16 subFrames; @@ -214,6 +227,7 @@ ivas_error ivas_mct_dec_fx( Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); // Scaling back to Q11 } } +#endif /* OPT_SBA_DEC_V2_NBE */ st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect ); move16(); @@ -224,18 +238,22 @@ ivas_error ivas_mct_dec_fx( /* MCT core decoder */ Word16 q_x[MAX_TRANSPORT_CHANNELS]; +#ifndef OPT_SBA_DEC_V2_NBE set16_fx( q_x, Q12, MAX_TRANSPORT_CHANNELS ); // Scaling output buffer to q_x FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); // Q11 -> Q12 } +#endif /* OPT_SBA_DEC_V2_NBE */ ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x ); // Scaling output buffer back to Q11 +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i ) { Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); // Q12 -> Q11 } +#endif /* OPT_SBA_DEC_V2_NBE */ /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/ @@ -263,16 +281,25 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16 x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11 x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11 +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][0] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_e[n][1] = 20; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } +#ifndef OPT_SBA_DEC_V2_NBE ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, x_e ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( Word16 ind = 0; ind < 2; ind++ ) { Word16 nSubFrames; @@ -291,6 +318,7 @@ ivas_error ivas_mct_dec_fx( Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); // Q11 } } +#endif /* OPT_SBA_DEC_V2_NBE */ } diff --git a/lib_dec/ivas_mct_dec_mct_fx_fx.c b/lib_dec/ivas_mct_dec_mct_fx_fx.c index 0d998b355..f470ac9cd 100644 --- a/lib_dec/ivas_mct_dec_mct_fx_fx.c +++ b/lib_dec/ivas_mct_dec_mct_fx_fx.c @@ -323,8 +323,13 @@ void mctStereoIGF_dec_fx( move16(); // Using input Q-factor as 12 +#ifdef OPT_SBA_DEC_V2_NBE + set16_fx( p_x_e[0], 31 - Q11, CPE_CHANNELS ); // Q12 + set16_fx( p_x_e[1], 31 - Q11, CPE_CHANNELS ); // Q12 +#else /* OPT_SBA_DEC_V2_NBE */ set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); // Q12 set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); // Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( k = 0; k < nSubframes; k++ ) { @@ -353,13 +358,21 @@ void mctStereoIGF_dec_fx( decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ ); // Shifting output with variable exponent back to Q12 +#ifdef OPT_SBA_DEC_V2_NBE + shr_k = sub( 31 - Q11, p_x_e[0][k] ); +#else /* OPT_SBA_DEC_V2_NBE */ shr_k = sub( 31 - Q12, p_x_e[0][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( Word16 i = 0; i < p_x_len[0][k]; i++ ) { p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k ); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + shr_k = sub( 31 - Q11, p_x_e[1][k] ); +#else /* OPT_SBA_DEC_V2_NBE */ shr_k = sub( 31 - Q12, p_x_e[1][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( Word16 i = 0; i < p_x_len[1][k]; i++ ) { p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k ); @@ -392,7 +405,11 @@ void mctStereoIGF_dec_fx( /* mono or dual mono IGF decoding */ +#ifdef OPT_SBA_DEC_V2_NBE + x_e = 31 - Q11; // input q-factor of x[p_ch[ch]][k] is Q12 +#else /* OPT_SBA_DEC_V2_NBE */ x_e = 31 - Q12; // input q-factor of x[p_ch[ch]][k] is Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); decoder_tcx_IGF_mono_fx( st, x[p_ch[ch]][k], &x_e, &x_len, L_frame[ch], left_rect[ch], bfi, k ); @@ -400,7 +417,11 @@ void mctStereoIGF_dec_fx( FOR( Word16 i = 0; i < x_len; i++ ) { // Converting from variable exponent to Fixed q-factor (Q12) +#ifdef OPT_SBA_DEC_V2_NBE + x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q11, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q12, x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } } @@ -452,7 +473,11 @@ void mctStereoIGF_dec_fx( init_tcx_info_fx( st, L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] ); /* mono or dual mono IGF decoding */ +#ifdef OPT_SBA_DEC_V2_NBE + x_e = 31 - Q11; // Input Q-factor is Q12. +#else /* OPT_SBA_DEC_V2_NBE */ x_e = 31 - Q12; // Input Q-factor is Q12. +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); decoder_tcx_IGF_mono_fx( st, x[ch][k], &x_e, &x_len, L_frame[0], left_rect[0], bfi, k ); @@ -460,7 +485,11 @@ void mctStereoIGF_dec_fx( FOR( Word16 i = 0; i < x_len; i++ ) { // Converting from variable exponent to Fixed q-factor (Q12) +#ifdef OPT_SBA_DEC_V2_NBE + x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q11, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q12, x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ move32(); } } diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 4e90792fb..5f529be55 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -630,9 +630,17 @@ void ivas_mdct_core_invQ_fx( Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_0_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_0_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e, +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV], +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 x_len[CPE_CHANNELS][NB_DIV], Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients Q12*/ Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ @@ -963,9 +971,11 @@ void ivas_mdct_core_invQ_fx( IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) ) { +#ifndef OPT_SBA_DEC_V2_NBE set32_fx( x[ch][0], 0, st->hTcxCfg->tcx_coded_lines ); x_e[ch][0] = 31; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ /* usually set in decoder_tcx_invQ(), needed for concealment */ st->hTcxDec->damping = 0; move16(); @@ -997,6 +1007,10 @@ void ivas_mdct_core_invQ_fx( FOR( k = 0; k < nSubframes[ch]; k++ ) { +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e_local = x_e; + Word16 j, diff; +#endif /* OPT_SBA_DEC_V2_NBE */ /* Stability Factor */ IF( !bfi ) { @@ -1031,17 +1045,38 @@ void ivas_mdct_core_invQ_fx( nf_seed = 0; move16(); - decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); + diff = sub( x_e_local, x_0_e ); + IF( diff != 0 ) + { + FOR( j = 0; j < L_frameTCX[ch]; j++ ) + { + x_0[ch][k][j] = L_shl_sat( x[ch][k][j], diff ); + move32(); + } + } + ELSE + { + Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); + } +#else /* OPT_SBA_DEC_V2_NBE */ + decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k ); +#endif /* OPT_SBA_DEC_V2_NBE */ shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] ); move16(); Scale_sig32( x[ch][k], L_frameTCX[ch], shift ); +#ifdef OPT_SBA_DEC_V2_NBE + x_e_local = sub( x_e_local, shift ); +#else /* OPT_SBA_DEC_V2_NBE */ x_e[ch][k] = sub( x_e[ch][k], shift ); move16(); Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] ); x_0_e[ch][k] = x_e[ch][k]; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ // PLC to be done test(); @@ -1050,15 +1085,29 @@ void ivas_mdct_core_invQ_fx( TonalMdctConceal_create_concealment_noise_ivas_fx( concealment_noise_fx[ch], &concealment_noise_e[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi ); } +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k ); +#else /* OPT_SBA_DEC_V2_NBE */ decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k ); +#endif /* OPT_SBA_DEC_V2_NBE */ shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] ); move16(); Scale_sig32( x[ch][k], L_frameTCX[ch], shift ); +#ifdef OPT_SBA_DEC_V2_NBE + x_e_local = sub( x_e_local, shift ); +#else /* OPT_SBA_DEC_V2_NBE */ x_e[ch][k] = sub( x_e[ch][k], shift ); +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); +#ifdef OPT_SBA_DEC_V2_NBE + decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e_local, &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi ); + + Scale_sig32( x[ch][k], L_frameTCX[ch], sub( x_e_local, x_e ) ); +#else /* OPT_SBA_DEC_V2_NBE */ decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e[ch][k], &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi ); +#endif /* OPT_SBA_DEC_V2_NBE */ } } } @@ -1458,7 +1507,11 @@ void ivas_mdct_core_tns_ns_fx( Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS Q(31 - x_e)*/ Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients Q16*/ const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 x_e ) +#else /* OPT_SBA_DEC_V2_NBE */ Word16 x_e[CPE_CHANNELS][NB_DIV] ) +#endif /* OPT_SBA_DEC_V2_NBE */ { Word16 ch, k, bfi; Decoder_State **sts, *st; @@ -1532,7 +1585,11 @@ void ivas_mdct_core_tns_ns_fx( &tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] ); Word16 q_x; +#ifdef OPT_SBA_DEC_V2_NBE + q_x = sub( 31, x_e ); +#else /* OPT_SBA_DEC_V2_NBE */ q_x = sub( 31, x_e[ch][k] ); +#endif /* OPT_SBA_DEC_V2_NBE */ IF( bfi == 0 ) { sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); // Q16 @@ -1551,7 +1608,11 @@ void ivas_mdct_core_tns_ns_fx( scf_e[ind] = sub( 15, q_shift ); move16(); } +#ifdef OPT_SBA_DEC_V2_NBE + TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); +#else /* OPT_SBA_DEC_V2_NBE */ TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ } } ELSE @@ -1613,8 +1674,10 @@ void ivas_mdct_core_tns_ns_fx( norm_x = getScaleFactor32( &x_fx[ch][k][0], length ); Scale_sig32( &x_fx[ch][k][0], length, norm_x ); q_x = add( q_x, norm_x ); +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ Word16 q_sns_int_scf; Word16 q_2; @@ -1641,8 +1704,10 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0] + length, sub( length2, length ), sub( add( q_x, 1 ), q_2 ) ); q_x = add( q_x, 1 ); } +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) ); @@ -1650,8 +1715,10 @@ void ivas_mdct_core_tns_ns_fx( Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) ); q_x = q_2; move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_e[ch][k] = sub( 31, q_x ); move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ q_x = sub( q_x, 5 ); length = L_frameTCX[ch]; @@ -1668,25 +1735,37 @@ void ivas_mdct_core_tns_ns_fx( } Scale_sig32( &x_fx[ch][k][0], length, -5 ); decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0, &length ); +#ifndef OPT_SBA_DEC_V2_NBE norm_x = getScaleFactor32( &x_fx[ch][k][0], length ); Scale_sig32( &x_fx[ch][k][0], length, norm_x ); q_x = add( q_x, norm_x ); x_e[ch][k] = sub( 31, q_x ); move16(); +#else /* OPT_SBA_DEC_V2_NBE */ + Scale_sig32( &x_fx[ch][k][0], length, sub( sub( 31, q_x ), x_e ) ); +#endif /* OPT_SBA_DEC_V2_NBE */ } IF( ( bfi != 0 ) && ( st->tonal_mdct_plc_active != 0 ) ) { - Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16, i; +#ifndef OPT_SBA_DEC_V2_NBE + Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ + Word16 i; FOR( i = 0; i < FDNS_NPTS; i++ ) { st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] ); } +#ifndef OPT_SBA_DEC_V2_NBE set16_fx( tmp_x_fx_exp, x_e[ch][0], L_FRAME48k ); TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent ); +#else /* OPT_SBA_DEC_V2_NBE */ + TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], x_e, st->hTcxCfg->psychParamsCurrent ); +#endif /* OPT_SBA_DEC_V2_NBE */ +#ifndef OPT_SBA_DEC_V2_NBE FOR( i = 0; i < L_FRAME48k; i++ ) { temp = s_max( temp, tmp_x_fx_exp[i] ); @@ -1701,6 +1780,7 @@ void ivas_mdct_core_tns_ns_fx( move32(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ } test(); diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 85ae00c90..b52d04951 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -178,7 +178,9 @@ void stereo_mdct_core_dec_fx( /*needed to allocate N_MAX to prevent stereo switching crash */ Word32 x_0_buf_fx[CPE_CHANNELS][N_MAX]; Word32 *x_0_fx[CPE_CHANNELS][NB_DIV]; +#ifndef OPT_SBA_DEC_V2_NBE Word16 x_0_e[CPE_CHANNELS][NB_DIV]; +#endif /* OPT_SBA_DEC_V2_NBE */ /* Concealment */ Word16 bfi; @@ -289,15 +291,24 @@ void stereo_mdct_core_dec_fx( { FOR( j = 0; j < NB_DIV; ++j ) { +#ifndef OPT_SBA_DEC_V2_NBE x_e[i][j] = 31; +#else /* OPT_SBA_DEC_V2_NBE */ + x_e[i][j] = 20; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); x_len[i][j] = 0; move16(); +#ifndef OPT_SBA_DEC_V2_NBE x_0_e[i][j] = 31; move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } } +#ifdef OPT_SBA_DEC_V2_NBE + ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, 20, x_fx, 20, x_len, Aq_fx, ms_mask, 0 ); +#else /* OPT_SBA_DEC_V2_NBE */ ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, x_0_e, x_fx, x_e, x_len, Aq_fx, ms_mask, 0 ); FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -323,6 +334,7 @@ void stereo_mdct_core_dec_fx( move16(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ FOR( ch = 0; ch < nChannels; ch++ ) { @@ -471,6 +483,8 @@ void stereo_mdct_core_dec_fx( move16(); #endif /* OPT_SBA_DEC_PATH */ +#ifndef OPT_SBA_DEC_V2_NBE + FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { if ( NE_16( hCPE->hCoreCoder[ch]->core, TCX_20_CORE ) ) @@ -479,6 +493,7 @@ void stereo_mdct_core_dec_fx( move16(); } } +#endif /* OPT_SBA_DEC_V2_NBE */ #ifdef OPT_SBA_DEC_PATH stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 ); #else /* OPT_SBA_DEC_PATH */ @@ -486,6 +501,10 @@ void stereo_mdct_core_dec_fx( #endif /* OPT_SBA_DEC_PATH */ } +#ifdef OPT_SBA_DEC_V2_NBE + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, 20 ); +#else /* OPT_SBA_DEC_V2_NBE */ + ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, x_e ); FOR( Word16 ind = 0; ind < 2; ind++ ) @@ -511,7 +530,7 @@ void stereo_mdct_core_dec_fx( move16(); } } - +#endif /* OPT_SBA_DEC_V2_NBE */ test(); test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index f61fe276e..9582463eb 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -2587,9 +2587,13 @@ void TonalMDCTConceal_Apply( } void TonalMDCTConceal_Apply_ivas_fx( - TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ - Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ - Word16 mdctSpectrum_exp[L_FRAME_MAX], /*IN */ + TonalMDCTConcealPtr hTonalMDCTConc, /*IN */ + Word32 *mdctSpectrum, // Q31-*mdctSpectrum_exp /*IN/OUT*/ +#ifdef OPT_SBA_DEC_V2_NBE + Word16 mdctSpectrum_exp, /*IN */ +#else /* OPT_SBA_DEC_V2_NBE */ + Word16 mdctSpectrum_exp[L_FRAME_MAX], /*IN */ +#endif /* OPT_SBA_DEC_V2_NBE */ const PsychoacousticParameters *psychParamsCurrent ) { @@ -2755,8 +2759,12 @@ void TonalMDCTConceal_Apply_ivas_fx( /* getCosWord16 returns 1Q14*/ mdctSpectrum[l] = Mpy_32_16_1( powerSpectrum[l], getCosWord16( extract_l( currentPhase ) ) ); move32(); +#ifdef OPT_SBA_DEC_V2_NBE + mdctSpectrum[l] = L_shr( mdctSpectrum[l], sub( mdctSpectrum_exp, add( powerSpectrum_exp, 1 ) ) ); +#else /* OPT_SBA_DEC_V2_NBE */ mdctSpectrum_exp[l] = add( powerSpectrum_exp, 1 ); // getCosWord16 returns Q14 (exp is 1)d move16(); +#endif /* OPT_SBA_DEC_V2_NBE */ } } } -- GitLab From 27ed4d5cb64596422a8690816f45956ae3def7e6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 1 Jul 2025 11:58:19 +0530 Subject: [PATCH 279/394] Q update in mct core dec --- lib_dec/ivas_mct_core_dec_fx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index 87c139f9c..bc2471e24 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -300,14 +300,22 @@ void ivas_mct_core_dec( /* mono or dual mono IGF decoding */ x_e = sub( 31, q_x[ch] ); decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12 +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); FOR( i = 0; i < x_len; i++ ) { x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] ); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } } @@ -325,14 +333,22 @@ void ivas_mct_core_dec( /* mono or dual mono IGF decoding */ x_e = sub( 31, q_x[ch] ); decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 ); +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12 +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12 +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); FOR( i = 0; i < x_len; i++ ) { x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] ); move32(); } +#ifdef OPT_SBA_DEC_V2_NBE + q_x[ch] = Q11; +#else /* OPT_SBA_DEC_V2_NBE */ q_x[ch] = Q12; +#endif /* OPT_SBA_DEC_V2_NBE */ move16(); } } -- GitLab From a81a25447c601e70ae7152117d5fe5a924714c56 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 1 Jul 2025 16:34:29 +0530 Subject: [PATCH 280/394] Multichannel decoder path optimizations - bit exact --- lib_com/options.h | 1 + lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 30 ++++++++- lib_dec/ivas_svd_dec_fx.c | 19 ++++-- lib_rend/ivas_dirac_decorr_dec_fx.c | 69 +++++++++++++++++++- 4 files changed, 112 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 450b94c16..0fda6f452 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -77,6 +77,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCH_DEC_V1_BE #define OPT_MCT_ENC_V2_NBE #define OPT_SBA_DEC_V2_NBE #define OPT_MCT_ENC_V1_NBE diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index 4869f8d1c..ea03e1ddb 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -895,9 +895,13 @@ Word16 computeMixingMatrices_fx( } } - L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); limit_e = add( limit_e, reg_Sx_e ); +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_Sx_fx ); +#else /* OPT_MCH_DEC_V1_BE */ + L_tmp = Mpy_32_32( limit_fx, reg_Sx_fx ); limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( i = 0; i < lengthCx; ++i ) { @@ -956,8 +960,12 @@ Word16 computeMixingMatrices_fx( move16(); } } +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // limit_e+ reg_ghat_e limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ limit_e = add( limit_e, reg_ghat_e ); FOR( i = 0; i < lengthCy; ++i ) @@ -1436,8 +1444,12 @@ Word16 computeMixingMatricesResidual_fx( } } +#ifdef OPT_MCH_DEC_V1_BE + limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e) +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( limit_fx, reg_ghat_fx ); // Q(limit_e+reg_ghat_e) limit_fx = L_add( L_tmp, EPSILON_FX ); +#endif /* OPT_MCH_DEC_V1_BE */ limit_e = add( limit_e, reg_ghat_e ); /* Computing G_hat */ @@ -1468,8 +1480,12 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < num_outputs; i++ ) { +#ifdef OPT_MCH_DEC_V1_BE + Kx_fx[i] = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) Kx_fx[i] = L_tmp; +#endif /* OPT_MCH_DEC_V1_BE */ move32(); Kx_fx_e[i] = add( Kx_fx_e[i], G_hat_e[i] ); move16(); @@ -1483,11 +1499,18 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { +#ifdef OPT_MCH_DEC_V1_BE + mat_mult_buffer1_fx[i + j * num_outputs] = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e)); + move32(); + mat_mult_buffer1_buff_e[i + j * num_outputs] = add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ); + move16(); +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( Ky_fx[i + j * num_outputs], fac_fx ); // Q(31-(Ky_fx_e+Kx_fx_e)) mat_mult_buffer1_fx[i + j * num_outputs] = L_tmp; move32(); mat_mult_buffer1_buff_e[i + j * num_outputs] = extract_l( L_add( Ky_fx_e[i + j * num_outputs], Kx_fx_e[i] ) ); move16(); +#endif /* OPT_MCH_DEC_V1_BE */ } } @@ -1543,9 +1566,14 @@ Word16 computeMixingMatricesResidual_fx( FOR( j = 0; j < num_outputs; j++ ) { +#ifdef OPT_MCH_DEC_V1_BE + mixing_matrix_fx[j + i * num_outputs] = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e); + move32(); +#else /* OPT_MCH_DEC_V1_BE */ L_tmp = Mpy_32_32( mat_mult_buffer1_fx[j + i * num_outputs], fac_fx ); // Q(31-mat_mult_buffer1_e+Kx_reg_inv_e) mixing_matrix_fx[j + i * num_outputs] = L_tmp; move32(); +#endif /* OPT_MCH_DEC_V1_BE */ mixing_matrix_fx_e[j + i * num_outputs] = add( mat_mult_buffer1_buff_e[j + i * num_outputs], Kx_reg_inv_e[i] ); move16(); } diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 4b0522884..2afe48db6 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -779,6 +779,9 @@ static void ApplyRotation_fx( move16(); } op_e = add( op_e, 1 ); // 64 bit mac -> +1 +#ifdef OPT_MCH_DEC_V1_BE + op_e = negate( op_e ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch = 0; ch < nChannels; ch++ ) { @@ -788,13 +791,21 @@ static void ApplyRotation_fx( move32(); Word64 temp = W_mac_32_32( W_mult_32_32( op1, x11 ), op2, x12 ); // Q(singularVector) + op_e - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) +#ifdef OPT_MCH_DEC_V1_BE + singularVector[ch][currentIndex2] = W_shl_sat_l( temp, op_e ); // Q(singularVector) +#else /* OPT_MCH_DEC_V1_BE */ + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) +#endif /* OPT_MCH_DEC_V1_BE */ move32(); temp = W_mac_32_32( W_mult_32_32( op1, x12 ), L_negate( op2 ), x11 ); // Q(singularVector) + op_e - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) +#ifdef OPT_MCH_DEC_V1_BE + singularVector[ch][currentIndex1] = W_shl_sat_l( temp, op_e ); // Q(singularVector) +#else /* OPT_MCH_DEC_V1_BE */ + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) +#endif /* OPT_MCH_DEC_V1_BE */ move32(); } diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index aa4aed84c..b7c0ebbbc 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -485,11 +485,19 @@ void ivas_dirac_dec_decorr_process_fx( set32_fx( aux_buffer_fx, 0, 2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX ); FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { - v_shr( &input_frame_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], negate( q_shift ), &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#ifdef OPT_MCH_DEC_V1_BE + v_shr( &input_frame_fx[2 * ch_idx * num_freq_bands], negate( q_shift ), &aux_buffer_fx[2 * ch_idx * num_freq_bands], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#else /* OPT_MCH_DEC_V1_BE */ + v_shr( &input_frame_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], negate( q_shift ), &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], imult1616( 2, num_freq_bands ) ); // Q - q_shift +#endif /* OPT_MCH_DEC_V1_BE */ } FOR( ch_idx = 0; ch_idx < num_protos_dir; ch_idx++ ) { +#ifdef OPT_MCH_DEC_V1_BE + v_mult_fixed( &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * num_freq_bands], &aux_buffer_fx[2 * ch_idx * max_band_decorr_temp], imult1616( 2, max_band_decorr_temp ) ); // q_aux_buffer +#else /* OPT_MCH_DEC_V1_BE */ v_mult_fixed( &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, num_freq_bands ) )], &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) )], imult1616( 2, max_band_decorr_temp ) ); // q_aux_buffer +#endif /* OPT_MCH_DEC_V1_BE */ } q_aux_buffer = sub( add( add( add( q_input_frame, q_input_frame ), q_shift ), q_shift ), 31 ); @@ -506,6 +514,10 @@ void ivas_dirac_dec_decorr_process_fx( max_band_decorr = h_freq_domain_decorr_ap_params->max_band_decorr; move16(); +#ifdef OPT_MCH_DEC_V1_BE + Word16 decorX2 = shl( max_band_decorr, 1 ); +#endif /* OPT_MCH_DEC_V1_BE */ + set32_fx( onset_filter_fx, ONE_IN_Q31, imult1616( num_protos_diff, num_freq_bands ) ); Word16 q_temp = s_min( q_onset_dec, q_aux_buffer ); @@ -678,7 +690,11 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); } +#ifdef OPT_MCH_DEC_V1_BE + decorr_buffer_ptr_fx = decorr_buffer_start_ptr_fx + ( pre_delay - 1 ) * decorr_buffer_step * 2; +#else /* OPT_MCH_DEC_V1_BE */ decorr_buffer_ptr_fx = decorr_buffer_start_ptr_fx + shl( imult1616( ( sub( pre_delay, 1 ) ), decorr_buffer_step ), 1 ); +#endif /* OPT_MCH_DEC_V1_BE */ /*add MA part to state */ decorr_buffer_ptr_fx[0] = L_add( decorr_buffer_ptr_fx[0], frame_ma_fx[0] ); @@ -723,7 +739,10 @@ void ivas_dirac_dec_decorr_process_fx( Word16 q_direct_energy; Word64 aux_64[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; Word16 e_reverb_energy_smooth, e_direct_energy_smooth; - Word16 offset1, offset2; + Word16 offset1; +#ifndef OPT_MCH_DEC_V1_BE + Word16 offset2; +#endif /* OPT_MCH_DEC_V1_BE */ Word16 norm = 63; move16(); e_reverb_energy_smooth = sub( 31, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); @@ -732,6 +751,17 @@ void ivas_dirac_dec_decorr_process_fx( // scaling to get max precision for aux_buffer values// q_shift = Q31; move16(); +#ifdef OPT_MCH_DEC_V1_BE + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + q_shift = s_min( q_shift, + L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); + } + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); + } +#else /* OPT_MCH_DEC_V1_BE */ offset = shl( max_band_decorr, 1 ); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { @@ -742,6 +772,7 @@ void ivas_dirac_dec_decorr_process_fx( { scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], offset, q_shift ); } +#endif /* OPT_MCH_DEC_V1_BE */ q_frame_f = add( q_frame_f, q_shift ); @@ -773,12 +804,18 @@ void ivas_dirac_dec_decorr_process_fx( Word32 *m32_frame_dec_fx = frame_dec_fx; move32(); offset1 = shl( num_freq_bands, 1 ); +#ifndef OPT_MCH_DEC_V1_BE offset2 = shl( max_band_decorr, 1 ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + FOR( Word16 i = 0; i < decorX2; i++ ) +#else /* OPT_MCH_DEC_V1_BE */ FOR( Word16 i = 0; i < offset2; i++ ) +#endif /* OPT_MCH_DEC_V1_BE */ { m64_aux[i] = W_mult0_32_32( m32_frame_dec_fx[i], m32_frame_dec_fx[i] ); move64(); @@ -788,19 +825,35 @@ void ivas_dirac_dec_decorr_process_fx( move64(); } } +#ifdef OPT_MCH_DEC_V1_BE + m64_aux += decorX2; +#else /* OPT_MCH_DEC_V1_BE */ m64_aux += offset2; +#endif /* OPT_MCH_DEC_V1_BE */ m32_frame_dec_fx += offset1; move64(); move32(); } norm = W_norm( min64 ); +#ifdef OPT_MCH_DEC_V1_BE + norm = sub( norm, 33 ); +#else /* OPT_MCH_DEC_V1_BE */ norm = sub( norm, 1 /*find_guarded_bits_fx( 2 )*/ ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( Word16 i = 0; i < 2 * num_channels * max_band_decorr; i++ ) { +#ifdef OPT_MCH_DEC_V1_BE + aux_buffer_fx[i] = W_shl_sat_l( aux_64[i], norm ); +#else /* OPT_MCH_DEC_V1_BE */ aux_buffer_fx[i] = W_extract_h( W_shl( aux_64[i], norm ) ); +#endif /* OPT_MCH_DEC_V1_BE */ move32(); } +#ifdef OPT_MCH_DEC_V1_BE + q_aux_buffer = add( shl( q_frame_f, 1 ), norm ); +#else /* OPT_MCH_DEC_V1_BE */ q_aux_buffer = add( shl( q_frame_f, 1 ), sub( norm, 32 ) ); +#endif /* OPT_MCH_DEC_V1_BE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) @@ -954,7 +1007,11 @@ void ivas_dirac_dec_decorr_process_fx( Word16 sf = MAX_16; FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); +#else /* OPT_MCH_DEC_V1_BE */ sf = s_min( sf, getScaleFactor32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ) ); +#endif /* OPT_MCH_DEC_V1_BE */ } sf = s_min( sub( sf, 1 ), q_shift ); q_if_local = sub( q_shift, sf ); @@ -963,7 +1020,11 @@ void ivas_dirac_dec_decorr_process_fx( // scaling it to sf FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); +#else /* OPT_MCH_DEC_V1_BE */ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); +#endif /* OPT_MCH_DEC_V1_BE */ } q_frame_f = add( q_frame_f, sf ); } @@ -972,7 +1033,11 @@ void ivas_dirac_dec_decorr_process_fx( // scaling it to input q FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_BE + scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); +#else /* OPT_MCH_DEC_V1_BE */ scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ), q_shift ); +#endif /* OPT_MCH_DEC_V1_BE */ } q_frame_f = q_input_frame; q_if_local = 0; -- GitLab From e6c5024923d6ea98da8e54d663d3193ed1be3f89 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 2 Jul 2025 12:17:28 +0200 Subject: [PATCH 281/394] [fix] MASA number of output channels not set correctly for Custom LS output in external renderer --- lib_rend/lib_rend_fx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 278046d08..615092669 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8050,7 +8050,12 @@ static ivas_error initMasaExtRenderer( return error; } - IF( NE_32( ( error = getAudioConfigNumChannels( outConfig, &hMasaExtRend->nchan_output ) ), IVAS_ERR_OK ) ) + IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + hMasaExtRend->nchan_output = add( inputMasa->base.ctx.pCustomLsOut->num_spk, inputMasa->base.ctx.pCustomLsOut->num_lfe ); + move16(); + } + ELSE IF( NE_32( ( error = getAudioConfigNumChannels( outConfig, &hMasaExtRend->nchan_output ) ), IVAS_ERR_OK ) ) { return error; } -- GitLab From bb07b79167d1dc886de362574f3ed31d6aa0f407 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 2 Jul 2025 12:43:42 +0200 Subject: [PATCH 282/394] Fix compile error with FIX_1348_BIT_PRECISION_IMPROVEMENT related macros all disabled. --- lib_dec/ivas_post_proc_fx.c | 2 ++ lib_dec/ivas_stereo_switching_dec_fx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 01182a493..1b02b2b17 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -112,7 +112,9 @@ void ivas_post_proc_fx( { Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/ move16(); +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( sts[n]->hHQ_core->Q_old_out_fx32 == Q11 ); +#endif Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/ } diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 17109bee6..57f631204 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -422,7 +422,9 @@ ivas_error stereo_memory_dec_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 == hCPE->hCoreCoder[1]->hHQ_core->Q_old_out_fx32 ); +#endif v_add_32( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[1]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ v_multc_fixed_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, 16384 /* 0.5 in Q15 */, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) ); /* exp(exp_old_out) */ @@ -2154,7 +2156,9 @@ void stereo_td2dft_update_fx( move16(); /* update buffers used for fading when switching to DFT Stereo */ +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT assert( sts[0]->hHQ_core->Q_old_out_fx32 == sts[1]->hHQ_core->Q_old_out_fx32 ); +#endif v_add_fx( sts[0]->hHQ_core->old_out_LB_fx32 + nsLB, sts[1]->hHQ_core->old_out_LB_fx32 + nsLB, hCPE->old_outLB_mdct_fx, old_outLB_len ); L_lerp_fx_q11( hCPE->old_outLB_mdct_fx, hCPE->old_outLB_mdct_fx, STEREO_MDCT2DFT_FADE_LEN_48k, old_outLB_len ); -- GitLab From bc4496f3c245a05d57dabc75de2cb28c939920d7 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 2 Jul 2025 13:07:50 +0200 Subject: [PATCH 283/394] Fix warning if FIX_1348_BIT_PRECISION_IMPROVEMENT... is deactivated. Disable overfloat guard assert because it trips with FIX_1348_BIT_PRECISION_IMPROVEMENT... disabled. --- lib_dec/dec_tcx_fx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index bea3d2006..f1d0fbe5b 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5773,7 +5773,7 @@ void decoder_tcx_imdct_fx( Word32 x_tmp_fx[L_FRAME_PLUS]; Word32 xn_bufFB_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX] = { 0 }; Word16 xn_bufFB_fx_16[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; - Word16 acelp_zir_fx[L_FRAME_MAX / 2], q_acelp_zir_fx = 0; + Word16 acelp_zir_fx[L_FRAME_MAX / 2]; Word32 x_itf_fx[N_MAX_TCX - IGF_START_MN]; Word16 index, proc = 0; TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; @@ -5784,7 +5784,9 @@ void decoder_tcx_imdct_fx( Word16 q_a_itf = 15; Word16 x_e = sub( 31, q_x ); move16(); -#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN + Word16 q_acelp_zir_fx = 0; +#else Word16 shift_q = sub( q_x, q_win ); #endif @@ -5991,7 +5993,9 @@ void decoder_tcx_imdct_fx( FOR( Word16 ind = 0; ind < L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX; ind++ ) { +#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN assert( extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == 0 || extract_h( L_shr( xn_bufFB_fx[ind], shift_q ) ) == -1 ); +#endif xn_bufFB_fx_16[ind] = extract_l( L_shr( xn_bufFB_fx[ind], shift_q ) ); // q_x16 move16(); } -- GitLab From 4a61a21299eae25f53eb24e44499cfb26870845d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 2 Jul 2025 15:24:53 +0200 Subject: [PATCH 284/394] remove inactive code under //#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF --- lib_com/options.h | 1 - lib_dec/dec_tcx_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9d6e68621..bfa02eacf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,7 +101,6 @@ #define FIX_1348_BIT_PRECISION_IMPROVEMENT #define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN #define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD -//#define FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF #define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index f1d0fbe5b..6206577c1 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3498,11 +3498,7 @@ void IMDCT_ivas_fx( { #ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD -#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_ROUND_OLD_BUFF - old_out_fx[ind] = shr_r_sat( old_out_fx[ind], q_diff ); -#else old_out_fx[ind] = shr_sat( old_out_fx[ind], q_diff ); -#endif move16(); #endif xn_buf_fx[ind] = shr_sat( xn_buf_fx[ind], diff ); -- GitLab From 839c13bba9dfe5752d2c35de24c4a41f7b446eac Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Jul 2025 16:38:43 +0200 Subject: [PATCH 285/394] fix issue 1795: Q3 overflow --- lib_com/options.h | 2 ++ lib_com/swb_bwe_com_fx.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index d1b3cb63e..d82b4862e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,4 +111,6 @@ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ +#define FIX_ISSUE_1795_Q3_OVERFLOW /* FhG: Q3 overflow in function WB_BWE_gain_pred_fx (EVS legacy code) BE, MR1855 */ + #endif diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 11da78c46..d017d9ba6 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -242,8 +242,15 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_deposit_l( enerL_16 ); enerL = L_shl( enerL, 6 ); /*Q6 */ +#ifdef FIX_ISSUE_1795_Q3_OVERFLOW_not + /* Here, we first square WB_fenv into Q6 format, then it is taken 3x */ + L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ + L_tmp = L_add(L_tmp, L_add( L_tmp, L_tmp ) ); /* Q6 */ +#else + /* Here, we have not enough headroom for mult with 3, so we get some overflow */ tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ L_tmp = L_mult0( tmp1, WB_fenv[0] ); /*Q6 */ +#endif test(); test(); -- GitLab From 01863bfdf2187dc135cf84cc75ec5f930ff6e0b3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Jul 2025 16:48:30 +0200 Subject: [PATCH 286/394] fix clang-format --- lib_com/swb_bwe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index d017d9ba6..792ff0619 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -241,11 +241,11 @@ Word16 WB_BWE_gain_pred_fx( tmp = extract_l( L_tmp ); enerL = L_deposit_l( enerL_16 ); - enerL = L_shl( enerL, 6 ); /*Q6 */ + enerL = L_shl( enerL, 6 ); /*Q6 */ #ifdef FIX_ISSUE_1795_Q3_OVERFLOW_not /* Here, we first square WB_fenv into Q6 format, then it is taken 3x */ L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ - L_tmp = L_add(L_tmp, L_add( L_tmp, L_tmp ) ); /* Q6 */ + L_tmp = L_add( L_tmp, L_add( L_tmp, L_tmp ) ); /* Q6 */ #else /* Here, we have not enough headroom for mult with 3, so we get some overflow */ tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ -- GitLab From b9cdafd5f60802c9381b934d652ffb0582245c2a Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Jul 2025 17:58:17 +0200 Subject: [PATCH 287/394] correct macro setting, was inactive --- lib_com/swb_bwe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 792ff0619..d85c4fe04 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -242,7 +242,7 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_deposit_l( enerL_16 ); enerL = L_shl( enerL, 6 ); /*Q6 */ -#ifdef FIX_ISSUE_1795_Q3_OVERFLOW_not +#ifdef FIX_ISSUE_1795_Q3_OVERFLOW /* Here, we first square WB_fenv into Q6 format, then it is taken 3x */ L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ L_tmp = L_add( L_tmp, L_add( L_tmp, L_tmp ) ); /* Q6 */ -- GitLab From c4df00266944f7f5edb338d511d0bad1cb167350 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Jul 2025 19:02:48 +0200 Subject: [PATCH 288/394] correct macro setting, was inactive, use option B --- lib_com/swb_bwe_com_fx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index d85c4fe04..689dff46b 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -243,9 +243,8 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_deposit_l( enerL_16 ); enerL = L_shl( enerL, 6 ); /*Q6 */ #ifdef FIX_ISSUE_1795_Q3_OVERFLOW - /* Here, we first square WB_fenv into Q6 format, then it is taken 3x */ + /* Here, we do not multiply L_tmp by 3 to avoid overflow */ L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ - L_tmp = L_add( L_tmp, L_add( L_tmp, L_tmp ) ); /* Q6 */ #else /* Here, we have not enough headroom for mult with 3, so we get some overflow */ tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ @@ -255,7 +254,13 @@ Word16 WB_BWE_gain_pred_fx( test(); test(); test(); +#ifdef FIX_ISSUE_1795_Q3_OVERFLOW +#define ONE_DIV_3 ((Word32) 0x2AAAAAAA) + /* Here, L_tmp is not pre-multiplied with 3, we multiply enerL with 1/3 */ + IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( Mpy_32_32(ONE_DIV_3, enerL), L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) +#else IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( enerL, L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) +#endif { env_var_flag = 1; move16(); -- GitLab From a832e36753f30d284c77b19fee4d928df763c613 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 2 Jul 2025 19:08:21 +0200 Subject: [PATCH 289/394] fix clang-format --- lib_com/swb_bwe_com_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 689dff46b..8b134e5d6 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -244,7 +244,7 @@ Word16 WB_BWE_gain_pred_fx( enerL = L_shl( enerL, 6 ); /*Q6 */ #ifdef FIX_ISSUE_1795_Q3_OVERFLOW /* Here, we do not multiply L_tmp by 3 to avoid overflow */ - L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ + L_tmp = L_mult0( WB_fenv[0], WB_fenv[0] ); /* Q6 */ #else /* Here, we have not enough headroom for mult with 3, so we get some overflow */ tmp1 = i_mult_sat( 3, WB_fenv[0] ); /*Q3 */ @@ -255,9 +255,9 @@ Word16 WB_BWE_gain_pred_fx( test(); test(); #ifdef FIX_ISSUE_1795_Q3_OVERFLOW -#define ONE_DIV_3 ((Word32) 0x2AAAAAAA) +#define ONE_DIV_3 ( (Word32) 0x2AAAAAAA ) /* Here, L_tmp is not pre-multiplied with 3, we multiply enerL with 1/3 */ - IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( Mpy_32_32(ONE_DIV_3, enerL), L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) + IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( Mpy_32_32( ONE_DIV_3, enerL ), L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) #else IF( GT_16( shr( enerL_16, 3 ), tmp ) && GT_32( enerL, L_tmp ) && NE_16( prev_coder_type, UNVOICED ) && WB_fenv[0] != 0 ) #endif -- GitLab From 8680bd29b11be8502b56436a5399e7fe1b7304e7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 3 Jul 2025 10:45:56 +0530 Subject: [PATCH 290/394] Fix for 3GPP issue 1428: Basop Encoder Artifact for Stereo 13.2 kps DTX Background Noise Segment Link #1428 --- lib_com/rom_com.c | 27 +++++++++++++++++++++++++++ lib_com/rom_com.h | 6 ++++-- lib_enc/swb_tbe_enc_fx.c | 4 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 1f43b3d1f..b10f5cc52 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -15654,6 +15654,33 @@ const Word16 wac_swb_l[LPC_SHB_ORDER] = 30328 }; +const Word16 wac_swb_ivas_h[LPC_SHB_ORDER] = +{//Q15 + 32749, + 32731, + 32686, + 32622, + 32541, + 32442, + 32325, + 32191, + 32039, + 31870 +}; + +const Word16 wac_swb_ivas_l[LPC_SHB_ORDER] = +{//Q15 + 2624, + 20874, + 7850, + 25873, + 12831, + 5927, + 10541, + 239, + 15037, + 30328 +}; const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[4 * 4] = { diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index a0a388bc6..8a8ff7dd0 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -616,8 +616,10 @@ extern const Word16 window_wb_fx[]; // extern const Word16 subwin_wb_fx[]; // Q15 extern const Word16 Hilbert_coeffs_fx[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1]; // Q14 -extern const Word16 wac_swb_h[]; // Q15 -extern const Word16 wac_swb_l[]; // Q15 +extern const Word16 wac_swb_h[]; // Q15 +extern const Word16 wac_swb_l[]; // Q15 +extern const Word16 wac_swb_ivas_h[]; // Q15 +extern const Word16 wac_swb_ivas_l[]; // Q15 extern const Word16 wb_bwe_lsfvq_cbook_8bit_fx[]; // Q15 extern const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[]; // Q15 diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6b65f9afa..d016cd721 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3062,7 +3062,7 @@ void swb_tbe_enc_ivas_fx( { FOR( i = 1; i <= LPC_SHB_ORDER; i++ ) { - L_tmp = Mpy_32( R_h[i], R_l[i], wac_swb_h[i - 1], wac_swb_l[i - 1] ); + L_tmp = Mpy_32( R_h[i], R_l[i], wac_swb_ivas_h[i - 1], wac_swb_ivas_l[i - 1] ); L_Extract( L_tmp, &R_h[i], &R_l[i] ); } } @@ -3091,7 +3091,7 @@ void swb_tbe_enc_ivas_fx( } /* this is needed as the E_LPC_lev_dur function outputs lpc in Q14 */ - Copy_Scale_sig( lpc_shb_fx, lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); + scale_sig( lpc_shb_fx, LPC_SHB_ORDER + 1, sub( norm_s( lpc_shb_fx[0] ), 2 ) ); /* Expand bandwidth of the LP coeffs */ test(); -- GitLab From 74409b7d0125f8972a67ae9d95007e8fc5c5ff36 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 3 Jul 2025 10:44:52 +0200 Subject: [PATCH 291/394] fix --- lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index d1b3cb63e..4537e0788 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,5 +110,6 @@ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ +#define FIX_ISSUE_1792 /* FhG: fix noise bursts in binaural rendering */ #endif diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 008093a89..ba464af7f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -630,7 +630,11 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); FOR( ch = 0; ch < nchan_transport; ch++ ) { +#ifdef FIX_ISSUE_1792 + temp_min = L_norm_arr( p_output_fx[ch], output_frame ); +#else temp_min = getScaleFactor32( p_output_fx[ch], output_frame ); +#endif Q_p_output = s_min( Q_p_output, temp_min ); } Q_p_output = sub( Q_p_output, 2 ); -- GitLab From 3013c508e7785252d2ecee37cfcba918c8fa7277 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 3 Jul 2025 16:14:17 +0530 Subject: [PATCH 292/394] Fix for 3GPP issue 1797: Decoder crash for MC 7.1+4 at 128kbps decoding to mono/stereo in ivas_ls_setup_conversion_process_mdct_param_mc_fx() Link #1797 --- lib_dec/ivas_out_setup_conversion_fx.c | 38 ++++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 93a7c204e..2135cd6d6 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -1028,6 +1028,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( Word16 start, stop, start_tcx5, stop_tcx5; Word16 mct_chan_mode[MAX_CICP_CHANNELS]; + Word16 all_ch_ignored; // Flag for checking if all channels are ignored /* Declare all handles */ LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; @@ -1130,13 +1131,22 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); Word16 max_e = 0; move16(); + all_ch_ignored = 1; + move16(); FOR( idx = 0; idx < nchan_transport; idx++ ) { IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) ) { max_e = s_max( max_e, x_e[idx][0] ); + all_ch_ignored = 0; + move16(); } } + if ( all_ch_ignored ) + { + max_e = 31; + move16(); + } FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ ) { set_zero_fx( real_in_buffer_fx, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS ); @@ -1164,22 +1174,32 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } } } - Word16 shift = 1; + input_exp = max_e; move16(); - FOR( i = 0; i < num_bands * nchan_transport; ++i ) + IF( all_ch_ignored == 0 ) { - real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); - move32(); - imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); - move32(); + Word16 shift = 1; + move16(); + FOR( i = 0; i < num_bands * nchan_transport; ++i ) + { + real_in_buffer_fx[i] = L_shr( real_in_buffer_fx[i], shift ); + move32(); + imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift ); + move32(); + } + input_exp = add( input_exp, shift ); } - input_exp = max_e; - move16(); - input_exp = add( input_exp, shift ); + cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp ); v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/ } + if ( all_ch_ignored ) + { + output_exp = 29; + move16(); + } + Word16 exp_in = 10, exp_out = 0; move16(); move16(); -- GitLab From d6b15db889198fc03b699073dba12c028f2774d8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 13 May 2025 14:20:18 +0530 Subject: [PATCH 293/394] Fix for 3GPP issue 1388: Stereo Encoder 16.4 kbps: Various Discontinuities in LTV Link #1388 --- lib_enc/inov_enc_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 216ca3860..9c78ccf7f 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -370,7 +370,7 @@ Word16 inov_encode_ivas_fx( Word16 shift, Word16 Q_new ) { - Word16 dn[2 * L_SUBFR], Qdn, Qcn; + Word16 dn[2 * L_SUBFR], Qdn, Qcn, Qh2; Word16 nBits, cmpl_flag; Word16 stack_pulses; Word16 g1, g2; @@ -586,6 +586,9 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); + Qh2 = sub( 14, norm_s( h2[0] ) ); + scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); + IF( !Opt_AMR_WB ) { IF( st_fx->acelp_cfg.fcb_mode ) -- GitLab From 94b0164cc6a4897ad28cf34e473350051320ab8e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 3 Jul 2025 16:33:59 +0530 Subject: [PATCH 294/394] Fix for 3GPP issue 1786: Metadata output result of MASA prerend with muted MASA signal and ISM3 is quite differing Link #1786 --- lib_com/ivas_masa_com_fx.c | 11 +++++++---- lib_rend/ivas_masa_merge_fx.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index a691fb390..f4c8fab10 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -978,7 +978,7 @@ static Word16 quantize_phi_masa_fx( Word32 tmp32; Word16 tmp_e, delta_phi_e; - delta_phi_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( 360, n, &delta_phi_e ) ); + delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( 360, n, &delta_phi_e ); delta_phi_fx = L_shr( delta_phi_fx, sub( sub( 31, delta_phi_e ), 22 ) ); // Q22 IF( EQ_16( n, 1 ) ) @@ -1000,8 +1000,8 @@ static Word16 quantize_phi_masa_fx( } tmp32 = L_add( L_sub( phi_fx, dd_fx ), L_shr( delta_phi_fx, 1 ) ); - id_phi = BASOP_Util_Divide3232_Scale( tmp32, delta_phi_fx, &tmp_e ); - id_phi = shr( id_phi, sub( 15, tmp_e ) ); // Q0 + tmp32 = BASOP_Util_Divide3232_Scale_newton( tmp32, delta_phi_fx, &tmp_e ); + id_phi = extract_l( L_shr( tmp32, sub( 31, tmp_e ) ) ); // Q0 if ( EQ_16( id_phi, n ) ) { @@ -1014,7 +1014,10 @@ static Word16 quantize_phi_masa_fx( id_phi = sub( n, 1 ); } - *phi_hat_fx = L_add( L_shl( Mpy_32_16_1( delta_phi_fx, id_phi ), 15 ), dd_fx ); // q22 + q0 - 15 = q7 -> q7 + 15 = q22 + delta_phi_fx = BASOP_Util_Divide3232_Scale_newton( L_mult0( 360, id_phi ), n, &delta_phi_e ); + delta_phi_fx = L_shr( delta_phi_fx, sub( sub( 31, delta_phi_e ), 22 ) ); // Q22 + + *phi_hat_fx = L_add( delta_phi_fx, dd_fx ); // Q22 move32(); return id_phi; // Q0 diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 892927d37..673d5330a 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -194,9 +194,9 @@ void diffuse_meta_merge_1x1_fx( scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); IF( L_tmp1 == 0 ) { - scale = 31; + scale = 0; move16(); - L_tmp2 = 1; + L_tmp2 = MAX_32; move32(); } ELSE -- GitLab From 25242c0172cceb3197596be7d841aaeda72ac950 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 16:31:20 +0530 Subject: [PATCH 295/394] Fix to correct the rounding of directToTotalRatio This change improves the precision as well as corrects the rounding of directToTotalRatio. Optimization: This MR removes 7 instances of BASOP_Util_Divide1616_Scale used in 2 functions: diffuse_meta_merge_1x1_fx and full_stream_merge_fx --- lib_rend/ivas_masa_merge_fx.c | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 673d5330a..54d2548c6 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -39,6 +39,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" +#define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ /*---------------------------------------------------------------------* * Local function prototypes @@ -172,23 +173,29 @@ void diffuse_meta_merge_1x1_fx( FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { Word32 energyTimesRatio_fx, energyTimesRatioISM_fx, total_diff_nrg_fx, dir_nrg_ratio_fx, total_nrg_fx = 0; - Word32 dir_ratio_ism_fx, L_tmp1, L_tmp2; + Word32 dir_ratio_ism_fx, L_tmp, L_tmp1, L_tmp2; Word16 scale, energyTimesRatio_e, tmp, total_nrg_e = 0, total_diff_nrg_e, dir_ratio_ism_e, energyTimesRatioISM_e, dir_nrg_ratio_e; move32(); move16(); - tmp = BASOP_Util_Divide1616_Scale( inMeta->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - energyTimesRatio_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + energyTimesRatio_fx = Mpy_32_32_r( inEne_fx[sf][band], L_tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ energyTimesRatio_e = add( inEne_e[sf][band], scale ); total_nrg_fx = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &total_nrg_e ); /* target is original MASA diffuseness */ - tmp = BASOP_Util_Divide1616_Scale( inMeta->diffuseToTotalRatio[sf][band], UINT8_MAX, &scale ); - total_diff_nrg_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta->diffuseToTotalRatio[sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + total_diff_nrg_fx = Mpy_32_32_r( inEne_fx[sf][band], L_tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ total_diff_nrg_e = add( inEne_e[sf][band], scale ); /* criterion is mean of ISM ratio and new ratio */ - dir_ratio_ism_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( inMetaISM->directToTotalRatio[0][sf][band], UINT8_MAX, &dir_ratio_ism_e ) ); + dir_ratio_ism_fx = Mpy_32_16_1( INV_UINT8_MAX, inMetaISM->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + dir_ratio_ism_e = 15; + move16(); tmp = BASOP_Util_Divide3232_Scale( total_diff_nrg_fx, L_add( total_nrg_fx, EPSILON_FX ), &scale ); L_tmp1 = L_deposit_h( tmp ); /* Q( 31 - ( scale + total_nrg_e - total_diff_nrg_e ) ) */ scale = add( scale, sub( total_diff_nrg_e, total_nrg_e ) ); @@ -245,7 +252,7 @@ void diffuse_meta_merge_1x1_fx( move16(); } - outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( new_dir_ratio_fx, sub( sub( 31, new_dir_ratio_e ), 8 ) ) ); + outMeta->directToTotalRatio[0][sf][band] = (UWord8) extract_l( L_shr( Mpy_32_16_1( new_dir_ratio_fx, UINT8_MAX ) /* (31 - new_dir_ratio_e) - 15*/, sub( 31 - 15, new_dir_ratio_e ) ) ); move16(); IF( GT_16( sub( 31, new_dir_ratio_e ), Q30 ) ) { @@ -325,7 +332,7 @@ void full_stream_merge_fx( { UWord8 n_dirs_1, n_dirs_2; UWord8 sf, band; - Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e; + Word16 scale, dir_nrg_1_e, dir_nrg_2_e; Word32 dir_nrg_1_fx, dir_nrg_2_fx, L_tmp; /* full stream select based on total direct energy */ @@ -336,26 +343,34 @@ void full_stream_merge_fx( { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - dir_nrg_1_fx = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta1->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + dir_nrg_1_fx = Mpy_32_32( L_tmp, inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ dir_nrg_1_e = add( scale, inEne1_e[sf][band] ); - tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); - dir_nrg_2_fx = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta2->directToTotalRatio[0][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + dir_nrg_2_fx = Mpy_32_32( L_tmp, inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ dir_nrg_2_e = add( scale, inEne2_e[sf][band] ); IF( EQ_16( n_dirs_1, 2 ) ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); - L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta1->directToTotalRatio[1][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + L_tmp = Mpy_32_32( L_tmp, inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ scale = add( scale, inEne1_e[sf][band] ); dir_nrg_1_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_1_fx, dir_nrg_1_e, &dir_nrg_1_e ); } IF( EQ_16( n_dirs_2, 2 ) ) { - tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); - L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ + L_tmp = Mpy_32_16_1( INV_UINT8_MAX, inMeta2->directToTotalRatio[1][sf][band] ); // Q31 - 15 => Q16 + scale = 15; + move16(); + L_tmp = Mpy_32_32( L_tmp, inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ scale = add( scale, inEne2_e[sf][band] ); dir_nrg_2_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_2_fx, dir_nrg_2_e, &dir_nrg_2_e ); } -- GitLab From f46551bf3816339f743fe6b1a4f1fc8669b00ffb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 16:36:57 +0530 Subject: [PATCH 296/394] Fix in stereo_dft_enc_compute_itd(): Q computed value correction --- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 28bac9e8b..44434f78f 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -1467,7 +1467,7 @@ void stereo_dft_enc_compute_itd_fx( // sfm_L = expf( log_prod_L / ( NFFT_mid ) ) / ( sum_abs_L / ( NFFT_mid ) ); L_temp = BASOP_Util_Divide3232_Scale_newton( log_prod_L, NFFT_mid, &L_temp_e ); L_temp_e = add( L_temp_e, sub( log_prod_L_e, 31 ) ); - L_temp = BASOP_Util_fPow( 1459366444 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); + L_temp = BASOP_Util_fPow( 1459215139 /*2.718 in Q29*/, 2, L_temp, L_temp_e, &L_temp_e ); q_temp = norm_l( NFFT_mid ); L_temp2 = L_shl( NFFT_mid, q_temp ); L_temp2_e = sub( 31, q_temp ); -- GitLab From 53143c0b4e42bedcd7e3f7f77ab4dadc5fc32455 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 16:51:28 +0530 Subject: [PATCH 297/394] Multichannel path decoder optimizations: Removal of BASOP_Util_Add_Mant32Exp and BASOP_Util_Cmp_Mant32Exp --- lib_com/options.h | 1 + lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 45 ++++++- lib_dec/ivas_svd_dec_fx.c | 130 +++++++++++++++++-- lib_rend/ivas_dirac_decorr_dec_fx.c | 99 +++++++++++++- 4 files changed, 263 insertions(+), 12 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5c1552fc3..de20f6959 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCH_DEC_V1_NBE #define OPT_MCH_DEC_V1_BE #define OPT_MCT_ENC_V2_NBE #define OPT_SBA_DEC_V2_NBE diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index ea03e1ddb..238ca3704 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -886,7 +886,11 @@ Word16 computeMixingMatrices_fx( move16(); FOR( i = 1; i < lengthCx; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( svd_s_buffer_fx[i], L_shl_sat( limit_fx, sub( limit_e, svd_s_buffer_e[i] ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = svd_s_buffer_fx[i]; move32(); @@ -896,6 +900,7 @@ Word16 computeMixingMatrices_fx( } limit_e = add( limit_e, reg_Sx_e ); + #ifdef OPT_MCH_DEC_V1_BE limit_fx = Madd_32_32( EPSILON_FX, limit_fx, reg_Sx_fx ); #else /* OPT_MCH_DEC_V1_BE */ @@ -905,7 +910,11 @@ Word16 computeMixingMatrices_fx( FOR( i = 0; i < lengthCx; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( LT_32( L_shl_sat( svd_s_buffer_fx[i], sub( svd_s_buffer_e[i], limit_e ) ), limit_fx ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( svd_s_buffer_fx[i], svd_s_buffer_e[i], limit_fx, limit_e ) < 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { svd_s_buffer_fx[i] = limit_fx; move32(); @@ -950,9 +959,16 @@ Word16 computeMixingMatrices_fx( matrix_product_diag_fx( Q_Cx_fx, Q_Cx_e, lengthCy, lengthCx, 0, Q_fx, Q_e, lengthCy, lengthCx, 1, Cy_hat_diag_fx, &Cy_hat_diag_e ); +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = sub( limit_e, Cy_hat_diag_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = Cy_hat_diag_fx[i]; move32(); @@ -968,11 +984,19 @@ Word16 computeMixingMatrices_fx( #endif /* OPT_MCH_DEC_V1_BE */ limit_e = add( limit_e, reg_ghat_e ); +#ifdef OPT_MCH_DEC_V1_NBE + com_e = sub( Cy_hat_diag_e, limit_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { Cy_hat_diag_buff_e[i] = Cy_hat_diag_e; move16(); + +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_buff_e[i] ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#endif /* OPT_MCH_DEC_V1_NBE */ { Cy_hat_diag_fx[i] = limit_fx; move32(); @@ -1392,7 +1416,11 @@ Word16 computeMixingMatricesResidual_fx( FOR( i = 0; i < lengthCx; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Kx_fx[i], L_shl_sat( limit_fx, sub( limit_e, Kx_fx_e[i] ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Kx_fx[i], Kx_fx_e[i], limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { div_tmp = Kx_fx[i]; move32(); @@ -1433,9 +1461,16 @@ Word16 computeMixingMatricesResidual_fx( Cy_hat_diag_e = Cx_e; move16(); +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = sub( limit_e, Cy_hat_diag_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( Cy_hat_diag_fx[i], L_shl_sat( limit_fx, com_e ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( Cy_hat_diag_fx[i], Cy_hat_diag_e, limit_fx, limit_e ) > 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { limit_fx = Cy_hat_diag_fx[i]; move32(); @@ -1453,11 +1488,19 @@ Word16 computeMixingMatricesResidual_fx( limit_e = add( limit_e, reg_ghat_e ); /* Computing G_hat */ + +#ifdef OPT_MCH_DEC_V1_NBE + com_e = sub( Cy_hat_diag_e, limit_e ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( i = 0; i < lengthCy; ++i ) { Cy_hat_diag_fx_e[i] = Cy_hat_diag_e; move16(); +#ifdef OPT_MCH_DEC_V1_NBE + IF( GT_32( limit_fx, L_shl_sat( Cy_hat_diag_fx[i], com_e ) ) ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( limit_fx, limit_e, Cy_hat_diag_fx[i], Cy_hat_diag_e ) > 0 ) /* Computing Cy_hat_diag = max(Cy_hat_diag,limit) */ +#endif /* OPT_MCH_DEC_V1_NBE */ { Cy_hat_diag_fx[i] = limit_fx; move32(); @@ -1483,7 +1526,7 @@ Word16 computeMixingMatricesResidual_fx( #ifdef OPT_MCH_DEC_V1_BE Kx_fx[i] = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) #else /* OPT_MCH_DEC_V1_BE */ - L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) + L_tmp = Mpy_32_32( Kx_fx[i], G_hat_fx[i] ); // Q(31-(Kx_fx_e+G_hag_e)) Kx_fx[i] = L_tmp; #endif /* OPT_MCH_DEC_V1_BE */ move32(); diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index 2afe48db6..ba65c4b7b 100644 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -322,7 +322,11 @@ Word16 svd_fx( move16(); FOR( iCh = 0; iCh < lengthSingularValues - 1; iCh++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( LT_32( L_shl_sat( singularValues_fx[iCh], sub( singularValues_fx_e[iCh], singularValues_fx_e[iCh + 1] ) ), singularValues_fx[iCh + 1] ) ) +#else /* OPT_MCH_DEC_V1_NBE */ IF( BASOP_Util_Cmp_Mant32Exp( singularValues_fx[iCh], singularValues_fx_e[iCh], singularValues_fx[iCh + 1], singularValues_fx_e[iCh + 1] ) < 0 ) +#endif /* OPT_MCH_DEC_V1_NBE */ { condition = 1; move16(); @@ -427,14 +431,24 @@ static Word16 BidagonalDiagonalisation_fx( FOR( jCh = iCh; jCh >= 0; jCh-- ) { - split = sub( jCh, 1 ); /* Q0 */ - IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( secDiag_fx[jCh] ), secDiag_new_e[jCh], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = s_max( secDiag_new_e[jCh], eps_x_e ); + IF( LE_32( L_shr( L_abs( secDiag_fx[jCh] ), sub( com_e, secDiag_new_e[jCh] ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#else + split = sub( jCh, 1 ); /* Q0 */ /* OPT_MCH_DEC_V1_NBE */ + IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( secDiag_fx[jCh] ), secDiag_new_e[jCh], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is secDiag[ch] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { found_split = 0; move16(); BREAK; } +#ifdef OPT_MCH_DEC_V1_NBE + com_e = s_max( singularValues_new_e[jCh - 1], eps_x_e ); + IF( LE_32( L_shr( L_abs( singularValues_fx[jCh - 1] ), sub( com_e, singularValues_new_e[jCh - 1] ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) /* is singularValues[jCh - 1] vanishing compared to eps_x */ +#else /* OPT_MCH_DEC_V1_NBE */ IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( singularValues_fx[split] ), singularValues_new_e[split], Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { BREAK; } @@ -462,14 +476,21 @@ static Word16 BidagonalDiagonalisation_fx( move32(); c_e = 0; move16(); - +#ifdef OPT_MCH_DEC_V1_NBE + split = sub( jCh, 1 ); /* Q0 */ +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( kCh = jCh; kCh <= iCh; kCh++ ) { g = Mpy_32_32( s, secDiag_fx[kCh] ); /* exp(s_e + secDiag_new_e) */ g_e = add( s_e, secDiag_new_e[kCh] ); secDiag_fx[kCh] = Mpy_32_32( c, secDiag_fx[kCh] ); /* exp(c_e + secDiag_new_e) */ secDiag_new_e[kCh] = add( c_e, secDiag_new_e[kCh] ); - IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( g ), g_e, Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#ifdef OPT_MCH_DEC_V1_NBE + Word16 com_e = s_max( g_e, eps_x_e ); + IF( LE_32( L_shr( L_abs( g ), sub( com_e, g_e ) ), L_shr( Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), sub( com_e, eps_x_e ) ) ) ) +#else /* OPT_MCH_DEC_V1_NBE */ + IF( LE_16( BASOP_Util_Cmp_Mant32Exp( L_abs( g ), g_e, Mpy_32_32( CONVERGENCE_FACTOR_FX, eps_x ), eps_x_e ), 0 ) ) /* is singularValues[split] vanishing compared to eps_x */ +#endif /* OPT_MCH_DEC_V1_NBE */ { BREAK; } @@ -794,8 +815,8 @@ static void ApplyRotation_fx( #ifdef OPT_MCH_DEC_V1_BE singularVector[ch][currentIndex2] = W_shl_sat_l( temp, op_e ); // Q(singularVector) #else /* OPT_MCH_DEC_V1_BE */ - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex2] = W_sat_l( temp ); // Q(singularVector) #endif /* OPT_MCH_DEC_V1_BE */ move32(); @@ -803,8 +824,8 @@ static void ApplyRotation_fx( #ifdef OPT_MCH_DEC_V1_BE singularVector[ch][currentIndex1] = W_shl_sat_l( temp, op_e ); // Q(singularVector) #else /* OPT_MCH_DEC_V1_BE */ - temp = W_shr( temp, op_e ); // Q(singularVector) - singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) + temp = W_shr( temp, op_e ); // Q(singularVector) + singularVector[ch][currentIndex1] = W_sat_l( temp ); // Q(singularVector) #endif /* OPT_MCH_DEC_V1_BE */ move32(); } @@ -929,9 +950,15 @@ static void biDiagonalReductionLeft_fx( Word16 invVal_e; Word32 invVal; invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, maxWithSign_fx( *sig_x ), &invVal_e ); +#ifdef OPT_MCH_DEC_V1_NBE + Word64 temp = 0; + move64(); + Word16 max_e = MIN_16; +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = 0; move32(); norm_x_e = 0; +#endif /* OPT_MCH_DEC_V1_NBE */ move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { @@ -940,8 +967,25 @@ static void biDiagonalReductionLeft_fx( move32(); singularVectors2_e[jCh][currChannel] = sub( add( invVal_e, sub( singularVectors2_e[jCh][currChannel], *sig_x_e ) ), temp_e ); move16(); +#ifdef OPT_MCH_DEC_V1_NBE + max_e = s_max( max_e, singularVectors2_e[jCh][currChannel] ); +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( singularVectors2_e[jCh][currChannel], 1 ), &norm_x_e ); /* exp(norm_x_e) */ +#endif /* OPT_MCH_DEC_V1_NBE */ } + +#ifdef OPT_MCH_DEC_V1_NBE + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + temp = W_add( temp, L_shr( Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sub( max_e, singularVectors2_e[jCh][currChannel] ), 1 ) ) ); + } + + Word16 nrm = W_norm( temp ); + nrm = sub( nrm, 32 ); + norm_x = W_shl_sat_l( temp, nrm ); + norm_x_e = sub( add( max_e, max_e ), nrm ); +#endif /* OPT_MCH_DEC_V1_NBE */ + IF( GT_16( norm_x_e, 0 ) ) { norm_x = MAX_32; @@ -969,6 +1013,30 @@ static void biDiagonalReductionLeft_fx( FOR( iCh = currChannel + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word16 max2_e = MIN_16; + max_e = MIN_16; + move16(); + move16(); + temp = 0; + move64(); + + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + max_e = s_max( max_e, singularVectors2_e[jCh][currChannel] ); /* exp(norm_x_e) */ + max2_e = s_max( max2_e, singularVectors2_e[jCh][iCh] ); /* exp(norm_x_e) */ + } + max_e = add( max_e, max2_e ); + + FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ + { + temp = W_add( temp, L_shr( Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), sub( max_e, add( singularVectors2_e[jCh][currChannel], singularVectors2_e[jCh][iCh] ) ) ) ); + } + nrm = W_norm( temp ); + nrm = sub( nrm, 32 ); + norm_x = W_shl_sat_l( temp, nrm ); + norm_x_e = sub( max_e, nrm ); +#else /* OPT_MCH_DEC_V1_NBE */ norm_x = 0; move32(); norm_x_e = 0; @@ -977,6 +1045,7 @@ static void biDiagonalReductionLeft_fx( { norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( singularVectors2_e[jCh][currChannel], singularVectors2_e[jCh][iCh] ), &norm_x_e ); /* exp(norm_x_e) */ } +#endif /* OPT_MCH_DEC_V1_NBE */ f = Mpy_32_32( norm_x, invVal ); /* invVal_e + (norm_x_e - r_e) */ f_e = add( invVal_e, sub( norm_x_e, r_e ) ); @@ -1228,8 +1297,16 @@ static void singularVectorsAccumulationLeft_fx( move32(); } } +#ifdef OPT_MCH_DEC_V1_NBE + Word16 exp = s_max( singularVectors_Left_e[nCh][nCh], 1 ); + singularVectors_Left[nCh][nCh] = L_sub( L_shr( singularVectors_Left[nCh][nCh], sub( exp, singularVectors_Left_e[nCh][nCh] ) ), L_shr( MINUS_ONE_IN_Q31, exp ) ); /* exp(sing_exp2) */ + move32(); + singularVectors_Left_e[nCh][nCh] = exp; + move16(); +#else /* OPT_MCH_DEC_V1_NBE */ singularVectors_Left[nCh][nCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Left[nCh][nCh], singularVectors_Left_e[nCh][nCh], ONE_IN_Q30, 1, &singularVectors_Left_e[nCh][nCh] ); /* exp(sing_exp2) */ move32(); +#endif /* OPT_MCH_DEC_V1_NBE */ } // fclose(fp); FOR( nCh = 0; nCh < nChannelsL; nCh++ ) @@ -1292,21 +1369,56 @@ static void singularVectorsAccumulationRight_fx( FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word64 norm_val = 0; + move64(); + Word16 maxL_e = MIN_16; + Word16 maxR_e = MIN_16; + Word16 maxR2_e = MIN_16; + move16(); + move16(); + move16(); + FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ + { + maxL_e = s_max( maxL_e, singularVectors_Left_e[nCh][k] ); + maxR_e = s_max( maxR_e, sing_right_exp[k][iCh] ); + maxR2_e = s_max( maxR2_e, sing_right_exp[k][nCh] ); + } +#else /* OPT_MCH_DEC_V1_NBE */ norm_y = 0; move32(); norm_y_e = 0; move16(); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ { - norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_Left_e[nCh][k], sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ +#ifdef OPT_MCH_DEC_V1_NBE + norm_val = W_mac_32_32( norm_val, L_shr( singularVectors_Left[nCh][k], sub( maxL_e, singularVectors_Left_e[nCh][k] ) ), L_shr( singularVectors_Right[k][iCh], sub( maxR_e, sing_right_exp[k][iCh] ) ) ); +#else /* OPT_MCH_DEC_V1_NBE */ + norm_y = BASOP_Util_Add_Mant32Exp( norm_y, norm_y_e, Mpy_32_32( singularVectors_Left[nCh][k], singularVectors_Right[k][iCh] ), add( singularVectors_Left_e[nCh][k], sing_right_exp[k][iCh] ), &norm_y_e ); /* exp(norm_y_e) */ +#endif /* OPT_MCH_DEC_V1_NBE */ } +#ifdef OPT_MCH_DEC_V1_NBE + norm_y_e = W_norm( norm_val ); + norm_y = W_extract_h( W_shl( norm_val, norm_y_e ) ); + norm_y_e = sub( add( maxL_e, maxR_e ), norm_y_e ); + Word16 max_new = s_max( maxR_e, add( maxR2_e, norm_y_e ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( k = nCh + 1; k < nChannelsC; k++ ) /* nChannelsC */ { +#ifdef OPT_MCH_DEC_V1_NBE + Word32 temp = Mpy_32_32( norm_y, singularVectors_Right[k][nCh] ); + Word32 op2 = L_shr( temp, sub( max_new, add( norm_y_e, sing_right_exp[k][nCh] ) ) ); + singularVectors_Right[k][iCh] = L_add_sat( L_shr( singularVectors_Right[k][iCh], sub( max_new, sing_right_exp[k][iCh] ) ), op2 ); /* exp(sing_right_exp) */ + move32(); + singularVectors_Right[k][iCh] = L_shl_sat( singularVectors_Right[k][iCh], max_new ); /* Q31 */ +#else /* OPT_MCH_DEC_V1_NBE */ singularVectors_Right[k][iCh] = BASOP_Util_Add_Mant32Exp( singularVectors_Right[k][iCh], sing_right_exp[k][iCh], Mpy_32_32( norm_y, singularVectors_Right[k][nCh] ), add( norm_y_e, sing_right_exp[k][nCh] ), &sing_right_exp[k][iCh] ); /* exp(sing_right_exp) */ move32(); singularVectors_Right[k][iCh] = L_shl_sat( singularVectors_Right[k][iCh], sing_right_exp[k][iCh] ); /* Q31 */ +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); sing_right_exp[k][iCh] = 0; move16(); diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index b7c0ebbbc..28c3cd5e7 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -514,9 +514,9 @@ void ivas_dirac_dec_decorr_process_fx( max_band_decorr = h_freq_domain_decorr_ap_params->max_band_decorr; move16(); -#ifdef OPT_MCH_DEC_V1_BE +#if ( defined OPT_MCH_DEC_V1_NBE || defined OPT_MCH_DEC_V1_BE ) Word16 decorX2 = shl( max_band_decorr, 1 ); -#endif /* OPT_MCH_DEC_V1_BE */ +#endif set32_fx( onset_filter_fx, ONE_IN_Q31, imult1616( num_protos_diff, num_freq_bands ) ); @@ -740,6 +740,7 @@ void ivas_dirac_dec_decorr_process_fx( Word64 aux_64[2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX]; Word16 e_reverb_energy_smooth, e_direct_energy_smooth; Word16 offset1; + #ifndef OPT_MCH_DEC_V1_BE Word16 offset2; #endif /* OPT_MCH_DEC_V1_BE */ @@ -868,15 +869,25 @@ void ivas_dirac_dec_decorr_process_fx( Word16 max_e = s_max( aux_e, e_reverb_energy_smooth ); Word16 shr_aux = sub( max_e, aux_e ); /* Note: headroom is zero */ Word16 shr_res = sub( max_e, e_reverb_energy_smooth ); /* Note: headroom is zero */ +#ifdef OPT_MCH_DEC_V1_NBE + Word32 temp1 = L_shr( ONE_M_DIRAC_DUCK_ALPHA, shr_aux ); + Word32 temp2 = L_shr( DIRAC_DUCK_ALPHA_FX, shr_res ); +#endif /* OPT_MCH_DEC_V1_NBE */ /* Note: DIRAC_DUCK_ALPHA_FX and ONE_M_DIRAC_DUCK_ALPHA are both in Q31 (e=0) */ /* => a multiplication with this values does not change the q/e value. */ FOR( Word16 i = 0; i < len; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i] = Madd_32_32( + Mpy_32_32( aux_buffer_fx[i], temp1 ), + h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i], temp2 ); +#else /* OPT_MCH_DEC_V1_NBE */ h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i] = L_add( L_shr( Mpy_32_32( aux_buffer_fx[i], ONE_M_DIRAC_DUCK_ALPHA ), shr_aux ), L_shr( Mpy_32_32( h_freq_domain_decorr_ap_state->reverb_energy_smooth_fx[i], DIRAC_DUCK_ALPHA_FX ), shr_res ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); } e_reverb_energy_smooth = max_e; @@ -889,12 +900,22 @@ void ivas_dirac_dec_decorr_process_fx( Word16 max_x = s_max( den_e, e_direct_energy_smooth ); Word16 shr_den = sub( max_x, den_e ); /* Note: headroom is zero */ Word16 shr_des = sub( max_x, e_direct_energy_smooth ); /* Note: headroom is zero */ +#ifdef OPT_MCH_DEC_V1_NBE + temp1 = L_shr( ONE_M_DIRAC_DUCK_ALPHA, shr_den ); + temp2 = L_shr( DIRAC_DUCK_ALPHA_FX, shr_des ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( Word16 i = 0; i < len; i++ ) { +#ifdef OPT_MCH_DEC_V1_NBE + h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i] = Madd_32_32( + Mpy_32_32( direct_energy_fx[i], temp1 ), + h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i], temp2 ); +#else /* OPT_MCH_DEC_V1_NBE */ h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i] = L_add( L_shr( Mpy_32_32( direct_energy_fx[i], ONE_M_DIRAC_DUCK_ALPHA ), shr_den ), L_shr( Mpy_32_32( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx[i], DIRAC_DUCK_ALPHA_FX ), shr_des ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ move32(); } e_direct_energy_smooth = max_x; @@ -903,6 +924,7 @@ void ivas_dirac_dec_decorr_process_fx( move16(); // scaling energy buffers for better precision for higher values// +#ifndef OPT_MCH_DEC_V1_NBE q_shift = L_norm_arr( h_freq_domain_decorr_ap_state->direct_energy_smooth_fx, imult1616( num_protos_dir, max_band_decorr ) ); IF( q_shift != 0 ) { @@ -917,6 +939,7 @@ void ivas_dirac_dec_decorr_process_fx( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = add( h_freq_domain_decorr_ap_state->q_reverb_energy_smooth, q_shift ); move16(); } +#endif h_freq_domain_decorr_ap_state->q_reverb_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_reverb_energy_smooth ); h_freq_domain_decorr_ap_state->q_direct_energy_smooth = s_min( MAX_Q_FX, h_freq_domain_decorr_ap_state->q_direct_energy_smooth ); @@ -928,15 +951,32 @@ void ivas_dirac_dec_decorr_process_fx( move16(); FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { +#ifdef OPT_MCH_DEC_V1_NBE + q_shift = s_min( q_shift, + L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ) ); +#else /* OPT_MCH_DEC_V1_NBE */ q_shift = s_min( q_shift, sub( L_norm_arr( &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ), Q2 ) ); +#endif /* OPT_MCH_DEC_V1_NBE */ } +#ifdef OPT_MCH_DEC_V1_NBE + q_shift = sub( q_shift, 2 ); + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + Scale_sig32( &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2, q_shift ); + } + q_frame_f = add( q_frame_f, q_shift ); + Word16 diff1 = sub( e_direct_energy_smooth, e_reverb_energy_smooth ); + Word16 diff2 = add( Q30, diff1 ); + diff1 = sub( Q30, diff1 ); +#else /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { Scale_sig32( &frame_dec_fx[shl( imult1616( ch_idx, num_freq_bands ), 1 )], shl( max_band_decorr, 1 ), q_shift ); } q_frame_f = add( q_frame_f, q_shift ); +#endif /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ch_idx++ ) { @@ -956,6 +996,14 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); +#ifdef OPT_MCH_DEC_V1_NBE + Word64 temp_1 = W_sub( W_shl( reverb_energy_loc, diff1 ), W_mult0_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ) ); + Word64 temp_2 = W_sub( W_shl( direct_energy_loc, diff2 ), W_mult0_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ) ); + + IF( temp_1 > 0 ) + { + duck_gain = BASOP_Util_Divide3232_Scale( Mpy_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ), L_add( reverb_energy_loc, EPSILON_FX ), &e_duck_gain ); +#else /* OPT_MCH_DEC_V1_NBE */ Word32 temp_1 = Mpy_32_32( direct_energy_loc, DIRAC_DUCK_GAMMA_FX ); // e+1 Word32 temp_2 = Mpy_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ); // e+1 Word16 comp_flag_1 = BASOP_Util_Cmp_Mant32Exp( reverb_energy_loc, e_reverb_energy_smooth, temp_1, add( e_direct_energy_smooth, 1 ) ); @@ -963,6 +1011,7 @@ void ivas_dirac_dec_decorr_process_fx( IF( EQ_16( comp_flag_1, 1 ) ) { duck_gain = BASOP_Util_Divide3232_Scale( temp_1, L_add( reverb_energy_loc, EPSILON_FX ), &e_duck_gain ); +#endif /* OPT_MCH_DEC_V1_NBE */ e_duck_gain = add( e_duck_gain, sub( add( e_direct_energy_smooth, 1 ), e_reverb_energy_smooth ) ); duck_gain = Sqrt16( duck_gain, &e_duck_gain ); @@ -974,10 +1023,17 @@ void ivas_dirac_dec_decorr_process_fx( move32(); move32(); } +#ifdef OPT_MCH_DEC_V1_NBE + ELSE IF( temp_2 > 0 ) + { + + duck_gain = BASOP_Util_Divide3232_Scale( direct_energy_loc, L_add( Mpy_32_32( reverb_energy_loc, DIRAC_DUCK_GAMMA_FX ), EPSILON_FX ), &e_duck_gain ); +#else /* OPT_MCH_DEC_V1_NBE */ ELSE IF( EQ_16( comp_flag_2, 1 ) ) { duck_gain = BASOP_Util_Divide3232_Scale( direct_energy_loc, L_add( temp_2, EPSILON_FX ), &e_duck_gain ); +#endif /* OPT_MCH_DEC_V1_NBE */ e_duck_gain = add( e_duck_gain, sub( e_direct_energy_smooth, add( e_reverb_energy_smooth, 1 ) ) ); duck_gain = Sqrt16( duck_gain, &e_duck_gain ); @@ -1048,6 +1104,44 @@ void ivas_dirac_dec_decorr_process_fx( IF( EQ_16( h_freq_domain_decorr_ap_params->add_back_onsets_on, 1 ) ) { +#ifdef OPT_MCH_DEC_V1_NBE + IF( q_if_local ) + { + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); + + FOR( k = 0; k < max_band_decorr; ++k ) + { + Word32 op2 = L_shr( L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ), q_if_local ); + aux_buffer_fx[2 * k] = Mpy_32_32( input_frame_fx[2 * ( offset + k )], op2 ); + aux_buffer_fx[2 * k + 1] = Mpy_32_32( input_frame_fx[2 * ( offset + k ) + 1], op2 ); // q_frame_f + move32(); + move32(); + } + + v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ); + } + } + ELSE + { + FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) + { + offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); + + FOR( k = 0; k < max_band_decorr; ++k ) + { + Word32 op2 = L_sub( ONE_IN_Q31, onset_filter_fx[offset + k] ); + aux_buffer_fx[2 * k] = Mpy_32_32( input_frame_fx[2 * ( offset + k )], op2 ); + aux_buffer_fx[2 * k + 1] = Mpy_32_32( input_frame_fx[2 * ( offset + k ) + 1], op2 ); // q_frame_f + move32(); + move32(); + } + + v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], decorX2 ); + } + } +#else /* OPT_MCH_DEC_V1_NBE */ FOR( ch_idx = 0; ch_idx < num_channels; ++ch_idx ) { offset = imult1616( proto_index_dir[ch_idx], num_freq_bands ); @@ -1062,6 +1156,7 @@ void ivas_dirac_dec_decorr_process_fx( v_add_fx( &frame_dec_fx[2 * ch_idx * num_freq_bands], aux_buffer_fx, &frame_dec_fx[2 * ch_idx * num_freq_bands], shl( max_band_decorr, 1 ) ); } +#endif /* OPT_MCH_DEC_V1_NBE */ } /* avoid decorrelation above maximum frequency -> set to zero the remaining frequencies*/ -- GitLab From 6d95be087e7e0b14312d0a49c2294ffb28405fa8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 15:16:54 +0530 Subject: [PATCH 298/394] Fix for 3GPP issue 1798: Decoder crash for ParamUpmix MC 7.1+4 at 160kbps decoding to mono at 16/32kHz in ivas_ls_setup_conversion_process_mdct_fx() Link #1798 --- lib_dec/ivas_out_setup_conversion_fx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 2135cd6d6..6e78e9c69 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -695,6 +695,11 @@ void ivas_ls_setup_conversion_process_mdct_fx( Word16 guard_1 = shr( add( find_guarded_bits_fx( tmp_sub ), 1 ), 1 ); Word16 guard_2 = find_guarded_bits_fx( L_mult0( outChannels, inChannels ) ); q_output = sub( q_output, s_max( guard_1, guard_2 ) ); + /* Increase the guard bit by 1 to avoid overflow only if q_output is positive */ + if ( q_output > 0 ) + { + q_output = sub( q_output, 1 ); + } FOR( i = 0; i < inChannels; ++i ) { -- GitLab From be8a2c4ba52ccd9eda84a4cb6d664d9991686515 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 21:37:22 +0530 Subject: [PATCH 299/394] Optimization changes for ivas_mcmasa_dmx_fx function - non bit exact --- lib_com/options.h | 1 + lib_enc/ivas_mcmasa_enc_fx.c | 64 ++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index de20f6959..3c6148817 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -80,6 +80,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCH_DEC_V1_NBE +#define OPT_MCT_ENC_48KB_NBE #define OPT_MCH_DEC_V1_BE #define OPT_MCT_ENC_V2_NBE #define OPT_SBA_DEC_V2_NBE diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index fb4ea608a..b24623003 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -1942,9 +1942,17 @@ static void ivas_mcmasa_dmx_fx( Word32 alpha_fx, L_tmp, L_tmp1; Word16 multiChEne_e, scale, downmixEne_e = 0, prevEQ_e, tmp, currEQ_e, instEQ_e; move16(); +#ifdef OPT_MCT_ENC_48KB_NBE + Word16 max_exp, tmp_exp, separateChannelFlag; + Word64 tmp_64; + Word64 multiChEne_64_fx = 0; + Word64 downmixEne_64_fx = 0; + move64(); + move64(); +#endif numAnalysisChannels = sub( nchan_inp, 1 ); - IF( hMcMasa->separateChannelEnabled ) + if ( hMcMasa->separateChannelEnabled ) { numAnalysisChannels = sub( nchan_inp, 2 ); } @@ -1957,22 +1965,45 @@ static void ivas_mcmasa_dmx_fx( { FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + multiChEne_64_fx = W_mac_32_32( multiChEne_64_fx, data_fx[j][i], data_fx[j][i] ); // exp: 2*data_e +#else L_tmp1 = BASOP_Util_Add_Mant32Exp( data_fx[j][i], data_e, 0, 0, &scale ); L_tmp = Mpy_32_32( L_tmp1, L_tmp1 ); // data_e + data_e multiChEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale + scale, multiChEne_fx, multiChEne_e, &scale ); multiChEne_e = scale; move16(); +#endif } } - +#ifdef OPT_MCT_ENC_48KB_NBE + tmp = shl( data_e, 1 ); +#endif IF( EQ_16( nchan_transport, 2 ) ) { Word16 numSideChannels; /* Channels other than left, right, center */ Word16 leftIndex, rightIndex; +#ifdef OPT_MCT_ENC_48KB_NBE + Word16 tmp_16; + + separateChannelFlag = 1; + move16(); + if ( hMcMasa->separateChannelEnabled ) + { + separateChannelFlag = 0; + move16(); + } +#endif numSideChannels = sub( shr( numAnalysisChannels, 1 ), 1 ); FOR( j = 0; j < numSideChannels; j++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + tmp_16 = add( shl( j, 1 ), 2 ); + + leftIndex = add( tmp_16, separateChannelFlag ); + rightIndex = add( add( tmp_16, 1 ), separateChannelFlag ); +#else IF( hMcMasa->separateChannelEnabled ) { leftIndex = add( shl( j, 1 ), 2 ); @@ -1983,7 +2014,7 @@ static void ivas_mcmasa_dmx_fx( leftIndex = add( shl( j, 1 ), 3 ); rightIndex = add( shl( j, 1 ), 4 ); } - +#endif FOR( i = 0; i < input_frame; i++ ) { data_fx[0][i] = L_add( data_fx[0][i], data_fx[leftIndex][i] ); // data_e @@ -2023,15 +2054,28 @@ static void ivas_mcmasa_dmx_fx( { FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + downmixEne_64_fx = W_mac_32_32( downmixEne_64_fx, data_fx[j][i], data_fx[j][i] ); // exp: 2*data_e +#else L_tmp1 = BASOP_Util_Add_Mant32Exp( data_fx[j][i], data_e, 0, 0, &scale ); L_tmp = Mpy_32_32( L_tmp1, L_tmp1 ); // data_e + data_e downmixEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale + scale, downmixEne_fx, downmixEne_e, &downmixEne_e ); +#endif } } alpha_fx = 214748364; // 0.1 in Q31 move32(); +#ifdef OPT_MCT_ENC_48KB_NBE + scale = W_norm( multiChEne_64_fx ); + multiChEne_fx = W_extract_h( W_shl( multiChEne_64_fx, scale ) ); + multiChEne_e = sub( tmp, scale ); + + scale = W_norm( downmixEne_64_fx ); + downmixEne_fx = W_extract_h( W_shl( downmixEne_64_fx, scale ) ); + downmixEne_e = sub( tmp, scale ); +#endif L_tmp = Mpy_32_32( alpha_fx, multiChEne_fx ); L_tmp1 = Mpy_32_32( 1932735284 /* 0.9f in Q31 */, hMcMasa->prevMultiChEne_fx ); hMcMasa->prevMultiChEne_fx = BASOP_Util_Add_Mant32Exp( L_tmp, multiChEne_e, L_tmp1, hMcMasa->prevMultiChEne_e, &hMcMasa->prevMultiChEne_e ); @@ -2056,12 +2100,26 @@ static void ivas_mcmasa_dmx_fx( hMcMasa->prevEQ_e = currEQ_e; move16(); +#ifdef OPT_MCT_ENC_48KB_NBE + max_exp = s_max( prevEQ_e, currEQ_e ); + prevEQ_fx = L_shl( prevEQ_fx, sub( prevEQ_e, max_exp ) ); // exp:max_exp + currEQ_fx = L_shl( currEQ_fx, sub( currEQ_e, max_exp ) ); // exp:max_exp + tmp_exp = add( max_exp, 16 ); +#endif + FOR( i = 0; i < input_frame; i++ ) { +#ifdef OPT_MCT_ENC_48KB_NBE + tmp_64 = W_mac_32_32( W_mult_32_16( currEQ_fx, hMcMasa->interpolator_fx[i] ), prevEQ_fx, L_sub( ONE_IN_Q15, hMcMasa->interpolator_fx[i] ) ); // exp:max_exp +16 + scale = W_norm( tmp_64 ); + instEQ_fx = W_extract_h( W_shl( tmp_64, scale ) ); + instEQ_e = sub( tmp_exp, scale ); +#else L_tmp = Mpy_32_32( L_deposit_h( hMcMasa->interpolator_fx[i] ), currEQ_fx ); L_tmp1 = L_sub( 1073741824 /* 1 in Q30 */, L_lshr( L_deposit_h( hMcMasa->interpolator_fx[i] ), 1 ) ); L_tmp1 = Mpy_32_32( L_tmp1, prevEQ_fx ); instEQ_fx = BASOP_Util_Add_Mant32Exp( L_tmp, currEQ_e, L_tmp1, add( prevEQ_e, 1 ), &instEQ_e ); +#endif FOR( j = 0; j < nchan_transport; j++ ) { -- GitLab From 1a983c58d4affdad0a1453dd1c79ee6472aa063c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 7 Jul 2025 12:17:37 +0530 Subject: [PATCH 300/394] Fix for LTV crash observed for encoder in CI - xes Encoder original crash for test stream ltv_basop_encoder-OMASA 2TC 3ISM at br sw techs 13.2 to 512 kbps start 24.4 kbps, 32kHz in, 48kHz out, BINAURAL out - Cause: In inov_encode, the h2 buffer (derived from h1) exceeds Q12 range (>8.0f) in float. - Fix: Added saturation when scaling h2 to Q12 --- lib_enc/inov_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/inov_enc_fx.c b/lib_enc/inov_enc_fx.c index 9c78ccf7f..02ef25096 100644 --- a/lib_enc/inov_enc_fx.c +++ b/lib_enc/inov_enc_fx.c @@ -587,7 +587,7 @@ Word16 inov_encode_ivas_fx( set16_fx( y2, 0, L_SUBFR ); Qh2 = sub( 14, norm_s( h2[0] ) ); - scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); + Scale_sig( h2, L_SUBFR, sub( Q12, Qh2 ) ); IF( !Opt_AMR_WB ) { -- GitLab From 9533c4e9d0cf522840d7de7559fc44b707e566e5 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 7 Jul 2025 11:40:20 +0200 Subject: [PATCH 301/394] Correct range of L_norm_arr() over xn_buf_fx_32 --- lib_com/options.h | 2 ++ lib_dec/dec_tcx_fx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 3c6148817..25425b0ca 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,6 +104,8 @@ #define FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN #define FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD +#define FIX_1802 + #define FIX_USAN_BASOP_UTIL_DIVIDE3232 /* Eri: Fix USAN error in BASOP_Util_Divide3232_Scale_newton by adding explicit type cast for -1 in hex */ #define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 6206577c1..a289fc733 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3464,7 +3464,11 @@ void IMDCT_ivas_fx( // sub( q_xn_buf_fx_32, q_win ) == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 +#ifdef FIX_1802 + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), sub( L_norm_arr( xn_buf_fx_32 + ( overlap / 2 ) + nz, L_frame ), 1 ) ) ); +#else q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); +#endif } IMDCT_ivas_fx_rescale( xn_buf_fx, &q_xn_buf_fx, syn_Overl_TDAC_fx, Q_syn_Overl_TDAC_fx, old_syn_overl_fx, Q_old_syn_overl_fx, hTcxDec->old_syn_Overl, &hTcxDec->Q_old_syn_Overl, old_out_fx, q_old_out_fx, q_win, FB_flag ); #endif -- GitLab From 5f8777187b7f5bd31d49b9b1523356bf9fca3f02 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 7 Jul 2025 12:52:06 +0200 Subject: [PATCH 302/394] Adjusted scaling of the synth_fx buffer. --- lib_com/options.h | 2 +- lib_dec/ivas_mct_dec_fx.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3c6148817..5724fc2f5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,5 +119,5 @@ #define FIX_ISSUE_1792 /* FhG: fix noise bursts in binaural rendering */ #define FIX_ISSUE_1795_Q3_OVERFLOW /* FhG: Q3 overflow in function WB_BWE_gain_pred_fx (EVS legacy code) BE, MR1855 */ - +#define FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION /* FhG: Fixed getScalefactor usage */ #endif diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index ccc515b03..3baef825f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -380,17 +380,27 @@ ivas_error ivas_mct_dec_fx( hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); IF( hdrm != 0 ) { +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm ); + e_sig[0] = sub( e_sig[0], hdrm ); +#else sh = s_min( sub( e_sig[0], 16 ), hdrm ); Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sh ); e_sig[0] = sub( e_sig[0], sh ); +#endif move16(); } hdrm = getScaleFactor16( synth_fx[1], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); IF( hdrm != 0 ) { +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm ); + e_sig[1] = sub( e_sig[1], hdrm ); +#else sh = s_min( sub( e_sig[1], 16 ), hdrm ); Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sh ); e_sig[1] = sub( e_sig[1], sh ); +#endif move16(); } -- GitLab From 45b66fdc14badd1ee8aee92a7ed712ea90076923 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 7 Jul 2025 13:24:43 +0200 Subject: [PATCH 303/394] Removed unused variable to fix Linux compilation failure. --- lib_dec/ivas_mct_dec_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 3baef825f..9d3fbbf6f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -375,8 +375,11 @@ ivas_error ivas_mct_dec_fx( Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) ); ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig ); - +#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + Word16 hdrm; +#else Word16 hdrm, sh; +#endif hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX ); IF( hdrm != 0 ) { -- GitLab From d102f50a7b495b3f1ce399d82b305c4b07e8531e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Mon, 7 Jul 2025 14:46:09 +0200 Subject: [PATCH 304/394] Automatically use latest CI scripts --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c61cf5b4..1c75ef140 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ variables: # note: GitLab cannot reference variables defined by users in the include ref:, we need to use a YAML anchor for this # see https://docs.gitlab.com/ci/yaml/includes/#use-variables-with-include for more information - IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF a31272de16bd1b556269a50bc179321a60f2a500 + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main include: - local: .gitlab-ci/variables.yml -- GitLab From 7ea9581747c2cfbafaf8dc997ee975ee0f4d408f Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 7 Jul 2025 15:34:24 +0200 Subject: [PATCH 305/394] Increase headroom of xn_buf_fx_32 / q_win to same value as in main branch. --- lib_dec/dec_tcx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a289fc733..62db44e96 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -3465,7 +3465,7 @@ void IMDCT_ivas_fx( // q_xn_buf_fx_32 - q_win == 16 - L_norm_arr( xn_buf_fx_32, L_frame ) // q_win == - 16 + L_norm_arr( xn_buf_fx_32, L_frame ) + q_xn_buf_fx_32 #ifdef FIX_1802 - q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), sub( L_norm_arr( xn_buf_fx_32 + ( overlap / 2 ) + nz, L_frame ), 1 ) ) ); + q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), sub( L_norm_arr( xn_buf_fx_32 + ( overlap / 2 ) + nz, L_frame ), 2 ) ) ); #else q_win = s_min( q_win, add( sub( q_xn_buf_fx_32, 16 ), L_norm_arr( xn_buf_fx_32, L_frame ) ) - 2 ); #endif -- GitLab From 77432c2e71e50581820acd0e9b832de455f53187 Mon Sep 17 00:00:00 2001 From: naghibza Date: Mon, 7 Jul 2025 17:37:52 +0200 Subject: [PATCH 306/394] Added 1 bit headroom to synth_fx. --- lib_dec/ivas_mct_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 9d3fbbf6f..c08cec4ce 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -384,6 +384,7 @@ ivas_error ivas_mct_dec_fx( IF( hdrm != 0 ) { #ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + hdrm = sub( hdrm, 1 ); Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm ); e_sig[0] = sub( e_sig[0], hdrm ); #else @@ -397,6 +398,7 @@ ivas_error ivas_mct_dec_fx( IF( hdrm != 0 ) { #ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION + hdrm = sub( hdrm, 1 ); Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm ); e_sig[1] = sub( e_sig[1], hdrm ); #else -- GitLab From 837f655c24cdb9cb184d29d8eeeeeb789ba313ed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 06:15:49 +0530 Subject: [PATCH 307/394] Decoder MSAN issue fix, warnings fix --- lib_com/cnst.h | 2 +- lib_dec/dec_tcx_fx.c | 1 + lib_dec/ivas_mdct_core_dec_fx.c | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 792df3946..53032d5ae 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -134,7 +134,7 @@ #define ONE_IN_Q29 536870912 #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 -2147483648 +#define MINUS_ONE_IN_Q31 0x80000000 #define TWO_IN_Q29 1073741824 #define FOUR_IN_Q28 1073741824 diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index 6206577c1..643d8bf7d 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5782,6 +5782,7 @@ void decoder_tcx_imdct_fx( move16(); #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN Word16 q_acelp_zir_fx = 0; + set16_fx( acelp_zir_fx, 0, L_FRAME_MAX / 2 ); #else Word16 shift_q = sub( q_x, q_win ); #endif diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index 92511a62d..2baa31d22 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -1233,7 +1233,10 @@ void ivas_mdct_core_reconstruct_fx( IF( st->core != ACELP_CORE ) { #ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN - Word16 q_win0, q_winFB0; + Word16 q_win0 = Q15; + move16(); + Word16 q_winFB0 = Q15; + move16(); #else Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win st->hTcxDec->Q_syn_Overl_TDACFB = q_win; -- GitLab From b9ddc95f747742326cb26e5b48981bb8321e27e7 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 8 Jul 2025 11:46:51 +1000 Subject: [PATCH 308/394] address review comment --- lib_com/ivas_spar_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 2be38b4bc..656868120 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -4334,7 +4334,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( FOR( ch = 1; ch < foa_ch; ch++ ) { /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ - response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( Q30, EPSILON_FX_SHIFT ) ); // q30 + response_avg_fx[ch] = L_shl( response_avg_fx[ch], Q30 - EPSILON_FX_SHIFT ); // q30 move32(); } } @@ -4939,7 +4939,7 @@ void ivas_get_spar_md_from_dirac_fx( FOR( ch = 1; ch < foa_ch; ch++ ) { /*when control comes here, response_avg_fx[ch] should be less than EPSILON*/ - response_avg_fx[ch] = L_shl( response_avg_fx[ch], sub( Q30, EPSILON_FX_SHIFT ) ); // q30 + response_avg_fx[ch] = L_shl( response_avg_fx[ch], Q30 - EPSILON_FX_SHIFT ); // q30 move32(); } } -- GitLab From c64f3b64c9cf505544c6c5945266373aa3db3051 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 09:36:29 +0530 Subject: [PATCH 309/394] Fix for 3GPP issue 1794: High MLD for MC 5.1 Decoder at 192kbps JBM decoding to BINAURAL_ROOM_REVERB Link #1794 --- lib_dec/ivas_jbm_dec_fx.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index b5cd8b186..74be1ed39 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2264,10 +2264,10 @@ ivas_error ivas_jbm_dec_render_fx( FOR( i = 0; i < nchan_in; i++ ) { - scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor IF( st_ivas->hDecoderConfig->Opt_tsm ) { - scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 + scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor } } IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -2277,6 +2277,17 @@ ivas_error ivas_jbm_dec_render_fx( return error; } + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + IF ( NE_16(exp , *st_ivas->hCrendWrapper->p_io_qfactor) ) + { + FOR( i = 0; i < nchan_in; i++ ) + { + scale_sig32( p_tc_fx[i], *nSamplesRendered, sub( *st_ivas->hCrendWrapper->p_io_qfactor, exp ) ); + } + } + } + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); FOR( i = 0; i < nchan_in; i++ ) -- GitLab From 4a5a01acae1eab4127769f401cfe85036b544c6f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 09:39:40 +0530 Subject: [PATCH 310/394] Fix for 3GPP issue 1804: Encoder crash for Stereo at 16.4kbps in prep_tbe_exc_fx() Link #1804 --- lib_com/swb_tbe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 8ddfa3e5f..2ca52b8e4 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -7077,7 +7077,7 @@ void prep_tbe_exc_fx( FOR( i = 0; i < L_subfr * HIBND_ACB_L_FAC; i++ ) { L_tmp = L_mult( gain_code16, tmp_code_fx[i] ); /* Q9 + Q_exc + 1*/ - L_tmp = L_shl( L_tmp, 5 ); /* Q9 + Q_exc + Q6*/ + L_tmp = L_shl_o( L_tmp, 5, &Overflow ); /* Q9 + Q_exc + Q6*/ L_tmp = L_mac_o( L_tmp, gain_pit_fx, bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC], &Overflow ); /*Q15+Q_exc */ L_tmp = L_shl_o( L_tmp, 1, &Overflow ); /*16+Q_exc */ /* saturation can occur here */ bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = round_fx_o( L_tmp, &Overflow ); /*Q_exc */ -- GitLab From 65f7beae15b611574da0aaf55a2e314814f07613 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 09:43:27 +0530 Subject: [PATCH 311/394] Clang formatting changes --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 74be1ed39..d00a9fe80 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2279,7 +2279,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) { - IF ( NE_16(exp , *st_ivas->hCrendWrapper->p_io_qfactor) ) + IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) ) { FOR( i = 0; i < nchan_in; i++ ) { @@ -2287,7 +2287,7 @@ ivas_error ivas_jbm_dec_render_fx( } } } - + ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); FOR( i = 0; i < nchan_in; i++ ) -- GitLab From 5c66dac3241798955f17901ba8969aacff646282 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 21:39:52 +0530 Subject: [PATCH 312/394] Fix for 3GPP issue 1763: Rate switching MASA with LTV signal has a couple of worse spikes in BASOP decoder Link #1763 --- lib_com/modif_fs_fx.c | 4 ++-- lib_dec/swb_tbe_dec_fx.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index a9b6581ed..46e24e31a 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -1759,8 +1759,8 @@ void interpolate_3_over_1_allpass_fx32( { mem_temp = out[i]; // Qx move32(); - out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2424 ) ); // Qx - // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2424 + out[i] = L_sub_sat( Mpy_32_16_1( L_add_sat( mem[12], mem[11] ), 18768 ), Mpy_32_16_1( L_add_sat( mem_temp, mem[10] ), 2425 ) ); // Qx + // 0.572769 in Q15 -> 18768, 0.074005 in Q15 -> 2425 move32(); mem[10] = mem[11]; // Qx move32(); diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 06da2a83d..c44f7656e 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -1181,8 +1181,9 @@ void ivas_wb_tbe_dec_fx( } ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) { - Scale_sig( hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, hBWE_TD->prev_Qx ) ); + Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) ); ivas_interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, hBWE_TD->mem_resamp_HB_fx ); + Copy_Scale_sig_16_32_no_sat( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, Qx ) ); Copy( upsampled_synth, synth, L_FRAME48k ); } } -- GitLab From 7461e40500642454980701531d2111a98c803229 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 10:58:20 +0530 Subject: [PATCH 313/394] Fix for artefacts observed in Linux --- lib_dec/swb_tbe_dec_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index c44f7656e..61dc3d0c5 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -613,6 +613,7 @@ void ivas_wb_tbe_dec_fx( Word16 error[L_FRAME16k]; Word16 synth_frac[L_FRAME16k]; Word16 upsampled_synth[L_FRAME48k]; + Word32 tmp_synL[L_FRAME48k], upsampled_synth_32fx[L_FRAME48k]; Word32 prev_pow, curr_pow, curr_frame_pow; Word16 curr_frame_pow_exp; Word16 temp, scale, n; @@ -1181,10 +1182,10 @@ void ivas_wb_tbe_dec_fx( } ELSE IF( EQ_32( st_fx->output_Fs, 48000 ) ) { + Copy_Scale_sig_16_32_no_sat( synth, tmp_synL, L_FRAME48k, sub( Q11, Qx ) ); + interpolate_3_over_1_allpass_fx32( tmp_synL, L_FRAME16k, upsampled_synth_32fx, hBWE_TD->mem_resamp_HB_fx_32 ); Copy_Scale_sig_32_16( hBWE_TD->mem_resamp_HB_fx_32, hBWE_TD->mem_resamp_HB_fx, INTERP_3_1_MEM_LEN, sub( Qx, Q11 ) ); - ivas_interpolate_3_over_1_allpass_fx( synth, L_FRAME16k, upsampled_synth, hBWE_TD->mem_resamp_HB_fx ); - Copy_Scale_sig_16_32_no_sat( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB_fx_32, INTERP_3_1_MEM_LEN, sub( Q11, Qx ) ); - Copy( upsampled_synth, synth, L_FRAME48k ); + Copy_Scale_sig_32_16( upsampled_synth_32fx, synth, L_FRAME48k, sub( Qx, Q11 ) ); } } ELSE -- GitLab From abcc1940c73a1375aee98746f1f8aba32c978a38 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 15:10:41 +0530 Subject: [PATCH 314/394] MSAN Fix: initialising tcx_mdct_window_length --- lib_dec/init_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index 11c108380..7ee1b8c34 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1558,6 +1558,8 @@ ivas_error init_decoder_ivas_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); } + st_fx->hTcxCfg->tcx_mdct_window_length = L_FRAME32k / 2; + move16(); } ELSE { -- GitLab From 8e2135bd0ded893d56d440b3d11a96b143d32d03 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 9 Jul 2025 06:38:32 +0530 Subject: [PATCH 315/394] Precision improvement changes for 3GPP Issues #1787 and #1788 Link #1787, #1788 --- lib_com/ivas_dirac_com_fx.c | 89 ++++++++--------------------- lib_rend/ivas_dirac_ana_fx.c | 64 +++++++++++++++++---- lib_rend/ivas_mcmasa_ana_fx.c | 104 +++++++++++++++++++++++++++------- lib_rend/ivas_omasa_ana_fx.c | 87 +++++++++++++++++++++------- lib_rend/ivas_prot_rend_fx.h | 13 +++-- 5 files changed, 235 insertions(+), 122 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index befeb273c..735bbddaa 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -793,109 +793,66 @@ void computeDiffuseness_fixed( ) { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; + Word16 intensity_slow_e[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; Word64 intensity_slow_abs_64[CLDFB_NO_CHANNELS_MAX]; Word16 intensity_slow_abs_q[CLDFB_NO_CHANNELS_MAX]; Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; + Word16 energy_slow_e[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0; move32(); Word32 *p_tmp; const Word32 *p_tmp_c; - Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; + Word16 exp1, exp2, q_tmp; Word16 q_ene, q_intensity; /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ - set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, CLDFB_NO_CHANNELS_MAX ) ); + set_zero_fx( intensity_slow, ( DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ) ); + set16_fx( intensity_slow_e, 0, ( DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ) ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); - - /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ - min_q_shift1 = Q31; - move16(); - min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ); - min_q_shift1 = sub( min_q_shift1, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); - - min_q_shift2 = Q31; - move16(); - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) - { - min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); - } - } - min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); - - q_ene = add( q_factor_energy[0], min_q_shift1 ); - move16(); - q_intensity = add( q_factor_intensity[0], min_q_shift2 ); - move16(); + set16_fx( energy_slow_e, 0, CLDFB_NO_CHANNELS_MAX ); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; - q_tmp = add( q_factor_energy[i], min_q_shift1 ); - - - Word16 shift_q = sub( q_tmp, q_ene ); - Word32 shiftEquiv = L_add( 0, 0 ); - Word16 shift_qtotal; - if ( shift_q < 0 ) - { - shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); - } - if ( shift_q >= 0 ) - { - shiftEquiv = L_add( 0x7FFFFFFF, 0 ); - } - shift_qtotal = sub( min_q_shift1, s_max( shift_q, 0 ) ); - FOR( k = 0; k < num_freq_bands; k++ ) { - tmp = L_shl( p_tmp_c[k], shift_qtotal ); - energy_slow[k] = Madd_32_32_r( tmp, energy_slow[k], shiftEquiv ); + energy_slow[k] = BASOP_Util_Add_Mant32Exp( p_tmp_c[k], sub( 31, q_factor_energy[i] ), energy_slow[k], energy_slow_e[k], &energy_slow_e[k] ); move32(); } - - q_ene = s_min( q_ene, q_tmp ); - - /* Intensity slow */ - q_tmp = add( q_factor_intensity[i], min_q_shift2 ); - - shift_q = sub( q_tmp, q_intensity ); - if ( shift_q < 0 ) - { - shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); - } - if ( shift_q >= 0 ) - { - shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); - } - shift_qtotal = sub( min_q_shift2, s_max( shift_q, 0 ) ); - FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { - tmp = L_shl( p_tmp[k], shift_qtotal ); - intensity_slow[j * num_freq_bands + k] = Madd_32_32_r( tmp, intensity_slow[j * num_freq_bands + k], shiftEquiv ); + intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( p_tmp[k], sub( 31, q_factor_intensity[i] ), intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], &intensity_slow_e[j * num_freq_bands + k] ); move32(); } } + } + Word16 max_e; + maximum_fx( energy_slow_e, CLDFB_NO_CHANNELS_MAX, &max_e ); + q_ene = sub( 31, max_e ); + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + energy_slow[i] = L_shr( energy_slow[i], sub( max_e, energy_slow_e[i] ) ); // scaling to q_ene + move32(); + } - q_intensity = s_min( q_intensity, q_tmp ); + maximum_fx( intensity_slow_e, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX, &max_e ); + q_intensity = sub( 31, max_e ); + FOR( i = 0; i < DIRAC_NUM_DIMS * num_freq_bands; i++ ) + { + intensity_slow[i] = L_shr( intensity_slow[i], sub( max_e, intensity_slow_e[i] ) ); // scaling to q_intensity + move32(); } - min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); - min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) ); - scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), min_q_shift1 ); - q_intensity = add( q_intensity, min_q_shift1 ); FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow_abs_64[k] = 0; diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index fcea6a6eb..5f0f8a3a4 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -293,6 +293,7 @@ static void ivas_dirac_param_est_ana_fx( Word32 Foa_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 Foa_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS]; @@ -308,6 +309,10 @@ static void ivas_dirac_param_est_ana_fx( Word16 numAnalysisChannels; Word16 inp_q; Word16 intensity_q, reference_power_q; + Word16 temp_e, sf, scaled_data_q, s, shift = 31; + move16(); + Word32 temp; + Word64 W_temp; num_freq_bands = hDirAC->nbands; /* l_ts = input_frame / CLDFB_NO_COL_MAX; */ l_ts = shr( input_frame, 4 ); @@ -320,6 +325,16 @@ static void ivas_dirac_param_est_ana_fx( move16(); move16(); move16(); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); + } + shift = sub( shift, find_guarded_bits_fx( l_ts ) ); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, shift ); + } + scaled_data_q = add( data_q, shift ); /* do processing over all CLDFB time slots */ FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) @@ -356,14 +371,14 @@ static void ivas_dirac_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { - Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; - inp_q = data_q; // Input Q of data_fx + Word16 cr_q = MAX_16, ci_q = MAX_16, c_e; + inp_q = scaled_data_q; // Q of data_fx after scaling move16(); move16(); move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - inp_q = data_q; + inp_q = scaled_data_q; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][l_ts * ts] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q ); cr_q = s_min( cr_q, getScaleFactor32( Foa_RealBuffer_fx[i], l_ts ) ); @@ -386,19 +401,38 @@ static void ivas_dirac_param_est_ana_fx( move16(); FOR( j = brange[0]; j < brange[1]; j++ ) { - Word32 temp = L_add( Mult_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Mult_32_32( Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e - hDirAC->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->energy_fx[block_m_idx][band_m_idx], hDirAC->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hDirAC->energy_e[block_m_idx][band_m_idx] ); + W_temp = W_mac_32_32( W_mult_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ); // Q-> 2*inp_q + 1 + sf = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, sf ) ); // 2*inp_q + 1 + sf - 32 + temp_e = sub( 63 - 1, add( shl( inp_q, 1 ), sf ) ); // 31 - ( 2 * inp_q + 1 + sf - 32 ) + hDirAC->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->energy_fx[block_m_idx][band_m_idx], hDirAC->energy_e[block_m_idx][band_m_idx], temp, temp_e, &hDirAC->energy_e[block_m_idx][band_m_idx] ); move32(); } } /* Direction estimation */ - computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ - intensity_q = sub( 31, shl( c_e, 1 ) ); + computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); + + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), NULL ); /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); //( 2 * ( scale_fact - Q1 ) - 31 - 1 ); // computeReferencePower_ana( hDirAC->band_grouping, Foa_RealBuffer, Foa_ImagBuffer, reference_power[ts], num_freq_bands ); + computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); //( 2 * ( scale_fact - Q1 ) - 31 - 1 ); reference_power_q = sub( shl( inp_q, 1 ), 30 ); + + /* Aligning intensity_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + } + /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hDirAC->index_buffer_intensity = add( ( hDirAC->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ move16(); @@ -426,7 +460,13 @@ static void ivas_dirac_param_est_ana_fx( move32(); hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] ); move32(); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); + + W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); + s = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, s ) ); + temp_e = sub( 63, add( add( reference_power_q, diffuseness_q ), s ) ); // 31 - ( reference_power_q + diffuseness_q + s - 32 ) + + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); move32(); renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); @@ -479,6 +519,10 @@ static void ivas_dirac_param_est_ana_fx( } } + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, negate( shift ) ); + } return; } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 99af8a0af..489dd72bf 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -529,7 +529,10 @@ void ivas_mcmasa_param_est_ana_fx( Word32 FoaEven_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 FoaEven_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 intensity_even_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_even_real_q[MASA_FREQUENCY_BANDS]; + Word16 intensity_q, intensity_even_q; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word32 vertical_diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; @@ -571,6 +574,11 @@ void ivas_mcmasa_param_est_ana_fx( Word16 i1, i2, i3; Word16 numAnalysisChannels; Word16 spreadCoh_e; + Word64 W_temp; + Word32 temp; + Word16 temp_e; + Word16 sf, scaled_data_q, s, shift = 31; + move16(); num_freq_bins = hMcMasa->cldfbAnaEnc[0]->no_channels; move16(); num_freq_bands = hMcMasa->nbands; @@ -580,6 +588,18 @@ void ivas_mcmasa_param_est_ana_fx( set16_fx( q_vdv, 31, MASA_FREQUENCY_BANDS ); set16_fx( out_exp, 30, MASA_FREQUENCY_BANDS ); + + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + shift = s_min( shift, L_norm_arr( data_fx[i], input_frame ) ); + } + shift = sub( shift, find_guarded_bits_fx( l_ts ) ); + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, shift ); + } + scaled_data_q = add( q_data, shift ); + /* do processing over all CLDFB time slots */ FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) { @@ -625,14 +645,14 @@ void ivas_mcmasa_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { - Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; + Word16 cr_q = MAX_16, ci_q = MAX_16, c_e; move16(); move16(); - Word16 inp_q = q_data; + Word16 inp_q = scaled_data_q; move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - inp_q = q_data; + inp_q = scaled_data_q; move16(); cldfbAnalysis_ts_fx_var_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q ); cr_q = s_min( cr_q, getScaleFactor32( Chnl_ImagBuffer_fx[i], l_ts ) ); @@ -659,8 +679,12 @@ void ivas_mcmasa_param_est_ana_fx( { FOR( i = 0; i < numAnalysisChannels; i++ ) { - Word32 temp = L_add( Mult_32_32( Chnl_RealBuffer_fx[i][j], Chnl_RealBuffer_fx[i][j] ), Mult_32_32( Chnl_ImagBuffer_fx[i][j], Chnl_ImagBuffer_fx[i][j] ) ); // Q-> 2*inp_q - 31, e = 31 - (2*inp_q - 31) = 62 - 2*inp_q = 2*(31 - inp_q) = 2*c_e - hMcMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->energy_fx[block_m_idx][band_m_idx], hMcMasa->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hMcMasa->energy_e[block_m_idx][band_m_idx] ); + W_temp = W_mac_32_32( W_mult_32_32( Chnl_RealBuffer_fx[i][j], Chnl_RealBuffer_fx[i][j] ), Chnl_ImagBuffer_fx[i][j], Chnl_ImagBuffer_fx[i][j] ); // Q-> 2*inp_q + 1 + sf = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, sf ) ); // 2 * inp_q + 1 + sf - 32 + temp_e = sub( 31 + 31, add( shl( inp_q, 1 ), sf ) ); // e = 31 - (2 * inp_q + 1 + sf - 32) + + hMcMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->energy_fx[block_m_idx][band_m_idx], hMcMasa->energy_e[block_m_idx][band_m_idx], temp, temp_e, &hMcMasa->energy_e[block_m_idx][band_m_idx] ); move32(); } } @@ -751,14 +775,39 @@ void ivas_mcmasa_param_est_ana_fx( } /* Direction estimation */ - computeIntensityVector_ana_fx( hMcMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ + computeIntensityVector_ana_fx( hMcMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), - NULL ); /* Q direction_vector_fx = Q30*/ + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, + intensity_real_q ); /* Q direction_vector_fx = Q30*/ /* Power and intensity estimation for diffuseness */ - computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx ); /*2*inp_q-31*/ - computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); /*2*inp_q-30*/ + computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx, intensity_even_real_q, inp_q ); + + computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); /*2*inp_q-30*/ + + /* Aligning intensity_real and intensity_even_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + minimum_fx( intensity_even_real_q, num_freq_bands, &intensity_even_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + + tmp = sub( intensity_even_q, intensity_even_real_q[i] ); + intensity_even_real_fx[0][i] = L_shl( intensity_even_real_fx[0][i], tmp ); + move32(); + intensity_even_real_fx[1][i] = L_shl( intensity_even_real_fx[1][i], tmp ); + move32(); + intensity_even_real_fx[2][i] = L_shl( intensity_even_real_fx[2][i], tmp ); + move32(); + } /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hMcMasa->index_buffer_intensity = add( ( hMcMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ @@ -769,7 +818,7 @@ void ivas_mcmasa_param_est_ana_fx( /* only real part needed */ Copy32( intensity_even_real_fx[i], &( hMcMasa->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); } - hMcMasa->buffer_intensity_real_q[index - 1] = sub( shl( inp_q, 1 ), 31 ); + hMcMasa->buffer_intensity_real_q[index - 1] = intensity_even_q; move16(); Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[i_mult( index - 1, num_freq_bands )] ), num_freq_bands ); hMcMasa->buffer_energy_q[index - 1] = sub( shl( inp_q, 1 ), 30 ); @@ -779,7 +828,7 @@ void ivas_mcmasa_param_est_ana_fx( IF( !hMcMasa->isHorizontalSetup ) { Copy32( intensity_real_fx[2], &( hMcMasa->buffer_intensity_real_vert_fx[index - 1][0] ), num_freq_bands ); - hMcMasa->buffer_intensity_real_vert_q[index - 1] = sub( shl( inp_q, 1 ), 31 ); + hMcMasa->buffer_intensity_real_vert_q[index - 1] = intensity_q; move16(); computeVerticalDiffuseness_fx( hMcMasa->buffer_intensity_real_vert_fx, hMcMasa->buffer_energy_fx, num_freq_bands, vertical_diffuseness_vector_fx, hMcMasa->buffer_intensity_real_vert_q, hMcMasa->buffer_energy_q ); // Q vertical_diffuseness_vector_fx = 31 v_min_fx( diffuseness_vector_fx, out_exp, vertical_diffuseness_vector_fx, q_vdv, diffuseness_vector_fx, out_exp, num_freq_bands ); @@ -790,7 +839,14 @@ void ivas_mcmasa_param_est_ana_fx( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); + + W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); + s = W_norm( W_temp ); + temp = W_extract_h( W_shl( W_temp, s ) ); + temp_e = sub( 32, add( sub( Q30, sub( shl( c_e, 1 ), 1 ) ), s ) ); // 31 - ( (31 - sub( shl( c_e, 1 ), 1 )) + diffuseness_q + s - 32 ) + + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); move32(); move32(); @@ -827,7 +883,7 @@ void ivas_mcmasa_param_est_ana_fx( { FOR( j = i; j < numAnalysisChannels; j++ ) { - Word32 temp = BASOP_Util_Add_Mant32Exp( Mult_32_32( COVls[band_m_idx].xr_fx[i][j], COVls[band_m_idx].xr_fx[i][j] ), shl( COVls[band_m_idx].xr_e[i][j], 1 ), Mult_32_32( COVls[band_m_idx].xi_fx[i][j], COVls[band_m_idx].xi_fx[i][j] ), shl( COVls[band_m_idx].xi_e[i][j], 1 ), &absCOVls_e[i][j] ); + temp = BASOP_Util_Add_Mant32Exp( Mult_32_32( COVls[band_m_idx].xr_fx[i][j], COVls[band_m_idx].xr_fx[i][j] ), shl( COVls[band_m_idx].xr_e[i][j], 1 ), Mult_32_32( COVls[band_m_idx].xi_fx[i][j], COVls[band_m_idx].xi_fx[i][j] ), shl( COVls[band_m_idx].xi_e[i][j], 1 ), &absCOVls_e[i][j] ); absCOVls_fx[i][j] = Sqrt32( temp, &absCOVls_e[i][j] ); move32(); } @@ -880,7 +936,7 @@ void ivas_mcmasa_param_est_ana_fx( move16(); } Word16 temp_exp = add( lsEnergy_e[i1], lsEnergy_e[i2] ); - Word32 temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_exp ); + temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i1], lsEnergy_fx[i2] ), EPSILON_FX ), &temp_exp ); tempCoh_e = 0; move16(); tempCoh_fx = L_shl( BASOP_Util_Divide3232_Scale( absCOVls_fx[i1][i2], temp, &tempCoh_e ), 16 ); @@ -932,8 +988,8 @@ void ivas_mcmasa_param_est_ana_fx( move16(); i3 = hMcMasa->rightNearest[i1]; move16(); - Word16 temp_e = add( lsEnergy_e[i2], lsEnergy_e[i3] ); - Word32 temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i2], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ); + temp_e = add( lsEnergy_e[i2], lsEnergy_e[i3] ); + temp = Sqrt32( L_add( Mult_32_32( lsEnergy_fx[i2], lsEnergy_fx[i3] ), EPSILON_FX ), &temp_e ); IF( LT_16( i2, i3 ) ) { stereoCoh_fx = BASOP_Util_Divide3232_Scale( absCOVls_fx[i2][i3], temp, &stereoCoh_e ); @@ -1190,6 +1246,12 @@ void ivas_mcmasa_param_est_ana_fx( } } } + + FOR( i = 0; i < numAnalysisChannels; i++ ) + { + scale_sig32( data_fx[i], input_frame, negate( shift ) ); + } + return; } @@ -1611,7 +1673,7 @@ void ivas_create_masa_out_meta_fx( /* Direct-to-total ratio */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->directToTotalRatio[0][sf][band] = (UWord8) L_shr( energyRatio[sf][band], sub( energyRatio_q, 8 ) ); // Q8 + extOutMeta->directToTotalRatio[0][sf][band] = (UWord8) L_shr( Mpy_32_16_1( energyRatio[sf][band], UINT8_MAX ), sub( energyRatio_q, 15 ) ); // Q0 move16(); extOutMeta->directToTotalRatio[1][sf][band] = 0; move16(); @@ -1620,7 +1682,7 @@ void ivas_create_masa_out_meta_fx( /* Spread coherence */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->spreadCoherence[0][sf][band] = (UWord8) L_shr( spreadCoherence[sf][band], sub( spreadCoherence_q, 8 ) ); // Q8 + extOutMeta->spreadCoherence[0][sf][band] = (UWord8) L_shr( Mpy_32_16_1( spreadCoherence[sf][band], UINT8_MAX ), sub( spreadCoherence_q, 15 ) ); // Q0 move16(); extOutMeta->spreadCoherence[1][sf][band] = 0; move16(); @@ -1629,14 +1691,14 @@ void ivas_create_masa_out_meta_fx( /* Diffuse-to-total ratio = 1 - sum(direct-to-total ratios) */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( UINT8_MAX, (UWord8) L_shr( energyRatio[sf][band], sub( energyRatio_q, 8 ) ) ); // Q8 + extOutMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( UINT8_MAX, (UWord8) L_shr( Mpy_32_16_1( energyRatio[sf][band], UINT8_MAX ), sub( energyRatio_q, 15 ) ) ); // Q0 move16(); } /* Surround coherence */ FOR( band = 0; band < numFrequencyBands; band++ ) { - extOutMeta->surroundCoherence[sf][band] = (UWord8) L_shr( surroundingCoherence[sf][band], sub( surroundingCoherence_q, 8 ) ); // Q8 + extOutMeta->surroundCoherence[sf][band] = (UWord8) L_shr( Mpy_32_16_1( surroundingCoherence[sf][band], UINT8_MAX ), sub( surroundingCoherence_q, 15 ) ); // Q0 move16(); } } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index c9ed32d26..fe9ffbea3 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -362,6 +362,7 @@ static void ivas_omasa_param_est_ana_fx( Word32 Foa_RealBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 Foa_ImagBuffer_fx[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 intensity_real_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + Word16 intensity_real_q[MASA_FREQUENCY_BANDS]; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word16 diffuseness_q = 0; @@ -523,15 +524,29 @@ static void ivas_omasa_param_est_ana_fx( v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q } - computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); /* Q intensity_real_fx = 2*inp_q-31, e = 31 - 2*inp_q + 31 = 62 - 2*inp_q = 2*(31-inp_q)=2*c_e */ - intensity_q = sub( 31, shl( c_e, 1 ) ); + computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, intensity_real_q, inp_q ); - computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], shl( c_e, 1 ), NULL ); /* Q direction_vector_fx = Q30*/ + computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); /* Q direction_vector_fx = Q30*/ /* Power estimation for diffuseness */ computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); // 2 * inputq - 30 reference_power_q = sub( shl( inp_q, 1 ), 30 ); + /* Aligning intensity_real to a common Q-factor */ + minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_q, intensity_real_q[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); + move32(); + } + /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hOMasa->index_buffer_intensity = add( ( hOMasa->index_buffer_intensity % DIRAC_NO_COL_AVG_DIFF ), 1 ); /* averaging_length = 32 */ move16(); @@ -761,8 +776,9 @@ void computeIntensityVector_ana_fx( Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity 2 * Qx -31 */ -) + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ) { /* Reminder * X = a + ib; Y = c + id @@ -771,33 +787,66 @@ void computeIntensityVector_ana_fx( Word16 i, j; Word32 real, img; Word16 brange[2]; - + Word16 shift_value = add( shl( inp_q, 1 ), 1 ); + Word16 tmp_norm; FOR( i = 0; i < num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; move16(); brange[1] = band_grouping[i + 1]; move16(); + Word16 num_bins = sub( brange[1], brange[0] ); + Word16 gb = find_guarded_bits_fx( num_bins ); + Word16 norm; - intensity_real[0][i] = 0; - move32(); - intensity_real[1][i] = 0; - move32(); - intensity_real[2][i] = 0; - move32(); + Word64 tmp_1 = 0, tmp_2 = 0, tmp_3 = 0; + move64(); + move64(); + move64(); FOR( j = brange[0]; j < brange[1]; j++ ) { - real = Cldfb_RealBuffer[0][j]; // Qx - img = Cldfb_ImagBuffer[0][j]; // Qx - /* Intensity is XYZ order, audio is WYZX order. */ - intensity_real[0][i] = L_add( intensity_real[0][i], L_add( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), Mpy_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q = 2 * Qx -31 + real = Cldfb_RealBuffer[0][j]; move32(); - intensity_real[1][i] = L_add( intensity_real[1][i], L_add( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), Mpy_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q = 2 * Qx -31 - move32(); - intensity_real[2][i] = L_add( intensity_real[2][i], L_add( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), Mpy_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q = 2 * Qx -31 + img = Cldfb_ImagBuffer[0][j]; move32(); + Word64 t1, t2, t3; + t1 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[3][j], real ), Cldfb_ImagBuffer[3][j], img ); /* 2 * q_cldfb + 1 */ + t2 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[1][j], real ), Cldfb_ImagBuffer[1][j], img ); /* 2 * q_cldfb + 1 */ + t3 = W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[2][j], real ), Cldfb_ImagBuffer[2][j], img ); /* 2 * q_cldfb + 1 */ + t1 = W_shr( t1, gb ); + t2 = W_shr( t2, gb ); + t3 = W_shr( t3, gb ); + /* Intensity is XYZ order, audio is WYZX order. */ + tmp_1 = W_add( tmp_1, t1 ); /* 2 * q_cldfb + 1 */ + tmp_2 = W_add( tmp_2, t2 ); /* 2 * q_cldfb + 1 */ + tmp_3 = W_add( tmp_3, t3 ); /* 2 * q_cldfb + 1 */ + } + norm = 63; + move16(); + IF( tmp_1 != 0 ) + { + tmp_norm = W_norm( tmp_1 ); + norm = s_min( norm, tmp_norm ); + } + IF( tmp_2 != 0 ) + { + tmp_norm = W_norm( tmp_2 ); + norm = s_min( norm, tmp_norm ); + } + IF( tmp_3 != 0 ) + { + tmp_norm = W_norm( tmp_3 ); + norm = s_min( norm, tmp_norm ); } + norm = sub( norm, 32 ); + intensity_real[0][i] = W_shl_sat_l( tmp_1, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[1][i] = W_shl_sat_l( tmp_2, norm ); // shift_value - (gb - norm) + move32(); + intensity_real[2][i] = W_shl_sat_l( tmp_3, norm ); // shift_value - (gb - norm) + q_intensity_real[i] = sub( shift_value, sub( gb, norm ) ); + move16(); } return; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 7c5c02c71..6b34bcffe 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1428,12 +1428,13 @@ void ivas_omasa_ana_close( OMASA_ANA_HANDLE *hOMasa /* i/o: analysis OMASA handle */ ); void computeIntensityVector_ana_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation */ - Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal Qx */ - const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] /* o : Intensity vector 2 * Qx -31 */ -); + const Word16 *band_grouping, /* i : Band grouping for estimation */ + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal Qx */ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input sig Qx */ + const Word16 num_frequency_bands, /* i : Number of frequency bands */ + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity */ + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], + Word16 inp_q ); void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ -- GitLab From dd858bd334a3bcfa1b65c1e3e6869528918df36e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 9 Jul 2025 11:53:09 +0530 Subject: [PATCH 316/394] Reverted changes in computeDiffuseness_fixed to resolve regressions --- lib_com/ivas_dirac_com_fx.c | 89 +++++++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 735bbddaa..befeb273c 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -793,66 +793,109 @@ void computeDiffuseness_fixed( ) { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; - Word16 intensity_slow_e[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; Word64 intensity_slow_abs_64[CLDFB_NO_CHANNELS_MAX]; Word16 intensity_slow_abs_q[CLDFB_NO_CHANNELS_MAX]; Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; - Word16 energy_slow_e[CLDFB_NO_CHANNELS_MAX]; Word16 i, j, k; Word32 tmp = 0; move32(); Word32 *p_tmp; const Word32 *p_tmp_c; - Word16 exp1, exp2, q_tmp; + Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; Word16 q_ene, q_intensity; /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ - set_zero_fx( intensity_slow, ( DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ) ); - set16_fx( intensity_slow_e, 0, ( DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ) ); + set_zero_fx( intensity_slow, i_mult( DIRAC_NUM_DIMS, CLDFB_NO_CHANNELS_MAX ) ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); set_zero_fx( energy_slow, CLDFB_NO_CHANNELS_MAX ); - set16_fx( energy_slow_e, 0, CLDFB_NO_CHANNELS_MAX ); + + /* Calculate max possible shift for the buffer buffer_energy and buffer_intensity */ + min_q_shift1 = Q31; + move16(); + min_q_shift1 = s_min( min_q_shift1, getScaleFactor32( buffer_energy, i_mult( DIRAC_NO_COL_AVG_DIFF, num_freq_bands ) ) ); + min_q_shift1 = sub( min_q_shift1, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); + + min_q_shift2 = Q31; + move16(); + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) + { + min_q_shift2 = s_min( min_q_shift2, getScaleFactor32( buffer_intensity[i][j], num_freq_bands ) ); + } + } + min_q_shift2 = sub( min_q_shift2, find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ) ); + + q_ene = add( q_factor_energy[0], min_q_shift1 ); + move16(); + q_intensity = add( q_factor_intensity[0], min_q_shift2 ); + move16(); FOR( i = 0; i < DIRAC_NO_COL_AVG_DIFF; ++i ) { /* Energy slow */ p_tmp_c = buffer_energy + i * num_freq_bands; + q_tmp = add( q_factor_energy[i], min_q_shift1 ); + + + Word16 shift_q = sub( q_tmp, q_ene ); + Word32 shiftEquiv = L_add( 0, 0 ); + Word16 shift_qtotal; + if ( shift_q < 0 ) + { + shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); + } + if ( shift_q >= 0 ) + { + shiftEquiv = L_add( 0x7FFFFFFF, 0 ); + } + shift_qtotal = sub( min_q_shift1, s_max( shift_q, 0 ) ); + FOR( k = 0; k < num_freq_bands; k++ ) { - energy_slow[k] = BASOP_Util_Add_Mant32Exp( p_tmp_c[k], sub( 31, q_factor_energy[i] ), energy_slow[k], energy_slow_e[k], &energy_slow_e[k] ); + tmp = L_shl( p_tmp_c[k], shift_qtotal ); + energy_slow[k] = Madd_32_32_r( tmp, energy_slow[k], shiftEquiv ); move32(); } + + q_ene = s_min( q_ene, q_tmp ); + + /* Intensity slow */ + q_tmp = add( q_factor_intensity[i], min_q_shift2 ); + + shift_q = sub( q_tmp, q_intensity ); + if ( shift_q < 0 ) + { + shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q ); + } + if ( shift_q >= 0 ) + { + shiftEquiv = L_lshl( 0x7FFFFFFF, 0 ); + } + shift_qtotal = sub( min_q_shift2, s_max( shift_q, 0 ) ); + FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = buffer_intensity[j][i]; FOR( k = 0; k < num_freq_bands; k++ ) { - intensity_slow[j * num_freq_bands + k] = BASOP_Util_Add_Mant32Exp( p_tmp[k], sub( 31, q_factor_intensity[i] ), intensity_slow[j * num_freq_bands + k], intensity_slow_e[j * num_freq_bands + k], &intensity_slow_e[j * num_freq_bands + k] ); + tmp = L_shl( p_tmp[k], shift_qtotal ); + intensity_slow[j * num_freq_bands + k] = Madd_32_32_r( tmp, intensity_slow[j * num_freq_bands + k], shiftEquiv ); move32(); } } - } - Word16 max_e; - maximum_fx( energy_slow_e, CLDFB_NO_CHANNELS_MAX, &max_e ); - q_ene = sub( 31, max_e ); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - energy_slow[i] = L_shr( energy_slow[i], sub( max_e, energy_slow_e[i] ) ); // scaling to q_ene - move32(); - } - maximum_fx( intensity_slow_e, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX, &max_e ); - q_intensity = sub( 31, max_e ); - FOR( i = 0; i < DIRAC_NUM_DIMS * num_freq_bands; i++ ) - { - intensity_slow[i] = L_shr( intensity_slow[i], sub( max_e, intensity_slow_e[i] ) ); // scaling to q_intensity - move32(); + q_intensity = s_min( q_intensity, q_tmp ); } + min_q_shift1 = getScaleFactor32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ) ); + min_q_shift1 = sub( min_q_shift1, idiv1616( add( find_guarded_bits_fx( DIRAC_NUM_DIMS ), 1 ), 2 ) ); + scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), min_q_shift1 ); + q_intensity = add( q_intensity, min_q_shift1 ); FOR( k = 0; k < num_freq_bands; k++ ) { intensity_slow_abs_64[k] = 0; -- GitLab From c4b66eb562a52bc61ab05709762498b29d6ca12f Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:25:35 +0200 Subject: [PATCH 317/394] test listing pipelines --- .gitlab-ci.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c75ef140..e625b1844 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,6 +66,9 @@ workflow: variables: IVAS_PIPELINE_NAME: 'Renderer framesize BE test on $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' + variables: + IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' || $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' variables: IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch @@ -1634,6 +1637,29 @@ voip-be-on-merge-request: - make -j >> /dev/null - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py +long-term-job-logs: + rules: + -if $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + stage: test + timeout: "20 minutes" + script: + - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" + + #- id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH $CI_JOB_NAME $CI_PROJECT_ID) + #- echo "Job ID from variables - $CI_JOB_ID, Job ID from script - $id_previous" + #- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + #- unzip artifacts.zip -d previous_artifacts + # This wildcard thingy relies on only one csv file being present per job + #- file_previous="previous_artifacts/mld--$CI_JOB_NAME-$id_previous--sha-*.csv" + #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME + - TODAY=$(date +'%Y-%m-%d') + # create log if it doesn't exist + - mkdir -p logs/$TODAY + - ls + - ls logs + + + # --------------------------------------------------------------- # Complexity measurement jobs -- GitLab From a0de38f21270ec1b45bf86f8d6196524da7cb539 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:26:37 +0200 Subject: [PATCH 318/394] fix syntax error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e625b1844..2b22701b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1639,7 +1639,7 @@ voip-be-on-merge-request: long-term-job-logs: rules: - -if $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + -if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job stage: test timeout: "20 minutes" script: -- GitLab From 3ea49bd8223b4ac925d840acea9efe700e25b949 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:28:51 +0200 Subject: [PATCH 319/394] fix syntax error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b22701b8..11866fffa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1639,7 +1639,7 @@ voip-be-on-merge-request: long-term-job-logs: rules: - -if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job stage: test timeout: "20 minutes" script: -- GitLab From dac810a8af51c3f4f660248d5639d88c87ec17eb Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:34:50 +0200 Subject: [PATCH 320/394] fix manual pipeline name --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 11866fffa..9acab3d8a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,11 +66,11 @@ workflow: variables: IVAS_PIPELINE_NAME: 'Renderer framesize BE test on $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' - variables: - IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' || $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' variables: IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' + variables: + IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch variables: IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' -- GitLab From f9a46a42fb0a63916ddc7e9f17f6c90699407114 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:39:29 +0200 Subject: [PATCH 321/394] update gitlab.yaml --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9acab3d8a..56716ba09 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'default' # for testing variables: IVAS_PIPELINE_NAME: 'Web run pipeline: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' + variables: + IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref: $CI_COMMIT_BRANCH' @@ -68,9 +71,6 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'peaq-enc-passthrough' variables: IVAS_PIPELINE_NAME: 'PEAQ encoder pass-through test: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' - variables: - IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch variables: IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' -- GitLab From 3fb306c27c3825339dfd3c99c8c47e76d148dab3 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 11:42:15 +0200 Subject: [PATCH 322/394] make job a manual job --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56716ba09..a8b50ac69 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1640,6 +1640,7 @@ voip-be-on-merge-request: long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + when: manual stage: test timeout: "20 minutes" script: -- GitLab From e7f91d3ceb7d03b36501b4c77526786896595325 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 12:44:56 +0200 Subject: [PATCH 323/394] add variable for new manual job --- .gitlab-ci/variables.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index d91866b86..a804cdddb 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -65,3 +65,4 @@ variables: - 'voip-be-test' - 'renderer-framesize-be' - 'peaq-enc-passthrough' + - 'long-term-logs' -- GitLab From 25089d410d39083104e7033d1b3704297156a6e2 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Wed, 9 Jul 2025 12:47:25 +0200 Subject: [PATCH 324/394] move job to '.pre' stage --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8b50ac69..9fc0b5e89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1640,8 +1640,7 @@ voip-be-on-merge-request: long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job - when: manual - stage: test + stage: .pre timeout: "20 minutes" script: - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" -- GitLab From a3c5954bb23bc5fc8b36beafcd72ecc1e59cafc3 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 9 Jul 2025 13:44:21 +0200 Subject: [PATCH 325/394] address comment on macro --- lib_dec/ivas_spar_md_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 72d5e6599..fdb29e842 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -45,7 +45,7 @@ * Local constants *------------------------------------------------------------------------------------------*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC -#define INV_PI_DEG180_Q_22 ( (Word32) 0x394BB835 ) /* 2.0/PI in Q31 times DEGREE_180_Q_22) */ +#define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */ #endif #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) @@ -2964,7 +2964,7 @@ void ivas_spar_to_dirac_fx( Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC - Word32 azi_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_azi_fx ); + Word32 azi_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_azi_fx ); #else Word16 check_azi_fx_res; Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/ @@ -2994,7 +2994,7 @@ void ivas_spar_to_dirac_fx( Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/ #ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC - Word32 ele_intermediate = Mpy_32_16_1( INV_PI_DEG180_Q_22, check_ele_fx ); + Word32 ele_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_ele_fx ); #else Word16 check_ele_fx_res; -- GitLab From 16945411451710c9dfa86c5d1ddfff94d6571197 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 9 Jul 2025 14:46:29 +0530 Subject: [PATCH 326/394] Decoder USAN error fix --- lib_com/cnst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 53032d5ae..a01f447d4 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -134,7 +134,7 @@ #define ONE_IN_Q29 536870912 #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 0x80000000 +#define MINUS_ONE_IN_Q31 -2147483647 - 1 #define TWO_IN_Q29 1073741824 #define FOUR_IN_Q28 1073741824 -- GitLab From e2c6c0ab96a85b9e7e1d8bf48c89ad7a138de4f6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 9 Jul 2025 17:28:09 +0530 Subject: [PATCH 327/394] Parenthesis for the macro added --- lib_com/cnst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index a01f447d4..8faa2cb57 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -134,7 +134,7 @@ #define ONE_IN_Q29 536870912 #define ONE_IN_Q30 1073741824 #define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 -2147483647 - 1 +#define MINUS_ONE_IN_Q31 (-2147483647 - 1) #define TWO_IN_Q29 1073741824 #define FOUR_IN_Q28 1073741824 -- GitLab From 80291602cf05440541e91bb913be0b02eb1e8d30 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 10 Jul 2025 12:12:53 +0530 Subject: [PATCH 328/394] Fix for 3GPP issue 1812: LTV assertion: Issue #1348 regression in +10dB decoder test Link #1812 Increased guard bits for stereo dft to avoid overflow --- lib_dec/ivas_cpe_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index d4c041e97..6e29c2ac9 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -652,7 +652,7 @@ ivas_error ivas_cpe_dec_fx( IF( NE_16( shift, 31 ) ) { - shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q15 ); /* Q15 for guard bits */ + shift = sub( add( hCPE->hStereoDft->q_dft, shift ), Q16 ); /* Q16 for guard bits */ IF( GT_16( shift, hCPE->hStereoDft->q_dft ) ) { -- GitLab From 8909e61337f847fdf63cf529da7a99b6ee9af523 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 09:21:00 +0200 Subject: [PATCH 329/394] test getting the artifacts from ivas-pytest-compare_ref-long-enc --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9fc0b5e89..f1ca84740 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1645,16 +1645,18 @@ long-term-job-logs: script: - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" - #- id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH $CI_JOB_NAME $CI_PROJECT_ID) - #- echo "Job ID from variables - $CI_JOB_ID, Job ID from script - $id_previous" + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) + - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" #- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - #- unzip artifacts.zip -d previous_artifacts + - unzip artifacts.zip -d previous_artifacts # This wildcard thingy relies on only one csv file being present per job - #- file_previous="previous_artifacts/mld--$CI_JOB_NAME-$id_previous--sha-*.csv" + - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" + - echo $ivas-pytest-compare_ref-long-enc_csv #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME - TODAY=$(date +'%Y-%m-%d') # create log if it doesn't exist - mkdir -p logs/$TODAY + - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY - ls - ls logs -- GitLab From a59209c78adb7111e9e11e95d8d0154388102d3e Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 09:33:36 +0200 Subject: [PATCH 330/394] use anchor for long-term-job-.logs job --- .gitlab-ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1ca84740..d9987e7b1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -293,6 +293,25 @@ workflow: - touch $MERGED_CSV_ARTIFACT_NAME - fi + # Aggregate job logs + - if [ $GET_LOGS -eq 1 ]; then + - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" + + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) + - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" + #- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip -d previous_artifacts + # This wildcard thingy relies on only one csv file being present per job + - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" + - echo $ivas-pytest-compare_ref-long-enc_csv + #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME + - TODAY=$(date +'%Y-%m-%d') + # create log if it doesn't exist + - mkdir -p logs/$TODAY + - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY + - ls + - fi + - if [ $zero_errors != 1 ]; then - echo "Run errors encountered!" # TODO: temporary only to not fail MR pipelines on crashes @@ -1637,6 +1656,23 @@ voip-be-on-merge-request: - make -j >> /dev/null - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py + +ivas-long-term-job-logs: + extends: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + tags: + - ivas-linux + timeout: "20 minutes" + stage: .pre + before_script: + - USE_LTV=1 + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + - SPLIT_COMPARISON="false" + - GET_LOGS=1 + <<: *ivas-pytest-anchor + long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job -- GitLab From b4255d5dc6c7c71a830d305f86513f3747970fa0 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 09:35:57 +0200 Subject: [PATCH 331/394] fix syntax err --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9987e7b1..87089e6d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1658,7 +1658,7 @@ voip-be-on-merge-request: ivas-long-term-job-logs: - extends: + rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job tags: - ivas-linux -- GitLab From 92a8417c101de494f0292f35e8d99435c878db89 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 09:41:43 +0200 Subject: [PATCH 332/394] remove job from .pre stage --- .gitlab-ci.yml | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 87089e6d3..50cee1d4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -295,11 +295,10 @@ workflow: # Aggregate job logs - if [ $GET_LOGS -eq 1 ]; then - - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" - #- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts # This wildcard thingy relies on only one csv file being present per job - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" @@ -1662,8 +1661,6 @@ ivas-long-term-job-logs: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job tags: - ivas-linux - timeout: "20 minutes" - stage: .pre before_script: - USE_LTV=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1673,29 +1670,6 @@ ivas-long-term-job-logs: - GET_LOGS=1 <<: *ivas-pytest-anchor -long-term-job-logs: - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job - stage: .pre - timeout: "20 minutes" - script: - - curl --request GET "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines" - - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) - - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" - #- curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" - - echo $ivas-pytest-compare_ref-long-enc_csv - #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME - - TODAY=$(date +'%Y-%m-%d') - # create log if it doesn't exist - - mkdir -p logs/$TODAY - - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY - - ls - - ls logs - -- GitLab From a44322cc44d1ebd90f4801d8a1432b67bd46a816 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 09:57:46 +0200 Subject: [PATCH 333/394] remove job from anchor and to .pre stage --- .gitlab-ci.yml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 50cee1d4d..777364efa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1661,6 +1661,8 @@ ivas-long-term-job-logs: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job tags: - ivas-linux + stage: .pre + timeout: "20 minutes" before_script: - USE_LTV=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1668,7 +1670,65 @@ ivas-long-term-job-logs: - LEVEL_SCALING=1.0 - SPLIT_COMPARISON="false" - GET_LOGS=1 - <<: *ivas-pytest-anchor + variables: + # keep "mld" in artifact name for backwards compatibility reasons + CSV_ARTIFACT_NAME: "mld--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv" + CSV_ARTIFACT_SPLIT: "mld--split--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv" + MERGED_CSV_ARTIFACT_NAME: "$CI_JOB_NAME--merged_csv--$CI_JOB_ID.csv" + PAGES_HTML_ARTIFACT_NAME: "$CI_JOB_NAME-index.html" + SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" + SUMMARY_HTML_ARTIFACT_SPLIT: "summary_split_$CI_JOB_NAME.html" + IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" + IMAGES_ARTIFACT_SPLIT: "images_split_$CI_JOB_NAME" + script: + - !reference [ .job-linux, before_script ] + + - set -euxo pipefail + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + - if [ $USE_LTV -eq 1 ]; then + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh + - testcase_timeout=$TESTCASE_TIMEOUT_LTV + - else + - testcase_timeout=$TESTCASE_TIMEOUT_STV + - fi + + # Aggregate job logs + - if [ $GET_LOGS -eq 1 ]; then + + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) + - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" + - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip -d previous_artifacts + # This wildcard thingy relies on only one csv file being present per job + - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" + - echo $ivas-pytest-compare_ref-long-enc_csv + #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME + - TODAY=$(date +'%Y-%m-%d') + # create log if it doesn't exist + - mkdir -p logs/$TODAY + - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY + - ls + - fi + - exit 0 + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" + expire_in: 1 week + when: always + paths: + #- report-junit.xml + #- report.html + - logs + expose_as: "ivas long term job logs results" + #reports: + # junit: + # - report-junit.xml + -- GitLab From b0bdb717cde913e7b2df0b1d9349171d967b2f94 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 10:07:32 +0200 Subject: [PATCH 334/394] add missing $ --- .gitlab-ci.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 777364efa..9b573bd6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -293,24 +293,6 @@ workflow: - touch $MERGED_CSV_ARTIFACT_NAME - fi - # Aggregate job logs - - if [ $GET_LOGS -eq 1 ]; then - - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) - - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" - - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" - - echo $ivas-pytest-compare_ref-long-enc_csv - #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME - - TODAY=$(date +'%Y-%m-%d') - # create log if it doesn't exist - - mkdir -p logs/$TODAY - - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY - - ls - - fi - - if [ $zero_errors != 1 ]; then - echo "Run errors encountered!" # TODO: temporary only to not fail MR pipelines on crashes @@ -1708,7 +1690,7 @@ ivas-long-term-job-logs: - TODAY=$(date +'%Y-%m-%d') # create log if it doesn't exist - mkdir -p logs/$TODAY - - mv ivas-pytest-compare_ref-long-enc_csv logs/$TODAY + - mv $ivas-pytest-compare_ref-long-enc_csv logs/$TODAY - ls - fi - exit 0 -- GitLab From c4e98f13ca70124936cb71143006b9d85bbfa63d Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 10:12:14 +0200 Subject: [PATCH 335/394] Update file .gitlab-ci.yml --- .gitlab-ci.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b573bd6a..d8f3332e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1683,14 +1683,11 @@ ivas-long-term-job-logs: - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - - ivas-pytest-compare_ref-long-enc_csv="previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv" - - echo $ivas-pytest-compare_ref-long-enc_csv - #- python3 ci/basop-pages/create_report_pages.py $PAGES_HTML_ARTIFACT_NAME $MERGED_CSV_ARTIFACT_NAME $CSV_ARTIFACT_NAME $file_previous $CI_JOB_ID $id_previous $CI_JOB_NAME - TODAY=$(date +'%Y-%m-%d') - # create log if it doesn't exist + # create logs dir if it doesn't exist - mkdir -p logs/$TODAY - - mv $ivas-pytest-compare_ref-long-enc_csv logs/$TODAY + # This wildcard thingy relies on only one csv file being present per job + - mv previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv logs/$TODAY - ls - fi - exit 0 -- GitLab From 4081cea23ff04534e074610453edc717323d4092 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 10:54:14 +0200 Subject: [PATCH 336/394] test getting logs for all relevant jobs --- .gitlab-ci.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8f3332e8..a550027f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1677,19 +1677,21 @@ ivas-long-term-job-logs: - fi # Aggregate job logs - - if [ $GET_LOGS -eq 1 ]; then - - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-pytest-compare_ref-long-enc $CI_PROJECT_ID) - - echo "Job ID from variables - ivas-pytest-compare_ref-long-enc, Job ID from script - $id_previous" - - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip -d previous_artifacts - - TODAY=$(date +'%Y-%m-%d') - # create logs dir if it doesn't exist - - mkdir -p logs/$TODAY - # This wildcard thingy relies on only one csv file being present per job - - mv previous_artifacts/mld--ivas-pytest-compare_ref-long-enc-$id_previous--sha-*.csv logs/$TODAY - - ls - - fi + - | + job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") + for job in "${job[@]}"; do + echo "Getting job logs for: $job" + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job" $CI_PROJECT_ID) + - echo "Job ID from variables - "$job", Job ID from script - $id_previous" + - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip -d previous_artifacts + - TODAY=$(date +'%Y-%m-%d') + # create logs dir if it doesn't exist + - mkdir -p logs/$TODAY + # This wildcard thingy relies on only one csv file being present per job + - mv previous_artifacts/mld--"$job"-$id_previous--sha-*.csv logs/$TODAY + done + - ls logs - exit 0 allow_failure: -- GitLab From fe1e1413c2532cb0bc22aa778653584ebc6276be Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:04:11 +0200 Subject: [PATCH 337/394] fix yaml syntax --- .gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a550027f0..ffe70e261 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1679,17 +1679,19 @@ ivas-long-term-job-logs: # Aggregate job logs - | job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") - for job in "${job[@]}"; do + for job_name in "${job[@]}"; do echo "Getting job logs for: $job" - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job" $CI_PROJECT_ID) - - echo "Job ID from variables - "$job", Job ID from script - $id_previous" + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) + - echo "Job ID from variables - "$job_name", Job ID from script -d $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts - TODAY=$(date +'%Y-%m-%d') # create logs dir if it doesn't exist - mkdir -p logs/$TODAY # This wildcard thingy relies on only one csv file being present per job - - mv previous_artifacts/mld--"$job"-$id_previous--sha-*.csv logs/$TODAY + - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY + - rm artifacts.zip + - rm -r previous_artifacts done - ls logs - exit 0 -- GitLab From 08b51ee7d15dffdd6aa5500bfce3c707747e08a3 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:09:24 +0200 Subject: [PATCH 338/394] fix syntax error --- .gitlab-ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ffe70e261..d1893dbf6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1681,17 +1681,17 @@ ivas-long-term-job-logs: job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") for job_name in "${job[@]}"; do echo "Getting job logs for: $job" - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) - - echo "Job ID from variables - "$job_name", Job ID from script -d $id_previous" - - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip -d previous_artifacts - - TODAY=$(date +'%Y-%m-%d') + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) + echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + unzip artifacts.zip -d previous_artifacts + TODAY=$(date +'%Y-%m-%d') # create logs dir if it doesn't exist - - mkdir -p logs/$TODAY + mkdir -p logs/$TODAY # This wildcard thingy relies on only one csv file being present per job - - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY - - rm artifacts.zip - - rm -r previous_artifacts + mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY + rm artifacts.zip + rm -r previous_artifacts done - ls logs - exit 0 -- GitLab From 32acfa9a148e29b1eef60c7d1e58924d448bf4f8 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:21:04 +0200 Subject: [PATCH 339/394] cleanup --- .gitlab-ci.yml | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1893dbf6..548dd6020 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1640,41 +1640,21 @@ voip-be-on-merge-request: ivas-long-term-job-logs: rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" # change this to a scheduled job + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" + - if: $CI_PIPELINE_SOURCE == 'schedule' tags: - ivas-linux stage: .pre - timeout: "20 minutes" - before_script: - - USE_LTV=1 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - - SPLIT_COMPARISON="false" - - GET_LOGS=1 - variables: - # keep "mld" in artifact name for backwards compatibility reasons - CSV_ARTIFACT_NAME: "mld--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv" - CSV_ARTIFACT_SPLIT: "mld--split--$CI_JOB_NAME-$CI_JOB_ID--sha-$CI_COMMIT_SHORT_SHA.csv" - MERGED_CSV_ARTIFACT_NAME: "$CI_JOB_NAME--merged_csv--$CI_JOB_ID.csv" - PAGES_HTML_ARTIFACT_NAME: "$CI_JOB_NAME-index.html" - SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" - SUMMARY_HTML_ARTIFACT_SPLIT: "summary_split_$CI_JOB_NAME.html" - IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" - IMAGES_ARTIFACT_SPLIT: "images_split_$CI_JOB_NAME" + timeout: "10 minutes" script: - - !reference [ .job-linux, before_script ] - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - if [ $USE_LTV -eq 1 ]; then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - - testcase_timeout=$TESTCASE_TIMEOUT_LTV - - else - - testcase_timeout=$TESTCASE_TIMEOUT_STV - - fi + + # create logs dir if it doesn't exist + - TODAY=$(date +'%Y-%m-%d') + - mkdir -p logs/$TODAY # Aggregate job logs - | @@ -1685,9 +1665,6 @@ ivas-long-term-job-logs: echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip unzip artifacts.zip -d previous_artifacts - TODAY=$(date +'%Y-%m-%d') - # create logs dir if it doesn't exist - mkdir -p logs/$TODAY # This wildcard thingy relies on only one csv file being present per job mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY rm artifacts.zip @@ -1704,13 +1681,8 @@ ivas-long-term-job-logs: expire_in: 1 week when: always paths: - #- report-junit.xml - #- report.html - logs expose_as: "ivas long term job logs results" - #reports: - # junit: - # - report-junit.xml -- GitLab From 79020ccbfdcbd5a52a1e27dfe7a3138247c77bf8 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:27:54 +0200 Subject: [PATCH 340/394] add missing scripts --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 548dd6020..d6c55e359 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1651,6 +1651,8 @@ ivas-long-term-job-logs: - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh # create logs dir if it doesn't exist - TODAY=$(date +'%Y-%m-%d') -- GitLab From 7c871709590308efbfc82eeb73e12b66727e1f51 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:35:50 +0200 Subject: [PATCH 341/394] add missing !ireference --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6c55e359..85d5f89b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1647,7 +1647,7 @@ ivas-long-term-job-logs: stage: .pre timeout: "10 minutes" script: - + - !reference [ .job-linux, before_script ] - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh -- GitLab From 7099af40c170eacca4fe86b3794a57100e69f3ab Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 11:55:39 +0200 Subject: [PATCH 342/394] get previous logs from same job --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 85d5f89b7..248ca3714 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1658,6 +1658,15 @@ ivas-long-term-job-logs: - TODAY=$(date +'%Y-%m-%d') - mkdir -p logs/$TODAY + # Get previous logs of this job incase we are running on a different machine + - rm logs + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip -d logs + + - ls logs + # Aggregate job logs - | job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") -- GitLab From f668c0a83664df9f133437f08bbdb841704780f5 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:11:36 +0200 Subject: [PATCH 343/394] remove dir --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 248ca3714..0e888abfb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1659,7 +1659,7 @@ ivas-long-term-job-logs: - mkdir -p logs/$TODAY # Get previous logs of this job incase we are running on a different machine - - rm logs + - rm -r logs - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip -- GitLab From 913b344955374fe12b0550c9cec60571d71e37c4 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:21:22 +0200 Subject: [PATCH 344/394] increase timeout --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e888abfb..a4d1bd5f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1645,9 +1645,9 @@ ivas-long-term-job-logs: tags: - ivas-linux stage: .pre - timeout: "10 minutes" + timeout: "20 minutes" script: - - !reference [ .job-linux, before_script ] + - !reference [ before_script ] - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh -- GitLab From 879aa7049d5ad5285ac950f3c41f5ba75e655345 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:23:22 +0200 Subject: [PATCH 345/394] Update file .gitlab-ci.yml --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4d1bd5f6..8ae2d1a4d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1642,12 +1642,10 @@ ivas-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" - if: $CI_PIPELINE_SOURCE == 'schedule' - tags: - - ivas-linux stage: .pre timeout: "20 minutes" script: - - !reference [ before_script ] + - !reference [ .job-linux, before_script ] - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh -- GitLab From 06e002e4fe6e39974c2f546fb888380ef5dd3a9e Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:45:33 +0200 Subject: [PATCH 346/394] add tag: ivas-basop-linux --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ae2d1a4d..bf04ea397 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1642,6 +1642,8 @@ ivas-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" - if: $CI_PIPELINE_SOURCE == 'schedule' + tags: + - ivas-basop-linux stage: .pre timeout: "20 minutes" script: -- GitLab From c81b37149b8e560982771df26badf23f4d230783 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:50:40 +0200 Subject: [PATCH 347/394] Update file .gitlab-ci.yml --- .gitlab-ci.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bf04ea397..d28bf878e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1654,10 +1654,6 @@ ivas-long-term-job-logs: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - # create logs dir if it doesn't exist - - TODAY=$(date +'%Y-%m-%d') - - mkdir -p logs/$TODAY - # Get previous logs of this job incase we are running on a different machine - rm -r logs - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) @@ -1667,6 +1663,10 @@ ivas-long-term-job-logs: - ls logs + # create logs dir if it doesn't exist + - TODAY=$(date +'%Y-%m-%d') + - mkdir -p logs/$TODAY + # Aggregate job logs - | job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") @@ -1698,7 +1698,6 @@ ivas-long-term-job-logs: - # --------------------------------------------------------------- # Complexity measurement jobs # --------------------------------------------------------------- -- GitLab From 5601670a5e8df4683d16d0a478e164d1b2e662b8 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:54:10 +0200 Subject: [PATCH 348/394] fix syntax err --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d28bf878e..80cf582ba 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1655,7 +1655,7 @@ ivas-long-term-job-logs: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh # Get previous logs of this job incase we are running on a different machine - - rm -r logs + - if [ -d "logs" ]; then rm -rf "logs"; fi - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip -- GitLab From b8541b1c844eda50cb5a3d9f70180b5b5535add7 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Thu, 10 Jul 2025 13:57:28 +0200 Subject: [PATCH 349/394] bug fix causing job not to be found --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 80cf582ba..1e5d3266d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1657,7 +1657,7 @@ ivas-long-term-job-logs: # Get previous logs of this job incase we are running on a different machine - if [ -d "logs" ]; then rm -rf "logs"; fi - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d logs -- GitLab From 1b8cb94b95a4238bd4cf61c35b642cbc39264dab Mon Sep 17 00:00:00 2001 From: kinuthia Date: Fri, 11 Jul 2025 10:06:40 +0200 Subject: [PATCH 350/394] handle case when job is running for the first time --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e5d3266d..2c190366b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1645,7 +1645,7 @@ ivas-long-term-job-logs: tags: - ivas-basop-linux stage: .pre - timeout: "20 minutes" + timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] - set -euxo pipefail @@ -1656,10 +1656,16 @@ ivas-long-term-job-logs: # Get previous logs of this job incase we are running on a different machine - if [ -d "logs" ]; then rm -rf "logs"; fi + # TODO add variable to inject logs from backup copy + + # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip -d logs + - + - if [ "$id_previous" != "-1" ]; then + - unzip artifacts.zip -d logs + - fi - ls logs @@ -1689,7 +1695,7 @@ ivas-long-term-job-logs: - 123 artifacts: name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - expire_in: 1 week + expire_in: 4 weeks when: always paths: - logs -- GitLab From 836bdf5093bec7a78f0c6af3f53dfa36fcc45c13 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Fri, 11 Jul 2025 10:12:14 +0200 Subject: [PATCH 351/394] correct formatting --- .gitlab-ci.yml | 68 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c190366b..79a8a62d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1646,49 +1646,49 @@ ivas-long-term-job-logs: - ivas-basop-linux stage: .pre timeout: "25 minutes" - script: - - !reference [ .job-linux, before_script ] - - set -euxo pipefail - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh + script: | + !reference [ .job-linux, before_script ] + set -euxo pipefail + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh # Get previous logs of this job incase we are running on a different machine - - if [ -d "logs" ]; then rm -rf "logs"; fi + if [ -d "logs" ]; then rm -rf "logs"; fi # TODO add variable to inject logs from backup copy # handle case where the job is running for the first time. e.g where the job was not found. - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - - - if [ "$id_previous" != "-1" ]; then - - unzip artifacts.zip -d logs - - fi + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" + curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + + if [ "$id_previous" != "-1" ]; then + unzip artifacts.zip -d logs + fi - - ls logs + ls logs - # create logs dir if it doesn't exist - - TODAY=$(date +'%Y-%m-%d') - - mkdir -p logs/$TODAY + # create logs dir if it doesn't exist + TODAY=$(date +'%Y-%m-%d') + mkdir -p logs/$TODAY # Aggregate job logs - - | - job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") - for job_name in "${job[@]}"; do - echo "Getting job logs for: $job" - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY - rm artifacts.zip - rm -r previous_artifacts - done - - ls logs - - exit 0 + + job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") + for job_name in "${job[@]}"; do + echo "Getting job logs for: $job" + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) + echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + unzip artifacts.zip -d previous_artifacts + # This wildcard thingy relies on only one csv file being present per job + mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY + rm artifacts.zip + rm -r previous_artifacts + done + ls logs + exit 0 allow_failure: exit_codes: -- GitLab From 624f2269a1dd6a3e4f2948771f547b039d3073ee Mon Sep 17 00:00:00 2001 From: kinuthia Date: Fri, 11 Jul 2025 10:15:52 +0200 Subject: [PATCH 352/394] fix syntax --- .gitlab-ci.yml | 85 +++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79a8a62d6..e70b75be9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1646,49 +1646,50 @@ ivas-long-term-job-logs: - ivas-basop-linux stage: .pre timeout: "25 minutes" - script: | - !reference [ .job-linux, before_script ] - set -euxo pipefail - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - - # Get previous logs of this job incase we are running on a different machine - if [ -d "logs" ]; then rm -rf "logs"; fi - # TODO add variable to inject logs from backup copy - - # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - if [ "$id_previous" != "-1" ]; then - unzip artifacts.zip -d logs - fi - - ls logs - - # create logs dir if it doesn't exist - TODAY=$(date +'%Y-%m-%d') - mkdir -p logs/$TODAY - - # Aggregate job logs - - job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") - for job_name in "${job[@]}"; do - echo "Getting job logs for: $job" - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + script: + - !reference [ .job-linux, before_script ] + - | + set -euxo pipefail + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh + + # Get previous logs of this job incase we are running on a different machine + if [ -d "logs" ]; then rm -rf "logs"; fi + # TODO add variable to inject logs from backup copy + + # handle case where the job is running for the first time. e.g where the job was not found. + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY - rm artifacts.zip - rm -r previous_artifacts - done - ls logs - exit 0 + + if [ "$id_previous" != "-1" ]; then + unzip artifacts.zip -d logs + fi + + ls logs + + # create logs dir if it doesn't exist + TODAY=$(date +'%Y-%m-%d') + mkdir -p logs/$TODAY + + # Aggregate job logs + + job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") + for job_name in "${job[@]}"; do + echo "Getting job logs for: $job" + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) + echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + unzip artifacts.zip -d previous_artifacts + # This wildcard thingy relies on only one csv file being present per job + mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY + rm artifacts.zip + rm -r previous_artifacts + done + ls logs + exit 0 allow_failure: exit_codes: -- GitLab From 6e5b690fca8649c9702c320c3d96c1b60359b546 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Fri, 11 Jul 2025 10:26:48 +0200 Subject: [PATCH 353/394] Update file .gitlab-ci.yml --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e70b75be9..173d604fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1668,8 +1668,6 @@ ivas-long-term-job-logs: unzip artifacts.zip -d logs fi - ls logs - # create logs dir if it doesn't exist TODAY=$(date +'%Y-%m-%d') mkdir -p logs/$TODAY -- GitLab From bf63482dd045da53b37ec8ada669d9f65400e0d8 Mon Sep 17 00:00:00 2001 From: kinuthia Date: Fri, 11 Jul 2025 10:42:48 +0200 Subject: [PATCH 354/394] require MANUAL_PIPELINE_TYPE to be set when running scheduled job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 173d604fc..7a0c0f324 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1641,7 +1641,7 @@ voip-be-on-merge-request: ivas-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" - - if: $CI_PIPELINE_SOURCE == 'schedule' + - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "long-term-logs" tags: - ivas-basop-linux stage: .pre -- GitLab From 9daf8e10191a7e445d3fe6e60b9240a665846aa1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 11 Jul 2025 10:52:47 +0200 Subject: [PATCH 355/394] replace i_mult_o() --- lib_com/options.h | 8 ++++++++ lib_dec/swb_tbe_dec_fx.c | 10 +++++++++- lib_enc/swb_tbe_enc_fx.c | 12 ++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0cf958d03..c555d9cff 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,6 +120,14 @@ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ #define FIX_ISSUE_1792 /* FhG: fix noise bursts in binaural rendering */ +/* Info for issue 1816: + * Some compilers do not automatically use 32 bit for 16x16bit products. The code "Word32 c = (Word16) a * (Word16) b;" creates then a 16-bit result, sign-extending the + * lower 16-bit of the product, any upper bits are omitted. Example: Product 0x0100 * 0x0100 results in 0x0001.0000, gets truncated to its lower bits and return 0x0000. + * The issue is fixed by simply casting one of the product operands to Word32 in lib_com/basop32.c + */ +#define FIX_ISSUE_1816_USE_W32_FOR_MPY_W16xW16 /* FhG: (QA-FIX) Use doubled data width for 16x16 product, some compilers keep 16-bit format also for products */ +#define FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION /* FhG: (NON-BE) improve precision of multiplications with factor 0.1f, avoids overflow with up-rounded value */ + #define FIX_ISSUE_1795_Q3_OVERFLOW /* FhG: Q3 overflow in function WB_BWE_gain_pred_fx (EVS legacy code) BE, MR1855 */ #define NONBE_FIX_1748_SPAR_DIV_OPT /*Dlb: issue 1748: SPAR common div optimizations*/ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 61dc3d0c5..35655a74b 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -2725,7 +2725,11 @@ void swb_tbe_dec_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + temp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#else temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#endif L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ temp = sub( 32767 /*1.0f Q15*/, temp ); Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); @@ -6287,7 +6291,11 @@ void ivas_swb_tbe_dec_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + temp_fx = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#else + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ +#endif L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index d016cd721..611a3625e 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -2537,7 +2537,11 @@ void swb_tbe_enc_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#else + tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ +#endif L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); @@ -3833,7 +3837,11 @@ void swb_tbe_enc_ivas_fx( } FOR( ; i < L_SHB_LAHEAD + 10; i++ ) { - tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ +#ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); +#else + tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ +#endif L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); -- GitLab From 4e41d8e1319d341278c61a9488c756d689f38a0c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 15:07:03 +0530 Subject: [PATCH 356/394] Multi channel bit-exact optimizations - 3 Residu3_fx, dotp_fixed_32, SQ_gain_estimate_stereo_fx, dotp_fixed_o, IGF_getCrest_new_fx updated. Around 4 WMOPs reduction observed --- lib_com/options.h | 1 + lib_com/residu_fx.c | 2 +- lib_com/tools.c | 8 ++++++++ lib_enc/igf_enc.c | 2 +- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 22 ++++++++++++++++++++-- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0cf958d03..23d8ca6d1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V2_BE #define OPT_MCH_DEC_V1_NBE #define OPT_MCT_ENC_48KB_NBE #define OPT_MCH_DEC_V1_BE diff --git a/lib_com/residu_fx.c b/lib_com/residu_fx.c index 32d18d1fe..91d0ee30a 100644 --- a/lib_com/residu_fx.c +++ b/lib_com/residu_fx.c @@ -156,7 +156,7 @@ void Residu3_fx( move16(); #endif q = add( norm_s( a[0] ), 1 ); - IF( shift != 0 ) + if ( shift != 0 ) { q = add( q, shift ); } diff --git a/lib_com/tools.c b/lib_com/tools.c index 3cf11ea92..0087920cd 100644 --- a/lib_com/tools.c +++ b/lib_com/tools.c @@ -688,7 +688,11 @@ Word32 dotp_fixed_o( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); @@ -718,7 +722,11 @@ Word32 dotp_fixed_32( move16(); test(); test(); +#ifdef OPT_MCT_ENC_V2_BE + FOR( ; ( suma > MAX_32 ) || ( suma < MIN_32 ) || ( *res_q > 31 ); ) +#else WHILE( GT_64( suma, MAX_32 ) || LT_64( suma, MIN_32 ) || GT_16( *res_q, 31 ) ) +#endif { suma = W_shr( suma, 1 ); *res_q = sub( *res_q, 1 ); diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index fe1ba10c1..7da9fa6cf 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -137,7 +137,7 @@ static Word16 IGF_getCrest_new_fx( move16(); x_eff = L_add( x_eff, L_mult0( x, x ) ); - IF( GT_16( x, x_max ) ) + if ( GT_16( x, x_max ) ) { x_max = x; move16(); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index 2f1b7d6c8..f7735e8df 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -882,7 +882,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } i = 0; move16(); @@ -901,7 +901,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res move32(); en_fx[q] = Mpy_32_16_1( L_add( L_shl( e_ener, Q25 ), en_fx[q] ), 9864 /* log10(2) in Q15 */ ); // Q(25) move32(); - i = add( i, 4 ); + i += 4; } /* SQ scale: 4 bits / 6 dB per quadruple */ @@ -911,6 +911,9 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res offset_fx = fac_fx; /* Q25 */ move32(); +#ifdef OPT_MCT_ENC_V2_BE + Word64 target_64_fx = W_shl( target_fx, 7 ); // Q25 +#endif /* find offset (0 to 128 dB with step of 0.125dB) */ FOR( iter = 0; iter < 10; iter++ ) { @@ -923,6 +926,20 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res { tmp_32 = L_sub( en_fx[i], offset_fx ); /* Q25 */ +#ifdef OPT_MCT_ENC_V2_BE + /* avoid SV with 1 bin of amp < 0.5f */ + if ( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) + { + W_tmp = W_add( W_tmp, tmp_32 ); /* Q25 */ + } + /* if ener is above target -> break and increase offset */ + IF( GT_64( W_tmp, target_64_fx ) ) + { + offset_fx = L_add( offset_fx, fac_fx ); /* Q25 */ + BREAK; + } +#else + /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp_32, 10066329 /*0.3 Q25*/ ) ) { @@ -935,6 +952,7 @@ static Word32 SQ_gain_estimate_stereo_fx( // e_res BREAK; } } +#endif } } -- GitLab From f3d2893fb20c3647145cb288dfabd3e0945d6f69 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 11 Jul 2025 12:09:51 +0200 Subject: [PATCH 357/394] keep EVS BE --- lib_dec/swb_tbe_dec_fx.c | 76 ++++++++++++++++++++++++++++++++++----- lib_enc/swb_tbe_enc_fx.c | 78 ++++++++++++++++++++++++++++++++++------ 2 files changed, 135 insertions(+), 19 deletions(-) diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 35655a74b..3ed08633c 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -2723,13 +2723,41 @@ void swb_tbe_dec_fx( exp = 0; move16(); } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { #ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION - temp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ + temp = sub( 32767 /*1.0f Q15*/, temp ); + Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ + temp = sub( 32767 /*1.0f Q15*/, temp ); + Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } #else + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { temp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#endif L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp ); /* Q31-exp */ temp = sub( 32767 /*1.0f Q15*/, temp ); Lscale = L_add( Mult_32_16( Lscale, temp ), L_tmp1 ); @@ -2737,6 +2765,7 @@ void swb_tbe_dec_fx( shaped_shb_excitation[i] = round_fx( L_shl( L_tmp, exp ) ); /* Q_bwe_exc */ move16(); } +#endif /* Update SHB excitation */ Copy( shaped_shb_excitation + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ @@ -6289,13 +6318,41 @@ void ivas_swb_tbe_dec_fx( exp = 0; move16(); } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { #ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION - temp_fx = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ + temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); + Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ + move16(); + } + } #else - temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ -#endif + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + temp_fx = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_sat( 1, sub( 31, exp ) ), temp_fx ); /* Q31-exp */ temp_fx = sub( 32767 /*1.0f Q15*/, temp_fx ); Lscale = L_add( Mult_32_16( Lscale, temp_fx ), L_tmp1 ); @@ -6303,6 +6360,7 @@ void ivas_swb_tbe_dec_fx( shaped_shb_excitation_fx[i] = round_fx_sat( L_shl_sat( L_tmp, exp ) ); /* Q_bwe_exc */ move16(); } +#endif } ELSE { diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 611a3625e..e1bbd3e19 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -2535,13 +2535,41 @@ void swb_tbe_enc_fx( exp = 0; move16(); } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { #ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION - tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( Lscale, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } #else - tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ -#endif + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); Lscale = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); @@ -2549,6 +2577,7 @@ void swb_tbe_enc_fx( shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } +#endif /* Update SHB excitation */ Copy( shaped_shb_excitation_fx + L_FRAME16k, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD ); /* Q_bwe_exc */ @@ -3835,13 +3864,41 @@ void swb_tbe_enc_ivas_fx( exp = 0; move16(); } - FOR( ; i < L_SHB_LAHEAD + 10; i++ ) - { #ifdef FIX_ISSUE_1816_IMPROVE_MPY_ZERO_DOT_1_PRECISION - tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + /* + code for EVS and IVAS are basically identical with the exception of i_mult_sat() which has precision issues + thus is was replaced for IVAS and kept for EVS, in order to keep EVS BE to test sequences and legacy implementations + */ + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_sat( sub( i, 19 ), 3277 /*0.1f Q15*/ ); /* Q15 */ + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } + ELSE + { + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = round_fx_sat( L_shl( L_mult( 0x6666 /* 0.1 in Q12 */, shl( sub( i, 19 ), 11 ) ), 1 ) ); + L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ + tmp = sub( 32767 /*1.0f Q15*/, tmp ); + L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); + L_tmp = Mult_32_16( L_tmp, shaped_shb_excitation_fx[i] ); /* Q_bwe_exc + (31-exp) - 15 */ + shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ + move16(); + } + } #else - tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ -#endif + FOR( ; i < L_SHB_LAHEAD + 10; i++ ) + { + tmp = i_mult_o( sub( i, 19 ), 3277 /*0.1f Q15*/, &Overflow ); /* Q15 */ L_tmp1 = Mult_32_16( L_shl_o( 1, sub( 31, exp ), &Overflow ), tmp ); /* Q31-exp */ tmp = sub( 32767 /*1.0f Q15*/, tmp ); L_tmp = L_add( Mult_32_16( Lscale, tmp ), L_tmp1 ); @@ -3849,6 +3906,7 @@ void swb_tbe_enc_ivas_fx( shaped_shb_excitation_fx[i] = round_fx_o( L_shl_o( L_tmp, exp, &Overflow ), &Overflow ); /* Q_bwe_exc */ move16(); } +#endif } ELSE { -- GitLab From 6c5ed9f1374b32878c9048594128b303e15f959a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 16:13:03 +0530 Subject: [PATCH 358/394] Optimization in ISM Dec path - Non bit exact --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_hrFilt_fx.c | 121 ++++++++++++++++++++++- lib_rend/ivas_objectRenderer_sfx_fx.c | 46 ++++++++- 3 files changed, 163 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 23d8ca6d1..21d976fac 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,6 +81,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCT_ENC_V2_BE #define OPT_MCH_DEC_V1_NBE +#define OPT_MASA_DEC_V1_NBE #define OPT_MCT_ENC_48KB_NBE #define OPT_MCH_DEC_V1_BE #define OPT_MCT_ENC_V2_NBE diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index a098aaa25..c5689b364 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -193,7 +193,6 @@ static void GenerateFilter_fx( ) { Word16 qp, p, k, i; - Word32 index; Word16 AzIdx[HRTF_MODEL_BSPLINE_NUM_COEFFS][HRTF_MODEL_BSPLINE_NUM_COEFFS], EvIdx[HRTF_MODEL_BSPLINE_NUM_COEFFS]; /* non-zero basis functions */ Word16 num_az_idx[HRTF_MODEL_BSPLINE_NUM_COEFFS]; Word16 num_ev_idx; @@ -255,6 +254,16 @@ static void GenerateFilter_fx( move16(); FOR( p = 0; p < num_ev_idx; p++ ) { +#ifdef OPT_MASA_DEC_V1_NBE + Word32 expt = L_shl_sat( modelEval->elevBfVec_fx[p], 1 ); + FOR( i = 0; i < num_az_idx[p]; i++ ) + { + modelEval->BM_fx[qp + i] = Mpy_32_32( expt, modelEval->azimBfVec_fx[p][i] ); /*Q30 - ( Q30 * 2 - 31 )*/ // Q30 + move32(); + BM_idx[qp + i] = add( model->azim_start_idx[EvIdx[p]], AzIdx[p][i] ); + move16(); + } +#else /* OPT_MASA_DEC_V1_NBE */ FOR( i = 0; i < num_az_idx[p]; i++ ) { modelEval->BM_fx[add( qp, i )] = L_shl( Mpy_32_32( modelEval->elevBfVec_fx[p], modelEval->azimBfVec_fx[p][i] ), 1 ); /*Q30 - ( Q30 * 2 - 31 )*/ // Q30 @@ -262,12 +271,21 @@ static void GenerateFilter_fx( BM_idx[add( qp, i )] = add( model->azim_start_idx[EvIdx[p]], AzIdx[p][i] ); move16(); } +#endif /* OPT_MASA_DEC_V1_NBE */ qp = add( qp, num_az_idx[p] ); } +#ifdef OPT_MASA_DEC_V1_NBE + Word16 expL = add( model->AlphaL_e, 1 ); + Word16 expR = add( model->AlphaR_e, 1 ); + BMEnergiesL_e = add( model->EL_e, 2 ); + BMEnergiesR_e = add( model->ER_e, 2 ); +#endif /* OPT_MASA_DEC_V1_NBE */ + /* Compute HR filters, approximate optimized model evaluation */ FOR( iSec = 0; iSec < HRTF_MODEL_N_SECTIONS; iSec++ ) { +#ifndef OPT_MASA_DEC_V1_NBE ETotL = 0; move32(); ETotR = 0; @@ -288,45 +306,102 @@ static void GenerateFilter_fx( BMEnergiesL_e = add( model->EL_e, 2 ); BMEnergiesR_e = add( model->ER_e, 2 ); +#else /* OPT_MASA_DEC_V1_NBE */ + Word64 temp1 = 0; + move64(); + Word64 temp2 = 0; + move64(); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Energy is precalculated part updated with square of BM value. Store index for sorting */ FOR( i = 0; i < qp; i++ ) { +#ifdef OPT_MASA_DEC_V1_NBE + modelEval->BMEnergiesL[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->EL_fx[( iSec * model->AlphaN ) + BM_idx[i]] ); // exp: model->EL_e + 2 + modelEval->BMEnergiesR[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->ER_fx[( iSec * model->AlphaN ) + BM_idx[i]] ); // exp: model->ER_e + 2 +#else /* OPT_MASA_DEC_V1_NBE */ modelEval->BMEnergiesL[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->EL_fx[add( i_mult( iSec, model->AlphaN ), BM_idx[i] )] ); // exp: model->EL_e + 2 modelEval->BMEnergiesR[i].val_fx = Mpy_32_32( Mpy_32_32( modelEval->BM_fx[i], modelEval->BM_fx[i] ) /*Q29*/, model->ER_fx[add( i_mult( iSec, model->AlphaN ), BM_idx[i] )] ); // exp: model->ER_e + 2 +#endif /* OPT_MASA_DEC_V1_NBE */ move32(); move32(); modelEval->BMEnergiesL[i].i = i; move16(); modelEval->BMEnergiesR[i].i = i; move16(); - +#ifndef OPT_MASA_DEC_V1_NBE ETotL = BASOP_Util_Add_Mant32Exp( ETotL, ETotL_e, modelEval->BMEnergiesL[i].val_fx, BMEnergiesL_e, &ETotL_e ); ETotR = BASOP_Util_Add_Mant32Exp( ETotR, ETotR_e, modelEval->BMEnergiesR[i].val_fx, BMEnergiesR_e, &ETotR_e ); +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = W_add( temp1, modelEval->BMEnergiesL[i].val_fx ); // BMEnergiesL_e + temp2 = W_add( temp2, modelEval->BMEnergiesR[i].val_fx ); // BMEnergiesR_e +#endif /* OPT_MASA_DEC_V1_NBE */ } +#ifdef OPT_MASA_DEC_V1_NBE + ETotL_e = W_norm( temp1 ); + ETotL_e = sub( ETotL_e, 32 ); + ETotL = W_shl_sat_l( temp1, ETotL_e ); + ETotL_e = sub( BMEnergiesL_e, ETotL_e ); + + ETotR_e = W_norm( temp2 ); + ETotR_e = sub( ETotR_e, 32 ); + ETotR = W_shl_sat_l( temp2, ETotR_e ); + ETotR_e = sub( BMEnergiesR_e, ETotR_e ); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Number of basis components actually used. */ p = s_min( HRTF_MODEL_N_CPTS_VAR[iSec], qp ); SkipSmallest_ValueIndex_fx( modelEval->UseIndsL, modelEval->BMEnergiesL, qp, sub( qp, p ) ); SkipSmallest_ValueIndex_fx( modelEval->UseIndsR, modelEval->BMEnergiesR, qp, sub( qp, p ) ); +#ifndef OPT_MASA_DEC_V1_NBE /* Account for lost energy */ FOR( i = 0; i < p; i++ ) { ESynL = BASOP_Util_Add_Mant32Exp( ESynL, ESynL_e, modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val_fx, BMEnergiesL_e, &ESynL_e ); ESynR = BASOP_Util_Add_Mant32Exp( ESynR, ESynR_e, modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val_fx, BMEnergiesR_e, &ESynR_e ); } +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = 0; + move64(); + temp2 = 0; + move64(); + + /* Account for lost energy */ + FOR( i = 0; i < p; i++ ) + { + temp1 = W_add( temp1, modelEval->BMEnergiesL[modelEval->UseIndsL[i]].val_fx ); // BMEnergiesL_e + temp2 = W_add( temp2, modelEval->BMEnergiesR[modelEval->UseIndsR[i]].val_fx ); // BMEnergiesR_e + } + ESynL_e = W_norm( temp1 ); + ESynL_e = sub( ESynL_e, 32 ); + ESynL = W_shl_sat_l( temp1, ESynL_e ); + ESynL_e = sub( BMEnergiesL_e, ESynL_e ); + + ESynR_e = W_norm( temp2 ); + ESynR_e = sub( ESynR_e, 32 ); + ESynR = W_shl_sat_l( temp2, ESynR_e ); + ESynR_e = sub( BMEnergiesR_e, ESynR_e ); + +#endif /* OPT_MASA_DEC_V1_NBE */ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( ETotL, ESynL, &ScaleL_e ) ); ScaleL_e = add( ScaleL_e, sub( ETotL_e, ESynL_e ) ); ScaleL = Sqrt32( tmp32, &ScaleL_e ); +#ifdef OPT_MASA_DEC_V1_NBE + ScaleL_e = sub( ScaleL_e, 1 ); +#endif /* OPT_MASA_DEC_V1_NBE */ tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( ETotR, ESynR, &ScaleR_e ) ); ScaleR_e = add( ScaleR_e, sub( ETotR_e, ESynR_e ) ); ScaleR = Sqrt32( tmp32, &ScaleR_e ); +#ifdef OPT_MASA_DEC_V1_NBE + ScaleR_e = sub( ScaleR_e, 1 ); +#endif /* OPT_MASA_DEC_V1_NBE */ /* Build using only the most energetic components. */ FOR( k = model->iSecFirst[iSec]; k <= model->iSecLast[iSec]; k++ ) { +#ifndef OPT_MASA_DEC_V1_NBE modelEval->hrfModL_fx[k] = 0; move32(); modelEval->hrfModR_fx[k] = 0; @@ -337,6 +412,7 @@ static void GenerateFilter_fx( tmp_hrfModR_e = 0; move16(); + Word32 index; FOR( i = 0; i < p; i++ ) { index = L_add( BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], imult3216( model->AlphaN, k ) ); @@ -348,6 +424,42 @@ static void GenerateFilter_fx( modelEval->hrfModR_fx[k] = BASOP_Util_Add_Mant32Exp( modelEval->hrfModR_fx[k], tmp_hrfModR_e, tmp32, add( model->AlphaR_e, 1 ), &tmp_hrfModR_e ); move32(); } +#else /* OPT_MASA_DEC_V1_NBE */ + temp1 = 0; + move64(); + temp2 = 0; + move64(); + + FOR( i = 0; i < p; i++ ) + { + temp1 = W_add( temp1, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i], model->AlphaL_fx[BM_idx[modelEval->BMEnergiesL[modelEval->UseIndsL[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaL_e, 1) + temp2 = W_add( temp2, Mpy_32_32( modelEval->BM_fx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i], model->AlphaR_fx[BM_idx[modelEval->BMEnergiesR[modelEval->UseIndsR[i]].i] + ( model->AlphaN * k )] ) ); // add(model->AlphaR_e, 1) + } + + tmp_hrfModL_e = W_norm( temp1 ); + tmp_hrfModL_e = sub( tmp_hrfModL_e, 32 ); + modelEval->hrfModL_fx[k] = W_shl_sat_l( temp1, tmp_hrfModL_e ); + move32(); + tmp_hrfModL_e = sub( expL, tmp_hrfModL_e ); + if ( temp1 == 0 ) + { + tmp_hrfModL_e = 0; + move16(); + } + + tmp_hrfModR_e = W_norm( temp2 ); + tmp_hrfModR_e = sub( tmp_hrfModR_e, 32 ); + modelEval->hrfModR_fx[k] = W_shl_sat_l( temp2, tmp_hrfModR_e ); + move32(); + tmp_hrfModR_e = sub( expR, tmp_hrfModR_e ); + + if ( temp2 == 0 ) + { + tmp_hrfModR_e = 0; + move16(); + } + +#endif /* OPT_MASA_DEC_V1_NBE */ /* Account for lost energy */ modelEval->hrfModL_fx[k] = Mpy_32_32( modelEval->hrfModL_fx[k], ScaleL ); move32(); @@ -355,8 +467,13 @@ static void GenerateFilter_fx( move32(); /* NOTE: Assuming that finally, hrfMod values will be <= 1. Hence making it Q30 */ +#ifdef OPT_MASA_DEC_V1_NBE + modelEval->hrfModL_fx[k] = L_shl( modelEval->hrfModL_fx[k], add( tmp_hrfModL_e, ScaleL_e ) ); // assuming Q30 + modelEval->hrfModR_fx[k] = L_shl( modelEval->hrfModR_fx[k], add( tmp_hrfModR_e, ScaleR_e ) ); // assuming Q30 +#else /* OPT_MASA_DEC_V1_NBE */ modelEval->hrfModL_fx[k] = L_shl( modelEval->hrfModL_fx[k], sub( add( tmp_hrfModL_e, ScaleL_e ), 1 ) ); // assuming Q30 modelEval->hrfModR_fx[k] = L_shl( modelEval->hrfModR_fx[k], sub( add( tmp_hrfModR_e, ScaleR_e ), 1 ) ); // assuming Q30 +#endif /* OPT_MASA_DEC_V1_NBE */ // move32(); move32(); } diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index a570273cf..ef5fa93e4 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -292,7 +292,9 @@ void TDREND_firfilt_fx( Word32 step_fx /* Q31 */, gain_tmp_fx /* Q31 */, gain_delta_fx /* Q30 */; Word16 tmp_e; Word64 tmp64_fx; - +#ifdef OPT_MASA_DEC_V1_NBE + Word16 shift = sub( filter_e, 32 ); +#endif /* OPT_MASA_DEC_V1_NBE */ gain_delta_fx = L_sub( Gain_fx, prevGain_fx ); // Q30 step_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( gain_delta_fx, subframe_length, &tmp_e ) ); // exp(tmp_e) tmp_e = sub( tmp_e, Q30 ); @@ -306,12 +308,18 @@ void TDREND_firfilt_fx( Copy32( signal_fx + add( sub( subframe_length, filterlength ), 1 ), mem_fx, sub( filterlength, 1 ) ); /* Update memory for next frame */ // Qx /* Convolution */ +#ifdef OPT_MASA_DEC_V1_NBE + FOR( i = 0; i < intp_count; i++ ) +#else /* OPT_MASA_DEC_V1_NBE */ FOR( i = 0; i < subframe_length; i++ ) +#endif /* OPT_MASA_DEC_V1_NBE */ { tmp64_fx = 0; move64(); +#ifndef OPT_MASA_DEC_V1_NBE tmp_e = 0; move16(); +#endif /* OPT_MASA_DEC_V1_NBE */ p_tmp_fx = p_signal_fx + i; // Qx p_filter_fx = filter_fx; // exp(filter_e) @@ -324,18 +332,50 @@ void TDREND_firfilt_fx( } // This is done to keep the output Q same as input Q for signal - tmp64_fx = W_shl( tmp64_fx, filter_e ); // Qx + 32 - tmp_fx = W_extract_h( tmp64_fx ); // Qx +#ifdef OPT_MASA_DEC_V1_NBE + tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx +#else /* OPT_MASA_DEC_V1_NBE */ + tmp64_fx = W_shl( tmp64_fx, filter_e ); // Qx + 32 + tmp_fx = W_extract_h( tmp64_fx ); // Qx +#endif /* OPT_MASA_DEC_V1_NBE */ /* Apply linear gain interpolation in case of abrupt gain changes */ gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx move32(); +#ifndef OPT_MASA_DEC_V1_NBE IF( LT_16( i, intp_count ) ) { v_add_fx( filter_fx, filter_delta_fx, filter_fx, filterlength ); // exp(filter_e) } } +#else /* OPT_MASA_DEC_V1_NBE */ + v_add_fx( filter_fx, filter_delta_fx, filter_fx, filterlength ); // exp(filter_e) + } + FOR( ; i < subframe_length; i++ ) + { + tmp64_fx = 0; + move64(); + p_tmp_fx = p_signal_fx + i; // Qx + p_filter_fx = filter_fx; // exp(filter_e) + + + FOR( j = 0; j < filterlength; j++ ) + { + tmp64_fx = W_mac_32_32( tmp64_fx, *p_filter_fx, *p_tmp_fx ); // Qx + (Q31 - filter_e) + 1 + p_filter_fx++; // exp(filter_e) + p_tmp_fx--; // Qx + } + + // This is done to keep the output Q same as input Q for signal + tmp_fx = W_shl_sat_l( tmp64_fx, shift ); // Qx + + /* Apply linear gain interpolation in case of abrupt gain changes */ + gain_tmp_fx = L_add_sat( gain_tmp_fx, step_fx ); /* Saturating values which just exceeds 1, Q31*/ + signal_fx[i] = Mpy_32_32( tmp_fx, gain_tmp_fx ); // Qx + move32(); + } +#endif /* OPT_MASA_DEC_V1_NBE */ return; } -- GitLab From 4f5b522bf36eb791640ccc2043cb35f661cf768d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 16:17:50 +0530 Subject: [PATCH 359/394] 3GPP issue 1787: Improved precision to align direction index with reference Link #1787 --- lib_rend/ivas_dirac_ana_fx.c | 13 +++++---- lib_rend/ivas_mcmasa_ana_fx.c | 17 ++++++------ lib_rend/ivas_omasa_ana_fx.c | 50 +++++++++++++++++------------------ lib_rend/ivas_prot_rend_fx.h | 12 +++++---- 4 files changed, 47 insertions(+), 45 deletions(-) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 5f0f8a3a4..41b3fecd3 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -415,8 +415,7 @@ static void ivas_dirac_param_est_ana_fx( computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); //( 2 * ( scale_fact - Q1 ) - 31 - 1 ); - reference_power_q = sub( shl( inp_q, 1 ), 30 ); + computeReferencePower_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); /* Aligning intensity_real to a common Q-factor */ minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); @@ -452,13 +451,13 @@ static void ivas_dirac_param_est_ana_fx( FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ - hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx], hDirAC->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx], hDirAC->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] ); move32(); - hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] ); + hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx], hDirAC->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] ); move32(); W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); @@ -469,7 +468,7 @@ static void ivas_dirac_param_est_ana_fx( diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); move32(); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); } } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index 489dd72bf..cf86608b2 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -521,6 +521,7 @@ void ivas_mcmasa_param_est_ana_fx( Word16 q_vdv[MASA_FREQUENCY_BANDS]; Word16 out_exp[MASA_FREQUENCY_BANDS]; Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 reference_power_q; Word32 dir_v_fx[DIRAC_NUM_DIMS]; Word32 Chnl_RealBuffer_fx[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX]; Word32 Chnl_ImagBuffer_fx[MCMASA_MAX_ANA_CHANS][CLDFB_NO_CHANNELS_MAX]; @@ -783,7 +784,7 @@ void ivas_mcmasa_param_est_ana_fx( /* Power and intensity estimation for diffuseness */ computeIntensityVector_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, num_freq_bands, intensity_even_real_fx, intensity_even_real_q, inp_q ); - computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); /*2*inp_q-30*/ + computeReferencePower_ana_fx( hMcMasa->band_grouping, FoaEven_RealBuffer_fx, FoaEven_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); /* Aligning intensity_real and intensity_even_real to a common Q-factor */ minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); @@ -821,7 +822,7 @@ void ivas_mcmasa_param_est_ana_fx( hMcMasa->buffer_intensity_real_q[index - 1] = intensity_even_q; move16(); Copy32( reference_power_fx[ts], &( hMcMasa->buffer_energy_fx[i_mult( index - 1, num_freq_bands )] ), num_freq_bands ); - hMcMasa->buffer_energy_q[index - 1] = sub( shl( inp_q, 1 ), 30 ); + hMcMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); computeDiffuseness_fixed( hMcMasa->buffer_intensity_real_fx, hMcMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hMcMasa->buffer_intensity_real_q, hMcMasa->buffer_energy_q, out_exp ); // out_exp = Q30 /* Compute vertical diffuseness, and tune original diffuseness if needed */ @@ -835,19 +836,19 @@ void ivas_mcmasa_param_est_ana_fx( } FOR( band_m_idx = 0; band_m_idx < hMcMasa->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ - hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); - hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); - hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ + hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); + hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); + hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hMcMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hMcMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); W_temp = W_mult0_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ); s = W_norm( W_temp ); temp = W_extract_h( W_shl( W_temp, s ) ); - temp_e = sub( 32, add( sub( Q30, sub( shl( c_e, 1 ), 1 ) ), s ) ); // 31 - ( (31 - sub( shl( c_e, 1 ), 1 )) + diffuseness_q + s - 32 ) + temp_e = sub( 63, add( Q30, add( reference_power_q, s ) ) ); // 31 - ( reference_power_q + diffuseness_q + s - 32 ) diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], temp, temp_e, &diffuseness_e[band_m_idx] ); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); move32(); move32(); diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index fe9ffbea3..67e72e84c 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -529,8 +529,7 @@ static void ivas_omasa_param_est_ana_fx( computeDirectionVectors_fixed( intensity_real_fx[0], intensity_real_fx[1], intensity_real_fx[2], 0, num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], direction_vector_fx[2], 0, intensity_real_q ); /* Q direction_vector_fx = Q30*/ /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands ); // 2 * inputq - 30 - reference_power_q = sub( shl( inp_q, 1 ), 30 ); + computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], num_freq_bands, inp_q, &reference_power_q ); /* Aligning intensity_real to a common Q-factor */ minimum_fx( intensity_real_q, num_freq_bands, &intensity_q ); @@ -568,17 +567,17 @@ static void ivas_omasa_param_est_ana_fx( FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { - norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*2*inp_q-30*/ - hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); + norm_tmp_fx = L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ), 1 ); /*reference_power_q*/ + hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], hOMasa->direction_vector_e[0][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] ); move32(); - hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); + hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx], hOMasa->direction_vector_e[1][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] ); move32(); - hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), shl( c_e, 1 ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); + hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx], hOMasa->direction_vector_e[2][block_m_idx][band_m_idx], Mult_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), sub( 31 + 1, reference_power_q ), &hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] ); move32(); - diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( shl( c_e, 1 ), 1 ), &diffuseness_e[band_m_idx] ); + diffuseness_m_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( diffuseness_m_fx[band_m_idx], diffuseness_e[band_m_idx], L_shl( Mult_32_32( reference_power_fx[ts][band_m_idx], diffuseness_vector_fx[band_m_idx] ), 1 ), sub( 31, reference_power_q ), &diffuseness_e[band_m_idx] ); move32(); - renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( shl( c_e, 1 ), 1 ), &renormalization_factor_diff_e[band_m_idx] ); + renormalization_factor_diff_fx[band_m_idx] = BASOP_Util_Add_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], renormalization_factor_diff_e[band_m_idx], reference_power_fx[ts][band_m_idx], sub( 31, reference_power_q ), &renormalization_factor_diff_e[band_m_idx] ); move32(); } } @@ -868,42 +867,43 @@ void computeReferencePower_ana_fx( const Word16 *band_grouping, /* i : Band grouping for estimation */ Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ - Word32 *reference_power, /* o : Estimated power 2 * inputq - 31 */ - const Word16 num_freq_bands /* i : Number of frequency bands */ + Word32 *reference_power, /* o : Estimated power */ + const Word16 num_freq_bands, /* i : Number of frequency bands */ + const Word16 input_q, /* i : Q-factor Real and Imag part of input signal */ + Word16 *reference_power_q /* o : Q-factor of the estimated power */ ) { Word16 brange[2]; - Word16 ch_idx, i, j; - + Word16 ch_idx, i, j, s; + Word64 reference_power64[MASA_FREQUENCY_BANDS]; FOR( i = 0; i < num_freq_bands; i++ ) { brange[0] = band_grouping[i]; move16(); brange[1] = band_grouping[i + 1]; move16(); - reference_power[i] = 0; - move32(); + reference_power64[i] = 0; + move64(); FOR( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ ) { /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { - // Q = 2*inputq - 31 - reference_power[i] = L_add( L_add( Mpy_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Mpy_32_32( Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ) ), reference_power[i] ); - move32(); + reference_power64[i] = W_add( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[ch_idx][j], Cldfb_RealBuffer[ch_idx][j] ), Cldfb_ImagBuffer[ch_idx][j], Cldfb_ImagBuffer[ch_idx][j] ), reference_power64[i] ); // 2 * input_q + 1 + move64(); } } } - // v_multc( reference_power, 0.5f, reference_power, num_freq_bands ); + s = sub( W_norm_arr( reference_power64, num_freq_bands ), 1 ); + FOR( i = 0; i < num_freq_bands; i++ ) + { + reference_power[i] = W_extract_h( W_shl( reference_power64[i], s ) ); // 2 * input_q + 1 + s - 32 + move32(); + } + *reference_power_q = sub( add( shl( input_q, 1 ), s ), 30 ); /* Bypassing the v_multc ,so output q = 2 * input_q + s - 30 */ + move16(); - /* Bypassing the v_multc ,so output q = 2*inputq - 30*/ return; } - -/*--------------------------------------------------------------------------* - * computeReferencePower_ana() - * - * - *--------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 6b34bcffe..7e6c2aa46 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1437,11 +1437,13 @@ void computeIntensityVector_ana_fx( Word16 inp_q ); void computeReferencePower_ana_fx( - const Word16 *band_grouping, /* i : Band grouping for estimation */ - Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ - Word32 *reference_power, /* o : Estimated power */ - const Word16 num_freq_bands /* i : Number of frequency bands 2 * input_q - 31 */ + const Word16 *band_grouping, /* i : Band grouping for estimation */ + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Real part of input signal input_q */ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal input_q */ + Word32 *reference_power, /* o : Estimated power */ + const Word16 num_freq_bands, /* i : Number of frequency bands */ + const Word16 input_q, /* i : Q-factor Real and Imag part of input signal */ + Word16 *reference_power_q /* o : Q-factor of the estimated power */ ); void ivas_create_masa_out_meta_fx( -- GitLab From d3cdb6b2381a5f967eb895e9ae403eb8786c2ae4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 16:44:21 +0530 Subject: [PATCH 360/394] Warning fix --- lib_rend/ivas_dirac_ana_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 41b3fecd3..4e00b9623 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -371,7 +371,7 @@ static void ivas_dirac_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { - Word16 cr_q = MAX_16, ci_q = MAX_16, c_e; + Word16 cr_q = MAX_16, ci_q = MAX_16; inp_q = scaled_data_q; // Q of data_fx after scaling move16(); move16(); @@ -391,7 +391,6 @@ static void ivas_dirac_param_est_ana_fx( scale_sig32( Foa_ImagBuffer_fx[i], l_ts, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); - c_e = sub( 31, inp_q ); /* Compute omni energy for metadata processing */ FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ ) { -- GitLab From 0b34b3642d65ea83b3764995286d58fc793c0fc7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 16:59:17 +0530 Subject: [PATCH 361/394] ISM decoder path optimizations - 2 sincResample_fx updated to reduce BASOP_Util_Add_Mant32Exp usage --- lib_com/options.h | 1 + lib_rend/ivas_objectRenderer_hrFilt_fx.c | 27 +++++++++++++++++++++-- lib_rend/ivas_objectRenderer_sfx_fx.c | 28 ++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 21d976fac..0f464530e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,6 +82,7 @@ #define OPT_MCT_ENC_V2_BE #define OPT_MCH_DEC_V1_NBE #define OPT_MASA_DEC_V1_NBE +#define OPT_MASA_DEC_V2_NBE #define OPT_MCT_ENC_48KB_NBE #define OPT_MCH_DEC_V1_BE #define OPT_MCT_ENC_V2_NBE diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index c5689b364..8504722af 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -604,11 +604,18 @@ static void GenerateITD_fx( } ELSE { +#ifdef OPT_MASA_DEC_V2_NBE + Word16 temp_e = add( imult1616( EvIdx[p], model->azimDim3 ), elev_offset ); +#endif /* OPT_MASA_DEC_V2_NBE */ FOR( i = 0; i < num_az_idx; i++ ) { modelEval->BM_ITD_fx[qp + i] = L_shl( Mpy_32_32( modelEval->elevBfVecITD_fx[p], modelEval->azimBfVecITD_fx[i] ), 1 ); // Q30 move32(); +#ifdef OPT_MASA_DEC_V2_NBE + BM_idx[qp + i] = add( temp_e, AzIdx[i] ); +#else /* OPT_MASA_DEC_V2_NBE */ BM_idx[qp + i] = add( add( imult1616( EvIdx[p], model->azimDim3 ), elev_offset ), AzIdx[i] ); +#endif /* OPT_MASA_DEC_V2_NBE */ move16(); } qp = add( qp, num_az_idx ); @@ -623,19 +630,35 @@ static void GenerateITD_fx( } /* Matrix multiplcation (row x column) */ +#ifndef OPT_MASA_DEC_V2_NBE modelEval->itdMod_fx = 0; move16(); itdMod_e = 0; move16(); +#else /* OPT_MASA_DEC_V2_NBE */ + Word64 temp = 0; + move64(); + Word16 res_e = add( model->W_e, 1 ); +#endif /* OPT_MASA_DEC_V2_NBE */ FOR( i = 0; i < qp; i++ ) { - Word16 tmp_e; index = BM_idx[i]; move32(); +#ifndef OPT_MASA_DEC_V2_NBE + Word16 tmp_e; modelEval->itdMod_fx = BASOP_Util_Add_Mant32Exp( modelEval->itdMod_fx, itdMod_e, Mpy_32_32( modelEval->BM_ITD_fx[i], model->W_fx[index] ), add( model->W_e, 1 ), &tmp_e ); itdMod_e = tmp_e; move16(); - } +#else /* OPT_MASA_DEC_V2_NBE */ + temp = W_add( temp, Mpy_32_32( modelEval->BM_ITD_fx[i], model->W_fx[index] ) ); +#endif /* OPT_MASA_DEC_V2_NBE */ + } +#ifdef OPT_MASA_DEC_V2_NBE + itdMod_e = W_norm( temp ); + itdMod_e = sub( itdMod_e, 32 ); + modelEval->itdMod_fx = W_shl_sat_l( temp, itdMod_e ); + itdMod_e = sub( res_e, itdMod_e ); +#endif /* OPT_MASA_DEC_V2_NBE */ Word32 tmp32 = Mpy_32_16_1( modelEval->itdMod_fx, model->resamp_factor_fx ); // Q = 31 - ( itdMod_e + 1 ) Word16 tmp_q = sub( 30, itdMod_e ); diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index ef5fa93e4..5f6ee03a7 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -191,6 +191,9 @@ static void sincResample_fx( Word16 t_step_e; Word32 t_frac_fx; Word16 t_frac_e; +#ifdef OPT_MASA_DEC_V2_NBE + Word64 t_frac_fx_acc; +#endif /* OPT_MASA_DEC_V2_NBE */ Word64 tmp64_fx; // Qx + 32 const Word32 *p_mid_fx; const Word32 *p_forward_fx; @@ -212,6 +215,10 @@ static void sincResample_fx( /* Compute fractional time step */ t_step_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( length_in, length_out, &t_step_e ) ); // exp(t_step_e) +#ifdef OPT_MASA_DEC_V2_NBE + t_frac_fx_acc = 0; + move64(); +#endif /* OPT_MASA_DEC_V2_NBE */ t_frac_fx = 0; move32(); t_frac_e = 0; @@ -224,13 +231,21 @@ static void sincResample_fx( t = extract_l( L_shr( t_frac_plus_eps, sub( 31, t_frac_plus_eps_e ) ) ); // Q0 /* Calculate the sinc-index for the center value of the sinc */ - Word32 center_val; Word16 center_val_e; +#ifndef OPT_MASA_DEC_V2_NBE + Word32 center_val; center_val = BASOP_Util_Add_Mant32Exp( t_frac_plus_eps, t_frac_plus_eps_e, L_negate( L_deposit_h( t ) ), 15, ¢er_val_e ); // exp(center_val_e) center_val_e = add( center_val_e, 6 ); // center_val * SFX_SPAT_BIN_NUM_SUBSAMPLES (i.e. 64) center_val = BASOP_Util_Add_Mant32Exp( center_val, center_val_e, ONE_IN_Q29, 1, ¢er_val_e ); // exp(center_val_e) snc0 = extract_l( L_shr( center_val, sub( 31, center_val_e ) ) ); // Q0 - +#else /* OPT_MASA_DEC_V2_NBE */ + Word64 center_val; + center_val = W_sub( t_frac_plus_eps, W_shl( t, sub( 31, t_frac_plus_eps_e ) ) ); // exp(center_val_e) + center_val_e = add( t_frac_plus_eps_e, 6 ); + Word16 com_e = s_max( 0, center_val_e ); + center_val = W_add( W_shr( center_val, sub( com_e, center_val_e ) ), W_shl( 1, sub( 30, com_e ) ) ); // exp(center_val_e) + snc0 = extract_l( W_shl_sat_l( center_val, sub( com_e, 31 ) ) ); +#endif /* OPT_MASA_DEC_V2_NBE */ /* Run convolution forward and backward from mid point */ p_mid_fx = input_fx + t; // Qx p_forward_fx = p_mid_fx + 1; // Qx @@ -255,7 +270,16 @@ static void sincResample_fx( move32(); /* Advance fractional time */ +#ifndef OPT_MASA_DEC_V2_NBE t_frac_fx = BASOP_Util_Add_Mant32Exp( t_frac_fx, t_frac_e, t_step_fx, t_step_e, &t_frac_e ); // exp( t_frac_fx ) +#else /* OPT_MASA_DEC_V2_NBE */ + t_frac_fx_acc = W_add( t_frac_fx_acc, t_step_fx ); // t_step_e + Word16 hdrm = W_norm( t_frac_fx_acc ); + hdrm = sub( hdrm, 32 ); + t_frac_fx = W_shl_sat_l( t_frac_fx_acc, hdrm ); + t_frac_e = sub( t_step_e, hdrm ); + move16(); +#endif /* OPT_MASA_DEC_V2_NBE */ } return; -- GitLab From 7c5ad78623e7d934a52ba020758e2bcc74060e89 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 11 Jul 2025 17:44:15 +0530 Subject: [PATCH 362/394] Multi channel optimizations in encoder - non bit exact sns_shape_spectrum_fx, SQ_gain_estimate_fx functions updated for BASOP usage --- lib_com/ivas_sns_com_fx.c | 26 ++++++++++++++++++++++++++ lib_com/options.h | 1 + lib_enc/cod_tcx_fx.c | 5 +++++ lib_enc/tcx_utils_enc_fx.c | 23 ++++++++++++++++++++++- 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index f1e44be78..1a0219b25 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -376,12 +376,14 @@ void sns_shape_spectrum_fx( { L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1 move64(); +#ifndef OPT_MCT_ENC_V3_NBE shift = W_norm( L64_tmp[k] ); if ( LT_16( shift, min_shift ) ) { min_shift = shift; move16(); } +#endif } } tmp_k = k; @@ -391,18 +393,29 @@ void sns_shape_spectrum_fx( *length = k; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + min_shift = W_norm_arr( L64_tmp, k ); +#endif q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 ); if ( GT_16( q_tmp, 30 ) ) { q_tmp = 30; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + shift = sub( q_tmp, add( *q_spectrum, q_scf_int ) ); + FOR( k = 0; k < tmp_k; k++ ) + { + spectrum[k] = W_shl_sat_l( L64_tmp[k], shift ); // q_tmp+1 + move32(); +#else FOR( k = 0; k < tmp_k; k++ ) { L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) ); // Q = q_tmp+1 move64(); spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp+1 move64(); +#endif } *q_spectrum = q_tmp; move16(); @@ -418,6 +431,7 @@ void sns_shape_spectrum_fx( { L64_tmp[k] = W_mult_32_32( spectrum[k], scf_int[i] ); // Q = q_spectrum + q_scf_int + 1 move64(); +#ifndef OPT_MCT_ENC_V3_NBE shift = W_norm( L64_tmp[k] ); test(); if ( LT_16( shift, min_shift ) && NE_64( L64_tmp[k], 0 ) ) @@ -425,6 +439,7 @@ void sns_shape_spectrum_fx( min_shift = shift; move16(); } +#endif } } tmp_k = k; @@ -434,18 +449,29 @@ void sns_shape_spectrum_fx( *length = k; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + min_shift = W_norm_arr( L64_tmp, k ); +#endif q_tmp = sub( add( add( *q_spectrum, q_scf_int ), min_shift ), 32 ); if ( GT_16( q_tmp, 30 ) ) { q_tmp = 30; move16(); } +#ifdef OPT_MCT_ENC_V3_NBE + shift = sub( q_tmp, add( *q_spectrum, q_scf_int ) ); + FOR( k = 0; k < tmp_k; k++ ) + { + spectrum[k] = W_shl_sat_l( L64_tmp[k], shift ); // q_tmp+1 + move32(); +#else FOR( k = 0; k < tmp_k; k++ ) { L64_tmp[k] = W_shr( L64_tmp[k], sub( add( *q_spectrum, q_scf_int ), q_tmp ) ); // q_tmp+1 move64(); spectrum[k] = W_sat_l( L64_tmp[k] ); // Q = q_tmp+1 move64(); +#endif } *q_spectrum = q_tmp; move16(); diff --git a/lib_com/options.h b/lib_com/options.h index 0f464530e..362cad558 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V3_NBE #define OPT_MCT_ENC_V2_BE #define OPT_MCH_DEC_V1_NBE #define OPT_MASA_DEC_V1_NBE diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c8fab11a9..b520d9eeb 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -3203,6 +3203,11 @@ void QuantizeTCXSpectrum_fx( IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) { +#ifdef OPT_MCT_ENC_V3_NBE + Word16 scale = sub( L_norm_arr( spectrum_fx, L_spec ), 2 ); + scale_sig32( spectrum_fx, L_spec, scale ); + *spectrum_e = sub( *spectrum_e, scale ); +#endif sqGain_fx = SQ_gain_estimate_fx( spectrum_fx, *spectrum_e, shl( mult( hTcxEnc->tcx_target_bits_fac, sqTargetBits ), 1 ), L_spec, &sqGain_e ); } ELSE diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 9ca9eb82a..6ce40b00e 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1053,6 +1053,10 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain Word32 tmp = 0, tmpp = 0; move32(); move32(); +#ifdef OPT_MCT_ENC_V3_NBE + Word64 ener64_fx; + Word16 tmp_exp; +#endif /* tmp = 0.5f * (float) log10( (float) lg / (float) NORM_MDCT_FACTOR ) + + 0.94f; lowest gain + expected value of the quantization noise energy per quadruple (log10(4/12)) in Q16*/ /* tmpp = 0.5f * (float) log10( (float) lg / (float) NORM_MDCT_FACTOR ) * log2(10) in Q16 */ @@ -1166,9 +1170,21 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain lg_4 = shr( lg, 2 ); +#ifdef OPT_MCT_ENC_V3_NBE + tmp_exp = shl( x_e, 1 ); +#endif /* SNR of quadruples for unit step quantizer and lowest possible gain */ FOR( i = 0; i < lg_4; i++ ) { +#ifdef OPT_MCT_ENC_V3_NBE + ener64_fx = W_mac_32_32( 1, x[0], x[0] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[1], x[1] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[2], x[2] ); // exp:2*x_e + ener64_fx = W_mac_32_32( ener64_fx, x[3], x[3] ); // exp:2*x_e + s = W_norm( ener64_fx ); + ener = W_extract_h( W_shl( ener64_fx, s ) ); + s = sub( tmp_exp, s ); +#else /* normalization */ s = 15; move16(); @@ -1215,7 +1231,7 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain ener = L_mac( ener, tmp16, tmp16 ); s = shl( sub( x_e, s ), 1 ); - +#endif /* log */ tmp32 = L_add_sat( BASOP_Util_Log2( ener ), L_shl_sat( L_deposit_l( s ), 25 ) ); /* log2, 6Q25 */ en[i] = L_add_sat( L_shr( tmp32, 9 ), tmp ); /* 15Q16 */ @@ -1241,8 +1257,13 @@ Word16 SQ_gain_estimate_fx( /* output: SQ gain { tmp32 = L_sub( en[i], offset ); +#ifdef OPT_MCT_ENC_V3_NBE + /* avoid SV with 1 bin of amp < 0.5f */ + if ( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ +#else /* avoid SV with 1 bin of amp < 0.5f */ IF( GT_32( tmp32, 0xFF20 ) ) /* 0xFF20 -> 0.3*log2(10); */ +#endif { ener = L_add( ener, tmp32 ); } -- GitLab From 60bbeeff8babaad203eccb9361ccb82636687e88 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 11 Jul 2025 08:25:34 -0400 Subject: [PATCH 363/394] Fix to correct wrong initialization, small expected impact --- lib_com/options.h | 3 +++ lib_enc/core_switching_enc_fx.c | 15 ++++++++++++--- lib_enc/rst_enc_fx.c | 8 ++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 21d976fac..2c65d182f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,4 +126,7 @@ #define NONBE_FIX_1748_SPAR_DIV_OPT /*Dlb: issue 1748: SPAR common div optimizations*/ #define FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION /* FhG: Fixed getScalefactor usage */ + +#define FIX_1818_WRONG_PIT_INIT /* VA: Fix wrong pitch initialization */ + #endif diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 5290509cd..5867eb362 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -282,8 +282,11 @@ void core_switching_pre_enc_fx( tmp16 = shr( st_fx->L_frame, 6 ); Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); /*Q6*/ +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old TD BWE buffers */ IF( hBWE_TD != NULL ) { @@ -851,8 +854,11 @@ void core_switching_pre_enc_ivas_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old ACELP buffers */ test(); IF( ( st_fx->element_mode == EVS_MONO ) && hLPDmem != NULL ) @@ -902,8 +908,11 @@ void core_switching_pre_enc_ivas_fx( tmp16 = shr( st_fx->L_frame, 6 ); Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); +#else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); - +#endif /* Reset old TD BWE buffers */ IF( hBWE_TD != NULL ) { diff --git a/lib_enc/rst_enc_fx.c b/lib_enc/rst_enc_fx.c index d519bc12f..9880084e1 100644 --- a/lib_enc/rst_enc_fx.c +++ b/lib_enc/rst_enc_fx.c @@ -53,11 +53,19 @@ void CNG_reset_enc_fx( /* reset the pitch buffer in case of FRAME_NO_DATA or SID frames */ IF( EQ_16( st_fx->L_frame, L_FRAME ) ) { +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( pitch_buf, L_SUBFR << 6, NB_SUBFR ); +#else set16_fx( pitch_buf, L_SUBFR, NB_SUBFR ); +#endif } ELSE /* st->L_frame == L_FRAME16k */ { +#ifdef FIX_1818_WRONG_PIT_INIT + set16_fx( pitch_buf, L_SUBFR16k << 6, NB_SUBFR16k ); +#else set16_fx( pitch_buf, L_SUBFR16k, NB_SUBFR16k ); +#endif } set16_fx( voice_factors, 1, NB_SUBFR16k ); -- GitLab From 8bc8881a5cbfcb5cd086dd15f9a62112bffa1735 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 11 Jul 2025 08:34:10 -0400 Subject: [PATCH 364/394] fix clang --- lib_enc/core_switching_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/core_switching_enc_fx.c b/lib_enc/core_switching_enc_fx.c index 5867eb362..4c0b843e9 100644 --- a/lib_enc/core_switching_enc_fx.c +++ b/lib_enc/core_switching_enc_fx.c @@ -854,7 +854,7 @@ void core_switching_pre_enc_ivas_fx( } Copy( st_fx->old_pitch_buf_fx + tmp16, st_fx->old_pitch_buf_fx, tmp16 ); -#ifdef FIX_1818_WRONG_PIT_INIT +#ifdef FIX_1818_WRONG_PIT_INIT set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR << 6, tmp16 ); #else set16_fx( st_fx->old_pitch_buf_fx + tmp16, L_SUBFR, tmp16 ); -- GitLab From c9dbededbfd71e5aa92ab0e82b59fd55d639af39 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 15:46:50 +0200 Subject: [PATCH 365/394] A few fixes for long term logs job --- .gitlab-ci.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7a0c0f324..23fd54f3e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -282,7 +282,7 @@ workflow: - if [ $USE_LTV -eq 1 ] && [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH $CI_JOB_NAME $CI_PROJECT_ID) - echo "Job ID from variables - $CI_JOB_ID, Job ID from script - $id_previous" - - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts # This wildcard thingy relies on only one csv file being present per job - file_previous="previous_artifacts/mld--$CI_JOB_NAME-$id_previous--sha-*.csv" @@ -1662,24 +1662,27 @@ ivas-long-term-job-logs: # handle case where the job is running for the first time. e.g where the job was not found. id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip if [ "$id_previous" != "-1" ]; then - unzip artifacts.zip -d logs + # Unzip artifacts to recover past logs dir + curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + unzip artifacts.zip + else + # create logs dir if it doesn't exist + mkdir logs fi - # create logs dir if it doesn't exist + # create folder for today's results TODAY=$(date +'%Y-%m-%d') mkdir -p logs/$TODAY # Aggregate job logs - - job=("ivas-pytest-compare_ref-long-enc" "ivas-pytest-compare_ref-long-enc-lev+10" "ivas-pytest-compare_ref-long-enc-lev-10" "ivas-pytest-compare_ref-long-dec" "ivas-pytest-compare_ref-long-dec-lev+10" "ivas-pytest-compare_ref-long-dec-lev-10" "ivas-pytest-compare_ref-long-fx-fx" "ivas-pytest-compare_ref-long-fx-fx-lev+10" "ivas-pytest-compare_ref-long-fx-fx-lev-10") - for job_name in "${job[@]}"; do + jobs="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" + for job in $jobs; do echo "Getting job logs for: $job" id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip unzip artifacts.zip -d previous_artifacts # This wildcard thingy relies on only one csv file being present per job mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY @@ -1717,7 +1720,7 @@ ivas-long-term-job-logs: # this is a testing/maintenance mechanism to force getting the log history from a specific job id # see below in the concrete complexity jobs - if [ "$JOB_ID_INJECT" != "" ]; then job_id=$JOB_ID_INJECT; fi - - curl --silent --show-error --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip + - curl --silent --show-error --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts.zip - unzip -qq artifacts.zip || true # this may fail on first run, when there are no artifacts there and the zip file is actually just "404"-html - public_dir="$CI_JOB_NAME-public" @@ -1747,7 +1750,7 @@ ivas-long-term-job-logs: ### 1.5.part: get the corresponding measurement from ivas-float-update - job_id=$(python3 ci/get_id_of_last_job_occurence.py ivas-float-update $CI_JOB_NAME $CI_PROJECT_ID) - echo $job_id - - curl --silent --show-error --request GET "https://forge.3gpp.org/rep/api/v4/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts_ref.zip + - curl --silent --show-error --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$job_id/artifacts" --output artifacts_ref.zip - unzip -qq -j artifacts_ref.zip "*latest_WMOPS.csv" || true # add file to arguments only if the artifact could be retrieved to prevent error later. - if [ -f latest_WMOPS.csv ]; then GET_WMOPS_ARGS="$GET_WMOPS_ARGS latest_WMOPS.csv"; fi -- GitLab From 547e6bdc24ac3d55bcffaf7c7c48085525742e0c Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 15:50:31 +0200 Subject: [PATCH 366/394] Cleanup of unnecessary LTV fetch in log job --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 23fd54f3e..1c33ff205 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1652,8 +1652,6 @@ ivas-long-term-job-logs: set -euxo pipefail bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh # Get previous logs of this job incase we are running on a different machine if [ -d "logs" ]; then rm -rf "logs"; fi -- GitLab From c9341a901bc67506a446a1646ca0f42404cce99a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 16:20:45 +0200 Subject: [PATCH 367/394] Fix syntax error in log job --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c33ff205..cc11f0433 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1675,8 +1675,8 @@ ivas-long-term-job-logs: mkdir -p logs/$TODAY # Aggregate job logs - jobs="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" - for job in $jobs; do + job_names="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" + for job_name in $job_names; do echo "Getting job logs for: $job" id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" -- GitLab From 1bafc9206b21590fde375efaec7e716b5901a729 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 16:41:45 +0200 Subject: [PATCH 368/394] Fix syntax error in long term logs job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc11f0433..f0126ea27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1677,7 +1677,7 @@ ivas-long-term-job-logs: # Aggregate job logs job_names="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" for job_name in $job_names; do - echo "Getting job logs for: $job" + echo "Getting job logs for: $job_name" id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip -- GitLab From d80dfda86f653656a77d0070011e71c8022f34d0 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 17:13:51 +0200 Subject: [PATCH 369/394] Try excluding build jobs --- .gitlab-ci.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0126ea27..1bd852a5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -842,6 +842,10 @@ clang-format-check: # ensure that codec builds on linux build-codec-linux-make: rules: + - if: $CI_JOB_NAME == 'pages' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs @@ -859,6 +863,10 @@ build-codec-linux-make: # ensure that codec builds on linux with instrumentation active build-codec-linux-instrumented-make: rules: + - if: $CI_JOB_NAME == 'pages' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main @@ -876,6 +884,10 @@ build-codec-linux-instrumented-make: build-codec-linux-debugging-make: rules: + - if: $CI_JOB_NAME == 'pages' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main @@ -894,6 +906,10 @@ build-codec-linux-debugging-make: build-codec-windows-msbuild: rules: + - if: $CI_JOB_NAME == 'pages' + when: never + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs @@ -1658,7 +1674,8 @@ ivas-long-term-job-logs: # TODO add variable to inject logs from backup copy # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + #id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + id_previous="-1" echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" if [ "$id_previous" != "-1" ]; then -- GitLab From 9f2a842fedfc8d9af3b7d15f6e9796a09a19fbce Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 17:16:54 +0200 Subject: [PATCH 370/394] Move to test stage --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1bd852a5d..8fb40a0ce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1660,7 +1660,7 @@ ivas-long-term-job-logs: - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "long-term-logs" tags: - ivas-basop-linux - stage: .pre + stage: .test timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] -- GitLab From c863ddfc1639cfd5216851dad14ff25e540cf72f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 11 Jul 2025 17:18:25 +0200 Subject: [PATCH 371/394] Maintenance stage --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8fb40a0ce..8b40ca840 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1660,7 +1660,7 @@ ivas-long-term-job-logs: - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "long-term-logs" tags: - ivas-basop-linux - stage: .test + stage: maintenance timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] -- GitLab From 268db15d6387d2a286301a20ea7bea460bba9455 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 12 Jul 2025 22:09:07 +0200 Subject: [PATCH 372/394] Add job for storing backup copy of logs, and way to inject backups --- .gitlab-ci.yml | 52 +++++++++++++++++++++++++++++++++++++--- .gitlab-ci/variables.yml | 4 ++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b40ca840..10f8513b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,9 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'long-term-logs' variables: IVAS_PIPELINE_NAME: 'Aggregate long term logs: $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' + variables: + IVAS_PIPELINE_NAME: 'Backup long term logs: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref: $CI_COMMIT_BRANCH' @@ -1659,19 +1662,24 @@ ivas-long-term-job-logs: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "long-term-logs" tags: - - ivas-basop-linux + - $RUNNER_TAG stage: maintenance timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] - | set -euxo pipefail + echo "Running on RUNNER_TAG: $RUNNER_TAG" bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - # Get previous logs of this job incase we are running on a different machine + # Clean up logs if [ -d "logs" ]; then rm -rf "logs"; fi - # TODO add variable to inject logs from backup copy + + # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set + if [ -d "$LOGS_BACKUP_SOURCE_DIR" ]; then + cp -r $LOGS_BACKUP_SOURCE_DIR/logs . + fi # handle case where the job is running for the first time. e.g where the job was not found. #id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) @@ -1719,6 +1727,44 @@ ivas-long-term-job-logs: expose_as: "ivas long term job logs results" +backup-long-term-job-logs: + rules: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "backup-long-term-logs" + - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "backup-long-term-logs" + tags: + - $RUNNER_TAG + stage: maintenance + timeout: "25 minutes" + script: + - !reference [ .job-linux, before_script ] + - | + set -euxo pipefail + echo "Running on RUNNER_TAG: $RUNNER_TAG" + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + echo "Job name from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" + + if [ "$id_previous" != "-1" ]; then + # Unzip artifacts to recover past logs dir + curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + unzip artifacts.zip + else + # create logs dir if it doesn't exist + mkdir logs + fi + + # Store logs as backup copy if LOGS_BACKUP_TARGET_DIR is set + if [ -d "$LOGS_BACKUP_TARGET_DIR" ]; then + cp -r logs $LOGS_BACKUP_TARGET_DIR/logs + exit 0; + else + echo "Error: LOGS_BACKUP_TARGET_DIR not set for backup job!" + exit -1; + fi + + # --------------------------------------------------------------- diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index a804cdddb..96ef1f507 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -46,6 +46,9 @@ variables: FLOAT_REF_COMMIT_FILE: "float-ref-git-sha.txt" CUT_COMMIT_FILE: "CuT-git-sha.txt" MERGE_TARGET_COMMIT_FILE: "merge-target-git-sha.txt" + RUNNER_TAG: "ivas-basop-linux" + LOGS_BACKUP_SOURCE_DIR: "" + LOGS_BACKUP_TARGET_DIR: "" MANUAL_PIPELINE_TYPE: description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." value: 'default' @@ -66,3 +69,4 @@ variables: - 'renderer-framesize-be' - 'peaq-enc-passthrough' - 'long-term-logs' + - 'backup-long-term-logs' -- GitLab From b2683cf3ca3c38eeae309e481f38e8699e4f5604 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 12 Jul 2025 22:15:21 +0200 Subject: [PATCH 373/394] Add comments to explain logs backup procedure --- .gitlab-ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10f8513b7..3eed21fb2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1656,7 +1656,11 @@ voip-be-on-merge-request: - make -j >> /dev/null - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py - +# To inject backup copy in manual trigger: +# - Store logs backup in accessible folder, e.g. /tmp/ivas +# - Set MANUAL_PIPELINE_TRIGGER to long-term-logs +# - Set RUNNER_TAG to specific runner with this folder prepared, e.g. test-ericsson-linux-runner-5 +# - Set LOGS_BACKUP_SOURCE_DIR to source folder, e.g. /tmp/ivas ivas-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" @@ -1715,9 +1719,6 @@ ivas-long-term-job-logs: ls logs exit 0 - allow_failure: - exit_codes: - - 123 artifacts: name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" expire_in: 4 weeks @@ -1726,7 +1727,11 @@ ivas-long-term-job-logs: - logs expose_as: "ivas long term job logs results" - +# To store backup copy: +# - Prepare accessible folder for backup, e.g. /tmp/ivas +# - Set MANUAL_PIPELINE_TRIGGER to backup-long-term-logs +# - Set RUNNER_TAG to specific runner with this folder prepared, e.g. test-ericsson-linux-runner-5 +# - Set LOGS_BACKUP_TARGET_DIR to source folder, e.g. /tmp/ivas backup-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "backup-long-term-logs" -- GitLab From 157362c71691b46ff05f46c4a1c7c0c2e0fa65ee Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sat, 12 Jul 2025 22:16:47 +0200 Subject: [PATCH 374/394] Remove temporary disabling of logs fetch --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3eed21fb2..4eb39a50e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1686,8 +1686,7 @@ ivas-long-term-job-logs: fi # handle case where the job is running for the first time. e.g where the job was not found. - #id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - id_previous="-1" + id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" if [ "$id_previous" != "-1" ]; then -- GitLab From f6a2f4a521ee3abfd8ce1496bcbfe967acc85ebb Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 13 Jul 2025 16:35:10 +0200 Subject: [PATCH 375/394] Add '-' in log jobs for consistency. Fix job name in backup-long-term-job-logs --- .gitlab-ci.yml | 124 +++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 65 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4eb39a50e..da736bfb4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1671,52 +1671,49 @@ ivas-long-term-job-logs: timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] - - | - set -euxo pipefail - echo "Running on RUNNER_TAG: $RUNNER_TAG" - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + - set -euxo pipefail + - echo "Running on RUNNER_TAG: $RUNNER_TAG" + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - # Clean up logs - if [ -d "logs" ]; then rm -rf "logs"; fi + # Clean up logs + - if [ -d "logs" ]; then rm -rf "logs"; fi + # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set + - if [ -d "$LOGS_BACKUP_SOURCE_DIR" ]; then + - cp -r $LOGS_BACKUP_SOURCE_DIR/logs . + - fi - # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set - if [ -d "$LOGS_BACKUP_SOURCE_DIR" ]; then - cp -r $LOGS_BACKUP_SOURCE_DIR/logs . - fi + # handle case where the job is running for the first time. e.g where the job was not found. + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) + - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - - if [ "$id_previous" != "-1" ]; then + - if [ "$id_previous" != "-1" ]; then # Unzip artifacts to recover past logs dir - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip - else + - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip + - else # create logs dir if it doesn't exist - mkdir logs - fi + - mkdir logs + - fi - # create folder for today's results - TODAY=$(date +'%Y-%m-%d') - mkdir -p logs/$TODAY - - # Aggregate job logs - job_names="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" - for job_name in $job_names; do - echo "Getting job logs for: $job_name" - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip -d previous_artifacts - # This wildcard thingy relies on only one csv file being present per job - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY - rm artifacts.zip - rm -r previous_artifacts - done - ls logs - exit 0 + # create folder for today's results + - TODAY=$(date +'%Y-%m-%d') + - mkdir -p logs/$TODAY + + # Aggregate job logs + - job_names="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" + - for job_name in $job_names; do + - echo "Getting job logs for: $job_name" + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) + - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" + - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip -d previous_artifacts + - mv previous_artifacts/mld--"$job_name"-$id_previous--sha-*.csv logs/$TODAY + - rm artifacts.zip + - rm -r previous_artifacts + - done + - ls logs + - exit 0 artifacts: name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" @@ -1741,34 +1738,31 @@ backup-long-term-job-logs: timeout: "25 minutes" script: - !reference [ .job-linux, before_script ] - - | - set -euxo pipefail - echo "Running on RUNNER_TAG: $RUNNER_TAG" - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job name from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - - if [ "$id_previous" != "-1" ]; then + - set -euxo pipefail + - echo "Running on RUNNER_TAG: $RUNNER_TAG" + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + + # Find ID of last run of ivas-long-term-job-logs + - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH ivas-long-term-job-logs $CI_PROJECT_ID) + + - if [ "$id_previous" != "-1" ]; then # Unzip artifacts to recover past logs dir - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - unzip artifacts.zip - else + - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip + - unzip artifacts.zip + - else # create logs dir if it doesn't exist - mkdir logs - fi - - # Store logs as backup copy if LOGS_BACKUP_TARGET_DIR is set - if [ -d "$LOGS_BACKUP_TARGET_DIR" ]; then - cp -r logs $LOGS_BACKUP_TARGET_DIR/logs - exit 0; - else - echo "Error: LOGS_BACKUP_TARGET_DIR not set for backup job!" - exit -1; - fi + - mkdir logs + - fi - + # Store logs as backup copy if LOGS_BACKUP_TARGET_DIR is set + - if [ -d "$LOGS_BACKUP_TARGET_DIR" ]; then + - cp -r logs $LOGS_BACKUP_TARGET_DIR + - exit 0; + - else + - echo "Error: LOGS_BACKUP_TARGET_DIR not set for backup job!" + - exit -1; + - fi # --------------------------------------------------------------- -- GitLab From 38c9d7ebf050fd5b3a340a4b493e240a8d094691 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 13 Jul 2025 16:39:22 +0200 Subject: [PATCH 376/394] Change example backup folder in comment --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da736bfb4..890c6588e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1657,10 +1657,10 @@ voip-be-on-merge-request: - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py # To inject backup copy in manual trigger: -# - Store logs backup in accessible folder, e.g. /tmp/ivas +# - Store logs backup in accessible folder, e.g. /usr/local/backup # - Set MANUAL_PIPELINE_TRIGGER to long-term-logs # - Set RUNNER_TAG to specific runner with this folder prepared, e.g. test-ericsson-linux-runner-5 -# - Set LOGS_BACKUP_SOURCE_DIR to source folder, e.g. /tmp/ivas +# - Set LOGS_BACKUP_SOURCE_DIR to source folder, e.g. /usr/local/backup ivas-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" @@ -1724,10 +1724,10 @@ ivas-long-term-job-logs: expose_as: "ivas long term job logs results" # To store backup copy: -# - Prepare accessible folder for backup, e.g. /tmp/ivas +# - Prepare accessible folder for backup, e.g. /usr/local/backup # - Set MANUAL_PIPELINE_TRIGGER to backup-long-term-logs # - Set RUNNER_TAG to specific runner with this folder prepared, e.g. test-ericsson-linux-runner-5 -# - Set LOGS_BACKUP_TARGET_DIR to source folder, e.g. /tmp/ivas +# - Set LOGS_BACKUP_TARGET_DIR to source folder, e.g. /usr/local/backup backup-long-term-job-logs: rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "backup-long-term-logs" -- GitLab From ee10b8d473b9c6f8ea6ec2eb723ae1660d2f60f2 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 13 Jul 2025 16:52:20 +0200 Subject: [PATCH 377/394] Try to fix syntax errors --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 890c6588e..c44beb080 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1672,7 +1672,7 @@ ivas-long-term-job-logs: script: - !reference [ .job-linux, before_script ] - set -euxo pipefail - - echo "Running on RUNNER_TAG: $RUNNER_TAG" + - echo "Running on RUNNER_TAG = $RUNNER_TAG" - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh @@ -1685,7 +1685,7 @@ ivas-long-term-job-logs: # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - - echo "Job ID from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" + - echo "Job name from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" - if [ "$id_previous" != "-1" ]; then # Unzip artifacts to recover past logs dir @@ -1703,7 +1703,7 @@ ivas-long-term-job-logs: # Aggregate job logs - job_names="ivas-pytest-compare_ref-long-enc ivas-pytest-compare_ref-long-enc-lev+10 ivas-pytest-compare_ref-long-enc-lev-10 ivas-pytest-compare_ref-long-dec ivas-pytest-compare_ref-long-dec-lev+10 ivas-pytest-compare_ref-long-dec-lev-10 ivas-pytest-compare_ref-long-fx-fx ivas-pytest-compare_ref-long-fx-fx-lev+10 ivas-pytest-compare_ref-long-fx-fx-lev-10" - for job_name in $job_names; do - - echo "Getting job logs for: $job_name" + - echo "Getting job logs for $job_name" - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$job_name" $CI_PROJECT_ID) - echo "Job ID from variables - "$job_name", Job ID from script - $id_previous" - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip @@ -1739,7 +1739,7 @@ backup-long-term-job-logs: script: - !reference [ .job-linux, before_script ] - set -euxo pipefail - - echo "Running on RUNNER_TAG: $RUNNER_TAG" + - echo "Running on RUNNER_TAG = $RUNNER_TAG" - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh @@ -1760,7 +1760,7 @@ backup-long-term-job-logs: - cp -r logs $LOGS_BACKUP_TARGET_DIR - exit 0; - else - - echo "Error: LOGS_BACKUP_TARGET_DIR not set for backup job!" + - echo "Error - LOGS_BACKUP_TARGET_DIR not set for backup job!" - exit -1; - fi -- GitLab From 0b814f35b944b49e5efb621a32b560014ee4499b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Sun, 13 Jul 2025 17:15:43 +0200 Subject: [PATCH 378/394] Use zip -o in case of overlap between new/injected logs --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c44beb080..32a321bc6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1690,7 +1690,8 @@ ivas-long-term-job-logs: - if [ "$id_previous" != "-1" ]; then # Unzip artifacts to recover past logs dir - curl --request GET "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$id_previous/artifacts" --output artifacts.zip - - unzip artifacts.zip + # If there is overlap between injected log and new log, use the new logs. + - unzip -o artifacts.zip - else # create logs dir if it doesn't exist - mkdir logs -- GitLab From 5bd99fde185648dfd6320cfc0a6a622de50af72f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 14 Jul 2025 14:25:19 +0200 Subject: [PATCH 379/394] Fix excluding build jobs for pages job --- .gitlab-ci.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32a321bc6..3b3957c70 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -845,9 +845,7 @@ clang-format-check: # ensure that codec builds on linux build-codec-linux-make: rules: - - if: $CI_JOB_NAME == 'pages' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -866,9 +864,7 @@ build-codec-linux-make: # ensure that codec builds on linux with instrumentation active build-codec-linux-instrumented-make: rules: - - if: $CI_JOB_NAME == 'pages' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -887,9 +883,7 @@ build-codec-linux-instrumented-make: build-codec-linux-debugging-make: rules: - - if: $CI_JOB_NAME == 'pages' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -909,9 +903,7 @@ build-codec-linux-debugging-make: build-codec-windows-msbuild: rules: - - if: $CI_JOB_NAME == 'pages' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' + - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH -- GitLab From 027155f5e7083a465cb1950cf85f6f1d6c28ceba Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 14 Jul 2025 14:50:54 +0200 Subject: [PATCH 380/394] Fix for non-set LOGS_BACKUP_SOURCE_DIR --- .gitlab-ci.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b3957c70..1aea80f40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1671,11 +1671,15 @@ ivas-long-term-job-logs: # Clean up logs - if [ -d "logs" ]; then rm -rf "logs"; fi # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set - - if [ -d "$LOGS_BACKUP_SOURCE_DIR" ]; then - - cp -r $LOGS_BACKUP_SOURCE_DIR/logs . + - if [ "$LOGS_BACKUP_SOURCE_DIR" != "" ]; then + - cp_ret=0 + - cp -r $LOGS_BACKUP_SOURCE_DIR/logs ./ || cp_ret=$? + - if [ "$cp_ret" != 0 ]; then + - echo "Error -- Copying to $LOGS_BACKUP_SOURCE_DIR failed!" + - exit 1 + - fi - fi - # handle case where the job is running for the first time. e.g where the job was not found. - id_previous=$(python3 ci/get_id_of_last_job_occurence.py $CI_DEFAULT_BRANCH "$CI_JOB_NAME" $CI_PROJECT_ID) - echo "Job name from variables - "$CI_JOB_NAME", Job ID from script - $id_previous" @@ -1685,7 +1689,8 @@ ivas-long-term-job-logs: # If there is overlap between injected log and new log, use the new logs. - unzip -o artifacts.zip - else - # create logs dir if it doesn't exist + # create logs dir if it doesn't exist (should only happen in first run) + - echo "Could not find previous job, creating empty logs folder. If this is not the first run, an error likely happened!" - mkdir logs - fi @@ -1751,10 +1756,10 @@ backup-long-term-job-logs: # Store logs as backup copy if LOGS_BACKUP_TARGET_DIR is set - if [ -d "$LOGS_BACKUP_TARGET_DIR" ]; then - cp -r logs $LOGS_BACKUP_TARGET_DIR - - exit 0; + - exit 0 - else - echo "Error - LOGS_BACKUP_TARGET_DIR not set for backup job!" - - exit -1; + - exit 1 - fi -- GitLab From be56131768ac11b1da1faeeacef2c62d664a6c00 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 14 Jul 2025 16:00:54 +0530 Subject: [PATCH 381/394] Fix for 3GPP issue 1805: Regression, spike in BASOP decoder MASA LTV at 64 kbps and 16 kHz input Link #1805 --- lib_com/options.h | 2 ++ lib_dec/dec_tcx_fx.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 73144fdac..4f498c158 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -141,4 +141,6 @@ #define FIX_1818_WRONG_PIT_INIT /* VA: Fix wrong pitch initialization */ +#define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ + #endif diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index a35db1f8e..8009c69e0 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5646,7 +5646,12 @@ void decoder_tcx_tns_fx( test(); test(); test(); +#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT + test(); + IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) && whitenedDomain ) || GT_16( L_spec, L_frameTCX ) ) +#else IF( ( NE_16( hTcxCfg->fIsTNSAllowed, 0 ) && NE_16( fUseTns, 0 ) && NE_16( bfi, 1 ) ) || GT_16( L_spec, L_frameTCX ) ) +#endif { L = L_spec; move16(); @@ -5700,7 +5705,12 @@ void decoder_tcx_tns_fx( IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && st->tcxonly != 0 && isTCX5 != 0 ) { test(); +#ifdef NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT + test(); + IF( st->element_mode == EVS_MONO || ( LT_16( L_spec, L_frameTCX ) && !whitenedDomain ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ +#else IF( st->element_mode == EVS_MONO || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ +#endif { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); tmp = L_frameTCX; -- GitLab From 3c0cda94d0f4fce4ef06ca20a8c261c333c7fc7c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 15 Jul 2025 12:06:39 +0530 Subject: [PATCH 382/394] Edit variables.yml to test against 3gpp_issue_1805_floatcode_fix reference This change will be reverted after testing --- .gitlab-ci/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 96ef1f507..3e9c1e57b 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -1,6 +1,6 @@ variables: EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" - FLOAT_REF_BRANCH: "ivas-float-update" + FLOAT_REF_BRANCH: "3gpp_issue_1805_floatcode_fix" SCRIPTS_DIR: "/usr/local/scripts" LONG_TEST_SUITE: "tests/codec_be_on_mr_nonselection tests/renderer --param_file scripts/config/self_test_ltv.prm --use_ltv" LONG_TEST_SUITE_NO_RENDERER: "tests/codec_be_on_mr_nonselection --param_file scripts/config/self_test_ltv.prm --use_ltv" -- GitLab From 6fd44de77a9b1f08b7688b67ca9e3e6db7c5b73d Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 15 Jul 2025 13:56:44 +0530 Subject: [PATCH 383/394] Revert variables.yml change --- .gitlab-ci/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 3e9c1e57b..96ef1f507 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -1,6 +1,6 @@ variables: EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" - FLOAT_REF_BRANCH: "3gpp_issue_1805_floatcode_fix" + FLOAT_REF_BRANCH: "ivas-float-update" SCRIPTS_DIR: "/usr/local/scripts" LONG_TEST_SUITE: "tests/codec_be_on_mr_nonselection tests/renderer --param_file scripts/config/self_test_ltv.prm --use_ltv" LONG_TEST_SUITE_NO_RENDERER: "tests/codec_be_on_mr_nonselection --param_file scripts/config/self_test_ltv.prm --use_ltv" -- GitLab From 24a16072958365c020eeb1e1b010ee3a8a1717c1 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 15 Jul 2025 14:55:18 +0530 Subject: [PATCH 384/394] Fix for 3GPP issue 1778: Different codebook precision at encoder and decoder for McMASA and MASA Link #1778 Combined McMASA_LFEGain_vectors_fx_q13 and McMASA_LFEGain_vectors_fx_q25 into McMASA_LFEGain_vectors_fx maintained in Q25. --- lib_com/ivas_rom_com_fx.c | 14 +------------- lib_com/ivas_rom_com_fx.h | 3 +-- lib_dec/ivas_masa_dec_fx.c | 10 +++++----- lib_enc/ivas_masa_enc_fx.c | 2 +- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index 1cfe1ff6c..b64ac5635 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -483,20 +483,8 @@ const Word32 dft_res_gains_q_fx[][2] = { }; -// Q13 -const Word16 McMASA_LFEGain_vectors_fx_q13[64] = { - 3113, 2703, 1556, 1638, -1311, -1802, -2867, -2785, - 4096, 4096, 4096, 4096, -6554, -3277, 8356, 819, - -4096, -4096, -4096, -4096, -4588, -983, -6390, 11141, - -8356, 9667, -4669, 2703, 5898, -9257, 7946, -5079, - -7455, 7619, 8192, -9011, 14172, -1884, -6390, -6881, - 7782, -13107, -2785, 7619, 7127, 3850, -15565, 4260, - 5489, 11633, -7946, -10158, 6799, 4751, 4997, -16712, - -6554, -12943, 6717, 11633, -17531, 2130, 6881, 8356 -}; - // Q25 -const Word32 McMASA_LFEGain_vectors_fx_q25[64] = { +const Word32 McMASA_LFEGain_vectors_fx[64] = { 12750684, 11072963, 6375342, 6710886, /* 1st bit */ -5368709, -7381975, -11744051, -11408507, 16777216, 16777216, 16777216, 16777216, /* 2nd bit*/ diff --git a/lib_com/ivas_rom_com_fx.h b/lib_com/ivas_rom_com_fx.h index 3344a35d2..2619a3f26 100644 --- a/lib_com/ivas_rom_com_fx.h +++ b/lib_com/ivas_rom_com_fx.h @@ -56,8 +56,7 @@ extern const Word16 dft_trigo_12k8_fx[STEREO_DFT_N_12k8_ENC / 4 + 1]; extern const Word16 dft_trigo_32k_fx[STEREO_DFT_N_32k_ENC / 4 + 1]; extern const Word16 dft_trigo_48k_fx[STEREO_DFT_N_MAX_ENC / 4 + 1]; extern const Word16 gridEq_Table[NO_THETA16_MAX]; -extern const Word16 McMASA_LFEGain_vectors_fx_q13[64]; -extern const Word32 McMASA_LFEGain_vectors_fx_q25[64]; +extern const Word32 McMASA_LFEGain_vectors_fx[64]; /* Q25 */ extern const Word16 ivas_divde_255[256]; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 457c040c3..6363bdf74 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1533,11 +1533,11 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( } ELSE { - tmp16 = shr( McMASA_LFEGain_vectors_fx_q13[4 * lfeToTotalEnergyRatioIndices[2] + i], 1 ); /* Q12 */ - tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ - tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ - tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ - hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ + tmp16 = shr( extract_l( L_shr_r( McMASA_LFEGain_vectors_fx[4 * lfeToTotalEnergyRatioIndices[2] + i], Q12 ) ), 1 ); /* Q12 */ + tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ + tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ + tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ + hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ move16(); } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 35c57c42b..b87bcf88b 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -2842,7 +2842,7 @@ static Word16 encode_lfe_to_total_energy_ratio_fx( IF( VQLevels > 0 ) { - lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx_q25, 4, VQLevels ); + lfeToTotalEnergyRatioIndices[2] = vquant_ivas_fx( log2LFEratio, 0, xqv, McMASA_LFEGain_vectors_fx, 4, VQLevels ); move16(); } } -- GitLab From d7fd73405197a5e802f73c6e7f357ed8d7a49247 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 16 Jul 2025 15:14:43 +0530 Subject: [PATCH 385/394] Bug fix: Scaling issue fix in CNG_enc_ivas_fx Link #1775 Fixes issue at time frame 16s-18s in #1775 --- lib_enc/cng_enc_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index 6dc3963f8..ed3663732 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -1261,11 +1261,11 @@ void CNG_enc_ivas_fx( move16(); /* Temp variables for floating point functions */ - lp_ener_thr_scale = 8; /* 4.0f*/ /* Q2 */ + lp_ener_thr_scale = 8; /* 4.0f*/ /* Q1 */ move16(); if ( st_fx->element_mode != EVS_MONO ) { - lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q2 */ + lp_ener_thr_scale = 7; /* 3.5f;*/ /* Q1 */ move16(); } @@ -1634,7 +1634,7 @@ void CNG_enc_ivas_fx( IF( hTdCngEnc->burst_ho_cnt > 0 ) { /**allow_cn_step |= ( hDtxEnc->first_CNG || st->element_mode == EVS_MONO ) && ( hTdCngEnc->ho_ener_hist[hTdCngEnc->ho_hist_ptr] > lp_ener_thr_scale * hTdCngEnc->lp_ener );*/ - w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 1 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q7*/ + w_temp = W_msu_32_16( W_shl( W_deposit32_l( hTdCngEnc->ho_ener_hist_fx[hTdCngEnc->ho_hist_ptr] ), 2 ), hTdCngEnc->lp_ener_fx, lp_ener_thr_scale ); /*Q8*/ test(); test(); -- GitLab From 2442c7da345f011c83f362f624affe18e6122aec Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 14 Jul 2025 11:38:58 +0530 Subject: [PATCH 386/394] Fix for 3GPP issue 784: BASOP decoder without JBM not BE to BASOP decoder with zero-delay profile Link #784 --- lib_dec/ivas_jbm_dec_fx.c | 14 ++-- lib_dec/ivas_mc_param_dec_fx.c | 5 +- lib_dec/jbm_pcmdsp_apa_fx.c | 116 ++++++++++++++++++--------------- 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index d00a9fe80..0cc6f1828 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4066,15 +4066,15 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( &cldfb_real_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], &cldfb_imag_buffer_fx[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &Q_tc ); - IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) - { - st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = sub( 31, Q_tc ); - st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = sub( 31, Q_tc ); - move16(); - move16(); - } } } + IF( EQ_16( (Word16) st_ivas->ivas_format, (Word16) MC_FORMAT ) ) + { + st_ivas->hParamMC->Cldfb_RealBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = 25; // 31-Q_tc = 31-(11-5) + move16(); + move16(); + } } hTcBuffer->n_samples_rendered = 0; move16(); diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 71c1b39fc..e20610dab 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -528,12 +528,15 @@ ivas_error ivas_param_mc_dec_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size ); + hParamMC->Cldfb_RealBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); } set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, cldfb_buf_size ); - + hParamMC->Cldfb_ImagBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases + move16(); hParamMC->sz = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands ); move16(); diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index e2528e619..e98e7781a 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -962,72 +962,81 @@ UWord8 apa_exec_ivas_fx( } ELSE { - Word16 a_tmp[APA_BUF]; - Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); - Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); - - Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out - move16(); - } - Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out - - /* fill input frame */ - /* 1st input frame: previous output samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in[i] = buf_out_ptr[i]; - move16(); - } - /* 2nd input frame: new input samples */ - FOR( i = 0; i < ps->l_frm; i++ ) - { - frm_in_ptr[i] = a_tmp[i]; - move16(); - } - /* no scaling */ IF( EQ_32( ps->scale, 100 ) ) { - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); - } - /* shrink */ - ELSE IF( LT_32( ps->scale, 100 ) ) - { - shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = a_in[i]; // Q11 + move32(); + } + l_frm_out = ps->l_frm; + move16(); } - /* extend */ ELSE { - extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); - } - /* control the amount/frequency of scaling */ - IF( NE_32( l_frm_out, ps->l_frm ) ) - { - test(); - IF( ( maxScaling != 0 ) && - GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) + + Word16 a_tmp[APA_BUF]; + Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); + Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); + + Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) { - /* maxScaling exceeded -> discard scaled frame */ - copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out + move16(); } - ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out + + /* fill input frame */ + /* 1st input frame: previous output samples */ + FOR( i = 0; i < ps->l_frm; i++ ) { - dl_copied = L_sub( l_frm_out_target, ps->l_frm ); - dl_scaled = L_sub( l_frm_out_target, l_frm_out ); - /* discard scaled frame if copied frame is closer to target length */ - IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + frm_in[i] = buf_out_ptr[i]; + move16(); + } + /* 2nd input frame: new input samples */ + FOR( i = 0; i < ps->l_frm; i++ ) + { + frm_in_ptr[i] = a_tmp[i]; + move16(); + } + /* shrink */ + IF( LT_32( ps->scale, 100 ) ) + { + shrink_frm_ivas_fx( ps, frm_in, maxScaling, a_tmp, Q_a_out, &l_frm_out ); + } + /* extend */ + ELSE + { + extend_frm_ivas_fx( ps, frm_in, a_tmp, Q_a_out, &l_frm_out ); + } + /* control the amount/frequency of scaling */ + IF( NE_32( l_frm_out, ps->l_frm ) ) + { + test(); + IF( ( maxScaling != 0 ) && + GT_32( abs_s( extract_l( L_sub( ps->l_frm, l_frm_out ) ) ), maxScaling ) ) { + /* maxScaling exceeded -> discard scaled frame */ copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); } + ELSE IF( GT_32( L_abs( l_frm_out_target ), ps->l_frm ) ) /* ignore small difference */ + { + dl_copied = L_sub( l_frm_out_target, ps->l_frm ); + dl_scaled = L_sub( l_frm_out_target, l_frm_out ); + /* discard scaled frame if copied frame is closer to target length */ + IF( LT_32( L_abs( dl_copied ), L_abs( dl_scaled ) ) ) + { + copy_frm_fx( ps, frm_in, a_tmp, &l_frm_out ); + } + } } - } - FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) - { - a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 - move32(); + FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) + { + a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 + move32(); + } } } @@ -1532,7 +1541,6 @@ static bool copy_frm_fx( return 0; } - /* ******************************************************************************** * -- GitLab From ac07b6eeead95ce22113b73ed0138b32a0850407 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 16 Jul 2025 16:11:56 +0530 Subject: [PATCH 387/394] Fix for high MLD observed with some STV test cases --- lib_dec/jbm_pcmdsp_apa_fx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index e98e7781a..0321a6495 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -962,6 +962,11 @@ UWord8 apa_exec_ivas_fx( } ELSE { + Word16 a_tmp[APA_BUF]; + Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); + + Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); + Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out IF( EQ_32( ps->scale, 100 ) ) { FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) @@ -974,19 +979,13 @@ UWord8 apa_exec_ivas_fx( } ELSE { - - Word16 a_tmp[APA_BUF]; - Word16 *buf_out_ptr = &( ps->buf_out_fx[ps->l_buf_out - ps->l_frm] ); Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); - Q_a_out = s_min( Q_a_out, ps->Q_buf_out ); FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) { a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out move16(); } - Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out - /* fill input frame */ /* 1st input frame: previous output samples */ FOR( i = 0; i < ps->l_frm; i++ ) -- GitLab From 974ff5f4d9028120ffbc0201feee8098aa715e04 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 16 Jul 2025 17:35:11 +0530 Subject: [PATCH 388/394] Fix for 3GPP issue 1823: Decoder segfault for Stereo at 24.4 / 32 kbps FER in ivas_spec_ana_fx() Link #1823 --- lib_dec/FEC_HQ_phase_ecu_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 7c4c91936..4be003ecb 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -1440,7 +1440,7 @@ static void ivas_spec_ana_fx( man = mult_r( man, FEC_HQ_ECU_ROOT2 ); /* FEC_HQ_ECU_ROOT2 is sqrt(2) in Q14 */ expoBy2 = sub( expoBy2, 1 ); } - *pXfp++ = shr( man, expoBy2 ); + *pXfp++ = shr_sat( man, expoBy2 ); move16(); /* Denormalize the mantissa back to Q0. */ } } @@ -2138,7 +2138,7 @@ static void ivas_subst_spec_fx( move16(); im = *pImX; move16(); - tmp = sub( mult_r( re, cos_F ), mult_r( im, sin_F ) ); + tmp = sub_sat( mult_r( re, cos_F ), mult_r( im, sin_F ) ); im = add( mult_r( re, sin_F ), mult_r( im, cos_F ) ); IF( LT_16( alpha[k], 32766 ) ) { -- GitLab From 6b8a3beba2de47ca92257c18c3e72a8bc442cad3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 16 Jul 2025 17:38:30 +0530 Subject: [PATCH 389/394] Binaural renderer optimization - non bit exact changes Around 6 WMOPs reduction observed for multichannel test case. MLD deviation < 1. --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 722 +++++++++++++------------ 2 files changed, 385 insertions(+), 338 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4f498c158..396d21f6c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,6 +81,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_MCT_ENC_V3_NBE #define OPT_MCT_ENC_V2_BE +#define OPT_BIN_REND_V2_NBE #define OPT_MCH_DEC_V1_NBE #define OPT_MASA_DEC_V1_NBE #define OPT_MASA_DEC_V2_NBE diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index efd9d0c67..5c2c73026 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -72,12 +72,17 @@ static void ivas_binRenderer_filterModule_fx( Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; move16(); - // to be checked: feasibility with 32 bit buffers +#ifdef OPT_BIN_REND_V2_NBE + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); + hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; +#else /* OPT_BIN_REND_V2_NBE */ Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif /* OPT_BIN_REND_V2_NBE */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { +#ifndef OPT_BIN_REND_V2_NBE set64_fx( &Cldfb_RealBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); set64_fx( &Cldfb_ImagBuffer_64fx[0][0], 0, BINAURAL_CHANNELS * MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -91,6 +96,7 @@ static void ivas_binRenderer_filterModule_fx( filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 +#endif /* OPT_BIN_REND_V2_NBE */ FOR( k = 0; k < numTimeSlots; k++ ) { Word64 outRealLeft_fx = 0, outRealRight_fx = 0, outImagLeft_fx = 0, outImagRight_fx = 0; @@ -98,469 +104,509 @@ static void ivas_binRenderer_filterModule_fx( move64(); move64(); move64(); +#ifdef OPT_BIN_REND_V2_NBE + Word64 outRealLeft = 0, outRealRight = 0, outImagLeft = 0, outImagRight = 0; + move64(); + move64(); + move64(); + move64(); - FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; - move32(); - filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; - move32(); - Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); - - - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); + filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 + filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 + filterTapsRightRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx]; // Q29 + filterTapsRightImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx]; // Q29 +#endif /* OPT_BIN_REND_V2_NBE */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates - } + FOR( tapIdx = hBinRenderer->hBinRenConvModule->numTapsArray[bandIdx] - 1; tapIdx > 0; tapIdx-- ) + { + filterStatesLeftRealPtr_fx[tapIdx] = filterStatesLeftRealPtr_fx[tapIdx - 1]; + move32(); + filterStatesLeftImagPtr_fx[tapIdx] = filterStatesLeftImagPtr_fx[tapIdx - 1]; + move32(); + Word32 neg_filterStatesLeftImagPtr_fx = L_negate( filterStatesLeftImagPtr_fx[tapIdx] ); - shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); - IF( shift_q != 0 ) - { - outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 - outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 - outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 - outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 - hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; - move16(); - } + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_filterStatesLeftImagPtr_fx, filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; - move32(); - filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; - move32(); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsLeftImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsLeftRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_filterStatesLeftImagPtr_fx, filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates - /* Left Real and Imag */ + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftRealPtr_fx[tapIdx], filterTapsRightImagPtr_fx[tapIdx] ); // Q30 + Q_filterStates + outImagRight_fx = W_mac_32_32( outImagRight_fx, filterStatesLeftImagPtr_fx[tapIdx], filterTapsRightRealPtr_fx[tapIdx] ); // Q30 + Q_filterStates + } - Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 - Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 - Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 +#ifndef OPT_BIN_REND_V2_NBE + shift_q = add( sub( Q_filterStates, Q_curr ), 1 ); + IF( shift_q != 0 ) + { + outRealLeft_fx = W_shr( outRealLeft_fx, shift_q ); // Q_curr + Q29 + outImagLeft_fx = W_shr( outImagLeft_fx, shift_q ); // Q_curr + Q29 + outRealRight_fx = W_shr( outRealRight_fx, shift_q ); // Q_curr + Q29 + outImagRight_fx = W_shr( outImagRight_fx, shift_q ); // Q_curr + Q29 + hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; + move16(); + } +#endif /* OPT_BIN_REND_V2_NBE */ + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); - outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr - move64(); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); - outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr - move64(); +#ifdef OPT_BIN_REND_V2_NBE + /* Left Real and Imag */ + Word32 neg_temp2 = L_negate( filterStatesLeftImagPtr_fx[0] ); // Q_curr -1 - /* Right Real and Imag */ - outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); - outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); - Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr - move64(); + outRealLeft = W_mac_32_32( W_mac_32_32( outRealLeft, filterStatesLeftRealPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), neg_temp2, filterTapsLeftImagPtr_fx[0] ); + outImagLeft = W_mac_32_32( W_mac_32_32( outImagLeft, filterStatesLeftImagPtr_fx[0], filterTapsLeftRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsLeftImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); - outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); - Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr - move64(); - } - } - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) - { - out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + /* Right Real and Imag */ + outRealRight = W_mac_32_32( W_mac_32_32( outRealRight, neg_temp2, filterTapsRightImagPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightRealPtr_fx[0] ); + outImagRight = W_mac_32_32( W_mac_32_32( outImagRight, filterStatesLeftImagPtr_fx[0], filterTapsRightRealPtr_fx[0] ), filterStatesLeftRealPtr_fx[0], filterTapsRightImagPtr_fx[0] ); + } + out_Conv_CLDFB_real[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealLeft_fx, shift_q ), W_shr( outRealLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_real[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outRealRight_fx, shift_q ), W_shr( outRealRight, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[0][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagLeft_fx, shift_q ), W_shr( outImagLeft, 1 ) ), shift_q6 ); + out_Conv_CLDFB_imag[1][k][bandIdx] = W_shl_sat_l( W_add( W_shr( outImagRight_fx, shift_q ), W_shr( outImagRight, 1 ) ), shift_q6 ); + move32(); + move32(); move32(); - out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 move32(); } +#else /* OPT_BIN_REND_V2_NBE */ + /* Left Real and Imag */ + + Word32 temp1 = L_shr( filterStatesLeftRealPtr_fx[0], 1 ); // Q_curr -1 + Word32 temp2 = L_shr( filterStatesLeftImagPtr_fx[0], 1 ); // Q_curr -1 + Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 + + + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); + outRealLeft_fx = W_mac_32_32( outRealLeft_fx, neg_temp2, filterTapsLeftImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[0][k] = W_add( Cldfb_RealBuffer_64fx[0][k], outRealLeft_fx ); // Q29 + Q_curr + move64(); + + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp1, filterTapsLeftImagPtr_fx[0] ); + outImagLeft_fx = W_mac_32_32( outImagLeft_fx, temp2, filterTapsLeftRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[0][k] = W_add( Cldfb_ImagBuffer_64fx[0][k], outImagLeft_fx ); // Q29 + Q_curr + move64(); + + /* Right Real and Imag */ + outRealRight_fx = W_mac_32_32( outRealRight_fx, temp1, filterTapsRightRealPtr_fx[0] ); + outRealRight_fx = W_mac_32_32( outRealRight_fx, neg_temp2, filterTapsRightImagPtr_fx[0] ); + Cldfb_RealBuffer_64fx[1][k] = W_add( Cldfb_RealBuffer_64fx[1][k], outRealRight_fx ); // Q29 + Q_curr + move64(); + + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp1, filterTapsRightImagPtr_fx[0] ); + outImagRight_fx = W_mac_32_32( outImagRight_fx, temp2, filterTapsRightRealPtr_fx[0] ); + Cldfb_ImagBuffer_64fx[1][k] = W_add( Cldfb_ImagBuffer_64fx[1][k], outImagRight_fx ); // Q29 + Q_curr + move64(); } } - - - return; -} - -/*------------------------------------------------------------------------- - * ivas_binRenderer_convModuleOpen() - * - * Open convolution module handle of fastconv binaural renderer - *-------------------------------------------------------------------------*/ -static ivas_error ivas_binRenderer_convModuleOpen( - BINAURAL_RENDERER_HANDLE hBinRenderer, - const Word16 renderer_type, - const Word16 isLoudspeaker, - const AUDIO_CONFIG input_config, - const HRTFS_FASTCONV_HANDLE hHrtf ) -{ - Word16 bandIdx, chIdx; - - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - - /*-----------------------------------------------------------------* - * prepare library opening - *-----------------------------------------------------------------*/ - - IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) + FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + FOR( k = 0; k < MAX_PARAM_SPATIAL_SUBFRAMES; k++ ) + { + out_Conv_CLDFB_real[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_RealBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + } } +#endif /* OPT_BIN_REND_V2_NBE */ + } - IF( !isLoudspeaker ) - { - hBinRenderer->nInChannels = audioCfg2channels( input_config ); - move16(); - } - ELSE - { - /* Note: needs to be revisited if multiple LFE support is required */ - hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); - move16(); + + return; } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + /*------------------------------------------------------------------------- + * ivas_binRenderer_convModuleOpen() + * + * Open convolution module handle of fastconv binaural renderer + *-------------------------------------------------------------------------*/ + static ivas_error ivas_binRenderer_convModuleOpen( + BINAURAL_RENDERER_HANDLE hBinRenderer, + const Word16 renderer_type, + const Word16 isLoudspeaker, + const AUDIO_CONFIG input_config, + const HRTFS_FASTCONV_HANDLE hHrtf ) { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; - move16(); + Word16 bandIdx, chIdx; - /* Use variable order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < 5; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; - move16(); - } - FOR( ; bandIdx < 10; bandIdx++ ) + BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + IF( ( hBinRenConvModule = (BINRENDERER_CONV_MODULE_HANDLE_FX) malloc( sizeof( BINRENDERER_CONV_MODULE_FX ) ) ) == NULL ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; - move16(); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( ; bandIdx < 20; bandIdx++ ) + + IF( !isLoudspeaker ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + hBinRenderer->nInChannels = audioCfg2channels( input_config ); move16(); } - FOR( ; bandIdx < 30; bandIdx++ ) + ELSE { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + /* Note: needs to be revisited if multiple LFE support is required */ + hBinRenderer->nInChannels = sub( audioCfg2channels( input_config ), isLoudspeaker ); move16(); } - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { - hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + hBinRenConvModule->numTaps = BINAURAL_NTAPS_MAX; move16(); - } - } - ELSE - { - IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) - { - hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + + /* Use variable order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < 5; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } + FOR( ; bandIdx < 10; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_6; + move16(); + } + FOR( ; bandIdx < 20; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_5; + move16(); + } + FOR( ; bandIdx < 30; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_4; + move16(); + } + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = NUM_TAPS_F0_3; + move16(); + } } ELSE { - hBinRenConvModule->numTaps = BINAURAL_NTAPS; - move16(); - } + IF( EQ_16( hBinRenderer->ivas_format, SBA_FORMAT ) ) + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS_SBA; + move16(); + } + ELSE + { + hBinRenConvModule->numTaps = BINAURAL_NTAPS; + move16(); + } - /* Use fixed order filtering */ - bandIdx = 0; - move16(); - FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + /* Use fixed order filtering */ + bandIdx = 0; move16(); + FOR( ; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + hBinRenConvModule->numTapsArray[bandIdx] = hBinRenConvModule->numTaps; + move16(); + } } - } - - /* allocate memory for filter states */ - IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + /* allocate memory for filter states */ + IF( ( hBinRenConvModule->filterTapsLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterTapsRightImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + IF( ( hBinRenConvModule->filterTapsLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } + IF( ( hBinRenConvModule->filterTapsRightReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + IF( ( hBinRenConvModule->filterTapsRightImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); + } + } - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + + IF( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx = (Word32 ***) malloc( hBinRenderer->conv_band * sizeof( Word32 ** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - IF( ( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = (Word32 **) malloc( hBinRenderer->nInChannels * sizeof( Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } - } - /* set memories */ - FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - Word16 tmp = 0; - move16(); - IF( isLoudspeaker ) + + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) - { - tmp = channelIndex_CICP6[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) - { - tmp = channelIndex_CICP12[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) - { - tmp = channelIndex_CICP14[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) - { - tmp = channelIndex_CICP16[chIdx]; - move16(); - } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) + IF( ( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { - tmp = channelIndex_CICP19[chIdx]; - move16(); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } - } - IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) - { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); - hBinRenConvModule->Q_filterStatesLeft = 31; - move16(); - IF( isLoudspeaker ) + IF( ( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * sizeof( Word32 ) ) ) == NULL ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); } } - ELSE + } + /* set memories */ + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { - /* set the memories to zero */ - set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); - hBinRenConvModule->Q_filterStatesLeft = 31; + Word16 tmp = 0; move16(); + IF( isLoudspeaker ) { - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; - } - ELSE - { - IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1 ) ) + { + tmp = channelIndex_CICP6[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1 ) ) + { + tmp = channelIndex_CICP12[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_2 ) ) + { + tmp = channelIndex_CICP14[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_5_1_4 ) ) + { + tmp = channelIndex_CICP16[chIdx]; + move16(); + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_7_1_4 ) ) { - /* HOA3 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + tmp = channelIndex_CICP19[chIdx]; + move16(); } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + } + + IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTapsArray[bandIdx] ); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); + IF( isLoudspeaker ) { - /* HOA2 filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftBRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightBRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightBRIRImag_fx[bandIdx][tmp]; } - ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + } + ELSE + { + /* set the memories to zero */ + set32_fx( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + set32_fx( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx], 0, hBinRenConvModule->numTaps ); + hBinRenConvModule->Q_filterStatesLeft = 31; + move16(); + IF( isLoudspeaker ) { - /* FOA filter coefficients */ - hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; - hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_fx[bandIdx][tmp]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_fx[bandIdx][tmp]; } ELSE { - return IVAS_ERR_INVALID_INPUT_FORMAT; + IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA3 ) ) + { + /* HOA3 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA3_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA3_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_HOA2 ) ) + { + /* HOA2 filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_HOA2_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_HOA2_fx[bandIdx][chIdx]; + } + ELSE IF( EQ_16( input_config, IVAS_AUDIO_CONFIG_FOA ) ) + { + /* FOA filter coefficients */ + hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx] = hHrtf->leftHRIRImag_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightReal_fx[bandIdx][chIdx] = hHrtf->rightHRIRReal_FOA_fx[bandIdx][chIdx]; + hBinRenConvModule->filterTapsRightImag_fx[bandIdx][chIdx] = hHrtf->rightHRIRImag_FOA_fx[bandIdx][chIdx]; + } + ELSE + { + return IVAS_ERR_INVALID_INPUT_FORMAT; + } } } } } - } - - - hBinRenderer->hBinRenConvModule = hBinRenConvModule; - - return IVAS_ERR_OK; -} -/*-------------------------------------------------------------------------* - * ivas_init_binaural_hrtf() - * - * initialize memory for HrtfFastConv structure elements - *-------------------------------------------------------------------------*/ -void ivas_init_binaural_hrtf_fx( - HRTFS_FASTCONV *HrtfFastConv /* i/o: FASTCONV HRTF structure */ -) -{ - Word16 i; - HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; - HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; - move32(); + hBinRenderer->hBinRenConvModule = hBinRenConvModule; - HrtfFastConv->leftHRIRReal_fx = NULL; - HrtfFastConv->leftHRIRImag_fx = NULL; - HrtfFastConv->rightHRIRReal_fx = NULL; - HrtfFastConv->rightHRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; - move32(); + return IVAS_ERR_OK; + } - HrtfFastConv->leftBRIRReal_fx = NULL; - HrtfFastConv->leftBRIRImag_fx = NULL; - HrtfFastConv->rightBRIRReal_fx = NULL; - HrtfFastConv->rightBRIRImag_fx = NULL; - HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; - move32(); + /*-------------------------------------------------------------------------* + * ivas_init_binaural_hrtf() + * + * initialize memory for HrtfFastConv structure elements + *-------------------------------------------------------------------------*/ + void ivas_init_binaural_hrtf_fx( + HRTFS_FASTCONV * HrtfFastConv /* i/o: FASTCONV HRTF structure */ + ) + { + Word16 i; - HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; - HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; - HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; - HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; - HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_HOA3_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA3_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA3_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA3_fx = NULL; + HrtfFastConv->FASTCONV_HOA3_latency_s_fx = 0; + move32(); - HrtfFastConv->leftHRIRReal_FOA_fx = NULL; - HrtfFastConv->leftHRIRImag_FOA_fx = NULL; - HrtfFastConv->rightHRIRReal_FOA_fx = NULL; - HrtfFastConv->rightHRIRImag_FOA_fx = NULL; - HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; - move32(); + HrtfFastConv->leftHRIRReal_fx = NULL; + HrtfFastConv->leftHRIRImag_fx = NULL; + HrtfFastConv->rightHRIRReal_fx = NULL; + HrtfFastConv->rightHRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_HRIR_latency_s_fx = 0; + move32(); - HrtfFastConv->allocate_init_flag = 0; - move16(); + HrtfFastConv->leftBRIRReal_fx = NULL; + HrtfFastConv->leftBRIRImag_fx = NULL; + HrtfFastConv->rightBRIRReal_fx = NULL; + HrtfFastConv->rightBRIRImag_fx = NULL; + HrtfFastConv->FASTCONV_BRIR_latency_s_fx = 0; + move32(); - FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - { - HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + HrtfFastConv->leftHRIRReal_HOA2_fx = NULL; + HrtfFastConv->leftHRIRImag_HOA2_fx = NULL; + HrtfFastConv->rightHRIRReal_HOA2_fx = NULL; + HrtfFastConv->rightHRIRImag_HOA2_fx = NULL; + HrtfFastConv->FASTCONV_HOA2_latency_s_fx = 0; move32(); - HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + + HrtfFastConv->leftHRIRReal_FOA_fx = NULL; + HrtfFastConv->leftHRIRImag_FOA_fx = NULL; + HrtfFastConv->rightHRIRReal_FOA_fx = NULL; + HrtfFastConv->rightHRIRImag_FOA_fx = NULL; + HrtfFastConv->FASTCONV_FOA_latency_s_fx = 0; move32(); - } - return; -} + HrtfFastConv->allocate_init_flag = 0; + move16(); -/*-------------------------------------------------------------------------* - * ivas_alloc_pppMem() - * - * Allocate memory for tripple pointer elements - *-------------------------------------------------------------------------*/ -static ivas_error ivas_alloc_pppMem_fx( - Word32 ****pppMem, /*Qx*/ - const Word16 dim1, - const Word16 dim2, - const Word16 dim3, - const Word16 allocate_init_flag ) -{ - Word16 i, j; - Word32 ***localMem = NULL; + FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + HrtfFastConv->fastconvReverberationTimes_fx[i] = 0; + move32(); + HrtfFastConv->fastconvReverberationEneCorrections_fx[i] = 0; + move32(); + } - IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + return; } - FOR( i = 0; i < dim1; i++ ){ - IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); -} -IF( allocate_init_flag == 0 ) -{ - FOR( j = 0; j < dim2; j++ ) + /*-------------------------------------------------------------------------* + * ivas_alloc_pppMem() + * + * Allocate memory for tripple pointer elements + *-------------------------------------------------------------------------*/ + static ivas_error ivas_alloc_pppMem_fx( + Word32 * ***pppMem, /*Qx*/ + const Word16 dim1, + const Word16 dim2, + const Word16 dim3, + const Word16 allocate_init_flag ) { - IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + Word16 i, j; + Word32 ***localMem = NULL; + + IF( ( localMem = (Word32 ***) malloc( dim1 * sizeof( Word32 ** ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); } + + FOR( i = 0; i < dim1; i++ ){ + IF( ( localMem[i] = (Word32 **) malloc( dim2 * sizeof( Word32 * ) ) ) == NULL ){ + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + IF( allocate_init_flag == 0 ) + { + FOR( j = 0; j < dim2; j++ ) + { + IF( ( localMem[i][j] = (Word32 *) malloc( dim3 * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HRTF memory" ); + } + } } -} } *pppMem = localMem; -- GitLab From 0557ff21f6afd8215d2f22007f11e7cbf67b913d Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 16 Jul 2025 17:42:25 +0200 Subject: [PATCH 390/394] Add one more bit headroom to product, to avoid assert failure in getSqrtWord32() for values larger than 0x3FFEC004. --- lib_com/options.h | 2 ++ lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 396d21f6c..48d8593c8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -144,4 +144,6 @@ #define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ +#define FIX_1824 + #endif diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index baad5c561..f9ac53b62 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -113,9 +113,15 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, sumXX = L_shl( sumXX, normX ); normY = norm_l( sumYY ); sumYY = L_shl( sumYY, normY ); +#ifdef FIX_1824 + product = L_shr(L_mult0( extract_h( sumXX ), extract_h( sumYY ) ), 1 ); + normXY = add( normX, normY ); + normXY = sub( normXY, 32 + 1 ); +#else product = L_mult0( extract_h( sumXX ), extract_h( sumYY ) ); normXY = add( normX, normY ); normXY = sub( normXY, 32 ); +#endif /* change norm to factor of 2 */ IF( s_and( normXY, 0x1 ) != 0 ) -- GitLab From c772a10ef9cb5eb8794d5b59287dce404e964358 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 16 Jul 2025 17:49:35 +0200 Subject: [PATCH 391/394] Clang format --- lib_dec/jbm_pcmdsp_similarityestimation_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c index f9ac53b62..7015022eb 100644 --- a/lib_dec/jbm_pcmdsp_similarityestimation_fx.c +++ b/lib_dec/jbm_pcmdsp_similarityestimation_fx.c @@ -114,7 +114,7 @@ Word16 normalized_cross_correlation_self_fx( const Word16 *signal, normY = norm_l( sumYY ); sumYY = L_shl( sumYY, normY ); #ifdef FIX_1824 - product = L_shr(L_mult0( extract_h( sumXX ), extract_h( sumYY ) ), 1 ); + product = L_shr( L_mult0( extract_h( sumXX ), extract_h( sumYY ) ), 1 ); normXY = add( normX, normY ); normXY = sub( normXY, 32 + 1 ); #else -- GitLab From bd37b471626ba0330e22e64cf54fbc68997bf687 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 17 Jul 2025 13:51:50 +0530 Subject: [PATCH 392/394] Multichannel encoder optmizations - bit exact Optimizations made in ivas_find_enr, dot_product_cholesky_fixed, tcx_res_Q_spec_ivas_fx, tcx_noise_factor_ivas_fx, IGF_getCrest_new_fx Around 2.2 WMOPs reduction observed. Changes are bit exact --- lib_com/ivas_tools_fx.c | 10 ++++++ lib_com/options.h | 1 + lib_enc/analy_sp_fx.c | 22 ++++++++++++ lib_enc/igf_enc.c | 4 +++ lib_enc/ivas_sns_enc_fx.c | 2 +- lib_enc/tcx_utils_enc_fx.c | 71 +++++++++++++++++++++++++++----------- 6 files changed, 89 insertions(+), 21 deletions(-) diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e334a8cda..a1b484f6d 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -606,7 +606,9 @@ Word64 dot_product_cholesky_fixed( { Word16 i, j; Word64 suma, tmp_sum; +#ifndef OPT_MCT_ENC_V3_BE Word32 mul; +#endif Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; @@ -621,12 +623,20 @@ Word64 dot_product_cholesky_fixed( FOR( j = 0; j <= i; j++ ) { +#ifdef OPT_MCT_ENC_V3_BE + tmp_sum = W_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); +#else mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); +#endif } +#ifdef OPT_MCT_ENC_V3_BE + tmp = W_shl_sat_l( tmp_sum, -4 ); // to make sure that the tmp_sum will not overflow +#else tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); +#endif suma = W_mac_32_32( suma, tmp, tmp ); } diff --git a/lib_com/options.h b/lib_com/options.h index 48d8593c8..90f1239d8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V3_BE #define OPT_MCT_ENC_V3_NBE #define OPT_MCT_ENC_V2_BE #define OPT_BIN_REND_V2_NBE diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 0d42e5ff2..48ed114c7 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -727,6 +727,9 @@ static void ivas_find_enr( Word32 min_ener; Word16 shift = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + Word16 tmp_shift; +#endif ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ @@ -756,13 +759,20 @@ static void ivas_find_enr( freq = BIN_FREQ_FX; move16(); +#ifdef OPT_MCT_ENC_V3_BE + tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 +#endif FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */ { band_ener = 0; move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *ptE = *ptR * *ptR + *ptI * *ptI; @@ -795,7 +805,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band @@ -820,7 +834,11 @@ static void ivas_find_enr( move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *Bin_E = *ptR * *ptR + *ptI * *ptI; @@ -851,7 +869,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 7da9fa6cf..0a01dfe66 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -135,7 +135,11 @@ static Word16 IGF_getCrest_new_fx( { x = logSpec[i]; move16(); +#ifdef OPT_MCT_ENC_V3_BE + x_eff = L_mac0( x_eff, x, x ); +#else x_eff = L_add( x_eff, L_mult0( x, x ) ); +#endif if ( GT_16( x, x_max ) ) { diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e74e2297c..610f39b1b 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -258,7 +258,7 @@ static Word16 sns_1st_cod_fx( } /* for second split shift by five bits to store both indices as one 10 bit value */ - IF( EQ_16( split, 1 ) ) + if ( EQ_16( split, 1 ) ) { index_split = shl( index_split, 5 ); } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 6ce40b00e..cd4c07297 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2725,15 +2725,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2741,15 +2741,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -2777,7 +2777,7 @@ void tcx_noise_factor_ivas_fx( } ELSE /* current line is zero, so update pointers & segment sum */ { - IF( LT_16( win, nTransWidth ) ) + if ( LT_16( win, nTransWidth ) ) { win = add( win, 1 ); } @@ -2794,15 +2794,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2810,15 +2810,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -3663,7 +3663,10 @@ Word16 tcx_res_Q_spec_ivas_fx( Word16 s, s2, lf_deemph_factor; Word16 c; Word32 thres; - +#ifdef OPT_MCT_ENC_V3_BE + Word16 cmp_1, cmp_2; + Word32 tmp32_1, tmp32_2; +#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3679,16 +3682,28 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); s2 = sub( x_Q_e, 1 ); +#ifdef OPT_MCT_ENC_V3_BE + cmp_1 = sub( sqTargetBits, kMaxEstimatorUndershoot ); + cmp_2 = s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ); +#endif FOR( i = 0; i < L_frame; i++ ) { +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_1 ) ) +#else IF( GE_16( bits, sub( sqTargetBits, kMaxEstimatorUndershoot ) ) ) +#endif { fac_m = 0; move16(); fac_p = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_2 ) ) +#else IF( GE_16( bits, s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ) ) ) +#endif { BREAK; } @@ -3700,11 +3715,11 @@ Word16 tcx_res_Q_spec_ivas_fx( { tmp1 = L_add( x_orig[i], 0 ); tmp2 = Mpy_32_16_1( x_Q[i], sqGain ); - IF( s > 0 ) + if ( s > 0 ) { tmp2 = L_shr( tmp2, s ); } - IF( s < 0 ) + if ( s < 0 ) { tmp1 = L_shl( tmp1, s ); } @@ -3721,11 +3736,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } @@ -3738,11 +3753,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } @@ -3755,12 +3770,17 @@ Word16 tcx_res_Q_spec_ivas_fx( /*Quantize zeroed-line of the spectrum*/ c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) ); +#ifdef OPT_MCT_ENC_V3_BE + FOR( i = 0; ( i < L_frame ) && ( bits < ( sqTargetBits - 2 ) ); i++ ) + { +#else FOR( i = 0; i < L_frame; i++ ) { IF( GE_16( bits, sub( sqTargetBits, 2 ) ) ) { BREAK; } +#endif test(); test(); @@ -3777,8 +3797,15 @@ Word16 tcx_res_Q_spec_ivas_fx( tmp1 = Mpy_32_16_1( thres, sqGain ); +#ifdef OPT_MCT_ENC_V3_BE + tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); + tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); + IF( GT_32( tmp32_1, tmp32_2 ) ) + { +#else IF( GT_32( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) ) { +#endif prm[bits] = 1; move16(); bits = add( bits, 1 ); @@ -3790,7 +3817,11 @@ Word16 tcx_res_Q_spec_ivas_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } +#ifdef OPT_MCT_ENC_V3_BE + ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) +#else ELSE IF( L_add( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) < 0 ) +#endif { prm[bits] = 1; move16(); -- GitLab From 2e53256c06f6101ea4c8e2a8675b1b0e4a6be470 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 17 Jul 2025 15:30:56 +1000 Subject: [PATCH 393/394] fix for issue 1822 --- lib_com/options.h | 1 + lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 90f1239d8..14b1c5eb8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -146,5 +146,6 @@ #define NONBE_FIX_TCX5_INTERLEAVING_FOR_FS_IN_UNEQUAL_FS_OUT /* FhG: apply correct TCX5 grouping/interleaving when input_fs != output_fs */ #define FIX_1824 +#define FIX_1822 #endif diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index a0fa343a2..e8700e223 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -1023,9 +1023,17 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( move16(); } } +#ifdef FIX_1822 + diff = L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_fx, ONE_IN_Q27 /*1 Q27*/ ); + diff = L_shl( diff, 2 ); // Q29 +#endif FOR( ; k < num_freq_bands; k++ ) { +#ifdef FIX_1822 + sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], diff ); // Q = q_diffuseness - 1 +#else sqr_inp = Madd_32_32( One_in_qdiff, diffuseness[k], L_sub( h_dirac_output_synthesis_params->diffuse_compensation_factor_decorr_fx, ONE_IN_Q29 /*1 Q29*/ ) ); // Q = q_diffuseness - 1 +#endif sqr_exp = sq_e; move16(); sqr = Sqrt32( sqr_inp, &sqr_exp ); /*Q(31-sqr_exp)*/ -- GitLab From 97cdbd047413bd169364c773311795b9ccbf07e7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 17 Jul 2025 16:36:16 +0530 Subject: [PATCH 394/394] Fix for 3GPP issue 1784: High frequency noise on binaural room reverb output for main and main-pc branch Link #1784 --- lib_rend/ivas_reverb_fft_filter_fx.c | 3 +++ lib_rend/ivas_reverb_fx.c | 26 ++++++++++++++++++++++++-- lib_rend/ivas_stat_rend.h | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index bbe077f8b..09720d202 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -232,6 +232,9 @@ void ivas_reverb_t2f_f2t_ClearHistory( move32(); } + t2f_f2t->prev_shift = 31; + move16(); + return; } /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9ea501f10..b90cfa91a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1824,6 +1824,7 @@ static void reverb_block_fx( Word32 pTemp_fx[INNER_BLK_SIZE]; Word32 *ppOutput_fx[IVAS_REV_MAX_NR_BRANCHES]; Word32 Output_fx[IVAS_REV_MAX_NR_BRANCHES][INNER_BLK_SIZE]; + Word16 shift; move16(); move16(); move16(); @@ -1894,6 +1895,27 @@ static void reverb_block_fx( } } + shift = s_min( L_norm_arr( pOut0_fx, hReverb->fft_filter_ols.block_size ), L_norm_arr( pOut1_fx, hReverb->fft_filter_ols.block_size ) ); + + IF( LT_16( shift, hReverb->fft_filter_ols.prev_shift ) ) + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, shift ); + scale_sig32( hReverb->fft_filter_ols.fft_history_L_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + scale_sig32( hReverb->fft_filter_ols.fft_history_R_fx, hReverb->fft_filter_ols.hist_size, sub( shift, hReverb->fft_filter_ols.prev_shift ) ); + + hReverb->fft_filter_ols.prev_shift = shift; + move16(); + } + ELSE + { + scale_sig32( pOut0_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + scale_sig32( pOut1_fx, hReverb->fft_filter_ols.block_size, hReverb->fft_filter_ols.prev_shift ); + + shift = hReverb->fft_filter_ols.prev_shift; + move16(); + } + Word16 r_shift; r_shift = add( find_guarded_bits_fx( hReverb->fft_filter_ols.fft_size ), 1 ); // Applying guard bits for the DoRTFT inside the post_fft_filter function @@ -1913,9 +1935,9 @@ static void reverb_block_fx( FOR( k = 0; k < hReverb->fft_filter_ols.block_size; k++ ) { - pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], 1 ); + pOut0_fx[k] = (Word32) L_shl( pOut0_fx[k], sub( 1, shift ) ); move32(); - pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], 1 ); + pOut1_fx[k] = (Word32) L_shl( pOut1_fx[k], sub( 1, shift ) ); move32(); } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f8dad9a66..9f853102d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -895,6 +895,7 @@ typedef struct ivas_reverb_t2f_f2t_t Word32 fft_history_L_fx[RV_FILTER_MAX_HISTORY]; // float fft_history_R[RV_FILTER_MAX_HISTORY]; Word32 fft_history_R_fx[RV_FILTER_MAX_HISTORY]; + Word16 prev_shift; } ivas_reverb_t2f_f2t_t; /* FFT filter with its frequency response coefficients */ -- GitLab