From 836824fdda922f165ad6ca47051bc9347298c6bc Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 24 Mar 2025 10:45:20 +0100 Subject: [PATCH 001/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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/692] 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 a4a26f8cb09e240a365b8d4b474ed2cc173bbe73 Mon Sep 17 00:00:00 2001 From: Hiromi Sekine Date: Fri, 25 Apr 2025 09:43:33 +0900 Subject: [PATCH 017/692] =?UTF-8?q?Enhanced=20accuracy=20by=20renormalizat?= =?UTF-8?q?ion=20in=20the=20frequency=20domain.=E3=80=80=20Added=20WMOPS?= =?UTF-8?q?=20counter=20#estimate=5Fitd=5Fwnd=5Ffft=5Ffx,#calc=5Fpoc=5Ffx,?= =?UTF-8?q?#find=5Fpoc=5Fpeak=5Ffx,#estimate=5Fitd=5Ffx,#weighted=5Fave=5F?= =?UTF-8?q?fx,#calc=5Fenergy=5Ffx,#adapt=5Fgain=5Ffx,#create=5FM=5Fsignal?= =?UTF-8?q?=5Ffx,#stereo=5Fdmx=5Fevs=5Fenc=5Ffx.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib_com/options.h | 12 +-- lib_enc/ivas_stereo_dmx_evs_fx.c | 147 +++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2f1e82de8..b297f0d1a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -53,12 +53,12 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -/*#define WMOPS*/ /* Activate complexity and memory counters */ +#define WMOPS /* Activate complexity and memory counters */ #ifdef WMOPS -/*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ -/*#define WMOPS_DETAIL*/ /* Output detailed complexity printout for every function. Increases runtime overhead */ -/*#define WMOPS_WC_FRAME_ANALYSIS*/ /* Output detailed complexity analysis for the worst-case frame */ -/*#define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ +#define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ +#define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */ +#define WMOPS_WC_FRAME_ANALYSIS /* Output detailed complexity analysis for the worst-case frame */ +/*define MEM_COUNT_DETAILS*/ /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */ #endif /* #################### End DEBUGGING switches ############################ */ @@ -94,6 +94,8 @@ #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 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_RENORM +#define FIX_1511_WMOPS #define TEST_HR #define REMOVE_EVS_DUPLICATES /* remove core-coder duplicated functions, ACELP low-band decoder */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 13ecbba00..21f5f48aa 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -223,6 +223,10 @@ void estimate_itd_wnd_fft_fx( Word16 step, bias; Word16 rshift; +#ifdef FIX_1511_WMOPS + push_wmops("estimate_itd_wnd_fft_fx"); +#endif + n0 = shr( input_frame, 1 ); IF( EQ_16( input_frame, L_FRAME16k ) ) { @@ -269,6 +273,10 @@ void estimate_itd_wnd_fft_fx( speci[n0] = 0; move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -322,6 +330,10 @@ static void calc_poc_fx( Word64 W_tmp; Word16 W_tmp_q; +#ifdef FIX_1511_WMOPS + push_wmops("calc_poc_fx"); +#endif + /* Initialization */ // iN = 1.0f / (float) input_frame; s = hPOC->sin_fx; @@ -412,6 +424,23 @@ 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_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -424,6 +453,23 @@ 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_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -444,6 +490,24 @@ static void calc_poc_fx( Li = L_add( L_sub( specLi[i], Mpy_32_32_r( specRr[i], eps_sin ) ), Mpy_32_32_r( specRi[i], eps_cos ) ); 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_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[i] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[i] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -454,6 +518,24 @@ static void calc_poc_fx( Li = L_sub( L_sub( specLi[j], Mpy_32_32_r( specRr[j], eps_sin ) ), Mpy_32_32_r( specRi[j], eps_cos ) ); 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_RENORM + { + Word32 TH1 = 65536 * 512; + Word16 SHIFT1 = 4; + IF((LT_32(L_abs(Lr), TH1)) && + (LT_32(L_abs(Li), TH1)) && + (LT_32(L_abs(Rr), TH1)) && + (LT_32(L_abs(Ri), TH1))) + { + Lr = L_shl(Lr, SHIFT1); + Li = L_shl(Li, SHIFT1); + Rr = L_shl(Rr, SHIFT1); + Ri = L_shl(Ri, SHIFT1); + } + } +#endif + specPOr[j] = L_add( Mpy_32_32_r( Lr, Rr ), Mpy_32_32_r( Li, Ri ) ); // 2*spec_e move32(); specPOi[j] = L_sub( Mpy_32_32_r( Lr, Ri ), Mpy_32_32_r( Li, Rr ) ); // 2*spec_e @@ -1125,6 +1207,10 @@ static void calc_poc_fx( } } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1144,6 +1230,11 @@ static Word32 find_poc_peak_fx( Word16 itd_cand[CPE_CHANNELS], i, n, cnt[CPE_CHANNELS], Lh, peak_range, *on, *itdLR, prev_off[CPE_CHANNELS], eps_fx; Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx; Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS]; + +#ifdef FIX_1511_WMOPS + push_wmops("find_poc_peak_fx"); +#endif + move16(); move16(); move16(); @@ -1434,6 +1525,10 @@ static Word32 find_poc_peak_fx( hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) ); // Q31 move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return hPOC->confidence_fx; } @@ -1459,6 +1554,10 @@ static ivas_error estimate_itd_fx( Word16 rfft_coef_step; ivas_error error; +#ifdef FIX_1511_WMOPS + push_wmops("estimate_itd_fx"); +#endif + error = IVAS_ERR_OK; move32(); @@ -1515,6 +1614,10 @@ static ivas_error estimate_itd_fx( *corr = round_fx( find_poc_peak_fx( hPOC, itd, input_frame, STEREO_DMX_EVS_POC_W_FORGETTING_FX ) ); move16(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return error; } @@ -1535,6 +1638,11 @@ static void weighted_ave_fx( { Word16 i, len; Word32 gain_tmp_fx = 0, gain_sub_fx; + +#ifdef FIX_1511_WMOPS + push_wmops("weighted_ave_fx"); +#endif + move32(); len = shr( input_frame, 4 ); gain_sub_fx = L_sub( gain_fx, old_gain_fx ); @@ -1550,6 +1658,10 @@ static void weighted_ave_fx( move32(); } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } /*-------------------------------------------------------------------* @@ -1569,6 +1681,11 @@ static void calc_energy_fx( Word32 E_32_fx, wnd_fx, wnd_diff_fx; Word16 i, adaptlen; Word64 E_fx; + +#ifdef FIX_1511_WMOPS + push_wmops("calc_energy_fx"); +#endif + /* Initialization */ E_fx = 0; move32(); @@ -1630,6 +1747,11 @@ static void calc_energy_fx( // *energy = *energy * ratio_float + ( E / (float) input_frame ) * ( 1.0f - ratio_float ); *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); + +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1650,6 +1772,10 @@ static void adapt_gain_fx( Word16 i, len; Word32 gain_tmp_fx, gain_sub_fx; +#ifdef FIX_1511_WMOPS + push_wmops("adapt_gain_fx"); +#endif + len = shr( input_frame, 4 ); // gain_sub = gain - old_gain; gain_sub_fx = L_sub( gain_fx, old_gain_fx ); // Q31 @@ -1668,6 +1794,10 @@ static void adapt_gain_fx( move32(); } +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1696,6 +1826,11 @@ static void create_M_signal_fx( Word32 temp32_1, temp32_2; Word16 temp_e; Word16 temp_e_1, temp_e_2; + +#ifdef FIX_1511_WMOPS + push_wmops("create_M_signal_fx"); +#endif + /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); @@ -1761,6 +1896,10 @@ static void create_M_signal_fx( w_prev_fx[2] = amp_mod_fx[1]; move32(); +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } @@ -1799,6 +1938,10 @@ void stereo_dmx_evs_enc_fx( Word64 W_tmp; Word16 W_tmp_q; +#ifdef FIX_1511_WMOPS + push_wmops("stereo_dmx_evs_enc_fx"); +#endif + if ( is_binaural ) { /* use of is_binaural flag is to be considered */ @@ -2150,6 +2293,10 @@ void stereo_dmx_evs_enc_fx( Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 +#ifdef FIX_1511_WMOPS + pop_wmops(); +#endif + return; } -- GitLab From 868dd2439660c01d806e5264ee392e873ce51a35 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Apr 2025 17:12:17 +0200 Subject: [PATCH 018/692] 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 019/692] 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 020/692] 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 021/692] [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 022/692] 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 023/692] 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 024/692] 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 025/692] 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 026/692] 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 027/692] 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 028/692] 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 029/692] 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 030/692] 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 031/692] 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 032/692] 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 033/692] 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 034/692] 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 035/692] 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 036/692] 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 037/692] 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 038/692] 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 039/692] 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 040/692] 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 041/692] 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 042/692] 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 0e4cf38fb376789c6fda4bb44c2ada3155554464 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 May 2025 11:13:59 +0200 Subject: [PATCH 043/692] port FIX_993_REMOVE_SBA_GET_ORDER --- lib_com/ivas_prot_fx.h | 3 ++- lib_com/ivas_sba_config_fx.c | 8 ++++++-- lib_com/options.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6c9166111..5c396140f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4937,12 +4937,13 @@ ivas_error ivas_cldfb_dec_reconfig_fx( ivas_error ivas_sba_enc_reconfigure_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); - +#ifndef FIX_993_REMOVE_SBA_GET_ORDER Word16 ivas_sba_get_order_fx( const Word16 nb_channels, /* i : Number of ambisonic channels */ const Word16 sba_planar /* i : SBA planar flag */ ); +#endif /*! r: Ambisonic (SBA) order used for analysis and coding */ Word16 ivas_sba_get_analysis_order( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index b3a0806d4..6dbe215ea 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -60,6 +60,7 @@ void ivas_sba_config_fx( Word16 *element_mode /* o : element mode of the core coder */ ) { +#ifndef FIX_993_REMOVE_SBA_GET_ORDER test(); IF( sba_order < 0 && nb_channels < 0 ) { @@ -74,6 +75,9 @@ void ivas_sba_config_fx( nb_channels = ivas_sba_get_nchan_fx( sba_order, sba_planar ); } ELSE +#else + IF( nb_channels > 0 ) +#endif { IF( sba_planar ) { @@ -124,7 +128,7 @@ void ivas_sba_config_fx( return; } - +#ifndef FIX_993_REMOVE_SBA_GET_ORDER /*-------------------------------------------------------------------* * ivas_sba_get_order() * @@ -174,7 +178,7 @@ Word16 ivas_sba_get_order_fx( return ( sba_order ); } - +#endif /*-------------------------------------------------------------------* * ivas_sba_get_analysis_order() diff --git a/lib_com/options.h b/lib_com/options.h index c568a52fa..1b05236bb 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define NONBE_FIX_968_ISM_BRIR_WITH_HEADROTATION_5MS_FIX /* FhG : issue #968: differences between 5ms and 20ms rendering for discrete ISM with BRIR and head rotation*/ #define FIX_969_USAN_IGF_ARITH /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */ +#define FIX_993_REMOVE_SBA_GET_ORDER /* VA: issue 993: remove unused function ivas_sba_get_order() */ /* #################### End BASOP porting switches ############################ */ -- GitLab From ec12834622a01b2833817478d5d10c450a43f476 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 May 2025 11:20:16 +0200 Subject: [PATCH 044/692] remove sum_l() leftover --- lib_com/prot_fx.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 45641b3f8..afae8dfbf 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -11252,12 +11252,6 @@ int16_t sum_s( const int16_t 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 */ -- GitLab From ea6a9c3a8509d2a9d050ac5d33b4c9ea26350735 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 7 May 2025 11:33:01 +0200 Subject: [PATCH 045/692] remove planarCP static variable --- lib_com/ivas_stat_com.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index fb11d3934..847442c35 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -176,6 +176,7 @@ typedef struct ivas_band_coeffs_t Word32 pred_quant_re_fx[IVAS_SPAR_MAX_CH - 1]; Word32 C_quant_re_fx[IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS][IVAS_SPAR_MAX_DMX_CHS - 1]; Word32 P_quant_re_fx[IVAS_SPAR_MAX_CH - 1]; + } ivas_band_coeffs_t; typedef struct ivas_band_coeffs_ind_t @@ -197,6 +198,7 @@ typedef struct ivas_spar_md_t Word32 ref_pow_slow_fx[IVAS_MAX_NUM_BANDS]; Word16 res_ind; Word16 prior_dyn_active_w_flag; + } ivas_spar_md_t; typedef struct ivas_spar_md_prev_t @@ -211,6 +213,7 @@ typedef struct ivas_quant_coeffs_t Word32 min_fx; /* Q28 */ Word32 max_fx; /* Q28 */ Word16 q_levels[2]; + } ivas_quant_coeffs_t; typedef struct ivas_quant_strat_t @@ -238,7 +241,6 @@ typedef struct ivas_spar_md_com_cfg Word16 max_bits_per_blk; Word16 prev_quant_idx; Word16 agc_bits_ch_idx; - Word16 planarCP; Word16 num_umx_chs; Word16 max_md_bits_spar; @@ -292,6 +294,7 @@ typedef struct ivas_arith_t Word16 range; Word16 num_models; Word32 saved_dist_arr[IVAS_NUM_PROB_MODELS][IVAS_MAX_QUANT_LEVELS]; /* Q15 */ + } ivas_arith_t; typedef struct ivas_arith_coeffs_t -- GitLab From 5c45d51c5ba179a99a9e56f371ab255fcf3f87ac Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 8 May 2025 10:52:28 +0200 Subject: [PATCH 046/692] 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 047/692] 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 048/692] 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 049/692] 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 050/692] 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 051/692] 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 052/692] 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 053/692] 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 054/692] 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 9aa816c470adf5b4a65d64f6c13edb2637f67f78 Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Mon, 12 May 2025 15:13:34 +0200 Subject: [PATCH 055/692] Fix 1511 - POC renorm cleaned and tuned. --- lib_com/options.h | 3 +- lib_enc/ivas_stereo_dmx_evs_fx.c | 189 ++++++++++--------------------- 2 files changed, 58 insertions(+), 134 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1ca29ab76..fb32b2240 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,8 +95,7 @@ #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_RENORM -#define FIX_1511_WMOPS +#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 */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 21f5f48aa..36315d2ed 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -98,6 +98,11 @@ #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, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, 2027355264, @@ -223,10 +228,6 @@ void estimate_itd_wnd_fft_fx( Word16 step, bias; Word16 rshift; -#ifdef FIX_1511_WMOPS - push_wmops("estimate_itd_wnd_fft_fx"); -#endif - n0 = shr( input_frame, 1 ); IF( EQ_16( input_frame, L_FRAME16k ) ) { @@ -273,10 +274,6 @@ void estimate_itd_wnd_fft_fx( speci[n0] = 0; move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -330,10 +327,6 @@ static void calc_poc_fx( Word64 W_tmp; Word16 W_tmp_q; -#ifdef FIX_1511_WMOPS - push_wmops("calc_poc_fx"); -#endif - /* Initialization */ // iN = 1.0f / (float) input_frame; s = hPOC->sin_fx; @@ -424,22 +417,18 @@ 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_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#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 ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + 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(); @@ -453,22 +442,18 @@ 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_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#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 ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + 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(); @@ -491,22 +476,18 @@ 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_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#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 ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + 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(); @@ -519,22 +500,18 @@ 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_RENORM - { - Word32 TH1 = 65536 * 512; - Word16 SHIFT1 = 4; - IF((LT_32(L_abs(Lr), TH1)) && - (LT_32(L_abs(Li), TH1)) && - (LT_32(L_abs(Rr), TH1)) && - (LT_32(L_abs(Ri), TH1))) - { - Lr = L_shl(Lr, SHIFT1); - Li = L_shl(Li, SHIFT1); - Rr = L_shl(Rr, SHIFT1); - Ri = L_shl(Ri, SHIFT1); - } - } -#endif +#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 ) ) && + ( LT_32( L_abs( Ri ), STEREO_DMX_EVS_POC_RENORM_TH ) ) ) + { + Lr = L_shl( Lr, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + Li = L_shl( Li, STEREO_DMX_EVS_POC_RENORM_SHIFT ); + 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(); @@ -1207,10 +1184,6 @@ static void calc_poc_fx( } } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1231,10 +1204,6 @@ static Word32 find_poc_peak_fx( Word32 Q_fx[CPE_CHANNELS], aQ_fx[CPE_CHANNELS], cQ_fx[CPE_CHANNELS], width_fx, *peak_width_fx, *peakQ_fx, cconfidence_fx, *P_fx, tmpf_fx, eps2_fx; Word16 tmpf_e = 0, eps2_e = 0, Q_e[CPE_CHANNELS], eps_e = 15, peakQ_e[CPE_CHANNELS]; -#ifdef FIX_1511_WMOPS - push_wmops("find_poc_peak_fx"); -#endif - move16(); move16(); move16(); @@ -1525,10 +1494,6 @@ static Word32 find_poc_peak_fx( hPOC->confidence_fx = L_add( cconfidence_var1, L_shl( cconfidence_var2, 1 ) ); // Q31 move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return hPOC->confidence_fx; } @@ -1554,10 +1519,6 @@ static ivas_error estimate_itd_fx( Word16 rfft_coef_step; ivas_error error; -#ifdef FIX_1511_WMOPS - push_wmops("estimate_itd_fx"); -#endif - error = IVAS_ERR_OK; move32(); @@ -1614,10 +1575,6 @@ static ivas_error estimate_itd_fx( *corr = round_fx( find_poc_peak_fx( hPOC, itd, input_frame, STEREO_DMX_EVS_POC_W_FORGETTING_FX ) ); move16(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return error; } @@ -1639,10 +1596,6 @@ static void weighted_ave_fx( Word16 i, len; Word32 gain_tmp_fx = 0, gain_sub_fx; -#ifdef FIX_1511_WMOPS - push_wmops("weighted_ave_fx"); -#endif - move32(); len = shr( input_frame, 4 ); gain_sub_fx = L_sub( gain_fx, old_gain_fx ); @@ -1658,10 +1611,6 @@ static void weighted_ave_fx( move32(); } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } /*-------------------------------------------------------------------* @@ -1682,10 +1631,6 @@ static void calc_energy_fx( Word16 i, adaptlen; Word64 E_fx; -#ifdef FIX_1511_WMOPS - push_wmops("calc_energy_fx"); -#endif - /* Initialization */ E_fx = 0; move32(); @@ -1748,10 +1693,6 @@ static void calc_energy_fx( *energy_fx = BASOP_Util_Add_Mant32Exp( Mpy_32_32( *energy_fx, ratio_float_fx ), *energy_fx_e, Mpy_32_32( temp32, L_sub( MAX_32, ratio_float_fx ) ), sub( 31, q_temp32 ), energy_fx_e ); move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1772,10 +1713,6 @@ static void adapt_gain_fx( Word16 i, len; Word32 gain_tmp_fx, gain_sub_fx; -#ifdef FIX_1511_WMOPS - push_wmops("adapt_gain_fx"); -#endif - len = shr( input_frame, 4 ); // gain_sub = gain - old_gain; gain_sub_fx = L_sub( gain_fx, old_gain_fx ); // Q31 @@ -1794,10 +1731,6 @@ static void adapt_gain_fx( move32(); } -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1827,10 +1760,6 @@ static void create_M_signal_fx( Word16 temp_e; Word16 temp_e_1, temp_e_2; -#ifdef FIX_1511_WMOPS - push_wmops("create_M_signal_fx"); -#endif - /* Initialization */ eps_fx = 1024; // 1024.0f in Q0 move32(); @@ -1896,10 +1825,6 @@ static void create_M_signal_fx( w_prev_fx[2] = amp_mod_fx[1]; move32(); -#ifdef FIX_1511_WMOPS - pop_wmops(); -#endif - return; } @@ -1938,8 +1863,8 @@ void stereo_dmx_evs_enc_fx( Word64 W_tmp; Word16 W_tmp_q; -#ifdef FIX_1511_WMOPS - push_wmops("stereo_dmx_evs_enc_fx"); +#ifdef FIX_1511_POC_RENORM + push_wmops( "stereo_dmx_evs_enc_fx" ); #endif if ( is_binaural ) @@ -2293,8 +2218,8 @@ void stereo_dmx_evs_enc_fx( Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 -#ifdef FIX_1511_WMOPS - pop_wmops(); +#ifdef FIX_1511_POC_RENORM + pop_wmops(); #endif return; -- GitLab From e6a26d0b423fa365fcea4cb29449b557a48a7176 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 12 May 2025 17:56:28 +0200 Subject: [PATCH 056/692] 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 057/692] 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 e6ee6c58dfcd22133883e20609e6e3834bcaa9bc Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Tue, 13 May 2025 12:17:33 +0200 Subject: [PATCH 058/692] clang formatted. --- lib_debug/debug.c | 2 +- lib_debug/wmc_auto.c | 8 ++--- lib_debug/wmc_auto.h | 52 +++++++++++++++++--------------- lib_enc/ivas_stereo_dmx_evs_fx.c | 1 + 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib_debug/debug.c b/lib_debug/debug.c index aafc1b663..ee6040faf 100644 --- a/lib_debug/debug.c +++ b/lib_debug/debug.c @@ -788,7 +788,7 @@ char *fname( #ifdef DEBUG_FORCE_DIR size_t len; len = strlen( tmp_fname ); - if (tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) + if ( tmp_fname[len - 1] != '/' && tmp_fname[len - 1] != '\\' ) { /* add trailing '/' slash */ strcat( tmp_fname, "/" ); diff --git a/lib_debug/wmc_auto.c b/lib_debug/wmc_auto.c index d357c03dd..9a4b371fc 100644 --- a/lib_debug/wmc_auto.c +++ b/lib_debug/wmc_auto.c @@ -1018,7 +1018,7 @@ int push_stack( const char *filename, const char *fctname ) } /* Check, if This is the New Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size < 0 ) { @@ -1226,7 +1226,7 @@ void *mem_alloc( current_heap_size += ptr_record->block_size; /* Check, if this is the new Worst-Case RAM (stack + heap) */ - current_stack_size = ( int32_t )( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); + current_stack_size = (int32_t) ( ( ( ptr_base_stack - ptr_current_stack ) * sizeof( int16_t ) ) ); if ( current_stack_size + current_heap_size > wc_ram_size ) { wc_ram_size = current_stack_size + current_heap_size; @@ -2416,7 +2416,7 @@ int EQ_64( long long int L64_var1, long long int L64_var2 ) #endif return F_ret; } -int NE_64( long long int L64_var1, long long int L64_var2 ) +int NE_64( long long int L64_var1, long long int L64_var2 ) { int F_ret = 0; @@ -2503,7 +2503,7 @@ void Reset_BASOP_WMOPS_counter( unsigned int counterId ) /* reset the current BASOP operation counter */ ptr = (unsigned int *) &multiCounter[counterId]; - for ( i = 0; i < (int) (sizeof(BASIC_OP) / sizeof(unsigned int)); i++ ) + for ( i = 0; i < (int) ( sizeof( BASIC_OP ) / sizeof( unsigned int ) ); i++ ) { *ptr++ = 0; } diff --git a/lib_debug/wmc_auto.h b/lib_debug/wmc_auto.h index 59bbc5bbf..8c6396313 100644 --- a/lib_debug/wmc_auto.h +++ b/lib_debug/wmc_auto.h @@ -34,7 +34,7 @@ #define ENH_64_BIT_OPERATOR #define ENH_U_32_BIT_OPERATOR #define COMPLEX_OPERATOR -#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ +#define CONTROL_CODE_OPS /* enable control code operators such as LT_16, GT_16, ... */ #define WMOPS_DISABLE_FCN_CALL_PENALIZATION /* do not count the complexity of function calls */ #ifdef WMOPS @@ -258,7 +258,7 @@ void update_mem( void ); { \ ops_cnt += ( 2 * _TRANS_C * ( x ) ); \ inst_cnt[_TRANS] += ( x ); \ - } + } #else @@ -335,29 +335,29 @@ extern int cntr_push_pop; #endif /* Define all Macros without '{' & '}' (None of these should be called externally!) */ -#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) -#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) -#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) -#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) -#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) -#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) -#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) -#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) -#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) -#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) -#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) -#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) +#define ABS_( x ) OP_COUNT_( _ABS, ( x ) ) +#define ADD_( x ) OP_COUNT_( _ADD, ( x ) ) +#define MULT_( x ) OP_COUNT_( _MULT, ( x ) ) +#define MAC_( x ) OP_COUNT_( _MAC, ( x ) ) +#define MOVE_( x ) OP_COUNT_( _MOVE, ( x ) ) +#define STORE_( x ) OP_COUNT_( _STORE, ( x ) ) +#define LOGIC_( x ) OP_COUNT_( _LOGIC, ( x ) ) +#define SHIFT_( x ) OP_COUNT_( _SHIFT, ( x ) ) +#define BRANCH_( x ) OP_COUNT_( _BRANCH, ( x ) ) +#define DIV_( x ) OP_COUNT_( _DIV, ( x ) ) +#define SQRT_( x ) OP_COUNT_( _SQRT, ( x ) ) +#define TRANS_( x ) OP_COUNT_( _TRANS, ( x ) ) #define POWER_( x ) TRANS_( x ) #define LOG_( x ) TRANS_( x ) -#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) -#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) -#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) +#define LOOP_( x ) OP_COUNT_( _LOOP, ( x ) ) +#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) ) +#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) ) #ifdef WMOPS_DISABLE_FCN_CALL_PENALIZATION -#define FUNC_( x ) ( x ) +#define FUNC_( x ) ( x ) #else -#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) +#define FUNC_( x ) ( OP_COUNT_( _MOVE, ( x ) ), OP_COUNT_( _FUNC, 1 ) ) #endif -#define MISC_( x ) ABS_( x ) +#define MISC_( x ) ABS_( x ) /* Math Operations */ #define abs_ OP_COUNT_WRAPPER1_( ABS_( 1 ), abs ) @@ -401,8 +401,8 @@ extern int cntr_push_pop; #define frexp_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexp ) #define frexpf_ OP_COUNT_WRAPPER1_( MISC_( 2 ), frexpf ) -/* the macros below are instrumented versions of user-defined macros that might be used in the source code - representing some well-known and recognized mathematical operations (that are not defined in math.h) +/* the macros below are instrumented versions of user-defined macros that might be used in the source code + representing some well-known and recognized mathematical operations (that are not defined in math.h) Note: the 'wmc_flag_=wmc_flag_' is used to avoid warning: left-hand operand of comma expression has no effect with gcc */ #define min_( a, b ) OP_COUNT_WRAPPER1_( MISC_( 1 ), min( ( a ), ( b ) ) ) @@ -928,7 +928,7 @@ typedef struct unsigned int Madd_32_32_r; /* Complexity Weight of 1 */ unsigned int Msub_32_32; /* Complexity Weight of 1 */ unsigned int Msub_32_32_r; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_32_BIT_OPERATOR */ #ifdef ENH_U_32_BIT_OPERATOR unsigned int UL_addNs; /* Complexity Weight of 1 */ @@ -938,7 +938,7 @@ typedef struct unsigned int Mpy_32_16_uu; /* Complexity Weight of 2 */ unsigned int norm_ul_float; /* Complexity Weight of 1 */ unsigned int UL_deposit_l; /* Complexity Weight of 1 */ -#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ +#endif /* #ifdef ENH_U_32_BIT_OPERATOR */ #ifdef CONTROL_CODE_OPS unsigned int LT_16; /* Complexity Weight of 1 */ @@ -1095,7 +1095,9 @@ void incrIf( const char *func_name ); #ifndef WMOPS #define ELSE else #else /* ifndef WMOPS */ -#define ELSE else if ( incrElse( __func__ ), 0 ); else +#define ELSE \ + else if ( incrElse( __func__ ), 0 ); \ + else void incrElse( const char *func_name ); #endif /* ifndef WMOPS */ diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 793f204d8..f84f90e46 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -2214,6 +2214,7 @@ void stereo_dmx_evs_enc_fx( } Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 + pop_wmops(); return; -- GitLab From 36bbe074068be90ed62402797f52b1b0ec3b8574 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 13 May 2025 19:36:04 +0200 Subject: [PATCH 059/692] 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 060/692] 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 061/692] 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 062/692] 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 063/692] 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 064/692] 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 065/692] 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 066/692] 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 067/692] 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 068/692] 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 069/692] 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 070/692] 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 071/692] 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 072/692] 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 073/692] 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 074/692] 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 075/692] 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 076/692] 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 077/692] 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 078/692] 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 079/692] 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 080/692] 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 081/692] 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 082/692] 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 083/692] 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 084/692] 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 085/692] 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 086/692] 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 087/692] 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 088/692] 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 089/692] 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 090/692] 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 091/692] 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 092/692] 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 093/692] 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 bb0b3cc44f4b2844a19b09d7cbf3a77e968e34ec Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 10:55:58 +0200 Subject: [PATCH 094/692] Added switches and definitions in options.h and common_api_types.h --- lib_com/common_api_types.h | 3 +++ lib_com/options.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 3200cb21d..e1114a4f3 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -182,6 +182,9 @@ typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; +#endif typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 2a87c540b..a5abfb012 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,6 +99,13 @@ //#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#define NONBE_FIX_AVG_IAC_CLDFB_REVERB +#endif +#endif #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #define NONBE_FIX_AVG_IAC_CLDFB_REVERB -- GitLab From 7c69312e25c9a50fe377c92041f935b774961d96 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 11:28:53 +0200 Subject: [PATCH 095/692] 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 555f98cfaf0d8f72419236b2799bd8e41610bb65 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 12:12:20 +0200 Subject: [PATCH 096/692] all changes in lib_util + imp declarations in lib_rend and lib_dec --- lib_com/options.h | 2 +- lib_dec/ivas_stat_dec.h | 3 ++ lib_dec/lib_dec.h | 6 +++ lib_dec/lib_dec_fx.c | 23 ++++++++++++ lib_rend/ivas_stat_rend.h | 15 +++++++- lib_util/hrtf_file_reader.c | 75 +++++++++++++++++++++++++++++++++++-- lib_util/hrtf_file_reader.h | 12 ++++++ 7 files changed, 131 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a5abfb012..17eeaec92 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define NONBE_FIX_973_HODIRAC_BAND_GROUPING /* FhG: issue 973: empty parameter band in DirAC */ -//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index d86ece7c8..c6f06f142 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1155,6 +1155,9 @@ typedef struct Decoder_Struct HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */ +#endif LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ Word32 *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index b6ce35d90..eca274491 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -379,6 +379,12 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 63f0ab53f..eee250751 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2599,6 +2599,29 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_DEC_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetHrtfStatisticsHandle( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasDec->st_ivas->hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif + /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) * diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index cc1565943..d8dd14034 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1200,9 +1200,11 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ Word32 latency_s_fx; /* Q31 */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const Word32 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb */ Word32 *lr_energy_and_iac_dyn_fx[3]; - +#endif } TDREND_HRFILT_FiltSet_t; /* Distance attenuation */ @@ -1474,6 +1476,17 @@ typedef struct ivas_hrtfs_parambin_struct } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +typedef struct ivas_hrtfs_statistics_struct +{ + float *average_energy_l; + float *average_energy_r; + float *inter_aural_coherence; + int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ +} HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index ee103db2d..fd53eb631 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -577,6 +577,7 @@ static ivas_error LoadBSplineBinary( } #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * set_default_reverb_iac_energy() * @@ -689,6 +690,7 @@ static ivas_error set_default_reverb_iac_energy( return IVAS_ERR_OK; } +#endif #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES @@ -699,11 +701,18 @@ static ivas_error set_default_reverb_iac_energy( --------------------------------------------------------------------*/ static ivas_error load_reverb_from_binary( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ - FILE *f_hrtf /* i : HR filter data file handle */ +#endif + FILE *f_hrtf /* i : HR filter data file handle */ ) { +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES int16_t i; +#endif bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; @@ -715,13 +724,21 @@ static ivas_error load_reverb_from_binary( int16_t lr_iac_len; float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( hHrtfStatistics == NULL ) +#else if ( HrFiltSet_p == NULL ) +#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } lr_iac_len = LR_IAC_LENGTH_NR_FC; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( sampleRate == 16000 ) +#else if ( HrFiltSet_p->SampleRate == 16000 ) +#endif { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } @@ -779,6 +796,21 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) ); + + if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf ); + + hHrtfStatistics->fromROM = FALSE; +#else /* left/right energy and interaural coherence for late reverb */ FOR( i = 0; i < 3; i++ ) { @@ -816,14 +848,17 @@ static ivas_error load_reverb_from_binary( HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; #endif } +#endif } else { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else if ( ( header_check_result = set_default_reverb_iac_energy( HrFiltSet_p ) ) != IVAS_ERR_OK ) { return header_check_result; } - +#endif return IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA; } @@ -838,13 +873,22 @@ static ivas_error load_reverb_from_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { fseek( hrtfReader->file, 0, SEEK_SET ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + return load_reverb_from_binary( hHrtfStatistics, sampleRate, hrtfReader->file ); +#else return load_reverb_from_binary( hHrtf, hrtfReader->file ); +#endif } #endif /*-------------------------------------------------------------------* @@ -1109,10 +1153,12 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL_fx ); free( ( *hHrtf )->ModelEval.hrfModR_fx ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES for ( i = 0; i < 3; i++ ) { free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ); } +#endif } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB else @@ -2314,6 +2360,29 @@ void destroy_SetOfHRTF( } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * Destroy the HRTF statistics set. + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +) +{ + if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE ) + { + free( ( *hHrtfStatistics )->average_energy_l ); + free( ( *hHrtfStatistics )->average_energy_r ); + free( ( *hHrtfStatistics )->inter_aural_coherence ); + } + ivas_HRTF_statistics_close( hHrtfStatistics ); + return IVAS_ERR_OK; +} +#endif + + /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() * diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 9a06a4e3b..51c321352 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -190,6 +190,18 @@ void destroy_parambin_hrtf( IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin /* i/o: Parambin HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * free memory allocated for HRTF statistics binary data + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif + /*---------------------------------------------------------------------* * destroy_td_hrtf() * -- GitLab From 9f805bb9f29a243e826083a07cd25290a810aad1 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 22 May 2025 13:09:10 +0200 Subject: [PATCH 097/692] 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 098/692] 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 099/692] 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 e22f1a9fa3653a7224d7a219851b39ef4d3cb651 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 17:07:14 +0200 Subject: [PATCH 100/692] lib_rend header and .c with changes --- lib_rend/lib_rend.c | 387 +++++++++++++++++++++++++----------- lib_rend/lib_rend.h | 15 +- lib_util/hrtf_file_reader.c | 1 - 3 files changed, 281 insertions(+), 122 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 12fb2c524..ecab18225 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -212,6 +212,9 @@ typedef struct hrtf_handles IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_HRTF_HANDLE hHrtfTD; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics; +#endif } hrtf_handles; struct IVAS_REND @@ -251,8 +254,11 @@ struct IVAS_REND /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, const RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hHrtfs ); +#else static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, hrtf_handles *hHrtfs ); +#endif static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); static void intermidiate_ext_dirac_render( @@ -1522,10 +1528,13 @@ static ivas_error setRendInputActiveIsm( #endif { #ifndef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } +#endif { + return error; + } #else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { @@ -1585,53 +1594,57 @@ static ivas_error setRendInputActiveIsm( } } #endif - } - ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) +} +ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) +{ + IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } - ELSE - { +} +ELSE +{ #ifndef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) - { - return error; - } - Word16 nchan_rend = num_src; - move16(); + IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) + { + return error; + } + Word16 nchan_rend = num_src; + move16(); - test(); - IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ - } + test(); + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ + } - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) + { + TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) { - TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p != NULL ) + IF( Src_p->SrcSpatial_p != NULL ) { - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->q_Pos_p = Q31; - move16(); - } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; + Src_p->SrcSpatial_p->q_Pos_p = Q31; move16(); } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = Q31; + move16(); } + } - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) +#else + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) +#endif { - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } + } #else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { @@ -1665,22 +1678,30 @@ static ivas_error setRendInputActiveIsm( IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) { - return error; - } +#endif + return error; } - ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { + } + ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) - { - return error; - } - } #endif + { + return error; + } } +#endif +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } static void clearInputIsm( @@ -2494,6 +2515,9 @@ static ivas_error initMcBinauralRendering( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif uint8_t reconfigureFlag ) { ivas_error error; @@ -2653,69 +2677,82 @@ static ivas_error initMcBinauralRendering( test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && inputMc->hReverb == NULL ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_reverb_open( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; - } +#endif { + return error; } } - ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) - { - /* open CREND */ +} +ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) +{ + /* open CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), - IVAS_ERR_OK ) ) +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, + outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), + IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, + hMixconv, + outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), + IVAS_ERR_OK ) ) #endif - { - return error; - } +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ), IVAS_ERR_OK ) ) +#else + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, + hMixconv, + outSampleRate ) ), + IVAS_ERR_OK ) ) +#endif +#endif + { + return error; } +} - /* Initialise the EFAP handle for rotation on input layout */ - test(); - test(); - IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) +/* Initialise the EFAP handle for rotation on input layout */ +test(); +test(); +IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) +{ + IF( NE_32( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; } +} - /* determine binaural delay ( used for aligning LFE to output signal ) */ +/* determine binaural delay ( used for aligning LFE to output signal ) */ - IF( ( inputMc->crendWrapper != NULL ) ) - { - binauralDelayNs = inputMc->crendWrapper->binaural_latency_ns; - } - ELSE - { - binauralDelayNs = 0; - } - move32(); +IF( ( inputMc->crendWrapper != NULL ) ) +{ + binauralDelayNs = inputMc->crendWrapper->binaural_latency_ns; +} +ELSE +{ + binauralDelayNs = 0; +} +move32(); - binauralDelayNs = L_max( binauralDelayNs, inputMc->tdRendWrapper.binaural_latency_ns ); - Word16 exp = 0; - move16(); - Word16 var1 = BASOP_Util_Divide3232_Scale( *inputMc->base.ctx.pOutSampleRate, 1000000000, &exp ); - Word32 var2 = L_shr_r( Mpy_32_32( binauralDelayNs, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ - inputMc->binauralDelaySmp = extract_l( var2 ); - move16(); - // inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); +binauralDelayNs = L_max( binauralDelayNs, inputMc->tdRendWrapper.binaural_latency_ns ); +Word16 exp = 0; +move16(); +Word16 var1 = BASOP_Util_Divide3232_Scale( *inputMc->base.ctx.pOutSampleRate, 1000000000, &exp ); +Word32 var2 = L_shr_r( Mpy_32_32( binauralDelayNs, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ +inputMc->binauralDelaySmp = extract_l( var2 ); +move16(); +// inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); - IF( GT_16( inputMc->binauralDelaySmp, MAX_BIN_DELAY_SAMPLES ) ) - { - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); - } +IF( GT_16( inputMc->binauralDelaySmp, MAX_BIN_DELAY_SAMPLES ) ) +{ + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } static ivas_error initMcMasaRendering( @@ -2893,10 +2930,15 @@ static ivas_error setRendInputActiveMc( IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif { + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -3059,7 +3101,13 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, - IVAS_DEC_HRTF_CREND_HANDLE hMixconv ) + IVAS_DEC_HRTF_CREND_HANDLE hMixconv +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + , + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics +#endif + +) { ivas_error error; AUDIO_CONFIG inConfig; @@ -3122,11 +3170,17 @@ static ivas_error updateSbaPanGains( #endif { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) - +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - +#endif #endif { return error; @@ -3141,9 +3195,17 @@ static ivas_error updateSbaPanGains( return error; } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) +#endif #endif { return error; @@ -3257,13 +3319,16 @@ static ivas_error setRendInputActiveSba( return error; } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ), IVAS_ERR_OK ) ) - { - return error; - } - +#endif { return error; } + +return error; +} static void clearInputSba( input_sba *inputSba ) { @@ -3298,8 +3363,11 @@ static ivas_error setRendInputActiveMasa( const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hrtfs - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +) +#else ) /* Todo: This is not used at all within MASA. Support might be better to do after refactoring. */ +#endif { ivas_error error; rendering_context rendCtx; @@ -3311,7 +3379,9 @@ static ivas_error setRendInputActiveMasa( rendCtx = inputMasa->base.ctx; outConfig = *rendCtx.pOutConfig; move32(); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES (void) hRendCfg; /* Suppress warning */ +#endif IF( !isIoConfigPairSupported( inConfig, outConfig ) ) { @@ -3350,15 +3420,18 @@ static ivas_error setRendInputActiveMasa( } ELSE { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ), IVAS_ERR_OK ) ) - { - return error; - } - inputMasa->metadataHasBeenFed = false; - move16(); +#endif { + return error; } + inputMasa->metadataHasBeenFed = false; + move16(); +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } static void clearInputMasa( @@ -3546,6 +3619,9 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfParambin = NULL; hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics = NULL; +#endif IF( asHrtfBinary ) { IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) @@ -3564,10 +3640,23 @@ ivas_error IVAS_REND_Open( { return error; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) + { + return error; + } +#endif } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) + { + return error; + } +#endif return IVAS_ERR_OK; } + static LSSETUP_CUSTOM_STRUCT makeCustomLsSetup( const IVAS_CUSTOM_LS_DATA rendCustomLsLayout ) { @@ -3711,7 +3800,11 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( /* Input inactive, skip. */ CONTINUE; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL, NULL ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -4228,8 +4321,14 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif { - IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, + IF( NE_32( ( error = initMcBinauralRendering( inputMc, + inputMc->base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif FALSE ) ), IVAS_ERR_OK ) ) { @@ -5062,8 +5161,14 @@ ivas_error IVAS_REND_SetHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif TRUE ) ), IVAS_ERR_OK ) ) { @@ -5169,8 +5274,14 @@ ivas_error IVAS_REND_DisableHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + hIvasRend->hHrtfs.hHrtfStatistics, +#endif TRUE ) ), IVAS_ERR_OK ) ) { @@ -9337,6 +9448,9 @@ void IVAS_REND_Close( ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hSetOfHRTF ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_HRTF_statistics_close( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); +#endif free( hIvasRend ); *phIvasRend = NULL; @@ -9569,6 +9683,30 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( return IVAS_ERR_OK; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * IVAS_REND_GetHrtfStatisticsHandle( ) + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +) +{ + if ( hIvasRend == NULL || hIvasRend->hHrtfs.hHrtfStatistics == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + *hHrtfStatistics = &hIvasRend->hHrtfs.hHrtfStatistics; + + return IVAS_ERR_OK; +} +#endif + static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) { @@ -9998,7 +10136,13 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( static ivas_error ivas_masa_ext_rend_parambin_init( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + input_masa *inputMasa, /* i/o: MASA external renderer structure */ + const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ + HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i : HRTF statistics */ +#else input_masa *inputMasa /* i/o: MASA external renderer structure */ +#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -10137,9 +10281,12 @@ static ivas_error ivas_masa_ext_rend_parambin_init( IF( hDiracDecBin->hReverb == NULL ) #endif { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) - { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ) , IVAS_ERR_OK ) ) +#else + /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ + IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) , IVAS_ERR_OK ) ) +#endif { return error; } } @@ -10197,6 +10344,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const RENDER_CONFIG_DATA *hRendCfg, +#endif hrtf_handles *hrtfs ) { Word16 i; @@ -10331,9 +10481,12 @@ static ivas_error initMasaExtRenderer( return error; } } - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } } diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 50663f936..9615a170d 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -193,26 +193,33 @@ ivas_error IVAS_REND_GetDelay( /*! r: error code */ ivas_error IVAS_REND_GetHrtfHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS rendder handle */ IVAS_DEC_HRTF_HANDLE **hHrtfTD /* o : HRTF handle */ ); /*! r: error code */ ivas_error IVAS_REND_GetHrtfCRendHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS render handle */ IVAS_DEC_HRTF_CREND_HANDLE **hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_REND_GetHrtfFastConvHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS render handle */ IVAS_DEC_HRTF_FASTCONV_HANDLE **hHrtfFastConv /* o : FASTCONV HRTF handle */ ); ivas_error IVAS_REND_GetHrtfParamBinHandle( - IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS decoder handle */ + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS render handle */ IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error IVAS_REND_GetHrtfStatisticsHandle( + IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ + IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ +); +#endif + /* Functions to be called during rendering */ ivas_error IVAS_REND_FeedInputAudio_fx( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index fd53eb631..7f58cfc94 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2359,7 +2359,6 @@ void destroy_SetOfHRTF( return; } - #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * destroy_hrtf_statistics() -- GitLab From 06917878414b2d8de2b02254c4589458fff3b8bb Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 17:29:16 +0200 Subject: [PATCH 101/692] All reverb .c files from lib_rend --- lib_rend/ivas_reverb_filter_design_fx.c | 4 ++ lib_rend/ivas_reverb_fx.c | 88 ++++++++++++++++++++++--- lib_rend/ivas_reverb_utils_fx.c | 51 ++++++++++++-- 3 files changed, 130 insertions(+), 13 deletions(-) diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 62c97f88f..ba6a53c7a 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -919,6 +919,9 @@ void ivas_reverb_interpolate_acoustic_data_fx( return; } + + +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * ivas_reverb_get_hrtf_set_properties() * @@ -1174,3 +1177,4 @@ void ivas_reverb_get_hrtf_set_properties_fx( return; } +#endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9b149940c..09af39bb6 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1264,21 +1264,32 @@ static void set_fft_and_datablock_sizes_fx( static void set_reverb_acoustic_data_fx( ivas_reverb_params_t *pParams, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else const AUDIO_CONFIG input_audio_config, const HRTFS_HANDLE hHrtf, +#endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics, +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const Word16 subframe_len, +#endif const Word16 nr_fc_input, const Word16 nr_fc_fft_filter ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + int16_t bin_idx; +#else Word16 nr_out_ch, hrtf_idx, offset, iter_idx, bin_idx; +#endif + Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp; + Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e; + Word16 pow_exp; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else Word32 *pHrtf_set_l_re_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_l_im_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_r_re_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_r_im_fx[MAX_INTERN_CHANNELS]; - Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp; - Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e; - Word16 pow_exp; Word32 *pFc_input_fx = pRoomAcoustics->pFc_input_fx; Word32 *pAcoustic_rt60_fx = pRoomAcoustics->pAcoustic_rt60_fx; @@ -1330,7 +1341,7 @@ static void set_reverb_acoustic_data_fx( pParams->pHrtf_avg_pwr_response_r_const_fx = (const Word32 *) pParams->pHrtf_avg_pwr_response_r_fx; pParams->pHrtf_inter_aural_coherence_const_fx = (const Word32 *) pParams->pHrtf_inter_aural_coherence_fx; } - +#endif /* interpolate input table data for T60 and DSR to the FFT filter grid */ ivas_reverb_interpolate_acoustic_data_fx( nr_fc_input, pFc_input_fx, pAcoustic_rt60_fx, pAcoustic_dsr_fx, nr_fc_fft_filter, pFc_fx, pRt60_fx, pDsr_fx, pRt60_e, pDsr_e ); @@ -1461,13 +1472,16 @@ static ivas_error setup_FDN_branches_fx( *------------------------------------------------------------------------*/ ivas_error ivas_reverb_open_fx( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ - const Word32 output_Fs /* i : output sampling rate */ -) +#endif + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + const int32_t output_Fs ) { ivas_error error; REVERB_HANDLE pState = NULL; @@ -1541,6 +1555,13 @@ ivas_error ivas_reverb_open_fx( } test(); + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); + params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; + params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; + params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; +#else IF( hHrtf == NULL && lr_energy_and_iac_fx != NULL ) { params.pHrtf_avg_pwr_response_l_const_fx = lr_energy_and_iac_fx[0]; @@ -1564,6 +1585,7 @@ ivas_error ivas_reverb_open_fx( params.pDsr_fx[i] = L_abs( params.pDsr_fx[i] ); move32(); } +#endif /* set reverb acoustic configuration based on renderer config */ pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; @@ -2416,6 +2438,55 @@ static ivas_error ivas_binaural_reverb_open_fx( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*------------------------------------------------------------------------- + * ivas_binaural_reverb_init() + * + * Allocate and initialize binaural room reverberator handle + * for CLDFB renderers + *------------------------------------------------------------------------*/ +ivas_error ivas_binaural_reverb_init( + REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ + const int16_t numBins, /* i : number of CLDFB bins */ + const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ + const int32_t sampling_rate, /* i : sampling rate */ + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +) +{ + ivas_error error; + const float *revTimes; + const float *revEne; + float t60[CLDFB_NO_CHANNELS_MAX]; + float ene[CLDFB_NO_CHANNELS_MAX]; + int16_t preDelay; + + error = IVAS_ERR_OK; + + if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) + { + revTimes = t60; + revEne = ene; + + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + { + return error; + } + preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); + } + else + { + revTimes = defaultTimes; + revEne = defaultEne; + preDelay = 10; + } + + error = ivas_binaural_reverb_open( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); + + return error; +} /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_fastconv() * @@ -2515,6 +2586,7 @@ ivas_error ivas_binaural_reverb_open_parambin( return error; } +#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index b3e1e72fa..53d4cf355 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -64,8 +64,11 @@ typedef struct cldfb_convolver_state float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX]; } cldfb_convolver_state; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); +#else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); - +#endif /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() @@ -74,10 +77,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCO *-----------------------------------------------------------------------------------------*/ ivas_error ivas_reverb_prepare_cldfb_params( +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ) @@ -89,7 +97,9 @@ ivas_error ivas_reverb_prepare_cldfb_params( float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -133,11 +143,14 @@ ivas_error ivas_reverb_prepare_cldfb_params( exp_argument = max( exp_argument, -23.0f ); pOutput_ene[idx] *= expf( exp_argument ); } - +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); +#else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { return error; } +#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -147,13 +160,13 @@ ivas_error ivas_reverb_prepare_cldfb_params( return IVAS_ERR_OK; } - +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------------------------* * Function ivas_cldfb_convolver() * * Function for convolving CLDFB-domain data with filter taps *-----------------------------------------------------------------------------------------*/ - +#endif /*-----------------------------------------------------------------------------------------* * Function get_IR_from_filter_taps() @@ -260,7 +273,18 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( return IVAS_ERR_OK; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------------------------* + * Function ivas_reverb_set_energies() + * + * Function gets the precalculated left/right energies and computes average + * left/right energies to CLDFB bin center frequencies. + *-----------------------------------------------------------------------------------------*/ +static void ivas_reverb_set_energies( + const float *avg_pwr_l, + const float *avg_pwr_r, +#else /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_get_fastconv_hrtf_set_energies() * @@ -273,21 +297,34 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, +#endif const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ) { int16_t freq_idx; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; +#endif float input_fc[FFT_SPECTRUM_SIZE]; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; +#endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; + + for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) + { + input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); + } +#else for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( FFT_SPECTRUM_SIZE - 1 ) ); } - +#endif if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) { @@ -315,6 +352,9 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); +#else ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_left_fft_fx, avg_pwr_right_fft_fx, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); for ( int i = 0; i < 257; i++ ) @@ -331,4 +371,5 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( avg_pwr_right_fx ); free( avg_pwr_right_e ); return IVAS_ERR_OK; +#endif } -- GitLab From 7db5ca7ab1cc6d938407c459da9da7612302fa72 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 18:16:38 +0200 Subject: [PATCH 102/692] All remaining headers and functions from lib_rend --- lib_rend/ivas_crend_fx.c | 13 ++- .../ivas_dirac_dec_binaural_functions_fx.c | 11 ++- lib_rend/ivas_hrtf_fx.c | 98 +++++++++++++++++++ lib_rend/ivas_objectRenderer_mix_fx.c | 3 + lib_rend/ivas_prot_rend_fx.h | 54 +++++++++- 5 files changed, 174 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 36965fc61..66dca6cfd 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1669,7 +1669,11 @@ ivas_error ivas_rend_openMultiBinCrend( ivas_error error; #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) +#endif #else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) #endif @@ -1693,6 +1697,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const Word32 output_Fs, const Word16 num_poses @@ -1867,8 +1874,12 @@ ivas_error ivas_rend_openCrend( IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if( ( NE_32( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 408f1cb1b..bdead9cbd 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -315,9 +315,14 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( IF( hDiracDecBin->hReverb == NULL ) #endif { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) - { + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) +#else + /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) +#endif + { return error; } } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 0cb8ae505..873b632fa 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,6 +33,9 @@ #include #include "options.h" #include "prot_fx.h" +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#include "ivas_rom_binaural_crend_head.h" +#endif #include "ivas_prot_rend_fx.h" #include "ivas_error.h" #include "wmc_auto.h" @@ -212,3 +215,98 @@ void ivas_HRTF_parambin_binary_close_fx( return; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_binary_open() + * + * Allocate HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + *hHrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ); + if ( *hHrtfStatistics == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + return IVAS_ERR_OK; +} + + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_close() + * + * Close HRTF binary handle for statistics handler + *-----------------------------------------------------------------------*/ + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics ) +{ + if ( hHrtfStatistics == NULL || *hHrtfStatistics == NULL ) + { + return; + } + + free( *hHrtfStatistics ); + *hHrtfStatistics = NULL; + + return; +} + +/*-----------------------------------------------------------------------* + * ivas_HRTF_statistics_init() + * + * Allocates HRTF statistics handle and initializes from ROM + *-----------------------------------------------------------------------*/ + +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, + int32_t sampleRate ) +{ + HRTFS_STATISTICS *HrtfStatistics; + + if ( hHrtfStatistics != NULL && *hHrtfStatistics != NULL ) + { + /* Tables already loaded from file */ + return IVAS_ERR_OK; + } + + /* Initialise tables from ROM */ + if ( ( HrtfStatistics = (HRTFS_STATISTICS *) malloc( sizeof( HRTFS_STATISTICS ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for statistics HRTF tables!" ); + } + + HrtfStatistics->average_energy_l = NULL; + HrtfStatistics->average_energy_r = NULL; + HrtfStatistics->inter_aural_coherence = NULL; + + switch ( sampleRate ) + { + case 48000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz; + break; + case 32000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz; + break; + case 16000: + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz; + break; + } + HrtfStatistics->fromROM = TRUE; + + *hHrtfStatistics = HrtfStatistics; + + + return IVAS_ERR_OK; +} +#endif \ No newline at end of file diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index 72042975b..c46ca25db 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -409,6 +409,8 @@ static ivas_error DefaultBSplineModel_fx( model = &( HrFiltSet_p->ModelParams ); modelITD = &( HrFiltSet_p->ModelParamsITD ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else SWITCH( output_Fs ) { case 48000: @@ -444,6 +446,7 @@ static ivas_error DefaultBSplineModel_fx( #endif BREAK; } +#endif /* Set ROM flag for correct deallocation */ model->modelROM = TRUE; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 4e23011b4..1513ff29b 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -620,6 +620,21 @@ void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_HRTF_statistics_init( + HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ + int32_t sampleRate /* i : Sample rate */ +); + +void ivas_HRTF_statistics_close( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +ivas_error ivas_HRTF_statistics_binary_open( + HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ +); + +#endif /*----------------------------------------------------------------------------------* * TD object renderer @@ -865,6 +880,9 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + HRTFS_STATISTICS_HANDLE hHrtfStatistics, +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT const Word32 output_Fs, const Word16 num_poses @@ -919,16 +937,35 @@ ivas_error ivas_rend_crendProcessSubframe( * Reverberator *----------------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_binaural_reverb_init( +#else ivas_error ivas_binaural_reverb_open_fastconv_fx( +#endif REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else +#endif const Word16 numBins, /* i : number of CLDFB bins */ const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ +#else IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ const AUDIO_CONFIG internal_config, /* i : internal audio config for FastConv */ +#endif const Word32 sampling_rate, /* i : sampling rate */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const float *defaultTimes, /* i : default reverberation times */ + const float *defaultEne /* i : default reverberation energies */ +#else const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ +#endif ); + +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const Word16 numBins, /* i : number of CLDFB bins Q0 */ @@ -937,6 +974,7 @@ ivas_error ivas_binaural_reverb_open_parambin( const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ); +#endif void ivas_binaural_reverb_close_fx( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ @@ -957,9 +995,13 @@ void ivas_binaural_reverb_processSubframe_fx( ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ +#else const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ +#endif RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const Word32 output_Fs /* i : output sampling rate */ ); @@ -1105,6 +1147,14 @@ void ivas_reverb_calc_color_levels_fx( const Word32 *pT60_filter_coeff, //input in Q31 Word32 *pTarget_color_L, //output in Q30 Word32 *pTarget_color_R); //output in Q30 +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_reverb_prepare_cldfb_params( + const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, + const HRTFS_STATISTICS_HANDLE hHrtfStatistics, + const int32_t output_Fs, + float *pOutput_t60, + float *pOutput_ene ); +#else ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, @@ -1113,6 +1163,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ); +#endif void ivas_reverb_interpolate_acoustic_data_fx( const Word16 input_table_size, const Word32 *pInput_fc, //input in Q16 @@ -1125,6 +1176,7 @@ void ivas_reverb_interpolate_acoustic_data_fx( Word16 *pOutput_t60_e, //output e Word16 *pOutput_dsr_e //output e ); +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES void ivas_reverb_get_hrtf_set_properties_fx( Word32 **ppHrtf_set_L_re, Word32 **ppHrtf_set_L_im, @@ -1138,7 +1190,7 @@ void ivas_reverb_get_hrtf_set_properties_fx( Word32 *pOut_avg_pwr_R, //output in Q23 Word32 *out_i_a_coherence //output in Q27 ); - +#endif /*---------------------------------------------------------------------------------* * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ -- GitLab From bd92de35e214fa7201ec3818c3f72f3938d97faf Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 18:43:36 +0200 Subject: [PATCH 103/692] All functions lib_dec --- lib_dec/ivas_binRenderer_internal_fx.c | 6 +++- lib_dec/ivas_init_dec.c | 45 +++++++++++++++++++++++++- lib_dec/ivas_ism_dec_fx.c | 18 +++++++++-- lib_dec/ivas_mct_dec_fx.c | 8 +++++ 4 files changed, 72 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 9b7bd86b6..5431fcece 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1418,8 +1418,12 @@ ivas_error ivas_binRenderer_open_fx( test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index b4af0ed06..e752080f8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1179,6 +1179,13 @@ ivas_error ivas_init_decoder_front( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) , IVAS_ERR_OK ) ) + { + return error; + } +#endif + /*-------------------------------------------------------------------* * Allocate and initialize Binaural Renderer configuration handle *--------------------------------------------------------------------*/ @@ -1364,6 +1371,20 @@ ivas_error ivas_init_decoder_fx( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /*--------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle + *--------------------------------------------------------------------*/ + + if ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { + if ( ( error = ivas_HRTF_statistics_init( &st_ivas->hHrtfStatistics, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -2274,8 +2295,12 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } } @@ -2318,13 +2343,23 @@ ivas_error ivas_init_decoder_fx( } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) +#endif #endif { return error; @@ -2862,6 +2897,9 @@ void ivas_initialize_handles_dec( st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + st_ivas->hHrtfStatistics = NULL; +#endif st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; st_ivas->hSbaIsmData = NULL; @@ -3096,6 +3134,11 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /* HRTF statistics */ + ivas_HRTF_statistics_close( &st_ivas->hHrtfStatistics ); +#endif + /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 18c6953f2..c8863947f 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -220,8 +220,12 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } } @@ -248,13 +252,21 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* Open Crend Binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) , IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) - { +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) + { return error; } #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) - { +#endif + { return error; } #endif diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index db9cddc39..825478479 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1576,9 +1576,17 @@ static ivas_error ivas_mc_dec_reconfig_fx( ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) { #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) +#endif #endif { return error; -- GitLab From e90663ed2e8f6f2017b5c0b373a81a05d22b5688 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 22 May 2025 18:57:34 +0200 Subject: [PATCH 104/692] All functions decoder.c and renderer.c --- apps/decoder.c | 34 ++++++++++++++++++++++++++++++++++ apps/renderer.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index a59bc5fac..3f30f4520 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -176,6 +176,9 @@ int main( IVAS_RENDER_FRAMESIZE asked_frame_size; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif #ifdef WMOPS reset_wmops(); @@ -644,6 +647,7 @@ int main( } } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) { @@ -653,6 +657,7 @@ int main( goto cleanup; } } +#endif #endif if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { @@ -736,6 +741,35 @@ int main( destroy_parambin_hrtf( hHrtfParambin ); } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef NONBE_FIX_BINARY_BINAURAL_READING + if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#else + if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } +#endif +#endif +#endif } /*------------------------------------------------------------------------------------------* diff --git a/apps/renderer.c b/apps/renderer.c index 64ef2e5d6..fa716c892 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -766,6 +766,9 @@ int main( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; +#endif IsmPositionProvider *positionProvider; LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS]; RenderConfigReader *renderConfigReader = NULL; @@ -1054,6 +1057,7 @@ int main( } } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) { @@ -1063,6 +1067,7 @@ int main( goto cleanup; } } +#endif #endif if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) @@ -1146,6 +1151,28 @@ int main( } } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES + if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); + goto cleanup; + } + if ( ( error = load_reverb_binary( *hHrtfStatistics, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK ) + { + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", args.customHrtfFilePath ); + goto cleanup; + } + else + { + destroy_hrtf_statistics( hHrtfStatistics ); + } + } +#endif +#endif + hrtfFileReader_close( &hrtfFileReader ); } @@ -2258,6 +2285,9 @@ cleanup: { destroy_td_hrtf( hHrtfTD ); } +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + destroy_hrtf_statistics( hHrtfStatistics ); +#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); -- GitLab From fcda84a8ee56a78ea0a27eb67be04d8e67c539bc Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Fri, 23 May 2025 15:33:13 +0900 Subject: [PATCH 105/692] Add NONBE_FIX_1006_PAST_DMX_NRG_ERROR --- lib_com/options.h | 1 + lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 91172d59a..fc61d4726 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,6 +129,7 @@ #ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA #define NONBE_FIX_947_STEREO_DMX_FADOPT /* Orange: Fading optimisation */ #endif +#define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index e82005965..2d0c3b4aa 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -376,10 +376,15 @@ void stereo_dft_unify_dmx_fx( Word16 idx_k0, idx_k1; Word16 q_shift0; Word16 q_shift1; +#ifdef NONBE_FIX_1006_PAST_DMX_NRG_ERROR + idx_k0 = add( hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX - 1 ) & ( STEREO_DFT_PAST_MAX - 1 ); /* Q0 */ + idx_k1 = add( idx_k0, 1 ) & ( STEREO_DFT_PAST_MAX - 1 ); +#else idx_k0 = ( add( hStereoDft->past_DMX_pos, 1 ) ) % STEREO_DFT_PAST_MAX; move16(); idx_k1 = ( add( idx_k0, 1 ) ) % STEREO_DFT_PAST_MAX; move16(); +#endif q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0] ); q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1] ); -- GitLab From 238ff2ba228072d2e755047194103a93da3323b4 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Fri, 23 May 2025 09:38:57 +0200 Subject: [PATCH 106/692] fix some compiling error --- lib_dec/ivas_binRenderer_internal_fx.c | 6 +- lib_dec/ivas_init_dec.c | 12 +- lib_dec/ivas_ism_dec_fx.c | 12 +- lib_dec/ivas_mct_dec_fx.c | 4 +- lib_rend/ivas_crend_fx.c | 6 +- .../ivas_dirac_dec_binaural_functions_fx.c | 7 +- lib_rend/ivas_hrtf_fx.c | 20 +- lib_rend/ivas_reverb_fx.c | 3 +- lib_rend/ivas_stat_rend.h | 12 +- lib_rend/lib_rend.c | 247 +++++++++--------- 10 files changed, 169 insertions(+), 160 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 5431fcece..d53d6c76d 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1419,11 +1419,11 @@ ivas_error ivas_binRenderer_open_fx( IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) -#endif - { +#endif + { return error; } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index e752080f8..05efe8207 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1180,7 +1180,7 @@ ivas_error ivas_init_decoder_front( } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) { return error; } @@ -2296,11 +2296,11 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #endif - { + { return error; } } @@ -2345,7 +2345,8 @@ ivas_error ivas_init_decoder_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) , IVAS_ERR_OK ) ) + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ), + IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), @@ -2354,7 +2355,8 @@ ivas_error ivas_init_decoder_fx( #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index c8863947f..4f900a6de 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -221,11 +221,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #endif - { + { return error; } } @@ -253,20 +253,20 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( /* Open Crend Binaural renderer */ #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) , IVAS_ERR_OK ) ) - { + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + { return error; } #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #endif - { + { return error; } #endif diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 825478479..d3268bda3 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1577,13 +1577,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( { #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 66dca6cfd..b293e8c00 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1875,11 +1875,11 @@ ivas_error ivas_rend_openCrend( IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if( ( NE_32( error = ivas_reverb_open( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ) , IVAS_ERR_OK ) ) + IF( ( NE_32( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) -#endif - { +#endif + { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index d0c4397e5..5c4d55488 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -317,13 +317,14 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK ) #else /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) -#endif - { +#endif + { return error; + x } } } diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 873b632fa..0e535170b 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -287,19 +287,19 @@ ivas_error ivas_HRTF_statistics_init( switch ( sampleRate ) { case 48000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz; + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx; break; case 32000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz; + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx; break; case 16000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz; + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx; + HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx; + HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx; break; } HrtfStatistics->fromROM = TRUE; @@ -309,4 +309,4 @@ ivas_error ivas_HRTF_statistics_init( return IVAS_ERR_OK; } -#endif \ No newline at end of file +#endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 09af39bb6..f1393148d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2487,6 +2487,8 @@ ivas_error ivas_binaural_reverb_init( return error; } +#endif + /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_fastconv() * @@ -2586,7 +2588,6 @@ ivas_error ivas_binaural_reverb_open_parambin( return error; } -#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index d8dd14034..77d3bcc35 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -847,7 +847,7 @@ typedef struct ivas_combined_orientation_struct #ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; #else - Word32 Rmat_prev_fx[3][3]; /* Q30 */ + Word32 Rmat_prev_fx[3][3]; /* Q30 */ #endif Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; @@ -1198,8 +1198,8 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParams_t ModelParams; ModelEval_t ModelEval; ModelParamsITD_t ModelParamsITD; - TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ - Word32 latency_s_fx; /* Q31 */ + TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ + Word32 latency_s_fx; /* Q31 */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #else const Word32 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb */ @@ -1480,9 +1480,9 @@ typedef struct ivas_hrtfs_parambin_struct #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES typedef struct ivas_hrtfs_statistics_struct { - float *average_energy_l; - float *average_energy_r; - float *inter_aural_coherence; + Word32 *average_energy_l; + Word32 *average_energy_r; + Word32 *inter_aural_coherence; int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; #endif diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index ecab18225..7c2e4115d 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1532,9 +1532,10 @@ static ivas_error setRendInputActiveIsm( IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { - return error; - } +#endif + { + return error; + } #else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { @@ -1594,57 +1595,57 @@ static ivas_error setRendInputActiveIsm( } } #endif -} -ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) -{ - IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { - return error; } -} -ELSE -{ -#ifndef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) + ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) { - return error; + IF( NE_32( ( error = initIsmMasaRendering( inputIsm, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + { + return error; + } } - Word16 nchan_rend = num_src; - move16(); - - test(); - IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + ELSE { - nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ - } +#ifndef SPLIT_REND_WITH_HEAD_ROT + IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) + { + return error; + } + Word16 nchan_rend = num_src; + move16(); - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p != NULL ) + test(); + IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) + { + nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ + } + + FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) { - IF( Src_p->SrcSpatial_p != NULL ) + TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; + IF( Src_p != NULL ) { - Src_p->SrcSpatial_p->q_Pos_p = Q31; + IF( Src_p->SrcSpatial_p != NULL ) + { + Src_p->SrcSpatial_p->q_Pos_p = Q31; + move16(); + } + TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; + SrcSpatial_p->q_Pos_p = Q31; move16(); } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; - move16(); } - } - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { + IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #endif - { - return error; + { + return error; + } } - } #else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { @@ -1679,29 +1680,29 @@ ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) - { #endif - return error; + { + return error; + } } - } - ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) - { + ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) + { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #endif - { - return error; + { + return error; + } } - } #endif -} + } -return IVAS_ERR_OK; + return IVAS_ERR_OK; } static void clearInputIsm( @@ -2681,78 +2682,79 @@ static ivas_error initMcBinauralRendering( IF( NE_32( ( error = ivas_reverb_open( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) -#endif { - return error; +#endif + { + return error; + } } } -} -ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) -{ - /* open CREND */ + ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) + { + /* open CREND */ #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, - outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, + outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), + IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, + hMixconv, + outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), + IVAS_ERR_OK ) ) #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ), IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, + hMixconv, + outSampleRate ) ), + IVAS_ERR_OK ) ) #endif #endif - { - return error; + { + return error; + } } -} -/* Initialise the EFAP handle for rotation on input layout */ -test(); -test(); -IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) -{ - IF( NE_32( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ), IVAS_ERR_OK ) ) + /* Initialise the EFAP handle for rotation on input layout */ + test(); + test(); + IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && inputMc->base.ctx.pHeadRotData->headRotEnabled && inputMc->efapInWrapper.hEfap == NULL ) { - return error; + IF( NE_32( ( error = initEfap( &inputMc->efapInWrapper, inConfig, NULL ) ), IVAS_ERR_OK ) ) + { + return error; + } } -} -/* determine binaural delay ( used for aligning LFE to output signal ) */ + /* determine binaural delay ( used for aligning LFE to output signal ) */ -IF( ( inputMc->crendWrapper != NULL ) ) -{ - binauralDelayNs = inputMc->crendWrapper->binaural_latency_ns; -} -ELSE -{ - binauralDelayNs = 0; -} -move32(); + IF( ( inputMc->crendWrapper != NULL ) ) + { + binauralDelayNs = inputMc->crendWrapper->binaural_latency_ns; + } + ELSE + { + binauralDelayNs = 0; + } + move32(); -binauralDelayNs = L_max( binauralDelayNs, inputMc->tdRendWrapper.binaural_latency_ns ); -Word16 exp = 0; -move16(); -Word16 var1 = BASOP_Util_Divide3232_Scale( *inputMc->base.ctx.pOutSampleRate, 1000000000, &exp ); -Word32 var2 = L_shr_r( Mpy_32_32( binauralDelayNs, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ -inputMc->binauralDelaySmp = extract_l( var2 ); -move16(); -// inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); + binauralDelayNs = L_max( binauralDelayNs, inputMc->tdRendWrapper.binaural_latency_ns ); + Word16 exp = 0; + move16(); + Word16 var1 = BASOP_Util_Divide3232_Scale( *inputMc->base.ctx.pOutSampleRate, 1000000000, &exp ); + Word32 var2 = L_shr_r( Mpy_32_32( binauralDelayNs, L_deposit_h( var1 ) ), negate( exp ) ); /* Q0 */ + inputMc->binauralDelaySmp = extract_l( var2 ); + move16(); + // inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); -IF( GT_16( inputMc->binauralDelaySmp, MAX_BIN_DELAY_SAMPLES ) ) -{ - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); -} + IF( GT_16( inputMc->binauralDelaySmp, MAX_BIN_DELAY_SAMPLES ) ) + { + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); + } -return IVAS_ERR_OK; + return IVAS_ERR_OK; } static ivas_error initMcMasaRendering( @@ -3323,11 +3325,12 @@ static ivas_error setRendInputActiveSba( IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ), IVAS_ERR_OK ) ) -#endif { - return error; -} +#endif + { + return error; + } -return error; + return error; } static void clearInputSba( input_sba *inputSba ) @@ -3424,14 +3427,15 @@ static ivas_error setRendInputActiveMasa( IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ), IVAS_ERR_OK ) ) -#endif { - return error; +#endif + { + return error; + } + inputMasa->metadataHasBeenFed = false; + move16(); } - inputMasa->metadataHasBeenFed = false; - move16(); -} -return IVAS_ERR_OK; + return IVAS_ERR_OK; } static void clearInputMasa( @@ -10276,17 +10280,18 @@ static ivas_error ivas_masa_ext_rend_parambin_init( move16(); #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ + IF( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ #else IF( hDiracDecBin->hReverb == NULL ) #endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ) , IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes_fx, hHrtfParambin->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ) , IVAS_ERR_OK ) ) -#endif { + IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif + { return error; } } @@ -10306,7 +10311,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ + IF( pos_idx == 0 ) /* open decorrelator only for the main direction */ { #endif /* Always open frequency domain decorrelator */ @@ -10482,11 +10487,11 @@ static ivas_error initMasaExtRenderer( } } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ) , IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ), IVAS_ERR_OK ) ) -#endif - { +#endif + { return error; } } -- GitLab From c501f1f5044db13c8128677e85749f508ed6ef31 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 23 May 2025 10:14:30 +0200 Subject: [PATCH 107/692] port NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER --- lib_com/options.h | 3 ++- lib_dec/ivas_jbm_dec_fx.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 91172d59a..09c753209 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,8 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA #define NONBE_FIX_947_STEREO_DMX_FADOPT /* Orange: Fading optimisation */ -#endif +#endif +#define NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER /* FhG: issues #1012, 1013: JBM flush function uses wrong output buffer */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c85e36d8e..d402fb1e3 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2668,8 +2668,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 n_slots_still_available; Word16 n_samples_to_render; DECODER_TC_BUFFER_HANDLE hTcBuffer; +#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER + Word32 *p_output_fx[MAX_CICP_CHANNELS + MAX_NUM_OBJECTS]; +#else Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; +#endif Word16 nchan_in, nchan_out; IF( !st_ivas->hDecoderConfig->Opt_tsm ) { @@ -2729,10 +2733,17 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); +#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER + FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; + } +#else FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; } +#endif test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) -- GitLab From 4ee97743e1866257069d05b4d7c2c1d2c0e7a273 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 10:41:01 +0200 Subject: [PATCH 108/692] changed float to word32 in hrtf_file_reader.c --- lib_util/hrtf_file_reader.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 7f58cfc94..364afc813 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -797,17 +797,17 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - hHrtfStatistics->average_energy_l = (float *) malloc( lr_iac_len * sizeof( float ) ); - hHrtfStatistics->average_energy_r = (float *) malloc( lr_iac_len * sizeof( float ) ); - hHrtfStatistics->inter_aural_coherence = (float *) malloc( lr_iac_len * sizeof( float ) ); + hHrtfStatistics->average_energy_l = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + hHrtfStatistics->average_energy_r = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + hHrtfStatistics->inter_aural_coherence = (Word32 *) malloc( lr_iac_len * sizeof( Word32) ); if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } - fread( hHrtfStatistics->average_energy_l, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->average_energy_r, sizeof( const float ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->inter_aural_coherence, sizeof( const float ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_l, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence, sizeof( const Word32 ), lr_iac_len, f_hrtf ); hHrtfStatistics->fromROM = FALSE; #else -- GitLab From 849959bb0865274dbd793106ab8610959abd59e3 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 11:02:35 +0200 Subject: [PATCH 109/692] bug fixes + additions in hrtf_file_reader.h --- lib_rend/ivas_crend_fx.c | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 1 - lib_util/hrtf_file_reader.h | 20 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index b293e8c00..392d8ea99 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1875,7 +1875,7 @@ ivas_error ivas_rend_openCrend( IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( ( NE_32( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 5c4d55488..023adcf7d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -324,7 +324,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( #endif { return error; - x } } } diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 51c321352..4b9806eb8 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -102,8 +102,13 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ + int32_t sampleRate, /* i : sample rate */ +#else + IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ +#endif + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); #endif @@ -174,6 +179,17 @@ ivas_error load_parambin_HRTF_from_binary( const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +/*---------------------------------------------------------------------* + * destroy_hrtf_statistics() + * + * free memory allocated for HRTF statistics binary data + *---------------------------------------------------------------------*/ + +ivas_error destroy_hrtf_statistics( + IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ +); +#endif /*---------------------------------------------------------------------* * dealloc_HRTF_binary() -- GitLab From e2cf5b321499d899bc7bb0d96a9f4eddc614a896 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 23 May 2025 10:58:33 +0200 Subject: [PATCH 110/692] port FIX_998_UNUSED_FUNCTION --- lib_com/options.h | 3 +- lib_dec/ivas_dirac_dec_fx.c | 34 +++++++++++++++++++ lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 22 +++++++++--- lib_rend/ivas_dirac_rend_fx.c | 4 +++ lib_rend/ivas_prot_rend_fx.h | 4 +++ 5 files changed, 62 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 91172d59a..d6b22d17d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,8 @@ #define NONBE_FIX_947_STEREO_DMX_EVS_PHA /* Orange: Fix issues on PHA */ #ifdef NONBE_FIX_947_STEREO_DMX_EVS_PHA #define NONBE_FIX_947_STEREO_DMX_FADOPT /* Orange: Fading optimisation */ -#endif +#endif +#define FIX_998_UNUSED_FUNCTION /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index feca814c8..058897119 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2738,6 +2738,7 @@ void ivas_dirac_dec_render_sf_fx( { masa_band_mapping = st_ivas->hMasa->data.band_mapping; } +#ifndef FIX_998_UNUSED_FUNCTION test(); test(); IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 1 ) ) @@ -2772,6 +2773,20 @@ void ivas_dirac_dec_render_sf_fx( NULL, hodirac_flag ); } +#else + ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, + hDirACRend, + st_ivas->hVBAPdata, + masa_band_mapping, + st_ivas->hMasaIsmData, + azimuth, + elevation, + md_idx, + surCohRatio_fx, + surCohRatio_q_fx, + hodirac_flag ); + +#endif } test(); @@ -3291,6 +3306,7 @@ void ivas_dirac_dec_render_sf_fx( move16(); } +#ifndef FIX_998_UNUSED_FUNCTION test(); test(); IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) @@ -3333,6 +3349,24 @@ void ivas_dirac_dec_render_sf_fx( hodirac_flag, hDirAC->hConfig->dec_param_estim ); } +#else + ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, + DirAC_mem.reference_power_q, + p_onset_filter_fx, + azimuth, + elevation, + hSpatParamRendCom->diffuseness_vector_fx[md_idx], + hSpatParamRendCom->q_diffuseness_vector, + hSpatParamRendCom, + hDirACRend, + st_ivas->hVBAPdata, + hDirACRend->hOutSetup, + nchan_transport, + md_idx, + hodirac_flag, + hDirAC->hConfig->dec_param_estim ); + +#endif IF( hDirAC->hConfig->dec_param_estim ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 7b446a80e..70719a185 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -650,8 +650,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ +#ifndef FIX_998_UNUSED_FUNCTION const Word16 sh_rot_max_order, - const Word32 *p_Rmat, /* i : rotation matrix Q30*/ + const Word32 *p_Rmat, /* i : rotation matrix Q30*/ +#endif const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ const Word16 nchan_transport, /* i : number of transport channels*/ @@ -705,8 +707,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( md_idx, NULL, 0, +#ifndef FIX_998_UNUSED_FUNCTION 2, p_Rmat, +#endif hodirac_flag ); { @@ -777,8 +781,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( md_idx, NULL, 0, +#ifndef FIX_998_UNUSED_FUNCTION sh_rot_max_order, p_Rmat, +#endif hodirac_flag ); { @@ -2778,6 +2784,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( return; } +#ifndef FIX_998_UNUSED_FUNCTION /*------------------------------------------------------------------------- * ivas_dirac_dec_get_response_split_order() @@ -3061,6 +3068,7 @@ static void ivas_dirac_dec_get_response_split_order_fx( return; } +#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_compute_directional_responses() @@ -3079,9 +3087,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 md_idx, const Word32 *surCohRatio_fx, /*i:Q_surCohRatio*/ Word16 Q_surCohRatio, +#ifndef FIX_998_UNUSED_FUNCTION const Word16 shd_rot_max_order, /* i : split-order rotation method */ const Word32 *p_Rmat, /* i : rotation matrix Q30*/ - const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ +#endif + const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ) { Word16 k, l, i; @@ -3194,6 +3204,7 @@ void ivas_dirac_dec_compute_directional_responses_fx( exp_direct_response_dir2 = 0; move16(); +#ifndef FIX_998_UNUSED_FUNCTION IF( p_Rmat != 0 ) { ivas_dirac_dec_get_response_split_order_fx( azimuth[k], elevation[k], direct_response_hoa_fx, shd_rot_max_order, p_Rmat, &Q_direct_response_hoa ); @@ -3205,10 +3216,11 @@ void ivas_dirac_dec_compute_directional_responses_fx( } ELSE { +#endif #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 ); + 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 ) @@ -3216,10 +3228,12 @@ void ivas_dirac_dec_compute_directional_responses_fx( #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 ); + ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); #endif } +#ifndef FIX_998_UNUSED_FUNCTION } +#endif test(); test(); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index f67f3761b..708fe8b20 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4223,8 +4223,10 @@ static void ivas_masa_ext_dirac_render_sf_fx( md_idx, surCohRatio_fx, Q_surCohRatio, +#ifndef FIX_998_UNUSED_FUNCTION 0, NULL, +#endif 0 ); Word16 proto_direct_buffer_f_temp_q[60]; @@ -4599,8 +4601,10 @@ static void ivas_masa_ext_dirac_render_sf_fx( hSpatParamRendCom->q_diffuseness_vector, hSpatParamRendCom, hDirACRend, +#ifndef FIX_998_UNUSED_FUNCTION 0, 0, +#endif hMasaExtRend->hVBAPdata, hDirACRend->hOutSetup, nchan_transport, diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 4e23011b4..ba7ca8458 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -472,8 +472,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ +#ifndef FIX_998_UNUSED_FUNCTION const Word16 sh_rot_max_order, const Word32 *p_Rmat, /* i : rotation matrix */ +#endif const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ const Word16 nchan_transport, /* i : number of transport channels*/ @@ -545,8 +547,10 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 md_idx, const Word32 *surCohRatio_fx, Word16 Q_surCohRatio, +#ifndef FIX_998_UNUSED_FUNCTION const Word16 shd_rot_max_order, /* i : split-order rotation method */ const Word32 *p_Rmat, /* i : rotation matrix */ +#endif const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); -- GitLab From 889b7fd5f512305821befc78e178b03e33466446 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 12:38:27 +0200 Subject: [PATCH 111/692] Fixed declarations and refs --- lib_rend/ivas_stat_rend.h | 9 ++++++--- lib_util/hrtf_file_reader.c | 39 ++++++++++++++++++++++++------------- lib_util/hrtf_file_reader.h | 16 ++------------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 77d3bcc35..0443d1854 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1480,9 +1480,12 @@ typedef struct ivas_hrtfs_parambin_struct #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES typedef struct ivas_hrtfs_statistics_struct { - Word32 *average_energy_l; - Word32 *average_energy_r; - Word32 *inter_aural_coherence; + const Word32 *average_energy_l; + const Word32 *average_energy_r; + const Word32 *inter_aural_coherence; + Word32 *average_energy_l_dyn; + Word32 *average_energy_r_dyn; + Word32 *inter_aural_coherence_dyn; int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 364afc813..890d488bf 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -797,17 +797,21 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - hHrtfStatistics->average_energy_l = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - hHrtfStatistics->average_energy_r = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - hHrtfStatistics->inter_aural_coherence = (Word32 *) malloc( lr_iac_len * sizeof( Word32) ); + hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32) ); - if ( hHrtfStatistics->average_energy_l == NULL || hHrtfStatistics->average_energy_r == NULL || hHrtfStatistics->inter_aural_coherence == NULL ) + if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } - fread( hHrtfStatistics->average_energy_l, sizeof( const Word32 ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->average_energy_r, sizeof( const Word32 ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->inter_aural_coherence, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + hHrtfStatistics->average_energy_l = hHrtfStatistics->average_energy_l_dyn; + hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; + hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; + fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + hHrtfStatistics->fromROM = FALSE; #else @@ -2366,18 +2370,27 @@ void destroy_SetOfHRTF( * Destroy the HRTF statistics set. *---------------------------------------------------------------------*/ -ivas_error destroy_hrtf_statistics( +void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { - if ( hHrtfStatistics != NULL && ( *hHrtfStatistics )->fromROM == FALSE ) + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) { - free( ( *hHrtfStatistics )->average_energy_l ); - free( ( *hHrtfStatistics )->average_energy_r ); - free( ( *hHrtfStatistics )->inter_aural_coherence ); + if ( ( *hHrtfStatistics )->average_energy_l != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_l_dyn ); + } + if ( ( *hHrtfStatistics )->average_energy_r != NULL ) + { + free( ( *hHrtfStatistics )->average_energy_r_dyn ); + } + if ( ( *hHrtfStatistics )->inter_aural_coherence != NULL ) + { + free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); + } + } ivas_HRTF_statistics_close( hHrtfStatistics ); - return IVAS_ERR_OK; } #endif diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 4b9806eb8..302a90dee 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -96,7 +96,7 @@ ivas_error load_HRTF_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES /*---------------------------------------------------------------------* - * load_reverb_from_binary() + * load_reverb_binary() * * Load reverb binary data into the HRTF handle *---------------------------------------------------------------------*/ @@ -186,7 +186,7 @@ ivas_error load_parambin_HRTF_from_binary( * free memory allocated for HRTF statistics binary data *---------------------------------------------------------------------*/ -ivas_error destroy_hrtf_statistics( +void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ); #endif @@ -206,18 +206,6 @@ void destroy_parambin_hrtf( IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin /* i/o: Parambin HRTF handle */ ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -/*---------------------------------------------------------------------* - * destroy_hrtf_statistics() - * - * free memory allocated for HRTF statistics binary data - *---------------------------------------------------------------------*/ - -ivas_error destroy_hrtf_statistics( - IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ -); -#endif - /*---------------------------------------------------------------------* * destroy_td_hrtf() * -- GitLab From 7d27a1f4b85ec132993021f9d441d693ac7687ca Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 13:02:06 +0200 Subject: [PATCH 112/692] deactivated switch --- 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 0542d2be6..c257150a2 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define NONBE_FIX_973_HODIRAC_BAND_GROUPING /* FhG: issue 973: empty parameter band in DirAC */ -#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -- GitLab From 21cfaa4b9c28ce68dbc421edec4ee3363202d47c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 23 May 2025 14:32:18 +0200 Subject: [PATCH 113/692] port MR 1425 from float fix msan error for OSBA to stereo decoding --- lib_com/options.h | 2 ++ lib_dec/ivas_ism_renderer_fx.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4fd97b2d4..1d23ec23f 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -132,6 +132,8 @@ #define NONBE_FIX_947_STEREO_DMX_FADOPT /* Orange: Fading optimisation */ #endif +#define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index c3904d136..efb022919 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -183,6 +183,11 @@ void ivas_ism_render_sf_fx( n_samples_rendered_loop = 0; move16(); +#ifdef DEBUGGING + assert( slots_to_render == 0 ); + assert( last_sf <= st_ivas->hTcBuffer->nb_subframes ); +#endif + WHILE( slots_to_render > 0 ) { slots_to_render = sub( slots_to_render, st_ivas->hTcBuffer->subframe_nbslots[last_sf] ); @@ -322,7 +327,13 @@ void ivas_ism_render_sf_fx( ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_in_subframe ); n_samples_rendered_loop = add( n_samples_rendered_loop, n_samples_in_subframe ); +#ifdef NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO + /* update rendered subframe and slots info for all cases apart from a following crend call, the update will + then happen in the crend call*/ + if ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) +#else IF( EQ_16( st_ivas->renderer_type, RENDERER_TD_PANNING ) ) +#endif { st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); -- GitLab From a2f8fbf18f04e7660cc87a609fea23d3ce1a7372 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 23 May 2025 17:46:17 +0530 Subject: [PATCH 114/692] Fix for 3GPP issue 1475: 160 kbit/s ISM4 Encoder: FB BWE lacking energy Link #1475 --- lib_enc/swb_tbe_enc_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 903f3a46c..a4230db46 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7548,7 +7548,7 @@ void fb_tbe_enc_ivas_fx( move16(); temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ - temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( q_input_fhb, hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb + temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb exp = W_norm( temp1 ); @@ -7605,7 +7605,6 @@ void fb_tbe_enc_ivas_fx( { push_indice( st->hBstr, IND_FB_SLOPE, idxGain, 4 ); } - return; } void tbe_write_bitstream_fx( -- GitLab From e26eb7288617bc285cf2e2ec22cd02f2183b8664 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 23 May 2025 18:15:50 +0530 Subject: [PATCH 115/692] Clang formatting changes --- lib_enc/swb_tbe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index a4230db46..9d0f16ee9 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7547,7 +7547,7 @@ void fb_tbe_enc_ivas_fx( hBWE_TD->old_input_fhb_fx_Q = exp_temp; move16(); - temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ + temp2 = sum2_fx_no_sat( input_fhb, L_FRAME48k / 2 ); // 2*q_input_fhb /* Q(2*Q_input_fhb-8) */ temp2 = W_add( temp2, W_shl( hBWE_TD->prev_fb_energy_fx, sub( shl( q_input_fhb, 1 ), hBWE_TD->prev_fb_energy_fx_Q ) ) ); // 2*q_input_fhb temp1 = sum2_fx_no_sat( input_fhb + L_FRAME48k / 2, L_FRAME48k / 2 ); // 2*q_input_fhb -- GitLab From 71126a82078ca01bf6c38a9e3cdd20e8502820aa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 23 May 2025 15:28:28 +0200 Subject: [PATCH 116/692] port MR 1382 from float correct energy for BINAURAL_ROOM_REVERB output with head rotation for parameteric multichannel modes --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 65 +++++++++++++++++++------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a0c7f4f3f..06952c341 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -132,6 +132,7 @@ #define NONBE_FIX_947_STEREO_DMX_FADOPT /* Orange: Fading optimisation */ #endif #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ +#define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 9b7bd86b6..33cf0c9e2 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1095,28 +1095,54 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) +#ifdef NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING + /*Ambisonics input requires different processing*/ + if ( EQ_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) { - Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 - Word32 one_add_foa_const, one_sub_foa_const; + Word32 *inRealPtr_W, *inImagPtr_W; + Word32 *inRealPtr_Y, *inImagPtr_Y; - one_add_foa_const = L_add( ONE_IN_Q30, foa_const_fx ); // Q30 - one_sub_foa_const = L_sub_sat( ONE_IN_Q30, foa_const_fx ); // Q30 + inRealPtr_W = (Word32 *) &( RealBuffer[0][k][0] ); + inImagPtr_W = (Word32 *) &( ImagBuffer[0][k][0] ); - inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); - inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + inRealPtr_Y = (Word32 *) &( RealBuffer[1][k][0] ); + inImagPtr_Y = (Word32 *) &( ImagBuffer[1][k][0] ); FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { - outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], one_add_foa_const ) ); // Q_in - 1 - move32(); - outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], one_add_foa_const ) ); // Q_in - 1 - move32(); + outRealLeftPtr_fx[bandIdx] = L_add( inRealPtr_W[bandIdx], inRealPtr_Y[bandIdx] ); + outImagLeftPtr_fx[bandIdx] = L_add( inImagPtr_W[bandIdx], inImagPtr_Y[bandIdx] ); - outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], one_sub_foa_const ) ); // Q_in - 1 - move32(); - outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], one_sub_foa_const ) ); // Q_in - 1 - move32(); + outRealRightPtr_fx[bandIdx] = L_sub( inRealPtr_W[bandIdx], inRealPtr_Y[bandIdx] ); + outImagRightPtr_fx[bandIdx] = L_sub( inImagPtr_W[bandIdx], inImagPtr_Y[bandIdx] ); + } + } + else +#endif + { + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + Word32 foa_const_fx = L_shl( hBinRenderer->hReverb->foa_enc_fx[chIdx][1], 1 ); // Q30 + Word32 one_add_foa_const, one_sub_foa_const; + + one_add_foa_const = L_add( ONE_IN_Q30, foa_const_fx ); // Q30 + one_sub_foa_const = L_sub_sat( ONE_IN_Q30, foa_const_fx ); // Q30 + + inRealPtr_fx = (Word32 *) &( RealBuffer[chIdx][k][0] ); + inImagPtr_fx = (Word32 *) &( ImagBuffer[chIdx][k][0] ); + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + outRealLeftPtr_fx[bandIdx] = L_add( outRealLeftPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], one_add_foa_const ) ); // Q_in - 1 + move32(); + outImagLeftPtr_fx[bandIdx] = L_add( outImagLeftPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], one_add_foa_const ) ); // Q_in - 1 + move32(); + + outRealRightPtr_fx[bandIdx] = L_add( outRealRightPtr_fx[bandIdx], Mpy_32_32( inRealPtr_fx[bandIdx], one_sub_foa_const ) ); // Q_in - 1 + move32(); + outImagRightPtr_fx[bandIdx] = L_add( outImagRightPtr_fx[bandIdx], Mpy_32_32( inImagPtr_fx[bandIdx], one_sub_foa_const ) ); // Q_in - 1 + move32(); + } } } } @@ -1462,8 +1488,15 @@ ivas_error ivas_binRenderer_open_fx( { test(); test(); - /* NOTE to future self by @kiene: this should have been changed by NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM, but the BASOP repo code is not at that point yet, so not change needed here */ +#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) +#else +#ifdef NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING + IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) +#else IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) +#endif +#endif { FOR( k = 0; k < 11; k++ ) { -- GitLab From 61c61ffbcbb1863eae0f7de1eea1f54765a7a863 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 16:51:53 +0200 Subject: [PATCH 117/692] fixed syntax in lib_rend.c, solved build errors locally in windows --- lib_rend/lib_rend.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 7c2e4115d..09894c319 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4319,22 +4319,17 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( test(); test(); + #ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) #else IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif { - IF( NE_32( ( error = initMcBinauralRendering( inputMc, - inputMc->base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - hIvasRend->hHrtfs.hSetOfHRTF, + IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - hIvasRend->hHrtfs.hHrtfStatistics, -#endif - FALSE ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -5170,11 +5165,20 @@ ivas_error IVAS_REND_SetHeadRotation( hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, + TRUE ) ), + IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - hIvasRend->hHrtfs.hHrtfStatistics, + + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, + hIvasRend->hHrtfs.hSetOfHRTF, + hIvasRend->hHrtfs.hHrtfStatistics, + TRUE ) ), + IVAS_ERR_OK ) ) #endif - TRUE ) ), - IVAS_ERR_OK ) ) + { return error; } @@ -5283,11 +5287,20 @@ ivas_error IVAS_REND_DisableHeadRotation( hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, + TRUE ) ), + IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], + hIvasRend->inputsMc[i].base.inConfig, + hIvasRend->outputConfig, + hIvasRend->hRendererConfig, + hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, -#endif TRUE ) ), - IVAS_ERR_OK ) ) + IVAS_ERR_OK ) ) +#endif + + { return error; -- GitLab From 2091110cbf8217c44fc3c6e24ca8e55456113d8e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 17:05:11 +0200 Subject: [PATCH 118/692] draft: activated compiler switch and added code for converting float binary hrtf data to word32 (needs debugigng) --- lib_com/options.h | 2 +- lib_util/hrtf_file_reader.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index c257150a2..0542d2be6 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define NONBE_FIX_973_HODIRAC_BAND_GROUPING /* FhG: issue 973: empty parameter band in DirAC */ -//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 890d488bf..30921e7fe 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -808,9 +808,15 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_l = hHrtfStatistics->average_energy_l_dyn; hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; - fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); - fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const Word32 ), lr_iac_len, f_hrtf ); + + fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, lr_iac_len ); + + fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, lr_iac_len ); + + fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; -- GitLab From 7c54695c08f961c2e460cd8db6b8d47bdcf2716e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Fri, 23 May 2025 17:08:59 +0200 Subject: [PATCH 119/692] Added code for converting float binary hrtf to word32. Build failed, needs debugging --- lib_util/hrtf_file_reader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 30921e7fe..e10e49870 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -810,13 +810,13 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, lr_iac_len ); + floatToFixed_arr32( hHrtfStatistics->average_energy_l_dyn, hHrtfStatistics->average_energy_l, Q27, lr_iac_len ); fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, lr_iac_len ); + floatToFixed_arr32( hHrtfStatistics->average_energy_r_dyn, hHrtfStatistics->average_energy_r, Q27, lr_iac_len ); fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, lr_iac_len ); + floatToFixed_arr32( hHrtfStatistics->inter_aural_coherence_dyn, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; -- GitLab From f866ba3f8b09e41b6ba9c9e788e8b4cc953aa4df Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 26 May 2025 08:23:55 +0200 Subject: [PATCH 120/692] 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 00fc2426fc83bcdd98ceff35f48c508bcbc14397 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 26 May 2025 11:29:35 +0200 Subject: [PATCH 121/692] port FIX_1024_REMOVE_PARAMMC_MIXING_MAT --- lib_com/options.h | 1 + lib_dec/ivas_mc_param_dec_fx.c | 2 ++ lib_dec/ivas_out_setup_conversion_fx.c | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7b19fc92a..91fa26a53 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index b59623113..3ee471861 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -3085,6 +3085,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( return; } +#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT /*------------------------------------------------------------------------- * ivas_param_mc_get_mono_stereo_mixing_matrices() @@ -3093,6 +3094,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( * for mono and stereo output *------------------------------------------------------------------------*/ +#endif /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 93a7c204e..5ce1f08f1 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -1190,7 +1190,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( cy_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero_fx( Nrqq_fx, MAX_OUTPUT_CHANNELS ); set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); +#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT + /* Step 1.2, get target channel energies for the transported format, Nrqq calculation */ +#else /* Step 1.2, get target channel energies for the transported format as in ivas_param_mc_get_mono_stereo_mixing_matrices(), Nrqq calculation */ +#endif ild_q_fx = hParamMC->icld_q_fx + imult1616( bandIdx, hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); move16(); FOR( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ ) @@ -1212,7 +1216,11 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( move32(); } +#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT + /* Step 1.3 get target Cy () (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ +#else /* Step 1.3 get target Cy like in ivas_param_mc_get_mono_stereo_mixing_matrices() (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ +#endif FOR( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) { FOR( i = 0; i < nchan_transport_format; i++ ) -- GitLab From 2f8b36395a72b58254886986570bb82a64dc3953 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 26 May 2025 12:07:31 +0200 Subject: [PATCH 122/692] Float to fixed point conversion for binary hrtf data + compiler switch bug fixes --- lib_com/options.h | 8 +--- lib_dec/ivas_init_dec.c | 2 +- lib_rend/ivas_reverb_fx.c | 12 +++--- lib_rend/ivas_reverb_utils_fx.c | 9 +++-- lib_util/hrtf_file_reader.c | 72 +++++++++++++++++---------------- 5 files changed, 53 insertions(+), 50 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0542d2be6..efcf2546b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -99,13 +99,7 @@ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT -#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format */ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES -#define NONBE_FIX_AVG_IAC_CLDFB_REVERB -#endif -#endif +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #define NONBE_FIX_AVG_IAC_CLDFB_REVERB diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 05efe8207..f30c7c891 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2345,7 +2345,7 @@ ivas_error ivas_init_decoder_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend.splitrend.multiBinPoseData.num_poses ) ), + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index f1393148d..9d71653fe 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1284,8 +1284,6 @@ static void set_reverb_acoustic_data_fx( Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp; Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e; Word16 pow_exp; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else Word32 *pHrtf_set_l_re_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_l_im_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_r_re_fx[MAX_INTERN_CHANNELS]; @@ -1300,6 +1298,8 @@ static void set_reverb_acoustic_data_fx( Word16 *pRt60_e = pParams->pRt60_e; Word32 *pDsr_fx = pParams->pDsr_fx; Word16 *pDsr_e = pParams->pDsr_e; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#else /* use crend hrtf filters */ IF( hHrtf != NULL ) @@ -1558,9 +1558,9 @@ ivas_error ivas_reverb_open_fx( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); - params.pHrtf_avg_pwr_response_l_const = hHrtfStatistics->average_energy_l; - params.pHrtf_avg_pwr_response_r_const = hHrtfStatistics->average_energy_r; - params.pHrtf_inter_aural_coherence_const = hHrtfStatistics->inter_aural_coherence; + params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l; + params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; + params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence; #else IF( hHrtf == NULL && lr_energy_and_iac_fx != NULL ) { @@ -1749,8 +1749,10 @@ ivas_error ivas_reverb_open_fx( { return error; } +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES free( pDsr_e ); free( pRt60_e ); +#endif *hReverb = pState; return error; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 53d4cf355..6c055ab2a 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -308,6 +308,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; #endif float input_fc[FFT_SPECTRUM_SIZE]; + float output_fc[CLDFB_NO_CHANNELS_MAX]; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif @@ -326,10 +327,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( } #endif +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); +#else + if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) { return error; } + Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); @@ -352,9 +358,6 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); -#else ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_left_fft_fx, avg_pwr_right_fft_fx, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); for ( int i = 0; i < 257; i++ ) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index e10e49870..c34eaf220 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -722,7 +722,9 @@ static ivas_error load_reverb_from_binary( char *hrtf_data; #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; +#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; +#endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( hHrtfStatistics == NULL ) @@ -799,9 +801,10 @@ static ivas_error load_reverb_from_binary( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32) ); + hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + float *hrtf_prop_local = (float *) malloc( lr_iac_len * sizeof( float ) ); - if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) + if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL || hrtf_prop_local == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } @@ -809,17 +812,17 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; - fread( hHrtfStatistics->average_energy_l_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hHrtfStatistics->average_energy_l_dyn, hHrtfStatistics->average_energy_l, Q27, lr_iac_len ); - - fread( hHrtfStatistics->average_energy_r_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hHrtfStatistics->average_energy_r_dyn, hHrtfStatistics->average_energy_r, Q27, lr_iac_len ); + fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_l, Q27, lr_iac_len ); - fread( hHrtfStatistics->inter_aural_coherence_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hHrtfStatistics->inter_aural_coherence_dyn, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len ); + fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_r, Q27, lr_iac_len ); + fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; + free( hrtf_prop_local ); #else /* left/right energy and interaural coherence for late reverb */ FOR( i = 0; i < 3; i++ ) @@ -1168,7 +1171,6 @@ void destroy_td_hrtf( { free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ); } -#endif } #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB else @@ -1182,6 +1184,9 @@ void destroy_td_hrtf( } } #endif +#else + } +#endif ivas_HRTF_binary_close_fx( hHrtf ); @@ -1317,12 +1322,12 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( float ); } #else - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); - ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); - hrtf_data_rptr += sizeof( float ); - } + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); + ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); + hrtf_data_rptr += sizeof( float ); + } #endif /* max_total_num_fsamp_per_iteration */ max_total_num_fsamp_per_iteration = *( (UWord16 *) ( hrtf_data_rptr ) ); @@ -1470,7 +1475,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ #else - RENDERER_TYPE rend_type, /* i : Renderer type */ + RENDERER_TYPE rend_type, /* i : Renderer type */ #endif BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) @@ -1507,7 +1512,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } #else - ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); + ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); #endif hrtf_data_rptr = hrtf_data; @@ -1525,7 +1530,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else - if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #endif { f_tmp = *( (float *) ( hrtf_data_rptr ) ); @@ -1591,7 +1596,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) #endif { /* HRIR_HOA3 */ @@ -1658,7 +1663,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) #endif { /* HRIR_HOA2 */ @@ -1726,7 +1731,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) #endif { /* HRIR_FOA */ @@ -1795,7 +1800,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #endif { f_tmp = *( (float *) ( hrtf_data_rptr ) ); @@ -1877,13 +1882,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata( hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #else - memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #endif } @@ -1943,7 +1948,7 @@ ivas_error load_fastconv_HRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) ) #else - if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) + if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) #endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2117,7 +2122,7 @@ ivas_error load_parambin_HRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ #else - if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ + if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ #endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2211,7 +2216,7 @@ ivas_error create_SetOfHRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) #else - if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV ) + if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV ) #endif { if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) @@ -2234,7 +2239,7 @@ ivas_error create_SetOfHRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) #else - else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) #endif { if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) @@ -2394,7 +2399,6 @@ void destroy_hrtf_statistics( { free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } - } ivas_HRTF_statistics_close( hHrtfStatistics ); } -- GitLab From e9f84b0b944f2405c3c498c6393ef8a053e4fe13 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 26 May 2025 13:54:32 +0200 Subject: [PATCH 123/692] 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 e972f4265c8e015240a303ccb29c589f52e69a87 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 26 May 2025 14:01:48 +0200 Subject: [PATCH 124/692] Corrected function names per fixed point --- apps/decoder.c | 2 - lib_rend/ivas_reverb_filter_design_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 4 +- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_rend/lib_rend.c | 58 ++++++------------------- 5 files changed, 18 insertions(+), 50 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 3f30f4520..cdd5e3096 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -743,7 +743,6 @@ int main( } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES -#ifdef NONBE_FIX_BINARY_BINAURAL_READING if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -768,7 +767,6 @@ int main( goto cleanup; } #endif -#endif #endif } diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index ba6a53c7a..0e4252655 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -839,7 +839,7 @@ void ivas_reverb_calc_color_levels_fx( } /*-------------------------------------------------------------------* - * ivas_reverb_interpolate_acoustic_data() + * ivas_reverb_interpolate_acoustic_data_fx() * * Interpolates data from the input T60 and DSR tables to the FFT pFilter uniform grid * Note: the fc frequencies both for the input and the output must be in the ascending order diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 9d71653fe..44add03bd 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1257,7 +1257,7 @@ static void set_fft_and_datablock_sizes_fx( } /*-----------------------------------------------------------------------------------------* - * Function set_reverb_acoustic_data() + * Function set_reverb_acoustic_data_fx() * * Sets reverb acoustic data (room acoustics and HRTF), interpolating it to the filter grid *-----------------------------------------------------------------------------------------*/ @@ -1557,7 +1557,7 @@ ivas_error ivas_reverb_open_fx( test(); #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - set_reverb_acoustic_data( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); + set_reverb_acoustic_data_fx( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 6c055ab2a..15fb2ee25 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -328,7 +328,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_reverb_interpolate_acoustic_data( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); + ivas_reverb_interpolate_acoustic_data_fx( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); #else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 09894c319..63b13e67b 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1638,7 +1638,7 @@ static ivas_error setRendInputActiveIsm( IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) #endif @@ -2679,7 +2679,7 @@ static ivas_error initMcBinauralRendering( IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && inputMc->hReverb == NULL ) { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) #endif @@ -2936,10 +2936,7 @@ static ivas_error setRendInputActiveMc( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) #else - IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, - hrtfs->hSetOfHRTF, - FALSE ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) #endif { return error; @@ -4326,10 +4323,11 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif { - IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) -#endif +#else + IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -5160,25 +5158,11 @@ ivas_error IVAS_REND_SetHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - hIvasRend->hHrtfs.hSetOfHRTF, - TRUE ) ), - IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - hIvasRend->hHrtfs.hSetOfHRTF, - hIvasRend->hHrtfs.hHrtfStatistics, - TRUE ) ), - IVAS_ERR_OK ) ) -#endif - + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ), IVAS_ERR_OK ) ) +#else + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, TRUE ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -5282,25 +5266,11 @@ ivas_error IVAS_REND_DisableHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - hIvasRend->hHrtfs.hSetOfHRTF, - TRUE ) ), - IVAS_ERR_OK ) ) #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], - hIvasRend->inputsMc[i].base.inConfig, - hIvasRend->outputConfig, - hIvasRend->hRendererConfig, - hIvasRend->hHrtfs.hSetOfHRTF, - hIvasRend->hHrtfs.hHrtfStatistics, - TRUE ) ), - IVAS_ERR_OK ) ) -#endif - - + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ), IVAS_ERR_OK ) ) +#else + IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, TRUE ) ), IVAS_ERR_OK ) ) +#endif { return error; -- GitLab From 0825873d6c981cd46cfb3435d4785340932400cc Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 26 May 2025 16:47:06 +0200 Subject: [PATCH 125/692] port float MR 1433 --- lib_com/options.h | 1 + lib_dec/ivas_ism_renderer_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7b19fc92a..efff11d1b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index c3904d136..25e40ea63 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -189,6 +189,9 @@ void ivas_ism_render_sf_fx( last_sf = add( last_sf, 1 ); } +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + num_objects = st_ivas->nchan_ism; +#else num_objects = st_ivas->nchan_transport; move16(); if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) @@ -196,6 +199,7 @@ void ivas_ism_render_sf_fx( num_objects = st_ivas->nchan_ism; move16(); } +#endif nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; move16(); -- GitLab From 68a13f7959af3a58f05a9a847845ad00aa656aea Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 26 May 2025 17:23:38 +0200 Subject: [PATCH 126/692] fix formatting --- lib_dec/ivas_ism_renderer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 25e40ea63..877ef8ed7 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -190,7 +190,7 @@ void ivas_ism_render_sf_fx( } #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH - num_objects = st_ivas->nchan_ism; + num_objects = st_ivas->nchan_ism; #else num_objects = st_ivas->nchan_transport; move16(); -- GitLab From fcb912776046556313cd96c5e26b828fed633dfc Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 26 May 2025 14:58:39 -0400 Subject: [PATCH 127/692] possible fix to 1713, icBWE exp --- lib_com/options.h | 2 ++ lib_enc/ivas_stereo_icbwe_enc_fx.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 20a1dc555..0932d2434 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,4 +101,6 @@ #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*/ + #endif diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index eba30f762..706cac13f 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -828,7 +828,11 @@ 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 ); @@ -854,8 +858,11 @@ 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(); -- GitLab From ae6c1839a8830c6d8eabd56e8c359399c01400dd Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 26 May 2025 15:03:08 -0400 Subject: [PATCH 128/692] clang format --- lib_enc/ivas_stereo_icbwe_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index 706cac13f..95c49aeae 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -857,7 +857,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 */ #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 -- GitLab From c5e06f1c533114862683b701a40c4687cbe821c8 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 12:08:32 +0200 Subject: [PATCH 129/692] Fixed point data type changes --- lib_rend/ivas_reverb_utils_fx.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 15fb2ee25..dabbcfd82 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -119,7 +119,16 @@ ivas_error ivas_reverb_prepare_cldfb_params( ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); - + const Word16 input_table_size, + const Word32 *pInput_fc, // input in Q16 + const Word32 *pInput_t60, // input in Q26 + const Word32 *pInput_dsr, // input in Q30 + const Word16 output_table_size, + const Word32 *pOutput_fc, // Q16 + Word32 *pOutput_t60, // pOutput_t60_e + Word32 *pOutput_dsr, // pOutput_dsr_e + Word16 *pOutput_t60_e, // output e + Word16 *pOutput_dsr_e // output e /* adjust DSR for the delay difference */ delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); @@ -282,8 +291,8 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( *-----------------------------------------------------------------------------------------*/ static void ivas_reverb_set_energies( - const float *avg_pwr_l, - const float *avg_pwr_r, + const Word32 *avg_pwr_l, + const Word32 *avg_pwr_r, #else /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_get_fastconv_hrtf_set_energies() @@ -299,16 +308,16 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const int16_t use_brir, #endif const int32_t sampling_rate, - float *avg_pwr_left, - float *avg_pwr_right ) + Word32 *avg_pwr_left, + Word32 *avg_pwr_right ) { int16_t freq_idx; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; #endif - float input_fc[FFT_SPECTRUM_SIZE]; - float output_fc[CLDFB_NO_CHANNELS_MAX]; + Word32 input_fc[FFT_SPECTRUM_SIZE]; + Word32 output_fc[CLDFB_NO_CHANNELS_MAX]; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif -- GitLab From 61b13180cfb63bb395a79895087e03ec3a2e1c74 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 16:11:51 +0200 Subject: [PATCH 130/692] Changed float to Word32 in function header --- lib_rend/ivas_reverb_utils_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index dabbcfd82..bb781f282 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -65,7 +65,7 @@ typedef struct cldfb_convolver_state } cldfb_convolver_state; #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -static void ivas_reverb_set_energies( const float *avg_pwr_l, const float *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); +static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); #else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); #endif -- GitLab From b4efde697c6415f8e84af5afca752f85dc3a5426 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 16:43:37 +0200 Subject: [PATCH 131/692] fixed function reverb_set_energies --- lib_rend/ivas_reverb_utils_fx.c | 51 ++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index bb781f282..57e6960dc 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -119,7 +119,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); - const Word16 input_table_size, + const Word16 input_table_size, const Word32 *pInput_fc, // input in Q16 const Word32 *pInput_t60, // input in Q26 const Word32 *pInput_dsr, // input in Q30 @@ -308,19 +308,20 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const int16_t use_brir, #endif const int32_t sampling_rate, - Word32 *avg_pwr_left, - Word32 *avg_pwr_right ) + float *avg_pwr_left, + float *avg_pwr_right ) { int16_t freq_idx; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; #endif - Word32 input_fc[FFT_SPECTRUM_SIZE]; - Word32 output_fc[CLDFB_NO_CHANNELS_MAX]; -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + float input_fc[FFT_SPECTRUM_SIZE]; + +#ifndef NON_BE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; @@ -329,7 +330,6 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); } #else - for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( FFT_SPECTRUM_SIZE - 1 ) ); @@ -337,14 +337,42 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_reverb_interpolate_acoustic_data_fx( avg_pwr_len, input_fc, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc, avg_pwr_left, avg_pwr_right ); -#else + Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); + Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); + Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); + + Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); + Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); + Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); + Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); + Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); + + for ( int i = 0; i < 60; i++ ) + { + input_fc_fx[i] = (Word32) input_fc[i] * ( 1 << 16 ); + } + + for ( int i = 0; i < 257; i++ ) + { + output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; + } + + ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, + CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); + + free( input_fc_fx ); + free( output_fc_fx ); + free( avg_pwr_left_fx ); + free( avg_pwr_left_e ); + free( avg_pwr_right_fx ); + free( avg_pwr_right_e ); + +#else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) { return error; } - Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); @@ -374,6 +402,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); } + free( input_fc_fx ); free( avg_pwr_left_fft_fx ); free( avg_pwr_right_fft_fx ); @@ -384,4 +413,4 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( avg_pwr_right_e ); return IVAS_ERR_OK; #endif -} +} \ No newline at end of file -- GitLab From 7ca302ea72d669df9565f0890d8c7cdb9c837926 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 16:49:54 +0200 Subject: [PATCH 132/692] fixed declarations ivas_reverb_utils --- lib_rend/ivas_reverb_utils_fx.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 57e6960dc..3be26195a 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -119,16 +119,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); - const Word16 input_table_size, - const Word32 *pInput_fc, // input in Q16 - const Word32 *pInput_t60, // input in Q26 - const Word32 *pInput_dsr, // input in Q30 - const Word16 output_table_size, - const Word32 *pOutput_fc, // Q16 - Word32 *pOutput_t60, // pOutput_t60_e - Word32 *pOutput_dsr, // pOutput_dsr_e - Word16 *pOutput_t60_e, // output e - Word16 *pOutput_dsr_e // output e + /* adjust DSR for the delay difference */ delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); -- GitLab From 72b541aa7d46660251538225381a3ea45650368b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 16:59:22 +0200 Subject: [PATCH 133/692] changed function name to ivas_reverb_open_fx(). local build successful --- lib_rend/ivas_reverb_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 44add03bd..0c991ad93 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2485,7 +2485,7 @@ ivas_error ivas_binaural_reverb_init( preDelay = 10; } - error = ivas_binaural_reverb_open( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); + error = ivas_binaural_reverb_open_fx( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); return error; } -- GitLab From d269d126b9f279baa324fafe7125f7352a8f6d41 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 17:03:44 +0200 Subject: [PATCH 134/692] deactivated compiler switch --- 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 efcf2546b..8abc918af 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define NONBE_FIX_973_HODIRAC_BAND_GROUPING /* FhG: issue 973: empty parameter band in DirAC */ -#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ -- GitLab From 6f5f8204c758fecf133dacde4d169cb71788fc83 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 27 May 2025 17:18:18 +0200 Subject: [PATCH 135/692] applied patch to fix clang editing --- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_util/hrtf_file_reader.c | 46 ++++++++++++++++----------------- lib_util/hrtf_file_reader.h | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 3be26195a..689670477 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -404,4 +404,4 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( avg_pwr_right_e ); return IVAS_ERR_OK; #endif -} \ No newline at end of file +} diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index c34eaf220..7a74e8e88 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1322,12 +1322,12 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( float ); } #else - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); - ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); - hrtf_data_rptr += sizeof( float ); - } + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); + ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); + hrtf_data_rptr += sizeof( float ); + } #endif /* max_total_num_fsamp_per_iteration */ max_total_num_fsamp_per_iteration = *( (UWord16 *) ( hrtf_data_rptr ) ); @@ -1475,7 +1475,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ #else - RENDERER_TYPE rend_type, /* i : Renderer type */ + RENDERER_TYPE rend_type, /* i : Renderer type */ #endif BINAURAL_INPUT_AUDIO_CONFIG input_cfg /* i : Input binaural config */ ) @@ -1512,7 +1512,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "renderer type not compliant" ); } #else - ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); + ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, rend_type, ( *hHRTF )->allocate_init_flag ); #endif hrtf_data_rptr = hrtf_data; @@ -1530,7 +1530,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else - if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #endif { f_tmp = *( (float *) ( hrtf_data_rptr ) ); @@ -1596,7 +1596,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) #endif { /* HRIR_HOA3 */ @@ -1663,7 +1663,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) #endif { /* HRIR_HOA2 */ @@ -1731,7 +1731,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) #endif { /* HRIR_FOA */ @@ -1800,7 +1800,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else - else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) + else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #endif { f_tmp = *( (float *) ( hrtf_data_rptr ) ); @@ -1882,13 +1882,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata( hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #else - memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); + memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #endif } @@ -1948,7 +1948,7 @@ ivas_error load_fastconv_HRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) ) #else - if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) + if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) #endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2122,7 +2122,7 @@ ivas_error load_parambin_HRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ #else - if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ + if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ #endif { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -2216,7 +2216,7 @@ ivas_error create_SetOfHRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) #else - if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV ) + if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV ) #endif { if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) @@ -2239,7 +2239,7 @@ ivas_error create_SetOfHRTF_from_binary( #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES else if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) #else - else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) + else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) #endif { if ( hrtf_header.input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 302a90dee..14ac33e9d 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -107,8 +107,8 @@ ivas_error load_reverb_binary( int32_t sampleRate, /* i : sample rate */ #else IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ -#endif - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ +#endif + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); #endif -- GitLab From 49308ae4d1d49b906de1a68bc35cbb0de68d3b6e Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Tue, 27 May 2025 17:55:01 +0200 Subject: [PATCH 136/692] 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 137/692] 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 3f865db7ccf62c5f370c6f27d1e9816121f051e6 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 27 May 2025 22:42:16 +0530 Subject: [PATCH 138/692] Precision improvement changes to improve the vad flag selection --- lib_enc/analy_sp_fx.c | 33 ++++++++++++++------------- lib_enc/ivas_core_pre_proc_front_fx.c | 7 +++--- lib_enc/ivas_front_vad_fx.c | 2 +- lib_enc/nois_est_fx.c | 26 ++++++++++----------- lib_enc/prot_fx_enc.h | 2 +- lib_enc/stat_enc.h | 1 + 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 7062a3090..dbd656dec 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -569,6 +569,8 @@ void ivas_analy_sp_fx( *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 move16(); } + *q_band_energies = *q_fr_bands; + move16(); } ELSE { @@ -578,10 +580,10 @@ void ivas_analy_sp_fx( set32_fx( lf_E, 0, 2 * VOIC_BINS ); set32_fx( band_energies, 0, 2 * NB_BANDS ); set32_fx( fr_bands, E_MIN_FXQ31, 2 * NB_BANDS ); // Q31 (*q_fr_bands) - - LEtot = W_shl( W_mult_32_16( E_MIN_FXQ31, add( sub( max_band, min_band ), 1 ) ), 1 ); // Q32 (*q_fr_bands+1) + *Etot = -193760400; // Q24 *q_fr_bands = Q31; *q_lf_E = *q_fr_bands; + move32(); move16(); move16(); } @@ -596,25 +598,24 @@ void ivas_analy_sp_fx( MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); - } - /* Average total log energy over both half-frames */ - *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; - move16(); - IF( LEtot != 0 ) - { - exp = W_norm( LEtot ); - LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp - Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25 - Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 - *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 + /* Average total log energy over both half-frames */ + *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; move16(); + IF( LEtot != 0 ) + { + exp = W_norm( LEtot ); + LEtot = W_shl( LEtot, exp ); // q_fr_bands+exp + Ltmp = BASOP_Util_Log10( W_extract_h( LEtot ), sub( 62, add( *q_fr_bands, exp ) ) /* 31-(q_fr_bands+1+exp-32) */ ); // Q25 + Ltmp = Mpy_32_32( Ltmp, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21 + *Etot = L_shl( Ltmp, Q24 - Q21 ); // Q24 + move16(); + } } + *q_band_energies = *q_fr_bands; + move16(); } - *q_band_energies = *q_fr_bands; - move16(); - exp = sub( getScaleFactor32( fr_bands, 2 * NB_BANDS ), 1 ); scale_sig32( fr_bands, 2 * NB_BANDS, exp ); /* q_fr_bands + exp */ *q_fr_bands = add( *q_fr_bands, exp ); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index be208296d..106d7c387 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1258,8 +1258,7 @@ ivas_error pre_proc_front_ivas_fx( 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, &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 ), - extract_h( st->hNoiseEst->Etot_v_h2_32fx ), &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, - hStereoClassif, NULL, st->ini_frame ); + st->hNoiseEst->Etot_v_h2_32fx, &st->hNoiseEst->bg_cnt, st->lgBin_E_fx, &dummy_fx, S_map_fx, hStereoClassif, NULL, st->ini_frame ); test(); IF( lr_vad_enabled && st->idchan == 0 ) @@ -1301,14 +1300,14 @@ ivas_error pre_proc_front_ivas_fx( 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, 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 ), extract_h( hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[0]->hNoiseEst->bg_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, 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 ), extract_h( hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx ), &hCPE->hFrontVad[1]->hNoiseEst->bg_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, st->lgBin_E_fx, &dummy_fx, S_map_LR_fx, NULL, hCPE->hFrontVad[1], hCPE->hFrontVad[0]->ini_frame ); } diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index a4baf6a00..a6054a841 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -741,7 +741,7 @@ ivas_error front_vad_spar_fx( 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, 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 ), extract_h( hFrontVad->hNoiseEst->Etot_v_h2_32fx ), + 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 ); MVR2R_WORD16( st->pitch, st->pitch, 3 ); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 4f178214f..7534a5159 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -358,14 +358,14 @@ void noise_est_init_ivas_fx( move16(); hNoiseEst->Etot_lp_fx = 0; hNoiseEst->Etot_h_fx = 0; - hNoiseEst->Etot_l_fx = 0; + hNoiseEst->Etot_l_32fx = 0; hNoiseEst->Etot_l_lp_32fx = 0; hNoiseEst->Etot_last_32fx = 0; hNoiseEst->Etot_v_h2_32fx = 0; hNoiseEst->sign_dyn_lp_fx = 0; move16(); move16(); - move16(); + move32(); move16(); move32(); move32(); @@ -528,7 +528,7 @@ void noise_est_pre_32fx( Etot_h_32fx = L_sub( L_deposit_h( hNoiseEst->Etot_h_fx ), 671089 ); /* 671089=0.04 in Q24 */ Etot_h_32fx = L_max( Etot_h_32fx, Etot ); - Etot_l_32fx = L_add( L_deposit_h( hNoiseEst->Etot_l_fx ), 1342177 ); /* 1342177 = .08 in Q24 */ + Etot_l_32fx = L_add( hNoiseEst->Etot_l_32fx, 1342177 ); /* 1342177 = .08 in Q24 */ /* Could even be higher but it also delays first entry to DTX */ IF( GT_16( hNoiseEst->harm_cor_cnt, HE_LT_CNT_PRE_FX ) ) @@ -590,10 +590,10 @@ void noise_est_pre_32fx( move16(); } - hNoiseEst->Etot_l_fx = extract_h( Etot_l_32fx ); // Q8 + hNoiseEst->Etot_l_32fx = Etot_l_32fx; // Q24 hNoiseEst->Etot_h_fx = extract_h( Etot_h_32fx ); // Q8 hNoiseEst->Etot_lp_fx = extract_h( Etot_lp_32fx ); // Q8 - move16(); + move32(); move16(); move16(); @@ -2213,7 +2213,7 @@ void noise_est_ivas_fx( const Word16 q_lf_E, /* i : Q of lf_E Q0 */ Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */ const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */ - const Word16 Etot_v_h2, /* i : Energy variations Q8 */ + const Word32 Etot_v_h2, /* i : Energy variations Q24 */ Word16 *bg_cnt, /* i : Background burst length timer Q0 */ Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ @@ -3176,14 +3176,14 @@ void noise_est_ivas_fx( haco_ev_max = s_max( tmp, hNoiseEst->lt_haco_ev_fx ); /* Q15 */ /* Etot_l_lp_thr = st->Etot_l_lp + (1.5f + 1.5f * (st->Etot_lp<50.0f))*st->Etot_v_h2; */ - tmp = 12288; - move16(); /* 1.5 Q13 */ + L_tmp = 49152; /* 1.5 Q15 */ + move32(); if ( LT_16( hNoiseEst->Etot_lp_fx, 12800 ) ) /* 50.0 in Q8 */ { - tmp = shl( tmp, 1 ); /*1.5 + 1.5 Q13 */ + L_tmp = L_shl( L_tmp, 1 ); /*1.5 + 1.5 Q15 */ } - Ltmp = hNoiseEst->Etot_l_lp_32fx; - Etot_l_lp_thr = round_fx( L_add( Ltmp, L_shl( L_mult( tmp, Etot_v_h2 ), 2 ) ) ); /* Q13+Q8+1 +2 = Q24 -> Q8*/ + temp = W_mac_32_32( W_mult_32_32( hNoiseEst->Etot_l_lp_32fx, ONE_IN_Q15 ), Etot_v_h2, L_tmp ); // Q40(24+15+1) + Etot_l_lp_thr = W_round32_s( temp ); // Q8 /* enr_bgd = Etot < Etot_l_lp_thr; */ enr_bgd = 0; @@ -3367,8 +3367,8 @@ void noise_est_ivas_fx( move16(); test(); test(); - if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */ - && ( LT_16( sub( Etot, extract_h( hNoiseEst->Etot_l_lp_32fx ) ), shl( Etot_v_h2, 1 ) ) ) /* Q8 , Etot_v_h2 has limited dynmics can be upscaled*/ + if ( ( GT_16( hNoiseEst->sign_dyn_lp_fx, 15 * 256 ) ) /* 15 in Q8 */ + && ( LT_32( L_sub( L_deposit_h( Etot ), hNoiseEst->Etot_l_lp_32fx ), L_shl( Etot_v_h2, 1 ) ) ) /* Q24 , Etot_v_h2 has limited dynmics can be upscaled*/ && ( GT_16( *st_harm_cor_cnt, 20 ) ) ) { sd1_bgd = 1; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 8e323af82..59d2fdf9a 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -404,7 +404,7 @@ void noise_est_ivas_fx( const Word16 q_lf_E, /* i : Q of lf_E Q0 */ Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */ const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */ - const Word16 Etot_v_h2, /* i : Energy variations Q8 */ + const Word32 Etot_v_h2, /* i : Energy variations Q24 */ Word16 *bg_cnt, /* i : Background burst length timer Q0 */ Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 for multi harm */ Word16 *sp_floor, /* o : noise floor estimate Q7 */ diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 41383f109..b9c515eea 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -549,6 +549,7 @@ typedef struct noise_estimation_structure Word16 bg_cnt; /* Noise estimator - pause length counter */ Word16 Etot_l_fx; /* Q8 Noise estimator - Track energy from below */ Word16 Etot_h_fx; /* Q8 Noise estimator - Track energy from above */ + Word32 Etot_l_32fx; /* Q24 Noise estimator - Track energy from below */ Word16 Etot_l_lp_fx; /* EVS- Q8 Noise estimator - Smoothed low energy */ Word32 Etot_l_lp_32fx; /* IVAS-Q24 Noise estimator - Smoothed low energy */ Word16 Etot_last_fx; /*EVS- Q8*/ -- GitLab From 76177d803521693ee1d7fffbff3ed4fc64e4c648 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 09:33:22 +0530 Subject: [PATCH 139/692] Optimizations in renderer and SBA encoder --- lib_com/ivas_fb_mixer_fx.c | 36 +++ lib_com/ivas_spar_com_fx.c | 78 ++++++- lib_com/options.h | 3 + lib_dec/ivas_binRenderer_internal_fx.c | 139 ++++++++++++ lib_dec/ivas_dirac_dec_fx.c | 19 +- lib_dec/ivas_mc_param_dec_fx.c | 2 + lib_dec/ivas_mc_paramupmix_dec_fx.c | 2 + lib_dec/ivas_sba_rendering_internal_fx.c | 22 +- lib_enc/ivas_enc_cov_handler_fx.c | 51 ++++- .../ivas_dirac_dec_binaural_functions_fx.c | 205 ++++++++++++++++-- lib_rend/ivas_reverb_fx.c | 11 + lib_rend/ivas_sba_rendering_fx.c | 71 +++++- 12 files changed, 605 insertions(+), 34 deletions(-) diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index d5cd8d4f1..0d8a74514 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -759,6 +759,13 @@ void ivas_fb_mixer_process_fx( pMdft_out_fx[0] = Mdft_out_0_fx; pMdft_out_fx[1] = Mdft_out_1_fx; +#ifdef OPT_SBA_ENC_V1_BE + Word16 total_guard = find_guarded_bits_fx( num_bands ); + Word16 total_guard_2 = find_guarded_bits_fx( shl( frame_len, 1 ) ); + Word16 tmp_q = sub( sub( *q_mixer_mat_fx, total_guard ), 32 ); // Q30 + hFbMixer->q_prior_mixer_fx - 31 - total_guard - 31 + Word16 len = shl( frame_len, 1 ); + Word16 res_q, q_check; +#endif FOR( ch = ( hFbMixer->fb_cfg->active_w_mixing == 0 ); ch < hFbMixer->fb_cfg->num_out_chans; ch++ ) { /* Run a loop of 2 to calculate current frame's filterbank output and prev frame's output */ @@ -773,6 +780,12 @@ void ivas_fb_mixer_process_fx( IF( in_out_mixer_map[ch][j] != 0 ) { +#ifdef OPT_SBA_ENC_V1_BE + res_q = add( tmp_q, hFbMixer->q_ppFilterbank_inFR[j] ); + q_check = s_min( q_pOut_fr_fx, res_q ); + scale_sig32( pOut_fr_re_fx, frame_len, sub( q_check, q_pOut_fr_fx ) ); + scale_sig32( pOut_fr_im_fx, frame_len, sub( q_check, q_pOut_fr_fx ) ); +#endif Word32 filterbank_mixer_bins_re_fx[L_FRAME48k]; Word32 filterbank_mixer_bins_im_fx[L_FRAME48k]; Word32 *pFb_inFR_re_fx = hFbMixer->ppFilterbank_inFR_re_fx[j]; // Q(hFbMixer->q_ppFilterbank_inFR_re_fx) @@ -781,8 +794,10 @@ void ivas_fb_mixer_process_fx( set_zero_fx( filterbank_mixer_bins_re_fx, frame_len ); set_zero_fx( filterbank_mixer_bins_im_fx, frame_len ); +#ifndef OPT_SBA_ENC_V1_BE Word16 total_guard = find_guarded_bits_fx( num_bands ); move16(); +#endif FOR( i = 0; i < num_bands; i++ ) { Word16 start_offset = pFb->fb_consts.pFilterbank_bins_start_offset[i]; @@ -808,15 +823,19 @@ void ivas_fb_mixer_process_fx( hFbMixer->prior_mixer_fx[ch][j][i] = mixer_mat_fx[ch][j][i]; // Q(q_mixer_mat_fx) move32(); } +#ifndef OPT_SBA_ENC_V1_BE Word16 res_q = 0; move16(); +#endif FOR( k = 0; k < frame_len; k++ ) { Word32 temp_out_re_fx, temp_out_im_fx; ivas_cmult_fix( filterbank_mixer_bins_re_fx[k], filterbank_mixer_bins_im_fx[k], pFb_inFR_re_fx[k], pFb_inFR_im_fx[k], &temp_out_re_fx, &temp_out_im_fx ); +#ifndef OPT_SBA_ENC_V1_BE res_q = sub( add( sub( sub( add( 30, *q_mixer_mat_fx ), 31 ), total_guard ), hFbMixer->q_ppFilterbank_inFR[j] ), 31 ); + Word16 q_check = s_min( q_pOut_fr_fx, res_q ); IF( NE_16( q_check, q_pOut_fr_fx ) ) { @@ -825,31 +844,48 @@ void ivas_fb_mixer_process_fx( pOut_fr_im_fx[k] = L_shr( pOut_fr_im_fx[k], sub( q_pOut_fr_fx, q_check ) ); // q_pOut_fr_fx -> q_check move32(); } +#endif IF( NE_16( q_check, res_q ) ) { temp_out_re_fx = L_shr( temp_out_re_fx, sub( res_q, q_check ) ); // res_q -> q_check temp_out_im_fx = L_shr( temp_out_im_fx, sub( res_q, q_check ) ); // res_q -> q_check } +#ifndef OPT_SBA_ENC_V1_BE res_q = q_check; move16(); +#endif + pOut_fr_re_fx[k] = L_add_sat( pOut_fr_re_fx[k], temp_out_re_fx ); // res_q move32(); pOut_fr_im_fx[k] = L_add_sat( pOut_fr_im_fx[k], temp_out_im_fx ); // res_q move32(); } +#ifdef OPT_SBA_ENC_V1_BE + q_pOut_fr_fx = q_check; +#else q_pOut_fr_fx = res_q; move16(); +#endif } } +#ifndef OPT_SBA_ENC_V1_BE Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) ); +#else + Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), total_guard_2 ); +#endif scale_sig32( pOut_fr_re_fx, frame_len, scale ); scale_sig32( pOut_fr_im_fx, frame_len, scale ); ivas_imdft_fx( pOut_fr_re_fx, pOut_fr_im_fx, pMdft_out_fx[hist], frame_len ); q_pMdft_out_fx[hist] = add( q_pOut_fr_fx, scale ); move16(); } +#ifdef OPT_SBA_ENC_V1_BE + scale_sig32( pMdft_out_fx[0], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) ); + scale_sig32( pMdft_out_fx[1], len, sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) ); +#else scale_sig32( pMdft_out_fx[0], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) ); scale_sig32( pMdft_out_fx[1], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) ); +#endif ivas_fb_mixer_cross_fading_fx( hFbMixer, ppOut_pcm_fx, pMdft_out_fx[0], pMdft_out_fx[1], ch, frame_len, frame_len ); q_ppOut_pcm_fx[ch] = s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ); move16(); diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index c2ad11e26..ef549a2ae 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -1995,15 +1995,23 @@ static void ivas_calc_post_pred_per_band_enc_fx( Word16 *q_postpred_cov_re ) { Word16 i, j, k; +#ifndef OPT_SBA_ENC_V1_BE Word32 dmx_mat_conj[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 q_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word16 min_val; +#else + Word16 max_val; + Word16 temp; + Word32 temp_add; + Word16 e_postpred_cov_re_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; +#endif + Word32 temp_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; + Word16 temp_mat_e[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; Word32 tmp_re; Word16 tmp_q; Word16 tmp_e; +#ifndef OPT_SBA_ENC_V1_BE FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) @@ -2013,25 +2021,40 @@ static void ivas_calc_post_pred_per_band_enc_fx( } } + FOR( i = 0; i < num_ch; i++ ) { set32_fx( temp_mat[i], 0, num_ch ); set32_fx( postpred_cov_re[i], 0, num_ch ); } +#endif +#ifdef OPT_SBA_ENC_V1_BE + max_val = MIN16B; + move16(); + temp = sub( 62, q_mixer_mat ); +#else min_val = MAX16B; move16(); +#endif + /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = 0; j < num_ch; j++ ) { +#ifndef OPT_SBA_ENC_V1_BE temp_mat[i][j] = 0; +#else + temp_add = 0; +#endif move32(); temp_mat_e[i][j] = 0; move16(); + FOR( k = 0; k < num_ch; k++ ) { +#ifndef OPT_SBA_ENC_V1_BE tmp_re = Mpy_32_32( cov_real[i][k][band_idx], dmx_mat_conj[k][j] ); tmp_e = sub( 62, add( q_cov_real[i][k][band_idx], q_mixer_mat ) ); IF( tmp_re ) @@ -2039,34 +2062,71 @@ static void ivas_calc_post_pred_per_band_enc_fx( temp_mat[i][j] = BASOP_Util_Add_Mant32Exp( temp_mat[i][j], temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); move32(); } +#else + tmp_re = Mpy_32_32( cov_real[i][k][band_idx], mixer_mat[j][k][band_idx] ); + tmp_e = sub( temp, q_cov_real[i][k][band_idx] ); + IF( tmp_re ) + { + temp_add = BASOP_Util_Add_Mant32Exp( temp_add, temp_mat_e[i][j], tmp_re, tmp_e, &temp_mat_e[i][j] ); + } +#endif } +#ifdef OPT_SBA_ENC_V1_BE + temp_mat[i][j] = temp_add; + move32(); +#endif } } + tmp_e = sub( Q31, q_mixer_mat ); /* num_ch x num_ch mult */ FOR( i = 0; i < num_ch; i++ ) { FOR( j = i; j < num_ch; j++ ) { +#ifdef OPT_SBA_ENC_V1_BE + temp_add = 0; + move32(); + e_postpred_cov_re_buf[i][j] = sub( 31, *q_postpred_cov_re ); +#else q_postpred_cov_re_buf[i][j] = *q_postpred_cov_re; +#endif move16(); FOR( k = 0; k < num_ch; k++ ) { tmp_re = Mpy_32_32( mixer_mat[i][k][band_idx], temp_mat[k][j] ); +#ifdef OPT_SBA_ENC_V1_BE + tmp_q = add( tmp_e, temp_mat_e[k][j] ); +#else tmp_q = sub( q_mixer_mat, temp_mat_e[k][j] ); +#endif IF( tmp_re ) { +#ifndef OPT_SBA_ENC_V1_BE tmp_e = sub( 31, q_postpred_cov_re_buf[i][j] ); postpred_cov_re[i][j] = BASOP_Util_Add_Mant32Exp( postpred_cov_re[i][j], tmp_e, tmp_re, sub( Q31, tmp_q ), &tmp_e ); move32(); q_postpred_cov_re_buf[i][j] = sub( 31, tmp_e ); move16(); +#else + temp_add = BASOP_Util_Add_Mant32Exp( temp_add, e_postpred_cov_re_buf[i][j], tmp_re, tmp_q, &e_postpred_cov_re_buf[i][j] ); +#endif } } +#ifndef OPT_SBA_ENC_V1_BE IF( postpred_cov_re[i][j] ) { min_val = s_min( min_val, q_postpred_cov_re_buf[i][j] ); +#else + if ( temp_add ) + { + max_val = s_max( max_val, e_postpred_cov_re_buf[i][j] ); +#endif } +#ifdef OPT_SBA_ENC_V1_BE + postpred_cov_re[i][j] = temp_add; + move32(); +#endif } } @@ -2077,7 +2137,11 @@ static void ivas_calc_post_pred_per_band_enc_fx( { IF( postpred_cov_re[i][j] ) { +#ifdef OPT_SBA_ENC_V1_BE + postpred_cov_re[i][j] = L_shr( postpred_cov_re[i][j], sub( max_val, e_postpred_cov_re_buf[i][j] ) ); +#else postpred_cov_re[i][j] = L_shl( postpred_cov_re[i][j], sub( min_val, q_postpred_cov_re_buf[i][j] ) ); +#endif move32(); } } @@ -2092,13 +2156,21 @@ static void ivas_calc_post_pred_per_band_enc_fx( move32(); } } - +#ifdef OPT_SBA_ENC_V1_BE + if ( EQ_16( max_val, MIN16B ) ) + { + max_val = 0; + move16(); + } + *q_postpred_cov_re = sub( Q31, max_val ); +#else if ( EQ_16( min_val, MAX16B ) ) { min_val = Q31; move16(); } *q_postpred_cov_re = min_val; +#endif move16(); return; diff --git a/lib_com/options.h b/lib_com/options.h index 20a1dc555..09765b959 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,6 +75,9 @@ #define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#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 FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx /*FhG: WMOPS tuning, nonbe*/ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index c05b8beb2..ee6304e6e 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -54,7 +54,137 @@ * * *-------------------------------------------------------------------------*/ +#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 */ + 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; + Word16 shift_q6 = sub( -29 + 6, Q_curr ); + Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; + move16(); + + // to be checked: feasibility with 32 bit buffers + Word64 Cldfb_RealBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; + Word64 Cldfb_ImagBuffer_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES]; + + FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) + { + 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 ); + + 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(); + 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 + + 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 + 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 + 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(); + } + + filterStatesLeftRealPtr_fx[0] = CLDFB_real[chIdx][k][bandIdx]; + move32(); + filterStatesLeftImagPtr_fx[0] = CLDFB_imag[chIdx][k][bandIdx]; + move32(); + + + /* 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(); + } + } + 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 + move32(); + out_Conv_CLDFB_imag[chIdx][k][bandIdx] = W_shl_sat_l( Cldfb_ImagBuffer_64fx[chIdx][k], shift_q6 ); // Q6 + move32(); + } + } + } + + + 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 */ @@ -164,6 +294,7 @@ static void ivas_binRenderer_filterModule_fx( return; } +#endif /* OPT_BIN_RENDERER_V2 */ /*------------------------------------------------------------------------- * ivas_binRenderer_convModuleOpen() @@ -1482,9 +1613,11 @@ 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 */ @@ -1495,8 +1628,10 @@ 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 */ } } @@ -1536,6 +1671,9 @@ 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++ ) @@ -1551,6 +1689,7 @@ void ivas_binRenderer_fx( } } } +#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 7fecb7ca7..f29133d92 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2227,6 +2227,7 @@ 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++ ) @@ -2235,6 +2236,7 @@ void ivas_dirac_dec_render_sf_fx( set32_fx( Cldfb_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); } } +#endif /* OPT_BIN_RENDERER_V2 */ /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; @@ -3931,8 +3933,8 @@ void ivas_dirac_dec_render_sf_fx( 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 + 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 ); } @@ -3973,9 +3975,19 @@ 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 ); @@ -3983,6 +3995,7 @@ void ivas_dirac_dec_render_sf_fx( 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++; } @@ -4012,8 +4025,10 @@ 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++ ) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index e0671eea0..0e2de6c01 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2151,6 +2151,7 @@ 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++ ) @@ -2159,6 +2160,7 @@ void ivas_param_mc_dec_render_fx( 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] ); } diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index 783b94940..7a1ef1126 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -847,6 +847,7 @@ 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++ ) @@ -855,6 +856,7 @@ static void ivas_mc_paramupmix_dec_sf( 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++ ) { diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index bbe63e965..d9ee47c84 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -77,7 +77,11 @@ void ivas_sba2mc_cldfb_fixed( FOR( m = 0; m < nb_channels_in; m++ ) { - g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 +#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]; @@ -87,9 +91,15 @@ 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 + *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++; @@ -167,7 +177,11 @@ 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(); } } @@ -196,7 +210,11 @@ 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( 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_enc/ivas_enc_cov_handler_fx.c b/lib_enc/ivas_enc_cov_handler_fx.c index 59c38aa5d..495e6caa1 100644 --- a/lib_enc/ivas_enc_cov_handler_fx.c +++ b/lib_enc/ivas_enc_cov_handler_fx.c @@ -514,6 +514,9 @@ static void ivas_band_cov_fx( Word16 q_shift, q_shift_tmp; Word16 m, start_bin, active_bins; Word16 num_blocks; +#ifdef OPT_SBA_ENC_V1_BE + Word16 shift_conv, q_shift_cov[IVAS_MAX_NUM_BANDS][IVAS_MAX_NUM_BANDS]; +#endif num_blocks = idiv1616( num_bins, stride ); /* Q0 */ FOR( i = 0; i < num_chans; i++ ) @@ -525,13 +528,24 @@ static void ivas_band_cov_fx( move16(); move16(); +#ifdef OPT_SBA_ENC_V1_BE + q_shift = 31; + move16(); +#endif FOR( k = 0; k < num_bins; k++ ) { pV_re_64bit[k] = W_add( W_mult0_32_32( ppIn_FR_real[i1][k], ppIn_FR_real[j1][k] ), W_mult0_32_32( ppIn_FR_imag[i1][k], ppIn_FR_imag[j1][k] ) ); //(q_In_FR[i1], q_In_FR[j1]) -> (q_In_FR[i1] + q_In_FR[j1]) move64(); +#ifdef OPT_SBA_ENC_V1_BE + q_shift_tmp = W_norm( pV_re_64bit[k] ); + if ( pV_re_64bit[k] != 0 ) + { + q_shift = s_min( q_shift, q_shift_tmp ); + } +#endif } - +#ifndef OPT_SBA_ENC_V1_BE q_shift = 31; move16(); FOR( k = 0; k < num_bins; k++ ) @@ -542,11 +556,17 @@ static void ivas_band_cov_fx( q_shift = s_min( q_shift, q_shift_tmp ); } } +#endif q_shift_tmp = sub( q_shift, 32 ); FOR( k = 0; k < num_bins; k++ ) { +#ifdef OPT_SBA_ENC_V1_BE + 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) move32(); +#endif /* perform rounding towards lower value for negative results */ if ( pV_re[k] < 0 ) { @@ -554,6 +574,10 @@ static void ivas_band_cov_fx( } } +#ifdef OPT_SBA_ENC_V1_BE + q_shift_cov[i][j] = Q31; + move16(); +#endif FOR( k = start_band; k < end_band; k++ ) { Word64 temp; @@ -575,7 +599,11 @@ static void ivas_band_cov_fx( /* optional: add temporal weight here */ FOR( m = 0; m < active_bins; m++ ) { +#ifdef OPT_SBA_ENC_V1_BE + temp = W_mac_32_32( temp, cov_ptr[m], p_bin_to_band[m] ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) + 1-> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 9) +#else temp = W_add( temp, W_mult0_32_32( cov_ptr[m], p_bin_to_band[m] ) ); // ((q_In_FR[i1] + q_In_FR[j1]) + (q_shift - 32), Q22) -> (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) +#endif } cov_ptr += stride; move16(); @@ -584,8 +612,19 @@ static void ivas_band_cov_fx( cov_real_64bit[i][j][k] = temp * (Word64) ( num_blocks ); // (q_In_FR[i1] + q_In_FR[j1] + (q_shift - 10) - guard_bits move64(); move64(); // conservative estimation of a 64 bit multiplication +#ifdef OPT_SBA_ENC_V1_BE + shift_conv = W_norm( cov_real_64bit[i][j][k] ); + if ( cov_real_64bit[i][j][k] != 0 ) + { + q_shift_cov[i][j] = s_min( q_shift_cov[i][j], shift_conv ); + } +#endif } +#ifdef OPT_SBA_ENC_V1_BE + q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q9 ) ); +#else q_cov_real[i][j] = add( add( q_In_FR, q_In_FR ), sub( q_shift, Q10 ) ); +#endif move16(); } } @@ -594,6 +633,7 @@ static void ivas_band_cov_fx( { FOR( j = i; j < num_chans; j++ ) { +#ifndef OPT_SBA_ENC_V1_BE q_shift = 31; move16(); FOR( k = start_band; k < end_band; k++ ) @@ -605,10 +645,19 @@ static void ivas_band_cov_fx( } } q_shift_tmp = sub( q_shift, 32 ); +#else + q_shift_tmp = sub( q_shift_cov[i][j], 32 ); +#endif FOR( k = start_band; k < end_band; k++ ) { +#ifdef OPT_SBA_ENC_V1_BE + + cov_real[i][j][k] = W_shl_sat_l( cov_real_64bit[i][j][k], q_shift_tmp ); /* q_cov_real[i][j] + q_shift - 32 */ + move32(); +#else cov_real[i][j][k] = W_extract_l( W_shl_nosat( cov_real_64bit[i][j][k], q_shift_tmp ) ); /* q_cov_real[i][j] + q_shift - 32 */ move32(); +#endif } q_cov_real[i][j] = add( q_cov_real[i][j], q_shift_tmp ); move16(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 9ea964bcb..2db86d6eb 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -694,7 +694,9 @@ 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++ ) @@ -854,19 +856,39 @@ 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++ ) + { + Word16 q_diff = sub( q_inp, q_cldfb[cha][slot] ); + IF( q_diff != 0 ) + { + Scale_sig32( Cldfb_RealBuffer_in_fx[cha][slot], 60, q_diff ); // Q6 + Scale_sig32( Cldfb_ImagBuffer_in_fx[cha][slot], 60, q_diff ); // Q6 + q_cldfb[cha][slot] = 6; + } + move16(); + } + } +#else /* OPT_BIN_RENDERER_V1 */ FOR( Word16 cha = 0; cha < 6; cha++ ) { FOR( slot = 0; slot < 4; slot++ ) @@ -877,6 +899,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } } +#endif /* OPT_BIN_RENDERER_V1 */ test(); test(); @@ -1853,6 +1876,76 @@ 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 ) + { + hDiracDecBin->ChEne_fx[1][bin] = L_shr( hDiracDecBin->ChEne_fx[1][bin], q_diff ); + 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_shl( hDiracDecBin->ChEne_fx[0][bin], q_diff ); + hDiracDecBin->q_ChEne = sub( 31, hDiracDecBin->ChEne_e[1][bin] ); + hDiracDecBin->ChEne_e[0][bin] = hDiracDecBin->ChEne_e[1][bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChEneOut_e[0][bin], hDiracDecBin->ChEneOut_e[1][bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChEneOut_fx[1][bin] = L_shr( hDiracDecBin->ChEneOut_fx[1][bin], q_diff ); + 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_shl( hDiracDecBin->ChEneOut_fx[0][bin], q_diff ); + hDiracDecBin->q_ChEneOut = sub( 31, hDiracDecBin->ChEneOut_e[1][bin] ); + hDiracDecBin->ChEneOut_e[0][bin] = hDiracDecBin->ChEneOut_e[1][bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChCrossRe_e[bin], hDiracDecBin->ChCrossIm_e[bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChCrossIm_fx[bin] = L_shr( hDiracDecBin->ChCrossIm_fx[bin], q_diff ); + hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossRe_e[bin] ); + hDiracDecBin->ChCrossIm_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossRe_fx[bin] = L_shl( hDiracDecBin->ChCrossRe_fx[bin], q_diff ); + hDiracDecBin->q_ChCross = sub( 31, hDiracDecBin->ChCrossIm_e[bin] ); + hDiracDecBin->ChCrossRe_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; + } + move32(); + move16(); + move16(); + + q_diff = sub( hDiracDecBin->ChCrossReOut_e[bin], hDiracDecBin->ChCrossImOut_e[bin] ); + IF( q_diff > 0 ) + { + hDiracDecBin->ChCrossImOut_fx[bin] = L_shr( hDiracDecBin->ChCrossImOut_fx[bin], q_diff ); + hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossReOut_e[bin] ); + hDiracDecBin->ChCrossImOut_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; + } + ELSE + { + hDiracDecBin->ChCrossReOut_fx[bin] = L_shl( hDiracDecBin->ChCrossReOut_fx[bin], q_diff ); + hDiracDecBin->q_ChCrossOut = sub( 31, hDiracDecBin->ChCrossImOut_e[bin] ); + hDiracDecBin->ChCrossReOut_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; + } + 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] ) ); @@ -1912,6 +2005,7 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( } move32(); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ formulate2x2MixingMatrix_fx( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->q_ChEne, @@ -2286,9 +2380,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin]; move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin]; move16(); } q_processMtxPrev_SCCR[bin] = q_processMtx_bin; @@ -2296,13 +2390,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked ); - hDiracDecBin->processMtxRe_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxRe_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxIm_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxIm_fx[0][chB + 2][bin] = extract_h( Mpy_32_32( lImagp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxRe_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxRe_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rRealp_fx, gainFactor_fx ) ); move16(); - hDiracDecBin->processMtxIm_fx[1][add( chB, 2 )][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) ); + hDiracDecBin->processMtxIm_fx[1][chB + 2][bin] = extract_h( Mpy_32_32( rImagp_fx, gainFactor_fx ) ); move16(); q_processMtx_SCCR[bin] = sub( sub( add( Q28, q_gain ), 31 ), 16 ); move16(); @@ -2311,9 +2405,9 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin]; move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin]; + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin]; move16(); } q_processMtxPrev_SCCR[bin] = q_processMtx_SCCR[bin]; @@ -2368,13 +2462,13 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( { FOR( chB = 0; chB < nchanSeparateChannels; chB++ ) { - hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx + hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRe_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx move16(); - hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][add( chB, 2 )][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx + hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxIm_fx[chA][chB + 2][bin], sub( q_processMtx_SCCR[bin], hDiracDecBin->q_processMtx ) ); // hDiracDecBin->q_processMtx move16(); - hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev + hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxRePrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev move16(); - hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][add( chB, 2 )][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev + hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin] = shr( hDiracDecBin->processMtxImPrev_fx[chA][chB + 2][bin], sub( q_processMtxPrev_SCCR[bin], hDiracDecBin->q_processMtxPrev ) ); // hDiracDecBin->q_processMtxPrev move16(); } } @@ -2421,6 +2515,10 @@ 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 ) @@ -2434,7 +2532,11 @@ 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++ ) { @@ -2461,7 +2563,14 @@ static void ivas_dirac_dec_binaural_process_output_fx( move16(); } + +#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++ ) { @@ -2471,8 +2580,13 @@ 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 */ } } } @@ -2636,7 +2750,11 @@ static void adaptTransportSignalsHeadtracked_fx( move16(); 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++ ) { @@ -3658,7 +3776,7 @@ static void matrixTransp2Mul_fx( { Word16 chA, chB; Word16 min_q_shift; - Word16 size = i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ); + Word16 size = BINAURAL_CHANNELS * BINAURAL_CHANNELS; IF( Ascale == 1 ) { @@ -4107,10 +4225,18 @@ 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 ); @@ -4178,11 +4304,18 @@ 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++ ) @@ -4195,8 +4328,8 @@ static void formulate2x2MixingMatrix_fx( q_GhatQ = sub( add( Q31, q_Ghat ), 31 ); exp = sub( s_min( L_norm_arr( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ), L_norm_arr( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ) ) ), 1 ); - scale_sig32( KyRe_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); - scale_sig32( KyIm_fx[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), exp ); + scale_sig32( KyRe_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp ); + scale_sig32( KyIm_fx[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, exp ); q_ky = add( q_ky, exp ); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -4204,7 +4337,7 @@ static void formulate2x2MixingMatrix_fx( FOR( chB = 0; chB < BINAURAL_CHANNELS; chB++ ) { tmpRe_fx[chA][chB] = Madd_32_32( Mpy_32_32( KyRe_fx[0][chA], GhatQ_fx[0][chB] ), KyRe_fx[1][chA], GhatQ_fx[1][chB] ); - tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( -KyIm_fx[0][chA], GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] ); + tmpIm_fx[chA][chB] = Msub_32_32( Mpy_32_32( L_negate( KyIm_fx[0][chA] ), GhatQ_fx[0][chB] ), KyIm_fx[1][chA], GhatQ_fx[1][chB] ); move32(); move32(); } @@ -4254,6 +4387,11 @@ 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 @@ -4270,6 +4408,7 @@ static void formulate2x2MixingMatrix_fx( 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 ); @@ -4286,6 +4425,13 @@ 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] ); @@ -4293,6 +4439,7 @@ static void formulate2x2MixingMatrix_fx( move32(); hdrm_re[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_re[chA][chB] ), 32 ); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4303,6 +4450,14 @@ 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] ); @@ -4310,6 +4465,7 @@ static void formulate2x2MixingMatrix_fx( move32(); hdrm_im[chA][chB] = sub( add( add( q_temp, q_div ), hdrm_im[chA][chB] ), 32 ); move16(); +#endif /* OPT_BIN_RENDERER_V1 */ } ELSE { @@ -4322,8 +4478,11 @@ static void formulate2x2MixingMatrix_fx( minimum_s( hdrm_re[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); q_temp = exp; move16(); - minimum_s( hdrm_im[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + 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++ ) { @@ -4337,7 +4496,11 @@ 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 */ @@ -4454,9 +4617,9 @@ static void formulate2x2MixingMatrix_fx( move16(); } #endif - minimum_s( q_Pre[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + minimum_s( q_Pre[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_P = s_min( q_P, exp ); - minimum_s( q_Pim[0], i_mult( BINAURAL_CHANNELS, BINAURAL_CHANNELS ), &exp ); + minimum_s( q_Pim[0], BINAURAL_CHANNELS * BINAURAL_CHANNELS, &exp ); q_P = s_min( q_P, exp ); FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 12b94b1a2..b9b897f4a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2271,6 +2271,16 @@ 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] ), + hReverb->binauralCoherenceCrossmixGains_fx[bin], hReverb->outputBufferReal_fx[bin][0][sample] ); // Q_in + leftIm_fx = Madd_32_32( Mpy_32_32( hReverb->binauralCoherenceDirectGains_fx[bin], hReverb->outputBufferImag_fx[bin][0][sample] ), + 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] ), @@ -2279,6 +2289,7 @@ void ivas_binaural_reverb_processSubframe_fx( 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 5e097ab2b..896742151 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -87,7 +87,11 @@ 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++ ) { @@ -95,22 +99,39 @@ void ivas_sba_prototype_renderer_fx( } } norm_q = sub( sub( 31, norm_q ), 2 ); // to handle overflow - Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME]; + 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++ ) { - 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 +#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(); } @@ -178,12 +199,21 @@ 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 */ } } - 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 +#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(); } @@ -242,11 +272,41 @@ 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++ ) + { + Word32 op1 = L_shr( inRe_fx[0][ts][idx], 1 ); + Word32 op2 = L_shr( inRe_fx[1][ts][idx], 1 ); + temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1 + inRe_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1 + move32(); + inRe_fx[0][ts][idx] = temp_signal_fx; + move32(); + } + + FOR( Word16 idx = 0; idx < num_cldfb_bands; idx++ ) + { + Word32 op1 = L_shr( inIm_fx[0][ts][idx], 1 ); + Word32 op2 = L_shr( inIm_fx[1][ts][idx], 1 ); + temp_signal_fx = L_add( op1, op2 ); // q_cldfb[][]-1 + move32(); + inIm_fx[1][ts][idx] = L_sub( op1, op2 ); // q_cldfb[][]-1 + move32(); + 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++ ) { @@ -267,6 +327,7 @@ void ivas_sba_prototype_renderer_fx( inIm_fx[0][ts][idx] = temp_signal_fx[idx]; move32(); } +#endif /* OPT_BIN_RENDERER_V1 */ } } } -- GitLab From a50df063f2a379c7abb1ab96dc4c36a6675820f7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 09:59:19 +0530 Subject: [PATCH 140/692] Clang formatting changes --- lib_dec/ivas_binRenderer_internal_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index ee6304e6e..ae16bf7b5 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -144,7 +144,7 @@ static void ivas_binRenderer_filterModule_fx( 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 + Word32 neg_temp2 = L_negate( temp2 ); // Q_curr -1 outRealLeft_fx = W_mac_32_32( outRealLeft_fx, temp1, filterTapsLeftRealPtr_fx[0] ); -- GitLab From d5d3ed62850d25c0751ed0df4ec83259374379c9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 11:31:01 +0530 Subject: [PATCH 141/692] Fix for 3GPP issue 1457: Stereo Encoder 32 kbps: More rattling artifcats in 16 kHz LTVs Link #1457 --- lib_enc/ivas_cpe_enc_fx.c | 10 +++-- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 26 ++++++++++- lib_enc/ivas_stereo_dft_td_itd_fx.c | 66 +++++++++++++++++++++------- 3 files changed, 79 insertions(+), 23 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index d0a33ed09..0cd7532d5 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -649,10 +649,11 @@ ivas_error ivas_cpe_enc_fx( hCPE->hStereoDft->Spd_R_smooth_fx_e = sub( hCPE->hStereoDft->Spd_R_smooth_fx_e, temp ); move16(); - + q_com = MAX_16; + move16(); FOR( n = 0; n < CPE_CHANNELS; n++ ) { - q_com = sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 ); + q_com = s_min( q_com, sub( add( L_norm_arr( sts[n]->input32_fx, input_frame ), sts[n]->q_inp32 ), 16 ) ); q_com = s_min( q_com, sub( add( L_norm_arr( sts[n]->old_input_signal32_fx, input_frame ), sts[n]->q_old_inp32 ), 16 ) ); q_com = s_min( q_com, add( norm_arr( hCPE->input_mem_fx[n], hCPE->hStereoDft->dft_ovl ), hCPE->q_input_mem[n] ) ); @@ -661,7 +662,9 @@ ivas_error ivas_cpe_enc_fx( q_com = 0; move16(); } - + } + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { Copy_Scale_sig_32_16( sts[n]->input32_fx, sts[n]->input_fx, input_frame, sub( q_com, sts[n]->q_inp32 ) ); sts[n]->q_inp = q_com; move16(); @@ -674,7 +677,6 @@ ivas_error ivas_cpe_enc_fx( hCPE->q_input_mem[n] = q_com; move16(); } - stereo_dft_hybrid_ITD_flag_fx( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max ); /* Time Domain ITD compensation using extrapolation */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index 1beacd19a..28bac9e8b 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -169,7 +169,8 @@ static void stereo_dft_quantize_itd_fx( Word16 *ind ) { Word16 itd; - + Word16 input_fs_by_stereo_dft_itd_fs = 0; + move16(); // itd = (int16_t) ( sign( in ) * 0.5f + in ); itd = in; move16(); @@ -188,9 +189,30 @@ static void stereo_dft_quantize_itd_fx( move16(); } + SWITCH( input_Fs ) + { + case 8000: + input_fs_by_stereo_dft_itd_fs = 1; // Q2 + move16(); + BREAK; + case 16000: + input_fs_by_stereo_dft_itd_fs = 2; // Q2 + move16(); + BREAK; + case 32000: + input_fs_by_stereo_dft_itd_fs = 4; // Q2 + move16(); + BREAK; + case 48000: + input_fs_by_stereo_dft_itd_fs = 6; // Q2 + move16(); + BREAK; + default: + assert( 0 ); + } /*Convert back @ fs*/ //*out = (float) ( itd * input_Fs ) / ( (float) ( STEREO_DFT_ITD_FS ) ); - *out = Mpy_32_32( L_shl( itd * input_Fs, 2 ), 1099511628 /*Q45*/ ); // Q45+Q2-Q31 = Q16 + *out = L_shl( L_mult( itd, input_fs_by_stereo_dft_itd_fs ), Q13 ); // Q16 move32(); return; diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 309ec3377..33763d4cc 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -50,9 +50,9 @@ #define STEREO_DFT_CHANNEL_EXTR_LPC_ORDER 10 #define STEREO_DFT_CHANNEL_EXTR_LPC_VEC_LIMIT 320 -#define FLR_FX 16384 // Q15 -#define ONE_HALF 24576 // Q14 -const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { // Q15 +#define FLR_FX 1073741824 // Q31 +#define ONE_HALF 24576 // Q14 +const Word16 wac_swb_h_fx[LPC_SHB_ORDER + 1] = { // Q15 32767, 32758, 32731, @@ -95,7 +95,12 @@ static void stereo_td_get_td_itd_fx( { /* *td_itd is the closest integer to itd that transforms into an integer value * * under the transform x -> (32000/fs) x. */ - Word16 d, d_e; + Word32 inverse_input_fs_by_16k = 0; + move32(); + Word64 tmp64; + Word16 d = 0, shift = 0; + move16(); + move16(); IF( EQ_32( input_Fs, 32000 ) ) { @@ -106,24 +111,51 @@ static void stereo_td_get_td_itd_fx( ELSE { assert( ( input_Fs % 16000 ) == 0 && "sampling frequency should be divisible by 16000" ); - Word16 temp_div, temp_e, temp_add; - d = BASOP_Util_Divide3232_Scale( input_Fs, 16000, &d_e ); - temp_div = BASOP_Util_Divide3232_Scale( itd, L_deposit_h( d ), &temp_e ); - temp_e = add( temp_e, sub( sub( 31, q_itd ), d_e ) ); // e+(e1-e2)// - temp_add = add_sat( temp_div, shr_sat( FLR_FX, temp_e ) ); - - IF( itd != 0 ) + IF( itd == 0 ) { - *td_itd_32 = extract_l( L_shl( L_shr( L_add( temp_add, EPSILON_FX ), sub( 15, temp_e ) ), 1 ) ); + *td_itd_32 = *td_itd = 0; + move16(); + move16(); } ELSE { - *td_itd_32 = shl( shr( temp_add, sub( 15, temp_e ) ), 1 ); - } - move16(); + SWITCH( input_Fs ) + { + case 16000: + inverse_input_fs_by_16k = 1073741824; // Q30 /* This is in Q30, because 2147483648 cannot be represnt in Word32*/ + move32(); + d = 1; // Q0 + move16(); + shift = 1; + move16(); + BREAK; + case 32000: + inverse_input_fs_by_16k = 1073741824; // Q31 + move32(); + d = 2; // Q0 + move16(); + BREAK; + case 48000: + inverse_input_fs_by_16k = 715827883; // Q31 + move32(); + d = 3; // Q0 + move16(); + if (itd < 0 ) + { + inverse_input_fs_by_16k = 715827882; /* Reducing the precision by 1 to handle multiplication of negative case*/ + move32(); + } + BREAK; + default: + assert( 0 ); + } + tmp64 = W_add( W_mult0_32_32( itd, inverse_input_fs_by_16k ), W_shl( FLR_FX, sub( q_itd, shift ) ) ); // Q: q_itd - shift + 31 + *td_itd_32 = shl( extract_l( W_extract_l( W_shr( tmp64, add( sub( q_itd, shift ), Q31 ) ) ) ), 1 ); // Q0 + move16(); - *td_itd = i_mult( shr( *td_itd_32, 1 ), shr( d, sub( 15, d_e ) ) ); - move16(); + *td_itd = i_mult( shr( *td_itd_32, 1 ), d ); // Q0 + move16(); + } } return; -- GitLab From 306f26e2237a46381b687aaf4c6ae86243ea5077 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 11:34:05 +0530 Subject: [PATCH 142/692] Clang formatting changes --- lib_enc/ivas_stereo_dft_td_itd_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 33763d4cc..a0d49176f 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -140,7 +140,7 @@ static void stereo_td_get_td_itd_fx( move32(); d = 3; // Q0 move16(); - if (itd < 0 ) + if ( itd < 0 ) { inverse_input_fs_by_16k = 715827882; /* Reducing the precision by 1 to handle multiplication of negative case*/ move32(); -- GitLab From 67f74ae7d4354cfb68eac5ca5b4746d60694c5ed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 11:36:09 +0530 Subject: [PATCH 143/692] Fix for 3GPP issue 1504: BASOP decoder to MONO output for MASA 2TC LTV input exhibits higher MLD Link #1504 --- lib_rend/ivas_dirac_rend_fx.c | 122 ++++++++++++---------------------- lib_rend/ivas_stat_rend.h | 4 +- 2 files changed, 44 insertions(+), 82 deletions(-) diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 063c70f66..99a84bf52 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -1759,17 +1759,19 @@ void protoSignalComputation2_fx( Word32 lr_total_bb_ratio_fx, lr_total_hi_ratio_fx; Word32 min_sum_total_ratio_fx, min_sum_total_ratio_db_fx; Word32 sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS]; - Word16 q_sum_total_ratio; + Word16 exp_sum_total_ratio_fx[MASA_SUM_FREQ_RANGE_BINS]; + Word16 q_sum_total_ratio = 0; + move16(); Word32 a_fx, b_fx, a2_fx, b2_fx; Word16 interpolatorSpaced_fx, interpolatorDmx_fx; Word32 tempSpaced_fx, tempDmx_fx; #ifdef FIX_867_CLDFB_NRG_SCALE - Word16 q_shift, min_q_shift[2], exp, q_temp[2], temp_q_shift, q_temp2; + Word16 q_shift, min_q_shift[2], exp, q_temp[2]; #else Word16 q_shift, min_q_shift, exp, q_temp, temp_q_shift, q_temp2; #endif Word32 temp; - Word64 W_tmp1, W_tmp2; + Word64 W_tmp1, W_tmp2, W_tmp3; Word64 reference_power_64fx[CLDFB_NO_CHANNELS_MAX]; Word16 q_reference_power_64fx; Word16 head_room, q_Left_Right_power; @@ -1786,9 +1788,7 @@ void protoSignalComputation2_fx( min_q_shift = Q31; move16(); #endif - temp_q_shift = Q31; - move16(); - q_sum_total_ratio = Q31; + q_sum_total_ratio = 0; move16(); exp = 0; move16(); @@ -1813,7 +1813,6 @@ void protoSignalComputation2_fx( min_q_shift = s_min( min_q_shift, q_shift ); #endif q_shift = s_min( L_norm_arr( RealBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ), L_norm_arr( ImagBuffer_fx[l][0], s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ); - temp_q_shift = s_min( temp_q_shift, q_shift ); } #ifdef FIX_867_CLDFB_NRG_SCALE @@ -1822,7 +1821,6 @@ void protoSignalComputation2_fx( #else min_q_shift = sub( min_q_shift, 2 ); // guard bits #endif - temp_q_shift = sub( temp_q_shift, 2 ); // guard bits /* Upscaling of the buffer proto_power_smooth_fx */ #ifdef FIX_867_CLDFB_NRG_SCALE @@ -2072,7 +2070,7 @@ void protoSignalComputation2_fx( } #ifdef FIX_867_CLDFB_NRG_SCALE - Word16 total_shift[2], q_temp_total; + Word16 total_shift[2]; /* total_shift shift required to get common Q of sum power values */ total_shift[0] = shl( s_max( 0, sub( min_q_shift[0], min_q_shift[1] ) ), 1 ); total_shift[1] = shl( s_max( 0, sub( min_q_shift[1], min_q_shift[0] ) ), 1 ); @@ -2080,13 +2078,11 @@ void protoSignalComputation2_fx( min_q_shift[1] = sub( min_q_shift[1], idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); q_temp[0] = sub( add( add( q_cldfb, min_q_shift[0] ), add( q_cldfb, min_q_shift[0] ) ), 31 ); q_temp[1] = sub( add( add( q_cldfb, min_q_shift[1] ), add( q_cldfb, min_q_shift[1] ) ), 31 ); - q_temp_total = s_min( q_temp[0], q_temp[1] ); #else min_q_shift = sub( min_q_shift, idiv1616( find_guarded_bits_fx( num_freq_bands ), 2 ) ); q_temp = sub( add( add( q_cldfb, min_q_shift ), add( q_cldfb, min_q_shift ) ), 31 ); #endif - q_temp2 = sub( add( add( q_cldfb, temp_q_shift ), add( q_cldfb, temp_q_shift ) ), 31 ); head_room = 63; move16(); @@ -2195,77 +2191,50 @@ void protoSignalComputation2_fx( IF( LT_16( l, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ) ) ) { -#ifdef FIX_867_CLDFB_NRG_SCALE - 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 -#endif + re_aux = L_add( L_shr( RealBuffer_fx[0][0][l], 1 ), L_shr( RealBuffer_fx[1][0][l], 1 ) ); + im_aux = L_add( L_shr( ImagBuffer_fx[0][0][l], 1 ), L_shr( ImagBuffer_fx[1][0][l], 1 ) ); - sum_power_fx = Madd_32_32( Mpy_32_32( re_aux, re_aux ), im_aux, im_aux ); // 2*(q_cldfb+temp_q_shift)-31 - temp = Mpy_32_32( a_fx, sum_power_fx ); // 2*(q_cldfb+temp_q_shift)-31 + W_tmp3 = W_add( W_mult0_32_32( re_aux, re_aux ), W_mult0_32_32( im_aux, im_aux ) ); + q_shift = W_norm( W_tmp3 ); + sum_power_fx = W_extract_h( W_shl( W_tmp3, q_shift ) ); + exp_temppp = sub( 31, sub( add( shl( sub( q_cldfb, 1 ), 1 ), q_shift ), 32 ) ); - IF( LT_16( q_temp2, stereo_type_detect->q_sum_power ) ) - { - stereo_type_detect->sum_power_fx[l] = L_add( temp, L_shr( Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), sub( stereo_type_detect->q_sum_power, q_temp2 ) ) ); // q_temp2 - move32(); - } - ELSE - { - stereo_type_detect->sum_power_fx[l] = L_add( L_shr( temp, sub( q_temp2, stereo_type_detect->q_sum_power ) ), Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ) ); // stereo_type_detect->q_sum_power - move32(); - } + stereo_type_detect->sum_power_fx[l] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, sum_power_fx ), exp_temppp, Mpy_32_32( b_fx, stereo_type_detect->sum_power_fx[l] ), stereo_type_detect->exp_sum_power[l], &stereo_type_detect->exp_sum_power[l] ); + move32(); + 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] ) ); + 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] ) ); -#ifdef FIX_867_CLDFB_NRG_SCALE - temp = Mpy_32_32( a_fx, W_extract_l( W_shr( reference_power_64fx[l], add( 31, total_shift[qidx] ) ) ) ); // 2*(q_cldfb+min_q_shift) -31 - IF( LT_16( q_temp_total, 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_total ) ) ); // q_temp - move32(); - } - ELSE - { - stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp_total, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power - 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 - 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 - move32(); - } - ELSE - { - stereo_type_detect->total_power_fx[l] = L_add( L_shr( temp, sub( q_temp, stereo_type_detect->q_total_power ) ), Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ) ); // stereo_type_detect->q_total_power - move32(); - } -#endif + 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 ) ); + + stereo_type_detect->total_power_fx[l] = BASOP_Util_Add_Mant32Exp( Mpy_32_32( a_fx, Total_power_fx ), exp_temppp, Mpy_32_32( b_fx, stereo_type_detect->total_power_fx[l] ), stereo_type_detect->exp_total_power[l], &stereo_type_detect->exp_total_power[l] ); + move32(); test(); IF( ( stereo_type_detect->sum_power_fx[l] == 0 ) && ( stereo_type_detect->total_power_fx[l] == 0 ) ) { sum_total_ratio_fx[l] = MAX_32; // q15 move32(); + exp_sum_total_ratio_fx[l] = 16; + move16(); } ELSE IF( stereo_type_detect->total_power_fx[l] == 0 ) { sum_total_ratio_fx[l] = MAX_32; // q15 move32(); + exp_sum_total_ratio_fx[l] = 16; + move16(); } ELSE { - sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) - move32(); -#ifdef FIX_867_CLDFB_NRG_SCALE - q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp_total ) ) ); -#else - q_sum_total_ratio = add( sub( 15, exp ), sub( s_min( stereo_type_detect->q_sum_power, q_temp2 ), s_min( stereo_type_detect->q_total_power, q_temp ) ) ); -#endif - sum_total_ratio_fx[l] = L_shl( sum_total_ratio_fx[l], sub( Q15, q_sum_total_ratio ) ); // q15 + sum_total_ratio_fx[l] = BASOP_Util_Divide3232_Scale_newton( stereo_type_detect->sum_power_fx[l], stereo_type_detect->total_power_fx[l], &exp ); // 15-(exp+s_min( stereo_type_detect->q_total_power, q_temp )-s_min( stereo_type_detect->q_sum_power, q_temp2 )) move32(); + exp_sum_total_ratio_fx[l] = add( exp, sub( stereo_type_detect->exp_sum_power[l], stereo_type_detect->exp_total_power[l] ) ); + move16(); } + q_sum_total_ratio = s_max( q_sum_total_ratio, exp_sum_total_ratio_fx[l] ); } IF( l == 0 ) @@ -2626,18 +2595,6 @@ void protoSignalComputation2_fx( move32(); } - stereo_type_detect->q_sum_power = s_min( stereo_type_detect->q_sum_power, q_temp2 ); - move16(); -#ifdef FIX_867_CLDFB_NRG_SCALE - stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp_total ); - move16(); -#else - stereo_type_detect->q_total_power = s_min( stereo_type_detect->q_total_power, q_temp ); - move16(); -#endif - q_sum_total_ratio = Q15; - move16(); - IF( stereo_type_detect->interpolator > 0 ) { stereo_type_detect->interpolator++; @@ -2767,8 +2724,15 @@ void protoSignalComputation2_fx( // 20480 = 10 in Q11 lr_total_hi_ratio_fx = Mpy_32_16_1( temp, 20480 ); // Q21 + FOR( Word16 i = 0; i < s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ); i++ ) + { + sum_total_ratio_fx[i] = L_shl( sum_total_ratio_fx[i], sub( exp_sum_total_ratio_fx[i], q_sum_total_ratio ) ); + move32(); + } + minimum_l( sum_total_ratio_fx, s_min( num_freq_bands, MASA_SUM_FREQ_RANGE_BINS ), &min_sum_total_ratio_fx ); // q_sum_total_ratio - exp = sub( 31, q_sum_total_ratio ); + exp = q_sum_total_ratio; + move16(); temp = BASOP_Util_Log2( min_sum_total_ratio_fx ); // q25 IF( NE_32( temp, MIN_32 ) ) { @@ -3537,10 +3501,8 @@ void ivas_masa_init_stereotype_detection_fx( set32_fx( stereo_type_detect->sum_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS ); set32_fx( stereo_type_detect->total_power_fx, 0, MASA_SUM_FREQ_RANGE_BINS ); - stereo_type_detect->q_sum_power = Q31; - move16(); - stereo_type_detect->q_total_power = Q31; - move16(); + set16_fx( stereo_type_detect->exp_sum_power, 0, MASA_SUM_FREQ_RANGE_BINS ); + set16_fx( stereo_type_detect->exp_total_power, 0, MASA_SUM_FREQ_RANGE_BINS ); stereo_type_detect->subtract_power_y_fx = 0; move32(); diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 90e4f5d69..a13ee27e7 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -395,9 +395,9 @@ typedef struct Word16 q_total_hi_power; Word32 sum_power_fx[MASA_SUM_FREQ_RANGE_BINS]; /* Q(q_sum_power) */ - Word16 q_sum_power; + Word16 exp_sum_power[MASA_SUM_FREQ_RANGE_BINS]; Word32 total_power_fx[MASA_SUM_FREQ_RANGE_BINS]; /* Q(q_total_power) */ - Word16 q_total_power; + Word16 exp_total_power[MASA_SUM_FREQ_RANGE_BINS]; Word32 subtract_power_y_fx; /* Q(q_subtract_power_y) */ Word16 q_subtract_power_y; -- GitLab From 30a34f9e30c460771ea363c3a283f80e5f7794c3 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 09:05:34 +0200 Subject: [PATCH 144/692] activated compiler switch --- 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 b6ae74594..8b312e21b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,7 +110,7 @@ #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ -//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ -- GitLab From 5132711f954eb053dbb6134abf728ea517be653a Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 12:37:41 +0530 Subject: [PATCH 145/692] Fix for 3GPP issue 1715: Possible typo in array initialization in function ivas_dirac_render_sf_fx() Link #1715 --- lib_dec/ivas_dirac_dec_fx.c | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index f29133d92..03bc7ee12 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2217,27 +2217,6 @@ void ivas_dirac_dec_render_sf_fx( move16(); move16(); - - FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) - { - FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) - { - set32_fx( Cldfb_RealBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( Cldfb_ImagBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } - -#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_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif /* OPT_BIN_RENDERER_V2 */ - /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; Word16 elevation[CLDFB_NO_CHANNELS_MAX]; @@ -2288,6 +2267,27 @@ void ivas_dirac_dec_render_sf_fx( push_wmops( "ivas_dirac_dec_render" ); /* Initialize aux buffers */ + + FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) + { + FOR( Word16 j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + set32_fx( Cldfb_RealBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( Cldfb_ImagBuffer_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); + } + } + +#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; hSpatParamRendCom = st_ivas->hSpatParamRendCom; -- GitLab From cf1db1c57390b424eb7c5e0e2f0dcde6892ca068 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 13:53:18 +0530 Subject: [PATCH 146/692] Fix for 3GPP issue 1267: High MLD for ParamMC 5.1 at 80 kbps with +10dB Input gain Link #1267 --- lib_enc/ivas_core_enc_fx.c | 15 ++++++++++----- lib_enc/ivas_core_pre_proc_front_fx.c | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 6fcb8abd0..ad998beb3 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -113,7 +113,7 @@ ivas_error ivas_core_enc_fx( Word16 diff_nBits; ivas_error error; Word16 max_num_indices_BWE; - Word16 i; + Word16 i, shift, Q_min; set32_fx( new_swb_speech_buffer_fx, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); set16_fx( new_swb_speech_buffer_fx_16, 0, L_FRAME48k + STEREO_DFT_OVL_MAX ); @@ -531,11 +531,16 @@ ivas_error ivas_core_enc_fx( st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc; move16(); } - Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) ); - Scale_sig( st->input_fx - input_frame, input_frame, sub( -1, st->q_old_inp ) ); - st->q_inp = -1; + shift = norm_arr( st->input_fx, input_frame ); + Q_min = s_max( -2, add( st->q_inp, shift ) ); + scale_sig( st->input_fx, input_frame, sub( Q_min, st->q_inp ) ); + st->q_inp = Q_min; move16(); - st->q_old_inp = -1; + + shift = norm_arr( st->input_fx - input_frame, input_frame ); + Q_min = s_max( -2, add( st->q_old_inp, shift ) ); + scale_sig( st->input_fx - input_frame, input_frame, sub( Q_min, st->q_old_inp ) ); + st->q_old_inp = Q_min; move16(); } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 106d7c387..3e7bf2464 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -232,7 +232,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 Q_min = add( sub( 15, st->exp_old_inp_12k8 ), norm_arr( st->old_inp_12k8_fx, L_INP_MEM ) ); Word16 input_frame_full = shl( input_frame, 1 ); //(old frame input length + new frame input length) Q_min = s_min( Q_min, sub( add( getScaleFactor32( st->input32_fx - input_frame, input_frame_full ), st->q_inp32 ), 16 ) ); - Q_min = s_max( -1, Q_min ); + Q_min = s_max( -2, Q_min ); Copy_Scale_sig_32_16( st->input32_fx - input_frame, st->input_fx - input_frame, input_frame_full, sub( Q_min, st->q_inp32 ) ); // Q_min st->q_inp = Q_min; move16(); @@ -682,7 +682,7 @@ ivas_error pre_proc_front_ivas_fx( } st->mem_preemph_fx = shl_sat( st->mem_preemph_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1) saturation added as float value goes above 65536 for +10 dB test (ltv48_MC512.wav and ltv48_MC51.wav) */ move16(); - st->mem_preemph_DFT_fx = shl( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ + st->mem_preemph_DFT_fx = shl_sat( st->mem_preemph_DFT_fx_q_inp, sub( -1, st->q_inp ) ); /*Q(-1)*/ move16(); st->mem_preemph_q = st->q_inp; 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 147/692] 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 75dbe8183bd4e28198f366cf6635be3cba4572cb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 28 May 2025 14:49:05 +0530 Subject: [PATCH 148/692] Warning fix --- lib_enc/ivas_core_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index ad998beb3..5737aad2f 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -712,7 +712,7 @@ ivas_error ivas_core_enc_fx( Word16 Q_shb_spch_16 = Q_shb_spch; move16(); - Word16 shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); + shift = add( getScaleFactor16( shb_speech_fx, L_FRAME16k ), Q16 ); Copy_Scale_sig_16_32_no_sat( shb_speech_fx, shb_speech_fx32, L_FRAME16k, shift ); // Q_shb_spch Q_shb_spch = add( Q_shb_spch, shift ); -- GitLab From 87603b32350da5f42cb1296de1e52003a7f0fe23 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 11:29:56 +0200 Subject: [PATCH 149/692] fixed formatting - compiler switch --- lib_dec/ivas_init_dec_fx.c | 82 +++++++++++++++++----- lib_rend/ivas_prot_rend_fx.h | 4 +- lib_rend/ivas_rom_binaural_crend_head_fx.c | 2 +- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index fea9c5b97..a697fc407 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1156,8 +1156,7 @@ ivas_error ivas_init_decoder_front( IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ) { - IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ) - { + IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ){ return error; } @@ -1175,32 +1174,39 @@ ivas_error ivas_init_decoder_front( { return error; } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) + { + return error; + } +#endif } - /*-------------------------------------------------------------------* - * Allocate and initialize Binaural Renderer configuration handle - *--------------------------------------------------------------------*/ - test(); - test(); +/*-------------------------------------------------------------------* + * Allocate and initialize Binaural Renderer configuration handle + *--------------------------------------------------------------------*/ +test(); +test(); #ifdef SPLIT_REND_WITH_HEAD_ROT - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || - ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) +IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) #else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif +{ + IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) { - IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) - { - return error; - } + return error; + } - IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) ) - { - return error; - } + IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) ) + { + return error; } +} - return error; +return error; } @@ -1362,6 +1368,21 @@ ivas_error ivas_init_decoder_fx( } } + +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /*--------------------------------------------------------------------* + * Allocate and initialize HRTF Statistics handle + *--------------------------------------------------------------------*/ + + IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) + { + IF( NE_32( ( error = ivas_HRTF_statistics_init( &st_ivas->hHrtfStatistics, output_Fs ) ), IVAS_ERR_OK ) ) + { + return error; + } + } +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -2273,7 +2294,11 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif { +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if ( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -2317,13 +2342,24 @@ ivas_error ivas_init_decoder_fx( } #ifdef SPLIT_REND_WITH_HEAD_ROT +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), + IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) +#endif +#else +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + if( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) +#endif #endif { return error; @@ -2861,6 +2897,9 @@ void ivas_initialize_handles_dec( st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + st_ivas->hHrtfStatistics = NULL; +#endif st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; st_ivas->hSbaIsmData = NULL; @@ -3095,6 +3134,11 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); +#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /* HRTF statistics */ + ivas_HRTF_statistics_close( &st_ivas->hHrtfStatistics ); +#endif + /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index ca1d3ccdc..a7f52eb32 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -957,8 +957,8 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( #endif const Word32 sampling_rate, /* i : sampling rate */ #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ + const Word32 *defaultTimes, /* i : default reverberation times */ + const Word32 *defaultEne /* i : default reverberation energies */ #else const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ #endif diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index b4ebfe6e5..71a98fb0e 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59838,7 +59838,7 @@ const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 2790378,2355663,2029237,1865240,1832432 }; -#ifndef NONBE_FIX_AVG_IAC_CLDFB_REVERB +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, -- GitLab From d8e0abccf35f5f41b80678308c013472b07aec19 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 12:11:15 +0200 Subject: [PATCH 150/692] verified Word32 type assignments --- lib_rend/ivas_reverb_utils_fx.c | 2 +- lib_rend/ivas_rom_binaural_crend_head.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 689670477..28eb69141 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -309,7 +309,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif float input_fc[FFT_SPECTRUM_SIZE]; -#ifndef NON_BE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 1d18ec02a..9e40c49ba 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -358,9 +358,9 @@ extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ #else extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -- GitLab From 75d6a4cd9faf425020eca5ed44b8b0d16b27bd41 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 12:35:19 +0200 Subject: [PATCH 151/692] fixed definitions of type Word32 --- lib_rend/ivas_prot_rend_fx.h | 4 ++-- lib_rend/ivas_reverb_fx.c | 20 ++++++++++---------- lib_rend/ivas_reverb_utils_fx.c | 2 -- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index a7f52eb32..fa74d0f0e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1152,8 +1152,8 @@ ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, - float *pOutput_t60, - float *pOutput_ene ); + Word32 *pOutput_t60, + Word32 *pOutput_ene ); #else ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index a7a3e5039..473a1e701 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2480,20 +2480,20 @@ static ivas_error ivas_binaural_reverb_open_fx( ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - const int16_t numBins, /* i : number of CLDFB bins */ - const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const Word16 numBins, /* i : number of CLDFB bins */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const int32_t sampling_rate, /* i : sampling rate */ - const float *defaultTimes, /* i : default reverberation times */ - const float *defaultEne /* i : default reverberation energies */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word32 *defaultTimes, /* i : default reverberation times */ + const Word32 *defaultEne /* i : default reverberation energies */ ) { ivas_error error; - const float *revTimes; - const float *revEne; - float t60[CLDFB_NO_CHANNELS_MAX]; - float ene[CLDFB_NO_CHANNELS_MAX]; - int16_t preDelay; + const Word32 *revTimes; + const Word32 *revEne; + Word32 t60[CLDFB_NO_CHANNELS_MAX]; + Word32 ene[CLDFB_NO_CHANNELS_MAX]; + Word16 preDelay; error = IVAS_ERR_OK; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 28eb69141..2cead56f1 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -330,8 +330,6 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); - Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); - Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); -- GitLab From 714426d6e864e74ec550fa7ccbc6859082d9b244 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 28 May 2025 13:40:13 +0300 Subject: [PATCH 152/692] Implement MR1400 changes to main-pc. Not including changes in split rendering off path. --- lib_com/options.h | 1 + lib_dec/ivas_dirac_dec_fx.c | 4 + lib_dec/ivas_init_dec_fx.c | 4 + lib_dec/ivas_ism_dec_fx.c | 8 ++ .../ivas_dirac_dec_binaural_functions_fx.c | 92 ++++++++++++++++++- lib_rend/ivas_prot_rend_fx.h | 4 + lib_rend/ivas_stat_rend.h | 20 ++++ lib_rend/lib_rend_fx.c | 24 ++++- 8 files changed, 150 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 73a8f082f..9c2c217ea 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index ff02d813d..5f8d1512b 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1150,7 +1150,11 @@ ivas_error ivas_dirac_dec_config_fx( IF( st_ivas->hDiracDecBin == NULL ) #endif { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index fea9c5b97..ee4a6b4fe 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2234,7 +2234,11 @@ ivas_error ivas_init_decoder_fx( } } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index f0ad208f5..3cc423910 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -291,7 +291,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -322,7 +326,11 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( return error; } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#endif { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index ac387c5cc..11467f008 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -128,9 +128,17 @@ static void adaptTransportSignalsHeadtracked_fx( COMBINED_ORIENTATION_HANDLE hHe static void ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( COMBINED_ORIENTATION_HANDLE hHeadTrackData, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 nBins, const Word16 nSlots, Word32 Rmat[3][3] /*Q30*/ ); - +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF +static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue, HRTFS_PARAMBIN_HANDLE hHrtfParambin ); +#else static void hrtfShGetHrtf_fx( const Word16 bin, const Word16 aziDeg, const Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 useCachedValue ); +#endif + +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF +static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked, HRTFS_PARAMBIN_HANDLE hHrtfParambin ); +#else static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked ); +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); @@ -162,7 +170,11 @@ static void matrixTransp2Mul_fx( *------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_init_binaural_data_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ +#else HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ +#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -206,6 +218,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( hDiracDecBin->hReverb = NULL; hDiracDecBin->h_freq_domain_decorr_ap_params = NULL; hDiracDecBin->h_freq_domain_decorr_ap_state = NULL; +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + hDiracDecBin->phHrtfParambin = NULL; +#endif } output_Fs = st_ivas->hDecoderConfig->output_Fs; @@ -297,7 +312,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( } ELSE IF( EQ_32( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); +#else Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); +#endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); /* reconfiguration needed when Reverb. parameters are changed -> close and open the handle again */ @@ -315,8 +334,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( IF( hDiracDecBin->hReverb == NULL ) #endif { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK) ) +#else + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -390,6 +412,10 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ move16(); +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + hDiracDecBin->phHrtfParambin = phHrtfParambin; +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin; } @@ -1797,7 +1823,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); +#endif Word16 q_lr = Q28; move16(); @@ -1848,7 +1878,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( rImagp_fx = Mpy_32_32( rImagp_fx, centerMul_fx ); // Q25 /* Apply the gain for the left source of the three coherent sources */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked ); +#endif hrtfEneSides_fx = L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 @@ -1862,7 +1896,11 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); +#endif hrtfEneSides_fx = L_add( hrtfEneSides_fx, L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 @@ -3308,7 +3346,11 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( q_processMtxPrev_SCCR[bin] = q_processMtx_bin; move16(); +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat, &gainCache[chB], isHeadtracked ); +#endif hDiracDecBin->processMtxRe_fx[0][add( chB, 2 )][bin] = extract_h( Mpy_32_32( lRealp_fx, gainFactor_fx ) ); move16(); @@ -5598,7 +5640,13 @@ static void getDirectPartGains_fx( const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3], /*Q30*/ PARAMBIN_HRTF_GAIN_CACHE *gainCache, - const Word16 isHeadtracked ) +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + const Word16 isHeadtracked, + HRTFS_PARAMBIN_HANDLE hHrtfParambin +#else + const Word16 isHeadtracked +#endif +) { // float aziRad, eleRad; Word32 y, mappedX; @@ -5727,7 +5775,11 @@ static void getDirectPartGains_fx( test(); IF( EQ_16( aziDeg, gainCache->azi ) && EQ_16( eleDeg, gainCache->ele ) ) { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, TRUE, hHrtfParambin ); +#else hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, TRUE ); +#endif } ELSE { @@ -5742,7 +5794,11 @@ static void getDirectPartGains_fx( // eleDeg = L_shr(eleDeg_32, 22); // aziDeg = L_shr(aziDeg_32, 22); } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, FALSE, hHrtfParambin ); +#else hrtfShGetHrtf_fx( bin, aziDeg, eleDeg, lRealp, lImagp, rRealp, rImagp, gainCache, FALSE ); +#endif } } @@ -5758,9 +5814,21 @@ static void hrtfShGetHrtf_fx( Word32 *rRealp, Word32 *rImagp, PARAMBIN_HRTF_GAIN_CACHE *gainCache, - const Word16 useCachedValue ) +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + const Word16 useCachedValue, + HRTFS_PARAMBIN_HANDLE hHrtfParambin +#else + const Word16 useCachedValue +#endif +) { Word16 k; +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + Word32( *hrtfShCoeffsReInt_fx )[16][60]; + Word32( *hrtfShCoeffsImInt_fx )[16][60]; + hrtfShCoeffsReInt_fx = hHrtfParambin->hrtfShCoeffsRe_fx; + hrtfShCoeffsImInt_fx = hHrtfParambin->hrtfShCoeffsIm_fx; +#endif *lRealp = 0; *lImagp = 0; @@ -5778,10 +5846,17 @@ static void hrtfShGetHrtf_fx( FOR( k = 0; k < HRTF_SH_CHANNELS; k++ ) { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsReInt_fx[0][k][bin] ); // Q28 + *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsImInt_fx[0][k][bin] ); // Q28 + *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsReInt_fx[1][k][bin] ); // Q28 + *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsImInt_fx[1][k][bin] ); // Q28 +#else *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsRe_fx[0][k][bin] ); // Q28 *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsIm_fx[0][k][bin] ); // Q28 *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsRe_fx[1][k][bin] ); // Q28 *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsIm_fx[1][k][bin] ); // Q28 +#endif move32(); move32(); move32(); @@ -5800,10 +5875,17 @@ static void hrtfShGetHrtf_fx( FOR( k = 0; k < HRTF_SH_CHANNELS; k++ ) { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsReInt_fx[0][k][bin] ); // Q28 + *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsImInt_fx[0][k][bin] ); // Q28 + *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsReInt_fx[1][k][bin] ); // Q28 + *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsImInt_fx[1][k][bin] ); // Q28 +#else *lRealp = Madd_32_16( *lRealp, shVec[k], hrtfShCoeffsRe_fx[0][k][bin] ); // Q28 *lImagp = Madd_32_16( *lImagp, shVec[k], hrtfShCoeffsIm_fx[0][k][bin] ); // Q28 *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsRe_fx[1][k][bin] ); // Q28 *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsIm_fx[1][k][bin] ); // Q28 +#endif gainCache->shVec_fx[k] = shVec[k]; // Q29 move32(); move32(); diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 7ab5288cc..17791d33b 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -231,7 +231,11 @@ void ivas_masa_ext_rend_parambin_render_fx( ); ivas_error ivas_dirac_dec_init_binaural_data_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ +#else HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : HRTF structure for rendering */ +#endif ); void ivas_dirac_dec_close_binaural_data( diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b7acbca2c..c2368a028 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -604,6 +604,20 @@ typedef struct ivas_diffuse_distribution_data_structure } DIFFUSE_DISTRIBUTION_DATA, *DIFFUSE_DISTRIBUTION_HANDLE; +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF +typedef struct ivas_hrtfs_parambin_struct +{ + Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ + Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ + + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ + + Word16 allocatedFromFile; /* Unused variable that should not be here. Remove in cleanup. */ + +} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#endif /* Parametric binaural data structure */ typedef struct ivas_dirac_dec_binaural_data_structure @@ -668,6 +682,10 @@ typedef struct ivas_dirac_dec_binaural_data_structure ivas_td_decorr_state_t *hTdDecorr; Word16 reqularizationFactor_fx; /* Q14 */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + HRTFS_PARAMBIN_HANDLE *phHrtfParambin; +#endif + DIFFUSE_DISTRIBUTION_HANDLE hDiffuseDist; HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params; @@ -1461,6 +1479,7 @@ typedef struct ivas_hrtfs_fastconv_struct } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; +#ifndef NONBE_FIX_991_PARAMBIN_BINARY_HRTF typedef struct ivas_hrtfs_parambin_struct { Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ @@ -1473,6 +1492,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 allocatedFromFile; } HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE; +#endif #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 4276b8146..3152955ed 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -10010,7 +10010,11 @@ static ivas_error ivas_masa_ext_rend_parambin_init( ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + HRTFS_PARAMBIN_HANDLE *phHrtfParambin; +#else HRTFS_PARAMBIN_HANDLE hHrtfParambin; +#endif Word16 nBins; Word32 output_Fs; RENDERER_TYPE renderer_type; @@ -10030,7 +10034,11 @@ static ivas_error ivas_masa_ext_rend_parambin_init( error = IVAS_ERR_OK; move32(); +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + phHrtfParambin = inputMasa->hMasaExtRend->hHrtfParambin; +#else hHrtfParambin = *( inputMasa->hMasaExtRend->hHrtfParambin ); +#endif /* Set common variables and defaults */ output_Fs = *( inputMasa->base.ctx.pOutSampleRate ); move32(); @@ -10135,7 +10143,11 @@ static ivas_error ivas_masa_ext_rend_parambin_init( } ELSE IF( EQ_16( renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) /* Indication of binaural rendering with room effect */ { +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); +#else Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); +#endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); @@ -10145,8 +10157,11 @@ static ivas_error ivas_masa_ext_rend_parambin_init( IF( hDiracDecBin->hReverb == NULL ) #endif { - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) +#else + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) +#endif { return error; } @@ -10192,6 +10207,11 @@ static ivas_error ivas_masa_ext_rend_parambin_init( /* External renderer uses constant regularization factor */ hDiracDecBin->reqularizationFactor_fx = 6554; /* 0.4f in Q14 */ move16(); + +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + hDiracDecBin->phHrtfParambin = phHrtfParambin; +#endif + #ifdef SPLIT_REND_WITH_HEAD_ROT inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } -- GitLab From a86062998f069b84c01dcb57f619c90e5fc325c6 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 12:41:41 +0200 Subject: [PATCH 153/692] clang formatting patch --- lib_dec/ivas_init_dec_fx.c | 44 +++++++++++++++++++------------------- lib_rend/ivas_reverb_fx.c | 10 ++++----- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a697fc407..44e20c645 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1154,34 +1154,33 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ - IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ) - { + IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ){ IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ){ return error; - } +} - IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) ) - { - return error; - } +IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) ) +{ + return error; +} - IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } +IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) +{ + return error; +} - IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) - { - return error; - } +IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) +{ + return error; +} #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) - { - return error; - } +IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) +{ + return error; +} #endif - } +} /*-------------------------------------------------------------------* * Allocate and initialize Binaural Renderer configuration handle @@ -2353,8 +2352,9 @@ ivas_error ivas_init_decoder_fx( #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 473a1e701..acfd656c5 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2480,12 +2480,12 @@ static ivas_error ivas_binaural_reverb_open_fx( ivas_error ivas_binaural_reverb_init( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - const Word16 numBins, /* i : number of CLDFB bins */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ + const Word16 numBins, /* i : number of CLDFB bins */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate */ - const Word32 *defaultTimes, /* i : default reverberation times */ - const Word32 *defaultEne /* i : default reverberation energies */ + const Word32 sampling_rate, /* i : sampling rate */ + const Word32 *defaultTimes, /* i : default reverberation times */ + const Word32 *defaultEne /* i : default reverberation energies */ ) { ivas_error error; -- GitLab From a33ee61c7caeca010d3ac040a3c63ec33b7bd06c Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 28 May 2025 14:00:01 +0300 Subject: [PATCH 154/692] Clang format --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 10 +++++----- lib_rend/lib_rend_fx.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 11467f008..fb403cfb7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -169,7 +169,7 @@ static void matrixTransp2Mul_fx( * Initialize parametric binaural renderer *------------------------------------------------------------------------*/ ivas_error ivas_dirac_dec_init_binaural_data_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF HRTFS_PARAMBIN_HANDLE *phHrtfParambin /* i : HRTF structure for rendering */ #else @@ -315,7 +315,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #else - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); @@ -335,9 +335,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( #endif { #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK) ) + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) #else - if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes, st_ivas->hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) #endif { return error; @@ -5886,7 +5886,7 @@ static void hrtfShGetHrtf_fx( *rRealp = Madd_32_16( *rRealp, shVec[k], hrtfShCoeffsRe_fx[1][k][bin] ); // Q28 *rImagp = Madd_32_16( *rImagp, shVec[k], hrtfShCoeffsIm_fx[1][k][bin] ); // Q28 #endif - gainCache->shVec_fx[k] = shVec[k]; // Q29 + gainCache->shVec_fx[k] = shVec[k]; // Q29 move32(); move32(); move32(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 3152955ed..dde950181 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -10146,7 +10146,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #else - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); @@ -10160,7 +10160,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes, ( *phHrtfParambin )->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) #else - if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes, hHrtfParambin->parametricReverberationEneCorrections ) ), IVAS_ERR_OK ) ) #endif { return error; -- GitLab From 831320b11388d274145054faf7197c593f66624a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 28 May 2025 13:10:22 +0200 Subject: [PATCH 155/692] remove ivas_prot.h + update MSVC project wrt. added files --- Workspace_msvc/lib_com.vcxproj.filters | 52 +- lib_com/ivas_prot.h | 4068 ------------------------ 2 files changed, 40 insertions(+), 4080 deletions(-) delete mode 100644 lib_com/ivas_prot.h diff --git a/Workspace_msvc/lib_com.vcxproj.filters b/Workspace_msvc/lib_com.vcxproj.filters index f1d860f1a..8860ccd56 100644 --- a/Workspace_msvc/lib_com.vcxproj.filters +++ b/Workspace_msvc/lib_com.vcxproj.filters @@ -508,6 +508,12 @@ common_all_c + + common_ivas_c + + + common_ivas_c + @@ -588,17 +594,39 @@ common_h - - - - - - - - - - - + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + + + common_h + @@ -614,4 +642,4 @@ {b95b7bed-a666-4a00-9332-2b528638503e} - + \ No newline at end of file diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h deleted file mode 100644 index 9ee17fed6..000000000 --- a/lib_com/ivas_prot.h +++ /dev/null @@ -1,4068 +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. - -*******************************************************************************************************/ - -#ifndef IVAS_PROT_H -#define IVAS_PROT_H - -#include -#include "options.h" -#include -#include "typedef.h" -#include "stat_enc.h" -#include "stat_dec.h" -#include "stat_com.h" -#include "ivas_stat_enc.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_rend.h" -#include "ivas_stat_com.h" -#include "ivas_error_utils.h" - -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED - -/* clang-format off */ - -/*----------------------------------------------------------------------------------* - * General IVAS prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_enc( - Encoder_Struct *st_ivas, /* i : IVAS encoder structure */ - const int16_t *data, /* i : input signal */ - const int16_t n_samples /* i : number of input samples */ -); - -void stereo_dmx_evs_enc( - STEREO_DMX_EVS_ENC_HANDLE hStereoDmxEVS, /* i/o: Stereo downmix for EVS encoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - int16_t data[CPE_CHANNELS * L_FRAME48k], /* i/o: input signal */ - const int16_t n_samples, /* i : number of input samples */ - const bool is_binaural /* i : indication that input is binaural audio */ -); - -/*! r: number of channels to be analysed */ - -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*/ -); - - - -ivas_error create_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - const int32_t element_brate /* i : element bitrate */ -); - -ivas_error create_mct_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void destroy_cpe_enc( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */ -); - -void ivas_mct_enc_close_fx( - MCT_ENC_HANDLE *hMCT /* i/o: MCT encoder structure */ -); - -ivas_error ivas_corecoder_enc_reconfig( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - const int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */ - const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */ -); - -ivas_error ivas_sce_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - const float data_f[], /* i : input signal for single channel */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -ivas_error ivas_cpe_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const Word16 cpe_id, /* i : CPE # identifier */ - float data_f_ch0[], /* i : input signal for channel 0 */ - float data_f_ch1[], /* i : input signal for channel 1 */ - const Word16 input_frame, /* i : input frame length per channel */ - const Word16 nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[MCT_MAX_CHANNELS], /* i : input signal buffers */ - const int16_t input_frame, /* i : input frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error pre_proc_front_ivas( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int32_t element_brate, /* i : SCE/CPE element bitrate */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int16_t input_frame, /* i : frame length */ - const int16_t n, /* i : channel number */ - float old_inp_12k8[], /* o : buffer of old input signal */ - float old_inp_16k[], /* o : buffer of old input signal @16kHz */ - float *ener, /* o : residual energy from Levinson-Durbin */ - float *relE, /* o : frame relative energy */ - float A[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes */ - float Aw[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes */ - float epsP[M + 1], /* o : LP prediction errors */ - float lsp_new[M], /* o : LSPs at the end of the frame */ - float lsp_mid[M], /* o : LSPs in the middle of the frame */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - int16_t *attack_flag, /* o : flag signaling attack */ - float realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer */ - float imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer */ - float old_wsp[], /* o : weighted input signal buffer */ - float pitch_fr[NB_SUBFR], /* o : fractional pitch values */ - float voicing_fr[NB_SUBFR], /* o : fractional pitch gains */ - int16_t *loc_harm, /* o : harmonicity flag */ - float *cor_map_sum, /* o : speech/music clasif. parameter */ - int16_t *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO */ - float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer */ - float fft_buff[2 * L_FFT], /* o : FFT buffer */ - const float tdm_A_PCh[M + 1], /* i : unq. LP coeff. of primary channel */ - const float tdm_lsp_new_PCh[M], /* i : unq. LSPs of primary channel */ - const float currFlatness, /* i : flatness parameter */ - const int16_t tdm_ratio_idx, /* i : Current Ratio_L index */ - float fr_bands_LR[][2 * NB_BANDS], /* i : energy in frequency bands */ - const float Etot_LR[], /* i : total energy Left & Right channel */ - float lf_E_LR[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - const int16_t localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ - const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ - const int16_t force_front_vad, /* i : flag to force VAD decision */ - const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error pre_proc_front_ivas_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const Word32 element_brate, /* i : SCE/CPE element bitrate Q0*/ - const Word16 nb_bits_metadata, /* i : number of metadata bits Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - const Word16 n, /* i : channel number Q0*/ - Word16 old_inp_12k8_fx[], /* o : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[], /* o : buffer of old input signal @16kHz Q_new-1*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 *relE_fx, /* o : frame relative energy Q8*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* o : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* o : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[M + 1], /* o : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, - Word16 lsp_new_fx[M], /* o : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* o : LSPs in the middle of the frame Q15*/ - Word16 *vad_hover_flag, /* o : VAD hangover flag Q0*/ - Word16 *attack_flag, /* o : flag signaling attack Q0*/ - Word32 realBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer Q(q_re_im_buf)*/ - Word32 imagBuffer_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer Q(q_re_im_buf)*/ - Word16 *q_re_im_buf, /* i/o: Q-factor of real and imag buffer */ - Word16 old_wsp_fx[], /* o : weighted input signal buffer q_old_wsp*/ - Word16 *q_old_wsp, - Word16 pitch_fr_fx[NB_SUBFR], /* o : fractional pitch values Q6*/ - Word16 voicing_fr_fx[NB_SUBFR], /* o : fractional pitch gains Q15*/ - Word16 *loc_harm, /* o : harmonicity flag Q0*/ - Word16 *cor_map_sum_fx, /* o : speech/music clasif. parameter Q8*/ - Word16 *vad_flag_dtx, /* o : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 *enerBuffer_fx_exp, /* o : energy buffer */ - Word16 fft_buff_fx[2 * L_FFT], /* o : FFT buffer fft_buff_fx_q*/ - Word16 *fft_buff_fx_q, /* o : FFT buffer */ - const Word16 tdm_A_PCh_fx[M + 1], /* i : unq. LP coeff. of primary channel Q12*/ - const Word16 tdm_lsp_new_PCh_fx[M], /* i : unq. LSPs of primary channel Q15*/ - const Word16 currFlatness_fx, /* i : flatness parameter Q7*/ - const Word16 tdm_ratio_idx, /* i : Current Ratio_L index Q0*/ - Word32 fr_bands_LR_fx[][2 * NB_BANDS], /* i : energy in frequency bands (fr_bands_LR_fx_q) fr_bands_LR_fx_q*/ - Word16 fr_bands_LR_fx_q[CPE_CHANNELS], - const Word16 Etot_LR_fx[], /* i : total energy Left & Right channel Q8*/ - Word32 lf_E_LR_fx[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels (lf_E_LR_fx_q)*/ - Word16 lf_E_LR_fx_q, - const Word16 localVAD_HE_SAD_LR[], /* i : HE-SAD flag without hangover, LR channels Q0*/ - Word32 band_energies_LR_fx[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN (band_energies_LR_fx_q)*/ - Word16 band_energies_LR_fx_q, - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - const Word16 front_vad_flag, /* i : front-VAD flag to overwrite VAD decision Q0*/ - const Word16 force_front_vad, /* i : flag to force VAD decision Q0*/ - const Word16 front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision Q0*/ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ -#ifdef NONBE_1211_DTX_BR_SWITCHING - const Word32 last_ivas_total_brate, /* i : last IVAS total bitrate Q0*/ -#endif - const Word32 ivas_total_brate, /* i : IVAS total bitrate - for setting the DTX Q0*/ - Word16 *Q_new -#ifdef DEBUG_MODE_INFO - , - const Word16 ch_idx -#endif -); -ivas_error pre_proc_ivas_fx( - Encoder_State *st, /* i/o: encoder state structure */ - const Word16 last_element_mode, /* i : last element mode Q0*/ - const Word32 element_brate, /* i : element bitrate Q0*/ - const Word32 last_element_brate, /* i : last element bitrate Q0*/ - const Word16 input_frame, /* i : frame length Q0*/ - Word16 old_inp_12k8_fx[], /* i/o: buffer of old input signal Q_new-1 */ - Word16 old_inp_16k_fx[], /* i/o: buffer of old input signal @ 16kHz Q_new-1 */ - Word16 **inp_fx, /* o : ptr. to inp. signal in the current frame Q_new*/ - Word32 *ener_fx, /* o : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes Q14*/ - Word32 epsP_fx[M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 *epsP_fx_q, /* i : LP prediction errors */ - Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[M], /* i/o: LSPs in the middle of the frame Q15*/ - Word16 *new_inp_resamp16k_fx, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE Q_new-1*/ - Word16 *Voicing_flag, /* o : voicing flag for HQ FEC Q0*/ - Word16 old_wsp_fx[], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp, - const Word16 loc_harm, /* i : harmonicity flag Q0*/ - const Word16 vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO Q0*/ - const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) Q0*/ - const Word16 vad_hover_flag, /* i : VAD hangover flag Q0*/ - const Word16 flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ - Word32 enerBuffer_fx[CLDFB_NO_CHANNELS_MAX], /* e_enerBuffer */ - Word16 e_enerBuffer, - Word16 fft_buff_fx[2 * L_FFT], /* Qx */ - Word16 cor_map_sum_fx, /* Q8 */ - Word16 *Q_new -); -/*! r: number of clipped samples */ -void ivas_initialize_handles_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_init_encoder( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_enc_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_initialize_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hBstr, /* o : encoder MD bitstream handle */ - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_destroy_MD_bstr_enc_fx( - BSTR_ENC_HANDLE *hMetaData /* i/o: encoder MD bitstream handle */ -); - -ivas_error ivas_init_decoder_front( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_init_decoder( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_output_buff_dec( - float *p_output_f[], /* i/o: output audio buffers */ - const int16_t nchan_out_buff_old, /* i : previous frame number of output channels*/ - const int16_t nchan_out_buff /* i : number of output channels */ -); -#endif - -ivas_error stereo_dmx_evs_init_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS, /* o : Stereo downmix for EVS encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_dmx_evs_close_encoder( - STEREO_DMX_EVS_ENC_HANDLE *hStereoDmxEVS /* i/o: Stereo downmix for EVS encoder handle */ -); - -ivas_error ivas_dec( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - int16_t *data /* o : output synthesis signal */ -); - - -ivas_error mct_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t b_nchan_change /* i : flag indicating different channel count */ -); - - -void ivas_mct_dec_close( - MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */ -); - -ivas_error ivas_corecoder_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSCE_old, /* i : number of SCEs in previous frame */ - int16_t nCPE_old, /* i : number of CPEs in previous frame */ - const int16_t nchan_transport_old, /* i : number of TCs in previous frame */ - const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */ - const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */ - const int32_t brate_CPE /* i : bitrate to be set for the CPEs */ -); - -ivas_error ivas_hp20_dec_reconfig( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame*/ -); - -ivas_error ivas_sce_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t sce_id, /* i : SCE # identifier */ - float *output[1], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_cpe_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t cpe_id, /* i : CPE # identifier */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -ivas_error ivas_mct_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -/*! r: number of channels to be synthesised */ - -void copy_decoder_config( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - Decoder_State *st /* o : decoder state structure */ -); - -void destroy_core_dec( - DEC_CORE_HANDLE hCoreCoder /* i/o: core decoder structure */ -); - - -void ivas_initialize_handles_dec( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_core_enc_fx( - SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const Word16 n_CoreChannels, /* i : number of core channels to be coded Q0*/ - Word16 old_inp_12k8_fx[][L_INP_12k8], /* i : buffer of old input signal Q_new-1*/ - Word16 old_inp_16k_fx[][L_INP], /* i : buffer of old input signal Q_new-1*/ - Word16 Q_new[], - Word32 ener_fx[], /* i : residual energy from Levinson-Durbin epsP_fx_q*/ - Word16 A_fx[][NB_SUBFR16k * ( M + 1 )], /* i : A(z) unquantized for the 4 subframes Q12*/ - Word16 Aw_fx[][NB_SUBFR16k * ( M + 1 )], /* i : weighted A(z) unquantized for subframes Q12*/ - Word32 epsP_fx[][M + 1], /* i : LP prediction errors epsP_fx_q*/ - Word16 epsP_fx_q[], /* i : LP prediction errors */ - Word16 lsp_new_fx[][M], /* i : LSPs at the end of the frame Q15*/ - Word16 lsp_mid_fx[][M], /* i : LSPs in the middle of the frame Q15*/ - const Word16 vad_hover_flag[], /* i : VAD hanglover flag Q0*/ - Word16 attack_flag[], /* i : attack flag (GSC or TC) Q0*/ - Word32 realBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: real buffer q_re_im_buf*/ - Word32 imagBuffer_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: imag buffer q_re_im_buf*/ - Word16 *q_re_im_buf, - Word16 old_wsp_fx[][L_WSP], /* i : weighted input signal buffer e_old_wsp*/ - Word16 e_old_wsp[], - const Word16 loc_harm[], /* i : harmonicity flag Q0*/ - const Word16 cor_map_sum_fx[], /* i : speech/music clasif. parameter Q8*/ - const Word16 vad_flag_dtx[], /* i : HE-SAD flag with additional DTX HO Q0*/ - Word32 enerBuffer_fx[][CLDFB_NO_CHANNELS_MAX], /* o : energy buffer enerBuffer_fx_exp*/ - Word16 enerBuffer_fx_exp[], /* o : energy buffer */ - Word16 fft_buff_fx[][2 * L_FFT], /* i : FFT buffer Qx*/ - const Word16 tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag Q0*/ - const Word16 ivas_format, /* i : IVAS format Q0*/ - const Word16 flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz Q0*/ -); - - - -void decod_gen_2sbfr( - Decoder_State *st, /* i/o: decoder static memory */ - const int16_t sharpFlag, /* i : formant sharpening flag */ - const float *Aq, /* i : LP filter coefficient */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - float *gain_buf, /* o : floating pitch gain for each subframe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : pitch values for primary channel */ -); - -void synchro_synthesis( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void synchro_synthesis_fixed( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_tcx_init_enc( - Encoder_State *st /* i/o: encoder state structure */ -); - - - - -void stereo_tcx_init_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t last_element_mode /* i : element mode of previous frame */ -); - -/*! r: S/M decision (0 = speech or noise, 1 = unclear, 2 = music) */ -int16_t ivas_smc_gmm( - Encoder_State *st, /* i/o: encoder state structure */ - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ - const float Etot, /* i : total frame energy */ - const float lsp_new[M], /* i : LSPs in current frame */ - const float cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.) */ - const float epsP[M + 1], /* i : LP prediciton error */ - const float PS[], /* i : energy spectrum */ - const float non_sta, /* i : unbound non-stationarity */ - const float relE, /* i : relative frame energy */ - int16_t *high_lpn_flag, /* i/o: sp/mus LPN flag */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -void ivas_smc_mode_selection( - Encoder_State *st, /* i/o: encoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - int16_t smc_dec, /* i : raw decision of the 1st stage classifier */ - const float relE, /* i : relative frame energy */ - const float Etot, /* i : total frame energy */ - int16_t *attack_flag, /* i/o: attack flag (GSC or TC) */ - const float *inp, /* i : input signal */ - const float S_map[], /* i : short-term correlation map */ - const int16_t flag_spitch /* i : flag to indicate very short stable pitch */ -); - -/*! r: S/M decision (0=speech or noise,1=unclear,2=music) */ -int16_t ivas_acelp_tcx20_switching( - Encoder_State *st, /* i/o: encoder state structure */ - const float *inp, /* i : new input signal */ - const float *wsp, /* i : input weighted signal */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas */ - const float *pitch_fr, /* i : fraction pitch values */ - const float *voicing_fr, /* i : fractional voicing values */ - const float currFlatness, /* i : flatness */ - const float lsp_mid[M], /* i : LSPs at the middle of the frame */ - const float stab_fac, /* i : LP filter stability */ - float *res_cod_SNR_M, - const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */ -); - - - -void ivas_decision_matrix_dec( - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *sharpFlag, /* o : formant sharpening flag */ - int16_t *core_switching_flag, /* o : ACELP->HQ switching frame flag */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t nchan_out /* i : Number of output channels */ -); - -void set_bw_stereo( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structures */ -); - -/*! r: flag indicating whether the coded BW has changed */ -int16_t set_bw_mct( - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nCPE /* i : number of CPEs */ -); -void dec_acelp_fast( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t cdk_index, /* i : codebook index */ - float code[], /* o : algebraic (fixed) codebook excitation */ - const int16_t L_subfr /* i : subframe length */ -); - -void set_transient_stereo( - CPE_ENC_HANDLE hCPE, /* i : CPE structure */ - float currFlatness[] /* i/o: current flatness */ -); - -/*! r: preliminary flag to force ACELP */ -int16_t transient_analysis( - TRAN_DET_HANDLE hTranDet, /* i : handle transient detection */ - const float cor_map_LT[], /* i : LT correlation map */ - const float multi_harm_limit /* i : multi harminic threshold */ -); - -void ivas_post_proc( - SCE_DEC_HANDLE hSCE, /* i/o: SCE decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float synth[], /* i/o: output synthesis signal */ - float *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void ivas_renderer_select( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_mc_enc_config_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_mc_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t idx, /* i : LS config. index */ - uint16_t *nSamplesRendered, /* o : samples flushed from last frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -/*! r: MC format mode (MCT, McMASA, ParamMC) */ -MC_MODE ivas_mc_mode_select( - const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ - const int32_t total_brate /* i : IVAS total bitrate */ -); - -/*! r: number of loudspeaker channels */ -int16_t ivas_mc_ls_setup_get_num_channels( - const MC_LS_SETUP mc_ls_setup /* i : loudspeaker setup (CICP) */ -); - -/*! r: output configuration*/ -AUDIO_CONFIG ivas_mc_map_ls_setup_to_output_config( - const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ -); - -/*! r: multi channel loudspeaker setup */ -MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( - const AUDIO_CONFIG output_config /* i : output audio configuration */ -); - -void smooth_dft2td_transition( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: synthesis @external Fs */ - const int16_t output_frame /* i : output frame length */ -); - - -/*! r: flag indicating a valid bitrate */ -Word16 is_IVAS_bitrate_fx( - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -int16_t is_DTXrate( - const int32_t ivas_total_brate /* i : IVAS total bitrate */ -); - - -void TonalMdctConceal_create_concealment_noise_ivas( - float concealment_noise[L_FRAME48k], - CPE_DEC_HANDLE hCPE, - const int16_t L_frameTCX, - const int16_t L_frame, - const int16_t idchan, - const int16_t subframe_idx, - const int16_t core, - const float crossfade_gain, - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode -); - -void TonalMdctConceal_whiten_noise_shape_ivas( - Decoder_State *st, - const int16_t L_frame, - const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE -); - -void dtx_read_padding_bits( - DEC_CORE_HANDLE st, - const int16_t num_bits -); - - - -/*----------------------------------------------------------------------------------* - * JBM prototypes - *----------------------------------------------------------------------------------*/ - - - -ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -void ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ -); - -ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ -); - -void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ -); - - - -int16_t ivas_jbm_dec_get_num_tc_channels( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -void ivas_jbm_dec_copy_tc_no_tsm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *tc[], /* i : transport channels */ - const int16_t output_frame /* i : output frame size */ -); - - -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -/*! r: render granularity */ -int16_t ivas_jbm_dec_get_render_granularity_flt( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int32_t output_Fs /* i : sampling rate */ -); - -ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : number of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ -); - -void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ -); - -void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_jbm_dec_metadata_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_jbm_masa_sf_to_sf_map( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM prototypes - *----------------------------------------------------------------------------------*/ - -void bitbudget_to_brate( - const Word16 x[], /* i : bitbudgets Q0 */ - Word32 y[], /* o : bitrates Q0 */ - const Word16 N /* i : number of entries to be converted */ -); - -void ivas_ism_reset_metadata( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -void ivas_ism_reset_metadata_enc( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handle */ -); -void ivas_ism_reset_metadata_API( - ISM_METADATA_HANDLE hIsmMeta /* i/o: ISM metadata handles */ -); - -/*! r: index of the winning codeword */ -Word16 ism_quant_meta_fx( - const Word32 val, /* i : scalar value to quantize Q22 */ - Word32 *valQ, /* o : quantized value Q22 */ - const Word32 borders_fx[], /* i : level borders Q22 */ - const Word32 q_step_fx, /* i : quantization step Q22 */ - const Word32 q_step_border_fx, /* i : quantization step at the border Q22 */ - const Word16 cbsize /* i : codebook size */ -); - -ivas_error ivas_ism_metadata_enc_create_fx( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_metadata_dec_create( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_ISms, /* i : number of objects */ - int32_t element_brate_tmp[] /* o : element bitrate per object */ -); - -ivas_error ivas_ism_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data[], /* i : input signal [channels][samples] */ - const int16_t input_frame, /* i : input frame length per channel */ - int16_t *nb_bits_metadata, /* i : number of metadata bits */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const int16_t bfi, /* i : bfi flag */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ - const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ - int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ - int16_t *ism_extmeta_cnt, /* i/o: Number of change frames observed */ - DEC_CORE_HANDLE st0 /* i : core-coder handle */ -); - - -/*----------------------------------------------------------------------------------* - * Parametric ISM prototypes - *----------------------------------------------------------------------------------*/ - -/*! r: ISM format mode */ - -ivas_error ivas_param_ism_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -void ivas_param_ism_enc_close_fx( - PARAM_ISM_CONFIG_HANDLE *hParamIsm, /* i/o: ParamISM handle */ - const int32_t input_Fs /* i : input sampling_rate */ -); - -void ivas_ism_metadata_close( - ISM_METADATA_HANDLE hIsmMetaData[], /* i/o : object metadata handles */ - const int16_t first_idx /* i : index of first handle to deallocate */ -); - - -ivas_error ivas_ism_enc_config( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - - - -void ivas_param_ism_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_ism_params_to_masa_param_mapping( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -/*----------------------------------------------------------------------------------* - * ISM DTX prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_dtx_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -/*! r: indication of DTX frame */ -int16_t ivas_ism_dtx_enc( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - SCE_ENC_HANDLE hSCE[MAX_SCE], /* i/o: SCE encoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t vad_flag[MAX_NUM_OBJECTS], /* i : VAD flag */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t md_diff_flag[], /* o : metadata differential flag */ - int16_t *sid_flag /* o : indication of SID frame */ -); - -void ivas_ism_dtx_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t *nb_bits_metadata /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_enc_fx( - ISM_DTX_HANDLE hISMDTX, /* i/o: ISM DTX handle */ - const int16_t flag_noisy_speech, /* i : noisy speech flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t sid_flag, /* i : indication of SID frame */ - const int16_t md_diff_flag[], /* i : metadata differental flag */ - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - -void ivas_ism_metadata_sid_dec( - SCE_DEC_HANDLE hSCE[MAX_SCE], /* i/o: SCE decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t bfi, /* i : bfi flag */ - const int16_t nchan_ism, /* i : number of objects */ - const int16_t nchan_transport, /* i : number of transport channels */ - const ISM_MODE ism_mode, /* i : ISM mode */ - int16_t *flag_noisy_speech, /* o : noisy speech flag */ - int16_t *sce_id_dtx, /* o : SCE DTX ID */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - int16_t nb_bits_metadata[] /* o : number of metadata bits */ -); - - -void ivas_param_ism_compute_noisy_speech_flag_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - - -void update_last_metadata( - const int16_t nchan_ism, /* i : number of objects */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - const int16_t updt_flag[] /* i : last metadata update flag */ -); - -void ivas_ism_dtx_limit_noise_energy_for_near_silence( - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder structures */ - const int16_t sce_id_dtx, /* i : SCE DTX ID */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -/*----------------------------------------------------------------------------------* - * DFT Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_dft_enc_analyze( - Encoder_State **sts, /* i/o: encoder state structure */ - const int16_t n_channels, /* i : number of input channels */ - const int16_t input_frame, /* i : input frame length */ - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: encoder MDCT stereo handle */ - float DFT[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC], /* o : DFT buffers */ - float *input_mem[CPE_CHANNELS] /* i/o: input buffer memory */ -); - -float stereo_dft_enc_synthesize( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - float *output, /* o : output synthesis */ - const int16_t chan, /* i : channel number */ - const int32_t input_Fs, /* i : input sampling rate */ - const int32_t output_sampling_rate, /* i : output sampling rate */ - const int16_t L_frame /* i : frame length at internal Fs */ -); - - - - -void stereo_dtf_cng( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - const int16_t output_frame /* i : output frame size */ -); - -void stereo_dft_cng_side_gain( - STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo encoder handle */ - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t core_brate, /* i : core bitrate */ - const int32_t last_core_brate, /* i : last core bitrate */ - const int16_t bwidth /* i : audio band-width */ -); - - -void stereo_dft_dequantize_itd( - int16_t *ind, - float *out, - const int32_t output_Fs -); - - - -void stereo_dft_dec_sid_coh( - Decoder_State *st, /* i/o: decoder state structure */ - const int16_t nbands, /* i : number of DFT stereo bands */ - float *coh, /* i/o: coherence */ - int16_t *nb_bits /* i/o: number of bits read */ -); - -ivas_error stereo_dft_dec_create( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const int32_t element_brate, /* i : element bitrate */ - const int32_t output_Fs, /* i : output sampling rate */ - const int16_t sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_dft_dec_reset( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_update( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void stereo_dft_dec_destroy( - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft /* i/o: decoder DFT stereo handle */ -); - -void stereo_dft_dec_analyze( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const float *input, /* i : input signal */ - float out_DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t chan, /* i : channel number */ - const int16_t input_frame, /* i : input frame size */ - const int16_t output_frame, /* i : output frame size */ - const DFT_STEREO_DEC_ANA_TYPE ana_type, /* i : signal type to analyze */ - const int16_t k_offset, /* i : offset of DFT */ - const int16_t delay /* i : delay in samples for input signal */ -); - -void stereo_dft_dec_synthesize( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i : DFT buffers */ - const int16_t chan, /* i : channel number */ - float output[L_FRAME48k], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length */ -); - - -void stereo_dft_res_ecu( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - float *const DFT_PRED_RES, /* i/o: residual prediction signal */ - const int16_t k, /* i : Subframe index */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t prev_bfi, /* i : Previous BFI */ - const float dmx_nrg, /* i : Down-mix energy */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - float *input_mem /* o : Residual DFT buffer input mem */ -); - -void stereo_dft_res_subst_spec( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal */ - const float *const DFT_PRED_RES, /* i : residual prediction signal */ - const int16_t time_offs, /* i : Time offset for phase adjustm. */ - const int16_t L_res, /* i : bandwidth of residual signal */ - const int16_t L_ana, /* i : Length of FFT analysis */ - const int16_t k, /* i : Subframe index */ - int16_t *num_plocs, /* i/o: Number of peak locations */ - int16_t *plocs, /* i/o: Peak locations (bin) */ - float *plocsi, /* i/o: Peak locations (fractional) */ - const int16_t analysis_flag /* i : Flag for running peak analysis */ -); - -void stereo_dft_res_ecu_burst_att( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: Decoder DFT stereo handle */ - float *pDFT_RES, /* i/o: residual signal /att. residual */ - const float dmx_nrg, /* i : dmx energy of current frame */ - const int16_t L_res, /* i : Bandwidth of residual */ - const int16_t L_ana /* i : Length of FFT analysis */ -); - -/*! r: total energy of downmix with maximum swb bandwidth max */ -float stereo_dft_dmx_swb_nrg( - const float *dmx_k0, /* i : first subframe spectrum */ - const float *dmx_k1, /* i : second subframe spectrum */ - const int16_t frame_length /* i : frame lanegth */ -); - -int16_t stereo_dft_sg_recovery( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: Decoder DFT stereo handle */ -); - -void stereo_dft_dec_res( - CPE_DEC_HANDLE hCPE, /* i/o: decoder CPE handle */ - float res_buf[STEREO_DFT_N_8k], /* i : residual buffer */ - float *output /* o : output frame */ -); - -/*! r: Decision to enable or disable BPF on DFT stereo residual */ - -void bpf_pitch_coherence( - Decoder_State *st, /* i/o: decoder state structure */ - const float pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ -); - -void stereo_dft_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t output_frame, /* i : output frame length */ - float res_buf[STEREO_DFT_N_8k], /* o : residual buffer */ - int16_t *nb_bits, /* o : number of bits read */ - float *coh, /* i/o: Coherence */ - const int16_t ivas_format /* i : ivas format */ -); - -void stereo_dft_dec_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */ - const int16_t active_frame_counter, /* i : Active frame counter */ - const int32_t element_brate /* i : Element bitrate */ -); - -void stereo_dft_generate_res_pred( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const float samp_ratio, /* i : sampling ratio */ - float *pDFT_DMX, /* i : downmix signal */ - float *DFT_PRED_RES, /* o : residual prediction signal */ - float *pPredGain, /* i : residual prediction gains */ - const int16_t k, /* i : subframe index */ - float *ap_filt_DMX, /* i : enhanced stereo filling signal */ - int16_t *stop, /* o : last FD stereo filling bin */ - const int16_t bfi /* i : BFI flag */ -); - -void stereo_dft_dec_core_switching( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i : synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* o : DFT buffers */ - const int16_t output_frame, /* i : output frame length */ - const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ - const int16_t sba_dirac_stereo_dtx_flag /* i : DTX indicator for SBA DirAC stereo */ -); - -void init_basic_allpass( - basic_allpass_t *ap, /* i/o: basic allpass structure */ - const float *gains, /* i : allpass filter gains */ - const int16_t *delays /* i : allpass filter delays */ -); - -void filter_with_allpass( - const float *sig, /* i : allpass input signal */ - float *out, /* o : filtered output */ - const int16_t len, /* i : length of input */ - basic_allpass_t *ap /* i/o: basic allpass structure */ -); - -/*! r: used GR order */ - -/*! r: used GR order */ - - -/*! r: number of bits written */ - -/*! r: number of bits written */ - - -void stereo_dft_enc_compute_itd( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - float *DFT_L, - float *DFT_R, - const int16_t k_offset, - const int16_t input_frame, - const int16_t vad_flag_dtx[], - const int16_t vad_hover_flag[], - float *bin_nrgL, - float *bin_nrgR -); - -void stereo_dft_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig, /* o : DFT stereo configuration */ - const int32_t brate, /* i : IVAS/CPE/nominal total bitrate */ - int16_t *bits_frame_nominal, /* o : primary channel nominal bits per frame */ - int16_t *bits_frame_nominal_2 /* o : secondary channel nominal bits per frame*/ -); - -int16_t stereo_dft_band_config( - int16_t *band_limits, /* o : DFT band limits */ - const int16_t band_res, /* i : DFT band resolution */ - const int16_t NFFT, /* i : analysis/synthesis window length */ - const int16_t enc_dec /* i : flag to indicate enc vs dec */ -); - -void stereo_dft_dmx_out_reset( - STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx /* i/o: DFT stereo DMX decoder */ -); - -void stereo_dft_unify_dmx( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder stereo handle */ - Decoder_State *st0, /* i/o: decoder state structure */ - float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX], /* i/o: DFT buffers */ - float *input_mem, /* i/o: mem of buffer DFT analysis */ - const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ -); - -void add_HB_to_mono_dmx( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output[L_FRAME48k], /* i/o: output synthesis */ - float outputHB[L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t output_frame /* i : frame length */ -); - -/*----------------------------------------------------------------------------------* - * Range Coder prototypes - *----------------------------------------------------------------------------------*/ - -void rc_uni_dec_init( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - uint16_t *bit_buffer, /* i : Bit buffer */ - const int16_t max_available_bits /* i : Total maximum bits available */ -); - -/*! r: Read symbol */ -uint16_t rc_uni_dec_read_symbol_fastS( - RangeUniDecState *rc_st_dec, /* i/o: Decoder State */ - const uint16_t cum_freq_table[], /* i : Cumulative frequency up to symbol */ - const uint16_t sym_freq_table[], /* i : Symbol frequency */ - const uint16_t alphabet_size, /* i : Number of symbols in the alphabet */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Read bit */ -uint16_t rc_uni_dec_read_bit_prob_fast( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t freq0, /* i : Frequency for symbol 0 */ - const uint16_t tot_shift /* i : Total frequency as a power of 2 */ -); - -/*! r: Read bits */ -uint16_t rc_uni_dec_read_bits( - RangeUniDecState *rc_st_dec, /* i/o: RC state handle */ - const int16_t bits /* i : Number of bits */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_virtual_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - -/*! r: Total number of bits consumed */ -int16_t rc_uni_dec_finish( - RangeUniDecState *rc_st_dec /* i/o: RC state handle */ -); - - -/*----------------------------------------------------------------------------------* - * ECLVQ Stereo prototypes - *----------------------------------------------------------------------------------*/ - -float ECSQ_dequantize_gain( - const int16_t index -); - - - -void ECSQ_init_instance( - ECSQ_instance *ecsq_inst, - const int16_t config_index, - void *ac_handle -); - - - -void ECSQ_dequantize_vector( - const int16_t *input, - const float global_gain, - const int16_t N, - float *output -); - - -/*----------------------------------------------------------------------------------* - * ICA Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_tca_init_enc( - STEREO_TCA_ENC_HANDLE hStereoTCA, /* i/o: Stereo TCA encoder handle */ - const int32_t input_Fs /* i : input sampling frequency */ -); - -void stereo_tca_enc( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t input_frame /* i : length of a frame per channel */ -); - -void stereo_tca_init_dec( - STEREO_TCA_DEC_HANDLE hStereoTCA /* i/o: Stereo TCA handle */ -); - -void stereo_tca_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synth[CPE_CHANNELS], /* i/o: output synth */ - const int16_t output_frame /* i : length of a frame per channel */ -); - -void stereo_tca_scale_R_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output, /* i/o: output synthesis, R channel */ - const int16_t output_frame /* i : frame length */ -); - -void adjustTargetSignal( - float *target, - const int16_t prevShift, - const int16_t currShift, - const int16_t L_shift_adapt, - const int16_t method -); - -/*----------------------------------------------------------------------------------* - * IC-BWE Stereo prototypes - *----------------------------------------------------------------------------------*/ - - -void stereo_icBWE_preproc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t input_frame, /* i : input frame length */ - float shb_speech_nonref[] /* o : SHB speech non-ref channel */ -); - -void stereo_icBWE_enc( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const float shb_speech_ref[], /* i : SHB speech ref channel */ - float shb_speech_nonref[], /* i/o: SHB speech non-ref channel */ - const float *voice_factors /* i : voicing factors */ -); - -void stereo_icBWE_init_dec( - STEREO_ICBWE_DEC_HANDLE hStereoICBWE /* i/o: Stereo inter-channel BWE handle */ -); - -void stereo_icBWE_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *synthRef, /* i/o: Reference channel HB synthesis at output Fs */ - float *synth, /* o : Non reference channel HB synthesis at output Fs */ - const float *fb_synth_ref, /* i : ref. high-band synthesis 16-20 kHz */ - const float *voice_factors, /* i : voicing factors */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_icBWE_decproc( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i/o: output symthesis */ - float outputHB[CPE_CHANNELS][L_FRAME48k], /* i : HB synthesis */ - const int16_t last_core, /* i : last core, primary channel */ - const int16_t last_bwidth, /* i : last bandwidth */ - const int16_t output_frame /* i : frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo classifiers prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_classifier_features( - STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure */ - const int16_t idchan, /* i : channel ID */ - const int16_t element_mode, /* i : element mode */ - const int16_t vad_flag, /* i : VAD flag */ - const float lsf_new[], /* i : LSFs at the end of the frame */ - const float epsP[], /* i : LP analysis residual energies for each iteration*/ - const int16_t pitch[], /* i : open-loop pitch values for quantiz. */ - const float voicing[], /* i : OL maximum normalized correlation */ - const float cor_map_sum, /* i : speech/music clasif. parameter */ - const float non_staX, /* i : unbound non-stationarity for sp/mu clas. */ - const float sp_div, /* i : spectral diversity feature */ - const int16_t clas /* i : signal class */ -); - - -void xtalk_classifier_dft( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t itd, /* i : ITD from DFT stereo - used as a feature */ - const float gcc_phat[] /* i : GPHAT cross-channel correlation function */ -); - -/*----------------------------------------------------------------------------------* - * TD Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_init_enc( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i/o: TD stereo encoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - - - -void stereo_tdm_downmix( - STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i : TD stereo IVAS encoder structure */ - float *Left_in, /* i/o: Left channel -> Primary channel */ - float *Right_in, /* i/o: Right channel -> Secondary channel */ - const int16_t input_frame, /* i : Number of samples */ - const int16_t tdm_ratio_idx, /* i : TDM ratio index */ - const int16_t tdm_SM_flag, /* i : channel combination scheme flag */ - const int16_t tdm_ratio_idx_SM /* i : TDM ratio index for SM mode */ -); - -void stereo_td_init_dec( - STEREO_TD_DEC_DATA_HANDLE hStereoTD, /* i/o: TD stereo decoder handle */ - const int16_t last_element_mode /* i : last element mode */ -); - -void tdm_configure_dec( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t *tdm_ratio_idx, /* o : ratio index */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void tdm_upmix_plain( - float Left[], /* o : left channel */ - float Right[], /* o : right channel */ - const float PCh_2_L[], /* i : primary channel */ - const float SCh_2_R[], /* i : secondary channel */ - const float LR_ratio, /* i : mixing ratio */ - const float inv_den_LR_ratio, /* i : inverse mixing ration */ - const int16_t start_index, /* i : start index */ - const int16_t end_index, /* i : end index */ - const int16_t plus_minus_flag /* i : plus/minus flag */ -); - -void stereo_tdm_combine( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *PCh_2_L, /* i/o: Primary channel -> output as L channel */ - float *SCh_2_R, /* i/o: Seconday channel -> output as R channel */ - const int16_t output_frame, /* i : Number of samples */ - const int16_t flag_HB, /* i : flag to distinguish between core (0) and HB (1) synthesis */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -/*! r: replication decision; 1 = Use old LP */ -void tdm_ol_pitch_comparison( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - float pitch_fr[CPE_CHANNELS][NB_SUBFR], /* i/o: fractional pitch values */ - float voicing_fr[CPE_CHANNELS][NB_SUBFR] /* i/o: fractional pitch gains */ -); - -void tdm_configure_enc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const float Etot_last[CPE_CHANNELS], /* i/o: Energy of last frame */ - const int16_t tdm_SM_or_LRTD_Pri, /* i : channel combination scheme flag in TD stereo OR LRTD primary channel */ - const int16_t tdm_ratio_idx, /* i : ratio index */ - const int16_t tdm_ratio_idx_SM, /* i : ratio index in SM mode */ - const int16_t attack_flag, /* i : Primary channel attack flag */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - - -void tdm_bit_alloc( - const int16_t ivas_format, /* i : IVAS format */ - const int16_t ism_mode, /* i : ISM mode in combined format */ - const int32_t element_brate_wo_meta, /* i : element bitrate without metadata */ - const int16_t tdm_lp_reuse_flag, /* i : LPC reusage flag */ - int32_t *total_brate_pri, /* o : Allocated primary channel bitrate */ - int32_t *total_brate_sec, /* o : Allocated secondary channel bitrate */ - int16_t *tdm_low_rate_mode, /* o : secondary channel low rate mode flag */ - const int16_t coder_type, /* i : secondary channel coder type */ - const int16_t ener_ratio_idx, /* i : correlation ratio indexe */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const int16_t bwidth_pri, /* i : bandwidth of the primary channel */ - const int16_t bwidth_sec, /* i : bandwidth of the secondary channel */ - const int16_t flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. */ - const int16_t tdm_LRTD_flag, /* i : LRTD stereo mode flag */ - const int16_t coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) */ - const int16_t tdm_inst_ratio_idx /* i : instantaneous correlation ratio index */ -); - - -/*! r: value of the indice */ -uint16_t get_indice_st( - Decoder_State *st, /* i/o: decoder state structure */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t pos, /* i : absolute position in the bitstream */ - const int16_t nb_bits /* i : number of bits to quantize the indice */ -); - -void tdm_low_rate_dec( - Decoder_State *st, /* i/o: decoder static memory */ - float dct_epit[], /* o : GSC excitation in DCT domain */ - float *tmp_noise, /* o : long term temporary noise energy */ - float *pitch_buf, /* o : floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *exc, /* i/o: adapt. excitation exc */ - float *exc2, /* i/o: adapt. excitation/total exc */ - float *bwe_exc, /* o : excitation for SWB TBE */ - const float *lsf_new /* i : ISFs at the end of the frame */ -); - -void tdm_SCh_LSF_intra_pred( - const int32_t element_brate, /* i : element bitrate */ - const float *tdm_lsfQ_PCh, /* i : primary channel LSFs */ - float *pred_lsf_SCh /* o : predicted secondary channel LSFs */ -); - - -void first_VQstages( - const float *const *cb, - const float u[], /* i : vector to be encoded (prediction and mean removed) */ - const int16_t *levels, /* i : number of levels in each stage */ - const int16_t stagesVQ, /* i : number of stages */ - const float w[], /* i : weights */ - const int16_t N, /* i : vector dimension */ - const int16_t max_inner, /* i : maximum number of swaps in inner loop */ - int16_t indices_VQstage[] -); - - -void deindex_lvq_SHB( - UWord32 index, - float *out, - const int16_t nbits, - const int16_t mode -); - -/*----------------------------------------------------------------------------------* - * MDCT Stereo prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ - const int16_t vad_hover_flag[], /* i : VAD hangover flags */ - const int16_t input_frame /* i : frame length */ -); - -void QuantizeTCXSpectrum( - Encoder_State *st, /* i : state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const float *x_orig, /* i : shaped MDCT spectrum */ - const float *gainlpc, /* i : FDNS gains */ - const Word16 *Aqind, /* i : frame-independent quantized coefficients (M+1) */ - const int16_t tnsSize, /* i : number of tns parameters put into prm */ - const int16_t nb_bits, /* i : bit budget */ - const int16_t vad_hover_flag, /* i : VAD hangover flag */ - int16_t *pL_frameTCX, /* o : full frame length */ - int16_t *pL_frame, /* o : frame length */ - int16_t *pL_spec, /* o : length of the coded spectrum */ - int16_t *ptcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *pnoiseFillingBorder, /* o : noise filling border */ - float spectrum[], /* o : quantized MDCT spectrum */ - CONTEXT_HM_CONFIG *hm_cfg, /* o : Context-based harmonic model configuration */ - int16_t *hm_active, /* o : flag indicating if the harmonic model is active */ - float lf_deemph_fact[], /* o : low frequency deemphasis factors */ - int16_t *nf_seed, /* o : noise filling random seed */ - float *ener, /* o : energy of the quantized spectrum */ - float *gain_tcx, /* o : global gain */ - int16_t prm[] /* o : tcx parameters */ -); - -void EstimateStereoTCXNoiseLevel( - Encoder_State **sts, /* i : state handle */ - float *q_spectrum[CPE_CHANNELS][NB_DIV], /* i : quantized MDCT spectrum */ - float gain_tcx[][NB_DIV], /* i : global gain */ - int16_t L_frame[][NB_DIV], /* i : frame length */ - int16_t noiseFillingBorder[][NB_DIV], /* i : noise filling border */ - int16_t hm_active[][NB_DIV], /* i : flag indicating if the harmonic model is active */ - const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */ - float fac_ns[][NB_DIV], /* o : noise filling level */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void TNSAnalysisStereo( - Encoder_State **sts, /* i : state handle */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* o : MDST spectrum */ - const int16_t bWhitenedDomain, /* i : whitened domain flag */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */ - int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void InternalTCXDecoder( - Encoder_State *st, /* i/o: state handle */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t L_frameTCX, /* i : full frame length */ - const int16_t L_frame, /* i : frame length */ - const int16_t L_spec, /* i : length of the coded spectrum */ - const int16_t tcx_offset, /* i : folding point offset relative to the end of the previous frame */ - const int16_t noiseFillingBorder, /* i : noise filling border */ - const float *x_quant, /* i : quantized spectrum */ - const float ener, /* i : energy of the quantized spectrum */ - float lf_deemph_fact[], /* i/o: low frequency deemphasis factors */ - const float fac_ns, /* i : noise filling level */ - const int16_t nf_seed, /* i : noise filling random seed */ - const float *A, /* i : LPC representation of the FDNS gains */ - float *gainlpc, /* i/o: FDNS gains */ - const int16_t hm_active, /* i : flag indicating if the harmonic model is active */ - float gain_tcx, /* i/o: global gain / quantized global gain */ - float spectrum[], /* o : dequantized spectrum */ - float synth[], /* o : time domain signal */ - int16_t *gain_tcx_q /* o : quantized global gain (at low bitrates) */ -); - -void stereo_mdct_core_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples[CPE_CHANNELS][L_INP], /* i : new samples Q0*/ - Word16 old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP Qx*/ - Word16 pitch_buf_fx[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe Q6*/ -); - -void initMdctStereoEncData( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int16_t element_mode, /* i : element mode */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth, /* i : bandwidth */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - const int16_t mem_init /* i : initialize memory after malloc */ -); - -ivas_error initMdctItdHandling( - STEREO_MDCT_ENC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void stereo_mdct_enc_destroy( - STEREO_MDCT_ENC_DATA_HANDLE *hStereoMdct /* i/o: encoder MDCT stereo handle */ -); - -void initMdctStereoDecData( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */ - const int16_t igf, /* i : flag indicating IGF activity */ - const H_IGF_GRID igfGrid, /* i : IGF grid configuration */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void stereo_mdct_init_bands( - const int16_t L_frame, /* i : frame length */ - const int16_t tmp_tcx_mode, /* i : tcx mode (TCX10, TCX 20), -1 if transition frame */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t igf, /* i : flag indicating if IGF is used */ - const H_IGF_GRID hIgfGrid, /* i : IGF grid setup */ - int16_t *sfbOffset, /* o : sfb offset table */ - int16_t *sfbCnt /* o : number of sfbs */ -); - -void stereo_mdct_init_igf_start_band( - STEREO_MDCT_BAND_PARAMETERS *stbParams, /* i/o: stereo frequency band parameters */ - const float transFac, /* i : transform factor */ - const int16_t bwidth, /* i : audio bandwidth */ - const int32_t element_brate /* i : element bitrate */ -); - -void init_tcx_enc_info( - Encoder_State *st, /* i : coder memory state */ - int16_t *L_frame, - int16_t *L_frameTCX, - int16_t *L_spec -); - -void decoder_tcx_invQ( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1] */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - float xn_buf[], - int16_t *fUseTns, /* o : flag that is set if TNS data is present */ - STnsData *tnsData, - float *gain_tcx, - const int16_t **prm_sqQ, - int16_t *nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noisefilling( - Decoder_State *st, /* i/o: coder memory state */ - float concealment_noise[L_FRAME48k], - const float A[], /* i : coefficients NxAz[M+1] */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[], - float gainlpc2[], - int16_t *temp_concealment_method, - const float gain_tcx, - const int16_t *prm_sqQ, - int16_t nf_seed, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t frame_cnt /* i : frame counter in the super frame */ -); - -void decoder_tcx_noiseshaping_igf( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[], - const float gainlpc2[], - int16_t *temp_concealment_method, - const int16_t bfi /* i : Bad frame indicator */ -); - -void decoder_tcx_tns( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, - const int16_t L_spec, - const int16_t L_frame, - const int16_t L_frameTCX, - float x[N_MAX], - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - STnsData *tnsData, - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t whitenedDomain -); - -void decoder_tcx_imdct( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : frame length */ - const int16_t L_frameTCX_glob, - const int16_t L_spec, - const int16_t tcx_offset, - const int16_t tcx_offsetFB, - const int16_t L_frame, - const int16_t L_frameTCX, - const int16_t left_rect, - float x[N_MAX], - float xn_buf[], - const uint16_t kernelType, /* i : TCX transform kernel type */ - const int16_t fUseTns, /* i : flag that is set if TNS data is present */ - float synth[], /* i/o: synth[-M..L_frame] */ - float synthFB[], - const int16_t bfi, /* i : Bad frame indicator */ - const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -); - -void init_tcx_info( - Decoder_State *st, /* i/o: coder memory state */ - const int16_t L_frame_glob, /* i : global frame length */ - const int16_t L_frameTCX_glob, /* i : FB global frame length */ - const int16_t frame_cnt, /* i : frame counter in the super_frame */ - const int16_t bfi, /* i : bad frame indicator */ - int16_t *tcx_offset, /* o : folding point offset relative to the end of the previous frame */ - int16_t *tcx_offsetFB, /* o : FB folding point offset relative to the end of the previous frame*/ - int16_t *L_frame, /* o : frame length */ - int16_t *L_frameTCX, /* o : TCX frame length */ - int16_t *left_rect, /* o : left part is rectangular */ - int16_t *L_spec /* o : spectrum length */ -); - -void decoder_tcx_IGF_mono( - Decoder_State *st, /* i/o: coder memory state */ - float x[], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t frame_cnt /* i : frame counter in the super_frame */ -); - -void decoder_tcx_IGF_stereo( - Decoder_State **sts, /* i/o: coder memory states */ - STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *x[CPE_CHANNELS][NB_DIV], /* o : de-quatized coefficients */ - const int16_t L_frame, /* i : frame length */ - const int16_t left_rect, /* i : left part is rectangular */ - const int16_t k, /* i : Subframe index */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ms_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - float x_0[], /* i/o: spectrum 1 */ - float x_1[], /* i/o: spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void ms_inv_mask_processing( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - const int16_t iSubframe, /* i : subframe number */ - const float x_0[], /* i : spectrum 1 */ - const float x_1[], /* i : spectrum 2 */ - float x_inv_0[], /* o : inverse spectrum 1 */ - float x_inv_1[], /* o : inverse spectrum 2 */ - int16_t maxSfb /* i : number of stereo frequency bands */ -); - -void IGFDecApplyStereo_flt( - const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i : instance handle of IGF Decoder */ - const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i : instance handle of IGF Decoder */ - float *spectrumL, /* i/o: L MDCT spectrum */ - float *spectrumR, /* i/o: R MDCT spectrum */ - const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */ - const int16_t *coreMsMask, - const int16_t restrict_hopsize, - const int16_t bfi, /* i : frame loss == 1, frame good == 0 */ - const int16_t bfi_apply_damping /* i : decoder element mode */ -); - -void IGFEncStereoEncoder( - STEREO_MDCT_BAND_PARAMETERS *sfbParam, /* i/o: sfb parameters for the right channel */ - const IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i : IGF handle */ - const float *mdctSpectrumL, /* i : left spectrum */ - const float *mdctSpectrumR, /* i : right spectrum */ - int16_t *msMask, /* i/o: MS mask */ - int16_t *igfStereoMode, /* o : IGF stereo mode */ - const int16_t mdct_stereo_mode, /* i : MDCT stereo mode */ - const int16_t isTCX20, /* i : flag for indicating TCX20 */ - const int16_t isTransition /* i : flag for transtition */ -); - -void IGFDecReplicateTCX10State_flt( - IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder */ -); - - -void InitPsychLPC( - const int32_t sr_core, /* i : sampling rate of core-coder */ - const int16_t L_frame, /* i : frame length */ - const TCX_CONFIG_HANDLE hTcxCfg /* i : TCX configuration handle */ -); - - -void stereo_coder_tcx( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ -); - -void stereo_decoder_tcx( - STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: MDCT stereo decoder structure */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask */ - float *spec_r_0[NB_DIV], /* i/o: spectrum right channel */ - float *spec_l[], /* i/o: spectrum left channel [NB_DIV][N] */ - float *spec_r[], /* i/o: spectrum right channel [NB_DIV][N] */ - const int16_t mdct_stereo_mode[], /* i : stereo mode (FB/band wise MS, dual mono */ - const int16_t core_l, /* i : core for left channel (TCX20/TCX10) */ - const int16_t core_r, /* i : core for right channel (TCX20/TCX10) */ - const int16_t igf, /* i : flag for IGF activity */ - const int16_t L_frameTCX_l, /* i : TCX frame length of left channel */ - const int16_t L_frameTCX_r, /* i : TCX frame length of right channel */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t last_core_l, /* i : last core for left channel */ - const int16_t last_core_r, /* i : last core for right channel */ - const int16_t tmp_plc_upmix /* i : indicates temp upmix for PLC decision */ -); - -void stereo_mdct_core_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *signal_out[CPE_CHANNELS], /* o : synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME48k] /* o : synthesis @output_FS */ -); - -void splitAvailableBits( - const int16_t total_bits, /* i : total available bits for TCX coding */ - const int16_t split_ratio, /* i : split ratio */ - const int16_t isSBAStereoMode, /* i : signal core coding for SBA */ - int16_t *bits_ch0, /* o : bits for channel 0 */ - int16_t *bits_ch1 /* o : bits for channel 1 */ -); - -Word16 write_stereo_to_bitstream_fx -( - STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: Stereo MDCT encoder structure */ - Encoder_State **sts, /* i/o: Encoder state structure */ - Word16 ms_mask[NB_DIV][MAX_SFB], /* i : bandwise MS mask Q0*/ - const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - - - -void ComputeSpectrumNoiseMeasure( - const float *powerSpec, - const int16_t L_frame, - const int16_t startLine, - const int16_t resetMemory, - int8_t *noiseFlags, - const int16_t lowpassLine -); - -void IGFSaveSpectrumForITF( - IGF_ENC_INSTANCE_HANDLE hIGFEnc, /* i/o: instance handle of IGF Encoder */ - const int16_t igfGridIdx, /* i : IGF grid index */ - const float *pITFSpectrum /* i : MDCT spectrum */ -); - -void convert_coeffs_to_higher_res( - const float *in1, /* i : first subframe input */ - const float *in2, /* i : second subframe input */ - float *out, /* o : converted output */ - const int16_t len /* i : length of subframes */ -); - -int16_t quantize_sns( - float sns_in[CPE_CHANNELS][NB_DIV][M], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Encoder_State **sts, - int16_t *indices, - int16_t *zero_side_flag, - int16_t *sns_stereo_mode -); - -void dequantize_sns( - int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], - float snsQ_out[CPE_CHANNELS][NB_DIV][M], - Decoder_State **sts -); - -void sns_avq_dec( - int16_t *index, /* i : Quantization indices */ - float SNS_Q[NB_DIV][M], /* o : Quantized SNS vectors */ - const int16_t L_frame, /* i : frame length */ - const int16_t numlpc /* i : Number of sets of lpc */ -); - -void sns_avq_dec_stereo( - int16_t *indexl, /* i : Quantization indices (left channel) */ - int16_t *indexr, /* i : Quantization indices (right channe) */ - const int16_t L_frame, /* i : frame length */ - float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ - float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ -); - -void convertToMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void inverseMS( - const int16_t L_frame, /* i : frame length */ - float x0[], /* i/o: mid/left channel coefficients */ - float x1[], /* i/o: side/right channel coefficients */ - const float norm_fac /* i : normalization factor */ -); - -void stereoFdCngCoherence( - Encoder_State **sts, /* i/o: core encoder structures */ - const int16_t last_element_mode, /* i : last element mode */ - float fft_buff[CPE_CHANNELS][2 * L_FFT] /* i : fft buffers for L and R channels */ -); - -void FdCngEncodeMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - -ivas_error initMdctStereoDtxData( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder handle */ -); - -void synchonize_channels_mdct_sid( - Decoder_State *sts[CPE_CHANNELS], /* i/o: decoder state structure */ - const int16_t n /* i : channel number */ -); - -void updateBuffersForDmxMdctStereo( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - const int16_t output_frame, /* i : output frame length */ - float *output[CPE_CHANNELS], /* i/o: decoder output */ - float synth[CPE_CHANNELS][L_FRAME48k] /* i/o: decoder synthesis */ -); - -void applyDmxMdctStereo( - const CPE_DEC_HANDLE hCPE, /* i : CPE handle */ - float *output[CPE_CHANNELS], /* o : output from core decoder */ - const int16_t output_frame /* i : output frame length */ -); - -/*----------------------------------------------------------------------------------* - * Front-VAD prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error front_vad_create( - FRONT_VAD_ENC_HANDLE *hFrontVad, /* i/o: front-VAD handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -void front_vad_destroy( - FRONT_VAD_ENC_HANDLE *hFrontVad /* i/o: front-VAD handle */ -); - -ivas_error front_vad( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure, nullable */ - Encoder_State *st, /* i/o: encoder state structure */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: front-VAD handles */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t input_frame, /* i : frame length */ - int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */ - float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */ - float Etot_LR[], /* o : total energy Left & Right channel */ - float lf_E[][2 * VOIC_BINS], /* i : per bin spectrum energy in lf, LR channels */ - int16_t localVAD_HE_SAD[], /* o : HE-SAD flag without hangover, LR channels */ - int16_t vad_hover_flag[], /* o : VAD hangover flag */ - float band_energies_LR[2 * NB_BANDS], /* o : energy in critical bands without minimum noise floor E_MIN */ - float *PS_out, /* o : energy spectrum */ - float *Bin_E_out /* o : log-energy spectrum of the current frame*/ -); - -ivas_error front_vad_spar( - SPAR_ENC_HANDLE hSpar, /* i/o: SPAR encoder structure */ - const float *omni_in, /* i : omnidirectional input signal */ - ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : encoder configuration handle */ - const int16_t input_frame /* i : input frame length */ -); - - -/*----------------------------------------------------------------------------------* - * Stereo CNG prototypes - *----------------------------------------------------------------------------------*/ - -void stereo_enc_cng_init( - STEREO_CNG_ENC_HANDLE hStereoCng /* i/o: stereo CNG encoder structure */ -); - -void stereo_cng_upd_counters( - STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure */ - const int32_t element_mode, /* i : element mode */ - const int16_t nbands, /* i : Number of bands in active */ - const float sidSideGain[], /* i : SID side gains */ - const int16_t burst_ho_count, /* i : Hang-over count */ - int16_t *coh_fade_counter /* i : Coherence fade counter */ -); - -void stereo_cng_init_dec( - STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ - const int16_t *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */ -); - -void stereo_cng_compute_PScorr( - float *output[CPE_CHANNELS], /* i : Output signal */ - float *c_PS_LT, /* i/o: Correlation */ - const int16_t L_frame_0, /* i : L_frame channel 0 */ - const int16_t L_frame_1 /* i : L_frame channel 1 */ -); - -void stereo_cng_dec_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int32_t ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_cna_update_params( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *output[CPE_CHANNELS], /* i : Output signal */ - const int16_t output_frame, /* i : Output frame length */ - const int16_t tdm_ratio_idx /* i : TDM ratio index */ -); - -void dtx_enc_init( - Encoder_State *st, /* i : Encoder state handle */ - const int16_t var_SID_rate_flag, /* i : flag for variable SID update rate */ - const int16_t interval_SID /* i : interval for SID update */ -); - - -/*----------------------------------------------------------------------------------* - * Framework general prototypes - *----------------------------------------------------------------------------------*/ - -void mvc2c( - const uint8_t x[], /* i : input vector */ - uint8_t y[], /* o : output vector */ - const int16_t n /* i : vector size */ -); - -/*! r: Adjusted value */ -ivas_error stereo_memory_dec( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - CPE_DEC_HANDLE hCPE, /* i : CPE decoder structure */ - const int16_t nb_bits_metadata, /* i : number of metadata bits */ - const int32_t output_Fs, /* i : output sampling rate */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const MC_MODE mc_mode, /* i : MC mode */ - const int16_t nchan_transport /* i : number of transport channels */ -); - -void stereo_switching_dec( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const Word32 ivas_total_brate /* i : IVAS total bitrate Q0*/ -); - -void stereo_td2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - const int16_t n, /* i : channel number */ - float output[], /* i/o: synthesis @internal Fs */ - float synth[], /* i/o: synthesis @output Fs */ - float hb_synth[], /* i/o: hb synthesis */ - const int16_t output_frame /* i : frame length */ -); - -void stereo_mdct2dft_update( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float output0[], /* i/o: synthesis @internal Fs, ch0 */ - float synth0[] /* i/o: synthesis @output Fs, ch0 */ -); - - -/*! r: number of bits written */ - - - -/*----------------------------------------------------------------------------------* - * MCT prototypes - *----------------------------------------------------------------------------------*/ -void ivas_mdct_core_whitening_enc_fx( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - Word16 new_samples_fx[CPE_CHANNELS][L_INP], /* i : new samples */ - Word16 old_wsp_fx[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ - Word16 pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */ - Word32 *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */ - Word32 *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t nChannels, /* i : total number of coded channels */ -Word16 mdst_spectrum_e[CPE_CHANNELS][NB_DIV], -Word16 orig_spectrum_e[CPE_CHANNELS][NB_DIV] -); -void ivas_mct_core_enc( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - CPE_ENC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE encoder structures */ - const int16_t nChannels, /* i : number of channels to be coded */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits, /* i : bits spent for LFE */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -); - -void ivas_mdct_quant_coder( - CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */ - int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */ - int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void apply_MCT_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ - float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t nchan /* i : number of channels */ -); - -void write_mct_bitstream( - Encoder_State **sts, /* i/o: encoder state structure */ - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - const int16_t nchan /* i : number of channels */ -); - -void splitAvailableBitsMCT_fx( - void **sts, /* i/o: encoder/decoder state structure */ - const Word16 total_bits, /* i : total number of available bits */ - const Word16 split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits Q0 */ - const Word16 enc_dec, /* i : encoder or decoder flag */ - const Word16 nchan /* i : number of channels */ -); - -void getChannelEnergies( - Encoder_State **sts, /* i : Encoder state structure */ - float nrg[MCT_MAX_CHANNELS], /* o : energies */ - const int16_t nchan /* i : number of channels */ -); - -void mctStereoIGF_enc( - MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */ - Encoder_State **sts, /* i/o: encoder state structure */ - float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */ - float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */ - float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */ - float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */ - const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */ -); - -void ivas_mdct_dec_side_bits_frame_channel( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */ - Decoder_State *st0, /* i : pointer to bitstream handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */ - const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ - const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */ -); - -void ivas_mct_side_bits( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */ - const int16_t nCPE, /* i : number of CPEs */ - Decoder_State *st0, /* i : decoder handle for Bstr */ - const int16_t bfi, /* i : BFI flag */ - uint16_t *bitstream, /* o : bitstream indices */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nb_bits_metadata /* i : number of metadata bits */ -); - -void ivas_mdct_core_invQ( - CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */ - int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */ - int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */ - int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */ - int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */ - float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */ - int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_reconstruct( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */ - float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - -void ivas_mdct_core_tns_ns( - CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */ - int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */ - STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */ - float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */ - float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */ - const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */ -); - - -void ivas_mct_dec_mct( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - const int16_t nchan /* i : number of channels */ -); - -void apply_MCT_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */ -); - -void mctStereoIGF_dec( - MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */ - Decoder_State **sts, /* i/o: decoder state structure */ - float *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequantized spectrum */ - const int16_t bfi /* i : bad frame flag */ -); - -void enc_prm_igf_mdct( - Encoder_State *st, /* i : Encoder state handle */ - BSTR_ENC_HANDLE hBstr /* i/o: Bitstream handle */ -); - -void mdct_read_IGF_bits( - Decoder_State *st, /* i/o: Encoder state handle */ - Decoder_State *st0 /* i : pointer to handle where bstr is read */ -); - - -/*----------------------------------------------------------------------------------* - * Q Metadata prototypes for DirAC and MASA - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_qmetadata_enc_encode( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: q_metadata handle */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -ivas_error ivas_qmetadata_enc_encode_hr_384_512( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData, /* i/o: metadata handle */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh -); - -void deindex_sph_idx( - const uint16_t sphIndex, /* i : Spherical index */ - const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ - float *theta, /* o : Elevation */ - float *phi /* o : Azimuth */ -); - -/*! r: output index for direction */ -uint16_t index_theta_phi_16( - float * p_theta, /* i/o: input elevation to be indexed */ - float * p_phi, /* i/o: input azimuth to be indexed */ - const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ -); - -void reset_metadata_spatial( - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - const int32_t element_brate, /* i : element bitrate */ - int32_t *total_brate, /* o : total bitrate */ - const int32_t core_brate, /* i : core bitrate */ - const int16_t nb_bits_metadata /* i : number of meatdata bits */ -); - -/*! r: number of bits written */ - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode_hr_384_512( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh, - const uint8_t ncoding_bands_config -); - -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_sid_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const int16_t nchan_transport, /* i : number of transport channels */ - int16_t *element_mode, /* o : element mode */ - const int16_t ivas_format /* i : IVAS format */ -); - - - - -void restore_metadata_buffer( - BSTR_ENC_HANDLE hMetaData, - const int16_t next_ind_start, - const int16_t bit_pos_start -); - -/*! r: codeword index */ -int16_t masa_sq( - const float in, /* i : input value */ - const float *threshold, /* i : partition */ - const int16_t cb_sz /* i : codebook size */ -); - -void ivas_qmetadata_azimuth_elevation_to_direction_vector( - const float az, /* i : azimuth */ - const float el, /* i : elevation */ - float *dv /* o : direction vector */ -); - -ivas_error only_reduce_bits_direction( - int16_t *reduce_bits_out, - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - int16_t reduce_bits, - const int16_t coding_subbands, - const int16_t no_subframes, - int16_t *ind_order -); - -void quantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding*/ -); - -/*! r: quantized spherical index */ -uint16_t quantize_direction( - const float theta, /* i : input elevation value */ - float phi, /* i : input azimuth value */ - const int16_t no_bits, /* i : number of bits */ - float *theta_q, /* o : quantized elevation */ - float *phi_q, /* o : quantized azimuth */ - uint16_t *index_theta, /* o : quantized elevation index */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -int16_t quantize_direction2D( - float phi, /* i : input azimuth value */ - const int16_t no_cw, /* i : number of bits */ - float *phi_q, /* o : quantized azimuth value */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -void quantize_direction_frame2D( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] /* i : input elevation values */ -); - -void small_requantize_direction_frame( - IVAS_QDIRECTION *q_direction, /* i/o: quantized direction structure */ - float azimuth_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input azimuth values */ - float elevation_orig[MASA_MAXIMUM_CODING_SUBBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], /* i : input elevation values */ - const int16_t raw_flag[MASA_MAXIMUM_CODING_SUBBANDS], /* i : raw/EC encoding mode for each subband */ - int16_t bits_dir_bands[MASA_MAXIMUM_CODING_SUBBANDS], /* i/o: number of bits per subband */ - int16_t *diff /* i/o: number of bits to be reduced */ -); - -/*! r: index azimuth */ -int16_t quantize_phi( - float phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - float *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ -); - -/*! r: decoded elevation value */ -float deindex_elevation( - uint16_t *id_th, /* i : input index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -float deindex_azimuth( - int16_t id_phi, /* i : index */ - const int16_t no_bits, /* i : number of bits for the spherical grid */ - const int16_t id_th, /* i : elevation index */ - const int16_t remap, /* i : remapping flag */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ -); - -UWord16 ivas_qmetadata_reorder_generic_fx( - const Word16 signed_value -); - -void ivas_sba_config( - const int32_t sba_total_brate, /* i : SBA total bitrate */ - int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t nb_channels, /* i : Number of Ambisonic (SBA) channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - const int16_t sba_planar, /* i : SBA planar flag */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int16_t *element_mode /* o : element mode of the core coder */ -); - -void ivas_sba_set_cna_cng_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_sba_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesFlushed, /* o : number of samples flushed */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ -); - - - -/*! r: Ambisonic (SBA) order */ -int16_t ivas_sba_get_order( - const int16_t nb_channels, /* i : Number of ambisonic channels */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of Ambisonic channels */ -int16_t ivas_sba_get_nchan( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t sba_planar /* i : SBA planar flag */ -); - -/*! r: number of ambisonics metadata channels */ - -void ivas_sba_getTCs( - float *sba_data[], /* i : SBA signals */ - Encoder_Struct *st_ivas, /* i/o: Encoder struct */ - const int16_t input_frame /* i : frame length */ -); - -int16_t ivas_sba_remapTCs( - float *sba_data[], /* i/o: SBA signals */ - Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const int16_t output_frame /* i : frame length */ -); - -void ivas_sba_dirac_stereo_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[CPE_CHANNELS], /* o : output synthesis signal */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t mcmasa /* i : McMASA flag */ -); - -void ivas_sba_dirac_stereo_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ -); - - -Word16 ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_sba_dirac_stereo_smooth_parameters( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - const int16_t cross_fade_start_offset, /* i : SPAR mixer delay compensation */ - const int32_t output_Fs, /* i : Fs for delay calculation */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - - -/*----------------------------------------------------------------------------------* - * DirAC prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_dirac_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - - - -ivas_error ivas_dirac_config( - void *st_ivas, /* i/o: IVAS encoder/decoder state structure */ - const int16_t enc_dec /* i : encoder or decoder flag */ -); - -void ivas_dirac_config_bands( - int16_t *band_grouping, /* o : band grouping */ - const int16_t nbands, /* i : number of bands */ - const int16_t max_band, /* i : maximal band index +1 */ - int16_t *dirac_to_spar_md_bands, /* o : mapping of DirAC parameter band index to SPAR FB band index */ - const int8_t useLowerBandRes, /* i : flag indicating lower band resolution for DirAC */ - const int16_t enc_param_start_band, /* i : band index of first DirAC parameter band */ - IVAS_FB_MIXER_HANDLE hFbMdft -); - -void ivas_get_dirac_sba_max_md_bits( - const int32_t sba_total_brate, - int16_t *bits_frame_nominal, - int16_t *metadata_max_bits, - int16_t *qmetadata_max_bit_req, - const int16_t nbands - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_sba_config( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode of the core coder */ - int32_t sba_total_brate, /* i : SBA total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t nbands /* i : number of frequency bands */ - , - IVAS_FORMAT ivas_format -); - -ivas_error ivas_dirac_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const DIRAC_CONFIG_FLAG flag_configopen /* i/ : Flag determining if we open or reconfigure the DirAC decoder */ -); - -void ivas_dirac_dec_close( - DIRAC_DEC_HANDLE *hDirAC_out -); - -void ivas_dirac_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder Core state structure */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial rendering data handle */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q metadata */ - int16_t *nb_bits, /* o : number of bits read */ - const int16_t last_bit_pos, /* i : last read bitstream position */ - const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ -); - -void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ -); - - -void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_dirac_dec_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport, /* i : number of transport channels */ - float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], - float *pppQMfFrame_ts_im[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] -); - - -void computeDirectionVectors( - float *intensity_real_x, - float *intensity_real_y, - float *intensity_real_z, - const int16_t enc_param_start_band, - const int16_t num_frequency_bands, - float *direction_vector_x, - float *direction_vector_y, - float *direction_vector_z -); - -void computeDiffuseness( - float *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], - const float *buffer_energy, - const int16_t num_freq_bands, - float *diffuseness -); - -void ivas_dirac_dec_get_response( - const int16_t azimuth, - const int16_t elevation, - float *response, - const int16_t ambisonics_order -); - - - -ivas_error ivas_mc_paramupmix_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_mc_paramupmix_enc_close_fx( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ -); - -void ivas_mc_paramupmix_dec_read_BS( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Decoder_State *st, /* i/o: decoder state structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ -); - -void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_param_mc_set_coded_bands_fx( - HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC /* i/o: handle for the Parametric MC parameter coding state */ -); - -/*! r: number of IVAS transport channels */ - -ivas_error ivas_param_mc_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -ivas_error ivas_param_mc_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_param_mc_enc_close( - PARAM_MC_ENC_HANDLE *hParamMC, /* i/o: Parametric MC encoder handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_param_mc_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float *data_f[], /* i/o: input/transport MC data */ - const int16_t input_frame /* i : input frame length */ -); - -ivas_error ivas_param_mc_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -ivas_error ivas_param_mc_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - - -void ivas_param_mc_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ -); - -void ivas_param_mc_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_param_mc_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ -); - -/*! r: number of cldfb synthesis instances */ -int16_t param_mc_get_num_cldfb_syntheses( - Decoder_Struct *st_ivas /* i : IVAS decoder structure */ -); - -UWord16 ivas_param_mc_get_configuration_index_fx( - const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */ - const Word32 ivas_total_brate /* i : IVAS total bitrate */ -); - -ivas_error ivas_dirac_dec_output_synthesis_cov_open( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: handle for the covariance synthesis state */ - const int16_t max_band_decorr, /* i : uppermost frequency band where decorrelation is applied */ - const int16_t interp_length, /* i : length for interpolating the mixing matrices in time slots */ - const int16_t num_param_bands, /* i : number of parameter bands */ - const int16_t num_param_bands_residual, /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ - const int16_t nchan_in, /* i : number of input (transport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const float *proto_matrix /* i : the prototype (upmix) matrix (only used if mode == 1) */ -); - -void ivas_dirac_dec_output_synthesis_get_interpolator( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i/o: handle for the covariance synthesis parameters */ - const uint16_t interp_length /* i : interpolator length */ -); - -void ivas_dirac_dec_output_synthesis_cov_init( - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state, /* i/o: pointer to the state of the covariance synthesis */ - const int16_t nchan_in, /* i : number of input (tranport) channels */ - const int16_t nchan_out, /* i : number of output channels */ - const int16_t n_param_bands, /* i : number of total parameter bands */ - const int16_t n_param_bands_res /* i : number of parameter bands with a residual mixing matrix (i.e. decorrelation */ -); - -void ivas_dirac_dec_output_synthesis_cov_close( - DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params, /* i : handle for the covariance synthesis parameters */ - DIRAC_OUTPUT_SYNTHESIS_COV_STATE *h_dirac_output_synthesis_state /* i/o: handle for the covariance synthesis state */ -); - - -void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot( - float *Cldfb_RealBuffer_in, /* i : input channel filter bank samples (real part) */ - float *Cldfb_ImagBuffer_in, /* i : input channel filter bank samples (imaginary part) */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (real part) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : output channel filter bank samples (imaginary part) */ - float *mixing_matrix[], /* i : parameter band wise mixing matrices (direct part) */ - float *mixing_matrix_res[], /* i : parameter band wise mixing matrices (residual part) */ - const uint16_t slot_idx_sfr, /* i : time slot index for the current slot within the current subframe */ - const uint16_t slot_idx_tot, /* i : time slot index for the current slot within the frame */ - const int16_t nX, /* i : number of input channels */ - const int16_t nY, /* i : number of output channels */ - PARAM_MC_DEC_HANDLE hParamMC /* i : handle to the Parametric MC decoder state */ -); - - -void FdCngEncodeDiracMDCTStereoSID( - CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure */ -); - -void FdCngDecodeDiracMDCTStereoSID( - CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure */ -); - - -/*----------------------------------------------------------------------------------* - * SPAR prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - -ivas_error ivas_spar_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *data_f[], /* i/o: input/transport audio channels */ - const int16_t input_frame, /* i : input frame length */ - int16_t *nb_bits_metadata, /* i : number of MD bits written */ - BSTR_ENC_HANDLE hMetaData /* o : MetaData handle */ -); - -ivas_error ivas_spar_dec_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ -); - - -ivas_error ivas_spar_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - int16_t *nb_bits_read /* o : number of MD bits read */ -); - -void ivas_spar_config( - int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - int16_t *nchan_transport, /* o : number of transport channels */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - int32_t *core_nominal_brate, /* o : core-coding nominal bitrate */ - const int16_t sid_format /* i : IVAS format indicator from SID frame */ -); - -ivas_error ivas_sba_linear_renderer( - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t nchan_in, /* i : number of input ambisonics channels */ - const int16_t nchan_ism, /* i : number of objects */ - const AUDIO_CONFIG output_config, /* i : output audio configuration */ - const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ -); - -void ivas_sba_mix_matrix_determiner( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - float *output[], /* i/o: transport/output audio channels */ - const int16_t bfi, /* i : BFI flag */ - const int16_t nchan_remapped, /* i : num channels after remapping of TCs */ - const int16_t output_frame, /* i : output frame length */ - const int16_t num_md_sub_frames /* i : number of subframes in mixing matrix */ -); - -/* AGC */ -/*! r: AGC enable flag */ - -ivas_error ivas_spar_agc_enc_open( - ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ -); - -void ivas_spar_agc_enc_close( - ivas_agc_enc_state_t **hAgcEnc /* i/o: AGC encoder handle */ -); - -void ivas_agc_enc_process( - ivas_agc_enc_state_t *hAgcEnc, /* i/o: AGC encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - float **ppPcm_in, /* i : input audio channels */ - float **ppPcm_out, /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ -); - -ivas_error ivas_spar_agc_dec_open( - ivas_agc_dec_state_t **hAgcDec, /* i/o: AGC decoder handle */ - const int32_t output_Fs /* i : output sampling rate */ -); - -void ivas_spar_agc_dec_close( - ivas_agc_dec_state_t **hAgcDec /* i/o: AGC decoder handle */ -); - - -void ivas_agc_dec_process( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - float *pcm_in[], /* i : input audio channels */ - float *pcm_out[], /* o : output audio channels */ - const int16_t n_channels, /* i : number of channels */ - const int16_t output_Fs /* i : output sampling rate */ -); - -void ivas_agc_read_bits( - ivas_agc_dec_state_t *hAgcDec, /* i/o: AGC decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t n_channels, /* i : number of channels */ - const int16_t AGC_flag /* i : AGC on/off flag */ -); - -void ivas_agc_initWindowFunc( - float *pWinFunc, - const int16_t length -); - -void ivas_agc_calcGainParams( - uint16_t *absEmin, - uint16_t *betaE, - uint16_t *maxAttExp, - const int16_t numCoeffs -); - -float ivas_get_mdct_scaling_gain( - const int16_t dct_len_by_2 -); - -void ivas_get_twid_factors( - const int16_t length, - const float **pTwid_re, - const float **pTwid_im -); - -int16_t ivas_get_bw_idx_from_sample_rate( - const int32_t sampling_rate /* i : sampling rate */ -); - -/*! r: config. table index */ -int16_t ivas_get_spar_table_idx( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : IVAS SBA order */ - const int16_t bwidth, /* i : audio bandwidth */ - int16_t *bitlen, /* o : number of bits */ - int16_t *ind /* o : indice */ -); - -/*! r: number of transport channels */ -int16_t ivas_get_sba_num_TCs( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order /* i : IVAS SBA order */ -); - - -void ivas_spar_bitrate_dist( - int32_t core_brates_act[], /* o : bitrates per core-coder */ - const int16_t nAvailBits, /* i : number of available bits */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int16_t bwidth /* i : audio bandwidth */ -); - -void ivas_mdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_dct_windowing( - const int16_t fade_len, - const int16_t full_len, - const int16_t dct_len, - const int16_t zero_pad_len, - const float *pWindow_coeffs, - const int16_t frame_len, - float *pOut_buf, - float *pBuffer_prev, - float *pTemp_lfe -); - -void ivas_tda( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_imdct( - const float *pIn, - float *pOut, - const int16_t length -); - -void ivas_itda( - const float *re, - float *pOut, - const int16_t length -); - -void ivas_spar_get_cldfb_gains( - SPAR_DEC_HANDLE hSpar, - HANDLE_CLDFB_FILTER_BANK cldfbAnaDec0, - HANDLE_CLDFB_FILTER_BANK cldfbSynDec0, - const DECODER_CONFIG_HANDLE hDecoderConfig -); - -/*! r: 1 if prediction residual channel */ - -void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const Word16 output_frame /* i : output frame length */ -); - -void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nCldfbTs /* i : number of CLDFB time slots */ -); - -void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ -); - -void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -void ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ -); - -ivas_error ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - -void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ -); - -void ivas_spar_dec_upmixer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* i/o: input/output audio channels */ - const int16_t nchan_internal, /* i : number of internal channels */ - const int16_t output_frame /* i : output frame length */ -); - -/* MD module */ - -void ivas_spar_md_enc_close( - ivas_spar_md_enc_state_t **hMdEnc /* i/o: SPAR MD encoder handle */ -); - -void ivas_compute_spar_params( - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - const int16_t i_ts, - float ***mixer_mat, - const int16_t start_band, - const int16_t end_band, - const int16_t dtx_vad, - const int16_t num_ch, - const int16_t bands_bw, - const int16_t active_w, - const int16_t active_w_vlbr, - ivas_spar_md_com_cfg *hSparCfg, - ivas_spar_md_t *hSparMd, - float *pWscale, - const int16_t from_dirac, - const int16_t dyn_active_w_flag -); - -void ivas_create_fullr_dmx_mat( - float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], - float ***mixer_mat, - const int16_t in_chans, - const int16_t start_band, - const int16_t end_band, - const int16_t active_w, - ivas_spar_md_com_cfg *hMdCfg -); - -void ivas_calc_c_p_coeffs( - ivas_spar_md_t *pSparMd, - float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], - const int16_t i_ts, - float ***mixer_mat, - const int16_t num_ch, - const int16_t num_dmx, - const int16_t band_idx, - const int16_t dtx_vad, - const int16_t compute_p_flag, - const int16_t dyn_active_w_flag -); - -void ivas_get_spar_md_from_dirac( - float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES], - float diffuseness[IVAS_MAX_NUM_BANDS], - const int16_t n_ts, - float ***mixer_mat, - ivas_spar_md_t *hSpar_md, - ivas_spar_md_com_cfg *hSpar_md_cfg, - const int16_t start_band, - const int16_t end_band, - const int16_t order, - const int16_t dtx_vad, - float Wscale_d[IVAS_MAX_NUM_BANDS], - const uint8_t useLowerRes, - const int16_t active_w_vlbr, - const int16_t dyn_active_w_flag -); - -/*! r: number of MD subframes */ - -ivas_error ivas_spar_md_dec_matrix_open( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t num_md_sub_frames -); - -void ivas_spar_md_dec_matrix_close( - ivas_spar_md_dec_state_t *hMdDecoder, /* i/o: SPAR MD decoder handle */ - const int16_t num_channels /* i : number of internal channels */ -); - -ivas_error ivas_spar_md_dec_open( - ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order, /* i : SBA order */ - const int16_t sid_format, /* i : SID format */ - const int32_t last_active_ivas_total_brate /* i : IVAS last active bitrate */ -); - -void ivas_spar_md_dec_close( - ivas_spar_md_dec_state_t **hMdDec /* i/o: SPAR MD decoder handle */ -); - -void ivas_spar_get_parameters( - SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t ts, /* i : time slot index */ - const int16_t num_ch_out, /* i : number of channels out */ - const int16_t num_ch_in, /* i : number of channels in */ - const int16_t num_spar_bands, /* i : number of SPAR bands */ - float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] /* o : mixing matrix */ -); - -ivas_error ivas_spar_md_dec_init( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ - const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_md_dec_process( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t sba_order /* i : SBA order */ -); - -void ivas_spar_to_dirac( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bw, /* i : band joining factor */ - const int16_t dyn_active_w_flag /* i : dynamic active W flag */ -); - -void ivas_spar_update_md_hist( - ivas_spar_md_dec_state_t *hMdDec /* i/o: SPAR MD decoder handle */ -); - -int16_t ivas_spar_chk_zero_coefs( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_spar_smooth_md_dtx( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_setup_md_smoothing( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t num_md_sub_frames /* i : number of metadata subframes */ -); - -void ivas_spar_dec_gen_umx_mat( - ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t num_bands_out, /* i : number of output bands */ - const int16_t bfi, /* i : bad frame indicator */ - const int16_t num_md_sub_frames -); - - - - - -/* Transient detector module */ -ivas_error ivas_transient_det_open_fx( - ivas_trans_det_state_t **hTranDet, /* i/o: Transient detector handle */ - const Word32 sampling_rate /* i : sampling rate */ -); - -void ivas_transient_det_close_fx( - ivas_trans_det_state_t **hTranDet /* i/o: Transient detector handle */ -); - -void ivas_transient_det_process( - ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ - float *pIn_pcm, /* i : input audio channels */ - const int16_t frame_len, /* i : frame length in samples */ - int16_t transient_det[2] /* o : transient det outputs */ -); - -void ivas_td_decorr_get_ducking_gains( - ivas_trans_det_state_t *hTranDet, /* i/o: Transient detector handle */ - float *pIn_pcm, - float *pIn_duck_gains, - float *pOut_duck_gains, - const int16_t frame_len, - const int16_t tdet_flag -); - -#define IVAS_CMULT_FLOAT( in1_re, in1_im, in2_re, in2_im, out1_re, out1_im ) \ - out1_re = ( in1_re * in2_re ) - ( in1_im * in2_im ); \ - out1_im = ( in1_re * in2_im ) + ( in2_re * in1_im ); - -#define IVAS_CALCULATE_ABS( re, im, out ) \ - out = sqrtf( ( re * re ) + ( im * im ) ); - -#define IVAS_CALCULATE_RABS( re, out ) \ - out = sqrtf( re * re ); - -#define IVAS_CALCULATE_SQ_ABS( re, im, out ) \ - out = (float) ( ( re * re ) + ( im * im ) ); - -#define IVAS_RMULT_DOUBLE( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); \ - -#define IVAS_CALCULATE_SQ_ABS_N( re, out ) \ - out = (float) ( re * re ); - -#define IVAS_RMULT_FLOAT( in1_re, in2_re, out1_re ) \ - out1_re = ( in1_re * in2_re ); - - -/* PCA */ -void ivas_pca_enc_init( - PCA_ENC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_read_bits( - Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ - PCA_DEC_STATE *hPCA /* i/o: PCA encoder structure */ -); - -void ivas_pca_dec_init( - PCA_DEC_STATE *hPCA /* i/o: PCA decoder structure */ -); - -void ivas_pca_dec( - PCA_DEC_STATE *hPCA, /* i/o: PCA decoder structure */ - const int16_t n_samples, /* i : output frame length */ - const int16_t n_channels, /* i : number of channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int32_t last_ivas_total_brate, /* i : last IVAS total bitrate */ - const int16_t bfi, /* i : bad frame indicator */ - float *pcm_out[] /* o : output audio channels */ -); - -void pca_dec_s3( - const int32_t index, - float *q -); - - -void ivas_huffman_encode_fx( - ivas_huffman_cfg_t *huff_cfg, - Word16 in, - Word16 *hcode, - Word16 *hlen -); - - - -ivas_error ivas_huffman_decode( - ivas_huffman_cfg_t *huff_cfg, - Decoder_State *st0, - int16_t *dec_out -); - -void ivas_arith_decode_cmplx_cell_array( - ivas_arith_t *pArith_re, - ivas_arith_t *pArith_re_diff, - Decoder_State *st0, - ivas_cell_dim_t *pCell_dims, - int16_t *pDo_diff, const int16_t nB, - int16_t *pSymbol_re, - int16_t *pSymbol_re_old -); - - - - -void ivas_ari_done_encoding_14bits( - BSTR_ENC_HANDLE hBstr, Tastat *s -); - - -void ivas_wrap_arround( - int16_t *pArr, - const int16_t min_val, - const int16_t max_val, - const int16_t length -); - -void ivas_get_cum_freq_model( - const int16_t *pFreq_model, - const int16_t length, - int16_t *pCum_freq_model -); - -int16_t ivas_map_num_pred_r_to_idx( - const int16_t num_quant_points_pred_r, - const int16_t active_w_flag -); - -int16_t ivas_map_num_drct_r_to_idx( - const int16_t num_quant_points_drct_r -); - -int16_t ivas_map_num_decd_r_to_idx( - const int16_t num_quant_points_decd_r -); - -/* Quantization utilities */ -void ivas_quantise_real_values( - const float *values, - const int16_t q_levels, - const float min_value, - const float max_value, - int16_t *index, - float *quant, - const int16_t dim -); - - -void ivas_spar_quant_dtx_init( - ivas_spar_md_t *spar_md, - float *min_max -); - -void ivas_map_prior_coeffs_quant( - ivas_spar_md_prev_t *pSpar_md_prior, - ivas_spar_md_com_cfg *pSpar_md_cfg, - const int16_t qsi, - const int16_t nB -); - - -void ivas_clear_band_coeffs( - ivas_band_coeffs_t *pband_coeffs, - const uint16_t num_bands -); - -void ivas_clear_band_coeff_idx( - ivas_band_coeffs_ind_t *pband_coeff_idx, - const uint16_t num_bands -); - - -/*----------------------------------------------------------------------------------* - * MASA prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_masa_decode( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - Decoder_State *st, /* i/o: decoder state structure */ - int16_t *nb_bits_read /* o : number of bits read */ -); - -void generate_gridEq( - SPHERICAL_GRID_DATA *data /* o : data structure for grid */ -); - -ivas_error ivas_masa_enc_open_fx( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_masa_enc_close_fx( - MASA_ENCODER_HANDLE *hMasa /* i/o: MASA metadata structure */ -); - -void ivas_masa_enc_reconfigure( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); - -ivas_error ivas_masa_dec_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - -ivas_error ivas_masa_encode( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */ - int16_t *nb_bits_metadata, /* o : number of metadata bits written */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t Opt_DTX_ON, /* i : DTX on flag */ - const int16_t element_mode, /* i : element mode */ - const ISM_MODE ism_mode, /* i : ISM format mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS], /* i : ISM metadata handle */ - const int16_t idx_separated_object, /* i : index of the separated object */ - OMASA_ENC_HANDLE hOMasa, /* i : OMASA encoder handle */ - const int16_t ism_imp, /* i : importance of separated object */ - const int16_t flag_omasa_ener_brate /* i : less bitrate for objects in OMASA flag */ -); - -void ivas_masa_estimate_energy( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA encoder structure */ - float *data_f[], /* i : Input audio channels */ - const int16_t input_frame, /* i : frame length */ - const int16_t nchan_transport /* i : number of MASA input/transport channels */ -); - - -void ivas_masa_set_elements( - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t mc_mode, /* i : MC format mode */ - const int16_t nchan_transport, /* i : number of MASA input/transport channels */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - int16_t *element_mode, /* o : element mode */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE, /* o : number of CPEs */ - const int16_t ivas_format, /* i : IVAS format */ - const ISM_MODE ism_mode, /* i : ISM mode */ - const int32_t ism_total_brate /* i : initial ISM total bitrate */ -); - -/*! r: valid or not 1/0 */ -int16_t valid_ratio_index( - int16_t index, /* i : index to be checked */ - const int16_t K, /* i : L1 norm to check against */ - const int16_t len /* i : vector length */ -); - -void reconstruct_ism_ratios( - int16_t *ratio_ism_idx, - const int16_t nchan_ism, - const float step, - float *q_energy_ratio_ism -); - -void distribute_evenly_ism( - int16_t *idx, - const int16_t K, - const int16_t nchan_ism -); - - -int16_t ivas_qmetadata_encode_extended_gr_length_fx( - const uint16_t value, - const uint16_t alphabet_size, - const int16_t gr_param); - -void ivas_qmetadata_encode_extended_gr_fx( - BSTR_ENC_HANDLE hMetaData, /* i/o: q_metadata handle */ - const uint16_t value, /* i : value to be encoded */ - const uint16_t alphabet_size, /* i : alphabet size */ - const int16_t gr_param); /* i : GR order */ - -/*! r: CPE bitrate value */ -int32_t calculate_cpe_brate_MASA_ISM( - const ISM_MODE ism_mode, /* i : ism mode */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_merge_masa_metadata( - MASA_ENCODER_HANDLE hMasa, /* i/o: MASA enc handle. source for MASA metadata and combined metadata will be here */ - OMASA_SPATIAL_META_HANDLE hOMasaMeta /* i : ISM-object metadata to be merged with the MASA metadata */ -); - - -/*!r : number of bits for ISM ratio index */ -int16_t bits_index_ism_ratio( - const int16_t nchan_ism /* i : number of objects */ -); - -void calculate_nbits_meta( - const int16_t nchan_ism, - float q_energy_ratio_ism[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t numSf, - const int16_t numCodingBands, - int16_t* bits_ism, - const int16_t idx_sep_obj, - const int16_t ism_imp -); - -/*! r: limitation flag */ -int16_t calculate_brate_limit_flag( - const int16_t ism_imp[], /* i : ISM importance flags */ - const int16_t nchan_ism /* i : number of objects */ -); - -void ivas_masa_set_coding_config( - MASA_CODEC_CONFIG* config, /* i/o: MASA coding config structure */ - int16_t* band_mapping, /* o : Band mapping used */ - const int32_t ivas_total_brate, /* i : codec total bitrate */ - const int16_t nchan_transport, /* i : number of transport channel (mono/stereo) */ - const uint8_t isMcMasa /* i : toggle for selecting McMASA specific config */ -); - -/*! r: Surround coherence significant flag */ -uint8_t ivas_masa_surrcoh_signicant( - float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Surround coherence */ - float diffuse_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : Diffuse to total ratio */ - const int16_t nSubFrames, /* i : Number of sub frames */ - const int16_t nBands /* i : Number of frequency bands */ -); - -void masa_compensate_two_dir_energy_ratio_index( - const int16_t ratio_index_1, /* i : Input ratio for direction 1 */ - const int16_t ratio_index_2, /* i : Input ratio for direction 2 */ - int16_t *ratio_index_mod1, /* o : Output modified ratio for direction 1 */ - int16_t *ratio_index_mod2, /* o : Output modified ratio for direction 2 */ - const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ -); - -void ivas_set_qmetadata_maxbit_req_fx( - IVAS_QMETADATA_HANDLE hQMetaData, /* o : qmetadata structure where the requirement value is set */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ -); - -void masa_sample_rate_band_correction( - MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ - int16_t *band_mapping, /* i/o: Band mapping used and modified */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ - const uint8_t maxBand, /* i : max band */ - uint8_t is_encoder, /* i : signals if called at encoder */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ -); - -void invdct4_transform( - float *v, /* i : input vector */ - uint8_t *invdct_v /* o : transformed vector */ -); - - -void ivas_spar_param_to_masa_param_mapping( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ - const int16_t subframe /* i : Subframe to map */ -); - -/*---------------------------------------------------------------------------------* - * Binaural FastConv Renderer Prototypes -*-----------------------------------------------------------------------------------*/ - - -void ivas_binaural_hrtf_close( - HRTFS_FASTCONV_HANDLE *hHrtfFastConv /* i/o: decoder binaural hrtf handle */ -); - -void ivas_binRenderer( - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle */ - const int16_t numTimeSlots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float Cldfb_ImagBuffer_Binaural[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ - float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] /* i : LS signals */ -); - -void ivas_binaural_add_LFE( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t output_frame, /* i : length of input frame */ - float *input_f[], /* i : transport channels */ - float *output_f[] /* o : synthesized core-coder transport channels/DirAC output */ -); - -/*----------------------------------------------------------------------------------* - * renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ism_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ism_renderer_close( - ISM_RENDERER_HANDLE *hIsmRendererData /* i/o: ISM renderer handle */ -); - -void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ -); - - -void ivas_mc2sba( - IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ - float *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ - float *buffer_td[], /* o : MC signals (on input) and the HOA3 (on output) */ - const int16_t output_frame, /* i : output frame length per channel */ - const int16_t sba_order, /* i : SBA order */ - const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ -); - -void ivas_param_mc_mc2sba_cldfb( - IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ - float *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ - const int16_t slot_idx, /* i : current slot in the subframe */ - float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - const int16_t nBands, /* i : number of synth CLDFB bands */ - const float gain_lfe /* i : gain applied to LFE */ -); - - -/*----------------------------------------------------------------------------------* - * Amplitude Panning VBAP prototypes - *----------------------------------------------------------------------------------*/ - -void panning_wrap_angles( - const float azi_deg, /* i : azimuth in degrees for panning direction (positive left) */ - const float ele_deg, /* i : elevation in degrees for panning direction (positive up) */ - float *azi_wrapped, /* o : wrapped azimuth component */ - float *ele_wrapped /* o : wrapped elevation component */ -); - -/*----------------------------------------------------------------------------------* - * LS Renderer prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_setup_conversion_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_ls_setup_conversion_close( - LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ -); - - -void ivas_ls_setup_conversion( - Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ - const int16_t input_chans, /* i : number of input channels to the renderer */ - const int16_t output_frame, /* i : frame length */ - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[] /* i/o: output synthesis signal */ -); - -void ivas_ls_setup_conversion_process_mdct_param_mc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *x[][NB_DIV] /* i/o: output synthesis signal */ -); - -void ivas_lssetupconversion_process_param_mc( - Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ - const int16_t num_timeslots, /* i : number of time slots to process */ - float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ -); - - -/*----------------------------------------------------------------------------------* - * Custom loudspeaker setup prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_ls_custom_open( - LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ -); - - - -/*----------------------------------------------------------------------------------* - * McMASA prototypes - *----------------------------------------------------------------------------------*/ - - -ivas_error ivas_mcmasa_dec_reconfig( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -void ivas_mcmasa_setNumTransportChannels( - int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */ - int16_t* element_mode, /* o : Pointer to element mode to be set */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_set_separate_channel_mode( - uint8_t *separateChannelEnabled, /* o : Pointer to separate channel toggle */ - int16_t *separateChannelIndex, /* o : Pointer to separate channel index */ - const int32_t ivas_total_brate /* i : Total bitrate of IVAS */ -); - -void ivas_mcmasa_split_brate( - const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */ - const int32_t ivas_total_brate, /* i : Total bitrate available to be split */ - const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */ - const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */ - int32_t *brate_sce, /* o : Pointer to SCE element bitrate */ - int32_t *brate_cpe /* o : Pointer to CPE element bitrate */ -); - - -void ivas_mcmasa_dmx_modify_fx( - const Word16 n_samples, /* i : input frame length in samples */ - Word32 dmx_fx[][L_FRAME48k + NS2SA(48000, IVAS_FB_ENC_DELAY_NS)], /* i/o: downmix signal to be transformed into another format Qx*/ - Word16 dmx_Q[], /* i/o : Q of the intput signal which is being transformed*/ - const Word16 n_chnls_dmx_old, /* i : number of downmix channels in the old format Q0 */ - const Word16 n_chnls_dmx_new /* i : number of downmix channels in the target format Q0*/ -); - -ivas_error ivas_mono_dmx_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - - -void ivas_mono_dmx_renderer_close( - MONO_DOWNMIX_RENDERER_HANDLE *hMonoDmxRenderer /* i/ i/o: Mono downmix structure */ -); - -void ivas_mono_downmix_render_passive( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ - const int16_t output_frame /* i : output frame length */ -); - - -/*----------------------------------------------------------------------------------* - * LFE encoder low pass filter prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_lpf_enc( - ivas_filters_process_state_t **hLfeLpf, /* o : LFE LPF handle */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_lpf_enc_close_fx( - ivas_filters_process_state_t **hLfeLpf /* i/o: LFE LPF handle */ -); - -void ivas_lfe_lpf_enc_apply( - ivas_filters_process_state_t *hLfeLpf, /* i/o: LFE LPF handle */ - float data_lfe_ch[], /* i/o: LFE signal */ - const int16_t input_frame /* i : input frame length per channel */ -); - - -/*----------------------------------------------------------------------------------* - * LFE Coding prototypes - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_create_lfe_enc_fx( - LFE_ENC_HANDLE *hLFE, /* o : IVAS LFE encoder structure */ - const int32_t input_Fs /* i : input sampling rate */ -); - -void ivas_lfe_enc_close_fx( - LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ -); - -void ivas_lfe_enc( - LFE_ENC_HANDLE hLFE, /* i/o: LFE encoder handle */ - float data_lfe_ch[], /* i : input LFE signal */ - const int16_t input_frame, /* i : input frame length per channel */ - BSTR_ENC_HANDLE hBstr /* i/o: bitstream handle */ -); - -void ivas_lfe_tdplc( - LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - float *prevsynth, /* i : previous frame synthesis */ - float *ytda, /* o : output time-domain buffer */ - const int16_t output_frame /* i : output frame length */ -); -void ivas_lfe_window_init( - LFE_WINDOW_HANDLE hLFEWindow, /* i/o: LFE window handle */ - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t frame_len /* i : frame length in samples */ -); - -void ivas_lfe_lpf_select_filt_coeff( - const int32_t sampling_rate, /* i : sampling rate */ - const int16_t order, /* i : filter order */ - const float **ppFilt_coeff /* o : filter coefficients */ -); - -void ivas_filters_init( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const float *filt_coeff, /* i : filter coefficients */ - const int16_t order /* i : filter order */ -); - -void ivas_filters_init_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - const Word32 *filt_coeff_fx, /* i : filter coefficients Q31- *filt_coeff_e */ - const Word16 *filt_coeff_e, /* i : exponents of filter coefficients */ - const Word16 order ) ; - -void ivas_filter_process( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - float *pIn_Out, /* i : signal subject to filtering */ - const int16_t length /* i : filter order */ -); - -void ivas_filter_process_fx( - ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */ - Word32 *pIn_Out_fx, /* i/o: signal subject to filtering Q(q_factor) */ - const Word16 length, /* i : filter order */ - Word16 q_factor ); - -/*----------------------------------------------------------------------------------* - * OSBA prototypes - *----------------------------------------------------------------------------------*/ -ivas_error ivas_osba_enc_reconfig( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -); -ivas_error ivas_osba_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); - -ivas_error ivas_osba_dirac_td_binaural_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ -); - - -void ivas_osba_data_close( - SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ -); - - -/*----------------------------------------------------------------------------------* -* OMASA prototypes -*---------------------------------------------------------------------------------*/ - -ivas_error ivas_omasa_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ -); - -void ivas_omasa_enc_close( - OMASA_ENC_HANDLE *hOMasa /* i/o: encoder OMASA handle */ -); - - -ivas_error ivas_omasa_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : output synthesis signal */ -); - - - - -void ivas_set_surplus_brate_enc( - Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ -#ifdef DEBUG_MODE_INFO - , - const int16_t *nb_bits_metadata /* i : number of metadata bits */ -#endif -); - -void ivas_set_surplus_brate_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int32_t *ism_total_brate /* i : ISM total bitrate */ -); - - -void ivas_set_ism_importance_interformat( - const int32_t ism_total_brate, /* i/o: ISms total bitrate */ - const int16_t nchan_transport, /* i : number of transported channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_ENC_HANDLE hSCE[], /* i/o: SCE encoder handles */ - const float lp_noise_CPE, /* i : LP filtered total noise estimation */ - int16_t ism_imp[] /* o : ISM importance flags */ -); - - -/*! r: adjusted bitrate */ -int32_t ivas_interformat_brate( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of ISM channels */ - const int32_t element_brate, /* i : element bitrate */ - const int16_t ism_imp, /* i : ISM importance flag */ - const int16_t limit_flag /* i : flag to limit the bitrate increase */ -); - -void ivas_combined_format_brate_sanity( - const int32_t element_brate, /* i : element bitrate */ - const int16_t core, /* i : core */ - const int32_t total_brate, /* i : total bitrate */ - int32_t *core_brate, /* i/o: core bitrate */ - int16_t *inactive_coder_type_flag, /* o : inactive coder_type flag */ - int16_t *diff_nBits /* o : number of differential bits */ -); - -ISM_MODE ivas_omasa_ism_mode_select( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nchan_ism /* i : number of input ISM's */ -); - -void ivas_set_omasa_TC( - const ISM_MODE ism_mode, /* i : ISM mode */ - const int16_t nchan_ism, /* i : number of input ISMs */ - int16_t *nSCE, /* o : number of SCEs */ - int16_t *nCPE /* o : number of CPEs */ -); - -void ivas_merge_masa_transports( - float data_in_f1[][L_FRAME48k], /* i : Transport audio signals 1 */ - float *data_in_f2[], /* i : Transport audio signals 2 */ - float *data_out_f[], /* o : Merged transport audio signals */ - const int16_t input_frame, /* i : Input frame size */ - const int16_t num_transport_channels /* i : Number of transport audio signals */ -); - - -ivas_error ivas_omasa_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t *nchan_transport_ism, /* o : number of ISM TCs */ - const int16_t dirac_bs_md_write_idx, /* i : DirAC bitstream write index */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ -); - -void ivas_omasa_preProcessStereoTransportsForMovedObjects( - Decoder_Struct *st_ivas, - float inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - float inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], - const int16_t nBins, - const int16_t subframe -); - -ivas_error ivas_omasa_separate_object_renderer_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_renderer_close( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_omasa_separate_object_render_jbm( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesRendered, /* i : number of samples rendered */ - float input_f[][L_FRAME48k], /* i : separated object signal */ - float *output_f[], /* o : rendered time signal */ - const int16_t subframes_rendered, /* i : number of subframes rendered */ - const int16_t slots_rendered /* i : number of CLDFB slots rendered */ -); - -void ivas_omasa_encode_masa_to_total( - float masa_to_total_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - BSTR_ENC_HANDLE hMetaData, - const int16_t low_bitrate_mode, - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_decode_masa_to_total( - uint16_t *bit_stream, - int16_t *index, - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], - const int16_t nbands, - const int16_t nblocks -); - -void ivas_omasa_modify_masa_energy_ratios( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ - float masa_to_total_energy_ratio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_MAXIMUM_CODING_SUBBANDS] -); - - -/*----------------------------------------------------------------------------------* - * TD Binaural Object renderer - *----------------------------------------------------------------------------------*/ - -#ifndef FIX_910_REMOVE_DUPLICATION_TD_REND -ivas_error ivas_td_binaural_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ -); -#endif -ivas_error ivas_td_binaural_renderer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ -); - -/*----------------------------------------------------------------------------------* - * Filter-bank (FB) Mixer - *----------------------------------------------------------------------------------*/ - -ivas_error ivas_fb_set_cfg( - IVAS_FB_CFG **pFb_cfg_out, /* o : FB config. handle */ - const int16_t ivas_format, /* i : IVAS format */ - const int16_t num_in_chans, /* i : number of FB input channels */ - const int16_t num_out_chans, /* i : number of FB output channels */ - const int16_t active_w_mixing, /* i : active_w_mixing flag */ - const int32_t sampling_Fs, /* i : sampling rate */ - const int16_t nachan_dirac_ana /* i : number of DirAR analysis channels */ -); - -void ivas_fb_mixer_pcm_ingest( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float **ppOut_pcm, /* o : output audio channels */ - const int16_t frame_length, /* i : frame length */ - const int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] -); - -void ivas_fb_mixer_update_prior_input( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - const int16_t length, /* i : length of time slot */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -void ivas_fb_mixer_get_windowed_fr( - IVAS_FB_MIXER_HANDLE hFbMixer, /* i/o: FB mixer handle */ - float *pcm_in[], /* i : input audio channels */ - float *frame_f_real[], /* o : real freq domain values */ - float *frame_f_imag[], /* o : imag freq domain values */ - const int16_t length, /* i : number of new samples in time slot */ - const int16_t mdft_len, /* i : MDFT frame length */ - const int16_t nchan_fb_in /* i : number of analysis channels */ -); - -/*! r: number of spectral bands */ - -/* clang-format on */ -- GitLab From 192977759c0c595e524a0384b0bbad1613ce34a6 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 28 May 2025 15:16:56 +0300 Subject: [PATCH 156/692] Port MR1418 from float to main-pc --- lib_com/options.h | 1 + lib_dec/ivas_masa_dec_fx.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 73a8f082f..84d277e27 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index eb010c146..e87683562 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -166,6 +166,16 @@ ivas_error ivas_masa_decode_fx( } move16(); +#ifdef NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS + test(); + test(); + IF( EQ_32( ivas_format, MASA_FORMAT ) && ( EQ_32( masa_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) ) + { + hMasa->config.numberOfDirections = 1; + move16(); + } +#endif + test(); test(); test(); -- GitLab From c4a3bacfd658f504ce06a655832e929fde2387e5 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 14:45:33 +0200 Subject: [PATCH 157/692] fixed definitions of type float --- lib_rend/ivas_reverb_fx.c | 8 +++++--- lib_rend/ivas_reverb_utils_fx.c | 26 ++++++++++++++------------ lib_util/hrtf_file_reader.c | 6 +++--- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index acfd656c5..1cbbf367b 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1284,10 +1284,12 @@ static void set_reverb_acoustic_data_fx( Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp; Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e; Word16 pow_exp; +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES Word32 *pHrtf_set_l_re_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_l_im_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_r_re_fx[MAX_INTERN_CHANNELS]; Word32 *pHrtf_set_r_im_fx[MAX_INTERN_CHANNELS]; +#endif Word32 *pFc_input_fx = pRoomAcoustics->pFc_input_fx; Word32 *pAcoustic_rt60_fx = pRoomAcoustics->pAcoustic_rt60_fx; @@ -1298,9 +1300,8 @@ static void set_reverb_acoustic_data_fx( Word16 *pRt60_e = pParams->pRt60_e; Word32 *pDsr_fx = pParams->pDsr_fx; Word16 *pDsr_e = pParams->pDsr_e; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else +#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* use crend hrtf filters */ IF( hHrtf != NULL ) { @@ -2519,7 +2520,7 @@ ivas_error ivas_binaural_reverb_init( return error; } -#endif +#else /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_fastconv() @@ -2621,6 +2622,7 @@ ivas_error ivas_binaural_reverb_open_parambin( return error; } +#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() * diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 2cead56f1..e463b3498 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -65,7 +65,7 @@ typedef struct cldfb_convolver_state } cldfb_convolver_state; #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); +static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, Word32 *avg_pwr_l_out, Word32 *avg_pwr_r_out ); #else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); #endif @@ -76,19 +76,24 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCO * Prepares reverb parameters for CLDFB-based reverberator *-----------------------------------------------------------------------------------------*/ -ivas_error ivas_reverb_prepare_cldfb_params( + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, + const int32_t output_Fs, + float *pOutput_t60, + float *pOutput_ene ) #else +ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, -#endif const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ) +#endif { int16_t idx; float fc[CLDFB_NO_CHANNELS_MAX]; @@ -96,14 +101,14 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - fc[idx] = ( (float) idx + 0.5f ) * ( (float) MAX_SAMPLING_RATE / (float) ( 2 * CLDFB_NO_CHANNELS_MAX ) ); + fc[idx] = ( idx + 0.5f ) * ( MAX_SAMPLING_RATE / ( 2 * CLDFB_NO_CHANNELS_MAX ) ); } Word32 *fc_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 * ) ); Word32 *pOutput_t60_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 * ) ); @@ -144,6 +149,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) @@ -299,8 +305,8 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const int16_t use_brir, #endif const int32_t sampling_rate, - float *avg_pwr_left, - float *avg_pwr_right ) + Word32 *avg_pwr_left, + Word32 *avg_pwr_right ) { int16_t freq_idx; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -332,9 +338,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); - Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); for ( int i = 0; i < 60; i++ ) @@ -348,13 +352,11 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( } ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, - CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); + CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left, avg_pwr_right, avg_pwr_left_e, avg_pwr_right_e ); free( input_fc_fx ); free( output_fc_fx ); - free( avg_pwr_left_fx ); free( avg_pwr_left_e ); - free( avg_pwr_right_fx ); free( avg_pwr_right_e ); #else diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 7a74e8e88..5832296c8 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -813,13 +813,13 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_l, Q27, lr_iac_len ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_l_dyn, Q27, lr_iac_len ); fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_r, Q27, lr_iac_len ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_r_dyn, Q27, lr_iac_len ); fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->inter_aural_coherence, Q23, lr_iac_len ); + floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; free( hrtf_prop_local ); -- GitLab From 336ac2ab53ac9f5d0ea4ec0775db11b1586bf088 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 14:48:21 +0200 Subject: [PATCH 158/692] clang formatting patch --- lib_rend/ivas_reverb_utils_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index e463b3498..2c9180927 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -101,7 +101,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif -- GitLab From 44e0af3b81d3e8f57f0018fc7d77120148ce9583 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Wed, 28 May 2025 15:58:06 +0300 Subject: [PATCH 159/692] Port MR1418 to main-pc --- lib_com/ivas_cnst.h | 4 ++++ lib_com/options.h | 1 + lib_enc/ivas_masa_enc_fx.c | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 24d396d2a..4d94cdbe6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1286,7 +1286,11 @@ enum #define MASA_RATIO_TOLERANCE 0.1f #define MASA_RATIO_THRESHOLD 0.1f #define MASA_ANGLE_TOLERANCE 0.5f +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS +#define MASA_RATIO_THRESHOLD_FX 322122547 // 0.15 in Q31 +#else #define MASA_RATIO_THRESHOLD_FX 214748365 // 0.1 in Q31 +#endif #define MASA_RATIO_TOLERANCE_FX 107374182 // 0.1 in Q30 #define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 // 0.5 in Q22 #define MASA_LIMIT_NO_BANDS_SUR_COH 8 diff --git a/lib_com/options.h b/lib_com/options.h index 73a8f082f..fc5a6ab3c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -135,6 +135,7 @@ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ +#define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 9d0579d12..6d53d1d09 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1857,6 +1857,9 @@ void ivas_masa_combine_directions_fx( hMeta->directional_meta[1].energy_ratio_fx[j][i] = 0; // Q30 move16(); move16(); +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS + hMeta->common_meta.diffuse_to_total_ratio_fx[j][i] = L_sub( ONE_IN_Q30, hMeta->directional_meta[0].energy_ratio_fx[j][i] ); // Q30 +#endif IF( computeCoherence ) { @@ -2104,6 +2107,10 @@ static void detect_metadata_composition_fx( { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS + hMeta->directional_meta[0].spherical_index[sf][band] = hMeta->directional_meta[1].spherical_index[sf][band]; + move16(); +#endif hMeta->directional_meta[0].azimuth_fx[sf][band] = hMeta->directional_meta[1].azimuth_fx[sf][band]; /*q22*/ hMeta->directional_meta[0].elevation_fx[sf][band] = hMeta->directional_meta[1].elevation_fx[sf][band]; /*q22*/ hMeta->directional_meta[0].energy_ratio_fx[sf][band] = hMeta->directional_meta[1].energy_ratio_fx[sf][band]; /*q30*/ @@ -2228,7 +2235,12 @@ static void compensate_energy_ratios_fx( UWord8 numDirs; hMeta = &( hMasa->masaMetadata ); +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS + numDirs = hMasa->config.numberOfDirections; + move16(); +#else numDirs = (UWord8) add( hMeta->descriptive_meta.numberOfDirections, 1 ); +#endif FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { @@ -3137,10 +3149,20 @@ static void copy_masa_metadata_subframe_fx( ) { UWord8 dir; +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS + UWord8 band; +#endif /* directional metadata */ FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) { +#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS + FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + hMetaTo->directional_meta[dir].spherical_index[sfTo][band] = hMetaFrom->directional_meta[dir].spherical_index[sfFrom][band]; + move16(); + } +#endif Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22 Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22 Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30 -- GitLab From ec728f38f51222f987c7bfc695d48223a903be6e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 15:02:50 +0200 Subject: [PATCH 160/692] fixed data type definition --- lib_rend/ivas_prot_rend_fx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index fa74d0f0e..a7f52eb32 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1152,8 +1152,8 @@ ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, - Word32 *pOutput_t60, - Word32 *pOutput_ene ); + float *pOutput_t60, + float *pOutput_ene ); #else ivas_error ivas_reverb_prepare_cldfb_params( IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, -- GitLab From 089fc29b1ad6da87905bc9594a8e2945d6add67c Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 28 May 2025 15:26:15 +0200 Subject: [PATCH 161/692] type reassignments --- lib_rend/ivas_reverb_utils_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 2c9180927..a385ef359 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -172,7 +172,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( * * Function for convolving CLDFB-domain data with filter taps *-----------------------------------------------------------------------------------------*/ -#endif + /*-----------------------------------------------------------------------------------------* * Function get_IR_from_filter_taps() @@ -279,6 +279,8 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( return IVAS_ERR_OK; } +#endif + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_set_energies() -- GitLab From 06b479d714a02229678e6722742af738c9a63f67 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 29 May 2025 15:46:18 +0530 Subject: [PATCH 162/692] IGF caclulate envelop precision enhancement, bug fix: sharpflag in encod_unvoiced, minimum statistics improvements --- lib_com/fd_cng_com_fx.c | 104 ++++++++++++++++++++++++++++++---------- lib_com/prot_fx.h | 10 +++- lib_dec/fd_cng_dec_fx.c | 10 ++-- lib_dec/stat_dec.h | 6 ++- lib_enc/enc_uv_fx.c | 2 +- lib_enc/fd_cng_enc_fx.c | 10 ++-- lib_enc/igf_enc.c | 2 +- lib_enc/stat_enc.h | 6 ++- 8 files changed, 109 insertions(+), 41 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index 207925724..7cc536822 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -483,6 +483,54 @@ void expand_range( move16(); } +void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ) +{ + Word16 i, tmp_e; + Word32 maxVal, tmp32; + Word16 maxOutExp; + + const Word32 low_lim = 726940; /* 0.0003385080526823181f in Q31 */ + move32(); + + /* Find max possible output exponent. */ + maxVal = 0; + move32(); + FOR( i = 0; i < len; i++ ) + { + maxVal = L_max( maxVal, in[i] ); + } + tmp32 = BASOP_util_Pow2( maxVal, Q31 - Q25, &tmp_e ); + maxOutExp = tmp_e; + move16(); + + /* out = (2^(in) - 1) */ + FOR( i = 0; i < len; i++ ) + { + tmp32 = BASOP_util_Pow2( in[i], Q31 - Q25, &tmp_e ); // 2^x + tmp32 = L_sub( tmp32, L_shl( 1, sub( 31, tmp_e ) ) ); // 2^x - 1 + tmp32 = L_shr( tmp32, sub( maxOutExp, tmp_e ) ); // make exp same as maxExpOut + + out[i] = tmp32; + move32(); + + Word32 tmp_low_lim = L_shr( low_lim, maxOutExp ); + if ( LT_32( out[i], tmp_low_lim ) ) + { + out[i] = tmp_low_lim; + move32(); + } + } + + *out_exp = maxOutExp; + move16(); + + return; +} + /*------------------------------------------------------------------- * expand_range_var_e() * @@ -1145,10 +1193,10 @@ void minimum_statistics( void minimum_statistics_fx( Word16 len, /* i : Total number of partitions (CLDFB or FFT) */ Word16 lenFFT, /* i : Number of FFT partitions */ - Word16 *psize, /* i : Partition sizes, fractional */ + Word16 *psize, /* i : Partition sizes, fractional Q9*/ Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ Word32 *msAlpha, /* i/o: Forgetting factors */ Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ @@ -1222,10 +1270,10 @@ void minimum_statistics_fx( /* No minimum statistics at initialization */ IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) { - Copy( msPeriodog, msPsd, len ); /* 6Q9 */ - Copy( msPeriodog, msNoiseFloor, len ); /* 6Q9 */ - Copy( msPeriodog, msNoiseEst, len ); /* 6Q9 */ - Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */ + Copy( msPeriodog, msPsd, len ); /* 6Q9 */ + Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor, len, Q16 ); /* Q25 */ + Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst, len, Q16 ); /* Q25 */ + Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */ set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len ); msPeriodogSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS ); @@ -1335,7 +1383,16 @@ void minimum_statistics_fx( /* Compute SNR */ /* msPeriodogSum[cnt] with format 16Q15 */ - snr = dotp_s_fx( msNoiseFloor + start, psize + start, current_len, CNG_HS ); + Word16 msNoiseFloor16tmp[NPART_SHAPING]; + IF( enc_dec == ENC ) + { + Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART, 0 ); + } + ELSE + { + Copy_Scale_sig32_16( msNoiseFloor, msNoiseFloor16tmp, NPART_SHAPING, 0 ); + } + snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS ); IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) ) { @@ -1366,16 +1423,16 @@ void minimum_statistics_fx( /* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */ s1 = WORD16_BITS - 1; move16(); - if ( msNoiseFloor[j] != 0 ) + if ( msNoiseFloor16tmp[j] != 0 ) { - s1 = norm_s( msNoiseFloor[j] ); + s1 = norm_s( msNoiseFloor16tmp[j] ); } - msNoiseFloor16 = shl( msNoiseFloor[j], s1 ); + msNoiseFloor16 = shl( msNoiseFloor16tmp[j], s1 ); scalar2 = L_mult( msNoiseFloor16, msNoiseFloor16 ); /* calculate difference, both elements in 6Q9 format, use absolute value to avoid -1.0 x -1.0 multiplications later */ - scalar316 = abs_s( sub( msPsd[j], msNoiseFloor[j] ) ); + scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) ); s2 = WORD16_BITS - 1; move16(); @@ -1475,7 +1532,7 @@ void minimum_statistics_fx( IF( msNoiseFloor[j] != 0 /*0.0 Q15*/ ) { - tmp = L_mult( msNoiseFloor[j], msNoiseFloor[j] ); + tmp = Mpy_32_32( msNoiseFloor[j], msNoiseFloor[j] ); tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s ); /* consider factor of 2 */ s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) ); @@ -1586,7 +1643,7 @@ void minimum_statistics_fx( } } /* Get the current noise floor */ - Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 ); + Copy32( msCurrentMinOut, msNoiseFloor, len ); } ELSE /* sub window complete */ { @@ -1644,7 +1701,7 @@ void minimum_statistics_fx( set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len ); /* Get the current noise floor */ - Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor, len, -16 ); + Copy32( msCurrentMinOut, msNoiseFloor, len ); } } @@ -1701,18 +1758,19 @@ void minimum_statistics_fx( hFdCngCom->msFrCnt = add( hFdCngCom->msFrCnt, 1 ); move16(); } - + Word64 tmp64; /* Smooth noise estimate during CNG phases */ FOR( j = 0; j < len; j++ ) { - msNoiseEst[j] = round_fx( L_mac( L_mult( 31130 /*0.95 Q15*/, msNoiseEst[j] ), 1638 /*0.05 Q15*/, msNoiseFloor[j] ) ); - move16(); + tmp64 = W_add( W_mult_32_16( msNoiseEst[j], 31130 /*0.95 Q15*/ ), W_mult_32_16( msNoiseFloor[j], 1638 /*0.05 Q15*/ ) ); + msNoiseEst[j] = W_extract_h( W_shl( tmp64, 16 ) ); // Q25 + move32(); } } IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) ) { // v_multc(msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING); - v_multc_att( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING ); + v_multc_att32( msNoiseEst, 23142, msNoiseEst, NPART_SHAPING ); } /* Collect buffers */ Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len ); @@ -1734,17 +1792,15 @@ void minimum_statistics_fx( { scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ ); } - scalar16 = round_fx( scalar ); - if ( GT_16( msNoiseEst[j], scalar16 ) /*0.0 Q15*/ ) + if ( GT_32( msNoiseEst[j], scalar ) /*0.0 Q15*/ ) { - msNoiseEst[j] = scalar16; - move16(); + msNoiseEst[j] = scalar; + move32(); } assert( msNoiseEst[j] >= 0 /*0.0 Q15*/ ); } } - /*------------------------------------------------------------------- * apply_scale() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 26999f048..b2df3a736 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5163,6 +5163,12 @@ void expand_range( Word16 *out_exp, const Word16 len ); +void expand_range_fx( + Word32 *in, // Q25 + Word32 *out, // exp:out_exp + Word16 *out_exp, + const Word16 len ); + void expand_range_var_exp( Word16 *in, Word16 in_exp, @@ -5198,8 +5204,8 @@ void minimum_statistics_fx( Word16 lenFFT, /* i : Number of FFT partitions */ Word16 *psize, /* i : Partition sizes, fractional */ Word16 *msPeriodog, /* i : Periodogram (energies) */ - Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */ - Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */ + Word32 *msNoiseFloor, /* i/o: Noise floors (energies) Q25*/ + Word32 *msNoiseEst, /* i/o: Noise estimates (energies) Q25*/ Word32 *msAlpha, /* i/o: Forgetting factors */ Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */ Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */ diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 99d202870..1d8185601 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -117,7 +117,7 @@ void initFdCngDec_ivas_fx( set16_fx( hFdCngDec->msPsd, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msPsd_fx, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msNoiseFloor, 0, NPART_SHAPING ); + set32_fx( hFdCngDec->msNoiseFloor_32fx, 0, NPART_SHAPING ); set32_fx( hFdCngDec->msNoiseEst, 0, NPART_SHAPING ); set16_fx( &hFdCngDec->msNoiseEst_exp, 0, 1 ); @@ -142,7 +142,7 @@ void initFdCngDec_ivas_fx( move16(); set16_fx( hFdCngDec->msLogPeriodog, 0, NPART_SHAPING ); - set16_fx( hFdCngDec->msLogNoiseEst, 0, NPART_SHAPING ); + set32_fx( hFdCngDec->msLogNoiseEst_32fx, 0, NPART_SHAPING ); set16_fx( hFdCngDec->psize_shaping, 0, NPART_SHAPING ); hFdCngDec->nFFTpart_shaping = 0; @@ -2231,8 +2231,8 @@ void perform_noise_estimation_dec_ivas_fx( nFFTpart, psize_norm, hFdCngDec->msLogPeriodog, - hFdCngDec->msNoiseFloor, - hFdCngDec->msLogNoiseEst, + hFdCngDec->msNoiseFloor_32fx, + hFdCngDec->msLogNoiseEst_32fx, hFdCngDec->msAlpha, hFdCngDec->msPsd, hFdCngDec->msPsdFirstMoment, @@ -2259,7 +2259,7 @@ void perform_noise_estimation_dec_ivas_fx( move16(); /* Expand MS outputs */ - expand_range( hFdCngDec->msLogNoiseEst, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); + expand_range_fx( hFdCngDec->msLogNoiseEst_32fx, hFdCngDec->msNoiseEst, &hFdCngDec->msNoiseEst_exp, npart ); } } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index fcd5142a4..4e4e33c36 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -94,11 +94,13 @@ typedef struct Word16 msPsdFirstMoment[NPART_SHAPING]; Word32 msPsdSecondMoment[NPART_SHAPING]; - Word16 msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */ - Word32 msNoiseEst[NPART_SHAPING]; /* Estimated noise level */ + Word16 msNoiseFloor[NPART_SHAPING]; /* Estimated noise floor */ + Word32 msNoiseFloor_32fx[NPART_SHAPING]; /* IVAS: Estimated noise floor Q25*/ + Word32 msNoiseEst[NPART_SHAPING]; /* Estimated noise level */ Word16 msNoiseEst_exp; Word16 msLogPeriodog[NPART_SHAPING]; Word16 msLogNoiseEst[NPART_SHAPING]; + Word32 msLogNoiseEst_32fx[NPART_SHAPING]; /*IVAS: Q25*/ Word16 npart_shaping; /* Number of partitions */ Word16 nFFTpart_shaping; /* Number of hybrid spectral partitions */ diff --git a/lib_enc/enc_uv_fx.c b/lib_enc/enc_uv_fx.c index a8612725b..887b4afb8 100644 --- a/lib_enc/enc_uv_fx.c +++ b/lib_enc/enc_uv_fx.c @@ -358,7 +358,7 @@ void encod_unvoiced_ivas_fx( // E_ACELP_innovative_codebook_fx( exc_fx, *pt_pitch_fx, 0, 1, gain_pit_fx, hLPDmem->tilt_code, acelp_cfg, i_subfr, p_Aq_fx, h1_fx, xn_fx, cn_fx, y1, y2_fx, (Word8) st_fx->acelp_autocorr, &prm, code_fx, shift, st_fx->L_frame, st_fx->last_L_frame, st_fx->total_brate, st_fx->element_mode ); inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, L_FRAME, st_fx->last_L_frame, - UNVOICED, st_fx->bwidth, st_fx->sharpFlag, i_subfr, -1, p_Aq_fx, + UNVOICED, st_fx->bwidth, 1, i_subfr, -1, p_Aq_fx, gain_pit_fx, cn_fx, exc_fx, h2_fx, hLPDmem->tilt_code, *pt_pitch_fx, xn_fx, code_fx, y2_fx, &unbits_PI, L_SUBFR, shift, Q_new ); E_ACELP_xy2_corr( xn_fx, y1, y2_fx, &g_corr, L_SUBFR, Q_xn ); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index a7339e653..fe5839565 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -130,8 +130,10 @@ void initFdCngEnc_fx( move16(); set16_fx( hsEnc->msLogPeriodog_fx, 0, NPART ); set16_fx( hsEnc->msLogNoiseEst_fx, 0, NPART ); + set32_fx( hsEnc->msLogNoiseEst_32fx, 0, NPART ); set16_fx( hsEnc->msPsd_fx, 0, NPART ); set16_fx( hsEnc->msNoiseFloor_fx, 0, NPART ); + set32_fx( hsEnc->msNoiseFloor_32fx, 0, NPART ); set32_fx( hsEnc->msMinBuf_fx, 2147483647l /*1.0 Q31*/, MSNUMSUBFR * NPART ); set32_fx( hsEnc->msCurrentMin_fx, 2147483647l /*1.0 Q31*/, NPART ); set32_fx( hsEnc->msCurrentMinOut_fx, 2147483647l /*1.0 Q31*/, NPART ); @@ -2240,12 +2242,12 @@ void perform_noise_estimation_enc_ivas_fx( Word16 nCLDFBpart = hFdCngEnc->hFdCngCom->nCLDFBpart; /* Q0 */ move16(); - Word16 *psize = hFdCngEnc->hFdCngCom->psize; // 6Q9 + Word16 *psize_norm = hFdCngEnc->hFdCngCom->psize_norm; // 6Q9 Word32 *msPeriodog_fx = hFdCngEnc->msPeriodog_fx; Word32 *msNoiseEst_fx = hFdCngEnc->msNoiseEst_fx; /* exp(msNoiseEst_fx_exp) */ Word16 *msLogPeriodog_fx = hFdCngEnc->msLogPeriodog_fx; - Word16 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_fx; + Word32 *msLogNoiseEst_fx = hFdCngEnc->msLogNoiseEst_32fx; Word32 scaleEB_fx = 0; move32(); @@ -2387,12 +2389,12 @@ void perform_noise_estimation_enc_ivas_fx( /* Call the minimum statistics routine for noise estimation */ - minimum_statistics_fx( npart, nFFTpart, psize, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, + minimum_statistics_fx( npart, nFFTpart, psize_norm, msLogPeriodog_fx, hFdCngEnc->msNoiseFloor_32fx, msLogNoiseEst_fx, hFdCngEnc->msAlpha_fx, hFdCngEnc->msPsd_fx, hFdCngEnc->msPsdFirstMoment_fx, hFdCngEnc->msPsdSecondMoment_fx, hFdCngEnc->msMinBuf_fx, hFdCngEnc->msBminWin_fx, hFdCngEnc->msBminSubWin_fx, hFdCngEnc->msCurrentMin_fx, hFdCngEnc->msCurrentMinOut_fx, hFdCngEnc->msCurrentMinSubWindow_fx, hFdCngEnc->msLocalMinFlag, hFdCngEnc->msNewMinFlag, hFdCngEnc->msPeriodogBuf_fx, &( hFdCngEnc->msPeriodogBufPtr ), hFdCngEnc->hFdCngCom, ENC, ( hCPE == NULL ) ? 0 : hCPE->element_mode ); /* Expand MS outputs */ - expand_range( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); + expand_range_fx( msLogNoiseEst_fx, msNoiseEst_fx, &hFdCngEnc->msNoiseEst_fx_exp, hFdCngEnc->hFdCngCom->npart ); return; } diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 18995bd1d..91e1b8520 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -521,7 +521,7 @@ static void IGF_CalculateEnvelope_ivas_fx( { IF( LT_32( 1, pPowerSpectrum_fx[sb] ) ) { - hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ), Q25 ) ); + hPrivateData->logSpec[sb] = s_max( 0, extract_l( W_extract_l( W_shr( W_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), W_shl( e_ps[sb], Q25 ) ), Q25 ) ) ) ); move16(); } ELSE diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index b9c515eea..2fbec12bd 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -381,8 +381,9 @@ typedef struct fd_cng_enc_structure Word16 msNewMinFlag[NPART]; Word16 msPsdFirstMoment_fx[NPART]; Word32 msPsdSecondMoment_fx[NPART]; - Word16 msNoiseFloor_fx[NPART]; /* Estimated noise floor */ - Word32 msNoiseEst_fx[NPART]; /* Estimated noise level */ + Word16 msNoiseFloor_fx[NPART]; /* Estimated noise floor */ + Word32 msNoiseFloor_32fx[NPART]; /* Estimated noise floor IVAS: Q25*/ + Word32 msNoiseEst_fx[NPART]; /* Estimated noise level */ Word16 msNoiseEst_fx_exp; Word32 energy_ho_fx[NPART]; Word16 energy_ho_fx_exp; @@ -399,6 +400,7 @@ typedef struct fd_cng_enc_structure Word16 partDec[NPART]; Word16 msLogPeriodog_fx[NPART]; Word16 msLogNoiseEst_fx[NPART]; + Word32 msLogNoiseEst_32fx[NPART]; /*IVAS: Q25*/ Word32 mem_coherence_fx[4]; Word16 mem_coherence_exp[4]; -- GitLab From 41ab0d527dbb7945e032f20c3cca6170435bb11c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 29 May 2025 15:53:53 +0530 Subject: [PATCH 163/692] Fix for 3GPP issue 1720: Memory allocation in ivas_dirac_dec_output_synthesis_process_slot_fx() Link #1720 --- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 51 +++++++++++-------- lib_rend/ivas_stat_rend.h | 2 + 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 622ebf89a..872d89c34 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -200,6 +200,12 @@ ivas_error ivas_dirac_dec_output_synthesis_open_fx( } dirac_output_synthesis_state->cy_cross_dir_smooth_prev_len = size; move16(); + + IF( ( dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx = (Word16 *) malloc( hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_dir * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis\n" ) ); + } + IF( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) ) { dirac_output_synthesis_state->cy_auto_dir_smooth_prev_fx = NULL; @@ -609,6 +615,11 @@ void ivas_dirac_dec_output_synthesis_close_fx( free( ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev_fx ); ( dirac_output_synthesis_state )->cy_cross_dir_smooth_prev_fx = NULL; } + IF( ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx != NULL ) + { + free( ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx ); + ( dirac_output_synthesis_state )->Q_temp_cy_cross_dir_smooth_fx = NULL; + } IF( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev_fx != NULL ) { free( ( dirac_output_synthesis_state )->cy_auto_diff_smooth_prev_fx ); @@ -818,13 +829,10 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( num_freq_bands ); /*h_dirac_output_synthesis_state->diffuse_power_factor_q+Q31-Q31->h_dirac_output_synthesis_state->diffuse_power_factor_q*/ /*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 ); 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; + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk] = h_dirac_output_synthesis_state->q_cy_cross_dir_smooth; move16(); } @@ -901,13 +909,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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-> (31-sqr_exp) */ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + 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 ) ); /*( 31- sqr_exp )-> h_dirac_output_synthesis_state->q_cy_cross_dir_smooth*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = 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*/ @@ -917,7 +925,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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 ); /*31-sqr_exp*/ move32(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -969,13 +977,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + 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*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = 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]*/ @@ -985,7 +993,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -1051,13 +1059,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + 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*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = 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]*/ @@ -1067,7 +1075,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -1092,13 +1100,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + 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*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = 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]*/ @@ -1108,7 +1116,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -1125,13 +1133,13 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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(); - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); + 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*/ - Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = 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]*/ @@ -1141,7 +1149,7 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( { 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] = sub( 31, sqr_exp ); + h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[ch_idx * num_freq_bands + k] = sub( 31, sqr_exp ); move16(); } } @@ -1152,16 +1160,15 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( tmp16 = imult1616( num_freq_bands, num_channels_dir ); FOR( Word16 kk = 0; kk < tmp16; kk++ ) { - temp = s_min( Q_temp_cy_cross_dir_smooth_fx[kk], temp ); + temp = s_min( h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk], temp ); } h_dirac_output_synthesis_state->q_cy_cross_dir_smooth = temp; move16(); FOR( Word16 kk = 0; kk < tmp16; 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( temp, Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ + 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( temp, h_dirac_output_synthesis_state->Q_temp_cy_cross_dir_smooth_fx[kk] ) ); /*Q_temp_cy_cross_dir_smooth_fx[kk]->temp*/ move32(); } - free( Q_temp_cy_cross_dir_smooth_fx ); /*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 ); IF( LT_16( temp_q, h_dirac_output_synthesis_state->q_cy_cross_dir_smooth ) ) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index a13ee27e7..00fbc2549 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -352,6 +352,8 @@ typedef struct dirac_output_synthesis_state_structure Word16 q_cy_cross_dir_smooth; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 q_cy_auto_diff_smooth; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ + Word16 *Q_temp_cy_cross_dir_smooth_fx; + Word16 cy_auto_dir_smooth_len; /* Target auto PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_cross_dir_smooth_len; /* Target cross PSD of direct sound. Size: num_freq_bands*num_channels. */ Word16 cy_auto_diff_smooth_len; /* Target auto PSD of diffuse sound. Size: num_freq_bands*num_channels. */ -- GitLab From f602e97871c026176fa68e63304c08a248a1de68 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 30 May 2025 15:42:13 +0530 Subject: [PATCH 164/692] Precision improvements for lp_noise, totalNoise; saturation resolution for non_staX --- lib_com/cnst.h | 1 + lib_com/ivas_prot_fx.h | 4 +-- lib_enc/bw_detect_fx.c | 13 +++++++- lib_enc/dtx_fx.c | 8 ++--- lib_enc/fd_cng_enc_fx.c | 12 +++++-- lib_enc/find_uv_fx.c | 6 ++-- lib_enc/init_enc_fx.c | 6 ++-- lib_enc/ivas_core_pre_proc_front_fx.c | 28 ++++++++-------- lib_enc/ivas_core_pre_proc_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 11 +++---- lib_enc/ivas_ism_dtx_enc_fx.c | 2 +- lib_enc/ivas_ism_metadata_enc_fx.c | 2 +- lib_enc/ivas_masa_enc_fx.c | 4 +-- lib_enc/ivas_omasa_enc_fx.c | 2 +- lib_enc/ivas_stereo_classifier_fx.c | 2 +- lib_enc/ivas_stereo_td_analysis_fx.c | 2 +- lib_enc/ivas_tcx_core_enc_fx.c | 4 +-- lib_enc/long_enr_fx.c | 44 ++++++++++++------------- lib_enc/nois_est_fx.c | 47 ++++++++++++++++++--------- lib_enc/prot_fx_enc.h | 13 ++++++-- lib_enc/speech_music_classif_fx.c | 6 ++-- lib_enc/stat_enc.h | 13 +++++--- lib_enc/vad_fx.c | 4 +-- 23 files changed, 140 insertions(+), 96 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 7b204a8e2..a2d051d87 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -759,6 +759,7 @@ enum #define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 ) #define E_MIN 0.0035f /* minimum allowable energy */ #define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ +#define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/ #define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ #define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ #define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 928736427..d9ca855be 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -2960,7 +2960,7 @@ Word16 ivas_acelp_tcx20_switching_fx( Word16 *inp_fx, /* i : new input signal */ Word16 q_inp, /* i : i/p Q */ Word16 *wsp, /* i : input weighted signal */ - Word16 non_staX, /* i : unbound non-stationarity for sp/mu clas */ + Word32 non_staX, /* i : unbound non-stationarity for sp/mu clas */ Word16 *pitch_fr, /* i : fraction pitch values */ Word16 *voicing_fr, /* i : fractional voicing values */ Word32 currFlatness, /* i : flatness */ @@ -3984,7 +3984,7 @@ Word16 ivas_smc_gmm_fx( const Word16 cor_map_sum_fx, /* i : correlation map sum (from multi-harmonic anal.) Q8 */ const Word32 epsP_fx[M + 1], /* i : LP prediciton error */ const Word32 PS_fx[], /* i : energy spectrum */ - const Word16 non_sta_fx, /* i : unbound non-stationarity Q8 */ + const Word32 non_sta_fx, /* i : unbound non-stationarity Q20 */ const Word16 relE_fx, /* i : relative frame energy Q8 */ Word16 *high_lpn_flag, /* i/o: sp/mus LPN flag */ const Word16 flag_spitch, /* i : flag to indicate very short stable pitch */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 050adbf01..94ed49129 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -71,6 +71,7 @@ void bw_detect_fx( Flag Overflow = 0; move32(); #endif + Word16 lp_noise_fx; bwd_count_wider_bw = BWD_COUNT_WIDER_BW; move16(); @@ -532,7 +533,17 @@ void bw_detect_fx( /*if( localVAD || st->lp_noise > 30 )*/ test(); - IF( st->localVAD || GT_16( st->lp_noise_fx, 7680 /*30 in Q8*/ ) ) + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + lp_noise_fx = st->lp_noise_fx; + move16(); + } + ELSE + { + lp_noise_fx = extract_h( st->lp_noise_32fx ); + } + + IF( st->localVAD || GT_32( ( lp_noise_fx ), 7680 /*30 in Q8*/ ) ) { /*st->lt_mean_NB_fx = ALPHA_BWD * st->lt_mean_NB_fx + (1-ALPHA_BWD) * mean_NB;*/ L_tmp = L_mult( ALPHA_BWD_FX, st->lt_mean_NB_fx ); /* Q15 * Q11 -> Q27 */ diff --git a/lib_enc/dtx_fx.c b/lib_enc/dtx_fx.c index 6d8a29795..7966fc7d8 100644 --- a/lib_enc/dtx_fx.c +++ b/lib_enc/dtx_fx.c @@ -95,7 +95,7 @@ void dtx_ivas_fx( test(); test(); test(); - last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); + last_br_cng_flag = LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_EVS ) || LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ) || ( EQ_16( st_fx->element_mode, IVAS_SCE ) && LE_32( st_fx->last_total_brate_cng, MAX_BRATE_DTX_IVAS ) ); test(); test(); @@ -103,7 +103,7 @@ void dtx_ivas_fx( last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) || ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || - LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); + LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 ); } /* Initialization */ @@ -211,7 +211,7 @@ void dtx_ivas_fx( test(); br_dtx_flag = ( ( st_fx->element_mode == EVS_MONO ) && LE_32( st_fx->total_brate, MAX_BRATE_DTX_EVS ) ) || ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) || - LT_16( st_fx->lp_noise_fx, DTX_THR * 256 ); + LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 ); } test(); test(); @@ -403,7 +403,7 @@ void dtx_ivas_fx( st_fx->cng_type = FD_CNG; move16(); } - ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_16( st_fx->lp_noise_fx, 512 /* 2 in Q8 */ ) ) ) + ELSE IF( EQ_16( st_fx->cng_type, FD_CNG ) && ( LT_32( st_fx->bckr_tilt_lt, fd_thresh ) ) && ( GT_32( st_fx->lp_noise_32fx, 67108864 /* 2 in Q24 */ ) ) ) { st_fx->cng_type = LP_CNG; move16(); diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index fe5839565..9298c8634 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -447,8 +447,16 @@ void resetFdCngEnc_fx( /* st->totalNoise_fx; Q8 Noise estimator - total noise energy */ /* Detect fast increase of totalNoise */ - totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx ); // Q8 - st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + totalNoiseIncrease = sub( hNoiseEst->totalNoise_fx, st->last_totalNoise_fx ); // Q8 + st->last_totalNoise_fx = hNoiseEst->totalNoise_fx; // Q8 + } + ELSE + { + totalNoiseIncrease = sub( extract_h( hNoiseEst->totalNoise_32fx ), st->last_totalNoise_fx ); // Q8 + st->last_totalNoise_fx = extract_h( hNoiseEst->totalNoise_32fx ); // Q8 + } move16(); IF( totalNoiseIncrease > 0 ) { diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index c4fe2e895..61de9ca7d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -853,11 +853,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ IF( st_fx->input_bwidth != NB ) { /*relE_thres = 0.700f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16) */ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, st_fx->lp_noise_fx ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 22938 /* 0.7 in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 IF( Last_Resort == 0 ) { /*relE_thres = 0.650f * st->lp_noise - 33.5f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, st_fx->lp_noise_fx ); // Q24 + L_tmp = L_mac( -562036736 /* 33.5f in Q24 */, 21299 /* 0.650f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 } relE_thres = round_fx( L_tmp ); } @@ -865,7 +865,7 @@ Word16 find_uv_ivas_fx( /* o : coding typ { /*relE_thres = 0.60f * st->lp_noise - 28.2f; (lp_noise in Q8, constant Q8<<16)*/ - L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, st_fx->lp_noise_fx ); // Q24 + L_tmp = L_mac( -473117491 /* 28.2f in Q24 */, 19661 /* 0.6f in Q15 */, extract_h( st_fx->lp_noise_32fx ) ); // Q24 relE_thres = round_fx( L_tmp ); } relE_thres = s_max( relE_thres, -6400 /* -25.0f in Q8 */ ); /* Q8 */ diff --git a/lib_enc/init_enc_fx.c b/lib_enc/init_enc_fx.c index 543a6fab9..ba1d47f79 100644 --- a/lib_enc/init_enc_fx.c +++ b/lib_enc/init_enc_fx.c @@ -1572,9 +1572,9 @@ ivas_error init_encoder_ivas_fx( * DTX *-----------------------------------------------------------------*/ - st->lp_speech_fx = 11520; /*Q8 (45.0) */ /* Initialize the long-term active speech level in dB */ - move16(); - st->lp_noise_fx = 0; + st->lp_speech_32fx = 754974720; /*Q24 (45.0) */ /* Initialize the long-term active speech level in dB */ + move32(); + st->lp_noise_32fx = 0; move16(); st->flag_noisy_speech_snr = 0; move16(); diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 3e7bf2464..fbd207e26 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -158,7 +158,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 high_lpn_flag; Word16 lsf_new_fx[M]; // Q2.56 Word16 localVAD_HE_SAD; - Word16 non_staX_fx; + Word32 non_staX_fx; Word16 alw_pitch_lag_12k8[2]; Word16 alw_voicing_fx[2]; Word16 last_core_orig; @@ -191,7 +191,7 @@ ivas_error pre_proc_front_ivas_fx( Word16 ncharX_fx; Word16 ncharX_LR_fx; /* noise character for sp/mus classifier */ Word16 loc_harmLR_fx[CPE_CHANNELS]; /* harmonicity flag */ - Word16 non_staX_LR_fx; /* non-stationarity for sp/mus classifier */ + Word32 non_staX_LR_fx; /* non-stationarity for sp/mus classifier */ Word16 sp_div_fx; Word16 q_sp_div; Word16 sp_div_LR_fx; @@ -742,7 +742,7 @@ ivas_error pre_proc_front_ivas_fx( IF( hStereoClassif != NULL ) { - IF( GT_32( sub( st->lp_speech_fx, extract_h( Etot_fx ) ), 25 << Q8 ) ) /*Q8*/ + IF( GT_32( L_sub( st->lp_speech_32fx, Etot_fx ), 25 << Q24 ) ) /*Q8*/ { hStereoClassif->silence_flag = 2; move16(); @@ -806,7 +806,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( ( hCPE != NULL && !( lr_vad_enabled && st->idchan == 0 ) ) || hSCE != NULL ) { - *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, sub( st->lp_speech_fx, st->lp_noise_fx ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ + *vad_flag_dtx = ivas_dtx_hangover_addition_fx( st, st->vad_flag, extract_h( L_sub( st->lp_speech_32fx, st->lp_noise_32fx ) ), 0, vad_hover_flag, NULL, NULL, NULL ); /* Q0 */ move16(); } ELSE @@ -904,21 +904,21 @@ ivas_error pre_proc_front_ivas_fx( *----------------------------------------------------------------*/ noise_est_down_ivas_fx( fr_bands_fx, fr_bands_fx_q, st->hNoiseEst->bckr_fx, &st->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band, - &st->hNoiseEst->totalNoise_fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_32fx ); + &st->hNoiseEst->totalNoise_32fx, Etot_fx, &st->hNoiseEst->Etot_last_32fx, &st->hNoiseEst->Etot_v_h2_32fx ); test(); IF( lr_vad_enabled && st->idchan == 0 ) { - noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx ); - noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx ); + noise_est_down_ivas_fx( fr_bands_LR_fx[0], fr_bands_LR_fx_q[0], hCPE->hFrontVad[0]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[0]->hNoiseEst->q_bckr, tmpN_LR_fx[0], &q_tmpN_LR[0], tmpE_LR_fx[0], &q_tmpE_LR[0], st->min_band, st->max_band, &hCPE->hFrontVad[0]->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_LR_fx[0] ), &hCPE->hFrontVad[0]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[0]->hNoiseEst->Etot_v_h2_32fx ); + noise_est_down_ivas_fx( fr_bands_LR_fx[1], fr_bands_LR_fx_q[1], hCPE->hFrontVad[1]->hNoiseEst->bckr_fx, &hCPE->hFrontVad[1]->hNoiseEst->q_bckr, tmpN_LR_fx[1], &q_tmpN_LR[1], tmpE_LR_fx[1], &q_tmpE_LR[1], st->min_band, st->max_band, &hCPE->hFrontVad[1]->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_LR_fx[1] ), &hCPE->hFrontVad[1]->hNoiseEst->Etot_last_32fx, &hCPE->hFrontVad[1]->hNoiseEst->Etot_v_h2_32fx ); - corr_shiftL_fx = correlation_shift_fx( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_fx ); // Q15 - corr_shiftR_fx = correlation_shift_fx( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_fx ); // Q15 + corr_shiftL_fx = correlation_shift_fx( extract_h( hCPE->hFrontVad[0]->hNoiseEst->totalNoise_32fx ) ); // Q15 + corr_shiftR_fx = correlation_shift_fx( extract_h( hCPE->hFrontVad[1]->hNoiseEst->totalNoise_32fx ) ); // Q15 } - *relE_fx = sub( extract_h( Etot_fx ), st->lp_speech_fx ); // Q8 + *relE_fx = sub( extract_h( Etot_fx ), extract_h( st->lp_speech_32fx ) ); // Q8 move16(); - corr_shift_fx = correlation_shift_fx( st->hNoiseEst->totalNoise_fx ); /* Q15 */ + corr_shift_fx = correlation_shift_fx( extract_h( st->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ /*----------------------------------------------------------------* * FD-CNG Noise Estimator @@ -1397,7 +1397,7 @@ ivas_error pre_proc_front_ivas_fx( move16(); stereo_classifier_features_ivas_fx( hStereoClassif, st->idchan, element_mode, localVAD_HE_SAD, lsf_new_fx, epsP_fx, st->pitch, st->voicing_fx, *cor_map_sum_fx, non_staX_fx, sp_div_fx, - st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q8 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); + st->clas, sub( 31, *epsP_fx_q ), ( 31 - Q8 ) /* exp of cor_map_sum */, ( 31 - Q20 ) /* exp of non_staX_fx */, sub( 15, q_sp_div ) ); } /*----------------------------------------------------------------* @@ -1443,7 +1443,7 @@ ivas_error pre_proc_front_ivas_fx( * Update of old per-band energy spectrum *----------------------------------------------------------------*/ - ivas_long_enr_fx( st, extract_h( Etot_fx ), localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); + ivas_long_enr_fx( st, Etot_fx, localVAD_HE_SAD, high_lpn_flag, NULL, 1, NULL, NULL ); Copy32( fr_bands_fx + NB_BANDS, st->hNoiseEst->enrO_fx, NB_BANDS ); /* fr_bands_fx_q */ st->hNoiseEst->q_enrO = fr_bands_fx_q; @@ -1452,7 +1452,7 @@ ivas_error pre_proc_front_ivas_fx( test(); IF( lr_vad_enabled && st->idchan == 0 ) { - ivas_long_enr_fx( st, -256 /*-1 q8*/, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx ); + ivas_long_enr_fx( st, -16777216 /*-1 << 24*/, localVAD_HE_SAD, high_lpn_flag, hCPE->hFrontVad, CPE_CHANNELS, localVAD_HE_SAD_LR, Etot_LR_fx ); Copy32( fr_bands_LR_fx[0] + NB_BANDS, hCPE->hFrontVad[0]->hNoiseEst->enrO_fx, NB_BANDS ); // fr_bands_LR_fx_q hCPE->hFrontVad[0]->hNoiseEst->q_enrO = fr_bands_LR_fx_q[0]; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 938ab9964..623b38e68 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -462,7 +462,7 @@ ivas_error pre_proc_ivas_fx( IF( EQ_16( st->coder_type, GENERIC ) || EQ_16( st->coder_type, VOICED ) || EQ_16( st->coder_type, TRANSITION ) ) { test(); - IF( GE_32( element_brate, FRMT_SHP_MIN_BRATE_IVAS ) && GT_16( st->lp_noise_fx, FORMANT_SHARPENING_NOISE_THRESHOLD_FX ) ) + IF( GE_32( element_brate, FRMT_SHP_MIN_BRATE_IVAS ) && GT_32( st->lp_noise_32fx, FORMANT_SHARPENING_NOISE_THRESHOLD_FX << 16 ) ) { st->sharpFlag = 0; move16(); diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index a6054a841..963e363b2 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -492,7 +492,7 @@ ivas_error front_vad_spar_fx( Word16 sp_div_fx; Word16 Q_sp_div; - Word16 non_staX_fx; + Word32 non_staX_fx; Word16 sp_floor; Word16 cor_map_sum_fx; @@ -603,9 +603,9 @@ ivas_error front_vad_spar_fx( Word16 q_tmpN, q_tmpE; noise_est_down_ivas_fx( fr_bands_fx[0], q_fr_bands[0], hFrontVad->hNoiseEst->bckr_fx, &hFrontVad->hNoiseEst->q_bckr, tmpN_fx, &q_tmpN, tmpE_fx, &q_tmpE, st->min_band, st->max_band, - &hFrontVad->hNoiseEst->totalNoise_fx, L_deposit_h( Etot_fx[0] ) /*q8->q24*/, &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_32fx ); + &hFrontVad->hNoiseEst->totalNoise_32fx, L_deposit_h( Etot_fx[0] ) /*q8->q24*/, &hFrontVad->hNoiseEst->Etot_last_32fx, &hFrontVad->hNoiseEst->Etot_v_h2_32fx ); - corr_shift_fx = correlation_shift_fx( hFrontVad->hNoiseEst->totalNoise_fx ); /* Q15 */ + corr_shift_fx = correlation_shift_fx( extract_h( hFrontVad->hNoiseEst->totalNoise_32fx ) ); /* Q15 */ dtx_ivas_fx( st, hEncoderConfig->last_ivas_total_brate, hEncoderConfig->ivas_total_brate, vad_flag_dtx[0], inp_12k8_fx, Q_inp_12k8 ); @@ -637,7 +637,7 @@ ivas_error front_vad_spar_fx( move32(); } - relE_fx = sub( Etot_fx[0], st->lp_speech_fx ); + relE_fx = sub( Etot_fx[0], extract_h( st->lp_speech_32fx ) ); Scale_sig( A_fx, ( L_FRAME / L_SUBFR ) * ( M + 1 ), -2 ); // Q12 st->mem_wsp_fx = (Word16) shl_sat( st->mem_wsp_fx, Q_inp_12k8 - st->mem_wsp_q ); /* Q_inp_12k8 */ @@ -749,13 +749,12 @@ ivas_error front_vad_spar_fx( /* 1st stage speech/music classification (GMM model) */ /* run only to get 'high_lpn_flag' parameter */ SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; - Word16 non_sta_fx = shr( non_staX_fx, Q2 ); // Q8->Q6 Word16 Etot_fx_0 = Etot_fx[0]; move16(); scale = getScaleFactor32( PS_fx, 128 ); Qfact_PS = add( Qfact_PS, scale ); Scale_sig32( PS_fx, 128, scale ); - ivas_smc_gmm_fx( st, NULL, localVAD_HE_SAD[0], Etot_fx_0, lsp_new_fx, cor_map_sum_fx, epsP_fx, PS_fx, non_sta_fx, relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q ); + ivas_smc_gmm_fx( st, NULL, localVAD_HE_SAD[0], Etot_fx_0, lsp_new_fx, cor_map_sum_fx, epsP_fx, PS_fx, non_staX_fx, relE_fx, &high_lpn_flag, flag_spitch, Qfact_PS, Q_esp, hSpMusClas->past_PS_Q ); /* long-term energy update */ ivas_long_enr_fx( st, -256 /*-1 q8*/, localVAD_HE_SAD[0], high_lpn_flag, &hFrontVad, 1, localVAD_HE_SAD, Etot_fx ); diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index b06acfbac..bc2c83de1 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -143,7 +143,7 @@ Word16 ivas_ism_dtx_enc_fx( /* one of the channels is active -> no DTX */ FOR( ch = 0; ch < nchan_transport; ch++ ) { - lp_noise_fx[ch] = hSCE[ch]->hCoreCoder[0]->lp_noise_fx; /*Q8*/ + lp_noise_fx[ch] = extract_h( hSCE[ch]->hCoreCoder[0]->lp_noise_32fx ); /*Q8*/ move16(); } diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index 1efbb2123..594871b29 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -277,7 +277,7 @@ ivas_error ivas_ism_metadata_enc_fx( /* In case of low level noise for low bitrate inactive frames, do not sent metadata */ test(); test(); - hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || GT_16( hSCE[ch]->hCoreCoder[0]->lp_noise_fx, 2560 /*10 Q8*/ ) || hSCE[ch]->hCoreCoder[0]->tcxonly; + hIsmMeta[ch]->ism_metadata_flag = vad_flag[ch] || GT_32( hSCE[ch]->hCoreCoder[0]->lp_noise_32fx, 167772160 /*10 Q24*/ ) || hSCE[ch]->hCoreCoder[0]->tcxonly; move16(); } diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 9d0579d12..303d11698 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1195,12 +1195,12 @@ ivas_error ivas_masa_enc_config_fx( test(); IF( EQ_16( st_ivas->hCPE[0]->element_mode, IVAS_CPE_DFT ) || LT_16( st_ivas->hMasa->data.hOmasaData->omasa_stereo_sw_cnt, OMASA_STEREO_SW_CNT_MAX ) ) { - st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx; /*Q8*/ + st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_32fx ); /*Q8*/ } ELSE { /* ( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise + st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise ) / CPE_CHANNELS; */ - st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( L_mac( L_mult( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_fx, ONE_IN_Q14 ), st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_fx, ONE_IN_Q14 ) ); /*Q8*/ + st_ivas->hMasa->data.hOmasaData->lp_noise_CPE_fx = extract_h( L_mac( L_mult( extract_h( st_ivas->hCPE[0]->hCoreCoder[0]->lp_noise_32fx ), ONE_IN_Q14 ), extract_h( st_ivas->hCPE[0]->hCoreCoder[1]->lp_noise_32fx ), ONE_IN_Q14 ) ); /*Q8*/ } move16(); } diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index b5b592582..b88bb69a1 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -795,7 +795,7 @@ void ivas_set_ism_importance_interformat_fx( IF( active_flag == 0 ) { test(); - if ( GT_16( st->lp_noise_fx, 3840 /* 15 in Q8 */ ) || LT_16( sub( lp_noise_CPE_fx, st->lp_noise_fx ), 7680 /* 30 in Q8 */ ) ) + if ( GT_32( st->lp_noise_32fx, 251658240 /* 15 in Q24 */ ) || LT_16( sub( lp_noise_CPE_fx, extract_h( st->lp_noise_32fx ) ), 7680 /* 30 in Q8 */ ) ) { active_flag = 1; move16(); diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 3a040517a..2c1bc0317 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -1507,7 +1507,7 @@ void xtalk_classifier_dft_fx( hStereoClassif->xtalk_decision = 1; move16(); } - ELSE IF( GE_32( hCPE->element_brate, IVAS_16k4 ) && hStereoClassif->xtalk_decision == 0 && GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && GT_16( sub( hCPE->hCoreCoder[0]->lp_speech_fx, hCPE->hCoreCoder[0]->lp_noise_fx ), 25 << 8 ) ) + ELSE IF( GE_32( hCPE->element_brate, IVAS_16k4 ) && hStereoClassif->xtalk_decision == 0 && GT_16( abs_s( itd ), STEREO_DFT_ITD_MAX ) && GT_32( L_sub( hCPE->hCoreCoder[0]->lp_speech_32fx, hCPE->hCoreCoder[0]->lp_noise_32fx ), 25 << 24 ) ) { hStereoClassif->xtalk_decision = 1; move16(); diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index 909d0c206..de47ea8e2 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -564,7 +564,7 @@ Word16 stereo_tdm_ener_analysis_fx( } } - IF( LT_16( sub( sts[1]->lp_speech_fx, sts[1]->lp_noise_fx ), 12800 /*50.0f in Q8*/ ) ) /* likely presence of noisy content */ + IF( LT_32( L_sub( sts[1]->lp_speech_32fx, sts[1]->lp_noise_32fx ), 838860800 /*50.0f in Q24*/ ) ) /* likely presence of noisy content */ { /* pointing in the right direction, inverse it else do nothing */ test(); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 5f2e9a8e0..da141f473 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -715,7 +715,7 @@ Word16 ivas_acelp_tcx20_switching_fx( Word16 *inp_fx, Word16 q_inp, Word16 *wsp, /*q_inp i : input weighted signal */ - Word16 non_staX, /*Q8 i : unbound non-stationarity for sp/mu clas*/ + Word32 non_staX, /*Q20 i : unbound non-stationarity for sp/mu clas*/ Word16 *pitch_fr, /*Q6 i : fraction pitch values */ Word16 *voicing_fr, /*Q15 i : fractional voicing values */ Word32 currFlatness, /*Q21 i : flatness */ @@ -1276,7 +1276,7 @@ Word16 ivas_acelp_tcx20_switching_fx( test(); test(); test(); - if ( ( !flag_16k_smc ) && ( LT_32( offset_tcx, 0x18950F ) ) && GT_16( non_staX, 1280 /*5.0f Q8*/ ) && ( GE_32( snr_acelp, L_sub( tcx_snr, 262144 /*4.0f in Q16*/ ) ) ) && GE_16( st->Nb_ACELP_frames, 1 ) && ( ( GT_16( st->hSpMusClas->lps_fx, st->hSpMusClas->lpm_fx ) && GE_32( mean_voicing_fr, /* 0.3 in Q30 */ 322122547 ) ) || ( GE_16( st->Nb_ACELP_frames, 6 ) && GT_16( st->hSpMusClas->lps_fx, sub( st->hSpMusClas->lpm_fx, 192 /*1.5in Q7*/ ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag ) + if ( ( !flag_16k_smc ) && ( LT_32( offset_tcx, 0x18950F ) ) && GT_32( non_staX, 5242880 /*5.0f Q20*/ ) && ( GE_32( snr_acelp, L_sub( tcx_snr, 262144 /*4.0f in Q16*/ ) ) ) && GE_16( st->Nb_ACELP_frames, 1 ) && ( ( GT_16( st->hSpMusClas->lps_fx, st->hSpMusClas->lpm_fx ) && GE_32( mean_voicing_fr, /* 0.3 in Q30 */ 322122547 ) ) || ( GE_16( st->Nb_ACELP_frames, 6 ) && GT_16( st->hSpMusClas->lps_fx, sub( st->hSpMusClas->lpm_fx, 192 /*1.5in Q7*/ ) ) ) ) && ( st->sp_aud_decision0 == 0 ) && st->vad_flag ) { /* Fine tuned across various databases based on various metrics to detect TCX frames in speech.*/ dsnr = 262144; /*4.0f Q16*/ diff --git a/lib_enc/long_enr_fx.c b/lib_enc/long_enr_fx.c index 60c40b3fe..93918b81e 100644 --- a/lib_enc/long_enr_fx.c +++ b/lib_enc/long_enr_fx.c @@ -17,7 +17,7 @@ *-------------------------------------------------------------------*/ void ivas_long_enr_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q8 */ + const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q24 */ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover Q0*/ Word16 high_lpn_flag, /* i : sp/mus LPN flag Q0*/ FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ @@ -28,7 +28,7 @@ void ivas_long_enr_fx( ) { Word16 tmp; - Word16 alpha; + Word32 alpha; NOISE_EST_HANDLE hNoiseEst = st_fx->hNoiseEst; /*-----------------------------------------------------------------* @@ -42,7 +42,7 @@ void ivas_long_enr_fx( { FOR( n = 0; n < n_chan; n++ ) { - hFrontVad[n]->lp_noise_fx = hFrontVad[n]->hNoiseEst->totalNoise_fx; /* Q8 */ + hFrontVad[n]->lp_noise_fx = extract_h( hFrontVad[n]->hNoiseEst->totalNoise_32fx ); /* Q8 */ move16(); tmp = add( hFrontVad[n]->lp_noise_fx, 2560 ); /* Q8 */ @@ -74,7 +74,7 @@ void ivas_long_enr_fx( FOR( n = 0; n < n_chan; n++ ) { - hFrontVad[n]->lp_noise_fx = add( mult_r( smooth_prev, hFrontVad[n]->lp_noise_fx ), mult_r( smooth_curr, hFrontVad[n]->hNoiseEst->totalNoise_fx ) ); /* Q8 */ + hFrontVad[n]->lp_noise_fx = add( mult_r( smooth_prev, hFrontVad[n]->lp_noise_fx ), mult_r( smooth_curr, extract_h( hFrontVad[n]->hNoiseEst->totalNoise_32fx ) ) ); /* Q8 */ move16(); test(); IF( localVAD_HE_SAD_LR[n] && !high_lpn_flag ) @@ -102,11 +102,11 @@ void ivas_long_enr_fx( { IF( LT_16( st_fx->ini_frame, 4 ) ) { - st_fx->lp_noise_fx = hNoiseEst->totalNoise_fx; /* Q8 */ - move16(); - tmp = add( st_fx->lp_noise_fx, 2560 ); /*10.0 in Q8*/ - st_fx->lp_speech_fx = s_max( st_fx->lp_speech_fx, tmp ); - move16(); + st_fx->lp_noise_32fx = hNoiseEst->totalNoise_32fx; /* Q24 */ + move32(); + Word32 tmp1 = L_add( st_fx->lp_noise_32fx, 167772160 ); /*10.0 in Q24*/ + st_fx->lp_speech_32fx = L_max( st_fx->lp_speech_32fx, tmp1 ); + move32(); } ELSE { @@ -115,34 +115,34 @@ void ivas_long_enr_fx( } else { st->lp_noise = 0.98f * st->lp_noise + 0.02f * st->totalNoise; } */ - alpha = 655; /* 0.02 Q15 */ - move16(); + alpha = 42949673; /* 0.02 Q31 */ + move32(); if ( LT_16( st_fx->ini_frame, 150 ) ) /* should match HE_LT_CNT_INIT_FX */ { - alpha = 1638; - move16(); /* 0.05 Q15 */ + alpha = 107374182; + move32(); /* 0.05 Q31 */ } - st_fx->lp_noise_fx = noise_est_AR1_Qx( hNoiseEst->totalNoise_fx, st_fx->lp_noise_fx, alpha ); /* Q8 state, alpha in Q15 */ - move16(); + st_fx->lp_noise_32fx = noise_est_AR1_Qx_32( hNoiseEst->totalNoise_32fx, st_fx->lp_noise_32fx, alpha ); /* Q24 state, alpha in Q31 */ + move32(); test(); IF( ( localVAD_HE_SAD != 0 ) && ( high_lpn_flag == 0 ) ) { - IF( LT_16( sub( st_fx->lp_speech_fx, Etot ), 2560 ) ) /* 10.0 in Q8 */ + IF( LT_32( L_sub( st_fx->lp_speech_32fx, Etot ), 167772160 ) ) /* 10.0 in Q24 */ { /* st->lp_speech = 0.98f * st->lp_speech + 0.02f * Etot; */ - st_fx->lp_speech_fx = noise_est_AR1_Qx( Etot, st_fx->lp_speech_fx, 655 ); /* Q8 state, 0.02 in Q15 */ - move16(); + st_fx->lp_speech_32fx = noise_est_AR1_Qx_32( Etot, st_fx->lp_speech_32fx, 42949673 ); /* Q24 state, 0.02 in Q31 */ + move32(); } ELSE { - st_fx->lp_speech_fx = sub( st_fx->lp_speech_fx, 13 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ - move16(); + st_fx->lp_speech_32fx = L_sub( st_fx->lp_speech_32fx, 838861 ); /* st->lp_speech = st->lp_speech - 0.05f; linear decay*/ + move32(); } } } /* Update */ - st_fx->hNoiseEst->Etot_last_32fx = L_deposit_h( Etot ); /* Q24 */ - move16(); + st_fx->hNoiseEst->Etot_last_32fx = Etot; /* Q24 */ + move32(); } /*-----------------------------------------------------------------* diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 7534a5159..676696fd6 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -75,6 +75,20 @@ Word16 noise_est_AR1_Qx( /* o : Qx y(n) */ return mac_r( L_mult( y, alpham1 ), x, alpha ); } +Word32 noise_est_AR1_Qx_32( /* o : Qx y(n) */ + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /*i : Q15 scaling of driving x(n) */ +) +{ + Word32 alpham1; + /*alpham1 = negate(add((Word16)-32768, alpha)); */ + alpham1 = L_sub( MAX_32, alpha ); /* one cycle less */ + alpham1++; + + return Madd_32_32( Mpy_32_32( y, alpham1 ), x, alpha ); +} + /*-----------------------------------------------------------------* * noise_est_ln_q8_fx() * @@ -280,7 +294,7 @@ void noise_est_init_ivas_fx( move32(); /*Q7//E_MIN; */ hNoiseEst->enrO_fx[i] = E_MIN_Q11_FX; move32(); - hNoiseEst->bckr_fx[i] = E_MIN_Q11_FX; + hNoiseEst->bckr_fx[i] = E_MIN_Q27_FX; move32(); hNoiseEst->ave_enr_fx[i] = E_MIN_Q11_FX; move32(); @@ -289,14 +303,14 @@ void noise_est_init_ivas_fx( move16(); /*1e-5f; */ hNoiseEst->q_enrO = Q11; move16(); - hNoiseEst->q_bckr = Q11; + hNoiseEst->q_bckr = Q27; move16(); hNoiseEst->ave_enr_q = Q11; move16(); move16(); - hNoiseEst->totalNoise_fx = 0; - move16(); + hNoiseEst->totalNoise_32fx = 0; + move32(); hNoiseEst->first_noise_updt = 0; move16(); hNoiseEst->first_noise_updt_cnt = 0; @@ -747,7 +761,7 @@ void noise_est_down_ivas_fx( Word16 *q_enr, const Word16 min_band, /* i : minimum critical band */ const Word16 max_band, /* i : maximum critical band */ - Word16 *totalNoise, /* o : noise estimate over all critical bands */ + Word32 *totalNoise, /* o : noise estimate over all critical bands */ Word32 Etot, /* i : Energy of current frame Q24*/ Word32 *Etot_last, /* i/o: Energy of last frame Q24 */ Word32 *Etot_v_h2 /* i/o: Energy variations of noise frames Q24 */ @@ -803,8 +817,8 @@ void noise_est_down_ivas_fx( Ltmp = L_mac( L_deposit_h( e_Noise ), f_Noise, 1 ); // Q16 Ltmp = Mpy_32_16_1( Ltmp, LG10 ); // Q14 (16+13-15) Ltmp = L_shl( Ltmp, 10 ); // Q26 - *totalNoise = round_fx( Ltmp ); /*Q8*/ - move16(); + *totalNoise = ( Ltmp ); /*Q24*/ + move32(); /*-----------------------------------------------------------------* * Average energy per frame for each frequency band @@ -2207,7 +2221,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 */ - Word16 *non_staX, /* o : non-stationarity for sp/mus classifier Q8 */ + Word32 *non_staX, /* o : non-stationarity for sp/mus classifier Q20 */ 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 */ @@ -2728,7 +2742,7 @@ void noise_est_ivas_fx( Ltmp1 = Mpy_32_16_1( Ltmp1, 22713 ); // Q15 log_enr16 = round_fx( L_shl( Ltmp1, 9 ) ); /* Q8 */ wtmp = abs_s( sub( log_enr16, hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] ) ); - *non_staX = add_o( *non_staX, wtmp, &Overflow ); + *non_staX = L_add( *non_staX, wtmp ); move16(); /* Q8 */ hSpMusClas->past_log_enr_fx[i - START_BAND_SPMUS] = log_enr16; move16(); @@ -2773,8 +2787,9 @@ void noise_est_ivas_fx( } } - } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */ - + } /* end of band loop FOR( i = st_fx->min_band; i <= st_fx->max_band; i++ ) */ + *non_staX = L_shl( *non_staX, 12 ); // Q20 + move32(); IF( LT_16( Etot, -1280 /* -5.0f in Q8 */ ) ) { non_sta = L_deposit_l( 1024 ); /* 1.0 in Q10 */ @@ -2974,7 +2989,7 @@ void noise_est_ivas_fx( * long term extensions of frame features *-----------------------------------------------------------------*/ - tmp = sub( Etot, hNoiseEst->totalNoise_fx ); /* Q8 */ + tmp = sub( Etot, extract_h( hNoiseEst->totalNoise_32fx ) ); /* Q8 */ /* st->lt_tn_track = 0.03f* (Etot - st->totalNoise < 10) + 0.97f*st->lt_tn_track; */ tmp2 = 0; move16(); @@ -3471,7 +3486,7 @@ void noise_est_ivas_fx( test(); test(); IF( ( LT_16( hNoiseEst->act_pred_fx, 27853 /* 0.85 in Q15 */ ) && ( aE_bgd != 0 ) && ( LT_16( hNoiseEst->lt_Ellp_dist_fx, 10 * 256 /* 10 in Q8*/ ) || ( sd1_bgd != 0 ) ) && ( LT_16( hNoiseEst->lt_tn_dist_fx, 40 * 256 ) ) /* 40.0 in Q8*/ - && LT_16( sub( Etot, hNoiseEst->totalNoise_fx ), 10 * 256 /* 10 in Q8 */ ) /* 10.0 in Q8*/ ) || + && LT_16( sub( Etot, extract_h( hNoiseEst->totalNoise_32fx ) ), 10 * 256 /* 10 in Q8 */ ) /* 10.0 in Q8*/ ) || ( ( hNoiseEst->first_noise_updt == 0 ) && GT_16( hNoiseEst->harm_cor_cnt, 80 ) && ( aE_bgd != 0 ) && GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 /* 0.5 in Q15 */ ) ) || ( ( tn_ini != 0 ) && ( ( aE_bgd != 0 ) || LT_16( non_staB, 10 * 256 /* 10 in Q8*/ ) || GT_16( hNoiseEst->harm_cor_cnt, 80 ) ) ) ) { @@ -3494,7 +3509,7 @@ void noise_est_ivas_fx( ) */ ELSE IF( ( LT_16( hNoiseEst->act_pred_fx, 26214 /* 0.8 in Q15*/ ) && ( ( aE_bgd != 0 ) || ( PAU != 0 ) ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 3277 /* 0.1 in q15*/ ) ) ) || ( ( LT_16( hNoiseEst->act_pred_fx, 22938 /* 0.70 in Q15 */ ) ) && ( ( aE_bgd != 0 ) || ( LT_16( non_staB, 17 * 256 /* 17.0 in Q8 */ ) ) ) && ( PAU != 0 ) && ( LT_16( hNoiseEst->lt_haco_ev_fx, 4915 /* 0.15 in Q15 */ ) ) ) || - ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) && GT_16( hNoiseEst->totalNoise_fx, 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, extract_h( L_add( hNoiseEst->Etot_v_h2_32fx, L_shr( hNoiseEst->Etot_v_h2_32fx, 1 ) ) ) /* 1.5= 1.0+.5 */ ) ) ) ) || + ( GT_16( hNoiseEst->harm_cor_cnt, 80 ) && GT_16( extract_h( hNoiseEst->totalNoise_32fx ), 5 * 256 /* 5.0 in Q8 */ ) && LT_16( Etot, s_max( 1 * 256, add( Etot_l_lp, extract_h( L_add( hNoiseEst->Etot_v_h2_32fx, L_shr( hNoiseEst->Etot_v_h2_32fx, 1 ) ) ) /* 1.5= 1.0+.5 */ ) ) ) ) || ( GT_16( hNoiseEst->harm_cor_cnt, 50 ) && GT_16( hNoiseEst->first_noise_updt, 30 ) && ( aE_bgd != 0 ) && GT_16( hNoiseEst->lt_aEn_zero_fx, 16384 /*.5 in Q15*/ ) ) || ( tn_ini != 0 ) ) { updt_step = 3277; @@ -3513,7 +3528,7 @@ void noise_est_ivas_fx( test(); if ( ( aE_bgd == 0 ) && LT_16( hNoiseEst->harm_cor_cnt, 50 ) && ( GT_16( hNoiseEst->act_pred_fx, 19661 /* 0.6 in Q15*/ ) || - ( ( tn_ini == 0 ) && LT_16( sub( Etot_l_lp, hNoiseEst->totalNoise_fx ), 10 * 256 /* 10.0 in Q8 */ ) && GT_16( non_staB, 8 * 256 /* 8.0 in in Q8*/ ) ) ) ) + ( ( tn_ini == 0 ) && LT_16( sub( Etot_l_lp, extract_h( hNoiseEst->totalNoise_32fx ) ), 10 * 256 /* 10.0 in Q8 */ ) && GT_16( non_staB, 8 * 256 /* 8.0 in in Q8*/ ) ) ) ) { updt_step = 328; move16(); /* 0.01 Q15 */ @@ -3543,7 +3558,7 @@ void noise_est_ivas_fx( /* If in music lower bckr to drop further */ test(); test(); - IF( GT_16( hNoiseEst->low_tn_track_cnt, 300 ) && GT_16( hNoiseEst->lt_haco_ev_fx, 29491 /* 0.9 in Q15 */ ) && ( hNoiseEst->totalNoise_fx > 0 ) ) + IF( GT_16( hNoiseEst->low_tn_track_cnt, 300 ) && GT_16( hNoiseEst->lt_haco_ev_fx, 29491 /* 0.9 in Q15 */ ) && ( hNoiseEst->totalNoise_32fx > 0 ) ) { updt_step = -655; move16(); /* for debug purposes */ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 59d2fdf9a..c433dcb2c 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -304,7 +304,7 @@ void long_enr_fx( Word16 high_lpn_flag ); void ivas_long_enr_fx( Encoder_State *st_fx, /* i/o: state structure */ - const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q=8*/ + const Word32 Etot, /* i : total channel E (see lib_enc\analy_sp.c) Q=24*/ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */ Word16 high_lpn_flag, /* i : sp/mus LPN flag */ FRONT_VAD_ENC_HANDLE hFrontVad[], /* i/o: front-VAD handles */ @@ -347,7 +347,7 @@ void noise_est_down_ivas_fx( Word16 *q_enr, const Word16 min_band, /* i : minimum critical band */ const Word16 max_band, /* i : maximum critical band */ - Word16 *totalNoise, /* o : noise estimate over all critical bands */ + Word32 *totalNoise, /* o : noise estimate over all critical bands */ Word32 Etot, /* i : Energy of current frame Q24*/ Word32 *Etot_last, /* i/o: Energy of last frame Q24 */ Word32 *Etot_v_h2 /* i/o: Energy variations of noise frames Q24 */ @@ -398,7 +398,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 */ - Word16 *non_staX, /* o : non-stationarity for sp/mus classifier */ + 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 */ @@ -4465,6 +4465,13 @@ Word16 noise_est_AR1_Qx( /* o: Qx y(n) */ Word16 y, /* i : Qx y(n-1) */ Word16 alpha /*i : Q15 scaling of driving x(n) */ ); + +Word32 noise_est_AR1_Qx_32( /* o: Qx y(n) */ + Word32 x, /* i : Qx x(n) */ + Word32 y, /* i : Qx y(n-1) */ + Word32 alpha /*i : Q15 scaling of driving x(n) */ +); + void FEC_lsf_estim_enc_fx( Encoder_State *st_fx, /* i : Encoder static memory */ Word16 *lsf /* o : estimated LSF vector Qlog2(2.56)*/ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 817e5fb70..fd983741b 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1588,7 +1588,7 @@ Word16 ivas_smc_gmm_fx( const Word16 cor_map_sum_fx, /* i : correlation map sum (from multi-harmonic anal.) Q8 */ const Word32 epsP_fx[M + 1], /* i : LP prediciton error */ const Word32 PS_fx[], /* i : energy spectrum */ - const Word16 non_sta_fx, /* i : unbound non-stationarity Q8 */ + const Word32 non_sta_fx, /* i : unbound non-stationarity Q20 */ const Word16 relE_fx, /* i : relative frame energy Q8 */ Word16 *high_lpn_flag, /* i/o: sp/mus LPN flag */ const Word16 flag_spitch, /* i : flag to indicate very short stable pitch */ @@ -1879,7 +1879,7 @@ Word16 ivas_smc_gmm_fx( move32(); /* [8] non_sta */ - *pFV_fx++ = L_shl( non_sta_fx, Q12 ); /*scaling from Q8 to Q20*/ + *pFV_fx++ = non_sta_fx; /*Q20*/ move32(); /* [9] epsP */ @@ -3161,7 +3161,7 @@ void ivas_smc_mode_selection_fx( test(); test(); test(); - if ( EQ_16( st->vad_flag, 1 ) && LE_32( element_brate, IVAS_16k4 ) && GT_16( st->lp_noise_fx, 7680 /* 30.0f in Q8 */ ) && st->sp_aud_decision1 == 0 && GE_16( st->bwidth, SWB ) && EQ_16( st->coder_type_raw, UNVOICED ) ) + if ( EQ_16( st->vad_flag, 1 ) && LE_32( element_brate, IVAS_16k4 ) && GT_32( st->lp_noise_32fx, 503316480 /* 30.0f in Q24 */ ) && st->sp_aud_decision1 == 0 && GE_16( st->bwidth, SWB ) && EQ_16( st->coder_type_raw, UNVOICED ) ) { st->GSC_noisy_speech = 1; move16(); diff --git a/lib_enc/stat_enc.h b/lib_enc/stat_enc.h index 2fbec12bd..0647b6ebc 100644 --- a/lib_enc/stat_enc.h +++ b/lib_enc/stat_enc.h @@ -542,8 +542,9 @@ typedef struct noise_estimation_structure Word32 ave_enr_fx[NB_BANDS]; /* Q_new + Q_SCALE Noise estimator - long-term average energy per critical band ave_enr_q */ Word16 ave_enr_q; - Word16 aEn; /* Noise estimator - noise estimator adaptation flag */ - Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */ + Word16 aEn; /* Noise estimator - noise estimator adaptation flag */ + Word16 totalNoise_fx; /* Q8 Noise estimator - total noise energy */ + Word32 totalNoise_32fx; /* Q24 Noise estimator - total noise energy */ Word16 first_noise_updt; /* Noise estimator - flag used to determine if the first noise update frame */ Word16 first_noise_updt_cnt; /* Noise estimator - counter of frame after first noise update */ @@ -1522,9 +1523,11 @@ typedef struct enc_core_structure Word16 sharpFlag; Word16 localVAD; /* i : local VAD flag */ - Word32 bckr_tilt_lt; /* Q16 */ - Word16 lp_speech_fx; /* Q8 */ - Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q8 */ + Word32 bckr_tilt_lt; /* Q16 */ + Word16 lp_speech_fx; /* Q8 */ + Word16 lp_noise_fx; /* CNG and DTX - LP filtered total noise estimation Q24 */ + Word32 lp_speech_32fx; /* Q24 */ + Word32 lp_noise_32fx; /* CNG and DTX - LP filtered total noise estimation Q24 */ Word16 Opt_HE_SAD_ON_fx; Word16 nb_active_frames_HE_SAD_fx; Word16 voicing_old_fx; diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 721a6e348..1cf7a5de8 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1997,13 +1997,13 @@ Word16 wb_vad_ivas_fx( } if ( LT_16( lp_speech_fx, -100 * 256 ) ) { - lp_speech_fx = st_fx->lp_speech_fx; /*Q8*/ + lp_speech_fx = extract_h( st_fx->lp_speech_32fx ); /*Q8*/ move16(); } if ( LT_16( lp_noise_fx, -100 * 256 ) ) { - lp_noise_fx = st_fx->lp_noise_fx; /*Q8*/ + lp_noise_fx = extract_h( st_fx->lp_noise_32fx ); /*Q8*/ move16(); } -- GitLab From a31c149eb178bd9c5938164fb31a67c5343ed6ab Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 30 May 2025 18:10:18 +0530 Subject: [PATCH 165/692] 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 2ba1cea8d687da5ee683e1a375132ded4738fa74 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 30 May 2025 18:13:46 +0530 Subject: [PATCH 166/692] Fix for 3GPP issue 1201: BASOP encoder ParamISM: high MLD and audible artifacts Link #1201 --- lib_com/swb_tbe_com_fx.c | 3 +++ lib_enc/swb_tbe_enc_fx.c | 48 ++++++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 96d07e7ef..e4d84ef23 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -3309,6 +3309,9 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); move16(); + scale_sig( White_exc16k, L_FRAME16k, -1 /* guard bit to prevent saturation in deemph*/ ); + Q_White_exc16k = sub( Q_White_exc16k, 1 ); + Word16 tbe_demph_fx = shl_sat( *tbe_demph, sub( Q_White_exc16k, *Q_bwe_exc ) ); // Q_White_exc16k deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, &tbe_demph_fx ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 9d0f16ee9..b001f8693 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -77,7 +77,8 @@ static void EstimateSHBGainShape_fx( const Word16 length, const Word16 Q_synSHB, Word16 *subgain, const Word16 *subwin, - Word16 *n_subfr_saturation ); + Word16 *n_subfr_saturation, + const Flag limit_min_gain ); static Word32 pow_off_pk_fx( Word16 a[], Word16 len, Word16 step ); @@ -1072,7 +1073,7 @@ void wb_tbe_enc_fx( Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); EstimateSHBGainShape_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, - shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL ); + shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL, 1 ); /* Gain frame adjustment factor */ test(); @@ -1707,7 +1708,7 @@ void wb_tbe_enc_ivas_fx( Copy( shaped_wb_excitation + L_FRAME16k / 4, hBWE_TD->state_syn_shbexc_fx, L_SHB_LAHEAD / 4 ); EstimateSHBGainShape_fx( SHB_OVERLAP_LEN / 2, hb_frame, Q_ns, - shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL ); + shaped_wb_excitation, Q_bwe_exc_ext, GainShape, subwin_wb_fx, NULL, 1 ); /* Gain frame adjustment factor */ test(); @@ -2552,7 +2553,7 @@ void swb_tbe_enc_fx( n_subfr_saturation = 0; move16(); EstimateSHBGainShape_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, - Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation ); + Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation, 1 ); /* Gain shape BWS/high band low energy fix */ IF( LT_16( hBWE_TD->cldfbHBLT, 8192 /*1.0f Q13*/ ) ) /* cldfbHBLT in Q13 */ @@ -3857,7 +3858,7 @@ void swb_tbe_enc_ivas_fx( n_subfr_saturation = 0; move16(); EstimateSHBGainShape_fx( SHB_OVERLAP_LEN, shb_frame_fx, Q_shb, shaped_shb_excitation_fx, - Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation ); + Q_bwe_exc, GainShape_fx, subwin_shb_fx, &n_subfr_saturation, 0 ); test(); IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) @@ -4931,14 +4932,15 @@ static Word32 pow_off_pk_corrected_fx( Word16 a[], Word16 len, Word16 step ) /*--------------------------------------------------------------------------*/ static void EstimateSHBGainShape_fx( - const Word16 length, /* i : SHB overlap length */ - const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ - const Word16 Q_oriSHB, /* i : Q of target original SHB frame */ - const Word16 *synSHB, /* i : shaped SHB excitation Q(Q_synSHB) */ - const Word16 Q_synSHB, /* i : Q of shaped SHB excitation */ - Word16 *subgain, /* o : estimate of gain shape Q15 */ - const Word16 *subwin, /* i : SHB subframe window Q15 */ - Word16 *n_subfr_saturation /* o : Number of subframes which saturated while calculating oriNrg */ + const Word16 length, /* i : SHB overlap length */ + const Word16 *oriSHB, /* i : target original SHB frame Q(Q_oriSHB) */ + const Word16 Q_oriSHB, /* i : Q of target original SHB frame */ + const Word16 *synSHB, /* i : shaped SHB excitation Q(Q_synSHB) */ + const Word16 Q_synSHB, /* i : Q of shaped SHB excitation */ + Word16 *subgain, /* o : estimate of gain shape Q15 */ + const Word16 *subwin, /* i : SHB subframe window Q15 */ + Word16 *n_subfr_saturation, /* o : Number of subframes which saturated while calculating oriNrg */ + const Flag limit_min_gain /* i : gain shape limiting flag */ ) { const Word16 *skip; @@ -5152,11 +5154,23 @@ static void EstimateSHBGainShape_fx( n = sub( 31, add( n, ( sub( 28, shl( n_max, 1 ) ) ) ) ); normFact = Isqrt_lc( L_sum_gain, &n ); - FOR( i = 0; i < num_gains; i++ ) + IF( limit_min_gain ) { - L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ - subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ - move16(); + FOR( i = 0; i < num_gains; i++ ) + { + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + subgain[i] = s_max( round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ), 3277 /*0.1f Q15*/ ); /* Q15 */ + move16(); + } + } + ELSE + { + FOR( i = 0; i < num_gains; i++ ) + { + L_tmp = Mpy_32_16_1( normFact, subgain[i] ); /*Q(31-n) * Q(31-norm[i]) */ /* Q(30-n-n_max) */ + subgain[i] = round_fx_o( L_shl_o( L_tmp, add( n, n_max + 1 ), &Overflow ), &Overflow ); /* Q15 */ + move16(); + } } return; -- GitLab From 4dd8fd4a022d0f04240331de6407854c58696974 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 1 Jun 2025 18:07:20 +0200 Subject: [PATCH 167/692] Added floating-point to fixed-point conversions (and vice-versa) to resolve build warnings --- lib_rend/ivas_crend_fx.c | 1 + lib_rend/ivas_reverb_fx.c | 8 ++++++-- lib_rend/ivas_reverb_utils_fx.c | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 392d8ea99..f827020af 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1741,6 +1741,7 @@ ivas_error ivas_rend_openCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) #endif { #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 1cbbf367b..ebb3af4af 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2502,8 +2502,12 @@ ivas_error ivas_binaural_reverb_init( { revTimes = t60; revEne = ene; - - if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + float t60_temp[CLDFB_NO_CHANNELS_MAX]; + float ene_temp[CLDFB_NO_CHANNELS_MAX]; + fixedToFloat_arrL(t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + fixedToFloat_arrL(ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + //if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index a385ef359..e6cddc5e3 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -101,7 +101,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; // Represent in fixed point #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif @@ -150,7 +150,12 @@ ivas_error ivas_reverb_prepare_cldfb_params( } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); + Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; + Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; + //floatToFixed_arr32(avg_pwr_left, avg_pwr_left_temp, Q15, CLDFB_NO_CHANNELS_MAX); + //floatToFixed_arr32(avg_pwr_right, avg_pwr_right_temp, Q15, CLDFB_NO_CHANNELS_MAX); + + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_temp, avg_pwr_right_temp); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { -- GitLab From 6f1c7d19c215ef7e87a8b3014f1b8f98686eb9be Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 1 Jun 2025 18:10:18 +0200 Subject: [PATCH 168/692] clang formatting patch --- lib_rend/ivas_crend_fx.c | 244 ++++++++++++++++---------------- lib_rend/ivas_reverb_fx.c | 6 +- lib_rend/ivas_reverb_utils_fx.c | 6 +- 3 files changed, 128 insertions(+), 128 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index f827020af..c180c59a8 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1741,64 +1741,64 @@ ivas_error ivas_rend_openCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) #endif - { + { #ifdef SPLIT_REND_WITH_HEAD_ROT - hCrend = ( *pCrend )->hCrend[pos_idx]; + hCrend = ( *pCrend )->hCrend[pos_idx]; #else hCrend = ( *pCrend )->hCrend; #endif - hHrtf = ( *pCrend )->hHrtfCrend; + hHrtf = ( *pCrend )->hHrtfCrend; - IF( hHrtf != NULL ) - { - max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); - - FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + IF( hHrtf != NULL ) { - IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); - IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + + IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); } - set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); - } - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); } - set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); - } - max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); + max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); - IF( max_total_ir_len > 0 ) - { -#ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - IF( hHrtf->same_inv_diffuse_weight == 0 ) + IF( max_total_ir_len > 0 ) { - IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) +#ifdef FIX_INV_DIFFUSE_WEIGHT + IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - } - ELSE - { - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + } + ELSE + { + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1806,30 +1806,30 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - IF( hHrtf->same_inv_diffuse_weight == 0 ) - { - IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - } - ELSE - { - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; - } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + } + ELSE + { + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1837,109 +1837,109 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); #endif - } - ELSE - { + } + ELSE + { #ifdef FIX_INV_DIFFUSE_WEIGHT - hCrend->freq_buffer_re_diffuse_fx[0] = NULL; - hCrend->freq_buffer_im_diffuse_fx[0] = NULL; - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + hCrend->freq_buffer_re_diffuse_fx[0] = NULL; + hCrend->freq_buffer_im_diffuse_fx[0] = NULL; + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; #else hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; #endif - } + } - max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ - IF( max_total_ir_len > 0 ) - { - IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ + IF( max_total_ir_len > 0 ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); + } + ELSE + { + hCrend->lfe_delay_line_fx = NULL; } - set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); - } - ELSE - { - hCrend->lfe_delay_line_fx = NULL; - } - IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { + IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #endif - { - return error; - } - - IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) - { - - /* Allocate memory for reflections */ - hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); - IF( !hCrend->reflections ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); - } - IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) { return error; } - hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; - hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; - move16(); - move32(); + IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + { - /* Set sample rate and frame size */ + /* Allocate memory for reflections */ + hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); + IF( !hCrend->reflections ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); + } + IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) + { + return error; + } - hCrend->reflections->output_Fs_fx = output_Fs; // Q0 - move32(); + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; + hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; + move16(); + move32(); - hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - move32(); + /* Set sample rate and frame size */ + + hCrend->reflections->output_Fs_fx = output_Fs; // Q0 + move32(); + + hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + move32(); - /* Init Shoebox */ - ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); + /* Init Shoebox */ + ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); - /* Init and compute Reflections */ - IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) + /* Init and compute Reflections */ + IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) + { + return error; + } + } + ELSE { - return error; + hCrend->reflections = NULL; } } ELSE { - hCrend->reflections = NULL; + hCrend->hReverb = NULL; } - } - ELSE - { - hCrend->hReverb = NULL; - } - ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); - move32(); - } + ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); + move32(); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - ( *pCrend )->hCrend[pos_idx] = hCrend; + ( *pCrend )->hCrend[pos_idx] = hCrend; #else ( *pCrend )->hCrend = hCrend; #endif - } + } return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index ebb3af4af..71f04a9c1 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2504,9 +2504,9 @@ ivas_error ivas_binaural_reverb_init( revEne = ene; float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; - fixedToFloat_arrL(t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - fixedToFloat_arrL(ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - //if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) + fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + fixedToFloat_arrL( ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + // if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index e6cddc5e3..93e565c59 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -152,10 +152,10 @@ ivas_error ivas_reverb_prepare_cldfb_params( Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - //floatToFixed_arr32(avg_pwr_left, avg_pwr_left_temp, Q15, CLDFB_NO_CHANNELS_MAX); - //floatToFixed_arr32(avg_pwr_right, avg_pwr_right_temp, Q15, CLDFB_NO_CHANNELS_MAX); + // floatToFixed_arr32(avg_pwr_left, avg_pwr_left_temp, Q15, CLDFB_NO_CHANNELS_MAX); + // floatToFixed_arr32(avg_pwr_right, avg_pwr_right_temp, Q15, CLDFB_NO_CHANNELS_MAX); - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_temp, avg_pwr_right_temp); + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_temp, avg_pwr_right_temp ); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { -- GitLab From a3cd93a0971a687c4a2839c86f67e5bf917c5997 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Mon, 2 Jun 2025 11:19:03 +0300 Subject: [PATCH 169/692] dummy commit to trigger CI -- GitLab From 32ed4e67d8746710fa23813e04a56b1b790dce62 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 2 Jun 2025 11:52:33 +0200 Subject: [PATCH 170/692] changes - fixed point data members --- lib_rend/ivas_reverb_fx.c | 4 ++-- lib_rend/ivas_reverb_utils_fx.c | 24 +++++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 71f04a9c1..228e399e2 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2504,8 +2504,8 @@ ivas_error ivas_binaural_reverb_init( revEne = ene; float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; - fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - fixedToFloat_arrL( ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + // fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); + // fixedToFloat_arrL( ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); // if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 93e565c59..ec2001527 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -65,7 +65,7 @@ typedef struct cldfb_convolver_state } cldfb_convolver_state; #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, Word32 *avg_pwr_l_out, Word32 *avg_pwr_r_out ); +static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); #else static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); #endif @@ -150,12 +150,10 @@ ivas_error ivas_reverb_prepare_cldfb_params( } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; - Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - // floatToFixed_arr32(avg_pwr_left, avg_pwr_left_temp, Q15, CLDFB_NO_CHANNELS_MAX); - // floatToFixed_arr32(avg_pwr_right, avg_pwr_right_temp, Q15, CLDFB_NO_CHANNELS_MAX); + //Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; + //Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left_temp, avg_pwr_right_temp ); + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { @@ -312,8 +310,8 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const int16_t use_brir, #endif const int32_t sampling_rate, - Word32 *avg_pwr_left, - Word32 *avg_pwr_right ) + float *avg_pwr_left, + float *avg_pwr_right ) { int16_t freq_idx; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -347,6 +345,8 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); + Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); + Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); for ( int i = 0; i < 60; i++ ) { @@ -359,7 +359,13 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( } ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, - CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left, avg_pwr_right, avg_pwr_left_e, avg_pwr_right_e ); + CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); + + for ( int i = 0; i < 257; i++ ) + { + avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); + avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); + } free( input_fc_fx ); free( output_fc_fx ); -- GitLab From 3adc971e8bd85d85d2996fb4fe5aa2ad4cb4d2d3 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 2 Jun 2025 12:01:08 +0200 Subject: [PATCH 171/692] clang patch --- lib_rend/ivas_reverb_utils_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index ec2001527..7263545b7 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -150,10 +150,10 @@ ivas_error ivas_reverb_prepare_cldfb_params( } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - //Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; - //Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; + // Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; + // Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right); + ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) { @@ -361,7 +361,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); - for ( int i = 0; i < 257; i++ ) + for ( int i = 0; i < 257; i++ ) { avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); -- GitLab From dd2547843d55bebccc43249166d162daed28f9ca Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 2 Jun 2025 12:21:19 +0200 Subject: [PATCH 172/692] 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 173/692] 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 174/692] 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 175/692] 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 176/692] 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 fffed9a8a89288deba88b1a5dd49e362b73c6650 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:01:23 +0200 Subject: [PATCH 177/692] bug fixes --- lib_rend/ivas_reverb_fx.c | 7 +++++-- lib_rend/ivas_reverb_utils_fx.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 228e399e2..79b599746 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2500,8 +2500,6 @@ ivas_error ivas_binaural_reverb_init( if ( ( roomAcoustics != NULL ) && roomAcoustics->override ) { - revTimes = t60; - revEne = ene; float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; // fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); @@ -2511,6 +2509,11 @@ ivas_error ivas_binaural_reverb_init( { return error; } + floatToFixed_arrL32(t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX); + floatToFixed_arrL32(t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX); + revTimes = t60; + revEne = ene; + preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); } else diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 7263545b7..b1a4a82ab 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -371,6 +371,8 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( output_fc_fx ); free( avg_pwr_left_e ); free( avg_pwr_right_e ); + free( avg_pwr_left_fx ); + free( avg_pwr_left_fx ); #else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) -- GitLab From 3678c34b1c15a8a981ae8d35c439ec330c799079 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 2 Jun 2025 14:04:29 +0200 Subject: [PATCH 178/692] clang patch --- lib_rend/ivas_reverb_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 79b599746..336b9da3f 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2509,8 +2509,8 @@ ivas_error ivas_binaural_reverb_init( { return error; } - floatToFixed_arrL32(t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX); - floatToFixed_arrL32(t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX); + floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); revTimes = t60; revEne = ene; -- GitLab From 36c5c06501f379b942be8c0d6af87f77b14aac55 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Mon, 2 Jun 2025 14:53:32 +0200 Subject: [PATCH 179/692] Add new fx-fx job --- .gitlab-ci.yml | 49 ++++++++++++++++++++++++++++++++++++++++ .gitlab-ci/variables.yml | 1 + 2 files changed, 50 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f37f50f2..b743f7a03 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,6 +36,9 @@ workflow: variables: IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long' + variables: + IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long-fx-fx' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input' @@ -133,6 +136,15 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' when: never +.rules-pytest-long-fx-fx: + rules: + - if: $PYTEST_MLD_LONG # Set by scheduled pipeline + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long-fx-fx" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + when: never + .rules-coverage: rules: - if: $COVERAGE_TEST # Set by scheduled pipeline @@ -1336,6 +1348,43 @@ ivas-pytest-compare_ref-long-dec-lev+10: - SPLIT_COMPARISON="true" <<: *ivas-pytest-anchor +ivas-pytest-compare_ref-long-fx-fx: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=1.0 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + +ivas-pytest-compare_ref-long-fx-fx-lev-10: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=0.3162 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + +ivas-pytest-compare_ref-long-fx-fx-lev+10: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=3.162 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + + ivas-smoke-test-saturation: extends: - .rules-pytest-saturation-smoke-test diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 94bb71fb3..0c212d312 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -54,6 +54,7 @@ variables: - 'pytest-compare' - 'pytest-compare-enc-dmx' - 'pytest-compare-long' + - 'pytest-compare-long-fx-fx' - 'pytest-compare-to-input' - 'pytest-saturation-smoke-test' - 'evs-26444' -- GitLab From d3cb8fcc06723b39a623cdb91c8776937d2f8483 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Mon, 2 Jun 2025 17:02:43 +0200 Subject: [PATCH 180/692] deactivated compiler switch --- lib_com/options.h | 2 +- lib_rend/ivas_reverb_utils_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3e4902d59..2e075ab32 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ -#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index b1a4a82ab..6b9ecf3ab 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -101,7 +101,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; // Represent in fixed point + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; // Represent in fixed point? #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif -- GitLab From 6ae2d5245bfa225979f06b9bdef6a7d76eda909c Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 2 Jun 2025 17:55:55 +0200 Subject: [PATCH 181/692] 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 4f34d8e44d3a7b41bb78e94818fc4b13c959f056 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 3 Jun 2025 08:32:21 +0200 Subject: [PATCH 182/692] Correct variable for scheduled FX-FX job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b743f7a03..d10993ad6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -138,7 +138,7 @@ workflow: .rules-pytest-long-fx-fx: rules: - - if: $PYTEST_MLD_LONG # Set by scheduled pipeline + - if: $PYTEST_MLD_LONG_FX_FX # Set by scheduled pipeline - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long-fx-fx" - if: $CI_PIPELINE_SOURCE == 'push' when: never -- GitLab From 6ac062f2ead46c7911f87844c13e354f3a53978f Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 3 Jun 2025 10:38:29 +0200 Subject: [PATCH 183/692] restart pipeline after test case edits -- GitLab From b23adcfa2a66c74e90e308ec043e079f178bb719 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 3 Jun 2025 14:37:51 +0200 Subject: [PATCH 184/692] 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 185/692] 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 186/692] 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 187/692] 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 7f30144ba1767174ab29777070380b4df55cf488 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 4 Jun 2025 10:49:42 +0530 Subject: [PATCH 188/692] Fix for 3GPP issue 1722: Assert in BASOP renderer when rendering ISM to certain custom LS setup Link #1722 Increased precision in in_tri function fixes the issue --- lib_rend/ivas_efap_fx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 4fb88643b..3a4ddde1e 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -2490,7 +2490,8 @@ static Word16 in_tri_fx( Word32 tmpDot1[2], tmpDot2[2]; Word32 matInv[2][2]; Word32 invFactor; - Word16 tmp16, tmp_e; + Word16 tmp_e; + Word32 tmp32; Word64 S[2]; /* Threshold adjusted */ Word64 thresh_int = 35184640; // 1e-6f in Q45 @@ -2520,8 +2521,8 @@ static Word16 in_tri_fx( } /* invFactor = 1.f / invFactor; */ - tmp16 = BASOP_Util_Divide3232_Scale( ONE_IN_Q13, invFactor, &tmp_e ); /*15-tmp_e*/ - invFactor = L_shl_sat( tmp16, add( Q16, tmp_e ) ); /* Q31 */ + tmp32 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q13, invFactor, &tmp_e ); /*31-tmp_e*/ + invFactor = L_shl_sat( tmp32, tmp_e ); /* Q31 */ Word16 invFactor_exp = norm_l( invFactor ); invFactor = L_shl( invFactor, invFactor_exp ); // 31+invFactor_exp -- GitLab From 9281becbefa13ab56fce58ddcd9ecfee17dbc0a2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 4 Jun 2025 10:54:36 +0530 Subject: [PATCH 189/692] Clang formatting changes --- lib_rend/ivas_efap_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 3a4ddde1e..fbcfdfe77 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -2522,7 +2522,7 @@ static Word16 in_tri_fx( /* invFactor = 1.f / invFactor; */ tmp32 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q13, invFactor, &tmp_e ); /*31-tmp_e*/ - invFactor = L_shl_sat( tmp32, tmp_e ); /* Q31 */ + invFactor = L_shl_sat( tmp32, tmp_e ); /* Q31 */ Word16 invFactor_exp = norm_l( invFactor ); invFactor = L_shl( invFactor, invFactor_exp ); // 31+invFactor_exp -- GitLab From 7ef8ea8a57c6b04c40eb4502f9722e11fff507bd Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 4 Jun 2025 12:52:12 +0530 Subject: [PATCH 190/692] Cleanup of synth_fx_32 buffer in ivas_mct_dec_fx, enhancer_ivas_fx function --- lib_com/enhancer_fx.c | 221 ++---------------------------- lib_com/prot_fx.h | 22 +-- lib_dec/dec_gen_voic_fx.c | 4 +- lib_dec/ivas_mct_dec_fx.c | 5 +- lib_dec/ivas_td_low_rate_dec_fx.c | 4 +- 5 files changed, 16 insertions(+), 240 deletions(-) diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c index 7df474a5d..620904d08 100644 --- a/lib_com/enhancer_fx.c +++ b/lib_com/enhancer_fx.c @@ -299,10 +299,11 @@ void enhancer_fx( /* RETURN ARGUMENTS : */ /* _ None */ /*======================================================================================*/ + void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - const Word16 cbk_index, /* i : */ + const Word16 codec_mode, /* i : flag indicating Codec Mode */ + const Word32 core_brate, /* i : decoder bitrate */ + const Word16 cbk_index, 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 */ @@ -322,9 +323,11 @@ void enhancer_ivas_fx( Word16 tmp, fac, *pt_exc2; Word16 i; Word32 L_tmp; + Word32 L_tmp1, L_tmp2; Word16 gain_code_hi; Word16 pit_sharp, tmp16; Word16 excp[L_SUBFR], sc; + Word64 w_temp; pit_sharp = gain_pit; @@ -400,215 +403,6 @@ void enhancer_ivas_fx( phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); - /*------------------------------------------------------------ - * noise enhancer - * - * - Enhance excitation on noise. (modify gain of code) - * If signal is noisy and LPC filter is stable, move gain - * of code 1.5 dB toward gain of code threshold. - * This decreases by 3 dB noise energy variation. - *-----------------------------------------------------------*/ - - /* tmp = 0.5f * (1.0f - voice_fac) */ - tmp = msu_r_sat( 0x40000000 /*0.5.Q31*/, voice_fac, 16384 /*0.5.Q14*/ ); /*Q15 */ /* 1=unvoiced, 0=voiced */ - /* fac = stab_fac * tmp */ - fac = mult( stab_fac, tmp ); /*Q15*/ - - IF( LT_32( norm_gain_code, *gc_threshold ) ) - { - L_tmp = Madd_32_16( norm_gain_code, norm_gain_code, 6226 /*0.19.Q15*/ ); /*Q16 */ - L_tmp = L_min( L_tmp, *gc_threshold ); /*Q16 */ - } - ELSE - { - L_tmp = Mult_32_16( norm_gain_code, 27536 /*0.84.Q15*/ ); /*Q16 */ - L_tmp = L_max( L_tmp, *gc_threshold ); /*Q16 */ - } - *gc_threshold = L_tmp; - move32(); /*Q16 */ - - /* gain_code = (fac * tmp) + (1.0 - fac) * gain_code ==> fac * (tmp - gain_code) + gain_code */ - L_tmp = L_sub( L_tmp, norm_gain_code ); /*Q16 */ - norm_gain_code = Madd_32_16( norm_gain_code, L_tmp, fac ); /*Q16 */ - - /* gain_code *= gain_inov - Inverse the normalization */ - L_tmp = Mult_32_16( norm_gain_code, gain_inov ); /*Q13*/ /* gain_inov in Q12 */ - - sc = 6; - move16(); - - gain_code_hi = round_fx( L_shl( L_tmp, add( Q_exc, 3 ) ) ); /* in Q_exc */ - - /*------------------------------------------------------------* - * pitch enhancer - * - * - Enhance excitation on voiced. (HP filtering of code) - * On voiced signal, filtering of code by a smooth fir HP - * filter to decrease energy of code at low frequency. - *------------------------------------------------------------*/ - test(); - IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) - { - /* Copy(code, exc2, L_SUBFR) */ - FOR( i = 0; i < L_SUBFR; i++ ) - { - pt_exc2[i] = round_fx( L_shl( L_mult( gain_code_hi, code[i] ), sc ) ); /*Q0 */ /* code in Q12 (Q9 for encoder) */ - move16(); - } - } - ELSE - { - test(); - test(); - IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) - { - pit_sharp = shl_sat( gain_pit, 1 ); /* saturation can occur here Q14 -> Q15 */ - /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */ - IF( GT_16( pit_sharp, 16384 /*0.5.Q15*/ ) ) - { - tmp16 = mult( pit_sharp, 8192 /*0.25.Q15*/ ); - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* excp[i] = pt_exc2[i] * pit_sharp * 0.25 */ - excp[i] = mult_r( pt_exc2[i], tmp16 ); - move16(); - } - } - } - - IF( EQ_16( L_frame, L_FRAME16k ) ) - { - /* tmp = 0.150 * (1.0 + voice_fac) */ - /* 0.30=voiced, 0=unvoiced */ - tmp = mac_r( 0x13333333L /*0.150.Q31*/, voice_fac, 4915 /*0.150.Q15*/ ); /*Q15 */ - } - ELSE - { - /* tmp = 0.125 * (1.0 + voice_fac) */ - /* 0.25=voiced, 0=unvoiced */ - tmp = mac_r( 0x10000000L /*0.125.Q31*/, voice_fac, 4096 ); /*Q15 */ - } - - /*----------------------------------------------------------------- - * Do a simple noncasual "sharpening": effectively an FIR - * filter with coefs [-tmp 1.0 -tmp] where tmp=0...0.25. - * This is applied to code and add_fxed to exc2 - *-----------------------------------------------------------------*/ - /* pt_exc2[0] += code[0] - tmp * code[1] */ - L_tmp = L_deposit_h( code[0] ); /* if Enc :Q9 * Q15 -> Q25 */ - L_tmp = L_msu( L_tmp, code[1], tmp ); /* Q12 * Q15 -> Q28 */ - L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); - pt_exc2[0] = msu_r( L_tmp, -32768, pt_exc2[0] ); - move16(); /* in Q_exc */ - - FOR( i = 1; i < L_SUBFR - 1; i++ ) - { - /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */ - L_tmp = L_msu( -32768, code[i], -32768 ); - L_tmp = L_msu( L_tmp, code[i + 1], tmp ); - tmp16 = msu_r( L_tmp, code[i - 1], tmp ); - L_tmp = L_shl( L_mult( gain_code_hi, tmp16 ), sc ); - pt_exc2[i] = msu_r_sat( L_tmp, -32768, pt_exc2[i] ); - move16(); /* in Q_exc */ - } - - /* pt_exc2[L_SUBFR-1] += code[L_SUBFR-1] - tmp * code[L_SUBFR-2] */ - L_tmp = L_deposit_h( code[L_SUBFR - 1] ); /*Q28 */ - L_tmp = L_msu( L_tmp, code[L_SUBFR - 2], tmp ); /*Q28 */ - L_tmp = L_shl( L_mult( gain_code_hi, extract_h( L_tmp ) ), sc ); - pt_exc2[L_SUBFR - 1] = msu_r( L_tmp, -32768, pt_exc2[L_SUBFR - 1] ); - move16(); /* in Q_exc */ - test(); - test(); - IF( Opt_AMR_WB && ( EQ_32( core_brate, ACELP_8k85 ) || EQ_32( core_brate, ACELP_6k60 ) ) ) - { - IF( GT_16( pit_sharp, 16384 /*0.5.Q14*/ ) ) - { - FOR( i = 0; i < L_SUBFR; i++ ) - { - /* excp[i] += pt_exc2[i] */ - excp[i] = add( excp[i], pt_exc2[i] ); - move16(); - } - agc2_fx( pt_exc2, excp, L_SUBFR ); - Copy( excp, pt_exc2, L_SUBFR ); - } - } - } -} - -void enhancer_ivas_fx2( - const Word32 core_brate, /* i : decoder bitrate */ - 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 */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -) -{ - Word16 tmp, fac, *pt_exc2; - Word16 i; - Word32 L_tmp; - Word32 L_tmp1, L_tmp2; - Word16 gain_code_hi; - Word16 pit_sharp, tmp16; - Word16 excp[L_SUBFR], sc; - Word64 w_temp; - - - pit_sharp = gain_pit; - move16(); /* to remove gcc warning */ - pt_exc2 = exc2 + i_subfr; - - /*------------------------------------------------------------* - * Phase dispersion to enhance noise at low bit rate - *------------------------------------------------------------*/ - - i = 2; - move16(); /* no dispersion */ - IF( Opt_AMR_WB ) - { - IF( LE_32( core_brate, ACELP_6k60 ) ) - { - i = 0; - move16(); /* high dispersion */ - } - ELSE IF( LE_32( core_brate, ACELP_8k85 ) ) - { - i = 1; - move16(); /* low dispersion */ - } - } - ELSE IF( NE_16( coder_type, UNVOICED ) ) - - { - test(); - test(); - test(); - test(); - IF( LE_32( core_brate, ACELP_7k20 ) ) - { - i = 0; - move16(); /* high dispersion */ - } - ELSE IF( ( EQ_16( coder_type, GENERIC ) || EQ_16( coder_type, TRANSITION ) || EQ_16( coder_type, AUDIO ) || coder_type == INACTIVE ) && LE_32( core_brate, ACELP_9k60 ) ) - { - i = 1; - move16(); /* low dispersion */ - } - } - - phase_dispersion_fx( norm_gain_code, gain_pit, code, i, dm_fx ); - /*------------------------------------------------------------ * noise enhancer * @@ -656,7 +450,8 @@ void enhancer_ivas_fx2( * filter to decrease energy of code at low frequency. *------------------------------------------------------------*/ test(); - IF( !Opt_AMR_WB && EQ_16( coder_type, UNVOICED ) ) + test(); + IF( !Opt_AMR_WB && EQ_16( codec_mode, MODE1 ) && EQ_16( coder_type, UNVOICED ) ) { /* Copy(code, exc2, L_SUBFR) */ FOR( i = 0; i < L_SUBFR; i++ ) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b2df3a736..0a11364dc 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5622,27 +5622,9 @@ void enhancer_fx( ); void enhancer_ivas_fx( - const Word16 codec_mode, /* i : flag indicating Codec Mode */ - const Word32 core_brate, /* i : decoder bitrate */ - 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 */ - const Word16 L_frame, /* i : frame size */ - const Word16 voice_fac, /* i : subframe voicing estimation Q15 */ - const Word16 stab_fac, /* i : LP filter stablility measure Q15 */ - Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */ - const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */ - Word32 *gc_threshold, /* i/o: gain code threshold Q16 */ - Word16 *code, /* i/o: innovation Q12 */ - Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/ - const Word16 gain_pit, /* i : quantized pitch gain Q14 */ - struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */ - const Word16 Q_exc /* i : Q of the excitation */ -); - -void enhancer_ivas_fx2( + const Word16 codec_mode, /* i : flag indicating Codec Mode */ const Word32 core_brate, /* i : decoder bitrate */ + 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 */ diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index 3e42d9535..b9f488942 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -344,8 +344,8 @@ ivas_error decod_gen_voic_fx( } ELSE { - 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 ); + enhancer_ivas_fx( MODE1, st_fx->core_brate, -1, 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/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index b34ce0c56..ec7b8c697 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -85,7 +85,7 @@ ivas_error ivas_mct_dec_fx( set16_fx( x_len[1], 0, NB_DIV ); Decoder_State **sts; Word32 *p_output_orig_fx[2]; - Word32 synth_32_fx[CPE_CHANNELS][L_FRAME_PLUS]; + Word32 synth_fx_32[CPE_CHANNELS][L_FRAME_PLUS]; Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth) Word32 ivas_total_brate; ivas_error error; @@ -168,7 +168,7 @@ ivas_error ivas_mct_dec_fx( FOR( n = 0; n < CPE_CHANNELS; n++ ) { p_output_orig_fx[n] = output_fx[n]; - output_fx[n] = synth_32_fx[n]; + output_fx[n] = synth_fx_32[n]; } } @@ -390,7 +390,6 @@ ivas_error ivas_mct_dec_fx( /*----------------------------------------------------------------* * CoreCoder Post-processing and updates *----------------------------------------------------------------*/ - Word32 synth_fx_32[CPE_CHANNELS][L_FRAME48k]; FOR( n = 0; n < CPE_CHANNELS; n++ ) { diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 6419f8517..f48d3fabc 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -329,9 +329,9 @@ void decod_gen_2sbfr_fx( * 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_fx( MODE1, st->core_brate, -1, 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 ); + enhancer_ivas_fx( MODE1, st->core_brate, -1, 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 ); p_Aq += 2 * ( M + 1 ); /* Q12 */ -- GitLab From 2282b282328e9c151b1d0e62d1650a509f2bb3e2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 4 Jun 2025 10:42:56 +0200 Subject: [PATCH 191/692] 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 192/692] 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 4b4940d8ab77d42f06026a37c733ed4ff60b385b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 4 Jun 2025 13:35:30 +0200 Subject: [PATCH 193/692] =?UTF-8?q?=C3=84dded=20compiler=20switch=20+=20lo?= =?UTF-8?q?gic=20for=20rt60=20and=20dsr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib_com/options.h | 2 +- lib_util/render_config_reader.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3315e495e..50db4e9e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,7 +126,7 @@ #endif - +#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ #define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ #define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index a1f806d6b..dae55f18c 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2255,7 +2255,11 @@ ivas_error RenderConfigReader_read( /* RT60 */ else if ( strcmp( item, "RT60" ) == 0 ) { +#ifdef FIX_777_COMBI_RENDER_CONFIG_FILE + if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) +#else if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) +#endif { errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; @@ -2265,7 +2269,11 @@ ivas_error RenderConfigReader_read( /* DSR */ else if ( strcmp( item, "DSR" ) == 0 ) { +#ifdef FIX_777_COMBI_RENDER_CONFIG_FILE + if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) +#else if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) +#endif { errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; -- GitLab From d72e34237b2f0894b607017aa676704f641841a2 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 4 Jun 2025 13:45:47 +0200 Subject: [PATCH 194/692] commit for push --- 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 50db4e9e5..99013a1c5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,7 +126,7 @@ #endif -#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ +//#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ #define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ #define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ -- GitLab From d82c0de87438e2a1e95de57a7415935886296a9d Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:14:07 +0200 Subject: [PATCH 195/692] restart CI -- GitLab From 14e3697e827be3335fd55b4a814ea5ac71ffad7e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 08:43:10 +0530 Subject: [PATCH 196/692] Fix for 3GPP issue 1020: ParamISM: Binaural: HF click Link #1020 --- lib_dec/acelp_core_dec_fx.c | 12 ++++++++-- lib_dec/stat_dec.h | 3 ++- lib_dec/swb_tbe_dec_fx.c | 46 ++++++++++++++++++++++--------------- lib_dec/updt_dec_fx.c | 2 ++ 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index fd0c8ce2d..37d284346 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2326,6 +2326,11 @@ ivas_error acelp_core_dec_fx( 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 ); + if ( NE_16( st->element_mode, EVS_MONO ) ) + { + st->hBWE_TD->q_old_bwe_exc_extended_fx = 0; + move16(); + } } test(); @@ -2341,9 +2346,12 @@ ivas_error acelp_core_dec_fx( } 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 + 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 ), st->hBWE_TD->q_old_bwe_exc_extended_fx ) ) ); /* Q(q_old_bwe_exc_extended_fx) -> Q(2 * Q_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 + exp = sub( L_norm_arr( bwe_exc_extended_fx + L_FRAME32k, NL_BUFF_OFFSET ), 16 ); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, exp ); /* Q(2 * Q_exc) -> Q(q_old_bwe_exc_extended_fx) */ + st->hBWE_TD->q_old_bwe_exc_extended_fx = add( shl( st->Q_exc, 1 ), exp ); + move16(); } } diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 4e4e33c36..28a97f072 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -822,7 +822,8 @@ typedef struct td_bwe_dec_structure Word16 old_bwe_exc_fx[PIT16k_MAX * 2]; /*Q_exc*/ Word16 bwe_seed[2]; Word32 bwe_non_lin_prev_scale_fx; - Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; + Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; /* EVS : Q(prev_Q_bwe_exc - 16), IVAS : Q(q_old_bwe_exc_extended_fx) */ + Word16 q_old_bwe_exc_extended_fx; Word32 genSHBsynth_Hilbert_Mem_fx[HILBERT_MEM_SIZE]; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index bd8700063..b005a88bf 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -56,10 +56,13 @@ static void find_max_mem_dec( hBWE_TD = st_fx->hBWE_TD; /* old BWE exc max */ - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ); - max = s_max( max, tempQ15 ); + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + tempQ15 = abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ); + max = s_max( max, tempQ15 ); + } } /* decimate all-pass steep memory */ @@ -232,10 +235,13 @@ static void rescale_genSHB_mem_dec( TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); - move16(); + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); + move16(); + } } FOR( i = 0; i < 7; i++ ) @@ -283,9 +289,12 @@ void find_max_mem_wb( Decoder_State *st_fx, Word16 *n_mem ) TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - max = s_max( max, abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ) ); + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + max = s_max( max, abs_s( hBWE_TD->old_bwe_exc_extended_fx[i] ) ); + } } FOR( i = 0; i < 7; i++ ) { @@ -362,10 +371,13 @@ void rescale_genWB_mem( Decoder_State *st_fx, Word16 sf ) TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) { - hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); - move16(); + FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) + { + hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); + move16(); + } } FOR( i = 0; i < 10; i++ ) @@ -418,6 +430,8 @@ static void InitSWBdecBuffer_fx( move16(); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); + hBWE_TD->q_old_bwe_exc_extended_fx = 0; + move16(); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); @@ -5375,12 +5389,6 @@ static void rescale_genSHB_mem_dec_ivas( TD_BWE_DEC_HANDLE hBWE_TD; hBWE_TD = st_fx->hBWE_TD; - FOR( i = 0; i < NL_BUFF_OFFSET; i++ ) - { - hBWE_TD->old_bwe_exc_extended_fx[i] = shl( hBWE_TD->old_bwe_exc_extended_fx[i], sf ); - move16(); - } - FOR( i = 0; i < 7; i++ ) { hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i] = shl( hBWE_TD->mem_genSHBexc_filt_down_shb_fx[i], sf ); @@ -6147,7 +6155,7 @@ void ivas_swb_tbe_dec_fx( /* ----- calculate optimum Q_bwe_exc and rescale memories accordingly ----- */ Lmax = 0; move32(); - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) { Lmax = L_max( Lmax, L_abs( bwe_exc_extended_fx[cnt] ) ); } @@ -6177,7 +6185,7 @@ void ivas_swb_tbe_dec_fx( /* rescale the bwe_exc_extended and bring it to 16-bit single precision with dynamic norm */ sc = sub( Q_bwe_exc, add( Q_exc, Q_exc ) ); - FOR( cnt = 0; cnt < L_FRAME32k; cnt++ ) + FOR( cnt = 0; cnt < L_FRAME32k + NL_BUFF_OFFSET; cnt++ ) { bwe_exc_extended_16[cnt] = round_fx_sat( L_shl_sat( bwe_exc_extended_fx[cnt], sc ) ); move16(); diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 81046fb19..7af4dec1a 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -240,6 +240,8 @@ void updt_IO_switch_dec_fx( { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); + hBWE_TD->q_old_bwe_exc_extended_fx = 0; + move16(); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); -- GitLab From 799da60a2c5a1bd2b5b3b6afc937dd4abbdc6fa5 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 22 May 2025 09:41:47 +0200 Subject: [PATCH 197/692] port MR 1411 from float fix different external target extrapolation between framesizes --- lib_com/options.h | 2 ++ lib_rend/ivas_rotation_fx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 3315e495e..1801f330c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -138,6 +138,8 @@ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ +#define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index aaae3e199..154dab321 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1379,6 +1379,7 @@ ivas_error ivas_combined_orientation_open( move32(); ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; // Q30 move32(); +#ifndef FIX_1008_EXTORIENT_TARGET_INTERPOLATION IF( EQ_16( num_subframes, 1 ) ) { ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 2000; @@ -1386,9 +1387,12 @@ ivas_error ivas_combined_orientation_open( } ELSE { +#endif ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 500; move16(); +#ifndef FIX_1008_EXTORIENT_TARGET_INTERPOLATION } +#endif ( *hCombinedOrientationData )->lrSwitchedNext = 0; move16(); ( *hCombinedOrientationData )->lrSwitchedCurrent = 0; -- GitLab From b7cb47dc09e7ce88dc1f2552bbb09dd88076c748 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 12:47:31 +0530 Subject: [PATCH 198/692] Review comments addressing --- lib_dec/acelp_core_dec_fx.c | 2 +- lib_dec/swb_tbe_dec_fx.c | 2 +- lib_dec/updt_dec_fx.c | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 37d284346..847e16594 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -2328,7 +2328,7 @@ ivas_error acelp_core_dec_fx( set16_fx( st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); if ( NE_16( st->element_mode, EVS_MONO ) ) { - st->hBWE_TD->q_old_bwe_exc_extended_fx = 0; + st->hBWE_TD->q_old_bwe_exc_extended_fx = Q15; move16(); } } diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index b005a88bf..1234e2853 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -430,7 +430,7 @@ static void InitSWBdecBuffer_fx( move16(); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); - hBWE_TD->q_old_bwe_exc_extended_fx = 0; + hBWE_TD->q_old_bwe_exc_extended_fx = Q15; move16(); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); diff --git a/lib_dec/updt_dec_fx.c b/lib_dec/updt_dec_fx.c index 7af4dec1a..81046fb19 100644 --- a/lib_dec/updt_dec_fx.c +++ b/lib_dec/updt_dec_fx.c @@ -240,8 +240,6 @@ void updt_IO_switch_dec_fx( { set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); set16_fx( hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET ); - hBWE_TD->q_old_bwe_exc_extended_fx = 0; - move16(); hBWE_TD->bwe_non_lin_prev_scale_fx = 0; move16(); -- GitLab From f874b377fb9be35147ceda399fb2653038557d1f Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 5 Jun 2025 09:31:10 +0200 Subject: [PATCH 199/692] Add FIX_USAN_BASOP_UTIL_DIVIDE3232 to address USAN in BASOP_Util_Divide3232_Scale_newton --- lib_com/basop_util.c | 4 ++++ lib_com/options.h | 1 + 2 files changed, 5 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index e52f404f6..3d6324783 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -1409,7 +1409,11 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s ) *s = 0; return ( (Word32) 0 ); } +#ifdef FIX_USAN_BASOP_UTIL_DIVIDE3232 + IF( EQ_32( y, (Word32) 0x80000000 ) ) +#else IF( EQ_32( y, 0x80000000 ) ) +#endif { /* Division by -1.0: same as negation of numerator */ /* Return normalized negated numerator */ diff --git a/lib_com/options.h b/lib_com/options.h index a5d5a4846..fe44eae00 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,5 +105,6 @@ #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 */ #endif -- GitLab From 9a6b8df96f3a92e5592c223c8bb6a81325b44bfb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 14:47:00 +0530 Subject: [PATCH 200/692] Fix for 3GPP issue 1728: Renderer crash with assertion in OMASA to MASA output (renderIsmToMasa) Link #1728, #1729 This change fixes issue #1729 as well --- lib_rend/lib_rend_fx.c | 45 +++++++++++------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e39b9a61e..4b98684fb 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5530,53 +5530,32 @@ static void renderIsmToMasa( Word16 *exp ) { Word32 tmpRendBuffer_fx[MAX_NUM_OBJECTS][L_FRAME48k]; - Word16 i, j; - Word16 q_fact; + Word16 i, guard_bits, q_min, q_diff; push_wmops( "renderIsmToMasa" ); - FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) - { - set32_fx( tmpRendBuffer_fx[i], 0, L_FRAME48k ); - } - copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx ); - Word16 input_e[MAX_NUM_OBJECTS], max_e; - - FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) - { - input_e[i] = sub( 31, add( getScaleFactor32( tmpRendBuffer_fx[i], L_FRAME48k ), *outAudio.pq_fact ) ); - move16(); - } - Word16 guard_bits = find_guarded_bits_fx( L_FRAME48k ); - max_e = input_e[0]; + q_min = MAX_16; move16(); - FOR( i = 1; i < MAX_NUM_OBJECTS; i++ ) + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; i++ ) { - if ( LT_16( max_e, input_e[0] ) ) - { - max_e = input_e[i]; - move16(); - } + q_min = s_min( q_min, L_norm_arr( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel ) ); } - FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) + guard_bits = find_guarded_bits_fx( ismInput->base.inputBuffer.config.numSamplesPerChannel ); + q_min = sub( add( q_min, *outAudio.pq_fact ), guard_bits ); + q_diff = sub( q_min, *outAudio.pq_fact ); + + FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; i++ ) { - FOR( j = 0; j < L_FRAME48k; j++ ) - { - tmpRendBuffer_fx[i][j] = L_shr( tmpRendBuffer_fx[i][j], add( sub( max_e, sub( 31, *outAudio.pq_fact ) ), guard_bits ) ); /* Q(31 - (max_e + guard_bits)) */ - move32(); - } + scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, q_diff ); // *outAudio.pq_fact -> q_min } - max_e = add( max_e, guard_bits ); - q_fact = sub( Q31, max_e ); - - ivas_omasa_ana_fx( ismInput->hOMasa, tmpRendBuffer_fx, &q_fact, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels ); + ivas_omasa_ana_fx( ismInput->hOMasa, tmpRendBuffer_fx, &q_min, ismInput->base.inputBuffer.config.numSamplesPerChannel, outAudio.config.numChannels, ismInput->base.inputBuffer.config.numChannels ); - *exp = q_fact; + *exp = q_min; move16(); accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); -- GitLab From 26272dddb88b8a15defd8167d6786e05a2e752b7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 14:50:39 +0530 Subject: [PATCH 201/692] Fix for 3GPP issue 1726: Renderer crash with assert for OMASA to MONO (renderBufferChannelLerp_fx) Link #1726 --- lib_com/cnst.h | 18 ++++++++++-------- lib_rend/lib_rend_fx.c | 6 ++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index a2d051d87..17dbc31c4 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -45,20 +45,22 @@ #define MATRIX_CONSTANT (759250113) #define NUM_SAMPLES_960 (960) #define NUM_SAMPLES_720 (720) +#define NUM_SAMPLES_640 (640) #define NUM_SAMPLES_320 (320) #define NUM_SAMPLES_160 (160) #define L_SUBFRAME_48k (240) #define L_SUBFRAME_32k (180) #define L_SUBFRAME_16k (80) #define L_SUBFRAME_8k (40) -#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) -#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) -#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) -#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) -#define Q31_BY_SUB_FRAME_240 ( 8985287 ) -#define Q31_BY_SUB_FRAME_180 ( 11997115 ) -#define Q31_BY_SUB_FRAME_80 ( 27183337 ) -#define Q31_BY_SUB_FRAME_40 ( 55063683 ) +#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ +#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ +#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ +#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ +#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ +#define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */ +#define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */ +#define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */ +#define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */ /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e39b9a61e..2b70c2e21 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4579,6 +4579,12 @@ static void renderBufferChannelLerp_fx( move32(); move32(); BREAK; + case NUM_SAMPLES_640: + tmp = Q31_BY_NUM_SAMPLES_640; + tmp1 = 639; /* NUM_SAMPLES_640 - 1 */ + move32(); + move32(); + BREAK; case NUM_SAMPLES_320: tmp = Q31_BY_NUM_SAMPLES_320; tmp1 = 319; /* NUM_SAMPLES_320 - 1 */ -- GitLab From ea1c1cd3b9b8581c9be393f63c503a3e51b1b76b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 14:57:34 +0530 Subject: [PATCH 202/692] Fix for 3GPP issue 1727: Renderer crash with assert for OMASA to MASA output (ivas_create_masa_out_meta_fx) Link #1727 --- lib_com/ivas_dirac_com_fx.c | 115 ------------- lib_com/ivas_prot_fx.h | 12 -- lib_rend/ivas_dirac_ana_fx.c | 270 ++++++++++------------------- lib_rend/ivas_masa_merge_fx.c | 4 +- lib_rend/ivas_omasa_ana_fx.c | 308 +++++++++++----------------------- lib_rend/ivas_stat_rend.h | 10 +- lib_rend/lib_rend_fx.c | 9 +- 7 files changed, 198 insertions(+), 530 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 4279065b0..2be3f8ace 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -778,121 +778,6 @@ void computeDirectionVectors_fx( return; } -/*------------------------------------------------------------------------- - * computeDiffuseness() - * - * - *------------------------------------------------------------------------*/ - -void computeDiffuseness_fx( - Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity) - const Word32 *buffer_energy, // i: Q(q_factor_energy) - const Word16 num_freq_bands, - Word32 *diffuseness, // o: exp(out_exp) - Word16 q_factor_intensity, - Word16 q_factor_energy, - Word16 *out_exp /*Ouput Q*/ -) -{ - Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; - Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; - Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; - Word16 i, j, k; - Word32 tmp = 0, tmp_1; - move32(); - Word32 *p_tmp; - const Word32 *p_tmp_c; - - /* Compute Intensity slow and energy slow */ - - set32_fx( intensity_slow, 0, DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX ); - set32_fx( intensity_slow_abs, 0, CLDFB_NO_CHANNELS_MAX ); - set32_fx( energy_slow, 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; - FOR( k = 0; k < num_freq_bands; k++ ) - { - energy_slow[k] = L_add( *( p_tmp_c++ ), energy_slow[k] ); // Q(q_factor_energy) - move32(); - } - - /* Intensity slow */ - 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] = L_add( *( p_tmp++ ), intensity_slow[j * num_freq_bands + k] ); - move32(); - } - } - } - - /* intensity_slow.^2 + intensity_slow_abs*/ - FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) - { - p_tmp = intensity_slow + j * num_freq_bands; - - FOR( k = 0; k < num_freq_bands; k++ ) - { - *( p_tmp ) = Mpy_32_32( *p_tmp, *( p_tmp ) ); // Q( 2*(q_factor_intensity + scale_fact - 1) -31 ) - intensity_slow_abs[k] = L_add( *( p_tmp++ ), intensity_slow_abs[k] ); - move32(); - move32(); - } - } - Word16 init_exp = sub( 62, shl( q_factor_intensity, 1 ) ); // 31 - ( 2 * q_factor_intensity - 31 ) - Word16 exp; - - Word16 exp1 = 0, exp2; - move16(); - /* Compute Diffuseness */ - p_tmp = intensity_slow_abs; - FOR( i = 0; i < num_freq_bands; ++i ) - { - exp = init_exp; - move16(); - Word32 temp = *( p_tmp++ ); - move32(); - tmp_1 = Sqrt32( temp, &exp ); - tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( tmp_1, L_add( energy_slow[i], 1 ), &exp1 ) ); - exp2 = add( sub( 31, exp1 ), sub( sub( 31, exp ), q_factor_energy ) ); - IF( GT_32( exp2, 30 ) ) - { - tmp = L_shr( tmp, sub( exp2, 30 ) ); - exp2 = sub( exp2, sub( exp2, 30 ) ); - } - tmp = L_sub( L_shl( 1, exp2 ), tmp ); - // diffuseness[i] = ( ( tmp < L_shl( 1, exp2 ) ) ? ( ( tmp < 0 ) ? 0 : tmp ) : L_shl( 1, exp2 ) ); - - IF( LT_32( tmp, L_shl( 1, exp2 ) ) ) - { - IF( tmp < 0 ) - { - diffuseness[i] = 0; - } - ELSE - { - diffuseness[i] = tmp; - } - } - ELSE - { - diffuseness[i] = L_shl( 1, exp2 ); - } - out_exp[i] = exp2; - - move32(); - move16(); - } - return; -} - - /*------------------------------------------------------------------------- * computeDiffuseness() * diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index d9ca855be..4bea59632 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4951,18 +4951,6 @@ void computeDirectionVectors_fx( Word32 *direction_vector_z, Word16 *q_factor ); - -void computeDiffuseness_fx( - Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], - const Word32 *buffer_energy, - const Word16 num_freq_bands, - Word32 *diffuseness, - Word16 q_factor_intensity, - Word16 q_factor_energy, - Word16 *out_exp - -); - void computeDiffuseness_fixed( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], const Word32 *buffer_energy, diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index c2430d008..0e3686197 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -127,7 +127,20 @@ ivas_error ivas_dirac_ana_open_fx( } set32_fx( hDirAC->direction_vector_m_fx[i][j], 0, MASA_FREQUENCY_BANDS ); } + IF( ( hDirAC->direction_vector_e[i] = (Word16 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); + } + + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + IF( ( hDirAC->direction_vector_e[i][j] = (Word16 *) malloc( MASA_FREQUENCY_BANDS * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); + } + } } + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) @@ -140,7 +153,8 @@ ivas_error ivas_dirac_ana_open_fx( } } set32_fx( hDirAC->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); - + set16_fx( hDirAC->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF ); + set16_fx( hDirAC->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF ); hDirAC->index_buffer_intensity = 0; move16(); @@ -194,6 +208,12 @@ void ivas_dirac_ana_close_fx( free( ( *hDirAC )->direction_vector_m_fx[i] ); ( *hDirAC )->direction_vector_m_fx[i] = NULL; + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + free( ( *hDirAC )->direction_vector_e[i][j] ); + ( *hDirAC )->direction_vector_e[i][j] = NULL; + } + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { free( ( *hDirAC )->buffer_intensity_real_fx[i][j] ); @@ -231,15 +251,10 @@ void ivas_dirac_ana_fx( 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]; - Word16 energyRatio_q, surroundingCoherence_q = 0, spreadCoherence_q = 0; - move16(); - move16(); /* 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 ); - energyRatio_q = 30; - move16(); /* 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, energyRatio_q, spreadCoherence_q, surroundingCoherence_q ); + 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 ); /* Downmix */ ivas_dirac_dmx_fx( data_fx, input_frame, nchan_transport ); // output Q of data_fx is same as that of input @@ -256,38 +271,37 @@ void ivas_dirac_ana_fx( static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, Word32 data_fx[][L_FRAME48k], /* Q7 */ - Word32 elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ - Word32 azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ - Word32 energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q30 */ - Word32 spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ - Word32 surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Qx */ + Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ + Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ + 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 ) { Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word16 ts, i, d, j; Word16 num_freq_bands, index; - Word32 dir_v[DIRAC_NUM_DIMS]; - Word16 dir_q; + Word32 dir_v_fx[DIRAC_NUM_DIMS]; + Word16 dir_v_q; Word16 l_ts; 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]; Word32 direction_vector_fx[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; - Word16 diffuseness_vector_exp[MASA_FREQUENCY_BANDS]; Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS]; - + Word16 diffuseness_e[MASA_FREQUENCY_BANDS]; + Word16 diffuseness_q = 0; + move16(); Word16 band_m_idx, block_m_idx; Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; + Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; Word16 mrange[2]; Word16 brange[2]; Word16 numAnalysisChannels; - Word16 io_q; - Word16 scale_fact, scale_fact2; - Word16 q_factor_intensity, q_factor_intensity_old = 0; - Word16 q_factor_energy = 0, q_factor_energy_old = 0; - Word16 exp = 0, exp_div = 0; + Word16 inp_q; + Word16 intensity_q, reference_power_q; num_freq_bands = hDirAC->nbands; /* l_ts = input_frame / CLDFB_NO_COL_MAX; */ l_ts = shr( input_frame, 4 ); @@ -327,24 +341,25 @@ 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 + move16(); + move16(); + move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - io_q = Q7; // Input Q of data_fx - move16(); - cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][imult1616( l_ts, ts )] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &io_q ); + cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][imult1616( 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 ) ); } - scale_fact = getScaleFactor32( (const Word32 *) Foa_RealBuffer_fx, FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ); - scale_fact = s_min( getScaleFactor32( (const Word32 *) Foa_ImagBuffer_fx, FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ), scale_fact ); - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + sf = sub( s_min( cr_q, ci_q ), 4 ); + FOR( i = 0; i < numAnalysisChannels; i++ ) { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - Foa_RealBuffer_fx[i][j] = L_shl( Foa_RealBuffer_fx[i][j], sub( scale_fact, Q3 ) ); // Q( scale_fact + Q1 ) - move32(); - Foa_ImagBuffer_fx[i][j] = L_shl( Foa_ImagBuffer_fx[i][j], sub( scale_fact, Q3 ) ); // Q( scale_fact + Q1 ) - move32(); - } + 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 } + 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++ ) { @@ -354,191 +369,82 @@ static void ivas_dirac_param_est_ana_fx( move16(); FOR( j = brange[0]; j < brange[1]; j++ ) { - hDirAC->energy_fx[block_m_idx][band_m_idx] = ( L_add( hDirAC->energy_fx[block_m_idx][band_m_idx], L_add( Mpy_32_32( Foa_RealBuffer_fx[0][j], Foa_RealBuffer_fx[0][j] ), Mpy_32_32( Foa_ImagBuffer_fx[0][j], Foa_ImagBuffer_fx[0][j] ) ) ) ); // 2*( scale_fact + Q1 )-31 + 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] ); move32(); } } /* Direction estimation */ - computeIntensityVector_ana_fx( hDirAC->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); // 2 * ( scale_fact + Q1 ) - 31 - exp = sub( shl( sub( scale_fact, Q1 ), 1 ), 31 ); - - computeDirectionVectors_fx( 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], &exp ); + 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)); + 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 ); - + reference_power_q = sub( shl( inp_q, 1 ), 30 ); /* 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(); index = hDirAC->index_buffer_intensity; move16(); - Word16 guard_bits = find_guarded_bits_fx( DIRAC_NO_COL_AVG_DIFF ); - scale_fact2 = getScaleFactor32( (const Word32 *) intensity_real_fx, DIRAC_NUM_DIMS * MASA_FREQUENCY_BANDS ); - IF( GT_16( guard_bits, scale_fact2 ) ) - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - intensity_real_fx[i][j] = L_shr( intensity_real_fx[i][j], sub( guard_bits, scale_fact2 ) ); - move32(); - } - } - q_factor_intensity = sub( sub( shl( sub( scale_fact, 1 ), 1 ), 31 ), sub( guard_bits, scale_fact2 ) ); - } - ELSE - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - intensity_real_fx[i][j] = L_shl( intensity_real_fx[i][j], sub( scale_fact2, guard_bits ) ); - move32(); - } - } - q_factor_intensity = add( sub( shl( sub( scale_fact, 1 ), 1 ), 31 ), sub( scale_fact2, guard_bits ) ); - } - scale_fact2 = getScaleFactor32( reference_power_fx[ts], MASA_FREQUENCY_BANDS ); - IF( GT_16( guard_bits, scale_fact2 ) ) - { - - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - reference_power_fx[ts][j] = L_shr( reference_power_fx[ts][j], sub( guard_bits, scale_fact2 ) ); - move32(); - } - - q_factor_energy = sub( sub( shl( scale_fact, 1 ), 31 ), sub( guard_bits, scale_fact2 ) ); - } - ELSE - { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - reference_power_fx[ts][j] = L_shl( reference_power_fx[ts][j], sub( scale_fact2, guard_bits ) ); - move32(); - } - - q_factor_energy = add( sub( shl( scale_fact, 1 ), 31 ), sub( scale_fact2, guard_bits ) ); - } - - IF( q_factor_intensity_old != 0 ) - { - - IF( LT_16( q_factor_intensity_old, q_factor_intensity ) ) - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - intensity_real_fx[i][j] = L_shr( intensity_real_fx[i][j], sub( q_factor_intensity, q_factor_intensity_old ) ); - move32(); - } - } - q_factor_intensity = q_factor_intensity_old; - move16(); - } - ELSE - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - FOR( j = 0; j < index - 1; j++ ) - { - /* only real part needed */ - FOR( Word16 k = 0; k < num_freq_bands; k++ ) - { - hDirAC->buffer_intensity_real_fx[i][j][k] = L_shr( hDirAC->buffer_intensity_real_fx[i][j][k], sub( q_factor_intensity_old, q_factor_intensity ) ); - move32(); - } - } - } - } - } - IF( q_factor_energy_old != 0 ) - { - - IF( LT_16( q_factor_energy_old, q_factor_energy ) ) - { - - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - reference_power_fx[ts][j] = L_shr( reference_power_fx[ts][j], sub( q_factor_energy, q_factor_energy_old ) ); - move32(); - } - - q_factor_energy = q_factor_energy_old; - move16(); - } - ELSE - { - FOR( i = 0; i < index - 1; i++ ) - { - FOR( j = 0; j < num_freq_bands; j++ ) - { - FOR( Word16 k = 0; k < num_freq_bands; k++ ) - { - hDirAC->buffer_energy_fx[add( imult1616( i, j ), k )] = L_shr( hDirAC->buffer_energy_fx[add( imult1616( i, j ), k )], sub( q_factor_energy_old, q_factor_energy_old ) ); - move32(); - } - } - } - } - } - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) { /* only real part needed */ - Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); + Copy32( intensity_real_fx[i], &( hDirAC->buffer_intensity_real_fx[i][index - 1][0] ), num_freq_bands ); // intensity_q } - Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[imult1616( sub( index, 1 ), num_freq_bands )] ), num_freq_bands ); - - computeDiffuseness_fx( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, q_factor_intensity, q_factor_energy, diffuseness_vector_exp ); - q_factor_intensity_old = q_factor_intensity; + hDirAC->buffer_intensity_real_q[index - 1] = intensity_q; move16(); - q_factor_energy_old = q_factor_energy; + Copy32( reference_power_fx[ts], &( hDirAC->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); + hDirAC->buffer_energy_q[index - 1] = reference_power_q; move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - if ( LT_16( diffuseness_vector_exp[j], 10 ) ) - { - diffuseness_vector_fx[j] = 0; - move16(); - } - } + computeDiffuseness_fixed( hDirAC->buffer_intensity_real_fx, hDirAC->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hDirAC->buffer_intensity_real_q, hDirAC->buffer_energy_q, &diffuseness_q ); FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { - norm_tmp_fx = Mpy_32_32( reference_power_fx[ts][band_m_idx], ( L_sub( ONE_IN_Q30, L_shr( diffuseness_vector_fx[band_m_idx], sub( 30, diffuseness_vector_exp[band_m_idx] ) ) ) ) ); // q_factor_energy-1 + 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*/ - hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ), hDirAC->direction_vector_m_fx[0][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32) + 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] ); move32(); - hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ), hDirAC->direction_vector_m_fx[1][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32) + 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] ); move32(); - hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ), hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] ); // Q (q_factor_energy + exp -32) + 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] = L_add( diffuseness_m_fx[band_m_idx], Mpy_32_32( reference_power_fx[ts][band_m_idx], L_shr( diffuseness_vector_fx[band_m_idx], sub( 30, diffuseness_vector_exp[band_m_idx] ) ) ) ); // Qq_factor_energy-1 + 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] ); move32(); - renormalization_factor_diff_fx[band_m_idx] = L_add( renormalization_factor_diff_fx[band_m_idx], reference_power_fx[ts][band_m_idx] ); // Qq_factor_energy + + 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(); + } + } - FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { + Word16 max_e = MIN_16; + move16(); FOR( d = 0; d < DIRAC_NUM_DIMS; d++ ) { - dir_v[d] = hDirAC->direction_vector_m_fx[d][block_m_idx][band_m_idx]; + max_e = s_max( max_e, hDirAC->direction_vector_e[d][block_m_idx][band_m_idx] ); + } + max_e = add( max_e, 1 ); /*1 as guard bit to prevent overflow*/ + FOR( d = 0; d < DIRAC_NUM_DIMS; d++ ) + { + dir_v_fx[d] = L_shr( hDirAC->direction_vector_m_fx[d][block_m_idx][band_m_idx], sub( max_e, hDirAC->direction_vector_e[d][block_m_idx][band_m_idx] ) ); move32(); } - dir_q = add( q_factor_energy, sub( exp, 32 ) ); - ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v, dir_q, &azimuth_m_values[block_m_idx][band_m_idx], &elevation_m_values[block_m_idx][band_m_idx] ); + dir_v_q = sub( 31, max_e ); + ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, dir_v_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] ); } /* Determine energy ratios */ FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { + Word16 diffuseness_m_e; IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) ) { - diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &exp_div ); + diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &diffuseness_m_e ); + move32(); + diffuseness_m_e = add( diffuseness_m_e, sub( diffuseness_e[band_m_idx], renormalization_factor_diff_e[band_m_idx] ) ); + diffuseness_m_fx[band_m_idx] = L_shl_sat( diffuseness_m_fx[band_m_idx], add( 16, diffuseness_m_e ) ); // Q31 move32(); } ELSE @@ -546,16 +452,14 @@ static void ivas_dirac_param_est_ana_fx( diffuseness_m_fx[band_m_idx] = 0; move32(); } - exp_div = sub( 30, exp_div ); - energyRatio[block_m_idx][band_m_idx] = L_sub( L_shl( 1, 30 ), L_shl( diffuseness_m_fx[band_m_idx], sub( 30, exp_div ) ) ); // Q30 + energyRatio_fx[block_m_idx][band_m_idx] = L_sub( ONE_IN_Q31, diffuseness_m_fx[band_m_idx] ); move32(); } - FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { - spreadCoherence[block_m_idx][band_m_idx] = 0; + spreadCoherence_fx[block_m_idx][band_m_idx] = 0; move32(); - surroundingCoherence[block_m_idx][band_m_idx] = 0; + surroundingCoherence_fx[block_m_idx][band_m_idx] = 0; move32(); } } diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index fd20a9fab..65829e1c8 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -209,7 +209,7 @@ 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( 1, scale ), L_deposit_h( tmp ) ); + dir_nrg_ratio_fx = L_sub( L_shl_sat( 1, sub( 31, scale ) ), L_deposit_h( tmp ) ); dir_nrg_ratio_e = scale; move16(); @@ -239,7 +239,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, new_dir_ratio_e ) ), UINT8_MAX ); + outMeta->diffuseToTotalRatio[sf][band] = (UWord8) imult1616( extract_l( L_shr( new_diff_ratio_fx, sub( 31, new_dir_ratio_e ) ) ), UINT8_MAX ); move16(); } ELSE diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 7b7f64c84..1a579aece 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -159,6 +159,18 @@ ivas_error ivas_omasa_ana_open( } set_zero_fx( hOMasa->direction_vector_m_fx[i][j], MASA_FREQUENCY_BANDS ); } + IF( ( hOMasa->direction_vector_e[i] = (Word16 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word16 * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); + } + + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + IF( ( hOMasa->direction_vector_e[i][j] = (Word16 *) malloc( MASA_FREQUENCY_BANDS * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); + } + } } FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) @@ -172,7 +184,8 @@ ivas_error ivas_omasa_ana_open( set_zero_fx( hOMasa->buffer_intensity_real_fx[i][j], MASA_FREQUENCY_BANDS ); } } - + set16_fx( hOMasa->buffer_intensity_real_q, 31, DIRAC_NO_COL_AVG_DIFF ); + set16_fx( hOMasa->buffer_energy_q, 31, DIRAC_NO_COL_AVG_DIFF ); set_zero_fx( hOMasa->buffer_energy_fx, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) @@ -249,6 +262,12 @@ void ivas_omasa_ana_close( ( *hOMasa )->direction_vector_m_fx[i][j] = NULL; } + FOR( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) + { + free( ( *hOMasa )->direction_vector_e[i][j] ); + ( *hOMasa )->direction_vector_e[i][j] = NULL; + } + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { free( ( *hOMasa )->buffer_intensity_real_fx[i][j] ); @@ -298,7 +317,7 @@ void ivas_omasa_ana_fx( /* Create MASA metadata buffer from the estimated values */ - ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, energyRatio_q, spreadCoherence_q, sorroundingCoherence_q ); + ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); /* Downmix */ ivas_omasa_dmx_fx( data_in_f_fx, data_in_q, input_frame, nchan_transport, nchan_ism, hOMasa->ism_azimuth_fx, hOMasa->ism_elevation_fx, hOMasa->prev_object_dm_gains_fx, hOMasa->interpolator_fx ); @@ -332,7 +351,7 @@ static void ivas_omasa_param_est_ana_fx( Word16 num_freq_bins, num_freq_bands, index; Word16 l_ts; - Word32 reference_power_fx[MASA_FREQUENCY_BANDS]; + Word32 reference_power_fx[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Chnl_RealBuffer_fx[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; Word16 Chnl_RealBuffer_q[MAX_NUM_OBJECTS]; Word16 Chnl_ImagBuffer_q[MAX_NUM_OBJECTS]; @@ -344,20 +363,16 @@ static void ivas_omasa_param_est_ana_fx( Word32 diffuseness_vector_fx[MASA_FREQUENCY_BANDS]; Word16 diffuseness_q = 0; move16(); + Word16 diffuseness_e[MASA_FREQUENCY_BANDS]; Word32 diffuseness_m_fx[MASA_FREQUENCY_BANDS]; - Word16 diffuseness_m_q = 0; - move16(); + Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; - Word16 renormalization_factor_diff_q = 0; - move16(); + Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; - Word16 scale; Word16 tmp_ener_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 dir_v_fx[DIRAC_NUM_DIMS], L_tmp1, L_tmp2; - Word16 dir_v_q, norm_tmp_q; - Word16 foa_q; - + Word32 dir_v_fx[DIRAC_NUM_DIMS]/*, L_tmp1, L_tmp2*/; + Word16 dir_v_q/*, norm_tmp_q*/; Word16 band_m_idx, block_m_idx; Word16 mrange[2]; @@ -367,13 +382,10 @@ static void ivas_omasa_param_est_ana_fx( move16(); num_freq_bands = hOMasa->nbands; move16(); - - // l_ts = input_frame / CLDFB_NO_COL_MAX; l_ts = shr( input_frame, 4 ); - move16(); Word16 intensity_q; - Word16 direction_q, reference_power_q; + Word16 reference_power_q; set16_zero_fx( Chnl_RealBuffer_q, MAX_NUM_OBJECTS ); set16_zero_fx( Chnl_ImagBuffer_q, MAX_NUM_OBJECTS ); @@ -381,37 +393,15 @@ static void ivas_omasa_param_est_ana_fx( /* Compute ISM to FOA matrices */ FOR( i = 0; i < nchan_ism; i++ ) { - Word16 tmp, tmp1; - // 180 in Q22 754974720 - hOMasa->chnlToFoaMtx_fx[0][i] = 32767; // 1 in Q15 - move16(); - - tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_azimuth_fx[i], 754974720, &scale ); - tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13 - tmp = getSinWord16( tmp ); // Q15 sine value - - tmp1 = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale ); - tmp1 = mult( tmp1, EVS_PI_FX ); - tmp1 = getCosWord16( tmp1 ); - hOMasa->chnlToFoaMtx_fx[1][i] = shl( mult( tmp, tmp1 ), 1 ); // Q14 + Q15 - Q15 + Q1 -> Q15 - move16(); - - tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale ); - tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13 - hOMasa->chnlToFoaMtx_fx[2][i] = getSinWord16( tmp ); // Q15 - move16(); - - tmp = BASOP_Util_Divide3232_Scale( hOMasa->ism_azimuth_fx[i], 754974720, &scale ); - tmp = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13 - tmp = getCosWord16( tmp ); // Q14 - - - tmp1 = BASOP_Util_Divide3232_Scale( hOMasa->ism_elevation_fx[i], 754974720, &scale ); - tmp1 = mult( tmp, EVS_PI_FX ); // Q13 + Q15 - Q15 --> Q13 - tmp1 = getCosWord16( tmp ); // Q14 + hOMasa->chnlToFoaMtx_fx[0][i] = ONE_IN_Q31; + move32(); + hOMasa->chnlToFoaMtx_fx[1][i] = L_mult( getSineWord16R2( extract_l( Mpy_32_32( hOMasa->ism_azimuth_fx[i], 46603 /*32767/360*/ ) /*Q22+Q24-31=>Q15*/ ) ), getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ) ); // Q31 + move32(); + hOMasa->chnlToFoaMtx_fx[2][i] = L_shl( getSineWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ), 16 ); // Q31 + move32(); + hOMasa->chnlToFoaMtx_fx[3][i] = L_mult( getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_azimuth_fx[i], 46603 /*2^24/360*/ ) ) ), getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ) ); // Q31 + move32(); - hOMasa->chnlToFoaMtx_fx[3][i] = shl( mult( tmp, tmp1 ), 2 ); // Q14 + Q14 - Q15 + Q2-> Q13 + Q2 -> Q15 - move16(); } /* do processing over all CLDFB time slots */ @@ -442,63 +432,29 @@ static void ivas_omasa_param_est_ana_fx( FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { + Word16 cr_q = MAX_16, ci_q = MAX_16, sf, c_e; + move16(); + move16(); + Word16 inp_q = data_f_q; + move16(); FOR( i = 0; i < nchan_ism; i++ ) { - Word16 in_q = Q11; + + inp_q = data_f_q; move16(); + cldfbAnalysis_ts_fx_fixed_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 ); - /* Keep input to cldfbAnalysis_ts_fx in Q11 */ - IF( NE_16( in_q, data_f_q ) ) - { - scale_sig32( &( data_f_fx[i][i_mult( l_ts, ts )] ), l_ts, sub( in_q, data_f_q ) ); /* Q11 */ - } - - cldfbAnalysis_ts_fx( &( data_f_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hOMasa->cldfbAnaEnc[i], &in_q ); - - /* Restore data_f_fx to it's original Q */ - IF( NE_16( data_f_q, Q11 ) ) - { - scale_sig32( &( data_f_fx[i][i_mult( l_ts, ts )] ), l_ts, sub( data_f_q, Q11 ) ); /* Q(data_f_q) */ - } - - FOR( Word16 ind = 0; ind < CLDFB_NO_CHANNELS_MAX; ind++ ) - { - Chnl_RealBuffer_fx[i][ind] = L_shr( Chnl_RealBuffer_fx[i][ind], 4 ); // Q: in_q - 4 - move32(); - Chnl_ImagBuffer_fx[i][ind] = L_shr( Chnl_ImagBuffer_fx[i][ind], 4 ); // Q: in_q - 4 - move32(); - } - - Chnl_RealBuffer_q[i] = sub( in_q, 4 ); - move16(); - Chnl_ImagBuffer_q[i] = sub( in_q, 4 ); - move16(); + 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 ) ); } - - IF( GT_16( nchan_ism, 1 ) ) + sf = sub( s_min( cr_q, ci_q ), 4 ); + FOR( i = 0; i < nchan_ism; i++ ) { - Word16 anaBuf_com_q; - minimum_fx( Chnl_RealBuffer_q, nchan_ism, &anaBuf_com_q ); - - FOR( i = 0; i < nchan_ism; i++ ) - { - IF( NE_16( anaBuf_com_q, Chnl_RealBuffer_q[i] ) ) - { - FOR( Word16 ind = 0; ind < CLDFB_NO_CHANNELS_MAX; ind++ ) - { - Chnl_RealBuffer_fx[i][ind] = L_shr( Chnl_RealBuffer_fx[i][ind], sub( Chnl_RealBuffer_q[i], anaBuf_com_q ) ); // Q: anaBuf_com_q - move32(); - Chnl_ImagBuffer_fx[i][ind] = L_shr( Chnl_ImagBuffer_fx[i][ind], sub( Chnl_ImagBuffer_q[i], anaBuf_com_q ) ); // Q: anaBuf_com_q - move32(); - } - Chnl_ImagBuffer_q[i] = anaBuf_com_q; - move16(); - Chnl_RealBuffer_q[i] = anaBuf_com_q; - move16(); - } - } + 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 } - + inp_q = add( inp_q, sf ); + c_e = sub( 31, inp_q ); /* Compute channel-based energy for metadata processing */ FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ ) @@ -510,21 +466,9 @@ static void ivas_omasa_param_est_ana_fx( FOR( j = brange[0]; j < brange[1]; j++ ) { FOR( i = 0; i < nchan_ism; i++ ) - { - Word16 tmp_e, tmp_r_q, tmp_i_q; - Word32 tmp_r, tmp_i, L_tmp_sum; - tmp_r_q = norm_l( Chnl_RealBuffer_fx[i][j] ); - tmp_r = L_shl( Chnl_RealBuffer_fx[i][j], tmp_r_q ); /* Q(Chnl_RealBuffer_q[i] + tmp_r_q) */ - tmp_r_q = add( tmp_r_q, Chnl_RealBuffer_q[i] ); - L_tmp1 = Mpy_32_32( tmp_r, tmp_r ); /* Q(2*tmp_r_q - 31)*/ - tmp_r_q = sub( add( tmp_r_q, tmp_r_q ), 31 ); - tmp_i_q = norm_l( Chnl_ImagBuffer_fx[i][j] ); - tmp_i = L_shl( Chnl_ImagBuffer_fx[i][j], tmp_i_q ); /* Q(Chnl_ImagBuffer_q[i] + tmp_i_q)*/ - tmp_i_q = add( tmp_i_q, Chnl_ImagBuffer_q[i] ); - tmp_i_q = sub( add( tmp_i_q, tmp_i_q ), 31 ); - L_tmp2 = Mpy_32_32( tmp_i, tmp_i ); /* Q(2*tmp_i_q - 31) */ - L_tmp_sum = BASOP_Util_Add_Mant32Exp( L_tmp1, sub( 31, tmp_r_q ), L_tmp2, sub( 31, tmp_i_q ), &tmp_e ); /* Q(31 - tmp_e) */ - hOMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->energy_fx[block_m_idx][band_m_idx], tmp_ener_e[block_m_idx][band_m_idx], L_tmp_sum, tmp_e, &tmp_ener_e[block_m_idx][band_m_idx] ); /* Q(31 - tmp_ener_e[block_m_idx][band_m_idx]) */ + { + 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 + hOMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->energy_fx[block_m_idx][band_m_idx], hOMasa->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hOMasa->energy_e[block_m_idx][band_m_idx] ); move32(); } } @@ -533,8 +477,8 @@ static void ivas_omasa_param_est_ana_fx( /* Compute FOA */ /* W */ - Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); - Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); + Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins );//inp_q + Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins );//inp_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -549,59 +493,42 @@ static void ivas_omasa_param_est_ana_fx( /* Y */ - v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[1][0] ), Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[1][0] ), Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[1][0], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { - v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_RealBuffer_fx[1], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[1][i], Foa_ImagBuffer_fx[1], num_freq_bins ); // Q: Chnl_ImagBuffer_q } /* Z */ - v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[2][0] ), Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[2][0] ), Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0] , Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0] , Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { - v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_acc_32_32( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q } - v_multc_fixed( Chnl_RealBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[3][0] ), Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], L_deposit_h( hOMasa->chnlToFoaMtx_fx[3][0] ), Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0] , Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0] , Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { - v_multc_acc_32_16( Chnl_RealBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_acc_32_16( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q - } - - /* Direction estimation */ - FOR( i = 0; i < FOA_CHANNELS; i++ ) - { - FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) - { - Foa_RealBuffer_fx[i][j] = L_shr( Foa_RealBuffer_fx[i][j], 5 ); // Q: ( Chnl_RealBuffer_q - 5 ) - move32(); - Foa_ImagBuffer_fx[i][j] = L_shr( Foa_ImagBuffer_fx[i][j], 5 ); // Q: ( Chnl_RealBuffer_q - 5 ) - move32(); - } + 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 } - foa_q = sub( Chnl_ImagBuffer_q[0], 5 ); - computeIntensityVector_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx ); - - intensity_q = sub( shl( add( foa_q, Q1 ), 1 ), 31 ); - direction_q = intensity_q; - move16(); - - computeDirectionVectors_fx( 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], &direction_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 ) ); + 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*/ /* Power estimation for diffuseness */ - computeReferencePower_ana_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx, num_freq_bands ); // 2 * inputq - 30 - reference_power_q = sub( shl( Chnl_ImagBuffer_q[0], 1 ), 30 ); + 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 ); /* 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 */ @@ -616,68 +543,61 @@ static void ivas_omasa_param_est_ana_fx( } hOMasa->buffer_intensity_real_q[index - 1] = intensity_q; move16(); - Copy32( reference_power_fx, &( hOMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); + Copy32( reference_power_fx[ts], &( hOMasa->buffer_energy_fx[( index - 1 ) * num_freq_bands] ), num_freq_bands ); hOMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); - computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q ); + computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q );//diffuseness_q=Q30 FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { - norm_tmp_fx = Mpy_32_32( reference_power_fx[band_m_idx], L_sub( ONE_IN_Q30, diffuseness_vector_fx[band_m_idx] ) ); // reference_power_q + 30 - 31 - norm_tmp_q = sub( add( reference_power_q, 30 ), 31 ); + 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] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[0][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 ) + 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] ); move32(); - - hOMasa->direction_vector_m_fx[1][block_m_idx][band_m_idx] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[1][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 ) + 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] ); move32(); - hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = L_add( hOMasa->direction_vector_m_fx[0][block_m_idx][band_m_idx], Mpy_32_32( norm_tmp_fx, direction_vector_fx[2][band_m_idx] ) ); // Q: hOMasa->direction_vector_m_q: ( ( norm_tmp_q + direction_q ) - 31 ) + 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] ); move32(); - hOMasa->direction_vector_m_q = sub( add( norm_tmp_q, direction_q ), 31 ); - - - diffuseness_m_fx[band_m_idx] = L_add( diffuseness_m_fx[band_m_idx], Mpy_32_32( reference_power_fx[band_m_idx], diffuseness_vector_fx[band_m_idx] ) ); // diffuseness_m_q: ( ( reference_power_q + diffuseness_q ) - 31 ); + 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] ); move32(); - diffuseness_m_q = sub( add( reference_power_q, diffuseness_q ), 31 ); - renormalization_factor_diff_fx[band_m_idx] = L_add( renormalization_factor_diff_fx[band_m_idx], reference_power_fx[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(); - renormalization_factor_diff_q = reference_power_q; - move16(); + } } FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { + Word16 max_e = MIN_16; + move16(); FOR( d = 0; d < DIRAC_NUM_DIMS; d++ ) { - dir_v_fx[d] = hOMasa->direction_vector_m_fx[d][block_m_idx][band_m_idx]; - move32(); + max_e = s_max( max_e, hOMasa->direction_vector_e[d][block_m_idx][band_m_idx] ); } - dir_v_q = hOMasa->direction_vector_m_q; - move16(); - - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + max_e = add( max_e, 1 ); /*1 as guard bit to prevent overflow*/ + FOR( d = 0; d < DIRAC_NUM_DIMS; d++ ) { - dir_v_fx[i] = L_shr( dir_v_fx[i], 1 ); + dir_v_fx[d] = L_shr( hOMasa->direction_vector_m_fx[d][block_m_idx][band_m_idx], sub( max_e, hOMasa->direction_vector_e[d][block_m_idx][band_m_idx] ) ); move32(); } + dir_v_q = sub( 31, max_e ); - dir_v_q = sub( dir_v_q, 1 ); ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, dir_v_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] ); + } /* Determine energy ratios */ FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { - IF( BASOP_Util_Cmp_Mant32Exp( renormalization_factor_diff_fx[band_m_idx], sub( 31, renormalization_factor_diff_q ), L_deposit_h( EPSILON_FX ), 2 ) > 0 ) + Word16 diffuseness_m_e; + IF( GT_32( renormalization_factor_diff_fx[band_m_idx], EPSILON_FX ) ) { - diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &scale ); + diffuseness_m_fx[band_m_idx] = BASOP_Util_Divide3232_Scale( diffuseness_m_fx[band_m_idx], renormalization_factor_diff_fx[band_m_idx], &diffuseness_m_e ); move32(); - scale = add( scale, sub( sub( 31, diffuseness_m_q ), sub( 31, renormalization_factor_diff_q ) ) ); - - diffuseness_m_fx[band_m_idx] = L_shr( diffuseness_m_fx[band_m_idx], sub( 31, add( scale, diffuseness_m_q ) ) ); + diffuseness_m_e = add( diffuseness_m_e, sub( diffuseness_e[band_m_idx], renormalization_factor_diff_e[band_m_idx] ) ); + diffuseness_m_fx[band_m_idx] = L_shl_sat( diffuseness_m_fx[band_m_idx], add( 16, diffuseness_m_e ) ); // Q31 move32(); } ELSE @@ -685,7 +605,7 @@ static void ivas_omasa_param_est_ana_fx( diffuseness_m_fx[band_m_idx] = 0; move32(); } - energyRatio_fx[block_m_idx][band_m_idx] = L_sub( L_shl( 1, diffuseness_m_q ), diffuseness_m_fx[band_m_idx] ); // Q: diffuseness_m_q + energyRatio_fx[block_m_idx][band_m_idx] = L_sub( ONE_IN_Q31, diffuseness_m_fx[band_m_idx] ); move32(); } @@ -698,40 +618,12 @@ static void ivas_omasa_param_est_ana_fx( move32(); } } - - Word16 q_ener_min = MAX_16; + *energyRatio_q = Q31; + *spreadCoherence_q = Q31; + *surroundingCoherence_q = Q31; move16(); - FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) - { - Word16 e_max; - maximum_fx( tmp_ener_e[block_m_idx], num_freq_bands, &e_max ); - e_max = sub( 31, e_max ); - if ( GT_16( q_ener_min, e_max ) ) - { - q_ener_min = e_max; - move16(); - } - } - - FOR( block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) - { - FOR( band_m_idx = 0; band_m_idx < num_freq_bands; band_m_idx++ ) - { - hOMasa->energy_fx[block_m_idx][band_m_idx] = L_shr( hOMasa->energy_fx[block_m_idx][band_m_idx], sub( sub( 31, tmp_ener_e[block_m_idx][band_m_idx] ), q_ener_min ) ); /* Q(q_ener_min) */ - move32(); - } - } - - hOMasa->energy_q = q_ener_min; - move16(); - - *spreadCoherence_q = 0; - move16(); - *surroundingCoherence_q = 0; move16(); - *energyRatio_q = 0; move16(); - return; } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 00fbc2549..588e416ca 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1597,13 +1597,14 @@ typedef struct ivas_omasa_ana_data_structure SPHERICAL_GRID_DATA *sph_grid16; Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ - Word16 direction_vector_m_q; /* Average direction vector */ + Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */ 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; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; + 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]; @@ -1611,7 +1612,7 @@ typedef struct ivas_omasa_ana_data_structure Word32 buffer_energy_fx[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS]; Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF]; Word16 buffer_energy_q[DIRAC_NO_COL_AVG_DIFF]; - Word16 chnlToFoaMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; // Q15 + Word32 chnlToFoaMtx_fx[FOA_CHANNELS][MCMASA_MAX_ANA_CHANS]; // Q15 } OMASA_ANA_DATA, *OMASA_ANA_HANDLE; @@ -1629,13 +1630,16 @@ typedef struct ivas_dirac_ana_data_structure /* DirAC parameter estimation */ Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ + Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; Word16 block_grouping[5]; /* diffuseness */ Word16 index_buffer_intensity; Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; + Word16 buffer_intensity_real_q[DIRAC_NO_COL_AVG_DIFF]; Word32 buffer_energy_fx[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS]; + Word16 buffer_energy_q[DIRAC_NO_COL_AVG_DIFF]; MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e39b9a61e..9a0f2a522 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5644,11 +5644,6 @@ static ivas_error renderInputIsm( BREAK; case IVAS_REND_AUDIO_CONFIG_TYPE_MASA: renderIsmToMasa( ismInput, outAudio, &exp ); - FOR( Word16 block_m_idx = 0; block_m_idx < MAX_PARAM_SPATIAL_SUBFRAMES; block_m_idx++ ) - { - ismInput->hOMasa->energy_e[block_m_idx] = sub( 31, ismInput->hOMasa->energy_q ); - move16(); - } BREAK; default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; @@ -7097,7 +7092,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( { *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); + inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { @@ -7127,7 +7122,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( { inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_e ); + inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { -- GitLab From c3e19ed30cc04e5265ea976872bf5f4d5d3c0251 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 11:31:37 +0200 Subject: [PATCH 203/692] 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 204/692] 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 bcb13845eb74b07d83331f1dde7b34e13853494c Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 15:28:46 +0530 Subject: [PATCH 205/692] Clang formatting changes --- lib_rend/ivas_dirac_ana_fx.c | 8 +++----- lib_rend/ivas_omasa_ana_fx.c | 29 +++++++++++++---------------- lib_rend/ivas_stat_rend.h | 4 ++-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 0e3686197..4fd86c9fe 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -270,7 +270,7 @@ void ivas_dirac_ana_fx( /* Estimate MASA parameters from the SBA signals */ static void ivas_dirac_param_est_ana_fx( DIRAC_ANA_HANDLE hDirAC, - Word32 data_fx[][L_FRAME48k], /* Q7 */ + Word32 data_fx[][L_FRAME48k], /* Q7 */ Word32 elevation_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ Word32 azimuth_m_values_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q22 */ Word32 energyRatio_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* Q30 */ @@ -355,7 +355,7 @@ static void ivas_dirac_param_est_ana_fx( 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_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 } inp_q = add( inp_q, sf ); @@ -376,7 +376,7 @@ static void ivas_dirac_param_est_ana_fx( } /* 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)); + intensity_q = sub( 31, shl( c_e, 1 ) ); 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 */ @@ -414,9 +414,7 @@ static void ivas_dirac_param_est_ana_fx( 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(); - } - } FOR( band_m_idx = 0; band_m_idx < hDirAC->nbands; band_m_idx++ ) { diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 1a579aece..f82ac12bd 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -371,8 +371,8 @@ static void ivas_omasa_param_est_ana_fx( Word32 norm_tmp_fx; Word16 tmp_ener_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word32 dir_v_fx[DIRAC_NUM_DIMS]/*, L_tmp1, L_tmp2*/; - Word16 dir_v_q/*, norm_tmp_q*/; + Word32 dir_v_fx[DIRAC_NUM_DIMS] /*, L_tmp1, L_tmp2*/; + Word16 dir_v_q /*, norm_tmp_q*/; Word16 band_m_idx, block_m_idx; Word16 mrange[2]; @@ -401,7 +401,6 @@ static void ivas_omasa_param_est_ana_fx( move32(); hOMasa->chnlToFoaMtx_fx[3][i] = L_mult( getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_azimuth_fx[i], 46603 /*2^24/360*/ ) ) ), getCosWord16R2( extract_l( Mpy_32_32( hOMasa->ism_elevation_fx[i], 46603 /*2^24/360*/ ) ) ) ); // Q31 move32(); - } /* do processing over all CLDFB time slots */ @@ -439,7 +438,7 @@ static void ivas_omasa_param_est_ana_fx( move16(); FOR( i = 0; i < nchan_ism; i++ ) { - + inp_q = data_f_q; move16(); cldfbAnalysis_ts_fx_fixed_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 ); @@ -466,8 +465,8 @@ static void ivas_omasa_param_est_ana_fx( FOR( j = brange[0]; j < brange[1]; j++ ) { FOR( i = 0; i < nchan_ism; 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 + { + 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 hOMasa->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( hOMasa->energy_fx[block_m_idx][band_m_idx], hOMasa->energy_e[block_m_idx][band_m_idx], temp, shl( c_e, 1 ), &hOMasa->energy_e[block_m_idx][band_m_idx] ); move32(); } @@ -477,8 +476,8 @@ static void ivas_omasa_param_est_ana_fx( /* Compute FOA */ /* W */ - Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins );//inp_q - Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins );//inp_q + Copy32( Chnl_RealBuffer_fx[0], Foa_RealBuffer_fx[0], num_freq_bins ); // inp_q + Copy32( Chnl_ImagBuffer_fx[0], Foa_ImagBuffer_fx[0], num_freq_bins ); // inp_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -504,8 +503,8 @@ static void ivas_omasa_param_est_ana_fx( /* Z */ - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0] , Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0] , Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_RealBuffer_fx[2], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[2][0], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { @@ -513,15 +512,15 @@ static void ivas_omasa_param_est_ana_fx( v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[2][i], Foa_ImagBuffer_fx[2], num_freq_bins ); // Q: Chnl_ImagBuffer_q } - v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0] , Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q - v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0] , Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q + v_multc_fixed( Chnl_RealBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_RealBuffer_fx[3], num_freq_bins ); // Q: Chnl_RealBuffer_q + v_multc_fixed( Chnl_ImagBuffer_fx[0], hOMasa->chnlToFoaMtx_fx[3][0], Foa_ImagBuffer_fx[3], num_freq_bins ); // Q: Chnl_ImagBuffer_q FOR( i = 1; i < nchan_ism; i++ ) { 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 */ + 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 ) ); 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*/ @@ -547,7 +546,7 @@ static void ivas_omasa_param_est_ana_fx( hOMasa->buffer_energy_q[index - 1] = reference_power_q; move16(); - computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q );//diffuseness_q=Q30 + computeDiffuseness_fixed( hOMasa->buffer_intensity_real_fx, hOMasa->buffer_energy_fx, num_freq_bands, diffuseness_vector_fx, hOMasa->buffer_intensity_real_q, hOMasa->buffer_energy_q, &diffuseness_q ); // diffuseness_q=Q30 FOR( band_m_idx = 0; band_m_idx < hOMasa->nbands; band_m_idx++ ) { @@ -564,7 +563,6 @@ static void ivas_omasa_param_est_ana_fx( 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] ); move32(); - } } @@ -585,7 +583,6 @@ static void ivas_omasa_param_est_ana_fx( dir_v_q = sub( 31, max_e ); ivas_qmetadata_direction_vector_to_azimuth_elevation_fx( dir_v_fx, dir_v_q, &azimuth_m_values_fx[block_m_idx][band_m_idx], &elevation_m_values_fx[block_m_idx][band_m_idx] ); - } /* Determine energy ratios */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 588e416ca..2654e5a53 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1596,7 +1596,7 @@ typedef struct ivas_omasa_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ + Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */ Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; @@ -1629,7 +1629,7 @@ typedef struct ivas_dirac_ana_data_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[DIRAC_MAX_ANA_CHANS]; /* DirAC parameter estimation */ - Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ + Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ Word16 **direction_vector_e[MAX_PARAM_SPATIAL_SUBFRAMES]; /* Average direction vector */ Word16 band_grouping[MASA_FREQUENCY_BANDS + 1]; Word16 block_grouping[5]; -- GitLab From dea11c9dfa834a7625eb7cf65dfa558291b54e1a Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 12:02:05 +0200 Subject: [PATCH 206/692] 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 207/692] 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 4272cc79608cb23134b2d8260f1c2eede5d4e8d4 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 5 Jun 2025 15:55:30 +0530 Subject: [PATCH 208/692] Added missed pointer freeing in renderer --- lib_rend/ivas_dirac_ana_fx.c | 5 ++++- lib_rend/ivas_omasa_ana_fx.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index 4fd86c9fe..f282e8390 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -214,6 +214,9 @@ void ivas_dirac_ana_close_fx( ( *hDirAC )->direction_vector_e[i][j] = NULL; } + free( ( *hDirAC )->direction_vector_e[i] ); + ( *hDirAC )->direction_vector_e[i] = NULL; + FOR( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { free( ( *hDirAC )->buffer_intensity_real_fx[i][j] ); @@ -348,7 +351,7 @@ static void ivas_dirac_param_est_ana_fx( move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][imult1616( l_ts, ts )] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q ); + cldfbAnalysis_ts_fx_fixed_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 ) ); } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index f82ac12bd..bce8870c8 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -276,6 +276,9 @@ void ivas_omasa_ana_close( free( ( *hOMasa )->direction_vector_m_fx[i] ); ( *hOMasa )->direction_vector_m_fx[i] = NULL; + + free( ( *hOMasa )->direction_vector_e[i] ); + ( *hOMasa )->direction_vector_e[i] = NULL; } free( ( *hOMasa )->hMasaOut ); -- GitLab From 23d04da560255d17065a42947911b5382614e1a4 Mon Sep 17 00:00:00 2001 From: Kacper Sagnowski Date: Thu, 5 Jun 2025 13:13:19 +0200 Subject: [PATCH 209/692] 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 210/692] 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 211/692] 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 212/692] 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 86af060636474ee4b1b2fa54912cbe2ab355ed4b Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 5 Jun 2025 16:17:55 +0200 Subject: [PATCH 213/692] Fix cldfbAnalysis_ts_fx() in regard to the consistency of real/imag output buffers scale respective to q_cldfb. --- lib_com/cldfb_fx.c | 19 +++++++++++++++++++ lib_com/options.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index bf832b640..06d72668f 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -519,6 +519,7 @@ 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++ ) { @@ -533,6 +534,7 @@ void cldfbAnalysis_ts_fx( move32(); move32(); } +#endif *q_cldfb = sub( *q_cldfb, 2 ); move16(); @@ -553,6 +555,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++ ) { diff --git a/lib_com/options.h b/lib_com/options.h index a5d5a4846..12580b20d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,4 +106,6 @@ #define FIX_1713_EXP /* VA: proposed correction to exp in ic-BWE*/ +#define FIX_1733_CLDFB_BUG + #endif -- GitLab From 6e410b332207a461eb284ba31d77a6cf928324fa Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 5 Jun 2025 16:21:38 +0200 Subject: [PATCH 214/692] clang format --- lib_com/cldfb_fx.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 06d72668f..ede4be78b 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -417,8 +417,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 +431,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(); @@ -478,8 +478,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(); @@ -492,8 +492,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(); @@ -581,8 +581,8 @@ void cldfbAnalysis_ts_fx( 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 + 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(); @@ -608,8 +608,8 @@ void cldfbAnalysis_ts_fx( 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 + 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(); -- GitLab From 7a7d3f5bf0cdd7472472f5191dc903648368d073 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Jun 2025 16:44:43 +0200 Subject: [PATCH 215/692] 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 216/692] 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 217/692] 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 218/692] 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 219/692] 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 2760d40420779c634b4834cacec998299f2126ad Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 8 Jun 2025 16:13:22 +0200 Subject: [PATCH 220/692] formatting fixes --- lib_rend/ivas_crend_fx.c | 243 ++++++++++++++++---------------- lib_rend/ivas_reverb_fx.c | 5 +- lib_rend/ivas_reverb_utils_fx.c | 6 +- 3 files changed, 123 insertions(+), 131 deletions(-) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index c180c59a8..392d8ea99 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1741,64 +1741,63 @@ ivas_error ivas_rend_openCrend( #ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) #endif - { + { #ifdef SPLIT_REND_WITH_HEAD_ROT - hCrend = ( *pCrend )->hCrend[pos_idx]; + hCrend = ( *pCrend )->hCrend[pos_idx]; #else hCrend = ( *pCrend )->hCrend; #endif - hHrtf = ( *pCrend )->hHrtfCrend; + hHrtf = ( *pCrend )->hHrtfCrend; - IF( hHrtf != NULL ) - { - max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); + IF( hHrtf != NULL ) + { + max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length ); - FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + FOR( i = 0; i < hHrtf->max_num_ir; i++ ) + { + IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { - IF( ( hCrend->freq_buffer_re_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len ); - IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); + IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } + set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len ); + } - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) + { + IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) { - IF( ( hCrend->prev_out_buffer_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * subframe_length ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } + set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length ); + } - max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); + max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length ); - IF( max_total_ir_len > 0 ) - { + IF( max_total_ir_len > 0 ) + { #ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - IF( hHrtf->same_inv_diffuse_weight == 0 ) - { - IF( ( hCrend->freq_buffer_re_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - } - ELSE - { - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - } + } + ELSE + { + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1806,30 +1805,30 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); + } + IF( hHrtf->same_inv_diffuse_weight == 0 ) + { + IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } - IF( hHrtf->same_inv_diffuse_weight == 0 ) - { - IF( ( hCrend->freq_buffer_im_diffuse_fx[1] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - } - ELSE - { - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; - } + } + ELSE + { + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + } #else IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { @@ -1837,109 +1836,109 @@ ivas_error ivas_rend_openCrend( } #endif #ifdef FIX_INV_DIFFUSE_WEIGHT - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); - IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) - { - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); - } + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); + IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) + { + set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); + } #else set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); #endif - } - ELSE - { + } + ELSE + { #ifdef FIX_INV_DIFFUSE_WEIGHT - hCrend->freq_buffer_re_diffuse_fx[0] = NULL; - hCrend->freq_buffer_im_diffuse_fx[0] = NULL; - hCrend->freq_buffer_re_diffuse_fx[1] = NULL; - hCrend->freq_buffer_im_diffuse_fx[1] = NULL; + hCrend->freq_buffer_re_diffuse_fx[0] = NULL; + hCrend->freq_buffer_im_diffuse_fx[0] = NULL; + hCrend->freq_buffer_re_diffuse_fx[1] = NULL; + hCrend->freq_buffer_im_diffuse_fx[1] = NULL; #else hCrend->freq_buffer_re_diffuse_fx = NULL; hCrend->freq_buffer_im_diffuse_fx = NULL; #endif - } + } - max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ - IF( max_total_ir_len > 0 ) - { - IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } - set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); - } - ELSE + max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ + IF( max_total_ir_len > 0 ) + { + IF( ( hCrend->lfe_delay_line_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { - hCrend->lfe_delay_line_fx = NULL; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); } + set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len ); + } + ELSE + { + hCrend->lfe_delay_line_fx = NULL; + } - IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { + IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) + { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) #endif + { + return error; + } + + IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + { + + /* Allocate memory for reflections */ + hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); + IF( !hCrend->reflections ) { - return error; + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); } - - IF( EQ_16( hRendCfg->roomAcoustics.use_er, 1 ) ) + IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) { + return error; + } - /* Allocate memory for reflections */ - hCrend->reflections = (er_struct_t *) malloc( sizeof( er_struct_t ) ); - IF( !hCrend->reflections ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Early Reflections" ); - } - IF( NE_32( ( error = ivas_er_init_handle( hCrend->reflections ) ), IVAS_ERR_OK ) ) - { - return error; - } - - hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; - hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; - move16(); - move32(); + hCrend->reflections->use_er = hRendCfg->roomAcoustics.use_er; + hCrend->reflections->lowComplexity = hRendCfg->roomAcoustics.lowComplexity; + move16(); + move32(); - /* Set sample rate and frame size */ + /* Set sample rate and frame size */ - hCrend->reflections->output_Fs_fx = output_Fs; // Q0 - move32(); + hCrend->reflections->output_Fs_fx = output_Fs; // Q0 + move32(); - hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); - move32(); + hCrend->reflections->max_frame_size = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ); + move32(); - /* Init Shoebox */ - ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); + /* Init Shoebox */ + ivas_shoebox_config_init( &hCrend->reflections->shoebox_lib.cal, hRendCfg ); - /* Init and compute Reflections */ - IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE + /* Init and compute Reflections */ + IF( NE_32( ( error = ivas_er_init( hCrend->reflections, inConfig ) ), IVAS_ERR_OK ) ) { - hCrend->reflections = NULL; + return error; } } ELSE { - hCrend->hReverb = NULL; + hCrend->reflections = NULL; } - - ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); - move32(); } + ELSE + { + hCrend->hReverb = NULL; + } + + ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 ); + move32(); + } #ifdef SPLIT_REND_WITH_HEAD_ROT - ( *pCrend )->hCrend[pos_idx] = hCrend; + ( *pCrend )->hCrend[pos_idx] = hCrend; #else ( *pCrend )->hCrend = hCrend; #endif - } + } return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 336b9da3f..74c2a0c0a 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2502,15 +2502,12 @@ ivas_error ivas_binaural_reverb_init( { float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; - // fixedToFloat_arrL( t60, t60_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - // fixedToFloat_arrL( ene, ene_temp, Q15, CLDFB_NO_CHANNELS_MAX ); - // if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60, ene ) ) != IVAS_ERR_OK ) if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { return error; } floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL32( ene_temp, ene, Q15, CLDFB_NO_CHANNELS_MAX ); revTimes = t60; revEne = ene; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 6b9ecf3ab..75cc4b816 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -101,7 +101,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; - const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; // Represent in fixed point? + const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif @@ -149,10 +149,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_ene[idx] *= expf( exp_argument ); } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - - // Word32 avg_pwr_left_temp[CLDFB_NO_CHANNELS_MAX]; - // Word32 avg_pwr_right_temp[CLDFB_NO_CHANNELS_MAX]; - ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); #else if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) -- GitLab From 7a59cc5c78501ad0865d315e4af4aab706bb6d9b Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Sun, 8 Jun 2025 16:28:52 +0200 Subject: [PATCH 221/692] marked branch as ready, trigger full pipeline -- GitLab From b55b837d06be2c2f160ac01f8c9bc2c8356f6c59 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 9 Jun 2025 11:29:32 +0530 Subject: [PATCH 222/692] Fix for 3GPP issue 1731: OMASA BASOP bitstream crashing float decoder (ivas_mdct_core_invQ) Link #1731 --- lib_com/ivas_cnst.h | 2 +- lib_com/ivas_masa_com_fx.c | 6 +++--- lib_com/ivas_prot_fx.h | 2 +- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_enc/ivas_masa_enc_fx.c | 8 +------- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 097ba1789..d3e52ec16 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -383,7 +383,7 @@ typedef enum #define PARAM_ISM_MAX_CHAN 16 #define PARAM_ISM_HYS_BUF_SIZE 10 -#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q15 (4681) /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */ +#define STEP_PARAM_ISM_POW_RATIO_NBITS_Q31 (306783378) /* 1.0f / (float)((1 << PARAM_ISM_POW_RATIO_NBITS) - 1) */ /* ISM DTX */ #define ISM_Q_STEP_FX ( 10485760 ) // Q22 diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index cfed06357..a28e229ff 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -1308,7 +1308,7 @@ Word16 valid_ratio_index_fx( void reconstruct_ism_ratios_fx( Word16 *ratio_ism_idx, /* i : index vector Q0 */ const Word16 nchan_ism, /* i : number of components/objects Q0 */ - const Word16 step, /* i : quantization step Q15 */ + const Word32 step, /* i : quantization step Q31 */ Word32 *q_energy_ratio_ism /* o : reconstructed ISM values Q30 */ ) { @@ -1317,10 +1317,10 @@ void reconstruct_ism_ratios_fx( sum = 0; move32(); - + FOR( i = 0; i < nchan_ism - 1; i++ ) { - q_energy_ratio_ism[i] = L_shl( L_mult( ratio_ism_idx[i], step ), 14 ); // q0 + q15 + 1 + 14 = q30; + q_energy_ratio_ism[i] = W_extract_l(W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 )); // q0 + q31 + 1 - 2 = q30; move32(); sum = L_add( sum, q_energy_ratio_ism[i] ); // Q30 diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index d9ca855be..542f9e0e9 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -115,7 +115,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( void reconstruct_ism_ratios_fx( Word16 *ratio_ism_idx, /* i : index vector Q0 */ const Word16 nchan_ism, /* i : number of components/objects Q0 */ - const Word16 step, /* i : quantization step Q15 */ + const Word32 step, /* i : quantization step Q31 */ Word32 *q_energy_ratio_ism /* o : reconstructed ISM values Q30 */ ); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 36900867e..e61e51262 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -3097,7 +3097,7 @@ static void decode_ism_ratios_fx( /* reconstructed values */ FOR( band = 0; band < nbands; band++ ) { - reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q15, ratio_ism[sf][band] ); + reconstruct_ism_ratios_fx( ratio_ism_idx[band], n_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, ratio_ism[sf][band] ); } test(); diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 303d11698..fb86dee7a 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -4666,7 +4666,6 @@ static void ivas_encode_masaism_metadata_fx( UWord16 index_theta, index_phi; Word16 ratio_ism_fx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; Word16 ratio_ism_idx[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS], ratio_ism_idx_prev_sf[MASA_FREQUENCY_BANDS][MAX_NUM_OBJECTS]; - Word16 step; Word32 energy_ism, energy_ism_ind[MAX_NUM_OBJECTS]; Word16 tmp, rotate, energy_ism_e, energy_ism_ind_e[MAX_NUM_OBJECTS]; Word16 n_ism_tmp, i; @@ -4919,11 +4918,6 @@ static void ivas_encode_masaism_metadata_fx( /* quantize ism_ratios */ IF( GT_16( nchan_ism, 1 ) ) { - /* inv_step = ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ); * - * step = 1.0f / inv_step; */ - step = 4681; // 1.f / ( ( 1 << PARAM_ISM_POW_RATIO_NBITS ) - 1 ) => 1.f / 7 in Q15 - move16(); - rotate = 0; n_ism_tmp = 0; move16(); @@ -4968,7 +4962,7 @@ static void ivas_encode_masaism_metadata_fx( } /* reconstructed values */ - reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, step, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] ); + reconstruct_ism_ratios_fx( ratio_ism_idx[band], nchan_ism, STEP_PARAM_ISM_POW_RATIO_NBITS_Q31, hMasa->data.hOmasaData->q_energy_ratio_ism_fx[sf][band] ); } test(); IF( GT_16( nchan_ism, 2 ) && EQ_16( idx_separated_object, sub( nchan_ism, 1 ) ) ) -- GitLab From 027d6aa2294158b013f6b2b97126bdbcc040de62 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 9 Jun 2025 11:33:58 +0530 Subject: [PATCH 223/692] Clang formatting changes --- lib_com/ivas_masa_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index a28e229ff..a691fb390 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -1317,10 +1317,10 @@ void reconstruct_ism_ratios_fx( sum = 0; move32(); - + FOR( i = 0; i < nchan_ism - 1; i++ ) { - q_energy_ratio_ism[i] = W_extract_l(W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 )); // q0 + q31 + 1 - 2 = q30; + q_energy_ratio_ism[i] = W_extract_l( W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 ) ); // q0 + q31 + 1 - 2 = q30; move32(); sum = L_add( sum, q_energy_ratio_ism[i] ); // Q30 -- GitLab From dae6401d9374fdde1bced371758d7d6e6398a9f9 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 9 Jun 2025 19:30:09 +0530 Subject: [PATCH 224/692] Fix for 3GPP issue 1730: Rendering MASA LTV has severe audible distortions Link #1730 --- .../ivas_dirac_dec_binaural_functions_fx.c | 107 +++++++++--------- lib_rend/ivas_rotation_fx.c | 9 +- lib_rend/ivas_stat_rend.h | 4 +- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 2db86d6eb..6dc701468 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -2740,14 +2740,12 @@ static void adaptTransportSignalsHeadtracked_fx( Word16 slot, ch, bin, louderCh; Word32 mono_factor_ILD, mono_factor; Word32 y_val, mono_factor_rotation, ene_proc, ene_target, ILD; + Word16 ene_proc_e, ene_target_e; Word16 max_band; Word32 eqVal; Word16 band_idx, bin_lo, bin_hi, norm, shift = 31; - Word16 q_chEneIIR = 0, q_procChEneIIR = 0; Word32 temp_div; - Word16 e_div, tmp, is_zero, i; - move16(); - move16(); + Word16 e_div, is_zero, i; move16(); #ifdef OPT_BIN_RENDERER_V1 @@ -2793,16 +2791,17 @@ static void adaptTransportSignalsHeadtracked_fx( shift = sub( shift, 5 ); // 5 is gaurded bits needed// Word32 re, img, temp; - Word16 q_temp = sub( imult1616( 2, add( q_inp, shift ) ), 31 ); + Word16 s, q_band_nrg, q_temp[2]; FOR( band_idx = 0; band_idx < max_band; band_idx++ ) { - Word32 ch_nrg[2]; /* storage for input signal channel energies */ + Word32 ch_nrg[2]; /* storage for input signal channel energies */ + Word64 W_ch_nrg[2]; /* storage for input signal channel energies */ bin_lo = MASA_band_grouping_24[band_idx]; bin_hi = s_min( MASA_band_grouping_24[band_idx + 1], (Word16) nBins ); FOR( ch = 0; ch < 2; ch++ ) { - ch_nrg[ch] = 0; + W_ch_nrg[ch] = 0; move32(); FOR( slot = 0; slot < nSlots; slot++ ) { @@ -2811,24 +2810,31 @@ static void adaptTransportSignalsHeadtracked_fx( re = L_shl( inRe_fx[ch][slot][bin], shift ); img = L_shl( inIm_fx[ch][slot][bin], shift ); - ch_nrg[ch] = L_add( ch_nrg[ch], ( L_add( Mpy_32_32( re, re ), Mpy_32_32( img, img ) ) ) ); // 2(q_inp +shift) -31 - move32(); + W_ch_nrg[ch] = W_add( W_ch_nrg[ch], ( W_add( W_mult0_32_32( re, re ), W_mult0_32_32( img, img ) ) ) ); // 2(q_inp +shift) + move64(); } } + s = W_norm( W_ch_nrg[ch] ); + ch_nrg[ch] = W_extract_h( W_shl( W_ch_nrg[ch], s ) ); // Q: 2*(q_inp+shift) + s - 32 + q_temp[ch] = sub( add( shl( add( q_inp, shift ), 1 ), s ), 32 ); + move32(); + move16(); + hHeadTrackData->chEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->chEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // q_chEneIIR move32(); - temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); - IF( LT_16( hHeadTrackData->q_chEneIIR, q_temp ) ) + temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); // q_temp[ch] + IF( LT_16( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] ) ) { - hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_chEneIIR ) ), hHeadTrackData->chEneIIR_fx[ch][band_idx] ); + hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp[ch], hHeadTrackData->q_chEneIIR[ch][band_idx] ) ), hHeadTrackData->chEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_chEneIIR[ch][band_idx] } ELSE { - hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->chEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_chEneIIR, q_temp ) ), temp ); + hHeadTrackData->chEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->chEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] ) ), temp ); // q_temp[ch] } move32(); + hHeadTrackData->q_chEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_chEneIIR[ch][band_idx], q_temp[ch] ); + move16(); } - q_chEneIIR = s_min( hHeadTrackData->q_chEneIIR, q_temp ); /* Determine ILD */ IF( EQ_32( L_max( 1, hHeadTrackData->chEneIIR_fx[0][band_idx] ), L_max( 1, hHeadTrackData->chEneIIR_fx[1][band_idx] ) ) ) @@ -2839,7 +2845,7 @@ static void adaptTransportSignalsHeadtracked_fx( ELSE { temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( L_max( 1, hHeadTrackData->chEneIIR_fx[0][band_idx] ), L_max( 1, hHeadTrackData->chEneIIR_fx[1][band_idx] ), &e_div ) ); - + e_div = add( e_div, sub( hHeadTrackData->q_chEneIIR[1][band_idx], hHeadTrackData->q_chEneIIR[0][band_idx] ) ); temp = BASOP_Util_Log2( temp_div ); // Q25 IF( e_div > 0 ) { @@ -2853,7 +2859,7 @@ static void adaptTransportSignalsHeadtracked_fx( temp = Mpy_32_32( temp, 646462464 ); // logx base 10 = 0.30103* logx base 2// ILD = L_abs( Mpy_32_16_1( temp, 20480 ) ); // Q21 } - IF( GT_32( hHeadTrackData->chEneIIR_fx[1][band_idx], hHeadTrackData->chEneIIR_fx[0][band_idx] ) ) + IF( BASOP_Util_Cmp_Mant32Exp( hHeadTrackData->chEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[1][band_idx] ), hHeadTrackData->chEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[0][band_idx] ) ) > 0 ) { louderCh = 1; } @@ -2886,8 +2892,9 @@ static void adaptTransportSignalsHeadtracked_fx( { IF( NE_16( ch, louderCh ) ) { - Word32 band_nrg = 0; - move32(); + Word32 band_nrg; + Word64 W_band_nrg = 0; + move64(); FOR( slot = 0; slot < nSlots; slot++ ) { @@ -2898,24 +2905,31 @@ static void adaptTransportSignalsHeadtracked_fx( inIm_fx[ch][slot][bin] = L_add( ( Mpy_32_32( mono_factor, L_add( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ) ) ), ( Mpy_32_32( L_sub( ONE_IN_Q31, mono_factor ), inIm_fx[ch][slot][bin] ) ) ); move32(); move32(); - re = L_shl( inRe_fx[ch][slot][bin], shift ); // q_inp +shift - img = L_shl( inIm_fx[ch][slot][bin], shift ); // q_inp +shift - band_nrg = L_add( band_nrg, ( L_add( Mpy_32_32( re, re ), Mpy_32_32( img, img ) ) ) ); // 2(q_inp +shift) -31 + re = L_shl( inRe_fx[ch][slot][bin], shift ); // q_inp +shift + img = L_shl( inIm_fx[ch][slot][bin], shift ); // q_inp +shift + + W_band_nrg = W_add( W_band_nrg, ( W_add( W_mult0_32_32( re, re ), W_mult0_32_32( img, img ) ) ) ); // 2(q_inp + shift) } } - hHeadTrackData->procChEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->procChEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // q_procChEneIIR + s = W_norm( W_band_nrg ); + band_nrg = W_extract_h( W_shl( W_band_nrg, s ) ); // Q: 2*(q_inp+shift) + s - 32 + q_band_nrg = sub( add( shl( add( q_inp, shift ), 1 ), s ), 32 ); + + hHeadTrackData->procChEneIIR_fx[ch][band_idx] = Mpy_32_16_1( hHeadTrackData->procChEneIIR_fx[ch][band_idx], ADAPT_HTPROTO_IIR_FAC_FX ); // hHeadTrackData->q_procChEneIIR[ch][band_idx] move32(); - temp = Mpy_32_16_1( band_nrg, sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); - IF( LT_16( hHeadTrackData->q_procChEneIIR, q_temp ) ) + temp = Mpy_32_16_1( band_nrg, sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); // q_band_nrg + IF( LT_16( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg ) ) { - hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_procChEneIIR ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); + hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_band_nrg, hHeadTrackData->q_procChEneIIR[ch][band_idx] ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_procChEneIIR[ch][band_idx] } ELSE { - hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR, q_temp ) ), temp ); + hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg ) ), temp ); // q_band_nrg } move32(); + hHeadTrackData->q_procChEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_band_nrg ); + move16(); } ELSE { @@ -2924,27 +2938,27 @@ static void adaptTransportSignalsHeadtracked_fx( move32(); temp = Mpy_32_16_1( ch_nrg[ch], sub( 32767, ADAPT_HTPROTO_IIR_FAC_FX ) ); - IF( LT_16( hHeadTrackData->q_procChEneIIR, q_temp ) ) + IF( LT_16( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] ) ) { - hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp, hHeadTrackData->q_procChEneIIR ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); + hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( temp, sub( q_temp[ch], hHeadTrackData->q_procChEneIIR[ch][band_idx] ) ), hHeadTrackData->procChEneIIR_fx[ch][band_idx] ); // hHeadTrackData->q_procChEneIIR[ch][band_idx] } ELSE { - hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR, q_temp ) ), temp ); + hHeadTrackData->procChEneIIR_fx[ch][band_idx] = L_add( L_shr( hHeadTrackData->procChEneIIR_fx[ch][band_idx], sub( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] ) ), temp ); // q_temp[ch] } move32(); + hHeadTrackData->q_procChEneIIR[ch][band_idx] = s_min( hHeadTrackData->q_procChEneIIR[ch][band_idx], q_temp[ch] ); + move16(); } } - q_procChEneIIR = s_min( hHeadTrackData->q_procChEneIIR, q_temp ); - /* Equalize */ - ene_target = L_add( hHeadTrackData->chEneIIR_fx[0][band_idx], hHeadTrackData->chEneIIR_fx[1][band_idx] ); // q_chEneIIR// + ene_target = BASOP_Util_Add_Mant32Exp( hHeadTrackData->chEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[0][band_idx] ), hHeadTrackData->chEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_chEneIIR[1][band_idx] ), &ene_target_e ); - ene_proc = L_add( hHeadTrackData->procChEneIIR_fx[0][band_idx], hHeadTrackData->procChEneIIR_fx[1][band_idx] ); // q_procChEneIIR// + ene_proc = BASOP_Util_Add_Mant32Exp( hHeadTrackData->procChEneIIR_fx[0][band_idx], sub( 31, hHeadTrackData->q_procChEneIIR[0][band_idx] ), hHeadTrackData->procChEneIIR_fx[1][band_idx], sub( 31, hHeadTrackData->q_procChEneIIR[1][band_idx] ), &ene_proc_e ); temp_div = L_deposit_h( BASOP_Util_Divide3232_Scale( ene_target, L_max( 1, ene_proc ), &e_div ) ); - e_div = add( e_div, sub( q_procChEneIIR, q_chEneIIR ) ); + e_div = add( e_div, sub( ene_target_e, ene_proc_e ) ); eqVal = Sqrt32( temp_div, &e_div ); @@ -2994,16 +3008,8 @@ static void adaptTransportSignalsHeadtracked_fx( } IF( is_zero ) { - hHeadTrackData->q_chEneIIR = 31; - move16(); - } - ELSE - { - tmp = sub( s_min( getScaleFactor32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); - scale_sig32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); - scale_sig32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); - hHeadTrackData->q_chEneIIR = add( q_chEneIIR, tmp ); - move16(); + set16_fx( hHeadTrackData->q_chEneIIR[0], 31, MASA_FREQUENCY_BANDS ); + set16_fx( hHeadTrackData->q_chEneIIR[1], 31, MASA_FREQUENCY_BANDS ); } is_zero = 1; @@ -3020,17 +3026,10 @@ static void adaptTransportSignalsHeadtracked_fx( } IF( is_zero ) { - hHeadTrackData->q_procChEneIIR = 31; - move16(); - } - ELSE - { - tmp = sub( s_min( getScaleFactor32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); - scale_sig32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); - scale_sig32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); - hHeadTrackData->q_procChEneIIR = add( q_procChEneIIR, tmp ); - move16(); + set16_fx( hHeadTrackData->q_procChEneIIR[0], 31, MASA_FREQUENCY_BANDS ); + set16_fx( hHeadTrackData->q_procChEneIIR[1], 31, MASA_FREQUENCY_BANDS ); } + return; } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 1633f42d0..b9403e7da 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1439,10 +1439,11 @@ ivas_error ivas_combined_orientation_open( set_zero_fx( ( *hCombinedOrientationData )->chEneIIR_fx[1], MASA_FREQUENCY_BANDS ); set_zero_fx( ( *hCombinedOrientationData )->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS ); set_zero_fx( ( *hCombinedOrientationData )->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS ); - ( *hCombinedOrientationData )->q_chEneIIR = Q31; - move16(); - ( *hCombinedOrientationData )->q_procChEneIIR = Q31; - move16(); + set16_fx( ( *hCombinedOrientationData )->q_chEneIIR[0], Q31, MASA_FREQUENCY_BANDS ); + set16_fx( ( *hCombinedOrientationData )->q_chEneIIR[1], Q31, MASA_FREQUENCY_BANDS ); + set16_fx( ( *hCombinedOrientationData )->q_procChEneIIR[0], Q31, MASA_FREQUENCY_BANDS ); + set16_fx( ( *hCombinedOrientationData )->q_procChEneIIR[1], Q31, MASA_FREQUENCY_BANDS ); + ( *hCombinedOrientationData )->isExtOrientationFrozen = 0; move16(); ( *hCombinedOrientationData )->isHeadRotationFrozen = 0; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 2654e5a53..ddf2b5942 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -837,9 +837,9 @@ typedef struct ivas_combined_orientation_struct Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */ Word32 Rmat_prev_fx[3][3]; /* Q30 */ Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ - Word16 q_chEneIIR; + Word16 q_chEneIIR[2][MASA_FREQUENCY_BANDS]; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ - Word16 q_procChEneIIR; + Word16 q_procChEneIIR[2][MASA_FREQUENCY_BANDS]; Word16 shd_rot_max_order; IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_QUATERNION Quaternion_frozen_ext; -- GitLab From a7617c8fada6aec8684857bb577d9895033db409 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 10 Jun 2025 09:55:16 +0530 Subject: [PATCH 225/692] Disable WMOPS macro in options.h - Fix for MR 1572 --- 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 940cd1fe7..cd57657b0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -54,7 +54,7 @@ #define SUPPORT_JBM_TRACEFILE /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -#define WMOPS /* Activate complexity and memory counters */ +/*#define WMOPS*/ /* Activate complexity and memory counters */ #ifdef WMOPS #define WMOPS_PER_FRAME /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ #define WMOPS_DETAIL /* Output detailed complexity printout for every function. Increases runtime overhead */ -- GitLab From 9230c2956c4af8efefae97b3780b37203b808811 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 9 Jun 2025 19:33:07 +0530 Subject: [PATCH 226/692] Fix for 3GPP issue 1732: Accuracy of spatial metadata in ivas_omasa_enc_fx compared to the floating point equivalent Link #1732 --- lib_com/ivas_dirac_com_fx.c | 33 ++++++++---- lib_enc/ivas_omasa_enc_fx.c | 101 ++++++++++++++++++++++++++---------- 2 files changed, 96 insertions(+), 38 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 2be3f8ace..0922e0289 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -796,19 +796,23 @@ void computeDiffuseness_fixed( { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; + Word64 tmp_intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; + Word16 intensity_slow_abs_exp[CLDFB_NO_CHANNELS_MAX]; Word32 energy_slow[CLDFB_NO_CHANNELS_MAX]; - Word16 i, j, k; + Word16 i, j, k, tmp16; Word32 tmp = 0; move32(); Word32 *p_tmp; const Word32 *p_tmp_c; Word16 min_q_shift1, min_q_shift2, exp1, exp2, q_tmp; - Word16 q_ene, q_intensity, q_intensity_slow; + 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 ); set_zero_fx( intensity_slow_abs, CLDFB_NO_CHANNELS_MAX ); + set16_fx( intensity_slow_abs_exp, 0, CLDFB_NO_CHANNELS_MAX ); + set64_fx( tmp_intensity_slow_abs, 0, 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 */ @@ -892,10 +896,8 @@ void computeDiffuseness_fixed( 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 ); + scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), -2 ); + q_intensity = sub( q_intensity, 2 ); /* intensity_slow.^2 + intensity_slow_abs*/ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) @@ -904,11 +906,19 @@ void computeDiffuseness_fixed( FOR( k = 0; k < num_freq_bands; k++ ) { - intensity_slow_abs[k] = Madd_32_32( intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); - move32(); + tmp_intensity_slow_abs[k] = W_mac_32_32( tmp_intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); + move64(); } } - q_intensity_slow = sub( add( q_intensity, q_intensity ), 31 ); + + FOR( k = 0; k < num_freq_bands; k++ ) + { + tmp16 = W_norm( tmp_intensity_slow_abs[k] ); + intensity_slow_abs[k] = W_extract_h( W_shl( tmp_intensity_slow_abs[k], tmp16 ) ); + move32(); + intensity_slow_abs_exp[k] = sub( 31, sub( add( add( shl( q_intensity, 1 ), 1 ), tmp16 ), 32 ) ); + move16(); + } /* Compute Diffuseness */ p_tmp = intensity_slow_abs; @@ -916,7 +926,8 @@ void computeDiffuseness_fixed( move16(); FOR( i = 0; i < num_freq_bands; ++i ) { - exp1 = sub( 31, q_intensity_slow ); + exp1 = intensity_slow_abs_exp[i]; + move16(); tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index b88bb69a1..58ba680d6 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -82,13 +82,14 @@ static void ivas_omasa_dmx_fx( Word16 prev_gains[][MASA_MAX_TRANSPORT_CHANNELS], /*o:q15*/ const Word16 interpolator[L_FRAME48k] /*i:q15*/ ); -static void computeIntensityVector_enc_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 */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity vector */ - Word16 guard_bits ); +void computeIntensityVector_enc_fx( + const Word16 *band_grouping, + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ + const Word16 num_frequency_bands, + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ + Word16 *exp_intensity_real, + 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 ); /*--------------------------------------------------------------------------* * ivas_omasa_enc_open() @@ -1191,8 +1192,13 @@ static void ivas_omasa_param_est_enc_fx( norm_buff = s_min( norm_buff, L_norm_arr( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ) ); guard_bits = find_guarded_bits_fx( max_band_grouping_diff ); guard_bits = add( guard_bits, sub( 1, norm_buff ) ); - computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, guard_bits ); - intensity_real_e = sub( add( 62, guard_bits ), shl( q, 1 ) ); + + scale_sig32( &Foa_RealBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX, negate( guard_bits ) ); + scale_sig32( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX, negate( guard_bits ) ); + + q = sub( q, guard_bits ); + + computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, &intensity_real_e, 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], intensity_real_e, NULL ); @@ -1478,20 +1484,27 @@ static void ivas_omasa_dmx_fx( } void computeIntensityVector_enc_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 */ - Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : Imag part of input signal */ - const Word16 num_frequency_bands, /* i : Number of frequency bands */ - Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /* o : Intensity vector */ - Word16 guard_bits ) + const Word16 *band_grouping, + Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ + Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ + const Word16 num_frequency_bands, + Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ + Word16 *exp_intensity_real, + Word16 inp_q ) { - /* Reminder - * X = a + ib; Y = c + id - * X*Y = ac - bd + i(ad +bc) - */ Word16 i, j; Word32 real, img; - Word16 brange[2]; + Word16 brange[2], shift = 63; + move16(); + Flag is_zero = 0; + move16(); + + Word64 intensity_real64[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; + + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + set64_fx( intensity_real64[i], 0, MASA_FREQUENCY_BANDS ); + } FOR( i = 0; i < num_frequency_bands; i++ ) { @@ -1510,21 +1523,55 @@ void computeIntensityVector_enc_fx( FOR( j = brange[0]; j < brange[1]; j++ ) { real = Cldfb_RealBuffer[0][j]; - img = Cldfb_ImagBuffer[0][j]; - /* Intensity is XYZ order, audio is WYZX order. */ - intensity_real[0][i] = L_add( intensity_real[0][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[3][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[3][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits - move32(); - intensity_real[1][i] = L_add( intensity_real[1][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[1][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[1][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits move32(); - intensity_real[2][i] = L_add( intensity_real[2][i], L_add( L_shr( Mpy_32_32( Cldfb_RealBuffer[2][j], real ), guard_bits ), L_shr( Mpy_32_32( Cldfb_ImagBuffer[2][j], img ), guard_bits ) ) ); // output Q= 2* input_q -31-guard_bits + img = Cldfb_ImagBuffer[0][j]; move32(); + /* Intensity is XYZ order, audio is WYZX order. */ + intensity_real64[0][i] = W_add( intensity_real64[0][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q= 2* input_q + move64(); + intensity_real64[1][i] = W_add( intensity_real64[1][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q= 2* input_q + move64(); + intensity_real64[2][i] = W_add( intensity_real64[2][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q= 2* input_q + move64(); + } + } + + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + is_zero = is_zero_arr64( intensity_real64[i], MASA_FREQUENCY_BANDS ); + IF( is_zero == 0 ) + { + BREAK; } } + IF( is_zero == 0 ) + { + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + shift = s_min( shift, W_norm_arr( intensity_real64[i], MASA_FREQUENCY_BANDS ) ); + } + + FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + { + FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) + { + intensity_real[i][j] = W_extract_h( W_shl( intensity_real64[i][j], shift ) ); + move32(); + } + } + + *exp_intensity_real = sub( 31, sub( add( shift, shl( inp_q, 1 ) ), 32 ) ); + move16(); + } + ELSE + { + *exp_intensity_real = 0; + move16(); + } return; } - static void computeReferencePower_omasa_ivas_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 Q6*/ -- GitLab From 42eb3f1e3ebd08e695c9c2be9ee1944d7f5fd785 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 10 Jun 2025 11:08:09 +0200 Subject: [PATCH 227/692] Fix for fx-fx job --- .gitlab-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d10993ad6..df6069de2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,10 +37,10 @@ workflow: IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long' variables: - IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH' + IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long-fx-fx' variables: - IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' + IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against input (pass-through only): $CI_COMMIT_BRANCH' @@ -196,7 +196,7 @@ workflow: .ivas-pytest-anchor: &ivas-pytest-anchor stage: test needs: ["build-codec-linux-make"] - timeout: "360 minutes" + timeout: "15 hours" 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" @@ -1352,6 +1352,8 @@ ivas-pytest-compare_ref-long-fx-fx: extends: - .rules-pytest-long-fx-fx - .test-job-linux + tags: + - ivas-linux before_script: - USE_LTV=1 - REF_ENCODER_PATH=./$DUT_ENCODER_PATH @@ -1364,6 +1366,8 @@ ivas-pytest-compare_ref-long-fx-fx-lev-10: extends: - .rules-pytest-long-fx-fx - .test-job-linux + tags: + - ivas-linux before_script: - USE_LTV=1 - REF_ENCODER_PATH=./$DUT_ENCODER_PATH @@ -1376,6 +1380,8 @@ ivas-pytest-compare_ref-long-fx-fx-lev+10: extends: - .rules-pytest-long-fx-fx - .test-job-linux + tags: + - ivas-linux before_script: - USE_LTV=1 - REF_ENCODER_PATH=./$DUT_ENCODER_PATH -- GitLab From 5575a01485d21a0863a7a228ecca43d917251c47 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:28:54 +0200 Subject: [PATCH 228/692] Added changes for float MR 1429 - aeid selection --- lib_com/options.h | 1 + lib_util/render_config_reader.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 99013a1c5..4ea8c823c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -127,6 +127,7 @@ #endif //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ +#define FIX_1020_AEID_SELECTION_ERRORS /* Philips: issue #1020: fix for acoustic environemnt ID selection errors */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ #define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ #define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index dae55f18c..8a33501af 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2197,7 +2197,11 @@ ivas_error RenderConfigReader_read( return IVAS_ERR_INVALID_RENDER_CONFIG; } idx = strtol( strtok( NULL, ":" ), NULL, 0 ); +#ifdef FIX_1020_AEID_SELECTION_ERRORS + pRenderConfigReader->pAE[acIdx].id = idx; +#else pRenderConfigReader->pAE->id = idx; +#endif aeHasFgIdx = aeHasPredelay = aeHasRt60 = aeHasDsr = FALSE; aeHasERsize = aeHasERabs = FALSE; -- GitLab From 211901e3cdd524c03c565c7f92662e695629732a Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 10 Jun 2025 13:09:47 +0200 Subject: [PATCH 229/692] add missing pop_wmops() --- lib_com/options.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index cd57657b0..0da972932 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,12 +101,10 @@ #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_1733_CLDFB_BUG +#define FIX_1740_MISING_POP_WMOPS /* VA: fix issue 1740: missing pop_wmops() */ #endif -- GitLab From 26f32cac3a02779628f87228700c739b8fe5f665 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:38:23 +0200 Subject: [PATCH 230/692] enabled compiler switch and changed target branch for CI pipeline --- .gitlab-ci.yml | 2 +- lib_com/options.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d630d11ba..545fe88a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "main" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 diff --git a/lib_com/options.h b/lib_com/options.h index 99013a1c5..69d97f02d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ -//#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ +#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ -- GitLab From a043cdb6c6c2ada41713db9da5fe81b192e4988a Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:48:37 +0200 Subject: [PATCH 231/692] restart pipeline -- GitLab From 24afafdf5f31ec85672e066716e95693accd65b8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 10 Jun 2025 18:35:20 +0530 Subject: [PATCH 232/692] Fix for 3GPP issue 1724: Renderer MASA output metadata difference Link #1724 --- lib_com/ivas_dirac_com_fx.c | 39 +++++++++++++++++------------------ lib_rend/ivas_dirac_ana_fx.c | 17 +++++++++++++-- lib_rend/ivas_mcmasa_ana_fx.c | 2 +- lib_rend/ivas_omasa_ana_fx.c | 22 ++++++++++++-------- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 0922e0289..feea9c5af 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -783,7 +783,6 @@ void computeDirectionVectors_fx( * * *------------------------------------------------------------------------*/ - void computeDiffuseness_fixed( Word32 *buffer_intensity[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF], // i: Q(q_factor_intensity) const Word32 *buffer_energy, // i: Q(q_factor_energy) @@ -796,10 +795,10 @@ void computeDiffuseness_fixed( { Word32 intensity_slow[DIRAC_NUM_DIMS * CLDFB_NO_CHANNELS_MAX]; Word32 intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; - Word64 tmp_intensity_slow_abs[CLDFB_NO_CHANNELS_MAX]; - Word16 intensity_slow_abs_exp[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 i, j, k, tmp16; + Word16 i, j, k; Word32 tmp = 0; move32(); Word32 *p_tmp; @@ -809,10 +808,8 @@ void computeDiffuseness_fixed( /* Compute Intensity slow and energy slow buffer_intensity and buffer_energy */ - set_zero_fx( intensity_slow, 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 ); - set16_fx( intensity_slow_abs_exp, 0, CLDFB_NO_CHANNELS_MAX ); - set64_fx( tmp_intensity_slow_abs, 0, 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 */ @@ -896,27 +893,31 @@ void computeDiffuseness_fixed( q_intensity = s_min( q_intensity, q_tmp ); } - scale_sig32( intensity_slow, i_mult( DIRAC_NUM_DIMS, num_freq_bands ), -2 ); - q_intensity = sub( q_intensity, 2 ); - + 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; + move64(); + } + /* intensity_slow.^2 + intensity_slow_abs*/ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { p_tmp = intensity_slow + j * num_freq_bands; - FOR( k = 0; k < num_freq_bands; k++ ) { - tmp_intensity_slow_abs[k] = W_mac_32_32( tmp_intensity_slow_abs[k], p_tmp[k], p_tmp[k] ); - move64(); + intensity_slow_abs_64[k] = W_add( intensity_slow_abs_64[k], W_mult_32_32( p_tmp[k], p_tmp[k] ) ); // 2*q_intensity+1 } } - FOR( k = 0; k < num_freq_bands; k++ ) { - tmp16 = W_norm( tmp_intensity_slow_abs[k] ); - intensity_slow_abs[k] = W_extract_h( W_shl( tmp_intensity_slow_abs[k], tmp16 ) ); + Word16 shift = W_norm( intensity_slow_abs_64[k] ); + intensity_slow_abs[k] = W_extract_h( W_shl( intensity_slow_abs_64[k], shift ) ); move32(); - intensity_slow_abs_exp[k] = sub( 31, sub( add( add( shl( q_intensity, 1 ), 1 ), tmp16 ), 32 ) ); + intensity_slow_abs_q[k] = sub( add( add( q_intensity, q_intensity ), shift ), 31 ); move16(); } @@ -926,8 +927,7 @@ void computeDiffuseness_fixed( move16(); FOR( i = 0; i < num_freq_bands; ++i ) { - exp1 = intensity_slow_abs_exp[i]; - move16(); + exp1 = sub( 31, intensity_slow_abs_q[i] ); tmp = Sqrt32( p_tmp[i], &exp1 ); tmp = BASOP_Util_Divide3232_Scale_newton( tmp, L_add( energy_slow[i], EPSILLON_FX ), &exp2 ); @@ -966,7 +966,6 @@ void computeDiffuseness_fixed( return; } - Word32 deindex_azimuth_fx( /* o : output Q22 */ Word16 id_phi, /* i : index */ const Word16 no_bits, /* i : number of bits for the spherical grid */ diff --git a/lib_rend/ivas_dirac_ana_fx.c b/lib_rend/ivas_dirac_ana_fx.c index f282e8390..df75d6d0a 100644 --- a/lib_rend/ivas_dirac_ana_fx.c +++ b/lib_rend/ivas_dirac_ana_fx.c @@ -138,6 +138,7 @@ ivas_error ivas_dirac_ana_open_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); } + set16_fx( hDirAC->direction_vector_e[i][j], 31, MASA_FREQUENCY_BANDS ); } } @@ -257,6 +258,7 @@ void ivas_dirac_ana_fx( /* 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 ); /* 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 ); /* Downmix */ @@ -334,13 +336,22 @@ static void ivas_dirac_param_est_ana_fx( move32(); hDirAC->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); + + hDirAC->direction_vector_e[0][block_m_idx][band_m_idx] = 0; + move16(); + hDirAC->direction_vector_e[1][block_m_idx][band_m_idx] = 0; + move16(); + hDirAC->direction_vector_e[2][block_m_idx][band_m_idx] = 0; + move16(); } /* Need to initialize renormalization_factors, and variables to be normalized */ set32_fx( renormalization_factor_diff_fx, 0, hDirAC->nbands ); + set16_fx( renormalization_factor_diff_e, 31, hDirAC->nbands ); set32_fx( diffuseness_m_fx, 0, hDirAC->nbands ); + set16_fx( diffuseness_e, 0, hDirAC->nbands ); set32_fx( hDirAC->energy_fx[block_m_idx], 0, MASA_FREQUENCY_BANDS ); - set32_fx( hDirAC->energy_fx[block_m_idx], 0, MASA_FREQUENCY_BANDS ); + set16_fx( hDirAC->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -351,7 +362,9 @@ static void ivas_dirac_param_est_ana_fx( move16(); FOR( i = 0; i < numAnalysisChannels; i++ ) { - cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][( l_ts * ts )] ), Foa_RealBuffer_fx[i], Foa_ImagBuffer_fx[i], l_ts, hDirAC->cldfbAnaEnc[i], &inp_q ); + inp_q = Q7; + 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 ) ); } diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index cfdd43116..bce7a4a5a 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -634,7 +634,7 @@ void ivas_mcmasa_param_est_ana_fx( { inp_q = q_data; move16(); - cldfbAnalysis_ts_fx_fixed_q( &( data_fx[i][i_mult( l_ts, ts )] ), Chnl_RealBuffer_fx[i], Chnl_ImagBuffer_fx[i], l_ts, hMcMasa->cldfbAnaEnc[i], &inp_q ); + 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 ) ); } diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index bce8870c8..d82346d34 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -41,7 +41,6 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" - /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ @@ -170,6 +169,7 @@ ivas_error ivas_omasa_ana_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OMASA data\n" ) ); } + set16_fx( hOMasa->direction_vector_e[i][j], 0, MASA_FREQUENCY_BANDS ); } } @@ -319,11 +319,11 @@ void ivas_omasa_ana_fx( ivas_omasa_param_est_ana_fx( hOMasa, data_in_f_fx, *data_in_q, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, &energyRatio_q, spreadCoherence_fx, &spreadCoherence_q, surroundingCoherence_fx, &sorroundingCoherence_q, input_frame, nchan_ism ); /* Create MASA metadata buffer from the estimated values */ - ivas_create_masa_out_meta_fx( hOMasa->hMasaOut, hOMasa->sph_grid16, nchan_transport, elevation_m_values_fx, azimuth_m_values_fx, energyRatio_fx, spreadCoherence_fx, surroundingCoherence_fx, Q31, Q31, Q31 ); /* Downmix */ ivas_omasa_dmx_fx( data_in_f_fx, data_in_q, input_frame, nchan_transport, nchan_ism, hOMasa->ism_azimuth_fx, hOMasa->ism_elevation_fx, hOMasa->prev_object_dm_gains_fx, hOMasa->interpolator_fx ); + return; } @@ -372,7 +372,6 @@ static void ivas_omasa_param_est_ana_fx( Word32 renormalization_factor_diff_fx[MASA_FREQUENCY_BANDS]; Word16 renormalization_factor_diff_e[MASA_FREQUENCY_BANDS]; Word32 norm_tmp_fx; - Word16 tmp_ener_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32 dir_v_fx[DIRAC_NUM_DIMS] /*, L_tmp1, L_tmp2*/; Word16 dir_v_q /*, norm_tmp_q*/; @@ -422,15 +421,23 @@ static void ivas_omasa_param_est_ana_fx( move32(); hOMasa->direction_vector_m_fx[2][block_m_idx][band_m_idx] = 0; move32(); + + hOMasa->direction_vector_e[0][block_m_idx][band_m_idx] = 0; + move16(); + hOMasa->direction_vector_e[1][block_m_idx][band_m_idx] = 0; + move16(); + hOMasa->direction_vector_e[2][block_m_idx][band_m_idx] = 0; + move16(); } /* Need to initialize renormalization_factors, and variables to be normalized */ set_zero_fx( renormalization_factor_diff_fx, hOMasa->nbands ); + set16_fx( renormalization_factor_diff_e, 0, hOMasa->nbands ); set_zero_fx( diffuseness_m_fx, hOMasa->nbands ); + set16_fx( diffuseness_e, 0, hOMasa->nbands ); set_zero_fx( hOMasa->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS ); - - set16_fx( tmp_ener_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); + set16_fx( hOMasa->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -441,10 +448,8 @@ static void ivas_omasa_param_est_ana_fx( move16(); FOR( i = 0; i < nchan_ism; i++ ) { - inp_q = data_f_q; - move16(); - cldfbAnalysis_ts_fx_fixed_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 ); + 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 ) ); @@ -554,7 +559,6 @@ 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] ); 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] ); -- GitLab From 9c90a8621750ca145a5ce48112830f527c00f2b7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 10 Jun 2025 18:39:50 +0530 Subject: [PATCH 233/692] Clang formatting --- lib_com/ivas_dirac_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index feea9c5af..c08dade43 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -902,7 +902,7 @@ void computeDiffuseness_fixed( intensity_slow_abs_64[k] = 0; move64(); } - + /* intensity_slow.^2 + intensity_slow_abs*/ FOR( j = 0; j < DIRAC_NUM_DIMS; ++j ) { -- GitLab From 9e6ab98f9c12c669a6f4642f2f38b2de8e429a7b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 10 Jun 2025 15:57:30 +0200 Subject: [PATCH 234/692] Restore to using basop-ci-branch, just get the new HRTF binary files --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 545fe88a1..aa08ae0f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "main" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -276,6 +276,9 @@ stages: - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO - git pull origin $BASOP_CI_BRANCH_PC_REPO +# Restore new format of HRTF binary + - git fetch origin main + - git checkout origin/main -- scripts/binauralRenderer_interface/binaural_renderers_hrtf_data - cd - - cp -r $SCRIPTS_DIR/ci . - cp -r $SCRIPTS_DIR/scripts . -- GitLab From 7de08c8f10180f2ff578fbadb88769b437a478f8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 11 Jun 2025 10:22:48 +0530 Subject: [PATCH 235/692] Precision improvements for processIGF, in McMASA and OMASA paths --- lib_com/ivas_dirac_com_fx.c | 3 +- lib_com/ivas_prot_fx.h | 6 +- lib_com/prot_fx.h | 4 +- lib_com/rom_com.c | 24 +-- lib_com/stat_com.h | 1 + lib_enc/cod_tcx_fx.c | 8 +- lib_enc/igf_enc.c | 194 +++++++++---------------- lib_enc/igf_enc_fx.c | 85 ++++++++++- lib_enc/ivas_dirac_enc_fx.c | 42 +++--- lib_enc/ivas_mcmasa_enc_fx.c | 136 ++++++++++------- lib_enc/ivas_mct_enc_mct_fx.c | 18 ++- lib_enc/ivas_omasa_enc_fx.c | 142 +++++++++--------- lib_enc/ivas_stereo_mdct_core_enc_fx.c | 23 ++- lib_enc/prot_fx_enc.h | 7 + lib_enc/tcx_utils_enc_fx.c | 2 +- 15 files changed, 377 insertions(+), 318 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 0922e0289..21f5d4995 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -608,8 +608,7 @@ void computeDirectionVectors_fixed( Word32 *direction_vector_x, /* o: Q30*/ Word32 *direction_vector_y, /* o: Q30*/ Word32 *direction_vector_z, /* o: Q30*/ - Word16 i_e /*Exponent of all the intensity buffers*/ - , + Word16 i_e, /*Exponent of all the intensity buffers*/ Word16 *i_e_band ) { Word16 i; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 00f0ba43b..74e682a4b 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3230,8 +3230,7 @@ void computeDirectionVectors_fixed( Word32 *direction_vector_x, /*Q30*/ Word32 *direction_vector_y, /*Q30*/ Word32 *direction_vector_z, /*Q30*/ - Word16 i_e /*Exponent of all the intensity buffers*/ - , + Word16 i_e, /*Exponent of all the intensity buffers*/ Word16 *i_e_band ); @@ -3293,8 +3292,7 @@ void computeReferencePower_enc_fx( Word16 ref_power_w, /* i : use 0 if hodirac is enabled */ const Word16 nchan_ana, /* i : number of analysis channels */ Word16 inp_q, /* i : q of cld buffers */ - Word16 *ref_q /* i : output q */ -); + Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] ); void computeReferencePower_enc_fx_dirac( const Word16 *band_grouping, /* i : Band grouping for estimation */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0a11364dc..38a6077e8 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10502,7 +10502,7 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ @@ -10519,7 +10519,7 @@ void IGFEncApplyStereo_fx( const Word16 igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index a5c8a3b7c..9eaf690f1 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -20441,42 +20441,42 @@ const Word16 qGains[2][1 << kTcxHmNumGainBits] = const struct TnsParameters tnsParametersIGF32kHz_LowBR[1] = { - { 600, 3, /*1.85f, 0.075f, 4.4f,*/ 237/*1.85f Q7*/, 2458/*0.075f Q15*/,563 /*4.4f Q7*/ } + { 600, 3, /*1.85f, 0.075f, 4.4f,*/ 237/*1.85f Q7*/, 15518925/*1.85f Q23*/, 2458/*0.075f Q15*/,563 /*4.4f Q7*/ } }; const struct TnsParameters tnsParameters32kHz[2] = { - { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 983/*0.0300f Q15*/, 128/*1.0f Q7*/}, - { 600, 1, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/, 2048/*0.0625f Q15*/, 563 /*4.4f Q7*/ } + { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/,11324621/*1.35f Q23*/, 983/*0.0300f Q15*/, 128/*1.0f Q7*/}, + { 600, 1, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/,14680064/*1.75f Q23*/, 2048/*0.0625f Q15*/, 563 /*4.4f Q7*/ } }; const struct TnsParameters tnsParameters32kHz_grouped[2] = { - { 8400, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ }, - { 800, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/} + { 8400, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ }, + { 800, 3, /*1.375f, 0.03125f, 1.0f ,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/} }; const struct TnsParameters tnsParameters16kHz[1] = { - { 600, 3, /*1.5f, 0.05f, 4.4f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ ,563 /*4.4f Q7*/ } + { 600, 3, /*1.5f, 0.05f, 4.4f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ ,563 /*4.4f Q7*/ } }; const struct TnsParameters tnsParameters16kHz_grouped[2] = { - { 4400, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/}, - { 800, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/} + { 4400, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/}, + { 800, 3, /*1.5f, 0.05f, 1.0f,*/ 192/*1.5f Q7*/, 12582912/*1.5f Q23*/, 1638/*0.05f Q15*/ , 128/*1.0f Q7*/} }; const struct TnsParameters tnsParameters48kHz_grouped[2] = { - { 10400, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/}, - { 800, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ } + { 10400, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/}, + { 800, 3, /*1.375f, 0.03125f, 1.0f,*/ 176/*1.375f Q7*/,11534336/*1.375f Q23*/, 1024/*0.03125f Q15*/ , 128/*1.0f Q7*/ } }; const struct TnsParameters tnsParameters32kHz_Stereo[2]= { - { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 983/*0.0300f Q15*/ , 128/*1.0f Q7*/}, - { 600, 3, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/, 2048/*0.0625f Q15*/ ,563 /*4.4f Q7*/ } + { 4500, 3, /*1.35f, 0.0300f, 1.0f ,*/ 173/*1.35f Q7*/, 11324621/*1.35f Q23*/, 983/*0.0300f Q15*/ , 128/*1.0f Q7*/}, + { 600, 3, /*1.75f, 0.0625f, 4.4f ,*/ 224/*1.75f Q7*/,14680064/*1.75f Q23*/, 2048/*0.0625f Q15*/ ,563 /*4.4f Q7*/ } }; const Word16 tnsAcfWindow_fx[TNS_MAX_FILTER_ORDER] = diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 80822f59e..712c1d702 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -561,6 +561,7 @@ struct TnsParameters Word16 startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */ Word16 nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */ Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ + Word32 minPredictionGain_32; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */ Word16 minEnergyChange; /* Minimum energy change required to turn on the TNS filter. Exponent = 8 */ }; diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c40db6678..27f3d2aa6 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -4914,8 +4914,8 @@ void TNSAnalysisStereo_fx( test(); test(); test(); - IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && - GT_32( pFilter[1]->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters[1]->minPredictionGain ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) + IF( GT_32( pFilter[0]->predictionGain32, L_shl_sat( ( pTnsParameters[0]->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter[0]->predictionGain_e ) ) ) && LT_32( sts[0]->element_brate, IVAS_80k ) && + GT_32( pFilter[1]->predictionGain32, L_shl_sat( ( pTnsParameters[1]->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter[1]->predictionGain_e ) ) ) && EQ_16( sts[0]->hTcxEnc->tnsData[k].nFilters, sts[1]->hTcxEnc->tnsData[k].nFilters ) ) { pFilter[0]->predictionGain32 = pFilter[1]->predictionGain32 = meanPredictionGain_fx; /* more TNS filter sync at 48kbps */ move32(); @@ -4947,7 +4947,7 @@ void TNSAnalysisStereo_fx( test(); test(); - IF( GT_32( meanPredictionGain_fx, L_shl_sat( L_deposit_h( pTnsParameters[0]->minPredictionGain ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) + IF( GT_32( meanPredictionGain_fx, L_shl_sat( ( pTnsParameters[0]->minPredictionGain_32 ), sub( PRED_GAIN_E, meanPredictionGain_e ) ) ) || GT_16( maxAvgSqrCoef_fx, pTnsParameters[0]->minAvgSqrCoef ) ) { test(); test(); @@ -5245,7 +5245,7 @@ void TNSAnalysisStereo_fx( } test(); - IF( GT_32( pFilter->predictionGain32, L_shl_sat( L_deposit_h( pTnsParameters->minPredictionGain ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) + IF( GT_32( pFilter->predictionGain32, L_shl_sat( ( pTnsParameters->minPredictionGain_32 ), sub( PRED_GAIN_E, pFilter->predictionGain_e ) ) ) || GT_16( pFilter->avgSqrCoef, pTnsParameters->minAvgSqrCoef ) ) { test(); test(); diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 91e1b8520..db77144df 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -246,94 +246,6 @@ static Word16 IGF_getSFM_new_fx( /*! r: spectral tilt value */ /* Returns value with exponent as 9 and Q as 22*/ -static Word32 IGF_getTNR_fx( - const Word32 *powerSpectrum, /* i : energies */ - const Word16 start, /* i : start subband index */ - const Word16 stop, /* i : stop subband index */ - const Word16 adap, /* i : SFB width adaptation */ - Word16 e_ps, /*Stores exponent for powerSpectrum*/ - Word16 e_adap /*Stores exponent for adap*/ -) -{ - Word16 i; - Word16 width; - Word32 avg; - Word32 tonal; - Word16 tonal_e; /* holds exp for tonal*/ - Word32 noise; - Word16 noise_e; /* holds exp for noise*/ - Word32 tonalToNoise; - Word32 rootSpec[300]; - Word16 rootSpec_e[300]; /*rootSpec_e[i] holds exp for rootSpec[i]*/ - Word16 avg_e; /* holds exp for avg*/ - Word16 tmp_e; - avg = 0; - tonal = 0; - noise = EPSILON_FX; - tonal_e = 0; - noise_e = 0; - avg_e = 0; - tmp_e = 0; - move32(); - move32(); - move32(); - move16(); - move16(); - move16(); - move16(); - - set32_fx( rootSpec, 0, 300 ); - set16_fx( rootSpec_e, 0, 300 ); - - width = sub( stop, start ); - FOR( i = start; i < stop; i++ ) - { - rootSpec_e[i - start] = e_ps; - move16(); - rootSpec[i - start] = Sqrt32( powerSpectrum[i], &rootSpec_e[i - start] ); /*rootSpec[i - start] = sqrtf( powerSpectrum[i] );*/ - move32(); - avg = BASOP_Util_Add_Mant32Exp( avg, avg_e, rootSpec[i - start], rootSpec_e[i - start], &avg_e ); /*avg += rootSpec[i - start];resultant exponent is avg_e*/ - } - avg = BASOP_Util_Divide3216_Scale( avg, width, &tmp_e ); /*avg /= width;*/ - avg_e = add( 16, sub( add( avg_e, tmp_e ), 15 ) ); - - FOR( i = start; i < stop; i++ ) - { - Word16 normSpec_e; /*stores resultant exponent for normSpec*/ - Word16 normSpec = BASOP_Util_Divide3232_Scale( rootSpec[i - start], avg, &normSpec_e ); /*rootSpec[i - start] / avg;*/ - normSpec_e = add( normSpec_e, sub( rootSpec_e[i - start], avg_e ) ); - IF( GT_32( normSpec, L_add( L_shl( 1, sub( 15, normSpec_e ) ), L_shl( adap, sub( e_adap, normSpec_e ) ) ) ) ) - { - tonal = BASOP_Util_Add_Mant32Exp( tonal, tonal_e, rootSpec[i - start], rootSpec_e[i - start], &tonal_e ); /*tonal += rootSpec[i - start];*/ - } - ELSE IF( LT_32( normSpec, L_shl( 1, sub( 15, normSpec_e ) ) ) ) - { - noise = BASOP_Util_Add_Mant32Exp( noise, noise_e, rootSpec[i - start], rootSpec_e[i - start], &noise_e ); /*noise += rootSpec[i - start];*/ - } - } - - /*tonalToNoise = 20.f * log10f( max( 1e-018f, tonal / noise ) )*/ - IF( noise == 0 ) // To handle condition if denom = 0 - { - tonalToNoise = imult3216( L_shr( L_add( L_shl( 18 /* log10f(1e-018f) */, Q25 ), Mpy_32_16_1( L_add( BASOP_Util_Log2( tonal ), L_shl( tonal_e, Q25 ) ) /*Q25*/, INV_Log2_10_Q15 ) /*25+15-15*/ ), 3 ) /*Q22*/, 20 ); - } - ELSE - { - Word16 temp = BASOP_Util_Divide3232_Scale( tonal, noise, &tmp_e ); /*tonal / noise*/ - tmp_e = add( tmp_e, sub( tonal_e, noise_e ) ); - IF( GE_16( temp, 1 ) ) - { - tonalToNoise = imult3216( Mult_32_16( L_add( BASOP_Util_Log2( temp ), L_shl( add( 16, tmp_e ), Q25 ) ) /*Q25*/, INV_Log2_10_Q12 ) /*25+12-15*/, 20 ); /*Q22*/ - } - ELSE - { - tonalToNoise = -1509949440; /*-360.f Q22*/ - move32(); - } - } - - return tonalToNoise; -} static Word32 IGF_getTNR_ivas_fx( const Word32 *powerSpectrum, /* i : energies */ @@ -1000,7 +912,7 @@ static void IGF_CalculateStereoEnvelope_fx( const Word32 *pMDCTSpectrumMsInv_fx, /* i : MDCT spectrum */ Word16 pMDCTSpectrumMsInv_e, /* i : expontent for pMDCTSpectrumMsInv_fx */ const Word32 *pPowerSpectrum_fx, /* i : MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 pPowerSpectrum_e, /* i : exponent for pPowerSpectrum_fx */ + Word16 *pPowerSpectrum_e, /* i : exponent for pPowerSpectrum_fx */ const Word32 *pPowerSpectrumMsInv_fx, /* i : inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv, /* i : Q for pPowerSpectrumMsInv_fx */ const Word16 igfGridIdx, /* i : IGF grid index */ @@ -1033,19 +945,19 @@ static void IGF_CalculateStereoEnvelope_fx( Word16 sfm; Word16 crest; Word16 temp; - Word16 mean_x_e, mean_y_e; /*Stores exponent for mean_x and mean_y respectively*/ - Word16 mean_xy_e, mean_x2_e; /*stores exponent for mean_xy and mean_x2 respectively*/ - Word16 tileSrcSpec_e; /*Exponent for tileSrcSpec_fx*/ - Word16 sfbEnergyTileR_e; /*Exponent for sfbEnergyTileR_fx*/ - Word16 sfbEnergyTileC_e; /*Exponent for sfbEnergyTileC_fx*/ - Word16 sfbEnergyC_e; /*Exponent for sfbEnergyC_fx*/ - Word16 gain_e; /*exponent for gain_fx*/ - Word16 crest_exp; /*stores exponent for output from crest*/ - Word16 sfm_exp; /*stores exponent for ouput from sfm*/ - Word16 tmp_tb_e; /*Stores exponent for tmp_tb_fx*/ - Word16 tmp_sb_e; /*stores exponent for tmp_sb_fx*/ - Word16 slope_e; /*stores exponent for slope_fx*/ - Word16 sfbEnergyR_e; /*stores exponent for sfbEnergyR*/ + Word16 mean_x_e, mean_y_e; /*Stores exponent for mean_x and mean_y respectively*/ + Word16 mean_xy_e, mean_x2_e; /*stores exponent for mean_xy and mean_x2 respectively*/ + Word16 tileSrcSpec_e[MAX_IGF_SFB_LEN]; /*Exponent for tileSrcSpec_fx*/ + Word16 sfbEnergyTileR_e; /*Exponent for sfbEnergyTileR_fx*/ + Word16 sfbEnergyTileC_e; /*Exponent for sfbEnergyTileC_fx*/ + Word16 sfbEnergyC_e; /*Exponent for sfbEnergyC_fx*/ + Word16 gain_e; /*exponent for gain_fx*/ + Word16 crest_exp; /*stores exponent for output from crest*/ + Word16 sfm_exp; /*stores exponent for ouput from sfm*/ + Word16 tmp_tb_e; /*Stores exponent for tmp_tb_fx*/ + Word16 tmp_sb_e; /*stores exponent for tmp_sb_fx*/ + Word16 slope_e; /*stores exponent for slope_fx*/ + Word16 sfbEnergyR_e; /*stores exponent for sfbEnergyR*/ Word16 tmp_e; Word32 temp_pPowerSpectrumMsInv[N_MAX], length; Word16 q_temp_pPowerSpectrumMsInv = Q31, i; @@ -1110,7 +1022,7 @@ static void IGF_CalculateStereoEnvelope_fx( /*hPrivateData->logSpec[sb] = max( 0, (Word16) ( logf( max( FLT_MIN, pPowerSpectrum[sb] ) ) * INV_LOG_2 ) );*/ IF( LE_32( 1, pPowerSpectrum_fx[sb] ) ) { - hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ), 25 ) ); + hPrivateData->logSpec[sb] = s_max( 0, (Word16) L_shr( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ), 25 ) ); } ELSE { @@ -1152,25 +1064,25 @@ static void IGF_CalculateStereoEnvelope_fx( { IF( NE_16( coreMsMask[sb], coreMsMask[strt_cpy] ) ) { - sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/ + sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e[sb], &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/ norm_exp = norm_l( pMDCTSpectrumMsInv_fx[strt_cpy] ); final_exp = sub( pMDCTSpectrumMsInv_e, norm_exp ); scaled_value = L_shl( pMDCTSpectrumMsInv_fx[strt_cpy], norm_exp ); sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/ sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrumMsInv_fx[strt_cpy], sub( 31, q_pPowerSpectrumMsInv[strt_cpy] ), &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/ - tileSrcSpec_fx[sub( strt_cpy, tmp )] = temp_pPowerSpectrumMsInv[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/ - tileSrcSpec_e = sub( 31, q_temp_pPowerSpectrumMsInv ); + tileSrcSpec_fx[strt_cpy - tmp] = temp_pPowerSpectrumMsInv[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/ + tileSrcSpec_e[strt_cpy - tmp] = sub( 31, q_temp_pPowerSpectrumMsInv ); } ELSE { - sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e, &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/ + sfbEnergyC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyC_fx, sfbEnergyC_e, pPowerSpectrum_fx[sb], pPowerSpectrum_e[sb], &sfbEnergyC_e ); /*resultant exponent is stored in sfbEnergyC_e*/ norm_exp = norm_l( pMDCTSpectrum_fx[strt_cpy] ); final_exp = sub( pMDCTSpectrum_e, norm_exp ); scaled_value = L_shl( pMDCTSpectrum_fx[strt_cpy], norm_exp ); sfbEnergyTileR_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileR_fx, sfbEnergyTileR_e, Mult_32_32( scaled_value, scaled_value ), shl( final_exp, 1 ), &sfbEnergyTileR_e ); /*resultant exponent is stored in sfbEnergyTileR_e*/ - sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], pPowerSpectrum_e, &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/ - tileSrcSpec_fx[sub( strt_cpy, tmp )] = pPowerSpectrum_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/ - tileSrcSpec_e = pPowerSpectrum_e; + sfbEnergyTileC_fx = BASOP_Util_Add_Mant32Exp( sfbEnergyTileC_fx, sfbEnergyTileC_e, pPowerSpectrum_fx[strt_cpy], pPowerSpectrum_e[strt_cpy], &sfbEnergyTileC_e ); /*resultant exponent is stored in sfbEnergyTileC_e*/ + tileSrcSpec_fx[strt_cpy - tmp] = pPowerSpectrum_fx[strt_cpy]; /*resultant exponent is stored in tileSrcSpec_e*/ + tileSrcSpec_e[strt_cpy - tmp] = pPowerSpectrum_e[strt_cpy]; } move32(); move16(); @@ -1197,14 +1109,14 @@ static void IGF_CalculateStereoEnvelope_fx( move16(); // tmp_tb = IGF_getSFM_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]) / IGF_getCrest_ivas(pPowerSpectrum, swb_offset[sfb], swb_offset[sfb + 1]); - sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); + sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); + crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, swb_offset[sfb], swb_offset[sfb + 1] ); tmp_tb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_tb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_tb_fx*/ // tmp_sb = IGF_getSFM_ivas(tileSrcSpec, 0, strt_cpy - tmp) / IGF_getCrest_ivas(tileSrcSpec, 0, strt_cpy - tmp); - sfm = IGF_getSFM_ivas_fx( &sfm_exp, tileSrcSpec_fx, &tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); - crest = IGF_getCrest( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); + sfm = IGF_getSFM_ivas_fx( &sfm_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); + crest = IGF_getCrest_ivas( &crest_exp, tileSrcSpec_fx, tileSrcSpec_e, 0, sub( strt_cpy, tmp ) ); tmp_sb_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &tmp_e ); tmp_sb_e = add( tmp_e, sub( sfm_exp, crest_exp ) ); /*stores the resultant exponent for tmp_sb_fx*/ @@ -1320,7 +1232,7 @@ static void IGF_CalculateStereoEnvelope_fx( } ELSE { - y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e, Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/ + y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/ } mean_y_fx = add( mean_y_fx, y ); /*Q0*/ mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/ @@ -1348,8 +1260,8 @@ static void IGF_CalculateStereoEnvelope_fx( { Word16 shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] - shift, swb_offset[sfb + 1] - shift ); - sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); + sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); + crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, sub( swb_offset[sfb], shift ), sub( swb_offset[sfb + 1], shift ) ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } ELSE IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( slope_fx, add( slope_e, 16 ), threshold_fx, add( threshold_e, 16 ) ), 1 ) && ( NE_16( sfb, sub( hGrid->sfbWrap[hGrid->nTiles], 1 ) ) ) ) @@ -1357,8 +1269,8 @@ static void IGF_CalculateStereoEnvelope_fx( Word16 shift; shift = shr( width, 1 ); // shiftedSFM = IGF_getSFM_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ) / IGF_getCrest_ivas( pPowerSpectrum, swb_offset[sfb] + shift, swb_offset[sfb + 1] + shift ); - sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, &pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); - crest = IGF_getCrest( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); + sfm = IGF_getSFM_ivas_fx( &sfm_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); + crest = IGF_getCrest_ivas( &crest_exp, pPowerSpectrum_fx, pPowerSpectrum_e, add( swb_offset[sfb], shift ), add( swb_offset[sfb + 1], shift ) ); shiftedSFM_fx = BASOP_Util_Divide1616_Scale( sfm, crest, &shiftedSFM_e ); } IF( shiftedSFM_fx ) @@ -1410,7 +1322,7 @@ static void IGF_CalculateStereoEnvelope_fx( tonalToNoise_e = 9; /*stores exponent for tonalToNoise*/ move16(); adap = BASOP_Util_Divide1616_Scale( width, 30, &adap_e ); - tonalToNoise = IGF_getTNR_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, pPowerSpectrum_e, adap_e ); /*Q22*/ + tonalToNoise = IGF_getTNR_ivas_fx( pPowerSpectrum_fx, swb_offset[sfb], swb_offset[sfb + 1], adap, pPowerSpectrum_e, adap_e ); /*Q22*/ IF( EQ_16( BASOP_Util_Cmp_Mant32Exp( tonalToNoise, tonalToNoise_e, L_add( L_shl( 10, sub( 15, adap_e ) ), adap ), add( 16, adap_e ) ), -1 ) ) { // currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise ); @@ -2564,7 +2476,7 @@ void IGFEncApplyMono_ivas_fx( Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX]; - set32_fx( common_pPowerSpectrum_fx, 0, N_MAX + L_MDCT_OVLP_MAX ); + set32_fx( common_pPowerSpectrum_fx, 0, N_MAX); Word16 common_pPowerSpectrum_exp = MIN16B; move16(); @@ -2652,7 +2564,7 @@ void IGFEncApplyStereo_fx( const Word16 igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ @@ -2662,13 +2574,19 @@ void IGFEncApplyStereo_fx( const Word32 element_brate, /* i : element bitrate */ const Word16 mct_on ) { - Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */ + Word32 *pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */ + Word16 *exp_pPowerSpectrumParameter_fx[NB_DIV]; /* If it is NULL it informs a function that specific handling is needed */ Word32 *pPowerSpectrumParameterMsInv_fx[NB_DIV]; Word16 *q_pPowerSpectrumParameterMsInv_fx[NB_DIV]; Word16 coreMsMask[N_MAX]; Word16 sfb, ch, last_core_acelp; STEREO_MDCT_BAND_PARAMETERS *sfbConf; - Word16 exp_pPowerSpectrum[L_FRAME48k]; + Word32 common_pPowerSpectrum_fx[N_MAX]; + + set32_fx( common_pPowerSpectrum_fx, 0, N_MAX ); + + Word16 common_pPowerSpectrum_exp = MIN16B; + move16(); /* assumptions: stereo filling was already done on the flattened spectra * IGF region is always coded M/S, never L/R (to be done in the encoder) @@ -2705,7 +2623,9 @@ void IGFEncApplyStereo_fx( IF( EQ_16( sts[0]->core, TCX_20_CORE ) && !sts[0]->hTcxEnc->fUseTns[frameno] && !sts[1]->hTcxEnc->fUseTns[frameno] ) { pPowerSpectrumParameter_fx[0] = &pPowerSpectrum_fx[0][0]; + exp_pPowerSpectrumParameter_fx[0] = &exp_pPowerSpectrum_fx[0][0]; pPowerSpectrumParameter_fx[1] = &pPowerSpectrum_fx[1][0]; + exp_pPowerSpectrumParameter_fx[1] = &exp_pPowerSpectrum_fx[1][0]; pPowerSpectrumParameterMsInv_fx[0] = pPowerSpectrumMsInv_fx[0][0]; pPowerSpectrumParameterMsInv_fx[1] = pPowerSpectrumMsInv_fx[1][0]; q_pPowerSpectrumParameterMsInv_fx[0] = q_pPowerSpectrumMsInv_fx[0][0]; @@ -2732,17 +2652,37 @@ void IGFEncApplyStereo_fx( IF( EQ_16( sts[ch]->core, TCX_20_CORE ) ) { pPowerSpectrumParameter_fx[ch] = pPowerSpectrum_fx[ch]; + exp_pPowerSpectrumParameter_fx[ch] = exp_pPowerSpectrum_fx[ch]; } ELSE { pPowerSpectrumParameter_fx[ch] = NULL; } - set16_fx( exp_pPowerSpectrum, exp_pPowerSpectrum_fx[ch], L_FRAME48k ); + IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrumParameter_fx[ch], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode ); - IGF_Whitening_ivas_fx( hIGFEnc[ch], pPowerSpectrumParameter_fx[ch], &exp_pPowerSpectrum[0], igfGridIdx, sts[ch]->hTranDet->transientDetector.bIsAttackPresent, last_core_acelp, ( sts[0]->hTcxEnc->fUseTns[frameno] || sts[1]->hTcxEnc->fUseTns[frameno] ), sp_aud_decision0, element_brate, sts[ch]->element_mode ); + IF( pPowerSpectrumParameter_fx[ch] ) + { + Word16 length = N_MAX; + move16(); + if ( mct_on ) + { + length = L_FRAME48k; + move16(); + } + FOR( Word16 i = 0; i < length; i++ ) + { + common_pPowerSpectrum_exp = s_max( common_pPowerSpectrum_exp, exp_pPowerSpectrumParameter_fx[ch][i] ); + } - IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], exp_pPowerSpectrum_fx[ch], igfGridIdx, mct_on ); + FOR( Word16 i = 0; i < length; i++ ) + { + common_pPowerSpectrum_fx[i] = L_shl( pPowerSpectrumParameter_fx[ch][i], sub( exp_pPowerSpectrumParameter_fx[ch][i], common_pPowerSpectrum_exp ) ); + move32(); + } + pPowerSpectrumParameter_fx[ch] = common_pPowerSpectrum_fx; + } + IGF_ErodeSpectrum_ivas_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], pPowerSpectrumParameter_fx[ch], common_pPowerSpectrum_exp, igfGridIdx, mct_on ); } return; } diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index f78ad2025..2befbe8ba 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -781,6 +781,87 @@ Word16 IGF_getCrest( /**< ou return crest; } +Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 start, /**< in: Q0 | start subband index */ + const Word16 stop /**< in: Q0 | stop subband index */ +) +{ + Word16 i; + Word16 x; + Word16 s; + Word32 x_eff32; + Word16 x_max; + Word16 crest; + Word16 tmp; + Word32 tmp32; + + x_eff32 = 0; + move32(); + x_max = 0; + move16(); + crest = 16384 /*.5f Q15*/; + move16(); + *crest_exp = 1; + move16(); + + FOR( i = start; i < stop; i++ ) + { + /*x = max(0, (int)(log(powerSpectrum[i]) * INV_LOG_2));*/ + + /*see IGF_getSFM for more comment */ + x = sub( sub( powerSpectrum_exp[i], norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ + if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ + { + x = 0; + move16(); + } + x = s_max( 0, x ); + x_eff32 = L_mac0( x_eff32, x, x ); /*Q0*/ + x_max = s_max( x_max, x ); /*Q0*/ + } + + /*x_eff /= (stop - start);*/ + x_eff32 = BASOP_Util_Divide3216_Scale( x_eff32, sub( stop, start ), &s ); /*Q-1, s*/ + s = add( s, 32 ); /*make x_eff Q31*/ + + /*trunkate to int*/ + x_eff32 = L_shr( x_eff32, sub( 31, s ) ); + x_eff32 = L_shl( x_eff32, sub( 31, s ) ); + + test(); + IF( x_eff32 > 0 && x_max > 0 ) + { + /*crest = max(1.f, (float)x_max/sqrt(x_eff));*/ + tmp32 = ISqrt32( x_eff32, &s ); /*Q31, s*/ + tmp32 = Mpy_32_16_1( tmp32 /*Q31, s*/, x_max /*Q0*/ ); /*Q16, s*/ + i = norm_l( tmp32 ); + tmp32 = L_shl( tmp32, i ); /*Q31, s-i+15*/ + crest = extract_h( tmp32 ); + *crest_exp = add( sub( s, i ), 15 ); + move16(); + /* limit crest factor to a lower bound of 1, may overflow */ + BASOP_SATURATE_WARNING_OFF_EVS + tmp = shl_sat( -1, sub( 15, *crest_exp ) ); /* build negative threshold */ + tmp = add_sat( crest, tmp ); + BASOP_SATURATE_WARNING_ON_EVS + if ( tmp < 0 ) + { + crest = 1; + move16(); + } + if ( tmp < 0 ) + { + *crest_exp = 15; + move16(); + } + } + + return crest; +} + /************************************************************************* calculates spectral flatness measurment **************************************************************************/ @@ -932,7 +1013,7 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value /* n = sub(n,31); */ /*<- -Qx */ /* n = add(n,*energy_exp); */ /*<- +xExp */ - n = sub( sub( *energy_exp, norm_l( energy[i] ) ), 1 ); /*<-- short form*/ + n = sub( sub( energy_exp[i], norm_l( energy[i] ) ), 1 ); /*<-- short form*/ if ( energy[i] == 0 ) /*special case: energy is zero*/ { @@ -943,7 +1024,7 @@ Word16 IGF_getSFM_ivas_fx( /**< out: Q15| SFM value n = s_max( 0, n ); num = L_add( num, L_deposit_l( n ) ); /*Q0*/ - denom = BASOP_Util_Add_Mant32Exp( energy[i], *energy_exp, denom, denom_exp, &denom_exp ); + denom = BASOP_Util_Add_Mant32Exp( energy[i], energy_exp[i], denom, denom_exp, &denom_exp ); } /* calculate SFM only if signal is present */ diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 615a6f4b6..be15b5048 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -849,16 +849,17 @@ void computeReferencePower_enc_fx( Word16 ref_power_w, /* i : use 0 if hodirac is enabled Q0*/ const Word16 nchan_ana, /* i : number of analysis channels Q0*/ Word16 inp_q, /* i : q of cld buffers */ - Word16 *ref_exp /* i : output q */ -) + Word16 q_reference_power[DIRAC_NO_FB_BANDS_MAX] ) { Word16 brange[2]; Word16 ch_idx, i, j; - Word16 ref_Q = 63; - move16(); + Word16 num_bins, guard_bits, norm; Word64 reference_power_tmp[DIRAC_MAX_NBANDS]; Word64 reference_power_W[DIRAC_MAX_NBANDS]; + + Word16 shift_ref_power = sub( shl( inp_q, 1 ), 31 ); + FOR( i = 0; i < num_freq_bands; i++ ) { brange[0] = band_grouping[i + enc_param_start_band]; /* Q0 */ @@ -871,24 +872,28 @@ void computeReferencePower_enc_fx( move64(); reference_power_tmp[i] = 0; move64(); + + num_bins = sub( brange[1], brange[0] ); + guard_bits = find_guarded_bits_fx( num_bins ); + FOR( j = brange[0]; j < brange[1]; j++ ) { - // 2*inp_q + 1 - reference_power_W[i] = W_add( reference_power_W[i], W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ) ); + reference_power_W[i] = W_add( reference_power_W[i], W_shr( W_mac_32_32( W_mult_32_32( Cldfb_RealBuffer[0][j], Cldfb_RealBuffer[0][j] ), Cldfb_ImagBuffer[0][j], Cldfb_ImagBuffer[0][j] ), guard_bits ) ); // 2*inp_q + 1 - guard_bits move64(); } - reference_power_tmp[i] = W_add( reference_power_tmp[i], reference_power_W[i] ); // 2*inp_q + 1 + reference_power_tmp[i] = W_add( reference_power_tmp[i], reference_power_W[i] ); // 2*inp_q + 1 - guard_bits move64(); FOR( ch_idx = 1; ch_idx < nchan_ana; ch_idx++ ) { /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { - reference_power_tmp[i] = W_add( reference_power_tmp[i], 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_power_tmp[i] = W_add( reference_power_tmp[i], W_shr( 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] ), guard_bits ) ); // 2*inp_q + 1 - guard_bits move64(); } - // 2*inp_q + 1 } + q_reference_power[i] = sub( shift_ref_power, guard_bits ); + move16(); } FOR( i = 0; i < num_freq_bands; i++ ) { @@ -908,20 +913,21 @@ void computeReferencePower_enc_fx( } } } + FOR( i = 0; i < num_freq_bands; i++ ) { - ref_Q = s_min( ref_Q, W_norm( reference_power_tmp[i] ) ); - } - FOR( i = 0; i < num_freq_bands; i++ ) - { - reference_power_tmp[i] = W_shl( reference_power_tmp[i], ref_Q ); // 2*inp_q + 1 + ref_Q - move64(); - reference_power[i] = W_extract_h( reference_power_tmp[i] ); // 2*inp_q + ref_Q - 31 + norm = 63; + move16(); + IF( reference_power_tmp[i] != 0 ) + { + norm = W_norm( reference_power_tmp[i] ); + } + reference_power[i] = W_extract_h( W_shl( reference_power_tmp[i], norm ) ); // 2 * inp_q + 1 - guard_bits + norm - 32 move32(); + q_reference_power[i] = add( q_reference_power[i], norm ); + move16(); } - *ref_exp = sub( Q31, ( sub( add( shl( inp_q, Q1 ), ref_Q ), Q31 ) ) ); - move16(); return; } /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_mcmasa_enc_fx.c b/lib_enc/ivas_mcmasa_enc_fx.c index b89424e76..314424341 100644 --- a/lib_enc/ivas_mcmasa_enc_fx.c +++ b/lib_enc/ivas_mcmasa_enc_fx.c @@ -89,7 +89,7 @@ static void computeIntensityVector_enc_fx( 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], - Word16 *exp_intensity_real, + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ); static void computeVerticalDiffuseness_fx( @@ -947,7 +947,9 @@ void ivas_mcmasa_param_est_enc_fx( Word32 renormalization_factor_coh_fx[MASA_FREQUENCY_BANDS]; // renormalization_factor_coh_e Word16 renormalization_factor_coh_e[MASA_FREQUENCY_BANDS]; Word16 surroundingCoherence_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 numAnalysisChannels, shift; + Word16 numAnalysisChannels; + Word16 q_intensity_real_fx[MASA_FREQUENCY_BANDS], q_intensity_even_real_fx[MASA_FREQUENCY_BANDS], q_reference_power_fx[DIRAC_NO_FB_BANDS_MAX]; + Word16 c_e, ref_e, shift; FOR( i = 0; i < MCMASA_MAX_ANA_CHANS; i++ ) { @@ -1038,7 +1040,7 @@ void ivas_mcmasa_param_est_enc_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, sf; Word16 inp_q = q_inp; move16(); move16(); @@ -1062,7 +1064,6 @@ void ivas_mcmasa_param_est_enc_fx( scale_sig32( Chnl_ImagBuffer_fx[i], DIRAC_NO_FB_BANDS_MAX, sf ); // Q-> inp_q + sf } inp_q = add( inp_q, sf ); - c_e = sub( 31, inp_q ); /* Compute covariance matrix */ FOR( i = 0; i < num_freq_bands; i++ ) @@ -1177,7 +1178,9 @@ void ivas_mcmasa_param_est_enc_fx( Foa_ImagBuffer_fx, 0, num_freq_bands, - intensity_real_fx, &c_e, inp_q ); + intensity_real_fx, + q_intensity_real_fx, + inp_q ); computeDirectionVectors_fixed( intensity_real_fx[0], @@ -1187,8 +1190,9 @@ void ivas_mcmasa_param_est_enc_fx( num_freq_bands, direction_vector_fx[0], direction_vector_fx[1], - direction_vector_fx[2], c_e, - NULL ); + direction_vector_fx[2], + 0, + q_intensity_real_fx ); /* Power and intensity estimation for diffuseness */ computeIntensityVector_enc_fx( @@ -1197,19 +1201,54 @@ void ivas_mcmasa_param_est_enc_fx( FoaEven_ImagBuffer_fx, 0, num_freq_bands, - intensity_even_real_fx, &shift, inp_q ); + intensity_even_real_fx, + q_intensity_even_real_fx, + inp_q ); - Word16 ref_e = 0; - move16(); - computeReferencePower_enc_fx( hMcMasa->band_grouping, - FoaEven_RealBuffer_fx, - FoaEven_ImagBuffer_fx, - reference_power_fx[ts], - 0, - num_freq_bands, - MC_FORMAT, - 0, - FOA_CHANNELS, inp_q, &ref_e ); + computeReferencePower_enc_fx( + hMcMasa->band_grouping, + FoaEven_RealBuffer_fx, + FoaEven_ImagBuffer_fx, + reference_power_fx[ts], + 0, + num_freq_bands, + MC_FORMAT, + 0, + FOA_CHANNELS, + inp_q, + q_reference_power_fx ); + + minimum_fx( q_intensity_real_fx, num_freq_bands, &c_e ); + minimum_fx( q_intensity_even_real_fx, num_freq_bands, &shift ); + minimum_fx( q_reference_power_fx, num_freq_bands, &ref_e ); + + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( c_e, q_intensity_real_fx[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( shift, q_intensity_even_real_fx[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(); + + tmp = sub( ref_e, q_reference_power_fx[i] ); + reference_power_fx[ts][i] = L_shl( reference_power_fx[ts][i], tmp ); + move32(); + } + + c_e = sub( Q31, c_e ); + shift = sub( Q31, shift ); + ref_e = sub( Q31, ref_e ); /* Fill buffers of length "averaging_length" time slots for intensity and energy */ hMcMasa->index_buffer_intensity = add( ( hMcMasa->index_buffer_intensity % hMcMasa->no_col_avg_diff ), 1 ); /* averaging_length = 32 */ @@ -2089,15 +2128,13 @@ static void computeIntensityVector_enc_fx( 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 *exp_intensity_real, + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ) { Word16 i, j; Word32 real, img; - Word16 brange[2], shift = 63; - move16(); - Flag is_zero = 0; - move16(); + Word16 brange[2]; + Word16 shift_intensity_real, num_bins, guard_bits, norm; Word64 intensity_real64[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; @@ -2106,6 +2143,8 @@ static void computeIntensityVector_enc_fx( set64_fx( intensity_real64[i], 0, MASA_FREQUENCY_BANDS ); } + shift_intensity_real = sub( shl( inp_q, 1 ), 32 ); + FOR( i = enc_param_start_band; i < enc_param_start_band + num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; @@ -2113,6 +2152,9 @@ static void computeIntensityVector_enc_fx( brange[1] = band_grouping[i + 1]; move16(); + num_bins = sub( brange[1], brange[0] ); + guard_bits = find_guarded_bits_fx( num_bins ); + intensity_real[0][i] = 0; move32(); intensity_real[1][i] = 0; @@ -2127,45 +2169,37 @@ static void computeIntensityVector_enc_fx( img = Cldfb_ImagBuffer[0][j]; move32(); /* Intensity is XYZ order, audio is WYZX order. */ - intensity_real64[0][i] = W_add( intensity_real64[0][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q= 2* input_q + intensity_real64[0][i] = W_add( intensity_real64[0][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits move32(); - intensity_real64[1][i] = W_add( intensity_real64[1][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q= 2* input_q + intensity_real64[1][i] = W_add( intensity_real64[1][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits move32(); - intensity_real64[2][i] = W_add( intensity_real64[2][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q= 2* input_q + intensity_real64[2][i] = W_add( intensity_real64[2][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits move32(); } - } - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - is_zero = is_zero_arr64( intensity_real64[i], MASA_FREQUENCY_BANDS ); - IF( is_zero == 0 ) + norm = 63; + move16(); + IF( intensity_real64[0][i] != 0 ) { - BREAK; + norm = s_min( norm, W_norm( intensity_real64[0][i] ) ); } - } - IF( is_zero == 0 ) - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + IF( intensity_real64[1][i] != 0 ) { - shift = s_min( shift, W_norm_arr( intensity_real64[i], MASA_FREQUENCY_BANDS ) ); + norm = s_min( norm, W_norm( intensity_real64[1][i] ) ); } - - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + IF( intensity_real64[2][i] != 0 ) { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - intensity_real[i][j] = W_extract_h( W_shl( intensity_real64[i][j], shift ) ); - move32(); - } + norm = s_min( norm, W_norm( intensity_real64[2][i] ) ); } - *exp_intensity_real = sub( 31, sub( add( shift, shl( inp_q, 1 ) ), 32 ) ); - move16(); - } - ELSE - { - *exp_intensity_real = 0; + intensity_real[0][i] = W_extract_h( W_shl( intensity_real64[0][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/ + move32(); + intensity_real[1][i] = W_extract_h( W_shl( intensity_real64[1][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/ + move32(); + intensity_real[2][i] = W_extract_h( W_shl( intensity_real64[2][i], norm ) ); /*2 * inp_q - guard_bits + norm - 32*/ + move32(); + + q_intensity_real[i] = add( shift_intensity_real, sub( norm, guard_bits ) ); move16(); } diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 8ff17ae01..8acbd42fc 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -996,6 +996,7 @@ void mctStereoIGF_enc_fx( Word32 *p_inv_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *p_orig_spectrum_fx[CPE_CHANNELS][NB_DIV]; Word32 *p_powerSpec_fx[NB_DIV]; + Word16 *p_exp_powerSpec_fx[NB_DIV]; Word16 b, nSubframes, L_subframeTCX; Word16 p_ch[2], n, ch, ch1, ch2; @@ -1004,7 +1005,7 @@ void mctStereoIGF_enc_fx( Encoder_State *st; Word16 singleChEle[MCT_MAX_CHANNELS]; Word16 q_spectrum; - Word16 exp_powerSpec[MCT_MAX_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; + Word16 exp_powerSpec[MCT_MAX_CHANNELS][L_FRAME48k]; L_subframeTCX = 0; /* to avoid compilation warning */ move16(); @@ -1042,7 +1043,9 @@ void mctStereoIGF_enc_fx( } p_powerSpec_fx[0] = powerSpec_fx[ch1]; // q_powerSpec + p_exp_powerSpec_fx[0] = exp_powerSpec[ch1]; // q_powerSpec p_powerSpec_fx[1] = powerSpec_fx[ch2]; + p_exp_powerSpec_fx[1] = exp_powerSpec[ch2]; /* Band-wise M/S for MDST */ nSubframes = NB_DIV; @@ -1072,17 +1075,16 @@ void mctStereoIGF_enc_fx( IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[n] ) || EQ_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[n], SMDCT_BW_MS ) ) { - Word16 exp_powerSpec_fx[CPE_CHANNELS], exp_inv_spectrum_fx[CPE_CHANNELS]; + Word16 exp_inv_spectrum_fx[CPE_CHANNELS]; FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { - exp_powerSpec_fx[ch] = sub( Q31, q_pS_ch[ch] ); exp_inv_spectrum_fx[ch] = p_st[ch]->hTcxEnc->spectrum_e[n]; move16(); - move16(); } - - ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, exp_powerSpec_fx, + set16_fx( exp_powerSpec[ch1], sub( Q31, q_pS_ch[0] ), L_FRAME48k ); + set16_fx( exp_powerSpec[ch2], sub( Q31, q_pS_ch[1] ), L_FRAME48k ); + ProcessStereoIGF_fx( hMCT->hBlockData[b]->hStereoMdct, p_st, hMCT->hBlockData[b]->mask, p_orig_spectrum_fx, q_origSpec, q_origSpec, p_powerSpec_fx, p_exp_powerSpec_fx, p_powerSpecMsInv_fx, q_p_powerSpecMsInv_fx, p_inv_spectrum_fx, exp_inv_spectrum_fx, n, sp_aud_decision0[ch1], p_st[0]->total_brate, 1 ); } ELSE @@ -1100,7 +1102,7 @@ void mctStereoIGF_enc_fx( q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); - set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), N_MAX + L_MDCT_OVLP_MAX ); + set16_fx( exp_powerSpec[p_ch[ch]], sub( Q31, q_powerSpec[p_ch[ch]] ), L_FRAME48k ); ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[p_ch[ch]][n], q_origSpec, &powerSpec_fx[p_ch[ch]][n * L_subframeTCX], &exp_powerSpec[p_ch[ch]][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); @@ -1141,7 +1143,7 @@ void mctStereoIGF_enc_fx( { q_spectrum = sub( 31, st->hTcxEnc->spectrum_e[n] ); - set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), N_MAX + L_MDCT_OVLP_MAX ); + set16_fx( exp_powerSpec[ch], sub( Q31, q_powerSpec[ch] ), L_FRAME48k ); ProcessIGF_ivas_fx( st, L_FRAME48k, st->hTcxEnc->spectrum_fx[n], &q_spectrum, orig_spectrum_fx[ch][n], q_origSpec, &powerSpec_fx[ch][n * L_subframeTCX], &exp_powerSpec[ch][n * L_subframeTCX], st->core == TCX_20_CORE, n, sp_aud_decision0[ch], 0 ); st->hTcxEnc->spectrum_e[n] = sub( 31, q_spectrum ); diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 58ba680d6..0b0aa90c5 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -82,14 +82,16 @@ static void ivas_omasa_dmx_fx( Word16 prev_gains[][MASA_MAX_TRANSPORT_CHANNELS], /*o:q15*/ const Word16 interpolator[L_FRAME48k] /*i:q15*/ ); + void computeIntensityVector_enc_fx( const Word16 *band_grouping, Word32 Cldfb_RealBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ const Word16 num_frequency_bands, Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ - Word16 *exp_intensity_real, + 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 ); /*--------------------------------------------------------------------------* * ivas_omasa_enc_open() @@ -1037,6 +1039,7 @@ static void ivas_omasa_param_est_enc_fx( Word16 q; /*stores q for cldfb buffers*/ Word32 temp; Word16 temp_e; + Word16 q_intensity_real_fx[MASA_FREQUENCY_BANDS], q_reference_power_fx[CLDFB_NO_CHANNELS_MAX]; ref_exp = 0; norm_buff = MAX16B; @@ -1188,24 +1191,34 @@ static void ivas_omasa_param_est_enc_fx( v_multc_acc_32_32( Chnl_ImagBuffer_fx[i], hOMasa->chnlToFoaMtx_fx[3][i], Foa_ImagBuffer_fx[3], num_freq_bins ); /*q*/ } /* Direction estimation */ - norm_buff = L_norm_arr( &Foa_RealBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ); - norm_buff = s_min( norm_buff, L_norm_arr( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX ) ); - guard_bits = find_guarded_bits_fx( max_band_grouping_diff ); - guard_bits = add( guard_bits, sub( 1, norm_buff ) ); + computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, q_intensity_real_fx, q ); - scale_sig32( &Foa_RealBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX, negate( guard_bits ) ); - scale_sig32( &Foa_ImagBuffer_fx[0][0], FOA_CHANNELS * CLDFB_NO_CHANNELS_MAX, negate( guard_bits ) ); + 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, q_intensity_real_fx ); - q = sub( q, guard_bits ); + /* Power estimation for diffuseness */ - computeIntensityVector_enc_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, num_freq_bands, intensity_real_fx, &intensity_real_e, q ); + computeReferencePower_omasa_ivas_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], 0, num_freq_bands, q, q_reference_power_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], intensity_real_e, - NULL ); + minimum_fx( q_intensity_real_fx, num_freq_bands, &intensity_real_e ); + minimum_fx( q_reference_power_fx, num_freq_bands, &ref_exp ); - /* Power estimation for diffuseness */ + Word16 tmp; + FOR( i = 0; i < num_freq_bands; i++ ) + { + tmp = sub( intensity_real_e, q_intensity_real_fx[i] ); + intensity_real_fx[0][i] = L_shl( intensity_real_fx[0][i], tmp ); // intensity_real_e + move32(); + intensity_real_fx[1][i] = L_shl( intensity_real_fx[1][i], tmp ); // intensity_real_e + move32(); + intensity_real_fx[2][i] = L_shl( intensity_real_fx[2][i], tmp ); // intensity_real_e + move32(); + + tmp = sub( ref_exp, q_reference_power_fx[i] ); + reference_power_fx[ts][i] = L_shl( reference_power_fx[ts][i], tmp ); // ref_exp + } - computeReferencePower_omasa_ivas_fx( hOMasa->band_grouping, Foa_RealBuffer_fx, Foa_ImagBuffer_fx, reference_power_fx[ts], 0, num_freq_bands, q, &ref_exp ); + intensity_real_e = sub( Q31, intensity_real_e ); + ref_exp = sub( Q31, ref_exp ); /* 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 */ @@ -1489,15 +1502,13 @@ void computeIntensityVector_enc_fx( Word32 Cldfb_ImagBuffer[FOA_CHANNELS][CLDFB_NO_CHANNELS_MAX], /*inp_q*/ const Word16 num_frequency_bands, Word32 intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS], /*exp: exp_intensity_real*/ - Word16 *exp_intensity_real, + Word16 q_intensity_real[MASA_FREQUENCY_BANDS], Word16 inp_q ) { Word16 i, j; Word32 real, img; - Word16 brange[2], shift = 63; - move16(); - Flag is_zero = 0; - move16(); + Word16 brange[2]; + Word16 shift_intensity_real, num_bins, guard_bits, norm; Word64 intensity_real64[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS]; @@ -1506,6 +1517,8 @@ void computeIntensityVector_enc_fx( set64_fx( intensity_real64[i], 0, MASA_FREQUENCY_BANDS ); } + shift_intensity_real = sub( shl( inp_q, 1 ), 32 ); + FOR( i = 0; i < num_frequency_bands; i++ ) { brange[0] = band_grouping[i]; @@ -1513,12 +1526,8 @@ void computeIntensityVector_enc_fx( brange[1] = band_grouping[i + 1]; move16(); - intensity_real[0][i] = 0; - move32(); - intensity_real[1][i] = 0; - move32(); - intensity_real[2][i] = 0; - move32(); + num_bins = sub( brange[1], brange[0] ); + guard_bits = find_guarded_bits_fx( num_bins ); FOR( j = brange[0]; j < brange[1]; j++ ) { @@ -1527,45 +1536,34 @@ void computeIntensityVector_enc_fx( img = Cldfb_ImagBuffer[0][j]; move32(); /* Intensity is XYZ order, audio is WYZX order. */ - intensity_real64[0][i] = W_add( intensity_real64[0][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ) ); // output Q= 2* input_q + intensity_real64[0][i] = W_add( intensity_real64[0][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[3][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[3][j], img ) ), guard_bits ) ); // output Q= 2* input_q -guard_bits move64(); - intensity_real64[1][i] = W_add( intensity_real64[1][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ) ); // output Q= 2* input_q + intensity_real64[1][i] = W_add( intensity_real64[1][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[1][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[1][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits move64(); - intensity_real64[2][i] = W_add( intensity_real64[2][i], W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ) ); // output Q= 2* input_q + intensity_real64[2][i] = W_add( intensity_real64[2][i], W_shr( W_add( W_mult0_32_32( Cldfb_RealBuffer[2][j], real ), W_mult0_32_32( Cldfb_ImagBuffer[2][j], img ) ), guard_bits ) ); // output Q= 2* input_q - guard_bits move64(); } - } - - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) - { - is_zero = is_zero_arr64( intensity_real64[i], MASA_FREQUENCY_BANDS ); - IF( is_zero == 0 ) + norm = 63; + move16(); + IF( intensity_real64[0][i] != 0 ) { - BREAK; + norm = s_min( norm, W_norm( intensity_real64[0][i] ) ); } - } - IF( is_zero == 0 ) - { - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + IF( intensity_real64[1][i] != 0 ) { - shift = s_min( shift, W_norm_arr( intensity_real64[i], MASA_FREQUENCY_BANDS ) ); + norm = s_min( norm, W_norm( intensity_real64[1][i] ) ); } - - FOR( i = 0; i < DIRAC_NUM_DIMS; i++ ) + IF( intensity_real64[2][i] != 0 ) { - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - intensity_real[i][j] = W_extract_h( W_shl( intensity_real64[i][j], shift ) ); - move32(); - } + norm = s_min( norm, W_norm( intensity_real64[2][i] ) ); } - - *exp_intensity_real = sub( 31, sub( add( shift, shl( inp_q, 1 ) ), 32 ) ); - move16(); - } - ELSE - { - *exp_intensity_real = 0; + intensity_real[0][i] = W_extract_h( W_shl( intensity_real64[0][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32 + move32(); + intensity_real[1][i] = W_extract_h( W_shl( intensity_real64[1][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32 + move32(); + intensity_real[2][i] = W_extract_h( W_shl( intensity_real64[2][i], norm ) ); // output Q = 2 * inp_q - guard_bits + norm - 32 + move32(); + q_intensity_real[i] = add( shift_intensity_real, sub( norm, guard_bits ) ); move16(); } @@ -1580,13 +1578,14 @@ static void computeReferencePower_omasa_ivas_fx( const Word16 enc_param_start_band, /* i : first band to process */ const Word16 num_freq_bands, /* i : Number of frequency bands */ Word16 q_Cldfb, - Word16 *ref_exp ) + Word16 q_reference_power[CLDFB_NO_CHANNELS_MAX] ) { Word16 brange[2]; Word16 ch_idx, i, j; Word64 reference_power_tmp[CLDFB_NO_CHANNELS_MAX]; - Word16 ref_Q = 63; - move16(); + Word16 shift_ref_power, num_bins, guard_bits, norm; + + shift_ref_power = sub( shl( q_Cldfb, 1 ), 30 ); FOR( i = 0; i < num_freq_bands; i++ ) { @@ -1599,34 +1598,29 @@ static void computeReferencePower_omasa_ivas_fx( reference_power_tmp[i] = 0; move64(); + num_bins = sub( brange[1], brange[0] ); + guard_bits = find_guarded_bits_fx( num_bins ); + FOR( ch_idx = 0; ch_idx < FOA_CHANNELS; ch_idx++ ) { /* abs()^2 */ FOR( j = brange[0]; j < brange[1]; j++ ) { - reference_power_tmp[i] = W_add( reference_power_tmp[i], 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] ) ); // Q13 (Q6+Q6+1) + reference_power_tmp[i] = W_add( reference_power_tmp[i], W_shr( 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] ), guard_bits ) ); // output Q = 2 * q_cldfb + 1 - guard_bits move64(); } } - } - // v_multc( reference_power, 0.5f, reference_power, num_freq_bands ); - FOR( i = 0; i < num_freq_bands; i++ ) - { - reference_power_tmp[i] = W_shr( reference_power_tmp[i], 1 ); - move64(); - ref_Q = s_min( ref_Q, W_norm( reference_power_tmp[i] ) ); - } - - FOR( i = 0; i < num_freq_bands; i++ ) - { - reference_power_tmp[i] = W_shl( reference_power_tmp[i], ref_Q ); // Q13 + ref_Q - move64(); - reference_power[i] = W_extract_h( reference_power_tmp[i] ); // Q13 + ref_Q -32 + norm = 63; + move16(); + IF( reference_power_tmp[i] != 0 ) + { + norm = W_norm( reference_power_tmp[i] ); + } + reference_power[i] = W_extract_h( W_shl( reference_power_tmp[i], norm ) ); // output Q = 2 * q_cldfb + 2 - guard_bits + norm - 32 move32(); + q_reference_power[i] = add( shift_ref_power, sub( norm, guard_bits ) ); + move16(); } - // ref_exp = 31- ((13+ref_Q) -32) - *ref_exp = sub( 31, ( sub( add( ref_Q, 2 * q_Cldfb + 1 ), 32 ) ) ); - move16(); return; } diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 2a71fc34d..6bb6af1b3 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -577,9 +577,11 @@ void stereo_mdct_core_enc_fx( { IGF_ENC_INSTANCE_HANDLE hIGFEnc[CPE_CHANNELS]; Word32 powerSpec_fx[CPE_CHANNELS][N_MAX], *p_powerSpec_fx[CPE_CHANNELS]; - Word16 exp_powSpec[CPE_CHANNELS]; + Word16 exp_powSpec[CPE_CHANNELS][N_MAX], *p_exp_powSpec[CPE_CHANNELS]; p_powerSpec_fx[0] = powerSpec_fx[0]; + p_exp_powSpec[0] = exp_powSpec[0]; p_powerSpec_fx[1] = powerSpec_fx[1]; + p_exp_powSpec[1] = exp_powSpec[1]; { /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -598,24 +600,19 @@ void stereo_mdct_core_enc_fx( { length = add( length, shr( length, 2 ) ); } - exp = sub( exp_powerSpec64[ch][0], W_norm_arr( powerSpec64[ch], length ) ); - IF( EQ_16( nsub, 2 ) ) - { - exp = s_max( exp, sub( exp_powerSpec64[ch][1], W_norm_arr( powerSpec64[ch] + length, length ) ) ); - } FOR( n1 = 0; n1 < nsub; n1++ ) { - shift1 = sub( sub( exp_powerSpec64[ch][n1], exp ), 32 ); FOR( i = 0; i < length; i++ ) { /* This doesn't result in saturation */ - powerSpec_fx[ch][i + n1 * length] = W_shl_sat_l( powerSpec64[ch][i + n1 * length], shift1 ); // exp: exp + shift1 = W_norm( powerSpec64[ch][i + n1 * length] ); + powerSpec_fx[ch][i + n1 * length] = W_extract_h( W_shl( powerSpec64[ch][i + n1 * length], shift1 ) ); // exp: exp move32(); + exp_powSpec[ch][i + n1 * length] = sub( exp_powerSpec64[ch][n1], shift1 ); } } set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); - exp_powSpec[ch] = exp; // exp: exp - move16(); + set16_fx( exp_powSpec[ch] + length, 0, sub( N_MAX, length ) ); } } @@ -627,13 +624,13 @@ void stereo_mdct_core_enc_fx( move16(); ProcessStereoIGF_fx( hStereoMdct, sts, ms_mask, orig_spectrum_fx, sub( Q31, p_orig_spectrum_e[0] ), sub( Q31, p_orig_spectrum_e[1] ), - p_powerSpec_fx, exp_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv_fx, inv_spectrum_fx, exp_inv_spectrum, + p_powerSpec_fx, p_exp_powSpec, powerSpecMsInv_fx, q_powerSpecMsInv_fx, inv_spectrum_fx, exp_inv_spectrum, n, hCPE->hCoreCoder[0]->sp_aud_decision0, hCPE->hCoreCoder[0]->element_brate, 0 ); } ELSE { Word32 powerSpec_fx[CPE_CHANNELS][N_MAX]; // each value has a different exponent - Word16 exp_powerSpec[CPE_CHANNELS][N_MAX + L_MDCT_OVLP_MAX]; + Word16 exp_powerSpec[CPE_CHANNELS][N_MAX]; { /* Copy powerSpec values from 64 bit buffer to 32 bit buffer */ FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) @@ -665,7 +662,7 @@ void stereo_mdct_core_enc_fx( } } set32_fx( powerSpec_fx[ch] + length, 0, sub( N_MAX, length ) ); - set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX + L_MDCT_OVLP_MAX, length ) ); + set16_fx( exp_powerSpec[ch] + length, 0, sub( N_MAX, length ) ); } } FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index c433dcb2c..75f318151 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3041,6 +3041,13 @@ Word16 IGF_getCrest( /**< out: Q15| crest factor const Word16 start, /**< in: Q0 | start subband index */ const Word16 stop /**< in: Q0 | stop subband index */ ); +Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 start, /**< in: Q0 | start subband index */ + const Word16 stop /**< in: Q0 | stop subband index */ +); Word16 IGF_getSFM( /**< out: Q15| SFM value */ Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ const Word32 *energy, /**< in: Q31| energies */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 680a69fa5..f8f6f5fac 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -4030,7 +4030,7 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ -- GitLab From f4b38f0289b69ce443a3cd4c572520b757da1470 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 11 Jun 2025 10:26:51 +0530 Subject: [PATCH 236/692] Clang formatting changes --- lib_com/prot_fx.h | 4 ++-- lib_com/stat_com.h | 12 ++++++------ lib_enc/igf_enc.c | 2 +- lib_enc/igf_enc_fx.c | 14 +++++++------- lib_enc/ivas_mct_enc_mct_fx.c | 2 +- lib_enc/prot_fx_enc.h | 12 ++++++------ lib_enc/tcx_utils_enc_fx.c | 2 +- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 38a6077e8..ec2aec450 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -10502,7 +10502,7 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ @@ -10519,7 +10519,7 @@ void IGFEncApplyStereo_fx( const Word16 igfGridIdx, /* i : IGF grid index */ Encoder_State *sts[CPE_CHANNELS], /* i : Encoder state */ Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 712c1d702..e5081d2be 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -558,12 +558,12 @@ typedef struct ParamsBitMap struct TnsParameters { /* Parameters for each TNS filter */ - Word16 startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */ - Word16 nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */ - Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ - Word32 minPredictionGain_32; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ - Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */ - Word16 minEnergyChange; /* Minimum energy change required to turn on the TNS filter. Exponent = 8 */ + Word16 startLineFrequency; /* Starting lower frequency of the TNS filter [20..16000] */ + Word16 nSubdivisions; /* Number of spectrum subdivisions in which the filter operates [1..8) */ + Word16 minPredictionGain; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ + Word32 minPredictionGain_32; /* Minimum prediction gain required to turn on the TNS filter. Exponent = PRED_GAIN_E */ + Word16 minAvgSqrCoef; /* Minimum average square of coefficients required to turn on the TNS filter. Exponent = 0 */ + Word16 minEnergyChange; /* Minimum energy change required to turn on the TNS filter. Exponent = 8 */ }; /**********************************************/ diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index db77144df..70b5166df 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -2476,7 +2476,7 @@ void IGFEncApplyMono_ivas_fx( Word32 common_pPowerSpectrum_fx[N_MAX + L_MDCT_OVLP_MAX]; - set32_fx( common_pPowerSpectrum_fx, 0, N_MAX); + set32_fx( common_pPowerSpectrum_fx, 0, N_MAX ); Word16 common_pPowerSpectrum_exp = MIN16B; move16(); diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 2befbe8ba..a7b5eabb3 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -781,12 +781,12 @@ Word16 IGF_getCrest( /**< ou return crest; } -Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ +Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 start, /**< in: Q0 | start subband index */ + const Word16 stop /**< in: Q0 | stop subband index */ ) { Word16 i; @@ -813,7 +813,7 @@ Word16 IGF_getCrest_ivas( /* /*see IGF_getSFM for more comment */ x = sub( sub( powerSpectrum_exp[i], norm_l( powerSpectrum[i] ) ), 1 ); /*Q0*/ - if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ + if ( powerSpectrum[i] == 0 ) /*special case: energy is zero*/ { x = 0; move16(); diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 8acbd42fc..f28adafa4 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -1042,7 +1042,7 @@ void mctStereoIGF_enc_fx( sts[ch2]->hBstr->ind_list = sts[0]->hBstr->ind_list + sts[0]->hBstr->nb_ind_tot; } - p_powerSpec_fx[0] = powerSpec_fx[ch1]; // q_powerSpec + p_powerSpec_fx[0] = powerSpec_fx[ch1]; // q_powerSpec p_exp_powerSpec_fx[0] = exp_powerSpec[ch1]; // q_powerSpec p_powerSpec_fx[1] = powerSpec_fx[ch2]; p_exp_powerSpec_fx[1] = exp_powerSpec[ch2]; diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 75f318151..6ef6991d4 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -3041,12 +3041,12 @@ Word16 IGF_getCrest( /**< out: Q15| crest factor const Word16 start, /**< in: Q0 | start subband index */ const Word16 stop /**< in: Q0 | stop subband index */ ); -Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ - Word16 *crest_exp, /**< out: | exponent of crest factor */ - const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ - const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ - const Word16 start, /**< in: Q0 | start subband index */ - const Word16 stop /**< in: Q0 | stop subband index */ +Word16 IGF_getCrest_ivas( /**< out: Q15| crest factor */ + Word16 *crest_exp, /**< out: | exponent of crest factor */ + const Word32 *powerSpectrum, /**< in: Q31 | power spectrum */ + const Word16 *powerSpectrum_exp, /**< in: | exponent of power spectrum */ + const Word16 start, /**< in: Q0 | start subband index */ + const Word16 stop /**< in: Q0 | stop subband index */ ); Word16 IGF_getSFM( /**< out: Q15| SFM value */ Word16 *SFM_exp, /**< out: | exponent of SFM Factor */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index f8f6f5fac..e1b067ac3 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -4030,7 +4030,7 @@ void ProcessStereoIGF_fx( Word16 q_pITFMDCTSpectrum_1, Word16 q_pITFMDCTSpectrum_2, Word32 *pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: MDCT^2 + MDST^2 spectrum, or estimate */ - Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ + Word16 *exp_pPowerSpectrum_fx[CPE_CHANNELS], /* i/o: exp of pPowerSpectrum_fx */ Word32 *pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i : inverse power spectrum */ Word16 *q_pPowerSpectrumMsInv_fx[CPE_CHANNELS][NB_DIV], /* i/o: Q of pPowerSpectrumMsInv_fx */ Word32 *inv_spectrum_fx[CPE_CHANNELS][NB_DIV], /* i : inverse spectrum */ -- GitLab From 2a9e6640c3f51659821755c412ba4b3b785edb90 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 11 Jun 2025 11:07:18 +0200 Subject: [PATCH 237/692] bug fix : segfault --- lib_dec/ivas_init_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 44e20c645..ad0f7a65c 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2343,7 +2343,7 @@ ivas_error ivas_init_decoder_fx( #ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, -- GitLab From 4126009526a8add96270b4d392e57f2d7d99c43f Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Wed, 11 Jun 2025 13:38:41 +0300 Subject: [PATCH 238/692] 1716_basop_port --- lib_com/options.h | 2 +- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 8 ++++---- lib_rend/lib_rend_fx.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 98e076d36..0cd498a89 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -137,7 +137,7 @@ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ -#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin */ +/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 5f8d1512b..22a7d4993 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1151,7 +1151,7 @@ ivas_error ivas_dirac_dec_config_fx( #endif { #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) #endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index c1c0bf626..d0a5e47d1 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -337,9 +337,9 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - if (NE_32((error = ivas_binaural_reverb_init(&hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &(st_ivas->hRenderConfig->roomAcoustics), output_Fs, (*phHrtfParambin)->parametricReverberationTimes, (*phHrtfParambin)->parametricReverberationEneCorrections)), IVAS_ERR_OK)) + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else - if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK ) #endif #else /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ @@ -5830,8 +5830,8 @@ static void hrtfShGetHrtf_fx( { Word16 k; #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - Word32( *hrtfShCoeffsReInt_fx )[16][60]; - Word32( *hrtfShCoeffsImInt_fx )[16][60]; + Word16( *hrtfShCoeffsReInt_fx )[16][60]; + Word16( *hrtfShCoeffsImInt_fx )[16][60]; hrtfShCoeffsReInt_fx = hHrtfParambin->hrtfShCoeffsRe_fx; hrtfShCoeffsImInt_fx = hHrtfParambin->hrtfShCoeffsIm_fx; #endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0857a4465..c7bd7b2d6 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9257,7 +9257,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, #endif hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } @@ -10290,7 +10290,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - if (NE_32((error = ivas_binaural_reverb_init(&hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &(hRendCfg->roomAcoustics), output_Fs, (*phHrtfParambin)->parametricReverberationTimes, (*phHrtfParambin)->parametricReverberationEneCorrections)), IVAS_ERR_OK)) + if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes_fx, hHrtfParambin->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #endif -- GitLab From eb2cb6cfd72389bd3d787c63b8d13b0e453241d8 Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 11 Jun 2025 12:43:35 +0200 Subject: [PATCH 239/692] fix missing pop_wmops() --- lib_rend/lib_rend_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e92922964..b46d13610 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5715,6 +5715,9 @@ static ivas_error renderLfeToBinaural_fx( ELSE { /* no LFE to render */ +#ifdef FIX_1740_MISING_POP_WMOPS + pop_wmops(); +#endif return IVAS_ERR_OK; } -- GitLab From 2b15315ae96d20deed96d96c6e696f08a6758a73 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Wed, 11 Jun 2025 13:44:58 +0300 Subject: [PATCH 240/692] fixc clang --- lib_dec/ivas_dirac_dec_fx.c | 2 +- lib_rend/lib_rend_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 22a7d4993..e843a82f9 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1151,7 +1151,7 @@ ivas_error ivas_dirac_dec_config_fx( #endif { #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) #endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c7bd7b2d6..562b35a6a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9257,7 +9257,7 @@ static ivas_error getSamplesInternal( hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, #endif hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, - &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) + &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { return error; } -- GitLab From 131aedf4654587a27ab2e4ca651a62c150ebf55b Mon Sep 17 00:00:00 2001 From: malenov Date: Wed, 11 Jun 2025 12:49:50 +0200 Subject: [PATCH 241/692] fix missing pop_wmops() --- lib_rend/lib_rend_fx.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index e92922964..b46d13610 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5715,6 +5715,9 @@ static ivas_error renderLfeToBinaural_fx( ELSE { /* no LFE to render */ +#ifdef FIX_1740_MISING_POP_WMOPS + pop_wmops(); +#endif return IVAS_ERR_OK; } -- GitLab From 15838fc796dbe1c8f1bbfca869655d8ad5f9c122 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 11 Jun 2025 11:42:00 +0200 Subject: [PATCH 242/692] [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 3dd6097684d3e9c96c3a05290b1fb0ab988e4f3d Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:03:51 +0200 Subject: [PATCH 243/692] nullptr bug fixes --- lib_dec/ivas_init_dec_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index ad0f7a65c..3f32d96a1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2352,9 +2352,9 @@ ivas_error ivas_init_decoder_fx( #endif #else #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), + IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), -- GitLab From 569915ed0eb988fcbdecd3c89fcf44d578ec435d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 11 Jun 2025 12:34:45 +0200 Subject: [PATCH 244/692] [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 fa716c892..8bddc7383 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -153,7 +153,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; #ifdef SPLIT_REND_WITH_HEAD_ROT char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -231,16 +231,16 @@ 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", #ifdef SPLIT_REND_WITH_HEAD_ROT - .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode", + .description = "Space-separated list of path to metadata files for ISM/MASA/OMASA/\nOSBA/BINAURAL_SPLIT_PCM inputs. \nFor OMASA, ISM files must be specified first.", #else - .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.", #endif }, { @@ -259,13 +259,13 @@ 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)", }, #ifdef SPLIT_REND_WITH_HEAD_ROT { @@ -285,42 +285,44 @@ static const CmdLnParser_Option cliOptions[] = { .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_compensation", @@ -331,7 +333,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, @@ -355,13 +357,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, @@ -373,19 +375,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.", }, }; @@ -400,6 +402,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 ); @@ -649,25 +653,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 ) @@ -690,6 +676,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; } @@ -2392,16 +2398,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 ); @@ -2413,6 +2414,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: @@ -2862,7 +2874,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 ); @@ -3703,6 +3715,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 ) @@ -3919,6 +3966,8 @@ static void printSupportedAudioConfigs( void ) "HOA2", "HOA3", "ISMx (input only)", + "ISMxSBAy (OSBA, input only)", + "ISMxMASAy (OMASA, input only)", "MASAx", "BINAURAL (output only)", #ifdef SPLIT_REND_WITH_HEAD_ROT @@ -3927,6 +3976,7 @@ static void printSupportedAudioConfigs( void ) #endif "BINAURAL_ROOM_IR (output only)", "BINAURAL_ROOM_REVERB (output only)", + "META (Scene description, input only)", }; fprintf( stdout, "Supported audio formats:\n" ); @@ -3934,6 +3984,7 @@ static void printSupportedAudioConfigs( void ) { fprintf( stdout, "%s\n", supportedFormats[i] ); } + fprintf( stdout, "\n" ); return; } -- GitLab From 434325618a140a9cb223199a3f63e6bfd09f484a Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 11 Jun 2025 14:15:33 +0200 Subject: [PATCH 245/692] Add main to scripts repo to be able to retrieve new format HRTFs --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa08ae0f8..bbebd523e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -272,6 +272,7 @@ stages: - cd $SCRIPTS_DIR - sed -i '/fetch/d' .git/config # Remove all fetch lines to clean out dead links - git remote set-branches --add origin $BASOP_CI_BRANCH_PC_REPO # Add currently used branch + - git remote set-branches --add origin main # Add main to be able to load new format HRTFs - git fetch - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO -- GitLab From d1c76ac6a5ca1dea0910e55ca91010800fe789c0 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:36:02 +0200 Subject: [PATCH 246/692] Memeory allocation and fixed point scaling bug fixes for reverb parameters in ivas_reverb_fx.c --- lib_rend/ivas_reverb_fx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 74c2a0c0a..c5c74ad9f 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1558,10 +1558,28 @@ ivas_error ivas_reverb_open_fx( test(); #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES + /* set up reverb acoustic data on the basis of HRTF data and renderer config */ + Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 2 ); + Word16 *pRt60_e = (Word16 *) malloc( sizeof( Word16 ) * nr_fc_fft_filter ); + Word16 *pDsr_e = (Word16 *) malloc( sizeof( Word16 ) * nr_fc_fft_filter ); + + params.pRt60_e = pRt60_e; + params.pDsr_e = pDsr_e; + set_reverb_acoustic_data_fx( ¶ms, &hRenderConfig->roomAcoustics, nr_fc_input, nr_fc_fft_filter ); + Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); + FOR( i = 0; i < nr_fc_fft_filter; i++ ) + { + params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); + move32(); + params.pDsr_fx[i] = L_abs( params.pDsr_fx[i] ); + move32(); + } + params.pHrtf_avg_pwr_response_l_const_fx = hHrtfStatistics->average_energy_l; params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence; + #else IF( hHrtf == NULL && lr_energy_and_iac_fx != NULL ) { -- GitLab From 0943b9bd324d47a6e189a655f6921c5a29e83b98 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 12 Jun 2025 09:31:39 +0300 Subject: [PATCH 247/692] fix comment --- 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 0cd498a89..cf71f5da6 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -137,7 +137,7 @@ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ -/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin */ +/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ /* #################### End BASOP porting switches ############################ */ -- GitLab From 5ef310e6bd42d9ee925174f08ac1c90d500ba2f7 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 12 Jun 2025 08:37:35 +0200 Subject: [PATCH 248/692] Update IVAS_CODEC_CI_REF to get HRTF model file restoration update --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df6069de2..59d11a2e9 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 44cb5638949b874ce0f5c3bf4359f9db860d88bc + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF 41186736915f5c0a857ac92e8ab438c434e5247d include: - local: .gitlab-ci/variables.yml -- GitLab From 5aa131a4aa7408549efd2bc90a05962faa9c0e15 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 12 Jun 2025 08:54:19 +0200 Subject: [PATCH 249/692] Fix for HRTF file loading in CI --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d630d11ba..e35d0e290 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,6 +273,7 @@ stages: - sed -i '/fetch/d' .git/config # Remove all fetch lines to clean out dead links - git remote set-branches --add origin $BASOP_CI_BRANCH_PC_REPO # Add currently used branch - git fetch + - git restore --staged . # Needed if HRTF model files were updated. - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO - git pull origin $BASOP_CI_BRANCH_PC_REPO -- GitLab From cde20f9aded676ccd13799996d59e125c3dfe1d4 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 12 Jun 2025 10:59:38 +0200 Subject: [PATCH 250/692] 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 251/692] 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 30acb8787ed053fdb43503b773896b91ee343f74 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 15:18:30 +0530 Subject: [PATCH 252/692] Fix for 3GPP issue 950: High MLD for ParamMC 5.1 at 48/64/80kbps or 7.1+4 at 128kbps Link #950, #1023, #1024 --- lib_dec/ivas_jbm_dec_fx.c | 7 +++++++ lib_dec/ivas_mc_param_dec_fx.c | 13 ++++++++----- lib_dec/ivas_stat_dec.h | 2 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3f67962dc..6b5023a70 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4032,6 +4032,13 @@ 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(); + } } } } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 0e2de6c01..f1bbec638 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -106,7 +106,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); -static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); +static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); /*------------------------------------------------------------------------- * ivas_param_mc_dec_open() @@ -1983,7 +1983,7 @@ void ivas_param_mc_dec_render_fx( param_mc_protoSignalComputation_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info, - hParamMC->num_freq_bands ); + hParamMC->num_freq_bands, hParamMC->Cldfb_RealBuffer_tc_e, &hParamMC->proto_frame_f_fx_q ); /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ @@ -1995,7 +1995,7 @@ void ivas_param_mc_dec_render_fx( DIRAC_SYNTHESIS_COV_MC_LS, nchan_transport, hParamMC->proto_frame_f_fx, - Q5, + hParamMC->proto_frame_f_fx_q, hParamMC->diff_proto_info->num_protos_diff, hParamMC->diff_proto_info->proto_index_diff, hParamMC->proto_frame_dec_f_fx, // output @@ -2321,8 +2321,9 @@ static void param_mc_protoSignalComputation_fx( Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */ Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */ const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */ - const Word16 num_freq_bands /* i : number of frequency bands for the prototypes */ -) + const Word16 num_freq_bands, /* i : number of frequency bands for the prototypes */ + const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */ + Word16 *proto_frame_f_fx_q ) { Word16 band; Word16 proto_ch_idx, source_ch_cnt; @@ -2367,6 +2368,8 @@ static void param_mc_protoSignalComputation_fx( move32(); p_proto_frame_fx++; } + *proto_frame_f_fx_q = sub( 30, Cldfb_Real_Imag_exp ); + move16(); } } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 891be05be..4eb40f337 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -573,7 +573,7 @@ typedef struct ivas_param_mc_dec_data_structure Word32 *proto_matrix_int_fx; Word16 proto_matrix_int_len; Word16 proto_matrix_int_e; - + Word16 proto_frame_f_fx_q; /*sub-modules*/ HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params; HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state; diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index 9b2bf02d7..aa4aed84c 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -482,6 +482,7 @@ void ivas_dirac_dec_decorr_process_fx( q_shift = 0; move16(); } + 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 @@ -496,6 +497,11 @@ void ivas_dirac_dec_decorr_process_fx( { v_add_inc_fx( &aux_buffer_fx[imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) )], 2, &aux_buffer_fx[add( imult1616( 2, imult1616( ch_idx, max_band_decorr_temp ) ), 1 )], 2, &aux_buffer_fx[imult1616( ch_idx, max_band_decorr_temp )], 1, max_band_decorr_temp ); // q_aux_buffer } + if ( is_zero_arr( aux_buffer_fx, 2 * MAX_OUTPUT_CHANNELS * CLDFB_NO_CHANNELS_MAX ) ) + { + q_aux_buffer = 31; + move16(); + } /* compute onset filter */ max_band_decorr = h_freq_domain_decorr_ap_params->max_band_decorr; move16(); -- GitLab From a1a5235b6e35314ad21b6d9cbce4370e60b56e26 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 17:28:11 +0530 Subject: [PATCH 253/692] Clang formatting changes --- lib_dec/ivas_mc_param_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index f1bbec638..b6868dbb1 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -2322,7 +2322,7 @@ static void param_mc_protoSignalComputation_fx( Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */ const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */ const Word16 num_freq_bands, /* i : number of frequency bands for the prototypes */ - const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */ + const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */ Word16 *proto_frame_f_fx_q ) { Word16 band; -- GitLab From bd7113d89e33139ee17325e8717ece7d22a101a3 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 14:44:48 +0200 Subject: [PATCH 254/692] port float MR 1413 --- lib_com/ivas_prot_fx.h | 3 +++ lib_com/options.h | 1 + lib_dec/ivas_jbm_dec_fx.c | 4 ++++ lib_dec/ivas_mono_dmx_renderer_fx.c | 8 ++++++++ 4 files changed, 16 insertions(+) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b1a03bd2e..3ca3c90c8 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1155,6 +1155,9 @@ void ivas_mono_stereo_downmix_mcmasa_fx( ); void ivas_apply_non_diegetic_panning_fx( +#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING + float *input_f, /* i : non-diegetic object */ +#endif Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */ const Word16 output_frame /* i : output frame length per channel */ diff --git a/lib_com/options.h b/lib_com/options.h index 51319adce..27a2da35a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -140,6 +140,7 @@ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ +#define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index beb6535a2..80749ed4a 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1992,7 +1992,11 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { +#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING + ivas_apply_non_diegetic_panning_fx(p_tc_fx[0], st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); +#else ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); +#endif } #ifdef DEBUGGING ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 66b14cc56..48cad29f8 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -318,6 +318,9 @@ void ivas_mono_stereo_downmix_mcmasa_fx( *------------------------------------------------------------------------*/ void ivas_apply_non_diegetic_panning_fx( +#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING + float *input_f, /* i : non-diegetic object */ +#endif Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ const Word16 output_frame /* i : output frame length per channel Q11*/ @@ -328,8 +331,13 @@ void ivas_apply_non_diegetic_panning_fx( pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384 pan_right_fx = sub( 32767, pan_left_fx ); +#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING + v_multc_fixed( input_f, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); + v_multc_fixed( input_f, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); +#else v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); +#endif return; } -- GitLab From 9034d45d6ddeec3b11c4ff7efb5a1abd5e6439ee Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 14:54:32 +0200 Subject: [PATCH 255/692] fix formatting --- 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 80749ed4a..1e5daaf5d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1993,7 +1993,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - ivas_apply_non_diegetic_panning_fx(p_tc_fx[0], st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #else ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #endif -- GitLab From 67a8805b82ba76a3c3ffa2e05deb158f50dfd89d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 14:59:04 +0200 Subject: [PATCH 256/692] fix compile error --- 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 1e5daaf5d..64896a1ff 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1993,7 +1993,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #else ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #endif -- GitLab From 16da4e2186c55aea3ce9c2e800ad391101ac8862 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Thu, 12 Jun 2025 15:18:24 +0200 Subject: [PATCH 257/692] Set HRTF model file version to 78154d0b (Feb 2024) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ecbee063d..d03cba388 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -280,7 +280,7 @@ stages: - git pull origin $BASOP_CI_BRANCH_PC_REPO # Restore new format of HRTF binary - git fetch origin main - - git checkout origin/main -- scripts/binauralRenderer_interface/binaural_renderers_hrtf_data + - git checkout 78154d0b3f1b2c6c8ff8a234f3f7cf865d467d35 -- scripts/binauralRenderer_interface/binaural_renderers_hrtf_data - cd - - cp -r $SCRIPTS_DIR/ci . - cp -r $SCRIPTS_DIR/scripts . -- GitLab From 90ebdced188553f03c754d75a7225b98786acc0d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 15:36:08 +0200 Subject: [PATCH 258/692] fix formatting --- 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 64896a1ff..57063e7b7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1993,7 +1993,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); + ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #else ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); #endif -- GitLab From 59693e942b661393647b79abcdd9f741e35856c9 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Thu, 12 Jun 2025 16:00:24 +0200 Subject: [PATCH 259/692] fix variable types --- lib_com/ivas_prot_fx.h | 2 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 3ca3c90c8..d989a1f68 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1156,7 +1156,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( void ivas_apply_non_diegetic_panning_fx( #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - float *input_f, /* i : non-diegetic object */ + Word32 *input_f_fx, /* i : non-diegetic object */ #endif Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */ diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 48cad29f8..7029f8b8d 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -319,7 +319,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( void ivas_apply_non_diegetic_panning_fx( #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - float *input_f, /* i : non-diegetic object */ + Word32 *input_f_fx, /* i : non-diegetic object */ #endif Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ @@ -332,8 +332,8 @@ void ivas_apply_non_diegetic_panning_fx( pan_right_fx = sub( 32767, pan_left_fx ); #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - v_multc_fixed( input_f, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); - v_multc_fixed( input_f, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); + v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); + v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); #else v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); -- GitLab From 8cfb2caf8f303f22c4c28f5e2f37907df4db149b Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Thu, 12 Jun 2025 17:23:46 +0200 Subject: [PATCH 260/692] 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 261/692] 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 d5bf98b49cae75aa0356d6088c3367a19753b3b2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 14:23:20 +0530 Subject: [PATCH 262/692] Fix for 3GPP issue 1512: Decoder 160 kbit/s 7.1+4: Binaural Rendering introduces bigger differences Link #1512 --- 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..b9084df88 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -5137,7 +5137,7 @@ void decoder_tcx_imdct_fx( } } - ITF_Detect_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, shl( x_e, 1 ) ); + ITF_Detect_ivas_fx( x_fx + IGF_START_MN, startLine, endLine, 8 /*maxOrder*/, A_itf_fx, &q_a_itf, &predictionGain_fx, &curr_order, q_x ); ITF_Apply_fx( x_fx, startLine, endLine, A_itf_fx, q_a_itf, curr_order ); -- GitLab From e281e4add6092352c2203716c80bf1a2900f8bef Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 13 Jun 2025 08:58:06 +0200 Subject: [PATCH 263/692] fix comments in ivas_mono_dmx_renderer_fx.c --- lib_dec/ivas_mono_dmx_renderer_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 7029f8b8d..1ee8676e2 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -319,9 +319,9 @@ void ivas_mono_stereo_downmix_mcmasa_fx( void ivas_apply_non_diegetic_panning_fx( #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - Word32 *input_f_fx, /* i : non-diegetic object */ + Word32 *input_f_fx, /* i : non-diegetic object */ #endif - Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ + Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ const Word16 output_frame /* i : output frame length per channel Q11*/ ) -- GitLab From 3921fa88ab7dda258e924c1c48263355eb14daed Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 13 Jun 2025 09:09:52 +0200 Subject: [PATCH 264/692] fix formatting --- lib_dec/ivas_mono_dmx_renderer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 1ee8676e2..4f04c4dd8 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -319,7 +319,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( void ivas_apply_non_diegetic_panning_fx( #ifdef FIX_1009_ISM_NONDIEGETIC_PANNING - Word32 *input_f_fx, /* i : non-diegetic object */ + Word32 *input_f_fx, /* i : non-diegetic object */ #endif Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ -- GitLab From 1876a8248085ce22bd7391de4d679cda9d567534 Mon Sep 17 00:00:00 2001 From: Thomas Dettbarn Date: Fri, 13 Jun 2025 09:42:59 +0200 Subject: [PATCH 265/692] 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 e441a50059df28bd8452386c75a1ccd18d3f0911 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 10:18:08 +0200 Subject: [PATCH 266/692] [fix] apply same fix under DISABLE_LIMITER --- lib_dec/ivas_jbm_dec_fx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index e6f94c889..f2a7f6549 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2991,9 +2991,15 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( #ifndef DISABLE_LIMITER Word16 ch_idx, exp = 11; move16(); +#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER + FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) + { + p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; +#else FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) { p_output_fx[ch_idx] = output_fx[ch_idx]; +#endif } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); #endif -- GitLab From 9a4a10bade86fc7cf6a8bdb9ce8e71766b558378 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 14:32:22 +0530 Subject: [PATCH 267/692] Fix for 3GPP issue 1593: Somewhat high MLD in BASOP decoder for McMASA with rate switching and FER Link #1593 --- lib_com/pred_lt4_fx.c | 57 ++++++++++++++++++++++++++++++ lib_com/prot_fx.h | 10 ++++++ lib_com/rom_com.c | 12 +++++++ lib_com/rom_com.h | 3 +- lib_dec/LD_music_post_filter_fx.c | 9 ++++- lib_dec/acelp_core_switch_dec_fx.c | 21 ++++++++--- lib_dec/dec_gen_voic_fx.c | 10 ++++-- lib_dec/dec_pit_exc_fx.c | 10 ++++-- lib_dec/ivas_td_low_rate_dec_fx.c | 10 ++++-- lib_dec/transition_dec_fx.c | 54 ++++++++++++++++++++++++---- 10 files changed, 177 insertions(+), 19 deletions(-) diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 4f8dd8712..465138bde 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -20,6 +20,63 @@ * (adaptive codebook excitation) * *-------------------------------------------------------------------*/ +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +) +{ + Word16 i, j; + Word32 s; + const Word16 *x0, *x1, *x2; + const Word32 *c1, *c2; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; + move32(); +#endif + x0 = &excI[-T0]; + + frac = negate( frac ); + + IF( frac < 0 ) + { + frac = add( frac, up_sample ); /* Q0 */ + x0--; + } + + FOR( j = 0; j < L_subfr; j++ ) + { + x1 = x0++; /* Q_exc */ + x2 = x1 + 1; /* Q_exc */ + c1 = ( &win[frac] ); /* Q14 */ + c2 = ( &win[up_sample - frac] ); /* Q14 */ + + { + Word64 s64 = 0; + move64(); + FOR( i = 0; i < nb_coef; i++ ) + { + /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ + s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */ + s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */ + + c1 += up_sample; + c2 += up_sample; + } + s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */ + } + + excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */ + move16(); + } + return; +} + void pred_lt4( const Word16 excI[], /* in : excitation buffer Q_exc*/ Word16 excO[], /* out: excitation buffer Q_exc*/ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index ec2aec450..d533c5612 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7183,6 +7183,16 @@ void pred_lt4( const Word16 up_sample /* i : up_sample Q0*/ ); +void pred_lt4_ivas_fx( + const Word16 excI[], /* in : excitation buffer Q_exc*/ + Word16 excO[], /* out: excitation buffer Q_exc*/ + const Word16 T0, /* input : integer pitch lag Q0*/ + Word16 frac, /* input : fraction of lag Q0*/ + const Word16 L_subfr, /* input : subframe size Q0*/ + const Word32 *win, /* i : interpolation window Q31*/ + const Word16 nb_coef, /* i : nb of filter coef Q0*/ + const Word16 up_sample /* i : up_sample Q0*/ +); void pred_lt4_tc_fx( Word16 exc[], /* i/o: excitation buffer Q0*/ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 9eaf690f1..5d0a7f303 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -1332,6 +1332,18 @@ const Word16 inter4_2_fx[] = }; /* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) */ +const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2] = { /* Q31 */ + 2018634624, 1839083520, 1357785216, 724904576, 126856152, -281447072, + -428193216, -340524320, -121030032, 102233104, 229241728, 222704784, + 111802296, -32603096, -136805440, -158183648, -99851544, -2110976, + 82091856, 114123720, 86026048, 19988778, -46544560, -81104016, + -71266392, -27977416, 22982370, 55621972, 56517476, 29680372, + -7827578, -36105644, -42638288, -27414776, -1138166, 21646636, + 30326764, 22885734, 5570572, -11516955, -20066088, -17396766, + -6833293, 5003637, 12101070, 11944304, 6107443, -1346472, -6427418, + -7219840, -4389456, -249108, 2823941, 3633542, 2471753, 556198, + -895500, -1327144, -932007, -285615, 135291, 210453, 103079, 15032, 0 +}; const Word16 pitch_inter4_2[PIT_FIR_SIZE2] = { /* cut-off frequency at 0.94*fs/2 */ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 73156b989..a87ee8d0d 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -175,7 +175,8 @@ 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]; /*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 diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 5b48ab472..12a13a4ec 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -832,7 +832,14 @@ void Prep_music_postP_fx( * Extrapolation of the last future part and windowing *------------------------------------------------------------*/ pt1 = exc_buffer_in + DCT_L_POST - OFFSET2; /*Q_exc*/ - pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( pt1, pt1, s_pit, fr_pit, OFFSET2, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( pt1, pt1, s_pit, fr_pit, OFFSET2, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*------------------------------------------------------------* * windowing right side *------------------------------------------------------------*/ diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index 363db8202..b12682385 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -921,9 +921,14 @@ static void decod_gen_voic_core_switch_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector. *--------------------------------------------------------------*/ - - pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + pred_lt4( &exc[0], &exc[0], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*--------------------------------------------------------------* * LP filtering of the adaptive excitation *--------------------------------------------------------------*/ @@ -991,8 +996,14 @@ static void decod_gen_voic_core_switch_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 ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[L_SUBFR], &exc[L_SUBFR], T0, T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } pt1 = exc + L_SUBFR; FOR( i = 0; i < L_SUBFR; i++ ) diff --git a/lib_dec/dec_gen_voic_fx.c b/lib_dec/dec_gen_voic_fx.c index b9f488942..14d9d1772 100644 --- a/lib_dec/dec_gen_voic_fx.c +++ b/lib_dec/dec_gen_voic_fx.c @@ -166,8 +166,14 @@ ivas_error decod_gen_voic_fx( /*--------------------------------------------------------------* * 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 ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + 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); tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag ); diff --git a/lib_dec/dec_pit_exc_fx.c b/lib_dec/dec_pit_exc_fx.c index a18029cdc..ca6660fab 100644 --- a/lib_dec/dec_pit_exc_fx.c +++ b/lib_dec/dec_pit_exc_fx.c @@ -182,8 +182,14 @@ void dec_pit_exc_fx( /*--------------------------------------------------------------* * 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 ); + IF( st_fx->element_mode != EVS_MONO ) + { + pred_lt4_ivas_fx( &exc_fx[i_subfr_fx], &exc_fx[i_subfr_fx], T0_fx, T0_frac_fx, L_subfr_fx + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } + ELSE + { + 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 diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index f48d3fabc..fb984f11f 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -278,8 +278,14 @@ void decod_gen_2sbfr_fx( /*--------------------------------------------------------------* * Find the adaptive codebook vector *--------------------------------------------------------------*/ - - pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, inter4_2_fx_Q15, L_INTERPOL2, PIT_UP_SAMP ); + IF( st->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], T0, T0_frac, 2 * L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } /*--------------------------------------------------------------* * LP filtering of the adaptive excitation diff --git a/lib_dec/transition_dec_fx.c b/lib_dec/transition_dec_fx.c index b9ad17fcf..102a81b9d 100644 --- a/lib_dec/transition_dec_fx.c +++ b/lib_dec/transition_dec_fx.c @@ -209,7 +209,14 @@ void transition_dec_fx( limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */ /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); @@ -239,7 +246,14 @@ void transition_dec_fx( limit_T0_fx( L_FRAME, 8, pit_flag, limit_flag, *T0, 0, T0_min, T0_max ); /* find T0_min and T0_max */ /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -308,7 +322,14 @@ void transition_dec_fx( } /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -330,7 +351,14 @@ void transition_dec_fx( delta_pit_dec_fx( 2, index, T0, T0_frac, *T0_min ); /* Find the adaptive codebook vector. ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -351,7 +379,14 @@ void transition_dec_fx( pit_Q_dec_fx( 0, index, nBits, 8, pit_flag, limit_flag, T0, T0_frac, T0_min, T0_max, &st_fx->BER_detect ); /* Find the adaptive codebook vector */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penality for 2 ptrs initialization */ @@ -544,7 +579,14 @@ void transition_dec_fx( ELSE { /* Find the adaptive codebook vector - ACELP long-term prediction */ - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + IF( st_fx->element_mode != EVS_MONO ) + { + 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 ); + } + ELSE + { + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_SUBFR + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } offset = tbe_celp_exc_offset( *T0, *T0_frac, L_frame ); move16(); move16(); /* penalty for 2 ptrs initialization */ -- GitLab From 33291b4380479f59bd519e1bb696060a188aff2c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:21 +0200 Subject: [PATCH 268/692] [cleanup] accept FIX_699_FILE_READER_JBM_TSM --- apps/encoder.c | 4 ---- lib_com/options.h | 1 - 2 files changed, 5 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index a7229dff5..8404747dc 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -681,11 +681,7 @@ int main( { if ( ( error = JbmFileReader_readCAconfig( jbmReader, &caConfig ) ) != IVAS_ERR_OK ) { -#ifdef FIX_699_FILE_READER_JBM_TSM fprintf( stderr, "\nError (%s) while reading Channel-Aware Config. from: %s\n\n", IVAS_ENC_GetErrorMessage( error ), JbmFileReader_getFilePath( jbmReader ) ); -#else - fprintf( stderr, "JbmFileReader_readCAconfig() failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); -#endif goto cleanup; } diff --git a/lib_com/options.h b/lib_com/options.h index a7c2f1b53..433b0692e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ -#define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ #define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ -- GitLab From 76a16c4560c001841017d908f26791f941f40531 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:24 +0200 Subject: [PATCH 269/692] [cleanup] accept FIX_997_REMOVE_SPAR_DEC_UPMIXER --- lib_com/options.h | 1 - lib_dec/ivas_spar_decoder_fx.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 433b0692e..4d5b8ca68 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ -#define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index b13c6ab7a..530614fe9 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1534,20 +1534,12 @@ void ivas_spar_dec_set_render_map_fx( return; } -#ifdef FIX_997_REMOVE_SPAR_DEC_UPMIXER /*-------------------------------------------------------------------* * ivas_spar_dec_set_render_params() * * IVAS SPAR set rendering parameters *-------------------------------------------------------------------*/ -#else -/*-------------------------------------------------------------------* - * ivas_spar_dec_upmixer() - * - * IVAS SPAR upmixer - *-------------------------------------------------------------------*/ -#endif void ivas_spar_dec_set_render_params_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ -- GitLab From 9e2b26b22bb7a73f72a7b24d35c5777abe679d16 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:27 +0200 Subject: [PATCH 270/692] [cleanup] accept FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4d5b8ca68..4f77453e2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -127,7 +127,6 @@ #endif //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f2a7f6549..3abf7b2e7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -175,25 +175,6 @@ ivas_error ivas_jbm_dec_tc_fx( { hp20_fx_32( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } -#ifndef FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO - - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) - { - s = Q16 - Q11; - move16(); - s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s) - } - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11 - } - } -#endif } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { -- GitLab From b31d44e0fbc64b60b1dc47d8ec4793d2d01b41f6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:30 +0200 Subject: [PATCH 271/692] [cleanup] accept FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN --- lib_com/options.h | 1 - lib_dec/ivas_ism_dec_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4f77453e2..a8836818c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -130,7 +130,6 @@ #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ -#define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ #define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index ff4f45eca..16fab99ef 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -393,18 +393,6 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( tc_nchan_full_new = tc_nchan_tc_new; move16(); -#ifndef FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) - { - tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; - move16(); - tc_nchan_full_new = tc_nchan_allocate_new; - move16(); - } - -#endif test(); test(); test(); -- GitLab From 45e2853b2ebc78466c383108142ed611aeae79ff Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:33 +0200 Subject: [PATCH 272/692] [cleanup] accept FIX_1001_ARI_HM_OVERFLOW --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a8836818c..d98b08ca2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -130,7 +130,6 @@ #define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ -#define FIX_1001_ARI_HM_OVERFLOW /* FhG: (no changes needed in BASOP) fix for undef behaviour in in the harmonic TCX model arithmetic coder */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -- GitLab From 9c8d48ff5c12a424bf8b129fa208c59e8eb050e9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:40 +0200 Subject: [PATCH 273/692] [cleanup] accept FIX_1008_EXTORIENT_TARGET_INTERPOLATION --- lib_com/options.h | 1 - lib_rend/ivas_rotation_fx.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index d98b08ca2..ea0be205a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,7 +133,6 @@ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define FIX_1008_EXTORIENT_TARGET_INTERPOLATION /* FhG: issue #1008, external orientation init was wrong for 5ms */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ #define NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER /* FhG: issues #1012, 1013: JBM flush function uses wrong output buffer */ diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 154dab321..36f363f83 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1379,20 +1379,8 @@ ivas_error ivas_combined_orientation_open( move32(); ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; // Q30 move32(); -#ifndef FIX_1008_EXTORIENT_TARGET_INTERPOLATION - IF( EQ_16( num_subframes, 1 ) ) - { - ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 2000; - move16(); - } - ELSE - { -#endif ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 500; move16(); -#ifndef FIX_1008_EXTORIENT_TARGET_INTERPOLATION - } -#endif ( *hCombinedOrientationData )->lrSwitchedNext = 0; move16(); ( *hCombinedOrientationData )->lrSwitchedCurrent = 0; -- GitLab From 8c97d14d112672f76953970dbeba3e164cc6714c Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:43 +0200 Subject: [PATCH 274/692] [cleanup] accept NONBE_FIX_978_MC_TDREND_REVERB --- lib_com/options.h | 1 - lib_dec/ivas_init_dec_fx.c | 4 ---- lib_dec/ivas_ism_dec_fx.c | 4 ---- lib_dec/ivas_objectRenderer_internal_fx.c | 8 -------- 4 files changed, 17 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index ea0be205a..a1fc5e751 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define NONBE_FIX_978_MC_TDREND_REVERB /* Eri : activate reverb for TDREND with headtracking */ #define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 312011c73..6643ed423 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2291,11 +2291,7 @@ ivas_error ivas_init_decoder_fx( move16(); } -#ifdef NONBE_FIX_978_MC_TDREND_REVERB IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#else - IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 16fab99ef..5f431d63b 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -218,11 +218,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( { return error; } -#ifdef NONBE_FIX_978_MC_TDREND_REVERB IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#else - IF( EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 48cbd21c7..1b174493d 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -237,11 +237,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } test(); -#ifdef NONBE_FIX_978_MC_TDREND_REVERB IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#else - IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { FOR( i = 0; i < nchan_ism_internal; ++i ) { @@ -273,11 +269,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( } test(); -#ifdef NONBE_FIX_978_MC_TDREND_REVERB IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#else - IF( st_ivas->hRenderConfig != NULL && EQ_32( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { /* add reverb to rendered signals */ v_add_32( reverb_signal_fx[0], output_fx_local[0], output_fx_local[0], output_frame ); // Q11 -- GitLab From 8b75e5595f09a8fdc58950d7244b3ef2ec1dde57 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:52 +0200 Subject: [PATCH 275/692] [cleanup] accept NONBE_FIX_999_JBM_MCT_FLUSH --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1fc5e751..0255c82a2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define NONBE_FIX_999_JBM_MCT_FLUSH /* FhG: issue #999: fix wrong flushing for MCT at a JBM rate switch */ #define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3abf7b2e7..6a0d49bfe 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2843,11 +2843,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } -#ifdef NONBE_FIX_999_JBM_MCT_FLUSH ELSE IF( EQ_16( renderer_type_old, RENDERER_BINAURAL_OBJECTS_TD ) ) -#else - ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) -#endif { IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ) ), IVAS_ERR_OK ) ) { @@ -2855,12 +2851,10 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( } ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } -#ifdef NONBE_FIX_999_JBM_MCT_FLUSH ELSE { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" ); } -#endif } ELSE { -- GitLab From cc113f025a6d0a4b9b2e5ead1713ba483c655ac7 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:55 +0200 Subject: [PATCH 276/692] [cleanup] accept NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE --- lib_com/options.h | 1 - lib_dec/ivas_mct_dec_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0255c82a2..fc33b50d9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,7 +128,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE /* FhG: issue #1005: fix TC Buffer update at a MC rate switch */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 4545ab61d..5c9deed2d 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1023,10 +1023,8 @@ static ivas_error ivas_mc_dec_reconfig_fx( /* transfer subframe info from DirAC or ParamMC to central tc buffer */ -#ifdef NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE if ( st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) { -#endif test(); IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) ) { @@ -1052,9 +1050,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( move16(); Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } -#ifdef NONBE_FIX_1005_MC_RS_TCBUFFER_UPDATE } -#endif /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv render what still fits in the new granularity */ -- GitLab From 0287dc47fc348f8d56d331dfa7b58846464dc9bf Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:30:58 +0200 Subject: [PATCH 277/692] [cleanup] accept SPLIT_REND_POSE_CORRECTION_UNUSED_BITS --- lib_com/options.h | 1 - lib_isar/isar_cnst.h | 4 - lib_isar/isar_prot.h | 8 - lib_isar/isar_splitRendererPost.c | 163 ------------------ lib_isar/isar_splitRendererPre.c | 246 ---------------------------- lib_isar/isar_splitRenderer_utils.c | 58 ------- lib_isar/isar_stat.h | 2 - 7 files changed, 482 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fc33b50d9..810fefcd4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,7 +105,6 @@ #define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT -#define SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #define FIX_1372_ISAR_POST_REND #endif diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 046beabdc..7eae62357 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -76,12 +76,8 @@ typedef enum #define MAX_SPLIT_REND_MD_BANDS 20 #define MAX_SPLIT_MD_SUBFRAMES 1 #define COMPLEX_MD_BAND_THRESH MAX_SPLIT_REND_MD_BANDS -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS #define COMPLEX_MD_BAND_THRESH_LOW 4 #define COMPLEX_MD_BAND_THRESH_HIGH 10 -#else -#define COMPLEX_MD_BAND_THRESH_LOW 5 -#endif #define SPLIT_REND_RO_MD_BAND_THRESH 4 #define ISAR_SPLIT_REND_PRED_63QUANT_PNTS_LOG2_CEIL 6 diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 618454f66..b97b81bbc 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -199,14 +199,8 @@ void isar_split_rend_get_quant_params_fx( Word16 bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const Word16 ro_flag, -#endif Word16 *num_quant_strats -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - , - Word16 *num_complex_bands -#endif ); void isar_split_rend_get_quant_params( @@ -293,7 +287,6 @@ void isar_rend_CldfbSplitPreRendProcess( const Word16 low_res_pre_rend_rot, const Word16 ro_md_flag ); -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word16 isar_renderSplitGetRot_axisNumBits( const Word16 dof ); @@ -305,7 +298,6 @@ Word16 isar_renderSplitGetCodeFromRot_axis( const Word16 dof, const ISAR_SPLIT_REND_ROT_AXIS rot_axis, Word16 *num_bits ); -#endif void isar_init_split_post_rend_handles( ISAR_SPLIT_POST_REND_WRAPPER *hSplitRendWrapper ); diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 306b47d71..32a230318 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -239,22 +239,9 @@ static void ivas_split_rend_unquant_md_fx( quantstep = pred_quant_step; move32(); -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - hMd->pred_mat_re_fx[ch1][ch2] = Mpy_32_16_1( quantstep, extract_l( L_shl( hMd->pred_mat_re_idx[ch1][ch2], Q9 ) ) ); /* Q25 */ - move32(); - hMd->pred_mat_re_fx[ch1][ch2] = L_add( hMd->pred_mat_re_fx[ch1][ch2], L_shr( fix_pos_rot_mat[ch1][ch2], Q6 ) ); /* Q25 */ - move32(); - } - } -#endif IF( real_only ) { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) @@ -265,7 +252,6 @@ static void ivas_split_rend_unquant_md_fx( move32(); } } -#endif FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { @@ -278,7 +264,6 @@ static void ivas_split_rend_unquant_md_fx( } ELSE { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) @@ -289,7 +274,6 @@ static void ivas_split_rend_unquant_md_fx( move32(); } } -#endif FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { @@ -385,34 +369,6 @@ static void isar_splitBinPostRendMdBase2Dec( { IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], ANY_YAW ) ) { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); - hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_idx ); - move16(); - } - } - } - FOR( b = 0; b < pred_imag_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_code_len ) ); - hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_idx ); - move16(); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -450,7 +406,6 @@ static void isar_splitBinPostRendMdBase2Dec( hMd->pred_mat_re_idx[1][0] = 0; move16(); } -#endif FOR( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -474,34 +429,6 @@ static void isar_splitBinPostRendMdBase2Dec( } ELSE { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_roll; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); - hMd->pred_mat_re_idx[ch1][ch2] = add( code, min_pred_roll_idx ); - move16(); - } - } - } - FOR( b = 0; b < pred_imag_bands_roll; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, pred_roll_code_len ) ); - hMd->pred_mat_im_idx[ch1][ch2] = add( code, min_pred_roll_idx ); - move16(); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_roll; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -539,7 +466,6 @@ static void isar_splitBinPostRendMdBase2Dec( hMd->pred_mat_re_idx[1][0] = 0; move16(); } -#endif } } } @@ -599,36 +525,6 @@ static void ivas_splitBinPostRendMdHuffDec( { IF( EQ_32( hBinHrSplitPostRend->pose_type[pos_idx], ANY_YAW ) ) { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); - move16(); - // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); - } - } - isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_idx, max_pred_idx ); - } - FOR( b = 0; b < pred_imag_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred[pred_cb_idx], pBits, pHuff_cfg->pred_idx_trav[pred_cb_idx] ); - move16(); - // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred, pBits ); - } - } - isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_idx, max_pred_idx ); - } -#else FOR( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -668,7 +564,6 @@ static void ivas_splitBinPostRendMdHuffDec( move16(); isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_idx, max_pred_idx ); } -#endif FOR( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -689,37 +584,6 @@ static void ivas_splitBinPostRendMdHuffDec( } ELSE { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_roll; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); - move16(); - // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); - } - } - isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); - } - FOR( b = 0; b < pred_imag_bands_roll; b++ ) - { - hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode_opt( &pHuff_cfg->pred_roll, pBits, pHuff_cfg->pred_roll_idx_trav ); - move16(); - // sym_adj_idx[ch1][ch2] = ivas_split_rend_huffman_decode( &pHuff_cfg->pred_roll, pBits ); - } - } - isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_im_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); - } -#else FOR( b = 0; b < pred_imag_bands_roll; b++ ) { hMd = &hBinHrSplitPostRend->rot_md[pos_idx][sf_idx][b]; @@ -760,7 +624,6 @@ static void ivas_splitBinPostRendMdHuffDec( move16(); isar_SplitRenderer_getdiagdiff( sym_adj_idx, hMd->pred_mat_re_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); } -#endif } } } @@ -789,11 +652,7 @@ void isar_splitBinPostRendMdDec_fx( Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; Word16 d_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word16 num_quant_strats; -#else - Word16 num_complex_bands, num_quant_strats; -#endif Word32 quant_strat_bits, is_huff_coding, quant_strat; Word16 pred_quant_pnts_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; Word32 pred_1byquantstep_yaw_fx[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; // Q26 @@ -804,9 +663,7 @@ void isar_splitBinPostRendMdDec_fx( ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; ISAR_SPLIT_REND_ROT_AXIS rot_axis; -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word16 ro_md_flag, num_bits, axis_code; -#endif hBinHrSplitPostRend->low_Res = 1; move16(); @@ -814,7 +671,6 @@ void isar_splitBinPostRendMdDec_fx( split_rend_config.dof = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_DOF_BITS ) ); split_rend_config.hq_mode = extract_l( ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_HQ_MODE_BITS ) ); -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS num_bits = isar_renderSplitGetRot_axisNumBits( split_rend_config.dof ); if ( num_bits > 0 ) { @@ -826,9 +682,6 @@ void isar_splitBinPostRendMdDec_fx( } rot_axis = isar_renderSplitGetRot_axisFromCode( split_rend_config.dof, axis_code ); ro_md_flag = (int16_t) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_RO_FLAG_BITS ); -#else - rot_axis = (ISAR_SPLIT_REND_ROT_AXIS) ISAR_SPLIT_REND_BITStream_read_int32( pBits, ISAR_SPLIT_REND_ROT_AXIS_BITS ); -#endif isar_renderSplitGetMultiBinPoseData_fx( &split_rend_config, pMultiBinPoseData, rot_axis ); set_fix_rotation_mat_fx( hBinHrSplitPostRend->fix_pos_rot_mat_fx, pMultiBinPoseData ); @@ -862,7 +715,6 @@ void isar_splitBinPostRendMdDec_fx( move32(); } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS isar_split_rend_get_quant_params_fx( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, @@ -876,21 +728,6 @@ void isar_splitBinPostRendMdDec_fx( pred_imag_bands_roll, ro_md_flag, &num_quant_strats ); -#else - isar_split_rend_get_quant_params_fx( - MAX_SPLIT_REND_MD_BANDS, - pred_real_bands_yaw, - pred_imag_bands_yaw, - pred_quant_pnts_yaw, - pred_quantstep_yaw_fx, - pred_1byquantstep_yaw_fx, - d_bands_yaw, - bands_pitch, - pred_real_bands_roll, - pred_imag_bands_roll, - &num_quant_strats, - &num_complex_bands ); -#endif quant_strat_bits = L_deposit_l( ceil_log_2( num_quant_strats ) ); is_huff_coding = ISAR_SPLIT_REND_BITStream_read_int32( pBits, 1 ); quant_strat = ISAR_SPLIT_REND_BITStream_read_int32( pBits, quant_strat_bits ); diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 8bdc824f8..e5454e852 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -912,11 +912,7 @@ static void isar_split_rend_quant_md_fx( { int16_t ch1, ch2; int16_t gd_idx_min; -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word32 quant_val; -#else - Word32 sign, quant_val; -#endif #ifdef DEBUG_QUANT_MD_FX float quant_val_flt; Word16 tmp; @@ -931,7 +927,6 @@ static void isar_split_rend_quant_md_fx( #endif IF( real_only == 1 ) { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { hMd->pred_mat_re_fx[ch1][ch1] = hMd->pred_mat_re2[ch1]; @@ -948,25 +943,9 @@ static void isar_split_rend_quant_md_fx( hMd->pred_mat_re_idx[ch1][ch2] = (Word16) L_shr_r( Mpy_32_32( onebyquantstep, quant_val ), sub( Q_frame, 5 ) ); // Q25*Q26 = Q20 -> Q16 -> Q0 } } -#else - for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - sign = GE_32( hMd->pred_mat_re_fx[ch1][ch2], 0 ) ? 1 : -1; - Word16 exp_out; - ivas_calculate_abs_fx( hMd->pred_mat_re_fx[ch1][ch2], Q31 - Q_frame, hMd->pred_mat_im_fx[ch1][ch2], Q31 - Q_frame, &hMd->pred_mat_re_fx[ch1][ch2], &exp_out ); - hMd->pred_mat_re_fx[ch1][ch2] = L_shr_r( hMd->pred_mat_re_fx[ch1][ch2], sub( sub( Q31, Q_frame ), exp_out ) ); // Q_frame - hMd->pred_mat_re_fx[ch1][ch2] = (Word32) W_mult0_32_32( hMd->pred_mat_re_fx[ch1][ch2], sign ); - hMd->pred_mat_im_fx[ch1][ch2] = 0; - } - } -#endif } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS else { -#endif for ( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) { for ( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) @@ -986,9 +965,7 @@ static void isar_split_rend_quant_md_fx( #endif } } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS } -#endif if ( real_only == 0 ) { @@ -1067,7 +1044,6 @@ static void isar_split_rend_quant_md_fx( } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS static void get_lr_gains( Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], const Word16 exp_cov_ii_re, Word32 cov_oo_re_fx[][BINAURAL_CHANNELS], @@ -1123,7 +1099,6 @@ static void get_lr_gains( Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], move16(); return; } -#endif static void ComputeCoeffs_fx( Word32 cov_ii_re_fx[][BINAURAL_CHANNELS], @@ -1216,7 +1191,6 @@ static void ComputeCoeffs_fx( { IF( real_only ) { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word32 gd_tmp_fx[BINAURAL_CHANNELS]; get_lr_gains( cov_ii_re_fx, exp_cov_ii_re, cov_oo_re_fx, exp_cov_oo_re, @@ -1237,77 +1211,12 @@ static void ComputeCoeffs_fx( } -#else - Word32 gd_tmp_fx[BINAURAL_CHANNELS]; - Word16 exp_gd_tmp_buf[BINAURAL_CHANNELS] = { 0 }; - Word16 exp_gd_tmp = 0; - - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - gd_tmp_fx[i] = cov_ii_re_fx[i][i]; - move32(); - exp_gd_tmp_buf[i] = exp_cov_ii_re; - move16(); - - Word16 flag = BASOP_Util_Cmp_Mant32Exp( gd_tmp_fx[i], exp_gd_tmp_buf[i], EPSILON_FX, 0 ); - IF( EQ_16( flag, negate( 1 ) ) ) - { - gd_tmp_fx[i] = ONE_IN_Q25; - move32(); - exp_gd_tmp_buf[i] = 6; - move16(); - } - ELSE - { - Word16 tmp, tmp_sqrt, exp_tmp = 0; - tmp = BASOP_Util_Divide3232_Scale( cov_oo_re_fx[i][i], gd_tmp_fx[i], &exp_tmp ); - exp_tmp = exp_tmp + ( exp_cov_oo_re - exp_gd_tmp_buf[i] ); - tmp_sqrt = Sqrt16( tmp, &exp_tmp ); - gd_tmp_fx[i] = L_deposit_h( tmp_sqrt ); - move32(); - exp_gd_tmp_buf[i] = exp_tmp; - move16(); - } - hMd->pred_mat_re_fx[i][i] = gd_tmp_fx[i]; - move32(); - set32_fx( hMd->pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); - } - hMd->pred_mat_re_fx[1][0] = 0; - move32(); - hMd->pred_mat_re_fx[0][1] = 0; - move32(); - - Word16 max_gd_exp = MIN16B; - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] ); - } - exp_gd_tmp = max_gd_exp; - - FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) - { - hMd->pred_mat_re_fx[i][i] = L_shr( hMd->pred_mat_re_fx[i][i], max_gd_exp - exp_gd_tmp_buf[i] ); - move32(); - } - - exp_pred_re = exp_gd_tmp; - move16(); - exp_pred_im = exp_gd_tmp; - move16(); - - hMd->exp_pred_mat_re = exp_pred_re; - move16(); - hMd->exp_pred_mat_im = exp_pred_im; - move16(); -#endif } ELSE { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS get_lr_gains( cov_ii_re_fx, exp_cov_ii_re, cov_oo_re_fx, exp_cov_oo_re, hMd->pred_mat_re2, &hMd->exp_pred_mat_re2 ); -#endif Word16 exp_norm_fact = 0; cov_norm_fact_fx = GetNormFact_fx( cov_ii_re_fx, exp_cov_ii_re, cov_ii_im_fx, exp_cov_ii_im, cov_io_re_fx, exp_cov_io_re, cov_io_im_fx, exp_cov_io_im, cov_oo_re_fx, exp_cov_oo_re, &exp_norm_fact ); @@ -1580,19 +1489,12 @@ static void get_base2_bits( pose_type = hBinHrSplitPreRend->pose_type[pose_idx]; IF( EQ_32( pose_type, ANY_YAW ) ) { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_real_bands_yaw[q] ), bin_ch_2_num_sf ) ); - move32(); - base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_2_num_sf ) ); - move32(); -#else base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_real_bands_yaw[q] ), bin_ch_num_sf ) ); move32(); base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_num_sf ) ); move32(); base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_yaw_bits[q], pred_imag_bands_yaw[q] ), bin_ch_2_num_sf ) ); move32(); -#endif base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( d_gain_bits, d_bands_yaw[q] ), num_subframes ) ); @@ -1607,19 +1509,12 @@ static void get_base2_bits( } ELSE { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_real_bands_roll[q] ), bin_ch_2_num_sf ) ); - move32(); - base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_2_num_sf ) ); - move32(); -#else base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_real_bands_roll[q] ), bin_ch_num_sf ) ); move32(); base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_num_sf ) ); move32(); base2bits[q] = L_add( base2bits[q], L_mult0( DEPR_i_mult( pred_roll_bits, pred_imag_bands_roll[q] ), bin_ch_2_num_sf ) ); move32(); -#endif } } } @@ -1683,33 +1578,6 @@ static void isar_SplitRenderer_code_md_base2( { IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], ANY_YAW ) ) { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_idx ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); - } - } - } - - FOR( b = 0; b < pred_imag_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_idx ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1740,7 +1608,6 @@ static void isar_SplitRenderer_code_md_base2( ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_code_len ); } } -#endif FOR( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1762,33 +1629,6 @@ static void isar_SplitRenderer_code_md_base2( } ELSE { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_roll; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = L_sub( hMd->pred_mat_re_idx[ch1][ch2], min_pred_roll_idx ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); - } - } - } - - FOR( b = 0; b < pred_imag_bands_roll; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - code = L_sub( hMd->pred_mat_im_idx[ch1][ch2], min_pred_roll_idx ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_roll; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1819,7 +1659,6 @@ static void isar_SplitRenderer_code_md_base2( ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, pred_roll_code_len ); } } -#endif } } } @@ -1895,35 +1734,6 @@ static void isar_SplitRenderer_code_md_huff( { IF( EQ_32( hBinHrSplitPreRend->pose_type[pos_idx], ANY_YAW ) ) { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_idx, max_pred_idx ); - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); - } - } - } - FOR( b = 0; b < pred_imag_bands_yaw; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_idx, max_pred_idx ); - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - isar_split_rend_huffman_encode( &pHuff_cfg->pred[pred_cb_idx], sym_adj_idx[ch1][ch2], &code, &len ); - - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1958,7 +1768,6 @@ static void isar_SplitRenderer_code_md_huff( ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); } } -#endif FOR( b = 0; b < d_bands_yaw; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -1980,34 +1789,6 @@ static void isar_SplitRenderer_code_md_huff( } ELSE { -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - FOR( b = 0; b < pred_real_bands_roll; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - isar_SplitRenderer_getdiagdiff( hMd->pred_mat_re_idx, sym_adj_idx, -1, min_pred_roll_idx, max_pred_roll_idx ); - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); - } - } - } - FOR( b = 0; b < pred_imag_bands_roll; b++ ) - { - hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; - isar_SplitRenderer_getdiagdiff( hMd->pred_mat_im_idx, sym_adj_idx, 1, min_pred_roll_idx, max_pred_roll_idx ); - FOR( ch1 = 0; ch1 < BINAURAL_CHANNELS; ch1++ ) - { - FOR( ch2 = 0; ch2 < BINAURAL_CHANNELS; ch2++ ) - { - isar_split_rend_huffman_encode( &pHuff_cfg->pred_roll, sym_adj_idx[ch1][ch2], &code, &len ); - ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); - } - } - } -#else FOR( b = 0; b < pred_imag_bands_roll; b++ ) { hMd = &hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b]; @@ -2041,7 +1822,6 @@ static void isar_SplitRenderer_code_md_huff( ISAR_SPLIT_REND_BITStream_write_int32( pBits, code, len ); } } -#endif } } } @@ -2073,17 +1853,11 @@ static void isar_SplitRenderer_quant_code( MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, ISAR_SPLIT_REND_BITS_HANDLE pBits, const Word16 low_res_pre_rend_rot, -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const int16_t ro_md_flag, -#endif const Word32 target_md_bits, Word16 Q_frame ) { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word16 q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; -#else - Word16 num_complex_bands, q, num_subframes, sf_idx, pos_idx, b, num_quant_strats; -#endif Word32 overhead_bits, quant_strat_bits, huff_bits, start_bit; Word16 pred_real_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; Word16 pred_imag_bands_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS], pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; @@ -2097,9 +1871,7 @@ static void isar_SplitRenderer_quant_code( float pred_quantstep_yaw[ISAR_SPLIT_REND_NUM_QUANT_STRATS]; #endif ISAR_BIN_HR_SPLIT_REND_MD_HANDLE hMd; -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word16 rot_axis_code, num_bits; -#endif IF( low_res_pre_rend_rot ) { @@ -2114,16 +1886,12 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->dof, ISAR_SPLIT_REND_DOF_BITS ); ISAR_SPLIT_REND_BITStream_write_int32( pBits, pMultiBinPoseData->hq_mode, ISAR_SPLIT_REND_HQ_MODE_BITS ); -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS rot_axis_code = isar_renderSplitGetCodeFromRot_axis( pMultiBinPoseData->dof, pMultiBinPoseData->rot_axis, &num_bits ); if ( num_bits > 0 ) { ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) rot_axis_code, num_bits ); } ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) ro_md_flag, ISAR_SPLIT_REND_RO_FLAG_BITS ); -#else - ISAR_SPLIT_REND_BITStream_write_int32( pBits, (int32_t) pMultiBinPoseData->rot_axis, ISAR_SPLIT_REND_ROT_AXIS_BITS ); -#endif /* code ref pose*/ FOR( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) @@ -2147,15 +1915,9 @@ static void isar_SplitRenderer_quant_code( ISAR_SPLIT_REND_BITStream_write_int32( pBits, angle, ISAR_SPLIT_REND_HEAD_POSE_BITS ); } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS isar_split_rend_get_quant_params_fx( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, pred_quant_pnts_yaw, pred_quantstep_yaw_fx, pred_1byquantstep_yaw_fx, d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, ro_md_flag, &num_quant_strats ); -#else - isar_split_rend_get_quant_params_fx( MAX_SPLIT_REND_MD_BANDS, pred_real_bands_yaw, pred_imag_bands_yaw, - pred_quant_pnts_yaw, pred_quantstep_yaw_fx, pred_1byquantstep_yaw_fx, - d_bands_yaw, bands_pitch, pred_real_bands_roll, pred_imag_bands_roll, &num_quant_strats, &num_complex_bands ); -#endif #ifdef DEBUG_QUANT_MD_FX fixedToFloat_arrL( pred_quantstep_yaw_fx, pred_quantstep_yaw, Q31, ISAR_SPLIT_REND_NUM_QUANT_STRATS ); fixedToFloat_arrL( pred_1byquantstep_yaw_fx, pred_1byquantstep_yaw, Q26, ISAR_SPLIT_REND_NUM_QUANT_STRATS ); @@ -2568,9 +2330,7 @@ void isar_rend_CldfbSplitPreRendProcess( ELSE { exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re ); -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re2 ); -#endif exp_frame = s_max( exp_frame, hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_im ); } } @@ -2600,19 +2360,13 @@ void isar_rend_CldfbSplitPreRendProcess( Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re_fx[i], BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re, exp_frame ) ); Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_im_fx[i], BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_im, exp_frame ) ); } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Scale_sig32( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].pred_mat_re2, BINAURAL_CHANNELS, sub( hBinHrSplitPreRend->rot_md[pos_idx][sf_idx][b].exp_pred_mat_re2, exp_frame ) ); -#endif } } } } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, ro_md_flag, target_md_bits, Q_frame ); -#else - isar_SplitRenderer_quant_code( hBinHrSplitPreRend, headPosition, pMultiBinPoseData, pBits, low_res_pre_rend_rot, target_md_bits, Q_frame ); -#endif #ifdef DEBUG_QUANT_CODE_OUT for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index 7f21a40c7..daa4c1806 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -961,40 +961,21 @@ ivas_error isar_split_rend_validate_config( ELSE { IF( EQ_16( pSplitRendConfig->dof, 1 ) ){ -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS IF( LT_32( pSplitRendConfig->splitRendBitRate, 34000 ) ){ return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 34 kbps" ); } -#else - IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ){ - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 50 kbps" ); - } -#endif } ELSE IF( EQ_16( pSplitRendConfig->dof, 2 ) ){ -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ){ return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" ); } -#else - IF( LT_32( pSplitRendConfig->splitRendBitRate, 66000 ) ){ - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 66 kbps" ); -} -#endif } ELSE IF( EQ_16( pSplitRendConfig->dof, 3 ) ) { -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS IF( LT_32( pSplitRendConfig->splitRendBitRate, 82000 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); } -#else - IF( LT_32( pSplitRendConfig->splitRendBitRate, 128000 ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); - } -#endif } } @@ -1019,25 +1000,14 @@ void isar_split_rend_get_quant_params_fx( Word16 bands_pitch[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS const Word16 ro_flag, -#endif Word16 *num_quant_strats -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - , - Word16 *num_complex_bands -#endif ) { Word16 q; *num_quant_strats = ISAR_SPLIT_REND_NUM_QUANT_STRATS; move16(); -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - *num_complex_bands = COMPLEX_MD_BAND_THRESH_LOW; - move16(); - assert( *num_complex_bands <= num_md_bands ); -#endif pred_quant_pnts_yaw[0] = ISAR_SPLIT_REND_PRED_63QUANT_PNTS; move16(); @@ -1063,24 +1033,6 @@ void isar_split_rend_get_quant_params_fx( move16(); } -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - pred_imag_bands_yaw[0] = num_md_bands; - move16(); - pred_imag_bands_roll[0] = num_md_bands; - move16(); - pred_imag_bands_yaw[1] = num_md_bands; - move16(); - pred_imag_bands_roll[1] = num_md_bands; - move16(); - - FOR( q = 2; q < *num_quant_strats; q++ ) - { - pred_imag_bands_yaw[q] = LT_16( q, sub( *num_quant_strats, 1 ) ) ? num_md_bands : *num_complex_bands; - move16(); - pred_imag_bands_roll[q] = *num_complex_bands; - move16(); - } -#else IF( ro_flag ) { FOR( q = 0; q < *num_quant_strats; q++ ) @@ -1107,7 +1059,6 @@ void isar_split_rend_get_quant_params_fx( pred_imag_bands_roll[q] = SPLIT_REND_RO_MD_BAND_THRESH; move16(); } -#endif FOR( q = 0; q < *num_quant_strats; q++ ) { @@ -1120,7 +1071,6 @@ void isar_split_rend_get_quant_params_fx( return; } -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS /*------------------------------------------------------------------------- * Function isar_renderSplitGetRot_axisNumBits() * @@ -1212,7 +1162,6 @@ Word16 isar_renderSplitGetCodeFromRot_axis( return code; } -#endif /*------------------------------------------------------------------------- * Function isar_renderSplitGetMultiBinPoseData() @@ -1287,10 +1236,6 @@ void isar_renderSplitGetMultiBinPoseData_fx( SWITCH( rot_axis ) { case DEFAULT_AXIS: -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - case YAW: - case PITCH: -#endif case YAW_PITCH: { num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; @@ -1299,9 +1244,6 @@ void isar_renderSplitGetMultiBinPoseData_fx( move16(); BREAK; } -#ifndef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS - case ROLL: -#endif case YAW_ROLL: { num_yaw_poses = SPLIT_REND_MAX_YAW_ONLY_POSES; diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index fec4a5d80..0b1e1bb07 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -115,10 +115,8 @@ typedef struct isar_binaural_head_rot_split_rendering_md_struct Word16 exp_pred_mat_re; Word32 pred_mat_im_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS]; /* Q25 */ Word16 exp_pred_mat_im; -#ifdef SPLIT_REND_POSE_CORRECTION_UNUSED_BITS Word32 pred_mat_re2[BINAURAL_CHANNELS]; Word16 exp_pred_mat_re2; -#endif Word32 gd_fx; /* Q25 */ Word32 gd2_fx; /* Q25 */ Word16 exp_gd; -- GitLab From a3804b2deab1746778f9ffabbf9e51d222ee4fcc Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:31:01 +0200 Subject: [PATCH 278/692] [cleanup] accept ISAR_BITSTREAM_UPDATE_LC3PLUS --- apps/decoder.c | 16 -- apps/isar_post_rend.c | 17 -- apps/renderer.c | 14 -- lib_com/common_api_types.h | 6 - lib_com/ivas_error.h | 2 - lib_com/options.h | 1 - lib_dec/ivas_init_dec_fx.c | 5 - lib_dec/lib_dec.h | 4 - lib_dec/lib_dec_fx.c | 14 -- lib_isar/isar_cnst.h | 2 - lib_isar/isar_lc3plus_common.c | 2 - lib_isar/isar_lc3plus_common.h | 6 - lib_isar/isar_lc3plus_dec.c | 296 ------------------------ lib_isar/isar_lc3plus_dec.h | 25 -- lib_isar/isar_lc3plus_enc.c | 113 --------- lib_isar/isar_lc3plus_enc.h | 14 -- lib_isar/isar_lc3plus_payload.c | 2 - lib_isar/isar_lc3plus_payload.h | 2 - lib_isar/isar_prot.h | 30 --- lib_isar/isar_splitRendererPre.c | 63 ----- lib_isar/isar_splitRenderer_utils.c | 146 ------------ lib_isar/lib_isar_post_rend.c | 104 --------- lib_isar/lib_isar_post_rend.h | 4 - lib_isar/lib_isar_pre_rend.c | 37 --- lib_isar/lib_isar_pre_rend.h | 6 - lib_rend/ivas_render_config_fx.c | 4 - lib_rend/lib_rend.h | 4 - lib_rend/lib_rend_fx.c | 10 - lib_util/render_config_reader.c | 2 - lib_util/split_render_file_read_write.c | 8 - lib_util/split_render_file_read_write.h | 4 - 31 files changed, 963 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index cdd5e3096..939f21aa7 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -558,11 +558,9 @@ int main( renderConfig.roomAcoustics.override = true; } #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; -#endif #endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) @@ -1670,10 +1668,8 @@ static ivas_error initOnFirstGoodFrame( ISAR_SPLIT_REND_CODEC splitRendCodec; int16_t splitRendCodecFrameSizeMs; ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t splitRendIsarFrameSizeMs; int16_t lc3plusHighRes; -#endif if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) { @@ -1684,14 +1680,10 @@ static ivas_error initOnFirstGoodFrame( if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS &splitRendIsarFrameSizeMs, -#endif &splitRendCodecFrameSizeMs -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , &lc3plusHighRes -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); @@ -1707,12 +1699,10 @@ static ivas_error initOnFirstGoodFrame( splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); @@ -1734,12 +1724,10 @@ static ivas_error initOnFirstGoodFrame( splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); @@ -1776,12 +1764,8 @@ static ivas_error initOnFirstGoodFrame( splitRendBitsZero.buf_len = 0; splitRendBitsZero.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; splitRendBitsZero.pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS splitRendBitsZero.codec_frame_size_ms = 0; splitRendBitsZero.isar_frame_size_ms = 20; -#else - splitRendBitsZero.codec_frame_size_ms = 20; -#endif if ( split_rend_write_bitstream_to_file( *splitRendWriter, splitRendBitsZero.bits_buf, &splitRendBitsZero.bits_read, &splitRendBitsZero.bits_written ) != IVAS_ERR_OK ) { diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index d9095054b..1e041c175 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -734,13 +734,9 @@ int main( bitsBuffer.config.bufLenInBytes = 0; bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS bitsBuffer.config.codec_frame_size_ms = 5; bitsBuffer.config.isar_frame_size_ms = 20; bitsBuffer.config.lc3plusHighRes = 0; -#else - bitsBuffer.config.codec_frame_size_ms = 20; -#endif CmdlnArgs args = parseCmdlnArgs( argc, argv ); @@ -764,9 +760,7 @@ int main( SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t inFileSampleRate = 0; -#endif strncpy( audioFilePath, args.inputFilePath, FILENAME_MAX - 1 ); hSplitRendFileReadWrite = NULL; if ( ( args.inConfig.numBinBuses > 0 ) && ( args.inConfig.binBuses[0].audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) @@ -776,12 +770,10 @@ int main( &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , &bitsBuffer.config.isar_frame_size_ms, &inFileSampleRate, &bitsBuffer.config.lc3plusHighRes -#endif ); if ( error != IVAS_ERR_OK ) { @@ -804,12 +796,10 @@ int main( &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , &bitsBuffer.config.isar_frame_size_ms, &inFileSampleRate, &bitsBuffer.config.lc3plusHighRes -#endif ); if ( error != IVAS_ERR_OK ) { @@ -819,17 +809,12 @@ int main( audioReader = NULL; } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - int32_t inFileSampleRate = 0; -#endif if ( audioReader != NULL ) { error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); } else -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( hSplitRendFileReadWrite == NULL ) -#endif { inFileSampleRate = args.sampleRate; } @@ -892,11 +877,9 @@ int main( bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , bitsBuffer.config.isar_frame_size_ms, bitsBuffer.config.lc3plusHighRes -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); diff --git a/apps/renderer.c b/apps/renderer.c index fa716c892..0d96f9dea 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -831,13 +831,9 @@ int main( bitsBuffer.config.bufLenInBytes = 0; bitsBuffer.config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; bitsBuffer.config.poseCorrection = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS bitsBuffer.config.codec_frame_size_ms = 5; bitsBuffer.config.isar_frame_size_ms = 20; bitsBuffer.config.lc3plus_highres = 0; -#else - bitsBuffer.config.codec_frame_size_ms = 20; -#endif #endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -1281,11 +1277,9 @@ int main( } #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5; -#endif #endif if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) @@ -1573,10 +1567,8 @@ int main( &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , &bitsBuffer.config.isar_frame_size_ms -#endif ); if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) @@ -1592,12 +1584,10 @@ int main( bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); @@ -1614,10 +1604,8 @@ int main( &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, &bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , &bitsBuffer.config.isar_frame_size_ms -#endif ); if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) @@ -1633,12 +1621,10 @@ int main( bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, bitsBuffer.config.codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , bitsBuffer.config.isar_frame_size_ms, args.sampleRate, bitsBuffer.config.lc3plus_highres -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index e1114a4f3..34facc703 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -276,10 +276,8 @@ typedef struct _ISAR_SPLIT_REND_BITS_DATA int16_t codec_frame_size_ms; ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; int16_t lc3plus_highres; -#endif } ISAR_SPLIT_REND_BITS_DATA, *ISAR_SPLIT_REND_BITS_HANDLE; @@ -295,16 +293,12 @@ typedef struct _ISAR_SPLIT_REND_CONFIG 3 - (3dof correction. By default YAW, PITCH and ROLL correction) */ int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ -#endif int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_RENDERER_SELECTION rendererSelection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t lc3plus_highres; -#endif } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; #endif diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 14c37a593..2f34e6709 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -99,10 +99,8 @@ typedef enum *----------------------------------------*/ IVAS_ERR_INVALID_BITSTREAM = 0x2000, #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM, IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM_CONFIG, -#endif #endif /*----------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 810fefcd4..e77c5a83b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,7 +105,6 @@ #define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #ifdef SPLIT_REND_WITH_HEAD_ROT -#define ISAR_BITSTREAM_UPDATE_LC3PLUS /* FhG: Multiple improvements to the ISAR bitstream when LC3plus is used. See MR 1456 for details. */ #define FIX_1372_ISAR_POST_REND #endif #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 6643ed423..8b0d171d5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -255,13 +255,8 @@ static ivas_error ivas_dec_init_split_rend( move16(); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); move16(); -#else - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, (int16_t) st_ivas->hDecoderConfig->render_framesize, mixed_td_cldfb_flag ); - move16(); -#endif return error; } #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index eca274491..d7a110a37 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -158,14 +158,10 @@ ivas_error IVAS_DEC_GetSplitRendBitstreamHeader( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ -#endif Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , Word16 *pLc3plusHighRes /* o: pointer to LC3plus High-Res setting */ -#endif ); /*! r: decoder error code */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9213b11ce..de939c5b0 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -296,10 +296,8 @@ static ivas_error isar_set_split_rend_setup( splitRendBits->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; splitRendBits->pose_correction = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE; splitRendBits->codec_frame_size_ms = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS splitRendBits->isar_frame_size_ms = 0; splitRendBits->lc3plus_highres = 0; -#endif if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) { @@ -1520,9 +1518,7 @@ IVAS_DEC_GetSplitBinauralBitstream( Quaternion, st_ivas->hRenderConfig->split_rend_config.splitRendBitRate, st_ivas->hRenderConfig->split_rend_config.codec, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms, -#endif st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms, splitRendBits, Cldfb_RealBuffer_Binaural, @@ -2653,18 +2649,14 @@ static ivas_error copyRendererConfigStruct( hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.codec_delay_ms = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hRCout->split_rend_config.isar_frame_size_ms = 20; move16(); -#endif hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hRCout->split_rend_config.lc3plus_highres = hRCin->split_rend_config.lc3plus_highres; move16(); -#endif move32(); move16(); move16(); @@ -4094,14 +4086,10 @@ IVAS_DEC_GetSplitRendBitstreamHeader( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ -#endif Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , Word16 *pLc3plusHighRes -#endif ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -4112,10 +4100,8 @@ IVAS_DEC_GetSplitRendBitstreamHeader( *pCodec = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec; *pCodec_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.codec_frame_size_ms; *poseCorrection = hIvasDec->st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS *pIsar_frame_size_ms = hIvasDec->st_ivas->hRenderConfig->split_rend_config.isar_frame_size_ms; *pLc3plusHighRes = hIvasDec->st_ivas->hRenderConfig->split_rend_config.lc3plus_highres; -#endif return IVAS_ERR_OK; } diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 7eae62357..ad6bf483a 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -136,9 +136,7 @@ typedef enum #define ISAR_SPLIT_REND_ROT_AXIS_BITS 3 #define ISAR_SPLIT_REND_RO_FLAG_BITS 1 -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #define IVAS_LC3PLUS_MAX_NUM_DECODERS 2 -#endif /*----------------------------------------------------------------------------------* * Split rendering bitrate constants *----------------------------------------------------------------------------------*/ diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 2e5a31cb6..6a4ef18ed 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -57,7 +57,6 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( return IVAS_ERR_INTERNAL; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ) { switch ( lc3PlusRtpError ) @@ -86,4 +85,3 @@ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtp return IVAS_ERR_UNKNOWN; } #endif -#endif diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 570609442..6042e8859 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -39,9 +39,7 @@ #include "ivas_error.h" #ifdef SPLIT_REND_WITH_HEAD_ROT #include "lc3.h" -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #include "isar_lc3plus_payload.h" -#endif /*! common configuration parameters between encoder and decoder */ typedef struct LC3PLUS_CONFIG @@ -54,19 +52,15 @@ typedef struct LC3PLUS_CONFIG int32_t samplerate; /*! number of channels */ int16_t channels; -#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS || defined ISAR_BITSTREAM_UPDATE_LC3PLUS /*! high resolution mode enabled (1) or disabled (0)*/ int16_t high_res_mode_enabled; -#endif } LC3PLUS_CONFIG; /*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ); -#endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_COM_H */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index fd1adb157..5a82dc13c 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -42,26 +42,6 @@ #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -/*------------------------------------------------------------------------- - * isar_LC3PLUS_AllocateSubframeDecodingMatrix() - * - * - *------------------------------------------------------------------------*/ - -static void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( - int16_t **subframeChannelMatrix ) -{ - for ( int16_t i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - free( subframeChannelMatrix[i] ); - } - - free( subframeChannelMatrix ); - - return; -} -#endif /*------------------------------------------------------------------------- @@ -78,37 +58,22 @@ ivas_error ISAR_LC3PLUS_DEC_Open( LC3PLUS_Error err; int32_t decoder_size; Word32 scratch_size; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t i; if ( 0 == config.lc3plus_frame_duration_us ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); } -#else - int16_t lc3plusFrameIdx; - int16_t numLC3plusFramesPerIvasFrame; - int16_t i; -#endif if ( ( *handle = malloc( sizeof( struct ISAR_LC3PLUS_DEC_HANDLE ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( config.channels > IVAS_LC3PLUS_MAX_NUM_DECODERS ) { return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "Maximum number of channels exceeds IVAS_LC3PLUS_MAX_NUM_DECODERS\n" ); } -#else - - if ( 0 == config.lc3plus_frame_duration_us ) - { - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); - } - numLC3plusFramesPerIvasFrame = (int16_t) ( config.isar_frame_duration_us / config.lc3plus_frame_duration_us ); -#endif ( *handle )->num_decs = 0; @@ -168,11 +133,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, config.high_res_mode_enabled ); -#else - err = lc3plus_dec_init( ( *handle )->handles[iCh], config.samplerate, 1, LC3PLUS_PLC_ADVANCED, 0 ); -#endif if ( LC3PLUS_OK != err ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -193,24 +154,10 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - if ( ( ( *handle )->selective_decoding_states[iCh]->frame_actions = malloc( numLC3plusFramesPerIvasFrame * sizeof( SelectiveDecAction ) ) ) == NULL ) - { - ISAR_LC3PLUS_DEC_Close( handle ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); - } -#endif ( *handle )->selective_decoding_states[iCh]->has_skipped_a_frame = 0; ( *handle )->selective_decoding_states[iCh]->shall_decode_cached_frame = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->selective_decoding_states[iCh]->frame_action = DEC_ACTION_DECODE_AND_USE; -#else - for ( lc3plusFrameIdx = 0; lc3plusFrameIdx < numLC3plusFramesPerIvasFrame; lc3plusFrameIdx++ ) - { - ( *handle )->selective_decoding_states[iCh]->frame_actions[lc3plusFrameIdx] = DEC_ACTION_DECODE_AND_USE; - } -#endif /* allocate and configure per LC3plus decoder bitstream cache */ if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( ISAR_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) @@ -218,11 +165,7 @@ ivas_error ISAR_LC3PLUS_DEC_Open( ISAR_LC3PLUS_DEC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/; -#else - ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; -#endif if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) { ISAR_LC3PLUS_DEC_Close( handle ); @@ -254,155 +197,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( return IVAS_ERR_OK; } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -/*------------------------------------------------------------------------- - * ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix() - * - * - *------------------------------------------------------------------------*/ - -ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( - int16_t ***subframeChannelMatrix, - const uint32_t num_decs ) -{ - int16_t i; - - if ( ( *subframeChannelMatrix = malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t * ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); - } - - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - ( *subframeChannelMatrix )[i] = NULL; - } - - for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - if ( ( ( *subframeChannelMatrix )[i] = malloc( num_decs * sizeof( int16_t ) ) ) == NULL ) - { - isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( *subframeChannelMatrix ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "subframeChannelMatrix allocation failed\n" ); - } - } - - return IVAS_ERR_OK; -} - - -/*------------------------------------------------------------------------- - * ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix() - * - * - *------------------------------------------------------------------------*/ - -ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( - ISAR_LC3PLUS_DEC_HANDLE handle, /* i : LC3plus decoder handle */ - int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] ) -{ - int16_t numIvasSubFramesPerLC3frame; - uint32_t decIdx; - int16_t ivasSubframeIdx; - int16_t effectiveIsarSubframeDuration; - int16_t actual_num_spatial_subframes; - - if ( NULL == handle ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "ISAR_LC3PLUS_DEC_HANDLE is NULL\n" ); - } - - if ( NULL == subframeChannelMatrix ) - { - return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "subframeChannelMatrix is NULL\n" ); - } - - if ( handle->config.lc3plus_frame_duration_us == 0 || handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) - { - return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "invalid isar_frame_duration_us/lc3plus_frame_duration_us values\n" ); - } - - effectiveIsarSubframeDuration = (int16_t) ( handle->config.isar_frame_duration_us == 20000 ? handle->config.isar_frame_duration_us / MAX_PARAM_SPATIAL_SUBFRAMES : handle->config.isar_frame_duration_us ); - numIvasSubFramesPerLC3frame = (int16_t) handle->config.lc3plus_frame_duration_us / effectiveIsarSubframeDuration; - actual_num_spatial_subframes = (int16_t) handle->config.isar_frame_duration_us / effectiveIsarSubframeDuration; - /* 0.5(0) = 10ms lc3plus, 5ms subframe */ - if ( numIvasSubFramesPerLC3frame != 1 ) - { - return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Selective decoding is only implemented for aligned IVAS-Subframes & LC3plus \n" ); - } - - /* map subframeChannelMatrix to lc3plus skip states */ - /* 1st pass: Flag the required frames */ - for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) - { - for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) - { - if ( 1 == subframeChannelMatrix[ivasSubframeIdx][decIdx] ) - { - /* subframe needed by the user, definitely decode */ - handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_USE; - } - else - { - - /* subframe not needed by the user, but might be required to re-initialize a decoder after inactivity */ - if ( - ( ivasSubframeIdx != actual_num_spatial_subframes - 1 ) && 1 == subframeChannelMatrix[ivasSubframeIdx + 1][decIdx] ) - { - /* ... but if the following subframe is required, it needs to be decoded and dropped */ - handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_DECODE_AND_DROP; - } - else - { - handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] = DEC_ACTION_SKIP; - } - } - } - } - - /* if a decoder was paused before, it needs to either: - * - Decode the cached frame (if available) and the first required frame OR - * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ - for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) - { - if ( handle->selective_decoding_states[decIdx]->has_skipped_a_frame ) - { - /* find the first frame required by the user */ - for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) - { - if ( DEC_ACTION_DECODE_AND_USE == handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] ) - { - /* The first required frame is the first subframe. To flush the decoder, the cached frame must be decoded and dropped */ - if ( 0 == ivasSubframeIdx ) - { - handle->selective_decoding_states[decIdx]->shall_decode_cached_frame = 1; - break; - } - /* The first required frame is not the first frame, so the cache is useless. Instead we decode & drop the previous frame*/ - else - { - handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx - 1] = DEC_ACTION_DECODE_AND_DROP; - break; - } - } - } - } - } - - /* if a dec gets paused & caching is activated we need to flag the last useful LC3plus frame for caching */ - for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) - { - for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) - { - if ( handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] == DEC_ACTION_SKIP && handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] != DEC_ACTION_DECODE_AND_USE ) - { - handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] = DEC_ACTION_CACHE; - } - } - } - - return IVAS_ERR_OK; -} -#endif /*------------------------------------------------------------------------- @@ -472,9 +266,6 @@ void ISAR_LC3PLUS_DEC_Close( if ( NULL != ( *handle )->selective_decoding_states && NULL != ( *handle )->selective_decoding_states[iDec] ) { -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - free( ( *handle )->selective_decoding_states[iDec]->frame_actions ); -#endif free( ( *handle )->selective_decoding_states[iDec] ); } @@ -559,17 +350,10 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( ) { uint32_t iDec; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t config_num_media_times; int32_t iMediaTime; int32_t iFtd; LC3PLUS_RTP_PAYLOAD payload; -#else - int32_t iLc3plusFrame; - int32_t lc3framesPerIvasFrame; - int32_t bitstreamOffsetPerCoder; - uint8_t *bitstream_in_iter = bitstream_in; -#endif int32_t ivasSampleIndex; int16_t numSamplesPerLC3plusChannel; ivas_error err; @@ -600,7 +384,6 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config_num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; if ( !badFrameIndicator ) { @@ -629,25 +412,13 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "LC3plus config change (number of media times per frame data block) in bitstream is not supported\n" ); } } -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / config_num_media_times ); for ( iDec = 0; iDec < handle->num_decs; iDec++ ) { for ( iMediaTime = 0; iMediaTime < config_num_media_times; iMediaTime++ ) { iFtd = iDec + iMediaTime * handle->num_decs; -#else - lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; - - numSamplesPerLC3plusChannel = (int16_t) ( handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame ); - bitstreamOffsetPerCoder = bitstream_in_size / handle->num_decs / lc3framesPerIvasFrame; - for ( iDec = 0; iDec < handle->num_decs; iDec++ ) - { - for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) - { -#endif if ( handle->selective_decoding_states[iDec]->shall_decode_cached_frame ) { if ( 0 == handle->bitstream_caches[iDec]->bitstream_cache_size ) @@ -670,27 +441,10 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle->bitstream_caches[iDec]->bitstream_cache_size = 0; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS switch ( handle->selective_decoding_states[iDec]->frame_action ) -#else - switch ( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] ) -#endif { -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - case DEC_ACTION_DECODE_AND_DROP: - { - err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); - if ( err != IVAS_ERR_OK ) - { - return IVAS_ERROR( err, "lc3plus decoding failed\n" ); - } - handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; - break; - } -#endif case DEC_ACTION_DECODE_AND_USE: { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( badFrameIndicator ) { err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in, bitstream_in_size, &handle->pcm_conversion_buffer, badFrameIndicator, handle->scratch ); @@ -717,33 +471,9 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( } handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; break; -#else - err = decode_or_conceal_one_lc3plus_frame( handle->handles[iDec], bitstream_in_iter, bitstreamOffsetPerCoder, &handle->pcm_conversion_buffer, badFrameIndicator ); - if ( err != IVAS_ERR_OK ) - { - return IVAS_ERROR( err, "lc3plus decoding failed\n" ); - } - - for ( int32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) - { - ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; - pcm_out[iDec][ivasSampleIndex] = handle->pcm_conversion_buffer[iSampleInt16]; - } - handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; - break; -#endif - } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - case DEC_ACTION_SKIP: - { - /* log that this instance has skipped a frame and must decode twice once reactivated */ - handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; - break; } -#endif case DEC_ACTION_CACHE: { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < (int32_t) payload.ftds[iFtd].frame_data_length ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); @@ -754,41 +484,15 @@ static ivas_error isar_LC3PLUS_DEC_Decode_or_Conceal_internal( /* log that this instance has skipped a frame and must decode twice once reactivated */ handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; break; -#else - if ( handle->bitstream_caches[iDec]->bitstream_cache_capacity < bitstreamOffsetPerCoder ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "bitstream_cache_capacity is too low for LC3plus frame size\n" ); - } - /* store bit rate of cached frame */ - mvc2c( bitstream_in_iter, handle->bitstream_caches[iDec]->bitstream_cache, (int16_t) bitstreamOffsetPerCoder ); - handle->bitstream_caches[iDec]->bitstream_cache_size = bitstreamOffsetPerCoder; - /* log that this instance has skipped a frame and must decode twice once reactivated */ - handle->selective_decoding_states[iDec]->has_skipped_a_frame = 1; - break; -#endif } case DEC_ACTION_NUM_ENUMS: default: return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "invalid LC3plus decoder state\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS } /* for each media time */ /* reset skipping state, must be set by the user before each decode call*/ handle->selective_decoding_states[iDec]->frame_action = DEC_ACTION_DECODE_AND_USE; } /* for each dec/channel */ -#else - - bitstream_in_iter += bitstreamOffsetPerCoder; - } - - /* reset skipping state, must be set by the user before each decode call*/ - for ( iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) - { - handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] = DEC_ACTION_DECODE_AND_USE; - } - } - -#endif return IVAS_ERR_OK; } diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index 5e297a407..f946a6402 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -44,13 +44,7 @@ typedef enum { -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - DEC_ACTION_DECODE_AND_DROP = 0, -#endif DEC_ACTION_DECODE_AND_USE, -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - DEC_ACTION_SKIP, -#endif DEC_ACTION_CACHE, DEC_ACTION_NUM_ENUMS } SelectiveDecAction; @@ -60,13 +54,8 @@ typedef struct ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE { /*! indicates that the decoder has skipped one or more frames. This means it must decode two frames to flush algorithmic delay when re-activated */ int16_t has_skipped_a_frame; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /*! action to execute for the next frame */ SelectiveDecAction frame_action; -#else - /*! if set to 1, decoder will skip decoding for the next frame */ - SelectiveDecAction *frame_actions; -#endif /*! if set to 1, decoder will decode the cache before decoding any of current frames */ int16_t shall_decode_cached_frame; } ISAR_LC3PLUS_DEC_SELECTIVE_DECODING_STATE; @@ -104,13 +93,6 @@ void ISAR_LC3PLUS_DEC_Close( ISAR_LC3PLUS_DEC_HANDLE *handle /* i/o: pointer to decoder handle */ ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -/*! Sets a matrix[MAX_PARAM_SPATIAL_SUBFRAMES][numLC3plusDecoders] where all require subframes must be flagged with 1, frames that are not required with 0 */ -ivas_error ISAR_LC3PLUS_DEC_SetSelectiveDecodingMatrix( - ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ - int16_t *subframeChannelMatrix[MAX_PARAM_SPATIAL_SUBFRAMES] /* i : */ -); -#endif ivas_error ISAR_LC3PLUS_DEC_Decode( ISAR_LC3PLUS_DEC_HANDLE handle, /* i : decoder handle */ @@ -124,13 +106,6 @@ ivas_error ISAR_LC3PLUS_DEC_Conceal( Word32 **pcm_out /* o : decoded samples */ ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -ivas_error ISAR_LC3PLUS_DEC_AllocateSubframeDecodingMatrix( - int16_t ***subframeChannelMatrix, - const uint32_t num_decs ); - -void isar_LC3PLUS_DEC_FreeSubframeDecodingMatrix( int16_t **subframeChannelMatrix ); -#endif #endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_DEC_H */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 08ec7c0a8..1de448423 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -38,11 +38,8 @@ #include "wmc_auto.h" #include "options.h" -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static const LC3PLUS_RTP_FDL s_fdl_request = LC3PLUS_RTP_FDL_NO_REQ_OR_NO_DATA; -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, int32_t per_channel_bitrate ) { @@ -79,7 +76,6 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, assert( false && "unreachable" ); return -1; } -#endif #ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* @@ -93,19 +89,9 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ISAR_LC3PLUS_ENC_HANDLE *handle /* o : encoder handle */ ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t num_lc3plus_media_times_per_ivas_frame; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - int32_t lc3plus_num_bytes_per_frame; -#endif bool is_last_media_time, is_last_channel; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error ivas_err; -#endif -#endif -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - int32_t bitsPerSecondPerChannel; -#endif Word32 scratch_size; int32_t encoder_size; LC3PLUS_Error err; @@ -118,10 +104,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid number of channels\n" ); } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - bitsPerSecondPerChannel = bitsPerSecond / config.channels; -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( config.lc3plus_frame_duration_us != 2500 && config.lc3plus_frame_duration_us != 5000 && config.lc3plus_frame_duration_us != 10000 ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid lc3plus_frame_duration_us\n" ); @@ -130,7 +112,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "Invalid isar_frame_duration_us\n" ); } -#endif encoder_size = lc3plus_enc_get_size( config.samplerate, 1 ); if ( 0 == encoder_size ) { @@ -141,10 +122,8 @@ ivas_error ISAR_LC3PLUS_ENC_Open( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->config = config; ( *handle )->frame_type_descriptors = NULL; -#endif ( *handle )->pcm_conversion_buffer = NULL; ( *handle )->scratch = NULL; @@ -160,7 +139,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ( *handle )->handles[i] = NULL; } ( *handle )->num_encs = config.channels; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_lc3plus_media_times_per_ivas_frame = config.isar_frame_duration_us / config.lc3plus_frame_duration_us; ( *handle )->fdl_request = s_fdl_request; ( *handle )->num_ftds = config.channels * num_lc3plus_media_times_per_ivas_frame; @@ -170,7 +148,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ISAR_LC3PLUS_ENC_Close( handle ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus frame_type_descriptors\n" ); } -#endif for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) { @@ -180,11 +157,7 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, config.high_res_mode_enabled, lfeChans ); -#else - err = lc3plus_enc_init( ( *handle )->handles[iCh], config.samplerate, 1, 0, lfeChans ); -#endif if ( err != LC3PLUS_OK ) { ISAR_LC3PLUS_ENC_Close( handle ); @@ -197,14 +170,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( ISAR_LC3PLUS_ENC_Close( handle ); return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_frame_dms failed\n" ); } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - err = lc3plus_enc_set_bitrate( ( *handle )->handles[iCh], bitsPerSecondPerChannel ); - if ( err != LC3PLUS_OK ) - { - ISAR_LC3PLUS_ENC_Close( handle ); - return IVAS_ERROR( ISAR_LC3PLUS_LC3plusErrToIvasErr( err ), "lc3plus_enc_set_bitrate failed\n" ); - } -#endif } if ( config.isar_frame_duration_us < config.lc3plus_frame_duration_us || config.isar_frame_duration_us % config.lc3plus_frame_duration_us != 0 ) @@ -213,9 +178,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Current pcm_conversion_buffer sizing requires that lc3plus uses a shorter or equal frame duration than ivas\n" ); } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - ( *handle )->config = config; -#endif ( *handle )->pcm_conversion_buffer = malloc( sizeof( int16_t ) * config.samplerate * config.lc3plus_frame_duration_us / 1000000 ); if ( NULL == ( *handle )->pcm_conversion_buffer ) { @@ -223,24 +185,13 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus encoder wrapper pcm_conversion_buffer\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* update FDI fields */ for ( int32_t iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) { for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; ++iEnc ) { int32_t ftd_index = iEnc + iMediaTime * ( *handle )->num_encs; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = 0; /* will be set to the correct value in IVAS_LC3PLUS_ENC_SetBitrate */ -#else - lc3plus_num_bytes_per_frame = lc3plus_enc_get_num_bytes( ( *handle )->handles[iEnc] ); - if ( lc3plus_num_bytes_per_frame <= 0 ) - { - ISAR_LC3PLUS_ENC_Close( handle ); - return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc_get_num_bytes reported invalid result failed\n" ); - } - ( *handle )->frame_type_descriptors[ftd_index].frame_data_length = lc3plus_num_bytes_per_frame; -#endif if ( 0 != LC3PLUS_RTP_ftd_bwr_from_samplerate( &( *handle )->frame_type_descriptors[ftd_index].bwr, config.samplerate, config.high_res_mode_enabled ) ) { ISAR_LC3PLUS_ENC_Close( handle ); @@ -277,15 +228,12 @@ ivas_error ISAR_LC3PLUS_ENC_Open( } } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_err = IVAS_LC3PLUS_ENC_SetBitrate( *handle, bitsPerSecond ); if ( ivas_err != IVAS_ERR_OK ) { ISAR_LC3PLUS_ENC_Close( handle ); return ivas_err; } -#endif -#endif scratch_size = lc3plus_enc_get_scratch_size( ( *handle )->handles[0] ); ( *handle )->scratch = malloc( sizeof( uint8_t ) * scratch_size ); IF( NULL == ( *handle )->scratch ) @@ -297,7 +245,6 @@ ivas_error ISAR_LC3PLUS_ENC_Open( return IVAS_ERR_OK; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /*-------------------------------------------------------------------* * Function IVAS_LC3PLUS_ENC_SetBitrate() * @@ -340,12 +287,10 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } minPayloadOverhead = fdrLength + ( numSubframes * LC3PLUS_RTP_FTD_MIN_SIZE ); targetLc3PlusBitratePerChannel = ( availableOctetsPerIsarFrame - minPayloadOverhead ) / handle->config.channels * 8 * lc3plusPacketRate / numLc3plusMediaTimesPerIvasFrame; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( targetLc3PlusBitratePerChannel <= 0 ) { return IVAS_ERROR( IVAS_ERR_LC3PLUS_INVALID_BITRATE, "available LC3plus bitrate <= 0\n" ); } -#endif targetLc3PlusBitratePerChannel = limit_per_channel_bitrate( handle->config, targetLc3PlusBitratePerChannel ); targetLc3PlusOctetCount = targetLc3PlusBitratePerChannel / 8 / lc3plusPacketRate; /* check resulting octet count. If it requires larger than 1-byte length fields, decrease the bitrate by enough to make room for the additional length field */ @@ -394,7 +339,6 @@ ivas_error IVAS_LC3PLUS_ENC_SetBitrate( } return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* @@ -451,15 +395,11 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( Word32 *bsSize /* o : size of each bitstream frame in bytes */ ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_RTP_ERR rtp_err; int32_t num_lc3plus_media_times_per_ivas_frame; int32_t iMediaTime; int32_t ftd_frame_data_length_size, lc3plus_frame_data_length; int32_t ftd_index; -#else - int32_t bitstreamSizeMultiplier; -#endif if ( NULL == handle ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3PLUS_Enc_Wrap_Handle is NULL\n" ); @@ -469,7 +409,6 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "bsSize is NULL\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( 0 == handle->config.lc3plus_frame_duration_us ) { return IVAS_ERROR( IVAS_ERR_INIT_ERROR, "lc3plus_frame_duration_us is 0\n" ); @@ -480,9 +419,7 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( } num_lc3plus_media_times_per_ivas_frame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; -#endif *bsSize = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t fdl_request_length; rtp_err = LC3PLUS_RTP_frame_data_length_get_size( &fdl_request_length, handle->fdl_request ); if ( rtp_err != LC3PLUS_RTP_ERR_NO_ERROR ) @@ -490,14 +427,12 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid LC3plus frame_data_length request\n" ); } *bsSize += fdl_request_length; -#endif for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) { if ( NULL == handle->handles[iEnc] ) { return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "LC3plus encoder handle is NULL\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS lc3plus_frame_data_length = lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); for ( iMediaTime = 0; iMediaTime < num_lc3plus_media_times_per_ivas_frame; ++iMediaTime ) { @@ -516,18 +451,6 @@ ivas_error ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( *bsSize += ftd_frame_data_length_size; } } -#else - *bsSize += lc3plus_enc_get_num_bytes( handle->handles[iEnc] ); - } - - if ( handle->config.isar_frame_duration_us % handle->config.lc3plus_frame_duration_us != 0 ) - { - return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); - } - bitstreamSizeMultiplier = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; - - *bsSize *= bitstreamSizeMultiplier; -#endif return IVAS_ERR_OK; } @@ -547,12 +470,10 @@ void ISAR_LC3PLUS_ENC_Close( { return; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( NULL != ( *handle )->frame_type_descriptors ) { free( ( *handle )->frame_type_descriptors ); } -#endif for ( uint32_t iEnc = 0; iEnc < ( *handle )->num_encs; iEnc++ ) { if ( NULL != ( *handle )->handles[iEnc] ) @@ -587,22 +508,13 @@ void ISAR_LC3PLUS_ENC_Close( ivas_error ISAR_LC3PLUS_ENC_Encode( ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ Word32 **pcm_in, /* i : pointer input samples */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS void *bitstream_out, /* o : pointer to bitstream frame */ const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ -#else - void *bitstream_out /* o : pointer to bitstream frame */ -#endif Word16 q_in[16] ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t ftdIndex; LC3PLUS_RTP_ERR rtpErr; uint32_t num_media_times; -#else - uint32_t lc3framesPerIvasFrame; - uint8_t *bitstream_out_iter = bitstream_out; -#endif uint32_t numSamplesPerLC3plusChannel; int32_t ivasSampleIndex; int32_t num_bytes = 0; @@ -627,7 +539,6 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( { return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "isar_frame_duration_us must be equal or multiple of lc3plus_frame_duration_us \n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS num_media_times = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / num_media_times; @@ -637,39 +548,20 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( { return IVAS_ERROR( IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( rtpErr ), "LC3PLUS_RTP_payload_serialize failed\n" ); } -#else - lc3framesPerIvasFrame = handle->config.isar_frame_duration_us / handle->config.lc3plus_frame_duration_us; - - numSamplesPerLC3plusChannel = handle->config.samplerate / ( 1000000 / handle->config.isar_frame_duration_us ) / lc3framesPerIvasFrame; -#endif for ( uint32_t iEnc = 0; iEnc < handle->num_encs; iEnc++ ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS for ( uint32_t iMediaTime = 0; iMediaTime < num_media_times; iMediaTime++ ) -#else - for ( uint32_t iLc3plusFrame = 0; iLc3plusFrame < lc3framesPerIvasFrame; iLc3plusFrame++ ) -#endif { for ( uint32_t iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; -#else - ivasSampleIndex = iSampleInt16 + iLc3plusFrame * numSamplesPerLC3plusChannel; -#endif handle->pcm_conversion_buffer[iSampleInt16] = (Word16) max( INT16_MIN, min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ftdIndex = iMediaTime * handle->num_encs + iEnc; -#endif num_bytes = 0; push_wmops( "lc3plus_enc16" ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, handle->frame_type_descriptors[ftdIndex].frame_data, &num_bytes, handle->scratch ); -#else - err = lc3plus_enc16( handle->handles[iEnc], &handle->pcm_conversion_buffer, bitstream_out_iter, &num_bytes, NULL ); -#endif pop_wmops(); if ( err != LC3PLUS_OK ) { @@ -679,15 +571,10 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( { return IVAS_ERROR( IVAS_ERR_INTERNAL, "lc3plus_enc16 did not produce output\n" ); } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( num_bytes != (int32_t) handle->frame_type_descriptors[ftdIndex].frame_data_length ) { return IVAS_ERROR( IVAS_ERR_INTERNAL, "payload format and lc3plus enc bitrate are not aligned\n" ); } -#else - - bitstream_out_iter += num_bytes; -#endif } } diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index 6d0f47030..5487f712c 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -39,9 +39,7 @@ #include "lc3.h" #include "isar_lc3plus_common.h" #include "typedef.h" -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS #include "isar_lc3plus_payload.h" -#endif /* encoder wrapper */ typedef struct ISAR_LC3PLUS_ENC_HANDLE @@ -50,30 +48,22 @@ typedef struct ISAR_LC3PLUS_ENC_HANDLE LC3PLUS_Enc **handles; uint32_t num_encs; int16_t *pcm_conversion_buffer; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS LC3PLUS_RTP_FTD *frame_type_descriptors; int32_t num_ftds; LC3PLUS_RTP_FDL fdl_request; -#endif uint8_t *scratch; } * ISAR_LC3PLUS_ENC_HANDLE; ivas_error ISAR_LC3PLUS_ENC_Open( const LC3PLUS_CONFIG config, /* i : encoder configuration */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const uint32_t initialBitsPerSecond, /* i : initial target bit rate */ -#else - const uint32_t bitsPerSecond, /* i : bit rate */ -#endif ISAR_LC3PLUS_ENC_HANDLE *handle /* o : LC3plus encoder handle */ ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error IVAS_LC3PLUS_ENC_SetBitrate( ISAR_LC3PLUS_ENC_HANDLE handle, /* o : LC3plus encoder handle */ const uint32_t bitsPerSecond /* i : new target bit rate */ ); -#endif ivas_error ISAR_LC3PLUS_ENC_GetDelay( ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ @@ -92,12 +82,8 @@ void ISAR_LC3PLUS_ENC_Close( ivas_error ISAR_LC3PLUS_ENC_Encode( ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ Word32 **pcm_in, /* i : pointer input samples */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS void *bitstream_out, /* o : pointer to bitstream frame */ const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ -#else - void *bitstream_out /* o : pointer to bitstream frame */ -#endif Word16 q_in[16] ); #endif diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index cd053978d..54895c78b 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -37,7 +37,6 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) { if ( NULL == frame_duration_us ) @@ -819,5 +818,4 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } -#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ #endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h index c225c9159..0eadc96a8 100644 --- a/lib_isar/isar_lc3plus_payload.h +++ b/lib_isar/isar_lc3plus_payload.h @@ -39,7 +39,6 @@ #include "options.h" #ifdef SPLIT_REND_WITH_HEAD_ROT -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Implementation of the "B.2.6 Table of contents" part of the RTP payload format * for LC3plus as specified in ETSI TS 103 634. */ @@ -211,6 +210,5 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( uint8_t *serialized_buffer, const size_t serialized_buffer_size ); -#endif /* ISAR_BITSTREAM_UPDATE_LC3PLUS */ #endif /* #ifdef SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_PAYLOAD_H */ diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index b97b81bbc..6860dda91 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -321,12 +321,6 @@ void isar_set_split_rend_ht_setup_fx( Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -Word32 isar_get_lc3plus_bitrate( - const Word32 SplitRendBitRate, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word16 split_prerender_frame_size_ms ); -#endif ivas_error isar_split_rend_validate_config( const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, @@ -336,37 +330,25 @@ Word32 isar_get_lcld_bitrate( const Word32 SplitRendBitRate, const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -Word8 isar_get_lc3plus_bitrate_id( - const Word32 SplitRendBitRate ); -#endif ivas_error splitRendLc3plusEncodeAndWrite( SPLIT_REND_WRAPPER *hSplitBin, ISAR_SPLIT_REND_BITS_HANDLE pBits, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const int32_t available_bits, -#else - const int32_t SplitRendBitRate, -#endif Word32 *in[], Word16 Q_sig ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error isar_framesize_to_ms( const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ Word16 *ms /* o : frame size in ms */ ); -#endif Word32 isar_get_split_rend_md_target_brate( const Word32 SplitRendBitRate, const Word16 pcm_out_flag ); ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS Word16 *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ -#endif Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ @@ -385,12 +367,6 @@ Word16 wrap_a( Word16 val, const Word16 min_val, const Word16 max_val ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -Word32 isar_get_lc3plus_size_from_id( - const Word8 SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word16 split_prerender_frame_size_ms ); -#endif void isar_renderSplitUpdateNoCorrectionPoseData( const ISAR_SPLIT_REND_CONFIG_DATA *pSplit_rend_config, @@ -404,11 +380,7 @@ ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const Word32 OutSampleRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const IVAS_RENDER_FRAMESIZE ivas_frame_size -#else - const int16_t num_subframes -#endif ); ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( @@ -421,9 +393,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( SPLIT_REND_WRAPPER *hSplitBin, const IVAS_QUATERNION headPosition, const Word32 SplitRendBitRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const Word16 isar_frame_size_ms, -#endif const Word16 codec_frame_size_ms, ISAR_SPLIT_REND_BITS_HANDLE pBits, const Word16 max_bands, diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index e5454e852..9b4e470cf 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -2679,51 +2679,32 @@ ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const Word32 OutSampleRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const IVAS_RENDER_FRAMESIZE isar_frame_size -#else - const int16_t num_subframes -#endif ) { ivas_error error; Word16 i, delayBufferLength; LC3PLUS_CONFIG config; -#if defined ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; if ( ( error = isar_framesize_to_ms( isar_frame_size, &isar_frame_size_ms ) ) != IVAS_ERR_OK ) { return error; } -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Check configuration validity */ if ( isar_frame_size_ms < pSplitRendConfig->codec_frame_size_ms ) { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "SR codec frame doesn't fit in one output frame" ); } -#endif config.lc3plus_frame_duration_us = pSplitRendConfig->codec_frame_size_ms * 1000; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - config.ivas_frame_duration_us = ( pSplitRendConfig->dof == 0 ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; -#endif config.samplerate = OutSampleRate; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config.isar_frame_duration_us = isar_frame_size_ms * 1000; -#endif -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config.high_res_mode_enabled = ( pSplitRendConfig->lc3plus_highres != 0 ); -#endif config.channels = BINAURAL_CHANNELS; if ( ( error = ISAR_LC3PLUS_ENC_Open( config, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode ), -#else - isar_get_lc3plus_bitrate( pSplitRendConfig->splitRendBitRate, pSplitRendConfig->poseCorrectionMode, (int16_t) ( config.isar_frame_duration_us / 1000 ) ), -#endif &hSplitRendWrapper->hLc3plusEnc ) ) != IVAS_ERR_OK ) { return error; @@ -2781,13 +2762,7 @@ ivas_error split_renderer_open_lc3plus( ivas_error splitRendLc3plusEncodeAndWrite( SPLIT_REND_WRAPPER *hSplitBin, ISAR_SPLIT_REND_BITS_HANDLE pBits, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const int32_t available_bits, -#endif -#else - const int32_t SplitRendBitRate, -#endif Word32 *in[], Word16 Q_sig ) { @@ -2809,29 +2784,20 @@ ivas_error splitRendLc3plusEncodeAndWrite( channel_ptrs[i] = in[i]; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( ( error = IVAS_LC3PLUS_ENC_SetBitrate( hSplitBin->hLc3plusEnc, available_bits * FRAMES_PER_SEC ) ) != IVAS_ERR_OK ) { return error; } -#endif if ( ( error = ISAR_LC3PLUS_ENC_GetOutputBitstreamSize( hSplitBin->hLc3plusEnc, &lc3plusBitstreamSize ) ) != IVAS_ERR_OK ) { return error; } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - ISAR_SPLIT_REND_BITStream_write_int32( pBits, isar_get_lc3plus_bitrate_id( SplitRendBitRate ), 8 ); -#endif /* Write bitstream */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS set16_fx( Q_in, Q_sig, 16 ); move16(); if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8], lc3plusBitstreamSize, Q_in ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ISAR_LC3PLUS_ENC_Encode( hSplitBin->hLc3plusEnc, channel_ptrs, &pBits->bits_buf[pBits->bits_written / 8] ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -2840,9 +2806,7 @@ ivas_error splitRendLc3plusEncodeAndWrite( pBits->codec = ISAR_SPLIT_REND_CODEC_LC3PLUS; pBits->pose_correction = hSplitBin->multiBinPoseData.poseCorrectionMode; pBits->codec_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.lc3plus_frame_duration_us / 1000 ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS pBits->isar_frame_size_ms = (int16_t) ( hSplitBin->hLc3plusEnc->config.isar_frame_duration_us / 1000 ); -#endif return IVAS_ERR_OK; } @@ -2856,9 +2820,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( SPLIT_REND_WRAPPER *hSplitBin, const IVAS_QUATERNION headPosition, const Word32 SplitRendBitRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const int16_t isar_frame_size_ms, -#endif const Word16 codec_frame_size_ms, ISAR_SPLIT_REND_BITS_HANDLE pBits, const Word16 max_bands, @@ -2870,11 +2832,7 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( const Word16 ro_md_flag ) { ivas_error error; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t bit_len, available_bits, target_md_bits, tmp_32; -#else - Word32 bit_len, available_bits, target_md_bits, actual_md_bits, tmp_32; -#endif Word16 num_cldfb_bands, ch, slot_idx, pos_idx, num_poses; Word16 tmp, tmp_e; Word32 Cldfb_In_BinReal_fx[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] = { 0 }; @@ -2920,10 +2878,6 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( } } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - actual_md_bits = pBits->bits_written; - move32(); -#endif test(); test(); @@ -2997,9 +2951,6 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( tmp_32 = BASOP_Util_Divide3232_Scale_cadence( target_md_bits, 48000, &tmp_e ); target_md_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - actual_md_bits = pBits->bits_written; -#endif /*scaling to max Q*/ Word16 scale_factor = 31; move32(); @@ -3037,34 +2988,20 @@ ivas_error isar_renderMultiTDBinToSplitBinaural( tmp_e = 0; tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = L_sub( available_bits, pBits->bits_written ); -#else - actual_md_bits = L_sub( pBits->bits_written, actual_md_bits ); - available_bits = L_sub( available_bits, actual_md_bits ); -#endif pBits->codec_frame_size_ms = codec_frame_size_ms; move16(); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS pBits->isar_frame_size_ms = isar_frame_size_ms; move16(); -#endif isar_splitBinLCLDEncProcess( hSplitBin->hSplitBinLCLDEnc, Cldfb_In_BinReal_fx, Cldfb_In_BinImag_fx, available_bits, pBits, &q_final ); } ELSE { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, in_fx, Q_in ) ) != IVAS_ERR_OK ) { return error; } -#else - IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, in_flt ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif } } ELSE diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index daa4c1806..e8866f421 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -738,135 +738,6 @@ Word32 isar_get_lcld_bitrate( return -1; } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS -/*------------------------------------------------------------------------- - * Function isar_get_lc3plus_bitrate() - * - * - *------------------------------------------------------------------------*/ - -Word32 isar_get_lc3plus_bitrate( - const Word32 SplitRendBitRate, - ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word16 split_prerender_frame_size_ms ) -{ - IF( EQ_32( poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) - { - Word32 inBandMdBps = (Word32) ( 8 * 1000 / split_prerender_frame_size_ms ); - return L_sub( isar_get_lcld_bitrate( SplitRendBitRate, poseCorrectionMode ), inBandMdBps ); - } - - IF( EQ_32( poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) - { - return SplitRendBitRate; - } - - /* Should not be reached */ - assert( 0 ); - return -1; -} - - -/*------------------------------------------------------------------------- - * Function isar_get_lc3plus_bitrate_id() - * - * - *------------------------------------------------------------------------*/ - -Word8 isar_get_lc3plus_bitrate_id( - const Word32 SplitRendBitRate ) -{ - SWITCH( SplitRendBitRate ) - { - case SPLIT_REND_768k: - { - return 4; - } - case SPLIT_REND_512k: - { - return 3; - } - case SPLIT_REND_384k: - { - return 2; - } - case SPLIT_REND_320k: - { - return 1; - } - case SPLIT_REND_256k: - { - return 0; - } - default: - { - BREAK; - } - } - - return -1; -} - - -/*------------------------------------------------------------------------- - * Function ivas_mat_mult_2by2_complex() - * - * - *------------------------------------------------------------------------*/ - -Word32 isar_get_lc3plus_size_from_id( - const Word8 SplitRendBitRateId, - const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode, - const Word16 split_prerender_frame_size_ms ) -{ - Word32 bitrate; - - SWITCH( SplitRendBitRateId ) - { - case 4: - { - bitrate = SPLIT_REND_768k; - move32(); - BREAK; - } - case 3: - { - bitrate = SPLIT_REND_512k; - move32(); - BREAK; - } - case 2: - { - bitrate = SPLIT_REND_384k; - move32(); - BREAK; - } - case 1: - { - bitrate = SPLIT_REND_320k; - move32(); - BREAK; - } - case 0: - { - bitrate = SPLIT_REND_256k; - move32(); - BREAK; - } - default: - { - bitrate = -1; - move32(); - BREAK; - } - } - - bitrate = isar_get_lc3plus_bitrate( bitrate, poseCorrectionMode, split_prerender_frame_size_ms ); - - /* Return size in bytes */ - return (Word32) ( bitrate * split_prerender_frame_size_ms / 1000 / 8 ); -} -#endif /*------------------------------------------------------------------------- * Function isar_split_rend_validate_config() @@ -940,20 +811,9 @@ ivas_error isar_split_rend_validate_config( BREAK; case SPLIT_REND_384k: case SPLIT_REND_512k: -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS case SPLIT_REND_768k: -#endif /* Always valid */ BREAK; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - case SPLIT_REND_768k: - test(); - IF( EQ_16( pSplitRendConfig->dof, 0 ) && EQ_32( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "Bitrate is too high for LC3plus with 0 DOF" ); - } - BREAK; -#endif default: return IVAS_ERR_LC3PLUS_INVALID_BITRATE; } @@ -1408,7 +1268,6 @@ void isar_init_multi_bin_pose_data_fx_enc( return; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_error isar_framesize_to_ms( const IVAS_RENDER_FRAMESIZE frame_size, /* i : frame size enum */ int16_t *ms /* o : frame size in ms */ @@ -1431,7 +1290,6 @@ ivas_error isar_framesize_to_ms( return IVAS_ERR_OK; } -#endif /*------------------------------------------------------------------------- * Function isar_split_rend_choose_default_codec() @@ -1441,9 +1299,7 @@ ivas_error isar_framesize_to_ms( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ -#endif Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ @@ -1480,12 +1336,10 @@ ivas_error isar_split_rend_choose_default_codec( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Unknown split codec value" ); } } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS IF( *pIsar_frame_size_ms == 0 ) /* isar frame size hasn't been set yet - use default for current configuration */ { *pIsar_frame_size_ms = 20; } -#endif return IVAS_ERR_OK; } diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 82c01004e..30f24b2b2 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -81,18 +81,9 @@ typedef struct { const int32_t *pOutSampleRate; const AUDIO_CONFIG *pOutConfig; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; - const EFAP_WRAPPER *pEfapOutWrapper; -#endif const ISAR_POST_REND_HeadRotData *pHeadRotData; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - const RENDER_CONFIG_HANDLE *hhRendererConfig; -#endif const int16_t *pSplitRendBFI; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRenderConfig; -#endif } rendering_context; /* Common base for input structs */ @@ -215,10 +206,8 @@ static void convertBitsBufferToInternalBitsBuff( hBits->codec = outBits.config.codec; hBits->pose_correction = outBits.config.poseCorrection; hBits->codec_frame_size_ms = outBits.config.codec_frame_size_ms; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hBits->isar_frame_size_ms = outBits.config.isar_frame_size_ms; hBits->lc3plus_highres = outBits.config.lc3plusHighRes; -#endif return; } @@ -234,10 +223,8 @@ static void convertInternalBitsBuffToBitsBuffer( hOutBits->config.codec = bits.codec; hOutBits->config.poseCorrection = bits.pose_correction; hOutBits->config.codec_frame_size_ms = bits.codec_frame_size_ms; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hOutBits->config.isar_frame_size_ms = bits.isar_frame_size_ms; hOutBits->config.lc3plusHighRes = bits.lc3plus_highres; -#endif return; } @@ -463,9 +450,7 @@ static rendering_context getRendCtx( ctx.pOutSampleRate = &hIvasRend->sampleRateOut; ctx.pHeadRotData = &hIvasRend->headRotData; ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ctx.pSplitRenderConfig = &hIvasRend->splitRenderConfig; -#endif return ctx; } @@ -488,10 +473,6 @@ static ivas_error updateSplitPostRendPanGains( input_split_post_rend *inputSplitPostRend, const AUDIO_CONFIG outConfig, ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t num_subframes -#endif ) { ivas_error error; @@ -504,30 +485,9 @@ static ivas_error updateSplitPostRendPanGains( rendCtx = inputSplitPostRend->base.ctx; isar_renderSplitGetMultiBinPoseData_fx( hRendCfg, &inputSplitPostRend->splitPostRendWrapper.multiBinPoseData, rendCtx.pHeadRotData->sr_pose_pred_axis ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config.high_res_mode_enabled = ( hRendCfg->lc3plus_highres != 0 ); -#endif config.lc3plus_frame_duration_us = hRendCfg->codec_frame_size_ms * 1000; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS config.isar_frame_duration_us = hRendCfg->isar_frame_size_ms * 1000; -#else - IF( NE_16( num_subframes, MAX_PARAM_SPATIAL_SUBFRAMES ) ) - { - IF( hRendCfg->codec == ISAR_SPLIT_REND_CODEC_LC3PLUS ) - { - config.ivas_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us * num_subframes : 20000; - } - ELSE - { - config.ivas_frame_duration_us = ( hRendCfg->poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ? config.lc3plus_frame_duration_us : 20000; - } - iNumLCLDIterationsPerFrame = 1; - } - ELSE - { - config.ivas_frame_duration_us = 20000; - } -#endif IF( GT_16( hRendCfg->codec_frame_size_ms, 0 ) ) { @@ -573,10 +533,6 @@ static ivas_error setRendInputActiveSplitPostRend( const AUDIO_CONFIG inConfig, const IVAS_REND_InputId id, ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - const int16_t num_subframes -#endif ) { ivas_error error; @@ -598,10 +554,6 @@ static ivas_error setRendInputActiveSplitPostRend( inputSplitPostRend->numCachedSamples = 0; if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - num_subframes -#endif ) ) != IVAS_ERR_OK ) { return error; @@ -929,10 +881,6 @@ ivas_error ISAR_POST_REND_AddInput( void *inputsArray; Word32 inputStructSize; ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - int16_t -#endif ); Word32 inputIndex; @@ -962,10 +910,6 @@ ivas_error ISAR_POST_REND_AddInput( *inputId = makeInputId( inConfig, inputIndex ); if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - , - hIvasRend->num_subframes -#endif ) ) != IVAS_ERR_OK ) { return error; @@ -1159,9 +1103,7 @@ ivas_error ISAR_POST_REND_InitConfig( hIvasRend->splitRenderConfig.hq_mode = 0; hIvasRend->splitRenderConfig.codec_delay_ms = 0; hIvasRend->splitRenderConfig.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->splitRenderConfig.isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ -#endif hIvasRend->splitRenderConfig.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hIvasRend->splitRenderConfig.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hIvasRend->splitRenderConfig.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; @@ -1194,9 +1136,7 @@ Word16 ISAR_POST_REND_GetRenderConfig( splitRenderConfig->hq_mode = 0; splitRenderConfig->codec_delay_ms = 0; splitRenderConfig->codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS splitRenderConfig->isar_frame_size_ms = 0; /* 0 means "use default for selected codec" */ -#endif splitRenderConfig->codec = ISAR_SPLIT_REND_CODEC_DEFAULT; splitRenderConfig->poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; splitRenderConfig->rendererSelection = hRCin.rendererSelection; @@ -1310,18 +1250,11 @@ static ivas_error splitBinLc3plusDecode( ISAR_SPLIT_POST_REND_WRAPPER *hSplitBin, ISAR_SPLIT_REND_BITS_HANDLE bits, Word32 outputBuffer[BINAURAL_CHANNELS][L_FRAME48k], -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - ISAR_SPLIT_REND_POSE_CORRECTION_MODE pose_correction, -#endif const int16_t SplitRendBFI ) { ivas_error error; Word32 *channel_ptrs[MAX_HEAD_ROT_POSES * 2]; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS Word32 lc3plusBitstreamSize; -#else - Word32 lc3plusBitrateId, lc3plusBitstreamSize; -#endif push_wmops( "splitBinLc3plusDecode" ); assert( hSplitBin->hLc3plusDec != NULL ); @@ -1338,15 +1271,9 @@ static ivas_error splitBinLc3plusDecode( { ++bits->bits_read; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Size is in bytes */ assert( ( bits->bits_written - bits->bits_read ) % 8 == 0 ); lc3plusBitstreamSize = ( bits->bits_written - bits->bits_read ) / 8; -#else - /* Read LC3plus bitstream size info */ - lc3plusBitrateId = ISAR_SPLIT_REND_BITStream_read_int32( bits, 8 ); - lc3plusBitstreamSize = isar_get_lc3plus_size_from_id( (Word8) lc3plusBitrateId, pose_correction, (Word16) ( hSplitBin->hLc3plusDec->config.ivas_frame_duration_us / 1000 ) ); -#endif if ( ( error = ISAR_LC3PLUS_DEC_Decode( hSplitBin->hLc3plusDec, &bits->bits_buf[bits->bits_read / 8], lc3plusBitstreamSize, channel_ptrs ) ) != IVAS_ERR_OK ) { @@ -1394,9 +1321,6 @@ static ivas_error renderSplitBinauralWithPostRot( Word16 Q_cldfb_final[MAX_PARAM_SPATIAL_SUBFRAMES] = { 0 }; Word16 Q_out[MAX_PARAM_SPATIAL_SUBFRAMES][BINAURAL_CHANNELS] = { 0 }; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - uint32_t ivas_frame_duration_us; -#endif Word16 iNumBlocksPerFrame, iNumLCLDIterationsPerFrame; const ISAR_POST_REND_HeadRotData *pHeadRotData; @@ -1404,24 +1328,15 @@ static ivas_error renderSplitBinauralWithPostRot( push_wmops( "renderSplitBinauralWithPostRot" ); error = IVAS_ERR_OK; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS if ( outAudio.config.numSamplesPerChannel / *splitBinInput->base.ctx.pOutSampleRate > splitBinInput->hBits->config.isar_frame_size_ms ) { return IVAS_ERR_INTERNAL_FATAL; } -#endif pHeadRotData = splitBinInput->base.ctx.pHeadRotData; hSplitBin = &splitBinInput->splitPostRendWrapper; convertBitsBufferToInternalBitsBuff( *splitBinInput->hBits, &bits ); -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - ivas_frame_duration_us = 20000; - if ( splitBinInput->splitPostRendWrapper.hLc3plusDec != NULL ) - { - ivas_frame_duration_us = splitBinInput->splitPostRendWrapper.hLc3plusDec->config.isar_frame_duration_us; - } -#endif iNumLCLDIterationsPerFrame = 1; iNumBlocksPerFrame = CLDFB_NO_COL_MAX; @@ -1466,13 +1381,7 @@ static ivas_error renderSplitBinauralWithPostRot( { isPostRendInputCldfb = 1; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * bits.isar_frame_size_ms / 1000 ) - outBufNumSamplesPerChannel; -#else - preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; - - numSamplesPerChannelCacheSize = (int16_t) ( *splitBinInput->base.ctx.pOutSampleRate * ( preRendFrameSize_ms - bits.codec_frame_size_ms ) / 1000 ); -#endif outBufNumColPerChannel = MAX_PARAM_SPATIAL_SUBFRAMES; numColPerChannelCacheSize = sub( DEPR_i_mult( iNumBlocksPerFrame, iNumLCLDIterationsPerFrame ), outBufNumColPerChannel ); @@ -1519,9 +1428,6 @@ static ivas_error renderSplitBinauralWithPostRot( Q_out[sf_idx][0] = 0; Q_out[sf_idx][1] = 0; if ( ( error = splitBinLc3plusDecode( hSplitBin, &bits, tmpCrendBuffer_fx, -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - bits.pose_correction, -#endif SplitRendBFI ) ) != IVAS_ERR_OK ) // Q0 { return error; @@ -1579,11 +1485,7 @@ static ivas_error renderSplitBinauralWithPostRot( copyBufferTo2dArray_fx( splitBinInput->base.inputBuffer, tmpCrendBuffer_fx ); IF( splitBinInput->numCachedSamples == 0 ) { -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS preRendFrameSize_ms = splitBinInput->base.ctx.pSplitRenderConfig->isar_frame_size_ms; -#else - preRendFrameSize_ms = (int16_t) ( ivas_frame_duration_us ) / 1000; -#endif numSamplesPerChannelCacheSize = (Word16) ( *splitBinInput->base.ctx.pOutSampleRate * preRendFrameSize_ms / 1000 ); numSamplesPerChannelCacheSize -= outAudio.config.numSamplesPerChannel; splitBinInput->numCachedSamples = numSamplesPerChannelCacheSize; @@ -1877,11 +1779,9 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ const int16_t codec_frame_size_ms /* i: codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , const int16_t isar_frame_size_ms, /* i: isar codec frame size setting */ const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ -#endif ) { IF( hIvasRend == NULL ) @@ -1889,14 +1789,10 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } hIvasRend->splitRenderConfig.codec = codec; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->splitRenderConfig.isar_frame_size_ms = isar_frame_size_ms; -#endif hIvasRend->splitRenderConfig.codec_frame_size_ms = codec_frame_size_ms; hIvasRend->splitRenderConfig.poseCorrectionMode = poseCorrection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->splitRenderConfig.lc3plus_highres = lc3plus_highres; -#endif return IVAS_ERR_OK; } diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index ef437eaa3..b919bb1d2 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -61,10 +61,8 @@ typedef struct ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; int16_t codec_frame_size_ms; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int16_t isar_frame_size_ms; int16_t lc3plusHighRes; -#endif } ISAR_POST_REND_BitstreamBufferConfig; typedef struct @@ -200,11 +198,9 @@ ivas_error ISAR_REND_SetSplitRendBitstreamHeader( const ISAR_SPLIT_REND_CODEC codec, /* o: codec setting */ const ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, /* o: pose correction mode */ const int16_t codec_frame_size_ms /* i: codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , const int16_t isar_frame_size_ms, /* i: isar frame size setting */ const int16_t lc3plus_highres /* i: LC3plus Hig-Res setting. Ignored if codec is not LC3plus */ -#endif ); diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index fa3462fdc..55a306a40 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -83,11 +83,7 @@ ivas_error ISAR_PRE_REND_open( const Word32 OutSampleRate, const Word16 cldfb_in_flag, const Word16 pcm_out_flag, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ -#else - const int16_t num_subframes, /* i: number of subframes */ -#endif const int16_t mixed_td_cldfb_flag ) { ivas_error error, ch, num_ch; @@ -95,17 +91,11 @@ ivas_error ISAR_PRE_REND_open( Word16 cldfb_in_flag_local = cldfb_in_flag; if ( ( error = isar_split_rend_choose_default_codec( &( pSplitRendConfig->codec ), -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS &pSplitRendConfig->isar_frame_size_ms, -#endif &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, pcm_out_flag, (int16_t) -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_frame_size -#else - num_subframes -#endif ) ) != IVAS_ERR_OK ) { return error; @@ -192,11 +182,7 @@ ivas_error ISAR_PRE_REND_open( IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ivas_frame_size -#else - num_subframes -#endif ) ) != IVAS_ERR_OK ) { return error; @@ -323,9 +309,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const IVAS_QUATERNION headPosition, const Word32 SplitRendBitRate, ISAR_SPLIT_REND_CODEC splitCodec, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const Word16 isar_frame_size_ms, /* i: ISAR framesize */ -#endif Word16 codec_frame_size_ms, ISAR_SPLIT_REND_BITS_HANDLE pBits, Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -340,11 +324,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Word16 *Q_out ) { ivas_error error; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS int32_t bit_len, target_md_bits, available_bits, tmp_32; -#else - Word32 bit_len, target_md_bits, actual_md_bits, available_bits, tmp_32; -#endif Word16 q1 = 31, q2 = 31, q_final, Q_cldfb, tmp, tmp_e; Word16 i, j; error = IVAS_ERR_OK; @@ -369,9 +349,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( IF( EQ_16( cldfb_in_flag, 0 ) ) { error = isar_renderMultiTDBinToSplitBinaural( hSplitBin, headPosition, SplitRendBitRate, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS isar_frame_size_ms, -#endif codec_frame_size_ms, pBits, max_bands, pOutput_fx, Q_out[0], low_res_pre_rend_rot, pcm_out_flag, ro_md_flag ); Q_out[1] = Q_out[0]; @@ -390,16 +368,10 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( move16(); } -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - actual_md_bits = pBits->bits_written; -#endif IF( hSplitBin->multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) { target_md_bits = isar_get_split_rend_md_target_brate( SplitRendBitRate, pcm_out_flag ) * L_FRAME48k / 48000; -#ifndef ISAR_BITSTREAM_UPDATE_LC3PLUS - actual_md_bits = pBits->bits_written; -#endif /*float2fix, to be removed*/ Word16 Q_Cldfb_re = 31, Q_Cldfb_im = 31; move16(); @@ -439,12 +411,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( tmp_e = 0; tmp_32 = BASOP_Util_Divide3232_Scale_cadence( available_bits, L_mult0( 16, FRAMES_PER_SEC ), &tmp_e ); available_bits = L_shr( tmp_32, sub( 31, tmp_e ) ); // Q0 -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = L_sub( available_bits, pBits->bits_written ); -#else - actual_md_bits = L_sub( pBits->bits_written, actual_md_bits ); - available_bits = L_sub( available_bits, actual_md_bits ); -#endif pBits->codec_frame_size_ms = codec_frame_size_ms; q_final = sub( s_min( Q_buff_re, Q_buff_im ), 2 ); FOR( i = 0; i < hSplitBin->hSplitBinLCLDEnc->iChannels; i++ ) @@ -532,12 +499,8 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( } assert( Q_out[0] == Q_out[1] ); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS available_bits = ( SplitRendBitRate / FRAMES_PER_SEC ) - pBits->bits_written; IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, available_bits, pOutput_fx, Q_out[0] ) ) != IVAS_ERR_OK ) -#else - IF( ( error = splitRendLc3plusEncodeAndWrite( hSplitBin, pBits, SplitRendBitRate, pOutput_fx ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index a4d03e8a5..41843ec84 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -47,11 +47,7 @@ ivas_error ISAR_PRE_REND_open( const int32_t output_Fs, /* i: output sampling rate */ const int16_t cldfb_in_flag, /* i: Flag to indicate CLDFB or time doamin input */ const int16_t pcm_out_flag, /* i: Flag to indicate PCM output */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const IVAS_RENDER_FRAMESIZE ivas_frame_size, /* i: IVAS frame size */ -#else - const int16_t num_subframes, /* i: number of subframes */ -#endif const int16_t mixed_td_cldfb_flag /* i: Flag to indicate combined TD and CLDFB input */ ); @@ -71,9 +67,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( const IVAS_QUATERNION headPosition, /* i: head rotation QUATERNION */ const Word32 SplitRendBitRate, /* i: Split renderer bitrate */ ISAR_SPLIT_REND_CODEC splitCodec, /* i/o: Split renderer codec */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS const Word16 isar_frame_size_ms, /* i: ISAR framesize */ -#endif Word16 codec_frame_size_ms, /* i/o: Split renderer codec framesize */ ISAR_SPLIT_REND_BITS_HANDLE pBits, /* i/o: Split renderer bitstream handle */ Word32 Cldfb_In_BinReal_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o: CLDFB real buffer */ diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 0ce576cb3..7f8e96d5c 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -146,10 +146,8 @@ ivas_error ivas_render_config_init_from_rom_fx( move16(); ( *hRenderConfig )->split_rend_config.codec_delay_ms = 0; move16(); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *hRenderConfig )->split_rend_config.isar_frame_size_ms = 20; move16(); -#endif ( *hRenderConfig )->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ move16(); ( *hRenderConfig )->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; @@ -158,10 +156,8 @@ ivas_error ivas_render_config_init_from_rom_fx( move32(); ( *hRenderConfig )->split_rend_config.rendererSelection = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT; move32(); -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; move16(); -#endif #endif return IVAS_ERR_OK; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 9615a170d..b27c59852 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -65,10 +65,8 @@ typedef struct ISAR_SPLIT_REND_CODEC codec; ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection; Word16 codec_frame_size_ms; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS Word16 isar_frame_size_ms; Word16 lc3plus_highres; -#endif } IVAS_REND_BitstreamBufferConfig; typedef struct { @@ -292,10 +290,8 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , Word16 *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ -#endif ); #endif diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 562b35a6a..eb155a89f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5014,17 +5014,13 @@ Word16 IVAS_REND_GetRenderConfig( hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; hRCout->split_rend_config.codec_delay_ms = 0; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hRCout->split_rend_config.isar_frame_size_ms = 20; -#endif hRCout->split_rend_config.codec_frame_size_ms = 0; /* 0 means "use default for selected codec" */ hRCout->split_rend_config.codec = ISAR_SPLIT_REND_CODEC_DEFAULT; hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hRCout->split_rend_config.lc3plus_highres = 0; #endif -#endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; @@ -9253,9 +9249,7 @@ static ivas_error getSamplesInternal( } if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper, hIvasRend->headRotData.headPositions[0], hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate, hIvasRend->hRendererConfig->split_rend_config.codec, -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms, -#endif hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms, &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, cldfb_in_flag, ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ? 1 : 0, ro_md_flag, Q_buff, &Q_out[0] ) ) != IVAS_ERR_OK ) { @@ -9355,10 +9349,8 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ int16_t *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , int16_t *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ -#endif ) { if ( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) @@ -9367,9 +9359,7 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( } *pCodec = hIvasRend->hRendererConfig->split_rend_config.codec; *pCodec_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.codec_frame_size_ms; -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS *pIsar_frame_size_ms = hIvasRend->hRendererConfig->split_rend_config.isar_frame_size_ms; -#endif *poseCorrection = hIvasRend->hRendererConfig->split_rend_config.poseCorrectionMode; return IVAS_ERR_OK; } diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index dae55f18c..3c897cc43 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2486,7 +2486,6 @@ ivas_error RenderConfigReader_read( errorHandler( pValue, ERROR_VALUE_INVALID ); } } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS else if ( strcmp( item, "LC3PLUS_HIGHRES" ) == 0 ) { if ( !sscanf( pValue, "%hd", &hRenderConfig->split_rend_config.lc3plus_highres ) ) @@ -2494,7 +2493,6 @@ ivas_error RenderConfigReader_read( errorHandler( item, ERROR_VALUE_INVALID ); } } -#endif #ifdef DEBUGGING else { diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 065300c10..c112863db 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -67,12 +67,10 @@ ivas_error split_rend_reader_open( ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, int16_t *codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres -#endif ) { SplitFileReadWrite *hSplitRendFileReadWrite; @@ -125,7 +123,6 @@ ivas_error split_rend_reader_open( { return IVAS_ERR_FAILED_FILE_READ; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* read isar bitstream frame size signalling */ if ( fread( isar_frame_size_ms, sizeof( *isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { @@ -141,7 +138,6 @@ ivas_error split_rend_reader_open( { return IVAS_ERR_FAILED_FILE_READ; } -#endif *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; @@ -163,12 +159,10 @@ ivas_error split_rend_writer_open( ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, int16_t codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , const int16_t isar_frame_size_ms, const int32_t sampling_rate, const int16_t lc3plus_highres -#endif ) { SplitFileReadWrite *hSplitRendFileReadWrite; @@ -220,7 +214,6 @@ ivas_error split_rend_writer_open( { return IVAS_ERR_FAILED_FILE_WRITE; } -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS /* Write isar bit stream frame size signalling */ if ( fwrite( &isar_frame_size_ms, sizeof( isar_frame_size_ms ), 1, hSplitRendFileReadWrite->file ) != 1 ) { @@ -236,7 +229,6 @@ ivas_error split_rend_writer_open( { return IVAS_ERR_FAILED_FILE_WRITE; } -#endif *hhSplitRendFileReadWrite = hSplitRendFileReadWrite; diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index bdda7e598..125daf94e 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -45,12 +45,10 @@ ivas_error split_rend_reader_open( ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, int16_t *codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , int16_t *isar_frame_size_ms, int32_t *sampling_rate, int16_t *lc3plus_highres -#endif ); @@ -63,12 +61,10 @@ ivas_error split_rend_writer_open( ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, int16_t codec_frame_size_ms -#ifdef ISAR_BITSTREAM_UPDATE_LC3PLUS , const int16_t isar_frame_size_ms, const int32_t sampling_rate, const int16_t lc3plus_highres -#endif ); -- GitLab From 363a89039256ac5b5e65d7402f80a5ebc0b3da56 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:31:04 +0200 Subject: [PATCH 279/692] [cleanup] accept SPLIT_REND_WITH_HEAD_ROT --- apps/decoder.c | 128 --- apps/isar_post_rend.c | 12 - apps/renderer.c | 150 --- lib_com/cnst.h | 5 - lib_com/common_api_types.h | 6 - lib_com/delay_comp_fx.c | 6 - lib_com/ivas_error.h | 6 - lib_com/ivas_prot_fx.h | 9 - lib_com/ivas_rotation_com.c | 2 - lib_com/options.h | 3 - lib_com/prot_fx.h | 2 - lib_dec/ivas_binRenderer_internal_fx.c | 172 ---- lib_dec/ivas_dirac_dec_fx.c | 80 -- lib_dec/ivas_init_dec_fx.c | 56 -- lib_dec/ivas_ism_dec_fx.c | 34 - lib_dec/ivas_ism_param_dec_fx.c | 13 - lib_dec/ivas_jbm_dec_fx.c | 103 -- lib_dec/ivas_masa_dec_fx.c | 44 - lib_dec/ivas_mc_param_dec_fx.c | 27 - lib_dec/ivas_mc_paramupmix_dec_fx.c | 29 - lib_dec/ivas_mct_dec_fx.c | 41 - lib_dec/ivas_objectRenderer_internal_fx.c | 2 - lib_dec/ivas_omasa_dec_fx.c | 14 - lib_dec/ivas_osba_dec_fx.c | 6 - lib_dec/ivas_output_config_fx.c | 28 - lib_dec/ivas_sba_dec_fx.c | 34 - lib_dec/ivas_spar_decoder_fx.c | 5 - lib_dec/ivas_stat_dec.h | 35 - lib_dec/lib_dec.h | 8 - lib_dec/lib_dec_fx.c | 48 - lib_enc/lib_enc_fx.c | 5 - lib_isar/isar_MSPred.c | 2 - lib_isar/isar_NoiseGen.c | 2 - lib_isar/isar_PerceptualModel.c | 2 - lib_isar/isar_PredDecoder.c | 2 - lib_isar/isar_PredEncoder.c | 2 - lib_isar/isar_RMSEnvGrouping.c | 2 - lib_isar/isar_cnst.h | 2 - lib_isar/isar_lc3plus_common.c | 2 - lib_isar/isar_lc3plus_common.h | 2 - lib_isar/isar_lc3plus_dec.c | 2 - lib_isar/isar_lc3plus_dec.h | 2 - lib_isar/isar_lc3plus_enc.c | 2 - lib_isar/isar_lc3plus_enc.h | 2 - lib_isar/isar_lc3plus_payload.c | 2 - lib_isar/isar_lc3plus_payload.h | 2 - lib_isar/isar_lcld_decoder.c | 2 - lib_isar/isar_lcld_encoder.c | 2 - lib_isar/isar_lcld_prot.h | 2 - lib_isar/isar_lcld_rom_tables.c | 2 - lib_isar/isar_prot.h | 2 - lib_isar/isar_rom_post_rend.c | 2 - lib_isar/isar_rom_post_rend.h | 2 - lib_isar/isar_splitRend_lcld_dec.c | 2 - lib_isar/isar_splitRend_lcld_enc.c | 2 - lib_isar/isar_splitRendererPLC.c | 2 - lib_isar/isar_splitRendererPost.c | 2 - lib_isar/isar_splitRendererPre.c | 2 - lib_isar/isar_splitRenderer_utils.c | 2 - lib_isar/isar_stat.h | 2 - lib_isar/lib_isar_post_rend.c | 9 - lib_isar/lib_isar_post_rend.h | 6 - lib_isar/lib_isar_pre_rend.c | 10 - lib_isar/lib_isar_pre_rend.h | 6 - lib_rend/ivas_crend_fx.c | 92 -- .../ivas_dirac_dec_binaural_functions_fx.c | 885 +----------------- lib_rend/ivas_orient_trk_fx.c | 8 - lib_rend/ivas_output_init_fx.c | 8 - lib_rend/ivas_prot_rend_fx.h | 20 - lib_rend/ivas_reflections_fx.c | 4 - lib_rend/ivas_render_config_fx.c | 2 - lib_rend/ivas_rotation_fx.c | 67 -- lib_rend/ivas_stat_rend.h | 28 - lib_rend/lib_rend.h | 10 - lib_rend/lib_rend_fx.c | 497 ---------- lib_util/render_config_reader.c | 8 - lib_util/rotation_file_reader.c | 8 - lib_util/split_rend_bfi_file_reader.c | 2 - lib_util/split_rend_bfi_file_reader.h | 2 - lib_util/split_render_file_read_write.c | 2 - lib_util/split_render_file_read_write.h | 2 - 81 files changed, 22 insertions(+), 2825 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 939f21aa7..b8d4c6596 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -43,9 +43,7 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" -#endif #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "options.h" @@ -117,9 +115,7 @@ typedef struct Word16 non_diegetic_pan_gain_fx; /* Q15 */ bool renderConfigEnabled; char *renderConfigFilename; -#ifdef SPLIT_REND_WITH_HEAD_ROT char *outputMdFilename; -#endif IVAS_DEC_COMPLEXITY_LEVEL complexityLevel; bool tsmEnabled; IVAS_RENDER_FRAMESIZE renderFramesize; @@ -136,11 +132,7 @@ typedef struct static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); static void usage_dec( void ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -#else -static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); -#endif static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); @@ -157,10 +149,8 @@ int main( bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ DecArguments arg; ivas_error error = IVAS_ERR_UNKNOWN; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA splitRendBits; uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES]; -#endif /* Any handles that require cleanup must be declared here and initialized to NULL */ IVAS_DEC_HANDLE hIvasDec = NULL; @@ -185,9 +175,7 @@ int main( reset_mem( USE_BYTES ); #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT splitRendBits.bits_buf = splitRendBitsBuf; -#endif /*------------------------------------------------------------------------------------------* * Parse command-line arguments @@ -235,7 +223,6 @@ int main( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) { fprintf( stdout, "Output metadata file: %s\n", arg.outputWavFilename ); @@ -246,7 +233,6 @@ int main( fprintf( stdout, "Output metadata file: %s\n", arg.outputMdFilename ); } else -#endif { fprintf( stdout, "Output synthesis file: %s\n", arg.outputWavFilename ); } @@ -281,9 +267,7 @@ int main( { /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB -#ifdef SPLIT_REND_WITH_HEAD_ROT && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM -#endif ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); @@ -385,10 +369,8 @@ int main( { /* sanity check */ if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB -#ifdef SPLIT_REND_WITH_HEAD_ROT && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 -#endif ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); @@ -425,7 +407,6 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------------------------* * Configure Split rendering *------------------------------------------------------------------------------------------*/ @@ -447,7 +428,6 @@ int main( arg.enableHeadRotation = true; } -#endif /*------------------------------------------------------------------------------------------* * Configure VoIP mode @@ -473,7 +453,6 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && arg.Opt_non_diegetic_pan == 0 ) @@ -481,13 +460,6 @@ int main( fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); goto cleanup; } -#else - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - { - fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" ); - goto cleanup; - } -#endif if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK ) { @@ -513,7 +485,6 @@ int main( renderConfig.directivity_fx[i * 3 + 2] = (Word16) ( renderConfig.directivity[i * 3 + 2] * ( ( 1u << 15 ) - 1 ) ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -538,7 +509,6 @@ int main( fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" ); } } -#endif if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { @@ -557,11 +527,9 @@ int main( } renderConfig.roomAcoustics.override = true; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5; -#endif if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { @@ -791,11 +759,7 @@ int main( } else { -#ifdef SPLIT_REND_WITH_HEAD_ROT error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf ); -#else - error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf ); -#endif } if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE ) @@ -933,7 +897,6 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; @@ -942,7 +905,6 @@ static IVAS_AUDIO_CONFIG cmdline2config( { output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; } -#endif else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 ) { output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -1010,9 +972,7 @@ static bool parseCmdlIVAS_dec( arg->renderConfigFilename = NULL; arg->Opt_dpid_on = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT arg->outputMdFilename = NULL; -#endif arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192; arg->Opt_non_diegetic_pan = 0; @@ -1260,7 +1220,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( argv_to_upper, "-OM" ) == 0 ) { arg->outputMdFilename = argv[i + 1]; @@ -1272,7 +1231,6 @@ static bool parseCmdlIVAS_dec( } i += 2; } -#endif else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 ) { i++; @@ -1439,14 +1397,12 @@ static bool parseCmdlIVAS_dec( usage_dec(); return false; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( arg->outputMdFilename != NULL && arg->outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "Error: Output split rendering metadata file is supported for BINAURAL_SPLIT_PCM output config. only\n\n" ); usage_dec(); return false; } -#endif } else { @@ -1523,13 +1479,8 @@ static void usage_dec( void ) fprintf( stdout, "Mandatory parameters:\n" ); fprintf( stdout, "---------------------\n" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" ); -#else - fprintf( stdout, "OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" ); - fprintf( stdout, " HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" ); -#endif fprintf( stdout, " By default, channel order and loudspeaker positions are equal to the\n" ); fprintf( stdout, " encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" ); fprintf( stdout, " layout file. See readme.txt for details.\n" ); @@ -1569,9 +1520,7 @@ static void usage_dec( void ) fprintf( stdout, "-rvf File : Reference vector specified by external trajectory File\n" ); fprintf( stdout, " works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" ); fprintf( stdout, "-render_config File : Renderer configuration File\n" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stdout, "-om File : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" ); -#endif fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" ); fprintf( stdout, " left or l or 90->left, right or r or -90->right, center or c or 0->middle\n" ); fprintf( stdout, "-exof File : External orientation File for external orientation trajectory\n" ); @@ -1601,12 +1550,8 @@ static ivas_error initOnFirstGoodFrame( IVAS_DEC_HANDLE hIvasDec, /* i/o: */ const DecArguments arg, /* i : */ const int16_t numInitialBadFrames, /* i : */ -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t *numOutSamples, /* i/o: */ int16_t *vec_pos_len, /* i/o: */ -#else - const uint16_t numOutSamples, /* i : */ -#endif int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1615,12 +1560,8 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ -#ifdef SPLIT_REND_WITH_HEAD_ROT uint16_t *pNumObj, /* o : */ SplitFileReadWrite **splitRendWriter -#else - uint16_t *pNumObj /* o : */ -#endif ) { ivas_error error = IVAS_ERR_UNKNOWN; @@ -1632,12 +1573,10 @@ static ivas_error initOnFirstGoodFrame( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { pFullDelayNumSamples[0] = 0; } -#endif if ( !arg.delayCompensationEnabled ) { @@ -1659,7 +1598,6 @@ static ivas_error initOnFirstGoodFrame( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { /* Open split rendering metadata writer */ @@ -1738,23 +1676,19 @@ static ivas_error initOnFirstGoodFrame( if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) { -#endif /* Open audio writer and write all previously skipped bad frames now that frame size is known */ if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename ); return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) ); memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) ); for ( int16_t i = 0; i < numInitialBadFrames; ++i ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero; @@ -1775,19 +1709,10 @@ static ivas_error initOnFirstGoodFrame( } else { -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *pRemainingDelayNumSamples < *numOutSamples ) -#else - if ( *pRemainingDelayNumSamples < numOutSamples ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) -#else - if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nOutput audio file writer error\n" ); return error; @@ -1796,15 +1721,9 @@ static ivas_error initOnFirstGoodFrame( } else { -#ifdef SPLIT_REND_WITH_HEAD_ROT *pRemainingDelayNumSamples -= *numOutSamples; -#else - *pRemainingDelayNumSamples -= numOutSamples; -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } free( zeroBuf ); @@ -1890,7 +1809,6 @@ static ivas_error initOnFirstGoodFrame( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( *splitRendWriter != NULL ) { if ( numOutSamples == NULL || vec_pos_len == NULL ) @@ -1910,7 +1828,6 @@ static ivas_error initOnFirstGoodFrame( return error; } } -#endif return IVAS_ERR_OK; } @@ -1929,9 +1846,7 @@ static ivas_error decodeG192( RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_BITS_DATA *splitRendBits, -#endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ) @@ -1958,9 +1873,7 @@ static ivas_error decodeG192( IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } }; int16_t vec_pos_update, vec_pos_len; -#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; -#endif for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) { @@ -2058,7 +1971,6 @@ static ivas_error decodeG192( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -2076,7 +1988,6 @@ static ivas_error decodeG192( } else { -#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -2085,17 +1996,11 @@ static ivas_error decodeG192( goto cleanup; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif for ( i = 0; i < num_subframes; i++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2154,7 +2059,6 @@ static ivas_error decodeG192( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (Word16 *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) @@ -2168,7 +2072,6 @@ static ivas_error decodeG192( } else { -#endif if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2176,9 +2079,7 @@ static ivas_error decodeG192( } nSamplesRendered += nSamplesRendered_loop; nSamplesToRender -= nSamplesRendered_loop; -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif if ( needNewFrame ) { @@ -2209,11 +2110,7 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) -#endif { goto cleanup; } @@ -2227,7 +2124,6 @@ static ivas_error decodeG192( /* Write current frame */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) ) { if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK ) @@ -2239,7 +2135,6 @@ static ivas_error decodeG192( if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 ) { -#endif if ( delayNumSamples < nOutSamples ) { if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK ) @@ -2253,9 +2148,7 @@ static ivas_error decodeG192( { delayNumSamples -= nOutSamples; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } /* Write ISm metadata to external file(s) */ @@ -2369,11 +2262,7 @@ static ivas_error decodeG192( goto cleanup; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2493,18 +2382,14 @@ static ivas_error decodeG192( *------------------------------------------------------------------------------------------*/ memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( afWriter != NULL ) { -#endif if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) ); goto cleanup; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif /*------------------------------------------------------------------------------------------* * Close files and deallocate resources @@ -2514,9 +2399,7 @@ static ivas_error decodeG192( cleanup: -#ifdef SPLIT_REND_WITH_HEAD_ROT split_rend_reader_writer_close( &splitRendWriter ); -#endif AudioFileWriter_close( &afWriter ); MasaFileWriter_close( &masaWriter ); for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ ) @@ -2763,7 +2646,6 @@ static ivas_error decodeVoIP( { IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( headRotReader == NULL ) { for ( i = 0; i < num_subframes; i++ ) @@ -2781,7 +2663,6 @@ static ivas_error decodeVoIP( } else { -#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK ) @@ -2791,17 +2672,13 @@ static ivas_error decodeVoIP( goto cleanup; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif for ( i = 0; i < num_subframes; i++ ) { if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i -#ifdef SPLIT_REND_WITH_HEAD_ROT , DEFAULT_AXIS -#endif ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -2929,15 +2806,10 @@ static ivas_error decodeVoIP( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT SplitFileReadWrite *splitRendWriter = NULL; if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK ) -#else - if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, - &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) -#endif { goto cleanup; } diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 1e041c175..e7fd6a05a 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -33,17 +33,6 @@ #include "lib_isar_post_rend.h" //#undef IVAS_FLOAT_FIXED -#ifndef SPLIT_REND_WITH_HEAD_ROT - -int main( int argc, char **argv ) -{ - (void) argc; - (void) argv; - ISAR_POST_REND_void_func(); - return 0; -} - -#else #include #include @@ -1242,4 +1231,3 @@ int main( #undef WMC_TOOL_SKIP -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/apps/renderer.c b/apps/renderer.c index 0d96f9dea..5ef8cca19 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -45,10 +45,8 @@ #include "masa_file_writer.h" #include "render_config_reader.h" #include "rotation_file_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "split_render_file_read_write.h" #include "split_rend_bfi_file_reader.h" -#endif #include "vector3_pair_file_reader.h" #include "wmc_auto.h" @@ -155,13 +153,9 @@ typedef struct OutputConfig outConfig; char inMetadataFilePaths[RENDERER_MAX_ISM_INPUTS][RENDERER_MAX_CLI_ARG_LENGTH]; int16_t numInMetadataFiles; -#ifdef SPLIT_REND_WITH_HEAD_ROT char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#endif char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#ifdef SPLIT_REND_WITH_HEAD_ROT char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; -#endif char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH]; @@ -208,10 +202,8 @@ typedef enum CmdLnOptionId_inputMetadata, CmdLnOptionId_listFormats, CmdLnOptionId_inputGain, -#ifdef SPLIT_REND_WITH_HEAD_ROT CmdLnOptionId_outputMetadata, CmdLnOptionId_SplitRendBFIFile, -#endif CmdLnOptionId_referenceVectorFile, CmdLnOptionId_exteriorOrientationFile, CmdLnOptionId_framing, @@ -237,11 +229,7 @@ static const CmdLnParser_Option cliOptions[] = { .id = CmdLnOptionId_inputMetadata, .match = "input_metadata", .matchShort = "im", -#ifdef SPLIT_REND_WITH_HEAD_ROT .description = "Space-separated list of path to metadata files for ISM or MASA inputs or BINAURAL_SPLIT_PCM input mode", -#else - .description = "Space-separated list of path to metadata files for ISM or MASA inputs", -#endif }, { .id = CmdLnOptionId_outputFile, @@ -267,7 +255,6 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "T", .description = "Head rotation trajectory file for simulation of head tracking (only for binaural outputs)", }, -#ifdef SPLIT_REND_WITH_HEAD_ROT { .id = CmdLnOptionId_outputMetadata, .match = "output_metadata", @@ -280,7 +267,6 @@ static const CmdLnParser_Option cliOptions[] = { .matchShort = "prbfi", .description = "Split rendering option: bfi file", }, -#endif { .id = CmdLnOptionId_refRotFile, .match = "reference_rotation_file", @@ -438,44 +424,26 @@ static void printSupportedAudioConfigs( void ); static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 *intBuffer, const Word16 cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, Word16 out_q -#else - Word16 *intBuffer, - Word16 out_q -#endif ); static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 *Word32Buffer, Word16 in_q_factor, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, Word16 *out_q_factor -#else - Word32 *Word32Buffer, - Word16 in_q_factor -#endif ); -#else -static void convertInputBuffer( const int16_t *intBuffer, const int16_t numIntSamplesPerChannel, const int16_t numFloatSamplesPerChannel, const int16_t numChannels, float *floatBuffer ); - -static void convertOutputBuffer( const float *floatBuffer, const int16_t numSamplesPerChannel, const int16_t numChannels, int16_t *intBuffer ); -static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, Word16 *intBuffer, Word16 q_factor ); -static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, Word32 *Int32Buffer, Word16 in_q_factor ); -#endif /*------------------------------------------------------------------------------------------* @@ -702,7 +670,6 @@ static float dBToLin( } -#ifdef SPLIT_REND_WITH_HEAD_ROT static int16_t get_cldfb_in_flag( const IVAS_AUDIO_CONFIG audioConfig, const IVAS_RENDER_CONFIG_DATA *renderConfig ) @@ -737,7 +704,6 @@ static int16_t is_split_pre_rend_mode( return flag; } -#endif /*------------------------------------------------------------------------------------------* @@ -754,12 +720,10 @@ int main( RotFileReader *headRotReader = NULL; RotFileReader *externalOrientationFileReader = NULL; RotFileReader *referenceRotReader = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[IVAS_MAX_INPUT_CHANNELS]; IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[IVAS_MAX_INPUT_CHANNELS]; int16_t cldfb_in_flag, CLDFBframeSize_smpls; SplitRendBFIFileReader *splitRendBFIReader = NULL; -#endif Vector3PairFileReader *referenceVectorReader = NULL; hrtfFileReader *hrtfFileReader = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; @@ -780,9 +744,7 @@ int main( AudioFileWriter *audioWriter; int32_t inBufferSize; int32_t outBufferSize; -#ifdef SPLIT_REND_WITH_HEAD_ROT int32_t bitsBufferSize; -#endif int16_t *inpInt16Buffer; float *inFloatBuffer; int16_t *outInt16Buffer; @@ -790,17 +752,13 @@ int main( Word32 *inInt32Buffer; Word32 gain_fx; float *outFloatBuffer; -#ifdef SPLIT_REND_WITH_HEAD_ROT uint8_t *bitsBufferData = NULL; -#endif IVAS_REND_AudioBuffer inBuffer; IVAS_REND_AudioBuffer outBuffer; -#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_REND_BitstreamBuffer bitsBuffer; SplitFileReadWrite *hSplitRendFileReadWrite; int16_t delayNumSamples_temp; int32_t delayTimeScale_temp; -#endif int16_t numSamplesRead; int16_t delayNumSamples = -1; int16_t delayNumSamples_orig = 0; @@ -821,7 +779,6 @@ int main( hMasaMetadata[i] = NULL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT hSplitRendFileReadWrite = NULL; CLDFBframeSize_smpls = 0; cldfb_in_flag = 0; @@ -834,7 +791,6 @@ int main( bitsBuffer.config.codec_frame_size_ms = 5; bitsBuffer.config.isar_frame_size_ms = 20; bitsBuffer.config.lc3plus_highres = 0; -#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { lfeRoutingConfigs[i] = NULL; @@ -893,13 +849,11 @@ int main( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( !isEmptyString( args.splitRendBFIFilePath ) ) { convert_backslash( args.splitRendBFIFilePath ); SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader ); } -#endif if ( !isEmptyString( args.externalOrientationFilePath ) ) { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) @@ -1227,28 +1181,16 @@ int main( IVAS_RENDER_CONFIG_DATA renderConfig; /* sanity check */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); exit( -1 ); } -#else - if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { - fprintf( stderr, "\nExternal Renderer Config is only supported for binaural output configurations. Exiting. \n" ); - exit( -1 ); - } -#endif if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n", ivas_error_to_string( error ) ); -#else - fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed\n" ); -#endif exit( -1 ); } @@ -1276,26 +1218,18 @@ int main( renderConfig.roomAcoustics.override = 1; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* ISAR frame size is set from command line, not renderer config file. * This will be ignored if output format is not split rendering. */ renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) args.render_framesize /* given in number of 5ms subframes */ * 5; -#endif if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n", ivas_error_to_string( error ) ); -#else - fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" ); -#endif exit( -1 ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT CLDFBframeSize_smpls = frameSize_smpls * 2; cldfb_in_flag = get_cldfb_in_flag( args.outConfig.audioConfig, &renderConfig ); -#endif } if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) @@ -1550,7 +1484,6 @@ int main( exit( -1 ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in_flag ) { if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) @@ -1631,22 +1564,18 @@ int main( exit( -1 ); } } -#endif if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); exit( -1 ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif inBufferSize = frameSize_smpls * totalNumInChannels; outBufferSize = frameSize_smpls * numOutChannels; inpInt16Buffer = malloc( inBufferSize * sizeof( int16_t ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in_flag == 0 ) { inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); @@ -1708,21 +1637,6 @@ int main( bitsBuffer.config.bitsRead = 0; bitsBuffer.config.bitsWritten = 0; bitsBuffer.config.bufLenInBytes = bitsBufferSize; -#else - inFloatBuffer = malloc( inBufferSize * sizeof( float ) ); - outInt16Buffer = malloc( outBufferSize * sizeof( int16_t ) ); - outInt32Buffer = malloc( outBufferSize * sizeof( Word32 ) ); - inInt32Buffer = malloc( inBufferSize * sizeof( Word32 ) ); - outFloatBuffer = malloc( outBufferSize * sizeof( float ) ); - - inBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; - inBuffer.config.numChannels = (int16_t) totalNumInChannels; - - outBuffer.config.numSamplesPerChannel = (int16_t) frameSize_smpls; - outBuffer.config.numChannels = (int16_t) numOutChannels; - outBuffer.data_fx = outInt32Buffer; - inBuffer.data_fx = inInt32Buffer; -#endif #ifdef WMOPS reset_stack(); @@ -1765,15 +1679,10 @@ int main( } /* Convert from int to float and from interleaved to packed */ -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 Q_out; *outBuffer.pq_fact = 16 - ( gd_bits ); convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact, inBuffer.config.is_cldfb, cldfbAna, &Q_out ); *outBuffer.pq_fact = Q_out; -#else - *outBuffer.pq_fact = 16 - ( gd_bits ); - convertInputBuffer_fx( inpInt16Buffer, numSamplesRead, inBuffer.config.numSamplesPerChannel, num_in_channels, inInt32Buffer, *outBuffer.pq_fact ); -#endif int16_t num_subframes, sf_idx; num_subframes = (int16_t) args.render_framesize; @@ -1831,11 +1740,7 @@ int main( exit( -1 ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) -#else - if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, sf_idx ) ) != IVAS_ERR_OK ) -#endif { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1988,7 +1893,6 @@ int main( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) @@ -1999,30 +1903,19 @@ int main( } else { -#endif if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); -#else - fprintf( stderr, "Error in getting samples\n" ); -#endif exit( -1 ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif int16_t num_out_channels; num_out_channels = outBuffer.config.numChannels; /* Convert from float to int and from packed to interleaved. * Values in outFloatBuffer are guaranteed to be within range INT16_MIN:INT16_MAX */ -#ifdef SPLIT_REND_WITH_HEAD_ROT convertOutputBuffer_fx( outInt32Buffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, cldfb_in_flag, cldfbSyn, *outBuffer.pq_fact ); -#else - convertOutputBuffer_fx( outInt32Buffer, outBuffer.config.numSamplesPerChannel, num_out_channels, outInt16Buffer, *outBuffer.pq_fact ); -#endif if ( delayNumSamples == -1 ) { @@ -2044,7 +1937,6 @@ int main( zeroPad = delayNumSamples; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( is_split_pre_rend_mode( &args ) ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, bitsBuffer.bits, &bitsBuffer.config.bitsRead, @@ -2057,7 +1949,6 @@ int main( if ( audioWriter != NULL ) { -#endif if ( delayNumSamples * num_out_channels < outBufferSize ) { if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) @@ -2072,12 +1963,10 @@ int main( delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT } bitsBuffer.config.bitsRead = 0; bitsBuffer.config.bitsWritten = 0; -#endif /* Write MASA metadata for MASA outputs */ @@ -2183,10 +2072,8 @@ int main( } /* add zeros at the end to have equal length of synthesized signals */ -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( audioWriter != NULL ) { -#endif for ( zeroPadToWrite = zeroPad; zeroPadToWrite > frameSize_smpls; zeroPadToWrite -= frameSize_smpls ) { memset( outInt16Buffer, 0, outBufferSize * sizeof( int16_t ) ); @@ -2204,9 +2091,7 @@ int main( exit( -1 ); } zeroPadToWrite = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif if ( args.inConfig.numAudioObjects != 0 && ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) @@ -2231,18 +2116,15 @@ int main( free( inInt32Buffer ); cleanup: -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( bitsBufferData != NULL ) { free( bitsBufferData ); } -#endif for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; ++i ) { MasaFileReader_close( &masaReaders[i] ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( cldfb_in_flag ) { IVAS_REND_closeCldfb( cldfbAna, cldfbSyn ); @@ -2250,7 +2132,6 @@ cleanup: split_rend_reader_writer_close( &hSplitRendFileReadWrite ); SplitRendBFIFileReader_close( &splitRendBFIReader ); -#endif for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i ) { @@ -2560,13 +2441,8 @@ static bool parseOrientationTracking( static IVAS_AUDIO_CONFIG parseAudioConfig( const char *configString ) { -#ifndef SPLIT_REND_WITH_HEAD_ROT - char charBuf[21]; - charBuf[20] = '\0'; -#else char charBuf[25]; charBuf[24] = '\0'; -#endif strncpy( charBuf, configString, sizeof( charBuf ) - 1 ); charBuf[sizeof( charBuf ) - 1] = '\0'; @@ -2641,7 +2517,6 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( { return IVAS_AUDIO_CONFIG_BINAURAL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( strcmp( charBuf, "BINAURAL_SPLIT_PCM" ) == 0 ) { return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM; @@ -2650,7 +2525,6 @@ static IVAS_AUDIO_CONFIG parseAudioConfig( { return IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED; } -#endif if ( strcmp( charBuf, "BINAURAL_ROOM_IR" ) == 0 ) { return IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR; @@ -2783,10 +2657,8 @@ static CmdlnArgs defaultArgs( args.numInMetadataFiles = 0; clearString( args.headRotationFilePath ); -#ifdef SPLIT_REND_WITH_HEAD_ROT clearString( args.outMetadataFilePath ); clearString( args.splitRendBFIFilePath ); -#endif clearString( args.referenceVectorFilePath ); clearString( args.referenceRotationFilePath ); clearString( args.customHrtfFilePath ); @@ -2879,7 +2751,6 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; -#ifdef SPLIT_REND_WITH_HEAD_ROT case CmdLnOptionId_outputMetadata: assert( numOptionValues == 1 ); strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); @@ -2888,7 +2759,6 @@ static void parseOption( assert( numOptionValues == 1 ); strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); break; -#endif case CmdLnOptionId_referenceVectorFile: assert( numOptionValues == 1 ); strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); @@ -3907,10 +3777,8 @@ static void printSupportedAudioConfigs( void ) "ISMx (input only)", "MASAx", "BINAURAL (output only)", -#ifdef SPLIT_REND_WITH_HEAD_ROT "BINAURAL_SPLIT_PCM", "BINAURAL_SPLIT_CODED", -#endif "BINAURAL_ROOM_IR (output only)", "BINAURAL_ROOM_REVERB (output only)", }; @@ -4006,23 +3874,17 @@ static void convertInputBuffer_fx( const Word16 numIntSamplesPerChannel, const Word16 numFloatSamplesPerChannel, const Word16 numChannels, -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 *Word32Buffer, Word16 in_q_factor, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, Word16 *out_q_factor -#else - Word32 *Word32Buffer, - Word16 in_q_factor -#endif ) { Word16 chnl, smpl, i; i = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( cldfb_in_flag ) { Word16 slotIdx, numCldfbBands, numFloatPcmSamples; @@ -4063,7 +3925,6 @@ static void convertInputBuffer_fx( } ELSE { -#endif FOR( smpl = 0; smpl < numFloatSamplesPerChannel; ++smpl ) { FOR( chnl = 0; chnl < numChannels; ++chnl ) @@ -4080,10 +3941,8 @@ static void convertInputBuffer_fx( ++i; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT *out_q_factor = in_q_factor; } -#endif return; } @@ -4100,15 +3959,10 @@ static void convertOutputBuffer_fx( const Word32 *Word32Buffer, const Word16 numSamplesPerChannel, const Word16 numChannels, -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 *intBuffer, const Word16 cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, Word16 out_q -#else - Word16 *intBuffer, - Word16 out_q -#endif ) { Word16 chnl, smpl, i; @@ -4116,7 +3970,6 @@ static void convertOutputBuffer_fx( Word32 temp_fx1; i = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( cldfb_in_flag ) { Word16 slotIdx, numCldfbBands, numPcmSamples, b, temp_out_q = 0; @@ -4180,7 +4033,6 @@ static void convertOutputBuffer_fx( } ELSE { -#endif FOR( smpl = 0; smpl < numSamplesPerChannel; ++smpl ) { @@ -4201,9 +4053,7 @@ static void convertOutputBuffer_fx( ++i; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif return; } diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 5ffbb56e7..2317dc95e 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -3077,13 +3077,8 @@ enum #define SYNC_BAD_FRAME (UWord16) 0x6B20 /* synchronization word of a "bad" frame */ #define G192_BIN0 (UWord16) 0x007F /* binary "0" according to ITU-T G.192 */ #define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT #define DEGREE_180 (Word32)(180.0 *ONE_IN_Q22) #define DEGREE_360 (Word32)(360.0 *ONE_IN_Q22) -#else -#define DEGREE_180 (Word32)(180.0 *ONE_IN_Q23) -#define DEGREE_360 (Word32)(360.0 *ONE_IN_Q23) -#endif extern const Word16 Idx2Freq_Tbl[]; #define chk_fs(fs) diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 34facc703..bb6351711 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -219,7 +219,6 @@ typedef struct _IVAS_JBM_TRACE_DATA } IVAS_JBM_TRACE_DATA; -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * Split rendering API constants, structures, and enums *----------------------------------------------------------------------------------*/ @@ -301,7 +300,6 @@ typedef struct _ISAR_SPLIT_REND_CONFIG int16_t lc3plus_highres; } ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE; -#endif /*----------------------------------------------------------------------------------* * Renderer API structures and enums @@ -348,9 +346,7 @@ typedef struct _IVAS_RENDER_CONFIG IVAS_RENDER_TYPE_OVERRIDE renderer_type_override; #endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_CONFIG_DATA split_rend_config; -#endif float directivity[IVAS_MAX_NUM_OBJECTS * 3]; Word16 directivity_fx[IVAS_MAX_NUM_OBJECTS * 3]; // has the following q-factor pattern: {6, 6, 15, 6, 6, 15, 6, 6, 15, 6, 6, 15} } IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE; @@ -359,9 +355,7 @@ typedef struct { int16_t numSamplesPerChannel; int16_t numChannels; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t is_cldfb; -#endif } IVAS_REND_AudioBufferConfig; typedef struct diff --git a/lib_com/delay_comp_fx.c b/lib_com/delay_comp_fx.c index 0398eb671..7bc574c3c 100644 --- a/lib_com/delay_comp_fx.c +++ b/lib_com/delay_comp_fx.c @@ -52,10 +52,8 @@ Word32 get_delay_fx( /* o : delay value in ms const Word32 io_fs, /* i : input/output sampling frequency Q0*/ const IVAS_FORMAT ivas_format, /* i : IVAS format */ HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ -#ifdef SPLIT_REND_WITH_HEAD_ROT , const AUDIO_CONFIG output_config /* i : decoder output config */ -#endif ) { Word32 delay; /*Q0*/ @@ -107,19 +105,15 @@ Word32 get_delay_fx( /* o : delay value in ms delay = IVAS_DEC_DELAY_NS; /*Q0*/ move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { -#endif if ( hCldfb != NULL ) { /* compensate for filterbank delay */ delay = L_add( delay, IVAS_FB_DEC_DELAY_NS ); /*Q0*/ } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif test(); if ( EQ_16( ivas_format, MASA_FORMAT ) || EQ_16( ivas_format, MASA_ISM_FORMAT ) ) { diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 2f34e6709..e46f901c6 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -98,10 +98,8 @@ typedef enum * input data errors * *----------------------------------------*/ IVAS_ERR_INVALID_BITSTREAM = 0x2000, -#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM, IVAS_ERR_UNEXPECTED_LC3PLUS_BITSTREAM_CONFIG, -#endif /*----------------------------------------* * hardware errors * @@ -140,10 +138,8 @@ typedef enum IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING, IVAS_ERR_INVALID_ER_PARAM, IVAS_ERR_DIRECTIVITY_PATTERN_ID_MISSING, -#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_ERR_LC3PLUS_INVALID_BITRATE, IVAS_ERR_INVALID_SPLIT_REND_CONFIG, -#endif /*----------------------------------------* * unknown error * @@ -242,12 +238,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong mode"; case IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED: return "Head rotation not supported"; -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_ERR_LC3PLUS_INVALID_BITRATE: return "Specified split rendering bit rate is not supported"; case IVAS_ERR_INVALID_SPLIT_REND_CONFIG: return "Specified split rendering configuration is invalid"; -#endif case IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED: return "External orientation not supported"; case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED: diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index d989a1f68..15a44f3b6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3699,18 +3699,11 @@ ivas_error ivas_allocate_binaural_hrtf_fx( void ivas_binRenderer_fx( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, -#endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const Word16 numTimeSlots, /* i : number of time slots to render */ -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ -#else - Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ - Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals */ -#endif Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals */ Word16 *Q_in /* i : LS signals exp */ @@ -5942,7 +5935,6 @@ float deg2rad( Word32 deg2rad_fx( Word32 degrees ); -#ifdef SPLIT_REND_WITH_HEAD_ROT void Quat2EulerDegree_fx( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ Word32 *yaw_fx, /* o : yaw */ @@ -5967,7 +5959,6 @@ void modify_Rmat_q_fx( Word16 q_cur, /* i : current q factor for rotation matrix */ Word16 q_new /* i : target q factor for rotation matrix */ ); -#endif /*=============================================================================================*/ /* clang-format off */ diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 6e31f96d5..f25c796d4 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -78,7 +78,6 @@ void Euler2Quat_fx( } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------- * Copy_Quat_fx() @@ -234,7 +233,6 @@ void Quat2EulerDegree_fx( return; } -#endif /*------------------------------------------------------------------------- * deg2rad() diff --git a/lib_com/options.h b/lib_com/options.h index e77c5a83b..4574f38d4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,10 +103,7 @@ /* #################### Start BASOP porting switches ############################ */ -#define SPLIT_REND_WITH_HEAD_ROT /* Dlb,FhG: Split Rendering contributions 21 and 35 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT #define FIX_1372_ISAR_POST_REND -#endif #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index e899d32f9..ca754b110 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1626,10 +1626,8 @@ Word32 get_delay_fx( /* o : delay value in ms const Word32 io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ HANDLE_CLDFB_FILTER_BANK hCldfb /* i : Handle of Cldfb analysis */ -#ifdef SPLIT_REND_WITH_HEAD_ROT , const AUDIO_CONFIG output_config /* i : decoder output config */ -#endif ); diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index d53d6c76d..db871d9cb 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -61,12 +61,8 @@ static void ivas_binRenderer_filterModule_fx( 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 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ const Word16 pos_idx, /* i : pose index */ -#else - BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ -#endif Word16 Q_curr ) { Word16 bandIdx, k, chIdx, tapIdx; @@ -74,25 +70,15 @@ static void ivas_binRenderer_filterModule_fx( Word16 Q_filterStates; const Word32 *filterTapsLeftRealPtr_fx, *filterTapsLeftImagPtr_fx, *filterTapsRightRealPtr_fx, *filterTapsRightImagPtr_fx; Word16 shift_q; -#ifdef SPLIT_REND_WITH_HEAD_ROT Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx]; move16(); -#else - Q_filterStates = hBinRenderer->hBinRenConvModule->Q_filterStatesLeft; - move16(); -#endif FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[pos_idx][bandIdx][chIdx][0] ); filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[pos_idx][bandIdx][chIdx][0] ); -#else - filterStatesLeftRealPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx][0] ); - filterStatesLeftImagPtr_fx = (Word32 *) &( hBinRenderer->hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx][0] ); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ filterTapsLeftRealPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx]; // Q29 filterTapsLeftImagPtr_fx = hBinRenderer->hBinRenConvModule->filterTapsLeftImag_fx[bandIdx][chIdx]; // Q29 @@ -136,11 +122,7 @@ static void ivas_binRenderer_filterModule_fx( 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 -#ifdef SPLIT_REND_WITH_HEAD_ROT hBinRenderer->hBinRenConvModule->Q_filterStates[pos_idx] = Q_curr; -#else - hBinRenderer->hBinRenConvModule->Q_filterStatesLeft = Q_curr; -#endif move16(); } @@ -194,18 +176,12 @@ static ivas_error ivas_binRenderer_convModuleOpen( const Word16 renderer_type, const Word16 isLoudspeaker, const AUDIO_CONFIG input_config, -#ifdef SPLIT_REND_WITH_HEAD_ROT const HRTFS_FASTCONV_HANDLE hHrtf, const Word16 num_poses -#else - const HRTFS_FASTCONV_HANDLE hHrtf -#endif ) { Word16 bandIdx, chIdx; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; @@ -331,7 +307,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( ( hBinRenConvModule->filterStatesLeftReal_fx = (Word32 ****) malloc( num_poses * sizeof( Word32 *** ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); @@ -388,45 +363,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } -#else - 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 = (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->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] = (Word32 **) malloc( hBinRenderer->nInChannels * 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++ ) - { - IF( ( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx] = (Word32 *) malloc( hBinRenConvModule->numTapsArray[bandIdx] * 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 ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Convolution Module \n" ) ); - } - } - } -#endif /* set memories */ FOR( bandIdx = 0; bandIdx < hBinRenderer->conv_band; bandIdx++ ) { @@ -467,12 +403,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { /* set the memories to zero */ -#ifndef SPLIT_REND_WITH_HEAD_ROT - 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(); -#endif /* !SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftBRIRReal_fx[bandIdx][tmp]; @@ -483,13 +413,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } ELSE { -#ifndef SPLIT_REND_WITH_HEAD_ROT - /* 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(); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ IF( isLoudspeaker ) { hBinRenConvModule->filterTapsLeftReal_fx[bandIdx][chIdx] = hHrtf->leftHRIRReal_fx[bandIdx][tmp]; @@ -532,7 +455,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) @@ -567,7 +489,6 @@ static ivas_error ivas_binRenderer_convModuleOpen( } } } -#endif hBinRenderer->hBinRenConvModule = hBinRenConvModule; @@ -1126,7 +1047,6 @@ static void ivas_binaural_obtain_DMX_fx( } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------- * ivas_rend_openCldfbRend() * @@ -1229,7 +1149,6 @@ ivas_error ivas_rend_openCldfbRend( return error; } -#endif /*------------------------------------------------------------------------- * ivas_binRenderer_open() @@ -1268,7 +1187,6 @@ ivas_error ivas_binRenderer_open_fx( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { hBinRenderer->numPoses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -1279,7 +1197,6 @@ ivas_error ivas_binRenderer_open_fx( hBinRenderer->numPoses = 1; move16(); } -#endif /* Declare some common variables needed for renderer */ /* Which format used for binaural rendering (needed for late reverb) ? MC or SBA */ @@ -1336,17 +1253,10 @@ ivas_error ivas_binRenderer_open_fx( IVAS_OUTPUT_SETUP out_setup; /* Allocate memories and buffers needed for convolutional module in CICP19 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, 1, IVAS_AUDIO_CONFIG_7_1_4, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif ivas_output_init( &out_setup, IVAS_AUDIO_CONFIG_7_1_4 ); IF( st_ivas->hoa_dec_mtx == NULL ) @@ -1364,17 +1274,10 @@ ivas_error ivas_binRenderer_open_fx( ELSE { /* Allocate memories and buffers needed for convolutional module */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv, hBinRenderer->numPoses ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_binRenderer_convModuleOpen( hBinRenderer, st_ivas->renderer_type, st_ivas->hIntSetup.is_loudspeaker_setup, st_ivas->hIntSetup.output_config, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) { @@ -1499,18 +1402,12 @@ ivas_error ivas_binRenderer_open_fx( * Close convolution module handle of fastconv binaural renderer *------------------------------------------------------------------------*/ static void ivas_binRenderer_convModuleClose_fx( -#ifdef SPLIT_REND_WITH_HEAD_ROT BINAURAL_RENDERER_HANDLE *hBinRenderer, /* i/o: fastconv binaural renderer handle */ const Word16 num_poses /* i : number of poses */ -#else - BINAURAL_RENDERER_HANDLE *hBinRenderer /* i/o: fastconv binaural renderer handle */ -#endif ) { Word16 bandIdx, chIdx; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 posIdx; -#endif BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; @@ -1548,7 +1445,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterTapsRightImag_fx ); hBinRenConvModule->filterTapsRightImag_fx = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( posIdx = 0; posIdx < num_poses; posIdx++ ) { FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) @@ -1574,25 +1470,6 @@ static void ivas_binRenderer_convModuleClose_fx( free( hBinRenConvModule->filterStatesLeftImag_fx[posIdx] ); hBinRenConvModule->filterStatesLeftImag_fx[posIdx] = NULL; } -#else - FOR( bandIdx = 0; bandIdx < ( *hBinRenderer )->conv_band; bandIdx++ ) - { - FOR( chIdx = 0; chIdx < ( *hBinRenderer )->nInChannels; chIdx++ ) - { - free( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[bandIdx][chIdx] = NULL; - - free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[bandIdx][chIdx] = NULL; - } - - free( hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] ); - hBinRenConvModule->filterStatesLeftReal_fx[bandIdx] = NULL; - - free( hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] ); - hBinRenConvModule->filterStatesLeftImag_fx[bandIdx] = NULL; - } -#endif free( hBinRenConvModule->filterStatesLeftReal_fx ); hBinRenConvModule->filterStatesLeftReal_fx = NULL; @@ -1623,11 +1500,7 @@ void ivas_binRenderer_close_fx( IF( ( *hBinRenderer )->hBinRenConvModule != NULL ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_binRenderer_convModuleClose_fx( hBinRenderer, ( *hBinRenderer )->numPoses ); -#else - ivas_binRenderer_convModuleClose_fx( hBinRenderer ); -#endif } IF( ( *hBinRenderer )->hReverb != NULL ) @@ -1798,29 +1671,20 @@ void ivas_binaural_add_LFE_fx( void ivas_binRenderer_fx( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, -#endif COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ const Word16 numTimeSlots, /* i : number of time slots to render */ -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ -#else - Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ - Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Binaural signals Q_in*/ -#endif Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx, num_poses; Word32 RealBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 ImagBuffer_local[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif // to be checked: feasibility with 32 bit buffers Word64 Cldfb_RealBuffer_Binaural_64fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1828,14 +1692,11 @@ void ivas_binRenderer_fx( push_wmops( "fastconv_binaural_rendering" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT num_poses = hBinRenderer->numPoses; -#endif /* Compute Convolution */ /* memory reset for the binaural output */ -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) @@ -1864,18 +1725,6 @@ void ivas_binRenderer_fx( Copy32( ImagBuffer_fx[chIdx][k], ImagBuffer_local[chIdx][k], CLDFB_NO_CHANNELS_MAX ); } } -#else - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) - { - FOR( k = 0; k < numTimeSlots; k++ ) - { - 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 ); - 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 /* Head rotation in HOA3 or CICPx */ test(); @@ -1914,11 +1763,7 @@ void ivas_binRenderer_fx( hBinRenderer->nInChannels, hBinRenderer->conv_band, numTimeSlots, hBinRenderer->hoa_dec_mtx ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, 0, *Q_in ); -#else - ivas_binRenderer_filterModule_fx( Cldfb_RealBuffer_Binaural_64fx, Cldfb_ImagBuffer_Binaural_64fx, RealBuffer_fx, ImagBuffer_fx, numTimeSlots, hBinRenderer, *Q_in ); -#endif FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -1926,22 +1771,14 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < CLDFB_NO_CHANNELS_MAX; k++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT Cldfb_RealBuffer_Binaural_fx[0][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[0][i][j][k] = W_extract_l( W_shr( Cldfb_ImagBuffer_Binaural_64fx[i][j][k], 29 ) ); //(*Q_in + 29) - 29 move32(); -#else - 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 } } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( pMultiBinPoseData != NULL ) { IF( GT_16( pMultiBinPoseData->num_poses, 1 ) ) @@ -2032,7 +1869,6 @@ void ivas_binRenderer_fx( } } } -#endif /* Obtain the binaural dmx and compute the reverb */ IF( hBinRenderer->hReverb != NULL ) @@ -2074,18 +1910,12 @@ void ivas_binRenderer_fx( { FOR( k = 0; k < numTimeSlots; k++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { /* Combine first and second parts to generate binaural output signal with room effect */ v_add_32( Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in v_add_32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[pos_idx][chIdx][k], hBinRenderer->conv_band ); // Q_in } -#else - /* Combine first and second parts to generate binaural output signal with room effect */ - v_add_32( Cldfb_RealBuffer_Binaural_fx[chIdx][k], reverbRe_fx[chIdx][k], Cldfb_RealBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in - v_add_32( Cldfb_ImagBuffer_Binaural_fx[chIdx][k], reverbIm_fx[chIdx][k], Cldfb_ImagBuffer_Binaural_fx[chIdx][k], hBinRenderer->conv_band ); // Q_in -#endif } } } @@ -2093,7 +1923,6 @@ void ivas_binRenderer_fx( return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------- * ivas_rend_CldfbMultiBinRendProcess() * @@ -2174,4 +2003,3 @@ void ivas_rend_CldfbMultiBinRendProcess( return; } -#endif diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index e843a82f9..b0bfb9fdc 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -978,9 +978,7 @@ ivas_error ivas_dirac_dec_config_fx( Word16 need_parambin; Word16 dec_param_estim_old; Word16 dec_param_estim_new; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 num_poses, pos_idx; -#endif error = IVAS_ERR_OK; move32(); @@ -1011,7 +1009,6 @@ ivas_error ivas_dirac_dec_config_fx( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT num_poses = 1; move16(); IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) @@ -1019,7 +1016,6 @@ ivas_error ivas_dirac_dec_config_fx( num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; move16(); } -#endif sparfoa_flag = 0; move16(); @@ -1067,11 +1063,7 @@ ivas_error ivas_dirac_dec_config_fx( IF( !need_parambin ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif } need_dirac_rend = 0; @@ -1144,11 +1136,7 @@ ivas_error ivas_dirac_dec_config_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] == NULL ) -#else - IF( st_ivas->hDiracDecBin == NULL ) -#endif { #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) ) @@ -1164,75 +1152,41 @@ ivas_error ivas_dirac_dec_config_fx( /* This is required to keep BE in rate switching. This probably means that 1TC and 2TC MASA perform differently. */ test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params != NULL && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->nSCE > 0 ) ) -#else - IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params != NULL && !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && st_ivas->nSCE > 0 ) ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ); // done -#else - ivas_dirac_dec_decorr_close_fx( &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params, &st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ); // done -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#endif { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* copy td-decorr flag to split renderer side rendereres */ FOR( pos_idx = 1; pos_idx < num_poses; pos_idx++ ) { st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; } IF( !st_ivas->hDiracDecBin[0]->useTdDecorr ) -#else - IF( !st_ivas->hDiracDecBin->useTdDecorr ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) -#else - IF( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params == NULL ) -#endif { Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis_fx, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, - DIRAC_SYNTHESIS_PSD_LS, frequency_axis_fx, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) - { - return error; - } -#endif } } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); move16(); } -#else - st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); - move16(); -#endif } } } @@ -2279,13 +2233,8 @@ void ivas_dirac_dec_render_sf_fx( /*CLDFB: last output channels reserved to LFT for CICPx*/ Word32 Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#else - Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif Word16 index = 0, num_freq_bands = 0; move16(); move16(); @@ -2300,7 +2249,6 @@ void ivas_dirac_dec_render_sf_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( Word16 p = 0; p < MAX_HEAD_ROT_POSES; p++ ) { FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -2312,16 +2260,6 @@ void ivas_dirac_dec_render_sf_fx( } } } -#else - 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_RealBuffer_Binaural_fx[i][j], 0, CLDFB_NO_CHANNELS_MAX ); - } - } -#endif /* local copies of azi, ele, diffuseness */ Word16 azimuth[CLDFB_NO_CHANNELS_MAX]; @@ -4093,7 +4031,6 @@ void ivas_dirac_dec_render_sf_fx( input_q = Q6; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) @@ -4110,28 +4047,19 @@ void ivas_dirac_dec_render_sf_fx( move16(); } } -#endif ivas_binRenderer_fx( st_ivas->hBinRenderer, -#ifdef SPLIT_REND_WITH_HEAD_ROT ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, -#endif st_ivas->hCombinedOrientationData, hSpatParamRendCom->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, &input_q ); -#ifndef SPLIT_REND_WITH_HEAD_ROT - 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 -#else Word16 pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { Scale_sig32( &Cldfb_RealBuffer_Binaural_fx[pos_idx][0][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[pos_idx][0][0][0], i_mult( BINAURAL_CHANNELS, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, CLDFB_NO_CHANNELS_MAX ) ), sub( Q6, input_q ) ); // Q6 } -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -4146,7 +4074,6 @@ void ivas_dirac_dec_render_sf_fx( } } } -#endif /* Inverse CLDFB*/ FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) @@ -4157,17 +4084,10 @@ void ivas_dirac_dec_render_sf_fx( Word32 *ImagBuffer_fx[MAX_PARAM_SPATIAL_SUBFRAMES]; FOR( i = 0; i < hSpatParamRendCom->subframe_nbslots[subframe_idx]; i++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; move32(); ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; move32(); -#else - RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; - move32(); - ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; - move32(); -#endif } scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( ( Q6 - 1 ), st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6-1 diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 8b0d171d5..f00ea4676 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -42,11 +42,9 @@ #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "lib_isar_pre_rend.h" #include "isar_prot.h" #include "isar_stat.h" -#endif /*-------------------------------------------------------------------* @@ -57,7 +55,6 @@ static ivas_error ivas_read_format( Decoder_Struct *st_ivas, Word16 *num_bits_re static ivas_error doSanityChecks_IVAS( Decoder_Struct *st_ivas ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error ivas_dec_reconfig_split_rend( Decoder_Struct *st_ivas ); @@ -259,7 +256,6 @@ static ivas_error ivas_dec_init_split_rend( move16(); return error; } -#endif /*-------------------------------------------------------------------* * ivas_dec_setup() @@ -729,7 +725,6 @@ ivas_error ivas_dec_setup( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * reconfig split rendering as renderer might change after bitrate switching *-----------------------------------------------------------------*/ @@ -741,7 +736,6 @@ ivas_error ivas_dec_setup( return error; } } -#endif /*----------------------------------------------------------------* * Reset bitstream pointers @@ -1182,12 +1176,8 @@ IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics *--------------------------------------------------------------------*/ test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) -#else -IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) { @@ -1377,7 +1367,6 @@ ivas_error ivas_init_decoder_fx( } #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------* * Initialize binuaral split rendering *-----------------------------------------------------------------*/ @@ -1390,7 +1379,6 @@ ivas_error ivas_init_decoder_fx( return error; } } -#endif /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles @@ -2335,7 +2323,6 @@ ivas_error ivas_init_decoder_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), @@ -2344,17 +2331,6 @@ ivas_error ivas_init_decoder_fx( IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) -#endif #endif { return error; @@ -2519,9 +2495,7 @@ ivas_error ivas_init_decoder_fx( { IF( st_ivas->hBinRenderer->render_lfe ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#endif { /* Account for filterbank delay */ binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS ); @@ -2871,14 +2845,10 @@ void ivas_initialize_handles_dec( /* rendering handles */ st_ivas->hBinRenderer = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) { st_ivas->hDiracDecBin[i] = NULL; } -#else - st_ivas->hDiracDecBin = NULL; -#endif st_ivas->hDirACRend = NULL; st_ivas->hSpatParamRendCom = NULL; st_ivas->hLsSetUpConversion = NULL; @@ -2906,13 +2876,11 @@ void ivas_initialize_handles_dec( st_ivas->hExtOrientationData = NULL; st_ivas->hCombinedOrientationData = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hSplitBinRend = NULL; for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { st_ivas->hTdRendHandles[i] = NULL; } -#endif /* JBM handles */ st_ivas->hTcBuffer = NULL; st_ivas->hJbmMetadata = NULL; @@ -3049,7 +3017,6 @@ void ivas_destroy_dec_fx( /* Fastconv binaural renderer handle */ ivas_binRenderer_close_fx( &st_ivas->hBinRenderer ); -#ifdef SPLIT_REND_WITH_HEAD_ROT /* TD binaural renderer handles */ for ( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { @@ -3059,21 +3026,12 @@ void ivas_destroy_dec_fx( ivas_td_binaural_close_fx( &st_ivas->hTdRendHandles[i] ); } } -#endif /* Parametric binaural renderer handle */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif /* Crend handle */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#endif /* Reverb handle */ ivas_reverb_close( &st_ivas->hReverb ); @@ -3244,11 +3202,7 @@ void ivas_init_dec_get_num_cldfb_instances( move16(); } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0]->useTdDecorr ) -#else - IF( st_ivas->hDiracDecBin->useTdDecorr ) -#endif { *numCldfbAnalyses = add( *numCldfbAnalyses, 2 ); move16(); @@ -3509,11 +3463,7 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx( move16(); } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0]->useTdDecorr ) -#else - IF( st_ivas->hDiracDecBin->useTdDecorr ) -#endif { *numCldfbAnalyses = add( *numCldfbAnalyses, 2 ); move16(); @@ -3801,22 +3751,16 @@ static ivas_error doSanityChecks_IVAS( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); } -#endif IF( st_ivas->hDecoderConfig->Opt_Headrotation ) { test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) -#endif { return IVAS_ERROR( IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED, "Wrong set-up: Head-rotation not supported in this configuration" ); } diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 5f431d63b..13e888af3 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -196,18 +196,10 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config ); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { /* close the parametric binaural renderer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif /* Open the TD Binaural renderer */ test(); IF( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) @@ -244,32 +236,14 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { /* close the parametric binaural renderer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif /* Open Crend Binaural renderer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) - { - return error; - } -#else - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) -#endif - { - return error; - } -#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; move32(); @@ -287,11 +261,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { /* open the parametric binaural renderer */ IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) @@ -344,11 +314,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } /* close the crend binaural renderer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#endif } } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 5552b3dc2..09e3c0e6c 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -527,11 +527,7 @@ static ivas_error ivas_param_ism_rendering_init_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) -#endif { /* computation of proto matrix */ ivas_ism_get_proto_matrix_fx( hOutSetup, nchan_transport, hParamIsmRendering->proto_matrix_fx ); @@ -708,13 +704,8 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( !( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) -#endif { /* Initialize efap handle */ IF( NE_32( ( error = efap_init_data_fx( &( st_ivas->hEFAPdata ), hOutSetup.ls_azimuth_fx, hOutSetup.ls_elevation_fx, hOutSetup.nchan_out_woLFE, EFAP_MODE_EFAP ) ), IVAS_ERR_OK ) ) @@ -737,11 +728,7 @@ ivas_error ivas_param_ism_dec_open_fx( test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { IF( NE_32( ( error = ivas_dirac_allocate_parameters_fx( hSpatParamRendCom, 1 ) ), IVAS_ERR_OK ) ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6a0d49bfe..c21f182da 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1623,7 +1623,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( test(); test(); /* delay the objects here for all renderers where it is needed */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || @@ -1632,14 +1631,6 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) && ( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( - EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || - EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || - EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || - EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) || - EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) -#endif { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -1843,9 +1834,7 @@ ivas_error ivas_jbm_dec_render_fx( const Word16 output_q_factor = Q11; move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 nchan_out_syn_output; -#endif push_wmops( "ivas_dec_render" ); /*----------------------------------------------------------------* @@ -2017,7 +2006,6 @@ ivas_error ivas_jbm_dec_render_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Binaural rendering */ IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { @@ -2036,16 +2024,6 @@ ivas_error ivas_jbm_dec_render_fx( } } } -#else - /* Binaural rendering */ - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) - { - IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) - { - return error; - } - } -#endif ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; @@ -2065,17 +2043,10 @@ ivas_error ivas_jbm_dec_render_fx( scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( 11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q11 } -#if defined SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif FOR( i = 0; i < nchan_out; i++ ) { @@ -2295,7 +2266,6 @@ ivas_error ivas_jbm_dec_render_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, @@ -2306,28 +2276,16 @@ ivas_error ivas_jbm_dec_render_fx( } else { -#endif -#if defined SPLIT_REND_WITH_HEAD_ROT 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, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } -#else - 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, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ), - IVAS_ERR_OK ) ) - { - return error; - } -#endif ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif FOR( i = 0; i < nchan_in; i++ ) { @@ -2351,7 +2309,6 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { IF( NE_32( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) @@ -2361,16 +2318,13 @@ ivas_error ivas_jbm_dec_render_fx( } else { -#endif IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; } ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx ); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) @@ -2382,10 +2336,8 @@ ivas_error ivas_jbm_dec_render_fx( /* Rendering */ IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) && !st_ivas->hDecoderConfig->Opt_Headrotation ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT /*handled in CLDFB domain already*/ IF( NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#endif { ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_output_fx, p_output_fx ); } @@ -2595,7 +2547,6 @@ ivas_error ivas_jbm_dec_render_fx( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( i = 0; i < st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS; i++ ) @@ -2607,7 +2558,6 @@ ivas_error ivas_jbm_dec_render_fx( move16(); IF( st_ivas->hDecoderConfig->Opt_Limiter ) -#endif { IF( NE_32( st_ivas->ivas_format, MONO_FORMAT ) ) { @@ -2617,11 +2567,7 @@ ivas_error ivas_jbm_dec_render_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out_syn_output, data ); -#else - ivas_syn_output_fx( p_output_fx, output_q_factor, *nSamplesRendered, nchan_out, data ); -#endif *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available; move16(); @@ -2660,9 +2606,6 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; #endif Word16 nchan_in, nchan_out; -#ifndef SPLIT_REND_WITH_HEAD_ROT - Word16 gd_bits, shift, n_chan_inp, i; -#endif IF( !st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_OK; @@ -2757,47 +2700,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); -#if defined SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } -#else - shift = MAX_16; - move16(); - n_chan_inp = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); - - FOR( i = 0; i < n_chan_inp; i++ ) - { - shift = s_min( shift, L_norm_arr( p_output_fx[i], hTcBuffer->n_samples_granularity ) ); - } - - gd_bits = sub( find_guarded_bits_fx( imult1616( hTcBuffer->subframe_nbslots[0], hTcBuffer->n_samples_granularity ) ), shift ); - - *st_ivas->hCrendWrapper->p_io_qfactor = sub( *st_ivas->hCrendWrapper->p_io_qfactor, gd_bits ); - move16(); - - FOR( i = 0; i < n_chan_inp; i++ ) - { - scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q(*st_ivas->hCrendWrapper->p_io_qfactor) - } - - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, - NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) - { - return error; - } - - FOR( i = 0; i < n_chan_inp; i++ ) - { - scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q(11) - } - *st_ivas->hCrendWrapper->p_io_qfactor = Q11; - move16(); -#endif } } ELSE @@ -2825,21 +2733,12 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *st_ivas->hCrendWrapper->p_io_qfactor = 11; move16(); -#if defined SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - hIntSetupOld, st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ), - IVAS_ERR_OK ) ) - { - return error; - } -#endif ivas_binaural_add_LFE_fx( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx ); } @@ -2957,9 +2856,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( *nSamplesRendered = n_samples_to_render; move16(); /* Only write out the valid data*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDecoderConfig->Opt_Limiter ) -#endif { IF( NE_16( st_ivas->ivas_format, MONO_FORMAT ) ) { diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index e87683562..8bf808ed6 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1589,9 +1589,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; ivas_error error; Word32 ism_total_brate; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif error = IVAS_ERR_OK; move16(); @@ -1622,13 +1620,8 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] == NULL ) ) -#else - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend == NULL ) || - ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin == NULL ) ) -#endif { /* init a new DirAC dec */ if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) @@ -1641,11 +1634,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( st_ivas->hDirAC != NULL ) { /* close all unnecessary parametric decoding and rendering */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); @@ -1696,11 +1685,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) -#else - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) -#endif { if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { @@ -1756,11 +1741,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) -#else - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) -#endif { if ( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) ) { @@ -1778,11 +1759,7 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin[0] != NULL ) ) -#else - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) && st_ivas->hDirACRend != NULL ) || ( ( EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) && st_ivas->hDiracDecBin != NULL ) ) -#endif { if ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) { @@ -1792,7 +1769,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { IF( st_ivas->hDiracDecBin[pos_idx] != NULL ) @@ -1802,14 +1778,6 @@ ivas_error ivas_masa_dec_reconfigure_fx( move16(); } } -#else - IF( st_ivas->hDiracDecBin != NULL ) - { - /* regularization factor is bitrate-dependent */ - st_ivas->hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); - move16(); - } -#endif test(); IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching within OMASA is handled in ivas_omasa_dec_config() */ @@ -1817,17 +1785,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] != NULL ) -#else - IF( st_ivas->hDiracDecBin != NULL ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2064,11 +2024,7 @@ void ivas_spar_param_to_masa_param_mapping_fx( move16(); hSpatParamRendCom->numSimultaneousDirections = 1; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT hDiffuseDist = st_ivas->hDiracDecBin[0]->hDiffuseDist; -#else - hDiffuseDist = st_ivas->hDiracDecBin->hDiffuseDist; -#endif nchan_transport = st_ivas->nchan_transport; move16(); band_grouping = hDirAC->band_grouping; diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index c49978058..1ee6d6ced 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1849,13 +1849,8 @@ void ivas_param_mc_dec_render_fx( /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#else - Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { @@ -2137,7 +2132,6 @@ void ivas_param_mc_dec_render_fx( Word16 input_q = 6; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { IF( st_ivas->hSplitBinRend->hCldfbDataOut != NULL ) @@ -2154,13 +2148,10 @@ void ivas_param_mc_dec_render_fx( move16(); } } -#endif /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, -#ifdef SPLIT_REND_WITH_HEAD_ROT ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, -#endif st_ivas->hCombinedOrientationData, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, @@ -2179,7 +2170,6 @@ void ivas_param_mc_dec_render_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { @@ -2192,18 +2182,7 @@ void ivas_param_mc_dec_render_fx( } } } -#else - 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 -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -2218,7 +2197,6 @@ void ivas_param_mc_dec_render_fx( } } } -#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, hParamMC->num_freq_bands * hParamMC->subframe_nbslots[subframe_idx] ); } @@ -2242,13 +2220,8 @@ void ivas_param_mc_dec_render_fx( { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[0][ch][i]; // Q6 ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[0][ch][i]; // Q6 -#else - RealBuffer_fx[i] = Cldfb_RealBuffer_Binaural_fx[ch][i]; // Q6 - ImagBuffer_fx[i] = Cldfb_ImagBuffer_Binaural_fx[ch][i]; // Q6 -#endif } ELSE { diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index eab782f8b..89a86d21a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -732,22 +732,15 @@ static void ivas_mc_paramupmix_dec_sf( Word32 Cldfb_RealBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; Word32 Cldfb_ImagBuffer_subfr_fx[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX] = { 0 }; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; int16_t slot_index_start; -#else - Word32 Cldfb_RealBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; - Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; -#endif hMCParamUpmix = st_ivas->hMCParamUpmix; assert( hMCParamUpmix ); push_wmops( "ivas_mc_paramupmix_dec_sf" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT slot_index_start = st_ivas->hTcBuffer->slots_rendered; -#endif FOR( i = 0; i < MC_PARAMUPMIX_COMBINATIONS; i++ ) { @@ -864,7 +857,6 @@ static void ivas_mc_paramupmix_dec_sf( Word16 input_q = 6; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT /*LFE handling for split rendering cases*/ IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -883,20 +875,16 @@ static void ivas_mc_paramupmix_dec_sf( move16(); } } -#endif /* Implement binaural rendering */ ivas_binRenderer_fx( st_ivas->hBinRenderer, -#ifdef SPLIT_REND_WITH_HEAD_ROT ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, -#endif st_ivas->hCombinedOrientationData, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx], Cldfb_RealBuffer_Binaural_fx, Cldfb_ImagBuffer_Binaural_fx, Cldfb_RealBuffer_subfr_fx, Cldfb_ImagBuffer_subfr_fx, &input_q ); -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) { @@ -909,18 +897,7 @@ static void ivas_mc_paramupmix_dec_sf( } } } -#else - 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 -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ ) @@ -935,7 +912,6 @@ static void ivas_mc_paramupmix_dec_sf( } } } -#endif /* Implement CLDFB synthesis */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) @@ -945,13 +921,8 @@ static void ivas_mc_paramupmix_dec_sf( FOR( slot_idx = 0; slot_idx < st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_idx++ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx]; // Q6 -#else - RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[ch][slot_idx]; // Q6 - ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[ch][slot_idx]; // Q6 -#endif } #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 diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 5c9deed2d..ed43b9991 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1470,11 +1470,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { /* remove unneeded binaural renderers */ test(); @@ -1489,17 +1485,9 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) ) -#else - IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); -#endif } test(); @@ -1512,21 +1500,13 @@ static ivas_error ivas_mc_dec_reconfig_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] != NULL ) -#else - IF( st_ivas->hDiracDecBin != NULL ) -#endif { test(); test(); IF( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); -#else - ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); -#endif } } @@ -1551,46 +1531,25 @@ static ivas_error ivas_mc_dec_reconfig_fx( } IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) -#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hCrendWrapper->hCrend[0] = NULL; st_ivas->hCrendWrapper->hHrtfCrend = NULL; IF( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); } -#else - st_ivas->hCrendWrapper->hCrend = NULL; - st_ivas->hCrendWrapper->hHrtfCrend = NULL; - IF( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); - } -#endif } } ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) #else IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) -#endif #endif { return error; diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 1b174493d..9c603fa93 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -296,7 +296,6 @@ ivas_error ivas_td_binaural_renderer_sf_fx( return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * ivas_td_binaural_renderer_sf_splitBinaural() * @@ -450,4 +449,3 @@ ivas_error ivas_td_binaural_renderer_sf_splitBinaural( return IVAS_ERR_OK; } -#endif diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 9d8b43515..35f4f1c4b 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -419,17 +419,9 @@ ivas_error ivas_omasa_dec_config_fx( * TD Decorrelator *-----------------------------------------------------------------*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] != NULL ) -#else - IF( st_ivas->hDiracDecBin != NULL ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -763,12 +755,10 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( Word32 *p_sepobj_fx[MAX_NUM_OBJECTS]; // Q11 Word32 data_separated_objects_fx[MAX_NUM_OBJECTS][L_FRAME48k]; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); -#endif FOR( n = 0; n < MAX_NUM_OBJECTS; n++ ) { @@ -782,7 +772,6 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( /* reset combined orientation access index before calling the td renderer */ ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { Word16 slot_idx, num_cldfb_bands, nchan_transport_orig, cldfb_slots; @@ -835,7 +824,6 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( } else { -#endif IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; @@ -845,9 +833,7 @@ ivas_error ivas_omasa_dirac_td_binaural_jbm_fx( { v_add_fx( output_fx[n], p_sepobj_fx[n], output_fx[n], *nSamplesRendered ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 87805290b..a8754d84f 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -137,12 +137,10 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; Word16 channel_offset; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 slot_idx_start; slot_idx_start = st_ivas->hSpatParamRendCom->slots_rendered; move16(); -#endif FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) { @@ -162,7 +160,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { Word16 slot_idx, num_cldfb_bands, b, nchan_transport_orig; @@ -217,7 +214,6 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( } else { -#endif IF( NE_32( ( error = ivas_td_binaural_renderer_sf_fx( st_ivas, p_sepobj_fx, *nSamplesRendered ) ), IVAS_ERR_OK ) ) { return error; @@ -232,9 +228,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( move32(); } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index 4a3362cd2..bdf7b67bc 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -80,11 +80,7 @@ void ivas_renderer_select( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { test(); test(); @@ -95,11 +91,7 @@ void ivas_renderer_select( { IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -113,11 +105,7 @@ void ivas_renderer_select( ELSE /* ISM_MODE_DISC */ { test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { *renderer_type = RENDERER_BINAURAL_OBJECTS_TD; move16(); @@ -137,11 +125,7 @@ void ivas_renderer_select( { *internal_config = output_config; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -158,11 +142,7 @@ void ivas_renderer_select( move16(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { *renderer_type = RENDERER_BINAURAL_FASTCONV; move16(); @@ -217,11 +197,7 @@ void ivas_renderer_select( *internal_config = output_config; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { *renderer_type = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -237,11 +213,7 @@ void ivas_renderer_select( *internal_config = transport_config; move16(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { test(); test(); diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 121b8a795..8f8a7f486 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -183,11 +183,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) -#endif { RENDERER_TYPE renderer_type_new; Word16 sba_order_internal; @@ -198,11 +194,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* copy the logic from ivas_renderer_select(), because calling this function has too many side effects that would affect the flushing */ IF( LE_16( ivas_get_sba_num_TCs_fx( ivas_total_brate, sba_order_internal ), 2 ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { renderer_type_new = RENDERER_BINAURAL_PARAMETRIC; move16(); @@ -216,11 +208,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( ELSE { test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) ) -#endif { renderer_type_new = RENDERER_BINAURAL_FASTCONV; move16(); @@ -639,7 +627,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( * TD Decorrelator *-----------------------------------------------------------------*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] != NULL ) { IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin[0]->hTdDecorr ), &( st_ivas->hDiracDecBin[0]->useTdDecorr ) ) ), IVAS_ERR_OK ) ) @@ -647,15 +634,6 @@ ivas_error ivas_sba_dec_reconfigure_fx( return error; } } -#else - IF( st_ivas->hDiracDecBin != NULL ) - { - IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( st_ivas->hDiracDecBin->hTdDecorr ), &( st_ivas->hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) - { - return error; - } - } -#endif /*-----------------------------------------------------------------* * CLDFB instances @@ -805,11 +783,7 @@ void ivas_sba_dec_digest_tc_fx( ivas_spar_dec_digest_tc_fx( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) -#else - IF( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) -#endif { Word16 nSamplesLeftForTD, default_frame; Word32 *decorr_signal[BINAURAL_CHANNELS]; @@ -832,17 +806,9 @@ void ivas_sba_dec_digest_tc_fx( { Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); /*Q0*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( st_ivas->hDiracDecBin[0]->hTdDecorr ) -#else - IF( st_ivas->hDiracDecBin->hTdDecorr ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_td_decorr_process_fx( st_ivas->hDiracDecBin[0]->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); -#else - ivas_td_decorr_process_fx( st_ivas->hDiracDecBin->hTdDecorr, p_tc, decorr_signal, nSamplesToDecorr ); -#endif } FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 530614fe9..7f12c592e 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -2036,13 +2036,8 @@ void ivas_spar_dec_upmixer_sf_fx( test(); test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) && !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) -#else - IF( ( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) || !( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) && - !( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) -#endif { FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c6f06f142..d7736e244 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -860,34 +860,8 @@ typedef struct renderer_struct } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; -#ifndef SPLIT_REND_WITH_HEAD_ROT -/* Fastconv binaural data structure */ -typedef struct ivas_binaural_rendering_struct -{ - /* Common variables for all modules */ - IVAS_OUTPUT_SETUP_HANDLE hInputSetup; /* pointer to input spatial format for binaural renderer*/ - EFAP_HANDLE hEFAPdata; /* EFAP structure*/ - Word32 *hoa_dec_mtx; /* pointer to HOA decoder mtx */ /*Q29*/ - Word8 rotInCldfb; /* Flag to enable rotation within bin Renderer in CLDFB*/ - Word16 max_band; /* band upto which rendering is performed */ - Word16 conv_band; /* band upto which convolution in cldfb domain is performed */ - Word16 timeSlots; /* number of time slots of binaural renderer */ - Word16 nInChannels; /* number input channels */ - Word8 render_lfe; /* Flag to render LFE in binaural rendering*/ - IVAS_FORMAT ivas_format; /* format; corresponds to st_ivas->ivas_format, unless the signal gets transormed to a different domain for rendering */ - - /* Convolution module structure */ - BINRENDERER_CONV_MODULE_HANDLE_FX hBinRenConvModule; - - /* Variables related to reverberator module */ - Word32 earlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; - REVERB_STRUCT_HANDLE hReverb; - -} BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * IVAS decoder specific ISAR wrapper structures *----------------------------------------------------------------------------------*/ @@ -917,7 +891,6 @@ typedef struct Word16 numTdSamplesPerChannelCached; } ISAR_DEC_SPLIT_REND_WRAPPER, *ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE; -#endif /*----------------------------------------------------------------------------------* * MASA decoder structures @@ -1062,9 +1035,7 @@ typedef struct decoder_config_structure Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; Word16 Opt_delay_comp; /* flag indicating delay compensation active */ -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t Opt_Limiter; -#endif } DECODER_CONFIG, *DECODER_CONFIG_HANDLE; @@ -1141,11 +1112,7 @@ typedef struct Decoder_Struct BINAURAL_RENDERER_HANDLE hBinRenderer; /* fastconv binaural renderer handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd; /* Time domain binaural object renderer handle */ TDREND_HRFILT_FiltSet_t *hHrtfTD; /* pointer to HRTF data for TD renderer */ -#ifdef SPLIT_REND_WITH_HEAD_ROT DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; /* parametric binaural renderer handle */ -#else - DIRAC_DEC_BIN_HANDLE hDiracDecBin; /* parametric binaural renderer handle */ -#endif LSSETUP_CONVERSION_HANDLE hLsSetUpConversion; /* MC LS configuration convertion handle */ EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ @@ -1172,10 +1139,8 @@ typedef struct Decoder_Struct Word16 flag_omasa_brate; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE hSplitBinRend; /* ISAR split binaural rendering handle */ BINAURAL_TD_OBJECT_RENDERER_HANDLE hTdRendHandles[MAX_HEAD_ROT_POSES - 1]; -#endif /* JBM module */ DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM structure */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d7a110a37..28b8594fe 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -144,7 +144,6 @@ ivas_error IVAS_DEC_GetSamples( bool *needNewFrame /* o : indication that the decoder needs a new frame */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_DEC_GetSplitBinauralBitstream( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ Word16 *pcmBuf_out, /* o : output synthesis signal for BINAURAL_SPLIT_PCM */ @@ -179,7 +178,6 @@ int16_t IVAS_DEC_is_split_rendering_enabled( int16_t IVAS_DEC_is_split_rendering_coded_out( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); -#endif /*! r: error code */ ivas_error IVAS_DEC_GetObjectMetadata( @@ -201,12 +199,8 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 subframe_idx, /* i : subframe index */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ -#else - const Word16 subframe_idx /* i : subframe index */ -#endif ); /*! r: error code */ @@ -283,12 +277,10 @@ ivas_error IVAS_DEC_EnableVoIP( const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT /*! r: error code */ ivas_error IVAS_DEC_EnableSplitRendering( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); -#endif ivas_error IVAS_DEC_SetRenderFramesize( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index de939c5b0..dd5db0071 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -114,11 +114,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 SPLIT_REND_WITH_HEAD_ROT static ivas_error isar_set_split_rend_setup( ISAR_DEC_SPLIT_REND_WRAPPER *hSplitBinRend, const ISAR_SPLIT_REND_CONFIG_DATA *hSplitBinConfig, const COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, ISAR_SPLIT_REND_BITS_DATA *splitRendBits ); static ivas_error ivas_create_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); static void ivas_destroy_handle_isar( ISAR_DEC_SPLIT_REND_WRAPPER_HANDLE *hSplitBinRend_out ); -#endif /*---------------------------------------------------------------------* * IVAS_DEC_Open() @@ -276,7 +274,6 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_WRONG_PARAMS; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------------* * isar_set_split_rend_setup() * @@ -313,7 +310,6 @@ static ivas_error isar_set_split_rend_setup( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* * init_decoder_config() @@ -336,10 +332,8 @@ static void init_decoder_config( hDecoderConfig->Opt_non_diegetic_pan = 0; hDecoderConfig->non_diegetic_pan_gain_fx = 0; // Q15 hDecoderConfig->Opt_tsm = 0; -#ifdef SPLIT_REND_WITH_HEAD_ROT hDecoderConfig->Opt_Limiter = 1; move16(); -#endif hDecoderConfig->Opt_delay_comp = 0; hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; @@ -386,10 +380,8 @@ void IVAS_DEC_Close( ( *phIvasDec )->hVoIP = NULL; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* destroy Split binaural renderer (ISAR) handle */ ivas_destroy_handle_isar( &( *phIvasDec )->st_ivas->hSplitBinRend ); -#endif IF( ( *phIvasDec )->st_ivas ) { @@ -576,13 +568,11 @@ ivas_error IVAS_DEC_Configure( move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { hDecoderConfig->Opt_Headrotation = TRUE; move16(); } -#endif /* Set decoder parameters to initial values */ IF( NE_32( ( error = ivas_init_decoder_front( st_ivas ) ), IVAS_ERR_OK ) ) @@ -590,7 +580,6 @@ ivas_error IVAS_DEC_Configure( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* create ISAR handle */ IF( EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -599,7 +588,6 @@ ivas_error IVAS_DEC_Configure( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for ISAR handle" ); } } -#endif if ( EQ_16( hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { @@ -622,7 +610,6 @@ ivas_error IVAS_DEC_Configure( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * IVAS_DEC_EnableSplitRendering( ) * @@ -658,7 +645,6 @@ ivas_error IVAS_DEC_EnableSplitRendering( return error; } -#endif /*---------------------------------------------------------------------* * get_render_framesize_ms( ) @@ -1121,7 +1107,6 @@ ivas_error IVAS_DEC_GetSamples( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------* * Binaural split rendering setup *----------------------------------------------------------------*/ @@ -1133,7 +1118,6 @@ ivas_error IVAS_DEC_GetSamples( isar_set_split_rend_ht_setup_fx( &hIvasDec->st_ivas->hSplitBinRend->splitrend, hIvasDec->st_ivas->hCombinedOrientationData->Quaternions, hIvasDec->st_ivas->hCombinedOrientationData->Rmat_fx ); } } -#endif hIvasDec->updateOrientation = false; move16(); @@ -1297,7 +1281,6 @@ return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitBinauralBitstream( ) * @@ -1555,7 +1538,6 @@ IVAS_DEC_GetSplitBinauralBitstream( return error; } -#endif /*---------------------------------------------------------------------* @@ -2226,12 +2208,8 @@ ivas_error IVAS_DEC_FeedHeadTrackData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ IVAS_VECTOR3 Pos, /* i : listener position */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 subframe_idx, /* i : subframe index */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ -#else - const Word16 subframe_idx /* i : subframe index */ -#endif ) { HEAD_TRACK_DATA_HANDLE hHeadTrackData; @@ -2252,19 +2230,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData( /* Move head-tracking data to the decoder handle */ /* check for Euler angle signaling */ -#ifdef SPLIT_REND_WITH_HEAD_ROT /* check for Euler angle signaling */ IF( EQ_32( orientation.w_fx, L_negate( 12582912 ) ) && EQ_16( orientation.q_fact, Q22 ) ) { Euler2Quat_fx( deg2rad_fx( orientation.x_fx ), deg2rad_fx( orientation.y_fx ), deg2rad_fx( orientation.z_fx ), &orientation ); modify_Quat_q_fx( &orientation, &orientation, Q29 ); } -#else - IF( EQ_32( orientation.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) - { - Euler2Quat_fx( deg2rad_fx( orientation.x_fx ), deg2rad_fx( orientation.y_fx ), deg2rad_fx( orientation.z_fx ), &orientation ); - } -#endif Word32 updateRate_fx = 1677721600; // value is 200 in Q23 move32(); @@ -2302,10 +2273,8 @@ ivas_error IVAS_DEC_FeedHeadTrackData( move32(); move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT hHeadTrackData->sr_pose_pred_axis = rot_axis; move32(); -#endif hIvasDec->updateOrientation = true; move16(); @@ -2644,7 +2613,6 @@ static ivas_error copyRendererConfigStruct( Copy32( hRCin->roomAcoustics.pAcoustic_dsr_fx, hRCout->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); // Q30 Copy( hRCin->directivity_fx, hRCout->directivity_fx, 3 * MAX_NUM_OBJECTS ); -#ifdef SPLIT_REND_WITH_HEAD_ROT hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; @@ -2665,7 +2633,6 @@ static ivas_error copyRendererConfigStruct( move32(); move32(); move32(); -#endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; hRCout->roomAcoustics.lowComplexity = hRCin->roomAcoustics.lowComplexity; @@ -2731,9 +2698,7 @@ ivas_error IVAS_DEC_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error error; -#endif test(); test(); @@ -2772,7 +2737,6 @@ ivas_error IVAS_DEC_FeedRenderConfig( Copy( renderConfig.directivity_fx, hRenderConfig->directivity_fx, 3 * MAX_NUM_OBJECTS ); -#ifdef SPLIT_REND_WITH_HEAD_ROT hRenderConfig->split_rend_config = renderConfig.split_rend_config; /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ @@ -2785,7 +2749,6 @@ ivas_error IVAS_DEC_FeedRenderConfig( { return error; } -#endif return IVAS_ERR_OK; } @@ -2841,13 +2804,8 @@ ivas_error IVAS_DEC_GetDelay( } move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], hDecoderConfig->output_config ) ); move16(); -#else - nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0] ) ); - move16(); -#endif nSamples[2] = extract_l( W_round64_L( W_mult0_32_32( L_shl( st_ivas->binaural_latency_ns, 1 ), out_fs_fx ) ) ); move16(); nSamples[0] = add( nSamples[1], nSamples[2] ); @@ -3675,11 +3633,7 @@ static ivas_error printConfigInfo_dec( test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) ) -#else - IF( ( EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( (Word16) output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) -#endif { fprintf( stdout, "Render framesize: %dms\n", get_render_frame_size_ms( st_ivas->hDecoderConfig->render_framesize ) ); } @@ -4074,7 +4028,6 @@ static ivas_error IVAS_DEC_VoIP_reconfigure( } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*---------------------------------------------------------------------* * IVAS_DEC_GetSplitRendBitstreamHeader() * @@ -4279,4 +4232,3 @@ Word16 IVAS_DEC_is_split_rendering_coded_out( return isSplitCoded; } -#endif diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 8b20cab7d..32c26be28 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -1572,13 +1572,8 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef SPLIT_REND_WITH_HEAD_ROT *delay = NS2SA_FX2( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, IVAS_AUDIO_CONFIG_INVALID ) ); move16(); -#else - *delay = NS2SA_FX2( hEncoderConfig->input_Fs, get_delay_fx( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL ) ); /*Q0*/ - move16(); -#endif *delay = imult1616( *delay, hEncoderConfig->nchan_inp ); /*Q0*/ move16(); diff --git a/lib_isar/isar_MSPred.c b/lib_isar/isar_MSPred.c index 1df47d695..040fcc3a9 100644 --- a/lib_isar/isar_MSPred.c +++ b/lib_isar/isar_MSPred.c @@ -32,7 +32,6 @@ #include "options.h" #include -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_rom_tables.h" #include "isar_lcld_prot.h" #include "isar_prot.h" @@ -547,4 +546,3 @@ void writeMSPred( return; } #endif -#endif diff --git a/lib_isar/isar_NoiseGen.c b/lib_isar/isar_NoiseGen.c index 7273b0e81..1a6881681 100644 --- a/lib_isar/isar_NoiseGen.c +++ b/lib_isar/isar_NoiseGen.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "prot_fx.h" #include "isar_lcld_prot.h" @@ -55,4 +54,3 @@ void DeleteNoiseGen( NoiseGen *psNoiseGen ) extern float GetNoise( NoiseGen *psNoiseGen ); extern Word32 GetNoise_fx( NoiseGen *psNoiseGen ); -#endif diff --git a/lib_isar/isar_PerceptualModel.c b/lib_isar/isar_PerceptualModel.c index 16558dd36..b9a5b1b33 100644 --- a/lib_isar/isar_PerceptualModel.c +++ b/lib_isar/isar_PerceptualModel.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" #include "prot_fx.h" #include "isar_lcld_rom_tables.h" @@ -466,4 +465,3 @@ void PerceptualModelStereo_fx( return; } -#endif diff --git a/lib_isar/isar_PredDecoder.c b/lib_isar/isar_PredDecoder.c index b30a6e0a8..a202aaa1c 100644 --- a/lib_isar/isar_PredDecoder.c +++ b/lib_isar/isar_PredDecoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "prot_fx.h" #include "isar_prot.h" @@ -492,4 +491,3 @@ void ApplyInversePredictors_fx( return; } -#endif diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index 0cd32b70c..8eed33ca6 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" @@ -1212,4 +1211,3 @@ Word32 WritePredictors( return iBitsWritten; } -#endif diff --git a/lib_isar/isar_RMSEnvGrouping.c b/lib_isar/isar_RMSEnvGrouping.c index 9b5de2574..9a7b2ba54 100644 --- a/lib_isar/isar_RMSEnvGrouping.c +++ b/lib_isar/isar_RMSEnvGrouping.c @@ -34,7 +34,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "prot_fx.h" #include "isar_lcld_prot.h" @@ -961,4 +960,3 @@ void ComputeEnvelopeGrouping( return; } -#endif diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index ad6bf483a..4aef03cf2 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -38,7 +38,6 @@ /* clang-format off */ -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * Split Binaural Rendering Constants @@ -147,7 +146,6 @@ typedef enum #define SPLIT_REND_512k 512000 #define SPLIT_REND_768k 768000 -#endif /*SPLIT_REND_WITH_HEAD_ROT */ #endif /*ISAR_CNST_H */ /* clang-format on */ diff --git a/lib_isar/isar_lc3plus_common.c b/lib_isar/isar_lc3plus_common.c index 6a4ef18ed..5c56c0b43 100644 --- a/lib_isar/isar_lc3plus_common.c +++ b/lib_isar/isar_lc3plus_common.c @@ -35,7 +35,6 @@ #include "ivas_error.h" #include "lc3.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------------------------------* * Function ISAR_LC3PLUS_LC3plusErrToIvasErr() * @@ -84,4 +83,3 @@ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtp return IVAS_ERR_UNKNOWN; } -#endif diff --git a/lib_isar/isar_lc3plus_common.h b/lib_isar/isar_lc3plus_common.h index 6042e8859..2638ea8a9 100644 --- a/lib_isar/isar_lc3plus_common.h +++ b/lib_isar/isar_lc3plus_common.h @@ -37,7 +37,6 @@ #include #include "options.h" #include "ivas_error.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "lc3.h" #include "isar_lc3plus_payload.h" @@ -62,5 +61,4 @@ ivas_error ISAR_LC3PLUS_LC3plusErrToIvasErr( const LC3PLUS_Error lc3PlusError ); /*! utility function to convert LC3PLUS_Errors to the suitable ivas_error */ ivas_error IVAS_LC3PLUS_LC3plusRtpErrToIvasErr( const LC3PLUS_RTP_ERR lc3PlusRtpError ); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_COM_H */ diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index 5a82dc13c..ea19833ba 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -40,7 +40,6 @@ #include "ivas_error_utils.h" #include "wmc_auto.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT @@ -559,4 +558,3 @@ ivas_error ISAR_LC3PLUS_DEC_Conceal( return isar_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, 0, badFrameIndicator, pcm_out ); } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_dec.h b/lib_isar/isar_lc3plus_dec.h index f946a6402..f3e969940 100644 --- a/lib_isar/isar_lc3plus_dec.h +++ b/lib_isar/isar_lc3plus_dec.h @@ -35,7 +35,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "lc3.h" #include "ivas_error.h" #include "ivas_cnst.h" @@ -107,5 +106,4 @@ ivas_error ISAR_LC3PLUS_DEC_Conceal( ); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_DEC_H */ diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 1de448423..467db9116 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -77,7 +77,6 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, return -1; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * Function ISAR_LC3PLUS_ENC_Open() * @@ -582,4 +581,3 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( return IVAS_ERR_OK; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index 5487f712c..eeef615fc 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -35,7 +35,6 @@ #include #include "ivas_error.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "lc3.h" #include "isar_lc3plus_common.h" #include "typedef.h" @@ -85,6 +84,5 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( void *bitstream_out, /* o : pointer to bitstream frame */ const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ Word16 q_in[16] ); -#endif #endif /* ISAR_LC3PLUS_ENC_H */ diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index 54895c78b..291cd9d05 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -36,7 +36,6 @@ #include "isar_lc3plus_payload.h" #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT static LC3PLUS_RTP_ERR s_frame_duration_ms_from_fdi( int32_t *frame_duration_us, const LC3PLUS_RTP_FTD_FDI fdi ) { if ( NULL == frame_duration_us ) @@ -818,4 +817,3 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_isar/isar_lc3plus_payload.h b/lib_isar/isar_lc3plus_payload.h index 0eadc96a8..e95128578 100644 --- a/lib_isar/isar_lc3plus_payload.h +++ b/lib_isar/isar_lc3plus_payload.h @@ -38,7 +38,6 @@ #include "lc3.h" #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Implementation of the "B.2.6 Table of contents" part of the RTP payload format * for LC3plus as specified in ETSI TS 103 634. */ @@ -210,5 +209,4 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_payload_deserialize( uint8_t *serialized_buffer, const size_t serialized_buffer_size ); -#endif /* #ifdef SPLIT_REND_WITH_HEAD_ROT */ #endif /* ISAR_LC3PLUS_PAYLOAD_H */ diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index a64a12aea..83f6261ee 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" #include "isar_lcld_rom_tables.h" #include "prot_fx.h" @@ -1992,4 +1991,3 @@ static void ComputeAllocation( return; } -#endif diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 48445d080..327edb6ad 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include #include "isar_lcld_prot.h" @@ -2139,4 +2138,3 @@ static Word32 ComputeAllocation( } return iBitsUsed; } -#endif diff --git a/lib_isar/isar_lcld_prot.h b/lib_isar/isar_lcld_prot.h index 49e03f5ef..3f79a2c12 100644 --- a/lib_isar/isar_lcld_prot.h +++ b/lib_isar/isar_lcld_prot.h @@ -34,7 +34,6 @@ #define ISAR_LCLD_PROT_H #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "typedef.h" #include "common_api_types.h" #include "isar_lcld_rom_tables.h" @@ -450,7 +449,6 @@ void ComputeEnvelopeGrouping( Word16 q_final ); -#endif /* clang-format on */ #endif /* _LCLD_ENCODER_H_ */ diff --git a/lib_isar/isar_lcld_rom_tables.c b/lib_isar/isar_lcld_rom_tables.c index 8ecf74336..42554611f 100644 --- a/lib_isar/isar_lcld_rom_tables.c +++ b/lib_isar/isar_lcld_rom_tables.c @@ -32,7 +32,6 @@ #include "isar_lcld_rom_tables.h" #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "wmc_auto.h" #include "prot_fx.h" #include "isar_lcld_prot.h" @@ -21204,4 +21203,3 @@ const Word32 c_pfWindowLUT[LCLD_PRED_WIN_LEN] = /* Q31 */ { 190779840, 338280192, 610825408, 966922816, 1352359680, 1708457216, 1981002240, 2128502656, 2128502528, 1981002240, 1708456960, 1352359808, 966922624, 610825152, 338280192, 190779776 }; -#endif diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 6860dda91..6e8bcaf9f 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -36,7 +36,6 @@ #include "isar_stat.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "options.h" @@ -409,7 +408,6 @@ void lc3plusTimeAlignCldfbPoseCorr( SPLIT_REND_WRAPPER *hSplitBin, Word32 Cldfb_In_BinImag_fx[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word16 *Q_in ); -#endif void ivas_cmult_fix( Word32 in1_re_fx, Word16 exp_re1, Word32 in1_im_fx, Word16 exp_im1, Word32 in2_re_fx, Word16 exp_re2, Word32 in2_im_fx, Word16 exp_im2, Word32 *out1_re_fx, Word32 *out1_im_fx, Word16 *exp_out1_re, Word16 *exp_out1_im ); diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index 99742bc4f..0af50df5c 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -43,7 +43,6 @@ /* clang-format off */ -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* * Binuaral split rendering ROM tables *-----------------------------------------------------------------------*/ @@ -187,7 +186,6 @@ const int32_t ivas_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_PRED_QU {14,10,1022},{15,10,1023}, }; -#endif /* Tables for split renderer fixed converison */ const Word16 fade_table_fx[4] = diff --git a/lib_isar/isar_rom_post_rend.h b/lib_isar/isar_rom_post_rend.h index b9acd75e1..90bcae60b 100644 --- a/lib_isar/isar_rom_post_rend.h +++ b/lib_isar/isar_rom_post_rend.h @@ -41,7 +41,6 @@ #include "cnst.h" #include "isar_cnst.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------* * Binuaral split rendering ROM tables *-----------------------------------------------------------------------*/ @@ -74,7 +73,6 @@ extern const int32_t ivas_split_rend_huff_roll_pred_consts[ISAR_SPLIT_REND_ROLL_ extern const int32_t ivas_split_rend_huff_p_d_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; extern const int32_t ivas_split_rend_huff_p_d_diff_consts[ISAR_SPLIT_REND_D_QUANT_PNTS][3]; extern const int32_t split_rend_brate_tbl[]; -#endif /* Tables for fixed point conversion */ extern const Word16 fade_table_fx[4]; diff --git a/lib_isar/isar_splitRend_lcld_dec.c b/lib_isar/isar_splitRend_lcld_dec.c index ddf9515b9..723888709 100644 --- a/lib_isar/isar_splitRend_lcld_dec.c +++ b/lib_isar/isar_splitRend_lcld_dec.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" #include "ivas_prot_fx.h" #include "prot_fx.h" @@ -282,4 +281,3 @@ void isar_splitBinLCLDDecProcess( return; } -#endif diff --git a/lib_isar/isar_splitRend_lcld_enc.c b/lib_isar/isar_splitRend_lcld_enc.c index 6804e97a4..e75910e8c 100644 --- a/lib_isar/isar_splitRend_lcld_enc.c +++ b/lib_isar/isar_splitRend_lcld_enc.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_prot.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING @@ -236,4 +235,3 @@ void isar_splitBinLCLDEncProcess( return; } -#endif diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index e3a0ce0e8..c81d0e12f 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot_fx.h" #include "prot_fx.h" @@ -1294,4 +1293,3 @@ void isar_splitBinRendPLC( return; } -#endif diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 32a230318..085cae9fc 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG #include @@ -1959,4 +1958,3 @@ void isar_init_split_post_rend_handles( return; } -#endif diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 9b4e470cf..5447aea1e 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG #include @@ -3137,4 +3136,3 @@ void lc3plusTimeAlignCldfbPoseCorr( return; } -#endif diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index e8866f421..bfdb1454f 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -32,7 +32,6 @@ #include #include "options.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "ivas_prot_fx.h" #include "prot_fx.h" @@ -1358,4 +1357,3 @@ Word32 get_bit( } -#endif diff --git a/lib_isar/isar_stat.h b/lib_isar/isar_stat.h index 0b1e1bb07..3fc1580e2 100644 --- a/lib_isar/isar_stat.h +++ b/lib_isar/isar_stat.h @@ -38,7 +38,6 @@ #include "options.h" #include "stat_com.h" #include "ivas_stat_com.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include "isar_lcld_prot.h" #include "isar_lc3plus_enc.h" #include "isar_lc3plus_dec.h" @@ -253,6 +252,5 @@ typedef struct Word32 lc3plusDelaySamples; } SPLIT_REND_WRAPPER; -#endif #endif /* ISAR_STAT_H */ diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 30f24b2b2..8ad605f40 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -38,14 +38,6 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#ifndef SPLIT_REND_WITH_HEAD_ROT - -int32_t ISAR_POST_REND_void_func( void ) -{ - return 0; -} - -#else #include "ivas_prot_rend_fx.h" #include @@ -1822,4 +1814,3 @@ int32_t ISAR_POST_REND_GetCntFramesLimited( #endif -#endif diff --git a/lib_isar/lib_isar_post_rend.h b/lib_isar/lib_isar_post_rend.h index b919bb1d2..70b46f57c 100644 --- a/lib_isar/lib_isar_post_rend.h +++ b/lib_isar/lib_isar_post_rend.h @@ -36,11 +36,6 @@ #include "common_api_types.h" #include -#ifndef SPLIT_REND_WITH_HEAD_ROT - -int32_t ISAR_POST_REND_void_func( void ); - -#else /*---------------------------------------------------------------------* * Renderer constants @@ -214,7 +209,6 @@ int32_t ISAR_POST_REND_GetCntFramesLimited( ); #endif -#endif /* SPLIT_REND_WITH_HEAD_ROT */ /* clang-format on */ diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 55a306a40..32773ef7a 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -47,13 +47,6 @@ #include "wmc_auto.h" -#ifndef SPLIT_REND_WITH_HEAD_ROT -int32_t ISAR_PRE_REND_void_func( void ) -{ - return 0; -} - -#else /*-------------------------------------------------------------------* * Local constants @@ -238,7 +231,6 @@ void ISAR_PRE_REND_close( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { IF( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] != NULL ) @@ -247,7 +239,6 @@ void ISAR_PRE_REND_close( hSplitBinRend->hCldfbHandles->cldfbSyn[ch] = NULL; } } -#endif free( hSplitBinRend->hCldfbHandles ); hSplitBinRend->hCldfbHandles = NULL; @@ -602,4 +593,3 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( return error; } -#endif diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 41843ec84..dd0ad5755 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -36,11 +36,6 @@ #include "isar_stat.h" #include "isar_prot.h" -#ifndef SPLIT_REND_WITH_HEAD_ROT - -int32_t ISAR_PRE_REND_void_func( void ); - -#else ivas_error ISAR_PRE_REND_open( SPLIT_REND_WRAPPER *hSplitBinRend, /* i/o: Split renderer pre-renerer handle */ ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, /* i/o: Split renderer pre-renerer config */ @@ -81,5 +76,4 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( Word16 Q_buff, Word16 *Q_out ); -#endif #endif /* LIB_ISAR_PRE_REND_H */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 392d8ea99..bf27912f7 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -207,9 +207,7 @@ static ivas_error ivas_rend_initCrend_fx( test(); test(); if ( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) -#ifdef SPLIT_REND_WITH_HEAD_ROT && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" ); @@ -1565,19 +1563,13 @@ static ivas_error ivas_er_init_handle( *------------------------------------------------------------------------*/ ivas_error ivas_rend_initCrendWrapper( -#ifdef SPLIT_REND_WITH_HEAD_ROT CREND_WRAPPER_HANDLE *pCrend, const int16_t num_poses -#else - CREND_WRAPPER_HANDLE *pCrend -#endif ) { Word16 i; CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif IF( pCrend == NULL ) { @@ -1596,9 +1588,7 @@ ivas_error ivas_rend_initCrendWrapper( move16(); ( *pCrend )->p_io_qfactor = &( *pCrend )->io_qfactor; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) -#endif { hCrend = NULL; IF( ( hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) @@ -1642,17 +1632,12 @@ ivas_error ivas_rend_initCrendWrapper( move32(); move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT ( *pCrend )->hCrend[pos_idx] = hCrend; -#else - ( *pCrend )->hCrend = hCrend; -#endif } return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------- * ivas_rend_openMultiBinCrend() * @@ -1668,14 +1653,10 @@ ivas_error ivas_rend_openMultiBinCrend( { ivas_error error; -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) -#endif -#else - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs ) ) != IVAS_ERR_OK ) #endif { return error; @@ -1683,7 +1664,6 @@ ivas_error ivas_rend_openMultiBinCrend( return error; } -#endif /*------------------------------------------------------------------------- * ivas_rend_openCrend() @@ -1700,12 +1680,8 @@ ivas_error ivas_rend_openCrend( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics, #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word32 output_Fs, const Word16 num_poses -#else - const Word32 output_Fs -#endif ) { Word16 i, subframe_length; @@ -1713,18 +1689,12 @@ ivas_error ivas_rend_openCrend( HRTFS_HANDLE hHrtf; CREND_HANDLE hCrend; ivas_error error; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif error = IVAS_ERR_OK; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( error = ivas_rend_initCrendWrapper( pCrend, num_poses ) ) != IVAS_ERR_OK ) -#else - IF( NE_32( ( error = ivas_rend_initCrendWrapper( pCrend ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -1739,15 +1709,9 @@ ivas_error ivas_rend_openCrend( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = ( *pCrend )->hCrend[pos_idx]; -#else - hCrend = ( *pCrend )->hCrend; -#endif hHrtf = ( *pCrend )->hHrtfCrend; IF( hHrtf != NULL ) @@ -1933,11 +1897,7 @@ ivas_error ivas_rend_openCrend( move32(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ( *pCrend )->hCrend[pos_idx] = hCrend; -#else - ( *pCrend )->hCrend = hCrend; -#endif } return IVAS_ERR_OK; } @@ -1949,18 +1909,12 @@ ivas_error ivas_rend_openCrend( *------------------------------------------------------------------------*/ void ivas_rend_closeCrend( -#ifdef SPLIT_REND_WITH_HEAD_ROT CREND_WRAPPER_HANDLE *pCrend, const Word16 num_poses -#else - CREND_WRAPPER_HANDLE *pCrend -#endif ) { Word16 i; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif CREND_HANDLE hCrend; test(); @@ -1974,15 +1928,9 @@ void ivas_rend_closeCrend( ivas_hrtf_close( &( *pCrend )->hHrtfCrend ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = ( *pCrend )->hCrend[pos_idx]; -#else - hCrend = ( *pCrend )->hCrend; -#endif IF( hCrend != NULL ) { FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ ) @@ -2074,11 +2022,7 @@ void ivas_rend_closeCrend( } free( hCrend ); hCrend = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT ( *pCrend )->hCrend[pos_idx] = hCrend; -#else - ( *pCrend )->hCrend = hCrend; -#endif } } @@ -2089,7 +2033,6 @@ void ivas_rend_closeCrend( } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*------------------------------------------------------------------------- * ivas_rend_closeCldfbRend() * @@ -2111,7 +2054,6 @@ void ivas_rend_closeCldfbRend( return; } -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crendConvolver() @@ -2126,12 +2068,8 @@ static ivas_error ivas_rend_crendConvolver( Word32 *pcm_in[], // Qx Word32 *pcm_out[], // Qx const Word32 output_Fs, -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 i_ts, const Word16 pos_idx -#else - const Word16 i_ts -#endif ) { Word16 i, j, k, m; @@ -2152,11 +2090,7 @@ static ivas_error ivas_rend_crendConvolver( CREND_HANDLE hCrend; ivas_error error; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = pCrend->hCrend[pos_idx]; -#else - hCrend = pCrend->hCrend; -#endif IF( NE_32( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ), IVAS_ERR_OK ) ) { @@ -2397,10 +2331,8 @@ ivas_error ivas_rend_crendProcessSubframe( Word32 *output[], /* i/o: input/output audio channels Qx */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word32 output_Fs /* i : output sampling rate */ -#ifdef SPLIT_REND_WITH_HEAD_ROT , const Word16 pos_idx -#endif ) { Word16 subframe_idx, subframe_len; @@ -2412,11 +2344,7 @@ ivas_error ivas_rend_crendProcessSubframe( ivas_error error; Word8 combinedOrientationEnabled; CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = pCrend->hCrend[pos_idx]; -#else - hCrend = pCrend->hCrend; -#endif combinedOrientationEnabled = 0; move16(); @@ -2547,16 +2475,11 @@ ivas_error ivas_rend_crendProcessSubframe( test(); IF( EQ_32( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || EQ_32( inConfigType, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local_fx, p_pcm_tmp_fx, output_Fs, 0, pos_idx ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendConvolver( pCrend, inConfig, outConfig, tc_local_fx, p_pcm_tmp_fx, output_Fs, 0 ) ), IVAS_ERR_OK ) ) -#endif { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( pCrend->hCrend[0]->hReverb != NULL ) { IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend[pos_idx]->hReverb, inConfig, 1, tc_local_fx, p_pcm_tmp_fx, 0 ) ), IVAS_ERR_OK ) ) @@ -2564,15 +2487,6 @@ ivas_error ivas_rend_crendProcessSubframe( return error; } } -#else - IF( pCrend->hCrend->hReverb != NULL ) - { - IF( NE_32( ( error = ivas_reverb_process_fx( pCrend->hCrend->hReverb, inConfig, 1, tc_local_fx, p_pcm_tmp_fx, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - } -#endif FOR( ch = 0; ch < nchan_in; ch++ ) { @@ -2598,11 +2512,7 @@ ivas_error ivas_rend_crendProcessSubframe( ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( pCrend->hCrend[0]->hReverb != NULL ) -#else - IF( pCrend->hCrend->hReverb != NULL ) -#endif { *pCrend->p_io_qfactor = sub( *pCrend->p_io_qfactor, 2 ); move16(); @@ -2633,7 +2543,6 @@ ivas_error ivas_rend_crendProcessSubframe( return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-----------------------------------------------------------------------------------------* * Function ivas_rend_crend_ProcessSplitBin() * @@ -2972,4 +2881,3 @@ ivas_error ivas_rend_crendProcessSubframesSplitBin( return IVAS_ERR_OK; } -#endif diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index d0a5e47d1..1fb026078 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -108,21 +108,13 @@ static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBIN static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 decIm[] /*q_inp*/[CLDFB_NO_CHANNELS_MAX] ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 Rmat[3][3], const Word16 subframe, const Word16 isHeadtracked, const Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, const Word32 *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); -#else -static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q*/, Word32 Rmat_fx[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const MASA_ISM_DATA_HANDLE hMasaIsmData, Word16 q ); -#endif static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, const Word16 max_band_decorr, Word32 Rmat[3][3] /*Q30*/, const Word16 subframe, const Word16 isHeadtracked, const Word16 nchanSeparateChannels, const MASA_ISM_DATA_HANDLE hMasaIsmData ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat, Word32 outRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *Q_inp_mix, const Word8 recompute ); -#else -static void ivas_dirac_dec_binaural_process_output_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, HANDLE_CLDFB_FILTER_BANK cldfbSynDec[MAX_OUTPUT_CHANNELS], Word32 *output_fx[] /*q_out*/, Word16 *q_out, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, const Word16 max_band_decorr, const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, const Word16 q_mat ); -#endif static void adaptTransportSignalsHeadtracked_fx( COMBINED_ORIENTATION_HANDLE hHeadTrackData, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, const Word16 nBins, const Word16 nSlots, Word32 Rmat[3][3] /*Q30*/ ); @@ -140,11 +132,7 @@ static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDe static void getDirectPartGains_fx( const Word16 bin, Word16 aziDeg, Word16 eleDeg, Word32 *lRealp, Word32 *lImagp, Word32 *rRealp, Word32 *rImagp, const UWord8 renderStereoOutputInsteadOfBinaural, Word32 Rmat[3][3] /*Q30*/, PARAMBIN_HRTF_GAIN_CACHE *gainCache, const Word16 isHeadtracked ); #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ); -#else -static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 subframe ); -#endif static void formulate2x2MixingMatrix_fx( Word32 Ein1_fx /*q_Ein*/, Word32 Ein2_fx /*q_Ein*/, Word16 q_Ein, Word32 CinRe_fx /*q_Cin*/, Word32 CinIm_fx /*q_Cin*/, Word16 q_Cin, Word32 Eout1_fx /*q_Eout*/, Word32 Eout2_fx /*q_Eout*/, Word16 q_Eout, Word32 CoutRe_fx /*q_Cout*/, Word32 CoutIm_fx /*q_Cout*/, Word16 q_Cout, Word32 Q_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*Q31*/, Word32 Mre_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word32 Mim_fx[BINAURAL_CHANNELS][BINAURAL_CHANNELS] /*q_M*/, Word16 *q_M, const Word16 regularizationFactor_fx /*Q14*/ ); @@ -189,7 +177,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( Word16 tmp2; ivas_error error; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 num_poses, pos_idx; num_poses = 1; @@ -203,9 +190,6 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( { hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; move32(); -#else - hDiracDecBin = st_ivas->hDiracDecBin; -#endif IF( hDiracDecBin == NULL ) { @@ -328,11 +312,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( ivas_binaural_reverb_close_fx( &( hDiracDecBin->hReverb ) ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( hDiracDecBin->hReverb == NULL && EQ_16( pos_idx, 0 ) ) /* open reverb only for the main direction */ -#else - IF( hDiracDecBin->hReverb == NULL ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -377,10 +357,8 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( ivas_dirac_dec_decorr_close_fx( &hDiracDecBin->h_freq_domain_decorr_ap_params, &hDiracDecBin->h_freq_domain_decorr_ap_state ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( pos_idx == 0 ) /* open decorrelator only for the main direction */ { -#endif IF( NE_32( ( error = ivas_td_decorr_reconfig_dec( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hDecoderConfig->output_Fs, &( hDiracDecBin->hTdDecorr ), &( hDiracDecBin->useTdDecorr ) ) ), IVAS_ERR_OK ) ) { return error; @@ -407,13 +385,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( return error; } } -#ifdef SPLIT_REND_WITH_HEAD_ROT } else { hDiracDecBin->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; /* copy the flag, but the implementation re-uses the decorrelated signal */ } -#endif hDiracDecBin->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); /* Q14 */ move16(); @@ -422,12 +398,8 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( hDiracDecBin->phHrtfParambin = phHrtfParambin; #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT st_ivas->hDiracDecBin[pos_idx] = hDiracDecBin; } -#else - st_ivas->hDiracDecBin = hDiracDecBin; -#endif /* allocate transport channels */ IF( st_ivas->hTcBuffer == NULL ) @@ -468,16 +440,13 @@ void ivas_dirac_dec_close_binaural_data( DIRAC_DEC_BIN_HANDLE *hBinaural /* i/o: decoder DirAC binaural data handle */ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; -#endif test(); IF( hBinaural == NULL || *hBinaural == NULL ) { return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { IF( hBinaural[pos_idx] != NULL ) @@ -498,21 +467,6 @@ void ivas_dirac_dec_close_binaural_data( hBinaural[pos_idx] = NULL; } } -#else - IF( ( *hBinaural )->hReverb != NULL ) - { - ivas_binaural_reverb_close_fx( &( ( *hBinaural )->hReverb ) ); - } - - ivas_td_decorr_dec_close( &( ( *hBinaural )->hTdDecorr ) ); - IF( ( *hBinaural )->h_freq_domain_decorr_ap_params != NULL ) - { - ivas_dirac_dec_decorr_close_fx( &( *hBinaural )->h_freq_domain_decorr_ap_params, &( *hBinaural )->h_freq_domain_decorr_ap_state ); - } - - free( *hBinaural ); - *hBinaural = NULL; -#endif return; } @@ -720,7 +674,6 @@ static void ivas_dirac_dec_binaural_internal_fx( Word16 nBins, offsetSamples; Word16 i, j; Word16 q_mat, q_out; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; Word32 tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -736,9 +689,6 @@ static void ivas_dirac_dec_binaural_internal_fx( Word16 Q_inp_mix; hDiracDecBin = st_ivas->hDiracDecBin[0]; -#else - hDiracDecBin = st_ivas->hDiracDecBin; -#endif assert( hDiracDecBin ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -1026,18 +976,13 @@ static void ivas_dirac_dec_binaural_internal_fx( IF( EQ_16( nchan_transport, 2 ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ -#endif adaptTransportSignalsHeadtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); } } test(); -#ifndef SPLIT_REND_WITH_HEAD_ROT - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, st_ivas->hMasaIsmData, q_inp ); -#endif IF( EQ_32( config_data.ivas_format, ISM_FORMAT ) ) { @@ -1055,13 +1000,11 @@ static void ivas_dirac_dec_binaural_internal_fx( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, subframe, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, q_inp ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, st_ivas->hMasaIsmData ); -#endif nchanSeparateChannels = 0; move16(); @@ -1128,7 +1071,6 @@ static void ivas_dirac_dec_binaural_internal_fx( hDiracDecBin->q_processMtxDecPrev = q_mat; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT pMultiBinPoseData = NULL; IF( st_ivas->hSplitBinRend != NULL ) { @@ -1136,11 +1078,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) -#endif { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, tmp_Cldfb_out_re, tmp_Cldfb_out_im, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); @@ -1159,13 +1097,9 @@ static void ivas_dirac_dec_binaural_internal_fx( ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); } -#else - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); -#endif hDiracDecBin->hDiffuseDist = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) { /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ @@ -1277,7 +1211,6 @@ static void ivas_dirac_dec_binaural_internal_fx( } /* update this counter only after the last rendering of split directions */ -#endif hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); @@ -1361,7 +1294,6 @@ static void ivas_dirac_dec_decorrelate_slot_fx( } -#ifdef SPLIT_REND_WITH_HEAD_ROT static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -1670,675 +1602,23 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( set32_fx( hDiracDecBin->ChCrossImOut_fx, 0, nBins ); set16_fx( hDiracDecBin->ChCrossReOut_e, 0, nBins ); set16_fx( hDiracDecBin->ChCrossImOut_e, 0, nBins ); - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - set32_fx( hDiracDecBin->ChEneOut_fx[ch], 0, nBins ); - set16_fx( hDiracDecBin->ChEneOut_e[ch], 0, nBins ); - } - set32_fx( hDiracDecBin->frameMeanDiffuseness_fx, 0, nBins ); - - set32_fx( frameMeanDiffusenessEneWeight_fx, 0, CLDFB_NO_CHANNELS_MAX ); - - FOR( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) - { - gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ - move16(); - } - - dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; - - /* Determine target covariance matrix containing target binaural properties */ - FOR( bin = 0; bin < nBins; bin++ ) - { - Word32 diffuseness_fx = ONE_IN_Q30; /* ratio1 and ratio2 are subtracted from diffuseness further below */ - Word32 diffusenessValForDecorrelationReduction_fx = ONE_IN_Q30; - Word32 diffEneValForDecorrelationReduction_fx; - Word16 q_diffEneValForDecorrelationReduction; - Word16 surCoh_fx = 0, spreadCoh_fx = 0; /* Default values if spreadSurroundCoherenceApplied == false */ - Word32 diffEne_fx, dirEne_fx, meanEnePerCh_fx; - Word16 q_meanEnePerCh; - Word16 q_diffEne, q_dirEne; - Word16 dirIndex; - move16(); - move16(); - move32(); - move32(); - - /* When BINAURAL_ROOM is not indicated, hBinaural->earlyPartEneCorrection[bin] values are all 1.0f. - * When BINAURAL_ROOM is indicated, the binaural audio output is based on combined use of the - * HRTF data set and a BRIR-based data set. The HRTF data set is spectrally corrected to match - * the early spectrum of the BRIR data, using the spectral correction data in - * hBinaural->earlyPartEneCorrection[bin], based on the BRIR set. */ - meanEnePerCh_fx = Mpy_32_32( hDiracDecBin->earlyPartEneCorrection_fx[bin], subFrameTotalEne_fx[bin] ); // Q( q_meanEnePerCh ) - q_meanEnePerCh = add( sub( q_earlyPartEneCorrection, subFrameTotalEne_e[bin] ), 1 ); // q_earlyPartEneCorrection + 31 - subFrameTotalEne_e[bin] - 31 + Q1(0.5f) - /* Determine direct part target covariance matrix (for 1 or 2 directions) */ - FOR( dirIndex = 0; dirIndex < hSpatParamRendCom->numSimultaneousDirections; dirIndex++ ) - { - Word16 aziDeg, eleDeg; - Word32 lRealp_fx, lImagp_fx, rRealp_fx, rImagp_fx; - Word32 lRealpTmp_fx, lImagpTmp_fx, rRealpTmp_fx, rImagpTmp_fx; - Word32 hrtfEne_fx[BINAURAL_CHANNELS], hrtfCrossRe_fx, hrtfCrossIm_fx, ratio_fx; - UWord8 isIsmDirection = 0; - move16(); - - test(); - test(); - IF( dirIndex == 0 ) /* For first of the two simultaneous directions */ - { - aziDeg = hSpatParamRendCom->azimuth[dirac_read_idx][bin]; - move16(); - eleDeg = hSpatParamRendCom->elevation[dirac_read_idx][bin]; - move16(); - ratio_fx = hSpatParamRendCom->energy_ratio1_fx[dirac_read_idx][bin]; - move32(); - spreadCoh_fx = hSpatParamRendCom->spreadCoherence_fx[dirac_read_idx][bin]; - move16(); - gainCacheBaseIndex = 0; - move16(); - } - ELSE IF( NE_32( ivas_format, MASA_ISM_FORMAT ) || ( EQ_32( ivas_format, MASA_ISM_FORMAT ) && LT_16( dirIndex, hSpatParamRendCom->numParametricDirections ) ) ) /* For second of the two simultaneous directions */ - { - IF( LT_32( ( ratio_fx = hSpatParamRendCom->energy_ratio2_fx[dirac_read_idx][bin] ), 10737418 /* 0.01 in Q30 */ ) ) - { - /* This touches only MASA path where second direction always has smaller ratio and - * for non-2dir it is zero. As the whole direction contribution is multiplied with - * the ratio, a very small ratio does not contribute any energy to output. Thus, - * it is better to save complexity. */ - CONTINUE; - } - aziDeg = hSpatParamRendCom->azimuth2[dirac_read_idx][bin]; - move16(); - eleDeg = hSpatParamRendCom->elevation2[dirac_read_idx][bin]; - move16(); - spreadCoh_fx = hSpatParamRendCom->spreadCoherence2_fx[dirac_read_idx][bin]; - move16(); - gainCacheBaseIndex = 3; - move16(); - } - ELSE /* For object directions of MASA_ISM_FORMAT */ - { - isIsmDirection = 1; - move16(); - UWord16 ismDirIndex; - ismDirIndex = sub( dirIndex, hSpatParamRendCom->numParametricDirections ); - assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); - IF( hMasaIsmData->ism_is_edited[ismDirIndex] ) - { - aziDeg = hMasaIsmData->azimuth_ism_edited[ismDirIndex]; - move16(); - eleDeg = hMasaIsmData->elevation_ism_edited[ismDirIndex]; - move16(); - } - ELSE - { - aziDeg = hMasaIsmData->azimuth_ism[ismDirIndex][dirac_read_idx]; - move16(); - eleDeg = hMasaIsmData->elevation_ism[ismDirIndex][dirac_read_idx]; - move16(); - } - ratio_fx = hMasaIsmData->energy_ratio_ism_fx[ismDirIndex][dirac_read_idx][bin]; - move32(); - spreadCoh_fx = 0; - move16(); - gainCacheBaseIndex = add( 6, ismDirIndex ); - } - - diffuseness_fx = L_sub( diffuseness_fx, ratio_fx ); /* diffuseness = 1 - ratio1 - ratio2 */ - - if ( diffuseness_fx < 0 ) - { - diffuseness_fx = 0; - move32(); - } - IF( isIsmDirection ) - { - /* Objects cause lesser decorrelation reduction, to avoid removing all decorrelation when only objects are present */ - diffusenessValForDecorrelationReduction_fx = L_sub( diffusenessValForDecorrelationReduction_fx, L_shr( ratio_fx, 1 ) ); /*Q30*/ - } - ELSE - { - diffusenessValForDecorrelationReduction_fx = L_sub( diffusenessValForDecorrelationReduction_fx, ratio_fx ); /*Q30*/ - } - - IF( separateCenterChannelRendering ) - { - /* In masa + mono rendering mode, the center directions originate from phantom sources, so the - * spread coherence is increased */ - Word16 azi_scaled, ele_scaled; - Word32 doaVectorX_fx, num, den; - Word16 e = 0, spatialAngleDeg_fx, altSpreadCoh_fx; - move16(); - - azi_scaled = i_mult( aziDeg, 91 ); - ele_scaled = i_mult( eleDeg, 91 ); - doaVectorX_fx = L_mult( getCosWord16R2( azi_scaled ), getCosWord16R2( ele_scaled ) ); /*Q31*/ - num = Sqrt32( L_sub( ONE_IN_Q31, Mpy_32_32( doaVectorX_fx, doaVectorX_fx ) ), &e ); - den = doaVectorX_fx; - move32(); - spatialAngleDeg_fx = BASOP_util_atan2( num, den, e ); // Q13 - Word16 numr, num_e = 0, denr, den_e; - move16(); - num_e = sub( norm_s( spatialAngleDeg_fx ), 1 ); - numr = shl( spatialAngleDeg_fx, num_e ); - denr = 17157; - move16(); - den_e = 4; - move16(); - altSpreadCoh_fx = sub( 32767, shl_sat( div_s( numr, denr ), sub( den_e, num_e ) ) ); // 4289 = pi/6 in Q13 - spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); - } - -#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked, *hDiracDecBin->phHrtfParambin ); -#else - getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); -#endif - - Word16 q_lr = Q28; - move16(); - if ( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - /* Synthesizing spread coherence is not needed for stereo loudspeaker output, - * as directional sound is reproduced with two loudspeakers in any case */ - spreadCoh_fx = 0; - move32(); - } - - IF( spreadCoh_fx > 0 ) - { - Word32 centerMul_fx, sidesMul_fx; - Word32 hrtfEneCenter_fx, hrtfEneSides_fx, hrtfEneRealized_fx; - Word16 eneCorrectionFactor_fx, eneCorrectionFactor_e; - Word16 w1_fx, w2_fx, w3_fx, eq_fx; - - hrtfEneCenter_fx = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), // Q25 - L_add( Mpy_32_32( lImagp_fx, lImagp_fx ), // Q25 - L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), // Q25 - Mpy_32_32( rImagp_fx, rImagp_fx ) ) ) ); // Q25 - - /* Spread coherence is synthesized as coherent sources at 30 degree horizontal spacing. - * The following formulas determine the gains for these sources. - * spreadCoh = 0: Only panning - * spreadCoh = 0.5: Three sources coherent panning (e.g. 30 0 -30 deg azi) - * spreadCoh = 1.0: Two sources coherent panning with gap (as above, but center is silent) */ - IF( LT_16( spreadCoh_fx, 16384 ) ) - { - /* 0.0f < spreadCoh < 0.5f */ - sidesMul_fx = L_mult0( spreadCoh_fx, 9459 ); /* 2*sqrt(1/3) in Q13 = 9459 */ // Q28 - centerMul_fx = L_add( L_sub( ONE_IN_Q28, L_shl( spreadCoh_fx, 14 ) ), sidesMul_fx ); // Q28 - } - ELSE - { - /* 0.5f <= spreadCoh < 1.0f */ - // centerMul = 2.0f - ( 2.0f * spreadCoh ); - centerMul_fx = L_shl( sub( 32767, spreadCoh_fx ), 14 ); // Q28 - sidesMul_fx = Isqrt( L_add( L_shr( centerMul_fx, 22 ), L_shl( 2, Q6 ) ) ); // Q28 - centerMul_fx = L_shl( Mpy_32_32( centerMul_fx, sidesMul_fx ), 3 ); // Q28 - } - - /* Apply the gain for the center source of the three coherent sources */ - lRealp_fx = Mpy_32_32( lRealp_fx, centerMul_fx ); // Q25 - lImagp_fx = Mpy_32_32( lImagp_fx, centerMul_fx ); // Q25 - rRealp_fx = Mpy_32_32( rRealp_fx, centerMul_fx ); // Q25 - rImagp_fx = Mpy_32_32( rImagp_fx, centerMul_fx ); // Q25 - - /* Apply the gain for the left source of the three coherent sources */ -#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked, *hDiracDecBin->phHrtfParambin ); -#else - getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked ); -#endif - - hrtfEneSides_fx = L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 - L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 - L_add( Mpy_32_32( rRealpTmp_fx, rRealpTmp_fx ), // Q25 - Mpy_32_32( rImagpTmp_fx, rImagpTmp_fx ) ) ) ); // Q25 - lRealp_fx = L_add( lRealp_fx, Mpy_32_32( sidesMul_fx, lRealpTmp_fx ) ); // Q25 - lImagp_fx = L_add( lImagp_fx, Mpy_32_32( sidesMul_fx, lImagpTmp_fx ) ); // Q25 - rRealp_fx = L_add( rRealp_fx, Mpy_32_32( sidesMul_fx, rRealpTmp_fx ) ); // Q25 - rImagp_fx = L_add( rImagp_fx, Mpy_32_32( sidesMul_fx, rImagpTmp_fx ) ); // Q25 - - /* Apply the gain for the right source of the three coherent sources. - * -30 degrees to 330 wrapping due to internal functions. */ - -#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF - getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked, *hDiracDecBin->phHrtfParambin ); -#else - getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); -#endif - - hrtfEneSides_fx = L_add( hrtfEneSides_fx, - L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 - L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 - L_add( Mpy_32_32( rRealpTmp_fx, rRealpTmp_fx ), // Q25 - Mpy_32_32( rImagpTmp_fx, rImagpTmp_fx ) ) ) ) ); // Q25 - lRealp_fx = L_add( lRealp_fx, Mpy_32_32( sidesMul_fx, lRealpTmp_fx ) ); // Q25 - lImagp_fx = L_add( lImagp_fx, Mpy_32_32( sidesMul_fx, lImagpTmp_fx ) ); // Q25 - rRealp_fx = L_add( rRealp_fx, Mpy_32_32( sidesMul_fx, rRealpTmp_fx ) ); // Q25 - rImagp_fx = L_add( rImagp_fx, Mpy_32_32( sidesMul_fx, rImagpTmp_fx ) ); // Q25 - - /* Formulate an eneCorrectionFactor that compensates for the coherent summation of the HRTFs */ - hrtfEneRealized_fx = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), // Q19 - L_add( Mpy_32_32( lImagp_fx, lImagp_fx ), // Q19 - L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), // Q19 - Mpy_32_32( rImagp_fx, rImagp_fx ) ) ) ); // Q19 - - eneCorrectionFactor_fx = BASOP_Util_Divide3232_Scale( L_add( Mpy_32_32( hrtfEneSides_fx, Mpy_32_32( sidesMul_fx, sidesMul_fx ) ), - Mpy_32_32( hrtfEneCenter_fx, Mpy_32_32( centerMul_fx, centerMul_fx ) ) ), - L_max( 1, hrtfEneRealized_fx ), &eneCorrectionFactor_e ); - - /* Weighting factors to determine appropriate target spectrum for spread coherent sound */ - IF( LT_16( spreadCoh_fx, 16384 ) ) - { - w1_fx = sub( 32767, shl( spreadCoh_fx, 1 ) ); /*Q15*/ - w2_fx = shl( spreadCoh_fx, 1 ); /*Q15*/ - w3_fx = 0; - move16(); - } - ELSE - { - w1_fx = 0; - move16(); - w2_fx = shl( sub( 32767, spreadCoh_fx ), 1 ); /*Q15*/ - w3_fx = shl( sub( spreadCoh_fx, 16384 ), 1 ); /*Q15*/ - } - - test(); - IF( ( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( mc_mode, MC_MODE_MCMASA ) ) ) - { - idx = s_min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); - - /* Apply the target spectrum to the eneCorrectionFactor */ - IF( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ - { - eneCorrectionFactor_fx = mult_r( eneCorrectionFactor_fx, add( mult_r( w1_fx, 8192 ), shr( mult_r( add( w2_fx, w3_fx ), spreadCohEne1_fx[idx] ), 1 ) ) ); - eneCorrectionFactor_e = add( eneCorrectionFactor_e, 2 ); - } - ELSE - { - eneCorrectionFactor_fx = mult_r( eneCorrectionFactor_fx, add( mult_r( w1_fx, 4096 ), add( shr( mult_r( w2_fx, spreadCohEne05_fx[idx] ), 1 ), shr( mult_r( w3_fx, spreadCohEne1_fx[idx] ), 2 ) ) ) ); - eneCorrectionFactor_e = add( eneCorrectionFactor_e, 3 ); - } - } - - /* Equalize the spread coherent combined HRTFs */ - Word16 tmp, tmp_e; - tmp_e = eneCorrectionFactor_e; - move16(); - tmp = Sqrt16( eneCorrectionFactor_fx, &tmp_e ); - IF( GE_16( shr( tmp, sub( 15, tmp_e ) ), 4 ) ) - { - eq_fx = 32767; // Q13 - move16(); - } - ELSE - { - eq_fx = shl( tmp, sub( tmp_e, 2 ) ); // Q13 - } - - lRealp_fx = Mpy_32_16_1( lRealp_fx, eq_fx ); // Q23 - lImagp_fx = Mpy_32_16_1( lImagp_fx, eq_fx ); // Q23 - rRealp_fx = Mpy_32_16_1( rRealp_fx, eq_fx ); // Q23 - rImagp_fx = Mpy_32_16_1( rImagp_fx, eq_fx ); // Q23 - q_lr = Q23; - move16(); - } - - hrtfEne_fx[0] = L_add( Mpy_32_32( lRealp_fx, lRealp_fx ), Mpy_32_32( lImagp_fx, lImagp_fx ) ); // Q( 2*q_lr - 31 ) - hrtfEne_fx[1] = L_add( Mpy_32_32( rRealp_fx, rRealp_fx ), Mpy_32_32( rImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) - move32(); - move32(); - hrtfCrossRe_fx = L_add( Mpy_32_32( lRealp_fx, rRealp_fx ), Mpy_32_32( lImagp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) - hrtfCrossIm_fx = L_add( Mpy_32_32( -lImagp_fx, rRealp_fx ), Mpy_32_32( lRealp_fx, rImagp_fx ) ); // Q( 2*q_lr - 31 ) - - /* Add direct part (1 or 2) covariance matrix */ - dirEne_fx = Mpy_32_32( ratio_fx, meanEnePerCh_fx ); // Q(q_meanEnePerCh - 1) - shift = norm_l( dirEne_fx ); - dirEne_fx = L_shl( dirEne_fx, shift ); - q_dirEne = add( sub( q_meanEnePerCh, 1 ), shift ); - - hDiracDecBin->ChEneOut_fx[0][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[0][bin], hDiracDecBin->ChEneOut_e[0][bin], Mpy_32_32( dirEne_fx, hrtfEne_fx[0] ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChEneOut_e[0][bin] ); /* Dir ene part*/ - hDiracDecBin->ChEneOut_fx[1][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[1][bin], hDiracDecBin->ChEneOut_e[1][bin], Mpy_32_32( dirEne_fx, hrtfEne_fx[1] ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChEneOut_e[1][bin] ); - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( dirEne_fx, hrtfCrossRe_fx ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChCrossReOut_e[bin] ); /* Dir cross re */ - hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( dirEne_fx, hrtfCrossIm_fx ), sub( 31, sub( add( q_dirEne, shl( q_lr, 1 ) ), 62 ) ), &hDiracDecBin->ChCrossImOut_e[bin] ); /* Dir cross im */ - move32(); - move32(); - move32(); - move32(); - } - - /* Add diffuse / ambient part covariance matrix */ - diffuseness_fx = L_max( 0, diffuseness_fx ); // Q30 - diffEne_fx = Mpy_32_32( diffuseness_fx, meanEnePerCh_fx ); // Q(2q - 32) - shift = norm_l( diffEne_fx ); - diffEne_fx = L_shl( diffEne_fx, shift ); - q_diffEne = add( shift, sub( q_meanEnePerCh, 1 ) ); - - surCoh_fx = hSpatParamRendCom->surroundingCoherence_fx[dirac_read_idx][bin]; // Q15 - move16(); - - diffusenessValForDecorrelationReduction_fx = L_max( 0, diffusenessValForDecorrelationReduction_fx ); // Q30 - diffEneValForDecorrelationReduction_fx = Mpy_32_32( diffusenessValForDecorrelationReduction_fx, meanEnePerCh_fx ); // resulting Q = q_meanEnePerCh - 1 - q_diffEneValForDecorrelationReduction = sub( q_meanEnePerCh, 1 ); - - test(); - IF( ( EQ_32( ivas_format, MC_FORMAT ) && EQ_32( mc_mode, MC_MODE_MCMASA ) ) ) - { - IF( !hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - Word32 spectrumModVal; - - idx = s_min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); - /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ - spectrumModVal = L_add( L_sub( ONE_IN_Q29, L_shl( surCoh_fx, 14 ) ), L_mult( surCoh_fx, surCohEne_fx[idx] ) ); // Q29 - diffEne_fx = Mpy_32_32( diffEne_fx, spectrumModVal ); // Q-2 - q_diffEne = sub( q_diffEne, 2 ); - /* Modify also the value for decorrelation reduction */ - diffEneValForDecorrelationReduction_fx = Mpy_32_32( diffEneValForDecorrelationReduction_fx, spectrumModVal ); // Q-2 - q_diffEneValForDecorrelationReduction = sub( q_diffEneValForDecorrelationReduction, 2 ); - } - } - hDiracDecBin->ChEneOut_fx[0][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[0][bin], hDiracDecBin->ChEneOut_e[0][bin], diffEne_fx, sub( 31, q_diffEne ), &hDiracDecBin->ChEneOut_e[0][bin] ); /* Diff ene part*/ - hDiracDecBin->ChEneOut_fx[1][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[1][bin], hDiracDecBin->ChEneOut_e[1][bin], diffEne_fx, sub( 31, q_diffEne ), &hDiracDecBin->ChEneOut_e[1][bin] ); - - move32(); - move32(); - IF( hDiracDecBin->renderStereoOutputInsteadOfBinaural ) - { - /* When rendering stereo, ambience (except for surround coherent sound) has zero ICC. */ - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_16_1( diffEne_fx, surCoh_fx ), sub( 31, q_diffEne ), &hDiracDecBin->ChCrossReOut_e[bin] ); - move32(); - } - ELSE /* When rendering binaural, ambience has frequency dependent ICC. */ - { - test(); - test(); - IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && LT_16( bin, BINAURAL_COHERENCE_DIFFERENCE_BINS ) ) - { - Word32 diffuseFieldCoherence_fx; - Word16 tmp_exp; - temp = BASOP_Util_Add_Mant32Exp( Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioX_fx[bin], hDiracDecBin->diffuseFieldCoherenceX_fx[bin] ), 0, Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioY_fx[bin], hDiracDecBin->diffuseFieldCoherenceY_fx[bin] ), 0, &tmp_exp ); - diffuseFieldCoherence_fx = BASOP_Util_Add_Mant32Exp( temp, tmp_exp, Mpy_32_32( hDiracDecBin->hDiffuseDist->diffuseRatioZ_fx[bin], hDiracDecBin->diffuseFieldCoherenceZ_fx[bin] ), 0, &tmp_exp ); - temp = BASOP_Util_Add_Mant32Exp( Mpy_32_16_1( diffuseFieldCoherence_fx, sub( 32767, surCoh_fx ) ), tmp_exp, L_shl( surCoh_fx, 16 ), 0, &tmp_exp ); - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( temp, diffEne_fx ), add( tmp_exp, sub( 31, q_diffEne ) ), &hDiracDecBin->ChCrossReOut_e[bin] ); - } - ELSE - { - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( L_add( Mpy_32_16_1( hDiracDecBin->diffuseFieldCoherence_fx[bin], sub( 32767, surCoh_fx ) ), L_shl( surCoh_fx, 16 ) ), diffEne_fx ), sub( 31, q_diffEne ), &hDiracDecBin->ChCrossReOut_e[bin] ); - } - move32(); - } - - /* Store parameters for formulating average diffuseness over frame */ - Word32 frameMeanDiffuseness = BASOP_Util_Add_Mant32Exp( hDiracDecBin->frameMeanDiffuseness_fx[bin], 2 /*Q29*/, diffEneValForDecorrelationReduction_fx, sub( 31, q_diffEneValForDecorrelationReduction ), &exp1 ); // exp = exp1 - frameMeanDiffusenessEneWeight_fx[bin] = L_add( frameMeanDiffusenessEneWeight_fx[bin], meanEnePerCh_fx ); - move32(); - - /* Formulate average diffuseness over frame */ - frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 - exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) ); - hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 - move32(); - } - - FOR( bin = 0; bin < nBins; bin++ ) - { - hDiracDecBin->ChCrossReOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossReOut_fx[bin], qualityBasedSmFactor_fx ); - hDiracDecBin->ChCrossImOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossImOut_fx[bin], qualityBasedSmFactor_fx ); - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEneOut_fx[ch][bin] = Mpy_32_32( hDiracDecBin->ChEneOut_fx[ch][bin], qualityBasedSmFactor_fx ); - move32(); - } - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossReOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossReOutPrev_e[bin], &hDiracDecBin->ChCrossReOut_e[bin] ); - hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossImOutPrev_e[bin], &hDiracDecBin->ChCrossImOut_e[bin] ); - move32(); - move32(); - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEneOut_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[ch][bin], hDiracDecBin->ChEneOut_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEneOutPrev_fx[ch][bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChEneOutPrev_e[ch][bin], &hDiracDecBin->ChEneOut_e[ch][bin] ); - move32(); - } - - - hDiracDecBin->ChCrossReOutPrev_fx[bin] = hDiracDecBin->ChCrossReOut_fx[bin]; - move32(); - hDiracDecBin->ChCrossImOutPrev_fx[bin] = hDiracDecBin->ChCrossImOut_fx[bin]; - move32(); - hDiracDecBin->ChCrossReOutPrev_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; - move16(); - hDiracDecBin->ChCrossImOutPrev_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; - move16(); - - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - hDiracDecBin->ChEnePrev_fx[ch][bin] = hDiracDecBin->ChEne_fx[ch][bin]; - move32(); - hDiracDecBin->ChEnePrev_e[ch][bin] = hDiracDecBin->ChEne_e[ch][bin]; - move16(); - hDiracDecBin->ChEneOutPrev_fx[ch][bin] = hDiracDecBin->ChEneOut_fx[ch][bin]; - move32(); - hDiracDecBin->ChEneOutPrev_e[ch][bin] = hDiracDecBin->ChEneOut_e[ch][bin]; - move16(); - } - } - - return; -} - - -#else -static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( - DIRAC_DEC_BIN_HANDLE hDiracDecBin, - SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, - PARAMBIN_REND_CONFIG_HANDLE hConfig, - Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q*/ - Word32 inIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q*/ - Word32 Rmat_fx[3][3], /*Q30*/ - const Word16 subframe, - const Word16 isHeadtracked, - const MASA_ISM_DATA_HANDLE hMasaIsmData, - Word16 q ) -{ - Word16 ch, slot, bin; - Word16 separateCenterChannelRendering; - Word16 nBins, idx, shift; - Word32 frameMeanDiffusenessEneWeight_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 IIReneLimiterFactor_fx; // Q26 - Word32 qualityBasedSmFactor_fx; - Word32 lowBitRateEQ_fx[CLDFB_NO_CHANNELS_MAX]; - UWord8 applyLowBitRateEQ; - Word16 dirac_read_idx; - Word32 subFrameTotalEne_fx[CLDFB_NO_CHANNELS_MAX]; - Word16 subFrameTotalEne_e[CLDFB_NO_CHANNELS_MAX]; - PARAMBIN_HRTF_GAIN_CACHE gainCache[MAX_GAIN_CACHE_SIZE]; - IVAS_FORMAT ivas_format; - MC_MODE mc_mode; - Word32 ivas_total_brate; - Word16 nchan_transport; - Word16 gainCacheBaseIndex; - Word16 q_earlyPartEneCorrection; - Word16 exp, exp1; - Word64 temp64; - Word32 temp; - - separateCenterChannelRendering = hConfig->separateCenterChannelRendering; - move16(); - ivas_format = hConfig->ivas_format; - move32(); - mc_mode = hConfig->mc_mode; - move32(); - ivas_total_brate = hConfig->ivas_total_brate; - move32(); - nchan_transport = hConfig->nchan_transport; - move16(); - qualityBasedSmFactor_fx = hConfig->qualityBasedSmFactor_fx; /*Q31*/ - move32(); - qualityBasedSmFactor_fx = Mpy_32_32( qualityBasedSmFactor_fx, qualityBasedSmFactor_fx ); /*Q31*/ - - nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ - move16(); - - q_earlyPartEneCorrection = s_min( Q31, add( getScaleFactor32( hDiracDecBin->earlyPartEneCorrection_fx, nBins ), hDiracDecBin->q_earlyPartEneCorrection ) ); - scale_sig32( hDiracDecBin->earlyPartEneCorrection_fx, nBins, sub( q_earlyPartEneCorrection, hDiracDecBin->q_earlyPartEneCorrection ) ); - hDiracDecBin->q_earlyPartEneCorrection = q_earlyPartEneCorrection; - move16(); - - set32_fx( hDiracDecBin->ChCrossRe_fx, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossIm_fx, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossReOut_fx, 0, nBins ); - set32_fx( hDiracDecBin->ChCrossImOut_fx, 0, nBins ); - - set16_fx( hDiracDecBin->ChCrossRe_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossIm_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossReOut_e, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossImOut_e, 0, nBins ); + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - set32_fx( hDiracDecBin->ChEne_fx[ch], 0, nBins ); set32_fx( hDiracDecBin->ChEneOut_fx[ch], 0, nBins ); - - set16_fx( hDiracDecBin->ChEne_e[ch], 0, nBins ); set16_fx( hDiracDecBin->ChEneOut_e[ch], 0, nBins ); } set32_fx( hDiracDecBin->frameMeanDiffuseness_fx, 0, nBins ); set32_fx( frameMeanDiffusenessEneWeight_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set16_fx( subFrameTotalEne_e, 0, CLDFB_NO_CHANNELS_MAX ); - FOR( idx = 0; idx < MAX_GAIN_CACHE_SIZE; idx++ ) { gainCache[idx].azi = -1000; /* Use -1000 as value for uninitialized cache. */ move16(); } - /* Determine EQ for low bit rates (13.2 and 16.4 kbps) */ - applyLowBitRateEQ = 0; - move16(); - test(); - test(); - IF( ( EQ_32( ivas_format, MASA_FORMAT ) || EQ_32( ivas_format, MC_FORMAT ) ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) - { - applyLowBitRateEQ = 1; - move16(); - IF( EQ_32( ivas_total_brate, IVAS_16k4 ) ) - { - FOR( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) - { - lowBitRateEQ_fx[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = L_add( L_shr( lowBitRateBinauralEQ_fx[bin], 1 ), ONE_IN_Q30 ); // Q31 - move32(); - } - } - ELSE - { - FOR( bin = 0; bin < LOW_BIT_RATE_BINAURAL_EQ_BINS; bin++ ) - { - lowBitRateEQ_fx[bin + LOW_BIT_RATE_BINAURAL_EQ_OFFSET] = lowBitRateBinauralEQ_fx[bin]; // Q31 - move32(); - } - } - } - - /* Formulate input and target covariance matrices for this subframe */ - set32_fx( subFrameTotalEne_fx, 0, CLDFB_NO_CHANNELS_MAX ); dirac_read_idx = hSpatParamRendCom->render_to_md_map[subframe]; - move16(); - - exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below - - /* Calculate input covariance matrix */ - FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - FOR( bin = 0; bin < nBins; bin++ ) - { - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - Word32 instEne_fx; - temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] ); // 2q - temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q - exp1 = W_norm( temp64 ); - instEne_fx = W_extract_h( W_shl( temp64, exp1 ) ); // 2q - 32 + exp1 - /* exp of instEne_fx = 31 - (2q -32 + exp1) = 63 - 2q - exp1 = exp - exp1*/ - - hDiracDecBin->ChEne_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[ch][bin], hDiracDecBin->ChEne_e[ch][bin], instEne_fx, sub( exp, exp1 ), &hDiracDecBin->ChEne_e[ch][bin] ); - subFrameTotalEne_fx[bin] = BASOP_Util_Add_Mant32Exp( subFrameTotalEne_fx[bin], subFrameTotalEne_e[bin], instEne_fx, sub( exp, exp1 ), &subFrameTotalEne_e[bin] ); - move32(); - move32(); - } - temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inRe_fx[1][slot][bin] ); // 2q - temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ) ); // 2q - exp1 = W_norm( temp64 ); - temp = W_extract_h( W_shl( temp64, exp1 ) ); // // 2q - 32 + exp1 - hDiracDecBin->ChCrossRe_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossRe_e[bin], temp, sub( exp, exp1 ), &hDiracDecBin->ChCrossRe_e[bin] ); - move32(); - - temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inIm_fx[1][slot][bin] ); // 2q - temp64 = W_sub( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inRe_fx[1][slot][bin] ) ); // 2q - exp1 = W_norm( temp64 ); - temp = W_extract_h( W_shl( temp64, exp1 ) ); // // 2q - 32 + exp1 - hDiracDecBin->ChCrossIm_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossIm_fx[bin], hDiracDecBin->ChCrossIm_e[bin], temp, sub( exp, exp1 ), &hDiracDecBin->ChCrossIm_e[bin] ); - move32(); - } - } - - /* Apply EQ at low bit rates */ - IF( applyLowBitRateEQ != 0 ) - { - Word16 lastEqBin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET + LOW_BIT_RATE_BINAURAL_EQ_BINS - 1; - - FOR( bin = LOW_BIT_RATE_BINAURAL_EQ_OFFSET; bin < lastEqBin; bin++ ) - { - subFrameTotalEne_fx[bin] = Mpy_32_32( subFrameTotalEne_fx[bin], lowBitRateEQ_fx[bin] ); // exp = subFrameTotalEne_e[bin] - move32(); - } - FOR( ; bin < nBins; bin++ ) - { - subFrameTotalEne_fx[bin] = Mpy_32_32( subFrameTotalEne_fx[bin], lowBitRateEQ_fx[lastEqBin] ); // exp = subFrameTotalEne_e[bin] - move32(); - } - } - - test(); - test(); - IF( ( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) && EQ_16( nchan_transport, 2 ) ) - { - Word32 tempRe, tempIm; - Word32 subFrameSumEne_fx[CLDFB_NO_CHANNELS_MAX]; - Word16 subFrameSumEne_e[CLDFB_NO_CHANNELS_MAX]; - - set32_fx( subFrameSumEne_fx, 0, CLDFB_NO_CHANNELS_MAX ); - set16_fx( subFrameSumEne_e, 0, CLDFB_NO_CHANNELS_MAX ); - FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) - { - FOR( bin = 0; bin < nBins; bin++ ) - { - tempRe = L_add( inRe_fx[0][slot][bin], inRe_fx[1][slot][bin] ); // q - tempIm = L_add( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ); // q - 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], 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 ) ) - { - subFrameTotalEne_fx[bin] = subFrameSumEne_fx[bin]; - move32(); - subFrameTotalEne_e[bin] = subFrameSumEne_e[bin]; - move16(); - } - } - } /* Determine target covariance matrix containing target binaural properties */ FOR( bin = 0; bin < nBins; bin++ ) @@ -2481,7 +1761,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric spreadCoh_fx = s_max( spreadCoh_fx, altSpreadCoh_fx ); } +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, aziDeg, eleDeg, &lRealp_fx, &lImagp_fx, &rRealp_fx, &rImagp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex], isHeadtracked ); +#endif Word16 q_lr = Q28; move16(); @@ -2532,7 +1816,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric rImagp_fx = Mpy_32_32( rImagp_fx, centerMul_fx ); // Q25 /* Apply the gain for the left source of the three coherent sources */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, add( aziDeg, 30 ), eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 1], isHeadtracked ); +#endif hrtfEneSides_fx = L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 L_add( Mpy_32_32( lImagpTmp_fx, lImagpTmp_fx ), // Q25 @@ -2546,7 +1834,11 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric /* Apply the gain for the right source of the three coherent sources. * -30 degrees to 330 wrapping due to internal functions. */ +#ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF + getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked, *hDiracDecBin->phHrtfParambin ); +#else getDirectPartGains_fx( bin, aziDeg + 330, eleDeg, &lRealpTmp_fx, &lImagpTmp_fx, &rRealpTmp_fx, &rImagpTmp_fx, hDiracDecBin->renderStereoOutputInsteadOfBinaural, Rmat_fx, &gainCache[gainCacheBaseIndex + 2], isHeadtracked ); +#endif hrtfEneSides_fx = L_add( hrtfEneSides_fx, L_add( Mpy_32_32( lRealpTmp_fx, lRealpTmp_fx ), // Q25 @@ -2716,97 +2008,38 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric move32(); /* Formulate average diffuseness over frame */ - frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_newton( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 + frameMeanDiffuseness = BASOP_Util_Divide3232_Scale_cadence( frameMeanDiffuseness, L_max( EPSILLON_FX, frameMeanDiffusenessEneWeight_fx[bin] ), &exp ); // exp = exp + 31 - q_meanEnePerCh - exp1 exp = sub( exp, sub( sub( 31, q_meanEnePerCh ), exp1 ) ); hDiracDecBin->frameMeanDiffuseness_fx[bin] = L_shl( frameMeanDiffuseness, sub( exp, 2 ) ); // Q29 move32(); } - test(); - /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ - IF( EQ_32( ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) - { - IIReneLimiterFactor_fx = L_add( L_shl( 16, Q26 ), L_sub( L_shl( 1, Q26 ), L_shr( qualityBasedSmFactor_fx, 5 ) ) ); // Q26 - } - ELSE - { - IIReneLimiterFactor_fx = L_add( L_shl( 8, Q26 ), L_sub( L_shl( 1, Q26 ), L_shr( qualityBasedSmFactor_fx, 5 ) ) ); // Q26 - } - FOR( bin = 0; bin < nBins; bin++ ) { - Word32 IIReneLimiter_fx; - - /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that - * the energy history (IIR) must not be more than double of the current frame energy. This provides more - * robust performance at energy offsets when compared to typical IIR averaging. */ - Word16 num_e, den_e; - Word32 num, den; - num = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->ChEne_e[1][bin], &num_e ); - num = Mpy_32_32( num, IIReneLimiterFactor_fx ); /*Q = (31 - num_e + 26 - 31) = (26 - num_e)*/ - den_e = 0; - move16(); - den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e ); - den = L_max( 1, den ); - IIReneLimiter_fx = BASOP_Util_Divide3232_Scale_newton( num, den, &exp ); - exp = add( sub( num_e, den_e ), add( 5, exp ) ); - IF( L_shr_sat( IIReneLimiter_fx, sub( 31, exp ) ) > 0 ) - { - IIReneLimiter_fx = ONE_IN_Q31; /*Q31*/ - move32(); - } - ELSE - { - IIReneLimiter_fx = L_shl( IIReneLimiter_fx, exp ); /*Q31*/ - } - - hDiracDecBin->ChCrossRe_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossRe_fx[bin], qualityBasedSmFactor_fx ); - hDiracDecBin->ChCrossIm_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossIm_fx[bin], qualityBasedSmFactor_fx ); hDiracDecBin->ChCrossReOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossReOut_fx[bin], qualityBasedSmFactor_fx ); hDiracDecBin->ChCrossImOut_fx[bin] = Mpy_32_32( hDiracDecBin->ChCrossImOut_fx[bin], qualityBasedSmFactor_fx ); - move32(); - move32(); - move32(); - move32(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - hDiracDecBin->ChEne_fx[ch][bin] = Mpy_32_32( hDiracDecBin->ChEne_fx[ch][bin], qualityBasedSmFactor_fx ); hDiracDecBin->ChEneOut_fx[ch][bin] = Mpy_32_32( hDiracDecBin->ChEneOut_fx[ch][bin], qualityBasedSmFactor_fx ); move32(); - move32(); } - - hDiracDecBin->ChCrossRe_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossRe_fx[bin], hDiracDecBin->ChCrossRe_e[bin], Mpy_32_32( hDiracDecBin->ChCrossRePrev_fx[bin], IIReneLimiter_fx ), hDiracDecBin->ChCrossRePrev_e[bin], &hDiracDecBin->ChCrossRe_e[bin] ); - hDiracDecBin->ChCrossIm_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossIm_fx[bin], hDiracDecBin->ChCrossIm_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImPrev_fx[bin], IIReneLimiter_fx ), hDiracDecBin->ChCrossImPrev_e[bin], &hDiracDecBin->ChCrossIm_e[bin] ); - hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossReOutPrev_fx[bin], IIReneLimiter_fx ), hDiracDecBin->ChCrossReOutPrev_e[bin], &hDiracDecBin->ChCrossReOut_e[bin] ); - hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImOutPrev_fx[bin], IIReneLimiter_fx ), hDiracDecBin->ChCrossImOutPrev_e[bin], &hDiracDecBin->ChCrossImOut_e[bin] ); - move32(); - move32(); + hDiracDecBin->ChCrossReOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossReOut_fx[bin], hDiracDecBin->ChCrossReOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossReOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossReOutPrev_e[bin], &hDiracDecBin->ChCrossReOut_e[bin] ); + hDiracDecBin->ChCrossImOut_fx[bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChCrossImOut_fx[bin], hDiracDecBin->ChCrossImOut_e[bin], Mpy_32_32( hDiracDecBin->ChCrossImOutPrev_fx[bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChCrossImOutPrev_e[bin], &hDiracDecBin->ChCrossImOut_e[bin] ); move32(); move32(); FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - hDiracDecBin->ChEne_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[ch][bin], hDiracDecBin->ChEne_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEnePrev_fx[ch][bin], IIReneLimiter_fx ), hDiracDecBin->ChEnePrev_e[ch][bin], &hDiracDecBin->ChEne_e[ch][bin] ); - hDiracDecBin->ChEneOut_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[ch][bin], hDiracDecBin->ChEneOut_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEneOutPrev_fx[ch][bin], IIReneLimiter_fx ), hDiracDecBin->ChEneOutPrev_e[ch][bin], &hDiracDecBin->ChEneOut_e[ch][bin] ); - move32(); + hDiracDecBin->ChEneOut_fx[ch][bin] = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEneOut_fx[ch][bin], hDiracDecBin->ChEneOut_e[ch][bin], Mpy_32_32( hDiracDecBin->ChEneOutPrev_fx[ch][bin], IIReneLimiter_fx[bin] ), hDiracDecBin->ChEneOutPrev_e[ch][bin], &hDiracDecBin->ChEneOut_e[ch][bin] ); move32(); } - /* Store energy values and coefficients for next round */ - hDiracDecBin->ChCrossRePrev_fx[bin] = hDiracDecBin->ChCrossRe_fx[bin]; - move32(); - hDiracDecBin->ChCrossImPrev_fx[bin] = hDiracDecBin->ChCrossIm_fx[bin]; - move32(); + hDiracDecBin->ChCrossReOutPrev_fx[bin] = hDiracDecBin->ChCrossReOut_fx[bin]; move32(); hDiracDecBin->ChCrossImOutPrev_fx[bin] = hDiracDecBin->ChCrossImOut_fx[bin]; move32(); - hDiracDecBin->ChCrossRePrev_e[bin] = hDiracDecBin->ChCrossRe_e[bin]; - move16(); - hDiracDecBin->ChCrossImPrev_e[bin] = hDiracDecBin->ChCrossIm_e[bin]; - move16(); hDiracDecBin->ChCrossReOutPrev_e[bin] = hDiracDecBin->ChCrossReOut_e[bin]; move16(); hDiracDecBin->ChCrossImOutPrev_e[bin] = hDiracDecBin->ChCrossImOut_e[bin]; @@ -2816,10 +2049,10 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric { hDiracDecBin->ChEnePrev_fx[ch][bin] = hDiracDecBin->ChEne_fx[ch][bin]; move32(); - hDiracDecBin->ChEneOutPrev_fx[ch][bin] = hDiracDecBin->ChEneOut_fx[ch][bin]; - move32(); hDiracDecBin->ChEnePrev_e[ch][bin] = hDiracDecBin->ChEne_e[ch][bin]; move16(); + hDiracDecBin->ChEneOutPrev_fx[ch][bin] = hDiracDecBin->ChEneOut_fx[ch][bin]; + move32(); hDiracDecBin->ChEneOutPrev_e[ch][bin] = hDiracDecBin->ChEneOut_e[ch][bin]; move16(); } @@ -2827,7 +2060,8 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric return; } -#endif + + static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, @@ -3460,7 +2694,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( const Word16 processReverb, const Word16 subframe, const Word16 q_mat -#ifdef SPLIT_REND_WITH_HEAD_ROT , Word32 outRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -3470,7 +2703,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *Q_inp_mix, const Word8 recompute -#endif ) { Word16 slot, bin, chA, chB; @@ -3487,10 +2719,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 decSlotRe_fx[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX], decSlotIm_fx[BINAURAL_CHANNELS][CLDFB_NO_CHANNELS_MAX]; Word32 outSlotRe_fx[CLDFB_NO_CHANNELS_MAX], outSlotIm_fx[CLDFB_NO_CHANNELS_MAX]; -#ifndef SPLIT_REND_WITH_HEAD_ROT - Word32 reverbRe_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 reverbIm_fx[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; -#endif Word16 q_inp[6][CLDFB_SLOTS_PER_SUBFRAME]; Word16 interpVal_fx; Word32 *decSlotRePointer_fx; @@ -3501,21 +2729,15 @@ static void ivas_dirac_dec_binaural_process_output_fx( IF( processReverb ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( recompute == 1 ) { -#endif /* Process second / room effect part of binaural output when needed */ ivas_binaural_reverb_processSubframe_fx( hDiracDecBin->hReverb, numInChannels, nSlots, inRe_fx, inIm_fx, reverbRe_fx, reverbIm_fx ); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( recompute, 1 ) ) { -#endif // scaling input and reverb to same q// // input scaling is to maintain precision in ivas_dirac_dec_decorrelate_slot fn// 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 ) ); @@ -3528,11 +2750,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( q_inp[i][j] = s_min( L_norm_arr( inRe_fx[i][j], nBins ), L_norm_arr( inIm_fx[i][j], nBins ) ); move16(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) -#else - IF( ( processReverb ) && LT_16( i, 2 ) ) -#endif { q_reverb = s_min( L_norm_arr( reverbRe_fx[i][j], CLDFB_NO_CHANNELS_MAX ), L_norm_arr( reverbIm_fx[i][j], CLDFB_NO_CHANNELS_MAX ) ); q_inp[i][j] = s_min( q_reverb, q_inp[i][j] ); @@ -3560,11 +2778,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( scale_sig32( inRe_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ scale_sig32( inIm_fx[i][j], nBins, q_inp_mix ); /*q_input + q_inp_mix*/ test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( processReverb && EQ_16( recompute, 1 ) ) && LT_16( i, 2 ) ) -#else - IF( ( processReverb ) && LT_16( i, 2 ) ) -#endif { 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*/ @@ -3579,7 +2793,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( cldfbSynDec[1]->Q_cldfb_state = add( cldfbSynDec[1]->Q_cldfb_state, cldfb_state_shift ); move16(); move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT *Q_inp_mix = q_inp_mix; move16(); } @@ -3587,7 +2800,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( { q_inp_mix = *Q_inp_mix; } -#endif q_inp_mix = add( q_inp_mix, q_input ); @@ -3613,12 +2825,9 @@ static void ivas_dirac_dec_binaural_process_output_fx( test(); IF( !hDiracDecBin->useTdDecorr && ( max_band_decorr > 0 ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( recompute == 1 ) { -#endif ivas_dirac_dec_decorrelate_slot_fx( hDiracDecBin, nBins, slot, inRe_fx, inIm_fx, q_inp_mix, decSlotRe_fx, decSlotIm_fx ); -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) { Copy32( decSlotRe_fx[chA], decorrRe_fx[chA][slot], CLDFB_NO_CHANNELS_MAX ); @@ -3633,7 +2842,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( Copy32( decorrIm_fx[chA][slot], decSlotIm_fx[chA], CLDFB_NO_CHANNELS_MAX ); } } -#endif } FOR( chA = 0; chA < BINAURAL_CHANNELS; chA++ ) @@ -3723,7 +2931,6 @@ static void ivas_dirac_dec_binaural_process_output_fx( outSlotRePr_fx = &( outSlotRe_fx[0] ); outSlotImPr_fx = &( outSlotIm_fx[0] ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( outRe_fx != NULL && outIm_fx != NULL ) { /* provide the data outside in CLDFB domain => mainly for split rendering */ @@ -3743,27 +2950,13 @@ static void ivas_dirac_dec_binaural_process_output_fx( cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); move16(); } -#else -#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 - cldfbSynthesis_ivas_fx( &outSlotRePr_fx, &outSlotImPr_fx, &( output_fx[chA][nBins * slot + offsetSamples] ), nBins, 0, cldfbSynDec[chA] ); -#endif - cldfbSynDec[chA]->Q_cldfb_state = sub( q_result, 1 ); - move16(); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ } } -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( recompute == 1 ) { *q_out = sub( q_result, 1 ); move16(); } -#else - *q_out = sub( q_result, 1 ); - move16(); -#endif return; } @@ -6330,14 +5523,10 @@ static void ivas_masa_ext_rend_parambin_internal_fx( MASA_EXT_REND_HANDLE hMasaExtRend, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[], /* Q11*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] -#else - const Word16 subframe -#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -6349,7 +5538,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word16 i, j; Word16 nchan_transport; Word16 q_mat; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData; Word32 tmp_Cldfb_out_re[BINAURAL_CHANNELS][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -6366,9 +5554,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( Word16 Q_inp_mix; hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; -#else - hDiracDecBin = hMasaExtRend->hDiracDecBin; -#endif hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; Word32 Cldfb_RealBuffer_in_fx[6][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -6383,11 +5568,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( } } Word32 Rmat_fx[3][3]; -#ifdef SPLIT_REND_WITH_HEAD_ROT hDiracDecBin = hMasaExtRend->hDiracDecBin[0]; -#else - hDiracDecBin = hMasaExtRend->hDiracDecBin; -#endif assert( hDiracDecBin ); hSpatParamRendCom = hMasaExtRend->hSpatParamRendCom; nBins = hSpatParamRendCom->num_freq_bands; @@ -6491,29 +5672,21 @@ static void ivas_masa_ext_rend_parambin_internal_fx( IF( EQ_16( nchan_transport, 2 ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT /* in case of split rendering, determine the prototype rotation based on the main direction and use the same prototypes for the offset directions */ -#endif adaptTransportSignalsHeadtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); ivas_dirac_dec_binaural_check_and_switch_transports_headtracked_fx( hCombinedOrientationData, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, nBins, hSpatParamRendCom->subframe_nbslots[subframe], Rmat_fx ); } } test(); -#ifndef SPLIT_REND_WITH_HEAD_ROT - ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, Rmat_fx, subframe, - hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, NULL, q_inp ); -#endif /* Always using CLDFB decorrelation in MASA EXT renderer */ max_band_decorr = hDiracDecBin->h_freq_domain_decorr_ap_params->max_band_decorr; -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, subframe, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, q_inp ); ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, subFrameTotalEne_fx, subFrameTotalEne_e, IIReneLimiter_fx, NULL ); -#endif ivas_dirac_dec_binaural_determine_processing_matrices_fx( hDiracDecBin, hSpatParamRendCom, &config_data, max_band_decorr, Rmat_fx, subframe, hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[hCombinedOrientationData->subframe_idx] > 0, @@ -6564,7 +5737,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( move16(); move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT pMultiBinPoseData = NULL; if ( hSplitRendWrapper != NULL ) { @@ -6587,13 +5759,9 @@ static void ivas_masa_ext_rend_parambin_internal_fx( ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, NULL, NULL, reverbRe_fx, reverbIm_fx, decorrRe_fx, decorrIm_fx, &Q_inp_mix, 1 ); } -#else - ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, hMasaExtRend->cldfbSynRend, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat ); -#endif hDiracDecBin->hDiffuseDist = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) { /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ @@ -6700,7 +5868,6 @@ static void ivas_masa_ext_rend_parambin_internal_fx( } /* update this counter only after the last rendering of split directions */ -#endif hSpatParamRendCom->slots_rendered = add( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->subframe_nbslots[subframe] ); hSpatParamRendCom->subframes_rendered = add( hSpatParamRendCom->subframes_rendered, 1 ); @@ -6721,14 +5888,10 @@ void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 num_subframes, /* i : number of subframes to render */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ -#else - const Word16 num_subframes /* i : number of subframes to render */ -#endif ) { Word16 subframe; @@ -6751,11 +5914,7 @@ void ivas_masa_ext_rend_parambin_render_fx( hSpatParamRendCom->slots_rendered = 0; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx, hSplitRendWrapper, Cldfb_Out_Real, Cldfb_Out_Imag ); -#else - ivas_masa_ext_rend_parambin_internal_fx( hMasaExtRend, hCombinedOrientationData, p_output, hSpatParamRendCom->dirac_read_idx ); -#endif FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index 5ea170a78..ee91e7060 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -696,20 +696,12 @@ ivas_error ivas_orient_trk_SetReferenceRotation_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* check for Euler angle signaling */ IF( EQ_32( refRot.w_fx, L_negate( 12582912 ) ) && EQ_16( refRot.q_fact, Q22 ) ) { Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); modify_Quat_q_fx( &pOTR->refRot, &pOTR->refRot, Q29 ); } -#else - /* check for Euler angle signaling */ - IF( EQ_32( refRot.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) - { - Euler2Quat_fx( deg2rad_fx( refRot.x_fx ), deg2rad_fx( refRot.y_fx ), deg2rad_fx( refRot.z_fx ), &pOTR->refRot ); - } -#endif pOTR->refRot = refRot; return IVAS_ERR_OK; diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 7bcf6e37d..f33ace930 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -100,10 +100,8 @@ Word16 audioCfg2channels( move16(); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: nchan_out = 2; @@ -270,10 +268,8 @@ void ivas_output_init( move16(); BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_ISM1: @@ -379,10 +375,8 @@ Word16 ivas_get_nchan_buffers_dec( nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } ELSE if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) -#ifdef SPLIT_REND_WITH_HEAD_ROT || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) -#endif ) { nchan_out_buff = shl( CPE_CHANNELS, 1 ); @@ -464,12 +458,10 @@ Word16 ivas_get_nchan_buffers_dec( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); } -#endif return nchan_out_buff; } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 90771862e..fec808243 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -220,14 +220,10 @@ void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word16 num_subframes, /* i : number of subframes to render */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* o : rendered orientations for split rend. imag part of cldfb */ -#else - const Word16 num_subframes /* i : number of subframes to render */ -#endif ); ivas_error ivas_dirac_dec_init_binaural_data_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -887,21 +883,13 @@ ivas_error ivas_rend_openCrend( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics, #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT const Word32 output_Fs, const Word16 num_poses -#else - const Word32 output_Fs -#endif ); void ivas_rend_closeCrend( -#ifdef SPLIT_REND_WITH_HEAD_ROT CREND_WRAPPER_HANDLE *pCrend , const Word16 num_poses -#else - CREND_WRAPPER_HANDLE *pCrend -#endif ); ivas_error ivas_hrtf_init( @@ -909,12 +897,8 @@ ivas_error ivas_hrtf_init( ); ivas_error ivas_rend_initCrendWrapper( -#ifdef SPLIT_REND_WITH_HEAD_ROT CREND_WRAPPER_HANDLE *pCrend, const Word16 num_poses -#else - CREND_WRAPPER_HANDLE *pCrend -#endif ); ivas_error ivas_rend_crendProcessSubframe( @@ -930,10 +914,8 @@ ivas_error ivas_rend_crendProcessSubframe( Word32 *output[], /* i/o: input/output audio channels */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word32 output_Fs /* i : output sampling rate */ -#ifdef SPLIT_REND_WITH_HEAD_ROT , const Word16 pos_idx -#endif ); @@ -1569,7 +1551,6 @@ void masaPrerendClose_fx( MASA_PREREND_HANDLE *hMasaPrerendPtr /* i/o: prerenderer handle to be closed */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * Split rendering *----------------------------------------------------------------------------------*/ @@ -1648,7 +1629,6 @@ void ivas_rend_closeCldfbRend( CLDFB_REND_WRAPPER *pCldfbRend ); -#endif /* clang-format on */ diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index fb3e86585..44eff1329 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -338,17 +338,13 @@ ivas_error ivas_er_encoder_init( p_y_fx = reflections->shoebox_data.az_angle.data_fx[i]; // Q23 move32(); move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT p_x_fx = L_shr( p_x_fx, 1 ); // Q22 p_y_fx = L_shr( p_y_fx, 1 ); // Q22 -#endif rad_el_angle = deg2rad_fx( p_x_fx ); // Q22 rad_az_angle = deg2rad_fx( p_y_fx ); // Q22 -#ifdef SPLIT_REND_WITH_HEAD_ROT rad_el_angle = L_shl( rad_el_angle, 1 ); // Q23 rad_az_angle = L_shl( rad_az_angle, 1 ); // Q23 -#endif rad_el_angle = L_shr( rad_el_angle, 10 ); // Q13 rad_az_angle = L_shr( rad_az_angle, 10 ); // Q13 diff --git a/lib_rend/ivas_render_config_fx.c b/lib_rend/ivas_render_config_fx.c index 7f8e96d5c..fc5c26351 100644 --- a/lib_rend/ivas_render_config_fx.c +++ b/lib_rend/ivas_render_config_fx.c @@ -137,7 +137,6 @@ ivas_error ivas_render_config_init_from_rom_fx( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ( *hRenderConfig )->split_rend_config.splitRendBitRate = SPLIT_REND_768k; move32(); ( *hRenderConfig )->split_rend_config.dof = 3; @@ -158,7 +157,6 @@ ivas_error ivas_render_config_init_from_rom_fx( move32(); ( *hRenderConfig )->split_rend_config.lc3plus_highres = 0; move16(); -#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 36f363f83..dc73967cc 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -87,9 +87,7 @@ Word16 square_root30_q12[31] = { static ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, IVAS_VECTOR3 *listenerPos, -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis*/ -#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData ); static void external_target_interpolation_fx( @@ -143,10 +141,8 @@ ivas_error ivas_headTrack_open_fx( move32(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ( *hHeadTrackData )->sr_pose_pred_axis = DEFAULT_AXIS; move32(); -#endif set32_fx( ( *hHeadTrackData )->chEneIIR_fx[0], 0, MASA_FREQUENCY_BANDS ); set32_fx( ( *hHeadTrackData )->chEneIIR_fx[1], 0, MASA_FREQUENCY_BANDS ); @@ -196,7 +192,6 @@ void QuatToRotMat_fx( ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( quat.w_fx, L_negate( 12582912 ) ) ) { assert( 0 ); @@ -206,7 +201,6 @@ void QuatToRotMat_fx( } else { -#endif Word32 w = quat.w_fx; // Qx move32(); Word32 x = quat.x_fx; @@ -252,9 +246,7 @@ void QuatToRotMat_fx( move32(); Rmat[2][2] = L_add( L_sub( L_sub( ww, xx ), yy ), zz ); move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif return; } @@ -731,11 +723,7 @@ void rotateFrame_shd( } /* calculate ambisonics rotation matrices for the previous and current frames */ -#ifdef SPLIT_REND_WITH_HEAD_ROT SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx[0], shd_rot_max_order ); -#else - SHrotmatgen_fx( SHrotmat_prev, hCombinedOrientationData->Rmat_prev_fx, shd_rot_max_order ); -#endif SHrotmatgen_fx( SHrotmat /*Q14*/, hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx], shd_rot_max_order ); FOR( i = 0; i < subframe_len; i++ ) @@ -796,11 +784,7 @@ void rotateFrame_shd( { Copy32( hCombinedOrientationData->Rmat_fx[subframe_idx][i], -#ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev_fx[0][i], -#else - hCombinedOrientationData->Rmat_prev_fx[i], -#endif 3 ); // Q14 } @@ -899,11 +883,7 @@ void rotateFrame_sd( } /* gains for previous subframe rotation */ -#ifdef SPLIT_REND_WITH_HEAD_ROT rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx[0], hTransSetup.is_planar_setup ); -#else - rotateAziEle_fx( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), &azimuth, &elevation, hCombinedOrientationData->Rmat_prev_fx, hTransSetup.is_planar_setup ); -#endif test(); test(); IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hTransSetup.ls_azimuth_fx[ch_in_woLFE], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hTransSetup.ls_elevation_fx[ch_in_woLFE], Q22 ) ), elevation ) ) ) @@ -997,11 +977,7 @@ void rotateFrame_sd( { Copy32( hCombinedOrientationData->Rmat_fx[hCombinedOrientationData->subframe_idx][i], // Q30 -#ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->Rmat_prev_fx[0][i], -#else - hCombinedOrientationData->Rmat_prev_fx[i], -#endif 3 ); } /* copy to output */ @@ -1345,9 +1321,7 @@ ivas_error ivas_combined_orientation_open( Word16 j; IVAS_QUATERNION identity; IVAS_VECTOR3 origo; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif identity.w_fx = ONE_IN_Q31; move32(); identity.x_fx = 0; @@ -1409,7 +1383,6 @@ ivas_error ivas_combined_orientation_open( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { FOR( j = 0; j < 3; j++ ) @@ -1423,14 +1396,6 @@ ivas_error ivas_combined_orientation_open( ( *hCombinedOrientationData )->sr_low_res_flag = 0; move32(); move16(); -#else - FOR( j = 0; j < 3; j++ ) - { - set32_fx( ( *hCombinedOrientationData )->Rmat_prev_fx[j], 0, 3 ); - ( *hCombinedOrientationData )->Rmat_prev_fx[j][j] = ONE_IN_Q30; - move32(); - } -#endif ( *hCombinedOrientationData ) ->Quaternion_prev_extOrientation = identity; @@ -1494,9 +1459,7 @@ ivas_error combine_external_and_head_orientations_dec( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; -#endif IVAS_QUATERNION *pHeadRotQuaternion = NULL; IVAS_VECTOR3 *listenerPos = NULL; @@ -1504,20 +1467,14 @@ ivas_error combine_external_and_head_orientations_dec( { pHeadRotQuaternion = hHeadTrackData->Quaternions; listenerPos = hHeadTrackData->Pos; -#ifdef SPLIT_REND_WITH_HEAD_ROT sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT ELSE { sr_pose_pred_axis = DEFAULT_AXIS; } -#endif return combine_external_and_head_orientations( pHeadRotQuaternion, listenerPos, -#ifdef SPLIT_REND_WITH_HEAD_ROT sr_pose_pred_axis, -#endif hExtOrientationData, hCombinedOrientationData ); } @@ -1534,16 +1491,12 @@ ivas_error combine_external_and_head_orientations_rend( COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; -#endif IVAS_QUATERNION *headRotQuaternions = NULL; IVAS_VECTOR3 *listenerPos = NULL; Word16 i; -#ifdef SPLIT_REND_WITH_HEAD_ROT sr_pose_pred_axis = DEFAULT_AXIS; -#endif IF( hHeadTrackData != NULL ) { @@ -1552,9 +1505,7 @@ ivas_error combine_external_and_head_orientations_rend( headRotQuaternions = hHeadTrackData->headPositions; listenerPos = hHeadTrackData->Pos; } -#ifdef SPLIT_REND_WITH_HEAD_ROT sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis; -#endif } ELSE IF( hExtOrientationData != NULL ) { @@ -1570,9 +1521,7 @@ ivas_error combine_external_and_head_orientations_rend( } return combine_external_and_head_orientations( headRotQuaternions, listenerPos, -#ifdef SPLIT_REND_WITH_HEAD_ROT sr_pose_pred_axis, -#endif hExtOrientationData, hCombinedOrientationData ); } @@ -1586,9 +1535,7 @@ ivas_error combine_external_and_head_orientations_rend( ivas_error combine_external_and_head_orientations( IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ IVAS_VECTOR3 *listenerPos, /* i : listener position */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ -#endif EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) @@ -1937,9 +1884,7 @@ ivas_error combine_external_and_head_orientations( move16(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT hCombinedOrientationData->sr_pose_pred_axis = sr_pose_pred_axis; -#endif return IVAS_ERR_OK; } @@ -2248,11 +2193,7 @@ static Word32 SHrot_w_fx( IF( m == 0 ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT assert( 0 && "ERROR should not be called\n" ); -#else - printf( "ERROR should not be called\n" ); -#endif return 0; } ELSE @@ -2450,11 +2391,7 @@ void ivas_combined_orientation_update_index( Word16 exp, div_result; IF( hCombinedOrientationData != NULL ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) || hCombinedOrientationData->sr_low_res_flag ) -#else - IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) ) -#endif { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; @@ -2511,11 +2448,7 @@ void ivas_combined_orientation_update_start_index( { IF( hCombinedOrientationData != NULL ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) || hCombinedOrientationData->sr_low_res_flag ) -#else - IF( EQ_16( hCombinedOrientationData->num_subframes, 1 ) ) -#endif { /* only one orientation available anyway or split rendering with low resolution*/ hCombinedOrientationData->subframe_idx = 0; diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index c93f62396..fd1945a3f 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -699,15 +699,9 @@ typedef struct ivas_binaural_rendering_conv_module_struct_fx Word32 ***filterTapsRightReal_fx; Word32 ***filterTapsRightImag_fx; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 ****filterStatesLeftReal_fx; Word32 ****filterStatesLeftImag_fx; Word16 *Q_filterStates; -#else - Word32 ***filterStatesLeftReal_fx; - Word32 ***filterStatesLeftImag_fx; - Word16 Q_filterStatesLeft; -#endif Word16 numTapsArray[BINAURAL_CONVBANDS]; Word16 numTaps; @@ -802,9 +796,7 @@ typedef struct IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; Word32 crossfade_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q31 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; -#endif ivas_orient_trk_state_t *hOrientationTracker; } IVAS_REND_HeadRotData; @@ -826,9 +818,7 @@ typedef struct ivas_binaural_head_track_struct Word16 shd_rot_max_order; ivas_orient_trk_state_t *OrientationTracker; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; -#endif } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; /*----------------------------------------------------------------------------------* @@ -862,21 +852,15 @@ typedef struct ivas_combined_orientation_struct IVAS_QUATERNION Quaternions_ext_interpolation_start; IVAS_QUATERNION Quaternions_ext_interpolation_target; Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3]; /* Q30 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT Word32 Rmat_prev_fx[MAX_HEAD_ROT_POSES][3][3]; -#else - Word32 Rmat_prev_fx[3][3]; /* Q30 */ -#endif Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ /* Q(q_chEneIIR) */ Word16 q_chEneIIR; Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* Q(q_procChEneIIR) */ Word16 q_procChEneIIR; Word16 shd_rot_max_order; IVAS_VECTOR3 listenerPos[MAX_PARAM_SPATIAL_SUBFRAMES]; -#ifdef SPLIT_REND_WITH_HEAD_ROT ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis; Word16 sr_low_res_flag; -#endif IVAS_QUATERNION Quaternion_frozen_ext; IVAS_QUATERNION Quaternion_frozen_head; Word8 isExtOrientationFrozen; @@ -1387,18 +1371,13 @@ typedef struct ivas_crend_state_t typedef struct ivas_binaural_crend_wrapper_struct { Word32 binaural_latency_ns; -#ifdef SPLIT_REND_WITH_HEAD_ROT CREND_HANDLE hCrend[MAX_HEAD_ROT_POSES]; -#else - CREND_HANDLE hCrend; -#endif HRTFS_HANDLE hHrtfCrend; Word16 *p_io_qfactor; Word16 io_qfactor; } CREND_WRAPPER, *CREND_WRAPPER_HANDLE; -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Fastconv binaural data structure */ typedef struct ivas_binaural_rendering_struct { @@ -1424,7 +1403,6 @@ typedef struct ivas_binaural_rendering_struct Word16 numPoses; } BINAURAL_RENDERER, *BINAURAL_RENDERER_HANDLE; -#endif /*------------------------------------------------------------------------------------------* * HRTF structures - hrtfs from binary files @@ -1510,7 +1488,6 @@ typedef struct ivas_hrtfs_statistics_struct } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT /*----------------------------------------------------------------------------------* * CLDFB renderer wrapper @@ -1524,7 +1501,6 @@ typedef struct } CLDFB_REND_WRAPPER; -#endif /*----------------------------------------------------------------------------------* * Limiter structure @@ -1622,11 +1598,7 @@ typedef struct ivas_masa_external_rendering_struct RENDERER_TYPE renderer_type; DIRAC_REND_HANDLE hDirACRend; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; -#ifdef SPLIT_REND_WITH_HEAD_ROT DIRAC_DEC_BIN_HANDLE hDiracDecBin[MAX_HEAD_ROT_POSES]; -#else - DIRAC_DEC_BIN_HANDLE hDiracDecBin; -#endif REVERB_STRUCT_HANDLE hReverb; HRTFS_PARAMBIN_HANDLE *hHrtfParambin; diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index b27c59852..1300d6340 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -56,7 +56,6 @@ typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; typedef Word32 IVAS_REND_LfePanMtx_fx[RENDERER_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS]; -#ifdef SPLIT_REND_WITH_HEAD_ROT typedef struct { Word32 bufLenInBytes; @@ -73,7 +72,6 @@ typedef struct IVAS_REND_BitstreamBufferConfig config; UWord8 *bits; } IVAS_REND_BitstreamBuffer; -#endif typedef struct { @@ -266,7 +264,6 @@ Word16 IVAS_REND_FeedRenderConfig( const IVAS_RENDER_CONFIG_DATA renderConfig /* i : Render configuration struct */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_FeedSplitBinauralBitstream( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_REND_InputId inputId, /* i : ID of the input */ @@ -293,15 +290,12 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( , Word16 *pIsar_frame_size_ms /* o: pointer to isar frame size setting */ ); -#endif ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering*/ -#endif const Word16 sf_idx /* i : subframe index */ ); @@ -336,11 +330,9 @@ ivas_error IVAS_REND_SetReferenceVector( const IVAS_VECTOR3 refPos /* i : Reference position */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error IVAS_REND_SetSplitRendBFI( IVAS_REND_HANDLE hIvasRend, const Word16 bfi); -#endif ivas_error IVAS_REND_SetExternalOrientation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ @@ -400,7 +392,6 @@ void IVAS_REND_Close( IVAS_REND_HANDLE* phIvasRend /* i/o: Pointer to renderer handle */ ); -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural rendering functions */ ivas_error IVAS_REND_openCldfb( @@ -433,7 +424,6 @@ void IVAS_REND_cldfbSynthesis_wrapper( IVAS_CLDFB_FILTER_BANK_HANDLE h_cldfb, /* i : filter bank state */ Word16 Q_cldfb, Word16 *Q_out ); -#endif /* Disclaimer and info printing */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index eb155a89f..1d019b675 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -95,11 +95,9 @@ typedef struct const LSSETUP_CUSTOM_STRUCT *pCustomLsOut; const EFAP_WRAPPER *pEfapOutWrapper; IVAS_REND_HeadRotData *pHeadRotData; // for now removing the const qualifier TODO: will modify later -#ifdef SPLIT_REND_WITH_HEAD_ROT const RENDER_CONFIG_HANDLE *hhRendererConfig; const Word16 *pSplitRendBFI; const SPLIT_REND_WRAPPER *pSplitRendWrapper; -#endif const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData; } rendering_context; /* Common base for input structs */ @@ -125,9 +123,7 @@ typedef struct rotation_matrix_fx rot_mat_prev_fx; pan_vector prev_pan_gains; Word8 firstFrameRendered; -#ifdef SPLIT_REND_WITH_HEAD_ROT TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ -#endif Word32 *bufferData_fx; Word16 nonDiegeticPan; Word32 nonDiegeticPanGain_fx; /* Q31 */ @@ -160,15 +156,9 @@ typedef struct EFAP_WRAPPER efapInWrapper; TDREND_WRAPPER tdRendWrapper; CREND_WRAPPER_HANDLE crendWrapper; -#ifdef SPLIT_REND_WITH_HEAD_ROT TDREND_WRAPPER splitTdRendWrappers[MAX_HEAD_ROT_POSES - 1]; /* Additional TD Rend instances used for split rendering */ -#endif REVERB_HANDLE hReverb; -#ifdef SPLIT_REND_WITH_HEAD_ROT rotation_gains_Word32 rot_gains_prev_fx[MAX_HEAD_ROT_POSES]; -#else - rotation_gains_Word32 rot_gains_prev_fx; -#endif Word16 nonDiegeticPan; Word32 nonDiegeticPanGain_fx; lfe_routing lfeRouting; @@ -182,15 +172,9 @@ typedef struct input_base base; // pan_matrix hoaDecMtx; pan_matrix_fx hoaDecMtx_fx; -#ifdef SPLIT_REND_WITH_HEAD_ROT CLDFB_REND_WRAPPER cldfbRendWrapper; -#endif CREND_WRAPPER_HANDLE crendWrapper; -#ifdef SPLIT_REND_WITH_HEAD_ROT rotation_gains_fx rot_gains_prev_fx[MAX_HEAD_ROT_POSES]; -#else - rotation_gains_fx rot_gains_prev_fx; -#endif Word32 *bufferData_fx; DIRAC_ANA_HANDLE hDirAC; } input_sba; @@ -232,14 +216,10 @@ struct IVAS_REND EFAP_WRAPPER efapOutWrapper; IVAS_LSSETUP_CUSTOM_STRUCT customLsOut; -#ifdef SPLIT_REND_WITH_HEAD_ROT SPLIT_REND_WRAPPER splitRendWrapper; IVAS_REND_AudioBuffer splitRendEncBuffer; -#endif IVAS_REND_HeadRotData headRotData; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 splitRendBFI; -#endif EXTERNAL_ORIENTATION_HANDLE hExternalOrientationData; COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; @@ -265,7 +245,6 @@ static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ Word16 to_fix ); -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], @@ -278,7 +257,6 @@ static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k] ); -#endif /*-------------------------------------------------------------------* * Local functions @@ -359,7 +337,6 @@ static Word32 *getSmplPtr_fx( return buffer.data_fx + chnlIdx * buffer.config.numSamplesPerChannel + smplIdx; } -#ifdef SPLIT_REND_WITH_HEAD_ROT static void convertBitsBufferToInternalBitsBuff( const IVAS_REND_BitstreamBuffer outBits, ISAR_SPLIT_REND_BITS_HANDLE hBits ) @@ -461,7 +438,6 @@ static void accumulateCLDFBArrayToBuffer_fx( return; } -#endif static void copyBufferTo2dArray_fx( const IVAS_REND_AudioBuffer buffer, @@ -471,9 +447,7 @@ static void copyBufferTo2dArray_fx( UWord32 chnlIdx; const Word32 *readPtr; -#ifdef SPLIT_REND_WITH_HEAD_ROT assert( ( buffer.config.is_cldfb == 0 ) && "for CLDFB input call copyBufferToCLDFBarray()" ); -#endif readPtr = buffer.data_fx; @@ -583,10 +557,8 @@ static ivas_error validateOutputAudioConfig( case IVAS_AUDIO_CONFIG_HOA2: case IVAS_AUDIO_CONFIG_HOA3: case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA1: @@ -669,14 +641,12 @@ static ivas_error validateOutputSampleRate( /* If no binaural rendering, any sampling rate is supported */ return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT ELSE IF( ( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( sampleRate, 48000 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); } ELSE { -#endif /* Otherwise rendering to binaural, support the same set as IVAS decoder */ SWITCH( sampleRate ) @@ -689,9 +659,7 @@ ELSE } return IVAS_ERR_INVALID_SAMPLING_RATE; -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } /*-------------------------------------------------------------------* * getAudioConfigNumChannels() @@ -713,10 +681,8 @@ ivas_error getAudioConfigNumChannels( BREAK; case IVAS_AUDIO_CONFIG_STEREO: case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: case IVAS_AUDIO_CONFIG_MASA2: @@ -1226,10 +1192,8 @@ static ivas_error initHeadRotation_fx( hIvasRend->headRotData.headPositions[i] = quaternionInit_fx(); } -#ifdef SPLIT_REND_WITH_HEAD_ROT hIvasRend->headRotData.sr_pose_pred_axis = DEFAULT_AXIS; move32(); -#endif IF( ( hIvasRend->headRotData.hOrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { @@ -1381,11 +1345,9 @@ static rendering_context getRendCtx( ctx.pCustomLsOut = &hIvasRend->customLsOut; ctx.pEfapOutWrapper = &hIvasRend->efapOutWrapper; ctx.pHeadRotData = &hIvasRend->headRotData; -#ifdef SPLIT_REND_WITH_HEAD_ROT ctx.hhRendererConfig = &hIvasRend->hRendererConfig; ctx.pSplitRendBFI = &hIvasRend->splitRendBFI; ctx.pSplitRendWrapper = &hIvasRend->splitRendWrapper; -#endif ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData; return ctx; @@ -1433,11 +1395,7 @@ static ivas_error initIsmMasaRendering( ivas_td_binaural_close_fx( &inputIsm->tdRendWrapper.hBinRendererTd ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper ); -#endif ivas_reverb_close( &inputIsm->hReverb ); IF( NE_32( ( error = ivas_omasa_ana_open( &inputIsm->hOMasa, inSampleRate, inputIsm->total_num_objects ) ), IVAS_ERR_OK ) ) @@ -1460,9 +1418,7 @@ static ivas_error setRendInputActiveIsm( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_ism *inputIsm; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 i; -#endif Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; Word16 num_src; Word16 ivas_format; @@ -1504,12 +1460,10 @@ static ivas_error setRendInputActiveIsm( set_zero_fx( inputIsm->prev_pan_gains_fx, MAX_OUTPUT_CHANNELS ); -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { inputIsm->splitTdRendWrappers[i].hHrtfTD = &hrtfs->hHrtfTD; } -#endif inputIsm->hOMasa = NULL; @@ -1519,24 +1473,10 @@ static ivas_error setRendInputActiveIsm( inputIsm->tdRendWrapper.hHrtfTD = &hrtfs->hHrtfTD; test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT test(); test(); IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) -#endif { -#ifndef SPLIT_REND_WITH_HEAD_ROT -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif - { - return error; - } -#else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { return error; @@ -1594,7 +1534,6 @@ static ivas_error setRendInputActiveIsm( } } } -#endif } ELSE IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) { @@ -1605,48 +1544,6 @@ static ivas_error setRendInputActiveIsm( } ELSE { -#ifndef SPLIT_REND_WITH_HEAD_ROT - IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) - { - return error; - } - Word16 nchan_rend = num_src; - move16(); - - test(); - IF( EQ_16( ivas_format, MC_FORMAT ) && NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) - { - nchan_rend = sub( nchan_rend, 1 ); /* Skip LFE channel -- added to the others */ - } - - FOR( Word16 nS = 0; nS < nchan_rend; nS++ ) - { - TDREND_SRC_t *Src_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[SrcInd[nS]]; - IF( Src_p != NULL ) - { - IF( Src_p->SrcSpatial_p != NULL ) - { - Src_p->SrcSpatial_p->q_Pos_p = Q31; - move16(); - } - TDREND_SRC_SPATIAL_t *SrcSpatial_p = inputIsm->tdRendWrapper.hBinRendererTd->Sources[nS]->SrcSpatial_p; - SrcSpatial_p->q_Pos_p = Q31; - move16(); - } - } - - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) - { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ) IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif - { - return error; - } - } -#else IF( NE_32( ( error = ivas_td_binaural_open_ext_fx( &inputIsm->tdRendWrapper, inConfig, hRendCfg, NULL, *rendCtx.pOutSampleRate, SrcInd, &num_src ) ), IVAS_ERR_OK ) ) { return error; @@ -1699,7 +1596,6 @@ static ivas_error setRendInputActiveIsm( return error; } } -#endif } return IVAS_ERR_OK; @@ -1709,9 +1605,7 @@ static void clearInputIsm( input_ism *inputIsm ) { rendering_context rendCtx; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t i; -#endif rendCtx = inputIsm->base.ctx; @@ -1720,11 +1614,7 @@ static void clearInputIsm( initRendInputBase_fx( &inputIsm->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); /* Free input's internal handles */ -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputIsm->crendWrapper, inputIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputIsm->crendWrapper ); -#endif ivas_reverb_close( &inputIsm->hReverb ); @@ -1733,12 +1623,10 @@ static void clearInputIsm( ivas_td_binaural_close_fx( &inputIsm->tdRendWrapper.hBinRendererTd ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { ivas_td_binaural_close_fx( &inputIsm->splitTdRendWrappers[i].hBinRendererTd ); } -#endif ivas_omasa_ana_close( &( inputIsm->hOMasa ) ); @@ -2468,10 +2356,8 @@ static ivas_error updateMcPanGains( SWITCH( outConfig ) { case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: -#endif BREAK; /* Do nothing */ case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: @@ -2525,9 +2411,7 @@ static ivas_error initMcBinauralRendering( Word32 binauralDelayNs; Word32 outSampleRate; Word8 useTDRend; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t i; -#endif /* Allocate TD binaural renderer for custom loudspeaker layouts (regardless of headrotation) or planar MC layouts with headrotation, CREND for the rest */ @@ -2558,7 +2442,6 @@ static ivas_error initMcBinauralRendering( ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( !reconfigureFlag || !useTDRend ) { FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) @@ -2569,16 +2452,11 @@ static ivas_error initMcBinauralRendering( } } } -#endif /* if we need to use TD renderer and CREND was open, close it */ IF( useTDRend ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper ); -#endif } test(); @@ -2638,7 +2516,6 @@ static ivas_error initMcBinauralRendering( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { /* Open TD renderer wrappers */ @@ -2673,7 +2550,6 @@ static ivas_error initMcBinauralRendering( } } -#endif test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && inputMc->hReverb == NULL ) @@ -2691,7 +2567,6 @@ static ivas_error initMcBinauralRendering( ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), @@ -2701,16 +2576,6 @@ static ivas_error initMcBinauralRendering( hMixconv, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), IVAS_ERR_OK ) ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate ) ), - IVAS_ERR_OK ) ) -#endif #endif { return error; @@ -2769,11 +2634,7 @@ static ivas_error initMcMasaRendering( ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2860,16 +2721,12 @@ static ivas_error setRendInputActiveMc( RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hrtfs ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 i; -#endif ivas_error error; rendering_context rendCtx; AUDIO_CONFIG outConfig; input_mc *inputMc; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pos_idx; -#endif inputMc = (input_mc *) input; rendCtx = inputMc->base.ctx; @@ -2902,14 +2759,10 @@ static ivas_error setRendInputActiveMc( inputMc->hReverb = NULL; inputMc->hMcMasa = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { initRotGainsWord32_fx( inputMc->rot_gains_prev_fx[pos_idx] ); } -#else - initRotGainsWord32_fx( inputMc->rot_gains_prev_fx ); -#endif inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); set32_fx( inputMc->lfeDelayBuffer_fx, 0, MAX_BIN_DELAY_SAMPLES ); inputMc->binauralDelaySmp = 0; @@ -2917,7 +2770,6 @@ static ivas_error setRendInputActiveMc( test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { if ( hrtfs->hHrtfTD ) @@ -2928,9 +2780,6 @@ static ivas_error setRendInputActiveMc( } IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) -#else - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES @@ -2963,9 +2812,7 @@ static void clearInputMc( input_mc *inputMc ) { rendering_context rendCtx; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 i; -#endif rendCtx = inputMc->base.ctx; freeMcLfeDelayBuffer_fx( &inputMc->lfeDelayBuffer_fx ); @@ -2978,11 +2825,7 @@ static void clearInputMc( efap_free_data_fx( &inputMc->efapInWrapper.hEfap ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputMc->crendWrapper, inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputMc->crendWrapper ); -#endif ivas_reverb_close( &inputMc->hReverb ); @@ -2991,7 +2834,6 @@ static void clearInputMc( ivas_td_binaural_close_fx( &inputMc->tdRendWrapper.hBinRendererTd ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i ) { IF( inputMc->splitTdRendWrappers[i].hBinRendererTd != NULL ) @@ -3000,7 +2842,6 @@ static void clearInputMc( inputMc->splitTdRendWrappers[i].hHrtfTD = NULL; } } -#endif ivas_mcmasa_ana_close( &( inputMc->hMcMasa ) ); @@ -3129,7 +2970,6 @@ static ivas_error updateSbaPanGains( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: SWITCH( outConfig ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: { @@ -3153,10 +2993,8 @@ static ivas_error updateSbaPanGains( } break; } -#endif case IVAS_AUDIO_CONFIG_BINAURAL: { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( hRendCfg->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) { if ( ( error = ivas_rend_openCldfbRend( &inputSba->cldfbRendWrapper, inConfig, outConfig, @@ -3166,20 +3004,11 @@ static ivas_error updateSbaPanGains( } } else -#endif { -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif #endif { return error; @@ -3193,18 +3022,10 @@ static ivas_error updateSbaPanGains( { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif -#else -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif #endif { return error; @@ -3237,11 +3058,7 @@ static ivas_error initSbaMasaRendering( { ivas_error error; -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputSba->crendWrapper, inputSba->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses ); -#else - ivas_rend_closeCrend( &inputSba->crendWrapper ); -#endif IF( NE_32( ( error = ivas_dirac_ana_open_fx( &inputSba->hDirAC, inSampleRate ) ), IVAS_ERR_OK ) ) { @@ -3264,9 +3081,7 @@ static ivas_error setRendInputActiveSba( rendering_context rendCtx; AUDIO_CONFIG outConfig; input_sba *inputSba; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; -#endif inputSba = (input_sba *) input; rendCtx = inputSba->base.ctx; @@ -3278,37 +3093,22 @@ static ivas_error setRendInputActiveSba( return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = allocateInputBaseBufferData_fx( &inputSba->bufferData_fx, MAX_CLDFB_BUFFER_LENGTH ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = allocateInputBaseBufferData_fx( &inputSba->bufferData_fx, MAX_BUFFER_LENGTH ) ), IVAS_ERR_OK ) ) - { - return error; - } -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT initRendInputBase_fx( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData_fx, MAX_CLDFB_BUFFER_LENGTH ); -#else - initRendInputBase_fx( &inputSba->base, inConfig, id, rendCtx, inputSba->bufferData_fx, MAX_BUFFER_LENGTH ); -#endif setZeroPanMatrix_fx( inputSba->hoaDecMtx_fx ); inputSba->crendWrapper = NULL; inputSba->hDirAC = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( pos_idx = 0; pos_idx < MAX_HEAD_ROT_POSES; pos_idx++ ) { initRotGains_fx( inputSba->rot_gains_prev_fx[pos_idx] ); } inputSba->cldfbRendWrapper.hHrtfFastConv = hrtfs->hHrtfFastConv; -#else - initRotGains_fx( inputSba->rot_gains_prev_fx ); -#endif test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_MASA1 ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_MASA2 ) ) @@ -3340,17 +3140,12 @@ static void clearInputSba( initRendInputBase_fx( &inputSba->base, IVAS_AUDIO_CONFIG_INVALID, 0, rendCtx, NULL, 0 ); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_rend_closeCrend( &inputSba->crendWrapper, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ); IF( inputSba->cldfbRendWrapper.hCldfbRend != NULL ) { ivas_rend_closeCldfbRend( &inputSba->cldfbRendWrapper ); } -#else - /* Free input's internal handles */ - ivas_rend_closeCrend( &inputSba->crendWrapper ); -#endif ivas_dirac_ana_close_fx( &( inputSba->hDirAC ) ); @@ -3470,9 +3265,7 @@ ivas_error IVAS_REND_Open( const Word16 num_subframes ) { Word16 i; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 j; -#endif IVAS_REND_HANDLE hIvasRend; ivas_error error; Word16 numOutChannels; @@ -3542,10 +3335,8 @@ ivas_error IVAS_REND_Open( } /* Initialize inputs */ -#ifdef SPLIT_REND_WITH_HEAD_ROT isar_init_split_rend_handles( &hIvasRend->splitRendWrapper ); hIvasRend->splitRendEncBuffer.data_fx = NULL; -#endif FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { @@ -3553,13 +3344,11 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsIsm[i].crendWrapper = NULL; hIvasRend->inputsIsm[i].hReverb = NULL; hIvasRend->inputsIsm[i].tdRendWrapper.hBinRendererTd = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) { hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hBinRendererTd = NULL; hIvasRend->inputsIsm[i].splitTdRendWrappers[j].hHrtfTD = NULL; } -#endif hIvasRend->inputsIsm[i].nonDiegeticPan = nonDiegeticPan; move16(); hIvasRend->inputsIsm[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; @@ -3583,13 +3372,11 @@ ivas_error IVAS_REND_Open( hIvasRend->inputsMc[i].nonDiegeticPanGain_fx = nonDiegeticPanGain; move32(); hIvasRend->inputsMc[i].hMcMasa = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT FOR( j = 0; j < MAX_HEAD_ROT_POSES - 1; ++j ) { hIvasRend->inputsMc[i].splitTdRendWrappers[j].hBinRendererTd = NULL; hIvasRend->inputsMc[i].splitTdRendWrappers[j].hHrtfTD = NULL; } -#endif } FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i ) @@ -3597,10 +3384,8 @@ ivas_error IVAS_REND_Open( initRendInputBase_fx( &hIvasRend->inputsSba[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 ); hIvasRend->inputsSba[i].crendWrapper = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT hIvasRend->inputsSba[i].cldfbRendWrapper.hCldfbRend = NULL; hIvasRend->inputsSba[i].cldfbRendWrapper.hHrtfFastConv = NULL; -#endif hIvasRend->inputsSba[i].bufferData_fx = NULL; hIvasRend->inputsSba[i].hDirAC = NULL; } @@ -4039,7 +3824,6 @@ static ivas_error findFreeInputSlot_fx( } -#ifdef SPLIT_REND_WITH_HEAD_ROT static Word16 getCldfbRendFlag( IVAS_REND_HANDLE hIvasRend, /* i : Renderer handle */ const IVAS_REND_AudioConfigType new_configType ) @@ -4168,7 +3952,6 @@ static ivas_error ivas_pre_rend_init( return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* @@ -4196,7 +3979,6 @@ ivas_error IVAS_REND_AddInput_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( ( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && hIvasRend->splitRendEncBuffer.data_fx == NULL && hIvasRend->hRendererConfig != NULL ) { Word16 cldfb_in_flag; @@ -4207,7 +3989,6 @@ ivas_error IVAS_REND_AddInput_fx( return error; } } -#endif SWITCH( getAudioConfigType( inConfig ) ) @@ -4317,11 +4098,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( test(); test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) -#else - IF( EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) @@ -4667,7 +4444,6 @@ ivas_error IVAS_REND_GetDelay_fx( { IF( NE_32( hIvasRend->inputsSba[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL ) { if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) @@ -4687,7 +4463,6 @@ ivas_error IVAS_REND_GetDelay_fx( max_latency_ns = max( max_latency_ns, latency_ns ); } else -#endif { IF( hIvasRend->inputsSba[i].crendWrapper != NULL ) { @@ -4738,9 +4513,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( ivas_error error; input_base *inputBase; Word16 numInputChannels; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 cldfb2tdShift; -#endif /* Validate function arguments */ test(); @@ -4750,14 +4523,10 @@ ivas_error IVAS_REND_FeedInputAudio_fx( } test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdShift = ( inputAudio.config.is_cldfb ) ? 1 : 0; IF( inputAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) -#else - IF( inputAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, inputAudio.config.numSamplesPerChannel ) ) -#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); } @@ -4770,15 +4539,10 @@ ivas_error IVAS_REND_FeedInputAudio_fx( test(); move32(); // move added for typecasting -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && NE_32( L_shr( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdShift ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) -#else - IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && - NE_32( L_mult0( inputAudio.config.numSamplesPerChannel, 1000 ), (Word32) W_mult0_32_32( L_mult0( BINAURAL_RENDERING_FRAME_SIZE_MS, hIvasRend->num_subframes ), hIvasRend->sampleRateOut ) ) ) -#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -4809,11 +4573,7 @@ ivas_error IVAS_REND_FeedInputAudio_fx( MVR2R_WORD32( inputAudio.data_fx, inputBase->inputBuffer.data_fx, inputAudio.config.numSamplesPerChannel * inputAudio.config.numChannels ); -#ifdef SPLIT_REND_WITH_HEAD_ROT inputBase->numNewSamplesPerChannel = shr( inputAudio.config.numSamplesPerChannel, cldfb2tdShift ); -#else - inputBase->numNewSamplesPerChannel = inputAudio.config.numSamplesPerChannel; -#endif move32(); return IVAS_ERR_OK; @@ -5009,7 +4769,6 @@ Word16 IVAS_REND_GetRenderConfig( Copy32( hRCin->roomAcoustics.pAcoustic_rt60_fx, hRCout->roomAcoustics.pAcoustic_rt60_fx, CLDFB_NO_CHANNELS_MAX ); Copy32( hRCin->roomAcoustics.pAcoustic_dsr_fx, hRCout->roomAcoustics.pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX ); -#ifdef SPLIT_REND_WITH_HEAD_ROT hRCout->split_rend_config.splitRendBitRate = SPLIT_REND_768k; hRCout->split_rend_config.dof = 3; hRCout->split_rend_config.hq_mode = 0; @@ -5020,7 +4779,6 @@ Word16 IVAS_REND_GetRenderConfig( hRCout->split_rend_config.poseCorrectionMode = ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB; hRCout->split_rend_config.rendererSelection = hRCin->split_rend_config.rendererSelection; hRCout->split_rend_config.lc3plus_highres = 0; -#endif hRCout->roomAcoustics.use_er = hRCin->roomAcoustics.use_er; @@ -5044,9 +4802,7 @@ Word16 IVAS_REND_FeedRenderConfig( ) { RENDER_CONFIG_HANDLE hRenderConfig; -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_error error; -#endif test(); IF( hIvasRend == NULL || hIvasRend->hRendererConfig == NULL ) @@ -5082,7 +4838,6 @@ Word16 IVAS_REND_FeedRenderConfig( Copy32( renderConfig.roomAcoustics.AbsCoeff_fx, hRenderConfig->roomAcoustics.AbsCoeff_fx, IVAS_ROOM_ABS_COEFF ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT hRenderConfig->split_rend_config = renderConfig.split_rend_config; /* Overwrite any pose correction settings if 0 DOF (no pose correction) was selected */ IF( EQ_16( hRenderConfig->split_rend_config.dof, 0 ) ) @@ -5110,7 +4865,6 @@ Word16 IVAS_REND_FeedRenderConfig( return error; } } -#endif return IVAS_ERR_OK; } @@ -5124,9 +4878,7 @@ ivas_error IVAS_REND_SetHeadRotation( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ -#ifdef SPLIT_REND_WITH_HEAD_ROT const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ -#endif const Word16 sf_idx /* i : subframe index */ ) { @@ -5165,20 +4917,12 @@ ivas_error IVAS_REND_SetHeadRotation( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* check for Euler angle signaling */ IF( EQ_32( headRot.w_fx, L_negate( 12582912 ) ) && EQ_16( headRot.q_fact, Q22 ) ) { Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); modify_Quat_q_fx( &rotQuat, &rotQuat, Q29 ); } -#else - /* check for Euler angle signaling */ - IF( EQ_32( headRot.w_fx, -1610612736 /* -3.0f in Q29 */ ) ) - { - Euler2Quat_fx( deg2rad_fx( headRot.x_fx ), deg2rad_fx( headRot.y_fx ), deg2rad_fx( headRot.z_fx ), &rotQuat ); - } -#endif ELSE { rotQuat = headRot; @@ -5225,9 +4969,7 @@ ivas_error IVAS_REND_SetHeadRotation( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT hIvasRend->headRotData.sr_pose_pred_axis = rot_axis; -#endif hIvasRend->headRotData.Pos[sf_idx] = Pos; @@ -5278,7 +5020,6 @@ ivas_error IVAS_REND_DisableHeadRotation( return IVAS_ERR_OK; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_SetSplitRendBFI() * @@ -5294,7 +5035,6 @@ IVAS_REND_SetSplitRendBFI( return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* @@ -6000,7 +5740,6 @@ static Word16 getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const Word32 sampleRate ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 cldfb2tdShift; cldfb2tdShift = buffer->config.is_cldfb ? 1 : 0; @@ -6009,11 +5748,6 @@ static Word16 getNumSubframesInBuffer( temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); temp = shr( temp, sub( 15, scale ) ); /* Q0 */ temp = shr( temp, cldfb2tdShift ); -#else - Word16 scale, temp = extract_l( Mpy_32_32( sampleRate, 10737418 /* 1 / FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); - temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); - temp = shr( temp, sub( 15, scale ) ); /* Q0 */ -#endif return temp; } @@ -6190,11 +5924,7 @@ static ivas_error renderIsmToBinauralRoom( } // Crend_process porting CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = ismInput->crendWrapper->hCrend[0]; -#else - hCrend = ismInput->crendWrapper->hCrend; -#endif IF( hCrend->reflections != NULL ) { test(); @@ -6210,13 +5940,8 @@ static ivas_error renderIsmToBinauralRoom( move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT /* render 7_1_4 with BRIRs */ IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - /* render 7_1_4 with BRIRs */ - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( ismInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, ismInput->base.inputBuffer.config.numSamplesPerChannel, *ismInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -6504,7 +6229,6 @@ static ivas_error renderIsmToSba( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderIsmToSplitBinaural( input_ism *ismInput, const IVAS_REND_AudioBuffer outAudio ) @@ -6627,7 +6351,6 @@ static ivas_error renderIsmToSplitBinaural( /* Encoding to split rendering bitstream done at a higher level */ return IVAS_ERR_OK; } -#endif static void renderIsmToMasa( @@ -6741,12 +6464,10 @@ static ivas_error renderInputIsm( case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR: error = renderIsmToBinauralRoom( ismInput, outAudio, &exp ); BREAK; -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: error = renderIsmToSplitBinaural( ismInput, outAudio ); break; -#endif case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB: error = renderIsmToBinauralReverb( ismInput, outAudio ); BREAK; @@ -6817,17 +6538,13 @@ static ivas_error renderActiveInputsIsm( static ivas_error renderLfeToBinaural_fx( const input_mc *mcInput, -#ifdef SPLIT_REND_WITH_HEAD_ROT const AUDIO_CONFIG outConfig, -#endif IVAS_REND_AudioBuffer outAudio, Word16 in_q, Word16 out_q ) { Word16 lfe_idx; -#ifdef SPLIT_REND_WITH_HEAD_ROT Word16 pose_idx, num_poses; -#endif Word32 gain_fx; Word16 ear_idx, i, r_shift; Word32 tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL]; @@ -6835,11 +6552,7 @@ static ivas_error renderLfeToBinaural_fx( const Word32 *lfeInput; Word32 *writePtr; -#ifdef SPLIT_REND_WITH_HEAD_ROT assert( ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && "Must be binaural output" ); -#else - assert( ( outAudio.config.numChannels == 2 ) && "Must be binaural output" ); -#endif push_wmops( "renderLfeToBinaural" ); gain_fx = GAIN_LFE_WORD32; /* 1.88364911f in Q30 */ @@ -6891,7 +6604,6 @@ static ivas_error renderLfeToBinaural_fx( } } -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Copy LFE to left and right binaural channels for all poses */ IF( mcInput->base.ctx.pSplitRendWrapper != NULL ) { @@ -6912,19 +6624,6 @@ static ivas_error renderLfeToBinaural_fx( v_add_fixed( writePtr, tmpLfeBuffer, writePtr, frame_size, 0 ); /* Q(out_q) */ } } -#else /* SPLIT_REND_WITH_HEAD_ROT */ - /* Copy LFE to left and right ears */ - FOR( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx ) - { - 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 */ - } -#endif pop_wmops(); @@ -7001,11 +6700,7 @@ static ivas_error renderMcToBinaural( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, imult1616( tmpRotBuffer.config.numSamplesPerChannel, tmpRotBuffer.config.numChannels ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7022,18 +6717,10 @@ static ivas_error renderMcToBinaural( } // Porting Crend_process function CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = mcInput->crendWrapper->hCrend[0]; -#else - hCrend = mcInput->crendWrapper->hCrend; -#endif /* call CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer_fx, p_tmpRendBuffer_fx, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7046,19 +6733,11 @@ static ivas_error renderMcToBinaural( accumulate2dArrayToBuffer_fx( tmpRendBuffer_fx, &outAudio ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) - - { - return error; - } -#endif *outAudio.pq_fact = exp; move16(); pop_wmops(); @@ -7139,17 +6818,10 @@ static ivas_error renderMcToBinauralRoom( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, - mcInput->rot_gains_prev_fx, - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), - IVAS_ERR_OK ) ) -#endif { return error; } @@ -7165,18 +6837,10 @@ static ivas_error renderMcToBinauralRoom( } // Porting Crend_process function CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = mcInput->crendWrapper->hCrend[0]; -#else - hCrend = mcInput->crendWrapper->hCrend; -#endif /* call CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, mcInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpRendBuffer, p_tmpRendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7189,11 +6853,7 @@ static ivas_error renderMcToBinauralRoom( accumulate2dArrayToBuffer_fx( tmpRendBuffer, &outAudio ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7251,17 +6911,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( tmpRotBuffer.data_fx = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( Word32 ) ); set32_fx( tmpRotBuffer.data_fx, 0, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, mcInput->rot_gains_prev_fx[0], mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = rotateFrameMc_fx( mcInput->base.inputBuffer, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pHeadRotData, mcInput->base.ctx.pCombinedOrientationData, - mcInput->rot_gains_prev_fx, - mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ), - IVAS_ERR_OK ) ) -#endif { return error; } @@ -7296,18 +6949,10 @@ static ivas_error renderMcCustomLsToBinauralRoom( copyBufferTo2dArray_fx( tmpMcBuffer, tmpCrendBuffer ); CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = mcInput->crendWrapper->hCrend[0]; -#else - hCrend = mcInput->crendWrapper->hCrend; -#endif /* call CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( mcInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, mcInput->base.inputBuffer.config.numSamplesPerChannel, *mcInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7319,11 +6964,7 @@ static ivas_error renderMcCustomLsToBinauralRoom( accumulate2dArrayToBuffer_fx( tmpCrendBuffer, &outAudio ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outConfig, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = renderLfeToBinaural_fx( mcInput, outAudio, *outAudio.pq_fact, exp ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -7388,7 +7029,6 @@ static void renderMcToMasa( return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderMcToSplitBinaural( input_mc *mcInput, const AUDIO_CONFIG outConfig, @@ -7528,11 +7168,7 @@ static ivas_error renderMcToSplitBinaural( } ELSE { -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = mcInput->crendWrapper->hCrend[0]; -#else - hCrend = mcInput->crendWrapper->hCrend; -#endif /* crend processing overview: * 1. rotateFrameMc: inputBuffer to tmpRotBuffer * 2. crend_process: tmpRotBuffer to tmpRendBuffer @@ -7601,7 +7237,6 @@ static ivas_error renderMcToSplitBinaural( pop_wmops(); return IVAS_ERR_OK; } -#endif static ivas_error renderInputMc( @@ -7653,12 +7288,10 @@ static ivas_error renderInputMc( error = renderMcToBinauralRoom( mcInput, outConfig, outAudio ); } BREAK; -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: error = renderMcToSplitBinaural( mcInput, outConfig, outAudio ); break; -#endif default: return IVAS_ERR_INVALID_OUTPUT_FORMAT; } @@ -7736,7 +7369,6 @@ static void renderSbaToSba( } -#ifdef SPLIT_REND_WITH_HEAD_ROT static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, @@ -7921,7 +7553,6 @@ static ivas_error renderSbaToSplitBinaural( pop_wmops(); return error; } -#endif static ivas_error renderSbaToBinaural( input_sba *sbaInput, @@ -7939,7 +7570,6 @@ static ivas_error renderSbaToBinaural( push_wmops( "renderSbaToBinaural" ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( sbaInput->base.ctx.hhRendererConfig[0]->split_rend_config.rendererSelection, ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV ) ) { Word32 Cldfb_RealBuffer_Binaural[BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; @@ -7954,7 +7584,6 @@ static ivas_error renderSbaToBinaural( accumulateCLDFBArrayToBuffer_fx( Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, &outAudio ); } ELSE -#endif { FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) @@ -7989,21 +7618,12 @@ static ivas_error renderSbaToBinaural( Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), IVAS_ERR_OK ) ) { return error; } -#else - IF( NE_16( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, - sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx, tmpRotBuffer ) ), - IVAS_ERR_OK ) ) - { - return error; - } -#endif copyBufferTo2dArray_fx( tmpRotBuffer, output_buffer_fx ); free( tmpRotBuffer.data_fx ); @@ -8014,18 +7634,10 @@ static ivas_error renderSbaToBinaural( } // Porting Crend_process function CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = sbaInput->crendWrapper->hCrend[0]; -#else - hCrend = sbaInput->crendWrapper->hCrend; -#endif /* call CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, sbaInput->base.inConfig, outConfig, NULL, NULL, NULL, NULL, NULL, output_fx, output_fx, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -8062,11 +7674,7 @@ static ivas_error renderSbaToBinauralRoom( push_wmops( "renderSbaToBinauralRoom" ); Word16 nchan_out; CREND_HANDLE hCrend; -#ifdef SPLIT_REND_WITH_HEAD_ROT hCrend = sbaInput->crendWrapper->hCrend[0]; -#else - hCrend = sbaInput->crendWrapper->hCrend; -#endif IF( NE_32( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ), IVAS_ERR_OK ) ) { @@ -8103,19 +7711,11 @@ static ivas_error renderSbaToBinauralRoom( /* copy input for in-place rotation */ Copy32( sbaInput->base.inputBuffer.data_fx, tmpRotBuffer.data_fx, i_mult( tmpRotBuffer.config.numChannels, tmpRotBuffer.config.numSamplesPerChannel ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, sbaInput->base.ctx.pCombinedOrientationData, sbaInput->rot_gains_prev_fx[0], tmpRotBuffer ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = rotateFrameSba_fx( sbaInput->base.inputBuffer, sbaInput->base.inConfig, sbaInput->base.ctx.pHeadRotData, - sbaInput->base.ctx.pCombinedOrientationData, - sbaInput->rot_gains_prev_fx, - tmpRotBuffer ) ), - IVAS_ERR_OK ) ) -#endif { return error; } @@ -8150,11 +7750,7 @@ static ivas_error renderSbaToBinauralRoom( // Porting Crend_process function /* call CREND */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate, 0 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_crendProcessSubframe( sbaInput->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, NULL, NULL, NULL, NULL, NULL, p_tmpCrendBuffer, p_tmpCrendBuffer, sbaInput->base.inputBuffer.config.numSamplesPerChannel, *sbaInput->base.ctx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -8197,20 +7793,14 @@ static ivas_error renderInputSba( { ivas_error error; IVAS_REND_AudioBuffer inAudio; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdShift; -#endif error = IVAS_ERR_OK; move32(); inAudio = sbaInput->base.inputBuffer; -#ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; IF( NE_32( L_shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( NE_32( sbaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) -#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -8237,12 +7827,10 @@ static ivas_error renderInputSba( case IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL: SWITCH( outConfig ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: error = renderSbaToSplitBinaural( sbaInput, outConfig, outAudio ); break; -#endif case IVAS_AUDIO_CONFIG_BINAURAL: error = renderSbaToBinaural( sbaInput, outConfig, outAudio ); BREAK; @@ -8576,11 +8164,9 @@ static ivas_error renderInputMasa( Word16 maxBin; Word32 *tmpBuffer_fx[MAX_OUTPUT_CHANNELS]; Word32 tmpBuffer_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k]; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdShift; Word32 Cldfb_RealBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; -#endif IF( !masaInput->metadataHasBeenFed ) { @@ -8589,13 +8175,9 @@ static ivas_error renderInputMasa( inAudio = masaInput->base.inputBuffer; -#ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; IF( ( NE_32( L_shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( NE_32( masaInput->base.numNewSamplesPerChannel, outAudio.config.numSamplesPerChannel ) ) -#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Mismatch between the number of input samples vs number of requested output samples - currently not allowed" ); } @@ -8632,7 +8214,6 @@ static ivas_error renderInputMasa( num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { /* split rendering. use the combined of the first subframe in all subframes */ @@ -8670,7 +8251,6 @@ static ivas_error renderInputMasa( ELSE { /* non-split path */ -#endif SWITCH( masaInput->hMasaExtRend->renderer_type ) { case RENDERER_DIRAC: @@ -8714,11 +8294,7 @@ static ivas_error renderInputMasa( scale_sig32( outAudio.data_fx, i_mult( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ), sub( Q11, *outAudio.pq_fact ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes, NULL, NULL, NULL ); -#else - ivas_masa_ext_rend_parambin_render_fx( masaInput->hMasaExtRend, *masaInput->base.ctx.pCombinedOrientationData, tmpBuffer_fx, num_subframes ); -#endif *outAudio.pq_fact = Q11; move16(); BREAK; @@ -8728,9 +8304,7 @@ static ivas_error renderInputMasa( return ( IVAS_ERROR( IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, "Wrong output config for MASA input in external renderer\n" ) ); } accumulate2dArrayToBuffer_fx( tmpBuffer_buff_fx, &outAudio ); -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif } return IVAS_ERR_OK; @@ -8961,20 +8535,14 @@ ivas_error IVAS_REND_SetIsmMetadataDelay( static ivas_error getSamplesInternal( IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ -#ifdef SPLIT_REND_WITH_HEAD_ROT IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */, IVAS_REND_BitstreamBuffer *hBits /*i/o: buffer for input/output bitstream. Needed in split rendering mode*/ -#else - IVAS_REND_AudioBuffer outAudio /* i/o: buffer for output audio */ -#endif ) { ivas_error error; Word16 numOutChannels; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t cldfb2tdSampleShift; IVAS_REND_AudioBuffer outAudioOrig; -#endif /* Validate function arguments */ test(); IF( hIvasRend == NULL || outAudio.data_fx == NULL ) @@ -8983,14 +8551,10 @@ static ivas_error getSamplesInternal( } test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT cldfb2tdSampleShift = ( outAudio.config.is_cldfb ) ? 1 : 0; IF( outAudio.config.numSamplesPerChannel <= 0 || ( MAX_BUFFER_LENGTH_PER_CHANNEL < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 0 ) || ( ( shl( MAX_BUFFER_LENGTH_PER_CHANNEL, cldfb2tdSampleShift ) ) < outAudio.config.numSamplesPerChannel && outAudio.config.is_cldfb == 1 ) ) -#else - IF( outAudio.config.numSamplesPerChannel <= 0 || LT_16( MAX_BUFFER_LENGTH_PER_CHANNEL, outAudio.config.numSamplesPerChannel ) ) -#endif { return IVAS_ERR_INVALID_BUFFER_SIZE; } @@ -9002,16 +8566,11 @@ static ivas_error getSamplesInternal( } test(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) && NE_32( L_shr( L_mult0( outAudio.config.numSamplesPerChannel, 1000 ), cldfb2tdSampleShift ), imult3216( hIvasRend->sampleRateOut, i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ) ) -#else - IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && - NE_32( L_mult0( outAudio.config.numSamplesPerChannel, 1000 ), imult3216( hIvasRend->sampleRateOut, i_mult( hIvasRend->num_subframes, BINAURAL_RENDERING_FRAME_SIZE_MS ) ) ) ) -#endif { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Binaural rendering requires specific frame size" ); } @@ -9090,11 +8649,7 @@ static ivas_error getSamplesInternal( return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( NE_16( numOutChannels, outAudio.config.numChannels ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) -#else - IF( NE_16( numOutChannels, outAudio.config.numChannels ) ) -#endif { return IVAS_ERR_WRONG_NUM_CHANNELS; } @@ -9102,7 +8657,6 @@ static ivas_error getSamplesInternal( /* Clear original output buffer */ set32_fx( outAudio.data_fx, 0, imult1616( outAudio.config.numChannels, outAudio.config.numSamplesPerChannel ) ); -#ifdef SPLIT_REND_WITH_HEAD_ROT outAudioOrig = outAudio; /* Use internal buffer if outputting split rendering bitstream */ IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || @@ -9121,7 +8675,6 @@ static ivas_error getSamplesInternal( /* Clear output buffer for split rendering bitstream */ set32_fx( outAudio.data_fx, 0, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel ); } -#endif IF( NE_32( ( error = renderActiveInputsIsm( hIvasRend, outAudio ) ), IVAS_ERR_OK ) ) { @@ -9143,13 +8696,7 @@ static ivas_error getSamplesInternal( test(); test(); -#ifndef SPLIT_REND_WITH_HEAD_ROT - Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); - limitRendererOutput_fx( hIvasRend->hLimiter, outAudio.data_fx, outAudio.config.numSamplesPerChannel, limiter_thresold, *outAudio.pq_fact ); -#endif - -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { ISAR_SPLIT_REND_BITS_DATA bits; @@ -9276,15 +8823,12 @@ static ivas_error getSamplesInternal( accumulate2dArrayToBuffer_fx( tmpBinaural_buff, &outAudio ); } } -#endif -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( outAudio.config.is_cldfb == 0 ) { Word32 limiter_thresold = L_lshl( IVAS_LIMITER_THRESHOLD, *outAudio.pq_fact ); 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 ); @@ -9304,14 +8848,9 @@ ivas_error IVAS_REND_GetSamples( ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT return getSamplesInternal( hIvasRend, outAudio, NULL ); -#else - return getSamplesInternal( hIvasRend, outAudio ); -#endif } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_GetSplitBinauralBitstream() * @@ -9364,7 +8903,6 @@ ivas_error IVAS_REND_GetSplitRendBitstreamHeader( return IVAS_ERR_OK; } -#endif /*-------------------------------------------------------------------* * IVAS_REND_Close() @@ -9416,10 +8954,8 @@ void IVAS_REND_Close( ivas_limiter_close_fx( &hIvasRend->hLimiter ); -#ifdef SPLIT_REND_WITH_HEAD_ROT /* Split binaural rendering */ ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer ); -#endif closeHeadRotation( hIvasRend ); @@ -9443,7 +8979,6 @@ void IVAS_REND_Close( return; } -#ifdef SPLIT_REND_WITH_HEAD_ROT /*-------------------------------------------------------------------* * IVAS_REND_openCldfb() * @@ -9578,7 +9113,6 @@ void IVAS_REND_cldfbSynthesis_wrapper( return; } -#endif /*---------------------------------------------------------------------* @@ -10144,9 +9678,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( Word16 tmpFloat_fx; ivas_error error; Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; -#ifdef SPLIT_REND_WITH_HEAD_ROT int16_t pos_idx; -#endif Word16 tmp; Word16 tmp_e; @@ -10168,13 +9700,9 @@ static ivas_error ivas_masa_ext_rend_parambin_init( renderer_type = inputMasa->hMasaExtRend->renderer_type; move32(); -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( pos_idx = 0; pos_idx < inputMasa->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; pos_idx++ ) { hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin[pos_idx]; -#else - hDiracDecBin = inputMasa->hMasaExtRend->hDiracDecBin; -#endif /* Init assumes that no reconfiguration is required in external renderer. Instead, free and rebuild whole rendering. */ IF( ( hDiracDecBin = (DIRAC_DEC_BIN_HANDLE) malloc( sizeof( DIRAC_DEC_BIN_DATA ) ) ) == NULL ) @@ -10272,11 +9800,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ -#else - IF( hDiracDecBin->hReverb == NULL ) -#endif { #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF @@ -10307,10 +9831,8 @@ static ivas_error ivas_masa_ext_rend_parambin_init( assert( false ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT IF( pos_idx == 0 ) /* open decorrelator only for the main direction */ { -#endif /* Always open frequency domain decorrelator */ ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, nBins ); @@ -10327,9 +9849,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( { return error; } -#ifdef SPLIT_REND_WITH_HEAD_ROT } -#endif /* External renderer uses constant regularization factor */ hDiracDecBin->reqularizationFactor_fx = 6554; /* 0.4f in Q14 */ move16(); @@ -10338,12 +9858,8 @@ static ivas_error ivas_masa_ext_rend_parambin_init( hDiracDecBin->phHrtfParambin = phHrtfParambin; #endif -#ifdef SPLIT_REND_WITH_HEAD_ROT inputMasa->hMasaExtRend->hDiracDecBin[pos_idx] = hDiracDecBin; } -#else - inputMasa->hMasaExtRend->hDiracDecBin = hDiracDecBin; -#endif return error; } @@ -10375,14 +9891,10 @@ static ivas_error initMasaExtRenderer( move32(); hMasaExtRend->hDirACRend = NULL; hMasaExtRend->hSpatParamRendCom = NULL; -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) { hMasaExtRend->hDiracDecBin[i] = NULL; } -#else - hMasaExtRend->hDiracDecBin = NULL; -#endif hMasaExtRend->hReverb = NULL; hMasaExtRend->hHrtfParambin = &hrtfs->hHrtfParambin; hMasaExtRend->hVBAPdata = NULL; @@ -10433,10 +9945,8 @@ static ivas_error initMasaExtRenderer( BREAK; case IVAS_AUDIO_CONFIG_BINAURAL: -#ifdef SPLIT_REND_WITH_HEAD_ROT case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM: case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED: -#endif hMasaExtRend->renderer_type = RENDERER_BINAURAL_PARAMETRIC; move32(); BREAK; @@ -10557,7 +10067,6 @@ static void freeMasaExtRenderer( ivas_spat_hSpatParamRendCom_close_fx( &hMasaExtRend->hSpatParamRendCom ); } -#ifdef SPLIT_REND_WITH_HEAD_ROT for ( i = 0; i < MAX_HEAD_ROT_POSES; i++ ) { if ( hMasaExtRend->hDiracDecBin[i] != NULL ) @@ -10566,12 +10075,6 @@ static void freeMasaExtRenderer( } } -#else - IF( hMasaExtRend->hDiracDecBin != NULL ) - { - ivas_dirac_dec_close_binaural_data( &hMasaExtRend->hDiracDecBin ); - } -#endif IF( hMasaExtRend->hReverb != NULL ) { diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 3c897cc43..84de1e7b7 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -1073,11 +1073,7 @@ static void strip_spaces( while ( pStr[read_idx] ) { -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( !isspace( (int32_t) pStr[read_idx] ) && !iscntrl( (int32_t) pStr[read_idx] ) ) -#else - if ( !isspace( pStr[read_idx] ) && !iscntrl( pStr[read_idx] ) ) -#endif { pStr[write_idx++] = pStr[read_idx]; } @@ -1841,10 +1837,8 @@ ivas_error RenderConfigReader_read( uint32_t fgHasMethod, fgHasNBands, fgHasFreqs, fgHasDefaultGrid, fgHasStartFreq, fgHasFreqHop; uint32_t aeHasFgIdx, aeHasPredelay, aeHasRt60, aeHasDsr; uint32_t aeHasERsize, aeHasERabs; -#ifdef SPLIT_REND_WITH_HEAD_ROT bool dofProvided = false; bool poseCorrProvided = false; -#endif uint32_t nDP; uint32_t accDPIdx; @@ -2369,7 +2363,6 @@ ivas_error RenderConfigReader_read( free( pValue ); acIdx++; } -#ifdef SPLIT_REND_WITH_HEAD_ROT else if ( strcmp( chapter, "SPLITREND" ) == 0 && strlen( pParams ) != 0 ) { params_idx = 0; @@ -2502,7 +2495,6 @@ ivas_error RenderConfigReader_read( } free( pValue ); } -#endif else if ( strcmp( chapter, "DIRECTIVITYSETTING" ) == 0 && strlen( pParams ) != 0 ) { params_idx = 0; diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index a3f9544c8..3cd2e798b 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -121,7 +121,6 @@ ivas_error HeadRotationFileReading( ( headRotReader->frameCounter )++; -#ifdef SPLIT_REND_WITH_HEAD_ROT if ( w == -3.0f ) { pQuaternion->w_fx = floatToFixed_32( w, Q22 ); @@ -138,13 +137,6 @@ ivas_error HeadRotationFileReading( pQuaternion->z_fx = floatToFixed_32( z, Q31 ); pQuaternion->q_fact = Q31; } -#else - pQuaternion->w_fx = floatToFixed_32( w, Q31 ); - pQuaternion->x_fx = floatToFixed_32( x, Q31 ); - pQuaternion->y_fx = floatToFixed_32( y, Q31 ); - pQuaternion->z_fx = floatToFixed_32( z, Q31 ); - pQuaternion->q_fact = Q31; -#endif if ( pPos != NULL ) { diff --git a/lib_util/split_rend_bfi_file_reader.c b/lib_util/split_rend_bfi_file_reader.c index 4c5770f45..6b7e1acd3 100644 --- a/lib_util/split_rend_bfi_file_reader.c +++ b/lib_util/split_rend_bfi_file_reader.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "split_rend_bfi_file_reader.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "prot_fx.h" @@ -159,4 +158,3 @@ const char *SplitRendBFIFileReader_getFilePath( return SplitRendBFIReader->file_path; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_rend_bfi_file_reader.h b/lib_util/split_rend_bfi_file_reader.h index 679c424a1..0956b6b3d 100644 --- a/lib_util/split_rend_bfi_file_reader.h +++ b/lib_util/split_rend_bfi_file_reader.h @@ -34,7 +34,6 @@ #define IVAS_SR_BFI_FILE_READER_H #include "common_api_types.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT typedef struct SplitRendBFIFileReader SplitRendBFIFileReader; @@ -56,5 +55,4 @@ const char *SplitRendBFIFileReader_getFilePath( ); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* IVAS_SR_BFI_FILE_READER_H */ diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index c112863db..ff0aa2e1a 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "split_render_file_read_write.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT #include #include "prot_fx.h" @@ -420,4 +419,3 @@ ivas_error split_rend_read_pre_rend_delay_ns( return IVAS_ERR_OK; } -#endif /* SPLIT_REND_WITH_HEAD_ROT */ diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index 125daf94e..b6f32a317 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -34,7 +34,6 @@ #define SPLIT_RENDER_FILE_READ_WRITE_H #include "common_api_types.h" -#ifdef SPLIT_REND_WITH_HEAD_ROT typedef struct SplitFileReadWrite SplitFileReadWrite; @@ -91,5 +90,4 @@ ivas_error split_rend_read_pre_rend_delay_ns( SplitFileReadWrite *hSplitRendFileReadWrite, uint32_t *delay_ns ); -#endif /* SPLIT_REND_WITH_HEAD_ROT */ #endif /* SPLIT_RENDER_FILE_READ_WRITE_H */ -- GitLab From 3dc61d51fd0c2478ae69a7bd82258be9693c7bf1 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 13 Jun 2025 11:32:06 +0200 Subject: [PATCH 280/692] clang-format --- apps/decoder.c | 49 ++++++---------- apps/isar_post_rend.c | 22 +++---- apps/renderer.c | 37 ++++-------- lib_com/common_api_types.h | 22 +++---- lib_com/ivas_rotation_com.c | 1 - lib_com/options.h | 3 - lib_dec/ivas_binRenderer_internal_fx.c | 17 +++--- lib_dec/ivas_stat_dec.h | 1 - lib_dec/lib_dec_fx.c | 13 ++--- lib_isar/isar_lc3plus_dec.c | 3 - lib_isar/isar_lc3plus_enc.c | 4 +- lib_isar/isar_lc3plus_enc.h | 8 +-- lib_isar/isar_lc3plus_payload.c | 1 - lib_isar/isar_lcld_decoder.c | 1 - lib_isar/isar_prot.h | 17 +++--- lib_isar/isar_splitRendererPost.c | 1 - lib_isar/isar_splitRendererPre.c | 6 +- lib_isar/isar_splitRenderer_utils.c | 53 ++++++++--------- lib_isar/lib_isar_post_rend.c | 17 ++---- lib_isar/lib_isar_pre_rend.c | 11 +--- lib_rend/ivas_crend_fx.c | 19 ++---- .../ivas_dirac_dec_binaural_functions_fx.c | 22 +++---- lib_rend/ivas_output_init_fx.c | 6 +- lib_rend/ivas_reflections_fx.c | 4 +- lib_rend/ivas_rotation_fx.c | 10 ++-- lib_rend/lib_rend_fx.c | 58 +++++++++---------- lib_util/split_render_file_read_write.c | 12 ++-- lib_util/split_render_file_read_write.h | 12 ++-- 28 files changed, 172 insertions(+), 258 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b8d4c6596..76bd23bbf 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -266,9 +266,7 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB - && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM - ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -368,10 +366,8 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB - && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && - arg.Opt_non_diegetic_pan == 0 - ) + if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM && + arg.Opt_non_diegetic_pan == 0 ) { fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -1547,11 +1543,11 @@ static void usage_dec( void ) *---------------------------------------------------------------------*/ static ivas_error initOnFirstGoodFrame( - IVAS_DEC_HANDLE hIvasDec, /* i/o: */ - const DecArguments arg, /* i : */ - const int16_t numInitialBadFrames, /* i : */ - int16_t *numOutSamples, /* i/o: */ - int16_t *vec_pos_len, /* i/o: */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: */ + const DecArguments arg, /* i : */ + const int16_t numInitialBadFrames, /* i : */ + int16_t *numOutSamples, /* i/o: */ + int16_t *vec_pos_len, /* i/o: */ int16_t *pFullDelayNumSamples, /* o : */ int16_t *pRemainingDelayNumSamples, /* o : */ int32_t *delayTimeScale, /* o : */ @@ -1560,9 +1556,8 @@ static ivas_error initOnFirstGoodFrame( MasaFileWriter **ppMasaWriter, /* o : */ IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o : */ int16_t *pNumOutChannels, /* o : */ - uint16_t *pNumObj, /* o : */ - SplitFileReadWrite **splitRendWriter -) + uint16_t *pNumObj, /* o : */ + SplitFileReadWrite **splitRendWriter ) { ivas_error error = IVAS_ERR_UNKNOWN; @@ -1619,10 +1614,8 @@ static ivas_error initOnFirstGoodFrame( &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, - &splitRendCodecFrameSizeMs - , - &lc3plusHighRes - ) ) != IVAS_ERR_OK ) + &splitRendCodecFrameSizeMs, + &lc3plusHighRes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); return error; @@ -1636,12 +1629,10 @@ static ivas_error initOnFirstGoodFrame( delayTimeScale_temp, splitRendCodec, poseCorrection, - splitRendCodecFrameSizeMs - , + splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, - lc3plusHighRes - ) ) != IVAS_ERR_OK ) + lc3plusHighRes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -1661,12 +1652,10 @@ static ivas_error initOnFirstGoodFrame( delayTimeScale_temp, splitRendCodec, poseCorrection, - splitRendCodecFrameSizeMs - , + splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, - lc3plusHighRes - ) ) != IVAS_ERR_OK ) + lc3plusHighRes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename ); return error; @@ -2676,10 +2665,8 @@ static ivas_error decodeVoIP( for ( i = 0; i < num_subframes; i++ ) { - if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i - , - DEFAULT_AXIS - ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, + DEFAULT_AXIS ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index e7fd6a05a..4b478f7c2 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -758,12 +758,10 @@ int main( args.inMetadataFilePaths[0], &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms - , + &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms, &inFileSampleRate, - &bitsBuffer.config.lc3plusHighRes - ); + &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); @@ -784,12 +782,10 @@ int main( args.inputFilePath, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms - , + &bitsBuffer.config.codec_frame_size_ms, &bitsBuffer.config.isar_frame_size_ms, &inFileSampleRate, - &bitsBuffer.config.lc3plusHighRes - ); + &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.inputFilePath ); @@ -802,8 +798,7 @@ int main( { error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate ); } - else - if ( hSplitRendFileReadWrite == NULL ) + else if ( hSplitRendFileReadWrite == NULL ) { inFileSampleRate = args.sampleRate; } @@ -865,11 +860,9 @@ int main( if ( ( error = ISAR_REND_SetSplitRendBitstreamHeader( hIsarPostRend, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, - bitsBuffer.config.codec_frame_size_ms - , + bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, - bitsBuffer.config.lc3plusHighRes - ) ) != IVAS_ERR_OK ) + bitsBuffer.config.lc3plusHighRes ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Error in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); exit( -1 ); @@ -1230,4 +1223,3 @@ int main( #undef WMC_TOOL_SKIP - diff --git a/apps/renderer.c b/apps/renderer.c index 5ef8cca19..8d7cb86c9 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -431,8 +431,7 @@ static void convertOutputBuffer_fx( Word16 *intBuffer, const Word16 cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, - Word16 out_q -); + Word16 out_q ); static void convertInputBuffer_fx( const Word16 *intBuffer, const Word16 numIntSamplesPerChannel, @@ -442,8 +441,7 @@ static void convertInputBuffer_fx( Word16 in_q_factor, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, - Word16 *out_q_factor -); + Word16 *out_q_factor ); /*------------------------------------------------------------------------------------------* @@ -1499,10 +1497,8 @@ int main( IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms - , - &bitsBuffer.config.isar_frame_size_ms - ); + &bitsBuffer.config.codec_frame_size_ms, + &bitsBuffer.config.isar_frame_size_ms ); if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1516,12 +1512,10 @@ int main( delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, - bitsBuffer.config.codec_frame_size_ms - , + bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, - bitsBuffer.config.lc3plus_highres - ) ) != IVAS_ERR_OK ) + bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); exit( -1 ); @@ -1536,10 +1530,8 @@ int main( IVAS_REND_GetSplitRendBitstreamHeader( hIvasRend, &bitsBuffer.config.codec, &bitsBuffer.config.poseCorrection, - &bitsBuffer.config.codec_frame_size_ms - , - &bitsBuffer.config.isar_frame_size_ms - ); + &bitsBuffer.config.codec_frame_size_ms, + &bitsBuffer.config.isar_frame_size_ms ); if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { @@ -1553,12 +1545,10 @@ int main( delayTimeScale_temp, bitsBuffer.config.codec, bitsBuffer.config.poseCorrection, - bitsBuffer.config.codec_frame_size_ms - , + bitsBuffer.config.codec_frame_size_ms, bitsBuffer.config.isar_frame_size_ms, args.sampleRate, - bitsBuffer.config.lc3plus_highres - ) ) != IVAS_ERR_OK ) + bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); exit( -1 ); @@ -1962,7 +1952,6 @@ int main( { delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); } - } bitsBuffer.config.bitsRead = 0; @@ -3878,8 +3867,7 @@ static void convertInputBuffer_fx( Word16 in_q_factor, const int16_t cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbAna, - Word16 *out_q_factor -) + Word16 *out_q_factor ) { Word16 chnl, smpl, i; @@ -3962,8 +3950,7 @@ static void convertOutputBuffer_fx( Word16 *intBuffer, const Word16 cldfb_in_flag, IVAS_CLDFB_FILTER_BANK_HANDLE *cldfbSyn, - Word16 out_q -) + Word16 out_q ) { Word16 chnl, smpl, i; Word32 temp_fx; diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index bb6351711..175b23c3b 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -282,17 +282,17 @@ typedef struct _ISAR_SPLIT_REND_BITS_DATA typedef struct _ISAR_SPLIT_REND_CONFIG { - int32_t splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ - int16_t hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ - int16_t dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ - /*The axis can be set dynamically per frame based on a file input */ - /*possible values: - 1 - (1dof correction. By default YAW correction) - 2 - (2dof correction. By default YAW and PITCH correction) - 3 - (3dof correction. By default YAW, PITCH and ROLL correction) - */ - int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ - int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ + int32_t splitRendBitRate; /*Bit rate for split rendering mode, if "pcm_out" is set then "splitRendBitRate" is used as a limit for MD bitrate */ + int16_t hq_mode; /*High quality 3DOF mode with additional side information. Requires more pre-renditions. */ + int16_t dof; /*flag to specify if pose correction is needed for 1, 2 or 3 degree of freedoms*/ + /*The axis can be set dynamically per frame based on a file input */ + /*possible values: + 1 - (1dof correction. By default YAW correction) + 2 - (2dof correction. By default YAW and PITCH correction) + 3 - (3dof correction. By default YAW, PITCH and ROLL correction) + */ + int16_t codec_delay_ms; /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/ + int16_t isar_frame_size_ms; /* ISAR bit stream frame size in milliseconds */ int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode; ISAR_SPLIT_REND_CODEC codec; diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index f25c796d4..78a0837ab 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -78,7 +78,6 @@ void Euler2Quat_fx( } - /*------------------------------------------------------------------------- * Copy_Quat_fx() * diff --git a/lib_com/options.h b/lib_com/options.h index 4574f38d4..3c1820254 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,6 @@ #define FIX_1372_ISAR_POST_REND #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ - //#define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ @@ -118,11 +117,9 @@ #define FIX_OLD_BINARY_FILE /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ - #endif //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ - #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index db871d9cb..b37b9bd6d 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -61,8 +61,8 @@ static void ivas_binRenderer_filterModule_fx( 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 */ - const Word16 pos_idx, /* i : pose index */ + BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: fastconv binaural renderer handle */ + const Word16 pos_idx, /* i : pose index */ Word16 Q_curr ) { Word16 bandIdx, k, chIdx, tapIdx; @@ -177,8 +177,7 @@ static ivas_error ivas_binRenderer_convModuleOpen( const Word16 isLoudspeaker, const AUDIO_CONFIG input_config, const HRTFS_FASTCONV_HANDLE hHrtf, - const Word16 num_poses -) + const Word16 num_poses ) { Word16 bandIdx, chIdx; Word16 pos_idx; @@ -1672,13 +1671,13 @@ void ivas_binaural_add_LFE_fx( void ivas_binRenderer_fx( BINAURAL_RENDERER_HANDLE hBinRenderer, /* i/o: binaural renderer handle */ const MULTI_BIN_REND_POSE_DATA *pMultiBinPoseData, - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ - const Word16 numTimeSlots, /* i : number of time slots to render */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined head and external orientation handle*/ + const Word16 numTimeSlots, /* i : number of time slots to render */ Word32 Cldfb_RealBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ Word32 Cldfb_ImagBuffer_Binaural_fx[][BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o : Rotated Binaural signals */ - Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ - Word16 *Q_in /* i : LS signals exp */ + Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word32 ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i : LS signals Q_in*/ + Word16 *Q_in /* i : LS signals exp */ ) { Word16 chIdx, i, j, k; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index d7736e244..db23485b8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -861,7 +861,6 @@ typedef struct renderer_struct } ISM_RENDERER_DATA, *ISM_RENDERER_HANDLE; - /*----------------------------------------------------------------------------------* * IVAS decoder specific ISAR wrapper structures *----------------------------------------------------------------------------------*/ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index dd5db0071..551a20c0f 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2205,9 +2205,9 @@ ivas_error IVAS_DEC_GetMasaMetadata( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_FeedHeadTrackData( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ - IVAS_VECTOR3 Pos, /* i : listener position */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_QUATERNION orientation, /* i : head-tracking data, listener orientation */ + IVAS_VECTOR3 Pos, /* i : listener position */ const Word16 subframe_idx, /* i : subframe index */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis /* i : external control for rotation axis for split rendering */ ) @@ -4039,11 +4039,10 @@ IVAS_DEC_GetSplitRendBitstreamHeader( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ ISAR_SPLIT_REND_CODEC *pCodec, /* o: pointer to codec setting */ ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, /* o: pointer to pose correction mode */ - Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ - Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ + Word16 *pIsar_frame_size_ms, /* o: pointer to isar frame size setting */ + Word16 *pCodec_frame_size_ms /* o: pointer to codec frame size setting */ , - Word16 *pLc3plusHighRes -) + Word16 *pLc3plusHighRes ) { if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { diff --git a/lib_isar/isar_lc3plus_dec.c b/lib_isar/isar_lc3plus_dec.c index ea19833ba..38371d134 100644 --- a/lib_isar/isar_lc3plus_dec.c +++ b/lib_isar/isar_lc3plus_dec.c @@ -41,8 +41,6 @@ #include "wmc_auto.h" - - /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_Open() * @@ -197,7 +195,6 @@ ivas_error ISAR_LC3PLUS_DEC_Open( } - /*------------------------------------------------------------------------- * ISAR_LC3PLUS_DEC_GetDelay() * diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 467db9116..7b11084af 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -505,8 +505,8 @@ void ISAR_LC3PLUS_ENC_Close( * *-------------------------------------------------------------------*/ ivas_error ISAR_LC3PLUS_ENC_Encode( - ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ - Word32 **pcm_in, /* i : pointer input samples */ + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + Word32 **pcm_in, /* i : pointer input samples */ void *bitstream_out, /* o : pointer to bitstream frame */ const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ Word16 q_in[16] ) diff --git a/lib_isar/isar_lc3plus_enc.h b/lib_isar/isar_lc3plus_enc.h index eeef615fc..f0c37afc8 100644 --- a/lib_isar/isar_lc3plus_enc.h +++ b/lib_isar/isar_lc3plus_enc.h @@ -54,9 +54,9 @@ typedef struct ISAR_LC3PLUS_ENC_HANDLE } * ISAR_LC3PLUS_ENC_HANDLE; ivas_error ISAR_LC3PLUS_ENC_Open( - const LC3PLUS_CONFIG config, /* i : encoder configuration */ + const LC3PLUS_CONFIG config, /* i : encoder configuration */ const uint32_t initialBitsPerSecond, /* i : initial target bit rate */ - ISAR_LC3PLUS_ENC_HANDLE *handle /* o : LC3plus encoder handle */ + ISAR_LC3PLUS_ENC_HANDLE *handle /* o : LC3plus encoder handle */ ); ivas_error IVAS_LC3PLUS_ENC_SetBitrate( @@ -79,8 +79,8 @@ void ISAR_LC3PLUS_ENC_Close( ); ivas_error ISAR_LC3PLUS_ENC_Encode( - ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ - Word32 **pcm_in, /* i : pointer input samples */ + ISAR_LC3PLUS_ENC_HANDLE handle, /* i : LC3plus encoder handle */ + Word32 **pcm_in, /* i : pointer input samples */ void *bitstream_out, /* o : pointer to bitstream frame */ const Word32 bitstream_out_size, /* i : size of the bitstream_out buffer in bytes. Must be equal to ISAR_LC3PLUS_ENC_GetOutputBitstreamSize. */ Word16 q_in[16] ); diff --git a/lib_isar/isar_lc3plus_payload.c b/lib_isar/isar_lc3plus_payload.c index 291cd9d05..2493aa6a3 100644 --- a/lib_isar/isar_lc3plus_payload.c +++ b/lib_isar/isar_lc3plus_payload.c @@ -816,4 +816,3 @@ LC3PLUS_RTP_ERR LC3PLUS_RTP_ftd_fdi_from_frame_duration_us( LC3PLUS_RTP_FTD_FDI return LC3PLUS_RTP_ERR_INVALID_PARAMETERS; } - diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 83f6261ee..ce517a492 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1990,4 +1990,3 @@ static void ComputeAllocation( return; } - diff --git a/lib_isar/isar_prot.h b/lib_isar/isar_prot.h index 6e8bcaf9f..112ee1155 100644 --- a/lib_isar/isar_prot.h +++ b/lib_isar/isar_prot.h @@ -199,8 +199,7 @@ void isar_split_rend_get_quant_params_fx( Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], const Word16 ro_flag, - Word16 *num_quant_strats -); + Word16 *num_quant_strats ); void isar_split_rend_get_quant_params( const int16_t num_md_bands, @@ -320,7 +319,6 @@ void isar_set_split_rend_ht_setup_fx( Word32 Rmat_fx[MAX_PARAM_SPATIAL_SUBFRAMES][3][3] ); - ivas_error isar_split_rend_validate_config( const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const Word16 is_pcm_out ); @@ -347,11 +345,11 @@ Word32 isar_get_split_rend_md_target_brate( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - Word16 *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ - Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ - const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ - const Word16 num_subframes /* i : number of subframes */ + Word16 *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ ); void ISAR_SPLIT_REND_BITStream_init( @@ -379,8 +377,7 @@ ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const Word32 OutSampleRate, - const IVAS_RENDER_FRAMESIZE ivas_frame_size -); + const IVAS_RENDER_FRAMESIZE ivas_frame_size ); ISAR_POST_REND_AudioConfigType isar_getAudioConfigType( const IVAS_AUDIO_CONFIG config ); diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index 085cae9fc..b1cf6659b 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1957,4 +1957,3 @@ void isar_init_split_post_rend_handles( return; } - diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 5447aea1e..b30f25ca7 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -1208,8 +1208,6 @@ static void ComputeCoeffs_fx( hMd->pred_mat_re2[i] = gd_tmp_fx[i]; set32_fx( hMd->pred_mat_im_fx[i], 0, BINAURAL_CHANNELS ); } - - } ELSE { @@ -2678,8 +2676,7 @@ ivas_error split_renderer_open_lc3plus( SPLIT_REND_WRAPPER *hSplitRendWrapper, const ISAR_SPLIT_REND_CONFIG_DATA *pSplitRendConfig, const Word32 OutSampleRate, - const IVAS_RENDER_FRAMESIZE isar_frame_size -) + const IVAS_RENDER_FRAMESIZE isar_frame_size ) { ivas_error error; Word16 i, delayBufferLength; @@ -3135,4 +3132,3 @@ void lc3plusTimeAlignCldfbPoseCorr( return; } - diff --git a/lib_isar/isar_splitRenderer_utils.c b/lib_isar/isar_splitRenderer_utils.c index bfdb1454f..62f3870d3 100644 --- a/lib_isar/isar_splitRenderer_utils.c +++ b/lib_isar/isar_splitRenderer_utils.c @@ -819,26 +819,30 @@ ivas_error isar_split_rend_validate_config( } ELSE { - IF( EQ_16( pSplitRendConfig->dof, 1 ) ){ - IF( LT_32( pSplitRendConfig->splitRendBitRate, 34000 ) ){ + IF( EQ_16( pSplitRendConfig->dof, 1 ) ) + { + IF( LT_32( pSplitRendConfig->splitRendBitRate, 34000 ) ) + { return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "1DOF metadata needs atleast 34 kbps" ); + } + } + ELSE IF( EQ_16( pSplitRendConfig->dof, 2 ) ) + { + IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" ); + } + } + ELSE IF( EQ_16( pSplitRendConfig->dof, 3 ) ) + { + IF( LT_32( pSplitRendConfig->splitRendBitRate, 82000 ) ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); + } + } } -} -ELSE IF( EQ_16( pSplitRendConfig->dof, 2 ) ){ - IF( LT_32( pSplitRendConfig->splitRendBitRate, 50000 ) ){ - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "2DOF metadata needs atleast 50 kbps" ); -} -} -ELSE IF( EQ_16( pSplitRendConfig->dof, 3 ) ) -{ - IF( LT_32( pSplitRendConfig->splitRendBitRate, 82000 ) ) - { - return IVAS_ERROR( IVAS_ERR_INVALID_SPLIT_REND_CONFIG, "3DOF metadata needs atleast 128 kbps" ); - } -} -} -return IVAS_ERR_OK; + return IVAS_ERR_OK; } @@ -860,8 +864,7 @@ void isar_split_rend_get_quant_params_fx( Word16 pred_real_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], Word16 pred_imag_bands_roll[ISAR_SPLIT_REND_NUM_QUANT_STRATS], const Word16 ro_flag, - Word16 *num_quant_strats -) + Word16 *num_quant_strats ) { Word16 q; @@ -1298,11 +1301,11 @@ ivas_error isar_framesize_to_ms( ivas_error isar_split_rend_choose_default_codec( ISAR_SPLIT_REND_CODEC *pCodec, /* i/o: pointer to codec setting */ - int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ - Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ - const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ - const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ - const Word16 num_subframes /* i : number of subframes */ + int16_t *pIsar_frame_size_ms, /* i/o: pointer to isar frame size setting */ + Word16 *pCodec_frame_size_ms, /* i/o: pointer to codec frame size setting */ + const Word16 cldfb_in_flag, /* i : flag indicating rendering in TD */ + const Word16 pcm_out_flag, /* i : flag to indicate PCM output */ + const Word16 num_subframes /* i : number of subframes */ ) { IF( EQ_16( pcm_out_flag, 0 ) ) @@ -1355,5 +1358,3 @@ Word32 get_bit( { return L_and( state, ( L_shl( 1, (Word16) bit_id ) ) ); } - - diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 8ad605f40..c784ed1a9 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -464,8 +464,7 @@ static ivas_error getRendInputNumChannels( static ivas_error updateSplitPostRendPanGains( input_split_post_rend *inputSplitPostRend, const AUDIO_CONFIG outConfig, - ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg -) + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg ) { ivas_error error; rendering_context rendCtx; @@ -524,8 +523,7 @@ static ivas_error setRendInputActiveSplitPostRend( void *input, const AUDIO_CONFIG inConfig, const IVAS_REND_InputId id, - ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg -) + ISAR_SPLIT_REND_CONFIG_DATA *hRendCfg ) { ivas_error error; rendering_context rendCtx; @@ -545,8 +543,7 @@ static ivas_error setRendInputActiveSplitPostRend( inputSplitPostRend->numCachedSamples = 0; - if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg - ) ) != IVAS_ERR_OK ) + if ( ( error = updateSplitPostRendPanGains( inputSplitPostRend, outConfig, hRendCfg ) ) != IVAS_ERR_OK ) { return error; } @@ -872,8 +869,7 @@ ivas_error ISAR_POST_REND_AddInput( Word32 maxNumInputsOfType; void *inputsArray; Word32 inputStructSize; - ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * - ); + ivas_error ( *activateInput )( void *, AUDIO_CONFIG, IVAS_REND_InputId, ISAR_SPLIT_REND_CONFIG_DATA * ); Word32 inputIndex; /* Validate function arguments */ @@ -901,8 +897,7 @@ ivas_error ISAR_POST_REND_AddInput( } *inputId = makeInputId( inConfig, inputIndex ); - if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig - ) ) != IVAS_ERR_OK ) + if ( ( error = activateInput( (uint8_t *) inputsArray + inputStructSize * inputIndex, inConfig, *inputId, &hIvasRend->splitRenderConfig ) ) != IVAS_ERR_OK ) { return error; } @@ -1812,5 +1807,3 @@ int32_t ISAR_POST_REND_GetCntFramesLimited( return hIvasRend->hLimiter->cnt_frames_limited; } #endif - - diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 32773ef7a..13ae12ac6 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -47,7 +47,6 @@ #include "wmc_auto.h" - /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -87,9 +86,7 @@ ivas_error ISAR_PRE_REND_open( &pSplitRendConfig->isar_frame_size_ms, &pSplitRendConfig->codec_frame_size_ms, cldfb_in_flag_local, - pcm_out_flag, (int16_t) - ivas_frame_size - ) ) != IVAS_ERR_OK ) + pcm_out_flag, (int16_t) ivas_frame_size ) ) != IVAS_ERR_OK ) { return error; } @@ -175,8 +172,7 @@ ivas_error ISAR_PRE_REND_open( IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { if ( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, - ivas_frame_size - ) ) != IVAS_ERR_OK ) + ivas_frame_size ) ) != IVAS_ERR_OK ) { return error; } @@ -481,7 +477,7 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( #ifdef OPT_AVOID_STATE_BUF_RESCALE cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #else - cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 + cldfbSynthesis_ivas_fx( Cldfb_In_BinReal_p_fx, Cldfb_In_BinImag_p_fx, pOutput_fx[ch], hSplitBin->hCldfbHandles->cldfbSyn[0]->no_channels * num_slots, 0, hSplitBin->hCldfbHandles->cldfbSyn[ch] ); // Q_cldfb - 1 #endif Q_out[ch] = sub( Q_cldfb, 1 ); move16(); @@ -592,4 +588,3 @@ ivas_error ISAR_PRE_REND_MultiBinToSplitBinaural( fclose(fp1);*/ return error; } - diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index bf27912f7..369a1d2b4 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -206,9 +206,7 @@ static ivas_error ivas_rend_initCrend_fx( test(); test(); - if ( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - ) + if ( NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" ); } @@ -1564,8 +1562,7 @@ static ivas_error ivas_er_init_handle( ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend, - const int16_t num_poses -) + const int16_t num_poses ) { Word16 i; CREND_HANDLE hCrend; @@ -1681,8 +1678,7 @@ ivas_error ivas_rend_openCrend( HRTFS_STATISTICS_HANDLE hHrtfStatistics, #endif const Word32 output_Fs, - const Word16 num_poses -) + const Word16 num_poses ) { Word16 i, subframe_length; Word32 max_total_ir_len; @@ -1910,8 +1906,7 @@ ivas_error ivas_rend_openCrend( void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend, - const Word16 num_poses -) + const Word16 num_poses ) { Word16 i; Word16 pos_idx; @@ -2069,8 +2064,7 @@ static ivas_error ivas_rend_crendConvolver( Word32 *pcm_out[], // Qx const Word32 output_Fs, const Word16 i_ts, - const Word16 pos_idx -) + const Word16 pos_idx ) { Word16 i, j, k, m; Word16 subframe_length, idx_in; @@ -2332,8 +2326,7 @@ ivas_error ivas_rend_crendProcessSubframe( const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word32 output_Fs /* i : output sampling rate */ , - const Word16 pos_idx -) + const Word16 pos_idx ) { Word16 subframe_idx, subframe_len; Word16 nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 1fb026078..a1d3a4908 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -299,7 +299,7 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #else - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); @@ -322,8 +322,8 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK ) #endif #else - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) + /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ + if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) #endif { return error; @@ -2062,7 +2062,6 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( } - static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -2693,8 +2692,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( const Word16 numInChannels, const Word16 processReverb, const Word16 subframe, - const Word16 q_mat - , + const Word16 q_mat, Word32 outRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 outIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 reverbRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], @@ -2702,8 +2700,7 @@ static void ivas_dirac_dec_binaural_process_output_fx( Word32 decorrRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 decorrIm_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word16 *Q_inp_mix, - const Word8 recompute -) + const Word8 recompute ) { Word16 slot, bin, chA, chB; Word16 nBins; @@ -5526,8 +5523,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( const Word16 subframe, const SPLIT_REND_WRAPPER *hSplitRendWrapper, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], - Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] -) + Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; @@ -5885,9 +5881,9 @@ static void ivas_masa_ext_rend_parambin_internal_fx( } void ivas_masa_ext_rend_parambin_render_fx( - MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ - COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ + COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ + Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ const Word16 num_subframes, /* i : number of subframes to render */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index f33ace930..5c19acb5f 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -374,10 +374,8 @@ Word16 ivas_get_nchan_buffers_dec( { nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ); } - ELSE if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) - || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) - ) + ELSE if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { nchan_out_buff = shl( CPE_CHANNELS, 1 ); } diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index 44eff1329..6bd0ed87c 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -338,8 +338,8 @@ ivas_error ivas_er_encoder_init( p_y_fx = reflections->shoebox_data.az_angle.data_fx[i]; // Q23 move32(); move32(); - p_x_fx = L_shr( p_x_fx, 1 ); // Q22 - p_y_fx = L_shr( p_y_fx, 1 ); // Q22 + p_x_fx = L_shr( p_x_fx, 1 ); // Q22 + p_y_fx = L_shr( p_y_fx, 1 ); // Q22 rad_el_angle = deg2rad_fx( p_x_fx ); // Q22 rad_az_angle = deg2rad_fx( p_y_fx ); // Q22 diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index dc73967cc..2fe95f151 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1353,8 +1353,8 @@ ivas_error ivas_combined_orientation_open( move32(); ( *hCombinedOrientationData )->interpolationIncrement_fx = ONE_IN_Q30; // Q30 move32(); - ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 500; - move16(); + ( *hCombinedOrientationData )->maximumFramesToTargetOrientation = 500; + move16(); ( *hCombinedOrientationData )->lrSwitchedNext = 0; move16(); ( *hCombinedOrientationData )->lrSwitchedCurrent = 0; @@ -1533,9 +1533,9 @@ ivas_error combine_external_and_head_orientations_rend( * NOTE that the external orientations are inversed. *------------------------------------------------------------------------*/ ivas_error combine_external_and_head_orientations( - IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ - IVAS_VECTOR3 *listenerPos, /* i : listener position */ - ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ + IVAS_QUATERNION *headRotQuaternions, /* i : quaternions for head rotation */ + IVAS_VECTOR3 *listenerPos, /* i : listener position */ + ISAR_SPLIT_REND_ROT_AXIS sr_pose_pred_axis, /* i : split rend pose prediction axis */ EXTERNAL_ORIENTATION_HANDLE hExtOrientationData, /* i : external orientation handle */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData /* i/o: combined orientation handle */ ) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 1d019b675..2b0f1bdea 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -635,31 +635,33 @@ IVAS_REND_AudioConfigType getAudioConfigType( static ivas_error validateOutputSampleRate( const Word32 sampleRate, - const AUDIO_CONFIG outConfig ){ + const AUDIO_CONFIG outConfig ) +{ - IF( NE_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ){ + IF( NE_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) + { /* If no binaural rendering, any sampling rate is supported */ return IVAS_ERR_OK; -} -ELSE IF( ( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( sampleRate, 48000 ) ) -{ - return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); -} -ELSE -{ - - /* Otherwise rendering to binaural, support the same set as IVAS decoder */ - SWITCH( sampleRate ) + } + ELSE IF( ( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( sampleRate, 48000 ) ) { - case 8000: - case 16000: - case 32000: - case 48000: - return IVAS_ERR_OK; + return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); } + ELSE + { - return IVAS_ERR_INVALID_SAMPLING_RATE; -} + /* Otherwise rendering to binaural, support the same set as IVAS decoder */ + SWITCH( sampleRate ) + { + case 8000: + case 16000: + case 32000: + case 48000: + return IVAS_ERR_OK; + } + + return IVAS_ERR_INVALID_SAMPLING_RATE; + } } /*-------------------------------------------------------------------* * getAudioConfigNumChannels() @@ -3953,7 +3955,6 @@ static ivas_error ivas_pre_rend_init( } - /*-------------------------------------------------------------------* * IVAS_REND_AddInput() * @@ -4875,11 +4876,11 @@ Word16 IVAS_REND_FeedRenderConfig( * *-------------------------------------------------------------------*/ ivas_error IVAS_REND_SetHeadRotation( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ - const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_QUATERNION headRot, /* i : head orientations for next rendering call */ + const IVAS_VECTOR3 Pos, /* i : listener positions for next rendering call */ const ISAR_SPLIT_REND_ROT_AXIS rot_axis, /* i : external control for rotation axis for split rendering */ - const Word16 sf_idx /* i : subframe index */ + const Word16 sf_idx /* i : subframe index */ ) { Word16 i; @@ -7369,7 +7370,6 @@ static void renderSbaToSba( } - static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, @@ -9660,7 +9660,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i : HRTF statistics */ #else - input_masa *inputMasa /* i/o: MASA external renderer structure */ + input_masa *inputMasa /* i/o: MASA external renderer structure */ #endif ) { @@ -9795,7 +9795,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF Copy32( ( *phHrtfParambin )->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #else - Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); + Copy32( hHrtfParambin->parametricEarlyPartEneCorrection_fx, hDiracDecBin->earlyPartEneCorrection_fx, nBins ); #endif hDiracDecBin->q_earlyPartEneCorrection = Q28; move16(); @@ -9809,8 +9809,8 @@ static ivas_error ivas_masa_ext_rend_parambin_init( IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes_fx, hHrtfParambin->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #endif #else - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) + /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ + IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) #endif { return error; diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index ff0aa2e1a..43c68cba5 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -65,12 +65,10 @@ ivas_error split_rend_reader_open( char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, - int16_t *lc3plus_highres -) + int16_t *lc3plus_highres ) { SplitFileReadWrite *hSplitRendFileReadWrite; size_t header_len, h; @@ -157,12 +155,10 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms - , + int16_t codec_frame_size_ms, const int16_t isar_frame_size_ms, const int32_t sampling_rate, - const int16_t lc3plus_highres -) + const int16_t lc3plus_highres ) { SplitFileReadWrite *hSplitRendFileReadWrite; size_t header_len, h; diff --git a/lib_util/split_render_file_read_write.h b/lib_util/split_render_file_read_write.h index b6f32a317..2895dd426 100644 --- a/lib_util/split_render_file_read_write.h +++ b/lib_util/split_render_file_read_write.h @@ -43,12 +43,10 @@ ivas_error split_rend_reader_open( char *filename, ISAR_SPLIT_REND_CODEC *codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE *poseCorrection, - int16_t *codec_frame_size_ms - , + int16_t *codec_frame_size_ms, int16_t *isar_frame_size_ms, int32_t *sampling_rate, - int16_t *lc3plus_highres -); + int16_t *lc3plus_highres ); /* Allocates and initializes a a split renderer writer instance */ @@ -59,12 +57,10 @@ ivas_error split_rend_writer_open( const int32_t delayTimeScale, ISAR_SPLIT_REND_CODEC codec, ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrection, - int16_t codec_frame_size_ms - , + int16_t codec_frame_size_ms, const int16_t isar_frame_size_ms, const int32_t sampling_rate, - const int16_t lc3plus_highres -); + const int16_t lc3plus_highres ); /* Closes the split renderer reader/writer and deallocates memory */ -- GitLab From ff910e8916731097fa517825b87be81746e8b964 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 12:51:21 +0200 Subject: [PATCH 281/692] 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 282/692] 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 e1ce3fb898faed74c4001636436e7b89e6bb88bb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 18:29:27 +0530 Subject: [PATCH 283/692] Crash fix for [Multi-channel 7_1_4 bitrate switching from 13.2 kbps to 512 kbps, 48kHz in, 48kHz out, HOA3 out] fxd enc fxd dec case and warning fix --- lib_dec/ivas_mc_param_dec_fx.c | 2 +- lib_dec/ivas_sba_rendering_internal_fx.c | 2 +- 2 files 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 b6868dbb1..c25ec972f 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -106,7 +106,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); -static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); +static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, const Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); /*------------------------------------------------------------------------- * ivas_param_mc_dec_open() diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index d9ee47c84..5a15a357e 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -211,7 +211,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( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/ + 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 */ -- GitLab From 79ae9a3cc39dc5e5be2cd87faae4be74ccf0b8b3 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 18:34:27 +0530 Subject: [PATCH 284/692] Clang formatting changes --- lib_dec/ivas_sba_rendering_internal_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 5a15a357e..ba8c529d7 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -212,9 +212,9 @@ void ivas_mc2sba_fx( { #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 */ +#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 */ +#endif /* OPT_BIN_RENDERER_V2 */ move32(); } } -- GitLab From 734b270395cda470643392d1ebabc9a7511fc97b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 18:36:00 +0530 Subject: [PATCH 285/692] Bug fix --- lib_enc/cod4t64_fast_fx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_enc/cod4t64_fast_fx.c b/lib_enc/cod4t64_fast_fx.c index e24f3b678..7079f6597 100644 --- a/lib_enc/cod4t64_fast_fx.c +++ b/lib_enc/cod4t64_fast_fx.c @@ -145,7 +145,8 @@ void acelp_fast_fx( Word16 track_order[NB_TRACK_FCB_4T * MAX_NUM_INTER], m0_track[NB_TRACK_FCB_4T]; Word16 ind_stream[NPMAXPT * NB_TRACK_FCB_4T], idx; Word16 G, G1, G2, G3, Gn, Gd; - Word32 Gd32; + Word32 Gd32 = 0; + move32(); Word16 y_tmp[L_SUBFR_MAX]; Word32 dn[L_SUBFR_MAX]; Word32 crit_num, crit_den, crit_num_max, crit_den_max, L_tmp1, L_tmp2; @@ -718,8 +719,6 @@ void acelp_fast_fx( IF( GE_16( nb_pulse, 4 ) ) { Gn = add( Gn, i_mult( s[2], dn_orig[m[2]] ) ); // Q_dn - Gd32 = Gd; - move16(); temp1 = alp[0]; move32(); temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[2] ), alp[m[0] - m[2]] ); @@ -770,8 +769,6 @@ void acelp_fast_fx( IF( GE_16( nb_pulse, 5 ) ) { Gn = add( Gn, i_mult( s[3], dn_orig[m[3]] ) ); // Q_dn - Gd32 = Gd; - move16(); temp1 = alp[0]; move32(); temp2 = L_mult0( i_mult( shl( s[0], 1 ), s[3] ), alp[m[0] - m[3]] ); -- GitLab From bd88ebcc33968191ec4327a1179d95abab2d6883 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 19:19:36 +0530 Subject: [PATCH 286/692] Bit exact optimizations in SBA decoder renderer path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes are enabled with macro OPT_SBA_REND_V1_BE Functions and corresponding WMOPs gains: ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx 1.5 vbap_gains 0.2 vector_matrix_multiply_3x3_fx 2.2 protoSignalComputation4_fx 1.8 in_tri_fx 0.1 Test case: ./IVAS_cod -sba 1 256000 48 scripts/testv/stvFOA48c.wav bit_sba ./IVAS_dec 7_1 48 bit_sba sba.wav  --- lib_com/options.h | 1 + .../ivas_dirac_dec_binaural_functions_fx.c | 165 ++++++++++++++++++ lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 63 ++++++- lib_rend/ivas_dirac_rend_fx.c | 8 +- lib_rend/ivas_efap_fx.c | 16 +- lib_rend/ivas_vbap_fx.c | 38 +++- 6 files changed, 277 insertions(+), 14 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9dc7e7fd1..7e3799ffc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -75,6 +75,7 @@ #define FIX_1379_MASA_ANGLE_ROUND /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_SBA_REND_V1_BE #define OPT_SBA_ENC_V1_BE #define OPT_BIN_RENDERER_V1 #define OPT_BIN_RENDERER_V2 diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 6dc701468..c92f800af 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -3415,6 +3415,169 @@ static void eig2x2_fx( move16(); move16(); +#ifdef OPT_SBA_REND_V1_BE + /* Eigenvectors */ + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word16 q_diff = sub( q_e, *q_D ); + IF( q_diff > 0 ) + { + tmp1 = L_sub( D_fx[ch], L_shr( e1, q_diff ) ); + tmp2 = L_sub( D_fx[ch], L_shr( e2, q_diff ) ); + q_tmp1 = *q_D; + move16(); + } + ELSE + { + tmp1 = L_sub( L_shl( D_fx[ch], q_diff ), e1 ); + tmp2 = L_sub( L_shl( D_fx[ch], q_diff ), e2 ); + q_tmp1 = q_e; + move16(); + } + + IF( GT_32( L_abs( tmp2 ), L_abs( tmp1 ) ) ) + { + s_fx = tmp2; + move32(); + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); + + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); + + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + + tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 + q_tmp2 = sub( 31, exp ); + + q_diff = sub( q_c, q_tmp1 ); + IF( q_diff > 0 ) + { + c_re = L_shr( c_re, q_diff ); + c_im = L_shr( c_im, q_diff ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shl( s_fx, q_diff ); + q_tmp1 = q_c; + move16(); + } + + Ure_fx[0][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[1][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[1][ch] = Mpy_32_32( c_im, normVal_fx ); + move32(); + q_U_1 = sub( add( q_tmp1, q_tmp2 ), 31 ); + + IF( q_U_2 != 0 ) + { + q_diff = sub( q_U_2, q_U_1 ); + IF( q_diff > 0 ) + { + Ure_fx[1][ch - 1] = L_shr( Ure_fx[1][ch - 1], q_diff ); + Ure_fx[0][ch - 1] = L_shr( Ure_fx[0][ch - 1], q_diff ); + Uim_fx[0][ch - 1] = L_shr( Uim_fx[0][ch - 1], q_diff ); + q_U_2 = q_U_1; + move32(); + move32(); + move32(); + move16(); + } + ELSE IF( GT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch] = L_shl( Ure_fx[1][ch], q_diff ); + Ure_fx[0][ch] = L_shl( Ure_fx[0][ch], q_diff ); + Uim_fx[1][ch] = L_shl( Uim_fx[1][ch], q_diff ); + q_U_1 = q_U_2; + move32(); + move32(); + move32(); + move16(); + } + } + q_U_2 = q_U_1; + move16(); + } + ELSE + { + s_fx = tmp1; + move32(); + + exp = sub( norm_l( s_fx ), 1 ); + tmp2 = Mpy_32_32( s_fx, s_fx ); + q_tmp2 = sub( add( q_tmp1, q_tmp1 ), 31 ); + + tmp2 = BASOP_Util_Add_Mant32Exp( crossSquare_fx, sub( 31, q_crossSquare ), tmp2, sub( 31, q_tmp2 ), &q_tmp2 ); + q_tmp2 = sub( 31, q_tmp2 ); + + tmp3 = BASOP_Util_Add_Mant32Exp( tmp2, sub( 31, q_tmp2 ), epsilon_mant, epsilon_exp, &exp_tmp3 ); + + tmp2 = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q30, tmp3, &exp ); + exp = sub( exp, sub( Q30, sub( 31, exp_tmp3 ) ) ); + normVal_fx = Sqrt32( tmp2, &exp ); // q_tmp2 + q_tmp2 = sub( 31, exp ); + + q_diff = sub( q_c, q_tmp1 ); + IF( q_diff > 0 ) + { + c_re = L_shr( c_re, q_diff ); + c_im = L_shr( c_im, q_diff ); + q_c = q_tmp1; + move16(); + } + ELSE + { + s_fx = L_shl( s_fx, q_diff ); + q_tmp1 = q_c; + move16(); + } + + Ure_fx[1][ch] = Mpy_32_32( s_fx, normVal_fx ); + move32(); + Ure_fx[0][ch] = Mpy_32_32( c_re, normVal_fx ); + move32(); + Uim_fx[0][ch] = Mpy_32_32( L_negate( c_im ), normVal_fx ); + move32(); + q_U_2 = sub( add( q_tmp1, q_tmp2 ), 31 ); + + IF( q_U_1 != 0 ) + { + q_diff = sub( q_U_2, q_U_1 ); + IF( q_diff > 0 ) + { + Ure_fx[1][ch] = L_shr( Ure_fx[1][ch], q_diff ); + Ure_fx[0][ch] = L_shr( Ure_fx[0][ch], q_diff ); + Uim_fx[0][ch] = L_shr( Uim_fx[0][ch], q_diff ); + q_U_2 = q_U_1; + move32(); + move32(); + move32(); + move16(); + } + ELSE IF( GT_16( q_U_1, q_U_2 ) ) + { + Ure_fx[1][ch - 1] = L_shl( Ure_fx[1][ch - 1], q_diff ); + Ure_fx[0][ch - 1] = L_shl( Ure_fx[0][ch - 1], q_diff ); + Uim_fx[1][ch - 1] = L_shl( Uim_fx[1][ch - 1], q_diff ); + q_U_1 = q_U_2; + move32(); + move32(); + move32(); + move16(); + } + } + q_U_1 = q_U_2; + move16(); + } + } +#else /* OPT_SBA_REND_V1_BE */ /* Eigenvectors */ FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { @@ -3571,6 +3734,8 @@ static void eig2x2_fx( move16(); } } +#endif /* OPT_SBA_REND_V1_BE */ + if ( q_U_1 != 0 ) { *q_U = q_U_1; diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 872d89c34..ba0ab8953 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2465,6 +2465,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( move16(); move16(); +#ifdef OPT_SBA_REND_V1_BE + Word32 cmp = W_shl_sat_l( DIRAC_GAIN_LIMIT_Q26, sub( h_dirac_output_synthesis_state->gains_dir_prev_q, 26 ) ); + Word32 cmp2 = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); +#endif /* OPT_SBA_REND_V1_BE */ + FOR( k = 0; k < nchan_out_woLFE; k++ ) { Word32 power_smooth_temp; @@ -2512,11 +2517,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = 0; move32(); } +#ifdef OPT_SBA_REND_V1_BE + ELSE IF( GT_32( *( p_gains_dir ), cmp ) ) + { + *( p_gains_dir ) = cmp; /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/ + move32(); + } +#else /* OPT_SBA_REND_V1_BE */ ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) { *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*26 + h_dirac_output_synthesis_state->gains_dir_prev_q + 1 + 5 - 32 -> h_dirac_output_synthesis_state->gains_dir_prev_q*/ move32(); } +#endif /* OPT_SBA_REND_V1_BE */ IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { @@ -2549,11 +2562,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_diff ) = 0; move32(); } +#ifdef OPT_SBA_REND_V1_BE + ELSE IF( GT_32( *( p_gains_diff ), cmp2 ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ + { + *( p_gains_diff ) = cmp2; /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ + move32(); + } +#else /* OPT_SBA_REND_V1_BE */ ELSE IF( GT_32( *( p_gains_diff ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ) ) ) /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ { *( p_gains_diff ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_diff_prev_q ) ), Q5 ) ); /*h_dirac_output_synthesis_state->gains_diff_prev_q*/ move32(); } +#endif /* OPT_SBA_REND_V1_BE */ p_gains_diff++; } @@ -2564,15 +2585,25 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( g1 = alpha[l]; // Q31 move32(); g2 = L_sub( ONE_IN_Q31, g1 ); // Q31 +#ifdef OPT_SBA_REND_V1_BE + W_temp = W_mac_32_32( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), + g2, ( *( p_cy_auto_dir_smooth_prev ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/ +#else /* OPT_SBA_REND_V1_BE */ W_temp = W_add( W_mult_32_32( g1, ( *( p_cy_auto_dir_smooth++ ) ) ), W_mult_32_32( g2, ( *( p_cy_auto_dir_smooth_prev ) ) ) ); /*32+q_cy_auto_dir_smooth_prev_local*/ +#endif /* OPT_SBA_REND_V1_BE */ q_tmp = W_norm( W_temp ); L_tmp = W_extract_h( W_shl( W_temp, q_tmp ) ); // q_cy_auto_dir_smooth_prev_local + q_tmp *( p_cy_auto_dir_smooth_prev++ ) = L_shr_r( L_tmp, q_tmp ); // q_cy_auto_dir_smooth_prev_local move32(); +#ifdef OPT_SBA_REND_V1_BE + *( p_cy_cross_dir_smooth_prev ) = Madd_32_32( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth ) ) ), + g2, ( *( p_cy_cross_dir_smooth_prev ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev +#else /* OPT_SBA_REND_V1_BE */ *( p_cy_cross_dir_smooth_prev ) = L_add( Mpy_32_32( g1, ( *( p_cy_cross_dir_smooth ) ) ), Mpy_32_32( g2, ( *( p_cy_cross_dir_smooth_prev ) ) ) ); // (Q31, q_cy_cross_dir_smooth_prev) -> q_cy_cross_dir_smooth_prev +#endif /* OPT_SBA_REND_V1_BE */ move32(); test(); if ( *( p_cy_cross_dir_smooth_prev ) == 0 && ( *( p_cy_cross_dir_smooth ) != 0 ) ) @@ -2604,11 +2635,19 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( *( p_gains_dir ) = 0; move32(); } +#ifdef OPT_SBA_REND_V1_BE + ELSE IF( GT_32( *( p_gains_dir ), cmp ) ) /*gains_dir_prev_q*/ + { + *( p_gains_dir ) = cmp; /*gains_dir_prev_q*/ + move32(); + } +#else /* OPT_SBA_REND_V1_BE */ ELSE IF( GT_32( *( p_gains_dir ), W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ) ) ) /*gains_dir_prev_q*/ { *( p_gains_dir ) = W_extract_h( W_shl( W_mult_32_32( DIRAC_GAIN_LIMIT_Q26, L_shl( 1, h_dirac_output_synthesis_state->gains_dir_prev_q ) ), Q5 ) ); /*gains_dir_prev_q*/ move32(); } +#endif /* OPT_SBA_REND_V1_BE */ IF( *( p_cy_cross_dir_smooth_prev++ ) < 0 ) { @@ -2695,7 +2734,11 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( shl( i_mult( proto_direct_index[k], num_freq_bands ), Q1 ); FOR( l = 0; l < num_freq_bands; l++ ) { - g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q +#ifdef OPT_SBA_REND_V1_BE + g = Madd_32_32( Mpy_32_32( g1, *( p_gain_1++ ) ), g2, *( p_gain_2++ ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q +#else /* OPT_SBA_REND_V1_BE */ + g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_dir_prev_q) -> gains_dir_prev_q +#endif /* OPT_SBA_REND_V1_BE */ Cldfb_RealBuffer64_fx[k][buf_idx][l] = W_mult0_32_32( g, ( *( p_power_smooth++ ) ) ); // (gains_dir_prev_q, q_proto_direct_buffer) -> gains_dir_prev_q + q_proto_direct_buffer move64(); @@ -2717,7 +2760,12 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( { FOR( l = 0; l < h_dirac_output_synthesis_params->max_band_decorr; l++ ) { - g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q +#ifdef OPT_SBA_REND_V1_BE + g = Madd_32_32( Mpy_32_32( g1, *( p_gain_1++ ) ), g2, *( p_gain_2++ ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q +#else /* OPT_SBA_REND_V1_BE */ + g = L_add( Mpy_32_32( g1, *( p_gain_1++ ) ), Mpy_32_32( g2, *( p_gain_2++ ) ) ); // (Q31, gains_diff_prev_q) -> gains_diff_prev_q + +#endif /* OPT_SBA_REND_V1_BE */ Cldfb_RealBuffer64_fx[k][buf_idx][l] = W_add( Cldfb_RealBuffer64_fx[k][buf_idx][l], W_shr( W_mult0_32_32( g, ( *( p_power_smooth_diff++ ) ) ), negate( q_align ) ) ); // (gains_diff_prev_q, q_proto_direct_buffer) -> gains_diff_prev_q + q_proto_direct_buffer move64(); @@ -2766,16 +2814,27 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( } } q_align = W_norm( W_temp ); +#ifdef OPT_SBA_REND_V1_BE + Word16 shift = sub( q_align, 32 ); +#endif /* OPT_SBA_REND_V1_BE */ + FOR( buf_idx = 0; buf_idx < nbslots; ++buf_idx ) { FOR( k = 0; k < nchan_out_woLFE; k++ ) { FOR( l = 0; l < num_freq_bands; l++ ) { +#ifdef OPT_SBA_REND_V1_BE + RealBuffer[k][buf_idx][l] = W_shl_sat_l( Cldfb_RealBuffer64_fx[k][buf_idx][l], shift ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ + move32(); + ImagBuffer[k][buf_idx][l] = W_shl_sat_l( Cldfb_ImagBuffer64_fx[k][buf_idx][l], shift ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ + move32(); +#else /* OPT_SBA_REND_V1_BE */ RealBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_RealBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ move32(); ImagBuffer[k][buf_idx][l] = W_extract_h( W_shl( Cldfb_ImagBuffer64_fx[k][buf_idx][l], q_align ) ); /*( ( ( h_dirac_output_synthesis_state->proto_direct_buffer_f_q+h_dirac_output_synthesis_state->gains_dir_prev_q )+ q_align )- 32 )*/ move32(); +#endif /* OPT_SBA_REND_V1_BE */ } } } diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 99a84bf52..155524790 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -3155,7 +3155,11 @@ void protoSignalComputation4_fx( sq_tmp_fx = Madd_32_32( Mpy_32_32( proto_frame_f_fx[idx], proto_frame_f_fx[idx] ), proto_frame_f_fx[idx + 1], proto_frame_f_fx[idx + 1] ); // 2*(proto_frame_f_q)-31 sq_tmp_q = sub( add( *proto_frame_f_q, *proto_frame_f_q ), 31 ); +#ifdef OPT_SBA_REND_V1_BE + proto_power_smooth_fx_q = s_min( *proto_power_smooth_q, sq_tmp_q ); + proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( L_shr( proto_power_smooth_fx[l + ( k * num_freq_bands )], sub( *proto_power_smooth_q, proto_power_smooth_fx_q ) ), L_shr( sq_tmp_fx, sub( sq_tmp_q, proto_power_smooth_fx_q ) ) ); // proto_power_smooth_fx_q +#else /* OPT_SBA_REND_V1_BE */ IF( LT_16( *proto_power_smooth_q, sq_tmp_q ) ) { proto_power_smooth_fx[l + ( k * num_freq_bands )] = L_add( proto_power_smooth_fx[l + ( k * num_freq_bands )], L_shr( sq_tmp_fx, sub( sq_tmp_q, *proto_power_smooth_q ) ) ); // proto_power_smooth_q @@ -3170,8 +3174,8 @@ void protoSignalComputation4_fx( proto_power_smooth_fx_q = sq_tmp_q; move16(); } - - p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; // proto_frame_f_q +#endif /* OPT_SBA_REND_V1_BE */ + p_proto_buffer_fx[idx] = proto_frame_f_fx[idx]; // proto_frame_f_q move32(); p_proto_buffer_fx[idx + 1] = proto_frame_f_fx[idx + 1]; // proto_frame_f_q move32(); diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index fbcfdfe77..2ac397e2c 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -1528,7 +1528,7 @@ static void get_poly_gains_fx( #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*/ + 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 ) @@ -1585,7 +1585,7 @@ static Word32 get_tri_gain_fx( #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 + v_sub_fixed( B, A, tmpSub1, 2, 0 ); // tmpSub1 q22 #endif /* VEC_ARITH_OPT_v1 */ tmpDot1 = dotp_fixed( tmpN, tmpSub1, 2 ); // Q13 @@ -2248,7 +2248,7 @@ static void sort_channels_vertex_fx( #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 + v_sub_fixed( tmpV1, tmpV2, tmpV3, 3, 0 ); // tmpV3 Q30 #endif /* VEC_ARITH_OPT_v1 */ Word16 exp2 = 2; move16(); @@ -2434,7 +2434,7 @@ static Word16 in_poly_fx( /* Angles are in Q22 */ #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*/ + 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 ) @@ -2508,12 +2508,16 @@ static Word16 in_tri_fx( 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 + 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 + invFactor = Msub_32_32( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), tmpDot1[1], tmpDot2[0] ); /*q22+q22-q31->q13*/ +#else /* OPT_SBA_REND_V1_BE */ invFactor = L_sub( Mpy_32_32( tmpDot1[0], tmpDot2[1] ), Mpy_32_32( tmpDot1[1], tmpDot2[0] ) ); /*q22+q22-q31->q13*/ +#endif /* OPT_SBA_REND_V1_BE */ IF( invFactor == 0 ) { diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index 7495953e3..cfcbc6760 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -578,7 +578,11 @@ void vbap_determine_gains_fx( move32(); FOR( ch = 0; ch < 3; ch++ ) { +#ifdef OPT_SBA_REND_V1_BE + gain_ene_fx = Madd_32_32( gain_ene_fx, gain_triplet_fx[ch], gain_triplet_fx[ch] ); /* Q(2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31) */ +#else /* OPT_SBA_REND_V1_BE */ gain_ene_fx = L_add( gain_ene_fx, Mpy_32_32( gain_triplet_fx[ch], gain_triplet_fx[ch] ) ); /* Q(2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31) */ +#endif /* OPT_SBA_REND_V1_BE */ } norm_value_fx = Isqrt( L_shr( gain_ene_fx, 1 ) ); /* Q(31 - (2 * VBAP_VS_TRIPLET.q_inverse_matrix - 31 - 1) / 2 ) = Q(47 - VBAP_VS_TRIPLET.q_inverse_matrix) */ @@ -681,9 +685,35 @@ static UWord8 vector_matrix_multiply_3x3_fx( Word32 *result, /* o : output vector Q(q_matrix) */ Word16 q_matrix ) { - result[0] = Mpy_32_16_1( matrix[0][0], src_vector[0] ); /* Q(q_matrix) */ - result[0] = L_add( result[0], Mpy_32_16_1( matrix[1][0], src_vector[1] ) ); /* Q(q_matrix) */ - result[0] = L_add( result[0], Mpy_32_16_1( matrix[2][0], src_vector[2] ) ); /* Q(q_matrix) */ +#ifdef OPT_SBA_REND_V1_BE + Word32 pointzero_one = Mpy_32_16_1( L_lshl( 1, q_matrix ), -327 /* -0.01 in Q15 */ ); + result[0] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][0], src_vector[0] ), matrix[1][0], src_vector[1] ), matrix[2][0], src_vector[2] ); /* Q(q_matrix) */ + move32(); + + IF( LT_32( result[0], pointzero_one ) ) + { + return 0; + } + + result[1] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][1], src_vector[0] ), matrix[1][1], src_vector[1] ), matrix[2][1], src_vector[2] ); /* Q(q_matrix) */ + move32(); + + IF( LT_32( result[1], pointzero_one ) ) + { + return 0; + } + + result[2] = Madd_32_16( Madd_32_16( Mpy_32_16_1( matrix[0][2], src_vector[0] ), matrix[1][2], src_vector[1] ), matrix[2][2], src_vector[2] ); /* Q(q_matrix) */ + move32(); + + IF( LT_32( result[2], pointzero_one ) ) + { + return 0; + } +#else /* OPT_SBA_REND_V1_BE */ + result[0] = Mpy_32_16_1( matrix[0][0], src_vector[0] ); /* Q(q_matrix) */ + result[0] = L_add( result[0], Mpy_32_16_1( matrix[1][0], src_vector[1] ) ); /* Q(q_matrix) */ + result[0] = L_add( result[0], Mpy_32_16_1( matrix[2][0], src_vector[2] ) ); /* Q(q_matrix) */ move32(); move32(); move32(); @@ -716,7 +746,7 @@ static UWord8 vector_matrix_multiply_3x3_fx( { return 0; } - +#endif /* OPT_SBA_REND_V1_BE */ return 1; } -- GitLab From ffc393eb77eee1d1ca1f275466c6ed16de5275c2 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 20:19:16 +0530 Subject: [PATCH 287/692] HRTF rend optimization - Bit exact changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes made under macro OPT_HEAD_ROT_REND_V1_BE Function and corresponding WMOPS gain: rotateFrame_shd_cldfb 7.9 Command: ./IVAS_dec -t headrot.csv BINAURAL 48  bit mc.wav --- lib_com/options.h | 1 + lib_rend/ivas_rotation_fx.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7e3799ffc..f734ff624 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -76,6 +76,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define OPT_SBA_REND_V1_BE +#define OPT_HEAD_ROT_REND_V1_BE #define OPT_SBA_ENC_V1_BE #define OPT_BIN_RENDERER_V1 #define OPT_BIN_RENDERER_V2 diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index b9403e7da..d65dab4c1 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1046,7 +1046,9 @@ void rotateFrame_shd_cldfb( Word16 l = 0, m1 = 0, m2 = 0; Word32 realRot[2 * HEADROT_ORDER + 1], imagRot[2 * HEADROT_ORDER + 1]; Word16 SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM]; +#ifndef OPT_HEAD_ROT_REND_V1_BE Word32 temp1, temp2; +#endif /* OPT_HEAD_ROT_REND_V1_BE */ move16(); move16(); move16(); @@ -1095,12 +1097,19 @@ void rotateFrame_shd_cldfb( move32(); FOR( m = m1; m < m2; m++ ) { +#ifdef OPT_HEAD_ROT_REND_V1_BE + realRot[n - m1] = Madd_32_16_r( realRot[n - m1], Cldfb_RealBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15) + move32(); + imagRot[n - m1] = Madd_32_16_r( imagRot[n - m1], Cldfb_ImagBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15) + move32(); +#else /* OPT_HEAD_ROT_REND_V1_BE */ temp1 = Mpy_32_16_r( Cldfb_RealBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15) temp2 = Mpy_32_16_r( Cldfb_ImagBuffer[m][i][iBand], SHrotmat[n][m] ); // Q(x + 14 - 15) realRot[n - m1] = L_add( temp1, realRot[n - m1] ); // Q(x + 14 - 15) move32(); imagRot[n - m1] = L_add( temp2, imagRot[n - m1] ); // Q(x + 14 - 15) move32(); +#endif /* OPT_HEAD_ROT_REND_V1_BE */ } } /* write back the result */ -- GitLab From d9019ae9e1e6224c9ff322d916e18879bd5430c7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 13 Jun 2025 21:05:19 +0530 Subject: [PATCH 288/692] SBA dec path optimization - Bit Exact changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes are made under macro OPT_SBA_DEC_V2_BE Functions and corresponding WMOPS improvements: ivas_spar_get_parameters_fx 0.4 Commands: ./IVAS_cod -sba 1 256000 48 scripts/testv/stvFOA48c.wav bit_sba  ./IVAS_dec 7_1 48 bit_sba sba.wav   --- lib_com/options.h | 1 + lib_dec/dec_tcx_fx.c | 21 +++++++ lib_dec/ivas_binRenderer_internal_fx.c | 15 +++++ lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 10 ++- lib_dec/ivas_spar_decoder_fx.c | 65 +++++++++++++++++++- lib_dec/ivas_spar_md_dec_fx.c | 13 ++++ 6 files changed, 123 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f734ff624..8bbd89e87 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_SBA_REND_V1_BE #define OPT_HEAD_ROT_REND_V1_BE +#define OPT_SBA_DEC_V2_BE #define OPT_SBA_ENC_V1_BE #define OPT_BIN_RENDERER_V1 #define OPT_BIN_RENDERER_V2 diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index b9084df88..8e8a2b343 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -2634,9 +2634,16 @@ void IMDCT_ivas_fx( Word32 fac; // fac = shl_sat( mult_r( extract_h( L_shr_sat( hTcxDec->conceal_eof_gain32, sub( 1, hTcxDec->conceal_eof_gain_e ) ) ), st->last_concealed_gain_syn_deemph ), 1 ); fac = Mpy_32_16_1( hTcxDec->conceal_eof_gain32, st->last_concealed_gain_syn_deemph ); // q = 31 - hTcxDec->conceal_eof_gain_e - last_concealed_gain_syn_deemph_e +#ifdef OPT_SBA_DEC_V2_BE + Word16 eff_e = add( hTcxDec->conceal_eof_gain_e, st->last_concealed_gain_syn_deemph_e ); +#endif /* OPT_SBA_DEC_V2_BE */ FOR( Word16 ind = 0; ind < overlap; ind++ ) { +#ifdef OPT_SBA_DEC_V2_BE + old_syn_overl_fx[ind] = extract_h( L_shl_sat( Mpy_32_16_1( fac, old_syn_overl_fx[ind] ), eff_e ) ); // Q(-2) +#else /* OPT_SBA_DEC_V2_BE */ old_syn_overl_fx[ind] = extract_h( L_shl_sat( Mpy_32_16_1( fac, old_syn_overl_fx[ind] ), add( hTcxDec->conceal_eof_gain_e, st->last_concealed_gain_syn_deemph_e ) ) ); // Q(-2) +#endif /* OPT_SBA_DEC_V2_BE */ move16(); } } @@ -4713,9 +4720,16 @@ void decoder_tcx_noiseshaping_igf_fx( { /* If the exponent on the spec side (i>L_frame) is lesser, then shift all the values in the spec side by the difference to make both sides have the same exponent. */ +#ifdef OPT_SBA_DEC_V2_BE + Word16 diff_e = sub( frame_side_x_e, spec_side_x_e ); +#endif /* OPT_SBA_DEC_V2_BE */ FOR( i = L_frame; i < L_spec; i++ ) { +#ifdef OPT_SBA_DEC_V2_BE + x_fx[i] = L_shr( x_fx[i], diff_e ); +#else /* OPT_SBA_DEC_V2_BE */ x_fx[i] = L_shr( x_fx[i], sub( frame_side_x_e, spec_side_x_e ) ); +#endif /* OPT_SBA_DEC_V2_BE */ move32(); } } @@ -4723,9 +4737,16 @@ void decoder_tcx_noiseshaping_igf_fx( { /* If the exponent on the spec side (i>L_frame) is greater, then shift all the values in the frame side (iconv_band ); + + FOR( k = 0; k < numTimeSlots; k++ ) + { + set32_fx( &Cldfb_RealBuffer_Binaural_fx[0][k][hBinRenderer->conv_band], 0, len ); + set32_fx( &Cldfb_RealBuffer_Binaural_fx[1][k][hBinRenderer->conv_band], 0, len ); + set32_fx( &Cldfb_ImagBuffer_Binaural_fx[0][k][hBinRenderer->conv_band], 0, len ); + set32_fx( &Cldfb_ImagBuffer_Binaural_fx[1][k][hBinRenderer->conv_band], 0, len ); + } +#endif /* OPT_SBA_DEC_V2_BE */ + pop_wmops(); return; } diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index caddb5c5c..598f90829 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -605,8 +605,11 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( #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 + 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_BE */ FOR( ch_idx = 0; ch_idx < nY; ch_idx++ ) { int i; @@ -625,8 +628,13 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( temp_imag = W_add( temp_imag, W_mult0_32_32( mixing_matrix_res_smooth_fx[idx], diff_f_imag_fx[i] ) ); idx += nY; } +#ifdef OPT_SBA_DEC_V2_BE + Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_real, shifter ); + Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_shl_sat_l( temp_imag, shifter ); +#else /* OPT_SBA_DEC_V2_BE */ Cldfb_RealBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_real, shifter ) ); Cldfb_ImagBuffer_fx[ch_idx][slot_idx_sfr][band] = W_extract_l( W_shr( temp_imag, shifter ) ); +#endif /* OPT_SBA_DEC_V2_BE */ } } diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 29a307425..fa5f6779f 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1163,6 +1163,69 @@ void ivas_spar_get_parameters_fx( move16(); Word16 add_weight_fx = sub( MAX_WORD16, weight_fx ); Word16 add_weight_20ms_fx = sub( MAX_WORD16, weight_20ms_fx ); +#ifdef OPT_SBA_DEC_V2_BE + Word16 out_flag[IVAS_MAX_FB_MIXER_OUT_CH]; + + Word32 band_bool = LT_16( split_band, IVAS_MAX_NUM_BANDS ); + + FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ ) + { + /* 20ms cross-fade for Transport channels in all frequency bands */ + /* sub-frame processing for missing channels in all frequency bands*/ + out_flag[out_ch] = band_bool && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) ); + move16(); + } + Word32 frame_bool = GT_16( hSpar->i_subframe, 3 ); + + FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ ) + { + IF( out_flag[out_ch] ) + { + IF( frame_bool ) + { + FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) + { + FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { + par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ), + hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], add_weight_fx ); + move32(); + } + } + } + ELSE + { + + + FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) + { + FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { + { + par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band]; /*hSpar->hMdDec->Q_mixer_mat*/ + move32(); + } + } + } + } + } + ELSE + { + FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) + { + FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ ) + { + /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ + Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + move16(); + par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], add_weight_20ms_fx ), + hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ); /*hSpar->hMdDec->Q_mixer_mat*/ + move32(); + } + } + } + } +#else /* OPT_SBA_DEC_V2_BE */ FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ ) { FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ ) @@ -1202,7 +1265,7 @@ void ivas_spar_get_parameters_fx( } } } - +#endif /* OPT_SBA_DEC_V2_BE */ return; } diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 7f487a75c..36b77732a 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -1318,6 +1318,14 @@ static void ivas_get_spar_matrices_fx( tmp_C2_re_fx[0][j] = Mpy_32_32( active_w_dm_fac_fx, L_negate( hMdDec->spar_md.band_coeffs[( b + ( i_ts * IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j - 1] ) ); // Q31 *Q22=Q22 move32(); } +#ifdef OPT_SBA_DEC_V2_BE + re_fx1 = Madd_32_32( ONE_IN_Q13, tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q13+Q13 + + re_fx1 = Madd_32_32( re_fx1, tmp_C2_re_fx[0][2], tmp_C1_re_fx[2][0] ); // Q13+Q13 + + tmp_dm_re_fx[0][0] = L_shl( Madd_32_32( re_fx1, tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ), Q9 ); // (Q13+Q13) << Q9 = Q22; + // +#else /* OPT_SBA_DEC_V2_BE */ re_fx = Mpy_32_32( tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q22 *Q22 =Q13 re_fx1 = L_add( ONE_IN_Q13, re_fx ); // Q13+Q13 @@ -1326,6 +1334,7 @@ static void ivas_get_spar_matrices_fx( re_fx = Mpy_32_32( tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ); // Q22 *Q22 =Q13 tmp_dm_re_fx[0][0] = L_shl( L_add( re_fx1, re_fx ), Q9 ); // (Q13+Q13) << Q9 = Q22; +#endif /* OPT_SBA_DEC_V2_BE */ move32(); IF( EQ_16( dyn_active_w_flag, 1 ) ) @@ -1401,7 +1410,11 @@ static void ivas_get_spar_matrices_fx( { FOR( k = dmx_ch; k < numch_out; k++ ) { +#ifndef OPT_SBA_DEC_V2_BE IF( EQ_16( sub( j, dmx_ch ), sub( k, dmx_ch ) ) ) +#else /* OPT_SBA_DEC_V2_BE */ + IF( EQ_16( j, k ) ) +#endif /* OPT_SBA_DEC_V2_BE */ { tmpP_re_fx[j][k] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[sub( k, dmx_ch )]; // Q22 move32(); -- GitLab From df97c617fb4859bbee367cbf1ed1fc63a6f23a3f Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 13 Jun 2025 20:08:58 +0200 Subject: [PATCH 289/692] 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 4179ea850e4bc1837b2b825af89899f088482758 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 13 Jun 2025 20:51:26 +0200 Subject: [PATCH 290/692] formatting --- lib_com/ivas_dirac_com_fx.c | 4 +--- lib_dec/ivas_dirac_dec_fx.c | 9 ++++++++- lib_dec/ivas_ism_dec_fx.c | 16 +++++----------- lib_dec/ivas_jbm_dec_fx.c | 10 +++++----- lib_dec/ivas_objectRenderer_internal_fx.c | 6 +----- lib_dec/ivas_sba_dec_fx.c | 8 +++----- lib_enc/ivas_enc_fx.c | 6 ++---- lib_enc/ivas_ism_enc_fx.c | 4 ++-- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 18 +++++++++--------- 10 files changed, 37 insertions(+), 46 deletions(-) diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index 0c913499b..017181d07 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -179,9 +179,7 @@ ivas_error ivas_dirac_config_fx( test(); IF( EQ_32( ivas_format, SBA_FORMAT ) || EQ_32( ivas_format, SBA_ISM_FORMAT ) ) /* skip for MASA decoder */ { - IF( NE_32( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, sub( hConfig->nbands, spar_dirac_split_band ), - ivas_format ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_sba_config_fx( hQMetaData, element_mode, ivas_total_brate, sba_order, sub( hConfig->nbands, spar_dirac_split_band ), ivas_format ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 8ac4fadf0..e3b32d3fc 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -798,8 +798,10 @@ static ivas_error ivas_dirac_rend_config_fx( nchan_transport_tmp = nchan_transport; move16(); } + /* close and reopen the decorrelator */ ivas_dirac_dec_decorr_close_fx( &hDirACRend->h_freq_domain_decorr_ap_params, &hDirACRend->h_freq_domain_decorr_ap_state ); + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( hDirACRend->h_freq_domain_decorr_ap_params ), &( hDirACRend->h_freq_domain_decorr_ap_state ), hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff, hDirACRend->num_protos_diff, hDirACRend->synthesisConf, hDirACRend->frequency_axis_fx, nchan_transport_tmp, output_Fs ) ), IVAS_ERR_OK ) ) @@ -1102,12 +1104,14 @@ ivas_error ivas_dirac_dec_config_fx( common_rend_config_flag = flag_config_inp; move32(); } + IF( NE_32( ( error = ivas_spat_hSpatParamRendCom_config_fx( &st_ivas->hSpatParamRendCom, common_rend_config_flag, dec_param_estim_new, st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, hodirac_flag, 0 ) ), IVAS_ERR_OK ) ) { return error; } + IF( need_dirac_rend ) { IF( st_ivas->hDirACRend == NULL ) @@ -1167,13 +1171,15 @@ ivas_error ivas_dirac_dec_config_fx( { st_ivas->hDiracDecBin[pos_idx]->useTdDecorr = st_ivas->hDiracDecBin[0]->useTdDecorr; } - IF( !st_ivas->hDiracDecBin[0]->useTdDecorr ) + IF( !st_ivas->hDiracDecBin[0]->useTdDecorr ) { IF( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params == NULL ) { Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; + ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, st_ivas->hDecoderConfig->output_Fs, st_ivas->hSpatParamRendCom->num_freq_bands ); + IF( NE_32( ( error = ivas_dirac_dec_decorr_open_fx( &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_params ), &( st_ivas->hDiracDecBin[0]->h_freq_domain_decorr_ap_state ), st_ivas->hSpatParamRendCom->num_freq_bands, BINAURAL_CHANNELS, BINAURAL_CHANNELS, DIRAC_SYNTHESIS_PSD_LS, frequency_axis_fx, BINAURAL_CHANNELS, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) @@ -1182,6 +1188,7 @@ ivas_error ivas_dirac_dec_config_fx( } } } + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) { st_ivas->hDiracDecBin[pos_idx]->reqularizationFactor_fx = configure_reqularization_factor_fx( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 13e888af3..727a0a651 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -454,16 +454,12 @@ ivas_error ivas_ism_dec_config_fx( IF( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ + test(); + IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) ) { - test(); - IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) ) + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { - IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, - data ) ), - IVAS_ERR_OK ) ) - { - return error; - } + return error; } } } @@ -486,9 +482,7 @@ ivas_error ivas_ism_dec_config_fx( /* ISM mode switching */ IF( NE_32( st_ivas->ism_mode, last_ism_mode ) ) { - IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, - data ) ), - IVAS_ERR_OK ) ) + IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c21f182da..c7863bb98 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2266,17 +2266,16 @@ ivas_error ivas_jbm_dec_render_fx( } } - if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, - &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } } - else + ELSE { - 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, &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ), IVAS_ERR_OK ) ) @@ -2699,6 +2698,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; + move16(); IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL, NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ), diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 9c603fa93..08bf0f437 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -227,11 +227,7 @@ ivas_error ivas_td_binaural_renderer_sf_fx( move16(); } - IF( NE_32( ( error = TDREND_Update_listener_orientation_fx( st_ivas->hBinRendererTd, - enableCombinedOrientation, - tmp_Quaternion_fx, - tmp_vector_fx ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = TDREND_Update_listener_orientation_fx( st_ivas->hBinRendererTd, enableCombinedOrientation, tmp_Quaternion_fx, tmp_vector_fx ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 8f8a7f486..687991c89 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -411,7 +411,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( IF( st_ivas->hBinRenderer == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) ) { /* open fastconv binaural renderer */ - if ( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_binRenderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -423,7 +423,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( IF( EQ_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && st_ivas->hMonoDmxRenderer == NULL ) { - if ( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_mono_dmx_renderer_open( st_ivas ) ), IVAS_ERR_OK ) ) { return error; } @@ -434,9 +434,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer ); } - if ( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), - st_ivas->ivas_format ) ), - IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_dirac_sba_config_fx( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ), st_ivas->ivas_format ) ), IVAS_ERR_OK ) ) { return error; } diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index 56299c69d..11368cec8 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -255,8 +255,7 @@ ivas_error ivas_enc_fx( ELSE { IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, hEncoderConfig->Opt_DTX_ON, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != - IVAS_ERR_OK ) + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; } @@ -648,8 +647,7 @@ ivas_error ivas_enc_fx( } IF( ( error = ivas_masa_encode_fx( st_ivas->hMasa, st_ivas->hQMetaData, hMetaData, &nb_bits_metadata[0], st_ivas->nchan_transport, ivas_format, ivas_total_brate, 0, -1, - ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != - IVAS_ERR_OK ) + ISM_MODE_NONE, -1, NULL, -1, NULL, 0, 0 ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_enc/ivas_ism_enc_fx.c b/lib_enc/ivas_ism_enc_fx.c index 122ea1d75..3e7d8afcd 100644 --- a/lib_enc/ivas_ism_enc_fx.c +++ b/lib_enc/ivas_ism_enc_fx.c @@ -360,9 +360,9 @@ ivas_error ivas_ism_enc_fx( { omasa_stereo_sw_cnt = NULL; } + IF( ( error = ivas_ism_metadata_enc_fx( &ism_total_brate, nchan_ism, nchan_transport_ism, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, - nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, lp_noise_CPE_fx, flag_omasa_ener_brate, omasa_stereo_sw_cnt, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != - IVAS_ERR_OK ) + nb_bits_metadata, vad_flag, st_ivas->ism_mode, NULL, st_ivas->hEncoderConfig->ism_extended_metadata_flag, lp_noise_CPE_fx, flag_omasa_ener_brate, omasa_stereo_sw_cnt, st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index da2c3cce9..9eea08c71 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -931,13 +931,13 @@ ivas_error ivas_td_binaural_renderer_ext_fx( } } - IF( NE_32( ( error = ivas_td_binaural_renderer_unwrap_fx( hReverb, transport_config, pTDRend->hBinRendererTd, num_src, lfe_idx, ivas_format, hIsmMetaData, *hCombinedOrientationData, ism_md_subframe_update_ext, p_output_fx, output_frame, num_subframes ) ), IVAS_ERR_OK ) ) { return error; } + IF( hReverb != NULL ) { *exp = sub( *exp, 2 ); diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 74c2a0c0a..b5da38708 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2555,17 +2555,15 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( /* THIS PART IS YET TO BE CONVERTED AS REVERB_UTILS.C IS NOT INVOKED IN GPROF */ float t60_flt[CLDFB_NO_CHANNELS_MAX]; float ene_flt[CLDFB_NO_CHANNELS_MAX]; + revTimes = t60; revEne = ene; - if ( NE_32( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, - hHrtfFastConv, - internal_config, - false, - sampling_rate, t60_flt, ene_flt ) ), - IVAS_ERR_OK ) ) + + IF( NE_32( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, internal_config, false, sampling_rate, t60_flt, ene_flt ) ), IVAS_ERR_OK ) ) { return error; } + preDelay = (Word16) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); floatToFixed_arrL( t60_flt, t60, Q31, CLDFB_NO_CHANNELS_MAX ); floatToFixed_arrL( ene_flt, ene, Q31, CLDFB_NO_CHANNELS_MAX ); @@ -2583,17 +2581,19 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( return error; } + /*------------------------------------------------------------------------- * ivas_binaural_reverb_open_parambin() * * Allocate and initialize binaural room reverberator handle for ParamBin *------------------------------------------------------------------------*/ + ivas_error ivas_binaural_reverb_open_parambin( REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const Word16 numBins, /* i : number of CLDFB bins Q0 */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ + const Word16 numBins, /* i : number of CLDFB bins Q0 */ + const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate Q0 */ + const Word32 sampling_rate, /* i : sampling rate Q0 */ const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ ) { -- GitLab From 7d3d159591efe93ed88799a3137b5ea66f11d472 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 12 Jun 2025 09:58:12 +0530 Subject: [PATCH 291/692] 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 292/692] 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 293/692] 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 294/692] 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 295/692] 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 296/692] 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 297/692] 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 298/692] 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 299/692] 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 300/692] 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 301/692] 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 302/692] 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 303/692] 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 304/692] 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 305/692] 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 306/692] 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 307/692] 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 308/692] 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 309/692] 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 310/692] 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 311/692] 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 312/692] 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 313/692] 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 314/692] 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 315/692] 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 316/692] 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 cc34b55998423602810bcbf1a79aa3a3e39b1ae6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 17 Jun 2025 09:52:33 +0200 Subject: [PATCH 317/692] Change ivas-basop-linux to ivas-linux to avoid taking runners allocated to main --- .gitlab-ci.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e35d0e290..6efbc33bf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1052,7 +1052,7 @@ branch-is-up-to-date-with-target-pre: stage: prevalidate needs: [] tags: - - ivas-basop-linux + - ivas-linux script: - *get-commits-behind-count - echo $commits_behind_count @@ -1067,7 +1067,7 @@ branch-is-up-to-date-with-target-post: - .rules-merge-request-to-main-pc stage: postvalidate tags: - - ivas-basop-linux + - ivas-linux script: - *get-commits-behind-count - echo $commits_behind_count @@ -1097,7 +1097,7 @@ check-naming-of-branch-for-main-pc-merges: - .rules-merge-request-to-main-pc stage: prevalidate tags: - - ivas-basop-linux + - ivas-linux script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then @@ -1114,7 +1114,7 @@ branch-is-up-to-date-with-target-pre: stage: prevalidate needs: [] tags: - - ivas-basop-linux + - ivas-linux script: - *get-commits-behind-count - | @@ -1128,7 +1128,7 @@ branch-is-up-to-date-with-target-post: - .rules-merge-request stage: postvalidate tags: - - ivas-basop-linux + - ivas-linux script: - *get-commits-behind-count - | @@ -1150,7 +1150,7 @@ clang-format-check: ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" stage: prevalidate tags: - - ivas-basop-linux + - ivas-linux needs: [] timeout: "5 minutes" script: @@ -1233,7 +1233,7 @@ build-codec-linux-make: extends: - .build-job-linux tags: - - ivas-basop-linux + - ivas-linux timeout: "10 minutes" script: - *print-common-info @@ -1251,7 +1251,7 @@ build-codec-linux-cmake: extends: - .build-job-linux tags: - - ivas-basop-linux + - ivas-linux timeout: "10 minutes" script: - *print-common-info @@ -1272,7 +1272,7 @@ build-codec-linux-instrumented-make: - .build-job-linux timeout: "10 minutes" tags: - - ivas-basop-linux + - ivas-linux script: - *print-common-info - *update-scripts-repo @@ -1286,7 +1286,7 @@ build-codec-sanitizers-linux: - .build-job-linux - .rules-basis tags: - - ivas-basop-linux + - ivas-linux timeout: "10 minutes" script: - *update-scripts-repo @@ -1703,7 +1703,7 @@ ivas-pytest-enc-msan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1714,7 +1714,7 @@ ivas-pytest-enc-asan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=2 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1725,7 +1725,7 @@ ivas-pytest-enc-usan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1793,7 +1793,7 @@ ivas-pytest-dec-msan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1804,7 +1804,7 @@ ivas-pytest-dec-asan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=2 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1815,7 +1815,7 @@ ivas-pytest-dec-usan: extends: - .test-job-linux tags: - - ivas-basop-linux-fast + - ivas-linux-fast before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -2095,7 +2095,7 @@ voip-be-on-merge-request: - .rules-merge-request-no-draft timeout: "20 minutes" tags: - - ivas-basop-linux + - ivas-linux stage: test needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] script: @@ -2129,7 +2129,7 @@ renderer-pytest-on-merge-request: # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" tags: - - ivas-basop-linux + - ivas-linux stage: compare script: - *print-common-info @@ -2189,7 +2189,7 @@ ivas-pytest-on-merge-request: needs: ["build-codec-linux-make"] #, "codec-smoke-test"] timeout: "40 minutes" tags: - - ivas-basop-linux + - ivas-linux script: - *print-common-info - *get-commits-behind-count @@ -2682,7 +2682,7 @@ complexity-osba-in-binaural_room_ir-out: pages: stage: deploy tags: - - ivas-basop-linux + - ivas-linux rules: - if: $UPDATE_PAGES script: -- GitLab From ae57ace8debbfb3d25e1c45045a2fa79037285a2 Mon Sep 17 00:00:00 2001 From: malenov Date: Tue, 17 Jun 2025 11:05:24 +0200 Subject: [PATCH 318/692] 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 319/692] 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 320/692] 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 321/692] 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 322/692] 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 323/692] 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 324/692] 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 325/692] 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 326/692] 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 327/692] 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 feae45bed0fc4cfdbf964b2ff54154b54fdb71eb Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 18 Jun 2025 07:09:30 +0200 Subject: [PATCH 328/692] Clean up switches --- lib_com/options.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index edc3cbe10..31a1eae51 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,19 +113,14 @@ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ -#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT -#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ +//#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #define NONBE_FIX_AVG_IAC_CLDFB_REVERB -#endif -#define FIX_OLD_BINARY_FORMAT /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/ -#define FIX_OLD_BINARY_FILE /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/ +//#define FIX_OLD_BINARY_FORMAT /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/ +//#define FIX_OLD_BINARY_FILE /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ -#endif - //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define FIX_944_REMOVE_LS_RENDERER_CALL_IN_STEREO /* VA: issue 994: remove an obsolete call of function ivas_ls_setup_conversion() in stereo */ #define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ -- GitLab From 40543cfecfd5f2b2d816eec6739ec5fafcd10e73 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 07:23:45 +0200 Subject: [PATCH 329/692] 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 330/692] 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 f42ce80b6108c2dc3636da2c0d64be049fb5afa2 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Wed, 18 Jun 2025 08:10:27 +0200 Subject: [PATCH 331/692] Temporarily disable HRTF model from file tests --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c73c057c6..0df727291 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -693,11 +693,11 @@ stages: - *check-up-to-date-in-comparison-jobs - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -k "not model" > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout -k "not model" > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -2214,7 +2214,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -2222,7 +2222,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From 7ed09264fd00973fe5d3b44b11581746319a5fa2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 18 Jun 2025 06:14:02 +0000 Subject: [PATCH 332/692] 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 333/692] 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 334/692] 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 335/692] 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 336/692] 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 fedc78528f2b7e6081e7e83a406ca28bdfda7f95 Mon Sep 17 00:00:00 2001 From: Arnaud Lefort Date: Wed, 18 Jun 2025 12:40:15 +0200 Subject: [PATCH 337/692] Compilation warnings removed. --- lib_enc/ivas_stereo_dmx_evs_fx.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 8e960d71e..e2500aeef 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -108,9 +108,9 @@ #define STEREO_DMX_EVS_SGC_GIR_S 32617 // 1/1.00461543f #define STEREO_DMX_EVS_SGC_GL 32391 // 0.9885f #define STEREO_DMX_EVS_SGC_GH 33148 // 1.0116f -#define STEREO_DMX_EVS_SGC_LEGY_THRES_16 2.5E8 -#define STEREO_DMX_EVS_SGC_LEGY_THRES_32 3.E8 -#define STEREO_DMX_EVS_SGC_LEGY_THRES_48 5.E8 +#define STEREO_DMX_EVS_SGC_LEGY_THRES_16 250000000 +#define STEREO_DMX_EVS_SGC_LEGY_THRES_32 300000000 +#define STEREO_DMX_EVS_SGC_LEGY_THRES_48 500000000 #define STEREO_DMX_EVS_SGC_LEGY_THRES_E 22 #define STEREO_DMX_EVS_SGC_GMAX 46340 // 1.4142f #define STEREO_DMX_EVS_SGC_GMIN 23170 // 0.7071f @@ -2116,7 +2116,8 @@ static void apply_gain_sgc( } W_tmp = W_mult_32_32( *gain, lr ); - *gain = W_shr( W_tmp, 16 ); + W_tmp = W_shr( W_tmp, 16 ); + *gain = W_extract_l( W_tmp ); return; } @@ -2634,11 +2635,9 @@ void stereo_dmx_evs_enc_fx( } Copy_Scale_sig32_16( p_dmx_data, data, n_samples, 5 ); // Q26->Q15 - pop_wmops(); pop_wmops(); - return; } -- GitLab From 54d86d4ed995b750a84dc5b2fa33c556305ca12c Mon Sep 17 00:00:00 2001 From: rtyag Date: Wed, 18 Jun 2025 20:52:04 +1000 Subject: [PATCH 338/692] 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 339/692] 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 340/692] 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 341/692] 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 342/692] 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 343/692] 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 6f2d744f1a96901fd95c3200cd338ad65b43c495 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:34:55 +0200 Subject: [PATCH 344/692] Fixed memory allocation errors for Binaural Room Reverb cases --- .gitlab-ci.yml | 8 ++++---- lib_rend/ivas_reverb_fx.c | 10 ++++++---- lib_rend/ivas_reverb_utils_fx.c | 34 ++++++++++++++++----------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0df727291..c73c057c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -693,11 +693,11 @@ stages: - *check-up-to-date-in-comparison-jobs - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -k "not model" > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout -k "not model" > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -2214,7 +2214,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -2222,7 +2222,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index deb2d3285..00513d30e 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2520,16 +2520,18 @@ ivas_error ivas_binaural_reverb_init( { float t60_temp[CLDFB_NO_CHANNELS_MAX]; float ene_temp[CLDFB_NO_CHANNELS_MAX]; + + revTimes = t60; + revEne = ene; + if ( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfStatistics, sampling_rate, t60_temp, ene_temp ) ) != IVAS_ERR_OK ) { return error; } - floatToFixed_arrL32( t60_temp, t60, Q15, CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL32( ene_temp, ene, Q15, CLDFB_NO_CHANNELS_MAX ); - revTimes = t60; - revEne = ene; preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( t60_temp, t60, Q31, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( ene_temp, ene, Q31, CLDFB_NO_CHANNELS_MAX ); } else { diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 75cc4b816..7f8659a8c 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -110,20 +110,20 @@ ivas_error ivas_reverb_prepare_cldfb_params( { fc[idx] = ( idx + 0.5f ) * ( MAX_SAMPLING_RATE / ( 2 * CLDFB_NO_CHANNELS_MAX ) ); } - Word32 *fc_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 * ) ); - Word32 *pOutput_t60_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 * ) ); - Word16 *pOutput_t60_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 * ) ); - Word32 *pOutput_ene_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 * ) ); - Word16 *pOutput_ene_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 * ) ); + Word32 *pOutput_fc_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); + Word32 *pOutput_t60_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); + Word16 *pOutput_t60_e = (Word16 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ) ); + Word32 *pOutput_ene_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); + Word16 *pOutput_ene_e = (Word16 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ) ); Word32 delay_diff_fx; - for ( int i = 0; i < pInput_params->nBands; i++ ) + for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - fc_fx[i] = (Word32) fc[i] * ONE_IN_Q16; + pOutput_fc_fx[i] = (Word32) fc[i] * ONE_IN_Q16; } ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, - CLDFB_NO_CHANNELS_MAX, fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); + CLDFB_NO_CHANNELS_MAX, pOutput_fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); /* adjust DSR for the delay difference */ delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); @@ -134,7 +134,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_t60[i] = (float) fabs( me2f( pOutput_t60_fx[i], pOutput_t60_e[i] ) ); pOutput_ene[i] = (float) fabs( me2f( pOutput_ene_fx[i], pOutput_ene_e[i] ) ); } - free( fc_fx ); + free( pOutput_fc_fx ); free( pOutput_t60_fx ); free( pOutput_t60_e ); free( pOutput_ene_fx ); @@ -336,13 +336,13 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); + Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) ); - Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); - Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); - Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); + Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); + Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 ) ); + Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 ) ); + Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); + Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); for ( int i = 0; i < 60; i++ ) { @@ -357,7 +357,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); - for ( int i = 0; i < 257; i++ ) + for ( int i = 0; i < 60; i++ ) { avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); @@ -368,7 +368,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( avg_pwr_left_e ); free( avg_pwr_right_e ); free( avg_pwr_left_fx ); - free( avg_pwr_left_fx ); + free( avg_pwr_right_fx ); #else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) -- GitLab From 1990fafbcbdca0a389d01a822834db923ea95d74 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:35:19 +0200 Subject: [PATCH 345/692] solved runtime error in binaural room reverb --- lib_rend/ivas_reverb_utils_fx.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 7f8659a8c..ba25686c8 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -110,6 +110,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( { fc[idx] = ( idx + 0.5f ) * ( MAX_SAMPLING_RATE / ( 2 * CLDFB_NO_CHANNELS_MAX ) ); } + Word32 *pOutput_fc_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); Word32 *pOutput_t60_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); Word16 *pOutput_t60_e = (Word16 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ) ); @@ -122,6 +123,19 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_fc_fx[i] = (Word32) fc[i] * ONE_IN_Q16; } + /* + for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) + { + fc[idx] = ( (float) idx + 0.5f ) * ( (float) MAX_SAMPLING_RATE / (float) ( 2 * CLDFB_NO_CHANNELS_MAX ) ); + } + Word32 *pOutput_fc_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); + Word32 *pOutput_t60_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); + Word16 *pOutput_t60_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 ) ); + Word32 *pOutput_ene_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); + Word16 *pOutput_ene_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 ) ); + Word32 delay_diff_fx; + */ + ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, pOutput_fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); @@ -129,7 +143,8 @@ ivas_error ivas_reverb_prepare_cldfb_params( delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); delay_diff = (float) delay_diff_fx / ONE_IN_Q27; - for ( int i = 0; i < pInput_params->nBands; i++ ) + for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + //for ( int i = 0; i < pInput_params->nBands; i++ ) { pOutput_t60[i] = (float) fabs( me2f( pOutput_t60_fx[i], pOutput_t60_e[i] ) ); pOutput_ene[i] = (float) fabs( me2f( pOutput_ene_fx[i], pOutput_ene_e[i] ) ); -- GitLab From 6411fd388feedcf744da94ad356ed80da1f846f8 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:43:02 +0200 Subject: [PATCH 346/692] clang formatting --- lib_rend/ivas_reverb_utils_fx.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index ba25686c8..2df3e22f8 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -123,19 +123,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( pOutput_fc_fx[i] = (Word32) fc[i] * ONE_IN_Q16; } - /* - for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - fc[idx] = ( (float) idx + 0.5f ) * ( (float) MAX_SAMPLING_RATE / (float) ( 2 * CLDFB_NO_CHANNELS_MAX ) ); - } - Word32 *pOutput_fc_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); - Word32 *pOutput_t60_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); - Word16 *pOutput_t60_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 ) ); - Word32 *pOutput_ene_fx = (Word32 *) malloc( pInput_params->nBands * sizeof( Word32 ) ); - Word16 *pOutput_ene_e = (Word16 *) malloc( pInput_params->nBands * sizeof( Word16 ) ); - Word32 delay_diff_fx; - */ - ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, CLDFB_NO_CHANNELS_MAX, pOutput_fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); @@ -144,7 +131,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( delay_diff = (float) delay_diff_fx / ONE_IN_Q27; for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) - //for ( int i = 0; i < pInput_params->nBands; i++ ) { pOutput_t60[i] = (float) fabs( me2f( pOutput_t60_fx[i], pOutput_t60_e[i] ) ); pOutput_ene[i] = (float) fabs( me2f( pOutput_ene_fx[i], pOutput_ene_e[i] ) ); -- GitLab From 08c6d6c328aad69ae9a2720444b1d7df87f7500e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 18 Jun 2025 21:20:46 +0530 Subject: [PATCH 347/692] 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 348/692] 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 349/692] 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 6a54be9bea544b44d6d9c5f3f9e7753737c83af3 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 18 Jun 2025 21:28:41 +0200 Subject: [PATCH 350/692] restored accidental changes to gitlab CI yaml --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c73c057c6..0df727291 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -693,11 +693,11 @@ stages: - *check-up-to-date-in-comparison-jobs - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -k "not model" > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout -k "not model" > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -2214,7 +2214,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -2222,7 +2222,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From 8e294c8eef9ee5db708e054f8c040568e0617ca3 Mon Sep 17 00:00:00 2001 From: rtyag Date: Thu, 19 Jun 2025 11:21:43 +1000 Subject: [PATCH 351/692] 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 352/692] 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 353/692] 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 354/692] 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 ff903c3cc96bd540ff1251376969d2b24daa346f Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:37:22 +0200 Subject: [PATCH 355/692] Renamed variables + removed dynamic allocation of pointers --- lib_rend/ivas_reverb_utils_fx.c | 34 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 2df3e22f8..c7903777f 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -96,7 +96,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( #endif { int16_t idx; - float fc[CLDFB_NO_CHANNELS_MAX]; + //float fc[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_left[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; @@ -105,26 +105,20 @@ ivas_error ivas_reverb_prepare_cldfb_params( #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; #endif - - for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) - { - fc[idx] = ( idx + 0.5f ) * ( MAX_SAMPLING_RATE / ( 2 * CLDFB_NO_CHANNELS_MAX ) ); - } - - Word32 *pOutput_fc_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); - Word32 *pOutput_t60_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); - Word16 *pOutput_t60_e = (Word16 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ) ); - Word32 *pOutput_ene_fx = (Word32 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word32 ) ); - Word16 *pOutput_ene_e = (Word16 *) malloc( CLDFB_NO_CHANNELS_MAX * sizeof( Word16 ) ); + Word32 output_fc_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 output_t60_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 output_t60_e[CLDFB_NO_CHANNELS_MAX]; + Word32 output_ene_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 output_ene_e[CLDFB_NO_CHANNELS_MAX]; Word32 delay_diff_fx; - for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { - pOutput_fc_fx[i] = (Word32) fc[i] * ONE_IN_Q16; + output_fc_fx[idx] = (Word32) ( ( idx + 0.5f ) * ( MAX_SAMPLING_RATE / ( 2 * CLDFB_NO_CHANNELS_MAX ) ) ) * ONE_IN_Q16; } ivas_reverb_interpolate_acoustic_data_fx( pInput_params->nBands, pInput_params->pFc_input_fx, pInput_params->pAcoustic_rt60_fx, pInput_params->pAcoustic_dsr_fx, - CLDFB_NO_CHANNELS_MAX, pOutput_fc_fx, pOutput_t60_fx, pOutput_ene_fx, pOutput_t60_e, pOutput_ene_e ); + CLDFB_NO_CHANNELS_MAX, output_fc_fx, output_t60_fx, output_ene_fx, output_t60_e, output_ene_e ); /* adjust DSR for the delay difference */ delay_diff_fx = L_sub( pInput_params->inputPreDelay_fx, pInput_params->acousticPreDelay_fx ); @@ -132,14 +126,10 @@ ivas_error ivas_reverb_prepare_cldfb_params( delay_diff = (float) delay_diff_fx / ONE_IN_Q27; for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { - pOutput_t60[i] = (float) fabs( me2f( pOutput_t60_fx[i], pOutput_t60_e[i] ) ); - pOutput_ene[i] = (float) fabs( me2f( pOutput_ene_fx[i], pOutput_ene_e[i] ) ); + pOutput_t60[i] = (float) fabs( me2f( output_t60_fx[i], output_t60_e[i] ) ); + pOutput_ene[i] = (float) fabs( me2f( output_ene_fx[i], output_ene_e[i] ) ); } - free( pOutput_fc_fx ); - free( pOutput_t60_fx ); - free( pOutput_t60_e ); - free( pOutput_ene_fx ); - free( pOutput_ene_e ); + ln_1e6_inverted = 1.0f / logf( 1e06f ); for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { -- GitLab From 65909d1b02e1ff2bf3c1a5528cbf9f6afe654a77 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 19 Jun 2025 17:24:01 +0530 Subject: [PATCH 356/692] 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 754125aff48ae951a8d8926eac8a72a925f319bb Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:56:48 +0200 Subject: [PATCH 357/692] removed comment + clang fix --- lib_rend/ivas_reverb_utils_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index c7903777f..f673fdc7d 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -96,7 +96,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( #endif { int16_t idx; - //float fc[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_left[CLDFB_NO_CHANNELS_MAX]; float avg_pwr_right[CLDFB_NO_CHANNELS_MAX]; float delay_diff, ln_1e6_inverted, exp_argument; -- GitLab From 5a952a01ad9f232f646350b0aaef3a71f44d1689 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 23 Jun 2025 13:00:36 +1000 Subject: [PATCH 358/692] 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 359/692] 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 360/692] 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 361/692] 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 362/692] 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 468aa780e99309ce3f3d3f83cad6559aec31ef39 Mon Sep 17 00:00:00 2001 From: marc emerit Date: Mon, 23 Jun 2025 17:37:18 +0200 Subject: [PATCH 363/692] fix FIX_INV_DIFFUSE_WEIGHT bug, make switchs USE_NEW_HRTF_BINARY_FILE_FORMAT, FIX_WARNING_RENDER_CONFIG, FIX_INV_DIFFUSE_WEIGHT, FIX_638_ENERGIE_IAC_ROM_TABLES independant --- apps/decoder.c | 13 +- apps/renderer.c | 5 +- lib_com/options.h | 16 ++- lib_rend/ivas_crend_fx.c | 18 ++- lib_rend/ivas_hrtf_fx.c | 29 ++++- lib_rend/ivas_rom_binaural_crend_head.h | 6 +- lib_rend/ivas_rom_binaural_crend_head_fx.c | 2 +- lib_rend/ivas_rom_rend.h | 6 +- lib_rend/ivas_rom_rend_fx.c | 59 +++++++++ lib_util/hrtf_file_reader.c | 137 ++++++++++----------- lib_util/hrtf_file_reader.h | 4 - 11 files changed, 186 insertions(+), 109 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 76bd23bbf..0ed86b187 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -610,7 +610,6 @@ int main( } #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) @@ -619,7 +618,6 @@ int main( goto cleanup; } } -#endif #endif if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { @@ -704,7 +702,6 @@ int main( } } #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -723,12 +720,14 @@ int main( } } #else - if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) + if ( ( hHrtfTD != NULL ) && ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; + if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) + { + fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); + goto cleanup; + } } -#endif #endif } diff --git a/apps/renderer.c b/apps/renderer.c index f2beb82c3..b2e732c6f 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1012,7 +1012,6 @@ int main( } #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) @@ -1021,7 +1020,6 @@ int main( goto cleanup; } } -#endif #endif if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) @@ -1105,8 +1103,8 @@ int main( } } + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); @@ -1124,7 +1122,6 @@ int main( destroy_hrtf_statistics( hHrtfStatistics ); } } -#endif #endif hrtfFileReader_close( &hrtfFileReader ); diff --git a/lib_com/options.h b/lib_com/options.h index 03189efed..78a494c61 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -105,17 +105,21 @@ #define FIX_1372_ISAR_POST_REND #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ - +#ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM +#define NONBE_FIX_AVG_IAC_CLDFB_REVERB +#endif #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ -#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ -#define NONBE_FIX_AVG_IAC_CLDFB_REVERB -//#define FIX_OLD_BINARY_FORMAT /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/ -//#define FIX_OLD_BINARY_FILE /* Orange: current hrtf binary file in ref branch contains wrong values for fastconv value. This switch can be activated to compre running codec with and without hrtf file*/ +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT +#define FIX_OLD_BINARY_FORMAT /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/ +//#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ +#endif + +//#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ + #define FIX_993_REMOVE_SBA_GET_ORDER /* VA: issue 993: remove unused function ivas_sba_get_order() */ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 369a1d2b4..031926546 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -2153,8 +2153,10 @@ static ivas_error ivas_rend_crendConvolver( FOR( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ ) { - pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i]; - pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i]; + pFreq_buf_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_re[k] ); // Qx + pFreq_buf_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_im[k] ); // Qx + move32(); + move32(); } } ELSE @@ -2168,10 +2170,14 @@ static ivas_error ivas_rend_crendConvolver( for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ ) { - pFreq_buf_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i]; - pFreq_buf_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i]; - pFreq_buf2_re[k] += pFreq_filt_re[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i]; - pFreq_buf2_im[k] += pFreq_filt_im[k] * pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i]; + pFreq_buf_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_re[k] ); // Qx + pFreq_buf_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_im[k] ); // Qx + move32(); + move32(); + pFreq_buf2_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i] ), pFreq_buf2_re[k] ); // Qx + pFreq_buf2_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i] ), pFreq_buf2_im[k] ); // Qx + move32(); + move32(); } } #else diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 0e535170b..845b61cb1 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,8 +33,10 @@ #include #include "options.h" #include "prot_fx.h" -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #include "ivas_rom_binaural_crend_head.h" +#else +#include "ivas_rom_rend.h" #endif #include "ivas_prot_rend_fx.h" #include "ivas_error.h" @@ -297,9 +299,34 @@ ivas_error ivas_HRTF_statistics_init( HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx; break; case 16000: +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; +#else + HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx; +#endif break; } HrtfStatistics->fromROM = TRUE; diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 9e40c49ba..183a025a8 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -358,9 +358,9 @@ extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ #else extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 71a98fb0e..b4ebfe6e5 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59838,7 +59838,7 @@ const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 2790378,2355663,2029237,1865240,1832432 }; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB +#ifndef NONBE_FIX_AVG_IAC_CLDFB_REVERB const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index f4aecc837..7cbe76051 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -103,9 +103,9 @@ extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ #else extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 75bd01756..5247b8e77 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -393,6 +393,64 @@ const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 5411340,5510149,5612037,5649820,5591435,5269472,4824498,4151094,3472472, 2790378,2355663,2029237,1865240,1832432 }; + +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB +/* Sample Rate = 16000 */ + + float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {0.983044f, 0.960794f, 0.893756f, 0.783586f, 0.638963f, 0.477338f, 0.319879f, 0.183374f, 0.075909f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003842f, 0.025288f, 0.035886f, + 0.037785f, 0.035991f, 0.034784f, 0.035091f, 0.034683f, 0.030849f, 0.023146f, 0.014061f, 0.007275f, + 0.005053f, 0.006930f, 0.010589f, 0.013905f, 0.016288f, 0.018404f, 0.020849f, 0.023164f, 0.024149f, + 0.023098f, 0.020635f, 0.018325f, 0.017381f, 0.017611f, 0.017534f, 0.015650f, 0.011786f, 0.007342f, + 0.004290f, 0.003732f, 0.005148f, 0.006838f, 0.007172f, 0.005579f, 0.002632f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000238f, 0.001738f, 0.003011f, 0.003910f, + 0.004120f, 0.003394f, 0.001769f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.002101f, 0.004247f, 0.006330f, 0.008300f, 0.010110f, 0.011735f, 0.013165f, 0.014384f, + 0.015345f, 0.015972f, 0.016191f}; + + float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {1.118974f, 1.115256f, 1.106210f, 1.096901f, 1.092316f, 1.094422f, 1.101140f, 1.107775f, 1.110000f, + 1.106535f, 1.099921f, 1.094914f, 1.095643f, 1.103178f, 1.114955f, 1.126292f, 1.132973f, 1.133288f, + 1.128471f, 1.121439f, 1.114842f, 1.109721f, 1.105480f, 1.100966f, 1.095650f, 1.090074f, 1.085225f, + 1.081525f, 1.078267f, 1.074026f, 1.067777f, 1.059839f, 1.051856f, 1.045772f, 1.042531f, 1.041432f, + 1.040607f, 1.038291f, 1.033910f, 1.028286f, 1.022846f, 1.018514f, 1.015152f, 1.011898f, 1.008047f, + 1.003762f, 0.999992f, 0.997770f, 0.997349f, 0.997960f, 0.998259f, 0.997177f, 0.994506f, 0.990883f, + 0.987207f, 0.984003f, 0.981133f, 0.977984f, 0.973950f, 0.968837f, 0.962915f, 0.956690f, 0.950584f, + 0.944679f, 0.938744f, 0.932399f, 0.925372f, 0.917663f, 0.909568f, 0.901511f, 0.893804f, 0.886455f, + 0.879155f, 0.871463f, 0.863142f, 0.854285f, 0.845334f, 0.836740f, 0.828656f, 0.820817f, 0.812713f, + 0.803960f, 0.794564f, 0.784952f, 0.775633f, 0.766881f, 0.758539f, 0.750156f, 0.741330f, 0.732004f, + 0.722524f, 0.713387f, 0.704919f, 0.697057f, 0.689419f, 0.681576f, 0.673350f, 0.664931f, 0.656703f, + 0.648997f, 0.641801f, 0.634760f, 0.627357f, 0.619192f, 0.610186f, 0.600526f, 0.590442f, 0.579952f, + 0.568762f, 0.556384f, 0.542389f, 0.526648f, 0.509355f, 0.490884f, 0.471542f, 0.451447f, 0.430550f, + 0.408842f, 0.386537f, 0.364126f, 0.342284f, 0.321675f, 0.302809f, 0.286016f, 0.271536f, 0.259639f, + 0.250691f, 0.245099f, 0.243192f}; + + float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {1.118974f, 1.115254f, 1.106207f, 1.096903f, 1.092317f, 1.094425f, 1.101145f, 1.107775f, 1.109999f, + 1.106540f, 1.099921f, 1.094912f, 1.095644f, 1.103178f, 1.114952f, 1.126292f, 1.132973f, 1.133288f, + 1.128472f, 1.121439f, 1.114842f, 1.109719f, 1.105481f, 1.100965f, 1.095650f, 1.090072f, 1.085224f, + 1.081527f, 1.078270f, 1.074025f, 1.067775f, 1.059840f, 1.051856f, 1.045772f, 1.042533f, 1.041433f, + 1.040611f, 1.038292f, 1.033911f, 1.028286f, 1.022844f, 1.018512f, 1.015153f, 1.011899f, 1.008050f, + 1.003762f, 0.999995f, 0.997769f, 0.997349f, 0.997959f, 0.998259f, 0.997178f, 0.994509f, 0.990883f, + 0.987204f, 0.984003f, 0.981133f, 0.977983f, 0.973949f, 0.968836f, 0.962914f, 0.956689f, 0.950583f, + 0.944681f, 0.938745f, 0.932399f, 0.925373f, 0.917662f, 0.909567f, 0.901511f, 0.893804f, 0.886456f, + 0.879153f, 0.871467f, 0.863138f, 0.854286f, 0.845334f, 0.836740f, 0.828656f, 0.820816f, 0.812712f, + 0.803961f, 0.794567f, 0.784951f, 0.775631f, 0.766882f, 0.758540f, 0.750158f, 0.741330f, 0.732005f, + 0.722523f, 0.713388f, 0.704920f, 0.697057f, 0.689418f, 0.681575f, 0.673352f, 0.664930f, 0.656706f, + 0.648998f, 0.641802f, 0.634762f, 0.627355f, 0.619192f, 0.610187f, 0.600527f, 0.590442f, 0.579953f, + 0.568763f, 0.556383f, 0.542389f, 0.526646f, 0.509355f, 0.490883f, 0.471543f, 0.451446f, 0.430550f, + 0.408843f, 0.386537f, 0.364127f, 0.342285f, 0.321676f, 0.302809f, 0.286016f, 0.271535f, 0.259640f, + 0.250692f, 0.245099f, 0.243192f}; + + +#else + const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, @@ -487,6 +545,7 @@ const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 1708239,1437966,1167685,1059573,1059573 }; #endif +#endif /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 5832296c8..c6d1d48ec 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -37,6 +37,8 @@ #include "ivas_prot_fx.h" #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #include "ivas_rom_binaural_crend_head.h" +#else +#include "ivas_rom_rend.h" #endif /*---------------------------------------------------------------------* @@ -193,7 +195,7 @@ static ivas_error check_hrtf_binary_header( { /* Check the renderer type */ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC ) && ( hrtf_header->rend_type != HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) && @@ -363,7 +365,7 @@ static ivas_error LoadBSplineBinary( float f_tmp_latency_s; -#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifndef USE_NEW_HRTF_BINARY_FILE_FORMAT float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; #endif @@ -551,7 +553,7 @@ static ivas_error LoadBSplineBinary( LoadBSplineBinaryITD( &HrFiltSet_p->ModelParamsITD, f_hrtf ); } -#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifndef USE_NEW_HRTF_BINARY_FILE_FORMAT /* left/right energy and interaural coherence for late reverb */ FOR( i = 0; i < 3; i++ ) { @@ -576,7 +578,6 @@ static ivas_error LoadBSplineBinary( return IVAS_ERR_OK; } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* * set_default_reverb_iac_energy() @@ -615,12 +616,10 @@ static ivas_error set_default_reverb_iac_energy( #else HrFiltSet_p->lr_energy_and_iac_dyn[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); #endif -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } -#endif } switch ( HrFiltSet_p->SampleRate ) { @@ -692,8 +691,6 @@ static ivas_error set_default_reverb_iac_energy( } #endif -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES - /*-------------------------------------------------------------------* * load_reverb_from_binary() * @@ -720,11 +717,8 @@ static ivas_error load_reverb_from_binary( ivas_hrtfs_header_t hrtf_header; int32_t hrtf_data_size_max; char *hrtf_data; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; -#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; -#endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( hHrtfStatistics == NULL ) @@ -736,6 +730,7 @@ static ivas_error load_reverb_from_binary( } lr_iac_len = LR_IAC_LENGTH_NR_FC; +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( sampleRate == 16000 ) #else @@ -783,7 +778,11 @@ static ivas_error load_reverb_from_binary( return header_check_result; } +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT is_reverb = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_REVERB_ALL ); +#else + is_reverb = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_REVERB_ALL ); +#endif if ( !is_reverb ) { if ( fread( hrtf_data, 1, hrtf_header.data_size, f_hrtf ) != hrtf_header.data_size ) @@ -802,9 +801,8 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); - float *hrtf_prop_local = (float *) malloc( lr_iac_len * sizeof( float ) ); - if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL || hrtf_prop_local == NULL ) + if ( hHrtfStatistics->average_energy_l_dyn == NULL || hHrtfStatistics->average_energy_r_dyn == NULL || hHrtfStatistics->inter_aural_coherence_dyn == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } @@ -812,23 +810,21 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; - fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_l_dyn, Q27, lr_iac_len ); + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q27, lr_iac_len ); - fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->average_energy_r_dyn, Q27, lr_iac_len ); + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_r_dyn, Q27, lr_iac_len ); - fread( hrtf_prop_local, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( hrtf_prop_local, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; - free( hrtf_prop_local ); #else /* left/right energy and interaural coherence for late reverb */ FOR( i = 0; i < 3; i++ ) { -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); + HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -843,23 +839,6 @@ static ivas_error load_reverb_from_binary( floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ } HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; -#else - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); - if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( f_tmp_lr_energy_and_iac_dyn, sizeof( const float ), LR_IAC_LENGTH_NR_FC_16KHZ, f_hrtf ); - IF( i == 2 ) - { - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - } - ELSE - { - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - } - HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; -#endif } #endif } @@ -877,7 +856,6 @@ static ivas_error load_reverb_from_binary( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* * load_reverb_binary() @@ -903,7 +881,6 @@ ivas_error load_reverb_binary( return load_reverb_from_binary( hHrtf, hrtfReader->file ); #endif } -#endif /*-------------------------------------------------------------------* * TDREND_MIX_LoadHRTF() * @@ -978,7 +955,7 @@ static ivas_error TDREND_MIX_LoadHRTF( return header_check_result; } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT is_tdrend = ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_OBJECTS_TD ); #else is_tdrend = ( hrtf_header.rend_type == RENDERER_BINAURAL_OBJECTS_TD ); @@ -1310,13 +1287,14 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( UWord16 ); /* inv_diffuse_weight */ +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT #ifdef FIX_INV_DIFFUSE_WEIGHT - FOR( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight_fx[0][i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); hrtf_data_rptr += sizeof( float ); } - FOR( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight_fx[1][i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); hrtf_data_rptr += sizeof( float ); @@ -1324,11 +1302,30 @@ static ivas_error create_HRTF_from_rawdata( #else for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { - //( *hHRTF )->inv_diffuse_weight[i] = *( (float *) ( hrtf_data_rptr ) ); ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); hrtf_data_rptr += sizeof( float ); } + hrtf_data_rptr += sizeof( float ) * ( *hHRTF )->max_num_ir; +#endif +#else +#ifdef FIX_INV_DIFFUSE_WEIGHT + /* inv_diffuse_weight */ + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + ( *hHRTF )->inv_diffuse_weight_fx[0][i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); + ( *hHRTF )->inv_diffuse_weight_fx[1][i] = ( *hHRTF )->inv_diffuse_weight[0][i]; + hrtf_data_rptr += sizeof( float ); + } +#else + /* inv_diffuse_weight */ + for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) + { + ( *hHRTF )->inv_diffuse_weight[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); + hrtf_data_rptr += sizeof( float ); + } +#endif #endif + /* max_total_num_fsamp_per_iteration */ max_total_num_fsamp_per_iteration = *( (UWord16 *) ( hrtf_data_rptr ) ); hrtf_data_rptr += sizeof( UWord16 ); @@ -1472,7 +1469,7 @@ static ivas_error create_HRTF_from_rawdata( static ivas_error create_fastconv_HRTF_from_rawdata( HRTFS_FASTCONV_HANDLE *hHRTF, /* i/o: HRTF FastConv handle */ char *hrtf_data, /* i : pointer to binary file */ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT HRTF_READER_RENDERER_TYPE rend_type, /* i : Renderer type */ #else RENDERER_TYPE rend_type, /* i : Renderer type */ @@ -1486,13 +1483,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata( float f_tmp_ntaps_max[BINAURAL_NTAPS_MAX]; float f_tmp_brir_reverb[CLDFB_NO_CHANNELS_MAX]; char *hrtf_data_rptr; -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT ivas_error error; #endif ( *hHRTF )->allocate_init_flag = 0; -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) { if ( ( error = ivas_allocate_binaural_hrtf_fx( *hHRTF, 0, input_cfg, RENDERER_BINAURAL_FASTCONV, ( *hHRTF )->allocate_init_flag ) ) != IVAS_ERR_OK ) @@ -1527,7 +1524,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( #endif /* HRIR */ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) @@ -1593,7 +1590,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) #else else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA3 ) @@ -1660,7 +1657,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) #else else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_HOA2 ) @@ -1728,7 +1725,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) #else else if ( rend_type == RENDERER_BINAURAL_FASTCONV && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_FOA ) @@ -1797,7 +1794,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } } /* BRIR */ -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT else if ( rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) #else else if ( rend_type == RENDERER_BINAURAL_FASTCONV_ROOM && input_cfg == BINAURAL_INPUT_AUDIO_CONFIG_COMBINED ) @@ -1871,25 +1868,13 @@ static ivas_error create_fastconv_HRTF_from_rawdata( } hrtf_data_rptr += sizeof( uint16_t ); - -#ifdef FIX_OLD_BINARY_FILE // old binary file is wrong - extern const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; - memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); - - memcpy( f_tmp_brir_reverb, fastconvReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); -#else memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); - hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); -#endif + hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); } return IVAS_ERR_OK; @@ -1945,7 +1930,7 @@ ivas_error load_fastconv_HRTF_from_binary( free( hrtf_data ); return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "HRTF binary file not compliant (number of HRTF)" ); } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_FASTCONV_ROOM ) ) #else if ( ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV ) || ( hrtf_header.rend_type == RENDERER_BINAURAL_FASTCONV_ROOM ) ) @@ -2119,7 +2104,7 @@ ivas_error load_parambin_HRTF_from_binary( } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ #else if ( hrtf_header.rend_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) /* Parametric binauralizer data is represented as single entity */ @@ -2213,7 +2198,7 @@ ivas_error create_SetOfHRTF_from_binary( hHRTF = NULL; if ( hrtf_header.frequency == output_Fs ) { -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV ) #else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV ) @@ -2236,7 +2221,7 @@ ivas_error create_SetOfHRTF_from_binary( hHRTF = &( ( *hSetOfHRTF ).hHRTF_hrir_foa ); } } -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT else if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM ) #else else if ( hrtf_header.rend_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) @@ -2374,6 +2359,7 @@ void destroy_SetOfHRTF( return; } + #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * destroy_hrtf_statistics() @@ -2385,17 +2371,21 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) ) +#else if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) +#endif { - if ( ( *hHrtfStatistics )->average_energy_l != NULL ) + if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) { free( ( *hHrtfStatistics )->average_energy_l_dyn ); } - if ( ( *hHrtfStatistics )->average_energy_r != NULL ) + if ( ( *hHrtfStatistics )->average_energy_r_dyn != NULL ) { free( ( *hHrtfStatistics )->average_energy_r_dyn ); } - if ( ( *hHrtfStatistics )->inter_aural_coherence != NULL ) + if ( ( *hHrtfStatistics )->inter_aural_coherence_dyn != NULL ) { free( ( *hHrtfStatistics )->inter_aural_coherence_dyn ); } @@ -2404,7 +2394,6 @@ void destroy_hrtf_statistics( } #endif - /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() * diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 14ac33e9d..ca8e8b135 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -47,7 +47,6 @@ typedef struct ivas_hrtfs_header_t } ivas_hrtfs_header_t; -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES typedef enum { HRTF_READER_RENDERER_BINAURAL_INVALID, @@ -60,7 +59,6 @@ typedef enum HRTF_READER_RENDERER_BINAURAL_MIXER_CONV_ROOM, HRTF_READER_RENDERER_BINAURAL_REVERB_ALL } HRTF_READER_RENDERER_TYPE; -#endif /*---------------------------------------------------------------------* * hrtfFileReader_open() @@ -94,7 +92,6 @@ ivas_error load_HRTF_binary( const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES /*---------------------------------------------------------------------* * load_reverb_binary() * @@ -110,7 +107,6 @@ ivas_error load_reverb_binary( #endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); -#endif /*---------------------------------------------------------------------* * create_SetOfHRTF_from_binary() -- GitLab From 1d1b53a5a5552a746d563bc9ada69810c20cd0da Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 23 Jun 2025 18:16:41 +0200 Subject: [PATCH 364/692] 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 365/692] 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 3ed5565acd314c7c36586c4995fdb602688149af Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 24 Jun 2025 09:51:22 +0200 Subject: [PATCH 366/692] Minor cleanup and set basop-ci-branch-pc as scripts folder --- .gitlab-ci.yml | 7 ++---- apps/decoder.c | 48 ------------------------------------- apps/renderer.c | 45 ---------------------------------- lib_util/hrtf_file_reader.c | 23 ------------------ lib_util/hrtf_file_reader.h | 11 --------- 5 files changed, 2 insertions(+), 132 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0df727291..c10a32b07 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,7 +29,7 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -272,15 +272,12 @@ stages: - cd $SCRIPTS_DIR - sed -i '/fetch/d' .git/config # Remove all fetch lines to clean out dead links - git remote set-branches --add origin $BASOP_CI_BRANCH_PC_REPO # Add currently used branch - - git remote set-branches --add origin main # Add main to be able to load new format HRTFs - git fetch - git restore --staged . # Needed if HRTF model files were updated. - git restore . # Just as a precaution - git checkout $BASOP_CI_BRANCH_PC_REPO - git pull origin $BASOP_CI_BRANCH_PC_REPO -# Restore new format of HRTF binary - - git fetch origin main - - git checkout 78154d0b3f1b2c6c8ff8a234f3f7cf865d467d35 -- scripts/binauralRenderer_interface/binaural_renderers_hrtf_data + - cd - - cp -r $SCRIPTS_DIR/ci . - cp -r $SCRIPTS_DIR/scripts . diff --git a/apps/decoder.c b/apps/decoder.c index 0ed86b187..746564eb4 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -576,32 +576,8 @@ int main( { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { -#ifdef FIX_OLD_BINARY_FORMAT - hrtfFileReader_close( &hrtfReader ); - strcat( arg.hrtfFileName, "new" ); - - if ( hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - - if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_td_hrtf( hHrtfTD ); - } - } -#else fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); goto cleanup; -#endif } else { @@ -627,29 +603,6 @@ int main( if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { -#ifdef FIX_OLD_BINARY_FORMAT - cleanup_SetOfHRTF( hSetOfHRTF ); - hrtfFileReader_close( &hrtfReader ); - strcat( arg.hrtfFileName, "new" ); - - if ( hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - else - { - destroy_SetOfHRTF( hSetOfHRTF ); - } - } -#else if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); @@ -659,7 +612,6 @@ int main( { destroy_SetOfHRTF( hSetOfHRTF ); } -#endif } IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; diff --git a/apps/renderer.c b/apps/renderer.c index b2e732c6f..b1b7e2258 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -980,30 +980,8 @@ int main( { if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { -#ifdef FIX_OLD_BINARY_FORMAT - hrtfFileReader_close( &hrtfFileReader ); - strcat( args.customHrtfFilePath, "new" ); - if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); - goto cleanup; - } - if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); - goto cleanup; - } - else - { - destroy_td_hrtf( hHrtfTD ); - } - } -#else fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); goto cleanup; -#endif } else { @@ -1030,28 +1008,6 @@ int main( if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) { -#ifdef FIX_OLD_BINARY_FORMAT - cleanup_SetOfHRTF( hSetOfHRTF ); - hrtfFileReader_close( &hrtfFileReader ); - strcat( args.customHrtfFilePath, "new" ); - if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); - goto cleanup; - } - if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); - goto cleanup; - } - else - { - destroy_SetOfHRTF( hSetOfHRTF ); - } - } -#else if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) { fprintf( stderr, "\nError in loading HRTF binary file %s:%s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); @@ -1061,7 +1017,6 @@ int main( { destroy_SetOfHRTF( hSetOfHRTF ); } -#endif } if ( ( error = IVAS_REND_GetHrtfFastConvHandle( hIvasRend, &hHrtfFastConv ) ) != IVAS_ERR_OK ) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index c6d1d48ec..0d4dd8619 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2311,29 +2311,6 @@ static void destroy_HRTF( return; } -#ifdef FIX_OLD_BINARY_FORMAT -/*---------------------------------------------------------------------* - * cleanup_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -void cleanup_SetOfHRTF( - HRTFS_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -) -{ - if ( ( hSetOfHRTF != NULL ) && ( *hSetOfHRTF != NULL ) ) - { - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_combined ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa3 ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_hoa2 ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_foa ) ); - destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_brir_combined ) ); - } - - return; -} -#endif /*---------------------------------------------------------------------* * destroy_SetOfHRTF() diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index ca8e8b135..91e68b358 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -120,17 +120,6 @@ ivas_error create_SetOfHRTF_from_binary( int32_t output_Fs /* i : Output sampling frequency */ ); -#ifdef FIX_OLD_BINARY_FORMAT -/*---------------------------------------------------------------------* - * cleanup_SetOfHRTF() - * - * Destroy the HRTF data set. - *---------------------------------------------------------------------*/ - -void cleanup_SetOfHRTF( - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* i/o: Set of HRTF CRend handle */ -); -#endif /*---------------------------------------------------------------------* * destroy_SetOfHRTF() -- GitLab From 9fd0c1d5de2b0d817c2eaac47ebe1d551b257308 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 24 Jun 2025 09:59:11 +0200 Subject: [PATCH 367/692] Enable HRTF model from file tests --- .gitlab-ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c10a32b07..9482f081f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,9 @@ variables: SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" + DISABLE_HRTF_MODEL_TESTS: "" + # DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests + # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod" @@ -690,11 +693,11 @@ stages: - *check-up-to-date-in-comparison-jobs - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -k "not model" > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH $DISABLE_HRTF_MODEL_TESTS > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout -k "not model" > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout $DISABLE_HRTF_MODEL_TESTS > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -2211,7 +2214,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 $DISABLE_HRTF_MODEL_TESTS ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -2219,7 +2222,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check -- GitLab From 66578364d370196d64f463f92ee3c84f01e0adad Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:07:39 +0200 Subject: [PATCH 368/692] 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 39bee78b39b4feb3d9a9d6f90ce0ae2d76a5bf71 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 24 Jun 2025 10:07:53 +0200 Subject: [PATCH 369/692] Remove obsolete define FIX_OLD_BINARY_FORMAT --- lib_com/options.h | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 78a494c61..662fb2be2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -111,7 +111,6 @@ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT -#define FIX_OLD_BINARY_FORMAT /* Orange: trick to make tests succesful when changing hrtf binary format between ref and new branch*/ //#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #endif -- GitLab From c809bdea7674b8f96f09ffc3b843be6af3d4f854 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 10:32:21 +0200 Subject: [PATCH 370/692] 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 371/692] [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 372/692] 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 373/692] 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 f22253281acdbff87e291a31fd45009475e4826d Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 24 Jun 2025 11:24:46 +0200 Subject: [PATCH 374/692] Enable switches NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES, FIX_638_ENERGIE_IAC_ROM_TABLES and FIX_777_COMBI_RENDER_CONFIG_FILE --- lib_com/options.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 662fb2be2..0c8f23d2a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,18 +110,16 @@ #endif #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ -#ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT -//#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -#endif +#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -//#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ +#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ #define FIX_993_REMOVE_SBA_GET_ORDER /* VA: issue 993: remove unused function ivas_sba_get_order() */ -//#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ +#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ -- GitLab From 6ea8b19de1a60324c8f9d053d936a86cad07bfc2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 11:45:07 +0200 Subject: [PATCH 375/692] 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 376/692] 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 377/692] 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 378/692] 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 379/692] 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 380/692] 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 381/692] 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 382/692] 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 383/692] 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 384/692] 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 385/692] 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 386/692] 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 387/692] 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 388/692] 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 389/692] 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 390/692] 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 391/692] 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 392/692] 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 393/692] 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 a33dd79600b1fe69bd5f51d61a2ec585269de99a Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:23:35 +0200 Subject: [PATCH 394/692] Changed Q values for 16kHz HRTF binary --- lib_rend/ivas_hrtf_fx.c | 6 +++--- lib_util/hrtf_file_reader.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 845b61cb1..0b82a8e19 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -315,9 +315,9 @@ ivas_error ivas_HRTF_statistics_init( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 0d4dd8619..31f75e876 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -811,10 +811,10 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q27, lr_iac_len ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q23, lr_iac_len ); fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_r_dyn, Q27, lr_iac_len ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_r_dyn, Q23, lr_iac_len ); fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); -- GitLab From a8f56457e553c93c45c923f8cc7af693cc769846 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 24 Jun 2025 14:34:25 +0200 Subject: [PATCH 395/692] 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 396/692] 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 bf9e2fb553e83b92d28dfa2ec6af497ea57045d7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 24 Jun 2025 15:41:11 +0200 Subject: [PATCH 397/692] Port MR 2051 and MR 2152 from float --- apps/decoder.c | 3 +- apps/isar_post_rend.c | 136 ++++++++-------- apps/renderer.c | 356 +++++++++++++++++++++--------------------- 3 files changed, 258 insertions(+), 237 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 746564eb4..0108d1325 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -497,7 +497,8 @@ int main( if ( ( error = IVAS_DEC_SetRenderFramesize( hIvasDec, arg.renderFramesize ) ) != IVAS_ERR_OK ) { - return error; + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; } if ( arg.renderFramesize != asked_frame_size ) diff --git a/apps/isar_post_rend.c b/apps/isar_post_rend.c index 4b478f7c2..b4ff098ba 100644 --- a/apps/isar_post_rend.c +++ b/apps/isar_post_rend.c @@ -682,19 +682,20 @@ int main( int argc, char **argv ) { - ISAR_POST_REND_HANDLE hIsarPostRend; + bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ + ISAR_POST_REND_HANDLE hIsarPostRend = NULL; RotFileReader *headRotReader = NULL; RotFileReader *externalOrientationFileReader = NULL; SplitRendBFIFileReader *splitRendBFIReader = NULL; AudioFileReader *audioReader = NULL; - AudioFileWriter *audioWriter; + AudioFileWriter *audioWriter = NULL; int32_t inBufferSize; int32_t outBufferSize; int32_t bitsBufferSize; - int16_t *inpInt16Buffer; - Word32 *inFloatBuffer_fx; - int16_t *outInt16Buffer; - Word32 *outFloatBuffer_fx; + int16_t *inpInt16Buffer = NULL; + Word32 *inFloatBuffer_fx = NULL; + int16_t *outInt16Buffer = NULL; + Word32 *outFloatBuffer_fx = NULL; uint8_t *bitsBufferData = NULL; IVAS_REND_AudioBuffer inBuffer; IVAS_REND_AudioBuffer outBuffer; @@ -716,6 +717,9 @@ int main( reset_mem( USE_BYTES ); #endif + inBuffer.pq_fact = NULL; + outBuffer.pq_fact = NULL; + hSplitRendFileReadWrite = NULL; bitsBuffer.bits = NULL; bitsBuffer.config.bitsRead = 0; @@ -727,7 +731,6 @@ int main( bitsBuffer.config.isar_frame_size_ms = 20; bitsBuffer.config.lc3plusHighRes = 0; - CmdlnArgs args = parseCmdlnArgs( argc, argv ); convert_backslash( args.inputFilePath ); @@ -738,8 +741,8 @@ int main( { if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.headRotationFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.headRotationFilePath ); + goto cleanup; } } @@ -764,14 +767,14 @@ int main( &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { - fprintf( stderr, "Could not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); - exit( -1 ); + fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inMetadataFilePaths[0] ); + goto cleanup; } if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", audioFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", audioFilePath ); + goto cleanup; } } @@ -788,8 +791,8 @@ int main( &bitsBuffer.config.lc3plusHighRes ); if ( error != IVAS_ERR_OK ) { - fprintf( stderr, "Could not open split rend metadata file %s\n", args.inputFilePath ); - exit( -1 ); + fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.inputFilePath ); + goto cleanup; } audioReader = NULL; } @@ -814,20 +817,20 @@ int main( /* else if sampling rate given on command line, compare with wav file */ else if ( inFileSampleRate != args.sampleRate ) { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); - exit( -1 ); + fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); + goto cleanup; } break; case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */ if ( args.sampleRate == 0 ) { - fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); - exit( -1 ); + fprintf( stderr, "\nSampling rate must be specified on command line when using raw PCM input\n" ); + goto cleanup; } break; default: - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } int16_t inFileNumChannels = 0; @@ -836,23 +839,24 @@ int main( error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nAudioFileReader_getNumChannels failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_BINAURAL; if ( ( error = ISAR_POST_REND_open( &hIsarPostRend, args.sampleRate, args.outConfig.audioConfig, true, 0, 0, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } /* === Configure === */ if ( ( error = ISAR_POST_REND_InitConfig( hIsarPostRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( args.inConfig.numBinBuses > 0 ) @@ -864,8 +868,8 @@ int main( bitsBuffer.config.isar_frame_size_ms, bitsBuffer.config.lc3plusHighRes ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in getting split renderer bitstream header: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -881,8 +885,8 @@ int main( { if ( ( error = ISAR_POST_REND_AddInput( hIsarPostRend, args.inConfig.binBuses[i].audioConfig, &splitBinIds[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nISAR_POST_REND_AddInput failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -890,16 +894,16 @@ int main( if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { - fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); - exit( -1 ); + fprintf( stderr, "\nNumber of channels in input file does not match selected configuration\n" ); + goto cleanup; } int16_t numOutChannels = 2; if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { - fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); + goto cleanup; } inBufferSize = frameSize_smpls * totalNumInChannels; @@ -977,7 +981,7 @@ int main( else { fprintf( stderr, "\nUnable to read from bitstream file!\n" ); - exit( -1 ); + goto cleanup; } } } @@ -988,7 +992,7 @@ int main( if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError reading from file %s\n", audioFilePath ); - exit( -1 ); + goto cleanup; } } @@ -1014,21 +1018,21 @@ int main( IF( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = ISAR_POST_REND_SetHeadRotation( hIsarPostRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } else { - fprintf( stderr, "Head Rotation should be enabled in post renderer\n" ); - exit( -1 ); + fprintf( stderr, "\nHead Rotation should be enabled in post renderer\n" ); + goto cleanup; } /* Read from split renderer bfi file if specified */ @@ -1037,14 +1041,14 @@ int main( int16_t bfi; if ( ( error = SplitRendBFIFileReading( splitRendBFIReader, &bfi ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in SplitRendBFIFileReading(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = ISAR_POST_REND_SetSplitRendBFI( hIsarPostRend, bfi ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in ISAR_POST_REND_SetSplitRendBFI(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1054,31 +1058,32 @@ int main( { if ( ( error = ISAR_POST_REND_GetInputNumChannels( hIsarPostRend, splitBinIds[i], &numChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } + ISAR_POST_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.binBuses[i].inputChannelIndex, numChannels ); if ( ( error = ISAR_POST_REND_FeedInputAudio( hIsarPostRend, splitBinIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nISAR_POST_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } if ( splitBinNeedsNewFrame ) { if ( ( error = ISAR_POST_REND_FeedSplitBinauralBitstream( hIsarPostRend, splitBinIds[i], &bitsBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nISAR_POST_REND_FeedSplitBinauralBitstream failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } if ( ( error = ISAR_POST_REND_GetSplitBinauralSamples( hIsarPostRend, outBuffer, &splitBinNeedsNewFrame ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nISAR_POST_REND_GetSplitBinauralSamples failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } int16_t num_out_channels; @@ -1095,7 +1100,7 @@ int main( if ( ISAR_POST_REND_GetDelay( hIsarPostRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); - exit( -1 ); + goto cleanup; } if ( hSplitRendFileReadWrite != NULL ) @@ -1120,8 +1125,8 @@ int main( { if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nError writing audio file %s\n", args.outputFilePath ); + goto cleanup; } delayNumSamples = 0; } @@ -1155,7 +1160,7 @@ int main( if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); + goto cleanup; } } @@ -1163,7 +1168,7 @@ int main( if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); + goto cleanup; } zeroPadToWrite = 0; } @@ -1187,7 +1192,14 @@ int main( } #endif - /* === Close === */ + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + +cleanup: + free( inpInt16Buffer ); free( inFloatBuffer_fx ); free( inBuffer.pq_fact ); @@ -1218,7 +1230,7 @@ int main( print_mem( NULL ); #endif - return 0; + return mainFailed ? -1 : 0; } diff --git a/apps/renderer.c b/apps/renderer.c index b1b7e2258..97b0a5e43 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -720,7 +720,8 @@ int main( int argc, char **argv ) { - IVAS_REND_HANDLE hIvasRend; + bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */ + IVAS_REND_HANDLE hIvasRend = NULL; RotFileReader *headRotReader = NULL; RotFileReader *externalOrientationFileReader = NULL; RotFileReader *referenceRotReader = NULL; @@ -737,7 +738,7 @@ int main( #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; #endif - IsmPositionProvider *positionProvider; + IsmPositionProvider *positionProvider = NULL; LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS]; RenderConfigReader *renderConfigReader = NULL; MasaFileReader *masaReaders[RENDERER_MAX_MASA_INPUTS]; @@ -745,17 +746,17 @@ int main( IVAS_MASA_METADATA_HANDLE hMasaMetadata[RENDERER_MAX_MASA_INPUTS]; char audioFilePath[FILENAME_MAX]; AudioFileReader *audioReader = NULL; - AudioFileWriter *audioWriter; + AudioFileWriter *audioWriter = NULL; int32_t inBufferSize; int32_t outBufferSize; int32_t bitsBufferSize; - int16_t *inpInt16Buffer; - float *inFloatBuffer; - int16_t *outInt16Buffer; - Word32 *outInt32Buffer; - Word32 *inInt32Buffer; + int16_t *inpInt16Buffer = NULL; + float *inFloatBuffer = NULL; + int16_t *outInt16Buffer = NULL; + Word32 *outInt32Buffer = NULL; + Word32 *inInt32Buffer = NULL; Word32 gain_fx; - float *outFloatBuffer; + float *outFloatBuffer = NULL; uint8_t *bitsBufferData = NULL; IVAS_REND_AudioBuffer inBuffer; IVAS_REND_AudioBuffer outBuffer; @@ -808,13 +809,13 @@ int main( ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_AUDIO_CONFIG_OBA && args.inConfig.numAudioObjects == 1 ) ) ) { fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires mono or ISM1 input\n" ); - exit( -1 ); + goto cleanup; } if ( args.nonDiegeticPan && args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_STEREO ) { fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires stereo output\n" ); - exit( -1 ); + goto cleanup; } positionProvider = IsmPositionProvider_open(); @@ -831,8 +832,8 @@ int main( { if ( RotationFileReader_open( args.headRotationFilePath, &headRotReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.headRotationFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.headRotationFilePath ); + goto cleanup; } } @@ -840,16 +841,16 @@ int main( { if ( RotationFileReader_open( args.referenceRotationFilePath, &referenceRotReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.referenceRotationFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.referenceRotationFilePath ); + goto cleanup; } } if ( !isEmptyString( args.referenceVectorFilePath ) ) { if ( Vector3PairFileReader_open( args.referenceVectorFilePath, &referenceVectorReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.referenceVectorFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.referenceVectorFilePath ); + goto cleanup; } } @@ -862,8 +863,8 @@ int main( { if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.externalOrientationFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.externalOrientationFilePath ); + goto cleanup; } } @@ -872,8 +873,8 @@ int main( { if ( RenderConfigReader_open( args.renderConfigFilePath, &renderConfigReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.renderConfigFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.renderConfigFilePath ); + goto cleanup; } } @@ -896,21 +897,21 @@ int main( { fprintf( stderr, "\nInvalid configuration - Merging to MASA output requires MASA input and at least one another input to be present\n" ); fprintf( stderr, "\nMASA input is missing\n" ); - exit( -1 ); + goto cleanup; } if ( args.inConfig.numAudioObjects == 0 && args.inConfig.numMultiChannelBuses == 0 && args.inConfig.numAmbisonicsBuses == 0 ) { fprintf( stderr, "\nInvalid configuration - Merging to MASA output requires MASA input and at least one another input to be present\n" ); fprintf( stderr, "\nNo object, multi-channel, or Ambisonic input present.\n" ); - exit( -1 ); + goto cleanup; } } if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", audioFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", audioFilePath ); + goto cleanup; } int32_t inFileSampleRate = 0; @@ -927,45 +928,47 @@ int main( /* else if sampling rate given on command line, compare with wav file */ else if ( inFileSampleRate != args.sampleRate ) { - fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); - exit( -1 ); + fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath ); + goto cleanup; } break; case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */ if ( args.sampleRate == 0 ) { - fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" ); - exit( -1 ); + fprintf( stderr, "\nSampling rate must be specified on command line when using raw PCM input\n" ); + goto cleanup; } break; default: - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; + ; } int16_t inFileNumChannels = 0; error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nAudioFileReader_getNumChannels failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } + const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) ); Word32 nonDiegeticPanGain_fx = ( args.nonDiegeticPanGain == 1.0f ) ? ONE_IN_Q31 : ( args.nonDiegeticPanGain == -1.0f ) ? L_negate( ONE_IN_Q31 ) : (Word32) ( args.nonDiegeticPanGain * ( 1LL << Q31 ) ); IF( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, nonDiegeticPanGain_fx, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError opening renderer handle: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( !isEmptyString( args.customHrtfFilePath ) ) { if ( hrtfFileReader_open( args.customHrtfFilePath, &hrtfFileReader ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error opening file: %s\n", args.customHrtfFilePath ); - exit( -1 ); + fprintf( stderr, "\nError opening file: %s\n", args.customHrtfFilePath ); + goto cleanup; } if ( hrtfFileReader != NULL ) @@ -1120,15 +1123,14 @@ int main( if ( ( error = IVAS_REND_PrintConfig( hIvasRend ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\n IVAS_REND_PrintConfig failed: %s\n\n", ivas_error_to_string( error ) ); - // goto cleanup; - exit( -1 ); + goto cleanup; } /* === Configure === */ if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } @@ -1140,20 +1142,20 @@ int main( if ( ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) && ( args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && !is_split_pre_rend_mode( &args ) ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split pre-rendering mode is enabled. Exiting. \n" ); - exit( -1 ); + goto cleanup; } if ( ( error = IVAS_REND_GetRenderConfig( hIvasRend, &renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetRenderConfig failed: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + goto cleanup; } if ( RenderConfigReader_read( renderConfigReader, args.renderConfigFilePath, &renderConfig ) != IVAS_ERR_OK ) { - fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath ); - exit( -1 ); + fprintf( stderr, "\nFailed to read renderer configuration from file %s\n", args.renderConfigFilePath ); + goto cleanup; } if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) @@ -1162,14 +1164,14 @@ int main( { if ( RenderConfigReader_checkValues( &renderConfig ) != IVAS_ERR_OK ) { - fprintf( stderr, "Invalid room acoustics configuration parameters\n\n" ); - exit( -1 ); + fprintf( stderr, "\nInvalid room acoustics configuration parameters\n\n" ); + goto cleanup; } } else { - fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId ); - exit( -1 ); + fprintf( stderr, "\nFailed to get acoustic environment with ID: %d\n\n", args.acousticEnvironmentId ); + goto cleanup; } renderConfig.roomAcoustics.override = 1; } @@ -1181,7 +1183,7 @@ int main( if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_FeedRenderConfig failed: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + goto cleanup; } CLDFBframeSize_smpls = frameSize_smpls * 2; @@ -1190,8 +1192,8 @@ int main( if ( ( error = IVAS_REND_SetOrientationTrackingMode( hIvasRend, args.orientation_tracking ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_SetOrientationTrackingMode(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_SetOrientationTrackingMode(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } /* Set up output custom layout configuration */ @@ -1201,8 +1203,8 @@ int main( floatToFixed_arrL_app( args.outConfig.outSetupCustom.elevation, args.outConfig.outSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); if ( ( error = IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( hIvasRend, args.outConfig.outSetupCustom ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomOutputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1222,14 +1224,14 @@ int main( { if ( ( error = IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } Word32 var1 = (Word32) ( args.syncMdDelay ); IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, var1 ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1240,8 +1242,8 @@ int main( { if ( ( error = parseLfePanMtxFile( args.inLfePanningMatrixFile, &lfePanMatrix ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1271,16 +1273,16 @@ int main( { IF( ( error = IVAS_REND_AddInput_fx( hIvasRend, args.inConfig.multiChannelBuses[i].audioConfig, &mcIds[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_AddInput failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } gain_fx = (Word32) ( ( args.inputGainGlobal * dBToLin( args.inConfig.multiChannelBuses[i].gain_dB ) ) * ( 1u << 30 ) ); IF( ( error = IVAS_REND_SetInputGain_fx( hIvasRend, mcIds[i], gain_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputGain failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( args.inConfig.multiChannelBuses[i].audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) @@ -1289,8 +1291,8 @@ int main( floatToFixed_arrL_app( args.inConfig.inSetupCustom.elevation, args.inConfig.inSetupCustom.elevation_fx, Q22, IVAS_MAX_OUTPUT_CHANNELS ); if ( ( error = IVAS_REND_ConfigureCustomInputLoudspeakerLayout( hIvasRend, mcIds[i], args.inConfig.inSetupCustom ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_ConfigureCustomInputLoudspeakerLayout(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1299,7 +1301,7 @@ int main( { if ( args.lfePanningEnabled ) { - fprintf( stderr, "Warning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" ); + fprintf( stderr, "\nWarning: LFE position specified as well as panning matrix! Ignoring position and using gains from panning matrix\n" ); args.lfePanningEnabled = false; } @@ -1310,8 +1312,8 @@ int main( IF( ( error = IVAS_REND_SetInputLfeMtx_fx( hIvasRend, mcIds[i], (const IVAS_REND_LfePanMtx_fx *) &lfePanMatrix_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputLfeMtx failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } /* set panning gains for input LFE */ @@ -1320,8 +1322,8 @@ int main( Word32 inputGain = (Word32) ( args.lfeConfigGain * ( 1u << 31 ) ); IF( ( error = IVAS_REND_SetInputLfePos_fx( hIvasRend, mcIds[i], inputGain, (Word16) args.lfeConfigAzimuth, (Word16) args.lfeConfigElevation ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputLfePos failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } else @@ -1334,8 +1336,8 @@ int main( { if ( ( error = parseLfePanMtxFile( lfeRoutingConfigs[i]->lfe_routing_mtx, &lfePanMatrix ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nparseLfePanMtxFile failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } FOR( Word16 k = 0; k < IVAS_MAX_OUTPUT_CHANNELS; k++ ) @@ -1345,8 +1347,8 @@ int main( if ( ( error = IVAS_REND_SetInputLfeMtx_fx( hIvasRend, mcIds[i], (const IVAS_REND_LfePanMtx_fx *) &lfePanMatrix_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputLfeMtx failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } /* set position based gains */ @@ -1355,8 +1357,8 @@ int main( Word32 inputGain = (Word32) ( lfeRoutingConfigs[i]->lfe_gain_dB * ( 1u << 31 ) ); IF( ( error = IVAS_REND_SetInputLfePos_fx( hIvasRend, mcIds[i], inputGain, (Word16) lfeRoutingConfigs[i]->lfe_azi, (Word16) lfeRoutingConfigs[i]->lfe_ele ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputLfePos failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1367,15 +1369,15 @@ int main( { IF( ( error = IVAS_REND_AddInput_fx( hIvasRend, IVAS_AUDIO_CONFIG_OBA, &ismIds[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_AddInput: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } gain_fx = (Word32) ( args.inputGainGlobal * dBToLin( args.inConfig.audioObjects[i].gain_dB ) * ( 1u << 30 ) ); IF( ( error = IVAS_REND_SetInputGain_fx( hIvasRend, ismIds[i], gain_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputGain failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } /* With MASA output, all objects are handled at once, so add only one input having all objects in it */ @@ -1389,15 +1391,15 @@ int main( { IF( ( error = IVAS_REND_AddInput_fx( hIvasRend, args.inConfig.ambisonicsBuses[i].audioConfig, &sbaIds[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_AddInput failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } gain_fx = (Word32) ( args.inputGainGlobal * dBToLin( args.inConfig.ambisonicsBuses[i].gain_dB ) * ( 1u << 30 ) ); IF( ( error = IVAS_REND_SetInputGain_fx( hIvasRend, sbaIds[i], gain_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputGain failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1405,15 +1407,15 @@ int main( { IF( ( error = IVAS_REND_AddInput_fx( hIvasRend, args.inConfig.masaBuses[i].audioConfig, &masaIds[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_AddInput failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } gain_fx = (Word32) ( ( args.inputGainGlobal * dBToLin( args.inConfig.masaBuses[i].gain_dB ) ) * ( 1u << 30 ) ); IF( ( error = IVAS_REND_SetInputGain_fx( hIvasRend, masaIds[i], gain_fx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetInputGain failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1421,8 +1423,8 @@ int main( if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels ) { - fprintf( stderr, "Number of channels in input file does not match selected configuration\n" ); - exit( -1 ); + fprintf( stderr, "\nNumber of channels in input file does not match selected configuration\n" ); + goto cleanup; } for ( i = 0; i < args.inConfig.numMasaBuses; ++i ) @@ -1433,19 +1435,19 @@ int main( } } - int16_t numOutChannels; + Word16 numOutChannels; if ( ( error = IVAS_REND_NumOutChannels( hIvasRend, &numOutChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_NumOutChannels(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( cldfb_in_flag ) { if ( ( error = IVAS_REND_openCldfb( cldfbAna, cldfbSyn, totalNumInChannels, numOutChannels, args.sampleRate ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_openCldfb(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1461,7 +1463,7 @@ int main( if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); - exit( -1 ); + goto cleanup; } if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, @@ -1475,8 +1477,8 @@ int main( args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Could not open split rend metadata file %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outputFilePath ); + goto cleanup; } audioWriter = NULL; } @@ -1494,7 +1496,7 @@ int main( if ( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples_temp, &delayTimeScale_temp ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); - exit( -1 ); + goto cleanup; } if ( ( error = split_rend_writer_open( &hSplitRendFileReadWrite, @@ -1508,15 +1510,15 @@ int main( args.sampleRate, bitsBuffer.config.lc3plus_highres ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Could not open split rend metadata file %s\n", args.outMetadataFilePath ); - exit( -1 ); + fprintf( stderr, "\nCould not open split rend metadata file %s\n", args.outMetadataFilePath ); + goto cleanup; } } if ( AudioFileWriter_open( &audioWriter, args.outputFilePath, args.sampleRate, numOutChannels ) != IVAS_ERR_OK ) { - fprintf( stderr, "Failed to open file: %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nFailed to open file: %s\n", args.outputFilePath ); + goto cleanup; } } @@ -1617,7 +1619,7 @@ int main( if ( ( error = AudioFileReader_read( audioReader, inpInt16Buffer, (int16_t) inBufferSize, &numSamplesRead ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError reading from file %s\n", audioFilePath ); - exit( -1 ); + goto cleanup; } if ( numSamplesRead == 0 ) @@ -1644,13 +1646,13 @@ int main( IVAS_VECTOR3 listenerPos, refPos; if ( ( error = Vector3PairFileReader_read( referenceVectorReader, &listenerPos, &refPos ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nVector3PairFileReader_read failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = IVAS_REND_SetReferenceVector( hIvasRend, listenerPos, refPos ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_SetReferenceVector failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } /* Read from reference rotation trajectory file if specified */ @@ -1661,14 +1663,14 @@ int main( IVAS_QUATERNION quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES]; if ( ( error = HeadRotationFileReading( referenceRotReader, &quaternions[sf_idx], NULL ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = IVAS_REND_SetReferenceRotation( hIvasRend, quaternions[sf_idx] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error setting Reference Rotation: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError setting Reference Rotation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1684,14 +1686,14 @@ int main( if ( ( error = HeadRotationFileReading( headRotReader, &headRot, &Pos ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in Head Rotation File Reading: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = IVAS_REND_SetHeadRotation( hIvasRend, headRot, Pos, DEFAULT_AXIS, sf_idx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError setting Head Rotation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1699,12 +1701,11 @@ int main( { if ( ( error = IVAS_REND_DisableHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error disabling head rotation: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError disabling head rotation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } - /* Read from external orientation file if specified */ if ( externalOrientationFileReader != NULL ) { @@ -1717,16 +1718,16 @@ int main( { if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &quatBuffer[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in External Orientation File Reading: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in External Orientation File Reading: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } for ( sf_idx = 0; sf_idx < num_subframes; sf_idx++ ) { if ( ( error = IVAS_REND_SetExternalOrientation( hIvasRend, &quatBuffer[sf_idx], enableHeadRotation[sf_idx], enableExternalOrientation[sf_idx], enableRotationInterpolation[sf_idx], numFramesToTargetOrientation[sf_idx], sf_idx ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error setting External Orientation: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError setting External Orientation: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1735,22 +1736,23 @@ int main( if ( ( error = IVAS_REND_CombineHeadAndExternalOrientation( hIvasRend ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error combining external and head orientations: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError combining external and head orientations: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i ) { if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, mcIds[i], &numChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.multiChannelBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, mcIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1763,15 +1765,15 @@ int main( IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, args.inConfig.numAudioObjects ); if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } if ( ( error = IVAS_REND_FeedInputObjectMetadataToOMasa( hIvasRend, i, mtdBuffer.positions[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputObjectMetadataToOMasa failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } else @@ -1779,14 +1781,14 @@ int main( IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.audioObjects[i].inputChannelIndex, 1 ); if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, ismIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = IVAS_REND_FeedInputObjectMetadata( hIvasRend, ismIds[i], mtdBuffer.positions[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputObjectMetadata failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1795,14 +1797,15 @@ int main( { if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, sbaIds[i], &numChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.ambisonicsBuses[i].inputChannelIndex, numChannels ); if ( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, sbaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1810,15 +1813,16 @@ int main( { if ( ( error = IVAS_REND_GetInputNumChannels( hIvasRend, masaIds[i], &numChannels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_GetInputNumChannels failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } + IVAS_REND_ReadOnlyAudioBuffer tmpBuffer = getReadOnlySubBuffer( inBuffer, (int16_t) args.inConfig.masaBuses[i].inputChannelIndex, numChannels ); IF( ( error = IVAS_REND_FeedInputAudio_fx( hIvasRend, masaIds[i], tmpBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputAudio failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( isCurrentFrameMultipleOf20ms ) @@ -1828,14 +1832,14 @@ int main( /* This will update data in hMasaMetadata[i] */ if ( ( error = MasaFileReader_readNextFrame( masaReaders[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in MASA Metadata File Reading: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in MASA Metadata File Reading: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } if ( ( error = IVAS_REND_FeedInputMasaMetadata( hIvasRend, masaIds[i], hMasaMetadata[i] ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nIVAS_REND_FeedInputMasaMetadata failed: %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -1845,16 +1849,16 @@ int main( { if ( ( error = IVAS_REND_GetSplitBinauralBitstream( hIvasRend, outBuffer, &bitsBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_GetSplitBinauralBitstream(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } else { if ( ( error = IVAS_REND_GetSamples( hIvasRend, outBuffer ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_GetSamples()%s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1872,10 +1876,9 @@ int main( IF( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to get delay of renderer!\n" ); - exit( -1 ); + goto cleanup; } - delayNumSamples_orig = delayNumSamples; } else @@ -1891,7 +1894,7 @@ int main( &bitsBuffer.config.bitsWritten ) != IVAS_ERR_OK ) { fprintf( stderr, "\nUnable to write to bitstream file!\n" ); - exit( -1 ); + goto cleanup; } } @@ -1901,28 +1904,27 @@ int main( { if ( AudioFileWriter_write( audioWriter, &outInt16Buffer[delayNumSamples * num_out_channels], outBufferSize - ( delayNumSamples * num_out_channels ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error writing audio file %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nError writing audio file %s\n", args.outputFilePath ); + goto cleanup; } delayNumSamples = 0; } else { - delayNumSamples -= (int16_t) ( outBufferSize / num_out_channels ); + delayNumSamples -= (Word16) ( outBufferSize / num_out_channels ); } } bitsBuffer.config.bitsRead = 0; bitsBuffer.config.bitsWritten = 0; - /* Write MASA metadata for MASA outputs */ if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA1 || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_MASA2 ) { IVAS_REND_AudioConfigType inputType1; IVAS_REND_AudioConfigType inputType2; IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMetaOutput; - int16_t numInputFormats; + Word16 numInputFormats; inputType1 = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN; inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN; @@ -1963,8 +1965,8 @@ int main( { if ( ( error = IVAS_REND_GetMasaMetadata( hIvasRend, &hMetaOutput, inputType1 ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_GetMasaMetadata(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_GetMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } else @@ -1974,8 +1976,8 @@ int main( inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1984,8 +1986,8 @@ int main( inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_MASA; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } @@ -1994,8 +1996,8 @@ int main( inputType2 = IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED; if ( ( error = IVAS_REND_MergeMasaMetadata( hIvasRend, &hMetaOutput, inputType1, inputType2 ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "Error in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); - exit( -1 ); + fprintf( stderr, "\nError in IVAS_REND_MergeMasaMetadata(): %s\n", ivas_error_to_string( error ) ); + goto cleanup; } } } @@ -2027,7 +2029,7 @@ int main( if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, outBufferSize ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); + goto cleanup; } } @@ -2035,7 +2037,7 @@ int main( if ( ( error = AudioFileWriter_write( audioWriter, outInt16Buffer, zeroPadToWrite * outBuffer.config.numChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); - exit( -1 ); + goto cleanup; } zeroPadToWrite = 0; } @@ -2053,6 +2055,13 @@ int main( fprintf( stdout, "\n\nRendering of %d frames finished\n\n", frame ); + /*------------------------------------------------------------------------------------------* + * Close files and deallocate resources + *------------------------------------------------------------------------------------------*/ + + mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */ + +cleanup: /* === Close === */ free( inpInt16Buffer ); @@ -2061,7 +2070,6 @@ int main( free( outFloatBuffer ); free( outInt32Buffer ); free( inInt32Buffer ); -cleanup: if ( bitsBufferData != NULL ) { @@ -2111,7 +2119,7 @@ cleanup: print_mem( NULL ); #endif - return 0; + return mainFailed ? -1 : 0; } -- GitLab From 4d365ea0f650ed5d7895f26267ff9ac5ced4371f Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 24 Jun 2025 15:44:31 +0200 Subject: [PATCH 398/692] 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 399/692] 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 400/692] 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 401/692] 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 402/692] 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 0f798c029aa90e433da8a71d79c63f83c8ed7c46 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 24 Jun 2025 18:33:48 +0200 Subject: [PATCH 403/692] update --- apps/renderer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 97b0a5e43..f36434778 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1214,8 +1214,8 @@ int main( MasaFileWriter_open( args.outputFilePath, true, &masaWriter ); /* No delay for audio in renderer, so calling metadata writer in delayCompensated mode, i.e., no delay applied to meta */ if ( masaWriter == NULL ) { - fprintf( stderr, "Could not open MASA metadata file %s\n", args.outputFilePath ); - exit( -1 ); + fprintf( stderr, "\nCould not open MASA metadata file %s\n", args.outputFilePath ); + goto cleanup; } } -- GitLab From dc36cb5ba921e36be19089ce8e890a80a7b6f0e7 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 25 Jun 2025 10:50:15 +0530 Subject: [PATCH 404/692] 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 405/692] 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 406/692] 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 407/692] 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 408/692] 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 409/692] 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 410/692] 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 411/692] 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 412/692] 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 413/692] 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 414/692] 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 415/692] 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 416/692] 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 ac343713076ad1ec5cf875a1c43028d5fa90e77e Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:06:45 +0200 Subject: [PATCH 417/692] Added fx ROM tables for 16kHz HRTF + comparison conditions for HRTFs at all sampling frequenies --- lib_rend/ivas_hrtf_fx.c | 118 ++++++++- lib_rend/ivas_rom_binaural_crend_head.h | 18 +- lib_rend/ivas_rom_binaural_crend_head_fx.c | 265 ++++++++++++++++++++- 3 files changed, 391 insertions(+), 10 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 0b82a8e19..5729337d4 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -289,14 +289,105 @@ ivas_error ivas_HRTF_statistics_init( switch ( sampleRate ) { case 48000: +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_48kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_48kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float*) defaultHRIR_coherence_48kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + // TODO: dump the converted fixed point arrays to an array + printf( "average_energy_l = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); + } + printf( "};\n" ); + + printf( "average_energy_r = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); + } + printf( "};\n" ); + + printf( "inter_aural_coherence = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); + } + printf( "};\n" ); +#else HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx; +#endif break; case 32000: +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_32kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float *) defaultHRIR_right_avg_power_32kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float *) defaultHRIR_coherence_32kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + // TODO: dump the converted fixed point arrays to a string + + printf( "average_energy_l = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); + } + printf( "};\n" ); + + printf( "average_energy_r = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); + } + printf( "};\n" ); + + printf( "inter_aural_coherence = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) + { + printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); + } + printf( "};\n" ); +#else HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx; +#endif break; case 16000: #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB @@ -315,12 +406,33 @@ ivas_error ivas_HRTF_statistics_init( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); } - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_16kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_16kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ + floatToFixed_arr32( (float*) defaultHRIR_coherence_16kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + + printf( "\naverage_energy_l = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); + } + printf( "};\n" ); + + printf( "average_energy_r = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) + { + printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); + } + printf( "};\n" ); + + printf( "inter_aural_coherence = {\n" ); + for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) + { + printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); + } + printf( "};\n" ); #else HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx; diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 183a025a8..017703460 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -357,10 +357,22 @@ extern const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ + #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern const float defaultHRIR_coherence_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ + +extern const float defaultHRIR_coherence_32kHz[LR_IAC_LENGTH_NR_FC]; +extern const float defaultHRIR_left_avg_power_32kHz[LR_IAC_LENGTH_NR_FC]; +extern const float defaultHRIR_right_avg_power_32kHz[LR_IAC_LENGTH_NR_FC]; + +extern const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC]; +extern const float defaultHRIR_left_avg_power_48kHz[LR_IAC_LENGTH_NR_FC]; +extern const float defaultHRIR_right_avg_power_48kHz[LR_IAC_LENGTH_NR_FC]; #else extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index b4ebfe6e5..405f26ca7 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59934,9 +59934,203 @@ const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 1708239,1437966,1167685,1059573,1059573 }; #else -/* Sample Rate = 16000 */ -const float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +/********************** default HRIR reverb rom tables **********************/ + +/* Sample Rate = 48000 */ + +const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC] = + {0.997092f, 0.947391f, 0.799213f, 0.575216f, 0.335047f, 0.138324f, 0.007933f, 0.000000f, 0.000000f, + 0.000000f, 0.008438f, 0.037607f, 0.044493f, 0.042149f, 0.041877f, 0.039860f, 0.029404f, 0.015898f, + 0.010316f, 0.014065f, 0.020005f, 0.024518f, 0.029292f, 0.033522f, 0.033418f, 0.029630f, 0.027260f, + 0.027515f, 0.025682f, 0.019571f, 0.013977f, 0.013695f, 0.016531f, 0.016882f, 0.013257f, 0.008483f, + 0.004883f, 0.002525f, 0.001004f, 0.000180f, 0.000000f, 0.000000f, 0.000000f, 0.000785f, 0.003979f, + 0.007082f, 0.009598f, 0.011665f, 0.012700f, 0.011794f, 0.009192f, 0.006164f, 0.003527f, 0.001284f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000894f, 0.002136f, 0.003127f, 0.003616f, + 0.003810f, 0.003754f, 0.003186f, 0.002091f, 0.000823f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.001007f, 0.001843f, 0.002400f, + 0.002505f, 0.002133f, 0.001524f, 0.000903f, 0.000317f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000202f, 0.000867f, 0.001309f, + 0.001553f, 0.001563f, 0.001334f, 0.000961f, 0.000530f, 0.000033f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000278f, 0.000621f, 0.000951f, 0.001272f, 0.001608f, 0.001931f, + 0.002199f, 0.002435f, 0.002687f, 0.002947f, 0.003173f, 0.003370f, 0.003577f, 0.003781f, 0.003920f, + 0.003978f, 0.003985f, 0.003937f, 0.003783f, 0.003511f, 0.003170f, 0.002788f, 0.002337f, 0.001808f, + 0.001255f, 0.000716f, 0.000166f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003551f, 0.000000f, 0.000000f, + 0.000000f, 0.005564f, 0.000000f, 0.000000f, 0.000000f, 0.008736f, 0.000000f, 0.000000f, 0.001007f, + 0.011608f, 0.002316f, 0.000000f, 0.000000f, 0.011987f, 0.005591f, 0.000000f, 0.000000f, 0.008714f, + 0.005905f, 0.000000f, 0.000000f, 0.005316f, 0.003972f, 0.000000f, 0.000000f, 0.003403f, 0.002041f, + 0.000000f, 0.000000f, 0.002140f, 0.000245f, 0.000000f}; + +const float defaultHRIR_left_avg_power_48kHz[LR_IAC_LENGTH_NR_FC] = + {0.981018f, 0.973361f, 0.958480f, 0.950611f, 0.953039f, 0.955845f, 0.950660f, 0.942556f, 0.943810f, + 0.958014f, 0.974983f, 0.982099f, 0.977269f, 0.968243f, 0.961714f, 0.957355f, 0.952468f, 0.947771f, + 0.945396f, 0.943711f, 0.938609f, 0.929975f, 0.922937f, 0.921202f, 0.922151f, 0.920926f, 0.917154f, + 0.914393f, 0.914067f, 0.913705f, 0.911632f, 0.910100f, 0.911873f, 0.915812f, 0.918271f, 0.917846f, + 0.916545f, 0.916408f, 0.916915f, 0.916273f, 0.914005f, 0.911339f, 0.909453f, 0.908137f, 0.906301f, + 0.903476f, 0.900479f, 0.898396f, 0.897057f, 0.895115f, 0.891879f, 0.888353f, 0.885879f, 0.884157f, + 0.881651f, 0.877929f, 0.874417f, 0.872453f, 0.871459f, 0.869941f, 0.867796f, 0.866504f, 0.866990f, + 0.868298f, 0.868985f, 0.869170f, 0.870398f, 0.873460f, 0.877373f, 0.880867f, 0.884271f, 0.889105f, + 0.895880f, 0.903280f, 0.909888f, 0.915965f, 0.922776f, 0.930375f, 0.937111f, 0.941667f, 0.944690f, + 0.947747f, 0.950950f, 0.952712f, 0.951893f, 0.949398f, 0.946830f, 0.944212f, 0.940067f, 0.933749f, + 0.926604f, 0.920193f, 0.914164f, 0.906886f, 0.897913f, 0.888731f, 0.880661f, 0.873093f, 0.864556f, + 0.855014f, 0.846098f, 0.839027f, 0.833268f, 0.827720f, 0.822648f, 0.819628f, 0.819557f, 0.821500f, + 0.823986f, 0.826902f, 0.831352f, 0.837670f, 0.844414f, 0.850004f, 0.854617f, 0.859684f, 0.865573f, + 0.870873f, 0.874346f, 0.876636f, 0.879215f, 0.882152f, 0.883944f, 0.883578f, 0.881897f, 0.880319f, + 0.878855f, 0.876201f, 0.871708f, 0.866458f, 0.861964f, 0.858239f, 0.853971f, 0.848551f, 0.843114f, + 0.839005f, 0.835832f, 0.831994f, 0.826972f, 0.822069f, 0.818424f, 0.815337f, 0.811300f, 0.806249f, + 0.801664f, 0.798529f, 0.796124f, 0.793286f, 0.790217f, 0.788277f, 0.788174f, 0.789082f, 0.789775f, + 0.790281f, 0.791803f, 0.794902f, 0.798467f, 0.801024f, 0.802713f, 0.804961f, 0.808244f, 0.811142f, + 0.812318f, 0.812488f, 0.813349f, 0.815025f, 0.815968f, 0.815334f, 0.814250f, 0.814149f, 0.814776f, + 0.814769f, 0.813685f, 0.812567f, 0.812562f, 0.813456f, 0.814055f, 0.813739f, 0.813391f, 0.814325f, + 0.816394f, 0.817949f, 0.818173f, 0.818552f, 0.820798f, 0.824070f, 0.826010f, 0.826515f, 0.828132f, + 0.832036f, 0.835874f, 0.837493f, 0.838582f, 0.842046f, 0.847074f, 0.850262f, 0.851182f, 0.852997f, + 0.856510f, 0.857491f, 0.852207f, 0.842444f, 0.831373f, 0.816756f, 0.793031f, 0.759822f, 0.723220f, + 0.686833f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441279f, 0.391675f, 0.324292f, 0.238341f, + 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, + 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, + 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; + +const float defaultHRIR_right_avg_power_48kHz[LR_IAC_LENGTH_NR_FC] = + {0.981020f, 0.973360f, 0.958481f, 0.950613f, 0.953040f, 0.955848f, 0.950658f, 0.942557f, 0.943810f, + 0.958017f, 0.974981f, 0.982098f, 0.977271f, 0.968244f, 0.961715f, 0.957356f, 0.952467f, 0.947770f, + 0.945398f, 0.943710f, 0.938610f, 0.929975f, 0.922938f, 0.921205f, 0.922151f, 0.920926f, 0.917152f, + 0.914393f, 0.914069f, 0.913705f, 0.911630f, 0.910101f, 0.911874f, 0.915811f, 0.918272f, 0.917846f, + 0.916542f, 0.916408f, 0.916918f, 0.916272f, 0.914004f, 0.911340f, 0.909452f, 0.908136f, 0.906302f, + 0.903479f, 0.900480f, 0.898395f, 0.897055f, 0.895119f, 0.891880f, 0.888352f, 0.885878f, 0.884154f, + 0.881649f, 0.877926f, 0.874417f, 0.872450f, 0.871458f, 0.869943f, 0.867797f, 0.866503f, 0.866987f, + 0.868297f, 0.868981f, 0.869171f, 0.870394f, 0.873460f, 0.877377f, 0.880866f, 0.884272f, 0.889105f, + 0.895880f, 0.903282f, 0.909886f, 0.915965f, 0.922778f, 0.930375f, 0.937113f, 0.941665f, 0.944689f, + 0.947744f, 0.950952f, 0.952711f, 0.951895f, 0.949398f, 0.946830f, 0.944209f, 0.940067f, 0.933750f, + 0.926601f, 0.920191f, 0.914167f, 0.906884f, 0.897916f, 0.888731f, 0.880663f, 0.873093f, 0.864559f, + 0.855017f, 0.846098f, 0.839028f, 0.833267f, 0.827717f, 0.822649f, 0.819631f, 0.819558f, 0.821499f, + 0.823985f, 0.826902f, 0.831353f, 0.837669f, 0.844416f, 0.850003f, 0.854616f, 0.859686f, 0.865572f, + 0.870872f, 0.874347f, 0.876635f, 0.879216f, 0.882154f, 0.883942f, 0.883576f, 0.881895f, 0.880318f, + 0.878857f, 0.876202f, 0.871706f, 0.866459f, 0.861965f, 0.858241f, 0.853968f, 0.848548f, 0.843114f, + 0.839005f, 0.835832f, 0.831994f, 0.826974f, 0.822068f, 0.818424f, 0.815335f, 0.811299f, 0.806245f, + 0.801662f, 0.798530f, 0.796124f, 0.793287f, 0.790217f, 0.788273f, 0.788173f, 0.789081f, 0.789770f, + 0.790279f, 0.791801f, 0.794900f, 0.798466f, 0.801028f, 0.802711f, 0.804962f, 0.808246f, 0.811143f, + 0.812318f, 0.812490f, 0.813348f, 0.815027f, 0.815969f, 0.815335f, 0.814254f, 0.814150f, 0.814776f, + 0.814772f, 0.813686f, 0.812569f, 0.812558f, 0.813456f, 0.814055f, 0.813736f, 0.813389f, 0.814324f, + 0.816395f, 0.817948f, 0.818173f, 0.818549f, 0.820796f, 0.824069f, 0.826013f, 0.826514f, 0.828134f, + 0.832033f, 0.835874f, 0.837493f, 0.838582f, 0.842047f, 0.847077f, 0.850263f, 0.851184f, 0.852998f, + 0.856513f, 0.857491f, 0.852209f, 0.842446f, 0.831375f, 0.816757f, 0.793032f, 0.759821f, 0.723221f, + 0.686832f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441280f, 0.391676f, 0.324293f, 0.238342f, + 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, + 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, + 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; + +/* Sample Rate = 32000 */ + +const float defaultHRIR_coherence_32kHz[LR_IAC_LENGTH_NR_FC] = + {0.992805f, 0.970760f, 0.904274f, 0.794804f, 0.650716f, 0.489140f, 0.331131f, 0.193608f, 0.084875f, + 0.006016f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.006084f, 0.028478f, 0.040113f, + 0.042718f, 0.041091f, 0.039575f, 0.039321f, 0.038312f, 0.033935f, 0.025743f, 0.016207f, 0.009052f, + 0.006651f, 0.008629f, 0.012678f, 0.016595f, 0.019686f, 0.022543f, 0.025721f, 0.028716f, 0.030244f, + 0.029496f, 0.027051f, 0.024537f, 0.023327f, 0.023382f, 0.023280f, 0.021454f, 0.017604f, 0.013058f, + 0.009830f, 0.009160f, 0.010653f, 0.012635f, 0.013369f, 0.012139f, 0.009418f, 0.006248f, 0.003470f, + 0.001368f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.001485f, 0.003632f, 0.005492f, 0.007105f, 0.008527f, 0.009629f, + 0.010103f, 0.009685f, 0.008382f, 0.006502f, 0.004466f, 0.002568f, 0.000890f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000067f, 0.000797f, 0.001293f, 0.001577f, 0.001732f, 0.001797f, 0.001717f, 0.001403f, 0.000826f, + 0.000060f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000318f, 0.000795f, 0.001124f, 0.001249f, 0.001151f, 0.000871f, 0.000495f, 0.000102f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000206f, 0.000612f, 0.000908f, 0.001107f, + 0.001211f, 0.001209f, 0.001095f, 0.000883f, 0.000607f, 0.000298f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000029f, 0.000144f, 0.000254f, 0.000368f, 0.000486f, 0.000599f, + 0.000706f, 0.000810f, 0.000925f, 0.001059f, 0.001209f, 0.001367f, 0.001526f, 0.001686f, 0.001850f, + 0.002018f, 0.002181f, 0.002324f, 0.002440f, 0.002532f, 0.002614f, 0.002696f, 0.002779f, 0.002860f, + 0.002941f, 0.003036f, 0.003166f, 0.003347f, 0.003580f, 0.003855f, 0.004158f, 0.004487f, 0.004850f, + 0.005251f, 0.005688f, 0.006141f, 0.006591f, 0.007029f, 0.007462f, 0.007902f, 0.008351f, 0.008798f, + 0.009224f, 0.009620f, 0.009991f, 0.010352f, 0.010711f, 0.011057f, 0.011367f, 0.011621f, 0.011817f, + 0.011973f, 0.012106f, 0.012223f, 0.012309f, 0.012340f}; + + +const float defaultHRIR_left_avg_power_32kHz[LR_IAC_LENGTH_NR_FC] = + {1.030501f, 1.026884f, 1.017950f, 1.008331f, 1.002600f, 1.002689f, 1.006923f, 1.011298f, 1.012169f, + 1.008564f, 1.002836f, 0.999190f, 1.001098f, 1.009190f, 1.020853f, 1.031695f, 1.037922f, 1.038190f, + 1.033894f, 1.027913f, 1.022760f, 1.019333f, 1.016935f, 1.014341f, 1.010980f, 1.007343f, 1.004372f, + 1.002476f, 1.000944f, 0.998381f, 0.993744f, 0.987300f, 0.980631f, 0.975661f, 0.973406f, 0.973314f, + 0.973708f, 0.972973f, 0.970597f, 0.967379f, 0.964640f, 0.963173f, 0.962707f, 0.962251f, 0.960983f, + 0.959006f, 0.957269f, 0.956892f, 0.958263f, 0.960779f, 0.963180f, 0.964405f, 0.964185f, 0.963091f, + 0.962007f, 0.961501f, 0.961514f, 0.961497f, 0.960845f, 0.959307f, 0.957094f, 0.954689f, 0.952548f, + 0.950838f, 0.949382f, 0.947807f, 0.945783f, 0.943211f, 0.940296f, 0.937430f, 0.934938f, 0.932866f, + 0.930925f, 0.928674f, 0.925802f, 0.922364f, 0.918772f, 0.915508f, 0.912798f, 0.910417f, 0.907879f, + 0.904771f, 0.901065f, 0.897182f, 0.893708f, 0.890989f, 0.888922f, 0.887041f, 0.884873f, 0.882294f, + 0.879602f, 0.877334f, 0.875865f, 0.875169f, 0.874822f, 0.874316f, 0.873406f, 0.872264f, 0.871377f, + 0.871228f, 0.871946f, 0.873284f, 0.874764f, 0.876044f, 0.877146f, 0.878469f, 0.880494f, 0.883471f, + 0.887228f, 0.891261f, 0.895055f, 0.898401f, 0.901497f, 0.904769f, 0.908500f, 0.912597f, 0.916577f, + 0.919848f, 0.922085f, 0.923416f, 0.924327f, 0.925296f, 0.926465f, 0.927512f, 0.927876f, 0.927108f, + 0.925203f, 0.922559f, 0.919733f, 0.917037f, 0.914341f, 0.911186f, 0.907145f, 0.902128f, 0.896510f, + 0.890876f, 0.885647f, 0.880803f, 0.875934f, 0.870521f, 0.864338f, 0.857593f, 0.850818f, 0.844491f, + 0.838728f, 0.833217f, 0.827473f, 0.821173f, 0.814417f, 0.807660f, 0.801457f, 0.796095f, 0.791458f, + 0.787181f, 0.782928f, 0.778681f, 0.774802f, 0.771808f, 0.770061f, 0.769530f, 0.769827f, 0.770454f, + 0.771132f, 0.771943f, 0.773228f, 0.775315f, 0.778206f, 0.781513f, 0.784677f, 0.787274f, 0.789288f, + 0.791065f, 0.793055f, 0.795463f, 0.798095f, 0.800470f, 0.802135f, 0.802987f, 0.803318f, 0.803610f, + 0.804182f, 0.804958f, 0.805536f, 0.805434f, 0.804413f, 0.802618f, 0.800482f, 0.798381f, 0.796424f, + 0.794397f, 0.791922f, 0.788779f, 0.785087f, 0.781262f, 0.777778f, 0.774863f, 0.772372f, 0.769886f, + 0.767005f, 0.763613f, 0.759968f, 0.756518f, 0.753595f, 0.751171f, 0.748880f, 0.746246f, 0.743010f, + 0.739317f, 0.735608f, 0.732307f, 0.729533f, 0.727006f, 0.724256f, 0.720938f, 0.717104f, 0.713138f, + 0.709525f, 0.706513f, 0.703976f, 0.701515f, 0.698771f, 0.695693f, 0.692572f, 0.689860f, 0.687867f, + 0.686574f, 0.685644f, 0.684672f, 0.683452f, 0.682093f, 0.680935f, 0.680291f, 0.680231f, 0.680501f, + 0.680700f, 0.680500f, 0.679869f, 0.679047f, 0.678394f, 0.678091f, 0.678035f, 0.677888f, 0.677314f, + 0.676218f, 0.674814f, 0.673484f, 0.672514f, 0.671917f, 0.671422f, 0.670711f, 0.669654f, 0.668436f, + 0.667417f, 0.666896f, 0.666879f, 0.667100f, 0.667225f}; + +const float defaultHRIR_right_avg_power_32kHz[LR_IAC_LENGTH_NR_FC] = + {1.030502f, 1.026883f, 1.017953f, 1.008327f, 1.002600f, 1.002691f, 1.006922f, 1.011300f, 1.012168f, + 1.008564f, 1.002837f, 0.999188f, 1.001094f, 1.009186f, 1.020854f, 1.031695f, 1.037923f, 1.038191f, + 1.033893f, 1.027913f, 1.022760f, 1.019332f, 1.016931f, 1.014338f, 1.010982f, 1.007343f, 1.004370f, + 1.002473f, 1.000948f, 0.998380f, 0.993744f, 0.987300f, 0.980628f, 0.975661f, 0.973406f, 0.973316f, + 0.973710f, 0.972971f, 0.970599f, 0.967380f, 0.964639f, 0.963173f, 0.962708f, 0.962246f, 0.960984f, + 0.959004f, 0.957270f, 0.956889f, 0.958265f, 0.960778f, 0.963180f, 0.964406f, 0.964189f, 0.963091f, + 0.962005f, 0.961500f, 0.961514f, 0.961496f, 0.960845f, 0.959306f, 0.957092f, 0.954688f, 0.952548f, + 0.950838f, 0.949380f, 0.947808f, 0.945783f, 0.943212f, 0.940298f, 0.937430f, 0.934937f, 0.932865f, + 0.930925f, 0.928674f, 0.925801f, 0.922365f, 0.918770f, 0.915509f, 0.912795f, 0.910417f, 0.907881f, + 0.904769f, 0.901065f, 0.897183f, 0.893709f, 0.890990f, 0.888922f, 0.887040f, 0.884874f, 0.882293f, + 0.879603f, 0.877335f, 0.875867f, 0.875169f, 0.874820f, 0.874318f, 0.873404f, 0.872263f, 0.871381f, + 0.871226f, 0.871950f, 0.873283f, 0.874763f, 0.876042f, 0.877147f, 0.878470f, 0.880494f, 0.883473f, + 0.887227f, 0.891261f, 0.895053f, 0.898401f, 0.901500f, 0.904769f, 0.908500f, 0.912599f, 0.916578f, + 0.919847f, 0.922084f, 0.923417f, 0.924328f, 0.925296f, 0.926463f, 0.927512f, 0.927872f, 0.927107f, + 0.925199f, 0.922559f, 0.919735f, 0.917037f, 0.914339f, 0.911186f, 0.907142f, 0.902131f, 0.896510f, + 0.890876f, 0.885644f, 0.880802f, 0.875934f, 0.870524f, 0.864337f, 0.857594f, 0.850819f, 0.844491f, + 0.838727f, 0.833219f, 0.827473f, 0.821173f, 0.814415f, 0.807662f, 0.801459f, 0.796094f, 0.791462f, + 0.787182f, 0.782926f, 0.778681f, 0.774803f, 0.771810f, 0.770061f, 0.769529f, 0.769825f, 0.770456f, + 0.771131f, 0.771940f, 0.773230f, 0.775319f, 0.778206f, 0.781513f, 0.784675f, 0.787274f, 0.789285f, + 0.791065f, 0.793054f, 0.795465f, 0.798097f, 0.800468f, 0.802133f, 0.802987f, 0.803319f, 0.803610f, + 0.804179f, 0.804959f, 0.805538f, 0.805434f, 0.804411f, 0.802621f, 0.800480f, 0.798379f, 0.796426f, + 0.794398f, 0.791920f, 0.788777f, 0.785087f, 0.781263f, 0.777777f, 0.774862f, 0.772372f, 0.769886f, + 0.767004f, 0.763614f, 0.759968f, 0.756517f, 0.753593f, 0.751172f, 0.748881f, 0.746246f, 0.743011f, + 0.739318f, 0.735608f, 0.732306f, 0.729532f, 0.727006f, 0.724254f, 0.720939f, 0.717103f, 0.713136f, + 0.709524f, 0.706514f, 0.703976f, 0.701513f, 0.698772f, 0.695692f, 0.692570f, 0.689859f, 0.687869f, + 0.686573f, 0.685642f, 0.684671f, 0.683452f, 0.682094f, 0.680934f, 0.680290f, 0.680228f, 0.680501f, + 0.680699f, 0.680498f, 0.679867f, 0.679050f, 0.678395f, 0.678093f, 0.678035f, 0.677889f, 0.677315f, + 0.676220f, 0.674814f, 0.673485f, 0.672517f, 0.671918f, 0.671424f, 0.670712f, 0.669657f, 0.668437f, + 0.667421f, 0.666896f, 0.666880f, 0.667103f, 0.667228f}; + +/* Sample Rate = 16000 */ +// Floating point +const float defaultHRIR_coherence_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = {0.983044f, 0.960794f, 0.893756f, 0.783586f, 0.638963f, 0.477338f, 0.319879f, 0.183374f, 0.075909f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003842f, 0.025288f, 0.035886f, 0.037785f, 0.035991f, 0.034784f, 0.035091f, 0.034683f, 0.030849f, 0.023146f, 0.014061f, 0.007275f, @@ -59953,7 +60147,7 @@ const float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = 0.000000f, 0.002101f, 0.004247f, 0.006330f, 0.008300f, 0.010110f, 0.011735f, 0.013165f, 0.014384f, 0.015345f, 0.015972f, 0.016191f}; -const float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = {1.118974f, 1.115256f, 1.106210f, 1.096901f, 1.092316f, 1.094422f, 1.101140f, 1.107775f, 1.110000f, 1.106535f, 1.099921f, 1.094914f, 1.095643f, 1.103178f, 1.114955f, 1.126292f, 1.132973f, 1.133288f, 1.128471f, 1.121439f, 1.114842f, 1.109721f, 1.105480f, 1.100966f, 1.095650f, 1.090074f, 1.085225f, @@ -59970,7 +60164,7 @@ const float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = 0.408842f, 0.386537f, 0.364126f, 0.342284f, 0.321675f, 0.302809f, 0.286016f, 0.271536f, 0.259639f, 0.250691f, 0.245099f, 0.243192f}; -const float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = {1.118974f, 1.115254f, 1.106207f, 1.096903f, 1.092317f, 1.094425f, 1.101145f, 1.107775f, 1.109999f, 1.106540f, 1.099921f, 1.094912f, 1.095644f, 1.103178f, 1.114952f, 1.126292f, 1.132973f, 1.133288f, 1.128472f, 1.121439f, 1.114842f, 1.109719f, 1.105481f, 1.100965f, 1.095650f, 1.090072f, 1.085224f, @@ -59987,6 +60181,69 @@ const float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = 0.408843f, 0.386537f, 0.364127f, 0.342285f, 0.321676f, 0.302809f, 0.286016f, 0.271535f, 0.259640f, 0.250692f, 0.245099f, 0.243192f}; +// Fixed-point +const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +{ + 131941936, 128955584, 119957896, 105171136, 85760160, 64067220, 42933432, 24612042, + 10188334, 0, 0, 0, 0, 0, 0, 515664, + 3394098, 4816537, 5071417, 4830630, 4668629, 4709834, 4655073, 4140482, + 3106603, 1887235, 976434, 678202, 930128, 1421231, 1866297, 2186138, + 2470143, 2798305, 3109019, 3241224, 3100161, 2769582, 2459539, 2332838, + 2363708, 2353373, 2100507, 1581890, 985426, 575794, 500900, 690952, + 917780, 962609, 748800, 353261, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 31943, 233270, 404129, 524791, + 552977, 455534, 237431, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 281991, 570022, + 849598, 1114007, 1356941, 1575045, 1766976, 1930587, 2059571, 2143725, + 2173119 +}; + +const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +{ + 9386634, 9355445, 9279562, 9201473, 9163011, 9180677, 9237032, 9292690, + 9311355, 9282288, 9226806, 9184804, 9190920, 9254128, 9352920, 9448022, + 9504066, 9506709, 9466301, 9407312, 9351973, 9309014, 9273438, 9235572, + 9190978, 9144203, 9103527, 9072489, 9045159, 9009583, 8957163, 8890574, + 8823608, 8772571, 8745384, 8736165, 8729244, 8709816, 8673066, 8625888, + 8580254, 8543915, 8515712, 8488416, 8456111, 8420166, 8388541, 8369901, + 8366370, 8371495, 8374003, 8364927, 8342521, 8312129, 8281292, 8254415, + 8230340, 8203924, 8170085, 8127194, 8077516, 8025297, 7974076, 7924542, + 7874755, 7821529, 7762583, 7697915, 7630009, 7562422, 7497771, 7436123, + 7374886, 7310361, 7240560, 7166262, 7091175, 7019084, 6951270, 6885512, + 6817531, 6744105, 6665286, 6584654, 6506481, 6433064, 6363086, 6292764, + 6218727, 6140494, 6060970, 5984324, 5913289, 5847338, 5783265, 5717474, + 5648469, 5577845, 5508824, 5444181, 5383817, 5324753, 5262652, 5194159, + 5118611, 5037577, 4952986, 4864990, 4771121, 4667287, 4549888, 4417843, + 4272779, 4117833, 3955581, 3787012, 3611715, 3429615, 3242507, 3054510, + 2871286, 2698405, 2540146, 2399276, 2277809, 2178009, 2102948, 2056039, + 2040042 +}; + +const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = +{ + 9386634, 9355429, 9279537, 9201489, 9163019, 9180702, 9237074, 9292690, + 9311346, 9282330, 9226806, 9184788, 9190928, 9254128, 9352895, 9448022, + 9504066, 9506709, 9466309, 9407312, 9351973, 9308998, 9273447, 9235564, + 9190978, 9144187, 9103519, 9072506, 9045184, 9009575, 8957146, 8890582, + 8823608, 8772571, 8745401, 8736173, 8729278, 8709825, 8673074, 8625888, + 8580237, 8543898, 8515721, 8488424, 8456136, 8420166, 8388566, 8369893, + 8366370, 8371487, 8374003, 8364935, 8342546, 8312129, 8281267, 8254415, + 8230340, 8203916, 8170076, 8127185, 8077508, 8025289, 7974068, 7924558, + 7874764, 7821529, 7762591, 7697907, 7630001, 7562422, 7497771, 7436132, + 7374870, 7310395, 7240526, 7166270, 7091175, 7019084, 6951270, 6885503, + 6817522, 6744113, 6665311, 6584646, 6506464, 6433072, 6363094, 6292781, + 6218727, 6140503, 6060962, 5984332, 5913297, 5847338, 5783257, 5717465, + 5648486, 5577837, 5508849, 5444190, 5383825, 5324769, 5262635, 5194159, + 5118619, 5037585, 4952986, 4864998, 4771130, 4667279, 4549888, 4417827, + 4272779, 4117825, 3955589, 3787003, 3611715, 3429623, 3242507, 3054518, + 2871294, 2698413, 2540146, 2399276, 2277800, 2178018, 2102957, 2056039, + 2040042 +}; #endif #endif -- GitLab From f8edfde8bfa607f535f83affcf8ac6178ac2fb31 Mon Sep 17 00:00:00 2001 From: Devansh Kandpal <43807487+mrkandpal@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:36:43 +0200 Subject: [PATCH 418/692] Code Cleanup --- lib_rend/ivas_hrtf_fx.c | 137 -------- lib_rend/ivas_rom_binaural_crend_head_fx.c | 345 --------------------- 2 files changed, 482 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 5729337d4..13b5ae5cb 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -289,156 +289,19 @@ ivas_error ivas_HRTF_statistics_init( switch ( sampleRate ) { case 48000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_48kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_48kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float*) defaultHRIR_coherence_48kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - // TODO: dump the converted fixed point arrays to an array - printf( "average_energy_l = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); - } - printf( "};\n" ); - - printf( "average_energy_r = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); - } - printf( "};\n" ); - - printf( "inter_aural_coherence = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); - } - printf( "};\n" ); -#else HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx; -#endif break; case 32000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); - if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_32kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float *) defaultHRIR_right_avg_power_32kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float *) defaultHRIR_coherence_32kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - // TODO: dump the converted fixed point arrays to a string - - printf( "average_energy_l = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); - } - printf( "};\n" ); - - printf( "average_energy_r = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); - } - printf( "};\n" ); - - printf( "inter_aural_coherence = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC; i++ ) - { - printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); - } - printf( "};\n" ); -#else HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx; -#endif break; case 16000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB - HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); - if ( HrtfStatistics->average_energy_l_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); - if ( HrtfStatistics->average_energy_r_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); - if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - floatToFixed_arr32( (float*) defaultHRIR_left_avg_power_16kHz, HrtfStatistics->average_energy_l_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float*) defaultHRIR_right_avg_power_16kHz, HrtfStatistics->average_energy_r_dyn, Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=2 */ - floatToFixed_arr32( (float*) defaultHRIR_coherence_16kHz, HrtfStatistics->inter_aural_coherence_dyn, Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; - HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; - HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; - - printf( "\naverage_energy_l = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_l_dyn[i] ); - } - printf( "};\n" ); - - printf( "average_energy_r = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) - { - printf( "%d, ", HrtfStatistics->average_energy_r_dyn[i] ); - } - printf( "};\n" ); - - printf( "inter_aural_coherence = {\n" ); - for ( int i = 0; i < LR_IAC_LENGTH_NR_FC_16KHZ; i++ ) - { - printf( "%d, ", HrtfStatistics->inter_aural_coherence_dyn[i] ); - } - printf( "};\n" ); -#else - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx; -#endif break; } HrtfStatistics->fromROM = TRUE; diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 405f26ca7..df78d5b25 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59838,350 +59838,6 @@ const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 2790378,2355663,2029237,1865240,1832432 }; -#ifndef NONBE_FIX_AVG_IAC_CLDFB_REVERB - -const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, - 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, - 1532229,985023,437818,0,0,0,0,0,0, - 0,343865,773496,1203261,2004810,3054258,4103707,4777480,4887673, - 4998000,5066316,4966727,4867271,4767816,4765534,4763253,4760971,4569174, - 4329998,4090822,3659312,3099355,2539533,2037290,1621350,1205543,880065, - 916304,952677,988916,1233058,1477200,1721342,1912602,2090441,2268413, - 2427327,2573490,2719788,2859643,2989834,3120025,3219078,3193576,3168075, - 3142574,2987686,2832665,2677778,2583691,2504771,2425851,2397128,2401692, - 2406255,2356594,2225464,2094333,1933137,1651280,1369423,1087566,924357, - 761148,597940,625051,699677,774302,854295,937779,1021128,1026631, - 915230,803830,670014,446676,223338,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,5100,30735, - 56371,81872,173140,264408,355542,419698,477144,534455,552037, - 543044,533918,485599,378494,271254,173946,115964,57982,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,671,1476,2415,99723,261321,423054,646795, - 963549,1280302,1632087,2124129,2616037,3108080,3841982,4575885,5309922, - 6280181,7309766,8339216,8750996,8750996 -}; -const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269680,9222847,9180350,9155201,9130044,9104894, - 9126688,9148473,9170267,9191549,9212688,9233844,9234423,9221295,9208167, - 9191205,9168497,9145789,9127997,9129884,9131780,9133676,9164823,9195978, - 9227125,9267550,9310290,9353038,9385225,9410374,9435531,9445170,9431538, - 9417907,9399855,9364128,9328409,9292682,9270670,9248667,9226655,9215783, - 9207688,9199593,9183605,9162356,9141108,9116244,9085961,9055678,9028608, - 9014432,9000255,8986078,8975962,8965845,8955728,8926108,8891606,8857103, - 8819145,8778896,8738639,8710806,8701604,8692401,8686227,8692209,8698190, - 8704171,8686706,8669232,8651767,8623917,8593466,8563024,8543554,8531399, - 8519252,8509748,8504203,8498667,8489716,8467083,8444459,8421835,8399773, - 8377711,8355649,8351698,8352268,8352847,8355833,8360430,8365027,8363484, - 8352721,8341959,8331028,8319460,8307884,8296308,8292063,8287827,8283582, - 8271142,8256647,8242159,8221389,8196442,8171494,8150547,8135607,8120659, - 8106465,8095225,8083992,8072760,8043073,8013394,7983706,7949422,7913997, - 7878564,7853893,7836394,7818904,7801472,7784141,7766811,7744782,7703972, - 7663169,7622359,7580802,7539253,7497696,7474266,7455367,7436467,7415496, - 7393140,7370784,7338471,7291235,7244007,7197551,7154232,7110914,7067595, - 7046615,7025627,7004647,6977485,6948779,6920073,6878751,6829015,6779278, - 6733644,6694184,6654724,6618804,6597044,6575284,6553524,6518183,6482842, - 6447501,6401632,6353137,6304634,6267229,6237215,6207201,6181045,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896503,5850198,5825150, - 5805428,5785707,5765742,5745626,5725510,5693398,5643285,5593180,5544358, - 5500720,5457091,5413454,5404126,5394797,5385469,5366930,5346085,5325239, - 5282164,5224274,5166376,5115566,5075376,5035186,5002731,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773822,4700355,4646282,4605153, - 4564023,4540250,4542523,4544788,4536869,4488241,4439612,4390983,4285488, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957300,3691818,3426335,3160861,2774481,2388110,2001740, - 1708239,1437966,1167685,1059581,1059581 -}; -const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269689,9222855,9180358,9155201,9130035,9104869, - 9126663,9148465,9170258,9191540,9212688,9233827,9234415,9221295,9208175, - 9191213,9168488,9145755,9127963,9129867,9131772,9133676,9164831,9195978, - 9227133,9267550,9310281,9353021,9385200,9410357,9435506,9445153,9431522, - 9417899,9399855,9364119,9328384,9292648,9270653,9248658,9226663,9215792, - 9207688,9199593,9183596,9162348,9141100,9116236,9085953,9055678,9028617, - 9014432,9000255,8986070,8975962,8965853,8955745,8926116,8891614,8857103, - 8819145,8778888,8738631,8710789,8701587,8692385,8686219,8692200,8698181, - 8704162,8686697,8669232,8651775,8623917,8593466,8563016,8543546,8531390, - 8519244,8509739,8504203,8498675,8489724,8467100,8444468,8421844,8399773, - 8377703,8355641,8351681,8352252,8352830,8355817,8360414,8365019,8363475, - 8352721,8341959,8331037,8319469,8307893,8296316,8292072,8287835,8283591, - 8271142,8256647,8242151,8221381,8196433,8171494,8150547,8135616,8120676, - 8106482,8095250,8084009,8072777,8043081,8013385,7983698,7949405,7913972, - 7878547,7853876,7836386,7818904,7801481,7784150,7766819,7744790,7703980, - 7663161,7622350,7580793,7539244,7497696,7474258,7455358,7436459,7415487, - 7393132,7370776,7338471,7291244,7244016,7197560,7154241,7110914,7067587, - 7046607,7025627,7004647,6977485,6948770,6920064,6878742,6829006,6779270, - 6733644,6694184,6654724,6618813,6597053,6575301,6553549,6518191,6482842, - 6447492,6401623,6353137,6304643,6267229,6237215,6207201,6181037,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896512,5850207,5825167, - 5805445,5785723,5765750,5745626,5725493,5693382,5643276,5593180,5544375, - 5500729,5457074,5413429,5404109,5394789,5385478,5366939,5346093,5325247, - 5282172,5224282,5166384,5115574,5075384,5035195,5002739,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773814,4700338,4646274,4605153, - 4564023,4540258,4542523,4544788,4536878,4488249,4439612,4390983,4285480, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957292,3691809,3426327,3160844,2774473,2388110,2001740, - 1708239,1437966,1167685,1059573,1059573 -}; -#else - -/********************** default HRIR reverb rom tables **********************/ - -/* Sample Rate = 48000 */ - -const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC] = - {0.997092f, 0.947391f, 0.799213f, 0.575216f, 0.335047f, 0.138324f, 0.007933f, 0.000000f, 0.000000f, - 0.000000f, 0.008438f, 0.037607f, 0.044493f, 0.042149f, 0.041877f, 0.039860f, 0.029404f, 0.015898f, - 0.010316f, 0.014065f, 0.020005f, 0.024518f, 0.029292f, 0.033522f, 0.033418f, 0.029630f, 0.027260f, - 0.027515f, 0.025682f, 0.019571f, 0.013977f, 0.013695f, 0.016531f, 0.016882f, 0.013257f, 0.008483f, - 0.004883f, 0.002525f, 0.001004f, 0.000180f, 0.000000f, 0.000000f, 0.000000f, 0.000785f, 0.003979f, - 0.007082f, 0.009598f, 0.011665f, 0.012700f, 0.011794f, 0.009192f, 0.006164f, 0.003527f, 0.001284f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000894f, 0.002136f, 0.003127f, 0.003616f, - 0.003810f, 0.003754f, 0.003186f, 0.002091f, 0.000823f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.001007f, 0.001843f, 0.002400f, - 0.002505f, 0.002133f, 0.001524f, 0.000903f, 0.000317f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000202f, 0.000867f, 0.001309f, - 0.001553f, 0.001563f, 0.001334f, 0.000961f, 0.000530f, 0.000033f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000278f, 0.000621f, 0.000951f, 0.001272f, 0.001608f, 0.001931f, - 0.002199f, 0.002435f, 0.002687f, 0.002947f, 0.003173f, 0.003370f, 0.003577f, 0.003781f, 0.003920f, - 0.003978f, 0.003985f, 0.003937f, 0.003783f, 0.003511f, 0.003170f, 0.002788f, 0.002337f, 0.001808f, - 0.001255f, 0.000716f, 0.000166f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003551f, 0.000000f, 0.000000f, - 0.000000f, 0.005564f, 0.000000f, 0.000000f, 0.000000f, 0.008736f, 0.000000f, 0.000000f, 0.001007f, - 0.011608f, 0.002316f, 0.000000f, 0.000000f, 0.011987f, 0.005591f, 0.000000f, 0.000000f, 0.008714f, - 0.005905f, 0.000000f, 0.000000f, 0.005316f, 0.003972f, 0.000000f, 0.000000f, 0.003403f, 0.002041f, - 0.000000f, 0.000000f, 0.002140f, 0.000245f, 0.000000f}; - -const float defaultHRIR_left_avg_power_48kHz[LR_IAC_LENGTH_NR_FC] = - {0.981018f, 0.973361f, 0.958480f, 0.950611f, 0.953039f, 0.955845f, 0.950660f, 0.942556f, 0.943810f, - 0.958014f, 0.974983f, 0.982099f, 0.977269f, 0.968243f, 0.961714f, 0.957355f, 0.952468f, 0.947771f, - 0.945396f, 0.943711f, 0.938609f, 0.929975f, 0.922937f, 0.921202f, 0.922151f, 0.920926f, 0.917154f, - 0.914393f, 0.914067f, 0.913705f, 0.911632f, 0.910100f, 0.911873f, 0.915812f, 0.918271f, 0.917846f, - 0.916545f, 0.916408f, 0.916915f, 0.916273f, 0.914005f, 0.911339f, 0.909453f, 0.908137f, 0.906301f, - 0.903476f, 0.900479f, 0.898396f, 0.897057f, 0.895115f, 0.891879f, 0.888353f, 0.885879f, 0.884157f, - 0.881651f, 0.877929f, 0.874417f, 0.872453f, 0.871459f, 0.869941f, 0.867796f, 0.866504f, 0.866990f, - 0.868298f, 0.868985f, 0.869170f, 0.870398f, 0.873460f, 0.877373f, 0.880867f, 0.884271f, 0.889105f, - 0.895880f, 0.903280f, 0.909888f, 0.915965f, 0.922776f, 0.930375f, 0.937111f, 0.941667f, 0.944690f, - 0.947747f, 0.950950f, 0.952712f, 0.951893f, 0.949398f, 0.946830f, 0.944212f, 0.940067f, 0.933749f, - 0.926604f, 0.920193f, 0.914164f, 0.906886f, 0.897913f, 0.888731f, 0.880661f, 0.873093f, 0.864556f, - 0.855014f, 0.846098f, 0.839027f, 0.833268f, 0.827720f, 0.822648f, 0.819628f, 0.819557f, 0.821500f, - 0.823986f, 0.826902f, 0.831352f, 0.837670f, 0.844414f, 0.850004f, 0.854617f, 0.859684f, 0.865573f, - 0.870873f, 0.874346f, 0.876636f, 0.879215f, 0.882152f, 0.883944f, 0.883578f, 0.881897f, 0.880319f, - 0.878855f, 0.876201f, 0.871708f, 0.866458f, 0.861964f, 0.858239f, 0.853971f, 0.848551f, 0.843114f, - 0.839005f, 0.835832f, 0.831994f, 0.826972f, 0.822069f, 0.818424f, 0.815337f, 0.811300f, 0.806249f, - 0.801664f, 0.798529f, 0.796124f, 0.793286f, 0.790217f, 0.788277f, 0.788174f, 0.789082f, 0.789775f, - 0.790281f, 0.791803f, 0.794902f, 0.798467f, 0.801024f, 0.802713f, 0.804961f, 0.808244f, 0.811142f, - 0.812318f, 0.812488f, 0.813349f, 0.815025f, 0.815968f, 0.815334f, 0.814250f, 0.814149f, 0.814776f, - 0.814769f, 0.813685f, 0.812567f, 0.812562f, 0.813456f, 0.814055f, 0.813739f, 0.813391f, 0.814325f, - 0.816394f, 0.817949f, 0.818173f, 0.818552f, 0.820798f, 0.824070f, 0.826010f, 0.826515f, 0.828132f, - 0.832036f, 0.835874f, 0.837493f, 0.838582f, 0.842046f, 0.847074f, 0.850262f, 0.851182f, 0.852997f, - 0.856510f, 0.857491f, 0.852207f, 0.842444f, 0.831373f, 0.816756f, 0.793031f, 0.759822f, 0.723220f, - 0.686833f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441279f, 0.391675f, 0.324292f, 0.238341f, - 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, - 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, - 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, - 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, - 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; - -const float defaultHRIR_right_avg_power_48kHz[LR_IAC_LENGTH_NR_FC] = - {0.981020f, 0.973360f, 0.958481f, 0.950613f, 0.953040f, 0.955848f, 0.950658f, 0.942557f, 0.943810f, - 0.958017f, 0.974981f, 0.982098f, 0.977271f, 0.968244f, 0.961715f, 0.957356f, 0.952467f, 0.947770f, - 0.945398f, 0.943710f, 0.938610f, 0.929975f, 0.922938f, 0.921205f, 0.922151f, 0.920926f, 0.917152f, - 0.914393f, 0.914069f, 0.913705f, 0.911630f, 0.910101f, 0.911874f, 0.915811f, 0.918272f, 0.917846f, - 0.916542f, 0.916408f, 0.916918f, 0.916272f, 0.914004f, 0.911340f, 0.909452f, 0.908136f, 0.906302f, - 0.903479f, 0.900480f, 0.898395f, 0.897055f, 0.895119f, 0.891880f, 0.888352f, 0.885878f, 0.884154f, - 0.881649f, 0.877926f, 0.874417f, 0.872450f, 0.871458f, 0.869943f, 0.867797f, 0.866503f, 0.866987f, - 0.868297f, 0.868981f, 0.869171f, 0.870394f, 0.873460f, 0.877377f, 0.880866f, 0.884272f, 0.889105f, - 0.895880f, 0.903282f, 0.909886f, 0.915965f, 0.922778f, 0.930375f, 0.937113f, 0.941665f, 0.944689f, - 0.947744f, 0.950952f, 0.952711f, 0.951895f, 0.949398f, 0.946830f, 0.944209f, 0.940067f, 0.933750f, - 0.926601f, 0.920191f, 0.914167f, 0.906884f, 0.897916f, 0.888731f, 0.880663f, 0.873093f, 0.864559f, - 0.855017f, 0.846098f, 0.839028f, 0.833267f, 0.827717f, 0.822649f, 0.819631f, 0.819558f, 0.821499f, - 0.823985f, 0.826902f, 0.831353f, 0.837669f, 0.844416f, 0.850003f, 0.854616f, 0.859686f, 0.865572f, - 0.870872f, 0.874347f, 0.876635f, 0.879216f, 0.882154f, 0.883942f, 0.883576f, 0.881895f, 0.880318f, - 0.878857f, 0.876202f, 0.871706f, 0.866459f, 0.861965f, 0.858241f, 0.853968f, 0.848548f, 0.843114f, - 0.839005f, 0.835832f, 0.831994f, 0.826974f, 0.822068f, 0.818424f, 0.815335f, 0.811299f, 0.806245f, - 0.801662f, 0.798530f, 0.796124f, 0.793287f, 0.790217f, 0.788273f, 0.788173f, 0.789081f, 0.789770f, - 0.790279f, 0.791801f, 0.794900f, 0.798466f, 0.801028f, 0.802711f, 0.804962f, 0.808246f, 0.811143f, - 0.812318f, 0.812490f, 0.813348f, 0.815027f, 0.815969f, 0.815335f, 0.814254f, 0.814150f, 0.814776f, - 0.814772f, 0.813686f, 0.812569f, 0.812558f, 0.813456f, 0.814055f, 0.813736f, 0.813389f, 0.814324f, - 0.816395f, 0.817948f, 0.818173f, 0.818549f, 0.820796f, 0.824069f, 0.826013f, 0.826514f, 0.828134f, - 0.832033f, 0.835874f, 0.837493f, 0.838582f, 0.842047f, 0.847077f, 0.850263f, 0.851184f, 0.852998f, - 0.856513f, 0.857491f, 0.852209f, 0.842446f, 0.831375f, 0.816757f, 0.793032f, 0.759821f, 0.723221f, - 0.686832f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441280f, 0.391676f, 0.324293f, 0.238342f, - 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, - 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, - 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, - 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, - 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; - -/* Sample Rate = 32000 */ - -const float defaultHRIR_coherence_32kHz[LR_IAC_LENGTH_NR_FC] = - {0.992805f, 0.970760f, 0.904274f, 0.794804f, 0.650716f, 0.489140f, 0.331131f, 0.193608f, 0.084875f, - 0.006016f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.006084f, 0.028478f, 0.040113f, - 0.042718f, 0.041091f, 0.039575f, 0.039321f, 0.038312f, 0.033935f, 0.025743f, 0.016207f, 0.009052f, - 0.006651f, 0.008629f, 0.012678f, 0.016595f, 0.019686f, 0.022543f, 0.025721f, 0.028716f, 0.030244f, - 0.029496f, 0.027051f, 0.024537f, 0.023327f, 0.023382f, 0.023280f, 0.021454f, 0.017604f, 0.013058f, - 0.009830f, 0.009160f, 0.010653f, 0.012635f, 0.013369f, 0.012139f, 0.009418f, 0.006248f, 0.003470f, - 0.001368f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.001485f, 0.003632f, 0.005492f, 0.007105f, 0.008527f, 0.009629f, - 0.010103f, 0.009685f, 0.008382f, 0.006502f, 0.004466f, 0.002568f, 0.000890f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000067f, 0.000797f, 0.001293f, 0.001577f, 0.001732f, 0.001797f, 0.001717f, 0.001403f, 0.000826f, - 0.000060f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000318f, 0.000795f, 0.001124f, 0.001249f, 0.001151f, 0.000871f, 0.000495f, 0.000102f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000206f, 0.000612f, 0.000908f, 0.001107f, - 0.001211f, 0.001209f, 0.001095f, 0.000883f, 0.000607f, 0.000298f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000029f, 0.000144f, 0.000254f, 0.000368f, 0.000486f, 0.000599f, - 0.000706f, 0.000810f, 0.000925f, 0.001059f, 0.001209f, 0.001367f, 0.001526f, 0.001686f, 0.001850f, - 0.002018f, 0.002181f, 0.002324f, 0.002440f, 0.002532f, 0.002614f, 0.002696f, 0.002779f, 0.002860f, - 0.002941f, 0.003036f, 0.003166f, 0.003347f, 0.003580f, 0.003855f, 0.004158f, 0.004487f, 0.004850f, - 0.005251f, 0.005688f, 0.006141f, 0.006591f, 0.007029f, 0.007462f, 0.007902f, 0.008351f, 0.008798f, - 0.009224f, 0.009620f, 0.009991f, 0.010352f, 0.010711f, 0.011057f, 0.011367f, 0.011621f, 0.011817f, - 0.011973f, 0.012106f, 0.012223f, 0.012309f, 0.012340f}; - - -const float defaultHRIR_left_avg_power_32kHz[LR_IAC_LENGTH_NR_FC] = - {1.030501f, 1.026884f, 1.017950f, 1.008331f, 1.002600f, 1.002689f, 1.006923f, 1.011298f, 1.012169f, - 1.008564f, 1.002836f, 0.999190f, 1.001098f, 1.009190f, 1.020853f, 1.031695f, 1.037922f, 1.038190f, - 1.033894f, 1.027913f, 1.022760f, 1.019333f, 1.016935f, 1.014341f, 1.010980f, 1.007343f, 1.004372f, - 1.002476f, 1.000944f, 0.998381f, 0.993744f, 0.987300f, 0.980631f, 0.975661f, 0.973406f, 0.973314f, - 0.973708f, 0.972973f, 0.970597f, 0.967379f, 0.964640f, 0.963173f, 0.962707f, 0.962251f, 0.960983f, - 0.959006f, 0.957269f, 0.956892f, 0.958263f, 0.960779f, 0.963180f, 0.964405f, 0.964185f, 0.963091f, - 0.962007f, 0.961501f, 0.961514f, 0.961497f, 0.960845f, 0.959307f, 0.957094f, 0.954689f, 0.952548f, - 0.950838f, 0.949382f, 0.947807f, 0.945783f, 0.943211f, 0.940296f, 0.937430f, 0.934938f, 0.932866f, - 0.930925f, 0.928674f, 0.925802f, 0.922364f, 0.918772f, 0.915508f, 0.912798f, 0.910417f, 0.907879f, - 0.904771f, 0.901065f, 0.897182f, 0.893708f, 0.890989f, 0.888922f, 0.887041f, 0.884873f, 0.882294f, - 0.879602f, 0.877334f, 0.875865f, 0.875169f, 0.874822f, 0.874316f, 0.873406f, 0.872264f, 0.871377f, - 0.871228f, 0.871946f, 0.873284f, 0.874764f, 0.876044f, 0.877146f, 0.878469f, 0.880494f, 0.883471f, - 0.887228f, 0.891261f, 0.895055f, 0.898401f, 0.901497f, 0.904769f, 0.908500f, 0.912597f, 0.916577f, - 0.919848f, 0.922085f, 0.923416f, 0.924327f, 0.925296f, 0.926465f, 0.927512f, 0.927876f, 0.927108f, - 0.925203f, 0.922559f, 0.919733f, 0.917037f, 0.914341f, 0.911186f, 0.907145f, 0.902128f, 0.896510f, - 0.890876f, 0.885647f, 0.880803f, 0.875934f, 0.870521f, 0.864338f, 0.857593f, 0.850818f, 0.844491f, - 0.838728f, 0.833217f, 0.827473f, 0.821173f, 0.814417f, 0.807660f, 0.801457f, 0.796095f, 0.791458f, - 0.787181f, 0.782928f, 0.778681f, 0.774802f, 0.771808f, 0.770061f, 0.769530f, 0.769827f, 0.770454f, - 0.771132f, 0.771943f, 0.773228f, 0.775315f, 0.778206f, 0.781513f, 0.784677f, 0.787274f, 0.789288f, - 0.791065f, 0.793055f, 0.795463f, 0.798095f, 0.800470f, 0.802135f, 0.802987f, 0.803318f, 0.803610f, - 0.804182f, 0.804958f, 0.805536f, 0.805434f, 0.804413f, 0.802618f, 0.800482f, 0.798381f, 0.796424f, - 0.794397f, 0.791922f, 0.788779f, 0.785087f, 0.781262f, 0.777778f, 0.774863f, 0.772372f, 0.769886f, - 0.767005f, 0.763613f, 0.759968f, 0.756518f, 0.753595f, 0.751171f, 0.748880f, 0.746246f, 0.743010f, - 0.739317f, 0.735608f, 0.732307f, 0.729533f, 0.727006f, 0.724256f, 0.720938f, 0.717104f, 0.713138f, - 0.709525f, 0.706513f, 0.703976f, 0.701515f, 0.698771f, 0.695693f, 0.692572f, 0.689860f, 0.687867f, - 0.686574f, 0.685644f, 0.684672f, 0.683452f, 0.682093f, 0.680935f, 0.680291f, 0.680231f, 0.680501f, - 0.680700f, 0.680500f, 0.679869f, 0.679047f, 0.678394f, 0.678091f, 0.678035f, 0.677888f, 0.677314f, - 0.676218f, 0.674814f, 0.673484f, 0.672514f, 0.671917f, 0.671422f, 0.670711f, 0.669654f, 0.668436f, - 0.667417f, 0.666896f, 0.666879f, 0.667100f, 0.667225f}; - -const float defaultHRIR_right_avg_power_32kHz[LR_IAC_LENGTH_NR_FC] = - {1.030502f, 1.026883f, 1.017953f, 1.008327f, 1.002600f, 1.002691f, 1.006922f, 1.011300f, 1.012168f, - 1.008564f, 1.002837f, 0.999188f, 1.001094f, 1.009186f, 1.020854f, 1.031695f, 1.037923f, 1.038191f, - 1.033893f, 1.027913f, 1.022760f, 1.019332f, 1.016931f, 1.014338f, 1.010982f, 1.007343f, 1.004370f, - 1.002473f, 1.000948f, 0.998380f, 0.993744f, 0.987300f, 0.980628f, 0.975661f, 0.973406f, 0.973316f, - 0.973710f, 0.972971f, 0.970599f, 0.967380f, 0.964639f, 0.963173f, 0.962708f, 0.962246f, 0.960984f, - 0.959004f, 0.957270f, 0.956889f, 0.958265f, 0.960778f, 0.963180f, 0.964406f, 0.964189f, 0.963091f, - 0.962005f, 0.961500f, 0.961514f, 0.961496f, 0.960845f, 0.959306f, 0.957092f, 0.954688f, 0.952548f, - 0.950838f, 0.949380f, 0.947808f, 0.945783f, 0.943212f, 0.940298f, 0.937430f, 0.934937f, 0.932865f, - 0.930925f, 0.928674f, 0.925801f, 0.922365f, 0.918770f, 0.915509f, 0.912795f, 0.910417f, 0.907881f, - 0.904769f, 0.901065f, 0.897183f, 0.893709f, 0.890990f, 0.888922f, 0.887040f, 0.884874f, 0.882293f, - 0.879603f, 0.877335f, 0.875867f, 0.875169f, 0.874820f, 0.874318f, 0.873404f, 0.872263f, 0.871381f, - 0.871226f, 0.871950f, 0.873283f, 0.874763f, 0.876042f, 0.877147f, 0.878470f, 0.880494f, 0.883473f, - 0.887227f, 0.891261f, 0.895053f, 0.898401f, 0.901500f, 0.904769f, 0.908500f, 0.912599f, 0.916578f, - 0.919847f, 0.922084f, 0.923417f, 0.924328f, 0.925296f, 0.926463f, 0.927512f, 0.927872f, 0.927107f, - 0.925199f, 0.922559f, 0.919735f, 0.917037f, 0.914339f, 0.911186f, 0.907142f, 0.902131f, 0.896510f, - 0.890876f, 0.885644f, 0.880802f, 0.875934f, 0.870524f, 0.864337f, 0.857594f, 0.850819f, 0.844491f, - 0.838727f, 0.833219f, 0.827473f, 0.821173f, 0.814415f, 0.807662f, 0.801459f, 0.796094f, 0.791462f, - 0.787182f, 0.782926f, 0.778681f, 0.774803f, 0.771810f, 0.770061f, 0.769529f, 0.769825f, 0.770456f, - 0.771131f, 0.771940f, 0.773230f, 0.775319f, 0.778206f, 0.781513f, 0.784675f, 0.787274f, 0.789285f, - 0.791065f, 0.793054f, 0.795465f, 0.798097f, 0.800468f, 0.802133f, 0.802987f, 0.803319f, 0.803610f, - 0.804179f, 0.804959f, 0.805538f, 0.805434f, 0.804411f, 0.802621f, 0.800480f, 0.798379f, 0.796426f, - 0.794398f, 0.791920f, 0.788777f, 0.785087f, 0.781263f, 0.777777f, 0.774862f, 0.772372f, 0.769886f, - 0.767004f, 0.763614f, 0.759968f, 0.756517f, 0.753593f, 0.751172f, 0.748881f, 0.746246f, 0.743011f, - 0.739318f, 0.735608f, 0.732306f, 0.729532f, 0.727006f, 0.724254f, 0.720939f, 0.717103f, 0.713136f, - 0.709524f, 0.706514f, 0.703976f, 0.701513f, 0.698772f, 0.695692f, 0.692570f, 0.689859f, 0.687869f, - 0.686573f, 0.685642f, 0.684671f, 0.683452f, 0.682094f, 0.680934f, 0.680290f, 0.680228f, 0.680501f, - 0.680699f, 0.680498f, 0.679867f, 0.679050f, 0.678395f, 0.678093f, 0.678035f, 0.677889f, 0.677315f, - 0.676220f, 0.674814f, 0.673485f, 0.672517f, 0.671918f, 0.671424f, 0.670712f, 0.669657f, 0.668437f, - 0.667421f, 0.666896f, 0.666880f, 0.667103f, 0.667228f}; - -/* Sample Rate = 16000 */ -// Floating point -const float defaultHRIR_coherence_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = - {0.983044f, 0.960794f, 0.893756f, 0.783586f, 0.638963f, 0.477338f, 0.319879f, 0.183374f, 0.075909f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003842f, 0.025288f, 0.035886f, - 0.037785f, 0.035991f, 0.034784f, 0.035091f, 0.034683f, 0.030849f, 0.023146f, 0.014061f, 0.007275f, - 0.005053f, 0.006930f, 0.010589f, 0.013905f, 0.016288f, 0.018404f, 0.020849f, 0.023164f, 0.024149f, - 0.023098f, 0.020635f, 0.018325f, 0.017381f, 0.017611f, 0.017534f, 0.015650f, 0.011786f, 0.007342f, - 0.004290f, 0.003732f, 0.005148f, 0.006838f, 0.007172f, 0.005579f, 0.002632f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000238f, 0.001738f, 0.003011f, 0.003910f, - 0.004120f, 0.003394f, 0.001769f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.002101f, 0.004247f, 0.006330f, 0.008300f, 0.010110f, 0.011735f, 0.013165f, 0.014384f, - 0.015345f, 0.015972f, 0.016191f}; - -const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = - {1.118974f, 1.115256f, 1.106210f, 1.096901f, 1.092316f, 1.094422f, 1.101140f, 1.107775f, 1.110000f, - 1.106535f, 1.099921f, 1.094914f, 1.095643f, 1.103178f, 1.114955f, 1.126292f, 1.132973f, 1.133288f, - 1.128471f, 1.121439f, 1.114842f, 1.109721f, 1.105480f, 1.100966f, 1.095650f, 1.090074f, 1.085225f, - 1.081525f, 1.078267f, 1.074026f, 1.067777f, 1.059839f, 1.051856f, 1.045772f, 1.042531f, 1.041432f, - 1.040607f, 1.038291f, 1.033910f, 1.028286f, 1.022846f, 1.018514f, 1.015152f, 1.011898f, 1.008047f, - 1.003762f, 0.999992f, 0.997770f, 0.997349f, 0.997960f, 0.998259f, 0.997177f, 0.994506f, 0.990883f, - 0.987207f, 0.984003f, 0.981133f, 0.977984f, 0.973950f, 0.968837f, 0.962915f, 0.956690f, 0.950584f, - 0.944679f, 0.938744f, 0.932399f, 0.925372f, 0.917663f, 0.909568f, 0.901511f, 0.893804f, 0.886455f, - 0.879155f, 0.871463f, 0.863142f, 0.854285f, 0.845334f, 0.836740f, 0.828656f, 0.820817f, 0.812713f, - 0.803960f, 0.794564f, 0.784952f, 0.775633f, 0.766881f, 0.758539f, 0.750156f, 0.741330f, 0.732004f, - 0.722524f, 0.713387f, 0.704919f, 0.697057f, 0.689419f, 0.681576f, 0.673350f, 0.664931f, 0.656703f, - 0.648997f, 0.641801f, 0.634760f, 0.627357f, 0.619192f, 0.610186f, 0.600526f, 0.590442f, 0.579952f, - 0.568762f, 0.556384f, 0.542389f, 0.526648f, 0.509355f, 0.490884f, 0.471542f, 0.451447f, 0.430550f, - 0.408842f, 0.386537f, 0.364126f, 0.342284f, 0.321675f, 0.302809f, 0.286016f, 0.271536f, 0.259639f, - 0.250691f, 0.245099f, 0.243192f}; - -const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ] = - {1.118974f, 1.115254f, 1.106207f, 1.096903f, 1.092317f, 1.094425f, 1.101145f, 1.107775f, 1.109999f, - 1.106540f, 1.099921f, 1.094912f, 1.095644f, 1.103178f, 1.114952f, 1.126292f, 1.132973f, 1.133288f, - 1.128472f, 1.121439f, 1.114842f, 1.109719f, 1.105481f, 1.100965f, 1.095650f, 1.090072f, 1.085224f, - 1.081527f, 1.078270f, 1.074025f, 1.067775f, 1.059840f, 1.051856f, 1.045772f, 1.042533f, 1.041433f, - 1.040611f, 1.038292f, 1.033911f, 1.028286f, 1.022844f, 1.018512f, 1.015153f, 1.011899f, 1.008050f, - 1.003762f, 0.999995f, 0.997769f, 0.997349f, 0.997959f, 0.998259f, 0.997178f, 0.994509f, 0.990883f, - 0.987204f, 0.984003f, 0.981133f, 0.977983f, 0.973949f, 0.968836f, 0.962914f, 0.956689f, 0.950583f, - 0.944681f, 0.938745f, 0.932399f, 0.925373f, 0.917662f, 0.909567f, 0.901511f, 0.893804f, 0.886456f, - 0.879153f, 0.871467f, 0.863138f, 0.854286f, 0.845334f, 0.836740f, 0.828656f, 0.820816f, 0.812712f, - 0.803961f, 0.794567f, 0.784951f, 0.775631f, 0.766882f, 0.758540f, 0.750158f, 0.741330f, 0.732005f, - 0.722523f, 0.713388f, 0.704920f, 0.697057f, 0.689418f, 0.681575f, 0.673352f, 0.664930f, 0.656706f, - 0.648998f, 0.641802f, 0.634762f, 0.627355f, 0.619192f, 0.610187f, 0.600527f, 0.590442f, 0.579953f, - 0.568763f, 0.556383f, 0.542389f, 0.526646f, 0.509355f, 0.490883f, 0.471543f, 0.451446f, 0.430550f, - 0.408843f, 0.386537f, 0.364127f, 0.342285f, 0.321676f, 0.302809f, 0.286016f, 0.271535f, 0.259640f, - 0.250692f, 0.245099f, 0.243192f}; - -// Fixed-point const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = { 131941936, 128955584, 119957896, 105171136, 85760160, 64067220, 42933432, 24612042, @@ -60245,7 +59901,6 @@ const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = 2040042 }; -#endif #endif Word32 sine_table_Q31 [361] = { -- GitLab From 87caabb2da09f7113bf2d3c0ad9a86567e9d2d45 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Wed, 25 Jun 2025 17:02:37 +0200 Subject: [PATCH 419/692] 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 420/692] 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 421/692] 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 422/692] 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 423/692] 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 424/692] 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 8906317ea92d1affc39c5110e963744ebcbd13cb Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:13:35 +0200 Subject: [PATCH 425/692] [cleanup] accept FIX_998_UNUSED_FUNCTION --- lib_com/options.h | 1 - lib_dec/ivas_dirac_dec_fx.c | 82 ----- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 317 ------------------ lib_rend/ivas_dirac_rend_fx.c | 8 - lib_rend/ivas_prot_rend_fx.h | 8 - 5 files changed, 416 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 662fb2be2..89e64da03 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,7 +126,6 @@ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ #define NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER /* FhG: issues #1012, 1013: JBM flush function uses wrong output buffer */ -#define FIX_998_UNUSED_FUNCTION /* FhG: issue 998: delete unused funtion ivas_dirac_dec_get_response_split_order */ #define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ #define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index e3b32d3fc..1e14a1675 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2752,42 +2752,6 @@ void ivas_dirac_dec_render_sf_fx( { masa_band_mapping = st_ivas->hMasa->data.band_mapping; } -#ifndef FIX_998_UNUSED_FUNCTION - test(); - test(); - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && EQ_16( st_ivas->hCombinedOrientationData->shd_rot_max_order, 1 ) ) - { - ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - masa_band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio_fx, - surCohRatio_q_fx, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat_fx, - hodirac_flag ); - } - ELSE - { - ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, - hDirACRend, - st_ivas->hVBAPdata, - masa_band_mapping, - st_ivas->hMasaIsmData, - azimuth, - elevation, - md_idx, - surCohRatio_fx, - surCohRatio_q_fx, - 0, - NULL, - hodirac_flag ); - } -#else ivas_dirac_dec_compute_directional_responses_fx( hSpatParamRendCom, hDirACRend, st_ivas->hVBAPdata, @@ -2800,7 +2764,6 @@ void ivas_dirac_dec_render_sf_fx( surCohRatio_q_fx, hodirac_flag ); -#endif } test(); @@ -3316,50 +3279,6 @@ void ivas_dirac_dec_render_sf_fx( move16(); } -#ifndef FIX_998_UNUSED_FUNCTION - test(); - test(); - IF( st_ivas->hCombinedOrientationData && st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx] && st_ivas->hCombinedOrientationData->shd_rot_max_order > 0 ) - { - ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, - DirAC_mem.reference_power_q, - p_onset_filter_fx, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector_fx[md_idx], - hSpatParamRendCom->q_diffuseness_vector, - hSpatParamRendCom, - hDirACRend, - st_ivas->hCombinedOrientationData->shd_rot_max_order, - p_Rmat_fx, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); - } - ELSE - { - ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, - DirAC_mem.reference_power_q, - p_onset_filter_fx, - azimuth, - elevation, - hSpatParamRendCom->diffuseness_vector_fx[md_idx], - hSpatParamRendCom->q_diffuseness_vector, - hSpatParamRendCom, - hDirACRend, - 0, - 0, - st_ivas->hVBAPdata, - hDirACRend->hOutSetup, - nchan_transport, - md_idx, - hodirac_flag, - hDirAC->hConfig->dec_param_estim ); - } -#else ivas_dirac_dec_output_synthesis_process_slot_fx( reference_power_fx, DirAC_mem.reference_power_q, p_onset_filter_fx, @@ -3376,7 +3295,6 @@ void ivas_dirac_dec_render_sf_fx( hodirac_flag, hDirAC->hConfig->dec_param_estim ); -#endif IF( hDirAC->hConfig->dec_param_estim ) { diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 548e06fb6..3d4ec3077 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -650,10 +650,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ -#ifndef FIX_998_UNUSED_FUNCTION - const Word16 sh_rot_max_order, - const Word32 *p_Rmat, /* i : rotation matrix Q30*/ -#endif const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ const Word16 nchan_transport, /* i : number of transport channels*/ @@ -707,10 +703,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( md_idx, NULL, 0, -#ifndef FIX_998_UNUSED_FUNCTION - 2, - p_Rmat, -#endif hodirac_flag ); { @@ -781,10 +773,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( md_idx, NULL, 0, -#ifndef FIX_998_UNUSED_FUNCTION - sh_rot_max_order, - p_Rmat, -#endif hodirac_flag ); { @@ -2818,291 +2806,6 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( return; } -#ifndef FIX_998_UNUSED_FUNCTION - -/*------------------------------------------------------------------------- - * ivas_dirac_dec_get_response_split_order() - * - * calculate reponse, 1 degree resolution - *------------------------------------------------------------------------*/ - -static void ivas_dirac_dec_get_response_split_order_fx( - const Word16 azimuth, /*q0*/ - const Word16 elevation, /*q0*/ - Word32 *response, /*q_response*/ - const Word16 shd_rot_max_order, - const Word32 *p_Rmat /* Q30 */, - Word16 *q_response ) -{ - Word16 index_azimuth, index_elevation; - Word16 el, e, az; - Word32 cos_1, cos_2, sin_1, cos_az[3]; - Word32 sin_az[3]; - Word32 f, c; - Word16 l, m; - Word16 b, b1, b_2, b1_2, a; - Word32 dv_0, dv_1, dv_2, dv_r_0, dv_r_1, dv_r_2; - Word32 w; - Word16 tmp; - Word32 temp; - Word16 exp; - - push_wmops( "ivas_dirac_dec_get_response_split_order" ); - - /* Corner case for handling crash in idiv1616 when numerator is 0 */ - IF( EQ_16( azimuth, -180 ) ) - { - tmp = 0; - move16(); - } - ELSE - { - tmp = 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 ); - - IF( GT_16( index_elevation, 90 ) ) - { - e = -ONE_IN_Q14; /*-1 in Q14*/ - move16(); - el = sub( 180, index_elevation ); - } - ELSE - { - e = ONE_IN_Q14; /*1 in Q14*/ - move16(); - el = index_elevation; - move16(); - } - - IF( GT_16( index_azimuth, 180 ) ) - { - az = sub( 360, index_azimuth ); - f = -ONE_IN_Q30; /*-1 Q30*/ - move32(); - } - ELSE - { - az = index_azimuth; - move16(); - f = ONE_IN_Q30; /*1 Q30*/ - move32(); - } - - // dirac_gains_trg_term_int Q30 - cos_1 = L_shr( dirac_gains_trg_term_int[az][0], 1 ); // Q29 - cos_2 = L_shl( Mpy_32_32( cos_1, cos_1 ), 2 ); // Q29 - sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] ); // Q29 - - cos_az[0] = cos_1; // Q29 - move32(); - cos_az[1] = L_shl( L_sub( Mpy_32_32( TWO_IN_Q29, cos_2 ), ONE_IN_Q27 ), 2 ); // Q29 - move32(); - cos_az[2] = L_sub( L_shl( Mpy_32_32( Mpy_32_32( TWO_IN_Q29, cos_1 ), cos_az[1] ), 4 ), cos_az[0] ); // Q29 - move32(); - - sin_az[0] = sin_1; // Q29 - move32(); - sin_az[1] = L_shl( Mpy_32_32( Mpy_32_32( sin_1, TWO_IN_Q29 ), cos_1 ), 4 ); // Q29 - move32(); - sin_az[2] = L_shl( Mpy_32_32( sin_1, L_sub( Mpy_32_32( FOUR_IN_Q28, cos_2 ), ONE_IN_Q26 ) ), 5 ); // Q29 - move32(); - - response[0] = ONE_IN_Q29; - move32(); - - FOR( l = 1; l <= shd_rot_max_order; l++ ) - { - b_2 = i_mult( l, l ); - b1_2 = add( b_2, i_mult( 2, l ) ); - FOR( m = 0; m < l; m += 2 ) - { - b = add( b_2, m ); - a = dirac_gains_P_idx[b]; - move16(); - - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), 6 ); // Q29 - move32(); - - b1 = sub( b1_2, m ); - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), 6 ); // Q29 - move32(); - } - - FOR( m = 1; m < l; m += 2 ) - { - b = add( b_2, m ); - a = dirac_gains_P_idx[b]; - move16(); - - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - c = Mpy_32_16_1( c, e ); // Q24 - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), 7 ); // Q29 - move32(); - - b1 = sub( b1_2, m ); - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), 7 ); // Q29 - move32(); - } - - b = add( b_2, l ); - a = dirac_gains_P_idx[b]; - move16(); - - c = L_shl( Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ), 3 ); // Q29 - IF( EQ_16( l % 2, 1 ) ) - { - c = L_shl( Mpy_32_16_1( c, e ), 1 ); // Q29 - } - - response[b] = c; // Q29 - move32(); - } - - /*Conversion spherical to cartesian coordinates*/ - w = L_negate( dirac_gains_trg_term_int[el][1] ); // Q30 - dv_0 = Mpy_32_32( w, cos_1 ); // Q28 - dv_1 = Mpy_32_32( w, sin_1 ); // Q28 - dv_2 = L_shr( Mpy_32_16_1( dirac_gains_trg_term_int[el][0], e ), 1 ); // Q28 - - /*Rotation mtx multiplication*/ - dv_r_0 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[0], Q1 ), dv_0 ), L_shr( p_Rmat[1], Q1 ), dv_1 ), L_shr( p_Rmat[2], Q1 ), dv_2 ); // Q26 - dv_r_1 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[3], Q1 ), dv_0 ), L_shr( p_Rmat[4], Q1 ), dv_1 ), L_shr( p_Rmat[5], Q1 ), dv_2 ); // Q26 - dv_r_2 = Madd_32_32( Madd_32_32( Mpy_32_32( L_shr( p_Rmat[6], Q1 ), dv_0 ), L_shr( p_Rmat[7], Q1 ), dv_1 ), L_shr( p_Rmat[8], Q1 ), dv_2 ); // Q26 - - tmp = BASOP_util_atan2( dv_r_1, dv_r_0, 0 ); // Q13 - index_azimuth = shr( mult( tmp, _180_OVER_PI_Q9 ), 7 ); // Q0; - IF( EQ_16( index_azimuth, -180 ) ) - { - tmp = 0; - move16(); - } - ELSE - { - tmp = idiv1616( add( index_azimuth, 180 ), 360 ); - } - index_azimuth = sub( add( index_azimuth, 180 ), i_mult( tmp, 360 ) ); // index_azimuth = (index_azimuth + 180) % 360 - - temp = L_add( Mpy_32_32( dv_r_0, dv_r_0 ), Mpy_32_32( dv_r_1, dv_r_1 ) ); // Q21 - exp = sub( 31, Q21 ); - temp = Sqrt32( temp, &exp ); - - tmp = BASOP_util_atan2( dv_r_2, temp, sub( sub( 31, Q26 ), exp ) ); // Q13 - index_elevation = shr( mult( tmp, _180_OVER_PI_Q9 ), Q7 ); // Q0 - index_elevation = add( index_elevation, 90 ); - - IF( GT_16( index_elevation, 90 ) ) - { - e = -ONE_IN_Q14; /*-1 Q14*/ - move16(); - el = sub( 180, index_elevation ); - } - ELSE - { - e = ONE_IN_Q14; /*1 Q14*/ - move16(); - el = index_elevation; - move16(); - } - - IF( GT_16( index_azimuth, 180 ) ) - { - az = sub( 360, index_azimuth ); - f = -ONE_IN_Q30; /*-1 Q30*/ - move32(); - } - ELSE - { - az = index_azimuth; - move16(); - f = ONE_IN_Q30; /*1 Q30*/ - move32(); - } - - // dirac_gains_trg_term_int Q30 - cos_1 = L_shr( dirac_gains_trg_term_int[az][0], 1 ); // Q29 - cos_2 = L_shl( Mpy_32_32( cos_1, cos_1 ), 2 ); // Q29 - sin_1 = Mpy_32_32( f, dirac_gains_trg_term_int[az][1] ); // Q29 - - cos_az[0] = cos_1; // Q29 - move32(); - cos_az[1] = L_shl( L_sub( Mpy_32_32( TWO_IN_Q29, cos_2 ), ONE_IN_Q27 ), 2 ); // Q29 - move32(); - cos_az[2] = L_sub( L_shl( Mpy_32_32( Mpy_32_32( TWO_IN_Q29, cos_1 ), cos_az[1] ), 4 ), cos_az[0] ); // Q29 - move32(); - - sin_az[0] = sin_1; // Q29 - move32(); - sin_az[1] = L_shl( Mpy_32_32( Mpy_32_32( sin_1, TWO_IN_Q29 ), cos_1 ), 4 ); // Q29 - move32(); - sin_az[2] = L_shl( Mpy_32_32( sin_1, L_sub( Mpy_32_32( FOUR_IN_Q28, cos_2 ), ONE_IN_Q26 ) ), 5 ); // Q29 - move32(); - - FOR( l = shd_rot_max_order + 1; l <= 3; l++ ) - { - b_2 = i_mult( l, l ); - b1_2 = add( b_2, i_mult( 2, l ) ); - - FOR( m = 0; m < l; m += 2 ) - { - b = add( b_2, m ); - a = dirac_gains_P_idx[b]; - move16(); - - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), 6 ); // Q29 - move32(); - - b1 = sub( b1_2, m ); - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), 6 ); // Q29 - move32(); - } - - FOR( m = 1; m < l; m += 2 ) - { - b = add( b_2, m ); - a = dirac_gains_P_idx[b]; - move16(); - - c = Mpy_32_32( Mpy_32_32( SQRT2_FIXED, dirac_gains_norm_term_int[a] ), dirac_gains_Pnm_int[el][a] ); // Q25 - c = Mpy_32_16_1( c, e ); // Q24 - - response[b] = L_shl( Mpy_32_32( c, sin_az[l - m - 1] ), 7 ); // Q29 - move32(); - - b1 = sub( b1_2, m ); - response[b1] = L_shl( Mpy_32_32( c, cos_az[l - m - 1] ), 7 ); // Q29 - move32(); - } - - b = add( b_2, l ); - a = dirac_gains_P_idx[b]; - move16(); - - c = L_shl( Mpy_32_32( dirac_gains_norm_term_int[a], dirac_gains_Pnm_int[el][a] ), 3 ); // Q29 - - IF( EQ_16( l % 2, 1 ) ) - { - c = L_shl( Mpy_32_16_1( c, e ), 1 ); // Q29 - } - - response[b] = c; // Q29 - move32(); - } - - *q_response = Q29; - move16(); - - pop_wmops(); - - return; -} -#endif /*------------------------------------------------------------------------- * ivas_dirac_dec_compute_directional_responses() @@ -3121,10 +2824,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 md_idx, const Word32 *surCohRatio_fx, /*i:Q_surCohRatio*/ Word16 Q_surCohRatio, -#ifndef FIX_998_UNUSED_FUNCTION - const Word16 shd_rot_max_order, /* i : split-order rotation method */ - const Word32 *p_Rmat, /* i : rotation matrix Q30*/ -#endif const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ) { @@ -3238,19 +2937,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( exp_direct_response_dir2 = 0; move16(); -#ifndef FIX_998_UNUSED_FUNCTION - IF( p_Rmat != 0 ) - { - ivas_dirac_dec_get_response_split_order_fx( azimuth[k], elevation[k], direct_response_hoa_fx, shd_rot_max_order, p_Rmat, &Q_direct_response_hoa ); - - IF( hodirac_flag ) - { - ivas_dirac_dec_get_response_split_order_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, shd_rot_max_order, p_Rmat, &Q_direct_response_dir2 ); - } - } - ELSE - { -#endif #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 @@ -3265,9 +2951,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( ivas_dirac_dec_get_response_fx( azimuth2[k], elevation2[k], direct_response_dir2_fx, hDirACRend->hOutSetup.ambisonics_order, Q_direct_response_dir2 ); #endif } -#ifndef FIX_998_UNUSED_FUNCTION - } -#endif test(); test(); diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 02a02f863..efcd1b0b4 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -4239,10 +4239,6 @@ static void ivas_masa_ext_dirac_render_sf_fx( md_idx, surCohRatio_fx, Q_surCohRatio, -#ifndef FIX_998_UNUSED_FUNCTION - 0, - NULL, -#endif 0 ); Word16 proto_direct_buffer_f_temp_q[60]; @@ -4621,10 +4617,6 @@ static void ivas_masa_ext_dirac_render_sf_fx( hSpatParamRendCom->q_diffuseness_vector, hSpatParamRendCom, hDirACRend, -#ifndef FIX_998_UNUSED_FUNCTION - 0, - 0, -#endif hMasaExtRend->hVBAPdata, hDirACRend->hOutSetup, nchan_transport, diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 96774b44f..9524f0904 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -472,10 +472,6 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ -#ifndef FIX_998_UNUSED_FUNCTION - const Word16 sh_rot_max_order, - const Word32 *p_Rmat, /* i : rotation matrix */ -#endif const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ const Word16 nchan_transport, /* i : number of transport channels*/ @@ -547,10 +543,6 @@ void ivas_dirac_dec_compute_directional_responses_fx( const Word16 md_idx, const Word32 *surCohRatio_fx, Word16 Q_surCohRatio, -#ifndef FIX_998_UNUSED_FUNCTION - const Word16 shd_rot_max_order, /* i : split-order rotation method */ - const Word32 *p_Rmat, /* i : rotation matrix */ -#endif const Word16 hodirac_flag /* i : flag to indicate HO-DirAC mode */ ); -- GitLab From 6f55992a7571fadcfc0b9dd394ffde622222fb8b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:13:38 +0200 Subject: [PATCH 426/692] [cleanup] accept FIX_1009_ISM_NONDIEGETIC_PANNING --- lib_com/ivas_prot_fx.h | 2 -- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 4 ---- lib_dec/ivas_mono_dmx_renderer_fx.c | 7 ------- 4 files changed, 14 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 06494a4a7..6da0a6de2 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1155,9 +1155,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( ); void ivas_apply_non_diegetic_panning_fx( -#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING Word32 *input_f_fx, /* i : non-diegetic object */ -#endif Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */ const Word16 output_frame /* i : output frame length per channel */ diff --git a/lib_com/options.h b/lib_com/options.h index 89e64da03..dd5d2e2b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,7 +124,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define FIX_1009_ISM_NONDIEGETIC_PANNING /* FhG: issue #1009: use correct object buffer for ISM1 non-diegetic pan */ #define NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER /* FhG: issues #1012, 1013: JBM flush function uses wrong output buffer */ #define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index c7863bb98..ad9091ae0 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1962,11 +1962,7 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { -#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING ivas_apply_non_diegetic_panning_fx( p_tc_fx[0], p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); -#else - ivas_apply_non_diegetic_panning_fx( p_output_fx, st_ivas->hDecoderConfig->non_diegetic_pan_gain_fx, *nSamplesRendered ); -#endif } #ifdef DEBUGGING ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 4f04c4dd8..57d3fa1ad 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -318,9 +318,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( *------------------------------------------------------------------------*/ void ivas_apply_non_diegetic_panning_fx( -#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING Word32 *input_f_fx, /* i : non-diegetic object */ -#endif Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ const Word16 output_frame /* i : output frame length per channel Q11*/ @@ -331,13 +329,8 @@ void ivas_apply_non_diegetic_panning_fx( pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384 pan_right_fx = sub( 32767, pan_left_fx ); -#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); -#else - v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); - v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); -#endif return; } -- GitLab From 2e4d664173a9597f42a1fd1d96633684b7549f88 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:13:41 +0200 Subject: [PATCH 427/692] [cleanup] accept FIX_1020_AEID_SELECTION_ERRORS --- lib_util/render_config_reader.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 050658bdf..8df6c0d42 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2191,11 +2191,7 @@ ivas_error RenderConfigReader_read( return IVAS_ERR_INVALID_RENDER_CONFIG; } idx = strtol( strtok( NULL, ":" ), NULL, 0 ); -#ifdef FIX_1020_AEID_SELECTION_ERRORS pRenderConfigReader->pAE[acIdx].id = idx; -#else - pRenderConfigReader->pAE->id = idx; -#endif aeHasFgIdx = aeHasPredelay = aeHasRt60 = aeHasDsr = FALSE; aeHasERsize = aeHasERabs = FALSE; -- GitLab From 23f60a96eb66fe7a2e1c0bb3aa5df46f75581b56 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:13:45 +0200 Subject: [PATCH 428/692] [cleanup] accept FIX_993_REMOVE_SBA_GET_ORDER --- lib_com/ivas_prot_fx.h | 7 ---- lib_com/ivas_sba_config_fx.c | 68 ------------------------------------ lib_com/options.h | 1 - 3 files changed, 76 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 6da0a6de2..501c91a35 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -4921,13 +4921,6 @@ ivas_error ivas_cldfb_dec_reconfig_fx( ivas_error ivas_sba_enc_reconfigure_fx( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); -#ifndef FIX_993_REMOVE_SBA_GET_ORDER -Word16 ivas_sba_get_order_fx( - const Word16 nb_channels, /* i : Number of ambisonic channels */ - const Word16 sba_planar /* i : SBA planar flag */ -); - -#endif /*! r: Ambisonic (SBA) order used for analysis and coding */ Word16 ivas_sba_get_analysis_order( const Word32 ivas_total_brate, /* i : IVAS total bitrate */ diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 6dbe215ea..ab4d931ad 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -60,24 +60,7 @@ void ivas_sba_config_fx( Word16 *element_mode /* o : element mode of the core coder */ ) { -#ifndef FIX_993_REMOVE_SBA_GET_ORDER - test(); - IF( sba_order < 0 && nb_channels < 0 ) - { - assert( 0 && "Either order or number of channels must be positive" ); - } - ELSE IF( sba_order < 0 ) - { - sba_order = ivas_sba_get_order_fx( nb_channels, sba_planar ); - } - ELSE IF( nb_channels < 0 ) - { - nb_channels = ivas_sba_get_nchan_fx( sba_order, sba_planar ); - } - ELSE -#else IF( nb_channels > 0 ) -#endif { IF( sba_planar ) { @@ -128,57 +111,6 @@ void ivas_sba_config_fx( return; } -#ifndef FIX_993_REMOVE_SBA_GET_ORDER -/*-------------------------------------------------------------------* - * ivas_sba_get_order() - * - * Get Ambisonic order from number of ambisonic channels - *-------------------------------------------------------------------*/ - -/*! r: Ambisonic (SBA) order */ -Word16 ivas_sba_get_order_fx( - const Word16 nb_channels, /* i : Number of ambisonic channels */ - const Word16 sba_planar /* i : SBA Planar flag */ -) -{ - Word16 sba_order; - - /* sba_order = (int16_t) sqrtf( (float) nb_channels ) - 1 */ - Word16 sba_order_non_sba_planar[MAX_INPUT_CHANNELS] = { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3 }; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - - IF( sba_planar ) - { - sba_order = shr( sub( nb_channels, 1 ), 1 ); - assert( ( EQ_16( add( shl( sba_order, 1 ), 1 ), nb_channels ) ) && "Number of channels not supported in Planar SBA!" ); - } - ELSE - { - sba_order = sba_order_non_sba_planar[nb_channels - 1]; - move16(); - assert( ( EQ_16( mult( add( sba_order, 1 ), add( sba_order, 1 ) ), nb_channels ) ) && "Number of channels not supported in SBA!" ); - } - - assert( ( sba_order <= 3 ) && "Error: SBA order must be <= 3!" ); - - return ( sba_order ); -} -#endif /*-------------------------------------------------------------------* * ivas_sba_get_analysis_order() diff --git a/lib_com/options.h b/lib_com/options.h index dd5d2e2b9..2629fef4c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,6 @@ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ -#define FIX_993_REMOVE_SBA_GET_ORDER /* VA: issue 993: remove unused function ivas_sba_get_order() */ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ -- GitLab From 1b256acc1c7b58060a0e7735addf046e5f8d32e2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:13:57 +0200 Subject: [PATCH 429/692] [cleanup] accept NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER --- lib_com/options.h | 1 - lib_dec/ivas_jbm_dec_fx.c | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2629fef4c..20012eef3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,7 +123,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER /* FhG: issues #1012, 1013: JBM flush function uses wrong output buffer */ #define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ #define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ad9091ae0..bc4a732e0 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2594,12 +2594,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( Word16 n_slots_still_available; Word16 n_samples_to_render; DECODER_TC_BUFFER_HANDLE hTcBuffer; -#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER Word32 *p_output_fx[MAX_CICP_CHANNELS + MAX_NUM_OBJECTS]; -#else - Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; -#endif Word16 nchan_in, nchan_out; IF( !st_ivas->hDecoderConfig->Opt_tsm ) { @@ -2659,17 +2654,10 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( move16(); move16(); -#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; } -#else - FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) - { - p_output_fx[ch_idx] = output_fx[ch_idx]; - } -#endif test(); IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) @@ -2859,15 +2847,9 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( #ifndef DISABLE_LIMITER Word16 ch_idx, exp = 11; move16(); -#ifdef NONBE_FIX_1012_1013_JBM_FLUSH_BUFFER FOR( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ ) { p_output_fx[ch_idx] = st_ivas->p_output_fx[ch_idx]; -#else - FOR( ch_idx = 0; ch_idx < MAX_CICP_CHANNELS; ch_idx++ ) - { - p_output_fx[ch_idx] = output_fx[ch_idx]; -#endif } ivas_limiter_dec_fx( st_ivas->hLimiter, p_output_fx, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect, exp ); #endif -- GitLab From 81e1438538ac45f8cd6efd392d6dad5e60c8c517 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:14:00 +0200 Subject: [PATCH 430/692] [cleanup] accept NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS --- lib_com/options.h | 1 - lib_dec/ivas_masa_dec_fx.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 20012eef3..5c6e0182d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -121,7 +121,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -#define NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS /* Nokia: fix USAN error caused by non-setting of correctly the number of MASA directions in DTX */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 8bf808ed6..8fdf80ee8 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -166,7 +166,6 @@ ivas_error ivas_masa_decode_fx( } move16(); -#ifdef NONBE_FIX_1004_USAN_DTX_MASA_NO_DIRS test(); test(); IF( EQ_32( ivas_format, MASA_FORMAT ) && ( EQ_32( masa_brate, IVAS_SID_5k2 ) || EQ_32( ivas_total_brate, FRAME_NO_DATA ) ) ) @@ -174,7 +173,6 @@ ivas_error ivas_masa_decode_fx( hMasa->config.numberOfDirections = 1; move16(); } -#endif test(); test(); -- GitLab From 47d2dc631e93a3286ca249f0012ab3a51b7c3e2a Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:14:03 +0200 Subject: [PATCH 431/692] [cleanup] accept NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO --- lib_com/options.h | 1 - lib_dec/ivas_ism_renderer_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5c6e0182d..6a8396455 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* FhG: issues #1014, #1015, #1016: fix tc buffer info update in the discrete ism renderer */ #define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ #define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 370905afd..f303ac761 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -327,13 +327,9 @@ void ivas_ism_render_sf_fx( ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_in_subframe ); n_samples_rendered_loop = add( n_samples_rendered_loop, n_samples_in_subframe ); -#ifdef NONBE_FIX_1014_1015_1016_OSBA_JBM_STEREO /* update rendered subframe and slots info for all cases apart from a following crend call, the update will then happen in the crend call*/ if ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) -#else - IF( EQ_16( st_ivas->renderer_type, RENDERER_TD_PANNING ) ) -#endif { st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); -- GitLab From a98343318ac9ba95d3d49758df1874ab38e29d08 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:14:07 +0200 Subject: [PATCH 432/692] [cleanup] accept NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 6 ------ 2 files changed, 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6a8396455..fa71cc503 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /* FhG: issue 987: solution b: downmix HOA3 to stereo a input for the reverberator */ #define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 75b746ae7..cf2f4a9a0 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1015,7 +1015,6 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( outRealRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); set32_fx( outImagRightPtr_fx, 0, CLDFB_NO_CHANNELS_MAX ); -#ifdef NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING /*Ambisonics input requires different processing*/ if ( EQ_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) { @@ -1038,7 +1037,6 @@ static void ivas_binaural_obtain_DMX_fx( } } else -#endif { FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { @@ -1397,11 +1395,7 @@ ivas_error ivas_binRenderer_open_fx( #ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) #else -#ifdef NONBE_FIX_987_PARAMC_BINAURAL_REVERB_RENDERING IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 && NE_16( hBinRenderer->nInChannels, HOA3_CHANNELS ) ) -#else - IF( hBinRenderer->hInputSetup->is_loudspeaker_setup == 0 ) -#endif #endif { FOR( k = 0; k < 11; k++ ) -- GitLab From be76af46001f3bf4f0b37072d72ad9e00092dd3e Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:14:10 +0200 Subject: [PATCH 433/692] [cleanup] accept NONBE_FIX_1006_PAST_DMX_NRG_ERROR --- lib_com/options.h | 1 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fa71cc503..1926ef742 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ //#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define NONBE_FIX_1006_PAST_DMX_NRG_ERROR /* Eri/FhG: Issue 1006: Bug fix in ivas_stereo_dft_dec not replicated in ivas_stereo_dft_dec_dmx */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 59ee077e8..6a369a14c 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -378,15 +378,8 @@ void stereo_dft_unify_dmx_fx( Word16 idx_k0, idx_k1; Word16 q_shift0; Word16 q_shift1; -#ifdef NONBE_FIX_1006_PAST_DMX_NRG_ERROR idx_k0 = add( hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX - 1 ) & ( STEREO_DFT_PAST_MAX - 1 ); /* Q0 */ idx_k1 = add( idx_k0, 1 ) & ( STEREO_DFT_PAST_MAX - 1 ); -#else - idx_k0 = ( add( hStereoDft->past_DMX_pos, 1 ) ) % STEREO_DFT_PAST_MAX; - move16(); - idx_k1 = ( add( idx_k0, 1 ) ) % STEREO_DFT_PAST_MAX; - move16(); -#endif q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0] ); q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1] ); -- GitLab From d3da440b6ff931fe8224f2f3d6f1d4a1335ebbc9 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Thu, 26 Jun 2025 10:19:53 +0200 Subject: [PATCH 434/692] formatting --- lib_dec/ivas_dirac_dec_fx.c | 1 - lib_dec/ivas_mono_dmx_renderer_fx.c | 2 +- lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 16 ++++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 1e14a1675..391f598ba 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2763,7 +2763,6 @@ void ivas_dirac_dec_render_sf_fx( surCohRatio_fx, surCohRatio_q_fx, hodirac_flag ); - } test(); diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 57d3fa1ad..848f457eb 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -318,7 +318,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( *------------------------------------------------------------------------*/ void ivas_apply_non_diegetic_panning_fx( - Word32 *input_f_fx, /* i : non-diegetic object */ + Word32 *input_f_fx, /* i : non-diegetic object */ Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ const Word16 output_frame /* i : output frame length per channel Q11*/ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 3d4ec3077..d96967bcf 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -650,9 +650,9 @@ void ivas_dirac_dec_output_synthesis_process_slot_fx( Word16 q_diffuseness, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common spatial renderer data handle */ DIRAC_REND_HANDLE hDirACRend, /* i/o: DirAC renderer handle */ - const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ - const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ - const Word16 nchan_transport, /* i : number of transport channels*/ + const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ + const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ + const Word16 nchan_transport, /* i : number of transport channels*/ const Word16 md_idx, const Word16 hodirac_flag, /* i : flag to indicate HO-DirAC mode */ const Word16 dec_param_estim ) @@ -2938,19 +2938,19 @@ void ivas_dirac_dec_compute_directional_responses_fx( move16(); #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 ); + 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 ) - { + 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 ); + 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 - } + } test(); test(); -- GitLab From 4542ebc70f732c58bbf35a046b30d78be1de5875 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 26 Jun 2025 10:55:44 +0200 Subject: [PATCH 435/692] 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 436/692] 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 437/692] 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 438/692] 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 439/692] 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 440/692] 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 441/692] 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 442/692] 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 443/692] 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 444/692] 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 445/692] 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 ead644bcbb9d5f739ab15baffa70b85c5ac82dee Mon Sep 17 00:00:00 2001 From: marc emerit Date: Thu, 26 Jun 2025 18:02:15 +0200 Subject: [PATCH 446/692] for iac and energy values of reverb use float values in rom and do the fix point conversion at init. Initialisation in Q28 for energy and Q26 for coherence --- lib_rend/ivas_hrtf_fx.c | 72 ++++ lib_rend/ivas_reverb_fx.c | 11 + lib_rend/ivas_reverb_utils_fx.c | 14 +- lib_rend/ivas_rom_binaural_crend_head.h | 30 +- lib_rend/ivas_rom_binaural_crend_head_fx.c | 402 ++++++++++++++++++--- lib_util/hrtf_file_reader.c | 12 +- 6 files changed, 459 insertions(+), 82 deletions(-) diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 13b5ae5cb..58dc54b26 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -288,6 +288,77 @@ ivas_error ivas_HRTF_statistics_init( switch ( sampleRate ) { +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + case 48000: + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( defaultHRIR_left_avg_power_48kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_right_avg_power_48kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_coherence_48kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + break; + case 32000: + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( defaultHRIR_left_avg_power_32kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_right_avg_power_32kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_coherence_32kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + break; + case 16000: + HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_l_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + if ( HrtfStatistics->average_energy_r_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + HrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( Word32 ) ); + if ( HrtfStatistics->inter_aural_coherence_dyn == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); + } + floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrtfStatistics->average_energy_l_dyn, Q28, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_right_avg_power_16kHz_fx, HrtfStatistics->average_energy_r_dyn, Q28, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrtfStatistics->inter_aural_coherence_dyn, Q26, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ + HrtfStatistics->average_energy_l = (const Word32 *) HrtfStatistics->average_energy_l_dyn; + HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; + HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; + break; +#else case 48000: HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx; HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx; @@ -303,6 +374,7 @@ ivas_error ivas_HRTF_statistics_init( HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx; HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx; break; +#endif } HrtfStatistics->fromROM = TRUE; diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 00513d30e..4e054b699 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1644,10 +1644,17 @@ ivas_error ivas_reverb_open_fx( { params.pDsr_fx[i] = L_shl( params.pDsr_fx[i], params.pDsr_e[i] ); move32(); +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + pHrtf_avg_pwr_response_l_const[i] = params.pHrtf_avg_pwr_response_l_const_fx[i]; /*Q28*/ + move32(); + pHrtf_avg_pwr_response_r_const[i] = params.pHrtf_avg_pwr_response_r_const_fx[i]; /*Q23+5*/ + move32(); +#else pHrtf_avg_pwr_response_l_const[i] = L_shl( params.pHrtf_avg_pwr_response_l_const_fx[i], 5 ); /*Q23+5*/ move32(); pHrtf_avg_pwr_response_r_const[i] = L_shl( params.pHrtf_avg_pwr_response_r_const_fx[i], 5 ); /*Q23+5*/ move32(); +#endif } FOR( i = 0; i < lenT60_filter_coeff; i++ ) { @@ -1695,7 +1702,11 @@ ivas_error ivas_reverb_open_fx( Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); FOR( i = 0; i < nr_fc_fft_filter; i++ ) { +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB pHrtf_inter_aural_coherence_const[i] = L_shl( params.pHrtf_inter_aural_coherence_const_fx[i], 3 ); /*Scaling up to Q30*/ +#else + pHrtf_inter_aural_coherence_const[i] = params.pHrtf_inter_aural_coherence_const_fx[i]; /*Scaling up to Q30*/ +#endif move32(); } ivas_reverb_calc_correl_filters_fx( pHrtf_inter_aural_coherence_const, pTime_window_fx, pState->fft_size, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx ); diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index f673fdc7d..4a3c0477c 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -311,7 +311,11 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; +#else + const int16_t avg_pwr_len = LR_IAC_LENGTH_NR_FC; +#endif for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { @@ -328,11 +332,11 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) ); - Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); - Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 ) ); - Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 ) ); - Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); - Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 ) ); + Word32 *output_fc_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); + Word16 *avg_pwr_left_e = (Word16 *) malloc( avg_pwr_len * sizeof( Word16 ) ); + Word16 *avg_pwr_right_e = (Word16 *) malloc( avg_pwr_len * sizeof( Word16 ) ); + Word32 *avg_pwr_left_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); + Word32 *avg_pwr_right_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); for ( int i = 0; i < 60; i++ ) { diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 017703460..4f40c2ed7 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -349,6 +349,19 @@ extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2522]; #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB +extern float defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ +extern float defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern float defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ + +extern float defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ +extern float defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ +extern float defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ + +extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ +extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ +#else extern const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ @@ -357,23 +370,6 @@ extern const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ - -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern const float defaultHRIR_coherence_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern const float defaultHRIR_left_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern const float defaultHRIR_right_avg_power_16kHz[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ - -extern const float defaultHRIR_coherence_32kHz[LR_IAC_LENGTH_NR_FC]; -extern const float defaultHRIR_left_avg_power_32kHz[LR_IAC_LENGTH_NR_FC]; -extern const float defaultHRIR_right_avg_power_32kHz[LR_IAC_LENGTH_NR_FC]; - -extern const float defaultHRIR_coherence_48kHz[LR_IAC_LENGTH_NR_FC]; -extern const float defaultHRIR_left_avg_power_48kHz[LR_IAC_LENGTH_NR_FC]; -extern const float defaultHRIR_right_avg_power_48kHz[LR_IAC_LENGTH_NR_FC]; -#else extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index df78d5b25..436ba60f6 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59651,6 +59651,257 @@ const Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS] }; #ifdef FIX_638_ENERGIE_IAC_ROM_TABLES + +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB +/********************** defaultHRIR reverb rom tables at sampling rate 48kHz **********************/ + +const float defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] = + {0.997092f, 0.947391f, 0.799213f, 0.575216f, 0.335047f, 0.138324f, 0.007933f, 0.000000f, 0.000000f, + 0.000000f, 0.008438f, 0.037607f, 0.044493f, 0.042149f, 0.041877f, 0.039860f, 0.029404f, 0.015898f, + 0.010316f, 0.014065f, 0.020005f, 0.024518f, 0.029292f, 0.033522f, 0.033418f, 0.029630f, 0.027260f, + 0.027515f, 0.025682f, 0.019571f, 0.013977f, 0.013695f, 0.016531f, 0.016882f, 0.013257f, 0.008483f, + 0.004883f, 0.002525f, 0.001004f, 0.000180f, 0.000000f, 0.000000f, 0.000000f, 0.000785f, 0.003979f, + 0.007082f, 0.009598f, 0.011665f, 0.012700f, 0.011794f, 0.009192f, 0.006164f, 0.003527f, 0.001284f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000894f, 0.002136f, 0.003127f, 0.003616f, + 0.003810f, 0.003754f, 0.003186f, 0.002091f, 0.000823f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.001007f, 0.001843f, 0.002400f, + 0.002505f, 0.002133f, 0.001524f, 0.000903f, 0.000317f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000202f, 0.000867f, 0.001309f, + 0.001553f, 0.001563f, 0.001334f, 0.000961f, 0.000530f, 0.000033f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000278f, 0.000621f, 0.000951f, 0.001272f, 0.001608f, 0.001931f, + 0.002199f, 0.002435f, 0.002687f, 0.002947f, 0.003173f, 0.003370f, 0.003577f, 0.003781f, 0.003920f, + 0.003978f, 0.003985f, 0.003937f, 0.003783f, 0.003511f, 0.003170f, 0.002788f, 0.002337f, 0.001808f, + 0.001255f, 0.000716f, 0.000166f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003551f, 0.000000f, 0.000000f, + 0.000000f, 0.005564f, 0.000000f, 0.000000f, 0.000000f, 0.008736f, 0.000000f, 0.000000f, 0.001007f, + 0.011608f, 0.002316f, 0.000000f, 0.000000f, 0.011987f, 0.005591f, 0.000000f, 0.000000f, 0.008714f, + 0.005905f, 0.000000f, 0.000000f, 0.005316f, 0.003972f, 0.000000f, 0.000000f, 0.003403f, 0.002041f, + 0.000000f, 0.000000f, 0.002140f, 0.000245f, 0.000000f}; + +const float defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] = + {0.981018f, 0.973361f, 0.958480f, 0.950611f, 0.953039f, 0.955845f, 0.950660f, 0.942556f, 0.943810f, + 0.958014f, 0.974983f, 0.982099f, 0.977269f, 0.968243f, 0.961714f, 0.957355f, 0.952468f, 0.947771f, + 0.945396f, 0.943711f, 0.938609f, 0.929975f, 0.922937f, 0.921202f, 0.922151f, 0.920926f, 0.917154f, + 0.914393f, 0.914067f, 0.913705f, 0.911632f, 0.910100f, 0.911873f, 0.915812f, 0.918271f, 0.917846f, + 0.916545f, 0.916408f, 0.916915f, 0.916273f, 0.914005f, 0.911339f, 0.909453f, 0.908137f, 0.906301f, + 0.903476f, 0.900479f, 0.898396f, 0.897057f, 0.895115f, 0.891879f, 0.888353f, 0.885879f, 0.884157f, + 0.881651f, 0.877929f, 0.874417f, 0.872453f, 0.871459f, 0.869941f, 0.867796f, 0.866504f, 0.866990f, + 0.868298f, 0.868985f, 0.869170f, 0.870398f, 0.873460f, 0.877373f, 0.880867f, 0.884271f, 0.889105f, + 0.895880f, 0.903280f, 0.909888f, 0.915965f, 0.922776f, 0.930375f, 0.937111f, 0.941667f, 0.944690f, + 0.947747f, 0.950950f, 0.952712f, 0.951893f, 0.949398f, 0.946830f, 0.944212f, 0.940067f, 0.933749f, + 0.926604f, 0.920193f, 0.914164f, 0.906886f, 0.897913f, 0.888731f, 0.880661f, 0.873093f, 0.864556f, + 0.855014f, 0.846098f, 0.839027f, 0.833268f, 0.827720f, 0.822648f, 0.819628f, 0.819557f, 0.821500f, + 0.823986f, 0.826902f, 0.831352f, 0.837670f, 0.844414f, 0.850004f, 0.854617f, 0.859684f, 0.865573f, + 0.870873f, 0.874346f, 0.876636f, 0.879215f, 0.882152f, 0.883944f, 0.883578f, 0.881897f, 0.880319f, + 0.878855f, 0.876201f, 0.871708f, 0.866458f, 0.861964f, 0.858239f, 0.853971f, 0.848551f, 0.843114f, + 0.839005f, 0.835832f, 0.831994f, 0.826972f, 0.822069f, 0.818424f, 0.815337f, 0.811300f, 0.806249f, + 0.801664f, 0.798529f, 0.796124f, 0.793286f, 0.790217f, 0.788277f, 0.788174f, 0.789082f, 0.789775f, + 0.790281f, 0.791803f, 0.794902f, 0.798467f, 0.801024f, 0.802713f, 0.804961f, 0.808244f, 0.811142f, + 0.812318f, 0.812488f, 0.813349f, 0.815025f, 0.815968f, 0.815334f, 0.814250f, 0.814149f, 0.814776f, + 0.814769f, 0.813685f, 0.812567f, 0.812562f, 0.813456f, 0.814055f, 0.813739f, 0.813391f, 0.814325f, + 0.816394f, 0.817949f, 0.818173f, 0.818552f, 0.820798f, 0.824070f, 0.826010f, 0.826515f, 0.828132f, + 0.832036f, 0.835874f, 0.837493f, 0.838582f, 0.842046f, 0.847074f, 0.850262f, 0.851182f, 0.852997f, + 0.856510f, 0.857491f, 0.852207f, 0.842444f, 0.831373f, 0.816756f, 0.793031f, 0.759822f, 0.723220f, + 0.686833f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441279f, 0.391675f, 0.324292f, 0.238341f, + 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, + 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, + 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; + +const float defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] = + {0.981020f, 0.973360f, 0.958481f, 0.950613f, 0.953040f, 0.955848f, 0.950658f, 0.942557f, 0.943810f, + 0.958017f, 0.974981f, 0.982098f, 0.977271f, 0.968244f, 0.961715f, 0.957356f, 0.952467f, 0.947770f, + 0.945398f, 0.943710f, 0.938610f, 0.929975f, 0.922938f, 0.921205f, 0.922151f, 0.920926f, 0.917152f, + 0.914393f, 0.914069f, 0.913705f, 0.911630f, 0.910101f, 0.911874f, 0.915811f, 0.918272f, 0.917846f, + 0.916542f, 0.916408f, 0.916918f, 0.916272f, 0.914004f, 0.911340f, 0.909452f, 0.908136f, 0.906302f, + 0.903479f, 0.900480f, 0.898395f, 0.897055f, 0.895119f, 0.891880f, 0.888352f, 0.885878f, 0.884154f, + 0.881649f, 0.877926f, 0.874417f, 0.872450f, 0.871458f, 0.869943f, 0.867797f, 0.866503f, 0.866987f, + 0.868297f, 0.868981f, 0.869171f, 0.870394f, 0.873460f, 0.877377f, 0.880866f, 0.884272f, 0.889105f, + 0.895880f, 0.903282f, 0.909886f, 0.915965f, 0.922778f, 0.930375f, 0.937113f, 0.941665f, 0.944689f, + 0.947744f, 0.950952f, 0.952711f, 0.951895f, 0.949398f, 0.946830f, 0.944209f, 0.940067f, 0.933750f, + 0.926601f, 0.920191f, 0.914167f, 0.906884f, 0.897916f, 0.888731f, 0.880663f, 0.873093f, 0.864559f, + 0.855017f, 0.846098f, 0.839028f, 0.833267f, 0.827717f, 0.822649f, 0.819631f, 0.819558f, 0.821499f, + 0.823985f, 0.826902f, 0.831353f, 0.837669f, 0.844416f, 0.850003f, 0.854616f, 0.859686f, 0.865572f, + 0.870872f, 0.874347f, 0.876635f, 0.879216f, 0.882154f, 0.883942f, 0.883576f, 0.881895f, 0.880318f, + 0.878857f, 0.876202f, 0.871706f, 0.866459f, 0.861965f, 0.858241f, 0.853968f, 0.848548f, 0.843114f, + 0.839005f, 0.835832f, 0.831994f, 0.826974f, 0.822068f, 0.818424f, 0.815335f, 0.811299f, 0.806245f, + 0.801662f, 0.798530f, 0.796124f, 0.793287f, 0.790217f, 0.788273f, 0.788173f, 0.789081f, 0.789770f, + 0.790279f, 0.791801f, 0.794900f, 0.798466f, 0.801028f, 0.802711f, 0.804962f, 0.808246f, 0.811143f, + 0.812318f, 0.812490f, 0.813348f, 0.815027f, 0.815969f, 0.815335f, 0.814254f, 0.814150f, 0.814776f, + 0.814772f, 0.813686f, 0.812569f, 0.812558f, 0.813456f, 0.814055f, 0.813736f, 0.813389f, 0.814324f, + 0.816395f, 0.817948f, 0.818173f, 0.818549f, 0.820796f, 0.824069f, 0.826013f, 0.826514f, 0.828134f, + 0.832033f, 0.835874f, 0.837493f, 0.838582f, 0.842047f, 0.847077f, 0.850263f, 0.851184f, 0.852998f, + 0.856513f, 0.857491f, 0.852209f, 0.842446f, 0.831375f, 0.816757f, 0.793032f, 0.759821f, 0.723221f, + 0.686832f, 0.646128f, 0.595684f, 0.539241f, 0.486856f, 0.441280f, 0.391676f, 0.324293f, 0.238342f, + 0.149255f, 0.076756f, 0.031022f, 0.009191f, 0.001733f, 0.000140f, 0.000010f, 0.000019f, 0.000015f, + 0.000015f, 0.000014f, 0.000011f, 0.000009f, 0.000009f, 0.000009f, 0.000007f, 0.000006f, 0.000006f, + 0.000007f, 0.000006f, 0.000005f, 0.000005f, 0.000006f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f, + 0.000005f, 0.000005f, 0.000005f, 0.000005f, 0.000005f}; + + +/********************** defaultHRIR reverb rom tables at sampling rate 32kHz **********************/ + +const float defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC] = + {0.992805f, 0.970760f, 0.904274f, 0.794804f, 0.650716f, 0.489140f, 0.331131f, 0.193608f, 0.084875f, + 0.006016f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.006084f, 0.028478f, 0.040113f, + 0.042718f, 0.041091f, 0.039575f, 0.039321f, 0.038312f, 0.033935f, 0.025743f, 0.016207f, 0.009052f, + 0.006651f, 0.008629f, 0.012678f, 0.016595f, 0.019686f, 0.022543f, 0.025721f, 0.028716f, 0.030244f, + 0.029496f, 0.027051f, 0.024537f, 0.023327f, 0.023382f, 0.023280f, 0.021454f, 0.017604f, 0.013058f, + 0.009830f, 0.009160f, 0.010653f, 0.012635f, 0.013369f, 0.012139f, 0.009418f, 0.006248f, 0.003470f, + 0.001368f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.001485f, 0.003632f, 0.005492f, 0.007105f, 0.008527f, 0.009629f, + 0.010103f, 0.009685f, 0.008382f, 0.006502f, 0.004466f, 0.002568f, 0.000890f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000067f, 0.000797f, 0.001293f, 0.001577f, 0.001732f, 0.001797f, 0.001717f, 0.001403f, 0.000826f, + 0.000060f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000318f, 0.000795f, 0.001124f, 0.001249f, 0.001151f, 0.000871f, 0.000495f, 0.000102f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000206f, 0.000612f, 0.000908f, 0.001107f, + 0.001211f, 0.001209f, 0.001095f, 0.000883f, 0.000607f, 0.000298f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000029f, 0.000144f, 0.000254f, 0.000368f, 0.000486f, 0.000599f, + 0.000706f, 0.000810f, 0.000925f, 0.001059f, 0.001209f, 0.001367f, 0.001526f, 0.001686f, 0.001850f, + 0.002018f, 0.002181f, 0.002324f, 0.002440f, 0.002532f, 0.002614f, 0.002696f, 0.002779f, 0.002860f, + 0.002941f, 0.003036f, 0.003166f, 0.003347f, 0.003580f, 0.003855f, 0.004158f, 0.004487f, 0.004850f, + 0.005251f, 0.005688f, 0.006141f, 0.006591f, 0.007029f, 0.007462f, 0.007902f, 0.008351f, 0.008798f, + 0.009224f, 0.009620f, 0.009991f, 0.010352f, 0.010711f, 0.011057f, 0.011367f, 0.011621f, 0.011817f, + 0.011973f, 0.012106f, 0.012223f, 0.012309f, 0.012340f}; + +const float defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] = + {1.030501f, 1.026884f, 1.017950f, 1.008331f, 1.002600f, 1.002689f, 1.006923f, 1.011298f, 1.012169f, + 1.008564f, 1.002836f, 0.999190f, 1.001098f, 1.009190f, 1.020853f, 1.031695f, 1.037922f, 1.038190f, + 1.033894f, 1.027913f, 1.022760f, 1.019333f, 1.016935f, 1.014341f, 1.010980f, 1.007343f, 1.004372f, + 1.002476f, 1.000944f, 0.998381f, 0.993744f, 0.987300f, 0.980631f, 0.975661f, 0.973406f, 0.973314f, + 0.973708f, 0.972973f, 0.970597f, 0.967379f, 0.964640f, 0.963173f, 0.962707f, 0.962251f, 0.960983f, + 0.959006f, 0.957269f, 0.956892f, 0.958263f, 0.960779f, 0.963180f, 0.964405f, 0.964185f, 0.963091f, + 0.962007f, 0.961501f, 0.961514f, 0.961497f, 0.960845f, 0.959307f, 0.957094f, 0.954689f, 0.952548f, + 0.950838f, 0.949382f, 0.947807f, 0.945783f, 0.943211f, 0.940296f, 0.937430f, 0.934938f, 0.932866f, + 0.930925f, 0.928674f, 0.925802f, 0.922364f, 0.918772f, 0.915508f, 0.912798f, 0.910417f, 0.907879f, + 0.904771f, 0.901065f, 0.897182f, 0.893708f, 0.890989f, 0.888922f, 0.887041f, 0.884873f, 0.882294f, + 0.879602f, 0.877334f, 0.875865f, 0.875169f, 0.874822f, 0.874316f, 0.873406f, 0.872264f, 0.871377f, + 0.871228f, 0.871946f, 0.873284f, 0.874764f, 0.876044f, 0.877146f, 0.878469f, 0.880494f, 0.883471f, + 0.887228f, 0.891261f, 0.895055f, 0.898401f, 0.901497f, 0.904769f, 0.908500f, 0.912597f, 0.916577f, + 0.919848f, 0.922085f, 0.923416f, 0.924327f, 0.925296f, 0.926465f, 0.927512f, 0.927876f, 0.927108f, + 0.925203f, 0.922559f, 0.919733f, 0.917037f, 0.914341f, 0.911186f, 0.907145f, 0.902128f, 0.896510f, + 0.890876f, 0.885647f, 0.880803f, 0.875934f, 0.870521f, 0.864338f, 0.857593f, 0.850818f, 0.844491f, + 0.838728f, 0.833217f, 0.827473f, 0.821173f, 0.814417f, 0.807660f, 0.801457f, 0.796095f, 0.791458f, + 0.787181f, 0.782928f, 0.778681f, 0.774802f, 0.771808f, 0.770061f, 0.769530f, 0.769827f, 0.770454f, + 0.771132f, 0.771943f, 0.773228f, 0.775315f, 0.778206f, 0.781513f, 0.784677f, 0.787274f, 0.789288f, + 0.791065f, 0.793055f, 0.795463f, 0.798095f, 0.800470f, 0.802135f, 0.802987f, 0.803318f, 0.803610f, + 0.804182f, 0.804958f, 0.805536f, 0.805434f, 0.804413f, 0.802618f, 0.800482f, 0.798381f, 0.796424f, + 0.794397f, 0.791922f, 0.788779f, 0.785087f, 0.781262f, 0.777778f, 0.774863f, 0.772372f, 0.769886f, + 0.767005f, 0.763613f, 0.759968f, 0.756518f, 0.753595f, 0.751171f, 0.748880f, 0.746246f, 0.743010f, + 0.739317f, 0.735608f, 0.732307f, 0.729533f, 0.727006f, 0.724256f, 0.720938f, 0.717104f, 0.713138f, + 0.709525f, 0.706513f, 0.703976f, 0.701515f, 0.698771f, 0.695693f, 0.692572f, 0.689860f, 0.687867f, + 0.686574f, 0.685644f, 0.684672f, 0.683452f, 0.682093f, 0.680935f, 0.680291f, 0.680231f, 0.680501f, + 0.680700f, 0.680500f, 0.679869f, 0.679047f, 0.678394f, 0.678091f, 0.678035f, 0.677888f, 0.677314f, + 0.676218f, 0.674814f, 0.673484f, 0.672514f, 0.671917f, 0.671422f, 0.670711f, 0.669654f, 0.668436f, + 0.667417f, 0.666896f, 0.666879f, 0.667100f, 0.667225f}; + +const float defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] = + {1.030502f, 1.026883f, 1.017953f, 1.008327f, 1.002600f, 1.002691f, 1.006922f, 1.011300f, 1.012168f, + 1.008564f, 1.002837f, 0.999188f, 1.001094f, 1.009186f, 1.020854f, 1.031695f, 1.037923f, 1.038191f, + 1.033893f, 1.027913f, 1.022760f, 1.019332f, 1.016931f, 1.014338f, 1.010982f, 1.007343f, 1.004370f, + 1.002473f, 1.000948f, 0.998380f, 0.993744f, 0.987300f, 0.980628f, 0.975661f, 0.973406f, 0.973316f, + 0.973710f, 0.972971f, 0.970599f, 0.967380f, 0.964639f, 0.963173f, 0.962708f, 0.962246f, 0.960984f, + 0.959004f, 0.957270f, 0.956889f, 0.958265f, 0.960778f, 0.963180f, 0.964406f, 0.964189f, 0.963091f, + 0.962005f, 0.961500f, 0.961514f, 0.961496f, 0.960845f, 0.959306f, 0.957092f, 0.954688f, 0.952548f, + 0.950838f, 0.949380f, 0.947808f, 0.945783f, 0.943212f, 0.940298f, 0.937430f, 0.934937f, 0.932865f, + 0.930925f, 0.928674f, 0.925801f, 0.922365f, 0.918770f, 0.915509f, 0.912795f, 0.910417f, 0.907881f, + 0.904769f, 0.901065f, 0.897183f, 0.893709f, 0.890990f, 0.888922f, 0.887040f, 0.884874f, 0.882293f, + 0.879603f, 0.877335f, 0.875867f, 0.875169f, 0.874820f, 0.874318f, 0.873404f, 0.872263f, 0.871381f, + 0.871226f, 0.871950f, 0.873283f, 0.874763f, 0.876042f, 0.877147f, 0.878470f, 0.880494f, 0.883473f, + 0.887227f, 0.891261f, 0.895053f, 0.898401f, 0.901500f, 0.904769f, 0.908500f, 0.912599f, 0.916578f, + 0.919847f, 0.922084f, 0.923417f, 0.924328f, 0.925296f, 0.926463f, 0.927512f, 0.927872f, 0.927107f, + 0.925199f, 0.922559f, 0.919735f, 0.917037f, 0.914339f, 0.911186f, 0.907142f, 0.902131f, 0.896510f, + 0.890876f, 0.885644f, 0.880802f, 0.875934f, 0.870524f, 0.864337f, 0.857594f, 0.850819f, 0.844491f, + 0.838727f, 0.833219f, 0.827473f, 0.821173f, 0.814415f, 0.807662f, 0.801459f, 0.796094f, 0.791462f, + 0.787182f, 0.782926f, 0.778681f, 0.774803f, 0.771810f, 0.770061f, 0.769529f, 0.769825f, 0.770456f, + 0.771131f, 0.771940f, 0.773230f, 0.775319f, 0.778206f, 0.781513f, 0.784675f, 0.787274f, 0.789285f, + 0.791065f, 0.793054f, 0.795465f, 0.798097f, 0.800468f, 0.802133f, 0.802987f, 0.803319f, 0.803610f, + 0.804179f, 0.804959f, 0.805538f, 0.805434f, 0.804411f, 0.802621f, 0.800480f, 0.798379f, 0.796426f, + 0.794398f, 0.791920f, 0.788777f, 0.785087f, 0.781263f, 0.777777f, 0.774862f, 0.772372f, 0.769886f, + 0.767004f, 0.763614f, 0.759968f, 0.756517f, 0.753593f, 0.751172f, 0.748881f, 0.746246f, 0.743011f, + 0.739318f, 0.735608f, 0.732306f, 0.729532f, 0.727006f, 0.724254f, 0.720939f, 0.717103f, 0.713136f, + 0.709524f, 0.706514f, 0.703976f, 0.701513f, 0.698772f, 0.695692f, 0.692570f, 0.689859f, 0.687869f, + 0.686573f, 0.685642f, 0.684671f, 0.683452f, 0.682094f, 0.680934f, 0.680290f, 0.680228f, 0.680501f, + 0.680699f, 0.680498f, 0.679867f, 0.679050f, 0.678395f, 0.678093f, 0.678035f, 0.677889f, 0.677315f, + 0.676220f, 0.674814f, 0.673485f, 0.672517f, 0.671918f, 0.671424f, 0.670712f, 0.669657f, 0.668437f, + 0.667421f, 0.666896f, 0.666880f, 0.667103f, 0.667228f}; + + + +/********************** defaultHRIR reverb rom tables at sampling rate 16kHz **********************/ + +const float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {0.983044f, 0.960794f, 0.893756f, 0.783586f, 0.638963f, 0.477338f, 0.319879f, 0.183374f, 0.075909f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003842f, 0.025288f, 0.035886f, + 0.037785f, 0.035991f, 0.034784f, 0.035091f, 0.034683f, 0.030849f, 0.023146f, 0.014061f, 0.007275f, + 0.005053f, 0.006930f, 0.010589f, 0.013905f, 0.016288f, 0.018404f, 0.020849f, 0.023164f, 0.024149f, + 0.023098f, 0.020635f, 0.018325f, 0.017381f, 0.017611f, 0.017534f, 0.015650f, 0.011786f, 0.007342f, + 0.004290f, 0.003732f, 0.005148f, 0.006838f, 0.007172f, 0.005579f, 0.002632f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000238f, 0.001738f, 0.003011f, 0.003910f, + 0.004120f, 0.003394f, 0.001769f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, + 0.000000f, 0.002101f, 0.004247f, 0.006330f, 0.008300f, 0.010110f, 0.011735f, 0.013165f, 0.014384f, + 0.015345f, 0.015972f, 0.016191f}; + +const float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {1.118974f, 1.115256f, 1.106210f, 1.096901f, 1.092316f, 1.094422f, 1.101140f, 1.107775f, 1.110000f, + 1.106535f, 1.099921f, 1.094914f, 1.095643f, 1.103178f, 1.114955f, 1.126292f, 1.132973f, 1.133288f, + 1.128471f, 1.121439f, 1.114842f, 1.109721f, 1.105480f, 1.100966f, 1.095650f, 1.090074f, 1.085225f, + 1.081525f, 1.078267f, 1.074026f, 1.067777f, 1.059839f, 1.051856f, 1.045772f, 1.042531f, 1.041432f, + 1.040607f, 1.038291f, 1.033910f, 1.028286f, 1.022846f, 1.018514f, 1.015152f, 1.011898f, 1.008047f, + 1.003762f, 0.999992f, 0.997770f, 0.997349f, 0.997960f, 0.998259f, 0.997177f, 0.994506f, 0.990883f, + 0.987207f, 0.984003f, 0.981133f, 0.977984f, 0.973950f, 0.968837f, 0.962915f, 0.956690f, 0.950584f, + 0.944679f, 0.938744f, 0.932399f, 0.925372f, 0.917663f, 0.909568f, 0.901511f, 0.893804f, 0.886455f, + 0.879155f, 0.871463f, 0.863142f, 0.854285f, 0.845334f, 0.836740f, 0.828656f, 0.820817f, 0.812713f, + 0.803960f, 0.794564f, 0.784952f, 0.775633f, 0.766881f, 0.758539f, 0.750156f, 0.741330f, 0.732004f, + 0.722524f, 0.713387f, 0.704919f, 0.697057f, 0.689419f, 0.681576f, 0.673350f, 0.664931f, 0.656703f, + 0.648997f, 0.641801f, 0.634760f, 0.627357f, 0.619192f, 0.610186f, 0.600526f, 0.590442f, 0.579952f, + 0.568762f, 0.556384f, 0.542389f, 0.526648f, 0.509355f, 0.490884f, 0.471542f, 0.451447f, 0.430550f, + 0.408842f, 0.386537f, 0.364126f, 0.342284f, 0.321675f, 0.302809f, 0.286016f, 0.271536f, 0.259639f, + 0.250691f, 0.245099f, 0.243192f}; + +const float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = + {1.118974f, 1.115254f, 1.106207f, 1.096903f, 1.092317f, 1.094425f, 1.101145f, 1.107775f, 1.109999f, + 1.106540f, 1.099921f, 1.094912f, 1.095644f, 1.103178f, 1.114952f, 1.126292f, 1.132973f, 1.133288f, + 1.128472f, 1.121439f, 1.114842f, 1.109719f, 1.105481f, 1.100965f, 1.095650f, 1.090072f, 1.085224f, + 1.081527f, 1.078270f, 1.074025f, 1.067775f, 1.059840f, 1.051856f, 1.045772f, 1.042533f, 1.041433f, + 1.040611f, 1.038292f, 1.033911f, 1.028286f, 1.022844f, 1.018512f, 1.015153f, 1.011899f, 1.008050f, + 1.003762f, 0.999995f, 0.997769f, 0.997349f, 0.997959f, 0.998259f, 0.997178f, 0.994509f, 0.990883f, + 0.987204f, 0.984003f, 0.981133f, 0.977983f, 0.973949f, 0.968836f, 0.962914f, 0.956689f, 0.950583f, + 0.944681f, 0.938745f, 0.932399f, 0.925373f, 0.917662f, 0.909567f, 0.901511f, 0.893804f, 0.886456f, + 0.879153f, 0.871467f, 0.863138f, 0.854286f, 0.845334f, 0.836740f, 0.828656f, 0.820816f, 0.812712f, + 0.803961f, 0.794567f, 0.784951f, 0.775631f, 0.766882f, 0.758540f, 0.750158f, 0.741330f, 0.732005f, + 0.722523f, 0.713388f, 0.704920f, 0.697057f, 0.689418f, 0.681575f, 0.673352f, 0.664930f, 0.656706f, + 0.648998f, 0.641802f, 0.634762f, 0.627355f, 0.619192f, 0.610187f, 0.600527f, 0.590442f, 0.579953f, + 0.568763f, 0.556383f, 0.542389f, 0.526646f, 0.509355f, 0.490883f, 0.471543f, 0.451446f, 0.430550f, + 0.408843f, 0.386537f, 0.364127f, 0.342285f, 0.321676f, 0.302809f, 0.286016f, 0.271535f, 0.259640f, + 0.250692f, 0.245099f, 0.243192f}; + + +#else + const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { 131936432,125285536,105934832,77097344,45729324,19356880,2523696,0,0, 0,1602425,4763253,5796595,5698884,5608690,5175704,3880368,2303444, @@ -59838,70 +60089,103 @@ const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ 2790378,2355663,2029237,1865240,1832432 }; -const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = -{ - 131941936, 128955584, 119957896, 105171136, 85760160, 64067220, 42933432, 24612042, - 10188334, 0, 0, 0, 0, 0, 0, 515664, - 3394098, 4816537, 5071417, 4830630, 4668629, 4709834, 4655073, 4140482, - 3106603, 1887235, 976434, 678202, 930128, 1421231, 1866297, 2186138, - 2470143, 2798305, 3109019, 3241224, 3100161, 2769582, 2459539, 2332838, - 2363708, 2353373, 2100507, 1581890, 985426, 575794, 500900, 690952, - 917780, 962609, 748800, 353261, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 31943, 233270, 404129, 524791, - 552977, 455534, 237431, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 281991, 570022, - 849598, 1114007, 1356941, 1575045, 1766976, 1930587, 2059571, 2143725, - 2173119 +const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { + 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, + 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, + 1532229,985023,437818,0,0,0,0,0,0, + 0,343865,773496,1203261,2004810,3054258,4103707,4777480,4887673, + 4998000,5066316,4966727,4867271,4767816,4765534,4763253,4760971,4569174, + 4329998,4090822,3659312,3099355,2539533,2037290,1621350,1205543,880065, + 916304,952677,988916,1233058,1477200,1721342,1912602,2090441,2268413, + 2427327,2573490,2719788,2859643,2989834,3120025,3219078,3193576,3168075, + 3142574,2987686,2832665,2677778,2583691,2504771,2425851,2397128,2401692, + 2406255,2356594,2225464,2094333,1933137,1651280,1369423,1087566,924357, + 761148,597940,625051,699677,774302,854295,937779,1021128,1026631, + 915230,803830,670014,446676,223338,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,5100,30735, + 56371,81872,173140,264408,355542,419698,477144,534455,552037, + 543044,533918,485599,378494,271254,173946,115964,57982,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0, + 0,0,671,1476,2415,99723,261321,423054,646795, + 963549,1280302,1632087,2124129,2616037,3108080,3841982,4575885,5309922, + 6280181,7309766,8339216,8750996,8750996 }; - -const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = -{ - 9386634, 9355445, 9279562, 9201473, 9163011, 9180677, 9237032, 9292690, - 9311355, 9282288, 9226806, 9184804, 9190920, 9254128, 9352920, 9448022, - 9504066, 9506709, 9466301, 9407312, 9351973, 9309014, 9273438, 9235572, - 9190978, 9144203, 9103527, 9072489, 9045159, 9009583, 8957163, 8890574, - 8823608, 8772571, 8745384, 8736165, 8729244, 8709816, 8673066, 8625888, - 8580254, 8543915, 8515712, 8488416, 8456111, 8420166, 8388541, 8369901, - 8366370, 8371495, 8374003, 8364927, 8342521, 8312129, 8281292, 8254415, - 8230340, 8203924, 8170085, 8127194, 8077516, 8025297, 7974076, 7924542, - 7874755, 7821529, 7762583, 7697915, 7630009, 7562422, 7497771, 7436123, - 7374886, 7310361, 7240560, 7166262, 7091175, 7019084, 6951270, 6885512, - 6817531, 6744105, 6665286, 6584654, 6506481, 6433064, 6363086, 6292764, - 6218727, 6140494, 6060970, 5984324, 5913289, 5847338, 5783265, 5717474, - 5648469, 5577845, 5508824, 5444181, 5383817, 5324753, 5262652, 5194159, - 5118611, 5037577, 4952986, 4864990, 4771121, 4667287, 4549888, 4417843, - 4272779, 4117833, 3955581, 3787012, 3611715, 3429615, 3242507, 3054510, - 2871286, 2698405, 2540146, 2399276, 2277809, 2178009, 2102948, 2056039, - 2040042 +const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 9335246,9335246,9316514,9269680,9222847,9180350,9155201,9130044,9104894, + 9126688,9148473,9170267,9191549,9212688,9233844,9234423,9221295,9208167, + 9191205,9168497,9145789,9127997,9129884,9131780,9133676,9164823,9195978, + 9227125,9267550,9310290,9353038,9385225,9410374,9435531,9445170,9431538, + 9417907,9399855,9364128,9328409,9292682,9270670,9248667,9226655,9215783, + 9207688,9199593,9183605,9162356,9141108,9116244,9085961,9055678,9028608, + 9014432,9000255,8986078,8975962,8965845,8955728,8926108,8891606,8857103, + 8819145,8778896,8738639,8710806,8701604,8692401,8686227,8692209,8698190, + 8704171,8686706,8669232,8651767,8623917,8593466,8563024,8543554,8531399, + 8519252,8509748,8504203,8498667,8489716,8467083,8444459,8421835,8399773, + 8377711,8355649,8351698,8352268,8352847,8355833,8360430,8365027,8363484, + 8352721,8341959,8331028,8319460,8307884,8296308,8292063,8287827,8283582, + 8271142,8256647,8242159,8221389,8196442,8171494,8150547,8135607,8120659, + 8106465,8095225,8083992,8072760,8043073,8013394,7983706,7949422,7913997, + 7878564,7853893,7836394,7818904,7801472,7784141,7766811,7744782,7703972, + 7663169,7622359,7580802,7539253,7497696,7474266,7455367,7436467,7415496, + 7393140,7370784,7338471,7291235,7244007,7197551,7154232,7110914,7067595, + 7046615,7025627,7004647,6977485,6948779,6920073,6878751,6829015,6779278, + 6733644,6694184,6654724,6618804,6597044,6575284,6553524,6518183,6482842, + 6447501,6401632,6353137,6304634,6267229,6237215,6207201,6181045,6160677, + 6140310,6115580,6073427,6031275,5989122,5942817,5896503,5850198,5825150, + 5805428,5785707,5765742,5745626,5725510,5693398,5643285,5593180,5544358, + 5500720,5457091,5413454,5404126,5394797,5385469,5366930,5346085,5325239, + 5282164,5224274,5166376,5115566,5075376,5035186,5002731,5001238,4999736, + 4998243,4969436,4940630,4911823,4847290,4773822,4700355,4646282,4605153, + 4564023,4540250,4542523,4544788,4536869,4488241,4439612,4390983,4285488, + 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, + 4073222,4038317,3957300,3691818,3426335,3160861,2774481,2388110,2001740, + 1708239,1437966,1167685,1059581,1059581 }; - -const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = -{ - 9386634, 9355429, 9279537, 9201489, 9163019, 9180702, 9237074, 9292690, - 9311346, 9282330, 9226806, 9184788, 9190928, 9254128, 9352895, 9448022, - 9504066, 9506709, 9466309, 9407312, 9351973, 9308998, 9273447, 9235564, - 9190978, 9144187, 9103519, 9072506, 9045184, 9009575, 8957146, 8890582, - 8823608, 8772571, 8745401, 8736173, 8729278, 8709825, 8673074, 8625888, - 8580237, 8543898, 8515721, 8488424, 8456136, 8420166, 8388566, 8369893, - 8366370, 8371487, 8374003, 8364935, 8342546, 8312129, 8281267, 8254415, - 8230340, 8203916, 8170076, 8127185, 8077508, 8025289, 7974068, 7924558, - 7874764, 7821529, 7762591, 7697907, 7630001, 7562422, 7497771, 7436132, - 7374870, 7310395, 7240526, 7166270, 7091175, 7019084, 6951270, 6885503, - 6817522, 6744113, 6665311, 6584646, 6506464, 6433072, 6363094, 6292781, - 6218727, 6140503, 6060962, 5984332, 5913297, 5847338, 5783257, 5717465, - 5648486, 5577837, 5508849, 5444190, 5383825, 5324769, 5262635, 5194159, - 5118619, 5037585, 4952986, 4864998, 4771130, 4667279, 4549888, 4417827, - 4272779, 4117825, 3955589, 3787003, 3611715, 3429623, 3242507, 3054518, - 2871294, 2698413, 2540146, 2399276, 2277800, 2178018, 2102957, 2056039, - 2040042 +const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { + 9335246,9335246,9316514,9269689,9222855,9180358,9155201,9130035,9104869, + 9126663,9148465,9170258,9191540,9212688,9233827,9234415,9221295,9208175, + 9191213,9168488,9145755,9127963,9129867,9131772,9133676,9164831,9195978, + 9227133,9267550,9310281,9353021,9385200,9410357,9435506,9445153,9431522, + 9417899,9399855,9364119,9328384,9292648,9270653,9248658,9226663,9215792, + 9207688,9199593,9183596,9162348,9141100,9116236,9085953,9055678,9028617, + 9014432,9000255,8986070,8975962,8965853,8955745,8926116,8891614,8857103, + 8819145,8778888,8738631,8710789,8701587,8692385,8686219,8692200,8698181, + 8704162,8686697,8669232,8651775,8623917,8593466,8563016,8543546,8531390, + 8519244,8509739,8504203,8498675,8489724,8467100,8444468,8421844,8399773, + 8377703,8355641,8351681,8352252,8352830,8355817,8360414,8365019,8363475, + 8352721,8341959,8331037,8319469,8307893,8296316,8292072,8287835,8283591, + 8271142,8256647,8242151,8221381,8196433,8171494,8150547,8135616,8120676, + 8106482,8095250,8084009,8072777,8043081,8013385,7983698,7949405,7913972, + 7878547,7853876,7836386,7818904,7801481,7784150,7766819,7744790,7703980, + 7663161,7622350,7580793,7539244,7497696,7474258,7455358,7436459,7415487, + 7393132,7370776,7338471,7291244,7244016,7197560,7154241,7110914,7067587, + 7046607,7025627,7004647,6977485,6948770,6920064,6878742,6829006,6779270, + 6733644,6694184,6654724,6618813,6597053,6575301,6553549,6518191,6482842, + 6447492,6401623,6353137,6304643,6267229,6237215,6207201,6181037,6160677, + 6140310,6115580,6073427,6031275,5989122,5942817,5896512,5850207,5825167, + 5805445,5785723,5765750,5745626,5725493,5693382,5643276,5593180,5544375, + 5500729,5457074,5413429,5404109,5394789,5385478,5366939,5346093,5325247, + 5282172,5224282,5166384,5115574,5075384,5035195,5002739,5001238,4999736, + 4998243,4969436,4940630,4911823,4847290,4773814,4700338,4646274,4605153, + 4564023,4540258,4542523,4544788,4536878,4488249,4439612,4390983,4285480, + 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, + 4073222,4038317,3957292,3691809,3426327,3160844,2774473,2388110,2001740, + 1708239,1437966,1167685,1059573,1059573 }; #endif +#endif + Word32 sine_table_Q31 [361] = { 187, diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 31f75e876..8648cfa73 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -810,6 +810,16 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; +#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q28, lr_iac_len ); + + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_r_dyn, Q28, lr_iac_len ); + + fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); + floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q26, lr_iac_len ); +#else fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q23, lr_iac_len ); @@ -818,7 +828,7 @@ static ivas_error load_reverb_from_binary( fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); - +#endif hHrtfStatistics->fromROM = FALSE; #else /* left/right energy and interaural coherence for late reverb */ -- GitLab From 70100607fc5d002d937ce5f8d940c01d8dc17cee Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 26 Jun 2025 21:39:42 +0530 Subject: [PATCH 447/692] 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 448/692] 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 449/692] 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 450/692] 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 451/692] 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 452/692] 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 453/692] 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 407b6c41d6fb55d5bd64e924f0c070eba6815209 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 27 Jun 2025 16:59:25 +0200 Subject: [PATCH 454/692] Updated Q-format fixed-point representation for RT60 reverberation times (Q31 -> Q27) --- .../3.31.5/CompilerIdC/CMakeCCompilerId.c | 904 ++++++++++++++++++ lib_com/options.h | 1 + .../ivas_dirac_dec_binaural_functions_fx.c | 4 + lib_rend/ivas_reverb_fx.c | 30 + lib_rend/ivas_rom_binauralRenderer.h | 8 + lib_rend/ivas_rom_binauralRenderer_fx.c | 29 + lib_rend/ivas_stat_rend.h | 12 + lib_util/hrtf_file_reader.c | 8 + 8 files changed, 996 insertions(+) create mode 100644 build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c diff --git a/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c b/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c new file mode 100644 index 000000000..8d8bb038b --- /dev/null +++ b/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c @@ -0,0 +1,904 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +#if defined(__18CXX) +# define ID_VOID_MAIN +#endif +#if defined(__CLASSIC_C__) +/* cv-qualifiers did not exist in K&R C */ +# define const +# define volatile +#endif + +#if !defined(__has_include) +/* If the compiler does not have __has_include, pretend the answer is + always no. */ +# define __has_include(x) 0 +#endif + + +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# if defined(__GNUC__) +# define SIMULATE_ID "GNU" +# endif + /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, + except that a few beta releases use the old format with V=2021. */ +# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif +# else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) + /* The third version component from --version is an update index, + but no macro is provided for it. */ +# define COMPILER_VERSION_PATCH DEC(0) +# endif +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) +# define COMPILER_ID "IntelLLVM" +#if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +#endif +#if defined(__GNUC__) +# define SIMULATE_ID "GNU" +#endif +/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and + * later. Look for 6 digit vs. 8 digit version number to decide encoding. + * VVVV is no smaller than the current year when a version is released. + */ +#if __INTEL_LLVM_COMPILER < 1000000L +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) +#else +# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) +# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) +#endif +#if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +#endif +#if defined(__GNUC__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +#elif defined(__GNUG__) +# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) +#endif +#if defined(__GNUC_MINOR__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +#endif +#if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +#endif + +#elif defined(__PATHCC__) +# define COMPILER_ID "PathScale" +# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) +# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) +# if defined(__PATHCC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) +# endif + +#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) +# define COMPILER_ID "Embarcadero" +# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) +# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) +# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) + +#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 +# define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__WATCOMC__) +# define COMPILER_ID "OpenWatcom" + /* __WATCOMC__ = VVRP + 1100 */ +# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) +# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) +# if (__WATCOMC__ % 10) > 0 +# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) +# endif + +#elif defined(__SUNPRO_C) +# define COMPILER_ID "SunPro" +# if __SUNPRO_C >= 0x5100 + /* __SUNPRO_C = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# endif + +#elif defined(__HP_cc) +# define COMPILER_ID "HP" + /* __HP_cc = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) + +#elif defined(__DECC) +# define COMPILER_ID "Compaq" + /* __DECC_VER = VVRRTPPPP */ +# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) +# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) +# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) + +#elif defined(__IBMC__) && defined(__COMPILER_VER__) +# define COMPILER_ID "zOS" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__open_xl__) && defined(__clang__) +# define COMPILER_ID "IBMClang" +# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__) +# define COMPILER_VERSION_MINOR DEC(__open_xl_release__) +# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__) + + +#elif defined(__ibmxl__) && defined(__clang__) +# define COMPILER_ID "XLClang" +# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) +# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) +# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) +# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) + + +#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 +# define COMPILER_ID "XL" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 +# define COMPILER_ID "VisualAge" + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) + +#elif defined(__NVCOMPILER) +# define COMPILER_ID "NVHPC" +# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) +# if defined(__NVCOMPILER_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) +# endif + +#elif defined(__PGI) +# define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif + +#elif defined(__clang__) && defined(__cray__) +# define COMPILER_ID "CrayClang" +# define COMPILER_VERSION_MAJOR DEC(__cray_major__) +# define COMPILER_VERSION_MINOR DEC(__cray_minor__) +# define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(_CRAYC) +# define COMPILER_ID "Cray" +# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) +# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) + +#elif defined(__TI_COMPILER_VERSION__) +# define COMPILER_ID "TI" + /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ +# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) +# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) +# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) + +#elif defined(__CLANG_FUJITSU) +# define COMPILER_ID "FujitsuClang" +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# define COMPILER_VERSION_INTERNAL_STR __clang_version__ + + +#elif defined(__FUJITSU) +# define COMPILER_ID "Fujitsu" +# if defined(__FCC_version__) +# define COMPILER_VERSION __FCC_version__ +# elif defined(__FCC_major__) +# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) +# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) +# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) +# endif +# if defined(__fcc_version) +# define COMPILER_VERSION_INTERNAL DEC(__fcc_version) +# elif defined(__FCC_VERSION) +# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) +# endif + + +#elif defined(__ghs__) +# define COMPILER_ID "GHS" +/* __GHS_VERSION_NUMBER = VVVVRP */ +# ifdef __GHS_VERSION_NUMBER +# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) +# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) +# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) +# endif + +#elif defined(__TASKING__) +# define COMPILER_ID "Tasking" + # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000) + # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100) +# define COMPILER_VERSION_INTERNAL DEC(__VERSION__) + +#elif defined(__ORANGEC__) +# define COMPILER_ID "OrangeC" +# define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__) +# define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__) + +#elif defined(__TINYC__) +# define COMPILER_ID "TinyCC" + +#elif defined(__BCC__) +# define COMPILER_ID "Bruce" + +#elif defined(__SCO_VERSION__) +# define COMPILER_ID "SCO" + +#elif defined(__ARMCC_VERSION) && !defined(__clang__) +# define COMPILER_ID "ARMCC" +#if __ARMCC_VERSION >= 1000000 + /* __ARMCC_VERSION = VRRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#else + /* __ARMCC_VERSION = VRPPPP */ + # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) + # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) + # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) +#endif + + +#elif defined(__clang__) && defined(__apple_build_version__) +# define COMPILER_ID "AppleClang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif +# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) + +#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) +# define COMPILER_ID "ARMClang" + # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) + # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) + # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100) +# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) + +#elif defined(__clang__) && defined(__ti__) +# define COMPILER_ID "TIClang" + # define COMPILER_VERSION_MAJOR DEC(__ti_major__) + # define COMPILER_VERSION_MINOR DEC(__ti_minor__) + # define COMPILER_VERSION_PATCH DEC(__ti_patchlevel__) +# define COMPILER_VERSION_INTERNAL DEC(__ti_version__) + +#elif defined(__clang__) +# define COMPILER_ID "Clang" +# if defined(_MSC_VER) +# define SIMULATE_ID "MSVC" +# endif +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) +# if defined(_MSC_VER) + /* _MSC_VER = VVRR */ +# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) +# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) +# endif + +#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) +# define COMPILER_ID "LCC" +# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100) +# if defined(__LCC_MINOR__) +# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) +# endif +# if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define SIMULATE_ID "GNU" +# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) +# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif +# endif + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# if defined(__GNUC_MINOR__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif + +#elif defined(_ADI_COMPILER) +# define COMPILER_ID "ADSP" +#if defined(__VERSIONNUM__) + /* __VERSIONNUM__ = 0xVVRRPPTT */ +# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF) +# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF) +# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF) +# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF) +#endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# define COMPILER_ID "IAR" +# if defined(__VER__) && defined(__ICCARM__) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) +# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) +# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) +# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) +# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) +# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) +# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) +# endif + +#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) +# define COMPILER_ID "SDCC" +# if defined(__SDCC_VERSION_MAJOR) +# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) +# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) +# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) +# else + /* SDCC = VRP */ +# define COMPILER_VERSION_MAJOR DEC(SDCC/100) +# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) +# define COMPILER_VERSION_PATCH DEC(SDCC % 10) +# endif + + +/* These compilers are either not known or too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; +#ifdef SIMULATE_ID +char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; +#endif + +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto[]"; +#endif + +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) +char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; +#endif + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__MSYS__) +# define PLATFORM_ID "MSYS" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__HAIKU__) +# define PLATFORM_ID "Haiku" + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#elif defined(__WATCOMC__) +# if defined(__LINUX__) +# define PLATFORM_ID "Linux" + +# elif defined(__DOS__) +# define PLATFORM_ID "DOS" + +# elif defined(__OS2__) +# define PLATFORM_ID "OS2" + +# elif defined(__WINDOWS__) +# define PLATFORM_ID "Windows3x" + +# elif defined(__VXWORKS__) +# define PLATFORM_ID "VxWorks" + +# else /* unknown platform */ +# define PLATFORM_ID +# endif + +#elif defined(__INTEGRITY) +# if defined(INT_178B) +# define PLATFORM_ID "Integrity178" + +# else /* regular Integrity */ +# define PLATFORM_ID "Integrity" +# endif + +# elif defined(_ADI_COMPILER) +# define PLATFORM_ID "ADSP" + +#else /* unknown platform */ +# define PLATFORM_ID + +#endif + +/* For windows compilers MSVC and Intel we can determine + the architecture of the compiler being used. This is because + the compilers do not have flags that can change the architecture, + but rather depend on which compiler is being used +*/ +#if defined(_WIN32) && defined(_MSC_VER) +# if defined(_M_IA64) +# define ARCHITECTURE_ID "IA64" + +# elif defined(_M_ARM64EC) +# define ARCHITECTURE_ID "ARM64EC" + +# elif defined(_M_X64) || defined(_M_AMD64) +# define ARCHITECTURE_ID "x64" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# elif defined(_M_ARM64) +# define ARCHITECTURE_ID "ARM64" + +# elif defined(_M_ARM) +# if _M_ARM == 4 +# define ARCHITECTURE_ID "ARMV4I" +# elif _M_ARM == 5 +# define ARCHITECTURE_ID "ARMV5I" +# else +# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) +# endif + +# elif defined(_M_MIPS) +# define ARCHITECTURE_ID "MIPS" + +# elif defined(_M_SH) +# define ARCHITECTURE_ID "SHx" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__WATCOMC__) +# if defined(_M_I86) +# define ARCHITECTURE_ID "I86" + +# elif defined(_M_IX86) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) +# if defined(__ICCARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + +# elif defined(__ICCRH850__) +# define ARCHITECTURE_ID "RH850" + +# elif defined(__ICCRL78__) +# define ARCHITECTURE_ID "RL78" + +# elif defined(__ICCRISCV__) +# define ARCHITECTURE_ID "RISCV" + +# elif defined(__ICCAVR__) +# define ARCHITECTURE_ID "AVR" + +# elif defined(__ICC430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__ICCV850__) +# define ARCHITECTURE_ID "V850" + +# elif defined(__ICC8051__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__ICCSTM8__) +# define ARCHITECTURE_ID "STM8" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__ghs__) +# if defined(__PPC64__) +# define ARCHITECTURE_ID "PPC64" + +# elif defined(__ppc__) +# define ARCHITECTURE_ID "PPC" + +# elif defined(__ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__x86_64__) +# define ARCHITECTURE_ID "x64" + +# elif defined(__i386__) +# define ARCHITECTURE_ID "X86" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__clang__) && defined(__ti__) +# if defined(__ARM_ARCH) +# define ARCHITECTURE_ID "Arm" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +#elif defined(__TI_COMPILER_VERSION__) +# if defined(__TI_ARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__MSP430__) +# define ARCHITECTURE_ID "MSP430" + +# elif defined(__TMS320C28XX__) +# define ARCHITECTURE_ID "TMS320C28x" + +# elif defined(__TMS320C6X__) || defined(_TMS320C6X) +# define ARCHITECTURE_ID "TMS320C6x" + +# else /* unknown architecture */ +# define ARCHITECTURE_ID "" +# endif + +# elif defined(__ADSPSHARC__) +# define ARCHITECTURE_ID "SHARC" + +# elif defined(__ADSPBLACKFIN__) +# define ARCHITECTURE_ID "Blackfin" + +#elif defined(__TASKING__) + +# if defined(__CTC__) || defined(__CPTC__) +# define ARCHITECTURE_ID "TriCore" + +# elif defined(__CMCS__) +# define ARCHITECTURE_ID "MCS" + +# elif defined(__CARM__) +# define ARCHITECTURE_ID "ARM" + +# elif defined(__CARC__) +# define ARCHITECTURE_ID "ARC" + +# elif defined(__C51__) +# define ARCHITECTURE_ID "8051" + +# elif defined(__CPCP__) +# define ARCHITECTURE_ID "PCP" + +# else +# define ARCHITECTURE_ID "" +# endif + +#else +# define ARCHITECTURE_ID +#endif + +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number. */ +#ifdef COMPILER_VERSION +char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; + +/* Construct a string literal encoding the version number components. */ +#elif defined(COMPILER_VERSION_MAJOR) +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct a string literal encoding the internal version number. */ +#ifdef COMPILER_VERSION_INTERNAL +char const info_version_internal[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', + 'i','n','t','e','r','n','a','l','[', + COMPILER_VERSION_INTERNAL,']','\0'}; +#elif defined(COMPILER_VERSION_INTERNAL_STR) +char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; +#endif + +/* Construct a string literal encoding the version number components. */ +#ifdef SIMULATE_VERSION_MAJOR +char const info_simulate_version[] = { + 'I', 'N', 'F', 'O', ':', + 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', + SIMULATE_VERSION_MAJOR, +# ifdef SIMULATE_VERSION_MINOR + '.', SIMULATE_VERSION_MINOR, +# ifdef SIMULATE_VERSION_PATCH + '.', SIMULATE_VERSION_PATCH, +# ifdef SIMULATE_VERSION_TWEAK + '.', SIMULATE_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + +/* Construct the string literal in pieces to prevent the source from + getting matched. Store it in a pointer rather than an array + because some compilers will just produce instructions to fill the + array rather than assigning a pointer to a static array. */ +char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; +char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; + + + +#define C_STD_99 199901L +#define C_STD_11 201112L +#define C_STD_17 201710L +#define C_STD_23 202311L + +#ifdef __STDC_VERSION__ +# define C_STD __STDC_VERSION__ +#endif + +#if !defined(__STDC__) && !defined(__clang__) +# if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) +# define C_VERSION "90" +# else +# define C_VERSION +# endif +#elif C_STD > C_STD_17 +# define C_VERSION "23" +#elif C_STD > C_STD_11 +# define C_VERSION "17" +#elif C_STD > C_STD_99 +# define C_VERSION "11" +#elif C_STD >= C_STD_99 +# define C_VERSION "99" +#else +# define C_VERSION "90" +#endif +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + +/*--------------------------------------------------------------------------*/ + +#ifdef ID_VOID_MAIN +void main() {} +#else +# if defined(__CLASSIC_C__) +int main(argc, argv) int argc; char *argv[]; +# else +int main(int argc, char* argv[]) +# endif +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif +#ifdef COMPILER_VERSION_INTERNAL + require += info_version_internal[argc]; +#endif +#ifdef SIMULATE_ID + require += info_simulate[argc]; +#endif +#ifdef SIMULATE_VERSION_MAJOR + require += info_simulate_version[argc]; +#endif +#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) + require += info_cray[argc]; +#endif + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; + (void)argv; + return require; +} +#endif diff --git a/lib_com/options.h b/lib_com/options.h index 8b1f827bb..f262bea81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,6 +122,7 @@ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ +#define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q27 format instead of Q31 */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index a1d3a4908..0b9e3750a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -503,7 +503,11 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( Copy( hrtfShCoeffsIm_fx[i][j], hrtfParambin->hrtfShCoeffsIm_fx[i][j], HRTF_NUM_BINS ); /*Q14*/ } } +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q27*/ +#else Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ +#endif Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX ); /*Q28*/ *hHrtfParambin = hrtfParambin; diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 4e054b699..8fbe82abf 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -219,7 +219,11 @@ static void ivas_binaural_reverb_setPreDelay_fx( static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + const Word32 *revTimes_fx, /*Q27 i : reverberation times T60 for each CLDFB bin in seconds */ +#else const Word32 *revTimes_fx, /*Q31 i : reverberation times T60 for each CLDFB bin in seconds */ +#endif const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ ) { @@ -324,7 +328,11 @@ static void ivas_binaural_reverb_setReverbTimes_fx( /* Determine attenuation factor that generates the appropriate energy decay according to reverberation time */ L_tmp = Mpy_32_32( 1677721600, revTimes_fx[bin] ); // e10 --> 800 * 2^21, + e0 tmp = BASOP_Util_Divide3232_Scale( 1073741824, L_tmp, &scale ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + scale = add( scale, sub( 1, 14 ) ); // revTimes_fx in Q27 +#else scale = add( scale, sub( 1, 10 ) ); +#endif L_tmp = Mpy_32_16_1( -1610612736, tmp ); // * -3 scale = add( 2, scale ); L_tmp = Mpy_32_32( 1783446563, L_tmp ); // scale + 2 @@ -2386,7 +2394,11 @@ static ivas_error ivas_binaural_reverb_open_fx( const Word16 numBins, /* i : Q0 number of CLDFB bins */ const Word16 numCldfbSlotsPerFrame, /* i : Q0 number of CLDFB slots per frame */ const Word32 sampling_rate, /* i : Q0 sampling rate */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + const Word32 *revTimes_fx, /* i : Q27 reverberation times T60 for each CLDFB bin in seconds */ +#else const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ +#endif const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ ) @@ -2446,9 +2458,15 @@ static ivas_error ivas_binaural_reverb_open_fx( * but not excessively long loops to generate reverberation. */ /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */ // hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 19 ), 19 ); + L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q18 ); + hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 18 ); /*Q0*/ +#else Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 23 ), 23 ); L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q22 ); hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 22 ); /*Q0*/ +#endif move16(); hReverb->loopBufLength[bin] = s_min( hReverb->loopBufLength[bin], hReverb->loopBufLengthMax[bin] ); @@ -2541,7 +2559,11 @@ ivas_error ivas_binaural_reverb_init( } preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + floatToFixed_arrL( t60_temp, t60, Q27, CLDFB_NO_CHANNELS_MAX ); +#else floatToFixed_arrL( t60_temp, t60, Q31, CLDFB_NO_CHANNELS_MAX ); +#endif floatToFixed_arrL( ene_temp, ene, Q31, CLDFB_NO_CHANNELS_MAX ); } else @@ -2601,7 +2623,11 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( } ELSE { +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q27*/ +#else revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ +#endif revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; move16(); @@ -2646,7 +2672,11 @@ ivas_error ivas_binaural_reverb_open_parambin( } ELSE { +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q27*/ +#else revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ +#endif revEne = hHrtfParambin->parametricReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; move16(); diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 4b1428ac8..39dd9556d 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -72,12 +72,20 @@ extern Word32 rightBRIRReal_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTAPS_MAX]; /* Q29 */ /* Reverberation parameters based on BRIRs for fastconv */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +#else extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ /* Binaural rendering data set based on BRIRs, to be used in a combined manner * with the above binaural rendering data set based on HRIRs for parametric * renderer */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +#else extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index e7dbbae70..dbec56202 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -47155,10 +47155,25 @@ const Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTA }, }; + +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q27 */ = +{ + 57606384, 27529398, 27157346, 27968692, 28945932, 31748532, 30950340, 30655330, + 30530104, 29387776, 30344346, 29622122, 29729360, 29993770, 30025176, 30475880, + 30588086, 29940082, 29527900, 29337714, 29583868, 29293020, 28621930, 28230418, + 27839038, 26675774, 26340230, 26161316, 25546062, 24763170, 24203886, 23644734, + 23689428, 23834786, 24640094, 26295534, 27279754, 27973256, 28812118, 29527900, + 29919414, 30926046, 31397284, 31359570, 31720078, 31867046, 32430896, 32362310, + 32057502, 32532230, 33056752, 33010582, 33030982, 32936494, 32742548, 32765634, + 32114276, 32410092, 31517544, 33962452 +}; +#else const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= { 921702144, 440470368, 434517536, 447499072, 463134912, 507976512, 495205440, 490485280, 488481664, 470204416, 485509536, 473953952, 475669760, 479900320, 480402816, 487614080, 489409376, 479041312, 472446400, 469403424, 473341888, 468688320, 457950880, 451686688, 445424608, 426812384, 421443680, 418581056, 408736992, 396210720, 387262176, 378315744, 379030848, 381356576, 394241504, 420728544, 436476064, 447572096, 460993888, 472446400, 478710624, 494816736, 502356544, 501753120, 507521248, 509872736, 518894336, 517796960, 512920032, 520515680, 528908032, 528169312, 528495712, 526983904, 523880768, 524250144, 513828416, 518561472, 504280704, 543399232 }; +#endif const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= @@ -47167,6 +47182,19 @@ const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q }; +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q27 */ = +{ + 46371420, 42876392, 44689268, 48442264, 50237560, 49764848, 48133832, 46721592, + 46051312, 44473180, 42480180, 40933052, 39574768, 38594172, 37570228, 36275964, + 35439116, 34413964, 33540876, 32486058, 31551098, 30822698, 30028532, 29366168, + 28534554, 27875546, 27122986, 26587726, 26025756, 24952150, 24518492, 24422258, + 24130736, 24035844, 23695066, 23129472, 22965056, 22542002, 22545088, 22710848, + 22459994, 22270210, 21953322, 21683948, 21260760, 21025342, 20850858, 20613158, + 20344186, 20127694, 19891604, 19655650, 19419694, 19183740, 18947786, 18711830, + 18475742, 18239786, 18003832, 17767878 +}; +#else const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= { 741942720,686022272,715028288,775076224,803800960,796237568,770141312,747545472,736820992, @@ -47177,6 +47205,7 @@ const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= 336405472,333613728,329810528,325506976,322043104,318265664,314490400,310715104,306939840, 303164576,299389280,295611872,291836576,288061312,284286048 }; +#endif const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index fd1945a3f..945421179 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -610,7 +610,11 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +#else Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ @@ -1454,7 +1458,11 @@ typedef struct ivas_hrtfs_fastconv_struct Word16 allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +#else Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ } HRTFS_FASTCONV, *HRTFS_FASTCONV_HANDLE; @@ -1465,7 +1473,11 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +#else Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +#endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8648cfa73..b4f54ea40 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1880,7 +1880,11 @@ static ivas_error create_fastconv_HRTF_from_rawdata( memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q27, CLDFB_NO_CHANNELS_MAX ); +#else floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); +#endif memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationEneCorrections_fx, Q31, CLDFB_NO_CHANNELS_MAX ); @@ -2044,7 +2048,11 @@ static ivas_error create_parambin_HRTF_from_rawdata( memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q27, CLDFB_NO_CHANNELS_MAX ); +#else floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); +#endif memcpy( f_tmp_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); -- GitLab From bcf32b297b796bc03b3de49f28c13ec4c970f5b0 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 27 Jun 2025 17:10:57 +0200 Subject: [PATCH 455/692] Minor update --- .../3.31.5/CompilerIdC/CMakeCCompilerId.c | 904 ------------------ 1 file changed, 904 deletions(-) delete mode 100644 build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c diff --git a/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c b/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c deleted file mode 100644 index 8d8bb038b..000000000 --- a/build/CMakeFiles/3.31.5/CompilerIdC/CMakeCCompilerId.c +++ /dev/null @@ -1,904 +0,0 @@ -#ifdef __cplusplus -# error "A C++ compiler has been selected for C." -#endif - -#if defined(__18CXX) -# define ID_VOID_MAIN -#endif -#if defined(__CLASSIC_C__) -/* cv-qualifiers did not exist in K&R C */ -# define const -# define volatile -#endif - -#if !defined(__has_include) -/* If the compiler does not have __has_include, pretend the answer is - always no. */ -# define __has_include(x) 0 -#endif - - -/* Version number components: V=Version, R=Revision, P=Patch - Version date components: YYYY=Year, MM=Month, DD=Day */ - -#if defined(__INTEL_COMPILER) || defined(__ICC) -# define COMPILER_ID "Intel" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# if defined(__GNUC__) -# define SIMULATE_ID "GNU" -# endif - /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, - except that a few beta releases use the old format with V=2021. */ -# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 -# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) -# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# if defined(__INTEL_COMPILER_UPDATE) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) -# else -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) -# endif -# else -# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) -# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) - /* The third version component from --version is an update index, - but no macro is provided for it. */ -# define COMPILER_VERSION_PATCH DEC(0) -# endif -# if defined(__INTEL_COMPILER_BUILD_DATE) - /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ -# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) -# endif -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif -# if defined(__GNUC__) -# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) -# elif defined(__GNUG__) -# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) -# endif -# if defined(__GNUC_MINOR__) -# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) -# endif -# if defined(__GNUC_PATCHLEVEL__) -# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -# endif - -#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER) -# define COMPILER_ID "IntelLLVM" -#if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -#endif -#if defined(__GNUC__) -# define SIMULATE_ID "GNU" -#endif -/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and - * later. Look for 6 digit vs. 8 digit version number to decide encoding. - * VVVV is no smaller than the current year when a version is released. - */ -#if __INTEL_LLVM_COMPILER < 1000000L -# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100) -# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10) -#else -# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000) -# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) -# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) -#endif -#if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -#endif -#if defined(__GNUC__) -# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) -#elif defined(__GNUG__) -# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) -#endif -#if defined(__GNUC_MINOR__) -# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) -#endif -#if defined(__GNUC_PATCHLEVEL__) -# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -#endif - -#elif defined(__PATHCC__) -# define COMPILER_ID "PathScale" -# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) -# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) -# if defined(__PATHCC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) -# endif - -#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) -# define COMPILER_ID "Embarcadero" -# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) -# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) -# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) - -#elif defined(__BORLANDC__) -# define COMPILER_ID "Borland" - /* __BORLANDC__ = 0xVRR */ -# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) -# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) - -#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 -# define COMPILER_ID "Watcom" - /* __WATCOMC__ = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__WATCOMC__) -# define COMPILER_ID "OpenWatcom" - /* __WATCOMC__ = VVRP + 1100 */ -# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) -# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) -# if (__WATCOMC__ % 10) > 0 -# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) -# endif - -#elif defined(__SUNPRO_C) -# define COMPILER_ID "SunPro" -# if __SUNPRO_C >= 0x5100 - /* __SUNPRO_C = 0xVRRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) -# else - /* __SUNPRO_CC = 0xVRP */ -# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) -# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) -# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) -# endif - -#elif defined(__HP_cc) -# define COMPILER_ID "HP" - /* __HP_cc = VVRRPP */ -# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) -# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) -# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) - -#elif defined(__DECC) -# define COMPILER_ID "Compaq" - /* __DECC_VER = VVRRTPPPP */ -# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) -# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) -# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) - -#elif defined(__IBMC__) && defined(__COMPILER_VER__) -# define COMPILER_ID "zOS" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__open_xl__) && defined(__clang__) -# define COMPILER_ID "IBMClang" -# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__) -# define COMPILER_VERSION_MINOR DEC(__open_xl_release__) -# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__) -# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__) - - -#elif defined(__ibmxl__) && defined(__clang__) -# define COMPILER_ID "XLClang" -# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) -# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) -# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) -# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) - - -#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 -# define COMPILER_ID "XL" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 -# define COMPILER_ID "VisualAge" - /* __IBMC__ = VRP */ -# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) -# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) - -#elif defined(__NVCOMPILER) -# define COMPILER_ID "NVHPC" -# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__) -# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__) -# if defined(__NVCOMPILER_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__) -# endif - -#elif defined(__PGI) -# define COMPILER_ID "PGI" -# define COMPILER_VERSION_MAJOR DEC(__PGIC__) -# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) -# if defined(__PGIC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) -# endif - -#elif defined(__clang__) && defined(__cray__) -# define COMPILER_ID "CrayClang" -# define COMPILER_VERSION_MAJOR DEC(__cray_major__) -# define COMPILER_VERSION_MINOR DEC(__cray_minor__) -# define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__) -# define COMPILER_VERSION_INTERNAL_STR __clang_version__ - - -#elif defined(_CRAYC) -# define COMPILER_ID "Cray" -# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) -# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) - -#elif defined(__TI_COMPILER_VERSION__) -# define COMPILER_ID "TI" - /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ -# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) -# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) -# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) - -#elif defined(__CLANG_FUJITSU) -# define COMPILER_ID "FujitsuClang" -# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) -# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) -# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) -# define COMPILER_VERSION_INTERNAL_STR __clang_version__ - - -#elif defined(__FUJITSU) -# define COMPILER_ID "Fujitsu" -# if defined(__FCC_version__) -# define COMPILER_VERSION __FCC_version__ -# elif defined(__FCC_major__) -# define COMPILER_VERSION_MAJOR DEC(__FCC_major__) -# define COMPILER_VERSION_MINOR DEC(__FCC_minor__) -# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__) -# endif -# if defined(__fcc_version) -# define COMPILER_VERSION_INTERNAL DEC(__fcc_version) -# elif defined(__FCC_VERSION) -# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION) -# endif - - -#elif defined(__ghs__) -# define COMPILER_ID "GHS" -/* __GHS_VERSION_NUMBER = VVVVRP */ -# ifdef __GHS_VERSION_NUMBER -# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) -# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) -# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) -# endif - -#elif defined(__TASKING__) -# define COMPILER_ID "Tasking" - # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000) - # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100) -# define COMPILER_VERSION_INTERNAL DEC(__VERSION__) - -#elif defined(__ORANGEC__) -# define COMPILER_ID "OrangeC" -# define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__) -# define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__) -# define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__) - -#elif defined(__TINYC__) -# define COMPILER_ID "TinyCC" - -#elif defined(__BCC__) -# define COMPILER_ID "Bruce" - -#elif defined(__SCO_VERSION__) -# define COMPILER_ID "SCO" - -#elif defined(__ARMCC_VERSION) && !defined(__clang__) -# define COMPILER_ID "ARMCC" -#if __ARMCC_VERSION >= 1000000 - /* __ARMCC_VERSION = VRRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#else - /* __ARMCC_VERSION = VRPPPP */ - # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) - # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) - # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) -#endif - - -#elif defined(__clang__) && defined(__apple_build_version__) -# define COMPILER_ID "AppleClang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif -# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) - -#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) -# define COMPILER_ID "ARMClang" - # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) - # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) - # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100) -# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) - -#elif defined(__clang__) && defined(__ti__) -# define COMPILER_ID "TIClang" - # define COMPILER_VERSION_MAJOR DEC(__ti_major__) - # define COMPILER_VERSION_MINOR DEC(__ti_minor__) - # define COMPILER_VERSION_PATCH DEC(__ti_patchlevel__) -# define COMPILER_VERSION_INTERNAL DEC(__ti_version__) - -#elif defined(__clang__) -# define COMPILER_ID "Clang" -# if defined(_MSC_VER) -# define SIMULATE_ID "MSVC" -# endif -# define COMPILER_VERSION_MAJOR DEC(__clang_major__) -# define COMPILER_VERSION_MINOR DEC(__clang_minor__) -# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) -# if defined(_MSC_VER) - /* _MSC_VER = VVRR */ -# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) -# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) -# endif - -#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__)) -# define COMPILER_ID "LCC" -# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100) -# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100) -# if defined(__LCC_MINOR__) -# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__) -# endif -# if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define SIMULATE_ID "GNU" -# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) -# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) -# if defined(__GNUC_PATCHLEVEL__) -# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -# endif -# endif - -#elif defined(__GNUC__) -# define COMPILER_ID "GNU" -# define COMPILER_VERSION_MAJOR DEC(__GNUC__) -# if defined(__GNUC_MINOR__) -# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) -# endif -# if defined(__GNUC_PATCHLEVEL__) -# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) -# endif - -#elif defined(_MSC_VER) -# define COMPILER_ID "MSVC" - /* _MSC_VER = VVRR */ -# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) -# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) -# if defined(_MSC_FULL_VER) -# if _MSC_VER >= 1400 - /* _MSC_FULL_VER = VVRRPPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) -# else - /* _MSC_FULL_VER = VVRRPPPP */ -# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) -# endif -# endif -# if defined(_MSC_BUILD) -# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) -# endif - -#elif defined(_ADI_COMPILER) -# define COMPILER_ID "ADSP" -#if defined(__VERSIONNUM__) - /* __VERSIONNUM__ = 0xVVRRPPTT */ -# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF) -# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF) -# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF) -# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF) -#endif - -#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) -# define COMPILER_ID "IAR" -# if defined(__VER__) && defined(__ICCARM__) -# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) -# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) -# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) -# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) -# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__)) -# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) -# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) -# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) -# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) -# endif - -#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) -# define COMPILER_ID "SDCC" -# if defined(__SDCC_VERSION_MAJOR) -# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) -# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) -# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) -# else - /* SDCC = VRP */ -# define COMPILER_VERSION_MAJOR DEC(SDCC/100) -# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) -# define COMPILER_VERSION_PATCH DEC(SDCC % 10) -# endif - - -/* These compilers are either not known or too old to define an - identification macro. Try to identify the platform and guess that - it is the native compiler. */ -#elif defined(__hpux) || defined(__hpua) -# define COMPILER_ID "HP" - -#else /* unknown compiler */ -# define COMPILER_ID "" -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; -#ifdef SIMULATE_ID -char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; -#endif - -#ifdef __QNXNTO__ -char const* qnxnto = "INFO" ":" "qnxnto[]"; -#endif - -#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) -char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; -#endif - -#define STRINGIFY_HELPER(X) #X -#define STRINGIFY(X) STRINGIFY_HELPER(X) - -/* Identify known platforms by name. */ -#if defined(__linux) || defined(__linux__) || defined(linux) -# define PLATFORM_ID "Linux" - -#elif defined(__MSYS__) -# define PLATFORM_ID "MSYS" - -#elif defined(__CYGWIN__) -# define PLATFORM_ID "Cygwin" - -#elif defined(__MINGW32__) -# define PLATFORM_ID "MinGW" - -#elif defined(__APPLE__) -# define PLATFORM_ID "Darwin" - -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -# define PLATFORM_ID "Windows" - -#elif defined(__FreeBSD__) || defined(__FreeBSD) -# define PLATFORM_ID "FreeBSD" - -#elif defined(__NetBSD__) || defined(__NetBSD) -# define PLATFORM_ID "NetBSD" - -#elif defined(__OpenBSD__) || defined(__OPENBSD) -# define PLATFORM_ID "OpenBSD" - -#elif defined(__sun) || defined(sun) -# define PLATFORM_ID "SunOS" - -#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) -# define PLATFORM_ID "AIX" - -#elif defined(__hpux) || defined(__hpux__) -# define PLATFORM_ID "HP-UX" - -#elif defined(__HAIKU__) -# define PLATFORM_ID "Haiku" - -#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) -# define PLATFORM_ID "BeOS" - -#elif defined(__QNX__) || defined(__QNXNTO__) -# define PLATFORM_ID "QNX" - -#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) -# define PLATFORM_ID "Tru64" - -#elif defined(__riscos) || defined(__riscos__) -# define PLATFORM_ID "RISCos" - -#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) -# define PLATFORM_ID "SINIX" - -#elif defined(__UNIX_SV__) -# define PLATFORM_ID "UNIX_SV" - -#elif defined(__bsdos__) -# define PLATFORM_ID "BSDOS" - -#elif defined(_MPRAS) || defined(MPRAS) -# define PLATFORM_ID "MP-RAS" - -#elif defined(__osf) || defined(__osf__) -# define PLATFORM_ID "OSF1" - -#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) -# define PLATFORM_ID "SCO_SV" - -#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) -# define PLATFORM_ID "ULTRIX" - -#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) -# define PLATFORM_ID "Xenix" - -#elif defined(__WATCOMC__) -# if defined(__LINUX__) -# define PLATFORM_ID "Linux" - -# elif defined(__DOS__) -# define PLATFORM_ID "DOS" - -# elif defined(__OS2__) -# define PLATFORM_ID "OS2" - -# elif defined(__WINDOWS__) -# define PLATFORM_ID "Windows3x" - -# elif defined(__VXWORKS__) -# define PLATFORM_ID "VxWorks" - -# else /* unknown platform */ -# define PLATFORM_ID -# endif - -#elif defined(__INTEGRITY) -# if defined(INT_178B) -# define PLATFORM_ID "Integrity178" - -# else /* regular Integrity */ -# define PLATFORM_ID "Integrity" -# endif - -# elif defined(_ADI_COMPILER) -# define PLATFORM_ID "ADSP" - -#else /* unknown platform */ -# define PLATFORM_ID - -#endif - -/* For windows compilers MSVC and Intel we can determine - the architecture of the compiler being used. This is because - the compilers do not have flags that can change the architecture, - but rather depend on which compiler is being used -*/ -#if defined(_WIN32) && defined(_MSC_VER) -# if defined(_M_IA64) -# define ARCHITECTURE_ID "IA64" - -# elif defined(_M_ARM64EC) -# define ARCHITECTURE_ID "ARM64EC" - -# elif defined(_M_X64) || defined(_M_AMD64) -# define ARCHITECTURE_ID "x64" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# elif defined(_M_ARM64) -# define ARCHITECTURE_ID "ARM64" - -# elif defined(_M_ARM) -# if _M_ARM == 4 -# define ARCHITECTURE_ID "ARMV4I" -# elif _M_ARM == 5 -# define ARCHITECTURE_ID "ARMV5I" -# else -# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) -# endif - -# elif defined(_M_MIPS) -# define ARCHITECTURE_ID "MIPS" - -# elif defined(_M_SH) -# define ARCHITECTURE_ID "SHx" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__WATCOMC__) -# if defined(_M_I86) -# define ARCHITECTURE_ID "I86" - -# elif defined(_M_IX86) -# define ARCHITECTURE_ID "X86" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) -# if defined(__ICCARM__) -# define ARCHITECTURE_ID "ARM" - -# elif defined(__ICCRX__) -# define ARCHITECTURE_ID "RX" - -# elif defined(__ICCRH850__) -# define ARCHITECTURE_ID "RH850" - -# elif defined(__ICCRL78__) -# define ARCHITECTURE_ID "RL78" - -# elif defined(__ICCRISCV__) -# define ARCHITECTURE_ID "RISCV" - -# elif defined(__ICCAVR__) -# define ARCHITECTURE_ID "AVR" - -# elif defined(__ICC430__) -# define ARCHITECTURE_ID "MSP430" - -# elif defined(__ICCV850__) -# define ARCHITECTURE_ID "V850" - -# elif defined(__ICC8051__) -# define ARCHITECTURE_ID "8051" - -# elif defined(__ICCSTM8__) -# define ARCHITECTURE_ID "STM8" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__ghs__) -# if defined(__PPC64__) -# define ARCHITECTURE_ID "PPC64" - -# elif defined(__ppc__) -# define ARCHITECTURE_ID "PPC" - -# elif defined(__ARM__) -# define ARCHITECTURE_ID "ARM" - -# elif defined(__x86_64__) -# define ARCHITECTURE_ID "x64" - -# elif defined(__i386__) -# define ARCHITECTURE_ID "X86" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__clang__) && defined(__ti__) -# if defined(__ARM_ARCH) -# define ARCHITECTURE_ID "Arm" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -#elif defined(__TI_COMPILER_VERSION__) -# if defined(__TI_ARM__) -# define ARCHITECTURE_ID "ARM" - -# elif defined(__MSP430__) -# define ARCHITECTURE_ID "MSP430" - -# elif defined(__TMS320C28XX__) -# define ARCHITECTURE_ID "TMS320C28x" - -# elif defined(__TMS320C6X__) || defined(_TMS320C6X) -# define ARCHITECTURE_ID "TMS320C6x" - -# else /* unknown architecture */ -# define ARCHITECTURE_ID "" -# endif - -# elif defined(__ADSPSHARC__) -# define ARCHITECTURE_ID "SHARC" - -# elif defined(__ADSPBLACKFIN__) -# define ARCHITECTURE_ID "Blackfin" - -#elif defined(__TASKING__) - -# if defined(__CTC__) || defined(__CPTC__) -# define ARCHITECTURE_ID "TriCore" - -# elif defined(__CMCS__) -# define ARCHITECTURE_ID "MCS" - -# elif defined(__CARM__) -# define ARCHITECTURE_ID "ARM" - -# elif defined(__CARC__) -# define ARCHITECTURE_ID "ARC" - -# elif defined(__C51__) -# define ARCHITECTURE_ID "8051" - -# elif defined(__CPCP__) -# define ARCHITECTURE_ID "PCP" - -# else -# define ARCHITECTURE_ID "" -# endif - -#else -# define ARCHITECTURE_ID -#endif - -/* Convert integer to decimal digit literals. */ -#define DEC(n) \ - ('0' + (((n) / 10000000)%10)), \ - ('0' + (((n) / 1000000)%10)), \ - ('0' + (((n) / 100000)%10)), \ - ('0' + (((n) / 10000)%10)), \ - ('0' + (((n) / 1000)%10)), \ - ('0' + (((n) / 100)%10)), \ - ('0' + (((n) / 10)%10)), \ - ('0' + ((n) % 10)) - -/* Convert integer to hex digit literals. */ -#define HEX(n) \ - ('0' + ((n)>>28 & 0xF)), \ - ('0' + ((n)>>24 & 0xF)), \ - ('0' + ((n)>>20 & 0xF)), \ - ('0' + ((n)>>16 & 0xF)), \ - ('0' + ((n)>>12 & 0xF)), \ - ('0' + ((n)>>8 & 0xF)), \ - ('0' + ((n)>>4 & 0xF)), \ - ('0' + ((n) & 0xF)) - -/* Construct a string literal encoding the version number. */ -#ifdef COMPILER_VERSION -char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; - -/* Construct a string literal encoding the version number components. */ -#elif defined(COMPILER_VERSION_MAJOR) -char const info_version[] = { - 'I', 'N', 'F', 'O', ':', - 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', - COMPILER_VERSION_MAJOR, -# ifdef COMPILER_VERSION_MINOR - '.', COMPILER_VERSION_MINOR, -# ifdef COMPILER_VERSION_PATCH - '.', COMPILER_VERSION_PATCH, -# ifdef COMPILER_VERSION_TWEAK - '.', COMPILER_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct a string literal encoding the internal version number. */ -#ifdef COMPILER_VERSION_INTERNAL -char const info_version_internal[] = { - 'I', 'N', 'F', 'O', ':', - 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', - 'i','n','t','e','r','n','a','l','[', - COMPILER_VERSION_INTERNAL,']','\0'}; -#elif defined(COMPILER_VERSION_INTERNAL_STR) -char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; -#endif - -/* Construct a string literal encoding the version number components. */ -#ifdef SIMULATE_VERSION_MAJOR -char const info_simulate_version[] = { - 'I', 'N', 'F', 'O', ':', - 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', - SIMULATE_VERSION_MAJOR, -# ifdef SIMULATE_VERSION_MINOR - '.', SIMULATE_VERSION_MINOR, -# ifdef SIMULATE_VERSION_PATCH - '.', SIMULATE_VERSION_PATCH, -# ifdef SIMULATE_VERSION_TWEAK - '.', SIMULATE_VERSION_TWEAK, -# endif -# endif -# endif - ']','\0'}; -#endif - -/* Construct the string literal in pieces to prevent the source from - getting matched. Store it in a pointer rather than an array - because some compilers will just produce instructions to fill the - array rather than assigning a pointer to a static array. */ -char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; -char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; - - - -#define C_STD_99 199901L -#define C_STD_11 201112L -#define C_STD_17 201710L -#define C_STD_23 202311L - -#ifdef __STDC_VERSION__ -# define C_STD __STDC_VERSION__ -#endif - -#if !defined(__STDC__) && !defined(__clang__) -# if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) -# define C_VERSION "90" -# else -# define C_VERSION -# endif -#elif C_STD > C_STD_17 -# define C_VERSION "23" -#elif C_STD > C_STD_11 -# define C_VERSION "17" -#elif C_STD > C_STD_99 -# define C_VERSION "11" -#elif C_STD >= C_STD_99 -# define C_VERSION "99" -#else -# define C_VERSION "90" -#endif -const char* info_language_standard_default = - "INFO" ":" "standard_default[" C_VERSION "]"; - -const char* info_language_extensions_default = "INFO" ":" "extensions_default[" -#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ - defined(__TI_COMPILER_VERSION__)) && \ - !defined(__STRICT_ANSI__) - "ON" -#else - "OFF" -#endif -"]"; - -/*--------------------------------------------------------------------------*/ - -#ifdef ID_VOID_MAIN -void main() {} -#else -# if defined(__CLASSIC_C__) -int main(argc, argv) int argc; char *argv[]; -# else -int main(int argc, char* argv[]) -# endif -{ - int require = 0; - require += info_compiler[argc]; - require += info_platform[argc]; - require += info_arch[argc]; -#ifdef COMPILER_VERSION_MAJOR - require += info_version[argc]; -#endif -#ifdef COMPILER_VERSION_INTERNAL - require += info_version_internal[argc]; -#endif -#ifdef SIMULATE_ID - require += info_simulate[argc]; -#endif -#ifdef SIMULATE_VERSION_MAJOR - require += info_simulate_version[argc]; -#endif -#if defined(__CRAYXT_COMPUTE_LINUX_TARGET) - require += info_cray[argc]; -#endif - require += info_language_standard_default[argc]; - require += info_language_extensions_default[argc]; - (void)argv; - return require; -} -#endif -- GitLab From 1fadc6836f9ea3f09f617cdd5b262c71485080f3 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Fri, 27 Jun 2025 17:20:46 +0200 Subject: [PATCH 456/692] To make clang happy --- .../ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- lib_rend/ivas_reverb_fx.c | 18 +++++++++--------- lib_rend/ivas_rom_binauralRenderer.h | 8 ++++---- lib_rend/ivas_stat_rend.h | 12 ++++++------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 0b9e3750a..dbbe3ebd7 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -504,9 +504,9 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( } } #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q27*/ + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q27*/ #else - Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ #endif Copy32( parametricReverberationEneCorrections_fx, hrtfParambin->parametricReverberationEneCorrections_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ Copy32( parametricEarlyPartEneCorrection_fx, hrtfParambin->parametricEarlyPartEneCorrection_fx, CLDFB_NO_CHANNELS_MAX ); /*Q28*/ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 8fbe82abf..096517afc 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -220,11 +220,11 @@ static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - const Word32 *revTimes_fx, /*Q27 i : reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /*Q27 i : reverberation times T60 for each CLDFB bin in seconds */ #else - const Word32 *revTimes_fx, /*Q31 i : reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /*Q31 i : reverberation times T60 for each CLDFB bin in seconds */ #endif - const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ + const Word32 *revEnes_fx /*Q31 i : spectrum for reverberated sound at each CLDFB bin */ ) { Word16 bin, ch, tap, sample; @@ -2395,12 +2395,12 @@ static ivas_error ivas_binaural_reverb_open_fx( const Word16 numCldfbSlotsPerFrame, /* i : Q0 number of CLDFB slots per frame */ const Word32 sampling_rate, /* i : Q0 sampling rate */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - const Word32 *revTimes_fx, /* i : Q27 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /* i : Q27 reverberation times T60 for each CLDFB bin in seconds */ #else - const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ #endif - const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ - const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ + const Word32 *revEnes_fx, /* i : Q31 spectrum for reverberated sound at each CLDFB bin */ + const Word16 preDelay /* i : Q0 reverb pre-delay in CLDFB slots */ ) { Word16 bin, chIdx, k, len, scale, tmp; @@ -2626,7 +2626,7 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q27*/ #else - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ #endif revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; @@ -2675,7 +2675,7 @@ ivas_error ivas_binaural_reverb_open_parambin( #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q27*/ #else - revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ + revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ #endif revEne = hHrtfParambin->parametricReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 39dd9556d..b4c05f9ff 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -73,9 +73,9 @@ extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT /* Reverberation parameters based on BRIRs for fastconv */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ #else -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ @@ -83,9 +83,9 @@ extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* * with the above binaural rendering data set based on HRIRs for parametric * renderer */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ #else -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif extern const Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ extern const Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 945421179..ce8f9438d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -611,9 +611,9 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ #else - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ @@ -1459,9 +1459,9 @@ typedef struct ivas_hrtfs_fastconv_struct Word16 allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ #else - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ @@ -1474,9 +1474,9 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ #else - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif Word32 parametricReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 parametricEarlyPartEneCorrection_fx[CLDFB_NO_CHANNELS_MAX]; /* Q28 */ -- GitLab From 4f89e38130f04dc71f72be03322ca68f5d0a3c7a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 29 Jun 2025 20:02:29 +0200 Subject: [PATCH 457/692] 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 458/692] 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 dc8a3c11e603cf0a50ceae017d19745675823248 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Jun 2025 08:33:52 +0200 Subject: [PATCH 459/692] Updated Q-format fixed-point representation for RT60 reverberation times (Q27 -> Q26) --- lib_com/options.h | 2 +- .../ivas_dirac_dec_binaural_functions_fx.c | 2 +- lib_rend/ivas_reverb_fx.c | 20 +++++------ lib_rend/ivas_rom_binauralRenderer.h | 6 ++-- lib_rend/ivas_rom_binauralRenderer_fx.c | 35 +++++++++---------- lib_rend/ivas_stat_rend.h | 6 ++-- lib_util/hrtf_file_reader.c | 4 +-- 7 files changed, 37 insertions(+), 38 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f262bea81..489192b1c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,7 @@ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ -#define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q27 format instead of Q31 */ +#define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index dbbe3ebd7..75a8d4b23 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -504,7 +504,7 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs_fx( } } #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q27*/ + Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q26*/ #else Copy32( parametricReverberationTimes_fx, hrtfParambin->parametricReverberationTimes_fx, CLDFB_NO_CHANNELS_MAX ); /*Q31*/ #endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 096517afc..6ac12a98d 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -220,7 +220,7 @@ static void ivas_binaural_reverb_setReverbTimes_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word32 output_Fs, /* i : sampling_rate */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - const Word32 *revTimes_fx, /*Q27 i : reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /*Q26 i : reverberation times T60 for each CLDFB bin in seconds */ #else const Word32 *revTimes_fx, /*Q31 i : reverberation times T60 for each CLDFB bin in seconds */ #endif @@ -329,7 +329,7 @@ static void ivas_binaural_reverb_setReverbTimes_fx( L_tmp = Mpy_32_32( 1677721600, revTimes_fx[bin] ); // e10 --> 800 * 2^21, + e0 tmp = BASOP_Util_Divide3232_Scale( 1073741824, L_tmp, &scale ); #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - scale = add( scale, sub( 1, 14 ) ); // revTimes_fx in Q27 + scale = add( scale, sub( 1, 15 ) ); // revTimes_fx in Q26 #else scale = add( scale, sub( 1, 10 ) ); #endif @@ -2395,7 +2395,7 @@ static ivas_error ivas_binaural_reverb_open_fx( const Word16 numCldfbSlotsPerFrame, /* i : Q0 number of CLDFB slots per frame */ const Word32 sampling_rate, /* i : Q0 sampling rate */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - const Word32 *revTimes_fx, /* i : Q27 reverberation times T60 for each CLDFB bin in seconds */ + const Word32 *revTimes_fx, /* i : Q26 reverberation times T60 for each CLDFB bin in seconds */ #else const Word32 *revTimes_fx, /* i : Q31 reverberation times T60 for each CLDFB bin in seconds */ #endif @@ -2459,9 +2459,9 @@ static ivas_error ivas_binaural_reverb_open_fx( /* Note: the resulted length is very sensitive to the precision of the constants below (e.g. 1.45 vs. 1.45f) */ // hReverb->loopBufLength[bin] = (int16_t) ( 1.45 * (int16_t) ( revTimes[bin] * 150.0 ) + 1 ); #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 19 ), 19 ); - L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q18 ); - hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 18 ); /*Q0*/ + Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 18 ), 18 ); + L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q17 ); + hReverb->loopBufLength[bin] = (Word16) L_shr( L_tmp_BufLength, 17 ); /*Q0*/ #else Word32 L_tmp_BufLength = L_shl( L_shr( Mpy_32_32( revTimes_fx[bin], 1258291200 /*150.0 in Q23*/ ), 23 ), 23 ); L_tmp_BufLength = L_add( Mpy_32_32( 1556925645 /*1.45 in Q30*/, L_tmp_BufLength ), ONE_IN_Q22 ); @@ -2560,7 +2560,7 @@ ivas_error ivas_binaural_reverb_init( preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - floatToFixed_arrL( t60_temp, t60, Q27, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( t60_temp, t60, Q26, CLDFB_NO_CHANNELS_MAX ); #else floatToFixed_arrL( t60_temp, t60, Q31, CLDFB_NO_CHANNELS_MAX ); #endif @@ -2624,9 +2624,9 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( ELSE { #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q27*/ + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q26*/ #else - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ #endif revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; @@ -2673,7 +2673,7 @@ ivas_error ivas_binaural_reverb_open_parambin( ELSE { #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q27*/ + revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q26*/ #else revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ #endif diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index b4c05f9ff..27980b3f5 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -73,9 +73,9 @@ extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT /* Reverberation parameters based on BRIRs for fastconv */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ @@ -83,7 +83,7 @@ extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* * with the above binaural rendering data set based on HRIRs for parametric * renderer */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ +extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else extern const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index dbec56202..7333868b0 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -47157,16 +47157,15 @@ const Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NTA #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q27 */ = +const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = { - 57606384, 27529398, 27157346, 27968692, 28945932, 31748532, 30950340, 30655330, - 30530104, 29387776, 30344346, 29622122, 29729360, 29993770, 30025176, 30475880, - 30588086, 29940082, 29527900, 29337714, 29583868, 29293020, 28621930, 28230418, - 27839038, 26675774, 26340230, 26161316, 25546062, 24763170, 24203886, 23644734, - 23689428, 23834786, 24640094, 26295534, 27279754, 27973256, 28812118, 29527900, - 29919414, 30926046, 31397284, 31359570, 31720078, 31867046, 32430896, 32362310, - 32057502, 32532230, 33056752, 33010582, 33030982, 32936494, 32742548, 32765634, - 32114276, 32410092, 31517544, 33962452 + 28803192, 13764699, 13578673, 13984346, 14472966, 15874266, 15475170, 15327665, + 15265052, 14693888, 15172173, 14811061, 14864680, 14996885, 15012588, 15237940, + 15294043, 14970041, 14763950, 14668857, 14791934, 14646510, 14310965, 14115209, + 13919519, 13337887, 13170115, 13080658, 12773031, 12381585, 12101943, 11822367, + 11844714, 11917393, 12320047, 13147767, 13639877, 13986628, 14406059, 14763950, + 14959707, 15463023, 15698642, 15679785, 15860039, 15933523, 16215448, 16181155, + 16028751, 16266115, 16528376, 16505291, 16515491, 16468247, 16371274, 16382817 }; #else const Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= @@ -47183,16 +47182,16 @@ const Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX] /* Q #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT -const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q27 */ = +const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q26 */ = { - 46371420, 42876392, 44689268, 48442264, 50237560, 49764848, 48133832, 46721592, - 46051312, 44473180, 42480180, 40933052, 39574768, 38594172, 37570228, 36275964, - 35439116, 34413964, 33540876, 32486058, 31551098, 30822698, 30028532, 29366168, - 28534554, 27875546, 27122986, 26587726, 26025756, 24952150, 24518492, 24422258, - 24130736, 24035844, 23695066, 23129472, 22965056, 22542002, 22545088, 22710848, - 22459994, 22270210, 21953322, 21683948, 21260760, 21025342, 20850858, 20613158, - 20344186, 20127694, 19891604, 19655650, 19419694, 19183740, 18947786, 18711830, - 18475742, 18239786, 18003832, 17767878 + 23185710, 21438196, 22344634, 24221132, 25118780, 24882424, 24066916, 23360796, + 23025656, 22236590, 21240090, 20466526, 19787384, 19297086, 18785114, 18137982, + 17719558, 17206982, 16770438, 16243029, 15775549, 15411349, 15014266, 14683084, + 14267277, 13937773, 13561493, 13293863, 13012878, 12476075, 12259246, 12211129, + 12065368, 12017922, 11847533, 11564736, 11482528, 11271001, 11272544, 11355424, + 11229997, 11135105, 10976661, 10841974, 10630380, 10512671, 10425429, 10306579, + 10172093, 10063847, 9945802, 9827825, 9709847, 9591870, 9473893, 9355915, + 9237871, 9119893, 9001916, 8883939 }; #else const Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX] /* Q31 */= diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ce8f9438d..963d6dd8d 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -611,7 +611,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif @@ -1459,7 +1459,7 @@ typedef struct ivas_hrtfs_fastconv_struct Word16 allocate_init_flag; /*Memory allocation flag 0: if the hrtf pointers are allocated at application level , 1: of allocated at ivas_binaural_hrtf_open() */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif @@ -1474,7 +1474,7 @@ typedef struct ivas_hrtfs_parambin_struct Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q27 */ + Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else Word32 parametricReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index b4f54ea40..33f4e366e 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1881,7 +1881,7 @@ static ivas_error create_fastconv_HRTF_from_rawdata( memcpy( f_tmp_brir_reverb, hrtf_data_rptr, CLDFB_NO_CHANNELS_MAX * sizeof( float ) ); hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q27, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q26, CLDFB_NO_CHANNELS_MAX ); #else floatToFixed_arrL( f_tmp_brir_reverb, ( *hHRTF )->fastconvReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #endif @@ -2049,7 +2049,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( hrtf_data_rptr += CLDFB_NO_CHANNELS_MAX * sizeof( float ); /*adding conversion as file reading is done in float*/ #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q27, CLDFB_NO_CHANNELS_MAX ); + floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q26, CLDFB_NO_CHANNELS_MAX ); #else floatToFixed_arrL( f_tmp_reverb, ( *hHRTF )->parametricReverberationTimes_fx, Q31, CLDFB_NO_CHANNELS_MAX ); #endif -- GitLab From 1f39091542b1020be9e4f4ccaf977aa30400f81a Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Jun 2025 08:42:20 +0200 Subject: [PATCH 460/692] To make clang happy --- lib_rend/ivas_reverb_fx.c | 6 +++--- lib_rend/ivas_rom_binauralRenderer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6ac12a98d..d7dd26ec3 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2624,9 +2624,9 @@ ivas_error ivas_binaural_reverb_open_fastconv_fx( ELSE { #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q26*/ + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q26*/ #else - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ + revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ #endif revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/ preDelay = 10; @@ -2673,7 +2673,7 @@ ivas_error ivas_binaural_reverb_open_parambin( ELSE { #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q26*/ + revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q26*/ #else revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ #endif diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 27980b3f5..4992cbb1f 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -75,7 +75,7 @@ extern Word32 rightBRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q26 */ #else -extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ +extern Word32 fastconvReverberationTimes_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ #endif extern Word32 fastconvReverberationEneCorrections_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ -- GitLab From f4db1967eb63c8a491be62cbebdad2efee565cf8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 30 Jun 2025 13:38:02 +0530 Subject: [PATCH 461/692] 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 462/692] 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 463/692] 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 464/692] 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 465/692] 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 466/692] 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 467/692] 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 743d1c3b9230bce12688b2d267a177021ad8716f Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Jun 2025 14:49:38 +0200 Subject: [PATCH 468/692] Added ivas_reverb_interpolate_energies_fx, fixes in ivas_reverb_set_energies for the frequency grids --- lib_rend/ivas_prot_rend_fx.h | 14 +++++ lib_rend/ivas_reverb_filter_design_fx.c | 83 +++++++++++++++++++++++++ lib_rend/ivas_reverb_utils_fx.c | 30 +++++++++ 3 files changed, 127 insertions(+) diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 9524f0904..3fc299761 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1158,6 +1158,20 @@ void ivas_reverb_interpolate_acoustic_data_fx( Word16 *pOutput_t60_e, //output e Word16 *pOutput_dsr_e //output e ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +void ivas_reverb_interpolate_energies_fx( + const Word16 input_table_size, + const Word32 *pInput_fc, //input in Q16 + const Word32 *pInput_ene_l, //input in Q28 + const Word32 *pInput_ene_r, //input in Q28 + const Word16 output_table_size, + const Word32 *pOutput_fc, + Word32 *pOutput_ene_l_m, // output m + Word32 *pOutput_ene_r_m, // output m + Word16 *pOutput_ene_l_e, //output e + Word16 *pOutput_ene_r_e //output e +); +#endif #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES void ivas_reverb_get_hrtf_set_properties_fx( Word32 **ppHrtf_set_L_re, diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 757108755..f2e03b800 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -920,6 +920,89 @@ void ivas_reverb_interpolate_acoustic_data_fx( return; } +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT +/*-------------------------------------------------------------------* + * ivas_reverb_interpolate_energies_fx() + * + * Interpolates data from the input average energy to the FFT pFilter uniform grid + * Note: the fc frequencies both for the input and the output must be in the ascending order + *-------------------------------------------------------------------*/ + + +void ivas_reverb_interpolate_energies_fx( + const Word16 input_table_size, + const Word32 *pInput_fc, // input in Q16 + const Word32 *pInput_ene_l, // input in Q28 + const Word32 *pInput_ene_r, // input in Q28 + const Word16 output_table_size, + const Word32 *pOutput_fc, // Q16 + Word32 *pOutput_ene_l_m, + Word32 *pOutput_ene_r_m, + Word16 *pOutput_ene_l_e, + Word16 *pOutput_ene_r_e +) +{ + Word16 input_idx, output_idx; + Word32 rel_offset; + Word16 rel_offset_e; + input_idx = 0; + move16(); + + FOR( output_idx = 0; output_idx < output_table_size; output_idx++ ) + { + /* if the bin frequency is lower than the 1st frequency point in the input table, take this 1st point */ + IF( LT_32( pOutput_fc[output_idx], pInput_fc[0] ) ) + { + input_idx = 0; + move16(); + rel_offset = 0; + move32(); + rel_offset_e = 0; + move16(); + } + ELSE + { + /* if the bin frequency is higher than the last frequency point in the input table, take this last point */ + IF( GT_32( pOutput_fc[output_idx], pInput_fc[input_table_size - 1] ) ) + { + input_idx = sub( input_table_size, 2 ); + rel_offset = ONE_IN_Q30; // Q30; + move32(); + rel_offset_e = 1; + move16(); + } + /* otherwise use linear interpolation between 2 consecutive points in the input table */ + ELSE + { + WHILE( GT_32( pOutput_fc[output_idx], pInput_fc[input_idx + 1] ) ) + { + input_idx = add( input_idx, 1 ); + } + rel_offset = BASOP_Util_Divide3232_Scale( L_sub( pOutput_fc[output_idx], pInput_fc[input_idx] ), L_sub( pInput_fc[input_idx + 1], pInput_fc[input_idx] ), &rel_offset_e ); // q15 + rel_offset = L_shl_sat( rel_offset, add( 16, rel_offset_e ) ); + rel_offset_e = 0; + move16(); + } + } + Word32 mult1; + Word16 mult_e = 0; + move16(); + mult1 = Mpy_32_32( rel_offset, L_sub( pInput_ene_l[input_idx + 1], pInput_ene_l[input_idx] ) ); + pOutput_ene_l_m[output_idx] = BASOP_Util_Add_Mant32Exp( pInput_ene_l[input_idx], 3, mult1, add( 3, rel_offset_e ), &mult_e ); // 31 - (31 - rel_offset_e + 28 - 31) + move32(); + pOutput_ene_l_e[output_idx] = mult_e; + move16(); + + mult1 = Mpy_32_32( rel_offset, L_sub( pInput_ene_r[input_idx + 1], pInput_ene_r[input_idx] ) ); + pOutput_ene_r_m[output_idx] = BASOP_Util_Add_Mant32Exp( pInput_ene_r[input_idx], 3, mult1, add( 3, rel_offset_e ), &mult_e ); // 31 - (31 - rel_offset_e + 28 - 31) + move32(); + pOutput_ene_r_e[output_idx] = mult_e; + move16(); + } + + return; +} +#endif #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 4a3c0477c..2c61d54df 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -305,6 +305,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; #endif float input_fc[FFT_SPECTRUM_SIZE]; +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + Word32 input_fc_fx[FFT_SPECTRUM_SIZE]; + Word32 output_fc_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 avg_pwr_left_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 avg_pwr_left_e[CLDFB_NO_CHANNELS_MAX]; + Word32 avg_pwr_right_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 avg_pwr_right_e[CLDFB_NO_CHANNELS_MAX]; + const Word16 cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); +#endif #ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error error; @@ -320,7 +329,17 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( avg_pwr_len - 1 ) ); +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + input_fc_fx[freq_idx] = input_fc[freq_idx] * ONE_IN_Q16; +#endif + } + +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + for ( freq_idx = 0; freq_idx < CLDFB_NO_CHANNELS_MAX; freq_idx++ ) + { + output_fc_fx[freq_idx] = ( ( freq_idx << 1 ) + 1 ) * cldfb_freq_halfstep * ONE_IN_Q16; } +#endif #else for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) { @@ -329,6 +348,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES +#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) ); @@ -337,7 +357,9 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( Word16 *avg_pwr_right_e = (Word16 *) malloc( avg_pwr_len * sizeof( Word16 ) ); Word32 *avg_pwr_left_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); Word32 *avg_pwr_right_fx = (Word32 *) malloc( avg_pwr_len * sizeof( Word32 ) ); +#endif +#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT for ( int i = 0; i < 60; i++ ) { input_fc_fx[i] = (Word32) input_fc[i] * ( 1 << 16 ); @@ -347,9 +369,15 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( { output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; } +#endif +#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT + ivas_reverb_interpolate_energies_fx( avg_pwr_len, input_fc_fx, avg_pwr_l, avg_pwr_r, + CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); +#else ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_l, avg_pwr_r, CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); +#endif for ( int i = 0; i < 60; i++ ) { @@ -357,12 +385,14 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); } +#ifndef FIX_1741_REVERB_TIMES_Q_FORMAT free( input_fc_fx ); free( output_fc_fx ); free( avg_pwr_left_e ); free( avg_pwr_right_e ); free( avg_pwr_left_fx ); free( avg_pwr_right_fx ); +#endif #else if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) -- GitLab From 63f05e3b060632fb2fbe4f51776bdc9a5b6bc582 Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Mon, 30 Jun 2025 15:10:50 +0200 Subject: [PATCH 469/692] To make clang happy --- lib_rend/ivas_reverb_filter_design_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index f2e03b800..aacfb2009 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -931,7 +931,7 @@ void ivas_reverb_interpolate_acoustic_data_fx( void ivas_reverb_interpolate_energies_fx( const Word16 input_table_size, - const Word32 *pInput_fc, // input in Q16 + const Word32 *pInput_fc, // input in Q16 const Word32 *pInput_ene_l, // input in Q28 const Word32 *pInput_ene_r, // input in Q28 const Word16 output_table_size, @@ -939,8 +939,7 @@ void ivas_reverb_interpolate_energies_fx( Word32 *pOutput_ene_l_m, Word32 *pOutput_ene_r_m, Word16 *pOutput_ene_l_e, - Word16 *pOutput_ene_r_e -) + Word16 *pOutput_ene_r_e ) { Word16 input_idx, output_idx; Word32 rel_offset; -- GitLab From 938ce84fd228dbdb1c92f4d271fbb19afe85ae8c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 30 Jun 2025 20:02:05 +0200 Subject: [PATCH 470/692] 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 471/692] 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 472/692] 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 473/692] 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 474/692] 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 475/692] 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 476/692] 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 477/692] 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 b5091ea6da830913dcb00387a11e4af1ae9b611f Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 1 Jul 2025 14:44:25 +0200 Subject: [PATCH 478/692] FIX_777_COMBI_RENDER_CONFIG_FILE activated --- 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 489192b1c..0008cdeba 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -118,7 +118,7 @@ -//#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ +#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ /* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ -- GitLab From 875e4eef6f800659a11a773e9dcfe1812eceb0aa Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 1 Jul 2025 16:49:16 +0300 Subject: [PATCH 479/692] Activate switch NONBE_FIX_991_PARAMBIN_BINARY_HRTF. --- 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 0008cdeba..21ee450aa 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,7 +119,7 @@ #define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ -/* #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF */ /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ +#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ -- GitLab From dd52617a8e9c4e64ede527aa433c3d3d80e6db6b Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 2 Jul 2025 12:22:28 +0200 Subject: [PATCH 480/692] [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 2b0f1bdea..97b83b7b6 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -9905,7 +9905,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 e6c5024923d6ea98da8e54d663d3193ed1be3f89 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 2 Jul 2025 12:17:28 +0200 Subject: [PATCH 481/692] [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 482/692] 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 483/692] 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 484/692] 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 485/692] 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 486/692] 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 487/692] 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 488/692] 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 489/692] 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 490/692] 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 198d3a2b085a82b82105fe05dd60acde72b89b45 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 3 Jul 2025 08:55:23 +0300 Subject: [PATCH 491/692] Align hrtfShCoeffsRe_fx Q everywhere to Q14 to remove differences. --- lib_rend/ivas_rom_binauralRenderer.h | 2 +- lib_util/hrtf_file_reader.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index 4992cbb1f..1027c482b 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -60,7 +60,7 @@ extern Word32 rightHRIRImag_fx[BINAURAL_CONVBANDS][HRTF_LS_CHANNELS][BINAURAL_NT extern Word32 FASTCONV_HOA3_latency_s_fx; extern Word32 FASTCONV_HOA2_latency_s_fx; extern Word32 FASTCONV_FOA_latency_s_fx; -extern Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q15 */ +extern Word16 hrtfShCoeffsRe_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ extern Word16 hrtfShCoeffsIm_fx[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS]; /* Q14 */ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 33f4e366e..4551617de 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -2023,7 +2023,7 @@ static ivas_error create_parambin_HRTF_from_rawdata( { memcpy( f_tmp_hrtfShCoeffs, hrtf_data_rptr, data_size_tmp ); /*adding conversion as file reading is done in float*/ - floatToFixed_arr16( f_tmp_hrtfShCoeffs, ( *hHRTF )->hrtfShCoeffsRe_fx[i][j], Q15, HRTF_NUM_BINS ); + floatToFixed_arr16( f_tmp_hrtfShCoeffs, ( *hHRTF )->hrtfShCoeffsRe_fx[i][j], Q14, HRTF_NUM_BINS ); hrtf_data_rptr += data_size_tmp; } } -- GitLab From 74409b7d0125f8972a67ae9d95007e8fc5c5ff36 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 3 Jul 2025 10:44:52 +0200 Subject: [PATCH 492/692] 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 493/692] 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 494/692] 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 bf7e97febbdd0869579278b1bdaac8e795bb24d0 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 4 Jul 2025 11:15:04 +0300 Subject: [PATCH 495/692] Clang format --- lib_enc/ivas_masa_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 6d53d1d09..57fc30e78 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -3157,7 +3157,7 @@ static void copy_masa_metadata_subframe_fx( FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) { #ifdef NONBE_FIX_1034_DRY_MASA_RATIOS - FOR ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { hMetaTo->directional_meta[dir].spherical_index[sfTo][band] = hMetaFrom->directional_meta[dir].spherical_index[sfFrom][band]; move16(); -- GitLab From dcf8b5fc7add37482d0c6b2382be8a92503ef118 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 4 Jul 2025 11:34:08 +0300 Subject: [PATCH 496/692] Fix wrong conversion based on code review. --- lib_com/ivas_cnst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 4d94cdbe6..6e17c7046 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1287,7 +1287,7 @@ enum #define MASA_RATIO_THRESHOLD 0.1f #define MASA_ANGLE_TOLERANCE 0.5f #ifdef NONBE_FIX_1034_DRY_MASA_RATIOS -#define MASA_RATIO_THRESHOLD_FX 322122547 // 0.15 in Q31 +#define MASA_RATIO_THRESHOLD_FX 32212255 // 0.015 in Q31 #else #define MASA_RATIO_THRESHOLD_FX 214748365 // 0.1 in Q31 #endif -- GitLab From 012b2473da508b008cb17b963567e860c24604c8 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 11:46:03 +0200 Subject: [PATCH 497/692] port missing changes from float MR 1433 --- lib_com/ivas_prot_fx.h | 9 ++++++--- lib_dec/ivas_ism_renderer_fx.c | 13 ++++++++++--- lib_dec/ivas_osba_dec_fx.c | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 501c91a35..a34c2297d 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1055,9 +1055,12 @@ ivas_error ivas_ism_renderer_open_fx( ); void ivas_ism_render_sf_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_fx[], /* i/o: core-coder transport channels/object output */ - const Word16 n_samples_to_render /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + const RENDERER_TYPE renderer_type, /* i : active renderer type */ +#endif + Word32 *output_fx[], /* i/o: core-coder transport channels/object output */ + const Word16 n_samples_to_render /* i : output frame length per channel */ ); void ivas_jbm_dec_get_adapted_linear_interpolator_fx( diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 0564868c8..6c80c39b7 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -156,9 +156,12 @@ void ivas_ism_renderer_close( * Object rendering process *-------------------------------------------------------------------------*/ void ivas_ism_render_sf_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ - const Word16 n_samples_to_render /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + const RENDERER_TYPE renderer_type, /* i : active renderer type */ +#endif + Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ + const Word16 n_samples_to_render /* i : output frame length per channel */ ) { Word16 i, j, k, j2; @@ -333,7 +336,11 @@ void ivas_ism_render_sf_fx( n_samples_rendered_loop = add( n_samples_rendered_loop, n_samples_in_subframe ); /* update rendered subframe and slots info for all cases apart from a following crend call, the update will then happen in the crend call*/ +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + if ( renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) +#else if ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) +#endif { st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index a8754d84f..3491b0491 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -308,7 +308,11 @@ ivas_error ivas_osba_render_sf_fx( IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); +#else ivas_ism_render_sf_fx( st_ivas, p_output_ism, *nSamplesRendered ); +#endif } FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) -- GitLab From 26b9d67f5af5e70643c512f4dedf23863583bcbe Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 12:40:55 +0200 Subject: [PATCH 498/692] fix formatting --- lib_dec/ivas_ism_renderer_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 6c80c39b7..b5ad713ba 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -156,12 +156,12 @@ void ivas_ism_renderer_close( * Object rendering process *-------------------------------------------------------------------------*/ void ivas_ism_render_sf_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH - const RENDERER_TYPE renderer_type, /* i : active renderer type */ + const RENDERER_TYPE renderer_type, /* i : active renderer type */ #endif - Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ - const Word16 n_samples_to_render /* i : output frame length per channel */ + Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ + const Word16 n_samples_to_render /* i : output frame length per channel */ ) { Word16 i, j, k, j2; -- GitLab From 5cadf600bbfc87d8e4f5c8fee78a8f354b49be28 Mon Sep 17 00:00:00 2001 From: weckbecker Date: Fri, 4 Jul 2025 12:42:28 +0200 Subject: [PATCH 499/692] add missing move16 --- lib_dec/ivas_ism_renderer_fx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index b5ad713ba..550128d7c 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -199,6 +199,7 @@ void ivas_ism_render_sf_fx( #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH num_objects = st_ivas->nchan_ism; + move16(); #else num_objects = st_ivas->nchan_transport; move16(); -- GitLab From ea5fa66de7c81f1cb02d6a75dcc4a8135353f84d Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 12:53:15 +0200 Subject: [PATCH 500/692] port missing changes from float MR 1433 in lib_dec/ivas_jbm_dec_fx.c --- lib_dec/ivas_jbm_dec_fx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index bc4a732e0..30431f3be 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1958,7 +1958,11 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); +#else + ivas_ism_render_sf_fx( st_ivas, p_output, *nSamplesRendered ); +#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { @@ -2139,8 +2143,12 @@ ivas_error ivas_jbm_dec_render_fx( p_tc_fx[2] = p_output_fx[3]; } - /* render objects */ + /* render objects */ +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); +#else ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); +#endif /* add already rendered SBA part */ FOR( n = 0; n < nchan_out; n++ ) -- GitLab From c2f722e6fb748b060d84394c7ac17e08b74b2a61 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 12:54:20 +0200 Subject: [PATCH 501/692] fix formatting --- 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 30431f3be..7aea1055d 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2143,7 +2143,7 @@ ivas_error ivas_jbm_dec_render_fx( p_tc_fx[2] = p_output_fx[3]; } - /* render objects */ + /* render objects */ #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); #else -- GitLab From 94b0164cc6a4897ad28cf34e473350051320ab8e Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 3 Jul 2025 16:33:59 +0530 Subject: [PATCH 502/692] 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 503/692] 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 168dc5f86bbca9160d959ac970bfd704d2ecc0ad Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 13:02:36 +0200 Subject: [PATCH 504/692] fix arguments in one call to ivas_ism_render_sf_fx --- lib_dec/ivas_jbm_dec_fx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 7aea1055d..a4547a483 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1961,7 +1961,7 @@ ivas_error ivas_jbm_dec_render_fx( #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); #else - ivas_ism_render_sf_fx( st_ivas, p_output, *nSamplesRendered ); + ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); #endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) @@ -2686,7 +2686,11 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15 +#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH + ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, hTcBuffer->n_samples_granularity ); +#else ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ); +#endif st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; -- GitLab From f46551bf3816339f743fe6b1a4f1fc8669b00ffb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 16:36:57 +0530 Subject: [PATCH 505/692] 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 506/692] 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 16873902114de389d33c0125545ab2ce647020fb Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 13:23:59 +0200 Subject: [PATCH 507/692] fix comparison with BASOP --- lib_dec/ivas_ism_renderer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 550128d7c..e5fe873a0 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -338,7 +338,7 @@ void ivas_ism_render_sf_fx( /* update rendered subframe and slots info for all cases apart from a following crend call, the update will then happen in the crend call*/ #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH - if ( renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM ) + if ( NE_16( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) #else if ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) #endif -- GitLab From 227d8a4ded61fc81e21a4f5364dee7431a807b06 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Fri, 4 Jul 2025 13:24:30 +0200 Subject: [PATCH 508/692] remove extra move16 --- lib_dec/ivas_ism_renderer_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index e5fe873a0..686329eea 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -199,7 +199,6 @@ void ivas_ism_render_sf_fx( #ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH num_objects = st_ivas->nchan_ism; - move16(); #else num_objects = st_ivas->nchan_transport; move16(); -- GitLab From 6d95be087e7e0b14312d0a49c2294ffb28405fa8 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 4 Jul 2025 15:16:54 +0530 Subject: [PATCH 509/692] 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 510/692] 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 511/692] 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 512/692] 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 513/692] 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 514/692] 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 13fa6872d23b7d578bf3806083f5090347be0bc0 Mon Sep 17 00:00:00 2001 From: rtyag Date: Mon, 7 Jul 2025 21:26:22 +1000 Subject: [PATCH 515/692] basop porting, fix for issue 1806 --- lib_com/options.h | 1 + lib_dec/ivas_binRenderer_internal_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f28c671ca..b292f4364 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -125,6 +125,7 @@ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ #define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/ +#define FIX_1035_HT_OSBA /* Dlb: issue 1035: Issue with headtracking in OSBA*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index cf2f4a9a0..7eae8c1bc 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1204,7 +1204,11 @@ ivas_error ivas_binRenderer_open_fx( hBinRenderer->rotInCldfb = 0; move16(); test(); +#ifdef FIX_1035_HT_OSBA + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32(st_ivas->ivas_format, SBA_ISM_FORMAT) ) +#else if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) +#endif { hBinRenderer->rotInCldfb = 1; move16(); -- 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 516/692] 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 517/692] 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 518/692] 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 b9667e4ee41a14f8fff9ec89ef3ad07c6e7d8817 Mon Sep 17 00:00:00 2001 From: rtyag Date: Tue, 8 Jul 2025 10:09:06 +1000 Subject: [PATCH 519/692] clang format fix --- lib_dec/ivas_binRenderer_internal_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 7eae8c1bc..883977d6f 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1205,7 +1205,7 @@ ivas_error ivas_binRenderer_open_fx( move16(); test(); #ifdef FIX_1035_HT_OSBA - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32(st_ivas->ivas_format, SBA_ISM_FORMAT) ) + if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) #else if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) #endif -- GitLab From 837f655c24cdb9cb184d29d8eeeeeb789ba313ed Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 8 Jul 2025 06:15:49 +0530 Subject: [PATCH 520/692] 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 521/692] 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 522/692] 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 523/692] 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 524/692] 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 525/692] 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 526/692] 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 527/692] 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 802fb9cd53d024f0cb1e550ba0426a22a9b3cdcd Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:11:20 +0200 Subject: [PATCH 528/692] [cleanup] accept FIX_1024_REMOVE_PARAMMC_MIXING_MAT --- lib_com/options.h | 1 - lib_dec/ivas_mc_param_dec_fx.c | 10 ---------- lib_dec/ivas_out_setup_conversion_fx.c | 8 -------- 3 files changed, 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b292f4364..14a9bf919 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -121,7 +121,6 @@ #define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ -#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ #define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/ diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 1767f5cde..a9cbc0264 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -3063,16 +3063,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( return; } -#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT - -/*------------------------------------------------------------------------- - * ivas_param_mc_get_mono_stereo_mixing_matrices() - * - * calculate the direct and residual mixing matrices - * for mono and stereo output - *------------------------------------------------------------------------*/ - -#endif /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 5ce1f08f1..596115278 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -1190,11 +1190,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( set_zero_fx( cy_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS ); set_zero_fx( Nrqq_fx, MAX_OUTPUT_CHANNELS ); set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS ); -#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* Step 1.2, get target channel energies for the transported format, Nrqq calculation */ -#else - /* Step 1.2, get target channel energies for the transported format as in ivas_param_mc_get_mono_stereo_mixing_matrices(), Nrqq calculation */ -#endif ild_q_fx = hParamMC->icld_q_fx + imult1616( bandIdx, hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); move16(); FOR( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ ) @@ -1216,11 +1212,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( move32(); } -#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT /* Step 1.3 get target Cy () (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ -#else - /* Step 1.3 get target Cy like in ivas_param_mc_get_mono_stereo_mixing_matrices() (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */ -#endif FOR( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ ) { FOR( i = 0; i < nchan_transport_format; i++ ) -- GitLab From 528dc61141306ed485003f126c3c15f599b76352 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:11:30 +0200 Subject: [PATCH 529/692] [cleanup] accept FIX_1035_HT_OSBA --- lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 14a9bf919..a51d49769 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,7 +124,6 @@ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ #define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/ -#define FIX_1035_HT_OSBA /* Dlb: issue 1035: Issue with headtracking in OSBA*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 883977d6f..a1b6bb5ed 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1204,11 +1204,7 @@ ivas_error ivas_binRenderer_open_fx( hBinRenderer->rotInCldfb = 0; move16(); test(); -#ifdef FIX_1035_HT_OSBA if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) -#else - if ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) -#endif { hBinRenderer->rotInCldfb = 1; move16(); -- GitLab From e29ad661df16322a547600a7ff14bd6933c24ee0 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:11:36 +0200 Subject: [PATCH 530/692] [cleanup] accept NONBE_FIX_1021_ISM_BRIR_RS_FLUSH --- lib_com/ivas_prot_fx.h | 2 -- lib_com/options.h | 1 - lib_dec/ivas_ism_renderer_fx.c | 16 ---------------- lib_dec/ivas_jbm_dec_fx.c | 12 ------------ lib_dec/ivas_osba_dec_fx.c | 4 ---- 5 files changed, 35 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index a34c2297d..e4945bf52 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1056,9 +1056,7 @@ ivas_error ivas_ism_renderer_open_fx( void ivas_ism_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH const RENDERER_TYPE renderer_type, /* i : active renderer type */ -#endif Word32 *output_fx[], /* i/o: core-coder transport channels/object output */ const Word16 n_samples_to_render /* i : output frame length per channel */ ); diff --git a/lib_com/options.h b/lib_com/options.h index a51d49769..b2f1e6b85 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,7 +123,6 @@ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ -#define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 686329eea..44008cf37 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -157,9 +157,7 @@ void ivas_ism_renderer_close( *-------------------------------------------------------------------------*/ void ivas_ism_render_sf_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH const RENDERER_TYPE renderer_type, /* i : active renderer type */ -#endif Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ const Word16 n_samples_to_render /* i : output frame length per channel */ ) @@ -197,17 +195,7 @@ void ivas_ism_render_sf_fx( last_sf = add( last_sf, 1 ); } -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH num_objects = st_ivas->nchan_ism; -#else - num_objects = st_ivas->nchan_transport; - move16(); - if ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) - { - num_objects = st_ivas->nchan_ism; - move16(); - } -#endif nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; move16(); @@ -336,11 +324,7 @@ void ivas_ism_render_sf_fx( n_samples_rendered_loop = add( n_samples_rendered_loop, n_samples_in_subframe ); /* update rendered subframe and slots info for all cases apart from a following crend call, the update will then happen in the crend call*/ -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH if ( NE_16( renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) -#else - if ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) -#endif { st_ivas->hTcBuffer->subframes_rendered = add( st_ivas->hTcBuffer->subframes_rendered, 1 ); st_ivas->hTcBuffer->slots_rendered = add( st_ivas->hTcBuffer->slots_rendered, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index a4547a483..324c099b6 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1958,11 +1958,7 @@ ivas_error ivas_jbm_dec_render_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_TD_PANNING ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); -#else - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); -#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_NON_DIEGETIC_DOWNMIX ) ) { @@ -2144,11 +2140,7 @@ ivas_error ivas_jbm_dec_render_fx( } /* render objects */ -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); -#else - ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered ); -#endif /* add already rendered SBA part */ FOR( n = 0; n < nchan_out; n++ ) @@ -2686,11 +2678,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx( /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15 -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, renderer_type_old, p_output_fx, hTcBuffer->n_samples_granularity ); -#else - ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity ); -#endif st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor; *st_ivas->hCrendWrapper->p_io_qfactor = 11; diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 3491b0491..fc325d893 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -308,11 +308,7 @@ ivas_error ivas_osba_render_sf_fx( IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { -#ifdef NONBE_FIX_1021_ISM_BRIR_RS_FLUSH ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered ); -#else - ivas_ism_render_sf_fx( st_ivas, p_output_ism, *nSamplesRendered ); -#endif } FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) -- GitLab From 6d2d54d0f31a787493cb33006fb4c7bbfb771fe6 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:11:39 +0200 Subject: [PATCH 531/692] [cleanup] accept NONBE_FIX_1034_DRY_MASA_RATIOS --- lib_com/ivas_cnst.h | 4 ---- lib_com/options.h | 1 - lib_enc/ivas_masa_enc_fx.c | 12 ------------ 3 files changed, 17 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6e17c7046..8e5d0d626 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1286,11 +1286,7 @@ enum #define MASA_RATIO_TOLERANCE 0.1f #define MASA_RATIO_THRESHOLD 0.1f #define MASA_ANGLE_TOLERANCE 0.5f -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS #define MASA_RATIO_THRESHOLD_FX 32212255 // 0.015 in Q31 -#else -#define MASA_RATIO_THRESHOLD_FX 214748365 // 0.1 in Q31 -#endif #define MASA_RATIO_TOLERANCE_FX 107374182 // 0.1 in Q30 #define MASA_ANGLE_TOLERANCE_FX ONE_IN_Q21 // 0.5 in Q22 #define MASA_LIMIT_NO_BANDS_SUR_COH 8 diff --git a/lib_com/options.h b/lib_com/options.h index b2f1e6b85..05c7dd2c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -122,7 +122,6 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ -#define NONBE_FIX_1034_DRY_MASA_RATIOS /* Nokia: Fix issue 1034, use of wrong numDir state. */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 57fc30e78..869b41fd2 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1857,9 +1857,7 @@ void ivas_masa_combine_directions_fx( hMeta->directional_meta[1].energy_ratio_fx[j][i] = 0; // Q30 move16(); move16(); -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS hMeta->common_meta.diffuse_to_total_ratio_fx[j][i] = L_sub( ONE_IN_Q30, hMeta->directional_meta[0].energy_ratio_fx[j][i] ); // Q30 -#endif IF( computeCoherence ) { @@ -2107,10 +2105,8 @@ static void detect_metadata_composition_fx( { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS hMeta->directional_meta[0].spherical_index[sf][band] = hMeta->directional_meta[1].spherical_index[sf][band]; move16(); -#endif hMeta->directional_meta[0].azimuth_fx[sf][band] = hMeta->directional_meta[1].azimuth_fx[sf][band]; /*q22*/ hMeta->directional_meta[0].elevation_fx[sf][band] = hMeta->directional_meta[1].elevation_fx[sf][band]; /*q22*/ hMeta->directional_meta[0].energy_ratio_fx[sf][band] = hMeta->directional_meta[1].energy_ratio_fx[sf][band]; /*q30*/ @@ -2235,12 +2231,8 @@ static void compensate_energy_ratios_fx( UWord8 numDirs; hMeta = &( hMasa->masaMetadata ); -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS numDirs = hMasa->config.numberOfDirections; move16(); -#else - numDirs = (UWord8) add( hMeta->descriptive_meta.numberOfDirections, 1 ); -#endif FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { @@ -3149,20 +3141,16 @@ static void copy_masa_metadata_subframe_fx( ) { UWord8 dir; -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS UWord8 band; -#endif /* directional metadata */ FOR( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) { -#ifdef NONBE_FIX_1034_DRY_MASA_RATIOS FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) { hMetaTo->directional_meta[dir].spherical_index[sfTo][band] = hMetaFrom->directional_meta[dir].spherical_index[sfFrom][band]; move16(); } -#endif Copy32( hMetaFrom->directional_meta[dir].azimuth_fx[sfFrom], hMetaTo->directional_meta[dir].azimuth_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22 Copy32( hMetaFrom->directional_meta[dir].elevation_fx[sfFrom], hMetaTo->directional_meta[dir].elevation_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q22 Copy32( hMetaFrom->directional_meta[dir].energy_ratio_fx[sfFrom], hMetaTo->directional_meta[dir].energy_ratio_fx[sfTo], MASA_FREQUENCY_BANDS ); // Q30 -- GitLab From 2cbc3f71f02024e7a585221f4e913823d7a64d2f Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:13:15 +0200 Subject: [PATCH 532/692] formatting --- lib_dec/ivas_ism_renderer_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 44008cf37..8d141537d 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -156,10 +156,10 @@ void ivas_ism_renderer_close( * Object rendering process *-------------------------------------------------------------------------*/ void ivas_ism_render_sf_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const RENDERER_TYPE renderer_type, /* i : active renderer type */ - Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ - const Word16 n_samples_to_render /* i : output frame length per channel */ + Word32 *output_fx[], /* i/o: core-coder transport channels/object output Q11*/ + const Word16 n_samples_to_render /* i : output frame length per channel */ ) { Word16 i, j, k, j2; -- GitLab From d9b5dca01d023e6888862d635db3c7760ee6bc1d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:22:54 +0200 Subject: [PATCH 533/692] [cleanup] accept FIX_638_ENERGIE_IAC_ROM_TABLES --- lib_com/options.h | 1 - lib_rend/ivas_hrtf_fx.c | 4 - lib_rend/ivas_objectRenderer_mix_fx.c | 2 - lib_rend/ivas_rom_binaural_crend_head.h | 2 - lib_rend/ivas_rom_binaural_crend_head_fx.c | 2 - lib_rend/ivas_rom_rend.h | 19 -- lib_rend/ivas_rom_rend_fx.c | 340 --------------------- lib_util/hrtf_file_reader.c | 4 - 8 files changed, 374 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 05c7dd2c7..b61f560ad 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,6 @@ #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ -#define FIX_638_ENERGIE_IAC_ROM_TABLES /* Orange: Missing left/right and coherence late reverb tables in binary format*/ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ #define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 58dc54b26..7a81b7946 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -33,11 +33,7 @@ #include #include "options.h" #include "prot_fx.h" -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #include "ivas_rom_binaural_crend_head.h" -#else -#include "ivas_rom_rend.h" -#endif #include "ivas_prot_rend_fx.h" #include "ivas_error.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index c46ca25db..b267044b1 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -38,9 +38,7 @@ #include "ivas_error.h" #include "wmc_auto.h" #include "ivas_rom_rend.h" -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #include "ivas_rom_binaural_crend_head.h" -#endif #include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 4f40c2ed7..0a8e3b7c6 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -348,7 +348,6 @@ extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURA extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2522]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2522]; -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB extern float defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern float defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ @@ -374,6 +373,5 @@ extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; / extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ #endif -#endif #endif /* _IVAS_ROM_BINAURAL_CREND_HEAD_ */ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 436ba60f6..bdf8e0252 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59650,7 +59650,6 @@ const Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS] -6515466, }, }; -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB /********************** defaultHRIR reverb rom tables at sampling rate 48kHz **********************/ @@ -60184,7 +60183,6 @@ const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ }; #endif -#endif Word32 sine_table_Q31 [361] = { diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 7cbe76051..6c966e457 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -93,25 +93,6 @@ extern const Word16 HRTF_MODEL_N_CPTS_VAR[HRTF_MODEL_N_SECTIONS]; extern const Word32 SincTable_fx[321]; -#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES -extern const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ - -extern const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ - -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ -extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -#else -extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -#endif -#endif /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_rom_rend_fx.c b/lib_rend/ivas_rom_rend_fx.c index 5247b8e77..6589adcf7 100644 --- a/lib_rend/ivas_rom_rend_fx.c +++ b/lib_rend/ivas_rom_rend_fx.c @@ -206,346 +206,6 @@ const Word32 SincTable_fx[321] /*Q31*/ = { 8716980, 8185692, 7649294, 7108665, 6564643, 6017979, 5469361, 4919434, 4368840, 3818118, 3267783, 2718370, 2170290, 1624034, 1079948, 538481, }; -#ifndef FIX_638_ENERGIE_IAC_ROM_TABLES -const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 131936432,125285536,105934832,77097344,45729324,19356880,2523696,0,0, - 0,1602425,4763253,5796595,5698884,5608690,5175704,3880368,2303444, - 1553033,1902670,2661537,3300414,3919560,4475624,4485288,3976468,3688169, - 3682129,3375844,2619661,1976758,1906026,2165066,2186943,1765500,1162325, - 671759,348160,140123,27783,0,0,0,148981,534991, - 939926,1281242,1547798,1665910,1550617,1228897,835102,478486,185757, - 0,0,0,0,4294,124554,284273,410840,479828, - 507343,493652,417417,278367,114890,0,0,0,0, - 0,0,0,0,0,29125,130728,242531,313264, - 326954,282528,204816,121735,46976,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,31943,114353,173543, - 205218,205755,176362,128043,69927,20803,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,3355,38117,83214,127372,170993,215553,257966, - 294607,327222,360643,395137,425738,452447,480096,507208,525462, - 533247,534186,526804,505463,469896,424799,372856,312190,242397, - 168711,95831,28319,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,102810,72074,0, - 226962,443858,219445,0,214882,1013209,77846,0,273535, - 1385798,289239,0,472983,1241648,688671,0,306821,870536, - 792153,0,115695,613375,552574,0,0,434462,205890, - 34762,26709,182938,117843,0 -}; -const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8209721,8156956,8050127,7984940,7992858,8011649,7974747,7910306,7917252, - 8038476,8174723,8228729,8192717,8124794,8070352,8029995,7989956,7953608, - 7931152,7912210,7870745,7803402,7745101,7727896,7735563,7724331,7693670, - 7672548,7668253,7662666,7647508,7638633,7652147,7680265,7699593,7698955, - 7689828,7687614,7690835,7685852,7667229,7645042,7629506,7617787,7601639, - 7578545,7554822,7537315,7524279,7507108,7481430,7453328,7431803,7415991, - 7395254,7364820,7335141,7319069,7310202,7296948,7280120,7270700,7273946, - 7282989,7288836,7292510,7303600,7327768,7359376,7389357,7418784,7458856, - 7515186,7577119,7632232,7684091,7741771,7803922,7858506,7897295,7924793, - 7950529,7975309,7989134,7983815,7964337,7942418,7920028,7885853,7832460, - 7773178,7719675,7667640,7605540,7531820,7456659,7388182,7322718,7251305, - 7173342,7099371,7039023,6989942,6943645,6900871,6876377,6876200,6891753, - 6912280,6938008,6976184,7027514,7081939,7129159,7169768,7212416,7260113, - 7303961,7334160,7353923,7375390,7399868,7413919,7410756,7397888,7384995, - 7371128,7347783,7311469,7269433,7231533,7198642,7162562,7118413,7073358, - 7038218,7011467,6978885,6936976,6896929,6866243,6838636,6804318,6763793, - 6726715,6699377,6677726,6654422,6630095,6613880,6612001,6619165,6625113, - 6629517,6642997,6668750,6697196,6718344,6734173,6753895,6779589,6802146, - 6813185,6816633,6823486,6836086,6844013,6839567,6830432,6829887,6834652, - 6833897,6825424,6817447,6817430,6823444,6827572,6826137,6824845,6832135, - 6847612,6860472,6863735,6867082,6885344,6912573,6928050,6933679,6949215, - 6980018,7009084,7024486,7037715,7065515,7103221,7130283,7141717,7156523, - 7182804,7191302,7148830,7066479,6973039,6845448,6642997,6369529,6067757, - 5757018,5407708,4989863,4529504,4091224,3695693,3270760,2711684,2000297, - 1252050,651123,273904,89170,20652,2843,209,134,134, - 125,117,92,75,75,75,58,50,50, - 58,50,41,41,50,41,41,41,41, - 41,41,41,41,41,41,41,41,41, - 41,41,41,41,41 -}; -const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8209721,8156956,8050144,7984965,7992850,8011640,7974756,7910323,7917252, - 8038484,8174707,8228738,8192709,8124794,8070361,8030003,7989948,7953583, - 7931127,7912202,7870737,7803402,7745101,7727896,7735563,7724331,7693679, - 7672548,7668236,7662658,7647491,7638624,7652147,7680265,7699609,7698964, - 7689820,7687597,7690827,7685844,7667229,7645050,7629472,7617779,7601639, - 7578545,7554822,7537315,7524288,7507133,7481447,7453337,7431803,7415982, - 7395229,7364812,7335141,7319077,7310185,7296931,7280120,7270700,7273955, - 7282998,7288836,7292494,7303583,7327776,7359401,7389382,7418776,7458856, - 7515186,7577127,7632241,7684082,7741787,7803939,7858523,7897295,7924793, - 7950529,7975309,7989125,7983824,7964320,7942426,7920062,7885853,7832443, - 7773194,7719675,7667640,7605556,7531829,7456675,7388199,7322726,7251305, - 7173333,7099379,7039032,6989967,6943653,6900880,6876377,6876226,6891753, - 6912271,6937999,6976184,7027514,7081931,7129151,7169768,7212416,7260122, - 7303961,7334160,7353940,7375398,7399868,7413910,7410731,7397871,7384978, - 7371145,7347791,7311477,7269450,7231542,7198633,7162554,7118413,7073358, - 7038218,7011475,6978885,6936976,6896920,6866226,6838628,6804310,6763785, - 6726707,6699369,6677709,6654414,6630095,6613889,6612010,6619148,6625071, - 6629508,6642989,6668750,6697204,6718352,6734190,6753920,6779597,6802146, - 6813210,6816641,6823495,6836095,6844030,6839559,6830457,6829904,6834677, - 6833905,6825416,6817455,6817421,6823428,6827555,6826129,6824837,6832135, - 6847620,6860472,6863735,6867082,6885336,6912582,6928059,6933679,6949232, - 6980026,7009084,7024477,7037706,7065489,7103188,7130275,7141708,7156497, - 7182812,7191285,7148847,7066488,6973047,6845439,6642997,6369529,6067757, - 5757001,5407699,4989863,4529504,4091224,3695702,3270751,2711693,2000297, - 1252050,651123,273904,89170,20652,2843,209,134,134, - 125,117,92,75,75,75,58,50,50, - 58,50,41,41,50,41,41,41,41, - 41,41,41,41,41,41,41,41,41, - 41,41,41,41,41 -}; -const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 131125216,129227112,119736576,105149792,87165424,65548180,45102524,26414452,12630962, - 2261837,646258,0,0,0,362790,1269699,3305916,5226035, - 5552185,5544266,5313545,5242007,4972498,4406099,3304843,2138491,1245809, - 945832,1040724,1586856,2087488,2519669,2930509,3330210,3706959,3852988, - 3845069,3506438,3230889,3049963,3020838,2972117,2692944,2226269,1634369, - 1306206,1176284,1344056,1533169,1651817,1468073,1147695,736184,393929, - 141465,23622,0,0,0,0,0,0,0, - 0,0,31004,186025,403995,663840,869999,1052669,1200174, - 1230910,1195208,1010927,774704,504121,258100,82812,13824,0, - 0,0,0,0,0,0,0,0,0, - 0,35567,94757,127104,150189,159048,139586,103616,29662, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,13287,46305,75833,95294,77980,44426,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,13153,45768,78383,106434, - 117574,114487,101871,68719,36641,6039,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,1476, - 5234,21072,40667,63619,89120,116098,144015,171932,199715, - 227901,255818,281723,304405,324941,341584,357824,373796,388962, - 403995,419296,437818,458621,488820,521301,557674,596329,636728, - 680886,727728,776315,821546,862751,897916,926773,952409,971870, - 980460,981802,955227,918049,865167,793897,713233,613106,507477, - 398224,342255,316082,334604,338228 -}; -const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8747993,8732977,8657866,8592845,8534553,8549703,8574332,8613196,8612450, - 8594632,8548151,8528631,8527079,8602383,8683241,8772412,8811402,8825092, - 8787822,8745552,8699960,8676052,8653847,8634210,8606620,8577981,8553109, - 8534922,8521190,8494783,8457906,8405301,8354525,8310963,8294462,8290268, - 8294278,8284279,8267812,8241648,8222362,8207531,8203647,8196752,8187852, - 8170672,8158450,8153660,8165857,8182684,8201064,8209352,8210920,8201391, - 8193506,8188086,8186669,8185008,8178398,8165219,8147653,8126564,8107262, - 8090653,8075973,8060647,8040892,8017060,7990510,7965369,7942812,7924139, - 7905508,7885266,7858574,7828903,7797253,7770124,7745051,7723047,7698192, - 7671231,7638683,7606840,7575458,7552800,7532081,7514280,7493736,7472068, - 7448614,7429295,7412736,7405756,7399180,7393182,7382990,7372018,7362119, - 7358680,7359552,7368629,7377118,7384718,7391127,7398953,7413675,7435679, - 7462522,7492302,7520043,7544714,7568412,7592915,7621662,7651325,7681599, - 7702873,7719423,7728886,7735043,7740672,7747517,7751812,7754412,7743650, - 7728089,7705339,7680970,7656341,7632308,7603568,7571683,7527366,7481606, - 7433699,7390347,7348345,7307132,7260525,7210319,7153108,7097458,7044149, - 6995864,6948351,6898883,6845179,6788657,6732512,6680016,6632990,6592154, - 6553113,6515029,6478094,6441947,6416664,6397714,6388260,6386465,6386851, - 6388319,6391700,6396364,6411102,6429029,6451720,6471844,6489796,6501641, - 6513435,6525204,6542518,6559405,6575670,6584344,6589771,6589813,6590845, - 6592531,6595845,6596365,6592707,6580091,6564161,6543961,6524642,6505902, - 6486113,6462969,6434800,6400113,6364034,6328861,6297445,6268521,6239597, - 6208098,6172732,6136241,6100909,6071330,6044722,6020084,5990858,5959116, - 5923599,5889046,5855634,5825838,5795177,5763938,5725518,5685253,5642211, - 5600763,5560540,5523688,5486661,5449525,5408043,5366612,5325264,5291257, - 5260940,5238031,5214778,5191290,5165126,5142795,5126186,5122067,5121799, - 5124433,5124877,5123837,5133241,5151268,5182239,5223192,5269715,5328527, - 5411331,5510141,5612029,5649811,5591443,5269488,4824515,4151102,3472472, - 2790361,2355655,2029229,1865232,1832432 -}; -const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8747984,8732969,8657857,8592837,8534561,8549686,8574315,8613188,8612450, - 8594632,8548151,8528622,8527070,8602392,8683241,8772404,8811402,8825109, - 8787822,8745552,8699951,8676044,8653847,8634226,8606620,8577964,8553100, - 8534914,8521190,8494808,8457931,8405310,8354525,8310963,8294471,8290276, - 8294278,8284287,8267820,8241639,8222362,8207540,8203664,8196752,8187826, - 8170663,8158450,8153685,8165873,8182684,8201064,8209360,8210945,8201416, - 8193531,8188095,8186669,8185008,8178398,8165219,8147653,8126539,8107237, - 8090644,8075973,8060664,8040875,8017043,7990510,7965369,7942812,7924122, - 7905499,7885283,7858574,7828903,7797270,7770116,7745034,7723056,7698192, - 7671222,7638675,7606840,7575466,7552809,7532089,7514280,7493736,7472068, - 7448597,7429287,7412753,7405756,7399163,7393174,7382981,7372009,7362111, - 7358680,7359560,7368637,7377126,7384718,7391135,7398970,7413692,7435679, - 7462514,7492293,7520026,7544705,7568403,7592915,7621688,7651341,7681582, - 7702873,7719423,7728877,7735026,7740663,7747517,7751829,7754437,7743650, - 7728080,7705330,7680970,7656349,7632308,7603568,7571700,7527383,7481623, - 7433716,7390363,7348353,7307132,7260525,7210327,7153125,7097475,7044149, - 6995872,6948359,6898883,6845179,6788657,6732520,6680024,6632990,6592154, - 6553113,6515037,6478102,6441947,6416664,6397714,6388269,6386457,6386843, - 6388327,6391700,6396347,6411102,6429029,6451712,6471844,6489796,6501624, - 6513427,6525213,6542518,6559405,6575653,6584327,6589763,6589813,6590845, - 6592531,6595836,6596365,6592716,6580099,6564169,6543978,6524642,6505894, - 6486122,6462994,6434817,6400122,6364034,6328852,6297428,6268521,6239597, - 6208090,6172723,6136241,6100909,6071330,6044722,6020076,5990842,5959107, - 5923599,5889037,5855617,5825829,5795169,5763921,5725518,5685253,5642194, - 5600755,5560548,5523688,5486661,5449508,5408026,5366603,5325256,5291257, - 5260949,5238040,5214778,5191281,5165134,5142795,5126194,5122075,5121799, - 5124441,5124877,5123854,5133241,5151259,5182230,5223192,5269715,5328527, - 5411340,5510149,5612037,5649820,5591435,5269472,4824498,4151094,3472472, - 2790378,2355663,2029237,1865240,1832432 -}; - -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB -/* Sample Rate = 16000 */ - - float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = - {0.983044f, 0.960794f, 0.893756f, 0.783586f, 0.638963f, 0.477338f, 0.319879f, 0.183374f, 0.075909f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.003842f, 0.025288f, 0.035886f, - 0.037785f, 0.035991f, 0.034784f, 0.035091f, 0.034683f, 0.030849f, 0.023146f, 0.014061f, 0.007275f, - 0.005053f, 0.006930f, 0.010589f, 0.013905f, 0.016288f, 0.018404f, 0.020849f, 0.023164f, 0.024149f, - 0.023098f, 0.020635f, 0.018325f, 0.017381f, 0.017611f, 0.017534f, 0.015650f, 0.011786f, 0.007342f, - 0.004290f, 0.003732f, 0.005148f, 0.006838f, 0.007172f, 0.005579f, 0.002632f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000238f, 0.001738f, 0.003011f, 0.003910f, - 0.004120f, 0.003394f, 0.001769f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, - 0.000000f, 0.002101f, 0.004247f, 0.006330f, 0.008300f, 0.010110f, 0.011735f, 0.013165f, 0.014384f, - 0.015345f, 0.015972f, 0.016191f}; - - float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = - {1.118974f, 1.115256f, 1.106210f, 1.096901f, 1.092316f, 1.094422f, 1.101140f, 1.107775f, 1.110000f, - 1.106535f, 1.099921f, 1.094914f, 1.095643f, 1.103178f, 1.114955f, 1.126292f, 1.132973f, 1.133288f, - 1.128471f, 1.121439f, 1.114842f, 1.109721f, 1.105480f, 1.100966f, 1.095650f, 1.090074f, 1.085225f, - 1.081525f, 1.078267f, 1.074026f, 1.067777f, 1.059839f, 1.051856f, 1.045772f, 1.042531f, 1.041432f, - 1.040607f, 1.038291f, 1.033910f, 1.028286f, 1.022846f, 1.018514f, 1.015152f, 1.011898f, 1.008047f, - 1.003762f, 0.999992f, 0.997770f, 0.997349f, 0.997960f, 0.998259f, 0.997177f, 0.994506f, 0.990883f, - 0.987207f, 0.984003f, 0.981133f, 0.977984f, 0.973950f, 0.968837f, 0.962915f, 0.956690f, 0.950584f, - 0.944679f, 0.938744f, 0.932399f, 0.925372f, 0.917663f, 0.909568f, 0.901511f, 0.893804f, 0.886455f, - 0.879155f, 0.871463f, 0.863142f, 0.854285f, 0.845334f, 0.836740f, 0.828656f, 0.820817f, 0.812713f, - 0.803960f, 0.794564f, 0.784952f, 0.775633f, 0.766881f, 0.758539f, 0.750156f, 0.741330f, 0.732004f, - 0.722524f, 0.713387f, 0.704919f, 0.697057f, 0.689419f, 0.681576f, 0.673350f, 0.664931f, 0.656703f, - 0.648997f, 0.641801f, 0.634760f, 0.627357f, 0.619192f, 0.610186f, 0.600526f, 0.590442f, 0.579952f, - 0.568762f, 0.556384f, 0.542389f, 0.526648f, 0.509355f, 0.490884f, 0.471542f, 0.451447f, 0.430550f, - 0.408842f, 0.386537f, 0.364126f, 0.342284f, 0.321675f, 0.302809f, 0.286016f, 0.271536f, 0.259639f, - 0.250691f, 0.245099f, 0.243192f}; - - float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = - {1.118974f, 1.115254f, 1.106207f, 1.096903f, 1.092317f, 1.094425f, 1.101145f, 1.107775f, 1.109999f, - 1.106540f, 1.099921f, 1.094912f, 1.095644f, 1.103178f, 1.114952f, 1.126292f, 1.132973f, 1.133288f, - 1.128472f, 1.121439f, 1.114842f, 1.109719f, 1.105481f, 1.100965f, 1.095650f, 1.090072f, 1.085224f, - 1.081527f, 1.078270f, 1.074025f, 1.067775f, 1.059840f, 1.051856f, 1.045772f, 1.042533f, 1.041433f, - 1.040611f, 1.038292f, 1.033911f, 1.028286f, 1.022844f, 1.018512f, 1.015153f, 1.011899f, 1.008050f, - 1.003762f, 0.999995f, 0.997769f, 0.997349f, 0.997959f, 0.998259f, 0.997178f, 0.994509f, 0.990883f, - 0.987204f, 0.984003f, 0.981133f, 0.977983f, 0.973949f, 0.968836f, 0.962914f, 0.956689f, 0.950583f, - 0.944681f, 0.938745f, 0.932399f, 0.925373f, 0.917662f, 0.909567f, 0.901511f, 0.893804f, 0.886456f, - 0.879153f, 0.871467f, 0.863138f, 0.854286f, 0.845334f, 0.836740f, 0.828656f, 0.820816f, 0.812712f, - 0.803961f, 0.794567f, 0.784951f, 0.775631f, 0.766882f, 0.758540f, 0.750158f, 0.741330f, 0.732005f, - 0.722523f, 0.713388f, 0.704920f, 0.697057f, 0.689418f, 0.681575f, 0.673352f, 0.664930f, 0.656706f, - 0.648998f, 0.641802f, 0.634762f, 0.627355f, 0.619192f, 0.610187f, 0.600527f, 0.590442f, 0.579953f, - 0.568763f, 0.556383f, 0.542389f, 0.526646f, 0.509355f, 0.490883f, 0.471543f, 0.451446f, 0.430550f, - 0.408843f, 0.386537f, 0.364127f, 0.342285f, 0.321676f, 0.302809f, 0.286016f, 0.271535f, 0.259640f, - 0.250692f, 0.245099f, 0.243192f}; - - -#else - -const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, - 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, - 1532229,985023,437818,0,0,0,0,0,0, - 0,343865,773496,1203261,2004810,3054258,4103707,4777480,4887673, - 4998000,5066316,4966727,4867271,4767816,4765534,4763253,4760971,4569174, - 4329998,4090822,3659312,3099355,2539533,2037290,1621350,1205543,880065, - 916304,952677,988916,1233058,1477200,1721342,1912602,2090441,2268413, - 2427327,2573490,2719788,2859643,2989834,3120025,3219078,3193576,3168075, - 3142574,2987686,2832665,2677778,2583691,2504771,2425851,2397128,2401692, - 2406255,2356594,2225464,2094333,1933137,1651280,1369423,1087566,924357, - 761148,597940,625051,699677,774302,854295,937779,1021128,1026631, - 915230,803830,670014,446676,223338,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,5100,30735, - 56371,81872,173140,264408,355542,419698,477144,534455,552037, - 543044,533918,485599,378494,271254,173946,115964,57982,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,671,1476,2415,99723,261321,423054,646795, - 963549,1280302,1632087,2124129,2616037,3108080,3841982,4575885,5309922, - 6280181,7309766,8339216,8750996,8750996 -}; -const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269680,9222847,9180350,9155201,9130044,9104894, - 9126688,9148473,9170267,9191549,9212688,9233844,9234423,9221295,9208167, - 9191205,9168497,9145789,9127997,9129884,9131780,9133676,9164823,9195978, - 9227125,9267550,9310290,9353038,9385225,9410374,9435531,9445170,9431538, - 9417907,9399855,9364128,9328409,9292682,9270670,9248667,9226655,9215783, - 9207688,9199593,9183605,9162356,9141108,9116244,9085961,9055678,9028608, - 9014432,9000255,8986078,8975962,8965845,8955728,8926108,8891606,8857103, - 8819145,8778896,8738639,8710806,8701604,8692401,8686227,8692209,8698190, - 8704171,8686706,8669232,8651767,8623917,8593466,8563024,8543554,8531399, - 8519252,8509748,8504203,8498667,8489716,8467083,8444459,8421835,8399773, - 8377711,8355649,8351698,8352268,8352847,8355833,8360430,8365027,8363484, - 8352721,8341959,8331028,8319460,8307884,8296308,8292063,8287827,8283582, - 8271142,8256647,8242159,8221389,8196442,8171494,8150547,8135607,8120659, - 8106465,8095225,8083992,8072760,8043073,8013394,7983706,7949422,7913997, - 7878564,7853893,7836394,7818904,7801472,7784141,7766811,7744782,7703972, - 7663169,7622359,7580802,7539253,7497696,7474266,7455367,7436467,7415496, - 7393140,7370784,7338471,7291235,7244007,7197551,7154232,7110914,7067595, - 7046615,7025627,7004647,6977485,6948779,6920073,6878751,6829015,6779278, - 6733644,6694184,6654724,6618804,6597044,6575284,6553524,6518183,6482842, - 6447501,6401632,6353137,6304634,6267229,6237215,6207201,6181045,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896503,5850198,5825150, - 5805428,5785707,5765742,5745626,5725510,5693398,5643285,5593180,5544358, - 5500720,5457091,5413454,5404126,5394797,5385469,5366930,5346085,5325239, - 5282164,5224274,5166376,5115566,5075376,5035186,5002731,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773822,4700355,4646282,4605153, - 4564023,4540250,4542523,4544788,4536869,4488241,4439612,4390983,4285488, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957300,3691818,3426335,3160861,2774481,2388110,2001740, - 1708239,1437966,1167685,1059581,1059581 -}; -const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269689,9222855,9180358,9155201,9130035,9104869, - 9126663,9148465,9170258,9191540,9212688,9233827,9234415,9221295,9208175, - 9191213,9168488,9145755,9127963,9129867,9131772,9133676,9164831,9195978, - 9227133,9267550,9310281,9353021,9385200,9410357,9435506,9445153,9431522, - 9417899,9399855,9364119,9328384,9292648,9270653,9248658,9226663,9215792, - 9207688,9199593,9183596,9162348,9141100,9116236,9085953,9055678,9028617, - 9014432,9000255,8986070,8975962,8965853,8955745,8926116,8891614,8857103, - 8819145,8778888,8738631,8710789,8701587,8692385,8686219,8692200,8698181, - 8704162,8686697,8669232,8651775,8623917,8593466,8563016,8543546,8531390, - 8519244,8509739,8504203,8498675,8489724,8467100,8444468,8421844,8399773, - 8377703,8355641,8351681,8352252,8352830,8355817,8360414,8365019,8363475, - 8352721,8341959,8331037,8319469,8307893,8296316,8292072,8287835,8283591, - 8271142,8256647,8242151,8221381,8196433,8171494,8150547,8135616,8120676, - 8106482,8095250,8084009,8072777,8043081,8013385,7983698,7949405,7913972, - 7878547,7853876,7836386,7818904,7801481,7784150,7766819,7744790,7703980, - 7663161,7622350,7580793,7539244,7497696,7474258,7455358,7436459,7415487, - 7393132,7370776,7338471,7291244,7244016,7197560,7154241,7110914,7067587, - 7046607,7025627,7004647,6977485,6948770,6920064,6878742,6829006,6779270, - 6733644,6694184,6654724,6618813,6597053,6575301,6553549,6518191,6482842, - 6447492,6401623,6353137,6304643,6267229,6237215,6207201,6181037,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896512,5850207,5825167, - 5805445,5785723,5765750,5745626,5725493,5693382,5643276,5593180,5544375, - 5500729,5457074,5413429,5404109,5394789,5385478,5366939,5346093,5325247, - 5282172,5224282,5166384,5115574,5075384,5035195,5002739,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773814,4700338,4646274,4605153, - 4564023,4540258,4542523,4544788,4536878,4488249,4439612,4390983,4285480, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957292,3691809,3426327,3160844,2774473,2388110,2001740, - 1708239,1437966,1167685,1059573,1059573 -}; -#endif -#endif /*----------------------------------------------------------------------------------* * t-design and SN3D normalization table *----------------------------------------------------------------------------------*/ diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 4551617de..b38743f1a 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -35,11 +35,7 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" -#ifdef FIX_638_ENERGIE_IAC_ROM_TABLES #include "ivas_rom_binaural_crend_head.h" -#else -#include "ivas_rom_rend.h" -#endif /*---------------------------------------------------------------------* * Local structures -- GitLab From 23339b3f9088d030ed0fe68eae923e3951029a47 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:22:57 +0200 Subject: [PATCH 534/692] [cleanup] accept FIX_INV_DIFFUSE_WEIGHT --- lib_com/options.h | 1 - lib_rend/ivas_crend_fx.c | 216 --------------------- lib_rend/ivas_rom_binaural_crend_head.h | 60 ------ lib_rend/ivas_rom_binaural_crend_head_fx.c | 63 ------ lib_rend/ivas_stat_rend.h | 9 - lib_util/hrtf_file_reader.c | 18 -- 6 files changed, 367 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index b61f560ad..b1d305f81 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,7 +113,6 @@ #define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ -#define FIX_INV_DIFFUSE_WEIGHT /* Orange : Fix error in energy compensation in late binaural */ diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 031926546..825ff582e 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -71,10 +71,8 @@ ivas_error ivas_hrtf_init( hHrtf->max_num_ir = 0; hHrtf->max_num_iterations = 0; hHrtf->index_frequency_max_diffuse = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->same_inv_diffuse_weight = 1; move16(); -#endif move32(); move16(); move16(); @@ -83,16 +81,10 @@ ivas_error ivas_hrtf_init( FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = 0; - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = 0; move16(); -#endif hHrtf->num_iterations[i][j] = 0; move16(); hHrtf->pIndex_frequency_max[i][j] = NULL; @@ -111,10 +103,8 @@ ivas_error ivas_hrtf_init( hHrtf->pOut_to_bin_diffuse_im_fx[j] = NULL; } -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->init_from_rom = 1; move16(); -#endif return IVAS_ERR_OK; } @@ -424,24 +414,11 @@ static ivas_error ivas_rend_initCrend_fx( IF( EQ_32( output_Fs, 48000 ) ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[tmp]; // Q15 - } - ELSE - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[tmp]; // Q15 - } - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[tmp][j]; @@ -450,9 +427,7 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_48kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[tmp][j]; @@ -467,24 +442,11 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE IF( EQ_32( output_Fs, 32000 ) ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[tmp]; // Q15 - } - ELSE - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[tmp]; // Q15 - } - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[tmp][j]; @@ -493,9 +455,7 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_32kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[tmp][j]; @@ -510,24 +470,11 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE IF( EQ_32( output_Fs, 16000 ) ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[tmp]; // Q15 - } - ELSE - { - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[tmp]; // Q15 - } - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_BRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[tmp][j]; @@ -536,9 +483,7 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[j][tmp]; -#endif hHrtf->num_iterations[i][j] = CRendBin_Combined_HRIR_num_iterations_16kHz[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[tmp][j]; @@ -572,16 +517,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[i][j]; @@ -617,16 +556,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[i][j]; @@ -663,17 +596,11 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA3_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[i][j]; @@ -717,16 +644,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[i][j]; @@ -762,16 +683,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[i][j]; @@ -808,16 +723,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_HOA2_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[i][j]; @@ -861,16 +770,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_48kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[i][j]; @@ -906,16 +809,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_32kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[i][j]; @@ -952,16 +849,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[j][i]; // Q15 move16(); -#endif hHrtf->num_iterations[i][j] = CRendBin_FOA_HRIR_num_iterations_16kHz[i][j]; hHrtf->pIndex_frequency_max[i][j] = CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[i][j]; @@ -1087,26 +978,12 @@ static ivas_error ivas_rend_initCrend_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" ); } move16(); -#ifndef FIX_INV_DIFFUSE_WEIGHT - - IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) - { - hHrtf->inv_diffuse_weight_fx[i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight_fx[tmp]; // Q15 - } - ELSE - { - hHrtf->inv_diffuse_weight_fx[i] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight_fx[tmp]; // Q15 - } - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight_fx[j][tmp]; move16(); -#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max[tmp][j]; @@ -1115,10 +992,8 @@ static ivas_error ivas_rend_initCrend_fx( } ELSE { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight_fx[j][tmp]; move16(); -#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations[tmp][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max[tmp][j]; @@ -1149,16 +1024,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight_fx[i]; // Q31 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = hSetOfHRTF->hHRTF_hrir_hoa3->inv_diffuse_weight_fx[j][i]; move16(); -#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa3->pIndex_frequency_max[i][j]; @@ -1198,16 +1067,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight_fx[i]; // Q15 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = hSetOfHRTF->hHRTF_hrir_hoa2->inv_diffuse_weight_fx[j][i]; move16(); -#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_hoa2->pIndex_frequency_max[i][j]; @@ -1247,16 +1110,10 @@ static ivas_error ivas_rend_initCrend_fx( FOR( i = 0; i < hHrtf->max_num_ir; i++ ) { -#ifndef FIX_INV_DIFFUSE_WEIGHT - hHrtf->inv_diffuse_weight_fx[i] = hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight_fx[i]; // Q31 - move16(); -#endif FOR( j = 0; j < BINAURAL_CHANNELS; j++ ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->inv_diffuse_weight_fx[j][i] = hSetOfHRTF->hHRTF_hrir_foa->inv_diffuse_weight_fx[j][i]; move16(); -#endif hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_hrir_foa->num_iterations[i][j]; hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_hrir_foa->pIndex_frequency_max[i][j]; @@ -1289,7 +1146,6 @@ static ivas_error ivas_rend_initCrend_fx( } } -#ifdef FIX_INV_DIFFUSE_WEIGHT hHrtf->same_inv_diffuse_weight = 1; for ( i = 0; i < hHrtf->max_num_ir; i++ ) { @@ -1302,7 +1158,6 @@ static ivas_error ivas_rend_initCrend_fx( } } } -#endif pCrend->hHrtfCrend = hHrtf; @@ -1607,15 +1462,10 @@ ivas_error ivas_rend_initCrendWrapper( } hCrend->hTrack = NULL; -#ifdef FIX_INV_DIFFUSE_WEIGHT hCrend->freq_buffer_re_diffuse_fx[0] = NULL; hCrend->freq_buffer_re_diffuse_fx[1] = NULL; hCrend->freq_buffer_im_diffuse_fx[0] = NULL; hCrend->freq_buffer_im_diffuse_fx[1] = NULL; -#else - hCrend->freq_buffer_re_diffuse_fx = NULL; - hCrend->freq_buffer_im_diffuse_fx = NULL; -#endif hCrend->hReverb = NULL; hCrend->reflections = NULL; hCrend->delay_line_rw_index = 0; @@ -1742,7 +1592,6 @@ ivas_error ivas_rend_openCrend( IF( max_total_ir_len > 0 ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT IF( ( hCrend->freq_buffer_re_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -1758,22 +1607,11 @@ ivas_error ivas_rend_openCrend( { hCrend->freq_buffer_re_diffuse_fx[1] = NULL; } -#else - IF( ( hCrend->freq_buffer_re_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } -#endif -#ifdef FIX_INV_DIFFUSE_WEIGHT set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[0], max_total_ir_len ); IF( hCrend->freq_buffer_re_diffuse_fx[1] != NULL ) { set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx[1], max_total_ir_len ); } -#else - set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len ); -#endif -#ifdef FIX_INV_DIFFUSE_WEIGHT IF( ( hCrend->freq_buffer_im_diffuse_fx[0] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); @@ -1789,33 +1627,18 @@ ivas_error ivas_rend_openCrend( { hCrend->freq_buffer_im_diffuse_fx[1] = NULL; } -#else - IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" ); - } -#endif -#ifdef FIX_INV_DIFFUSE_WEIGHT set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[0], max_total_ir_len ); IF( hCrend->freq_buffer_im_diffuse_fx[1] != NULL ) { set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx[1], max_total_ir_len ); } -#else - set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len ); -#endif } ELSE { -#ifdef FIX_INV_DIFFUSE_WEIGHT hCrend->freq_buffer_re_diffuse_fx[0] = NULL; hCrend->freq_buffer_im_diffuse_fx[0] = NULL; hCrend->freq_buffer_re_diffuse_fx[1] = NULL; hCrend->freq_buffer_im_diffuse_fx[1] = NULL; -#else - hCrend->freq_buffer_re_diffuse_fx = NULL; - hCrend->freq_buffer_im_diffuse_fx = NULL; -#endif } max_total_ir_len = add( extract_l( L_shr( L_add( L_shl( Mult_32_32( hHrtf->latency_s_fx, output_Fs ), 1 ), 1 ), 1 ) ), subframe_length ); /*(int16_t) ( hHrtf->latency_s * output_Fs + 0.5f ) + subframe_length;*/ @@ -1956,7 +1779,6 @@ void ivas_rend_closeCrend( free( hCrend->lfe_delay_line_fx ); hCrend->lfe_delay_line_fx = NULL; } -#ifdef FIX_INV_DIFFUSE_WEIGHT IF( hCrend->freq_buffer_re_diffuse_fx[0] != NULL ) { free( hCrend->freq_buffer_re_diffuse_fx[0] ); @@ -1980,18 +1802,6 @@ void ivas_rend_closeCrend( free( hCrend->freq_buffer_im_diffuse_fx[1] ); hCrend->freq_buffer_im_diffuse_fx[1] = NULL; } -#else - IF( hCrend->freq_buffer_re_diffuse_fx != NULL ) - { - free( hCrend->freq_buffer_re_diffuse_fx ); - hCrend->freq_buffer_re_diffuse_fx = NULL; - } - IF( hCrend->freq_buffer_im_diffuse_fx != NULL ) - { - free( hCrend->freq_buffer_im_diffuse_fx ); - hCrend->freq_buffer_im_diffuse_fx = NULL; - } -#endif IF( hCrend->hTrack != NULL ) { free( hCrend->hTrack ); @@ -2074,9 +1884,7 @@ static ivas_error ivas_rend_crendConvolver( Word16 nchan_in, nchan_out; const Word32 *pIn; Word32 *pFreq_buf_re, *pFreq_buf_im; -#ifdef FIX_INV_DIFFUSE_WEIGHT Word32 *pFreq_buf2_re, *pFreq_buf2_im; -#endif const Word32 *pFreq_filt_re, *pFreq_filt_im; Word32 pOut[L_FRAME48k * 2]; Word32 tmp_out_re[L_FRAME48k]; @@ -2119,7 +1927,6 @@ static ivas_error ivas_rend_crendConvolver( IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT set32_fx( &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse], 0, subframe_length ); set32_fx( &hCrend->freq_buffer_im_diffuse_fx[0][offset_diffuse], 0, subframe_length ); if ( pCrend->hHrtfCrend->same_inv_diffuse_weight == 0 ) @@ -2127,10 +1934,6 @@ static ivas_error ivas_rend_crendConvolver( set32_fx( &hCrend->freq_buffer_re_diffuse_fx[1][offset_diffuse], 0, subframe_length ); set32_fx( &hCrend->freq_buffer_im_diffuse_fx[1][offset_diffuse], 0, subframe_length ); } -#else - set32_fx( &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse], 0, subframe_length ); - set32_fx( &hCrend->freq_buffer_im_diffuse_fx[offset_diffuse], 0, subframe_length ); -#endif } i = 0; @@ -2143,7 +1946,6 @@ static ivas_error ivas_rend_crendConvolver( { IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 ) { -#ifdef FIX_INV_DIFFUSE_WEIGHT IF( pCrend->hHrtfCrend->same_inv_diffuse_weight ) { pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse]; @@ -2180,19 +1982,6 @@ static ivas_error ivas_rend_crendConvolver( move32(); } } -#else - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse]; // Qx - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[offset_diffuse]; // Qx - pFreq_filt_re = &hCrend->freq_buffer_re_fx[i][offset]; // Qx - pFreq_filt_im = &hCrend->freq_buffer_im_fx[i][offset]; // Qx - FOR( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ ) - { - pFreq_buf_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[i] ), pFreq_buf_re[k] ); // Qx - pFreq_buf_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[i] ), pFreq_buf_im[k] ); // Qx - move32(); - move32(); - } -#endif } pFreq_buf_re = &hCrend->freq_buffer_re_fx[i][offset]; // Qx pFreq_buf_im = &hCrend->freq_buffer_im_fx[i][offset]; // Qx @@ -2253,7 +2042,6 @@ static ivas_error ivas_rend_crendConvolver( index_in = index_in % pCrend->hHrtfCrend->num_iterations_diffuse[0]; move16(); offset_diffuse = L_mult0( index_in, subframe_length ); -#ifdef FIX_INV_DIFFUSE_WEIGHT if ( pCrend->hHrtfCrend->same_inv_diffuse_weight ) { pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse]; @@ -2264,10 +2052,6 @@ static ivas_error ivas_rend_crendConvolver( pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[j][offset_diffuse]; pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[j][offset_diffuse]; } -#else - pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse]; // Qx - pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[offset_diffuse]; // Qx -#endif pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re_fx[j][offset]; // Q31 pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im_fx[j][offset]; // Q31 FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ ) diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 0a8e3b7c6..30d9cbb24 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -61,11 +61,7 @@ extern UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_Combined_HRIR_coeff_im_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][240]; @@ -79,11 +75,7 @@ extern UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_Combined_HRIR_coeff_im_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][160]; @@ -97,11 +89,7 @@ extern UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_Combined_HRIR_coeff_re_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_Combined_HRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][80]; @@ -122,11 +110,7 @@ extern UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[FOA_CHANNELS][BINAURAL_CHA extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]; -#else -extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[FOA_CHANNELS]; -#endif extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_48kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_FOA_HRIR_coeff_im_48kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][240]; @@ -140,11 +124,7 @@ extern UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[FOA_CHANNELS][BINAURAL_CHA extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]; -#else -extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[FOA_CHANNELS]; -#endif extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_32kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_FOA_HRIR_coeff_im_32kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][160]; @@ -158,11 +138,7 @@ extern UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[FOA_CHANNELS][BINAURAL_CHA extern UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]; -#else -extern Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[FOA_CHANNELS]; -#endif extern UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_FOA_HRIR_coeff_re_16kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_FOA_HRIR_coeff_im_16kHz_fx[FOA_CHANNELS][BINAURAL_CHANNELS][80]; @@ -182,11 +158,7 @@ extern UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[HOA2_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]; -#else -extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[HOA2_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_48kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_48kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][240]; @@ -200,11 +172,7 @@ extern UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[HOA2_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]; -#else -extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[HOA2_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_32kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_32kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][160]; @@ -218,11 +186,7 @@ extern UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[HOA2_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]; -#else -extern Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[HOA2_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA2_HRIR_coeff_re_16kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA2_HRIR_coeff_im_16kHz_fx[HOA2_CHANNELS][BINAURAL_CHANNELS][80]; @@ -241,11 +205,7 @@ extern UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[HOA3_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HOA3_CHANNELS]; -#else -extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[HOA3_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_48kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_48kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][240]; @@ -259,11 +219,7 @@ extern UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[HOA3_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HOA3_CHANNELS]; -#else -extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[HOA3_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_32kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_32kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][160]; @@ -277,11 +233,7 @@ extern UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[HOA3_CHANNELS][BINAURAL_C extern UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]; extern UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HOA3_CHANNELS]; -#else -extern Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[HOA3_CHANNELS]; -#endif extern UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]; extern Word32 CRendBin_HOA3_HRIR_coeff_re_16kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][80]; extern Word32 CRendBin_HOA3_HRIR_coeff_im_16kHz_fx[HOA3_CHANNELS][BINAURAL_CHANNELS][80]; @@ -301,11 +253,7 @@ extern UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]; extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; extern Word32 CRendBin_Combined_BRIR_coeff_im_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955]; @@ -319,11 +267,7 @@ extern UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]; extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2819]; extern Word32 CRendBin_Combined_BRIR_coeff_im_32kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2819]; @@ -337,11 +281,7 @@ extern UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BIN extern UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS]; extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][23]; extern UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz; -#ifdef FIX_INV_DIFFUSE_WEIGHT extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]; -#else -extern Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[HRTF_LS_CHANNELS]; -#endif extern UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]; extern Word32 CRendBin_Combined_BRIR_coeff_re_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1774]; extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1774]; diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index bdf8e0252..866a70c97 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -61,11 +61,7 @@ const UWord16 CRendBin_Combined_HRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_48kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_48kHz_fx[HRTF_LS_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -76,11 +72,7 @@ const UWord16 CRendBin_Combined_HRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_32kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_32kHz_fx[HRTF_LS_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -#endif const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -91,11 +83,7 @@ const UWord16 CRendBin_Combined_HRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_Combined_HRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const UWord16 CRendBin_Combined_HRIR_index_frequency_max_diffuse_16kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_Combined_HRIR_inv_diffuse_weight_16kHz_fx[HRTF_LS_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,}; -#endif const UWord16 *CRendBin_Combined_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_Combined_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -113,11 +101,7 @@ const UWord16 CRendBin_FOA_HRIR_num_iterations_48kHz[FOA_CHANNELS][BINAURAL_CHAN const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_48kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_48kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]={{0, 0, 0, 0},{0, 0, 0, 0}}; -#else -const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_48kHz_fx[FOA_CHANNELS]={0, 0, 0, 0}; -#endif const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -128,11 +112,7 @@ const UWord16 CRendBin_FOA_HRIR_num_iterations_32kHz[FOA_CHANNELS][BINAURAL_CHAN const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_32kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_32kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]={{0, 0, 0, 0},{0, 0, 0, 0}}; -#else -const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_32kHz_fx[FOA_CHANNELS]={0, 0, 0, 0}; -#endif const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -143,11 +123,7 @@ const UWord16 CRendBin_FOA_HRIR_num_iterations_16kHz[FOA_CHANNELS][BINAURAL_CHAN const UWord16 CRendBin_FOA_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_FOA_HRIR_pIndex_frequency_max_16kHz[FOA_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const UWord16 CRendBin_FOA_HRIR_index_frequency_max_diffuse_16kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][FOA_CHANNELS]={{0, 0, 0, 0},{0, 0, 0, 0}}; -#else -const Word16 CRendBin_FOA_HRIR_inv_diffuse_weight_16kHz_fx[FOA_CHANNELS]={0, 0, 0, 0}; -#endif const UWord16 *CRendBin_FOA_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_FOA_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -164,11 +140,7 @@ const UWord16 CRendBin_HOA2_HRIR_num_iterations_48kHz[HOA2_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_48kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_48kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_48kHz_fx[HOA2_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -179,11 +151,7 @@ const UWord16 CRendBin_HOA2_HRIR_num_iterations_32kHz[HOA2_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_32kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_32kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_32kHz_fx[HOA2_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -194,11 +162,7 @@ const UWord16 CRendBin_HOA2_HRIR_num_iterations_16kHz[HOA2_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA2_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA2_HRIR_pIndex_frequency_max_16kHz[HOA2_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const UWord16 CRendBin_HOA2_HRIR_index_frequency_max_diffuse_16kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HOA2_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_HOA2_HRIR_inv_diffuse_weight_16kHz_fx[HOA2_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_HOA2_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA2_HRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -214,11 +178,7 @@ const UWord16 CRendBin_HOA3_HRIR_num_iterations_48kHz[HOA3_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_48kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}},{{240},{240}}}; const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_48kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_48kHz_fx[HOA3_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_48kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -229,11 +189,7 @@ const UWord16 CRendBin_HOA3_HRIR_num_iterations_32kHz[HOA3_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_32kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}},{{160},{160}}}; const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_32kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_32kHz_fx[HOA3_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -#endif const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_im_32kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -244,11 +200,7 @@ const UWord16 CRendBin_HOA3_HRIR_num_iterations_16kHz[HOA3_CHANNELS][BINAURAL_CH const UWord16 CRendBin_HOA3_HRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {0, 0}; const UWord16 CRendBin_HOA3_HRIR_pIndex_frequency_max_16kHz[HOA3_CHANNELS][BINAURAL_CHANNELS][1]={{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}},{{80},{80}}}; const UWord16 CRendBin_HOA3_HRIR_index_frequency_max_diffuse_16kHz = 0; -#ifdef FIX_INV_DIFFUSE_WEIGHT const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HOA3_CHANNELS]={{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; -#else -const float CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz[HOA3_CHANNELS]={0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f, 0.000000f}; -#endif const Word16 CRendBin_HOA3_HRIR_inv_diffuse_weight_16kHz_fx[HOA3_CHANNELS]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; const UWord16 *CRendBin_HOA3_HRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS]={NULL,NULL}; const Word32 *CRendBin_HOA3_HRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS]={NULL,NULL}; @@ -265,13 +217,8 @@ const UWord16 CRendBin_Combined_BRIR_num_iterations_48kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_48kHz[BINAURAL_CHANNELS] = {40, 40}; const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_48kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]={{{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240},{116, 118, 117, 121, 112, 119, 121, 131, 134, 131, 137, 127, 134, 135, 134, 135, 129, 139, 135, 130, 128, 240}},{{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240},{122, 106, 121, 114, 121, 123, 119, 126, 123, 126, 127, 130, 128, 136, 132, 131, 129, 141, 137, 131, 129, 240}},{{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240},{118, 104, 116, 104, 123, 123, 122, 125, 130, 128, 132, 135, 131, 132, 131, 132, 135, 137, 144, 129, 129, 240}},{{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240},{102, 117, 116, 121, 117, 114, 115, 125, 126, 124, 125, 142, 133, 124, 129, 132, 134, 137, 143, 125, 125, 240}},{{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240},{116, 115, 117, 120, 121, 119, 125, 129, 123, 129, 124, 127, 128, 143, 133, 131, 136, 141, 158, 127, 131, 240}},{{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240},{112, 106, 118, 123, 115, 120, 129, 123, 130, 127, 130, 130, 131, 131, 131, 135, 134, 153, 138, 132, 127, 240}},{{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240},{107, 112, 111, 120, 115, 125, 122, 123, 132, 123, 133, 138, 125, 134, 130, 131, 135, 137, 136, 127, 121, 240}},{{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240},{111, 113, 132, 115, 121, 123, 121, 127, 135, 128, 129, 128, 133, 130, 133, 138, 134, 137, 152, 138, 124, 240}},{{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240},{114, 104, 114, 117, 125, 127, 123, 129, 123, 127, 144, 131, 138, 132, 129, 129, 132, 134, 136, 127, 121, 240}},{{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240},{100, 102, 112, 118, 115, 116, 118, 116, 121, 124, 125, 121, 125, 130, 127, 132, 133, 134, 134, 129, 132, 240}},{{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240},{106, 93, 103, 108, 124, 111, 114, 115, 120, 121, 119, 123, 131, 130, 132, 132, 132, 131, 140, 129, 131, 240}},{{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240},{108, 101, 115, 115, 115, 110, 121, 124, 124, 120, 122, 129, 124, 128, 125, 132, 135, 133, 138, 160, 119, 240}},{{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240},{112, 106, 114, 110, 128, 117, 120, 126, 124, 128, 126, 132, 129, 127, 133, 134, 136, 133, 154, 197, 129, 240}},{{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240},{102, 107, 111, 116, 116, 120, 118, 115, 120, 119, 128, 131, 131, 130, 128, 126, 126, 132, 145, 136, 133, 240}},{{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240},{111, 117, 106, 120, 123, 121, 125, 125, 130, 125, 123, 123, 127, 131, 125, 131, 135, 134, 148, 134, 132, 240}}}; const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_48kHz = 98; -#ifdef FIX_INV_DIFFUSE_WEIGHT const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f},{0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907},{7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907}}; -#else -const float CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz[HRTF_LS_CHANNELS]={0.224183f, 0.227455f, 0.241830f, 0.207155f, 0.218087f, 0.222942f, 0.232158f, 0.248203f, 0.249262f, 0.261591f, 0.246276f, 0.279163f, 0.285701f, 0.262541f, 0.271844f}; -const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_48kHz_fx[HRTF_LS_CHANNELS]={7346, 7453, 7924, 6788, 7146, 7305, 7607, 8133, 8167, 8571, 8069, 9147, 9361, 8602, 8907}; -#endif const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_48kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98},{47, 47, 47, 47, 47, 47, 51, 51, 58, 58, 58, 65, 65, 65, 65, 65, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 91, 91, 93, 93, 93, 98}}; /* Sample Rate = 32000 */ @@ -280,13 +227,8 @@ const UWord16 CRendBin_Combined_BRIR_num_iterations_32kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_32kHz[BINAURAL_CHANNELS] = {40, 40}; const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_32kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][22]={{{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160},{115, 117, 117, 120, 112, 118, 121, 130, 126, 130, 136, 127, 133, 135, 132, 133, 129, 137, 134, 129, 128, 160}},{{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160},{121, 106, 119, 113, 120, 123, 114, 126, 123, 125, 127, 128, 127, 134, 132, 130, 129, 139, 133, 131, 128, 160}},{{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160},{113, 103, 116, 104, 123, 123, 122, 124, 130, 128, 132, 131, 131, 132, 130, 132, 130, 135, 137, 128, 128, 160}},{{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160},{102, 116, 116, 121, 116, 114, 115, 121, 125, 123, 124, 130, 132, 122, 127, 131, 131, 135, 133, 124, 125, 160}},{{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160},{115, 115, 115, 119, 121, 119, 125, 127, 123, 129, 122, 126, 128, 134, 130, 130, 131, 140, 146, 127, 131, 160}},{{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160},{112, 106, 118, 121, 115, 117, 129, 123, 128, 126, 130, 130, 131, 131, 130, 134, 133, 149, 130, 132, 126, 160}},{{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160},{107, 112, 110, 119, 114, 124, 121, 121, 132, 122, 131, 134, 124, 133, 130, 129, 134, 134, 135, 127, 120, 160}},{{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160},{110, 113, 123, 113, 121, 120, 120, 126, 131, 123, 128, 128, 132, 130, 132, 136, 133, 136, 135, 128, 124, 160}},{{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160},{114, 101, 113, 113, 124, 126, 123, 128, 122, 127, 132, 127, 136, 128, 128, 127, 132, 132, 129, 125, 120, 160}},{{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160},{99, 100, 111, 117, 114, 114, 118, 116, 121, 124, 124, 121, 125, 130, 127, 132, 132, 130, 133, 128, 131, 160}},{{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160},{105, 93, 103, 108, 119, 110, 111, 114, 120, 121, 119, 122, 130, 128, 130, 131, 132, 131, 136, 128, 128, 160}},{{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160},{105, 100, 112, 114, 115, 108, 117, 120, 123, 117, 122, 129, 124, 128, 124, 132, 135, 131, 139, 153, 116, 160}},{{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160},{110, 106, 113, 110, 122, 116, 119, 125, 123, 128, 125, 127, 128, 127, 133, 130, 132, 132, 143, 155, 127, 160}},{{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160},{102, 107, 110, 112, 115, 117, 117, 115, 120, 118, 127, 130, 130, 129, 126, 126, 125, 130, 141, 135, 127, 160}},{{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160},{110, 117, 106, 118, 118, 116, 121, 124, 128, 125, 122, 122, 126, 131, 124, 130, 133, 131, 139, 134, 131, 160}}}; const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_32kHz = 97; -#ifdef FIX_INV_DIFFUSE_WEIGHT const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.224190f, 0.227445f, 0.241827f, 0.207131f, 0.218113f, 0.222941f, 0.232139f, 0.248192f, 0.249239f, 0.261572f, 0.246309f, 0.279145f, 0.285786f, 0.262528f, 0.271847f},{0.224190f, 0.227445f, 0.241827f, 0.207131f, 0.218113f, 0.222941f, 0.232139f, 0.248192f, 0.249239f, 0.261572f, 0.246309f, 0.279145f, 0.285786f, 0.262528f, 0.271847f}}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907},{7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}}; -#else -const float CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz[HRTF_LS_CHANNELS]={0.224190f, 0.227445f, 0.241827f, 0.207131f, 0.218113f, 0.222941f, 0.232139f, 0.248192f, 0.249239f, 0.261572f, 0.246309f, 0.279145f, 0.285786f, 0.262528f, 0.271847f}; -const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_32kHz_fx[HRTF_LS_CHANNELS]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}; -#endif const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_32kHz[BINAURAL_CHANNELS][40]={{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97},{47, 47, 47, 47, 47, 47, 50, 50, 56, 56, 56, 63, 63, 63, 63, 63, 72, 72, 72, 74, 74, 77, 77, 79, 81, 81, 81, 81, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 97}}; /* Sample Rate = 16000 */ @@ -295,13 +237,8 @@ const UWord16 CRendBin_Combined_BRIR_num_iterations_16kHz[HRTF_LS_CHANNELS][BINA const UWord16 CRendBin_Combined_BRIR_num_iterations_diffuse_16kHz[BINAURAL_CHANNELS] = {40, 40}; const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_16kHz[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][23]={{{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80},{77, 76, 77, 77, 77, 76, 77, 76, 77, 76, 77, 77, 77, 78, 76, 76, 77, 77, 77, 77, 77, 76, 80}},{{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80},{76, 77, 77, 75, 77, 78, 77, 76, 77, 77, 76, 77, 77, 77, 77, 77, 76, 77, 76, 76, 77, 78, 80}},{{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80},{77, 76, 76, 78, 75, 76, 74, 78, 77, 76, 77, 77, 77, 76, 76, 77, 78, 78, 77, 77, 77, 77, 80}},{{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80},{76, 76, 76, 76, 77, 77, 76, 78, 77, 77, 77, 77, 78, 78, 77, 77, 77, 77, 77, 78, 77, 78, 80}},{{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80},{76, 77, 77, 76, 77, 77, 75, 77, 77, 77, 76, 77, 77, 77, 77, 78, 77, 77, 77, 77, 76, 76, 80}},{{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80},{77, 76, 77, 77, 77, 77, 77, 77, 76, 78, 76, 78, 75, 76, 77, 77, 76, 76, 77, 78, 78, 77, 80}},{{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80},{77, 77, 75, 76, 76, 77, 77, 77, 77, 77, 77, 75, 77, 76, 76, 76, 77, 77, 76, 77, 76, 77, 80}},{{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80},{75, 76, 77, 77, 75, 77, 75, 76, 76, 77, 77, 77, 78, 78, 77, 77, 76, 77, 78, 78, 78, 76, 80}},{{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80},{77, 77, 77, 76, 77, 77, 76, 76, 76, 77, 77, 75, 76, 78, 78, 77, 77, 78, 78, 77, 76, 76, 80}},{{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80},{76, 75, 76, 76, 77, 77, 77, 77, 77, 77, 74, 78, 77, 78, 78, 77, 76, 77, 77, 77, 77, 76, 80}},{{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80},{76, 76, 77, 76, 77, 77, 76, 76, 76, 76, 77, 77, 76, 76, 77, 75, 77, 76, 76, 76, 77, 77, 80}},{{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80},{76, 76, 77, 75, 78, 77, 77, 77, 77, 77, 77, 77, 77, 76, 78, 77, 76, 78, 76, 77, 76, 77, 80}},{{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80},{76, 77, 77, 76, 76, 77, 77, 75, 77, 77, 77, 77, 77, 77, 78, 78, 78, 78, 77, 76, 76, 78, 80}},{{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80},{74, 76, 74, 76, 75, 76, 76, 76, 76, 77, 77, 78, 77, 78, 75, 76, 77, 76, 78, 76, 78, 77, 80}},{{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80},{76, 77, 77, 77, 76, 78, 77, 76, 75, 77, 77, 77, 76, 78, 77, 78, 78, 78, 77, 76, 77, 75, 80}}}; const UWord16 CRendBin_Combined_BRIR_index_frequency_max_diffuse_16kHz = 77; -#ifdef FIX_INV_DIFFUSE_WEIGHT const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{0.223532f, 0.226827f, 0.248830f, 0.208782f, 0.220391f, 0.219790f, 0.231187f, 0.248730f, 0.251408f, 0.263698f, 0.243858f, 0.281483f, 0.283080f, 0.261660f, 0.273527f},{0.223532f, 0.226827f, 0.248830f, 0.208782f, 0.220391f, 0.219790f, 0.231187f, 0.248730f, 0.251408f, 0.263698f, 0.243858f, 0.281483f, 0.283080f, 0.261660f, 0.273527f}}; const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[BINAURAL_CHANNELS][HRTF_LS_CHANNELS]={{7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907},{7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}}; -#else -const float CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz[HRTF_LS_CHANNELS]={0.223532f, 0.226827f, 0.248830f, 0.208782f, 0.220391f, 0.219790f, 0.231187f, 0.248730f, 0.251408f, 0.263698f, 0.243858f, 0.281483f, 0.283080f, 0.261660f, 0.273527f}; -const Word16 CRendBin_Combined_BRIR_inv_diffuse_weight_16kHz_fx[HRTF_LS_CHANNELS]={7346, 7452, 7924, 6787, 7147, 7305, 7606, 8132, 8167, 8571, 8071, 9147, 9364, 8602, 8907}; -#endif const UWord16 CRendBin_Combined_BRIR_pIndex_frequency_max_diffuse_16kHz[BINAURAL_CHANNELS][40]={{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77},{46, 46, 46, 46, 46, 46, 46, 49, 49, 53, 53, 53, 55, 55, 61, 61, 61, 65, 67, 67, 67, 67, 67, 67, 69, 72, 72, 72, 73, 73, 75, 75, 75, 75, 75, 75, 75, 75, 75, 77}}; //BRIR and HRIR coeff tables in Q29 const Word32 CRendBin_Combined_BRIR_coeff_re_48kHz_fx[HRTF_LS_CHANNELS][BINAURAL_CHANNELS][2955] ={ diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 963d6dd8d..50e3d7f6c 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1336,12 +1336,8 @@ typedef struct ivas_hrtfs_structure UWord16 index_frequency_max_diffuse; Word16 max_num_ir; Word16 max_num_iterations; -#ifdef FIX_INV_DIFFUSE_WEIGHT Word16 inv_diffuse_weight_fx[BINAURAL_CHANNELS][MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] */ Word16 same_inv_diffuse_weight; -#else - Word16 inv_diffuse_weight_fx[MAX_INTERN_CHANNELS]; /* inverse diffuse weights array, access one inverse weight by pInvDiffuseWeight[channel] Q15 */ -#endif Word32 latency_s_fx; Word16 init_from_rom; Word16 gain_lfe_fx; // Q14 @@ -1351,13 +1347,8 @@ typedef struct ivas_crend_state_t { Word32 *freq_buffer_re_fx[MAX_INTERN_CHANNELS]; Word32 *freq_buffer_im_fx[MAX_INTERN_CHANNELS]; -#ifdef FIX_INV_DIFFUSE_WEIGHT Word32 *freq_buffer_re_diffuse_fx[BINAURAL_CHANNELS]; Word32 *freq_buffer_im_diffuse_fx[BINAURAL_CHANNELS]; -#else - Word32 *freq_buffer_re_diffuse_fx; - Word32 *freq_buffer_im_diffuse_fx; -#endif Word32 *prev_out_buffer_fx[BINAURAL_CHANNELS]; Word32 *lfe_delay_line_fx; Word32 m_fYaw_fx; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index b38743f1a..8b5dadf39 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -1294,7 +1294,6 @@ static ivas_error create_HRTF_from_rawdata( /* inv_diffuse_weight */ #ifdef USE_NEW_HRTF_BINARY_FILE_FORMAT -#ifdef FIX_INV_DIFFUSE_WEIGHT for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { ( *hHRTF )->inv_diffuse_weight_fx[0][i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); @@ -1306,15 +1305,6 @@ static ivas_error create_HRTF_from_rawdata( hrtf_data_rptr += sizeof( float ); } #else - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight_fx[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); - hrtf_data_rptr += sizeof( float ); - } - hrtf_data_rptr += sizeof( float ) * ( *hHRTF )->max_num_ir; -#endif -#else -#ifdef FIX_INV_DIFFUSE_WEIGHT /* inv_diffuse_weight */ for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) { @@ -1322,14 +1312,6 @@ static ivas_error create_HRTF_from_rawdata( ( *hHRTF )->inv_diffuse_weight_fx[1][i] = ( *hHRTF )->inv_diffuse_weight[0][i]; hrtf_data_rptr += sizeof( float ); } -#else - /* inv_diffuse_weight */ - for ( i = 0; i < ( *hHRTF )->max_num_ir; i++ ) - { - ( *hHRTF )->inv_diffuse_weight[i] = (Word16) ( *( (float *) ( hrtf_data_rptr ) ) * ONE_IN_Q15 ); - hrtf_data_rptr += sizeof( float ); - } -#endif #endif /* max_total_num_fsamp_per_iteration */ -- GitLab From 1adaa7f6966e297006d09ad2950bdce48bee12e2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:23:00 +0200 Subject: [PATCH 535/692] [cleanup] accept NONBE_FIX_AVG_IAC_CLDFB_REVERB --- lib_com/ivas_cnst.h | 4 - lib_com/options.h | 1 - lib_rend/ivas_hrtf_fx.c | 18 -- lib_rend/ivas_objectRenderer_mix_fx.c | 6 - lib_rend/ivas_reverb_fx.c | 11 - lib_rend/ivas_reverb_utils_fx.c | 4 - lib_rend/ivas_rom_binaural_crend_head.h | 14 - lib_rend/ivas_rom_binaural_crend_head_fx.c | 285 --------------------- lib_util/hrtf_file_reader.c | 39 --- 9 files changed, 382 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 8e5d0d626..06d8fa323 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1743,15 +1743,11 @@ typedef enum #define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */ #define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1 -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define RV_LENGTH_NR_FC_16KHZ ( RV_FILTER_MAX_FFT_SIZE / 4 ) + 1 -#endif #define IVAS_REVERB_DEFAULT_N_BANDS 31 #define LR_IAC_LENGTH_NR_FC ( RV_LENGTH_NR_FC ) -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #define LR_IAC_LENGTH_NR_FC_16KHZ ( RV_LENGTH_NR_FC_16KHZ ) -#endif /*----------------------------------------------------------------------------------* * FB mixer constants diff --git a/lib_com/options.h b/lib_com/options.h index b1d305f81..1bb60b341 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,6 @@ #define FIX_1372_ISAR_POST_REND #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ #ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM -#define NONBE_FIX_AVG_IAC_CLDFB_REVERB #endif #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index 7a81b7946..da862b51b 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -284,7 +284,6 @@ ivas_error ivas_HRTF_statistics_init( switch ( sampleRate ) { -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB case 48000: HrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( Word32 ) ); if ( HrtfStatistics->average_energy_l_dyn == NULL ) @@ -354,23 +353,6 @@ ivas_error ivas_HRTF_statistics_init( HrtfStatistics->average_energy_r = (const Word32 *) HrtfStatistics->average_energy_r_dyn; HrtfStatistics->inter_aural_coherence = (const Word32 *) HrtfStatistics->inter_aural_coherence_dyn; break; -#else - case 48000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_48kHz_fx; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_48kHz_fx; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_48kHz_fx; - break; - case 32000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_32kHz_fx; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_32kHz_fx; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_32kHz_fx; - break; - case 16000: - HrtfStatistics->average_energy_l = defaultHRIR_left_avg_power_16kHz_fx; - HrtfStatistics->average_energy_r = defaultHRIR_right_avg_power_16kHz_fx; - HrtfStatistics->inter_aural_coherence = defaultHRIR_coherence_16kHz_fx; - break; -#endif } HrtfStatistics->fromROM = TRUE; diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index b267044b1..cb6e3a3fe 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -422,7 +422,6 @@ static ivas_error DefaultBSplineModel_fx( HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_32kHz_fx; // Q23 BREAK; case 16000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB for ( i = 0; i < 3; i++ ) { HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); @@ -437,11 +436,6 @@ static ivas_error DefaultBSplineModel_fx( HrFiltSet_p->lr_energy_and_iac_fx[0] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[0]; HrFiltSet_p->lr_energy_and_iac_fx[1] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[1]; HrFiltSet_p->lr_energy_and_iac_fx[2] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[2]; -#else - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_16kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_16kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_16kHz_fx; // Q23 -#endif BREAK; } #endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index d7dd26ec3..e886bfeab 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1652,17 +1652,10 @@ ivas_error ivas_reverb_open_fx( { params.pDsr_fx[i] = L_shl( params.pDsr_fx[i], params.pDsr_e[i] ); move32(); -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB pHrtf_avg_pwr_response_l_const[i] = params.pHrtf_avg_pwr_response_l_const_fx[i]; /*Q28*/ move32(); pHrtf_avg_pwr_response_r_const[i] = params.pHrtf_avg_pwr_response_r_const_fx[i]; /*Q23+5*/ move32(); -#else - pHrtf_avg_pwr_response_l_const[i] = L_shl( params.pHrtf_avg_pwr_response_l_const_fx[i], 5 ); /*Q23+5*/ - move32(); - pHrtf_avg_pwr_response_r_const[i] = L_shl( params.pHrtf_avg_pwr_response_r_const_fx[i], 5 ); /*Q23+5*/ - move32(); -#endif } FOR( i = 0; i < lenT60_filter_coeff; i++ ) { @@ -1710,11 +1703,7 @@ ivas_error ivas_reverb_open_fx( Word32 *pHrtf_inter_aural_coherence_const = (Word32 *) malloc( nr_fc_fft_filter * sizeof( Word32 ) ); FOR( i = 0; i < nr_fc_fft_filter; i++ ) { -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB pHrtf_inter_aural_coherence_const[i] = L_shl( params.pHrtf_inter_aural_coherence_const_fx[i], 3 ); /*Scaling up to Q30*/ -#else - pHrtf_inter_aural_coherence_const[i] = params.pHrtf_inter_aural_coherence_const_fx[i]; /*Scaling up to Q30*/ -#endif move32(); } ivas_reverb_calc_correl_filters_fx( pHrtf_inter_aural_coherence_const, pTime_window_fx, pState->fft_size, pFft_wf_filter_ch0_fx, pFft_wf_filter_ch1_fx, &q_pFft_wf_filter_ch0_fx, &q_pFft_wf_filter_ch1_fx ); diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 2c61d54df..e63e6017a 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -320,11 +320,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( #endif #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; -#else - const int16_t avg_pwr_len = LR_IAC_LENGTH_NR_FC; -#endif for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) { diff --git a/lib_rend/ivas_rom_binaural_crend_head.h b/lib_rend/ivas_rom_binaural_crend_head.h index 30d9cbb24..77d54a5d3 100644 --- a/lib_rend/ivas_rom_binaural_crend_head.h +++ b/lib_rend/ivas_rom_binaural_crend_head.h @@ -288,7 +288,6 @@ extern Word32 CRendBin_Combined_BRIR_coeff_im_16kHz_fx[HRTF_LS_CHANNELS][BINAURA extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_re_16kHz_fx[BINAURAL_CHANNELS][2522]; extern Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS][2522]; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB extern float defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ extern float defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ extern float defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ @@ -300,18 +299,5 @@ extern float defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23* extern float defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-27*/ extern float defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ extern float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ]; /*Q-23*/ -#else -extern const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ - -extern const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ - -extern const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-27*/ -extern const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -extern const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC]; /*Q-23*/ -#endif #endif /* _IVAS_ROM_BINAURAL_CREND_HEAD_ */ diff --git a/lib_rend/ivas_rom_binaural_crend_head_fx.c b/lib_rend/ivas_rom_binaural_crend_head_fx.c index 866a70c97..a14d75137 100644 --- a/lib_rend/ivas_rom_binaural_crend_head_fx.c +++ b/lib_rend/ivas_rom_binaural_crend_head_fx.c @@ -59588,7 +59588,6 @@ const Word32 CRendBin_Combined_BRIR_coeff_diffuse_im_16kHz_fx[BINAURAL_CHANNELS] }; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB /********************** defaultHRIR reverb rom tables at sampling rate 48kHz **********************/ const float defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] = @@ -59836,290 +59835,6 @@ const float defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC_16KHZ] = 0.250692f, 0.245099f, 0.243192f}; -#else - -const Word32 defaultHRIR_coherence_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 131936432,125285536,105934832,77097344,45729324,19356880,2523696,0,0, - 0,1602425,4763253,5796595,5698884,5608690,5175704,3880368,2303444, - 1553033,1902670,2661537,3300414,3919560,4475624,4485288,3976468,3688169, - 3682129,3375844,2619661,1976758,1906026,2165066,2186943,1765500,1162325, - 671759,348160,140123,27783,0,0,0,148981,534991, - 939926,1281242,1547798,1665910,1550617,1228897,835102,478486,185757, - 0,0,0,0,4294,124554,284273,410840,479828, - 507343,493652,417417,278367,114890,0,0,0,0, - 0,0,0,0,0,29125,130728,242531,313264, - 326954,282528,204816,121735,46976,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,31943,114353,173543, - 205218,205755,176362,128043,69927,20803,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,3355,38117,83214,127372,170993,215553,257966, - 294607,327222,360643,395137,425738,452447,480096,507208,525462, - 533247,534186,526804,505463,469896,424799,372856,312190,242397, - 168711,95831,28319,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,102810,72074,0, - 226962,443858,219445,0,214882,1013209,77846,0,273535, - 1385798,289239,0,472983,1241648,688671,0,306821,870536, - 792153,0,115695,613375,552574,0,0,434462,205890, - 34762,26709,182938,117843,0 -}; -const Word32 defaultHRIR_left_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8209721,8156956,8050127,7984940,7992858,8011649,7974747,7910306,7917252, - 8038476,8174723,8228729,8192717,8124794,8070352,8029995,7989956,7953608, - 7931152,7912210,7870745,7803402,7745101,7727896,7735563,7724331,7693670, - 7672548,7668253,7662666,7647508,7638633,7652147,7680265,7699593,7698955, - 7689828,7687614,7690835,7685852,7667229,7645042,7629506,7617787,7601639, - 7578545,7554822,7537315,7524279,7507108,7481430,7453328,7431803,7415991, - 7395254,7364820,7335141,7319069,7310202,7296948,7280120,7270700,7273946, - 7282989,7288836,7292510,7303600,7327768,7359376,7389357,7418784,7458856, - 7515186,7577119,7632232,7684091,7741771,7803922,7858506,7897295,7924793, - 7950529,7975309,7989134,7983815,7964337,7942418,7920028,7885853,7832460, - 7773178,7719675,7667640,7605540,7531820,7456659,7388182,7322718,7251305, - 7173342,7099371,7039023,6989942,6943645,6900871,6876377,6876200,6891753, - 6912280,6938008,6976184,7027514,7081939,7129159,7169768,7212416,7260113, - 7303961,7334160,7353923,7375390,7399868,7413919,7410756,7397888,7384995, - 7371128,7347783,7311469,7269433,7231533,7198642,7162562,7118413,7073358, - 7038218,7011467,6978885,6936976,6896929,6866243,6838636,6804318,6763793, - 6726715,6699377,6677726,6654422,6630095,6613880,6612001,6619165,6625113, - 6629517,6642997,6668750,6697196,6718344,6734173,6753895,6779589,6802146, - 6813185,6816633,6823486,6836086,6844013,6839567,6830432,6829887,6834652, - 6833897,6825424,6817447,6817430,6823444,6827572,6826137,6824845,6832135, - 6847612,6860472,6863735,6867082,6885344,6912573,6928050,6933679,6949215, - 6980018,7009084,7024486,7037715,7065515,7103221,7130283,7141717,7156523, - 7182804,7191302,7148830,7066479,6973039,6845448,6642997,6369529,6067757, - 5757018,5407708,4989863,4529504,4091224,3695693,3270760,2711684,2000297, - 1252050,651123,273904,89170,20652,2843,209,134,134, - 125,117,92,75,75,75,58,50,50, - 58,50,41,41,50,41,41,41,41, - 41,41,41,41,41,41,41,41,41, - 41,41,41,41,41 -}; -const Word32 defaultHRIR_right_avg_power_48kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8209721,8156956,8050144,7984965,7992850,8011640,7974756,7910323,7917252, - 8038484,8174707,8228738,8192709,8124794,8070361,8030003,7989948,7953583, - 7931127,7912202,7870737,7803402,7745101,7727896,7735563,7724331,7693679, - 7672548,7668236,7662658,7647491,7638624,7652147,7680265,7699609,7698964, - 7689820,7687597,7690827,7685844,7667229,7645050,7629472,7617779,7601639, - 7578545,7554822,7537315,7524288,7507133,7481447,7453337,7431803,7415982, - 7395229,7364812,7335141,7319077,7310185,7296931,7280120,7270700,7273955, - 7282998,7288836,7292494,7303583,7327776,7359401,7389382,7418776,7458856, - 7515186,7577127,7632241,7684082,7741787,7803939,7858523,7897295,7924793, - 7950529,7975309,7989125,7983824,7964320,7942426,7920062,7885853,7832443, - 7773194,7719675,7667640,7605556,7531829,7456675,7388199,7322726,7251305, - 7173333,7099379,7039032,6989967,6943653,6900880,6876377,6876226,6891753, - 6912271,6937999,6976184,7027514,7081931,7129151,7169768,7212416,7260122, - 7303961,7334160,7353940,7375398,7399868,7413910,7410731,7397871,7384978, - 7371145,7347791,7311477,7269450,7231542,7198633,7162554,7118413,7073358, - 7038218,7011475,6978885,6936976,6896920,6866226,6838628,6804310,6763785, - 6726707,6699369,6677709,6654414,6630095,6613889,6612010,6619148,6625071, - 6629508,6642989,6668750,6697204,6718352,6734190,6753920,6779597,6802146, - 6813210,6816641,6823495,6836095,6844030,6839559,6830457,6829904,6834677, - 6833905,6825416,6817455,6817421,6823428,6827555,6826129,6824837,6832135, - 6847620,6860472,6863735,6867082,6885336,6912582,6928059,6933679,6949232, - 6980026,7009084,7024477,7037706,7065489,7103188,7130275,7141708,7156497, - 7182812,7191285,7148847,7066488,6973047,6845439,6642997,6369529,6067757, - 5757001,5407699,4989863,4529504,4091224,3695702,3270751,2711693,2000297, - 1252050,651123,273904,89170,20652,2843,209,134,134, - 125,117,92,75,75,75,58,50,50, - 58,50,41,41,50,41,41,41,41, - 41,41,41,41,41,41,41,41,41, - 41,41,41,41,41 -}; -const Word32 defaultHRIR_coherence_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 131125216,129227112,119736576,105149792,87165424,65548180,45102524,26414452,12630962, - 2261837,646258,0,0,0,362790,1269699,3305916,5226035, - 5552185,5544266,5313545,5242007,4972498,4406099,3304843,2138491,1245809, - 945832,1040724,1586856,2087488,2519669,2930509,3330210,3706959,3852988, - 3845069,3506438,3230889,3049963,3020838,2972117,2692944,2226269,1634369, - 1306206,1176284,1344056,1533169,1651817,1468073,1147695,736184,393929, - 141465,23622,0,0,0,0,0,0,0, - 0,0,31004,186025,403995,663840,869999,1052669,1200174, - 1230910,1195208,1010927,774704,504121,258100,82812,13824,0, - 0,0,0,0,0,0,0,0,0, - 0,35567,94757,127104,150189,159048,139586,103616,29662, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,13287,46305,75833,95294,77980,44426,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,13153,45768,78383,106434, - 117574,114487,101871,68719,36641,6039,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,1476, - 5234,21072,40667,63619,89120,116098,144015,171932,199715, - 227901,255818,281723,304405,324941,341584,357824,373796,388962, - 403995,419296,437818,458621,488820,521301,557674,596329,636728, - 680886,727728,776315,821546,862751,897916,926773,952409,971870, - 980460,981802,955227,918049,865167,793897,713233,613106,507477, - 398224,342255,316082,334604,338228 -}; -const Word32 defaultHRIR_left_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8747993,8732977,8657866,8592845,8534553,8549703,8574332,8613196,8612450, - 8594632,8548151,8528631,8527079,8602383,8683241,8772412,8811402,8825092, - 8787822,8745552,8699960,8676052,8653847,8634210,8606620,8577981,8553109, - 8534922,8521190,8494783,8457906,8405301,8354525,8310963,8294462,8290268, - 8294278,8284279,8267812,8241648,8222362,8207531,8203647,8196752,8187852, - 8170672,8158450,8153660,8165857,8182684,8201064,8209352,8210920,8201391, - 8193506,8188086,8186669,8185008,8178398,8165219,8147653,8126564,8107262, - 8090653,8075973,8060647,8040892,8017060,7990510,7965369,7942812,7924139, - 7905508,7885266,7858574,7828903,7797253,7770124,7745051,7723047,7698192, - 7671231,7638683,7606840,7575458,7552800,7532081,7514280,7493736,7472068, - 7448614,7429295,7412736,7405756,7399180,7393182,7382990,7372018,7362119, - 7358680,7359552,7368629,7377118,7384718,7391127,7398953,7413675,7435679, - 7462522,7492302,7520043,7544714,7568412,7592915,7621662,7651325,7681599, - 7702873,7719423,7728886,7735043,7740672,7747517,7751812,7754412,7743650, - 7728089,7705339,7680970,7656341,7632308,7603568,7571683,7527366,7481606, - 7433699,7390347,7348345,7307132,7260525,7210319,7153108,7097458,7044149, - 6995864,6948351,6898883,6845179,6788657,6732512,6680016,6632990,6592154, - 6553113,6515029,6478094,6441947,6416664,6397714,6388260,6386465,6386851, - 6388319,6391700,6396364,6411102,6429029,6451720,6471844,6489796,6501641, - 6513435,6525204,6542518,6559405,6575670,6584344,6589771,6589813,6590845, - 6592531,6595845,6596365,6592707,6580091,6564161,6543961,6524642,6505902, - 6486113,6462969,6434800,6400113,6364034,6328861,6297445,6268521,6239597, - 6208098,6172732,6136241,6100909,6071330,6044722,6020084,5990858,5959116, - 5923599,5889046,5855634,5825838,5795177,5763938,5725518,5685253,5642211, - 5600763,5560540,5523688,5486661,5449525,5408043,5366612,5325264,5291257, - 5260940,5238031,5214778,5191290,5165126,5142795,5126186,5122067,5121799, - 5124433,5124877,5123837,5133241,5151268,5182239,5223192,5269715,5328527, - 5411331,5510141,5612029,5649811,5591443,5269488,4824515,4151102,3472472, - 2790361,2355655,2029229,1865232,1832432 -}; -const Word32 defaultHRIR_right_avg_power_32kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 8747984,8732969,8657857,8592837,8534561,8549686,8574315,8613188,8612450, - 8594632,8548151,8528622,8527070,8602392,8683241,8772404,8811402,8825109, - 8787822,8745552,8699951,8676044,8653847,8634226,8606620,8577964,8553100, - 8534914,8521190,8494808,8457931,8405310,8354525,8310963,8294471,8290276, - 8294278,8284287,8267820,8241639,8222362,8207540,8203664,8196752,8187826, - 8170663,8158450,8153685,8165873,8182684,8201064,8209360,8210945,8201416, - 8193531,8188095,8186669,8185008,8178398,8165219,8147653,8126539,8107237, - 8090644,8075973,8060664,8040875,8017043,7990510,7965369,7942812,7924122, - 7905499,7885283,7858574,7828903,7797270,7770116,7745034,7723056,7698192, - 7671222,7638675,7606840,7575466,7552809,7532089,7514280,7493736,7472068, - 7448597,7429287,7412753,7405756,7399163,7393174,7382981,7372009,7362111, - 7358680,7359560,7368637,7377126,7384718,7391135,7398970,7413692,7435679, - 7462514,7492293,7520026,7544705,7568403,7592915,7621688,7651341,7681582, - 7702873,7719423,7728877,7735026,7740663,7747517,7751829,7754437,7743650, - 7728080,7705330,7680970,7656349,7632308,7603568,7571700,7527383,7481623, - 7433716,7390363,7348353,7307132,7260525,7210327,7153125,7097475,7044149, - 6995872,6948359,6898883,6845179,6788657,6732520,6680024,6632990,6592154, - 6553113,6515037,6478102,6441947,6416664,6397714,6388269,6386457,6386843, - 6388327,6391700,6396347,6411102,6429029,6451712,6471844,6489796,6501624, - 6513427,6525213,6542518,6559405,6575653,6584327,6589763,6589813,6590845, - 6592531,6595836,6596365,6592716,6580099,6564169,6543978,6524642,6505894, - 6486122,6462994,6434817,6400122,6364034,6328852,6297428,6268521,6239597, - 6208090,6172723,6136241,6100909,6071330,6044722,6020076,5990842,5959107, - 5923599,5889037,5855617,5825829,5795169,5763921,5725518,5685253,5642194, - 5600755,5560548,5523688,5486661,5449508,5408026,5366603,5325256,5291257, - 5260949,5238040,5214778,5191281,5165134,5142795,5126194,5122075,5121799, - 5124441,5124877,5123854,5133241,5151259,5182230,5223192,5269715,5328527, - 5411340,5510149,5612037,5649820,5591435,5269472,4824498,4151094,3472472, - 2790378,2355663,2029237,1865240,1832432 -}; - -const Word32 defaultHRIR_coherence_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-27*/ = { - 130123416,130123416,128225040,123478832,118732624,113118568,104033232,94947768,85862304, - 75063144,64263984,53464828,43914296,34675820,25437480,17993766,11746601,5499437, - 1532229,985023,437818,0,0,0,0,0,0, - 0,343865,773496,1203261,2004810,3054258,4103707,4777480,4887673, - 4998000,5066316,4966727,4867271,4767816,4765534,4763253,4760971,4569174, - 4329998,4090822,3659312,3099355,2539533,2037290,1621350,1205543,880065, - 916304,952677,988916,1233058,1477200,1721342,1912602,2090441,2268413, - 2427327,2573490,2719788,2859643,2989834,3120025,3219078,3193576,3168075, - 3142574,2987686,2832665,2677778,2583691,2504771,2425851,2397128,2401692, - 2406255,2356594,2225464,2094333,1933137,1651280,1369423,1087566,924357, - 761148,597940,625051,699677,774302,854295,937779,1021128,1026631, - 915230,803830,670014,446676,223338,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,5100,30735, - 56371,81872,173140,264408,355542,419698,477144,534455,552037, - 543044,533918,485599,378494,271254,173946,115964,57982,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0, - 0,0,671,1476,2415,99723,261321,423054,646795, - 963549,1280302,1632087,2124129,2616037,3108080,3841982,4575885,5309922, - 6280181,7309766,8339216,8750996,8750996 -}; -const Word32 defaultHRIR_left_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269680,9222847,9180350,9155201,9130044,9104894, - 9126688,9148473,9170267,9191549,9212688,9233844,9234423,9221295,9208167, - 9191205,9168497,9145789,9127997,9129884,9131780,9133676,9164823,9195978, - 9227125,9267550,9310290,9353038,9385225,9410374,9435531,9445170,9431538, - 9417907,9399855,9364128,9328409,9292682,9270670,9248667,9226655,9215783, - 9207688,9199593,9183605,9162356,9141108,9116244,9085961,9055678,9028608, - 9014432,9000255,8986078,8975962,8965845,8955728,8926108,8891606,8857103, - 8819145,8778896,8738639,8710806,8701604,8692401,8686227,8692209,8698190, - 8704171,8686706,8669232,8651767,8623917,8593466,8563024,8543554,8531399, - 8519252,8509748,8504203,8498667,8489716,8467083,8444459,8421835,8399773, - 8377711,8355649,8351698,8352268,8352847,8355833,8360430,8365027,8363484, - 8352721,8341959,8331028,8319460,8307884,8296308,8292063,8287827,8283582, - 8271142,8256647,8242159,8221389,8196442,8171494,8150547,8135607,8120659, - 8106465,8095225,8083992,8072760,8043073,8013394,7983706,7949422,7913997, - 7878564,7853893,7836394,7818904,7801472,7784141,7766811,7744782,7703972, - 7663169,7622359,7580802,7539253,7497696,7474266,7455367,7436467,7415496, - 7393140,7370784,7338471,7291235,7244007,7197551,7154232,7110914,7067595, - 7046615,7025627,7004647,6977485,6948779,6920073,6878751,6829015,6779278, - 6733644,6694184,6654724,6618804,6597044,6575284,6553524,6518183,6482842, - 6447501,6401632,6353137,6304634,6267229,6237215,6207201,6181045,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896503,5850198,5825150, - 5805428,5785707,5765742,5745626,5725510,5693398,5643285,5593180,5544358, - 5500720,5457091,5413454,5404126,5394797,5385469,5366930,5346085,5325239, - 5282164,5224274,5166376,5115566,5075376,5035186,5002731,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773822,4700355,4646282,4605153, - 4564023,4540250,4542523,4544788,4536869,4488241,4439612,4390983,4285488, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957300,3691818,3426335,3160861,2774481,2388110,2001740, - 1708239,1437966,1167685,1059581,1059581 -}; -const Word32 defaultHRIR_right_avg_power_16kHz_fx[LR_IAC_LENGTH_NR_FC] /*Q-23*/ = { - 9335246,9335246,9316514,9269689,9222855,9180358,9155201,9130035,9104869, - 9126663,9148465,9170258,9191540,9212688,9233827,9234415,9221295,9208175, - 9191213,9168488,9145755,9127963,9129867,9131772,9133676,9164831,9195978, - 9227133,9267550,9310281,9353021,9385200,9410357,9435506,9445153,9431522, - 9417899,9399855,9364119,9328384,9292648,9270653,9248658,9226663,9215792, - 9207688,9199593,9183596,9162348,9141100,9116236,9085953,9055678,9028617, - 9014432,9000255,8986070,8975962,8965853,8955745,8926116,8891614,8857103, - 8819145,8778888,8738631,8710789,8701587,8692385,8686219,8692200,8698181, - 8704162,8686697,8669232,8651775,8623917,8593466,8563016,8543546,8531390, - 8519244,8509739,8504203,8498675,8489724,8467100,8444468,8421844,8399773, - 8377703,8355641,8351681,8352252,8352830,8355817,8360414,8365019,8363475, - 8352721,8341959,8331037,8319469,8307893,8296316,8292072,8287835,8283591, - 8271142,8256647,8242151,8221381,8196433,8171494,8150547,8135616,8120676, - 8106482,8095250,8084009,8072777,8043081,8013385,7983698,7949405,7913972, - 7878547,7853876,7836386,7818904,7801481,7784150,7766819,7744790,7703980, - 7663161,7622350,7580793,7539244,7497696,7474258,7455358,7436459,7415487, - 7393132,7370776,7338471,7291244,7244016,7197560,7154241,7110914,7067587, - 7046607,7025627,7004647,6977485,6948770,6920064,6878742,6829006,6779270, - 6733644,6694184,6654724,6618813,6597053,6575301,6553549,6518191,6482842, - 6447492,6401623,6353137,6304643,6267229,6237215,6207201,6181037,6160677, - 6140310,6115580,6073427,6031275,5989122,5942817,5896512,5850207,5825167, - 5805445,5785723,5765750,5745626,5725493,5693382,5643276,5593180,5544375, - 5500729,5457074,5413429,5404109,5394789,5385478,5366939,5346093,5325247, - 5282172,5224282,5166384,5115574,5075384,5035195,5002739,5001238,4999736, - 4998243,4969436,4940630,4911823,4847290,4773814,4700338,4646274,4605153, - 4564023,4540258,4542523,4544788,4536878,4488249,4439612,4390983,4285480, - 4179984,4074489,4025282,3990150,3955019,3974925,4031523,4088129,4108127, - 4073222,4038317,3957292,3691809,3426327,3160844,2774473,2388110,2001740, - 1708239,1437966,1167685,1059573,1059573 -}; - -#endif Word32 sine_table_Q31 [361] = { diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 8b5dadf39..7e38a1a08 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -586,32 +586,24 @@ static ivas_error set_default_reverb_iac_energy( ) { int16_t i; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB int16_t lr_iac_len; -#endif if ( HrFiltSet_p == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB lr_iac_len = LR_IAC_LENGTH_NR_FC; if ( HrFiltSet_p->SampleRate == 16000 ) { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } -#endif if ( HrFiltSet_p->ModelParams.modelROM == 0 ) { for ( i = 0; i < 3; i++ ) { -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); -#else - HrFiltSet_p->lr_energy_and_iac_dyn[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC * sizeof( float ) ); -#endif if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); @@ -630,15 +622,9 @@ static ivas_error set_default_reverb_iac_energy( mvl2l( defaultHRIR_coherence_32kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], LR_IAC_LENGTH_NR_FC ); break; case 16000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], Q27, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ -#else - mvl2l( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_right_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_coherence_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], LR_IAC_LENGTH_NR_FC ); -#endif break; } } @@ -657,7 +643,6 @@ static ivas_error set_default_reverb_iac_energy( HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_32kHz_fx; break; case 16000: -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB for ( i = 0; i < 3; i++ ) { HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); @@ -672,11 +657,6 @@ static ivas_error set_default_reverb_iac_energy( HrFiltSet_p->lr_energy_and_iac_fx[0] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[0]; HrFiltSet_p->lr_energy_and_iac_fx[1] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[1]; HrFiltSet_p->lr_energy_and_iac_fx[2] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[2]; -#else - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_16kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_16kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_16kHz_fx; -#endif break; @@ -726,7 +706,6 @@ static ivas_error load_reverb_from_binary( } lr_iac_len = LR_IAC_LENGTH_NR_FC; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB #ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( sampleRate == 16000 ) #else @@ -735,7 +714,6 @@ static ivas_error load_reverb_from_binary( { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } -#endif header_check_result = IVAS_ERR_OK; @@ -806,7 +784,6 @@ static ivas_error load_reverb_from_binary( hHrtfStatistics->average_energy_r = hHrtfStatistics->average_energy_r_dyn; hHrtfStatistics->inter_aural_coherence = hHrtfStatistics->inter_aural_coherence_dyn; -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q28, lr_iac_len ); @@ -815,16 +792,6 @@ static ivas_error load_reverb_from_binary( fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q26, lr_iac_len ); -#else - fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_l_dyn, Q23, lr_iac_len ); - - fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->average_energy_r_dyn, Q23, lr_iac_len ); - - fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q23, lr_iac_len ); -#endif hHrtfStatistics->fromROM = FALSE; #else /* left/right energy and interaural coherence for late reverb */ @@ -1155,7 +1122,6 @@ void destroy_td_hrtf( free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ); } } -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB else { for ( i = 0; i < 3; i++ ) @@ -1166,7 +1132,6 @@ void destroy_td_hrtf( } } } -#endif #else } #endif @@ -2344,11 +2309,7 @@ void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ) { -#ifdef NONBE_FIX_AVG_IAC_CLDFB_REVERB if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) ) -#else - if ( ( hHrtfStatistics != NULL ) && ( *hHrtfStatistics != NULL ) && ( ( *hHrtfStatistics )->fromROM == FALSE ) ) -#endif { if ( ( *hHrtfStatistics )->average_energy_l_dyn != NULL ) { -- GitLab From c4510ca6a7bca037ee36933a5b0c4355034e7728 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:23:03 +0200 Subject: [PATCH 536/692] [cleanup] accept NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES --- apps/decoder.c | 23 -- apps/renderer.c | 16 -- lib_com/common_api_types.h | 2 - lib_com/options.h | 1 - lib_dec/ivas_binRenderer_internal_fx.c | 4 - lib_dec/ivas_init_dec_fx.c | 18 -- lib_dec/ivas_ism_dec_fx.c | 8 - lib_dec/ivas_mct_dec_fx.c | 4 - lib_dec/ivas_stat_dec.h | 2 - lib_dec/lib_dec.h | 2 - lib_dec/lib_dec_fx.c | 2 - lib_rend/ivas_crend_fx.c | 10 - .../ivas_dirac_dec_binaural_functions_fx.c | 5 - lib_rend/ivas_hrtf_fx.c | 2 - lib_rend/ivas_objectRenderer_mix_fx.c | 32 --- lib_rend/ivas_prot_rend_fx.h | 62 ----- lib_rend/ivas_reverb_filter_design_fx.c | 257 ------------------ lib_rend/ivas_reverb_fx.c | 208 -------------- lib_rend/ivas_reverb_utils_fx.c | 214 --------------- lib_rend/ivas_stat_rend.h | 7 - lib_rend/lib_rend.h | 2 - lib_rend/lib_rend_fx.c | 97 ------- lib_util/hrtf_file_reader.c | 164 ----------- lib_util/hrtf_file_reader.h | 6 - 24 files changed, 1148 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0108d1325..98673972e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -166,9 +166,7 @@ int main( IVAS_RENDER_FRAMESIZE asked_frame_size; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; -#endif #ifdef WMOPS reset_wmops(); @@ -586,16 +584,6 @@ int main( } } -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - } -#endif if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -654,7 +642,6 @@ int main( destroy_parambin_hrtf( hHrtfParambin ); } } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -672,16 +659,6 @@ int main( destroy_hrtf_statistics( hHrtfStatistics ); } } -#else - if ( ( hHrtfTD != NULL ) && ( *hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName ); - goto cleanup; - } - } -#endif } /*------------------------------------------------------------------------------------------* diff --git a/apps/renderer.c b/apps/renderer.c index f36434778..13d68cdef 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -735,9 +735,7 @@ int main( IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL; IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL; IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL; -#endif IsmPositionProvider *positionProvider = NULL; LfeRoutingConfig *lfeRoutingConfigs[RENDERER_MAX_MC_INPUTS]; RenderConfigReader *renderConfigReader = NULL; @@ -992,16 +990,6 @@ int main( } } -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - if ( ( hHrtfTD != NULL ) && ( error = load_reverb_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK ) - { - if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA ) - { - fprintf( stderr, "\nError in loading HRTF binary file %s: %s \n\n", args.customHrtfFilePath, ivas_error_to_string( error ) ); - goto cleanup; - } - } -#endif if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK ) { @@ -1062,7 +1050,6 @@ int main( } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( ( error = IVAS_REND_GetHrtfStatisticsHandle( hIvasRend, &hHrtfStatistics ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_REND_GetHrtfStatisticsHandle failed\n\n" ); @@ -1080,7 +1067,6 @@ int main( destroy_hrtf_statistics( hHrtfStatistics ); } } -#endif hrtfFileReader_close( &hrtfFileReader ); } @@ -2107,9 +2093,7 @@ cleanup: { destroy_td_hrtf( hHrtfTD ); } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES destroy_hrtf_statistics( hHrtfStatistics ); -#endif IVAS_REND_Close( &hIvasRend ); IsmPositionProvider_close( positionProvider ); RenderConfigReader_close( &renderConfigReader ); diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 175b23c3b..33013360e 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -182,9 +182,7 @@ typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE; typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE; typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE; typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE; -#endif typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE; typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE; diff --git a/lib_com/options.h b/lib_com/options.h index 1bb60b341..fb009faea 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -109,7 +109,6 @@ #endif #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ -#define NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* Philips: Use pre-computed HRTF average L/R energies and IAC in all renderers */ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index a1b6bb5ed..6911e487f 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -1344,11 +1344,7 @@ ivas_error ivas_binRenderer_open_fx( test(); IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_binaural_reverb_open_fastconv_fx( &( hBinRenderer->hReverb ), hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hIntSetup.output_config, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 926d1f93f..ef3d8c6e9 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1163,12 +1163,10 @@ IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin return error; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) { return error; } -#endif } /*-------------------------------------------------------------------* @@ -1353,7 +1351,6 @@ ivas_error ivas_init_decoder_fx( } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*--------------------------------------------------------------------* * Allocate and initialize HRTF Statistics handle *--------------------------------------------------------------------*/ @@ -1365,7 +1362,6 @@ ivas_error ivas_init_decoder_fx( return error; } } -#endif /*-----------------------------------------------------------------* * Initialize binuaral split rendering @@ -2276,11 +2272,7 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2323,15 +2315,9 @@ ivas_error ivas_init_decoder_fx( } } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, - st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), - IVAS_ERR_OK ) ) -#endif { return error; } @@ -2862,9 +2848,7 @@ void ivas_initialize_handles_dec( st_ivas->hSetOfHRTF = NULL; st_ivas->hHrtfFastConv = NULL; st_ivas->hHrtfParambin = NULL; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES st_ivas->hHrtfStatistics = NULL; -#endif st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; st_ivas->hSbaIsmData = NULL; @@ -3087,10 +3071,8 @@ void ivas_destroy_dec_fx( /* Parametric binauralizer HRTF filters */ ivas_HRTF_parambin_binary_close_fx( &st_ivas->hHrtfParambin ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* HRTF statistics */ ivas_HRTF_statistics_close( &st_ivas->hHrtfStatistics ); -#endif /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); diff --git a/lib_dec/ivas_ism_dec_fx.c b/lib_dec/ivas_ism_dec_fx.c index 727a0a651..41c1efcdc 100644 --- a/lib_dec/ivas_ism_dec_fx.c +++ b/lib_dec/ivas_ism_dec_fx.c @@ -212,11 +212,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( } IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hDecoderConfig->output_config, NULL, st_ivas->hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -239,11 +235,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); /* Open Crend Binaural renderer */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; move32(); diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index ed43b9991..97b794b44 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -1546,11 +1546,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( } ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#else - IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index db23485b8..274aa1910 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1121,9 +1121,7 @@ typedef struct Decoder_Struct HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */ -#endif LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ Word32 *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 28b8594fe..3a6ea5b45 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -367,12 +367,10 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error IVAS_DEC_GetHrtfStatisticsHandle( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ ); -#endif /*! r: error code*/ ivas_error IVAS_DEC_GetRenderConfig( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 551a20c0f..4c448efc7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -2564,7 +2564,6 @@ ivas_error IVAS_DEC_GetHrtfParamBinHandle( return IVAS_ERR_OK; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * IVAS_DEC_GetHrtfStatisticsHandle( ) * @@ -2585,7 +2584,6 @@ ivas_error IVAS_DEC_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } -#endif /*---------------------------------------------------------------------* * copyRendererConfigStruct( ) diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 825ff582e..a8195dae3 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1500,11 +1500,7 @@ ivas_error ivas_rend_openMultiBinCrend( { ivas_error error; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, NULL /* hHrtfStatistics */, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) -#else - if ( ( error = ivas_rend_openCrend( pCrend, inConfig, outConfig, NULL /*hRendCfg*/, NULL, output_Fs, pMultiBinPoseData->num_poses ) ) != IVAS_ERR_OK ) -#endif { return error; } @@ -1524,9 +1520,7 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics, -#endif const Word32 output_Fs, const Word16 num_poses ) { @@ -1657,11 +1651,7 @@ ivas_error ivas_rend_openCrend( IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), hHrtfStatistics, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &( hCrend->hReverb ), inConfig, ( *pCrend )->hHrtfCrend, NULL, hRendCfg, output_Fs ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 75a8d4b23..959c8165c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -315,15 +315,10 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( IF( hDiracDecBin->hReverb == NULL && EQ_16( pos_idx, 0 ) ) /* open reverb only for the main direction */ { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else if ( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, st_ivas->hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( st_ivas->hRenderConfig->roomAcoustics ), output_Fs, st_ivas->hHrtfParambin->parametricReverberationTimes_fx, st_ivas->hHrtfParambin->parametricReverberationEneCorrections_fx ) ) != IVAS_ERR_OK ) -#endif -#else - /* Todo Philips: Room acoustics should be passed here once the underlying part works. Probably enough to pick it from st_ivas but you know best. */ - if ( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_rend/ivas_hrtf_fx.c b/lib_rend/ivas_hrtf_fx.c index da862b51b..2a75dee81 100644 --- a/lib_rend/ivas_hrtf_fx.c +++ b/lib_rend/ivas_hrtf_fx.c @@ -214,7 +214,6 @@ void ivas_HRTF_parambin_binary_close_fx( return; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------* * ivas_HRTF_statistics_binary_open() * @@ -361,4 +360,3 @@ ivas_error ivas_HRTF_statistics_init( return IVAS_ERR_OK; } -#endif diff --git a/lib_rend/ivas_objectRenderer_mix_fx.c b/lib_rend/ivas_objectRenderer_mix_fx.c index cb6e3a3fe..1fc754dff 100644 --- a/lib_rend/ivas_objectRenderer_mix_fx.c +++ b/lib_rend/ivas_objectRenderer_mix_fx.c @@ -407,38 +407,6 @@ static ivas_error DefaultBSplineModel_fx( model = &( HrFiltSet_p->ModelParams ); modelITD = &( HrFiltSet_p->ModelParamsITD ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else - SWITCH( output_Fs ) - { - case 48000: - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_48kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_48kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_48kHz_fx; // Q23 - BREAK; - case 32000: - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_32kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_32kHz_fx; // Q23 - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_32kHz_fx; // Q23 - BREAK; - case 16000: - for ( i = 0; i < 3; i++ ) - { - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( LR_IAC_LENGTH_NR_FC_16KHZ * sizeof( float ) ); - if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - } - floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], Q27, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], Q23, LR_IAC_LENGTH_NR_FC_16KHZ ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - HrFiltSet_p->lr_energy_and_iac_fx[0] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[0]; - HrFiltSet_p->lr_energy_and_iac_fx[1] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[1]; - HrFiltSet_p->lr_energy_and_iac_fx[2] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[2]; - BREAK; - } -#endif /* Set ROM flag for correct deallocation */ model->modelROM = TRUE; diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 3fc299761..0e2033fd4 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -616,7 +616,6 @@ void ivas_HRTF_CRend_binary_close_fx( HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_HRTF_statistics_init( HRTFS_STATISTICS_HANDLE *hHrtfStatistics, /* i/o: HRTF statistics structure */ int32_t sampleRate /* i : Sample rate */ @@ -630,7 +629,6 @@ ivas_error ivas_HRTF_statistics_binary_open( HRTFS_STATISTICS **hHrtfStatistics /* i/o: HRTF statistics structure */ ); -#endif /*----------------------------------------------------------------------------------* * TD object renderer @@ -876,9 +874,7 @@ ivas_error ivas_rend_openCrend( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, HRTFS_CREND_HANDLE hSetOfHRTF, -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics, -#endif const Word32 output_Fs, const Word16 num_poses ); @@ -919,44 +915,18 @@ ivas_error ivas_rend_crendProcessSubframe( * Reverberator *----------------------------------------------------------------------------------*/ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_binaural_reverb_init( -#else -ivas_error ivas_binaural_reverb_open_fastconv_fx( -#endif REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ -#else -#endif const Word16 numBins, /* i : number of CLDFB bins */ const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ -#else - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const AUDIO_CONFIG internal_config, /* i : internal audio config for FastConv */ -#endif const Word32 sampling_rate, /* i : sampling rate */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const Word32 *defaultTimes, /* i : default reverberation times */ const Word32 *defaultEne /* i : default reverberation energies */ -#else - const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ -#endif ); -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -ivas_error ivas_binaural_reverb_open_parambin( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const Word16 numBins, /* i : number of CLDFB bins Q0 */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate Q0 */ - const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ -); -#endif void ivas_binaural_reverb_close_fx( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ @@ -977,13 +947,7 @@ void ivas_binaural_reverb_processSubframe_fx( ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ -#else - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ - const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ -#endif RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const Word32 output_Fs /* i : output sampling rate */ ); @@ -1129,23 +1093,12 @@ void ivas_reverb_calc_color_levels_fx( const Word32 *pT60_filter_coeff, //input in Q31 Word32 *pTarget_color_L, //output in Q30 Word32 *pTarget_color_R); //output in Q30 -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ); -#else -ivas_error ivas_reverb_prepare_cldfb_params( - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, - const AUDIO_CONFIG input_audio_config, - const int16_t use_brir, - const int32_t output_Fs, - float *pOutput_t60, - float *pOutput_ene ); -#endif void ivas_reverb_interpolate_acoustic_data_fx( const Word16 input_table_size, const Word32 *pInput_fc, //input in Q16 @@ -1172,21 +1125,6 @@ void ivas_reverb_interpolate_energies_fx( Word16 *pOutput_ene_r_e //output e ); #endif -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -void ivas_reverb_get_hrtf_set_properties_fx( - Word32 **ppHrtf_set_L_re, - Word32 **ppHrtf_set_L_im, - Word32 **ppHrtf_set_R_re, - Word32 **ppHrtf_set_R_im, - const AUDIO_CONFIG input_audio_config, - const Word16 hrtf_count, - const Word16 in_freq_count, - const Word16 out_freq_count, - Word32 *pOut_avg_pwr_L, //output in Q23 - Word32 *pOut_avg_pwr_R, //output in Q23 - Word32 *out_i_a_coherence //output in Q27 -); -#endif /*---------------------------------------------------------------------------------* * Shoebox Prototypes *-----------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index aacfb2009..0b8642120 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -1003,260 +1003,3 @@ void ivas_reverb_interpolate_energies_fx( } #endif -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -/*-------------------------------------------------------------------* - * ivas_reverb_get_hrtf_set_properties() - * - * Function analyses the HRTF set and computes avarage left/right power spectrum - * and frequency-dependent IA coherence. Expects frequency-domain HRTF input - *-------------------------------------------------------------------*/ - - -void ivas_reverb_get_hrtf_set_properties_fx( - Word32 **ppHrtf_set_L_re, // Q29 - Word32 **ppHrtf_set_L_im, // Q29 - Word32 **ppHrtf_set_R_re, // Q29 - Word32 **ppHrtf_set_R_im, // Q29 - const AUDIO_CONFIG input_audio_config, - const Word16 hrtf_count, - const Word16 in_freq_count, - const Word16 out_freq_count, - Word32 *pOut_avg_pwr_L, // output in Q23 - Word32 *pOut_avg_pwr_R, // output in Q23 - Word32 *out_i_a_coherence ) // output in Q27 -{ - const Word16 foa_sum_coeffs[4][3] = { - { MAX_WORD16, MAX_WORD16, 0 }, - { MAX_WORD16, -MAX_WORD16, 0 }, - { MAX_WORD16, 0, MAX_WORD16 }, - { MAX_WORD16, 0, -MAX_WORD16 } - }; - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - move16(); - const Word32 inp_freq_step = divide3232( ONE_IN_Q22, L_shl( in_freq_count, 23 ) ); // q= 15 - const Word32 inp_freq_offset = L_shr( inp_freq_step, 1 ); // q= 15 - const Word16 out_freq_step = divide3232( ONE_IN_Q21, L_shl( L_sub( out_freq_count, 1 ), 22 ) ); // q = 15 - - Word16 hrtf_count_inverted, used_hrtf_count, freq_idx, hrtf_idx, out_bin_idx, ch_index, is_ambisonics; - Word32 relative_pos, weight_1st, base_idx; - Word32 avg_pwr_left[2]; - Word32 avg_pwr_right[2]; - Word32 IA_coherence[2]; - - test(); - test(); - IF( EQ_16( input_audio_config, IVAS_AUDIO_CONFIG_FOA ) || EQ_16( input_audio_config, IVAS_AUDIO_CONFIG_HOA2 ) || EQ_16( input_audio_config, IVAS_AUDIO_CONFIG_HOA3 ) ) - { - is_ambisonics = 1; - move16(); - used_hrtf_count = 4; /* Using only 1st order HRTFs */ - move16(); - } - ELSE - { - is_ambisonics = 0; - move16(); - used_hrtf_count = hrtf_count; - move16(); - } - - /* Interpolation (linear to a new grid) */ - base_idx = 0; - move32(); - relative_pos = 0; - move32(); - hrtf_count_inverted = divide1616( ONE_IN_Q11, shl( used_hrtf_count, 11 ) ); // q = 15 - - /* Loop over output frequency bins */ - FOR( out_bin_idx = 0; out_bin_idx < out_freq_count; out_bin_idx++ ) - { - /* Computing normalized frequency for the current bin (1.0 corresponds to sampling rate) */ - - const Word32 norm_freq = L_mult( out_freq_step, shl( out_bin_idx, 5 ) ); // q = 21 - - /* Computing the bin index in the source data */ - Word16 div_q = 0; - move16(); - // Word32 tbl_index = BASOP_Util_Divide3232_Scale(L_sub(norm_freq , L_shl(inp_freq_offset, 6)), L_shl(inp_freq_step, 6), &div_q);//q =15 - div_q - Word32 tbl_index = Mpy_32_32( L_sub( norm_freq, L_shl( inp_freq_offset, 6 ) ), L_shl( in_freq_count, 22 ) ); // q = 11 - IF( div_q < 0 ) - { - tbl_index = L_shl( tbl_index, div_q ); - div_q = 0; - move16(); - } - IF( tbl_index <= 0 ) /* In case of extrapolation (below 1st bin), choose nearest */ - { - base_idx = 0; - move32(); - relative_pos = 0; - move32(); - } - ELSE - { - base_idx = ( tbl_index ); // q = 21 - move32(); - relative_pos = L_shl( L_sub( tbl_index, L_shl( L_shr( base_idx, 11 ), 11 ) ), 20 ); // q = 31 - base_idx = L_shr( base_idx, 11 ); - IF( GT_32( base_idx, L_sub( in_freq_count, 2 ) ) ) /* In case of extrapolation (above last bin), choose nearest */ - { - base_idx = L_sub( in_freq_count, 2 ); - relative_pos = ONE_IN_Q31; // Q31 - move32(); - } - } - - /* Computing 2 bins data for later interpolation */ - - /* Zeroing before accumalation for average value computing */ - avg_pwr_left[0] = 0; - move32(); - avg_pwr_left[1] = 0; - move32(); - avg_pwr_right[0] = 0; - move32(); - avg_pwr_right[1] = 0; - move32(); - IA_coherence[0] = 0; - move32(); - IA_coherence[1] = 0; - move32(); - - /* Get power spectra and cross - correlation between left and right hrtfs */ - /* Loop over all the HRTFs available */ - FOR( hrtf_idx = 0; hrtf_idx < used_hrtf_count; hrtf_idx++ ) - { - /* Pointers to current HRTF data */ - Word32 *current_base_L_ptr_re, *current_base_L_ptr_im, *current_base_R_ptr_re, *current_base_R_ptr_im; - - /* combined HRTF data used for FOA */ - Word32 combined_channels_L_re[2]; - Word32 combined_channels_L_im[2]; - Word32 combined_channels_R_re[2]; - Word32 combined_channels_R_im[2]; - - /* Process the frequency bins containing both real and img parts */ - /* In case of 5.1 or 7.1 formats, use the available HRTF paires directly*/ - IF( !is_ambisonics ) - { - current_base_L_ptr_re = ( ppHrtf_set_L_re[hrtf_idx] + base_idx ); // Q29 - current_base_R_ptr_re = ( ppHrtf_set_R_re[hrtf_idx] + base_idx ); // Q29 - current_base_L_ptr_im = ( ppHrtf_set_L_im[hrtf_idx] + base_idx ); // Q29 - current_base_R_ptr_im = ( ppHrtf_set_R_im[hrtf_idx] + base_idx ); // Q29 - } - - /* In case of FOA format, combine the W channel with the X/Y channels */ - ELSE - { - FOR( freq_idx = 0; freq_idx < 2; freq_idx++ ) - { - combined_channels_L_re[freq_idx] = 0; - move32(); - combined_channels_R_re[freq_idx] = 0; - move32(); - combined_channels_L_im[freq_idx] = 0; - move32(); - combined_channels_R_im[freq_idx] = 0; - move32(); - - FOR( ch_index = 0; ch_index < 3; ch_index++ ) - { - combined_channels_L_re[freq_idx] = L_add( combined_channels_L_re[freq_idx], Mpy_32_16_1( ppHrtf_set_L_re[ch_index][base_idx + freq_idx], foa_sum_coeffs[hrtf_idx][ch_index] ) ); // Q29 + Q15 - 15 - move32(); - combined_channels_R_re[freq_idx] = L_add( combined_channels_R_re[freq_idx], Mpy_32_16_1( ppHrtf_set_R_re[ch_index][base_idx + freq_idx], foa_sum_coeffs[hrtf_idx][ch_index] ) ); // Q29 + Q15 - 15 - move32(); - combined_channels_L_im[freq_idx] = L_add( combined_channels_L_im[freq_idx], Mpy_32_16_1( ppHrtf_set_L_im[ch_index][base_idx + freq_idx], foa_sum_coeffs[hrtf_idx][ch_index] ) ); // Q29 + Q15 - 15 - move32(); - combined_channels_R_im[freq_idx] = L_add( combined_channels_R_im[freq_idx], Mpy_32_16_1( ppHrtf_set_R_im[ch_index][base_idx + freq_idx], foa_sum_coeffs[hrtf_idx][ch_index] ) ); // Q29 + Q15 - 15 - move32(); - } - } - - current_base_L_ptr_re = &combined_channels_L_re[0]; // Q29 - current_base_R_ptr_re = &combined_channels_R_re[0]; // Q29 - current_base_L_ptr_im = &combined_channels_L_im[0]; // Q29 - current_base_R_ptr_im = &combined_channels_R_im[0]; // Q29 - } - - FOR( freq_idx = 0; freq_idx < 2; freq_idx++ ) - { - Word32 L_re, L_im, R_re, R_im, C_re; - - L_re = current_base_L_ptr_re[freq_idx]; // Q29 - R_re = current_base_R_ptr_re[freq_idx]; // Q29 - L_im = current_base_L_ptr_im[freq_idx]; // Q29 - R_im = current_base_R_ptr_im[freq_idx]; // Q29 - move32(); - move32(); - move32(); - move32(); - avg_pwr_left[freq_idx] = L_add( L_shr( L_add( Mpy_32_32( L_re, L_re ), Mpy_32_32( L_im, L_im ) ), 4 ), avg_pwr_left[freq_idx] ); // q = 23 - move32(); - avg_pwr_right[freq_idx] = L_add( L_shr( L_add( Mpy_32_32( R_re, R_re ), Mpy_32_32( R_im, R_im ) ), 4 ), avg_pwr_right[freq_idx] ); // q = 23 - move32(); - /* Cross product (Re part) */ - C_re = L_add( Mpy_32_32( L_re, R_re ), Mpy_32_32( L_im, R_im ) ); // q = 27 - - IA_coherence[freq_idx] = L_add( C_re, IA_coherence[freq_idx] ); // q = 27 - move32(); - } - } - - /* Compute the averages and the IA coherence */ - FOR( freq_idx = 0; freq_idx < 2; freq_idx++ ) - { - Word16 sqrt_exp = 0; - move16(); - Word32 var1; - avg_pwr_left[freq_idx] = Mpy_32_16_1( avg_pwr_left[freq_idx], hrtf_count_inverted ); // q = 23 - move32(); - avg_pwr_right[freq_idx] = Mpy_32_16_1( avg_pwr_right[freq_idx], hrtf_count_inverted ); // q = 23 - move32(); - IF( EQ_32( avg_pwr_left[freq_idx], avg_pwr_right[freq_idx] ) ) - { - var1 = avg_pwr_left[freq_idx]; - move32(); - sqrt_exp = 4; - move16(); - } - ELSE - { - var1 = Sqrt32( Mpy_32_32( avg_pwr_left[freq_idx], avg_pwr_right[freq_idx] ), &sqrt_exp ); - move32(); - } - Word16 temp; - IA_coherence[freq_idx] = BASOP_Util_Divide3232_Scale( Mpy_32_16_1( IA_coherence[freq_idx], hrtf_count_inverted ), L_shl( var1, sqrt_exp ), &temp ); // q =15 - move32(); - IA_coherence[freq_idx] = L_shl( IA_coherence[freq_idx], sub( 27, sub( 15, temp ) ) ); // q = 27 - move32(); - /* Limiting to (0...1) range in case of small numerical errors or negative values */ - IA_coherence[freq_idx] = L_min( IA_coherence[freq_idx], ONE_IN_Q27 ); // Q27 - move32(); - IA_coherence[freq_idx] = L_max( IA_coherence[freq_idx], 0 ); // Q27 - move32(); - } - - /* Computing weighted average of 2 nearest values (1 below + 1 above) for linear interpolation */ - weight_1st = L_sub( ONE_IN_Q31, relative_pos ); // q = 31 - - pOut_avg_pwr_L[out_bin_idx] = L_add( Mpy_32_32( weight_1st, avg_pwr_left[0] ), Mpy_32_32( relative_pos, avg_pwr_left[1] ) ); // q = 23 - move32(); - pOut_avg_pwr_R[out_bin_idx] = L_add( Mpy_32_32( weight_1st, avg_pwr_right[0] ), Mpy_32_32( relative_pos, avg_pwr_right[1] ) ); // q = 23 - move32(); - out_i_a_coherence[out_bin_idx] = L_add( Mpy_32_32( weight_1st, IA_coherence[0] ), Mpy_32_32( relative_pos, IA_coherence[1] ) ); // q = 27 - move32(); - } - - return; -} -#endif diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index e886bfeab..b6a634bb7 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1272,32 +1272,14 @@ static void set_fft_and_datablock_sizes_fx( static void set_reverb_acoustic_data_fx( ivas_reverb_params_t *pParams, -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else - const AUDIO_CONFIG input_audio_config, - const HRTFS_HANDLE hHrtf, -#endif IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics, -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - const Word16 subframe_len, -#endif const Word16 nr_fc_input, const Word16 nr_fc_fft_filter ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES int16_t bin_idx; -#else - Word16 nr_out_ch, hrtf_idx, offset, iter_idx, bin_idx; -#endif Word32 ln_1e6_inverted_fx, delay_diff_fx, L_tmp; Word16 exp_argument_fx, tmp, tmp_flag, exp_argument_e; Word16 pow_exp; -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - Word32 *pHrtf_set_l_re_fx[MAX_INTERN_CHANNELS]; - Word32 *pHrtf_set_l_im_fx[MAX_INTERN_CHANNELS]; - Word32 *pHrtf_set_r_re_fx[MAX_INTERN_CHANNELS]; - Word32 *pHrtf_set_r_im_fx[MAX_INTERN_CHANNELS]; -#endif Word32 *pFc_input_fx = pRoomAcoustics->pFc_input_fx; Word32 *pAcoustic_rt60_fx = pRoomAcoustics->pAcoustic_rt60_fx; @@ -1309,48 +1291,6 @@ static void set_reverb_acoustic_data_fx( Word32 *pDsr_fx = pParams->pDsr_fx; Word16 *pDsr_e = pParams->pDsr_e; -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - /* use crend hrtf filters */ - IF( hHrtf != NULL ) - { - /* Compute HRTF set properties: average left/right energies, IA coherence */ - /* First, find the offset of the frequency-domain data for the 1st frame and assign HRTF pointers */ - FOR( nr_out_ch = 0; nr_out_ch < BINAURAL_CHANNELS; nr_out_ch++ ) - { - FOR( hrtf_idx = 0; hrtf_idx < hHrtf->max_num_ir; hrtf_idx++ ) - { - offset = 0; - move16(); - FOR( iter_idx = 0; iter_idx < hHrtf->num_iterations[hrtf_idx][nr_out_ch] - 1; iter_idx++ ) - { - offset = add( offset, hHrtf->pIndex_frequency_max[hrtf_idx][nr_out_ch][iter_idx] ); - } - - IF( EQ_16( nr_out_ch, 0 ) ) - { - pHrtf_set_l_re_fx[hrtf_idx] = &hHrtf->pOut_to_bin_re_fx[hrtf_idx][0][offset]; - pHrtf_set_l_im_fx[hrtf_idx] = &hHrtf->pOut_to_bin_im_fx[hrtf_idx][0][offset]; - } - ELSE - { - pHrtf_set_r_re_fx[hrtf_idx] = &hHrtf->pOut_to_bin_re_fx[hrtf_idx][1][offset]; - pHrtf_set_r_im_fx[hrtf_idx] = &hHrtf->pOut_to_bin_im_fx[hrtf_idx][1][offset]; - } - } - } - - /* Compute HRTF set properties using frequency-domain HRTF data */ - Word32 *pHrtf_avg_pwr_response_l_fx = pParams->pHrtf_avg_pwr_response_l_fx; - Word32 *pHrtf_avg_pwr_response_r_fx = pParams->pHrtf_avg_pwr_response_r_fx; - Word32 *pHrtf_inter_aural_coherence_fx = pParams->pHrtf_inter_aural_coherence_fx; - ivas_reverb_get_hrtf_set_properties_fx( pHrtf_set_l_re_fx, pHrtf_set_l_im_fx, pHrtf_set_r_re_fx, pHrtf_set_r_im_fx, input_audio_config, hHrtf->max_num_ir, subframe_len, - nr_fc_fft_filter, pHrtf_avg_pwr_response_l_fx, pHrtf_avg_pwr_response_r_fx, pHrtf_inter_aural_coherence_fx ); - - pParams->pHrtf_avg_pwr_response_l_const_fx = (const Word32 *) pParams->pHrtf_avg_pwr_response_l_fx; - pParams->pHrtf_avg_pwr_response_r_const_fx = (const Word32 *) pParams->pHrtf_avg_pwr_response_r_fx; - pParams->pHrtf_inter_aural_coherence_const_fx = (const Word32 *) pParams->pHrtf_inter_aural_coherence_fx; - } -#endif /* interpolate input table data for T60 and DSR to the FFT filter grid */ ivas_reverb_interpolate_acoustic_data_fx( nr_fc_input, pFc_input_fx, pAcoustic_rt60_fx, pAcoustic_dsr_fx, nr_fc_fft_filter, pFc_fx, pRt60_fx, pDsr_fx, pRt60_e, pDsr_e ); @@ -1482,13 +1422,7 @@ static ivas_error setup_FDN_branches_fx( ivas_error ivas_reverb_open_fx( REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ -#else - const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ - const HRTFS_HANDLE hHrtf, /* i : HRTF handle */ - const Word32 *lr_energy_and_iac_fx[], /* i : precomuputed lr energies and iac */ -#endif RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const int32_t output_Fs ) { @@ -1565,7 +1499,6 @@ ivas_error ivas_reverb_open_fx( test(); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /* set up reverb acoustic data on the basis of HRTF data and renderer config */ Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 2 ); Word16 *pRt60_e = (Word16 *) malloc( sizeof( Word16 ) * nr_fc_fft_filter ); @@ -1588,31 +1521,6 @@ ivas_error ivas_reverb_open_fx( params.pHrtf_avg_pwr_response_r_const_fx = hHrtfStatistics->average_energy_r; params.pHrtf_inter_aural_coherence_const_fx = hHrtfStatistics->inter_aural_coherence; -#else - IF( hHrtf == NULL && lr_energy_and_iac_fx != NULL ) - { - params.pHrtf_avg_pwr_response_l_const_fx = lr_energy_and_iac_fx[0]; - params.pHrtf_avg_pwr_response_r_const_fx = lr_energy_and_iac_fx[1]; - params.pHrtf_inter_aural_coherence_const_fx = lr_energy_and_iac_fx[2]; - } - /* set up reverb acoustic data on the basis of HRTF data and renderer config */ - Scale_sig32( params.pFc_fx, nr_fc_fft_filter, 2 ); - Word16 *pRt60_e = (Word16 *) malloc( sizeof( Word16 ) * nr_fc_fft_filter ); - Word16 *pDsr_e = (Word16 *) malloc( sizeof( Word16 ) * nr_fc_fft_filter ); - - params.pRt60_e = pRt60_e; - params.pDsr_e = pDsr_e; - - set_reverb_acoustic_data_fx( ¶ms, input_audio_config, hHrtf, &hRenderConfig->roomAcoustics, subframe_len, nr_fc_input, nr_fc_fft_filter ); - Scale_sig32( params.pFc_fx, nr_fc_fft_filter, -2 ); - FOR( i = 0; i < nr_fc_fft_filter; i++ ) - { - params.pRt60_fx[i] = L_abs( params.pRt60_fx[i] ); - move32(); - params.pDsr_fx[i] = L_abs( params.pDsr_fx[i] ); - move32(); - } -#endif /* set reverb acoustic configuration based on renderer config */ pState->pConfig.roomAcoustics.override = hRenderConfig->roomAcoustics.override; @@ -1776,10 +1684,6 @@ ivas_error ivas_reverb_open_fx( { return error; } -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - free( pDsr_e ); - free( pRt60_e ); -#endif *hReverb = pState; return error; @@ -2507,7 +2411,6 @@ static ivas_error ivas_binaural_reverb_open_fx( return IVAS_ERR_OK; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*------------------------------------------------------------------------- * ivas_binaural_reverb_init() * @@ -2566,117 +2469,6 @@ ivas_error ivas_binaural_reverb_init( return error; } -#else - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_open_fastconv() - * - * Allocate and initialize binaural room reverberator handle for FastConv - *------------------------------------------------------------------------*/ -ivas_error ivas_binaural_reverb_open_fastconv_fx( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const Word16 numBins, /* i : number of CLDFB bins */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const AUDIO_CONFIG internal_config, /* i : internal audio config for FastConv */ - const Word32 sampling_rate, /* i : sampling rate */ - const HRTFS_FASTCONV_HANDLE hHrtfFastConv /* i : FastConv HRTF handle */ -) -{ - ivas_error error; - const Word32 *revTimes; - const Word32 *revEne; - Word32 t60[CLDFB_NO_CHANNELS_MAX]; - Word32 ene[CLDFB_NO_CHANNELS_MAX]; - Word16 preDelay; - - error = IVAS_ERR_OK; - - IF( ( roomAcoustics != NULL ) && roomAcoustics->override ) - { - /* THIS PART IS YET TO BE CONVERTED AS REVERB_UTILS.C IS NOT INVOKED IN GPROF */ - float t60_flt[CLDFB_NO_CHANNELS_MAX]; - float ene_flt[CLDFB_NO_CHANNELS_MAX]; - - revTimes = t60; - revEne = ene; - - IF( NE_32( ( error = ivas_reverb_prepare_cldfb_params( roomAcoustics, hHrtfFastConv, internal_config, false, sampling_rate, t60_flt, ene_flt ) ), IVAS_ERR_OK ) ) - { - return error; - } - - preDelay = (Word16) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL( t60_flt, t60, Q31, CLDFB_NO_CHANNELS_MAX ); - floatToFixed_arrL( ene_flt, ene, Q31, CLDFB_NO_CHANNELS_MAX ); - } - ELSE - { -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q26*/ -#else - revTimes = hHrtfFastConv->fastconvReverberationTimes_fx; /*Q31*/ -#endif - revEne = hHrtfFastConv->fastconvReverberationEneCorrections_fx; /*Q31*/ - preDelay = 10; - move16(); - } - - error = ivas_binaural_reverb_open_fx( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); - - return error; -} - - -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_open_parambin() - * - * Allocate and initialize binaural room reverberator handle for ParamBin - *------------------------------------------------------------------------*/ - -ivas_error ivas_binaural_reverb_open_parambin( - REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */ - const Word16 numBins, /* i : number of CLDFB bins Q0 */ - const Word16 numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame Q0 */ - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *roomAcoustics, /* i/o: room acoustics parameters */ - const Word32 sampling_rate, /* i : sampling rate Q0 */ - const HRTFS_PARAMBIN_HANDLE hHrtfParambin /* i : Parametric binauralizer HRTF handle */ -) -{ - ivas_error error; - const Word32 *revTimes; - const Word32 *revEne; - Word32 t60[CLDFB_NO_CHANNELS_MAX]; - Word32 ene[CLDFB_NO_CHANNELS_MAX]; - Word16 preDelay; - - error = IVAS_ERR_OK; - - IF( ( roomAcoustics != NULL ) && roomAcoustics->override ) - { - revTimes = t60; - revEne = ene; - preDelay = (Word16) L_shr_r( Mpy_32_32( 1677721600 /*800 in Q21*/, roomAcoustics->acousticPreDelay_fx /*Q27*/ ), Q17 ); /*Q0*/ - move16(); - } - ELSE - { -#ifdef FIX_1741_REVERB_TIMES_Q_FORMAT - revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q26*/ -#else - revTimes = hHrtfParambin->parametricReverberationTimes_fx; /*Q31*/ -#endif - revEne = hHrtfParambin->parametricReverberationEneCorrections_fx; /*Q31*/ - preDelay = 10; - move16(); - } - - error = ivas_binaural_reverb_open_fx( hReverbPr, numBins, numCldfbSlotsPerFrame, sampling_rate, revTimes, revEne, preDelay ); - - return error; -} - -#endif /*------------------------------------------------------------------------- * ivas_binaural_reverb_close() * diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index e63e6017a..84fa82bce 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -64,11 +64,7 @@ typedef struct cldfb_convolver_state float filter_states_im[BINAURAL_CONVBANDS][CLDFB_CONVOLVER_NTAPS_MAX]; } cldfb_convolver_state; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, const int32_t sampling_rate, float *avg_pwr_l_out, float *avg_pwr_r_out ); -#else -static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCONV_HANDLE hHrtfFastConv, const AUDIO_CONFIG input_audio_config, const int16_t use_brir, const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ); -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_prepare_cldfb_params() @@ -77,23 +73,12 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const HRTFS_FASTCO *-----------------------------------------------------------------------------------------*/ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error ivas_reverb_prepare_cldfb_params( const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, const HRTFS_STATISTICS_HANDLE hHrtfStatistics, const int32_t output_Fs, float *pOutput_t60, float *pOutput_ene ) -#else -ivas_error ivas_reverb_prepare_cldfb_params( - IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pInput_params, - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, - const AUDIO_CONFIG input_audio_config, - const int16_t use_brir, - const int32_t output_Fs, - float *pOutput_t60, - float *pOutput_ene ) -#endif { int16_t idx; float avg_pwr_left[CLDFB_NO_CHANNELS_MAX]; @@ -101,9 +86,6 @@ ivas_error ivas_reverb_prepare_cldfb_params( float delay_diff, ln_1e6_inverted, exp_argument; const float dist = DEFAULT_SRC_DIST; const float dmx_gain_2 = 4.0f * EVS_PI * dist * dist / 0.001f; -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_error error; -#endif Word32 output_fc_fx[CLDFB_NO_CHANNELS_MAX]; Word32 output_t60_fx[CLDFB_NO_CHANNELS_MAX]; Word16 output_t60_e[CLDFB_NO_CHANNELS_MAX]; @@ -138,14 +120,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( exp_argument = max( exp_argument, -23.0f ); pOutput_ene[idx] *= expf( exp_argument ); } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_reverb_set_energies( hHrtfStatistics->average_energy_l, hHrtfStatistics->average_energy_r, output_Fs, avg_pwr_left, avg_pwr_right ); -#else - if ( ( error = ivas_reverb_get_fastconv_hrtf_set_energies( hHrtfFastConv, input_audio_config, use_brir, output_Fs, avg_pwr_left, avg_pwr_right ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif for ( idx = 0; idx < CLDFB_NO_CHANNELS_MAX; idx++ ) { @@ -155,122 +130,7 @@ ivas_error ivas_reverb_prepare_cldfb_params( return IVAS_ERR_OK; } -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -/*-----------------------------------------------------------------------------------------* - * Function ivas_cldfb_convolver() - * - * Function for convolving CLDFB-domain data with filter taps - *-----------------------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------------------------* - * Function get_IR_from_filter_taps() - * - * Function converts CLDFB filter taps into time-domain data - *-----------------------------------------------------------------------------------------*/ - -/*-----------------------------------------------------------------------------------------* - * Function ivas_reverb_get_cldfb_hrtf_set_properties() - * - * Function analyses the HRTF set and computes avarage left/right power spectrum - * and frequency-dependent IA coherence. - * Uses fastconv renderer filter taps to compute energies - *-----------------------------------------------------------------------------------------*/ - -static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( - AUDIO_CONFIG input_audio_config, - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, - const int16_t use_brir, - const int32_t sampling_rate, - float *avg_pwr_left, - float *avg_pwr_right ) -{ - float current_HRTF_data_L[L_FRAME48k]; - float current_HRTF_data_R[L_FRAME48k]; - int16_t freq_idx, hrtf_idx, hrtf_count; - float hrtf_count_inverted; - int16_t fft_size, log2_fft_size, half_fft_size, freq_count; - ivas_error error; - UNUSED_PARAM( error ); - fft_size = RV_FILTER_MAX_FFT_SIZE; - Word16 IR_length; - IR_length = CLDFB_NO_CHANNELS_MAX * ( ( fft_size + CLDFB_NO_CHANNELS_MAX - 1 ) / CLDFB_NO_CHANNELS_MAX ); - log2_fft_size = int_log2( fft_size ); - half_fft_size = fft_size >> 1; - freq_count = 1 + half_fft_size; - - /* chosing between ambisonics, 5.1 and 7.1 MC audio */ - if ( ( input_audio_config == IVAS_AUDIO_CONFIG_FOA ) || ( input_audio_config == IVAS_AUDIO_CONFIG_HOA2 ) || ( input_audio_config == IVAS_AUDIO_CONFIG_HOA3 ) ) - { - hrtf_count = 1; - } - else if ( input_audio_config == IVAS_AUDIO_CONFIG_7_1 ) - { - hrtf_count = 7; - } - else - { - hrtf_count = 5; - input_audio_config = IVAS_AUDIO_CONFIG_5_1; - } - - /* Zeroing before accumalation for average value computing */ - for ( freq_idx = 0; freq_idx < freq_count; freq_idx++ ) - { - avg_pwr_left[freq_idx] = 0.0f; - avg_pwr_right[freq_idx] = 0.0f; - } - - /* Get power spectra and cross - correlation between left and right hrtfs - Loop over all the HRTFs available */ - for ( hrtf_idx = 0; hrtf_idx < hrtf_count; hrtf_idx++ ) - { - UNUSED_PARAM( hHrtfFastConv ); - UNUSED_PARAM( use_brir ); - UNUSED_PARAM( sampling_rate ); - UNUSED_PARAM( IR_length ); - - /* Perform forward FFT on both L/R channels */ - fft_rel( current_HRTF_data_L, (int16_t) fft_size, (int16_t) log2_fft_size ); - fft_rel( current_HRTF_data_R, (int16_t) fft_size, (int16_t) log2_fft_size ); - - /* Process the DC bin (without img part) */ - avg_pwr_left[0] += current_HRTF_data_L[0] * current_HRTF_data_L[0]; - avg_pwr_right[0] += current_HRTF_data_R[0] * current_HRTF_data_R[0]; - - /* Process the Nyquist frequency bin (without img part) */ - avg_pwr_left[half_fft_size] += current_HRTF_data_L[half_fft_size] * current_HRTF_data_L[half_fft_size]; - avg_pwr_right[half_fft_size] += current_HRTF_data_R[half_fft_size] * current_HRTF_data_R[half_fft_size]; - - /* Process the other frequency bins containing both real and img parts */ - for ( freq_idx = 1; freq_idx < half_fft_size; freq_idx++ ) - { - float L_re, L_im, R_re, R_im; - L_re = current_HRTF_data_L[freq_idx]; - R_re = current_HRTF_data_R[freq_idx]; - L_im = current_HRTF_data_L[fft_size - freq_idx]; - R_im = current_HRTF_data_R[fft_size - freq_idx]; - - avg_pwr_left[freq_idx] += L_re * L_re + L_im * L_im; - avg_pwr_right[freq_idx] += R_re * R_re + R_im * R_im; - } - } - - /* Compute the averages and the IA coherence */ - hrtf_count_inverted = 1.0f / (float) hrtf_count; - for ( freq_idx = 0; freq_idx < freq_count; freq_idx++ ) - { - avg_pwr_left[freq_idx] *= hrtf_count_inverted; - avg_pwr_right[freq_idx] *= hrtf_count_inverted; - } - - return IVAS_ERR_OK; -} - -#endif - -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_set_energies() * @@ -281,29 +141,11 @@ static ivas_error ivas_reverb_get_cldfb_hrtf_set_properties( static void ivas_reverb_set_energies( const Word32 *avg_pwr_l, const Word32 *avg_pwr_r, -#else -/*-----------------------------------------------------------------------------------------* - * Function ivas_reverb_get_fastconv_hrtf_set_energies() - * - * Function analyses the HRTF set and computes avarage left/right power spectrum. - * Uses fastconv renderer filter taps to compute energies. Output interpolated - * to CLDFB bin center frequencies - *-----------------------------------------------------------------------------------------*/ - -static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( - const HRTFS_FASTCONV_HANDLE hHrtfFastConv, - const AUDIO_CONFIG input_audio_config, - const int16_t use_brir, -#endif const int32_t sampling_rate, float *avg_pwr_left, float *avg_pwr_right ) { int16_t freq_idx; -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - float avg_pwr_left_fft[FFT_SPECTRUM_SIZE]; - float avg_pwr_right_fft[FFT_SPECTRUM_SIZE]; -#endif float input_fc[FFT_SPECTRUM_SIZE]; #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 input_fc_fx[FFT_SPECTRUM_SIZE]; @@ -315,11 +157,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( const Word16 cldfb_freq_halfstep = MAX_SAMPLING_RATE / ( 4 * CLDFB_NO_CHANNELS_MAX ); #endif -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - ivas_error error; -#endif -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const int16_t avg_pwr_len = sampling_rate == 16000 ? LR_IAC_LENGTH_NR_FC_16KHZ : LR_IAC_LENGTH_NR_FC; for ( freq_idx = 0; freq_idx < avg_pwr_len; freq_idx++ ) @@ -336,14 +174,7 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( output_fc_fx[freq_idx] = ( ( freq_idx << 1 ) + 1 ) * cldfb_freq_halfstep * ONE_IN_Q16; } #endif -#else - for ( freq_idx = 0; freq_idx < FFT_SPECTRUM_SIZE; freq_idx++ ) - { - input_fc[freq_idx] = freq_idx * ( 0.5f * sampling_rate / (float) ( FFT_SPECTRUM_SIZE - 1 ) ); - } -#endif -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifndef FIX_1741_REVERB_TIMES_Q_FORMAT Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 ) ); @@ -390,49 +221,4 @@ static ivas_error ivas_reverb_get_fastconv_hrtf_set_energies( free( avg_pwr_right_fx ); #endif -#else - if ( ( error = ivas_reverb_get_cldfb_hrtf_set_properties( input_audio_config, hHrtfFastConv, use_brir, sampling_rate, avg_pwr_left_fft, avg_pwr_right_fft ) ) != IVAS_ERR_OK ) - { - return error; - } - Word32 *input_fc_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); - Word32 *avg_pwr_left_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); - Word32 *avg_pwr_right_fft_fx = (Word32 *) malloc( 60 * sizeof( Word32 * ) ); - - Word32 *output_fc_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word32 *avg_pwr_left_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word16 *avg_pwr_left_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); - Word32 *avg_pwr_right_fx = (Word32 *) malloc( 257 * sizeof( Word32 * ) ); - Word16 *avg_pwr_right_e = (Word16 *) malloc( 257 * sizeof( Word16 * ) ); - - for ( int i = 0; i < 60; i++ ) - { - input_fc_fx[i] = (Word32) input_fc[i] * ( 1 << 16 ); - avg_pwr_left_fft_fx[i] = (Word32) ( avg_pwr_left_fft[i] ) * ONE_IN_Q26; - avg_pwr_right_fft_fx[i] = (Word32) avg_pwr_right_fft[i] * ONE_IN_Q30; - } - - for ( int i = 0; i < 257; i++ ) - { - output_fc_fx[i] = (Word32) input_fc[i] * ONE_IN_Q16; - } - - ivas_reverb_interpolate_acoustic_data_fx( FFT_SPECTRUM_SIZE, input_fc_fx, avg_pwr_left_fft_fx, avg_pwr_right_fft_fx, - CLDFB_NO_CHANNELS_MAX, output_fc_fx, avg_pwr_left_fx, avg_pwr_right_fx, avg_pwr_left_e, avg_pwr_right_e ); - for ( int i = 0; i < 257; i++ ) - { - avg_pwr_left[i] = (float) fabs( me2f( avg_pwr_left_fx[i], avg_pwr_left_e[i] ) ); - avg_pwr_right[i] = (float) fabs( me2f( avg_pwr_right_fx[i], avg_pwr_right_e[i] ) ); - } - - free( input_fc_fx ); - free( avg_pwr_left_fft_fx ); - free( avg_pwr_right_fft_fx ); - free( output_fc_fx ); - free( avg_pwr_left_fx ); - free( avg_pwr_left_e ); - free( avg_pwr_right_fx ); - free( avg_pwr_right_e ); - return IVAS_ERR_OK; -#endif } diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 50e3d7f6c..747af4048 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1206,11 +1206,6 @@ typedef struct TDREND_HRFILT_FiltSet_struct ModelParamsITD_t ModelParamsITD; TDREND_HRFILT_Method_t FilterMethod; /* HR filtering method */ Word32 latency_s_fx; /* Q31 */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else - const Word32 *lr_energy_and_iac_fx[3]; /* left/right energy and interaural coherence for late reverb */ - Word32 *lr_energy_and_iac_dyn_fx[3]; -#endif } TDREND_HRFILT_FiltSet_t; /* Distance attenuation */ @@ -1478,7 +1473,6 @@ typedef struct ivas_hrtfs_parambin_struct #endif -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES typedef struct ivas_hrtfs_statistics_struct { const Word32 *average_energy_l; @@ -1489,7 +1483,6 @@ typedef struct ivas_hrtfs_statistics_struct Word32 *inter_aural_coherence_dyn; int16_t fromROM; /* Flag that indicates that the pointers point to tables in ROM (controls init/dealloc).*/ } HRTFS_STATISTICS, *HRTFS_STATISTICS_HANDLE; -#endif /*----------------------------------------------------------------------------------* diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1300d6340..41fbff92d 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -209,12 +209,10 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( IVAS_DEC_HRTF_PARAMBIN_HANDLE **hHrtfParambin /* o : Parametric binauralizer HRTF handle */ ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_error IVAS_REND_GetHrtfStatisticsHandle( IVAS_REND_HANDLE hIvasRend, /* i/o: IVAS renderer handle */ IVAS_DEC_HRTF_STATISTICS_HANDLE **hHrtfStatistics /* o : HRTF statistics handle */ ); -#endif /* Functions to be called during rendering */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 97b83b7b6..ee83f69c7 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -196,9 +196,7 @@ typedef struct hrtf_handles IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv; IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_HRTF_HANDLE hHrtfTD; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics; -#endif } hrtf_handles; struct IVAS_REND @@ -234,11 +232,7 @@ struct IVAS_REND /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, const RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hHrtfs ); -#else -static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, hrtf_handles *hHrtfs ); -#endif static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut ); static void intermidiate_ext_dirac_render( @@ -1578,22 +1572,14 @@ static ivas_error setRendInputActiveIsm( IF( EQ_16( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), hrtfs->hHrtfStatistics, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputIsm->hReverb ), outConfig, NULL, inputIsm->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, *rendCtx.pOutSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } } ELSE IF( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputIsm->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hrtfs->hSetOfHRTF, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2404,9 +2390,7 @@ static ivas_error initMcBinauralRendering( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv, -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES HRTFS_STATISTICS_HANDLE hHrtfStatistics, -#endif uint8_t reconfigureFlag ) { ivas_error error; @@ -2556,11 +2540,7 @@ static ivas_error initMcBinauralRendering( test(); IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) && inputMc->hReverb == NULL ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), hHrtfStatistics, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_reverb_open_fx( &( inputMc->hReverb ), outConfig, NULL, inputMc->tdRendWrapper.hBinRendererTd->HrFiltSet_p->lr_energy_and_iac_fx, hRendCfg, outSampleRate ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2569,16 +2549,9 @@ static ivas_error initMcBinauralRendering( ELSE IF( !useTDRend && inputMc->crendWrapper == NULL ) { /* open CREND */ -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( inConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputMc->crendWrapper, ( EQ_16( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) ? IVAS_AUDIO_CONFIG_7_1_4 : inConfig, outConfig, hRendCfg, - hMixconv, - outSampleRate, ( ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) ? inputMc->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses : 1 ) ), - IVAS_ERR_OK ) ) -#endif { return error; } @@ -2784,11 +2757,7 @@ static ivas_error setRendInputActiveMc( IF( EQ_32( getAudioConfigType( outConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = initMcBinauralRendering( inputMc, inConfig, outConfig, hRendCfg, hrtfs->hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -2944,10 +2913,8 @@ static ivas_error updateSbaPanGains( const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, IVAS_DEC_HRTF_CREND_HANDLE hMixconv -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES , IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics -#endif ) { @@ -3007,11 +2974,7 @@ static ivas_error updateSbaPanGains( } else { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, inConfig, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -3024,11 +2987,7 @@ static ivas_error updateSbaPanGains( { return error; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, hHrtfStatistics, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_rend_openCrend( &inputSba->crendWrapper, IVAS_AUDIO_CONFIG_7_1_4, outConfig, hRendCfg, hMixconv, *rendCtx.pOutSampleRate, rendCtx.pSplitRendWrapper->multiBinPoseData.num_poses ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -3120,11 +3079,7 @@ static ivas_error setRendInputActiveSba( return error; } } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = updateSbaPanGains( inputSba, outConfig, hRendCfg, hrtfs->hSetOfHRTF ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -3160,11 +3115,7 @@ static ivas_error setRendInputActiveMasa( const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hrtfs -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ) -#else - ) /* Todo: This is not used at all within MASA. Support might be better to do after refactoring. */ -#endif { ivas_error error; rendering_context rendCtx; @@ -3176,9 +3127,6 @@ static ivas_error setRendInputActiveMasa( rendCtx = inputMasa->base.ctx; outConfig = *rendCtx.pOutConfig; move32(); -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - (void) hRendCfg; /* Suppress warning */ -#endif IF( !isIoConfigPairSupported( inConfig, outConfig ) ) { @@ -3217,11 +3165,7 @@ static ivas_error setRendInputActiveMasa( } ELSE { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hRendCfg, hrtfs ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = initMasaExtRenderer( inputMasa, outConfig, hrtfs ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -3407,9 +3351,7 @@ ivas_error IVAS_REND_Open( hIvasRend->hHrtfs.hHrtfParambin = NULL; hIvasRend->hHrtfs.hHrtfTD = NULL; hIvasRend->hHrtfs.hSetOfHRTF = NULL; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES hIvasRend->hHrtfs.hHrtfStatistics = NULL; -#endif IF( asHrtfBinary ) { IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( hIvasRend->hHrtfs.hHrtfTD ) ) ), IVAS_ERR_OK ) ) @@ -3428,19 +3370,15 @@ ivas_error IVAS_REND_Open( { return error; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &( hIvasRend->hHrtfs.hHrtfStatistics ) ) ), IVAS_ERR_OK ) ) { return error; } -#endif } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = ivas_HRTF_statistics_init( &( hIvasRend->hHrtfs.hHrtfStatistics ), hIvasRend->sampleRateOut ) ), IVAS_ERR_OK ) ) { return error; } -#endif return IVAS_ERR_OK; } @@ -3588,11 +3526,7 @@ ivas_error IVAS_REND_ConfigureCustomOutputLoudspeakerLayout( /* Input inactive, skip. */ CONTINUE; } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL, NULL ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = updateSbaPanGains( inputSba, hIvasRend->outputConfig, hIvasRend->hRendererConfig, NULL ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -4101,11 +4035,7 @@ ivas_error IVAS_REND_ConfigureCustomInputLoudspeakerLayout( IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, FALSE ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = initMcBinauralRendering( inputMc, inputMc->base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, FALSE ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -4907,11 +4837,7 @@ ivas_error IVAS_REND_SetHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, TRUE ) ), IVAS_ERR_OK ) ) -#endif { return error; } @@ -5005,11 +4931,7 @@ ivas_error IVAS_REND_DisableHeadRotation( { IF( NE_32( hIvasRend->inputsMc[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, hIvasRend->hHrtfs.hHrtfStatistics, TRUE ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = initMcBinauralRendering( &hIvasRend->inputsMc[i], hIvasRend->inputsMc[i].base.inConfig, hIvasRend->outputConfig, hIvasRend->hRendererConfig, hIvasRend->hHrtfs.hSetOfHRTF, TRUE ) ), IVAS_ERR_OK ) ) -#endif { return error; @@ -8969,9 +8891,7 @@ void IVAS_REND_Close( ivas_HRTF_CRend_binary_close_fx( &( hIvasRend->hHrtfs.hSetOfHRTF ) ); ivas_HRTF_fastconv_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfFastConv ) ); ivas_HRTF_parambin_binary_close_fx( &( hIvasRend->hHrtfs.hHrtfParambin ) ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES ivas_HRTF_statistics_close( &( hIvasRend->hHrtfs.hHrtfStatistics ) ); -#endif free( hIvasRend ); *phIvasRend = NULL; @@ -9203,7 +9123,6 @@ ivas_error IVAS_REND_GetHrtfParamBinHandle( } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * IVAS_REND_GetHrtfStatisticsHandle( ) * @@ -9224,7 +9143,6 @@ ivas_error IVAS_REND_GetHrtfStatisticsHandle( return IVAS_ERR_OK; } -#endif static ivas_error ivas_masa_ext_rend_dirac_rend_init( input_masa *inputMasa ) @@ -9655,13 +9573,9 @@ static ivas_error ivas_masa_ext_rend_dirac_rend_init( static ivas_error ivas_masa_ext_rend_parambin_init( -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES input_masa *inputMasa, /* i/o: MASA external renderer structure */ const RENDER_CONFIG_DATA *hRendCfg, /* i : Renderer configuration data handle */ HRTFS_STATISTICS_HANDLE hHrtfStatistics /* i : HRTF statistics */ -#else - input_masa *inputMasa /* i/o: MASA external renderer structure */ -#endif ) { DIRAC_DEC_BIN_HANDLE hDiracDecBin; @@ -9802,15 +9716,10 @@ static ivas_error ivas_masa_ext_rend_parambin_init( IF( hDiracDecBin->hReverb == NULL && pos_idx == 0 ) /* open reverb only for the main direction */ { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF if ( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, ( *phHrtfParambin )->parametricReverberationTimes_fx, ( *phHrtfParambin )->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) #else IF( NE_32( ( error = ivas_binaural_reverb_init( &hDiracDecBin->hReverb, hHrtfStatistics, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, &( hRendCfg->roomAcoustics ), output_Fs, hHrtfParambin->parametricReverberationTimes_fx, hHrtfParambin->parametricReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) -#endif -#else - /* Todo Philips: Room acoustics should be passed here once the underlying part works. In this case, it probably should come from render context or somewhere else suitable. */ - IF( NE_32( ( error = ivas_binaural_reverb_open_parambin( &hDiracDecBin->hReverb, nBins, CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES, NULL, output_Fs, hHrtfParambin ) ), IVAS_ERR_OK ) ) #endif { return error; @@ -9867,9 +9776,7 @@ static ivas_error ivas_masa_ext_rend_parambin_init( static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES const RENDER_CONFIG_DATA *hRendCfg, -#endif hrtf_handles *hrtfs ) { Word16 i; @@ -10003,11 +9910,7 @@ static ivas_error initMasaExtRenderer( return error; } } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa, hRendCfg, hrtfs->hHrtfStatistics ) ), IVAS_ERR_OK ) ) -#else - IF( NE_32( ( error = ivas_masa_ext_rend_parambin_init( inputMasa ) ), IVAS_ERR_OK ) ) -#endif { return error; } diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 7e38a1a08..abf157d9c 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -574,98 +574,6 @@ static ivas_error LoadBSplineBinary( return IVAS_ERR_OK; } -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -/*-------------------------------------------------------------------* - * set_default_reverb_iac_energy() - * - * Loads reverb data from file. - --------------------------------------------------------------------*/ - -static ivas_error set_default_reverb_iac_energy( - IVAS_DEC_HRTF_HANDLE HrFiltSet_p /* i/o: HR filter model parameter structure */ -) -{ - int16_t i; - int16_t lr_iac_len; - - if ( HrFiltSet_p == NULL ) - { - return IVAS_ERR_UNEXPECTED_NULL_POINTER; - } - - lr_iac_len = LR_IAC_LENGTH_NR_FC; - if ( HrFiltSet_p->SampleRate == 16000 ) - { - lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; - } - - if ( HrFiltSet_p->ModelParams.modelROM == 0 ) - { - for ( i = 0; i < 3; i++ ) - { - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); - if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - } - switch ( HrFiltSet_p->SampleRate ) - { - case 48000: - mvl2l( defaultHRIR_left_avg_power_48kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_right_avg_power_48kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_coherence_48kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], LR_IAC_LENGTH_NR_FC ); - break; - case 32000: - mvl2l( defaultHRIR_left_avg_power_32kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_right_avg_power_32kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], LR_IAC_LENGTH_NR_FC ); - mvl2l( defaultHRIR_coherence_32kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], LR_IAC_LENGTH_NR_FC ); - break; - case 16000: - floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], Q27, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - break; - } - } - else - { - switch ( HrFiltSet_p->SampleRate ) - { - case 48000: - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_48kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_48kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_48kHz_fx; - break; - case 32000: - HrFiltSet_p->lr_energy_and_iac_fx[0] = defaultHRIR_left_avg_power_32kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[1] = defaultHRIR_right_avg_power_32kHz_fx; - HrFiltSet_p->lr_energy_and_iac_fx[2] = defaultHRIR_coherence_32kHz_fx; - break; - case 16000: - for ( i = 0; i < 3; i++ ) - { - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); - if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - } - floatToFixed_arr32( defaultHRIR_coherence_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[2], Q27, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[1], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - floatToFixed_arr32( defaultHRIR_left_avg_power_16kHz_fx, HrFiltSet_p->lr_energy_and_iac_dyn_fx[0], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - HrFiltSet_p->lr_energy_and_iac_fx[0] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[0]; - HrFiltSet_p->lr_energy_and_iac_fx[1] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[1]; - HrFiltSet_p->lr_energy_and_iac_fx[2] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[2]; - - - break; - } - } - - return IVAS_ERR_OK; -} -#endif /*-------------------------------------------------------------------* * load_reverb_from_binary() @@ -674,18 +582,11 @@ static ivas_error set_default_reverb_iac_energy( --------------------------------------------------------------------*/ static ivas_error load_reverb_from_binary( -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ -#else - IVAS_DEC_HRTF_HANDLE HrFiltSet_p, /* i/o: HR filter model parameter structure */ -#endif FILE *f_hrtf /* i : HR filter data file handle */ ) { -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - int16_t i; -#endif bool is_reverb; ivas_error header_check_result; ivas_hrtfs_file_header_t hrtfs_file_header; @@ -696,21 +597,13 @@ static ivas_error load_reverb_from_binary( int16_t lr_iac_len; float f_tmp_lr_energy_and_iac_dyn[LR_IAC_LENGTH_NR_FC]; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( hHrtfStatistics == NULL ) -#else - if ( HrFiltSet_p == NULL ) -#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } lr_iac_len = LR_IAC_LENGTH_NR_FC; -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES if ( sampleRate == 16000 ) -#else - if ( HrFiltSet_p->SampleRate == 16000 ) -#endif { lr_iac_len = LR_IAC_LENGTH_NR_FC_16KHZ; } @@ -771,7 +664,6 @@ static ivas_error load_reverb_from_binary( if ( is_reverb ) { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES hHrtfStatistics->average_energy_l_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->average_energy_r_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); hHrtfStatistics->inter_aural_coherence_dyn = (Word32 *) malloc( lr_iac_len * sizeof( Word32 ) ); @@ -793,37 +685,9 @@ static ivas_error load_reverb_from_binary( fread( f_tmp_lr_energy_and_iac_dyn, sizeof( float ), lr_iac_len, f_hrtf ); floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, hHrtfStatistics->inter_aural_coherence_dyn, Q26, lr_iac_len ); hHrtfStatistics->fromROM = FALSE; -#else - /* left/right energy and interaural coherence for late reverb */ - FOR( i = 0; i < 3; i++ ) - { - HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] = (Word32 *) malloc( lr_iac_len * sizeof( float ) ); - if ( HrFiltSet_p->lr_energy_and_iac_dyn_fx[i] == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for hrtf data" ); - } - fread( f_tmp_lr_energy_and_iac_dyn, sizeof( const float ), lr_iac_len, f_hrtf ); - IF( i == 2 ) - { - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q27, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q27 for i=2 */ - } - ELSE - { - floatToFixed_arr32( f_tmp_lr_energy_and_iac_dyn, HrFiltSet_p->lr_energy_and_iac_dyn_fx[i], Q23, lr_iac_len ); /* tables from which lr_energy_and_iac is updated has Q23 for i=0,1 */ - } - HrFiltSet_p->lr_energy_and_iac_fx[i] = (const Word32 *) HrFiltSet_p->lr_energy_and_iac_dyn_fx[i]; - } -#endif } else { -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES -#else - if ( ( header_check_result = set_default_reverb_iac_energy( HrFiltSet_p ) ) != IVAS_ERR_OK ) - { - return header_check_result; - } -#endif return IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA; } @@ -837,22 +701,14 @@ static ivas_error load_reverb_from_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ -#else - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ -#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { fseek( hrtfReader->file, 0, SEEK_SET ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES return load_reverb_from_binary( hHrtfStatistics, sampleRate, hrtfReader->file ); -#else - return load_reverb_from_binary( hHrtf, hrtfReader->file ); -#endif } /*-------------------------------------------------------------------* * TDREND_MIX_LoadHRTF() @@ -1116,25 +972,7 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL_fx ); free( ( *hHrtf )->ModelEval.hrfModR_fx ); -#ifndef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES - for ( i = 0; i < 3; i++ ) - { - free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ); - } } - else - { - for ( i = 0; i < 3; i++ ) - { - if ( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ) - { - free( ( *hHrtf )->lr_energy_and_iac_dyn_fx[i] ); - } - } - } -#else - } -#endif ivas_HRTF_binary_close_fx( hHrtf ); @@ -2298,7 +2136,6 @@ void destroy_SetOfHRTF( } -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -2326,7 +2163,6 @@ void destroy_hrtf_statistics( } ivas_HRTF_statistics_close( hHrtfStatistics ); } -#endif /*---------------------------------------------------------------------* * destroy_fastconv_hrtf() diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 91e68b358..904182ab3 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -99,12 +99,8 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error load_reverb_binary( -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ -#else - IVAS_DEC_HRTF_HANDLE hHrtf, /* i/o: HRTF handle */ -#endif const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); @@ -164,7 +160,6 @@ ivas_error load_parambin_HRTF_from_binary( const hrtfFileReader *hrtfReader /* i : pointer to hrtfFileReader handle */ ); -#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES /*---------------------------------------------------------------------* * destroy_hrtf_statistics() * @@ -174,7 +169,6 @@ ivas_error load_parambin_HRTF_from_binary( void destroy_hrtf_statistics( IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics /* i/o: HRTF statistics handle */ ); -#endif /*---------------------------------------------------------------------* * dealloc_HRTF_binary() -- GitLab From a3b7687d08b1178ef4b0af3c63b12503aac545a8 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:23:06 +0200 Subject: [PATCH 537/692] [cleanup] accept FIX_777_COMBI_RENDER_CONFIG_FILE --- lib_com/options.h | 1 - lib_util/render_config_reader.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index fb009faea..7a8ea4d33 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -114,7 +114,6 @@ -#define FIX_777_COMBI_RENDER_CONFIG_FILE /* Philips: Fix for combined renderer config file support */ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 8df6c0d42..bd9e7a48e 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -2249,11 +2249,7 @@ ivas_error RenderConfigReader_read( /* RT60 */ else if ( strcmp( item, "RT60" ) == 0 ) { -#ifdef FIX_777_COMBI_RENDER_CONFIG_FILE if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) -#else - if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pAE[acIdx].pRT60 ) ) -#endif { errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; @@ -2263,11 +2259,7 @@ ivas_error RenderConfigReader_read( /* DSR */ else if ( strcmp( item, "DSR" ) == 0 ) { -#ifdef FIX_777_COMBI_RENDER_CONFIG_FILE if ( read_txt_vector( pValue, pRenderConfigReader->pAE[acIdx].pFG->nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) -#else - if ( read_txt_vector( pValue, pRenderConfigReader->pFG[idx].nrBands, pRenderConfigReader->pAE[acIdx].pDSR ) ) -#endif { errorHandler( item, ERROR_VALUE_INVALID ); return IVAS_ERR_INVALID_RENDER_CONFIG; -- GitLab From a8de754fdbc8a9075d622f5df195bc9b10a4f646 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Tue, 8 Jul 2025 15:24:13 +0200 Subject: [PATCH 538/692] formatting --- lib_dec/ivas_init_dec_fx.c | 74 +++++++++++++------------ lib_rend/ivas_reverb_filter_design_fx.c | 1 - lib_rend/ivas_reverb_fx.c | 4 +- lib_rend/ivas_reverb_utils_fx.c | 1 - lib_rend/lib_rend_fx.c | 6 +- lib_util/hrtf_file_reader.c | 5 +- lib_util/hrtf_file_reader.h | 2 +- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index ef3d8c6e9..40bf1ccf5 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -1143,52 +1143,54 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ - IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ){ - IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ){ + IF( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + { + IF( NE_32( ( error = ivas_HRTF_binary_open_fx( &( st_ivas->hHrtfTD ) ) ), IVAS_ERR_OK ) ) + { return error; -} - -IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) ) -{ - return error; -} + } -IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) -{ - return error; -} + IF( NE_32( ( error = ivas_HRTF_CRend_binary_open_fx( &( st_ivas->hSetOfHRTF ) ) ), IVAS_ERR_OK ) ) + { + return error; + } -IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) -{ - return error; -} + IF( NE_32( ( error = ivas_HRTF_fastconv_binary_open_fx( &st_ivas->hHrtfFastConv ) ), IVAS_ERR_OK ) ) + { + return error; + } -IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) -{ - return error; -} -} + IF( NE_32( ( error = ivas_HRTF_parambin_binary_open_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) ) + { + return error; + } -/*-------------------------------------------------------------------* - * Allocate and initialize Binaural Renderer configuration handle - *--------------------------------------------------------------------*/ -test(); -test(); -IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || - ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) -{ - IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) - { - return error; + IF( NE_32( ( error = ivas_HRTF_statistics_binary_open( &st_ivas->hHrtfStatistics ) ), IVAS_ERR_OK ) ) + { + return error; + } } - IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) ) + /*-------------------------------------------------------------------* + * Allocate and initialize Binaural Renderer configuration handle + *--------------------------------------------------------------------*/ + test(); + test(); + IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || + ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) { - return error; + IF( NE_32( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) ) + { + return error; + } + + IF( NE_32( ( error = ivas_render_config_init_from_rom_fx( &st_ivas->hRenderConfig ) ), IVAS_ERR_OK ) ) + { + return error; + } } -} -return error; + return error; } diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index 0b8642120..a40fcfac8 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -1002,4 +1002,3 @@ void ivas_reverb_interpolate_energies_fx( return; } #endif - diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index b6a634bb7..761f87ef8 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -1421,9 +1421,9 @@ static ivas_error setup_FDN_branches_fx( *------------------------------------------------------------------------*/ ivas_error ivas_reverb_open_fx( - REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ + REVERB_HANDLE *hReverb, /* i/o: Reverberator handle */ const HRTFS_STATISTICS_HANDLE hHrtfStatistics, /* i : HRTF statistics handle */ - RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ + RENDER_CONFIG_HANDLE hRenderConfig, /* i : Renderer configuration handle */ const int32_t output_Fs ) { ivas_error error; diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 84fa82bce..cfbfd7315 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -220,5 +220,4 @@ static void ivas_reverb_set_energies( free( avg_pwr_left_fx ); free( avg_pwr_right_fx ); #endif - } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index ee83f69c7..050da6393 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -2912,8 +2912,7 @@ static ivas_error updateSbaPanGains( input_sba *inputSba, const AUDIO_CONFIG outConfig, RENDER_CONFIG_DATA *hRendCfg, - IVAS_DEC_HRTF_CREND_HANDLE hMixconv - , + IVAS_DEC_HRTF_CREND_HANDLE hMixconv, IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics ) @@ -3114,8 +3113,7 @@ static ivas_error setRendInputActiveMasa( const AUDIO_CONFIG inConfig, const IVAS_REND_InputId id, RENDER_CONFIG_DATA *hRendCfg, - hrtf_handles *hrtfs -) + hrtf_handles *hrtfs ) { ivas_error error; rendering_context rendCtx; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index abf157d9c..9a89badaf 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -584,7 +584,7 @@ static ivas_error LoadBSplineBinary( static ivas_error load_reverb_from_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ - FILE *f_hrtf /* i : HR filter data file handle */ + FILE *f_hrtf /* i : HR filter data file handle */ ) { bool is_reverb; @@ -703,7 +703,7 @@ static ivas_error load_reverb_from_binary( ivas_error load_reverb_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ) { fseek( hrtfReader->file, 0, SEEK_SET ); @@ -971,7 +971,6 @@ void destroy_td_hrtf( free( ( *hHrtf )->ModelEval.hrfModL_fx ); free( ( *hHrtf )->ModelEval.hrfModR_fx ); - } ivas_HRTF_binary_close_fx( hHrtf ); diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 904182ab3..c0b44e29b 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -101,7 +101,7 @@ ivas_error load_HRTF_binary( ivas_error load_reverb_binary( IVAS_DEC_HRTF_STATISTICS_HANDLE hHrtfStatistics, /* i/o: HRTF statistics handle */ int32_t sampleRate, /* i : sample rate */ - const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ + const hrtfFileReader *hrtfReader /* i/o: pointer to hrtfFileReader handle */ ); /*---------------------------------------------------------------------* -- GitLab From 8e2135bd0ded893d56d440b3d11a96b143d32d03 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 9 Jul 2025 06:38:32 +0530 Subject: [PATCH 539/692] 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 540/692] 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 541/692] 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 542/692] 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 543/692] 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 544/692] 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 545/692] 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 546/692] 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 547/692] 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 548/692] 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 549/692] 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 550/692] 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 551/692] 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 552/692] 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 553/692] 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 554/692] 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 555/692] 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 556/692] 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 557/692] 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 558/692] 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 559/692] 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 560/692] 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 561/692] 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 562/692] 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 563/692] 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 564/692] 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 565/692] 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 566/692] 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 567/692] 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 568/692] 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 569/692] 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 570/692] 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 571/692] 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 572/692] 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 573/692] 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 574/692] 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 575/692] 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 576/692] 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 577/692] 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 578/692] 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 579/692] 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 580/692] 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 581/692] 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 582/692] 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 583/692] 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 584/692] 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 585/692] 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 586/692] 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 587/692] 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 588/692] 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 589/692] 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 590/692] 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 591/692] 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 592/692] 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 593/692] 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 594/692] 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 595/692] 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 596/692] 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 597/692] 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 598/692] 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 599/692] 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 600/692] 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 601/692] 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 602/692] 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 603/692] 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 604/692] 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 605/692] 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 606/692] 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 607/692] 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 608/692] 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 609/692] 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 fca13dbc7f379ce2301e365145ec40efd46ab443 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 16 Jul 2025 12:10:12 +0200 Subject: [PATCH 610/692] apply clang-format --- lib_dec/ivas_dirac_dec_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 0337643f0..3ffcde306 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -1883,8 +1883,8 @@ void ivas_qmetadata_to_dirac_fx( } /* for ( block =...) */ - } /* for ( band = ...) */ - } /* for ( idx_sec = ...)*/ + } /* for ( band = ...) */ + } /* for ( idx_sec = ...)*/ /* Bands not transmitted -> zeroed*/ FOR( b = band_grouping[band]; b < hSpatParamRendCom->num_freq_bands; b++ ) @@ -3940,8 +3940,8 @@ void ivas_dirac_dec_render_sf_fx( 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 + 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 ); } -- GitLab From 2442c7da345f011c83f362f624affe18e6122aec Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 14 Jul 2025 11:38:58 +0530 Subject: [PATCH 611/692] 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 612/692] 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 613/692] 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 614/692] 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 615/692] 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 616/692] 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 617/692] 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 618/692] 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 619/692] 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 From 6ea80024df77b2923d69be8e00238b6321420481 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 09:14:49 +0200 Subject: [PATCH 620/692] Keep same commit in pipelines --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9482f081f..9b0ffb3b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -238,8 +238,13 @@ stages: .build-merge-target-binaries: &build-merge-target-binaries - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - if [ -f $MERGE_REQUEST_TARGET_FILE ]; then + - MERGE_REQUEST_TARGET=$(echo $MERGE_REQUEST_TARGET_FILE) + - else + - echo "MERGE_REQUEST_TARGET_FILE does not exist, exiting!" + - exit 1 + - fi + - git checkout $MERGE_REQUEST_TARGET - *activate-debug-mode-info-if-set - make clean - make -j >> /dev/null @@ -496,6 +501,9 @@ stages: .test-job-linux: tags: - ivas-linux + needs: + - job: branch-is-up-to-date-with-target-pre + - artifacts: true .build-job-linux: stage: build @@ -1065,6 +1073,12 @@ branch-is-up-to-date-with-target-pre: echo "Your branch is behind the target branch, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." exit 1 fi + - git fetch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + - echo "TARGET_COMMIT is $TARGET_COMMIT" + - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE + artifacts: + - $MERGE_TARGET_COMMIT_FILE branch-is-up-to-date-with-target-post: extends: @@ -1078,8 +1092,11 @@ branch-is-up-to-date-with-target-post: - | if [ $commits_behind_count -ne 0 ]; then echo "Your branch is behind the target branch, possibly main changed during your pipeline run, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." - exit 1 + exit 123 fi + allow_failure: + exit_codes: + - 123 # fail pipeline in the final stage for pipelines on Draft MRs # this also only runs on Draft MRs, so should always fail @@ -1126,6 +1143,12 @@ branch-is-up-to-date-with-target-pre: echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 fi + - git fetch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + - echo "TARGET_COMMIT is $TARGET_COMMIT" + - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE + artifacts: + - $MERGE_TARGET_COMMIT_FILE branch-is-up-to-date-with-target-post: extends: @@ -1138,8 +1161,11 @@ branch-is-up-to-date-with-target-post: - | if [ $commits_behind_count -ne 0 ]; then echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." - exit 1 + exit 123 fi + allow_failure: + exit_codes: + - 123 clang-format-check: extends: -- GitLab From 63d9b9e93004e12533da587f3d04fc8d86c81fc4 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 09:22:03 +0200 Subject: [PATCH 621/692] Fix syntax error for artifact --- .gitlab-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b0ffb3b4..1a87d0e44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1078,7 +1078,8 @@ branch-is-up-to-date-with-target-pre: - echo "TARGET_COMMIT is $TARGET_COMMIT" - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE artifacts: - - $MERGE_TARGET_COMMIT_FILE + paths: + - $MERGE_TARGET_COMMIT_FILE branch-is-up-to-date-with-target-post: extends: @@ -1148,7 +1149,8 @@ branch-is-up-to-date-with-target-pre: - echo "TARGET_COMMIT is $TARGET_COMMIT" - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE artifacts: - - $MERGE_TARGET_COMMIT_FILE + paths: + - $MERGE_TARGET_COMMIT_FILE branch-is-up-to-date-with-target-post: extends: -- GitLab From 34e13b27475d8582675bf996b732ba2453324c54 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 13:47:44 +0200 Subject: [PATCH 622/692] Added .test-job-linux-needs-fixed-target --- .gitlab-ci.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a87d0e44..0e8e32361 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -501,10 +501,14 @@ stages: .test-job-linux: tags: - ivas-linux + +.test-job-linux-needs-fixed-target: + extends: .test-job-linux needs: - job: branch-is-up-to-date-with-target-pre - artifacts: true + .build-job-linux: stage: build timeout: "2 minutes" @@ -1410,6 +1414,7 @@ lc3-wrapper-unit-test: split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir + - .test-job-linux-needs-fixed-target - .rules-merge-request-to-main-pc needs: ["build-codec-linux-make"] timeout: "60 minutes" @@ -1503,7 +1508,7 @@ split-rendering-pytest-on-merge-request: check-be-to-target-short-enc-0db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1517,7 +1522,7 @@ check-be-to-target-short-enc-0db: check-be-to-target-short-enc-+10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1531,7 +1536,7 @@ check-be-to-target-short-enc-+10db: check-be-to-target-short-enc--10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1545,7 +1550,7 @@ check-be-to-target-short-enc--10db: check-be-to-target-short-dec-0db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1559,7 +1564,7 @@ check-be-to-target-short-dec-0db: check-be-to-target-short-dec-+10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1573,7 +1578,7 @@ check-be-to-target-short-dec-+10db: check-be-to-target-short-dec--10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1592,7 +1597,7 @@ check-regressions-short-enc-0db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1609,7 +1614,7 @@ check-regressions-short-enc-+10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1626,7 +1631,7 @@ check-regressions-short-enc--10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1643,7 +1648,7 @@ check-regressions-short-dec-0db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1660,7 +1665,7 @@ check-regressions-short-dec-+10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1677,7 +1682,7 @@ check-regressions-short-dec--10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux + - .test-job-linux-needs-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 -- GitLab From 87147385ffb5efa3d59404b9b748afcd22d0ad4b Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 13:51:56 +0200 Subject: [PATCH 623/692] Fix fetch --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e8e32361..8fbdb32a3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1077,7 +1077,7 @@ branch-is-up-to-date-with-target-pre: echo "Your branch is behind the target branch, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." exit 1 fi - - git fetch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) - echo "TARGET_COMMIT is $TARGET_COMMIT" - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE @@ -1148,7 +1148,7 @@ branch-is-up-to-date-with-target-pre: echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 fi - - git fetch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) - echo "TARGET_COMMIT is $TARGET_COMMIT" - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE -- GitLab From a32b045308060f6940a4dca558baa4cda23ca9b6 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 14:06:56 +0200 Subject: [PATCH 624/692] Fix name for commit target file --- .gitlab-ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8fbdb32a3..10c6af1ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -238,10 +238,10 @@ stages: .build-merge-target-binaries: &build-merge-target-binaries - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - - if [ -f $MERGE_REQUEST_TARGET_FILE ]; then - - MERGE_REQUEST_TARGET=$(echo $MERGE_REQUEST_TARGET_FILE) + - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then + - MERGE_REQUEST_TARGET=$(echo $MERGE_TARGET_COMMIT_FILE) - else - - echo "MERGE_REQUEST_TARGET_FILE does not exist, exiting!" + - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" - exit 1 - fi - git checkout $MERGE_REQUEST_TARGET @@ -2161,6 +2161,7 @@ voip-be-on-merge-request: renderer-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir + - .test-job-linux-needs-fixed-target - .rules-merge-request-to-main-pc needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less @@ -2217,6 +2218,7 @@ renderer-pytest-on-merge-request: ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir + - .test-job-linux-needs-fixed-target - .rules-merge-request-to-main-pc stage: compare # TODO: broken dependency needs to be removed temporarily, see above -- GitLab From a00905b74f3667f85b7cdad9c1187d28b27b7d28 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 14:22:47 +0200 Subject: [PATCH 625/692] Fix needs in check-be-to-target-anchor, extends likely overwritten --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10c6af1ec..63a460162 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -669,7 +669,7 @@ stages: .check-be-to-target-anchor: &check-be-to-target-anchor stage: check-be - needs: ["build-codec-linux-make"] + needs: ["build-codec-linux-make","branch-is-up-to-date-with-target-pre"] timeout: "300 minutes" variables: XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" -- GitLab From a342cc681afdcbd36102da4d7213e2e0f06dd8cb Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 22 Jul 2025 14:33:07 +0200 Subject: [PATCH 626/692] Syntax error --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63a460162..ae5d0e477 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -239,7 +239,7 @@ stages: - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then - - MERGE_REQUEST_TARGET=$(echo $MERGE_TARGET_COMMIT_FILE) + - MERGE_REQUEST_TARGET=$(cat $MERGE_TARGET_COMMIT_FILE) - else - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" - exit 1 -- GitLab From 6ac80834679366fed644bd9da14a30b659c1379e Mon Sep 17 00:00:00 2001 From: norvell Date: Tue, 22 Jul 2025 19:52:44 +0200 Subject: [PATCH 627/692] Apply 7 suggestion(s) to 1 file(s) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fabian Müller --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ae5d0e477..db0ca2794 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -239,7 +239,7 @@ stages: - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then - - MERGE_REQUEST_TARGET=$(cat $MERGE_TARGET_COMMIT_FILE) + - MERGE_REQUEST_TARGET="$(cat "$MERGE_TARGET_COMMIT_FILE")" - else - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" - exit 1 @@ -1077,10 +1077,10 @@ branch-is-up-to-date-with-target-pre: echo "Your branch is behind the target branch, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." exit 1 fi - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + - git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" + - TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" - echo "TARGET_COMMIT is $TARGET_COMMIT" - - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE + - echo "$TARGET_COMMIT" > "$MERGE_TARGET_COMMIT_FILE" artifacts: paths: - $MERGE_TARGET_COMMIT_FILE @@ -1148,10 +1148,10 @@ branch-is-up-to-date-with-target-pre: echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 fi - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - TARGET_COMMIT=$(git rev-parse origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) + - git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" + - TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" - echo "TARGET_COMMIT is $TARGET_COMMIT" - - echo $TARGET_COMMIT > $MERGE_TARGET_COMMIT_FILE + - echo "$TARGET_COMMIT" > "$MERGE_TARGET_COMMIT_FILE" artifacts: paths: - $MERGE_TARGET_COMMIT_FILE -- GitLab From 88ca330676b082ca9ac3265a124d41c25aa05c7d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 12:51:35 +0200 Subject: [PATCH 628/692] cleanup + make fixed ref commit work for comp stage --- .gitlab-ci.yml | 79 +++++++++++++++------------------------- .gitlab-ci/variables.yml | 10 +++++ 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index db0ca2794..215ab929b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,16 +20,26 @@ variables: # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod" DUT_DECODER_PATH: "./IVAS_dec" + DUT_RENDERER_PATH: "./IVAS_rend" + DUT_POST_RENDERER_PATH: "./ISAR_post_rend" REF_ENCODER_PATH: "./IVAS_cod_ref" REF_DECODER_PATH: "./IVAS_dec_ref" + REF_RENDERER_PATH: "./IVAS_rend_ref" + REF_POST_RENDERER_PATH: "./ISAR_post_rend_ref" MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target" MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" + MERGE_TARGET_RENDERER_PATH: "./IVAS_rend_merge_target" + MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" # These path variables are used for building the binaries # They should never be overwritten! REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" + REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_ref" + REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_ref" MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_target" MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" + MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_target" + MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_target" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" @@ -174,35 +184,16 @@ stages: # From float CI .merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec - ### build test binaries, initial clean for paranoia reasons - - make clean - - make -j - - mv IVAS_cod IVAS_cod_test - - mv IVAS_dec IVAS_dec_test - - mv IVAS_rend IVAS_rend_test - - git restore . + - *build-merge-target-binaries - ### store the current commit hash - - source_branch_commit_sha=$(git rev-parse HEAD) + # need to rename to match the conventions for the renderer tests... + - mv $MERGE_TARGET_ENCODER_PATH $REF_ENCODER_PATH + - mv $MERGE_TARGET_DECODER_PATH $REF_DECODER_PATH + - mv $MERGE_TARGET_RENDERER_PATH $REF_RENDERER_PATH + - mv $MERGE_TARGET_POST_RENDERER_PATH $REF_POST_RENDERER_PATH - ### checkout version to compare against - - *mr-fetch-target-branch - - *mr-get-target-commit - - git checkout $target_commit - - echo "Building reference codec at commit $target_commit" - - ### build reference binaries - make clean - make -j - - mv IVAS_cod IVAS_cod_ref - - mv IVAS_dec IVAS_dec_ref - - mv IVAS_rend IVAS_rend_ref - - git restore . - - # rename test binaries back - - mv IVAS_cod_test IVAS_cod - - mv IVAS_dec_test IVAS_dec - - mv IVAS_rend_test IVAS_rend .merge-request-comparison-check: &merge-request-comparison-check - echo "--------------- Running merge-request-comparison-check anchor ---------------" @@ -229,7 +220,8 @@ stages: - make -j >> /dev/null - mv ./IVAS_cod ./$REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_dec ./$REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_rend ./IVAS_rend_ref + - mv ./IVAS_rend ./$REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./ISAR_post_rend ./$REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY ### Return to current branch - git restore . - git rev-parse HEAD > $FLOAT_REF_COMMIT_FILE @@ -250,7 +242,8 @@ stages: - make -j >> /dev/null - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_rend ./IVAS_rend_merge_target + - mv ./IVAS_rend ./$MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./ISAR_post_rend ./$MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY ### Return to current branch - git restore . - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE @@ -849,10 +842,7 @@ stages: - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT ### run main now - - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - make clean - - make -j >> /dev/null + - *build-merge-target-binaries # need to restore cache again - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true @@ -1424,6 +1414,7 @@ split-rendering-pytest-on-merge-request: - *update-scripts-repo - *get-commits-behind-count - *check-commits-behind-count-in-compare-jobs + - *merge-request-comparison-setup-codec # some helper variables - "|| true" to prevent failures from grep not finding anything # write to temporary file as workaround for failures observed with piping echo @@ -1436,36 +1427,24 @@ split-rendering-pytest-on-merge-request: # store the current commit hash - source_branch_commit_sha=$(git rev-parse HEAD) - - *mr-fetch-target-branch - - *mr-get-target-commit - - git checkout $target_commit - - echo "Building reference codec at commit $target_commit" - - # build reference binaries - - make -j - - mv IVAS_cod IVAS_cod_ref - - mv IVAS_dec IVAS_dec_ref - - mv IVAS_rend IVAS_rend_ref - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - if [ $ref_using_target == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - exit_code=0 - testcase_timeout=60 - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? - # back to source branch - - git restore lib_com/options.h # Revert changes back before checking out another branch to avoid conflicts - - git checkout $source_branch_commit_sha - - make clean - - make -j + # remporary solution to make it work with and without https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/merge_requests/2181 + - mv $DUT_POST_RENDERER_PATH ISAR_post_rend_tmp + - cp $REF_POST_RENDERER_PATH $DUT_POST_RENDERER_PATH + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? + - mv ISAR_post_rend_tmp $DUT_POST_RENDERER_PATH ### Run test using scripts and input from main - if [ $ref_using_target == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi - comp_args="--mld --ssnr --odg" - - echo "$comp_args" + - echo "$comp_args" # run test - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py $comp_args --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? @@ -1994,7 +1973,7 @@ coverage-test-on-main-scheduled: # Build DuT binaries with GCOV - make clean >> /dev/null - make GCOV=1 -j - - cp IVAS_rend IVAS_rend_ref # Copy to ensure instrumented renderer is run in the first pytest call + - cp IVAS_rend $REF_RENDERER_PATH # Copy to ensure instrumented renderer is run in the first pytest call - testcase_timeout=$TESTCASE_TIMEOUT_LTV - exit_code_dec=0 diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 0c212d312..fc29579a5 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -12,16 +12,26 @@ variables: # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod" DUT_DECODER_PATH: "./IVAS_dec" + DUT_RENDERER_PATH: "./IVAS_rend" + DUT_POST_RENDERER_PATH: "./ISAR_post_rend" REF_ENCODER_PATH: "./IVAS_cod_ref" REF_DECODER_PATH: "./IVAS_dec_ref" + REF_RENDERER_PATH: "./IVAS_rend_ref" + REF_POST_RENDERER_PATH: "./ISAR_post_rend_ref" MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target" MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" + MERGE_TARGET_RENDERER_PATH: "./IVAS_rend_merge_target" + MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" # These path variables are used for building the binaries # They should never be overwritten! REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" + REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_ref" + REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_ref" MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_target" MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" + MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_target" + MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_target" LEVEL_SCALING: "1.0" BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" -- GitLab From 8fb4f6ca1a37b34961a61183b900fb6cc6f27e7a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 13:54:13 +0200 Subject: [PATCH 629/692] move anchor up to be able to use it in other part --- .gitlab-ci.yml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 215ab929b..a95babb6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -170,6 +170,28 @@ stages: echo "Commit time was $CI_COMMIT_TIMESTAMP" ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression +.build-merge-target-binaries: &build-merge-target-binaries + - current_commit_sha=$(git rev-parse HEAD) + ### build merge target binaries + - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then + - MERGE_REQUEST_TARGET="$(cat "$MERGE_TARGET_COMMIT_FILE")" + - else + - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" + - exit 1 + - fi + - git checkout $MERGE_REQUEST_TARGET + - *activate-debug-mode-info-if-set + - make clean + - make -j >> /dev/null + - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./IVAS_rend ./$MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY + - mv ./ISAR_post_rend ./$MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY + ### Return to current branch + - git restore . + - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE + - git checkout $current_commit_sha + # From float CI .mr-fetch-target-branch: &mr-fetch-target-branch # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching @@ -227,28 +249,6 @@ stages: - git rev-parse HEAD > $FLOAT_REF_COMMIT_FILE - git checkout $current_commit_sha -.build-merge-target-binaries: &build-merge-target-binaries - - current_commit_sha=$(git rev-parse HEAD) - ### build merge target binaries - - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then - - MERGE_REQUEST_TARGET="$(cat "$MERGE_TARGET_COMMIT_FILE")" - - else - - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" - - exit 1 - - fi - - git checkout $MERGE_REQUEST_TARGET - - *activate-debug-mode-info-if-set - - make clean - - make -j >> /dev/null - - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_rend ./$MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./ISAR_post_rend ./$MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - ### Return to current branch - - git restore . - - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE - - git checkout $current_commit_sha - .build-float-ref-and-dut-binaries: &build-float-ref-and-dut-binaries ### build reference binaries - *build-float-ref-binaries -- GitLab From e20e5aeb6c59944c24f474b8dbe36285f8911058 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 13:55:39 +0200 Subject: [PATCH 630/692] move up yet another anchor --- .gitlab-ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a95babb6a..7a82008e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -170,6 +170,12 @@ stages: echo "Commit time was $CI_COMMIT_TIMESTAMP" ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression +.activate-debug-mode-info-if-set: &activate-debug-mode-info-if-set + - if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then + - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h + - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h + - fi + .build-merge-target-binaries: &build-merge-target-binaries - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries @@ -224,13 +230,6 @@ stages: - if [ $exit_code -ne 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi - exit 0 - -.activate-debug-mode-info-if-set: &activate-debug-mode-info-if-set - - if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then - - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h - - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h - - fi - .build-float-ref-binaries: &build-float-ref-binaries - git rev-parse HEAD > $CUT_COMMIT_FILE - current_commit_sha=$(git rev-parse HEAD) -- GitLab From d621ca2ef5a4bc739ad73bb96a7066b0ac8b271a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:22:59 +0200 Subject: [PATCH 631/692] add additional info to printout + remove duplicates --- .gitlab-ci.yml | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cae7e9a15..04d1dc4d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -182,7 +182,7 @@ stages: - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then - MERGE_REQUEST_TARGET="$(cat "$MERGE_TARGET_COMMIT_FILE")" - else - - echo "MERGE_TARGET_COMMIT_FILE does not exist, exiting!" + - echo "MERGE_TARGET_COMMIT_FILE ($MERGE_TARGET_COMMIT_FILE) does not exist, exiting!" - exit 1 - fi - git checkout $MERGE_REQUEST_TARGET @@ -1051,47 +1051,6 @@ uninterruptible: # Validation jobs # --------------------------------------------------------------- -branch-is-up-to-date-with-target-pre: - extends: - - .rules-merge-request-to-main-pc - stage: prevalidate - needs: [] - tags: - - ivas-linux - script: - - *get-commits-behind-count - - echo $commits_behind_count - - | - if [ $commits_behind_count -ne 0 ]; then - echo "Your branch is behind the target branch, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." - exit 1 - fi - - git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" - - TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" - - echo "TARGET_COMMIT is $TARGET_COMMIT" - - echo "$TARGET_COMMIT" > "$MERGE_TARGET_COMMIT_FILE" - artifacts: - paths: - - $MERGE_TARGET_COMMIT_FILE - -branch-is-up-to-date-with-target-post: - extends: - - .rules-merge-request-to-main-pc - stage: postvalidate - tags: - - ivas-linux - script: - - *get-commits-behind-count - - echo $commits_behind_count - - | - if [ $commits_behind_count -ne 0 ]; then - echo "Your branch is behind the target branch, possibly main changed during your pipeline run, run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." - exit 123 - fi - allow_failure: - exit_codes: - - 123 - # fail pipeline in the final stage for pipelines on Draft MRs # this also only runs on Draft MRs, so should always fail fail-pipeline-if-in-draft: -- GitLab From 30fab5792ed90906626301e528d50fb00a247f7b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:31:03 +0200 Subject: [PATCH 632/692] fix comparison merge target build there was a "needs:" in the job itself that overwrote the one coming in from the template --- .gitlab-ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04d1dc4d1..4d3827ded 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1364,7 +1364,6 @@ split-rendering-pytest-on-merge-request: - .test-job-linux-needs-testv-dir - .test-job-linux-needs-fixed-target - .rules-merge-request-to-main-pc - needs: ["build-codec-linux-make"] timeout: "60 minutes" stage: compare script: @@ -2100,7 +2099,6 @@ renderer-pytest-on-merge-request: - .test-job-linux-needs-testv-dir - .test-job-linux-needs-fixed-target - .rules-merge-request-to-main-pc - needs: ["build-codec-linux-make"] # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" tags: @@ -2162,7 +2160,6 @@ ivas-pytest-on-merge-request: # note: this step doesn't really depend on codec-smoke-test # it's just pointless to run this step when the smoke test fails and the smoke test should be reasonably fast # thus, overall, this should save time - needs: ["build-codec-linux-make"] #, "codec-smoke-test"] timeout: "40 minutes" tags: - ivas-linux -- GitLab From 8fee3d590f8f5ec3d0a12bef669385a5c9884eda Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:36:04 +0200 Subject: [PATCH 633/692] remove more duplicates --- .gitlab-ci.yml | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d3827ded..e3ab8a25d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -434,43 +434,6 @@ stages: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' when: never -# --------------------------------------------------------------- -# Job templates -# --------------------------------------------------------------- - -# When designing templates, try not to use too much inheritance and -# if multiple templates and extended on, remember that on conflict, -# latest overwrites the parameter. - -# templates for rules -.rules-basis: - rules: - - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined) - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions) - when: never - - if: $CI_PIPELINE_SOURCE == 'trigger' # Don't run triggered pipeline by default - when: never - - if: $MANUAL_PIPELINE_TYPE == 'test-be-release' # Skip all the normal jobs when testing manually against release codec - when: never - - if: $MANUAL_PIPELINE_TYPE == 'test-long-self-test' # Skip all the normal jobs when testing manually against release codec - when: never - - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance-linux' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'check-clipping' - - if: $MANUAL_PIPELINE_TYPE == 'test-branch-vs-input-passthrough' - when: never - - when: on_success - -.rules-merge-request: - extends: .rules-basis - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - .rules-merge-request-no-draft: extends: .rules-basis rules: @@ -500,7 +463,6 @@ stages: - job: branch-is-up-to-date-with-target-pre - artifacts: true - .build-job-linux: stage: build timeout: "2 minutes" @@ -514,9 +476,9 @@ stages: - ivas-windows .print-results-banner: &print-results-banner - - set +x - - echo "" - - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" + - set +x + - echo "" + - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: -- GitLab From 1ce1ce7970d1c9f0f740d884169e296683a22bf9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:46:40 +0200 Subject: [PATCH 634/692] also add build job to needs section in template --- .gitlab-ci.yml | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e3ab8a25d..ea7949bc1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -457,11 +457,12 @@ stages: tags: - ivas-linux -.test-job-linux-needs-fixed-target: +.test-job-linux-compares-to-fixed-target: extends: .test-job-linux needs: - job: branch-is-up-to-date-with-target-pre - artifacts: true + - job: build-codec-linux-make .build-job-linux: stage: build @@ -1324,7 +1325,7 @@ lc3-wrapper-unit-test: split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target - .rules-merge-request-to-main-pc timeout: "60 minutes" stage: compare @@ -1406,7 +1407,7 @@ split-rendering-pytest-on-merge-request: check-be-to-target-short-enc-0db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1420,7 +1421,7 @@ check-be-to-target-short-enc-0db: check-be-to-target-short-enc-+10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1434,7 +1435,7 @@ check-be-to-target-short-enc-+10db: check-be-to-target-short-enc--10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1448,7 +1449,7 @@ check-be-to-target-short-enc--10db: check-be-to-target-short-dec-0db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1462,7 +1463,7 @@ check-be-to-target-short-dec-0db: check-be-to-target-short-dec-+10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1476,7 +1477,7 @@ check-be-to-target-short-dec-+10db: check-be-to-target-short-dec--10db: extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1495,7 +1496,7 @@ check-regressions-short-enc-0db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1512,7 +1513,7 @@ check-regressions-short-enc-+10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1529,7 +1530,7 @@ check-regressions-short-enc--10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1546,7 +1547,7 @@ check-regressions-short-dec-0db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1563,7 +1564,7 @@ check-regressions-short-dec-+10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1580,7 +1581,7 @@ check-regressions-short-dec--10db: artifacts: true extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -2059,7 +2060,7 @@ voip-be-on-merge-request: renderer-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target - .rules-merge-request-to-main-pc # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" @@ -2115,7 +2116,7 @@ renderer-pytest-on-merge-request: ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .test-job-linux-needs-fixed-target + - .test-job-linux-compares-to-fixed-target - .rules-merge-request-to-main-pc stage: compare # TODO: broken dependency needs to be removed temporarily, see above -- GitLab From d935df2b4c7cefa560d4d8b946c2d28823142afa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:51:53 +0200 Subject: [PATCH 635/692] remove another duplicate --- .gitlab-ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea7949bc1..eb24b0c68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -288,13 +288,6 @@ stages: - echo "Applying level scaling in scripts/testv using scale=$LEVEL_SCALING" - tests/scale_pcm.py ./scripts/testv/ $LEVEL_SCALING -.merge-request-comparison-check: &merge-request-comparison-check - - echo "--------------- Running merge-request-comparison-check anchor ---------------" - - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi - - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi - - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi - - exit 0 - .update-ltv-repo: &update-ltv-repo - cd $LTV_DIR - git pull -- GitLab From 5274f1bbc527687bb6d334b7e2a85ba1ca0efd6d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:56:43 +0200 Subject: [PATCH 636/692] test if it works without template --- .gitlab-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb24b0c68..f971fb166 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1318,9 +1318,13 @@ lc3-wrapper-unit-test: split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target + # - .test-job-linux-compares-to-fixed-target - .rules-merge-request-to-main-pc timeout: "60 minutes" + needs: + - job: branch-is-up-to-date-with-target-pre + - artifacts: true + - job: build-codec-linux-make stage: compare script: - *print-common-info -- GitLab From ee5a1e4d742d92a621536ce976651370d351316d Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:58:17 +0200 Subject: [PATCH 637/692] Revert "test if it works without template" This reverts commit 5274f1bbc527687bb6d334b7e2a85ba1ca0efd6d. --- .gitlab-ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f971fb166..eb24b0c68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1318,13 +1318,9 @@ lc3-wrapper-unit-test: split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - # - .test-job-linux-compares-to-fixed-target + - .test-job-linux-compares-to-fixed-target - .rules-merge-request-to-main-pc timeout: "60 minutes" - needs: - - job: branch-is-up-to-date-with-target-pre - - artifacts: true - - job: build-codec-linux-make stage: compare script: - *print-common-info -- GitLab From b1710d570ab1fb8a83781b27f80192c9bd1da06b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 23 Jul 2025 14:59:09 +0200 Subject: [PATCH 638/692] fix syntax in template --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb24b0c68..e0fd7d958 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -454,7 +454,7 @@ stages: extends: .test-job-linux needs: - job: branch-is-up-to-date-with-target-pre - - artifacts: true + artifacts: true - job: build-codec-linux-make .build-job-linux: -- GitLab From e630d6063cdc71ac012d189c5a24fbd82bfe90b6 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 09:54:12 +0200 Subject: [PATCH 639/692] fix needs for regression tests --- .gitlab-ci.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0fd7d958..842aefbc7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1487,9 +1487,11 @@ check-regressions-short-enc-0db: needs: - job: "check-be-to-target-short-enc-0db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1504,9 +1506,11 @@ check-regressions-short-enc-+10db: needs: - job: "check-be-to-target-short-enc-+10db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1521,9 +1525,11 @@ check-regressions-short-enc--10db: needs: - job: "check-be-to-target-short-enc--10db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1538,9 +1544,11 @@ check-regressions-short-dec-0db: needs: - job: "check-be-to-target-short-dec-0db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1555,9 +1563,11 @@ check-regressions-short-dec-+10db: needs: - job: "check-be-to-target-short-dec-+10db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1572,9 +1582,11 @@ check-regressions-short-dec--10db: needs: - job: "check-be-to-target-short-dec--10db" artifacts: true + - job: branch-is-up-to-date-with-target-pre + artifacts: true + - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 -- GitLab From 9b39aac6c7122831e3f00c66e3b13124599ae98b Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 15:06:33 +0200 Subject: [PATCH 640/692] move remaining variables to .gitlab-ci/variables.yml --- .gitlab-ci/variables.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index cb883cc28..8bf02a062 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -1,13 +1,20 @@ variables: + TESTV_DIR: "/usr/local/testv" + LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" FLOAT_REF_BRANCH: "ivas-float-update" + BUILD_OUTPUT: "build_output.txt" SCRIPTS_DIR: "/usr/local/scripts" + EXIT_CODE_NON_BE: 123 + EXIT_CODE_FAIL: 1 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" SHORT_TEST_SUITE: "tests/codec_be_on_mr_nonselection" SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" + DISABLE_HRTF_MODEL_TESTS: "" + # DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod" @@ -33,7 +40,8 @@ variables: MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_target" MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_target" LEVEL_SCALING: "1.0" - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch" + IVAS_PIPELINE_NAME: '' + BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 @@ -42,7 +50,9 @@ variables: CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50" CI_REGRESSION_THRESH_SSNR: "-1" CI_REGRESSION_THRESH_ODG: "-0.05" + GIT_CLEAN_FLAGS: -ffdxq INSTR_DIR: "scripts/c-code_instrument" + TESTS_DIR_CODEC_BE_ON_MR: "tests/codec_be_on_mr_nonselection" BUILD_WITH_DEBUG_MODE_INFO: "" ENCODER_TEST: "" DELTA_ODG: "" -- GitLab From dd40499a9c2aa9bbe2d5cbb329723f209b787a0e Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 24 Jul 2025 16:22:35 +0300 Subject: [PATCH 641/692] Port MR 1365 OMASA EXT from IVAS PC to BASOP --- apps/decoder.c | 49 ++ apps/renderer.c | 5 +- lib_com/ivas_cnst.h | 6 + lib_com/ivas_prot_fx.h | 39 +- lib_com/options.h | 4 +- lib_dec/ivas_init_dec_fx.c | 88 ++- lib_dec/ivas_jbm_dec_fx.c | 92 ++- lib_dec/ivas_masa_dec_fx.c | 111 ++- lib_dec/ivas_omasa_dec_fx.c | 1255 ++++++++++++++++++++++++++++++- lib_dec/ivas_output_config_fx.c | 18 + lib_dec/ivas_sba_dec_fx.c | 5 + lib_dec/ivas_stat_dec.h | 23 +- lib_dec/lib_dec_fx.c | 72 +- lib_enc/ivas_masa_enc_fx.c | 37 +- lib_rend/ivas_masa_merge_fx.c | 4 +- lib_util/masa_file_writer.c | 114 ++- lib_util/masa_file_writer.h | 5 + 17 files changed, 1881 insertions(+), 46 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 0da70053d..d9333726e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -1717,7 +1717,12 @@ static ivas_error initOnFirstGoodFrame( for ( int16_t j = 0; j < numInitialBadFrames; ++j ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + float delayMs = (float) ( pFullDelayNumSamples[0] ) / (float) ( *delayTimeScale ); + if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK ) +#else if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) ); return error; @@ -2101,13 +2106,28 @@ static ivas_error decodeG192( 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; @@ -2233,13 +2253,27 @@ static ivas_error decodeG192( 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; + + 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; @@ -2785,13 +2819,28 @@ static ivas_error decodeVoIP( 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_orig is fetched only for the first good frame, but here the delay can change between frames, so need to re-fetch */ + 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, 1 ) ) != 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; diff --git a/apps/renderer.c b/apps/renderer.c index 13d68cdef..4d976c76e 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1987,8 +1987,11 @@ int main( } } } - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMetaOutput, NULL ) ) != IVAS_ERR_OK ) /* NULL -> use default metadata delay settings */ +#else if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMetaOutput ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) ); } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 5b1d54265..a94ab1fbb 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -147,7 +147,13 @@ typedef enum RENDERER_NON_DIEGETIC_DOWNMIX, RENDERER_OSBA_STEREO, RENDERER_OSBA_AMBI, +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + RENDERER_OSBA_LS, + RENDERER_OMASA_OBJECT_EXT, + RENDERER_OMASA_MIX_EXT +#else RENDERER_OSBA_LS +#endif } RENDERER_TYPE; #define MAX_FREQUENCY_BANDS 64 diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 510a9067d..6486d68c3 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -156,6 +156,33 @@ void ivas_omasa_rearrange_channels_fx( const Word16 output_frame /* i : output frame length per channel */ ); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT +ivas_error ivas_omasa_combine_separate_ism_with_masa_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_omasa_combine_separate_ism_with_masa_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* o : output synthesis signal */ + Word16 *output_q, /* i/o: output Q value */ + const int16_t nchan_ism, /* i : number of ISMs */ + const int16_t output_frame /* i : output frame length per channel */ +); + +ivas_error ivas_omasa_render_objects_from_mix_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + +void ivas_omasa_render_objects_from_mix_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* o : output synthesis signal */ + const int16_t nchan_ism, /* i : number of ISMs */ + const int16_t output_frame, /* i : output frame length per channel */ + Word16 *output_q /* i/o: output Q value */ +); + +#endif + ivas_error ivas_omasa_ism_metadata_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word32 ism_total_brate, /* i : ISM total bitrate */ @@ -3906,7 +3933,7 @@ void ivas_omasa_decode_masa_to_total_fx( ivas_error ivas_td_binaural_open_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word16 *SrcInd, /*Temporarily used to store the updated value of SrcInd*/ - Word16 *num_src + Word16 *num_src ); ivas_error ivas_td_binaural_renderer_sf_fx( @@ -6471,7 +6498,7 @@ Word16 ivas_qmetadata_dec_sid_decode( UWord16 ivas_qmetadata_reorder_generic_fx( - const Word16 signed_value + const Word16 signed_value ); void ivas_sba_set_cna_cng_flag( @@ -6605,9 +6632,9 @@ void ivas_map_prior_coeffs_quant( const Word16 nB ); -void ivas_clear_band_coeff_idx( - ivas_band_coeffs_ind_t *pband_coeff_idx, - const UWord16 num_bands +void ivas_clear_band_coeff_idx( + ivas_band_coeffs_ind_t *pband_coeff_idx, + const UWord16 num_bands ); @@ -6715,7 +6742,7 @@ ivas_error ivas_create_lfe_enc_fx( const Word32 input_Fs /* i : input sampling rate */ ); -void ivas_lfe_enc_close_fx( +void ivas_lfe_enc_close_fx( LFE_ENC_HANDLE *hLFE /* i/o: LFE encoder handle */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 929ae2b05..f9a69637c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,12 +155,12 @@ #ifdef NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM #endif +#define NONBE_FIX_984_OMASA_EXT_OUTPUT /* Nokia: issue #984: complete the OMASA EXT output implementation */ + #define USE_NEW_HRTF_BINARY_FILE_FORMAT /* Orange: to activate when decided to change the hrtf binary file format */ #define FIX_WARNING_RENDER_CONFIG /* Orange: fix warning on windows build */ - - #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 40bf1ccf5..a3df9ed2c 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -386,6 +386,26 @@ ivas_error ivas_dec_setup( st_ivas->nchan_transport = 1; move16(); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + /* this should be non-zero if original input format was MASA_ISM_FORMAT */ + st_ivas->nchan_ism = add( st_ivas->bit_stream[sub( res_dec, 3 )], shl( st_ivas->bit_stream[sub( res_dec, 2 )], 1 ) ); + + IF( GT_16( st_ivas->nchan_ism, 0 ) ) + { + /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */ + test(); + IF( EQ_16( st_ivas->nchan_transport, 2 ) && EQ_16( st_ivas->nchan_ism, 3 ) ) + { + st_ivas->nchan_ism = 4; + move16(); + } + /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 */ + st_ivas->nchan_transport = 2; + element_mode_flag = 1; + move16(); + move16(); + } +#endif IF( st_ivas->ini_frame > 0 ) { @@ -1232,6 +1252,9 @@ ivas_error ivas_init_decoder_fx( IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); +#endif IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { hDecoderConfig->nchan_out = audioCfg2channels( IVAS_AUDIO_CONFIG_HOA3 ); @@ -1239,7 +1262,11 @@ ivas_error ivas_init_decoder_fx( hDecoderConfig->nchan_out = add( hDecoderConfig->nchan_out, st_ivas->nchan_ism ); move16(); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) +#else ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) +#endif { hDecoderConfig->nchan_out = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); move16(); @@ -2391,7 +2418,39 @@ ivas_error ivas_init_decoder_fx( return error; } } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) + { + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + error = ivas_omasa_render_objects_from_mix_open_fx( st_ivas ); + move32(); + + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + + error = ivas_spat_hSpatParamRendCom_config_fx( &st_ivas->hSpatParamRendCom, DIRAC_OPEN, 0, + st_ivas->ivas_format, st_ivas->mc_mode, output_Fs, 0, 0 ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } + + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) + { + /* Allocate 'hIsmRendererData' handle */ + error = ivas_omasa_combine_separate_ism_with_masa_open_fx( st_ivas ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } +#endif test(); test(); test(); @@ -3360,6 +3419,19 @@ void ivas_init_dec_get_num_cldfb_instances( move16(); } BREAK; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + case RENDERER_OMASA_OBJECT_EXT: + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; + move16(); + move16(); + break; + case RENDERER_OMASA_MIX_EXT: + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + *numCldfbSyntheses = 0; + move16(); + break; +#endif default: assert( 0 && "Renderer not handled for CLDFB reservation." ); } @@ -3621,6 +3693,19 @@ void ivas_init_dec_get_num_cldfb_instances_ivas_fx( move16(); } BREAK; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + case RENDERER_OMASA_OBJECT_EXT: + *numCldfbAnalyses = st_ivas->nchan_transport; + *numCldfbSyntheses = st_ivas->hDecoderConfig->nchan_out; + move16(); + move16(); + break; + case RENDERER_OMASA_MIX_EXT: + *numCldfbAnalyses = add( st_ivas->nchan_transport, 1 ); + *numCldfbSyntheses = 0; + move16(); + break; +#endif default: assert( 0 && "Renderer not handled for CLDFB reservation." ); } @@ -3777,6 +3862,7 @@ static ivas_error doSanityChecks_IVAS( } } +#ifndef NONBE_FIX_984_OMASA_EXT_OUTPUT IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { test(); @@ -3786,7 +3872,7 @@ static ivas_error doSanityChecks_IVAS( return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration specified for combined MASA and ISM format" ); } } - +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index bcca2a71d..48264d70f 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -668,6 +668,20 @@ ivas_error ivas_jbm_dec_tc_fx( { Scale_sig32( p_output_fx[i], output_frame, negate( q_shift ) ); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + /* external output */ + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && + EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + FOR( n = 0; n < st_ivas->nchan_ism; n++ ) + { + set_zero_fx( p_output_fx[add( st_ivas->nchan_transport, n )], output_frame ); + } + + ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, output_frame ); + } +#endif } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -792,6 +806,22 @@ ivas_error ivas_jbm_dec_tc_fx( } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ + ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ + ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); + } +#else /* sanity check in case of bitrate switching */ IF( NE_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { @@ -799,9 +829,7 @@ ivas_error ivas_jbm_dec_tc_fx( } ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); - - output_q = 11; - move16(); +#endif ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } @@ -1706,29 +1734,42 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT test(); - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) { - n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); + ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); } - - IF( st_ivas->hSCE[0] ) + ELSE { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); - if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) +#endif + test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + n_render_timeslots = i_mult( n_render_timeslots, idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ) ); } - scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31- (st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp - shift) - st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); - move16(); - } - ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { - ivas_ism_dec_digest_tc_fx( st_ivas ); + IF( st_ivas->hSCE[0] ) + { + Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) + { + shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); + } + scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31- (st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp - shift) + st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); + move16(); + } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + + IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + ivas_ism_dec_digest_tc_fx( st_ivas ); + } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT } +#endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) { @@ -2110,6 +2151,9 @@ ivas_error ivas_jbm_dec_render_fx( move16(); test(); test(); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); +#endif IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { test(); @@ -2129,6 +2173,14 @@ ivas_error ivas_jbm_dec_render_fx( { ivas_omasa_dirac_rend_jbm_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) || + EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) + { + ivas_jbm_dec_tc_buffer_playout_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output_fx ); + ivas_omasa_rearrange_channels_fx( p_output_fx, st_ivas->nchan_ism, *nSamplesRendered ); + } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { @@ -3927,6 +3979,10 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( case RENDERER_PARAM_ISM: case RENDERER_BINAURAL_MIXER_CONV: case RENDERER_BINAURAL_MIXER_CONV_ROOM: +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + case RENDERER_OMASA_OBJECT_EXT: + case RENDERER_OMASA_MIX_EXT: +#endif case RENDERER_OSBA_AMBI: case RENDERER_OSBA_LS: buffer_mode = TC_BUFFER_MODE_RENDERER; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 3133c8c57..f66970710 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -320,7 +320,33 @@ ivas_error ivas_masa_decode_fx( } } } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + + /* read 2 bits: + '00' - MASA format at the encoder + '01' - MASA_ISM_FORMAT at the encoder, with 1 object + '10' - MASA_ISM_FORMAT at the encoder, with 2 objects + '11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects + reading if 3 or 4 object is performed later + */ + byteBuffer = st->bit_stream[st->next_bit_pos]; + move16(); + st->next_bit_pos = sub( st->next_bit_pos, 1 ); + byteBuffer = add( byteBuffer, shl( st->bit_stream[st->next_bit_pos], 1 ) ); + st->next_bit_pos = sub( st->next_bit_pos, 1 ); + test(); + IF( EQ_16( byteBuffer, 0 ) && EQ_32( ivas_format, MASA_FORMAT ) ) + { + hMasa->config.input_ivas_format = MASA_FORMAT; + move32(); + } + ELSE + { + hMasa->config.input_ivas_format = MASA_ISM_FORMAT; + move32(); + } +#else /* read the MASA_ISM_FORMAT bit */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); @@ -337,6 +363,7 @@ ivas_error ivas_masa_decode_fx( /* reserved bit */ byteBuffer = st->bit_stream[( st->next_bit_pos )--]; move16(); +#endif *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS ); /* read number of directions */ @@ -418,8 +445,9 @@ ivas_error ivas_masa_decode_fx( { IF( st_ivas->hDirAC != NULL ) { - *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, - st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ); + *nb_bits_read = add( *nb_bits_read, + ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, + st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ); move16(); FOR( obj = 0; obj <= st_ivas->nchan_ism; obj++ ) { @@ -439,6 +467,14 @@ ivas_error ivas_masa_decode_fx( } } } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) + { + *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, + st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, + st_ivas->hMasaIsmData->idx_separated_ism, ism_imp, st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ); + } +#endif ELSE { *nb_bits_read = add( *nb_bits_read, ivas_decode_masaism_metadata_fx( hQMetaData, st_ivas->hMasa, st_ivas->hMasaIsmData, st_ivas->nchan_ism, st->bit_stream, &st->next_bit_pos, @@ -587,7 +623,19 @@ ivas_error ivas_masa_decode_fx( ivas_qmetadata_to_dirac_fx( hQMetaData, st_ivas->hDirAC, hMasa, st_ivas->hSpatParamRendCom, ivas_total_brate, ivas_format, 0, 0 ); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) + { + Word16 index = add( st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx, MAX_PARAM_SPATIAL_SUBFRAMES ); + IF( GE_16( index, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ) + { + index = sub( index, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ); + } + st_ivas->hSpatParamRendCom->dirac_bs_md_write_idx = index; + move16(); + } +#endif IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { IF( hQMetaData->q_direction == NULL ) @@ -743,7 +791,18 @@ ivas_error ivas_masa_dec_open_fx( ism_total_brate = 0; move32(); - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + /* ISM metadata */ + test(); + test(); + if ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && + st_ivas->hIsmMetaData[0] != NULL && + EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + /* these are not needed -> clean. EXT metafile writer in OMASA needs only the number of ISMs and writes default null-data */ + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + } +#endif test(); test(); test(); @@ -826,7 +885,10 @@ ivas_error ivas_masa_dec_open_fx( nchan_transport = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); nchan_to_allocate = nchan_transport; move16(); - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + test(); +#endif test(); test(); IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) @@ -836,6 +898,15 @@ ivas_error ivas_masa_dec_open_fx( nchan_to_allocate = 1; move16(); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && + ( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || + EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) ) + { + nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + } +#endif ELSE IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_32( st_ivas->renderer_type, RENDERER_DIRAC ) ) { /* addtl channel for CNG */ @@ -1830,8 +1901,18 @@ ivas_error ivas_masa_dec_reconfigure_fx( IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( NE_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + move16(); + st_ivas->nchan_ism = 0; /* Initialization if it has not been already read from the end of the bitstream at the same time + with reading of the format: nchan_ism is needed in MASA format because for the EXT output in + MASA-only (pre-rendering mode of OMASA) the number of ISMs to output correct number of empty objects is needed */ + } +#else st_ivas->nchan_ism = 0; move16(); +#endif st_ivas->ism_mode = ISM_MODE_NONE; move16(); } @@ -1854,6 +1935,10 @@ ivas_error ivas_masa_dec_reconfigure_fx( test(); test(); test(); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + test(); +#endif IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) @@ -1894,7 +1979,15 @@ ivas_error ivas_masa_dec_reconfigure_fx( /* addtl channel for CNG */ tc_nchan_to_allocate = add( tc_nchan_to_allocate, 1 ); } - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && + ( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || + EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) ) + { + tc_nchan_transport = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + tc_nchan_to_allocate = add( st_ivas->nchan_transport, st_ivas->nchan_ism ); + } +#endif test(); test(); IF( NE_16( tc_nchan_transport, st_ivas->hTcBuffer->nchan_transport_jbm ) || NE_16( tc_nchan_to_allocate, st_ivas->hTcBuffer->nchan_transport_internal ) || NE_16( buffer_mode_new, st_ivas->hTcBuffer->tc_buffer_mode ) ) @@ -3332,6 +3425,14 @@ static Word16 ivas_decode_masaism_metadata_fx( hMasaIsmData->energy_ratio_ism_fx[dir][meta_write_index][b] = energy_ratio_ism_fx[i][band][dir]; move32(); } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( hMasaIsmData->hExtData != NULL ) + { + hMasaIsmData->hExtData->masa_render_masa_to_total[meta_write_index][b] = + hMasaIsmData->masa_to_total_energy_ratio_fx[i][band]; + move32(); + } +#endif } } } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 35f4f1c4b..642e9af40 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -32,6 +32,9 @@ #include "options.h" #include +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT +#include +#endif #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" @@ -45,6 +48,223 @@ * Local constants *------------------------------------------------------------------------*/ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + +#define EXT_RENDER_IIR_FAC 0.95f +#define MULT_17_DIV_20_Q15 ( Word16 )( ( 17.0 / 20.0f ) * pow( 2, 15 ) + 0.5f ) +#define MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ( Word16 )( ( 1.0 / CLDFB_NO_COL_MAX ) * pow( 2, 15 ) + 0.5f ) +#define ONEMINUX_EXT_RENDER_IIR_FAC_Q31 ( Word32 )( ( 1.0f - EXT_RENDER_IIR_FAC ) * pow( 2, 31 ) + 0.5f ) +#define EXT_RENDER_IIR_FAC_Q31 ( Word32 )( EXT_RENDER_IIR_FAC * pow( 2, 31 ) + 0.5f ) + +// Calculated as (Word16)(((1.0f / (50 * MAX_PARAM_SPATIAL_SUBFRAMES)) * pow(2, 15)) + 0.5f) +#define OMASA_DELAYFRAMES_PER_SEC_Q15 (Word16) 164 // Q15 + +static Word16 interpolator_table_48k_q15[] = { + 0, 137, 273, 410, 546, 683, 819, 956, 1092, 1229, + 1365, 1502, 1638, 1775, 1911, 2048, 2185, 2321, 2458, 2594, + 2731, 2867, 3004, 3140, 3277, 3413, 3550, 3686, 3823, 3959, + 4096, 4233, 4369, 4506, 4642, 4779, 4915, 5052, 5188, 5325, + 5461, 5598, 5734, 5871, 6007, 6144, 6281, 6417, 6554, 6690, + 6827, 6963, 7100, 7236, 7373, 7509, 7646, 7782, 7919, 8055, + 8192, 8329, 8465, 8602, 8738, 8875, 9011, 9148, 9284, 9421, + 9557, 9694, 9830, 9967, 10103, 10240, 10377, 10513, 10650, 10786, + 10923, 11059, 11196, 11332, 11469, 11605, 11742, 11878, 12015, 12151, + 12288, 12425, 12561, 12698, 12834, 12971, 13107, 13244, 13380, 13517, + 13653, 13790, 13926, 14063, 14199, 14336, 14473, 14609, 14746, 14882, + 15019, 15155, 15292, 15428, 15565, 15701, 15838, 15974, 16111, 16247, + 16384, 16521, 16657, 16794, 16930, 17067, 17203, 17340, 17476, 17613, + 17749, 17886, 18022, 18159, 18295, 18432, 18569, 18705, 18842, 18978, + 19115, 19251, 19388, 19524, 19661, 19797, 19934, 20070, 20207, 20343, + 20480, 20617, 20753, 20890, 21026, 21163, 21299, 21436, 21572, 21709, + 21845, 21982, 22118, 22255, 22391, 22528, 22665, 22801, 22938, 23074, + 23211, 23347, 23484, 23620, 23757, 23893, 24030, 24166, 24303, 24439, + 24576, 24713, 24849, 24986, 25122, 25259, 25395, 25532, 25668, 25805, + 25941, 26078, 26214, 26351, 26487, 26624, 26761, 26897, 27034, 27170, + 27307, 27443, 27580, 27716, 27853, 27989, 28126, 28262, 28399, 28535, + 28672, 28809, 28945, 29082, 29218, 29355, 29491, 29628, 29764, 29901, + 30037, 30174, 30310, 30447, 30583, 30720, 30857, 30993, 31130, 31266, + 31403, 31539, 31676, 31812, 31949, 32085, 32222, 32358, 32495, 32631 +}; + +static Word16 interpolator_table_32k_q15[] = { + 0, 205, 410, 614, 819, 1024, 1229, 1434, 1638, 1843, + 2048, 2253, 2458, 2662, 2867, 3072, 3277, 3482, 3686, 3891, + 4096, 4301, 4506, 4710, 4915, 5120, 5325, 5530, 5734, 5939, + 6144, 6349, 6554, 6758, 6963, 7168, 7373, 7578, 7782, 7987, + 8192, 8397, 8602, 8806, 9011, 9216, 9421, 9626, 9830, 10035, + 10240, 10445, 10650, 10854, 11059, 11264, 11469, 11674, 11878, 12083, + 12288, 12493, 12698, 12902, 13107, 13312, 13517, 13722, 13926, 14131, + 14336, 14541, 14746, 14950, 15155, 15360, 15565, 15770, 15974, 16179, + 16384, 16589, 16794, 16998, 17203, 17408, 17613, 17818, 18022, 18227, + 18432, 18637, 18842, 19046, 19251, 19456, 19661, 19866, 20070, 20275, + 20480, 20685, 20890, 21094, 21299, 21504, 21709, 21914, 22118, 22323, + 22528, 22733, 22938, 23142, 23347, 23552, 23757, 23962, 24166, 24371, + 24576, 24781, 24986, 25190, 25395, 25600, 25805, 26010, 26214, 26419, + 26624, 26829, 27034, 27238, 27443, 27648, 27853, 28058, 28262, 28467, + 28672, 28877, 29082, 29286, 29491, 29696, 29901, 30106, 30310, 30515, + 30720, 30925, 31130, 31334, 31539, 31744, 31949, 32154, 32358, 32563 +}; + +static Word16 interpolator_table_16k_q15[] = { + 0, 410, 819, 1229, 1638, 2048, 2458, 2867, 3277, 3686, + 4096, 4506, 4915, 5325, 5734, 6144, 6554, 6963, 7373, 7782, + 8192, 8602, 9011, 9421, 9830, 10240, 10650, 11059, 11469, 11878, + 12288, 12698, 13107, 13517, 13926, 14336, 14746, 15155, 15565, 15974, + 16384, 16794, 17203, 17613, 18022, 18432, 18842, 19251, 19661, 20070, + 20480, 20890, 21299, 21709, 22118, 22528, 22938, 23347, 23757, 24166, + 24576, 24986, 25395, 25805, 26214, 26624, 27034, 27443, 27853, 28262, + 28672, 29082, 29491, 29901, 30310, 30720, 31130, 31539, 31949, 32358 +}; + +/** + * Calculate mantissa (Q31) * gain (Q31). + * + * Exponent for the mantissa value is also included as input parameter. + * Adjust the result so that accuracy of the mantissa multiplication is maximixed + * and the corresponding exponent is minimized. + */ +static Word32 mult32_mantissa_fx( Word32 mantissa, Word32 gain, Word16 exp, Word16 *exp_result ) +{ + Word64 mult = W_mult_32_32( mantissa, gain ); // Q31 * Q31 -> Q63 + Word16 norm = W_norm( mult ); + Word32 result = W_extract_h( W_shl( mult, norm ) ); // Q63 -> Q31 + *exp_result = sub( exp, norm ); + + return result; +} + +/** + * Calculate re^2 + im^2 using exponent (Q0) and mantissa (Q31) format. + */ +static Word32 sample_energy_fx( Word32 re_m, Word16 re_e, Word32 im_m, Word16 im_e, Word16 *exp_result ) +{ + Word16 re_exp = add( re_e, re_e ); + Word32 re_mult = mult32_mantissa_fx( re_m, re_m, re_exp, &re_exp ); + move32(); + + Word16 im_exp = add( im_e, im_e ); + Word32 im_mult = mult32_mantissa_fx( im_m, im_m, im_exp, &im_exp ); + move32(); + + return BASOP_Util_Add_Mant32Exp( re_mult, re_exp, im_mult, im_exp, exp_result ); +} + +/** + * Accumulate sum of re^2 + im^2 over the specified length using exponent (Q0) and mantissa (Q31) format. + */ +static void sample_energy_acc_fx( Word32 *re_m, Word16 *re_e, Word32 *im_m, Word16 *im_e, Word32 *out_m, Word16 *out_e, Word16 len ) +{ + Word16 i; + + FOR( i = 0; i < len; i++ ) + { + Word16 exp; + + // energy = re^2 + im^2 + Word32 mantissa = sample_energy_fx( re_m[i], re_e[i], im_m[i], im_e[i], &exp ); + move32(); + + // Accumulate energy + *out_m = BASOP_Util_Add_Mant32Exp( *out_m, *out_e, mantissa, exp, out_e ); + move32(); + } +} + +// Multiplication of vector (comprising of exponent and mantissa parts) by constant value (Q31) +static void v_multc_exp_mantissa_fx( + const Word32 *in_mantissa, + const Word16 *in_exp, + Word32 c, + Word32 *out_mantissa, + Word16 *out_exp, + Word16 len ) +{ + Word16 i; + + FOR( i = 0; i < len; i++ ) + { + out_mantissa[i] = mult32_mantissa_fx( in_mantissa[i], c, in_exp[i], &out_exp[i] ); + move32(); + } +} + +// Multiplication of vector (comprising of exponent and mantissa parts) by constant acumulate to the output +static void v_multc_acc_exp_mantissa_fx( + const Word32 *in_mantissa, + const Word16 *in_exp, + Word32 c, + Word32 *out_mantissa, + Word16 *out_exp, + Word16 len ) +{ + Word16 i; + + FOR( i = 0; i < len; i++ ) + { + Word16 exp; + Word32 mantissa = mult32_mantissa_fx( in_mantissa[i], c, in_exp[i], &exp ); + move32(); + + out_mantissa[i] = BASOP_Util_Add_Mant32Exp( out_mantissa[i], out_exp[i], + mantissa, exp, &out_exp[i] ); + move32(); + } +} + +// Calculate min( 4, sqrtf( target / proto ) ) +// target and proto values are expressed using exponent and mantissa +static Word32 get_processing_gain_fx( Word32 proto_m, Word16 proto_e, Word32 target_m, Word16 target_e, Word16 *exp ) +{ + Word16 b = extract_h( proto_m ); + IF( EQ_16( b, 0 ) ) + { + b = 1; + move16(); + } + + Word16 mantissa; + BASOP_Util_Divide_MantExp( extract_h( target_m ), target_e, b, proto_e, &mantissa, exp ); + + Word32 sqrt_mantissa = Sqrt32( L_shl( mantissa, 16 ), exp ); + + Word16 norm = norm_l( sqrt_mantissa ); + sqrt_mantissa = L_shl( sqrt_mantissa, norm ); + *exp = sub( *exp, norm ); + + test(); + IF( GT_16( *exp, 2 ) && NE_32( sqrt_mantissa, 0 ) ) + { + // (2^3) * (1073741824 / 2^31) == 4.0 + sqrt_mantissa = ONE_IN_Q30; // 0.5 in Q31 + *exp = 3; + move32(); + move16(); + } + + return sqrt_mantissa; +} + +static void mantissa_exp_to_qvalue( Word16 *exp, Word32 *output, Word16 target_exp, Word16 len ) +{ + Word16 bin; + + FOR( bin = 0; bin < len; bin++ ) + { + IF( LT_16( exp[bin], -Q31 ) ) + { + output[bin] = 0; + move32(); + } + ELSE + { + Word16 shift = sub( target_exp, exp[bin] ); + output[bin] = W_sat_l( W_shr( output[bin], shift ) ); + } + } +} + +#endif + /*-------------------------------------------------------------------* * ivas_omasa_data_open() @@ -110,6 +330,51 @@ ivas_error ivas_omasa_data_open_fx( set16_fx( hMasaIsmData->azimuth_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); set16_fx( hMasaIsmData->elevation_separated_ism, 0, MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR ); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + hMasaIsmData->hExtData = NULL; + move32(); + + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + MASA_ISM_EXT_DATA_HANDLE hExtData; + hExtData = (MASA_ISM_EXT_DATA_HANDLE) malloc( sizeof( MASA_ISM_EXT_DATA ) ); + move32(); + + IF( hExtData == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM data\n" ) ); + } + + hExtData->prev_idx_separated_ism = 0; + move16(); + + FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) + { + set32_fx( hExtData->prev_panning_gains[ch], 0, 2 ); + } + + FOR( ch = 0; ch < MAX_NUM_OBJECTS; ch++ ) + { + set32_fx( hExtData->ism_render_proto_energy_frac[ch], 0, CLDFB_NO_CHANNELS_MAX ); + set16_fx( hExtData->ism_render_proto_energy_exp[ch], 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( hExtData->ism_render_target_energy_frac[ch], 0, CLDFB_NO_CHANNELS_MAX ); + set16_fx( hExtData->ism_render_target_energy_exp[ch], 0, CLDFB_NO_CHANNELS_MAX ); + } + + set32_fx( hExtData->masa_render_proto_energy_frac, 0, CLDFB_NO_CHANNELS_MAX ); + set16_fx( hExtData->masa_render_proto_energy_exp, 0, CLDFB_NO_CHANNELS_MAX ); + set32_fx( hExtData->masa_render_target_energy_frac, 0, CLDFB_NO_CHANNELS_MAX ); + set16_fx( hExtData->masa_render_target_energy_exp, 0, CLDFB_NO_CHANNELS_MAX ); + + FOR( sf = 0; sf < add( MAX_PARAM_SPATIAL_SUBFRAMES, DELAY_MASA_PARAM_DEC_SFR ); sf++ ) + { + set32_fx( hExtData->masa_render_masa_to_total[sf], 0, CLDFB_NO_CHANNELS_MAX ); + } + + hMasaIsmData->hExtData = hExtData; + move32(); + } +#endif st_ivas->hMasaIsmData = hMasaIsmData; return IVAS_ERR_OK; @@ -143,7 +408,14 @@ void ivas_omasa_data_close_fx( free( ( *hMasaIsmData )->delayBuffer_fx ); ( *hMasaIsmData )->delayBuffer_fx = NULL; } - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( ( *hMasaIsmData )->hExtData != NULL ) + { + free( ( *hMasaIsmData )->hExtData ); + ( *hMasaIsmData )->hExtData = NULL; + move32(); + } +#endif free( *hMasaIsmData ); *hMasaIsmData = NULL; @@ -293,7 +565,59 @@ ivas_error ivas_omasa_dec_config_fx( /* ISM MD reconfig. */ n_MD = 0; move16(); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + /* the full number of hIsmMetaData are needed for EXT output */ + move16(); + n_MD = st_ivas->nchan_ism; + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + + error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + + ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD ); + } + ELSE + { + test(); + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + n_MD = 1; + move16(); + + IF( st_ivas->hIsmMetaData[0] == NULL ) + { + error = ivas_ism_metadata_dec_create_fx( st_ivas, 1, NULL ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + { + n_MD = st_ivas->nchan_ism; + move16(); + + ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); + error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } + + ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD ); + } +#else test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { @@ -322,7 +646,7 @@ ivas_error ivas_omasa_dec_config_fx( } ivas_ism_metadata_close( st_ivas->hIsmMetaData, n_MD ); - +#endif st_ivas->hCPE[0]->element_brate = L_sub( ivas_total_brate, ism_total_brate ); /*-----------------------------------------------------------------* @@ -351,8 +675,15 @@ ivas_error ivas_omasa_dec_config_fx( } /* objects renderer reconfig. */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + IF( st_ivas->hMasaIsmData != NULL || st_ivas->hIsmRendererData != NULL ) + { + /* this calls also ivas_ism_renderer_close() closing st_ivas->hIsmRendererData used by the EXT renderers. also cleans st_ivas->hMasaIsmData */ +#else IF( st_ivas->hMasaIsmData != NULL ) { +#endif ivas_omasa_separate_object_renderer_close( st_ivas ); } @@ -414,7 +745,49 @@ ivas_error ivas_omasa_dec_config_fx( ivas_omasa_separate_object_renderer_close( st_ivas ); } } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) ) + { + /* Allocate 'hIsmRendererData' handle */ + error = ivas_omasa_combine_separate_ism_with_masa_open_fx( st_ivas ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } + + IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) + { + DIRAC_CONFIG_FLAG common_rend_config_flag; + IF( st_ivas->hSpatParamRendCom == NULL ) + { + common_rend_config_flag = DIRAC_OPEN; + } + ELSE + { + common_rend_config_flag = DIRAC_RECONFIGURE; + } + move32(); + /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ + error = ivas_omasa_render_objects_from_mix_open_fx( st_ivas ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + + error = ivas_spat_hSpatParamRendCom_config_fx( &st_ivas->hSpatParamRendCom, + common_rend_config_flag, 0, + st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs, 0, 0 ); + move32(); + IF( NE_32( error, IVAS_ERR_OK ) ) + { + return error; + } + } +#endif /*-----------------------------------------------------------------* * TD Decorrelator *-----------------------------------------------------------------*/ @@ -600,7 +973,9 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( *nchan_transport_ism = 1; move16(); } - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); +#endif test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) { @@ -666,6 +1041,37 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( } } } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) && + EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + azimuth_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[0]->azimuth_fx ), 22 ) ); + if ( st_ivas->hIsmMetaData[0]->azimuth_fx < 0 ) + { + azimuth_ism = negate( azimuth_ism ); + } + elevation_ism = extract_l( L_shr_r( L_abs( st_ivas->hIsmMetaData[0]->elevation_fx ), 22 ) ); + if ( st_ivas->hIsmMetaData[0]->elevation_fx < 0 ) + { + elevation_ism = negate( elevation_ism ); + } + + FOR( block = 0; block < 2; block++ ) + { + st_ivas->hMasaIsmData->azimuth_separated_ism[block] = st_ivas->hMasaIsmData->azimuth_separated_ism[add( block, 2 )]; + st_ivas->hMasaIsmData->elevation_separated_ism[block] = st_ivas->hMasaIsmData->elevation_separated_ism[add( block, 2 )]; + move16(); + move16(); + } + FOR( block = 2; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) + { + st_ivas->hMasaIsmData->azimuth_separated_ism[block] = azimuth_ism; + st_ivas->hMasaIsmData->elevation_separated_ism[block] = elevation_ism; + move16(); + move16(); + } + } +#endif } return IVAS_ERR_OK; @@ -865,3 +1271,846 @@ void ivas_omasa_rearrange_channels_fx( return; } + +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + +/*-------------------------------------------------------------------------* + * ivas_omasa_combine_separate_ism_with_masa_open_fx() + * + * Open structures, reserve memory, and init values. + *-------------------------------------------------------------------------*/ + +ivas_error ivas_omasa_combine_separate_ism_with_masa_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 i; + Word16 *tmp; + + st_ivas->hIsmRendererData = (ISM_RENDERER_HANDLE) malloc( sizeof( ISM_RENDERER_DATA ) ); + move32(); + + IF( st_ivas->hIsmRendererData == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM renderer \n" ) ); + } + + FOR( i = 0; i < MAX_NUM_OBJECTS; i++ ) + { + set_zero_fx( st_ivas->hIsmRendererData->prev_gains_fx[i], MAX_OUTPUT_CHANNELS ); + } + + test(); + test(); + IF( EQ_32( st_ivas->hDecoderConfig->output_Fs, 16000 ) || + EQ_32( st_ivas->hDecoderConfig->output_Fs, 32000 ) || + EQ_32( st_ivas->hDecoderConfig->output_Fs, 48000 ) ) + { + IF( EQ_32( st_ivas->hDecoderConfig->output_Fs, 16000 ) ) + { + st_ivas->hIsmRendererData->interpolator_len = 80; + tmp = interpolator_table_16k_q15; + } + ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_Fs, 32000 ) ) + { + st_ivas->hIsmRendererData->interpolator_len = 160; + tmp = interpolator_table_32k_q15; + } + ELSE + { + st_ivas->hIsmRendererData->interpolator_len = 240; + tmp = interpolator_table_48k_q15; + } + move16(); + move32(); + + st_ivas->hIsmRendererData->interpolator_fx = + (Word16 *) malloc( sizeof( Word16 ) * st_ivas->hIsmRendererData->interpolator_len ); + + IF( st_ivas->hIsmRendererData->interpolator_fx == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA ISM renderer interpolator\n" ) ); + } + + FOR( i = 0; i < st_ivas->hIsmRendererData->interpolator_len; i++ ) + { + st_ivas->hIsmRendererData->interpolator_fx[i] = tmp[i]; + move16(); + } + } + ELSE + { + return ( IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Unsupported output sample rate\n" ) ); + } + + return IVAS_ERR_OK; +} + +/*--------------------------------------------------------------------------* + * ivas_omasa_combine_separate_ism_with_masa_fx() + * + * in case of external rendering, combine separated ISM signal with MASA stream + *--------------------------------------------------------------------------*/ + +void ivas_omasa_combine_separate_ism_with_masa_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* i/o: output synthesis signal */ + Word16 *output_q, /* i/o: output Q value */ + const int16_t nchan_ism, /* i : number of ISMs */ + const int16_t output_frame /* i : output frame length per channel */ +) +{ + Word16 n, sf, band, k; + MASA_DECODER_EXT_OUT_META_HANDLE masaMetaHandle; + MASA_DECODER_EXT_OUT_META_HANDLE ismMetaHandle; + MASA_DECODER_EXT_OUT_META ismMeta; + Word32 inRe[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + UWord16 directionIndex; + Word16 nchan_in; + Word16 nBins; + Word16 slot; + Word16 mrange[2], brange[2]; + Word16 processing_len, offset; + + Word32 old_panning_gains_fx[2]; + Word32 new_panning_gains_fx[2]; + + Word16 inRe_exp[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 inIm_exp[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 out_exp[MASA_MAX_TRANSPORT_CHANNELS + 1][L_FRAME48k]; + + Word16 eneMasa_exp[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 eneMasa_frac[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16 eneIsm_exp[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 eneIsm_frac[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + + Word16 old_panning_gains_q15_fx[2]; + Word16 new_panning_gains_q15_fx[2]; + + Word16 exp; + + masaMetaHandle = st_ivas->hMasa->data.extOutMeta; + ismMetaHandle = &ismMeta; + move32(); + move32(); + + /* Compute CLDFB analysis */ + nchan_in = add( st_ivas->nchan_transport, 1 ); + nBins = mult( output_frame, MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ); // Q15 + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + FOR( n = 0; n < nchan_in; n++ ) + { + Word16 in_q = *output_q; + move16(); + + cldfbAnalysis_ts_fx_var_q( &( output[n][L_mult0( nBins, slot )] ), + inRe[n][slot], + inIm[n][slot], + nBins, st_ivas->cldfbAnaDec[n], &in_q ); + + /* Assign input exponent */ + exp = sub( Q31, in_q ); + set16_fx( inRe_exp[n][slot], exp, nBins ); + set16_fx( inIm_exp[n][slot], exp, nBins ); + } + } + + /* Convert output to exponent+mantissa representation */ + exp = sub( Q31, *output_q ); + FOR( n = 0; n < add( MASA_MAX_TRANSPORT_CHANNELS, 1 ); n++ ) + { + set16_fx( out_exp[n], exp, output_frame ); + } + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + set16_fx( eneMasa_exp[sf], 0, MASA_FREQUENCY_BANDS ); + set32_fx( eneMasa_frac[sf], 0, MASA_FREQUENCY_BANDS ); + + set16_fx( eneIsm_exp[sf], 0, MASA_FREQUENCY_BANDS ); + set32_fx( eneIsm_frac[sf], 0, MASA_FREQUENCY_BANDS ); + } + + /* Determine energies */ + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + mrange[0] = st_ivas->hMasa->config.block_grouping[sf]; + mrange[1] = st_ivas->hMasa->config.block_grouping[add( sf, 1 )]; + move16(); + move16(); + + FOR( slot = mrange[0]; slot < mrange[1]; slot++ ) + { + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + brange[0] = st_ivas->hMasa->config.band_grouping[band]; + brange[1] = st_ivas->hMasa->config.band_grouping[add( band, 1 )]; + move16(); + move16(); + + IF( GT_16( brange[1], nBins ) ) + { + brange[1] = nBins; + move16(); + } + + Word16 len = sub( brange[1], brange[0] ); + + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + sample_energy_acc_fx( &inRe[n][slot][brange[0]], + &inRe_exp[n][slot][brange[0]], + &inIm[n][slot][brange[0]], + &inIm_exp[n][slot][brange[0]], + &eneMasa_frac[sf][band], + &eneMasa_exp[sf][band], + len ); + } + + sample_energy_acc_fx( &inRe[MASA_MAX_TRANSPORT_CHANNELS][slot][brange[0]], + &inRe_exp[MASA_MAX_TRANSPORT_CHANNELS][slot][brange[0]], + &inIm[MASA_MAX_TRANSPORT_CHANNELS][slot][brange[0]], + &inIm_exp[MASA_MAX_TRANSPORT_CHANNELS][slot][brange[0]], + &eneIsm_frac[sf][band], + &eneIsm_exp[sf][band], + len ); + } + } + } + + /* Determine MASA metadata for the object */ + ismMetaHandle->descriptiveMeta.numberOfDirections = 0u; + move16(); + + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + Word32 ele, azi; + + ele = st_ivas->hMasaIsmData->elevation_separated_ism[sf]; + azi = st_ivas->hMasaIsmData->azimuth_separated_ism[sf]; + + directionIndex = index_theta_phi_16_fx( &ele, &azi, st_ivas->hMasa->data.sph_grid16 ); + + FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + ismMetaHandle->directionIndex[0][sf][band] = directionIndex; + ismMetaHandle->directToTotalRatio[0][sf][band] = UINT8_MAX; + ismMetaHandle->spreadCoherence[0][sf][band] = 0; + ismMetaHandle->surroundCoherence[sf][band] = 0; + ismMetaHandle->diffuseToTotalRatio[sf][band] = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + } + } + + /* Merge MASA metadatas */ + ivas_prerend_merge_masa_metadata_fx( masaMetaHandle, masaMetaHandle, + IVAS_REND_AUDIO_CONFIG_TYPE_MASA, + eneMasa_frac, eneMasa_exp, ismMetaHandle, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED, + eneIsm_frac, eneIsm_exp ); + + /* Mix the separated object audio signal to the MASA audio signals */ + ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism[0], + st_ivas->hMasaIsmData->elevation_separated_ism[0], old_panning_gains_q15_fx ); + ivas_get_stereo_panning_gains_fx( st_ivas->hMasaIsmData->azimuth_separated_ism[2], + st_ivas->hMasaIsmData->elevation_separated_ism[2], new_panning_gains_q15_fx ); + + /* Subsequent processing in Q31 format */ + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + new_panning_gains_fx[n] = L_shl( new_panning_gains_q15_fx[n], Q16 ); + old_panning_gains_fx[n] = L_shl( old_panning_gains_q15_fx[n], Q16 ); + } + + processing_len = shr( output_frame, 1 ); + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + v_multc_acc_exp_mantissa_fx( output[MASA_MAX_TRANSPORT_CHANNELS], + out_exp[MASA_MAX_TRANSPORT_CHANNELS], + old_panning_gains_fx[n], + output[n], + out_exp[n], + processing_len ); + } + offset = processing_len; + move16(); + + processing_len = shr( output_frame, 2 ); /* divide by MAX_PARAM_SPATIAL_SUBFRAMES; */ + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + Word32 mantissa; + + /* k == 0->gain == old_panning_gains[n] */ + /* output[n][offset] += gain * output[MASA_MAX_TRANSPORT_CHANNELS][offset]; */ + mantissa = mult32_mantissa_fx( output[MASA_MAX_TRANSPORT_CHANNELS][offset], + old_panning_gains_fx[n], + out_exp[MASA_MAX_TRANSPORT_CHANNELS][offset], &exp ); + + output[n][offset] = BASOP_Util_Add_Mant32Exp( output[n][offset], out_exp[n][offset], + mantissa, exp, &out_exp[n][offset] ); + move32(); + move32(); + + FOR( k = 1; k < processing_len; k++ ) + { + Word16 index = add( k, offset ); + + Word32 g1_fx = L_shl( st_ivas->hIsmRendererData->interpolator_fx[k], Q16 ); + + /* 1.0f - g1 */ + Word32 g2_fx = L_sub( MAX_32, L_sub( g1_fx, 1 ) ); + + /* g1 *new_panning_gains[n] + g2 *old_panning_gains[n] */ + Word32 gain_k = W_extract_h( W_add( W_mult_32_32( g1_fx, new_panning_gains_fx[n] ), + W_mult_32_32( g2_fx, old_panning_gains_fx[n] ) ) ); + + /* output[n][k + offset] += gain_k * output[MASA_MAX_TRANSPORT_CHANNELS][k + offset]; */ + mantissa = mult32_mantissa_fx( output[MASA_MAX_TRANSPORT_CHANNELS][index], gain_k, + out_exp[MASA_MAX_TRANSPORT_CHANNELS][index], &exp ); + output[n][index] = BASOP_Util_Add_Mant32Exp( output[n][index], out_exp[n][index], + mantissa, exp, &out_exp[n][index] ); + move32(); + move32(); + } + } + offset = add( offset, processing_len ); + + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + v_multc_acc_exp_mantissa_fx( &output[MASA_MAX_TRANSPORT_CHANNELS][offset], + &out_exp[MASA_MAX_TRANSPORT_CHANNELS][offset], + new_panning_gains_fx[n], + &output[n][offset], + &out_exp[n][offset], + processing_len ); + } + + /* Convert output from exponent+mantissa representation to Q11 */ + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + mantissa_exp_to_qvalue( &out_exp[n][0], &output[n][0], Q20, output_frame ); + } + + /* Zero output object channels */ + FOR( n = 0; n < nchan_ism; n++ ) + { + set_zero_fx( output[add( MASA_MAX_TRANSPORT_CHANNELS, n )], output_frame ); + } +} + + +/*-------------------------------------------------------------------------* + * ivas_omasa_render_objects_from_mix_open_fx() + * + * Open structures, reserve memory, and init values. + *-------------------------------------------------------------------------*/ + +ivas_error ivas_omasa_render_objects_from_mix_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 i; + Word32 size; + + st_ivas->hMasaIsmData->delayBuffer_nchan = 1; + move16(); + + st_ivas->hMasaIsmData->delayBuffer_size = extract_l( Mult_32_16( st_ivas->hDecoderConfig->output_Fs, + OMASA_DELAYFRAMES_PER_SEC_Q15 ) ); + + size = L_mult0( st_ivas->hMasaIsmData->delayBuffer_nchan, sizeof( Word16 * ) ); + st_ivas->hMasaIsmData->delayBuffer_fx = (Word32 **) malloc( size ); + move32(); + + IF( st_ivas->hMasaIsmData->delayBuffer_fx == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + + size = L_mult0( st_ivas->hMasaIsmData->delayBuffer_size, sizeof( Word32 ) ); + FOR( i = 0; i < st_ivas->hMasaIsmData->delayBuffer_nchan; i++ ) + { + st_ivas->hMasaIsmData->delayBuffer_fx[i] = (Word32 *) malloc( size ); + move32(); + + IF( st_ivas->hMasaIsmData->delayBuffer_fx[i] == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + set_zero_fx( st_ivas->hMasaIsmData->delayBuffer_fx[i], st_ivas->hMasaIsmData->delayBuffer_size ); + } + + return IVAS_ERR_OK; +} + + +/*--------------------------------------------------------------------------* + * ivas_omasa_render_objects_from_mix() + * + * In case of external rendering, render objects from the transport signal + * mix containing MASA audio and object audio. + *--------------------------------------------------------------------------*/ + +void ivas_omasa_render_objects_from_mix_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* o : output synthesis signal */ + const int16_t nchan_ism, /* i : number of ISMs */ + const int16_t output_frame, /* i : output frame length per channel */ + Word16 *output_q /* i/o: output Q value */ +) +{ + Word16 n, m, i; + MASA_ISM_EXT_DATA_HANDLE hExtData; + Word32 separated_object[L_FRAME48k]; + Word32 rendered_objects[MAX_NUM_OBJECTS][L_FRAME48k]; + Word16 coding_delay; + Word32 inRe[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 inIm[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 outRe[MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 outIm[MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 slot; + Word16 sf; + Word16 bin; + Word16 nchan_transport; + Word16 nBins; + + Word16 inRe_exp[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 inIm_exp[3][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 outRe_exp[MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word16 outIm_exp[MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + Word16 transport_energy_exp[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + Word32 transport_energy_frac[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + + /* Create slot to metadata map */ + slot = 0; + move16(); + FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) + { + Word16 index; + + FOR( i = 0; i < CLDFB_SLOTS_PER_SUBFRAME; i++ ) + { + st_ivas->hSpatParamRendCom->render_to_md_map[slot] = st_ivas->hSpatParamRendCom->dirac_read_idx; + move16(); + slot = add( slot, 1 ); + } + + index = add( st_ivas->hSpatParamRendCom->dirac_read_idx, 1 ); + IF( GE_16( index, st_ivas->hSpatParamRendCom->dirac_md_buffer_length ) ) + { + index = 0; + move16(); + } + st_ivas->hSpatParamRendCom->dirac_read_idx = index; + move16(); + } + + /* Move separated object signal and object channels */ + mvl2l( output[CPE_CHANNELS], separated_object, output_frame ); + FOR( n = 0; n < nchan_ism; n++ ) + { + set_zero_fx( output[CPE_CHANNELS + n], output_frame ); + } + + /* Delay the separated object signal by the CLDFB delay */ + delay_signal32_fx( separated_object, output_frame, st_ivas->hMasaIsmData->delayBuffer_fx[0], + st_ivas->hMasaIsmData->delayBuffer_size ); + + /* Set object metadata to the ism struct */ + FOR( n = 0; n < nchan_ism; n++ ) + { + // Q0 -> Q22 + Word32 azi = L_shl( st_ivas->hMasaIsmData->azimuth_ism[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); + Word32 ele = L_shl( st_ivas->hMasaIsmData->elevation_ism[n][st_ivas->hSpatParamRendCom->dirac_read_idx], Q22 ); + + st_ivas->hIsmMetaData[n]->azimuth_fx = azi; + st_ivas->hIsmMetaData[n]->elevation_fx = ele; + move16(); + move16(); + } + + /* Move the separated object signal to the correct output channel */ + hExtData = st_ivas->hMasaIsmData->hExtData; + move32(); + coding_delay = mult( output_frame, MULT_17_DIV_20_Q15 ); /* Q15: 17 ms of coding and CLDFB delay */ + mvl2l( separated_object, output[add( CPE_CHANNELS, hExtData->prev_idx_separated_ism )], coding_delay ); + mvl2l( &separated_object[coding_delay], + &output[add( CPE_CHANNELS, st_ivas->hMasaIsmData->idx_separated_ism )][coding_delay], + sub( output_frame, coding_delay ) ); + + /* Compute CLDFB analysis */ + nchan_transport = st_ivas->nchan_transport; + move16(); + nBins = mult( output_frame, MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ); // Q15 + + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + FOR( n = 0; n < nchan_transport; n++ ) + { + Word16 in_q = *output_q; + move16(); + + cldfbAnalysis_ts_fx_var_q( &( output[n][L_mult0( nBins, slot )] ), + inRe[n][slot], + inIm[n][slot], + nBins, st_ivas->cldfbAnaDec[n], &in_q ); + + /* Assign input exponent */ + Word16 exp = sub( Q31, in_q ); + set16_fx( inRe_exp[n][slot], exp, nBins ); + set16_fx( inIm_exp[n][slot], exp, nBins ); + } + } + + /* Create prototype signals */ + for ( n = 0; n < nchan_ism; n++ ) + { + Word32 panning_gains_fx[2]; + Word16 new_panning_gains_fx[2]; + Word16 azimuth_fx, elevation_fx; + + // Q22 -> Q0 + azimuth_fx = extract_l( L_shr( st_ivas->hIsmMetaData[n]->azimuth_fx, Q22 ) ); + elevation_fx = extract_l( L_shr( st_ivas->hIsmMetaData[n]->elevation_fx, Q22 ) ); + ivas_get_stereo_panning_gains_fx( azimuth_fx, elevation_fx, new_panning_gains_fx ); + + Word16 interpValInc = 0; + move16(); + + // Represents (1.0f - interpVal) value + Word16 interpValDec = extract_l( L_sub( -MIN16B, MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ) ); + + FOR( slot = 0; slot < sub( CLDFB_NO_COL_MAX, 1 ); slot++ ) + { + interpValInc = add( interpValInc, MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ); + + FOR( m = 0; m < 2; m++ ) + { + Word32 prev_gain = hExtData->prev_panning_gains[n][m]; + move32(); + + Word32 new_gain = L_shl( new_panning_gains_fx[m], 16 ); // Q15 -> Q31 + + panning_gains_fx[m] = L_add( Mpy_32_16( extract_h( prev_gain ), extract_l( prev_gain ), + interpValDec ), + Mpy_32_16( extract_h( new_gain ), extract_l( new_gain ), + interpValInc ) ); + } + + interpValDec = sub( interpValDec, MULT_1_DIV_CLDFB_NO_COL_MAX_Q15 ); + + v_multc_exp_mantissa_fx( inRe[0][slot], inRe_exp[0][slot], panning_gains_fx[0], + outRe[n][slot], outRe_exp[n][slot], nBins ); + v_multc_exp_mantissa_fx( inIm[0][slot], inIm_exp[0][slot], panning_gains_fx[0], + outIm[n][slot], outIm_exp[n][slot], nBins ); + + v_multc_acc_exp_mantissa_fx( inRe[1][slot], inRe_exp[1][slot], panning_gains_fx[1], + outRe[n][slot], outRe_exp[n][slot], nBins ); + v_multc_acc_exp_mantissa_fx( inIm[1][slot], inIm_exp[1][slot], panning_gains_fx[1], + outIm[n][slot], outIm_exp[n][slot], nBins ); + } + + // Special case where (1.0f - interpVal) = 0 and interpVal = 1 + FOR( m = 0; m < 2; m++ ) + { + panning_gains_fx[m] = L_shl( new_panning_gains_fx[m], 16 ); // Q15 -> Q31 + } + + v_multc_exp_mantissa_fx( inRe[0][slot], inRe_exp[0][slot], panning_gains_fx[0], + outRe[n][slot], outRe_exp[n][slot], nBins ); + v_multc_exp_mantissa_fx( inIm[0][slot], inIm_exp[0][slot], panning_gains_fx[0], + outIm[n][slot], outIm_exp[n][slot], nBins ); + + v_multc_acc_exp_mantissa_fx( inRe[1][slot], inRe_exp[1][slot], panning_gains_fx[1], + outRe[n][slot], outRe_exp[n][slot], nBins ); + v_multc_acc_exp_mantissa_fx( inIm[1][slot], inIm_exp[1][slot], panning_gains_fx[1], + outIm[n][slot], outIm_exp[n][slot], nBins ); + + FOR( m = 0; m < 2; m++ ) + { + hExtData->prev_panning_gains[n][m] = panning_gains_fx[m]; + move32(); + } + } + + /* Determine transport energy */ + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + set_zero_fx( &transport_energy_frac[slot][0], nBins ); + set16_zero_fx( &transport_energy_exp[slot][0], nBins ); + } + FOR( n = 0; n < CPE_CHANNELS; n++ ) + { + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + FOR( bin = 0; bin < nBins; bin++ ) + { + Word16 exp; + + // energy = re^2 + im^2 + Word32 mantissa = sample_energy_fx( inRe[n][slot][bin], inRe_exp[n][slot][bin], + inIm[n][slot][bin], inIm_exp[n][slot][bin], &exp ); + move32(); + + // Accumulate energy + transport_energy_frac[slot][bin] = BASOP_Util_Add_Mant32Exp( transport_energy_frac[slot][bin], + transport_energy_exp[slot][bin], + mantissa, + exp, + &transport_energy_exp[slot][bin] ); + move32(); + } + } + } + + /* Determine temporally smoothed energies and determine gains using them */ + FOR( n = 0; n < nchan_ism; n++ ) + { + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + Word16 md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[slot]; + move16(); + + FOR( bin = 0; bin < nBins; bin++ ) + { + Word16 exp, exp_mult, proto_e, target_e; + Word32 mantissa, proto_m, target_m; + + Word32 ism_target_energy_frac; + Word16 ism_target_energy_exp; + + Word32 ism_proto_energy_frac; + Word16 ism_proto_energy_exp; + + // r1 = transport_energy[slot][bin] * st_ivas->hMasaIsmData->energy_ratio_ism[n][md_idx][bin] + ism_target_energy_frac = mult32_mantissa_fx( transport_energy_frac[slot][bin], + st_ivas->hMasaIsmData->energy_ratio_ism_fx[n][md_idx][bin], + add( transport_energy_exp[slot][bin], 1 ), + &ism_target_energy_exp ); + move32(); + + // r2 = r1 * (1.0 - EXT_RENDER_IIR_FAC) + ism_target_energy_frac = mult32_mantissa_fx( ism_target_energy_frac, + ONEMINUX_EXT_RENDER_IIR_FAC_Q31, + ism_target_energy_exp, + &ism_target_energy_exp ); + move32(); + + // r3 = re^2 + im^2 + mantissa = sample_energy_fx( outRe[n][slot][bin], + outRe_exp[n][slot][bin], + outIm[n][slot][bin], + outIm_exp[n][slot][bin], + &exp ); + move32(); + + // r4 = r3 * (1 - EXT_RENDER_IIR_FAC) + ism_proto_energy_frac = mult32_mantissa_fx( mantissa, ONEMINUX_EXT_RENDER_IIR_FAC_Q31, + exp, &ism_proto_energy_exp ); + move32(); + + + // r5 = ism_render_proto_energy[n][bin] * EXT_RENDER_IIR_FAC + proto_m = mult32_mantissa_fx( hExtData->ism_render_proto_energy_frac[n][bin], EXT_RENDER_IIR_FAC_Q31, + hExtData->ism_render_proto_energy_exp[n][bin], &proto_e ); + move32(); + + // r6 = r5 + r4 + proto_m = BASOP_Util_Add_Mant32Exp( proto_m, proto_e, + ism_proto_energy_frac, + ism_proto_energy_exp, + &proto_e ); + move32(); + + // r7 = ism_render_target_energy[n][bin] * EXT_RENDER_IIR_FAC + target_m = mult32_mantissa_fx( hExtData->ism_render_target_energy_frac[n][bin], EXT_RENDER_IIR_FAC_Q31, + hExtData->ism_render_target_energy_exp[n][bin], &target_e ); + move32(); + + // r8 = r7 + r2 + target_m = BASOP_Util_Add_Mant32Exp( target_m, target_e, + ism_target_energy_frac, + ism_target_energy_exp, + &target_e ); + move32(); + + hExtData->ism_render_proto_energy_frac[n][bin] = proto_m; + hExtData->ism_render_proto_energy_exp[n][bin] = proto_e; + move32(); + move16(); + + hExtData->ism_render_target_energy_frac[n][bin] = target_m; + hExtData->ism_render_target_energy_exp[n][bin] = target_e; + move32(); + move16(); + + // r9 = sqrt(r8 / r6) + mantissa = get_processing_gain_fx( proto_m, proto_e, target_m, target_e, &exp ); + move32(); + + // outRe[n][slot][bin] *= r9 + exp_mult = add( exp, outRe_exp[n][slot][bin] ); + outRe[n][slot][bin] = mult32_mantissa_fx( outRe[n][slot][bin], mantissa, exp_mult, + &outRe_exp[n][slot][bin] ); + move32(); + + // outIm[n][slot][bin] *= r9 + exp_mult = add( exp, outIm_exp[n][slot][bin] ); + outIm[n][slot][bin] = mult32_mantissa_fx( outIm[n][slot][bin], mantissa, exp_mult, + &outIm_exp[n][slot][bin] ); + move32(); + } + } + } + + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + Word16 md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[slot]; + move16(); + + FOR( bin = 0; bin < nBins; bin++ ) + { + Word16 exp, proto_e, target_e, transport_exp; + Word32 mantissa, proto_m, target_m, transport_mantissa; + + Word32 masa_target_energy_frac; + Word16 masa_target_energy_exp; + + // r1 = transport_energy[slot][bin] * hExtData->masa_render_masa_to_total[md_idx][bin] + masa_target_energy_frac = mult32_mantissa_fx( transport_energy_frac[slot][bin], + hExtData->masa_render_masa_to_total[md_idx][bin], + add( transport_energy_exp[slot][bin], 1 ), + &masa_target_energy_exp ); + move32(); + + // r2 = r1 * EXT_RENDER_IIR_FAC + masa_target_energy_frac = mult32_mantissa_fx( masa_target_energy_frac, + ONEMINUX_EXT_RENDER_IIR_FAC_Q31, + masa_target_energy_exp, + &masa_target_energy_exp ); + move32(); + + // r3 = masa_render_proto_energy[bin] * EXT_RENDER_IIR_FAC + proto_m = mult32_mantissa_fx( hExtData->masa_render_proto_energy_frac[bin], EXT_RENDER_IIR_FAC_Q31, + hExtData->masa_render_proto_energy_exp[bin], &proto_e ); + move32(); + + // r4 = transport_energy[slot][bin] * EXT_RENDER_IIR_FAC + transport_mantissa = mult32_mantissa_fx( transport_energy_frac[slot][bin], + ONEMINUX_EXT_RENDER_IIR_FAC_Q31, + transport_energy_exp[slot][bin], &transport_exp ); + move32(); + + // r5 = r3 + r4 + proto_m = BASOP_Util_Add_Mant32Exp( proto_m, proto_e, + transport_mantissa, + transport_exp, + &proto_e ); + move32(); + + // r6 = masa_render_target_energy[bin] * EXT_RENDER_IIR_FAC + target_m = mult32_mantissa_fx( hExtData->masa_render_target_energy_frac[bin], EXT_RENDER_IIR_FAC_Q31, + hExtData->masa_render_target_energy_exp[bin], &target_e ); + move32(); + + // r7 = r6 + r2 + target_m = BASOP_Util_Add_Mant32Exp( target_m, target_e, + masa_target_energy_frac, + masa_target_energy_exp, + &target_e ); + move32(); + + hExtData->masa_render_proto_energy_frac[bin] = proto_m; + hExtData->masa_render_proto_energy_exp[bin] = proto_e; + move16(); + move32(); + + hExtData->masa_render_target_energy_frac[bin] = target_m; + hExtData->masa_render_target_energy_exp[bin] = target_e; + move16(); + move32(); + + // r8 = sqrt(r7 / r5) + mantissa = get_processing_gain_fx( proto_m, proto_e, target_m, target_e, &exp ); + move32(); + + FOR( n = 0; n < MASA_MAX_TRANSPORT_CHANNELS; n++ ) + { + Word16 exp_mult; + + // inRe[n][slot][bin] *= r8 + exp_mult = add( exp, inRe_exp[n][slot][bin] ); + inRe[n][slot][bin] = mult32_mantissa_fx( inRe[n][slot][bin], mantissa, exp_mult, + &inRe_exp[n][slot][bin] ); + move32(); + + // inIm[n][slot][bin] *= r8 + exp_mult = add( exp, inIm_exp[n][slot][bin] ); + inIm[n][slot][bin] = mult32_mantissa_fx( inIm[n][slot][bin], mantissa, exp_mult, + &inIm_exp[n][slot][bin] ); + move32(); + } + } + } + + *output_q = Q11; + + /* Compute CLDFB synthesis */ + FOR( slot = 0; slot < CLDFB_NO_COL_MAX; slot++ ) + { + Word32 *outSlotRePr, *outSlotImPr; + Word32 index = L_mult0( nBins, slot ); + + FOR( n = 0; n < nchan_transport; n++ ) + { + outSlotRePr = &( inRe[n][slot][0] ); + outSlotImPr = &( inIm[n][slot][0] ); + move32(); + move32(); + + FOR( bin = 0; bin < nBins; bin++ ) + { + inRe_exp[n][slot][bin] = sub( inRe_exp[n][slot][bin], Q2 ); + inIm_exp[n][slot][bin] = sub( inIm_exp[n][slot][bin], Q2 ); + } + + mantissa_exp_to_qvalue( &inRe_exp[n][slot][0], &inRe[n][slot][0], Q20, nBins ); + mantissa_exp_to_qvalue( &inIm_exp[n][slot][0], &inIm[n][slot][0], Q20, nBins ); + + cldfbSynthesis_ivas_fx( &outSlotRePr, &outSlotImPr, &output[n][index], + nBins, Q2, 1, st_ivas->cldfbSynDec[n] ); + } + + FOR( n = 0; n < nchan_ism; n++ ) + { + Word32 index2 = add( n, CPE_CHANNELS ); + + outSlotRePr = &( outRe[n][slot][0] ); + outSlotImPr = &( outIm[n][slot][0] ); + move32(); + move32(); + + mantissa_exp_to_qvalue( &outRe_exp[n][slot][0], &outRe[n][slot][0], Q20, nBins ); + mantissa_exp_to_qvalue( &outIm_exp[n][slot][0], &outIm[n][slot][0], Q20, nBins ); + + cldfbSynthesis_ivas_fx( &outSlotRePr, &outSlotImPr, &rendered_objects[n][index], + nBins, 0, 1, st_ivas->cldfbSynDec[index2] ); + } + } + + /* Combine the rendered objects with the separated objects */ + FOR( n = 0; n < nchan_ism; n++ ) + { + Word16 index = add( CPE_CHANNELS, n ); + v_add_32( output[index], rendered_objects[n], output[index], output_frame ); + } + + hExtData->prev_idx_separated_ism = st_ivas->hMasaIsmData->idx_separated_ism; + move16(); +} +#endif diff --git a/lib_dec/ivas_output_config_fx.c b/lib_dec/ivas_output_config_fx.c index bdf7b67bc..c5a01180d 100644 --- a/lib_dec/ivas_output_config_fx.c +++ b/lib_dec/ivas_output_config_fx.c @@ -479,8 +479,26 @@ void ivas_renderer_select( } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + *renderer_type = RENDERER_OMASA_OBJECT_EXT; + move32(); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + *renderer_type = RENDERER_OMASA_MIX_EXT; + move32(); + } + ELSE + { + *renderer_type = RENDERER_DISABLE; + move32(); + } +#else *renderer_type = RENDERER_DISABLE; move16(); +#endif } } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 687991c89..1e58959d5 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -771,7 +771,12 @@ void ivas_sba_dec_digest_tc_fx( Word16 ch_idx, nchan_transport; /* set the md map */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + IF( st_ivas->hDirAC != NULL || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) +#else IF( st_ivas->hDirAC ) +#endif { ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots ); } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 4a8c3cbd9..5b8bd48ff 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -926,6 +926,25 @@ typedef struct ivas_masa_decoder_struct } MASA_DECODER, *MASA_DECODER_HANDLE; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT +/* Data structure for MASA_ISM EXT rendering */ +typedef struct ivas_masa_ism_ext_data_structure +{ + Word16 prev_idx_separated_ism; // Q0 (Integer) + Word32 prev_panning_gains[MAX_NUM_OBJECTS][2]; // Q31 + Word16 ism_render_proto_energy_exp[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent) + Word32 ism_render_proto_energy_frac[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q31 + Word16 ism_render_target_energy_exp[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent) + Word32 ism_render_target_energy_frac[MAX_NUM_OBJECTS][CLDFB_NO_CHANNELS_MAX]; // Q31 + Word16 masa_render_proto_energy_exp[CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent) + Word32 masa_render_proto_energy_frac[CLDFB_NO_CHANNELS_MAX]; // Q31 + Word16 masa_render_target_energy_exp[CLDFB_NO_CHANNELS_MAX]; // Q0 (Integer exponent) + Word32 masa_render_target_energy_frac[CLDFB_NO_CHANNELS_MAX]; // Q31 + Word32 masa_render_masa_to_total[MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_MASA_PARAM_DEC_SFR][CLDFB_NO_CHANNELS_MAX]; // Q30 + +} MASA_ISM_EXT_DATA, *MASA_ISM_EXT_DATA_HANDLE; +#endif + /* Data structure for MASA_ISM rendering */ typedef struct ivas_masa_ism_data_structure { @@ -955,7 +974,9 @@ typedef struct ivas_masa_ism_data_structure Word32 **delayBuffer_fx; /* Q11 */ Word16 delayBuffer_size; Word16 delayBuffer_nchan; - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + MASA_ISM_EXT_DATA_HANDLE hExtData; +#endif } MASA_ISM_DATA, *MASA_ISM_DATA_HANDLE; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7c881cce9..98bbfd3d5 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1987,14 +1987,37 @@ ivas_error IVAS_DEC_GetNumObjects( UWord16 *numObjects /* o : number of objects for which the decoder has been configured */ ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + Word16 is_masa_ism; + is_masa_ism = 0; + move16(); +#endif test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( hIvasDec->st_ivas->hMasa != NULL ) + { + IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + is_masa_ism = 1; + move16(); + } + } + test(); + test(); + test(); + IF( EQ_32( hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) || + EQ_32( hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) || + EQ_32( hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) || + EQ_16( is_masa_ism, 1 ) ) +#else test(); test(); IF( EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, ISM_FORMAT ) || EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, SBA_ISM_FORMAT ) || EQ_16( (Word16) hIvasDec->st_ivas->ivas_format, MASA_ISM_FORMAT ) ) +#endif { *numObjects = hIvasDec->st_ivas->nchan_ism; } @@ -2029,7 +2052,14 @@ ivas_error IVAS_DEC_GetFormat( *format = IVAS_DEC_BS_UNKOWN; } move32(); - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + if ( EQ_32( *format, IVAS_DEC_BS_MASA ) && EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + *format = IVAS_DEC_BS_MASA_ISM; + move32(); + } +#endif return IVAS_ERR_OK; } @@ -2140,7 +2170,11 @@ ivas_error IVAS_DEC_GetObjectMetadata( { Decoder_Struct *st_ivas; ISM_METADATA_HANDLE hIsmMeta; - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + Word16 is_masa_ism; + is_masa_ism = 0; + move16(); +#endif test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -2148,9 +2182,27 @@ ivas_error IVAS_DEC_GetObjectMetadata( } st_ivas = hIvasDec->st_ivas; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( hIvasDec->st_ivas->hMasa != NULL ) + { + IF( EQ_32( hIvasDec->st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + { + is_masa_ism = 1; + move16(); + } + } + test(); + test(); + test(); + if ( NE_32( st_ivas->ivas_format, ISM_FORMAT ) && + NE_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && + NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && + EQ_16( is_masa_ism, 0 ) ) +#else test(); test(); IF( NE_16( st_ivas->ivas_format, ISM_FORMAT ) && NE_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) +#endif { return IVAS_ERR_WRONG_MODE; } @@ -2161,8 +2213,16 @@ ivas_error IVAS_DEC_GetObjectMetadata( } hIsmMeta = st_ivas->hIsmMetaData[objectIdx]; - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + test(); + test(); + IF( hIsmMeta == NULL || + EQ_16( zero_flag, 1 ) || + ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) ) +#else IF( hIsmMeta == NULL || zero_flag ) +#endif { metadata->azimuth_fx = 0; // Q22 metadata->elevation_fx = 0; // Q22 @@ -2834,9 +2894,13 @@ ivas_error IVAS_DEC_GetDelay( out_fs_fx = FS_48K_IN_NS_Q31; } move32(); - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbSynDec[0], hDecoderConfig->output_config ) ); + move16(); +#else nSamples[1] = NS2SA_FX2( hDecoderConfig->output_Fs, get_delay_fx( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], hDecoderConfig->output_config ) ); move16(); +#endif nSamples[2] = extract_l( W_round64_L( W_mult0_32_32( L_shl( st_ivas->binaural_latency_ns, 1 ), out_fs_fx ) ) ); move16(); nSamples[0] = add( nSamples[1], nSamples[2] ); diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 616c28ad8..72cc9d78d 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -533,8 +533,28 @@ ivas_error ivas_masa_encode_fx( } ELSE { - /* write the number of MASA transport channels */ - push_next_indice( hMetaData, sub( nchan_transport, 1 ), MASA_TRANSP_BITS ); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + test(); + IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) ) + { + /* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */ + IF( EQ_16( nchan_ism, 4 ) ) + { + push_next_indice( hMetaData, 1, MASA_TRANSP_BITS ); + } + ELSE + { + push_next_indice( hMetaData, 0, MASA_TRANSP_BITS ); + } + } + ELSE + { +#endif + /* write the number of MASA transport channels */ + push_next_indice( hMetaData, sub( nchan_transport, 1 ), MASA_TRANSP_BITS ); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + } +#endif hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_TRANSP_BITS ); move16(); } @@ -542,12 +562,25 @@ ivas_error ivas_masa_encode_fx( test(); IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) ) { +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IF( LE_16( nchan_ism, 3 ) ) + { + push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS ); + } + ELSE + { + push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_HEADER_BITS ); + } + hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); + move16(); +#else /* signal MASA_ISM_FORMAT to decoder */ push_next_indice( hMetaData, 1, 1 ); /* write reserved bit */ push_next_indice( hMetaData, 0, MASA_HEADER_BITS - 1 ); hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS ); move16(); +#endif } ELSE { diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 528ee4d76..432ed8253 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -220,6 +220,7 @@ void diffuse_meta_merge_1x1_fx( { Word32 new_dir_ratio_fx, new_diff_ratio_fx; Word16 new_dir_ratio_e; + outMeta->directionIndex[0][sf][band] = inMetaISM->directionIndex[0][sf][band]; move16(); outMeta->directToTotalRatio[0][sf][band] = inMetaISM->directToTotalRatio[0][sf][band]; @@ -252,7 +253,8 @@ void diffuse_meta_merge_1x1_fx( move16(); } - 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 ) ) ); + 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 ) ) ); /* Q0 */ + move16(); IF( GT_16( sub( 31, new_dir_ratio_e ), Q30 ) ) { diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 0939d0829..5cf767d0e 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -41,11 +41,20 @@ typedef struct masaMetaDelayStorage { MASA_DECRIPTIVE_META descriptiveMeta; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS]; + uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS]; + uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS]; + uint8_t surroundCoherence[DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS]; + uint8_t diffuseToTotalRatio[DELAY_MASA_PARAM_DEC_SFR + 1][MASA_FREQUENCY_BANDS]; + uint8_t prevDelay; +#else uint16_t directionIndex[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS]; uint8_t directToTotalRatio[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS]; uint8_t spreadCoherence[MASA_MAXIMUM_DIRECTIONS][DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS]; uint8_t surroundCoherence[DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS]; uint8_t diffuseToTotalRatio[DELAY_MASA_PARAM_DEC_SFR][MASA_FREQUENCY_BANDS]; +#endif } MASA_META_DELAY_STORAGE; @@ -88,14 +97,93 @@ static void getExtMasaMetadataFileName( static void delayMasaMetadata( MASA_DECODER_EXT_OUT_META_HANDLE extOutMeta, /* i/o: New input metadata which is inplace replaced with delayed metadata frame */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + MASA_META_DELAY_STORAGE *delayStorage, /* i/o: Storage for 15 ms of metadata and related descriptive metadata */ + uint8_t delayNsf +#else MASA_META_DELAY_STORAGE *delayStorage /* i/o: Storage for 10 ms of metadata and related descriptive metadata */ +#endif ) { int16_t dir, sf, band; uint8_t currentNumberOfDirections; - +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + int16_t storeReadOffset; +#endif /* Move meta to delay and output. Always use two directions as the metadata is prepared to contain zero energy second direction * if there is 1dir meta. */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + /* stable state expected results delay change expected results + delayNsf = 2 delayNsf = 3 delayNsf = 3 (from 2) delayNsf = 2 (from 3) + ext[0] = delayStorage[0] (prev ext[2]) ext[0] = delayStorage[0] (prev ext[1]) ext[0] = delayStorage[0] (prev ext[2]) ext[0] = delayStorage[1] (prev ext[2]) + ext[1] = delayStorage[1] (prev ext[3]) ext[1] = delayStorage[1] (prev ext[2]) ext[1] = delayStorage[1] (prev ext[3]) ext[1] = delayStorage[2] (prev ext[3]) + ext[2] = ext[0] ext[2] = delayStorage[2] (prev ext[3]) ext[2] = delayStorage[1] (prev ext[3]) ext[2] = ext[0] + ext[3] = ext[1] ext[3] = ext[0] ext[3] = ext[0] ext[3] = ext[0] + delayStorage[0] = ext[2] delayStorage[0] = ext[1] delayStorage[0] = ext[1] delayStorage[0] = ext[2] + delayStorage[1] = ext[3] delayStorage[1] = ext[2] delayStorage[1] = ext[2] delayStorage[1] = ext[3] + delayStorage[2] = ext[3] delayStorage[2] = ext[3] + */ + storeReadOffset = delayStorage->prevDelay > delayNsf ? delayStorage->prevDelay - delayNsf : 0; /* delay decreases: read later from storage -> discard one sf */ + + for ( sf = 0; sf < delayNsf; sf++ ) + { + for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) + { + uint16_t temp_u16; + uint8_t temp_u8; + int16_t toStoreIdx, reOrgIdx, storeReadIdx; + + toStoreIdx = sf + MAX_PARAM_SPATIAL_SUBFRAMES - delayNsf; + reOrgIdx = sf + delayNsf; + /* when switching to longer delay, repeat the last valid sf to fill the gap */ + storeReadIdx = ( ( sf + storeReadOffset ) < delayStorage->prevDelay ) ? sf + storeReadOffset : delayStorage->prevDelay - 1; + + for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ ) + { + temp_u16 = delayStorage->directionIndex[dir][storeReadIdx][band]; + delayStorage->directionIndex[dir][sf][band] = extOutMeta->directionIndex[dir][toStoreIdx][band]; + if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + extOutMeta->directionIndex[dir][reOrgIdx][band] = extOutMeta->directionIndex[dir][sf][band]; + } + extOutMeta->directionIndex[dir][sf][band] = temp_u16; + + temp_u8 = delayStorage->directToTotalRatio[dir][storeReadIdx][band]; + delayStorage->directToTotalRatio[dir][sf][band] = extOutMeta->directToTotalRatio[dir][toStoreIdx][band]; + if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + extOutMeta->directToTotalRatio[dir][reOrgIdx][band] = extOutMeta->directToTotalRatio[dir][sf][band]; + } + extOutMeta->directToTotalRatio[dir][sf][band] = temp_u8; + + temp_u8 = delayStorage->spreadCoherence[dir][storeReadIdx][band]; + delayStorage->spreadCoherence[dir][sf][band] = extOutMeta->spreadCoherence[dir][toStoreIdx][band]; + if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + extOutMeta->spreadCoherence[dir][reOrgIdx][band] = extOutMeta->spreadCoherence[dir][sf][band]; + } + extOutMeta->spreadCoherence[dir][sf][band] = temp_u8; + } + + temp_u8 = delayStorage->surroundCoherence[storeReadIdx][band]; + delayStorage->surroundCoherence[sf][band] = extOutMeta->surroundCoherence[toStoreIdx][band]; + if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + extOutMeta->surroundCoherence[reOrgIdx][band] = extOutMeta->surroundCoherence[sf][band]; + } + extOutMeta->surroundCoherence[sf][band] = temp_u8; + + temp_u8 = delayStorage->diffuseToTotalRatio[storeReadIdx][band]; + delayStorage->diffuseToTotalRatio[sf][band] = extOutMeta->diffuseToTotalRatio[toStoreIdx][band]; + if ( reOrgIdx < MAX_PARAM_SPATIAL_SUBFRAMES ) + { + extOutMeta->diffuseToTotalRatio[reOrgIdx][band] = extOutMeta->diffuseToTotalRatio[sf][band]; + } + extOutMeta->diffuseToTotalRatio[sf][band] = temp_u8; + } + } + +#else for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES - DELAY_MASA_PARAM_DEC_SFR; sf++ ) { for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) @@ -131,6 +219,7 @@ static void delayMasaMetadata( extOutMeta->diffuseToTotalRatio[sf][band] = temp_u8; } } +#endif /* Finalize descriptive meta by using new frame except for number of directions which is the larger of the two */ currentNumberOfDirections = extOutMeta->descriptiveMeta.numberOfDirections; @@ -140,6 +229,9 @@ static void delayMasaMetadata( } delayStorage->descriptiveMeta.numberOfDirections = currentNumberOfDirections; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + delayStorage->prevDelay = delayNsf; +#endif return; } @@ -182,6 +274,9 @@ ivas_error MasaFileWriter_open( if ( !delayCompensationEnabled ) { self->delayStorage = calloc( sizeof( MASA_META_DELAY_STORAGE ), 1 ); +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + self->delayStorage->prevDelay = DELAY_MASA_PARAM_DEC_SFR; +#endif } *masaWriter = self; @@ -198,7 +293,12 @@ ivas_error MasaFileWriter_open( ivas_error MasaFileWriter_writeFrame( MasaFileWriter *self, /* i/o: MasaFileWriter handle */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */ + const float *decDelay /* i : decoding audio delay */ +#else MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta /* i/o: MASA ext out meta handle to be written */ +#endif ) { if ( self == NULL ) @@ -209,7 +309,17 @@ ivas_error MasaFileWriter_writeFrame( uint16_t descMetaTemp = 0; int16_t i, sf, dir, numDirections; uint8_t writeTempOther[MASA_FREQUENCY_BANDS]; +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + /* If delay storage has been reserved, then we are in the normal mode for the decoder + * (i.e., no delay compensation for PCM) which means that metadata should be delayed + * by two or three subframes (10 or 15 ms). Descriptive metadata is a combined result. */ + if ( self->delayStorage ) + { + uint8_t delayFrames = (uint8_t) ( (int32_t) ( ( *decDelay ) * 48000 ) / L_SPATIAL_SUBFR_48k ); + delayMasaMetadata( hMasaExtOutMeta, self->delayStorage, delayFrames ); + } +#else /* If delay storage has been reserved, then we are in the normal mode for the decoder * (i.e., no delay compensation for PCM) which means that metadata should be delayed * by two subframes (10 ms). Descriptive metadata is a combined result. */ @@ -217,7 +327,7 @@ ivas_error MasaFileWriter_writeFrame( { delayMasaMetadata( hMasaExtOutMeta, self->delayStorage ); } - +#endif numDirections = hMasaExtOutMeta->descriptiveMeta.numberOfDirections + 1; if ( fwrite( &( hMasaExtOutMeta->descriptiveMeta.formatDescriptor ), sizeof( uint8_t ), 8, self->file ) != 8 ) diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index 2d476e28f..17c2a790a 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -48,7 +48,12 @@ ivas_error MasaFileWriter_open( ivas_error MasaFileWriter_writeFrame( MasaFileWriter *self, /* i/o: MasaFileWriter handle */ +#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */ + const float *decDelay /* i : decoding audio delay */ +#else IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta /* i/o: MASA ext out meta handle to be written */ +#endif ); void MasaFileWriter_close( -- GitLab From 9a88a2925e96856eb9c89e64f1f095888115eaa9 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 24 Jul 2025 16:30:36 +0300 Subject: [PATCH 642/692] Clang format --- lib_util/masa_file_writer.c | 6 +++--- lib_util/masa_file_writer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_util/masa_file_writer.c b/lib_util/masa_file_writer.c index 5cf767d0e..ab2596320 100644 --- a/lib_util/masa_file_writer.c +++ b/lib_util/masa_file_writer.c @@ -100,8 +100,8 @@ static void delayMasaMetadata( #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT MASA_META_DELAY_STORAGE *delayStorage, /* i/o: Storage for 15 ms of metadata and related descriptive metadata */ uint8_t delayNsf -#else - MASA_META_DELAY_STORAGE *delayStorage /* i/o: Storage for 10 ms of metadata and related descriptive metadata */ +#else + MASA_META_DELAY_STORAGE *delayStorage /* i/o: Storage for 10 ms of metadata and related descriptive metadata */ #endif ) { @@ -292,7 +292,7 @@ ivas_error MasaFileWriter_open( *---------------------------------------------------------------------*/ ivas_error MasaFileWriter_writeFrame( - MasaFileWriter *self, /* i/o: MasaFileWriter handle */ + MasaFileWriter *self, /* i/o: MasaFileWriter handle */ #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */ const float *decDelay /* i : decoding audio delay */ diff --git a/lib_util/masa_file_writer.h b/lib_util/masa_file_writer.h index 17c2a790a..c3e142254 100644 --- a/lib_util/masa_file_writer.h +++ b/lib_util/masa_file_writer.h @@ -47,7 +47,7 @@ ivas_error MasaFileWriter_open( ); ivas_error MasaFileWriter_writeFrame( - MasaFileWriter *self, /* i/o: MasaFileWriter handle */ + MasaFileWriter *self, /* i/o: MasaFileWriter handle */ #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta, /* i/o: MASA ext out meta handle to be written */ const float *decDelay /* i : decoding audio delay */ -- GitLab From 1ab046ca15117bc2468e0709b42302586b4a9b1c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:23:21 +0200 Subject: [PATCH 643/692] ci adjustments for merge to main --- .gitlab-ci.yml | 1670 +++++++++++++++++++++++++----------------------- 1 file changed, 853 insertions(+), 817 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 842aefbc7..a2bd885d5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,89 +1,14 @@ variables: - TESTV_DIR: "/usr/local/testv" - LTV_DIR: "/usr/local/ltv" - EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" - FLOAT_REF_BRANCH: "ivas-float-update" - BUILD_OUTPUT: "build_output.txt" - SCRIPTS_DIR: "/usr/local/scripts" - EXIT_CODE_NON_BE: 123 - EXIT_CODE_FAIL: 1 - 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" - SHORT_TEST_SUITE: "tests/codec_be_on_mr_nonselection" - SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" - LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" - TEST_SUITE: "" - DISABLE_HRTF_MODEL_TESTS: "" - # DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests - - # These path variables are used by the pytest calls. - # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain - DUT_ENCODER_PATH: "./IVAS_cod" - DUT_DECODER_PATH: "./IVAS_dec" - DUT_RENDERER_PATH: "./IVAS_rend" - DUT_POST_RENDERER_PATH: "./ISAR_post_rend" - REF_ENCODER_PATH: "./IVAS_cod_ref" - REF_DECODER_PATH: "./IVAS_dec_ref" - REF_RENDERER_PATH: "./IVAS_rend_ref" - REF_POST_RENDERER_PATH: "./ISAR_post_rend_ref" - MERGE_TARGET_ENCODER_PATH: "./IVAS_cod_merge_target" - MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" - MERGE_TARGET_RENDERER_PATH: "./IVAS_rend_merge_target" - MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" - # These path variables are used for building the binaries - # They should never be overwritten! - REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" - REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" - REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_ref" - REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_ref" - MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_target" - MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" - MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_target" - MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_target" - LEVEL_SCALING: "1.0" - IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" - PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" - TESTCASE_TIMEOUT_STV: 900 - TESTCASE_TIMEOUT_LTV: 2400 - TESTCASE_TIMEOUT_LTV_SANITIZERS: 6000 - CI_REGRESSION_THRESH_MLD: "0.1" - CI_REGRESSION_THRESH_MAX_ABS_DIFF: "50" - CI_REGRESSION_THRESH_SSNR: "-1" - CI_REGRESSION_THRESH_ODG: "-0.05" - GIT_CLEAN_FLAGS: -ffdxq - INSTR_DIR: "scripts/c-code_instrument" - TESTS_DIR_CODEC_BE_ON_MR: "tests/codec_be_on_mr_nonselection" - BUILD_WITH_DEBUG_MODE_INFO: "" - ENCODER_TEST: "" - DELTA_ODG: "" - COMPARE_DMX: "" - SPLIT_COMPARISON: "" - SKIP_REGRESSION_CHECK: "" - FAILED_TESTCASES_LIST: "failed-testcases.txt" - ERRORS_TESTCASES_LIST: "errors-testcases.txt" - PYTEST_CACHE_ARTIFACT: "pytest_cache.zip" - MEASURES_FOR_REPORT: "MLD MAX_ABS_DIFF MIN_SSNR MIN_ODG" - 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" - MANUAL_PIPELINE_TYPE: - description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec." - value: 'default' - options: - - 'default' - - 'pytest-compare' - - 'pytest-compare-long' - - 'pytest-compare-to-input' - - 'pytest-saturation-smoke-test' - - 'evs-26444' - - 'sanitizer' - - 'pytest-renderer' - - 'complexity' - - 'coverage' - - 'voip-be-test' - - 'peaq-enc-passthrough' + # 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 main +include: + - local: .gitlab-ci/variables.yml + - local: .gitlab-ci/rules-basis.yml + - project: ivas-codec-pc/ivas-codec-ci + ref: *IVAS_CODEC_CI_REF + file: main.yml default: interruptible: true # Make all jobs by default interruptible @@ -104,12 +29,24 @@ 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 == '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' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-enc-dmx' + variables: + IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long-fx-fx' + variables: + IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH' - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input' variables: IVAS_PIPELINE_NAME: 'Run comparison tools against input (pass-through only): $CI_COMMIT_BRANCH' @@ -131,6 +68,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' @@ -138,17 +78,6 @@ workflow: variables: IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' - -stages: - - .pre - - prevalidate - - build - - check-be - - test - - compare - - postvalidate - - deploy - # --------------------------------------------------------------- # Generic script anchors # --------------------------------------------------------------- @@ -156,13 +85,6 @@ stages: # These can be used later on to do common tasks # Prints useful information for every job and should be used at the beginning of each job -.print-common-info: &print-common-info - - | - echo "Printing common information for build job." - echo "Current job is run on commit $CI_COMMIT_SHA" - echo "Commit time was $CI_COMMIT_TIMESTAMP" - date | xargs echo "System time is" - .print-common-info-windows: &print-common-info-windows - | echo "Printing common information for build job." @@ -170,12 +92,15 @@ stages: echo "Commit time was $CI_COMMIT_TIMESTAMP" ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression -.activate-debug-mode-info-if-set: &activate-debug-mode-info-if-set - - if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then - - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h - - sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h - - fi +.activate-Werror-linux: &activate-Werror-linux + - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile + - sed -i.bak "s/# \(set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -Werror\")\)/\1/" CMakeLists.txt +.activate-WX-windows: &activate-WX-windows + - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" + - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } + +# NOTE: can be removed if script from ci repo works .build-merge-target-binaries: &build-merge-target-binaries - current_commit_sha=$(git rev-parse HEAD) ### build merge target binaries @@ -198,21 +123,9 @@ stages: - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE - git checkout $current_commit_sha -# From float CI -.mr-fetch-target-branch: &mr-fetch-target-branch - # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching - # depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later - - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME || true - # needed when depth is lower than the number of commits in the branch - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:$CI_MERGE_REQUEST_TARGET_BRANCH_NAME - -# From float CI -.mr-get-target-commit: &mr-get-target-commit # compare to last target branch commit before pipeline was created - - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H) - # From float CI .merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec - - *build-merge-target-binaries + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh # need to rename to match the conventions for the renderer tests... - mv $MERGE_TARGET_ENCODER_PATH $REF_ENCODER_PATH @@ -230,136 +143,12 @@ stages: - if [ $exit_code -ne 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi - exit 0 -.build-float-ref-binaries: &build-float-ref-binaries - - git rev-parse HEAD > $CUT_COMMIT_FILE - - current_commit_sha=$(git rev-parse HEAD) - ### build reference binaries - - git checkout $FLOAT_REF_BRANCH - - git pull origin $FLOAT_REF_BRANCH - - *activate-debug-mode-info-if-set - - make clean - - make -j >> /dev/null - - mv ./IVAS_cod ./$REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_dec ./$REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_rend ./$REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./ISAR_post_rend ./$REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - ### Return to current branch - - git restore . - - git rev-parse HEAD > $FLOAT_REF_COMMIT_FILE - - git checkout $current_commit_sha - -.build-float-ref-and-dut-binaries: &build-float-ref-and-dut-binaries -### build reference binaries - - *build-float-ref-binaries -### build dut binaries - - *activate-debug-mode-info-if-set - - make clean - - make -j >> /dev/null - -.build-and-create-float-ref-outputs: &build-and-create-float-ref-outputs - - *build-float-ref-and-dut-binaries - - ### prepare pytest - # create short test vectors - - python3 tests/create_short_testvectors.py - # create references - - exit_code=0 - - enc_stats_arg="" - - if [ "$ENCODER_TEST" = "true" ]; then enc_stats_arg="--enc_stats"; fi - - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? - -.update-scripts-repo: &update-scripts-repo - - cd $SCRIPTS_DIR - - sed -i '/fetch/d' .git/config # Remove all fetch lines to clean out dead links - - git remote set-branches --add origin $BASOP_CI_BRANCH_PC_REPO # Add currently used branch - - git fetch - - git restore --staged . # Needed if HRTF model files were updated. - - git restore . # Just as a precaution - - git checkout $BASOP_CI_BRANCH_PC_REPO - - git pull origin $BASOP_CI_BRANCH_PC_REPO - - - cd - - - cp -r $SCRIPTS_DIR/ci . - - cp -r $SCRIPTS_DIR/scripts . - - cp -r $SCRIPTS_DIR/tests . - - cp $SCRIPTS_DIR/pytest.ini . - -.apply-testv-scaling: &apply-testv-scaling - - echo "Applying level scaling in scripts/testv using scale=$LEVEL_SCALING" - - tests/scale_pcm.py ./scripts/testv/ $LEVEL_SCALING - -.update-ltv-repo: &update-ltv-repo - - cd $LTV_DIR - - git pull - - cd - - -.get-commits-behind-count: &get-commits-behind-count - - echo $CI_COMMIT_SHA - - echo $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - commits_behind_count=$(git rev-list --count $CI_COMMIT_SHA..origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME) - -.check-commits-behind-count-in-compare-jobs: &check-commits-behind-count-in-compare-jobs - - | - if [ $commits_behind_count -ne 0 ]; then - echo "Your branch is not up-to-date with main -> Compare tests will not run as they can contain false negatives this way." - echo "Main might have changed during your pipeline run. Run 'git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME' to update." - exit 1 - fi - -.copy-ltv-files-to-testv-dir: ©-ltv-files-to-testv-dir - - cp "$LTV_DIR"/*.wav scripts/testv/ - - cp "$LTV_DIR"/*.met scripts/testv/ - - cp "$LTV_DIR"/*.csv scripts/testv/ - -.activate-Werror-linux: &activate-Werror-linux - - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile - - sed -i.bak "s/# \(set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -Werror\")\)/\1/" CMakeLists.txt - -.activate-WX-windows: &activate-WX-windows - - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" - - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } - -.remove_unsupported_testcases: &remove_unsupported_testcases - # Note: the --use-main-pc-set arg should only be used on main-pc and float-pc branches - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - -# --------------------------------------------------------------- -# Job templates -# --------------------------------------------------------------- - -# When designing templates, try not to use too much inheritance and -# if multiple templates and extended on, remember that on conflict, -# latest overwrites the parameter. - -# templates for rules -.rules-basis: - rules: - - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined) - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions) - when: never - - if: $CI_PIPELINE_SOURCE == 'trigger' # Don't run triggered pipeline by default - when: never - - if: $MANUAL_PIPELINE_TYPE == 'test-be-release' # Skip all the normal jobs when testing manually against release codec - when: never - - if: $MANUAL_PIPELINE_TYPE == 'test-long-self-test' # Skip all the normal jobs when testing manually against release codec - when: never - - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'ivas-conformance-linux' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'check-clipping' - when: never - - if: $MANUAL_PIPELINE_TYPE == 'test-branch-vs-input-passthrough' - when: never - - when: on_success - .rules-merge-request: - extends: .rules-basis rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_PIPELINE_SOURCE == 'push' when: never + - when: never .rules-pytest-to-ref-short: rules: @@ -377,26 +166,17 @@ stages: - if: $CI_PIPELINE_SOURCE == 'schedule' when: never -.rules-pytest-to-main-short: +.rules-pytest-to-ref-enc-short-dmx: rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-enc-dmx" - if: $CI_PIPELINE_SOURCE == 'push' when: never - -.rules-mr-to-main-or-main-pc: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc") - - if: $CI_PIPELINE_SOURCE == 'push' + - if: $CI_PIPELINE_SOURCE == 'schedule' when: never -.rules-mr-to-main-or-main-pc-or-manual: +.rules-pytest-to-main-short: rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc") + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - if: $CI_PIPELINE_SOURCE == 'push' when: never @@ -409,6 +189,15 @@ stages: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' when: never +.rules-pytest-long-fx-fx: + rules: + - if: $PYTEST_MLD_LONG_FX_FX # Set by scheduled pipeline + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long-fx-fx" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + when: never + .rules-coverage: rules: - if: $COVERAGE_TEST # Set by scheduled pipeline @@ -436,19 +225,22 @@ stages: - if: $CI_PIPELINE_SOURCE == 'push' when: never -.rules-merge-request-to-main-pc: - extends: .rules-basis - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main-pc' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never +# --------------------------------------------------------------- +# Job templates +# --------------------------------------------------------------- -# templates to define stages and platforms -.test-job-linux: +# override for centrally defined job to make use of the basop runners +.job-linux: tags: - - ivas-linux + - ivas-basop-linux + +# custom variant of this template, we need to update the scripts repo before every build +.test-job-linux: + extends: + - .job-linux + before_script: + - !reference [.job-linux, before_script] + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh .test-job-linux-compares-to-fixed-target: extends: .test-job-linux @@ -457,28 +249,17 @@ stages: artifacts: true - job: build-codec-linux-make -.build-job-linux: - stage: build - timeout: "2 minutes" - tags: - - ivas-linux - -.build-job-windows: - stage: build - timeout: "4 minutes" - tags: - - ivas-windows - .print-results-banner: &print-results-banner - - set +x - - echo "" - - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" + - set +x + - echo "" + - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" # template for test jobs on linux that need the TESTV_DIR .test-job-linux-needs-testv-dir: extends: .test-job-linux before_script: - - *update-scripts-repo + - !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/ @@ -497,24 +278,28 @@ stages: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" IMAGES_ARTIFACT_SPLIT: "images_split_$CI_JOB_NAME" script: - - *print-common-info - - *update-scripts-repo + - !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 - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir + - 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 - - *remove_unsupported_testcases - - if [ $LEVEL_SCALING != "1.0" ];then - - *apply-testv-scaling + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - if [ $LEVEL_SCALING != "1.0" ]; then + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi - if [ "$COMPARE_DMX" = "true" ] || [ "$ENCODER_TEST" = "true" ]; then - BUILD_WITH_DEBUG_MODE_INFO="true" - fi + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" @@ -524,7 +309,7 @@ stages: - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; MEASURES_FOR_REPORT="$MEASURES_FOR_REPORT DELTA_ODG"; fi - if [ "$SPLIT_COMPARISON" = "true" ]; then comp_args="${comp_args} --split-comparison"; fi - - *build-and-create-float-ref-outputs + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh # DMX comparison only in manual job with no other metrics - if [ "$COMPARE_DMX" = "true" ]; then @@ -560,7 +345,7 @@ stages: - 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" @@ -607,15 +392,38 @@ stages: - report-junit.xml .check-up-to-date-in-comparison-jobs: &check-up-to-date-in-comparison-jobs - - *get-commits-behind-count - | + commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" if [ $commits_behind_count -ne 0 ]; then set +x echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness or testing for regressions now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 fi -.check-be-to-target-anchor: &check-be-to-target-anchor +.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 + variables: + USE_LTV: 0 + +# TODO: we might need a new mechanism here now that everything happens on main +.set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch + - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main" ]; then + - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file + - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt + - FLOAT_REF_BRANCH=$(cat tmp_ref_branch.txt) + - fi + - fi + +.check-be-to-target-job: + extends: + - .check-be-job stage: check-be needs: ["build-codec-linux-make","branch-is-up-to-date-with-target-pre"] timeout: "300 minutes" @@ -624,40 +432,40 @@ stages: HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" PYTEST_LOG_TARGET_BRANCH: "pytest-log-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME.txt" script: - - *print-common-info + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - set -euxo pipefail - - *update-scripts-repo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - python3 tests/create_short_testvectors.py - if [ $USE_LTV -eq 1 ]; then - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir + - 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 - - *remove_unsupported_testcases + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - python3 scripts/prepare_combined_format_inputs.py - if [ $LEVEL_SCALING != "1.0" ];then - - *apply-testv-scaling + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi - - *build-float-ref-binaries - - *build-merge-target-binaries + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target - make clean - make -j >> /dev/null - *check-up-to-date-in-comparison-jobs - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH $DISABLE_HRTF_MODEL_TESTS > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout $DISABLE_HRTF_MODEL_TESTS > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -726,7 +534,9 @@ stages: - unzip $PYTEST_CACHE_ARTIFACT - fi -.check-regressions-pytest-anchor: &check-regressions-pytest-anchor +.check-regressions-pytest-job: + extends: + - .check-be-job stage: test timeout: "300 minutes" variables: @@ -739,7 +549,7 @@ stages: IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" script: - - *print-common-info + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh # create empty files for all artifacts to suppress warnings in case of no regressions found or all is BE - touch $XML_REPORT_BRANCH $XML_REPORT_MAIN $HTML_REPORT_BRANCH $HTML_REPORT_MAIN $CSV_BRANCH $CSV_MAIN $SUMMARY_HTML_ARTIFACT_NAME $FLOAT_REF_COMMIT_FILE $CUT_COMMIT_FILE $MERGE_TARGET_COMMIT_FILE regressions_crashes.csv regressions_MLD.csv regressions_MAX_ABS_DIFF.csv regressions_MIN_SSNR.csv regressions_MIN_ODG.csv improvements_crashes.csv improvements_MLD.csv improvements_MAX_ABS_DIFF.csv improvements_MIN_SSNR.csv improvements_MIN_ODG.csv @@ -757,19 +567,19 @@ stages: - exit 0 - fi - - *update-scripts-repo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - if [ $USE_LTV -eq 1 ]; then - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir + - 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 - - *remove_unsupported_testcases + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - if [ $LEVEL_SCALING != "1.0" ];then - - *apply-testv-scaling + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi # check MR title for flag that allows regressions to be mergable @@ -781,7 +591,7 @@ stages: ### run branch first # this per default builds the branch and the reference and creates the reference outputs - - *build-and-create-float-ref-outputs + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh - *check-up-to-date-in-comparison-jobs # need to restore cache again - *overwrite-pytest-cache-with-artifact @@ -797,7 +607,10 @@ stages: - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT ### run main now - - *build-merge-target-binaries + - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - make clean + - make -j >> /dev/null # need to restore cache again - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true @@ -871,9 +684,11 @@ stages: .ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor + extends: + - .job-linux stage: test needs: ["build-codec-linux-make"] - timeout: "300 minutes" + timeout: "600 minutes" rules: - if: $CI_PIPELINE_SOURCE == 'push' when: never @@ -882,12 +697,14 @@ stages: - if: $CI_PIPELINE_SOURCE == 'schedule' && $IVAS_PYTEST_MSAN - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer" script: - - *print-common-info - - *update-scripts-repo - - *copy-ltv-files-to-testv-dir - - *remove_unsupported_testcases + - !reference [ .job-linux, before_script ] - - *build-float-ref-binaries + - 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/copy-ltv-files-to-testv-dir.sh + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - set -euxo pipefail - make_args="CLANG=$CLANG_NUM" - if [[ $CLANG_NUM == 3 ]]; then @@ -922,21 +739,23 @@ stages: SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" script: - - *print-common-info - - *update-scripts-repo + - !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 - if [ $USE_LTV -eq 1 ]; then - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir + - 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 - - *remove_unsupported_testcases + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - if [ $LEVEL_SCALING != "1.0" ];then - - *apply-testv-scaling + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi - - *build-float-ref-and-dut-binaries + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" @@ -1001,10 +820,10 @@ uninterruptible: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: always tags: - - ivas-linux + - ivas-basop-linux # --------------------------------------------------------------- -# Validation jobs +# verification jobs # --------------------------------------------------------------- # fail pipeline in the final stage for pipelines on Draft MRs @@ -1029,25 +848,22 @@ check-naming-of-branch-for-main-pc-merges: tags: - ivas-linux script: - - *update-scripts-repo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - fi -# --------------------------------------------------------------- -# verification jobs -# --------------------------------------------------------------- - branch-is-up-to-date-with-target-pre: extends: + - .job-linux - .rules-merge-request stage: prevalidate needs: [] tags: - - ivas-linux + - ivas-basop-linux script: - - *get-commits-behind-count - | + commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" if [ $commits_behind_count -ne 0 ]; then echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 1 @@ -1062,13 +878,14 @@ branch-is-up-to-date-with-target-pre: branch-is-up-to-date-with-target-post: extends: + - .job-linux - .rules-merge-request stage: postvalidate tags: - - ivas-linux + - ivas-basop-linux script: - - *get-commits-behind-count - | + commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" if [ $commits_behind_count -ne 0 ]; then echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." exit 123 @@ -1081,7 +898,7 @@ clang-format-check: extends: - .test-job-linux rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - if: $CI_PIPELINE_SOURCE == 'push' when: never - if: $CI_PIPELINE_SOURCE == 'schedule' @@ -1089,12 +906,10 @@ clang-format-check: variables: ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" stage: prevalidate - tags: - - ivas-linux needs: [] timeout: "5 minutes" script: - - *update-scripts-repo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch - > @@ -1141,8 +956,9 @@ clang-format-check: needs: ["build-codec-linux-make"] timeout: "5 minutes" script: - - *print-common-info - - *update-scripts-repo + - 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 + - make clean - make -j - python3 tests/create_short_testvectors.py --cut_len 1.0 @@ -1161,9 +977,12 @@ clang-format-check: # Build jobs # --------------------------------------------------------------- +# TODO: template rules for the build jobs # ensure that codec builds on linux build-codec-linux-make: rules: + - 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 - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs @@ -1172,16 +991,16 @@ build-codec-linux-make: when: never extends: - .build-job-linux - tags: - - ivas-linux - timeout: "10 minutes" + timeout: "100 minutes" script: - - *print-common-info + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - *activate-Werror-linux - make -j build-codec-linux-cmake: rules: + - 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 - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs @@ -1190,152 +1009,391 @@ build-codec-linux-cmake: when: never extends: - .build-job-linux - tags: - - ivas-linux timeout: "10 minutes" script: - - *print-common-info - - *update-scripts-repo + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - cmake -B cmake-build -G "Unix Makefiles" - cmake --build cmake-build -- -j # ensure that codec builds on linux with instrumentation active build-codec-linux-instrumented-make: rules: + - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - if: $CI_PIPELINE_SOURCE == 'schedule' - if: $CI_PIPELINE_SOURCE == 'push' when: never extends: - .build-job-linux - timeout: "10 minutes" - tags: - - ivas-linux + timeout: "100 minutes" script: - - *print-common-info - - *update-scripts-repo + - 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 scripts/prepare_instrumentation.sh -m MEM_ONLY - make -j -C $INSTR_DIR - # make sure that the codec builds with msan, asan and usan build-codec-sanitizers-linux: + rules: + - 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 + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main + - if: $CI_PIPELINE_SOURCE == 'schedule' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never extends: - .build-job-linux - - .rules-basis - tags: - - ivas-linux - timeout: "10 minutes" + timeout: "100 minutes" script: - - *update-scripts-repo - - *print-common-info + - 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 # TODO: re-enable once all the warnings have been fixed #- *activate-Werror-linux - bash ci/build_codec_sanitizers_linux.sh -build-codec-windows-msbuild: +build-codec-linux-debugging-make: rules: + - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - if: $CI_PIPELINE_SOURCE == 'schedule' - if: $CI_PIPELINE_SOURCE == 'push' when: never extends: - - .build-job-windows - timeout: "10 minutes" - tags: - - ivas-windows + - .build-job-linux + timeout: "100 minutes" + variables: + BUILD_WITH_DEBUG_MODE_INFO: "true" script: - - *print-common-info-windows - - *activate-WX-windows - - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug - + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh + - make -j -build-codec-linux-debugging-make: +build-codec-windows-msbuild: rules: + - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs - if: $CI_PIPELINE_SOURCE == 'schedule' - if: $CI_PIPELINE_SOURCE == 'push' when: never extends: - - .build-job-linux + - .build-job-windows timeout: "10 minutes" - variables: - BUILD_WITH_DEBUG_MODE_INFO: "true" + tags: + - ivas-windows script: - - *print-common-info - - *activate-debug-mode-info-if-set - - make -j + - *print-common-info-windows + - *activate-WX-windows + - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug # --------------------------------------------------------------- # Test jobs for merge requests # --------------------------------------------------------------- -split-rendering-smoke-test: +### jobs that check for bitexactness of fx encoder and decoder +check-be-to-target-short-enc-0db: extends: - - .test-job-linux - - .rules-merge-request-to-main-pc - needs: ["build-codec-linux-make"] - stage: test - script: - - *print-common-info - - *update-scripts-repo + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # -/-0dB + LEVEL_SCALING: "1.0" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 - - make -j - - testcase_timeout=10 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "split rendering smoke results" - reports: - junit: - - report-junit.xml +check-be-to-target-short-enc-+10db: + extends: + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # +10dB + LEVEL_SCALING: "3.162" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 -lc3-wrapper-unit-test: +check-be-to-target-short-enc--10db: extends: - - .test-job-linux - - .rules-merge-request-to-main-pc - needs: ["build-codec-linux-make"] - stage: test - script: - - *print-common-info - - *update-scripts-repo + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # -10dB + LEVEL_SCALING: "0.3162" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 - - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j - - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test +check-be-to-target-short-dec-0db: + extends: + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # +/-0dB + LEVEL_SCALING: "1.0" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 -# compare split-rendering bitexactness between target and source branch -split-rendering-pytest-on-merge-request: +check-be-to-target-short-dec-+10db: extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc - timeout: "60 minutes" - stage: compare - script: - - *print-common-info - - *update-scripts-repo - - *get-commits-behind-count - - *check-commits-behind-count-in-compare-jobs - - *merge-request-comparison-setup-codec + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # +10dB + LEVEL_SCALING: "3.162" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 +check-be-to-target-short-dec--10db: + extends: + - .check-be-to-target-job + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # -10dB + LEVEL_SCALING: "0.3162" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 + +### jobs that check for regressions on non-BE testcases +check-regressions-short-enc-0db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-enc-0db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # +/-0dB + LEVEL_SCALING: "1.0" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 + +check-regressions-short-enc-+10db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-enc-+10db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # +10dB + LEVEL_SCALING: "3.162" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 + +check-regressions-short-enc--10db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-enc--10db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" + # -10dB + LEVEL_SCALING: "0.3162" + # overwrite decoder with float reference one + DUT_DECODER_PATH: "$REF_DECODER_PATH" + MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" + USE_LTV: 0 + +check-regressions-short-dec-0db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-dec-0db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # +/-0dB + LEVEL_SCALING: "1" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 + +check-regressions-short-dec-+10db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-dec-+10db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # +10dB + LEVEL_SCALING: "3.162" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 + +check-regressions-short-dec--10db: + extends: + - .check-regressions-pytest-job + needs: + - job: "check-be-to-target-short-dec--10db" + artifacts: true + variables: + TEST_SUITE: "$SHORT_TEST_SUITE" + # -10dB + LEVEL_SCALING: "0.3162" + # overwrite encoder with float reference one + DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" + USE_LTV: 0 + +### jobs that compare bitexactness between merge target and source +renderer-pytest-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .test-job-linux-compares-to-fixed-target + - .rules-merge-request-to-main-pc + # TODO: set reasonable timeout, will most likely take less + timeout: "20 minutes" + tags: + - ivas-linux + stage: compare + 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 + - *merge-request-comparison-setup-codec + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_be_flag=$(grep -c --ignore-case "\[rend\(erer\)*[ -]*non[ -]*be\]" tmp.txt) || true + # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + - ref_using_target=0 + + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there + - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi + + - exit_code=0 + - testcase_timeout=60 + - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? + + ### Run test using branch scripts and input + - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi + + # run test + - python3 -m pytest -q --log-level ERROR -n auto -rA --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? + - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + + - *merge-request-comparison-check + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "pytest renderer results" + reports: + junit: + - report-junit.xml + +ivas-pytest-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .test-job-linux-compares-to-fixed-target + - .rules-merge-request-to-main-pc + stage: compare + timeout: "40 minutes" + tags: + - ivas-linux + 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 + - *merge-request-comparison-setup-codec + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_be_flag=$(grep -c --ignore-case "\[non[ -]*be\]" tmp.txt) || true + # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + - ref_using_target=0 + + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there + - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi + + ### prepare pytest + # create references + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 $DISABLE_HRTF_MODEL_TESTS + + ### Run test using branch scripts and input + - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi + + ### run pytest + - exit_code=0 + - testcase_timeout=600 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? + - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + + - *merge-request-comparison-check + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "pytest ivas results" + reports: + junit: + - report-junit.xml + +split-rendering-pytest-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .test-job-linux-compares-to-fixed-target + - .rules-merge-request-to-main-pc + timeout: "60 minutes" + stage: compare + 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 + - *merge-request-comparison-setup-codec + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true + # TODO: ref_using_target comes from float repo, but does not apply here - disable for now + # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true + - ref_using_target=0 # store the current commit hash - source_branch_commit_sha=$(git rev-parse HEAD) @@ -1380,221 +1438,77 @@ split-rendering-pytest-on-merge-request: junit: - report-junit.xml -# --------------------------------------------------------------- -# Short test jobs that run in merge request pipelines -# --------------------------------------------------------------- - -.set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main-pc" ]; then - - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - *update-scripts-repo - # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt - - FLOAT_REF_BRANCH=$(cat tmp_ref_branch.txt) - - else - - FLOAT_REF_BRANCH="float-pc" - - fi - - fi - -### jobs that check for bitexactness of fx encoder and decoder -check-be-to-target-short-enc-0db: - extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -check-be-to-target-short-enc-+10db: - extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -check-be-to-target-short-enc--10db: - extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -check-be-to-target-short-dec-0db: - extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=1.0 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -check-be-to-target-short-dec-+10db: - extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=3.162 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -check-be-to-target-short-dec--10db: +# test that runs all modes with 1s input signals +# TODO: disabled temporarily, needs to be adapted to BASOP +.codec-smoke-test: extends: - - .rules-mr-to-main-or-main-pc - - .test-job-linux-compares-to-fixed-target - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=0.3162 - - rm -rf tests/dut tests/ref - <<: *check-be-to-target-anchor - -### jobs that check for regressions on non-BE testcases -check-regressions-short-enc-0db: + - .test-job-linux-needs-testv-dir + - .rules-merge-request-no-draft + timeout: "20 minutes" + tags: + - ivas-linux stage: test - needs: - - job: "check-be-to-target-short-enc-0db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make - extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor + needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] + script: + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + # LTV update needed as ltv ISM metadata files are used + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh + - bash ci/smoke_test.sh + ### analyze for failures + - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_jbm.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi + - ret_val=0 + - if cat smoke_test_output.txt | grep -c "failed"; then echo "Smoke test without JBM failed"; ret_val=1; fi + - if cat smoke_test_output_jbm.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi + - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi + - exit $ret_val + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" + expire_in: 1 week + when: always + paths: + - smoke_test_output.txt + - smoke_test_output_jbm.txt + - smoke_test_output_hrtf.txt + expose_as: "Smoke test results" -check-regressions-short-enc-+10db: - stage: test - needs: - - job: "check-be-to-target-short-enc-+10db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make +### split rendering tests +split-rendering-smoke-test: extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor - -check-regressions-short-enc--10db: + - .test-job-linux + - .rules-merge-request-to-main + needs: ["build-codec-linux-make"] stage: test - needs: - - job: "check-be-to-target-short-enc--10db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make - extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_DECODER_PATH=./IVAS_dec_ref - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor + 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 -check-regressions-short-dec-0db: - stage: test - needs: - - job: "check-be-to-target-short-dec-0db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make - extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=1.0 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor + - make -j + - testcase_timeout=10 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "split rendering smoke results" + reports: + junit: + - report-junit.xml -check-regressions-short-dec-+10db: - stage: test - needs: - - job: "check-be-to-target-short-dec-+10db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make +lc3-wrapper-unit-test: extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=3.162 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor - -check-regressions-short-dec--10db: + - .test-job-linux + - .rules-merge-request-to-main-pc + needs: ["build-codec-linux-make"] stage: test - needs: - - job: "check-be-to-target-short-dec--10db" - artifacts: true - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make - extends: - - .rules-mr-to-main-or-main-pc - before_script: - - *set-reference-for-basop-port-branch - - USE_LTV=0 - - DUT_ENCODER_PATH=./IVAS_cod_ref - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=0.3162 - - rm -rf tests/dut tests/ref - <<: *check-regressions-pytest-anchor + 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 + + - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test # --------------------------------------------------------------- # Short test jobs for running from web interface or schedule @@ -1606,7 +1520,6 @@ ivas-pytest-compare_to_ref-short-enc: - .rules-pytest-to-ref-short - .test-job-linux before_script: - - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1619,7 +1532,6 @@ ivas-pytest-compare_to_ref-short-enc-lev-10: - .rules-pytest-to-ref-short - .test-job-linux before_script: - - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1632,7 +1544,6 @@ ivas-pytest-compare_to_ref-short-enc-lev+10: - .rules-pytest-to-ref-short - .test-job-linux before_script: - - *set-reference-for-basop-port-branch - USE_LTV=0 - ENCODER_TEST="true" - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1640,11 +1551,51 @@ ivas-pytest-compare_to_ref-short-enc-lev+10: - LEVEL_SCALING=3.162 <<: *ivas-pytest-anchor +# encoder dmx comparison jobs +ivas-pytest-compare_to_ref-dmx-short-enc: + extends: + - .rules-pytest-to-ref-enc-short-dmx + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - COMPARE_DMX="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=1.0 + <<: *ivas-pytest-anchor + +ivas-pytest-compare_to_ref-dmx-short-enc-lev-10: + extends: + - .rules-pytest-to-ref-enc-short-dmx + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - COMPARE_DMX="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=0.3162 + <<: *ivas-pytest-anchor + +ivas-pytest-compare_to_ref-dmx-short-enc-lev+10: + extends: + - .rules-pytest-to-ref-enc-short-dmx + - .test-job-linux + before_script: + - USE_LTV=0 + - ENCODER_TEST="true" + - COMPARE_DMX="true" + - DUT_DECODER_PATH=./$REF_DECODER_PATH + - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" + - LEVEL_SCALING=3.162 + <<: *ivas-pytest-anchor + ivas-pytest-enc-msan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1655,7 +1606,7 @@ ivas-pytest-enc-asan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1666,7 +1617,7 @@ ivas-pytest-enc-usan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1677,7 +1628,7 @@ ivas-pytest-enc-usan: ivas-pytest-compare_to_ref-short-dec: extends: - .rules-pytest-to-ref-short - - .test-job-linux + - .test-job-linux before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1688,7 +1639,7 @@ ivas-pytest-compare_to_ref-short-dec: ivas-pytest-compare_to_ref-short-dec-lev-10: extends: - .rules-pytest-to-ref-short - - .test-job-linux + - .test-job-linux before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1699,7 +1650,7 @@ ivas-pytest-compare_to_ref-short-dec-lev-10: ivas-pytest-compare_to_ref-short-dec-lev+10: extends: - .rules-pytest-to-ref-short - - .test-job-linux + - .test-job-linux before_script: - USE_LTV=0 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1734,7 +1685,7 @@ ivas-pytest-dec-msan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1745,7 +1696,7 @@ ivas-pytest-dec-asan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1756,7 +1707,7 @@ ivas-pytest-dec-usan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1764,7 +1715,7 @@ ivas-pytest-dec-usan: <<: *ivas-pytest-sanitizers-anchor # --------------------------------------------------------------- -# Long test jobs +# Long test job # --------------------------------------------------------------- ivas-pytest-compare_ref-long-enc: @@ -1783,6 +1734,9 @@ ivas-pytest-compare_ref-long-dec: extends: - .rules-pytest-long - .test-job-linux + tags: + - ivas-basop-linux + - high-memory-capacity before_script: - USE_LTV=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1807,6 +1761,9 @@ ivas-pytest-compare_ref-long-dec-lev-10: extends: - .rules-pytest-long - .test-job-linux + tags: + - ivas-basop-linux + - high-memory-capacity before_script: - USE_LTV=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1831,6 +1788,9 @@ ivas-pytest-compare_ref-long-dec-lev+10: extends: - .rules-pytest-long - .test-job-linux + tags: + - ivas-basop-linux + - high-memory-capacity before_script: - USE_LTV=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1839,6 +1799,49 @@ ivas-pytest-compare_ref-long-dec-lev+10: - SPLIT_COMPARISON="true" <<: *ivas-pytest-anchor +ivas-pytest-compare_ref-long-fx-fx: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + tags: + - ivas-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=1.0 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + +ivas-pytest-compare_ref-long-fx-fx-lev-10: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + tags: + - ivas-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=0.3162 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + +ivas-pytest-compare_ref-long-fx-fx-lev+10: + extends: + - .rules-pytest-long-fx-fx + - .test-job-linux + tags: + - ivas-linux + before_script: + - USE_LTV=1 + - REF_ENCODER_PATH=./$DUT_ENCODER_PATH + - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" + - LEVEL_SCALING=3.162 + - SPLIT_COMPARISON="true" + <<: *ivas-pytest-anchor + + ivas-smoke-test-saturation: extends: - .rules-pytest-saturation-smoke-test @@ -1847,14 +1850,14 @@ ivas-smoke-test-saturation: - USE_LTV=1 - LEVEL_SCALING=32768 - - *print-common-info - - *update-scripts-repo + - 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 - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir + - 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 - fi - if [ $LEVEL_SCALING != "1.0" ];then - - *apply-testv-scaling + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi - cp -r scripts/testv/* $TESTV_DIR/ @@ -1890,15 +1893,15 @@ coverage-test-on-main-scheduled: stage: test timeout: 3 hours script: - - *print-common-info - - *update-scripts-repo - - *update-ltv-repo - - *copy-ltv-files-to-testv-dir - - *build-float-ref-binaries + - 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 + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref # Build DuT binaries with GCOV - make clean >> /dev/null - make GCOV=1 -j - - cp IVAS_rend $REF_RENDERER_PATH # Copy to ensure instrumented renderer is run in the first pytest call + - cp IVAS_rend IVAS_rend_ref # Copy to ensure instrumented renderer is run in the first pytest call - testcase_timeout=$TESTCASE_TIMEOUT_LTV - exit_code_dec=0 @@ -1944,17 +1947,15 @@ be-2-evs-26444: extends: - .test-job-linux rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "evs-26444" - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main-pc") + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" tags: - be-2-evs-basop stage: test timeout: "120 minutes" # To be revisited script: - - *print-common-info - - *update-scripts-repo + - 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 - sed -i".bak" "s/\(#define EVS_FLOAT\)/\/\/\1/" lib_com/options.h - make -j >> /dev/null @@ -1977,7 +1978,7 @@ be-2-evs-26444: expose_as: "EVS 26444 result" reports: junit: - - report-junit.xml + - report-junit.xml ivas-pytest-renderer: extends: @@ -2018,166 +2019,181 @@ voip-be-on-merge-request: needs: ["build-codec-linux-make"] timeout: "10 minutes" script: - - *print-common-info + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - make clean - make -j >> /dev/null - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py - -# --------------------------------------------------------------- -# Test jobs for merge requests -# --------------------------------------------------------------- - -# test that runs all modes with 1s input signals -# TODO: disabled temporarily, needs to be adapted to BASOP -.codec-smoke-test: +check-be-between-renderer-framesizes: extends: - - .test-job-linux-needs-testv-dir - - .rules-merge-request-no-draft - timeout: "20 minutes" - tags: - - ivas-linux + - .test-job-linux + # - .rules-pytest-to-main-short + rules: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "renderer-framesize-be" stage: test - needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] - script: - - *print-common-info - # LTV update needed as ltv ISM metadata files are used - - *update-ltv-repo - - bash ci/smoke_test.sh - ### analyze for failures - - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_jbm.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi - - ret_val=0 - - if cat smoke_test_output.txt | grep -c "failed"; then echo "Smoke test without JBM failed"; ret_val=1; fi - - if cat smoke_test_output_jbm.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi - - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi - - exit $ret_val - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week - when: always - paths: - - smoke_test_output.txt - - smoke_test_output_jbm.txt - - smoke_test_output_hrtf.txt - expose_as: "Smoke test results" - -# compare renderer bitexactness between target and source branch -renderer-pytest-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc - # TODO: set reasonable timeout, will most likely take less - timeout: "20 minutes" - tags: - - ivas-linux - stage: compare + needs: ["build-codec-linux-make"] script: - - *print-common-info - - *get-commits-behind-count - - *check-commits-behind-count-in-compare-jobs - - *merge-request-comparison-setup-codec - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[rend\(erer\)*[ -]*non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh + - make clean + - make -j + - echo "$SHORT_TEST_SUITE" - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - exit_code=0 - - testcase_timeout=60 - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? - - ### Run test using branch scripts and input - - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; 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=$? - # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + - 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=$? - - *merge-request-comparison-check + - 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 - allow_failure: - exit_codes: - - 123 + - *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 + - if [ $exit_code -ne 0 ]; then exit $EXIT_CODE_FAIL; fi artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + 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.xml - - report.html - expose_as: "pytest renderer results" + - report-junit-5ms.xml + - report-5ms.html + - report-junit-10ms.xml + - report-10ms.html + - report-junit-20ms.xml + - report-20ms.html reports: junit: - - report-junit.xml - -# compare bit exactness between target and source branch -ivas-pytest-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc - stage: compare - # TODO: broken dependency needs to be removed temporarily, see above - # note: this step doesn't really depend on codec-smoke-test - # it's just pointless to run this step when the smoke test fails and the smoke test should be reasonably fast - # thus, overall, this should save time - timeout: "40 minutes" + - report-junit-5ms.xml + - report-junit-10ms.xml + - report-junit-20ms.xml + +# To inject backup copy in manual trigger: +# - 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. /usr/local/backup +ivas-long-term-job-logs: + rules: + - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" + - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "long-term-logs" tags: - - ivas-linux + - $RUNNER_TAG + stage: maintenance + timeout: "25 minutes" script: - - *print-common-info - - *get-commits-behind-count - - *check-commits-behind-count-in-compare-jobs - - *merge-request-comparison-setup-codec - - *remove_unsupported_testcases - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 - - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - - ### prepare pytest - # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 $DISABLE_HRTF_MODEL_TESTS + - !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 + + # Clean up logs + - if [ -d "logs" ]; then rm -rf "logs"; fi + # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set + - 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 - ### Run test using branch scripts and input - - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi + - 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" - ### run pytest - - exit_code=0 - - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true + - 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 + # 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 (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 - - *merge-request-comparison-check + # 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 - allow_failure: - exit_codes: - - 123 artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week + name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" + expire_in: 4 weeks when: always paths: - - report-junit.xml - - report.html - expose_as: "pytest ivas results" - reports: - junit: - - report-junit.xml + - logs + expose_as: "ivas long term job logs results" + +# To store backup copy: +# - 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. /usr/local/backup +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 + + # 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 + # 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 + - exit 0 + - else + - echo "Error - LOGS_BACKUP_TARGET_DIR not set for backup job!" + - exit 1 + - fi + # --------------------------------------------------------------- # Complexity measurement jobs @@ -2193,19 +2209,37 @@ ivas-pytest-on-merge-request: # 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" + # if is needed to catch case when no artifact is there (first run), similarly as above - - if [[ -d $public_dir ]]; then mv $public_dir/* wmops/; fi - - ls wmops + # 1. check for public_dir being there as this might not be the case when artifact download failed + # 2. check for public dir not being empty - handle job failures in prev job that happen after the dir is created. In that case, the empty dir is in the artifacts + - if [ -d $public_dir ] && [ ! -z "$( ls -A $public_dir )" ]; then + - mv $public_dir/* wmops/ + # check here if we have the split-by-levels files present - if not, fake them up with the existing global one + # this is needed for the first run with split graphs on a branch where the global version did run previously + # NOTE: checking only for level_1 file here as this should already be sufficient + # NOTE2: also not chechking for RAM for same reason + - wmops_all_global="wmops/log_wmops_all.txt" + - ram_all_global="wmops/log_ram_all.txt" + - if [ -f "${wmops_all_global}" ] && [ ! -f "wmops/log_wmops_all_level_1.txt" ]; then + - declare -a suffixes=("level_1" "level_2" "level_3" "rate_sw") + - for suffix in "${suffixes[@]}"; do + - cp ${wmops_all_global} wmops/log_wmops_all_${suffix}.txt + - cp ${ram_all_global} wmops/log_ram_all_${suffix}.txt + - done + - fi + - fi + - rm artifacts.zip - rm -rf $public_dir ### 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 @@ -2214,7 +2248,7 @@ ivas-pytest-on-merge-request: &complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory - public_dir="$CI_JOB_NAME-public" - mkdir $public_dir - - mv -f wmops/log_*_all.txt ./*.js ${public_dir}/ + - mv -f wmops/log_*_all*.txt ./*.js ${public_dir}/ # move logfiles for links - mkdir $public_dir/logs # first move logs @@ -2246,10 +2280,11 @@ ivas-pytest-on-merge-request: GET_WMOPS_ARGS: "mem_only" timeout: 3 hours 30 minutes before_script: - - *print-common-info - - *update-scripts-repo - - *update-ltv-repo - - *build-float-ref-and-dut-binaries + - !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 + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - *complexity-measurements-setup # delete previous jobs logfiles if present (-f flag ensures return calue of 0 even in first run where this folder is not present) - rm -rf COMPLEXITY/logs @@ -2623,12 +2658,13 @@ complexity-osba-in-binaural_room_ir-out: pages: stage: deploy tags: - - ivas-linux + - ivas-basop-linux rules: - if: $UPDATE_PAGES script: - - *print-common-info - - *update-scripts-repo + - !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 - ls - ls -lh public -- GitLab From 63436032df42eff72cf2a025b385a19e43dd56ed Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:23:54 +0200 Subject: [PATCH 644/692] [revert-me] set CI ref to wip branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2bd885d5..f7cd9b118 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 main + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF kiene/basop-ci-merge include: - local: .gitlab-ci/variables.yml -- GitLab From 834b955b69c4cc19a4cc799225db7e1ba2d9b292 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:25:32 +0200 Subject: [PATCH 645/692] remove unneeded anchor --- .gitlab-ci.yml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7cd9b118..42ced8b6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,29 +100,6 @@ workflow: - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } -# NOTE: can be removed if script from ci repo works -.build-merge-target-binaries: &build-merge-target-binaries - - current_commit_sha=$(git rev-parse HEAD) - ### build merge target binaries - - if [ -f $MERGE_TARGET_COMMIT_FILE ]; then - - MERGE_REQUEST_TARGET="$(cat "$MERGE_TARGET_COMMIT_FILE")" - - else - - echo "MERGE_TARGET_COMMIT_FILE ($MERGE_TARGET_COMMIT_FILE) does not exist, exiting!" - - exit 1 - - fi - - git checkout $MERGE_REQUEST_TARGET - - *activate-debug-mode-info-if-set - - make clean - - make -j >> /dev/null - - mv ./IVAS_cod ./$MERGE_TARGET_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_dec ./$MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./IVAS_rend ./$MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - - mv ./ISAR_post_rend ./$MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY - ### Return to current branch - - git restore . - - git rev-parse HEAD > $MERGE_TARGET_COMMIT_FILE - - git checkout $current_commit_sha - # From float CI .merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh -- GitLab From 86de595312b12b6a4387e47dec7f17c6b483775c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:27:02 +0200 Subject: [PATCH 646/692] fix usage of obsolete rule template --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42ced8b6a..ec335a2fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -818,9 +818,9 @@ fail-pipeline-if-in-draft: - exit 1 # this branch runs on merges to main-pc only and will fail if the branch itself does not conform to the naming conventions -check-naming-of-branch-for-main-pc-merges: +check-naming-of-branch-for-basop-update-merges: extends: - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main stage: prevalidate tags: - ivas-linux @@ -928,7 +928,7 @@ clang-format-check: .check-bitexactness-hrtf-rom-and-file: extends: - .test-job-linux - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main stage: test needs: ["build-codec-linux-make"] timeout: "5 minutes" @@ -1246,7 +1246,7 @@ renderer-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" tags: @@ -1300,7 +1300,7 @@ ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main stage: compare timeout: "40 minutes" tags: @@ -1356,7 +1356,7 @@ split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main timeout: "60 minutes" stage: compare script: @@ -1476,7 +1476,7 @@ split-rendering-smoke-test: lc3-wrapper-unit-test: extends: - .test-job-linux - - .rules-merge-request-to-main-pc + - .rules-merge-request-to-main needs: ["build-codec-linux-make"] stage: test script: -- GitLab From 4da0580c678b2052f55ba7999f295131f878e272 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:33:36 +0200 Subject: [PATCH 647/692] add missing inheritance --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ec335a2fb..dec25ec17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -821,6 +821,7 @@ fail-pipeline-if-in-draft: check-naming-of-branch-for-basop-update-merges: extends: - .rules-merge-request-to-main + - .job-linux stage: prevalidate tags: - ivas-linux -- GitLab From e75688d2433206c0740a597e7483baba716bb3dc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 16:41:15 +0200 Subject: [PATCH 648/692] dummy commit to trigger CI -- GitLab From 208ec98d82e8afc03cfb3f7ad9b8e1b5587039a7 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 17:52:54 +0200 Subject: [PATCH 649/692] add missing script call --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dec25ec17..f1eb4f4a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -990,6 +990,7 @@ build-codec-linux-cmake: timeout: "10 minutes" 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 - cmake -B cmake-build -G "Unix Makefiles" - cmake --build cmake-build -- -j -- GitLab From dd3a642bfc4c60451585708c96fc0328acfeeaf9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 24 Jul 2025 17:59:12 +0200 Subject: [PATCH 650/692] still use main set of unsupported testcases --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1eb4f4a8..6d922ea67 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -268,7 +268,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - if [ $LEVEL_SCALING != "1.0" ]; then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -424,7 +424,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - python3 scripts/prepare_combined_format_inputs.py - if [ $LEVEL_SCALING != "1.0" ];then @@ -554,7 +554,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - if [ $LEVEL_SCALING != "1.0" ];then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -679,7 +679,7 @@ workflow: - 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/copy-ltv-files-to-testv-dir.sh - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - set -euxo pipefail @@ -728,7 +728,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES - if [ $LEVEL_SCALING != "1.0" ];then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -1311,7 +1311,7 @@ ivas-pytest-on-merge-request: - 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 - *merge-request-comparison-setup-codec - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - python3 ci/remove_unsupported_testcases.py $PRM_FILES # some helper variables - "|| true" to prevent failures from grep not finding anything # write to temporary file as workaround for failures observed with piping echo @@ -2018,7 +2018,7 @@ 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 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + - 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 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml || exit_code=$? -- GitLab From 010559e25c64771e8fe0aa63f5d1cce8bf326e3e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 09:53:28 +0200 Subject: [PATCH 651/692] dummy commit to trigger CI -- GitLab From e52f884d263f266402a34e24627208c69289afea Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 10:23:01 +0200 Subject: [PATCH 652/692] add check if post renderer exists b4 renaming --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d922ea67..35a115b3d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,7 +108,8 @@ workflow: - mv $MERGE_TARGET_ENCODER_PATH $REF_ENCODER_PATH - mv $MERGE_TARGET_DECODER_PATH $REF_DECODER_PATH - mv $MERGE_TARGET_RENDERER_PATH $REF_RENDERER_PATH - - mv $MERGE_TARGET_POST_RENDERER_PATH $REF_POST_RENDERER_PATH + # NOTE: temporary solution for merge to main + - if [ -f $MERGE_TARGET_POST_RENDERER_PATH ]; then mv $MERGE_TARGET_POST_RENDERER_PATH $REF_POST_RENDERER_PATH; fi - make clean - make -j -- GitLab From 6171f9949c4fc7b6941d0b58c5bc693cb27ec5a3 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 10:25:12 +0200 Subject: [PATCH 653/692] temporarily disable split rendering comparison job --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35a115b3d..9f3fdc6c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1355,7 +1355,8 @@ ivas-pytest-on-merge-request: junit: - report-junit.xml -split-rendering-pytest-on-merge-request: +#TODO: re-enable after merge to main is done +.split-rendering-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target -- GitLab From 94111c3f383f9423994ff211bec64e93ad525705 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 11:27:03 +0200 Subject: [PATCH 654/692] adjustments for correct float references and needs --- .gitlab-ci.yml | 65 +++++++++++++++++----------------------- .gitlab-ci/variables.yml | 10 +++++++ 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f3fdc6c8..197781470 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -382,28 +382,17 @@ workflow: extends: - .test-job-linux - .rules-pytest-to-main-short + - .test-job-linux-compares-to-fixed-target before_script: - !reference [ .test-job-linux, before_script ] - rm -rf tests/dut tests/ref variables: USE_LTV: 0 -# TODO: we might need a new mechanism here now that everything happens on main -.set-reference-for-basop-port-branch: &set-reference-for-basop-port-branch - - if [ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME = "main" ]; then - - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - # a bit awkward: write to file + standard out first so that the error message is visivle in case of failure. Then fill the variable from the file - - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | tee tmp_ref_branch.txt - - FLOAT_REF_BRANCH=$(cat tmp_ref_branch.txt) - - fi - - fi - .check-be-to-target-job: extends: - .check-be-job stage: check-be - needs: ["build-codec-linux-make","branch-is-up-to-date-with-target-pre"] timeout: "300 minutes" variables: XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" @@ -432,11 +421,14 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi + # set branches for reference builds + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh + # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target - - make clean - - make -j >> /dev/null - - *check-up-to-date-in-comparison-jobs + # build to-be-merged branch and corresponding float ref branch + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - exit_code_target=0 - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? @@ -567,10 +559,15 @@ workflow: - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" - ### run branch first - # this per default builds the branch and the reference and creates the reference outputs - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh - - *check-up-to-date-in-comparison-jobs + # set branches for reference builds + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh + # build merge target branch and correpsonding float reference + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target + # build to-be-merged branch and corresponding float ref branch + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source + # need to restore cache again - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true @@ -584,11 +581,6 @@ workflow: - python3 scripts/create_histograms.py $CSV_BRANCH $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - ### run main now - - git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - make clean - - make -j >> /dev/null # need to restore cache again - *overwrite-pytest-cache-with-artifact - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true @@ -682,7 +674,6 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - python3 ci/remove_unsupported_testcases.py $PRM_FILES - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - set -euxo pipefail - make_args="CLANG=$CLANG_NUM" - if [[ $CLANG_NUM == 3 ]]; then @@ -1089,7 +1080,7 @@ check-be-to-target-short-enc-0db: # -/-0dB LEVEL_SCALING: "1.0" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1101,7 +1092,7 @@ check-be-to-target-short-enc-+10db: # +10dB LEVEL_SCALING: "3.162" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1113,7 +1104,7 @@ check-be-to-target-short-enc--10db: # -10dB LEVEL_SCALING: "0.3162" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1125,7 +1116,7 @@ check-be-to-target-short-dec-0db: # +/-0dB LEVEL_SCALING: "1.0" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 @@ -1137,7 +1128,7 @@ check-be-to-target-short-dec-+10db: # +10dB LEVEL_SCALING: "3.162" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 @@ -1149,7 +1140,7 @@ check-be-to-target-short-dec--10db: # -10dB LEVEL_SCALING: "0.3162" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 @@ -1165,7 +1156,7 @@ check-regressions-short-enc-0db: # +/-0dB LEVEL_SCALING: "1.0" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1180,7 +1171,7 @@ check-regressions-short-enc-+10db: # +10dB LEVEL_SCALING: "3.162" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1195,7 +1186,7 @@ check-regressions-short-enc--10db: # -10dB LEVEL_SCALING: "0.3162" # overwrite decoder with float reference one - DUT_DECODER_PATH: "$REF_DECODER_PATH" + DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 @@ -1210,7 +1201,7 @@ check-regressions-short-dec-0db: # +/-0dB LEVEL_SCALING: "1" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 @@ -1225,7 +1216,7 @@ check-regressions-short-dec-+10db: # +10dB LEVEL_SCALING: "3.162" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 @@ -1240,7 +1231,7 @@ check-regressions-short-dec--10db: # -10dB LEVEL_SCALING: "0.3162" # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$REF_ENCODER_PATH" + DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 8bf02a062..8b54397ed 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -3,6 +3,7 @@ variables: LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" FLOAT_REF_BRANCH: "ivas-float-update" + FLOAT_REF_BRANCH_MERGE_SOURCE: "" BUILD_OUTPUT: "build_output.txt" SCRIPTS_DIR: "/usr/local/scripts" EXIT_CODE_NON_BE: 123 @@ -31,6 +32,10 @@ variables: MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" # These path variables are used for building the binaries # They should never be overwritten! + DUT_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod" + DUT_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec" + DUT_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend" + DUT_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend" REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_ref" @@ -39,6 +44,10 @@ variables: MERGE_TARGET_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_target" MERGE_TARGET_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_target" MERGE_TARGET_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_target" + MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_source_float_ref" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" @@ -66,6 +75,7 @@ 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" + MERGE_SOURCE_FLOAT_REF_COMMIT_FILE: "merge-source-float-ref-git-sha.txt" RUNNER_TAG: "ivas-basop-linux" LOGS_BACKUP_SOURCE_DIR: "" LOGS_BACKUP_TARGET_DIR: "" -- GitLab From fe8cdfb33feb0be47f09cc86f4bb9dcdebcb4403 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 11:34:31 +0200 Subject: [PATCH 655/692] increase timeout --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 197781470..4b0837a68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -877,7 +877,7 @@ clang-format-check: ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" stage: prevalidate needs: [] - timeout: "5 minutes" + timeout: "10 minutes" script: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there -- GitLab From 90fb4a07ff1ca4f128d0258d4489e19c8c5bb3fa Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 12:04:56 +0200 Subject: [PATCH 656/692] [revert-me] temporarily reduce jobs for faster testing --- .gitlab-ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b0837a68..3374ddda4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -967,7 +967,7 @@ build-codec-linux-make: - *activate-Werror-linux - make -j -build-codec-linux-cmake: +.build-codec-linux-cmake: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -987,7 +987,7 @@ build-codec-linux-cmake: - cmake --build cmake-build -- -j # ensure that codec builds on linux with instrumentation active -build-codec-linux-instrumented-make: +.build-codec-linux-instrumented-make: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1007,7 +1007,7 @@ build-codec-linux-instrumented-make: - make -j -C $INSTR_DIR # make sure that the codec builds with msan, asan and usan -build-codec-sanitizers-linux: +.build-codec-sanitizers-linux: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1027,7 +1027,7 @@ build-codec-sanitizers-linux: #- *activate-Werror-linux - bash ci/build_codec_sanitizers_linux.sh -build-codec-linux-debugging-make: +.build-codec-linux-debugging-make: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1047,7 +1047,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: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1084,7 +1084,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-be-to-target-short-enc-+10db: +.check-be-to-target-short-enc-+10db: extends: - .check-be-to-target-job variables: @@ -1096,7 +1096,7 @@ check-be-to-target-short-enc-+10db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-be-to-target-short-enc--10db: +.check-be-to-target-short-enc--10db: extends: - .check-be-to-target-job variables: @@ -1108,7 +1108,7 @@ check-be-to-target-short-enc--10db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-be-to-target-short-dec-0db: +.check-be-to-target-short-dec-0db: extends: - .check-be-to-target-job variables: @@ -1120,7 +1120,7 @@ check-be-to-target-short-dec-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -check-be-to-target-short-dec-+10db: +.check-be-to-target-short-dec-+10db: extends: - .check-be-to-target-job variables: @@ -1132,7 +1132,7 @@ check-be-to-target-short-dec-+10db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -check-be-to-target-short-dec--10db: +.check-be-to-target-short-dec--10db: extends: - .check-be-to-target-job variables: @@ -1160,7 +1160,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-regressions-short-enc-+10db: +.check-regressions-short-enc-+10db: extends: - .check-regressions-pytest-job needs: @@ -1175,7 +1175,7 @@ check-regressions-short-enc-+10db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-regressions-short-enc--10db: +.check-regressions-short-enc--10db: extends: - .check-regressions-pytest-job needs: @@ -1190,7 +1190,7 @@ check-regressions-short-enc--10db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -check-regressions-short-dec-0db: +.check-regressions-short-dec-0db: extends: - .check-regressions-pytest-job needs: @@ -1205,7 +1205,7 @@ check-regressions-short-dec-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -check-regressions-short-dec-+10db: +.check-regressions-short-dec-+10db: extends: - .check-regressions-pytest-job needs: @@ -1220,7 +1220,7 @@ check-regressions-short-dec-+10db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -check-regressions-short-dec--10db: +.check-regressions-short-dec--10db: extends: - .check-regressions-pytest-job needs: -- GitLab From 2540977bfd13a7237fc186c883198d7794f58e12 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 12:50:47 +0200 Subject: [PATCH 657/692] dummy commit to trigger CI -- GitLab From 299ea3ae385f9871d8cdcafc19e110a00a00688c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 13:10:25 +0200 Subject: [PATCH 658/692] add debug output --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3374ddda4..c05a016bc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -423,6 +423,7 @@ workflow: # set branches for reference builds - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh + - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target -- GitLab From 2953ee52fb39373b54ae9164d7d246a9ef3eca3c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 13:11:43 +0200 Subject: [PATCH 659/692] [revert-me] disable more jobs for faster testing --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c05a016bc..f305d86c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -811,7 +811,7 @@ fail-pipeline-if-in-draft: - exit 1 # this branch runs on merges to main-pc only and will fail if the branch itself does not conform to the naming conventions -check-naming-of-branch-for-basop-update-merges: +.check-naming-of-branch-for-basop-update-merges: extends: - .rules-merge-request-to-main - .job-linux @@ -865,7 +865,7 @@ branch-is-up-to-date-with-target-post: exit_codes: - 123 -clang-format-check: +.clang-format-check: extends: - .test-job-linux rules: -- GitLab From ec9eb5598942f59c52df7b87dfb2e73be68d71eb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 13:27:52 +0200 Subject: [PATCH 660/692] use other script and set different default --- .gitlab-ci.yml | 2 +- .gitlab-ci/variables.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f305d86c9..0e538d0fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -426,7 +426,7 @@ workflow: - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh # build to-be-merged branch and corresponding float ref branch - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 8b54397ed..b233cc97e 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -3,7 +3,7 @@ variables: LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" FLOAT_REF_BRANCH: "ivas-float-update" - FLOAT_REF_BRANCH_MERGE_SOURCE: "" + FLOAT_REF_BRANCH_MERGE_SOURCE: "float-pc" BUILD_OUTPUT: "build_output.txt" SCRIPTS_DIR: "/usr/local/scripts" EXIT_CODE_NON_BE: 123 -- GitLab From 545beb1f625fe9735c92eb318f16ebf7a3e4340e Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 13:34:17 +0200 Subject: [PATCH 661/692] back to old default and use source for scripts scripts that intend to modify env vars need to be run with source --- .gitlab-ci.yml | 9 +++++---- .gitlab-ci/variables.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e538d0fb..89780212a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ workflow: # From float CI .merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh + - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh # need to rename to match the conventions for the renderer tests... - mv $MERGE_TARGET_ENCODER_PATH $REF_ENCODER_PATH @@ -422,11 +422,12 @@ workflow: - fi # set branches for reference builds - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh + - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh + - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh + - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" # build to-be-merged branch and corresponding float ref branch - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source @@ -561,7 +562,7 @@ workflow: - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" # set branches for reference builds - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh + - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh # build merge target branch and correpsonding float reference - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index b233cc97e..8b54397ed 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -3,7 +3,7 @@ variables: LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" FLOAT_REF_BRANCH: "ivas-float-update" - FLOAT_REF_BRANCH_MERGE_SOURCE: "float-pc" + FLOAT_REF_BRANCH_MERGE_SOURCE: "" BUILD_OUTPUT: "build_output.txt" SCRIPTS_DIR: "/usr/local/scripts" EXIT_CODE_NON_BE: 123 -- GitLab From a19d4088ece4cca7860685501b7b64cafe18a86f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 13:53:12 +0200 Subject: [PATCH 662/692] use explicit name for dut executables using the default ones is prone to being overwritten/deleted by e.g. "make clean" --- .gitlab-ci/variables.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 8b54397ed..71830df85 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -18,10 +18,10 @@ variables: # DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain - DUT_ENCODER_PATH: "./IVAS_cod" - DUT_DECODER_PATH: "./IVAS_dec" - DUT_RENDERER_PATH: "./IVAS_rend" - DUT_POST_RENDERER_PATH: "./ISAR_post_rend" + DUT_ENCODER_PATH: "./IVAS_cod_dut" + DUT_DECODER_PATH: "./IVAS_dec_dut" + DUT_RENDERER_PATH: "./IVAS_rend_dut" + DUT_POST_RENDERER_PATH: "./ISAR_post_rend_dut" REF_ENCODER_PATH: "./IVAS_cod_ref" REF_DECODER_PATH: "./IVAS_dec_ref" REF_RENDERER_PATH: "./IVAS_rend_ref" @@ -32,10 +32,10 @@ variables: MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" # These path variables are used for building the binaries # They should never be overwritten! - DUT_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod" - DUT_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec" - DUT_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend" - DUT_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend" + DUT_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_dut" + DUT_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_dut" + DUT_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_dut" + DUT_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_dut" REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_ref" REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_dec_ref" REF_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_rend_ref" -- GitLab From d62478727363ab8a2930dcb1cee78996ff21cca9 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 14:13:02 +0200 Subject: [PATCH 663/692] store commit hash in compare jobs --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 89780212a..74354efe8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1261,6 +1261,9 @@ renderer-pytest-on-merge-request: # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - ref_using_target=0 + # store the current commit hash + - source_branch_commit_sha=$(git rev-parse HEAD) + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi @@ -1315,6 +1318,9 @@ ivas-pytest-on-merge-request: # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - ref_using_target=0 + # store the current commit hash + - source_branch_commit_sha=$(git rev-parse HEAD) + ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi -- GitLab From 1a91d0abfe9d4ff716f6795188e3355952e28bcc Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 15:35:37 +0200 Subject: [PATCH 664/692] support two different float references in regression jobs --- .gitlab-ci.yml | 29 ++++++++++++++++++++++------- .gitlab-ci/variables.yml | 4 ++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 74354efe8..b881cbc1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -570,22 +570,37 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - # need to restore cache again + # set pytest args for ref creation + - enc_stats_arg="" + - if [ "$ENCODER_TEST" = "true" ]; then + - enc_stats_arg="--enc_stats" + - fi + - enc_dmx_arg="" + - if [ "$COMPARE_DMX" = "true" ]; then + - enc_dmx_arg="--compare_enc_dmx" + - fi + + ### ----- run pytest for branch (dut) first ----- + # create float reference outputs with corresponding branch + - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + # create dut outputs + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH - - # Store branch outputs for comparison + # Store branch outputs for later comparison - mv tests/dut tests/dut_branch - # create the summary based on the branch only - python3 scripts/create_histograms.py $CSV_BRANCH $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT + - *overwrite-pytest-cache-with-artifact - # need to restore cache again + ### ----- run pytest for merge target now ----- + # create float reference outputs with corresponding branch + - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + # create merge-target outputs + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN ### compare the two csv files for regressions diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 71830df85..22e588d97 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -30,6 +30,10 @@ variables: MERGE_TARGET_DECODER_PATH: "./IVAS_dec_merge_target" MERGE_TARGET_RENDERER_PATH: "./IVAS_rend_merge_target" MERGE_TARGET_POST_RENDERER_PATH: "./ISAR_post_rend_merge_target" + MERGE_SOURCE_FLOAT_REF_ENCODER_PATH: "./IVAS_cod_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_DECODER_PATH: "./IVAS_dec_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_RENDERER_PATH: "./IVAS_rend_merge_source_float_ref" + MERGE_SOURCE_FLOAT_REF_POST_RENDERER_PATH: "./ISAR_post_rend_merge_source_float_ref" # These path variables are used for building the binaries # They should never be overwritten! DUT_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./IVAS_cod_dut" -- GitLab From 3068ade44968974c07c2c2a004f57945d8a46173 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 15:37:55 +0200 Subject: [PATCH 665/692] add merge-target float ref commit file to artifacts --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b881cbc1d..e4d088be5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -493,6 +493,7 @@ workflow: - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE - $MERGE_TARGET_COMMIT_FILE + - $MERGE_SOURCE_FLOAT_REF_COMMIT_FILE - $PYTEST_LOG_TARGET_BRANCH expose_as: "pytest compare results" reports: @@ -653,6 +654,7 @@ workflow: - $FLOAT_REF_COMMIT_FILE - $CUT_COMMIT_FILE - $MERGE_TARGET_COMMIT_FILE + - $MERGE_SOURCE_FLOAT_REF_COMMIT_FILE - regressions_crashes.csv - regressions_MLD.csv - regressions_MAX_ABS_DIFF.csv -- GitLab From 6c7e5e564576d9165a565039ce2b57787082b84c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 16:01:43 +0200 Subject: [PATCH 666/692] [revert-me] disable hrtf file testcases for merge --- .gitlab-ci/variables.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 22e588d97..383efe9fb 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -2,6 +2,7 @@ variables: TESTV_DIR: "/usr/local/testv" LTV_DIR: "/usr/local/ltv" EVS_BE_TEST_DIR_BASOP: "/usr/local/be_2_evs_basop" + # TODO: cleanup and use global var defined in ivas-codec-ci FLOAT_REF_BRANCH: "ivas-float-update" FLOAT_REF_BRANCH_MERGE_SOURCE: "" BUILD_OUTPUT: "build_output.txt" @@ -14,8 +15,8 @@ variables: SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" - DISABLE_HRTF_MODEL_TESTS: "" - # DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests + # DISABLE_HRTF_MODEL_TESTS: "" + DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod_dut" -- GitLab From a5ec0a4e67aacf3b4726e671eddfb908befcf60c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 16:06:32 +0200 Subject: [PATCH 667/692] Revert "[revert-me] disable more jobs for faster testing" This reverts commit 2953ee52fb39373b54ae9164d7d246a9ef3eca3c. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4d088be5..a72f90c2b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -829,7 +829,7 @@ fail-pipeline-if-in-draft: - exit 1 # this branch runs on merges to main-pc only and will fail if the branch itself does not conform to the naming conventions -.check-naming-of-branch-for-basop-update-merges: +check-naming-of-branch-for-basop-update-merges: extends: - .rules-merge-request-to-main - .job-linux @@ -883,7 +883,7 @@ branch-is-up-to-date-with-target-post: exit_codes: - 123 -.clang-format-check: +clang-format-check: extends: - .test-job-linux rules: -- GitLab From 5ca25d8ddcfce75c344a328e318e830aea66b718 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 16:07:10 +0200 Subject: [PATCH 668/692] Revert "[revert-me] temporarily reduce jobs for faster testing" This reverts commit 90fb4a07ff1ca4f128d0258d4489e19c8c5bb3fa. --- .gitlab-ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a72f90c2b..851b7b952 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -986,7 +986,7 @@ build-codec-linux-make: - *activate-Werror-linux - make -j -.build-codec-linux-cmake: +build-codec-linux-cmake: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1006,7 +1006,7 @@ build-codec-linux-make: - cmake --build cmake-build -- -j # ensure that codec builds on linux with instrumentation active -.build-codec-linux-instrumented-make: +build-codec-linux-instrumented-make: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1026,7 +1026,7 @@ build-codec-linux-make: - make -j -C $INSTR_DIR # make sure that the codec builds with msan, asan and usan -.build-codec-sanitizers-linux: +build-codec-sanitizers-linux: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1046,7 +1046,7 @@ build-codec-linux-make: #- *activate-Werror-linux - bash ci/build_codec_sanitizers_linux.sh -.build-codec-linux-debugging-make: +build-codec-linux-debugging-make: rules: - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1066,7 +1066,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: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never @@ -1103,7 +1103,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-be-to-target-short-enc-+10db: +check-be-to-target-short-enc-+10db: extends: - .check-be-to-target-job variables: @@ -1115,7 +1115,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-be-to-target-short-enc--10db: +check-be-to-target-short-enc--10db: extends: - .check-be-to-target-job variables: @@ -1127,7 +1127,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-be-to-target-short-dec-0db: +check-be-to-target-short-dec-0db: extends: - .check-be-to-target-job variables: @@ -1139,7 +1139,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -.check-be-to-target-short-dec-+10db: +check-be-to-target-short-dec-+10db: extends: - .check-be-to-target-job variables: @@ -1151,7 +1151,7 @@ check-be-to-target-short-enc-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -.check-be-to-target-short-dec--10db: +check-be-to-target-short-dec--10db: extends: - .check-be-to-target-job variables: @@ -1179,7 +1179,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-regressions-short-enc-+10db: +check-regressions-short-enc-+10db: extends: - .check-regressions-pytest-job needs: @@ -1194,7 +1194,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-regressions-short-enc--10db: +check-regressions-short-enc--10db: extends: - .check-regressions-pytest-job needs: @@ -1209,7 +1209,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" USE_LTV: 0 -.check-regressions-short-dec-0db: +check-regressions-short-dec-0db: extends: - .check-regressions-pytest-job needs: @@ -1224,7 +1224,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -.check-regressions-short-dec-+10db: +check-regressions-short-dec-+10db: extends: - .check-regressions-pytest-job needs: @@ -1239,7 +1239,7 @@ check-regressions-short-enc-0db: MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" USE_LTV: 0 -.check-regressions-short-dec--10db: +check-regressions-short-dec--10db: extends: - .check-regressions-pytest-job needs: -- GitLab From 75218036a414ee22a8f8b008029938a7e9787693 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 16:26:07 +0200 Subject: [PATCH 669/692] try to fix the DISABLE_HRTF_MODEL_TESTS mechanism --- .gitlab-ci.yml | 4 ++-- .gitlab-ci/variables.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 851b7b952..60b08a081 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1343,7 +1343,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 $DISABLE_HRTF_MODEL_TESTS + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 "${DISABLE_HRTF_MODEL_TESTS}" ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -1351,7 +1351,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout $DISABLE_HRTF_MODEL_TESTS || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout "${DISABLE_HRTF_MODEL_TESTS}" || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 383efe9fb..924279500 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -16,7 +16,7 @@ variables: LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" # DISABLE_HRTF_MODEL_TESTS: "" - DISABLE_HRTF_MODEL_TESTS: "-k not model" #enable this declaration to disable HRTF model from file tests + DISABLE_HRTF_MODEL_TESTS: "-k 'not model'" #enable this declaration to disable HRTF model from file tests # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod_dut" -- GitLab From bf116acdfd41b6923199de0d4f698b019d1cc41a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 17:00:03 +0200 Subject: [PATCH 670/692] clean up pytest calls --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60b08a081..e258e6d26 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -433,11 +433,11 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE -- GitLab From 3c2057c563b5ef1c1bf1533db6b0146a0d1af061 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 17:02:29 +0200 Subject: [PATCH 671/692] add --use-main-pc-set flag back --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e258e6d26..15b920676 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -269,7 +269,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - if [ $LEVEL_SCALING != "1.0" ]; then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -414,7 +414,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - python3 scripts/prepare_combined_format_inputs.py - if [ $LEVEL_SCALING != "1.0" ];then @@ -550,7 +550,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - if [ $LEVEL_SCALING != "1.0" ];then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -691,7 +691,7 @@ workflow: - 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/copy-ltv-files-to-testv-dir.sh - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - set -euxo pipefail - make_args="CLANG=$CLANG_NUM" @@ -739,7 +739,7 @@ workflow: - testcase_timeout=$TESTCASE_TIMEOUT_STV - fi - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - if [ $LEVEL_SCALING != "1.0" ];then - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - fi @@ -1325,7 +1325,7 @@ ivas-pytest-on-merge-request: - 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 - *merge-request-comparison-setup-codec - - python3 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set # some helper variables - "|| true" to prevent failures from grep not finding anything # write to temporary file as workaround for failures observed with piping echo @@ -2036,7 +2036,7 @@ 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 ci/remove_unsupported_testcases.py $PRM_FILES + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - 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=$? -- GitLab From cfd2b82646338841fb0afde6265f2ff87cc73b45 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 17:04:34 +0200 Subject: [PATCH 672/692] add DISABLE_HRTF var to every pytest call --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 15b920676..aa70a77a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -433,11 +433,11 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -583,10 +583,10 @@ workflow: ### ----- run pytest for branch (dut) first ----- # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? + - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact # create dut outputs - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH # Store branch outputs for later comparison @@ -598,10 +598,10 @@ workflow: ### ----- run pytest for merge target now ----- # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? + - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact # create merge-target outputs - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN ### compare the two csv files for regressions -- GitLab From e69de1c63c3acc80eec38fd33393a69d168e048c Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 25 Jul 2025 17:53:07 +0200 Subject: [PATCH 673/692] DISABLE_HRTF... env var to explicit command gitlab CI variable expansion and qoutes do not match well... --- .gitlab-ci.yml | 16 ++++++++-------- .gitlab-ci/variables.yml | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa70a77a1..5f65b2aac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -433,11 +433,11 @@ workflow: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - exit_code_target=0 - - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? + - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - exit_code=0 - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? + - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - if [ $exit_code -ne 0 ]; then - exit_code=$EXIT_CODE_NON_BE @@ -583,10 +583,10 @@ workflow: ### ----- run pytest for branch (dut) first ----- # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? + - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact # create dut outputs - - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH # Store branch outputs for later comparison @@ -598,10 +598,10 @@ workflow: ### ----- run pytest for merge target now ----- # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? + - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? - *overwrite-pytest-cache-with-artifact # create merge-target outputs - - python3 -m pytest --tb=no -q $TEST_SUITE "${DISABLE_HRTF_MODEL_TESTS}" -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN ### compare the two csv files for regressions @@ -1343,7 +1343,7 @@ ivas-pytest-on-merge-request: ### prepare pytest # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 "${DISABLE_HRTF_MODEL_TESTS}" + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" ### Run test using branch scripts and input - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi @@ -1351,7 +1351,7 @@ ivas-pytest-on-merge-request: ### run pytest - exit_code=0 - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout "${DISABLE_HRTF_MODEL_TESTS}" || exit_code=$? + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - *merge-request-comparison-check diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index 924279500..ddbfe614a 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -15,8 +15,6 @@ variables: SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm" LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm" TEST_SUITE: "" - # DISABLE_HRTF_MODEL_TESTS: "" - DISABLE_HRTF_MODEL_TESTS: "-k 'not model'" #enable this declaration to disable HRTF model from file tests # These path variables are used by the pytest calls. # They can be overwritten in the job templates to e.g. only test encoder or decoder in the chain DUT_ENCODER_PATH: "./IVAS_cod_dut" -- GitLab From 7000566d40d9ed19334741c06bec6ada0211bce2 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 28 Jul 2025 11:57:41 +0200 Subject: [PATCH 674/692] harmonize CI config with ivas-float-update --- .gitlab-ci.yml | 480 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 396 insertions(+), 84 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5f65b2aac..dc2ff117f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,6 +128,44 @@ workflow: when: never - when: never +.rules-merge-request-no-draft: + extends: .rules-basis + rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + - when: never + +.rules-merge-request-to-main: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + +.rules-merge-request-to-float-ref: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + +.rules-merge-request-to-main-no-draft: + rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + +.rules-merge-request-to-float-ref-no-draft: + rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" + - if: $CI_PIPELINE_SOURCE == 'push' + when: never + .rules-pytest-to-ref-short: rules: - if: $PYTEST_MLD_SHORT # Set by scheduled pipeline @@ -152,12 +190,6 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'schedule' when: never -.rules-pytest-to-main-short: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - .rules-pytest-long: rules: - if: $PYTEST_MLD_LONG # Set by scheduled pipeline @@ -194,15 +226,6 @@ workflow: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' when: never -.rules-merge-request-no-draft: - extends: .rules-basis - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - # --------------------------------------------------------------- # Job templates # --------------------------------------------------------------- @@ -369,19 +392,10 @@ workflow: junit: - report-junit.xml -.check-up-to-date-in-comparison-jobs: &check-up-to-date-in-comparison-jobs - - | - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" - if [ $commits_behind_count -ne 0 ]; then - set +x - echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run. Checking bitexactness or testing for regressions now can result in meaningless results. Run\n\t git pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." - exit 1 - fi - .check-be-job: extends: - .test-job-linux - - .rules-pytest-to-main-short + - .rules-merge-request-to-main-no-draft - .test-job-linux-compares-to-fixed-target before_script: - !reference [ .test-job-linux, before_script ] @@ -868,7 +882,7 @@ branch-is-up-to-date-with-target-pre: branch-is-up-to-date-with-target-post: extends: - .job-linux - - .rules-merge-request + - .rules-merge-request-no-draft stage: postvalidate tags: - ivas-basop-linux @@ -886,12 +900,7 @@ branch-is-up-to-date-with-target-post: clang-format-check: extends: - .test-job-linux - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' - when: never + - .rules-merge-request variables: ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" stage: prevalidate @@ -935,33 +944,6 @@ clang-format-check: name: "$ARTIFACT_BASE_NAME" expose_as: "formatting patch" -# from float -# needs fix to be merged from floating point repo before it can be activated -.check-bitexactness-hrtf-rom-and-file: - extends: - - .test-job-linux - - .rules-merge-request-to-main - stage: test - needs: ["build-codec-linux-make"] - timeout: "5 minutes" - 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 - - - make clean - - make -j - - python3 tests/create_short_testvectors.py --cut_len 1.0 - # TODO: run full test again once the custom binary files are supported - - python3 -m pytest -k "not diff_from_rom and not test_binary_file" tests/hrtf_binary_loading --html=report.html --junit-xml=report-junit.xml --self-contained-html - artifacts: - paths: - - report.html - - report-junit.xml - when: always - name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_ID--sha-$CI_COMMIT_SHA--hrtf-loading" - expose_as: "logs-hrtf-loading" - expire_in: "5 days" - # --------------------------------------------------------------- # Build jobs # --------------------------------------------------------------- @@ -988,6 +970,8 @@ build-codec-linux-make: build-codec-linux-cmake: rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' @@ -1008,6 +992,8 @@ build-codec-linux-cmake: # ensure that codec builds on linux with instrumentation active build-codec-linux-instrumented-make: rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' @@ -1028,6 +1014,8 @@ build-codec-linux-instrumented-make: # make sure that the codec builds with msan, asan and usan build-codec-sanitizers-linux: rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' @@ -1048,6 +1036,8 @@ build-codec-sanitizers-linux: build-codec-linux-debugging-make: rules: + - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ + when: never - if: $MANUAL_PIPELINE_TYPE == 'long-term-logs' || $MANUAL_PIPELINE_TYPE == 'backup-long-term-logs' || $UPDATE_PAGES when: never - if: $CI_PIPELINE_SOURCE == 'web' @@ -1259,7 +1249,7 @@ renderer-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main + - .rules-merge-request-no-draft # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" tags: @@ -1316,7 +1306,7 @@ ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main + - .rules-merge-request-no-draft stage: compare timeout: "40 minutes" tags: @@ -1376,7 +1366,7 @@ ivas-pytest-on-merge-request: extends: - .test-job-linux-needs-testv-dir - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-to-main + - .rules-merge-request-no-draft timeout: "60 minutes" stage: compare script: @@ -1436,21 +1426,22 @@ ivas-pytest-on-merge-request: - report-junit.xml # test that runs all modes with 1s input signals -# TODO: disabled temporarily, needs to be adapted to BASOP -.codec-smoke-test: +codec-smoke-test: extends: - .test-job-linux-needs-testv-dir - - .rules-merge-request-no-draft + - .rules-merge-request-to-float-ref-no-draft timeout: "20 minutes" - tags: - - ivas-linux stage: test - needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] + needs: ["build-codec-linux-make"] script: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh # LTV update needed as ltv ISM metadata files are used + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - bash ci/smoke_test.sh + - python3 scripts/smoketest-basop-filter.py scripts/config/ivas_modes.json --inline + - bash ci/smoke_test.sh || true + - tar cJf logs.tar.xz out/logs/ + - ls -al logs.tar.* ### analyze for failures - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_jbm.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi - ret_val=0 @@ -1466,13 +1457,110 @@ ivas-pytest-on-merge-request: - smoke_test_output.txt - smoke_test_output_jbm.txt - smoke_test_output_hrtf.txt + - logs.tar.xz expose_as: "Smoke test results" +# from float +# check for crashes if first received frame on decoder side is an SID +check-first-frame-is-sid: + extends: + - .test-job-linux-needs-testv-dir + - .rules-merge-request-to-float-ref-no-draft + stage: test + needs: ["build-codec-linux-make"] + 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 + # this rm makes check-for-testvectors only check for the signals we actually need in this test + - rm scripts/config/ci_linux_ltv.json scripts/config/ci_linux.json + - python3 -m pytest ci/test_vectors_available.py + - bash ci/run-first-frame-is-sid-test.sh + +# from float +# needs fix to be merged from floating point repo before it can be activated +.check-bitexactness-hrtf-rom-and-file: + extends: + - .test-job-linux + - .rules-merge-request-no-draft + stage: test + needs: ["build-codec-linux-make"] + timeout: "5 minutes" + 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 + + - make clean + - make -j + - python3 tests/create_short_testvectors.py --cut_len 1.0 + # TODO: run full test again once the custom binary files are supported + - python3 -m pytest -k "not diff_from_rom and not test_binary_file" tests/hrtf_binary_loading --html=report.html --junit-xml=report-junit.xml --self-contained-html + artifacts: + paths: + - report.html + - report-junit.xml + when: always + name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_ID--sha-$CI_COMMIT_SHA--hrtf-loading" + expose_as: "logs-hrtf-loading" + expire_in: "5 days" + + +### From Float +# Check interop IVAS_cod_test -> IVAS_dec_ref +ivas-interop-on-merge-request: + extends: + - .test-job-linux-needs-testv-dir + - .rules-merge-request-to-float-ref-no-draft + - .test-job-linux-compares-to-fixed-target + stage: test + timeout: "10 minutes" + script: + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh + - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/float/check-commits-behind-count-in-compare-jobs.sh + - *merge-request-comparison-setup-codec + + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + + # some helper variables - "|| true" to prevent failures from grep not finding anything + # write to temporary file as workaround for failures observed with piping echo + - echo $CI_MERGE_REQUEST_TITLE > tmp.txt + - non_interop_flag=$(grep -c --ignore-case "\[non[ -]*io\]" tmp.txt) || true + + ### prepare pytest + + # Run reference creation, using source branch encoder and main decoder (see .merge-request-comparison-setup-codec) + - exit_code=0 + - exit_code2=0 + # set timeout for individual testcase runs to 60 seconds + - testcase_timeout=60 + - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --update_ref 1 --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec_ref --testcase_timeout=$testcase_timeout || exit_code=$? + - zero_failures=$(cat report-junit.xml | grep -c 'failures="0"') || true + + - if [ $zero_failures != 1 ] && [ $non_interop_flag == 0 ]; then echo "Non-interop cases without non-interop flag encountered!"; exit $EXIT_CODE_FAIL; fi + - if [ $zero_failures != 1 ] && [ $non_interop_flag == 1 ]; then echo "Non-interop cases with non-interop flag encountered"; exit $EXIT_CODE_NON_BE; fi + - exit 0 + + allow_failure: + exit_codes: + - 123 + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + - report.html + expose_as: "interop test results" + reports: + junit: + - report-junit.xml + ### split rendering tests split-rendering-smoke-test: extends: - .test-job-linux - - .rules-merge-request-to-main + - .rules-merge-request-no-draft needs: ["build-codec-linux-make"] stage: test script: @@ -1496,7 +1584,7 @@ split-rendering-smoke-test: lc3-wrapper-unit-test: extends: - .test-job-linux - - .rules-merge-request-to-main + - .rules-merge-request-no-draft needs: ["build-codec-linux-make"] stage: test script: @@ -1505,7 +1593,222 @@ lc3-wrapper-unit-test: - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - cmake --build cmake-build -- -j - - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test + + - echo "Assuming here that you either merge to main or to $FLOAT_REF_BRANCH." + - echo "If you have some other merge target, this might fail and manual fiddling is needed." + - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" == "$FLOAT_REF_BRANCH" ]; then + - scripts/split_rendering/lc3plus_float/ivas_lc3plus_unit_test + - else + - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test + - fi + +# from float +# test renderer executable +renderer-smoke-test: + extends: + - .test-job-linux + - .rules-merge-request-to-float-ref-no-draft + needs: ["build-codec-linux-make"] + stage: test + 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 + - make -j IVAS_rend + - testcase_timeout=60 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "renderer make pytest results" + reports: + junit: + - report-junit.xml + +# from float +# test renderer executable with cmake + asan +renderer-asan: + extends: + - .test-job-linux + - .rules-merge-request-to-float-ref-no-draft + needs: ["build-codec-linux-make"] + stage: test + 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 + - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - testcase_timeout=180 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout + + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "renderer asan pytest results" + reports: + junit: + - report-junit.xml + +# from float +# test renderer executable with cmake + msan +renderer-msan: + extends: + - .test-job-linux + - .rules-merge-request-to-float-ref-no-draft + needs: ["build-codec-linux-make"] + stage: test + tags: + - ivas-linux + 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 + - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - testcase_timeout=180 + - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout + + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "renderer msan pytest results" + reports: + junit: + - report-junit.xml + +# from float +# test renderer executable with cmake + usan +renderer-usan: + extends: + - .test-job-linux + - .rules-merge-request-to-float-ref-no-draft + needs: ["build-codec-linux-make"] + stage: test + tags: + - ivas-linux + 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 + - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true + - cmake --build cmake-build -- -j + - testcase_timeout=180 + - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout + - grep_exit_code=0 + - touch usan_log_empty # Creates an empty file, this is to avoid "grep: usan_log_*: No such file or directory" in case no USAN failures are reported from pytest + - grep UndefinedBehaviorSanitizer usan_log_* || grep_exit_code=$? + - if [ $grep_exit_code != 1 ] ; then echo "Run errors in test_renderer.py with Clang undefined-behavior-sanitizer"; exit 1; fi + + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" + expire_in: 1 week + when: always + paths: + - report-junit.xml + expose_as: "renderer usan pytest results" + reports: + junit: + - report-junit.xml + +.sanitizer-selftest-on-mr: + stage: test + extends: + - .rules-merge-request-to-float-ref-no-draft + artifacts: + name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" + expire_in: 1 week + when: always + paths: + - report-junit-20ms.xml + - report-junit-10ms.xml + - report-junit-5ms.xml + - report-20ms.html + - report-10ms.html + - report-5ms.html + expose_as: "Sanitizer selftest results" + reports: + junit: + - report-junit-20ms.xml + - report-junit-10ms.xml + - report-junit-5ms.xml + +# From float repo +# to be reused in MR and LTV-scheduled sanitizer test jobs +# set CLANG_NUM, SELFTEST_SANITY_TIMEOUT and SELF_TEST_PRM_FILE in before_script section +.sanitizer-selftest-anchor: &sanitizer-selftest-anchor + 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/copy-ltv-files-to-testv-dir.sh + - make clean + - make -j CLANG=$CLANG_NUM + - testcase_timeout=$SELFTEST_SANITY_TIMEOUT + - export UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1 + + - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set + + - exit_code20=0 + - exit_code10=0 + - exit_code5=0 + + - if [ $CLANG_NUM -eq 1 ]; then sanitizer_type="MemorySanitizer"; elif [ $CLANG_NUM -eq 2 ]; then sanitizer_type="AddressSanitizer"; elif [ $CLANG_NUM -eq 3 ]; then sanitizer_type="UndefinedBehaviorSanitizer"; else echo "Wrong CLANG_NUM $CLANG_NUM given!"; exit 1; fi + + # run encoder and decoder with 20ms renderer framesize first, use reference creation mode + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code20=$? + # for 10ms and 5ms renderer framesize, we only need to run the decoder part as renderer framesize is a decoder-only option + # set tolerance very high do ignore any BE differences due to the different renderer framesizes, those can appear due to the limiter being active + # we are only interested in runtime errors from the sanitizers and ignore the diffs + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only --abs_tol 100000 || exit_code5=$? + - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only --abs_tol 100000 || exit_code10=$? + + - if [ $exit_code20 -ne 0 ] || [ $exit_code10 -ne 0 ] || [ $exit_code5 -ne 0 ]; then exit 1; fi + +# from float repo +# NOTE: (per-testcase) timeout was adjusted to work for float only +# code selftest testvectors with memory-sanitizer binaries +.codec-msan: + extends: + - .sanitizer-selftest-on-mr + tags: + - ivas-linux + before_script: + - CLANG_NUM=1 + - SELFTEST_SANITY_TIMEOUT=180 + - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - USE_LTV="" + <<: *sanitizer-selftest-anchor + +# code selftest testvectors with address-sanitizer binaries +.codec-asan: + extends: + - .sanitizer-selftest-on-mr + tags: + - ivas-linux + before_script: + - CLANG_NUM=2 + - SELFTEST_SANITY_TIMEOUT=180 + - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - USE_LTV="" + <<: *sanitizer-selftest-anchor + +# code selftest testvectors with undefined-behaviour-sanitizer binaries +.codec-usan: + extends: + - .sanitizer-selftest-on-mr + tags: + - ivas-linux + before_script: + - CLANG_NUM=3 + - SELFTEST_SANITY_TIMEOUT=180 + - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" + - USE_LTV="" + <<: *sanitizer-selftest-anchor # --------------------------------------------------------------- # Short test jobs for running from web interface or schedule @@ -2010,21 +2313,26 @@ voip-be-on-merge-request: extends: - .test-job-linux-needs-testv-dir rules: - # - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "voip-be-test" + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" + # - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main stage: test needs: ["build-codec-linux-make"] timeout: "10 minutes" script: - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - make clean - - make -j >> /dev/null + - make -j > build_log.txt - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py + artifacts: + when: always + expire_in: "5 days" + paths: + - build_log.txt check-be-between-renderer-framesizes: extends: - .test-job-linux - # - .rules-pytest-to-main-short rules: - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "renderer-framesize-be" stage: test @@ -2196,8 +2504,8 @@ backup-long-term-job-logs: # Complexity measurement jobs # --------------------------------------------------------------- -.complexity-measurements-setup: - &complexity-measurements-setup # create necessary environment +# create necessary environment +.complexity-measurements-setup: &complexity-measurements-setup ### 1. part: mainly same as in float repo - this is boilerplate code to make the gitlab pages presentation work - mkdir -p wmops/logs @@ -2234,15 +2542,18 @@ backup-long-term-job-logs: - rm -rf $public_dir ### 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 "$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 + # only do this on main and not for the complexity meaurements run on ivas-float-update + - if [ "$CI_COMMIT_REF_NAME" == "main" ]; then + - job_id=$(python3 ci/get_id_of_last_job_occurence.py $FLOAT_REF_BRANCH $CI_JOB_NAME $CI_PROJECT_ID) + - echo $job_id + - 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 + - if [ -f latest_WMOPS.csv ]; then GET_WMOPS_ARGS="$GET_WMOPS_ARGS latest_WMOPS.csv"; fi + - fi -.complexity-measurements-prepare-artifacts: - &complexity-measurements-prepare-artifacts # prepare artifacts -> move to public directory +# prepare artifacts -> move to public directory +.complexity-measurements-prepare-artifacts: &complexity-measurements-prepare-artifacts - public_dir="$CI_JOB_NAME-public" - mkdir $public_dir - mv -f wmops/log_*_all*.txt ./*.js ${public_dir}/ @@ -2251,6 +2562,7 @@ backup-long-term-job-logs: # first move logs - log_files=$(cat $public_dir/graphs*.js | grep logFile | sed "s/.*\(wmops_newsletter_.*\.csv\).*/\1/g") - for f in $log_files; do [ -f wmops/logs/$f ] && mv wmops/logs/$f $public_dir/logs/$f; done + - if [ "$CI_COMMIT_REF_NAME" == "$FLOAT_REF_BRANCH" ]; then mv wmops/logs/latest_WMOPS.csv $public_dir/logs/; fi # copy index page blueprint - cp ci/complexity_measurements/index_complexity.html ${public_dir}/index.html # patch the format in the title -- GitLab From a4b69e585c5ce378e711df8b7453ebe2039fac73 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 28 Jul 2025 14:31:03 +0200 Subject: [PATCH 675/692] use unified CI config from ci repo --- .gitlab-ci.yml | 2976 +----------------------------------------------- 1 file changed, 2 insertions(+), 2974 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc2ff117f..ba4f1fe3d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,2983 +1,11 @@ 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 kiene/basop-ci-merge + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF kiene/basop-ci-merge-test-unified-config include: - local: .gitlab-ci/variables.yml - local: .gitlab-ci/rules-basis.yml - project: ivas-codec-pc/ivas-codec-ci ref: *IVAS_CODEC_CI_REF - file: main.yml - -default: - interruptible: true # Make all jobs by default interruptible - -workflow: - name: '$IVAS_PIPELINE_NAME' - rules: - # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - variables: - IVAS_PIPELINE_NAME: 'MR pipeline: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME' - ### disabled for now because pipeline cd is redundant with MR pipeline with current workflow - # - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Pushes to main - # variables: - # IVAS_PIPELINE_NAME: 'Push pipeline: $CI_COMMIT_BRANCH' - - 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 == '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' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-enc-dmx' - variables: - IVAS_PIPELINE_NAME: 'Run encoder dmx comparison against float ref: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long' - variables: - IVAS_PIPELINE_NAME: 'Run comparison tools against float ref (long test vectors): $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-long-fx-fx' - variables: - IVAS_PIPELINE_NAME: 'Run comparison tools against float ref FX-FX (long test vectors): $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-compare-to-input' - variables: - IVAS_PIPELINE_NAME: 'Run comparison tools against input (pass-through only): $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-saturation-smoke-test' - variables: - IVAS_PIPELINE_NAME: 'Run saturation smoke-test: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'evs-26444' - variables: - IVAS_PIPELINE_NAME: 'EVS 26.444 test: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer' - variables: - IVAS_PIPELINE_NAME: 'Short testvectors sanitizers' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-renderer' - variables: - IVAS_PIPELINE_NAME: 'Renderer test: $CI_COMMIT_BRANCH' - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'complexity' - variables: - IVAS_PIPELINE_NAME: 'Complexity Measurement on $CI_COMMIT_BRANCH' - - 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' - - if: $CI_PIPELINE_SOURCE == 'schedule' # Scheduled in any branch - variables: - IVAS_PIPELINE_NAME: 'Scheduled pipeline: $CI_COMMIT_BRANCH' - -# --------------------------------------------------------------- -# Generic script anchors -# --------------------------------------------------------------- - -# These can be used later on to do common tasks - -# Prints useful information for every job and should be used at the beginning of each job -.print-common-info-windows: &print-common-info-windows - - | - echo "Printing common information for build job." - echo "Current job is run on commit $CI_COMMIT_SHA" - echo "Commit time was $CI_COMMIT_TIMESTAMP" - ("echo 'System time is'", "Get-Date -Format 'dddd dd/MM/yyyy HH:mm K'") | Invoke-Expression - -.activate-Werror-linux: &activate-Werror-linux - - sed -i.bak "s/^# \(CFLAGS += -Werror\)/\1/" Makefile - - sed -i.bak "s/# \(set(CMAKE_C_FLAGS \"\${CMAKE_C_FLAGS} -Werror\")\)/\1/" CMakeLists.txt - -.activate-WX-windows: &activate-WX-windows - - (Get-Content -Path "CMakeLists.txt") -replace '# \(add_compile_options\("\/WX"\)\)', '$1' | Set-Content -Path "CMakeLists.txt" - - Get-ChildItem -Path "Workspace_msvc" -Filter "*.vcxproj" | ForEach-Object { (Get-Content -Path $_.FullName) -replace 'false', 'true' | Set-Content -Path $_.FullName } - -# From float CI -.merge-request-comparison-setup-codec: &merge-request-comparison-setup-codec - - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh - - # need to rename to match the conventions for the renderer tests... - - mv $MERGE_TARGET_ENCODER_PATH $REF_ENCODER_PATH - - mv $MERGE_TARGET_DECODER_PATH $REF_DECODER_PATH - - mv $MERGE_TARGET_RENDERER_PATH $REF_RENDERER_PATH - # NOTE: temporary solution for merge to main - - if [ -f $MERGE_TARGET_POST_RENDERER_PATH ]; then mv $MERGE_TARGET_POST_RENDERER_PATH $REF_POST_RENDERER_PATH; fi - - - make clean - - make -j - -.merge-request-comparison-check: &merge-request-comparison-check - - echo "--------------- Running merge-request-comparison-check anchor ---------------" - - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi - - if [ $exit_code -ne 0 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi - - if [ $exit_code -ne 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi - - exit 0 - -.rules-merge-request: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - when: never - -.rules-merge-request-no-draft: - extends: .rules-basis - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - when: never - -.rules-merge-request-to-main: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - -.rules-merge-request-to-float-ref: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - -.rules-merge-request-to-main-no-draft: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - -.rules-merge-request-to-float-ref-no-draft: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - -.rules-pytest-to-ref-short: - rules: - - if: $PYTEST_MLD_SHORT # Set by scheduled pipeline - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare" - - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - -.rules-pytest-to-input-short: - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-to-input" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' - when: never - -.rules-pytest-to-ref-enc-short-dmx: - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-enc-dmx" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' - when: never - -.rules-pytest-long: - rules: - - if: $PYTEST_MLD_LONG # Set by scheduled pipeline - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - when: never - -.rules-pytest-long-fx-fx: - rules: - - if: $PYTEST_MLD_LONG_FX_FX # Set by scheduled pipeline - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-compare-long-fx-fx" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - when: never - -.rules-coverage: - rules: - - if: $COVERAGE_TEST # Set by scheduled pipeline - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "coverage" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - when: never - -.rules-pytest-saturation-smoke-test: - rules: - - if: $PYTEST_SMOKE_TEST # Set by scheduled pipeline - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-saturation-smoke-test" - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - when: never - -# --------------------------------------------------------------- -# Job templates -# --------------------------------------------------------------- - -# override for centrally defined job to make use of the basop runners -.job-linux: - tags: - - ivas-basop-linux - -# custom variant of this template, we need to update the scripts repo before every build -.test-job-linux: - extends: - - .job-linux - before_script: - - !reference [.job-linux, before_script] - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - -.test-job-linux-compares-to-fixed-target: - extends: .test-job-linux - needs: - - job: branch-is-up-to-date-with-target-pre - artifacts: true - - job: build-codec-linux-make - -.print-results-banner: &print-results-banner - - set +x - - echo "" - - echo -e "==================================================================================================================\n================================================== TEST RESULTS ==================================================\n==================================================================================================================\n" - -# template for test jobs on linux that need the TESTV_DIR -.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/ - -.ivas-pytest-anchor: &ivas-pytest-anchor - stage: test - needs: ["build-codec-linux-make"] - timeout: "360 minutes" - 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 - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - if [ $LEVEL_SCALING != "1.0" ]; then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - - fi - - - if [ "$COMPARE_DMX" = "true" ] || [ "$ENCODER_TEST" = "true" ]; then - - BUILD_WITH_DEBUG_MODE_INFO="true" - - fi - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh - - - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" - - summary_args="MLD DIFF SSNR ODG" - - REPORT_ARG="" - - if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi - - if [ "$DELTA_ODG" = "true" ]; then comp_args="${comp_args} --odg_bin"; MEASURES_FOR_REPORT="$MEASURES_FOR_REPORT DELTA_ODG"; fi - - if [ "$SPLIT_COMPARISON" = "true" ]; then comp_args="${comp_args} --split-comparison"; fi - - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-and-create-float-ref-outputs.sh - - # DMX comparison only in manual job with no other metrics - - if [ "$COMPARE_DMX" = "true" ]; then - - comp_args="--compare_enc_dmx" - - fi - - - echo "$comp_args" - - ### run pytest - - exit_code=0 - - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml $comp_args -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - - ### create histograms - - if [ "$SPLIT_COMPARISON" = "true" ]; then - - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME --split-csv-file $CSV_ARTIFACT_SPLIT - - else - - python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME - - fi - - # first for "whole" files comparison - - python3 scripts/create_histograms.py $CSV_ARTIFACT_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT --write-out-histograms - - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - - - if [ "$SPLIT_COMPARISON" = "true" ]; then - - python3 scripts/create_histograms.py $CSV_ARTIFACT_SPLIT $IMAGES_ARTIFACT_SPLIT --measures $MEASURES_FOR_REPORT --write-out-histograms - - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_SPLIT $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_SPLIT --measures $MEASURES_FOR_REPORT - - else - # touch files to suppress warning for missing artifacts - - touch $CSV_ARTIFACT_SPLIT $IMAGES_ARTIFACT_SPLIT - - fi - - - 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 "$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" - - 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 - - else - # create empty file for artifacts to avoid errors - - touch $PAGES_HTML_ARTIFACT_NAME - - touch $MERGED_CSV_ARTIFACT_NAME - - fi - - - if [ $zero_errors != 1 ]; then - - echo "Run errors encountered!" - # TODO: temporary only to not fail MR pipelines on crashes - - if [ $CI_PIPELINE_SOURCE == 'merge_request_event' ]; then - - exit $EXIT_CODE_NON_BE - - else - - exit $EXIT_CODE_FAIL - - fi - - fi - - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit $EXIT_CODE_NON_BE; 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 - - $PAGES_HTML_ARTIFACT_NAME - - $CSV_ARTIFACT_NAME - - $CSV_ARTIFACT_SPLIT - - $MERGED_CSV_ARTIFACT_NAME - - $SUMMARY_HTML_ARTIFACT_NAME - - $SUMMARY_HTML_ARTIFACT_SPLIT - - $IMAGES_ARTIFACT_NAME - - $IMAGES_ARTIFACT_SPLIT - expose_as: "pytest compare results" - reports: - junit: - - report-junit.xml - -.check-be-job: - extends: - - .test-job-linux - - .rules-merge-request-to-main-no-draft - - .test-job-linux-compares-to-fixed-target - before_script: - - !reference [ .test-job-linux, before_script ] - - rm -rf tests/dut tests/ref - variables: - USE_LTV: 0 - -.check-be-to-target-job: - extends: - - .check-be-job - stage: check-be - timeout: "300 minutes" - variables: - XML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" - HTML_REPORT: "report--$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" - PYTEST_LOG_TARGET_BRANCH: "pytest-log-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME.txt" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - - set -euxo pipefail - - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - python3 tests/create_short_testvectors.py - - - 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 - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - python3 scripts/prepare_combined_format_inputs.py - - - if [ $LEVEL_SCALING != "1.0" ];then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - - fi - - # set branches for reference builds - - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh - - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - # build merge target branch and correpsonding float reference - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-merge-target-binaries.sh - - echo "$FLOAT_REF_BRANCH - $FLOAT_REF_BRANCH_MERGE_SOURCE - $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" - # build to-be-merged branch and corresponding float ref branch - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - - - exit_code_target=0 - - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 --create_ref -n auto --ref_encoder_path $MERGE_TARGET_ENCODER_PATH --ref_decoder_path $MERGE_TARGET_DECODER_PATH > $PYTEST_LOG_TARGET_BRANCH || exit_code_target=$? - - - exit_code=0 - - rm -rf .pytest_cache || true - - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT --self-contained-html --junit-xml=$XML_REPORT --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout > pytest_log.txt || exit_code=$? - - - if [ $exit_code -ne 0 ]; then - - exit_code=$EXIT_CODE_NON_BE - - zip -r $PYTEST_CACHE_ARTIFACT .pytest_cache - - - grep "^FAILED" pytest_log.txt | sed "s/^FAILED /'/" | sed "s/] - .*/]'/" | tr "\n" " " > $FAILED_TESTCASES_LIST || true - - grep "^FAILED" pytest_log.txt | sed "s/^FAILED //" | sed "s/] - .*/]/" > failed_testcases_for_printing.txt || true - - num_failures=$(wc -l < failed_testcases_for_printing.txt) - - - grep "^ERROR" pytest_log.txt | sed "s/^ERROR /'/" | sed "s/] - .*/]'/" | tr "\n" " " > $ERRORS_TESTCASES_LIST || true - - grep "^ERROR" pytest_log.txt | sed "s/^ERROR //" | sed "s/] - .*/]/" > errors_testcases_for_printing.txt || true - - num_errors=$(wc -l < errors_testcases_for_printing.txt) - - - *print-results-banner - - echo "Found these $num_failures non-bitexact testcases:" - - cat failed_testcases_for_printing.txt - - - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - - echo "The individual command lines can be found in the html report in the job artifacts." - - if [ $num_errors -ne 0 ]; then - - exit_code=1 - - echo "There were errors present in the following testcases:" - - cat errors_testcases_for_printing.txt - - fi - - - exit $exit_code - - else - # create empty files to not have errors at artifact stage - - touch $FAILED_TESTCASES_LIST - - touch $ERRORS_TESTCASES_LIST - - touch $PYTEST_CACHE_ARTIFACT - - *print-results-banner - - echo "All testcases are bitexact." - - fi - - exit $exit_code - - allow_failure: - exit_codes: - - 123 - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - expire_in: 1 week - when: always - paths: - - $XML_REPORT - - $HTML_REPORT - - $FAILED_TESTCASES_LIST - - $ERRORS_TESTCASES_LIST - - pytest_log.txt - - $PYTEST_CACHE_ARTIFACT - - $FLOAT_REF_COMMIT_FILE - - $CUT_COMMIT_FILE - - $MERGE_TARGET_COMMIT_FILE - - $MERGE_SOURCE_FLOAT_REF_COMMIT_FILE - - $PYTEST_LOG_TARGET_BRANCH - expose_as: "pytest compare results" - reports: - junit: - - $XML_REPORT - - $XML_REPORT - -.overwrite-pytest-cache-with-artifact: &overwrite-pytest-cache-with-artifact - - if [ -f $PYTEST_CACHE_ARTIFACT ]; then - - rm -rf .pytest_cache || true - - unzip $PYTEST_CACHE_ARTIFACT - - fi - -.check-regressions-pytest-job: - extends: - - .check-be-job - stage: test - timeout: "300 minutes" - variables: - XML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" - XML_REPORT_MAIN: "report-junit-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.xml" - HTML_REPORT_BRANCH: "report-junit-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" - HTML_REPORT_MAIN: "report-junit-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.html" - CSV_BRANCH: "scores-branch-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.csv" - CSV_MAIN: "scores-main-$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA.csv" - IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" - SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - # create empty files for all artifacts to suppress warnings in case of no regressions found or all is BE - - touch $XML_REPORT_BRANCH $XML_REPORT_MAIN $HTML_REPORT_BRANCH $HTML_REPORT_MAIN $CSV_BRANCH $CSV_MAIN $SUMMARY_HTML_ARTIFACT_NAME $FLOAT_REF_COMMIT_FILE $CUT_COMMIT_FILE $MERGE_TARGET_COMMIT_FILE regressions_crashes.csv regressions_MLD.csv regressions_MAX_ABS_DIFF.csv regressions_MIN_SSNR.csv regressions_MIN_ODG.csv improvements_crashes.csv improvements_MLD.csv improvements_MAX_ABS_DIFF.csv improvements_MIN_SSNR.csv improvements_MIN_ODG.csv - - mkdir $IMAGES_ARTIFACT_NAME - - - set -euxo pipefail - - - if [ -s $FAILED_TESTCASES_LIST ]; then - - *overwrite-pytest-cache-with-artifact - - export PYTEST_ADDOPTS=--last-failed - - else - # turn off echoing back of commands for result printout - - *print-results-banner - - echo -e "All tested cases were bit-exact between $CI_MERGE_REQUEST_TARGET_BRANCH_NAME and $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME.\nNo need to check for regressions. All is fine." - - exit 0 - - fi - - - 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 - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - if [ $LEVEL_SCALING != "1.0" ];then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - - fi - - # check MR title for flag that allows regressions to be mergable - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - allow_regressions_flag=$(grep -c --ignore-case "\[allow[ -]*regression\]" tmp.txt) || true - - - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" - - # set branches for reference builds - - source "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/set-float-reference-branches.sh - # build merge target branch and correpsonding float reference - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-target - # build to-be-merged branch and corresponding float ref branch - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh merge-source - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref-merge-source - - # set pytest args for ref creation - - enc_stats_arg="" - - if [ "$ENCODER_TEST" = "true" ]; then - - enc_stats_arg="--enc_stats" - - fi - - enc_dmx_arg="" - - if [ "$COMPARE_DMX" = "true" ]; then - - enc_dmx_arg="--compare_enc_dmx" - - fi - - ### ----- run pytest for branch (dut) first ----- - # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $MERGE_SOURCE_FLOAT_REF_ENCODER_PATH --ref_decoder_path $MERGE_SOURCE_FLOAT_REF_DECODER_PATH || exit_code=$? - - *overwrite-pytest-cache-with-artifact - # create dut outputs - - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT_BRANCH --self-contained-html --junit-xml=$XML_REPORT_BRANCH $comp_args --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - - zero_errors_branch=$(cat $XML_REPORT_BRANCH | grep -c 'errors="0"') || true - - python3 scripts/parse_xml_report.py $XML_REPORT_BRANCH $CSV_BRANCH - # Store branch outputs for later comparison - - mv tests/dut tests/dut_branch - # create the summary based on the branch only - - python3 scripts/create_histograms.py $CSV_BRANCH $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - - *overwrite-pytest-cache-with-artifact - - ### ----- run pytest for merge target now ----- - # create float reference outputs with corresponding branch - - python3 -m pytest $TEST_SUITE -k "not model" -v --update_ref 1 $enc_stats_arg $enc_dmx_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH || exit_code=$? - - *overwrite-pytest-cache-with-artifact - # create merge-target outputs - - python3 -m pytest --tb=no -q $TEST_SUITE -k "not model" -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN - - ### compare the two csv files for regressions - - regressions_found=0 - - python3 scripts/basop_check_for_changes_in_testcases.py --show_improvements --xml_report $XML_REPORT_BRANCH $CSV_BRANCH $CSV_MAIN > regression_log.txt || regressions_found=$? - - - exit_code=0 - - *print-results-banner - - if [ $zero_errors_branch != 1 ]; then - - echo "Run errors encountered!" - - exit_code=$EXIT_CODE_FAIL - - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $ERRORS_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - - echo "The individual command lines can be found in the regressions_crashes.csv files in the job artifacts." - - elif [ $regressions_found != 0 ] && [ "$SKIP_REGRESSION_CHECK" != "true" ]; then - - cat regression_log.txt - - if [ $allow_regressions_flag == 0 ]; then - - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] not set!" - - exit_code=$EXIT_CODE_FAIL; - - else - - echo "Detected regression wrt to $CI_MERGE_REQUEST_TARGET_BRANCH_NAME, [allow regression] set." - - exit_code=$EXIT_CODE_NON_BE; - - fi - - echo "Reproduce locally with:" - - echo -e "1. Create references with target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:\n\t- git checkout $(cat $FLOAT_REF_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- mv IVAS_cod IVAS_cod_ref\n\t- mv IVAS_dec IVAS_dec_ref\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --update_ref 1 --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH" - - echo -e "2. Run test with source branch $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:\n\t- git checkout $(cat $CUT_COMMIT_FILE)\n\t- make clean\n\t- make -j\n\t- python3 -m pytest $(cat $FAILED_TESTCASES_LIST) --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH" - - echo "The individual command lines can be found in the regressions_*.csv files in the job artifacts." - - fi - - - exit $exit_code - after_script: - - rm -rf tests/dut tests/ref - allow_failure: - exit_codes: - - 123 - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - expire_in: 1 week - when: always - paths: - - $XML_REPORT_BRANCH - - $XML_REPORT_MAIN - - $HTML_REPORT_BRANCH - - $HTML_REPORT_MAIN - - $CSV_BRANCH - - $CSV_MAIN - - $SUMMARY_HTML_ARTIFACT_NAME - - $IMAGES_ARTIFACT_NAME - - $FLOAT_REF_COMMIT_FILE - - $CUT_COMMIT_FILE - - $MERGE_TARGET_COMMIT_FILE - - $MERGE_SOURCE_FLOAT_REF_COMMIT_FILE - - regressions_crashes.csv - - regressions_MLD.csv - - regressions_MAX_ABS_DIFF.csv - - regressions_MIN_SSNR.csv - - regressions_MIN_ODG.csv - - improvements_crashes.csv - - improvements_MLD.csv - - improvements_MAX_ABS_DIFF.csv - - improvements_MIN_SSNR.csv - - improvements_MIN_ODG.csv - expose_as: "pytest compare results" - reports: - junit: - - $XML_REPORT_BRANCH - - $XML_REPORT_MAIN - - -.ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor - extends: - - .job-linux - stage: test - needs: ["build-codec-linux-make"] - timeout: "600 minutes" - rules: - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - when: never - - if: $CI_PIPELINE_SOURCE == 'schedule' && $IVAS_PYTEST_MSAN - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer" - 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/copy-ltv-files-to-testv-dir.sh - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - - set -euxo pipefail - - make_args="CLANG=$CLANG_NUM" - - if [[ $CLANG_NUM == 3 ]]; then - - export UBSAN_OPTIONS="suppressions=scripts/ubsan_basop.supp,report_error_type=1,print_stacktrace=1" - - python3 scripts/basop_create_ignorelist_for_ubsan.py - - make_args="$make_args IGNORELIST=1" - - fi - - make clean - - make -j $make_args >> /dev/null - - testcase_timeout_arg="--testcase_timeout $TESTCASE_TIMEOUT_LTV_SANITIZERS" - # disable per-testcase timeout for msan to evaluate what is going on that it takes so long - - if [[ $CLANG_NUM = 1 ]]; then - - testcase_timeout_arg="" - - fi - - python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml $testcase_timeout_arg --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - when: always - expire_in: "2 weeks" - paths: - - report-junit.xml - - report.html - reports: - junit: - - report-junit.xml - -.ivas-pytest-compare-to-input-anchor: &ivas-pytest-compare-to-input-anchor - stage: test - needs: ["build-codec-linux-make"] - timeout: "360 minutes" - variables: - SUMMARY_HTML_ARTIFACT_NAME: "summary_$CI_JOB_NAME.html" - IMAGES_ARTIFACT_NAME: "images_$CI_JOB_NAME" - 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 - - 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 - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - if [ $LEVEL_SCALING != "1.0" ];then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - - fi - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - - - INV_LEVEL_SCALING=$(awk "BEGIN {print 1.0 / $LEVEL_SCALING}") - - comp_args="--mld --ssnr --odg --scalefac $INV_LEVEL_SCALING" - - ### run pytest - - exit_code=0 - - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-ref.html --self-contained-html --junit-xml=report-junit-ref.xml $comp_args -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $REF_ENCODER_PATH --dut_decoder_path $REF_DECODER_PATH --compare_to_input || exit_code=$? - - python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report-dut.html --self-contained-html --junit-xml=report-junit-dut.xml $comp_args -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH --compare_to_input || exit_code=$? - - zero_errors_ref=$(cat report-junit-ref.xml | grep -c 'errors="0"') || true - - zero_errors_dut=$(cat report-junit-dut.xml | grep -c 'errors="0"') || true - - python3 scripts/parse_xml_report.py report-junit-ref.xml report-ref.csv - - python3 scripts/parse_xml_report.py report-junit-dut.xml report-dut.csv - - python3 scripts/diff_report.py report-ref.csv report-dut.csv report-diff.csv - - # create summary - - mkdir $IMAGES_ARTIFACT_NAME - - python3 scripts/create_histograms.py report-diff.csv $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT --write-out-histograms --no-bins - - python3 ci/basop-pages/create_summary_page.py $SUMMARY_HTML_ARTIFACT_NAME $CI_JOB_ID $CI_JOB_NAME $IMAGES_ARTIFACT_NAME --measures $MEASURES_FOR_REPORT - - - 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-ref.xml - - report-ref.html - - report-ref.csv - - report-junit-dut.xml - - report-dut.html - - report-dut.csv - - report-diff.csv - - $IMAGES_ARTIFACT_NAME - - $SUMMARY_HTML_ARTIFACT_NAME - expose_as: "pytest compare to input results" - reports: - junit: - - report-junit-ref.xml - - report-junit-dut.xml - -# --------------------------------------------------------------- -# .pre jobs for setting up things -# --------------------------------------------------------------- - -# See: https://gitlab.com/gitlab-org/gitlab/-/issues/194023 -# Solution to make main branch pipelines uninterruptible while all other -# pipelines can be interrupted by default. This works because all jobs -# after uninterruptible jobs will be uninterruptible. Resource group -# setting avoids rare case where two fast merges could still interrupt -# pipeline. This should be revisited if there are updates to Gitlab. -uninterruptible: - stage: .pre - interruptible: false - resource_group: uninterruptible - script: - - echo "$CI_COMMIT_BRANCH is uninterruptible" - rules: - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - when: always - tags: - - ivas-basop-linux - -# --------------------------------------------------------------- -# verification jobs -# --------------------------------------------------------------- - -# fail pipeline in the final stage for pipelines on Draft MRs -# this also only runs on Draft MRs, so should always fail -fail-pipeline-if-in-draft: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - stage: postvalidate - tags: - - ivas-linux - script: - - echo "Your MR is still in Draft state, set it to ready to be mergable, then retrigger the pipeline." - - exit 1 - -# this branch runs on merges to main-pc only and will fail if the branch itself does not conform to the naming conventions -check-naming-of-branch-for-basop-update-merges: - extends: - - .rules-merge-request-to-main - - .job-linux - stage: prevalidate - tags: - - ivas-linux - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then - - ci/get_float_ref_branch_name.sh $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME - - fi - -branch-is-up-to-date-with-target-pre: - extends: - - .job-linux - - .rules-merge-request - stage: prevalidate - needs: [] - tags: - - ivas-basop-linux - script: - - | - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" - if [ $commits_behind_count -ne 0 ]; then - echo -e "Your branch is $commits_behind_count commits behind the target branch, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." - exit 1 - fi - - git fetch origin "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" - - TARGET_COMMIT="$(git rev-parse "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME")" - - echo "TARGET_COMMIT is $TARGET_COMMIT" - - echo "$TARGET_COMMIT" > "$MERGE_TARGET_COMMIT_FILE" - artifacts: - paths: - - $MERGE_TARGET_COMMIT_FILE - -branch-is-up-to-date-with-target-post: - extends: - - .job-linux - - .rules-merge-request-no-draft - stage: postvalidate - tags: - - ivas-basop-linux - script: - - | - commits_behind_count="$(bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh)" - if [ $commits_behind_count -ne 0 ]; then - echo -e "Your branch is $commits_behind_count commits behind the target branch, possibly main changed during your pipeline run, run\n\tgit pull origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME\nto update." - exit 123 - fi - allow_failure: - exit_codes: - - 123 - -clang-format-check: - extends: - - .test-job-linux - - .rules-merge-request - variables: - ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" - stage: prevalidate - needs: [] - timeout: "10 minutes" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - # Set up variables. This can't be done in the "variables" section because variables are not expanded properly there - - PATCH_FILE_NAME="$ARTIFACT_BASE_NAME".patch - - > - INSTRUCTIONS_GITLAB="To fix formatting issues:\n - - download the diff patch available as artifact of this job\n - - unzip the artifact and place the patch file in the root directory of your local IVAS repo\n - - run: git apply $PATCH_FILE_NAME\n - - commit new changes" - - > - INSTRUCTIONS_README="To fix formatting issues:\n - - place the patch file in the root directory of your local IVAS repo\n - - run: git apply $PATCH_FILE_NAME\n - - commit new changes" - - - format_problems=0 - - scripts/check-format.sh -afD -p 8 || format_problems=$? - - if [ $format_problems == 0 ] ; then exit 0; fi - - - mkdir tmp-formatting-fix - - git diff > "tmp-formatting-fix/$PATCH_FILE_NAME" - - # Print instructions to job output - - echo -e "$INSTRUCTIONS_GITLAB" - - # Include readme in the artifact, in case someone misses the job printout (e.g. getting the artifact via MR interface) - - echo -e "$INSTRUCTIONS_README" > "tmp-formatting-fix/readme.txt" - - - exit $format_problems - artifacts: - expire_in: 1 day - paths: - - tmp-formatting-fix/ - when: on_failure - name: "$ARTIFACT_BASE_NAME" - expose_as: "formatting patch" - -# --------------------------------------------------------------- -# Build jobs -# --------------------------------------------------------------- - -# TODO: template rules for the build jobs -# ensure that codec builds on linux -build-codec-linux-make: - rules: - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-linux - timeout: "100 minutes" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - *activate-Werror-linux - - make -j - -build-codec-linux-cmake: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-linux - timeout: "10 minutes" - 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 - - cmake -B cmake-build -G "Unix Makefiles" - - cmake --build cmake-build -- -j - -# ensure that codec builds on linux with instrumentation active -build-codec-linux-instrumented-make: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-linux - timeout: "100 minutes" - 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 scripts/prepare_instrumentation.sh -m MEM_ONLY - - make -j -C $INSTR_DIR - -# make sure that the codec builds with msan, asan and usan -build-codec-sanitizers-linux: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-linux - timeout: "100 minutes" - 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 - # TODO: re-enable once all the warnings have been fixed - #- *activate-Werror-linux - - bash ci/build_codec_sanitizers_linux.sh - -build-codec-linux-debugging-make: - rules: - - if: $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ - when: never - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-linux - timeout: "100 minutes" - variables: - BUILD_WITH_DEBUG_MODE_INFO: "true" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/activate-debug-mode-info-if-set.sh - - make -j - -build-codec-windows-msbuild: - rules: - - 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 - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # trigger build job for all MRs - - if: $CI_PIPELINE_SOURCE == 'schedule' - - if: $CI_PIPELINE_SOURCE == 'push' - when: never - extends: - - .build-job-windows - timeout: "10 minutes" - tags: - - ivas-windows - script: - - *print-common-info-windows - - *activate-WX-windows - - MSBuild.exe -maxcpucount .\Workspace_msvc\Workspace_msvc.sln /property:Configuration=Debug - -# --------------------------------------------------------------- -# Test jobs for merge requests -# --------------------------------------------------------------- - -### jobs that check for bitexactness of fx encoder and decoder -check-be-to-target-short-enc-0db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # -/-0dB - LEVEL_SCALING: "1.0" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-be-to-target-short-enc-+10db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # +10dB - LEVEL_SCALING: "3.162" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-be-to-target-short-enc--10db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # -10dB - LEVEL_SCALING: "0.3162" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-be-to-target-short-dec-0db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # +/-0dB - LEVEL_SCALING: "1.0" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -check-be-to-target-short-dec-+10db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # +10dB - LEVEL_SCALING: "3.162" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -check-be-to-target-short-dec--10db: - extends: - - .check-be-to-target-job - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # -10dB - LEVEL_SCALING: "0.3162" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -### jobs that check for regressions on non-BE testcases -check-regressions-short-enc-0db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-enc-0db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # +/-0dB - LEVEL_SCALING: "1.0" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-regressions-short-enc-+10db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-enc-+10db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # +10dB - LEVEL_SCALING: "3.162" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-regressions-short-enc--10db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-enc--10db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE_ENCODER" - # -10dB - LEVEL_SCALING: "0.3162" - # overwrite decoder with float reference one - DUT_DECODER_PATH: "$MERGE_SOURCE_FLOAT_REF_DECODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_DECODER_PATH: "$REF_DECODER_PATH" - USE_LTV: 0 - -check-regressions-short-dec-0db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-dec-0db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # +/-0dB - LEVEL_SCALING: "1" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -check-regressions-short-dec-+10db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-dec-+10db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # +10dB - LEVEL_SCALING: "3.162" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -check-regressions-short-dec--10db: - extends: - - .check-regressions-pytest-job - needs: - - job: "check-be-to-target-short-dec--10db" - artifacts: true - variables: - TEST_SUITE: "$SHORT_TEST_SUITE" - # -10dB - LEVEL_SCALING: "0.3162" - # overwrite encoder with float reference one - DUT_ENCODER_PATH: "$MERGE_SOURCE_FLOAT_REF_ENCODER_PATH_FOR_BUILD_DO_NOT_MODIFY" - MERGE_TARGET_ENCODER_PATH: "$REF_ENCODER_PATH" - USE_LTV: 0 - -### jobs that compare bitexactness between merge target and source -renderer-pytest-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-no-draft - # TODO: set reasonable timeout, will most likely take less - timeout: "20 minutes" - tags: - - ivas-linux - stage: compare - 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 - - *merge-request-comparison-setup-codec - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[rend\(erer\)*[ -]*non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 - - # store the current commit hash - - source_branch_commit_sha=$(git rev-parse HEAD) - - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - - - exit_code=0 - - testcase_timeout=60 - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? - - ### Run test using branch scripts and input - - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi - - # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - - - *merge-request-comparison-check - - allow_failure: - exit_codes: - - 123 - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - - report.html - expose_as: "pytest renderer results" - reports: - junit: - - report-junit.xml - -ivas-pytest-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-no-draft - stage: compare - timeout: "40 minutes" - tags: - - ivas-linux - 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 - - *merge-request-comparison-setup-codec - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 - - # store the current commit hash - - source_branch_commit_sha=$(git rev-parse HEAD) - - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - - ### prepare pytest - # create references - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --update_ref 1 -k "not model" - - ### Run test using branch scripts and input - - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi - - ### run pytest - - exit_code=0 - - testcase_timeout=600 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --mld --ssnr --odg --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout=$testcase_timeout -k "not model" || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - - - *merge-request-comparison-check - - allow_failure: - exit_codes: - - 123 - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - - report.html - expose_as: "pytest ivas results" - reports: - junit: - - report-junit.xml - -#TODO: re-enable after merge to main is done -.split-rendering-pytest-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .test-job-linux-compares-to-fixed-target - - .rules-merge-request-no-draft - timeout: "60 minutes" - stage: compare - 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 - - *merge-request-comparison-setup-codec - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_be_flag=$(grep -c --ignore-case "\[split*[ -]*non[ -]*be\]" tmp.txt) || true - # TODO: ref_using_target comes from float repo, but does not apply here - disable for now - # - ref_using_target=$(grep -c --ignore-case "\[ref[ -]*using[ -]*target\]" tmp.txt) || true - - ref_using_target=0 - - # store the current commit hash - - source_branch_commit_sha=$(git rev-parse HEAD) - - ### If ref_using_target is not set, checkout the source branch to use scripts and input from there - - if [ $ref_using_target == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - - if [ $ref_using_target == 0 ]; then git checkout $source_branch_commit_sha; fi - - exit_code=0 - - testcase_timeout=60 - - # remporary solution to make it work with and without https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec/-/merge_requests/2181 - - mv $DUT_POST_RENDERER_PATH ISAR_post_rend_tmp - - cp $REF_POST_RENDERER_PATH $DUT_POST_RENDERER_PATH - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref --testcase_timeout=$testcase_timeout || exit_code=$? - - mv ISAR_post_rend_tmp $DUT_POST_RENDERER_PATH - - ### Run test using scripts and input from main - - if [ $ref_using_target == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts - - if [ $ref_using_target == 1 ]; then git checkout $source_branch_commit_sha; fi - - - comp_args="--mld --ssnr --odg" - - echo "$comp_args" - - # run test - - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py $comp_args --create_cut --testcase_timeout=$testcase_timeout || exit_code=$? - - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true - - - *merge-request-comparison-check - - allow_failure: - exit_codes: - - 123 - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 2 week - when: always - paths: - - report-junit.xml - - report.html - expose_as: "pytest split rendering results" - reports: - junit: - - report-junit.xml - -# test that runs all modes with 1s input signals -codec-smoke-test: - extends: - - .test-job-linux-needs-testv-dir - - .rules-merge-request-to-float-ref-no-draft - timeout: "20 minutes" - stage: test - needs: ["build-codec-linux-make"] - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - # LTV update needed as ltv ISM metadata files are used - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/update-ltv-repo.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/update-scripts-repo.sh - - python3 scripts/smoketest-basop-filter.py scripts/config/ivas_modes.json --inline - - bash ci/smoke_test.sh || true - - tar cJf logs.tar.xz out/logs/ - - ls -al logs.tar.* - ### analyze for failures - - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_jbm.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi - - ret_val=0 - - if cat smoke_test_output.txt | grep -c "failed"; then echo "Smoke test without JBM failed"; ret_val=1; fi - - if cat smoke_test_output_jbm.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi - - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi - - exit $ret_val - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week - when: always - paths: - - smoke_test_output.txt - - smoke_test_output_jbm.txt - - smoke_test_output_hrtf.txt - - logs.tar.xz - expose_as: "Smoke test results" - -# from float -# check for crashes if first received frame on decoder side is an SID -check-first-frame-is-sid: - extends: - - .test-job-linux-needs-testv-dir - - .rules-merge-request-to-float-ref-no-draft - stage: test - needs: ["build-codec-linux-make"] - 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 - # this rm makes check-for-testvectors only check for the signals we actually need in this test - - rm scripts/config/ci_linux_ltv.json scripts/config/ci_linux.json - - python3 -m pytest ci/test_vectors_available.py - - bash ci/run-first-frame-is-sid-test.sh - -# from float -# needs fix to be merged from floating point repo before it can be activated -.check-bitexactness-hrtf-rom-and-file: - extends: - - .test-job-linux - - .rules-merge-request-no-draft - stage: test - needs: ["build-codec-linux-make"] - timeout: "5 minutes" - 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 - - - make clean - - make -j - - python3 tests/create_short_testvectors.py --cut_len 1.0 - # TODO: run full test again once the custom binary files are supported - - python3 -m pytest -k "not diff_from_rom and not test_binary_file" tests/hrtf_binary_loading --html=report.html --junit-xml=report-junit.xml --self-contained-html - artifacts: - paths: - - report.html - - report-junit.xml - when: always - name: "$CI_JOB_NAME--$CI_MERGE_REQUEST_ID--sha-$CI_COMMIT_SHA--hrtf-loading" - expose_as: "logs-hrtf-loading" - expire_in: "5 days" - - -### From Float -# Check interop IVAS_cod_test -> IVAS_dec_ref -ivas-interop-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - - .rules-merge-request-to-float-ref-no-draft - - .test-job-linux-compares-to-fixed-target - stage: test - timeout: "10 minutes" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/get-commits-behind-count.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/float/check-commits-behind-count-in-compare-jobs.sh - - *merge-request-comparison-setup-codec - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - # some helper variables - "|| true" to prevent failures from grep not finding anything - # write to temporary file as workaround for failures observed with piping echo - - echo $CI_MERGE_REQUEST_TITLE > tmp.txt - - non_interop_flag=$(grep -c --ignore-case "\[non[ -]*io\]" tmp.txt) || true - - ### prepare pytest - - # Run reference creation, using source branch encoder and main decoder (see .merge-request-comparison-setup-codec) - - exit_code=0 - - exit_code2=0 - # set timeout for individual testcase runs to 60 seconds - - testcase_timeout=60 - - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v --html=report.html --self-contained-html --junit-xml=report-junit.xml --update_ref 1 --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec_ref --testcase_timeout=$testcase_timeout || exit_code=$? - - zero_failures=$(cat report-junit.xml | grep -c 'failures="0"') || true - - - if [ $zero_failures != 1 ] && [ $non_interop_flag == 0 ]; then echo "Non-interop cases without non-interop flag encountered!"; exit $EXIT_CODE_FAIL; fi - - if [ $zero_failures != 1 ] && [ $non_interop_flag == 1 ]; then echo "Non-interop cases with non-interop flag encountered"; exit $EXIT_CODE_NON_BE; fi - - exit 0 - - allow_failure: - exit_codes: - - 123 - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - - report.html - expose_as: "interop test results" - reports: - junit: - - report-junit.xml - -### split rendering tests -split-rendering-smoke-test: - extends: - - .test-job-linux - - .rules-merge-request-no-draft - needs: ["build-codec-linux-make"] - stage: test - 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 - - - make -j - - testcase_timeout=10 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --testcase_timeout=$testcase_timeout - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "split rendering smoke results" - reports: - junit: - - report-junit.xml - -lc3-wrapper-unit-test: - extends: - - .test-job-linux - - .rules-merge-request-no-draft - needs: ["build-codec-linux-make"] - stage: test - 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 - - - cmake -B cmake-build -G "Unix Makefiles" -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j - - - echo "Assuming here that you either merge to main or to $FLOAT_REF_BRANCH." - - echo "If you have some other merge target, this might fail and manual fiddling is needed." - - if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" == "$FLOAT_REF_BRANCH" ]; then - - scripts/split_rendering/lc3plus_float/ivas_lc3plus_unit_test - - else - - scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test - - fi - -# from float -# test renderer executable -renderer-smoke-test: - extends: - - .test-job-linux - - .rules-merge-request-to-float-ref-no-draft - needs: ["build-codec-linux-make"] - stage: test - 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 - - make -j IVAS_rend - - testcase_timeout=60 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "renderer make pytest results" - reports: - junit: - - report-junit.xml - -# from float -# test renderer executable with cmake + asan -renderer-asan: - extends: - - .test-job-linux - - .rules-merge-request-to-float-ref-no-draft - needs: ["build-codec-linux-make"] - stage: test - 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 - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j - - testcase_timeout=180 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout - - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "renderer asan pytest results" - reports: - junit: - - report-junit.xml - -# from float -# test renderer executable with cmake + msan -renderer-msan: - extends: - - .test-job-linux - - .rules-merge-request-to-float-ref-no-draft - needs: ["build-codec-linux-make"] - stage: test - tags: - - ivas-linux - 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 - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j - - testcase_timeout=180 - - python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout - - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "renderer msan pytest results" - reports: - junit: - - report-junit.xml - -# from float -# test renderer executable with cmake + usan -renderer-usan: - extends: - - .test-job-linux - - .rules-merge-request-to-float-ref-no-draft - needs: ["build-codec-linux-make"] - stage: test - tags: - - ivas-linux - 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 - - cmake -B cmake-build -G "Unix Makefiles" -DCLANG=asan -DCOPY_EXECUTABLES_FROM_BUILD_DIR=true - - cmake --build cmake-build -- -j - - testcase_timeout=180 - - UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1,log_path=usan_log_catchall python3 -m pytest -q -n auto -rA --junit-xml=report-junit.xml tests/renderer/test_renderer.py --testcase_timeout=$testcase_timeout - - grep_exit_code=0 - - touch usan_log_empty # Creates an empty file, this is to avoid "grep: usan_log_*: No such file or directory" in case no USAN failures are reported from pytest - - grep UndefinedBehaviorSanitizer usan_log_* || grep_exit_code=$? - - if [ $grep_exit_code != 1 ] ; then echo "Run errors in test_renderer.py with Clang undefined-behavior-sanitizer"; exit 1; fi - - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--job-$CI_JOB_NAME--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - expose_as: "renderer usan pytest results" - reports: - junit: - - report-junit.xml - -.sanitizer-selftest-on-mr: - stage: test - extends: - - .rules-merge-request-to-float-ref-no-draft - artifacts: - name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results" - expire_in: 1 week - when: always - paths: - - report-junit-20ms.xml - - report-junit-10ms.xml - - report-junit-5ms.xml - - report-20ms.html - - report-10ms.html - - report-5ms.html - expose_as: "Sanitizer selftest results" - reports: - junit: - - report-junit-20ms.xml - - report-junit-10ms.xml - - report-junit-5ms.xml - -# From float repo -# to be reused in MR and LTV-scheduled sanitizer test jobs -# set CLANG_NUM, SELFTEST_SANITY_TIMEOUT and SELF_TEST_PRM_FILE in before_script section -.sanitizer-selftest-anchor: &sanitizer-selftest-anchor - 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/copy-ltv-files-to-testv-dir.sh - - make clean - - make -j CLANG=$CLANG_NUM - - testcase_timeout=$SELFTEST_SANITY_TIMEOUT - - export UBSAN_OPTIONS=suppressions=scripts/ubsan.supp,report_error_type=1 - - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - - exit_code20=0 - - exit_code10=0 - - exit_code5=0 - - - if [ $CLANG_NUM -eq 1 ]; then sanitizer_type="MemorySanitizer"; elif [ $CLANG_NUM -eq 2 ]; then sanitizer_type="AddressSanitizer"; elif [ $CLANG_NUM -eq 3 ]; then sanitizer_type="UndefinedBehaviorSanitizer"; else echo "Wrong CLANG_NUM $CLANG_NUM given!"; exit 1; fi - - # run encoder and decoder with 20ms renderer framesize first, use reference creation mode - - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --update_ref 1 --html=report-20ms.html --self-contained-html --junit-xml=report-junit-20ms.xml --testcase_timeout=$testcase_timeout --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec || exit_code20=$? - # for 10ms and 5ms renderer framesize, we only need to run the decoder part as renderer framesize is a decoder-only option - # set tolerance very high do ignore any BE differences due to the different renderer framesizes, those can appear due to the limiter being active - # we are only interested in runtime errors from the sanitizers and ignore the diffs - - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-5ms.html --self-contained-html --junit-xml=report-junit-5ms.xml --dut_fr 5 --decoder_only --abs_tol 100000 || exit_code5=$? - - python3 -m pytest tests/codec_be_on_mr_nonselection $USE_LTV --param_file $SELF_TEST_PRM_FILE -v --html=report-10ms.html --self-contained-html --junit-xml=report-junit-10ms.xml --dut_fr 10 --decoder_only --abs_tol 100000 || exit_code10=$? - - - if [ $exit_code20 -ne 0 ] || [ $exit_code10 -ne 0 ] || [ $exit_code5 -ne 0 ]; then exit 1; fi - -# from float repo -# NOTE: (per-testcase) timeout was adjusted to work for float only -# code selftest testvectors with memory-sanitizer binaries -.codec-msan: - extends: - - .sanitizer-selftest-on-mr - tags: - - ivas-linux - before_script: - - CLANG_NUM=1 - - SELFTEST_SANITY_TIMEOUT=180 - - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - USE_LTV="" - <<: *sanitizer-selftest-anchor - -# code selftest testvectors with address-sanitizer binaries -.codec-asan: - extends: - - .sanitizer-selftest-on-mr - tags: - - ivas-linux - before_script: - - CLANG_NUM=2 - - SELFTEST_SANITY_TIMEOUT=180 - - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - USE_LTV="" - <<: *sanitizer-selftest-anchor - -# code selftest testvectors with undefined-behaviour-sanitizer binaries -.codec-usan: - extends: - - .sanitizer-selftest-on-mr - tags: - - ivas-linux - before_script: - - CLANG_NUM=3 - - SELFTEST_SANITY_TIMEOUT=180 - - SELF_TEST_PRM_FILE="scripts/config/self_test.prm" - - USE_LTV="" - <<: *sanitizer-selftest-anchor - -# --------------------------------------------------------------- -# Short test jobs for running from web interface or schedule -# --------------------------------------------------------------- - -### jobs that test fx encoder -> flt decoder -ivas-pytest-compare_to_ref-short-enc: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-short-enc-lev-10: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-short-enc-lev+10: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 - <<: *ivas-pytest-anchor - -# encoder dmx comparison jobs -ivas-pytest-compare_to_ref-dmx-short-enc: - extends: - - .rules-pytest-to-ref-enc-short-dmx - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - COMPARE_DMX="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-dmx-short-enc-lev-10: - extends: - - .rules-pytest-to-ref-enc-short-dmx - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - COMPARE_DMX="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-dmx-short-enc-lev+10: - extends: - - .rules-pytest-to-ref-enc-short-dmx - - .test-job-linux - before_script: - - USE_LTV=0 - - ENCODER_TEST="true" - - COMPARE_DMX="true" - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 - <<: *ivas-pytest-anchor - -ivas-pytest-enc-msan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=1 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_ENCODER - <<: *ivas-pytest-sanitizers-anchor - -ivas-pytest-enc-asan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=2 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_ENCODER - <<: *ivas-pytest-sanitizers-anchor - -ivas-pytest-enc-usan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=3 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_ENCODER - <<: *ivas-pytest-sanitizers-anchor - -### jobs that test flt encoder -> fx decoder -ivas-pytest-compare_to_ref-short-dec: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-short-dec-lev-10: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=0.3162 - <<: *ivas-pytest-anchor - -ivas-pytest-compare_to_ref-short-dec-lev+10: - extends: - - .rules-pytest-to-ref-short - - .test-job-linux - before_script: - - USE_LTV=0 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=3.162 - <<: *ivas-pytest-anchor - -### jobs that compare the output synthesis to the input files directly -ivas-pytest-compare-to-input-short-dec: - extends: - - .rules-pytest-to-input-short - - .test-job-linux - before_script: - - USE_LTV=0 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-compare-to-input-anchor - -ivas-pytest-compare-to-input-short-enc: - extends: - - .rules-pytest-to-input-short - - .test-job-linux - before_script: - - USE_LTV=0 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-compare-to-input-anchor - -ivas-pytest-dec-msan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=1 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER - <<: *ivas-pytest-sanitizers-anchor - -ivas-pytest-dec-asan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=2 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER - <<: *ivas-pytest-sanitizers-anchor - -ivas-pytest-dec-usan: - extends: - - .test-job-linux - tags: - - ivas-basop-linux-fast - before_script: - - CLANG_NUM=3 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE=$LONG_TEST_SUITE_NO_RENDERER - <<: *ivas-pytest-sanitizers-anchor - -# --------------------------------------------------------------- -# Long test job -# --------------------------------------------------------------- - -ivas-pytest-compare_ref-long-enc: - extends: - - .rules-pytest-long - - .test-job-linux - before_script: - - USE_LTV=1 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_ENCODER" - - LEVEL_SCALING=1.0 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-dec: - extends: - - .rules-pytest-long - - .test-job-linux - tags: - - ivas-basop-linux - - high-memory-capacity - before_script: - - USE_LTV=1 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE" - - LEVEL_SCALING=1.0 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-enc-lev-10: - extends: - - .rules-pytest-long - - .test-job-linux - before_script: - - USE_LTV=1 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_ENCODER" - - LEVEL_SCALING=0.3162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-dec-lev-10: - extends: - - .rules-pytest-long - - .test-job-linux - tags: - - ivas-basop-linux - - high-memory-capacity - before_script: - - USE_LTV=1 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE" - - LEVEL_SCALING=0.3162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-enc-lev+10: - extends: - - .rules-pytest-long - - .test-job-linux - before_script: - - USE_LTV=1 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_ENCODER" - - LEVEL_SCALING=3.162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-dec-lev+10: - extends: - - .rules-pytest-long - - .test-job-linux - tags: - - ivas-basop-linux - - high-memory-capacity - before_script: - - USE_LTV=1 - - DUT_ENCODER_PATH=./$REF_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE" - - LEVEL_SCALING=3.162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-fx-fx: - extends: - - .rules-pytest-long-fx-fx - - .test-job-linux - tags: - - ivas-linux - before_script: - - USE_LTV=1 - - REF_ENCODER_PATH=./$DUT_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" - - LEVEL_SCALING=1.0 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-fx-fx-lev-10: - extends: - - .rules-pytest-long-fx-fx - - .test-job-linux - tags: - - ivas-linux - before_script: - - USE_LTV=1 - - REF_ENCODER_PATH=./$DUT_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" - - LEVEL_SCALING=0.3162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - -ivas-pytest-compare_ref-long-fx-fx-lev+10: - extends: - - .rules-pytest-long-fx-fx - - .test-job-linux - tags: - - ivas-linux - before_script: - - USE_LTV=1 - - REF_ENCODER_PATH=./$DUT_ENCODER_PATH - - TEST_SUITE="$LONG_TEST_SUITE_NO_RENDERER" - - LEVEL_SCALING=3.162 - - SPLIT_COMPARISON="true" - <<: *ivas-pytest-anchor - - -ivas-smoke-test-saturation: - extends: - - .rules-pytest-saturation-smoke-test - - .test-job-linux-needs-testv-dir - script: - - USE_LTV=1 - - LEVEL_SCALING=32768 - - - 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 - - fi - - if [ $LEVEL_SCALING != "1.0" ];then - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/apply-testv-scaling.sh - - fi - - cp -r scripts/testv/* $TESTV_DIR/ - - # skip prepare_mem_dryrun.py script in smoke_test.sh - - sed -i 's/python3 .\/scripts\/prepare_mem_dryrun.py/#python3 .\/scripts\/prepare_mem_dryrun.py/g' ci/smoke_test.sh - - - bash ci/smoke_test.sh - ### analyze for failures - - if ! [ -s smoke_test_output.txt ] || ! [ -s smoke_test_output_plc.txt ] || ! [ -s smoke_test_output_jbm_noEXT.txt ] || ! [ -s smoke_test_output_hrtf.txt ]; then echo "Error in smoke test"; exit 1; fi - - ret_val=0 - - if cat smoke_test_output.txt | grep -c "failed" ; then echo "Smoke test without PLC failed"; ret_val=1; fi - - if cat smoke_test_output_plc.txt | grep -c "failed"; then echo "Smoke test with PLC failed"; ret_val=1; fi - - if cat smoke_test_output_jbm_noEXT.txt | grep -c "failed"; then echo "Smoke test JBM part failed"; ret_val=1; fi - - if cat smoke_test_output_hrtf.txt | grep -c "failed"; then echo "Smoke test with external hrtf files failed"; ret_val=1; fi - - exit $ret_val - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - expire_in: 1 week - when: always - paths: - - smoke_test_output.txt - - smoke_test_output_plc.txt - - smoke_test_output_jbm_noEXT.txt - - smoke_test_output_hrtf.txt - expose_as: "saturation smoke test results" - - -# GCOV/LCOV coverage analysis of self_test suite -coverage-test-on-main-scheduled: - extends: - - .test-job-linux - - .rules-coverage - stage: test - timeout: 3 hours - 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 - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/copy-ltv-files-to-testv-dir.sh - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-binaries.sh float-ref - # Build DuT binaries with GCOV - - make clean >> /dev/null - - make GCOV=1 -j - - cp IVAS_rend IVAS_rend_ref # Copy to ensure instrumented renderer is run in the first pytest call - - - testcase_timeout=$TESTCASE_TIMEOUT_LTV - - exit_code_dec=0 - - exit_code_enc=0 - - python3 -m pytest --tb=no tests/codec_be_on_mr_nonselection tests/renderer --update_ref 1 -v --create_ref --html=report-dec.html --self-contained-html --junit-xml=report-junit-dec.xml -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH || exit_code_dec=$? - - lcov -c -d obj -o coverage_dec_rend.info # extract coverage of decoder/renderer - - - python3 -m pytest --tb=no tests/codec_be_on_mr_nonselection --encoder_only -v --html=report-enc.html --self-contained-html --junit-xml=report-junit-enc.xml -n auto --testcase_timeout $testcase_timeout --dut_encoder_path $DUT_ENCODER_PATH || exit_code_enc=$? - - lcov -c -d obj -o coverage_enc_dec_rend.info # extract coverage of encoder/decoder/renderer - - # remove apps and lib_util files from coverage - - lcov -r coverage_dec_rend.info "*apps*" -o coverage_dec_rend.info - - lcov -r coverage_dec_rend.info "*lib_util*" -o coverage_dec_rend.info - - lcov -r coverage_enc_dec_rend.info "*apps*" -o coverage_enc_dec_rend.info - - lcov -r coverage_enc_dec_rend.info "*lib_util*" -o coverage_enc_dec_rend.info - - - commit_sha=$(git rev-parse HEAD) - - genhtml coverage_enc_dec_rend.info -o coverage_enc_dec_rend -t "Coverage on main enc/dec/rend @ $commit_sha" - - genhtml coverage_dec_rend.info -o coverage_dec_rend -t "Coverage on main -- dec/rend @ $commit_sha" - artifacts: - name: "main-coverage-sha-$CI_COMMIT_SHORT_SHA" - when: always - expire_in: 1 week - paths: - - coverage_enc_dec_rend.info - - coverage_dec_rend.info - - coverage_enc_dec_rend - - coverage_dec_rend - - report-dec.html - - report-enc.html - expose_as: "Coverage result" - reports: - junit: - - report-junit-dec.xml - - report-junit-enc.xml - -# --------------------------------------------------------------- -# EVS 26.444 test job -# --------------------------------------------------------------- - -# check bitexactness to EVS -be-2-evs-26444: - extends: - - .test-job-linux - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "evs-26444" - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" - tags: - - be-2-evs-basop - stage: test - timeout: "120 minutes" # To be revisited - 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 - - sed -i".bak" "s/\(#define EVS_FLOAT\)/\/\/\1/" lib_com/options.h - - make -j >> /dev/null - - # copy over to never change the testvector dir - - cp -r $EVS_BE_TEST_DIR_BASOP ./evs_be_test - - mkdir -p ./evs_be_test/output/decoded ./evs_be_test/output/bitstreams - - - exit_code=0 - - python3 -m pytest tests/test_26444.py -v --html=report.html --self-contained-html --junit-xml=report-junit.xml -n auto || exit_code=$? - - if [ $exit_code -eq 1 ]; then echo "Differences encountered"; exit $EXIT_CODE_FAIL; fi - - exit 0 - - artifacts: - name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results" - expire_in: 1 week - when: always - paths: - - report-junit.xml - - report.html - expose_as: "EVS 26444 result" - reports: - junit: - - report-junit.xml - -ivas-pytest-renderer: - extends: - - .test-job-linux - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "pytest-renderer" - before_script: - - USE_LTV=0 - - TEST_SUITE="tests/renderer" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-anchor - -peaq-enc-passthrough: - extends: - - .test-job-linux - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "peaq-enc-passthrough" - before_script: - - USE_LTV=0 - - DUT_DECODER_PATH=./$REF_DECODER_PATH - - TEST_SUITE="tests/test_enc_passthrough.py" - - DELTA_ODG="true" - - LEVEL_SCALING=1.0 - <<: *ivas-pytest-anchor - -# --------------------------------------------------------------- -# Various other tests -# --------------------------------------------------------------- - -# TODO: actually run on MR once main problems are fixed -voip-be-on-merge-request: - extends: - - .test-job-linux-needs-testv-dir - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "voip-be-test" - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "ivas-float-update" - # - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main - stage: test - needs: ["build-codec-linux-make"] - timeout: "10 minutes" - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/print-common-info.sh - - make clean - - make -j > build_log.txt - - python3 -m pytest tests/test_be_for_jbm_neutral_dly_profile.py - artifacts: - when: always - expire_in: "5 days" - paths: - - build_log.txt - -check-be-between-renderer-framesizes: - extends: - - .test-job-linux - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "renderer-framesize-be" - stage: test - needs: ["build-codec-linux-make"] - script: - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/disable-limiter.sh - - make clean - - make -j - - echo "$SHORT_TEST_SUITE" - - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - - python3 ci/remove_unsupported_testcases.py $PRM_FILES --use-main-pc-set - - - 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=$? - - - 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=$? - - - 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 - - - *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 - - 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 - - report-junit-20ms.xml - - report-20ms.html - reports: - junit: - - report-junit-5ms.xml - - report-junit-10ms.xml - - report-junit-20ms.xml - -# To inject backup copy in manual trigger: -# - 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. /usr/local/backup -ivas-long-term-job-logs: - rules: - - if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "long-term-logs" - - if: $CI_PIPELINE_SOURCE == 'schedule' && $MANUAL_PIPELINE_TYPE == "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 - - # Clean up logs - - if [ -d "logs" ]; then rm -rf "logs"; fi - # Inject logs from backup copy if LOGS_BACKUP_SOURCE_DIR is set - - 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 - - - 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 - # 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 (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 - - # 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" - expire_in: 4 weeks - when: always - paths: - - logs - expose_as: "ivas long term job logs results" - -# To store backup copy: -# - 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. /usr/local/backup -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 - - # 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 - # 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 - - exit 0 - - else - - echo "Error - LOGS_BACKUP_TARGET_DIR not set for backup job!" - - exit 1 - - fi - - -# --------------------------------------------------------------- -# Complexity measurement jobs -# --------------------------------------------------------------- - -# create necessary environment -.complexity-measurements-setup: &complexity-measurements-setup - ### 1. part: mainly same as in float repo - this is boilerplate code to make the gitlab pages presentation work - - mkdir -p wmops/logs - - - job_id=$(python3 ci/get_id_of_last_job_occurence.py $CI_COMMIT_REF_NAME $CI_JOB_NAME $CI_PROJECT_ID) - - echo $job_id - # 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 "$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" - - # if is needed to catch case when no artifact is there (first run), similarly as above - # 1. check for public_dir being there as this might not be the case when artifact download failed - # 2. check for public dir not being empty - handle job failures in prev job that happen after the dir is created. In that case, the empty dir is in the artifacts - - if [ -d $public_dir ] && [ ! -z "$( ls -A $public_dir )" ]; then - - mv $public_dir/* wmops/ - # check here if we have the split-by-levels files present - if not, fake them up with the existing global one - # this is needed for the first run with split graphs on a branch where the global version did run previously - # NOTE: checking only for level_1 file here as this should already be sufficient - # NOTE2: also not chechking for RAM for same reason - - wmops_all_global="wmops/log_wmops_all.txt" - - ram_all_global="wmops/log_ram_all.txt" - - if [ -f "${wmops_all_global}" ] && [ ! -f "wmops/log_wmops_all_level_1.txt" ]; then - - declare -a suffixes=("level_1" "level_2" "level_3" "rate_sw") - - for suffix in "${suffixes[@]}"; do - - cp ${wmops_all_global} wmops/log_wmops_all_${suffix}.txt - - cp ${ram_all_global} wmops/log_ram_all_${suffix}.txt - - done - - fi - - fi - - - rm artifacts.zip - - rm -rf $public_dir - - ### 1.5.part: get the corresponding measurement from ivas-float-update - # only do this on main and not for the complexity meaurements run on ivas-float-update - - if [ "$CI_COMMIT_REF_NAME" == "main" ]; then - - job_id=$(python3 ci/get_id_of_last_job_occurence.py $FLOAT_REF_BRANCH $CI_JOB_NAME $CI_PROJECT_ID) - - echo $job_id - - 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 - - fi - -# prepare artifacts -> move to public directory -.complexity-measurements-prepare-artifacts: &complexity-measurements-prepare-artifacts - - public_dir="$CI_JOB_NAME-public" - - mkdir $public_dir - - mv -f wmops/log_*_all*.txt ./*.js ${public_dir}/ - # move logfiles for links - - mkdir $public_dir/logs - # first move logs - - log_files=$(cat $public_dir/graphs*.js | grep logFile | sed "s/.*\(wmops_newsletter_.*\.csv\).*/\1/g") - - for f in $log_files; do [ -f wmops/logs/$f ] && mv wmops/logs/$f $public_dir/logs/$f; done - - if [ "$CI_COMMIT_REF_NAME" == "$FLOAT_REF_BRANCH" ]; then mv wmops/logs/latest_WMOPS.csv $public_dir/logs/; fi - # copy index page blueprint - - cp ci/complexity_measurements/index_complexity.html ${public_dir}/index.html - # patch the format in the title - - sed -i "s/IVAS FORMAT/IVAS $in_format to $out_format/g" ${public_dir}/index.html - # do separately here to avoid overwrite complaints by mv - - mv -f ci/complexity_measurements/style.css ${public_dir}/ - -.complexity-measurements-report-summary: &complexity-measurements-report-summary - - *print-results-banner - - if [ $ret_val -eq 0 ]; then - - echo -e "No crashes occured.\nNo changes in complexity or memory usage (>1%) detected." - - elif [ $ret_val -eq 123 ]; then - - echo -e "Changes in complexity or memory usage (>1%) detected!!!\nNo crashes occured." - - else - - echo -e "Something went wrong in running the codec. Likely some modes were crashing." - - fi - -.complexity-template: - extends: - - .test-job-linux - stage: test - variables: - ret_val: 0 - GET_WMOPS_ARGS: "mem_only" - timeout: 3 hours 30 minutes - 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 - - bash "${CI_PROJECT_DIR}"/ivas-codec-ci/snippets/basop/build-float-ref-and-dut-binaries.sh - - *complexity-measurements-setup - # delete previous jobs logfiles if present (-f flag ensures return calue of 0 even in first run where this folder is not present) - - rm -rf COMPLEXITY/logs - allow_failure: - exit_codes: - - 123 - artifacts: - name: "$CI_JOB_NAME--$CI_COMMIT_REF_NAME--sha-$CI_COMMIT_SHA" - when: always - expire_in: 2 week - paths: - - $CI_JOB_NAME-public - - COMPLEXITY/logs - -complexity-stereo-in-stereo-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - variables: - JOB_ID_INJECT: "" - script: - - in_format=stereo - - out_format=stereo - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-ism-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 1 hour - variables: - JOB_ID_INJECT: "" - script: - - in_format=ISM - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-ism-in-binaural_room_ir-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 2 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=ISM - - out_format=BINAURAL_ROOM_IR - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-ism-in-ext-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 3 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=ISM - - out_format=EXT - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "ISM+1 ISM+2 ISM+3 ISM+4" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-sba-hoa3-in-hoa3-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 4 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=HOA3 - - out_format=HOA3 - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-sba-hoa3-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 5 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=HOA3 - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-sba-hoa3-in-binaural_room_ir-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 6 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=HOA3 - - out_format=BINAURAL_ROOM_IR - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-mc-in-7_1_4-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 7 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=MC - - out_format=7_1_4 - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-mc-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 10 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=MC - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-mc-in-binaural_room_ir-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 12 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=MC - - out_format=BINAURAL_ROOM_IR - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-masa-in-ext-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 15 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=MASA - - out_format=EXT - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-masa-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 16 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=MASA - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-masa-in-hoa3-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 17 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=MASA - - out_format=HOA3 - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -# complexity-omasa-in-ext-out: -# extends: -# - .complexity-template -# rules: -# - if: $MEASURE_COMPLEXITY_LINUX -# when: delayed -# start_in: 13 hours - # variables: - # JOB_ID_INJECT: "" -# script: -# - in_format=OMASA -# - out_format=EXT -# - ret_val=0 -# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? -# - *complexity-measurements-prepare-artifacts -# - *complexity-measurements-report-summary -# - exit $ret_val - -complexity-omasa-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 18 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=OMASA - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-omasa-in-hoa3-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 20 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=OMASA - - out_format=HOA3 - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-StereoDmxEVS-stereo-in-mono-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 22 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=StereoDmxEVS - - out_format=mono - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -# complexity-osba-in-ext-out: -# extends: -# - .complexity-template -# rules: -# - if: $MEASURE_COMPLEXITY_LINUX -# when: delayed -# start_in: 17 hours -# script: -# - in_format=OSBA -# - out_format=EXT -# - ret_val=0 -# - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? -# - *complexity-measurements-prepare-artifacts -# - *complexity-measurements-report-summary -# - exit $ret_val - -complexity-osba-in-binaural-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 22 hours 30 minutes - variables: - JOB_ID_INJECT: "" - script: - - in_format=OSBA - - out_format=BINAURAL - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -complexity-osba-in-binaural_room_ir-out: - extends: - - .complexity-template - rules: - - if: $MEASURE_COMPLEXITY_LINUX - when: delayed - start_in: 25 hours - variables: - JOB_ID_INJECT: "" - script: - - in_format=OSBA - - out_format=BINAURAL_ROOM_IR - - ret_val=0 - - bash ci/complexity_measurements/getWmops.sh "$in_format" "$out_format" $GET_WMOPS_ARGS || ret_val=$? - - *complexity-measurements-prepare-artifacts - - *complexity-measurements-report-summary - - exit $ret_val - -# job that sets up gitlab pages website -pages: - stage: deploy - tags: - - ivas-basop-linux - 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 - - ls - - ls -lh public - artifacts: - paths: - - public - expire_in: 1 day + file: main-basop.yml -- GitLab From ef2e881b04d5e06bed3626aba2feef91adb23b45 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 28 Jul 2025 20:54:39 +0200 Subject: [PATCH 676/692] port 3gpp_issue_1517_fix --- 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 b0077d223..1cf8f03c0 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1454,12 +1454,14 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( 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 10615874c6461adc48c8c410d8a9e587c3cf5e3d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 28 Jul 2025 20:59:46 +0200 Subject: [PATCH 677/692] formatting --- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 1cf8f03c0..65d8976ac 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -1460,8 +1460,8 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( } FOR( bin = 0; bin < nBins; bin++ ) { - subFrameTotalEne_e[bin] = sub( subFrameTotalEne_e[bin], 1 ); - move16(); + 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 5ae0e0f694e5b9c599b72153621fbb05a5eb9c3d Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 29 Jul 2025 11:11:22 +0200 Subject: [PATCH 678/692] Fix for computing reverb predelay in samples --- lib_com/options.h | 1 + lib_rend/ivas_reverb_fx.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 929ae2b05..4a5a53c98 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ +#define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index b4b9f7d1e..1be277fce 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2426,6 +2426,10 @@ ivas_error ivas_binaural_reverb_init( Word32 t60[CLDFB_NO_CHANNELS_MAX]; Word32 ene[CLDFB_NO_CHANNELS_MAX]; Word16 preDelay; +#ifdef FIX_1831_REVERB_REGRESSION + Word16 temp16, s; + Word32 temp32; +#endif error = IVAS_ERR_OK; @@ -2442,7 +2446,14 @@ ivas_error ivas_binaural_reverb_init( return error; } +#ifdef FIX_1831_REVERB_REGRESSION + temp16 = BASOP_Util_Divide3216_Scale( sampling_rate, CLDFB_NO_CHANNELS_MAX, &s ); + temp16 = shl( temp16, s ); // Q0 + temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 ); // Q11 + preDelay = shr( add( temp32, shl( 1, 10 ) ), 11 ); // Q0 +#else preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); +#endif #ifdef FIX_1741_REVERB_TIMES_Q_FORMAT floatToFixed_arrL( t60_temp, t60, Q26, CLDFB_NO_CHANNELS_MAX ); #else -- GitLab From 8ec96c567ad24981a9b8398477414bae7a5f3a1e Mon Sep 17 00:00:00 2001 From: Marek Szczerba Date: Tue, 29 Jul 2025 12:30:44 +0200 Subject: [PATCH 679/692] To make clang happy --- lib_rend/ivas_reverb_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 1be277fce..bd1634c77 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2448,9 +2448,9 @@ ivas_error ivas_binaural_reverb_init( #ifdef FIX_1831_REVERB_REGRESSION temp16 = BASOP_Util_Divide3216_Scale( sampling_rate, CLDFB_NO_CHANNELS_MAX, &s ); - temp16 = shl( temp16, s ); // Q0 - temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 ); // Q11 - preDelay = shr( add( temp32, shl( 1, 10 ) ), 11 ); // Q0 + temp16 = shl( temp16, s ); // Q0 + temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 ); // Q11 + preDelay = shr( add( temp32, shl( 1, 10 ) ), 11 ); // Q0 #else preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); #endif -- GitLab From c39a21cea262db5d4fb091c17c134b3f59c58573 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Tue, 29 Jul 2025 17:05:49 +0200 Subject: [PATCH 680/692] fix MERGE_TARGET executable assignment in regression test jobs --- .gitlab-ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 842aefbc7..e8acbd24b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -800,7 +800,7 @@ stages: - *build-merge-target-binaries # need to restore cache again - *overwrite-pytest-cache-with-artifact - - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true + - python3 -m pytest --tb=no -q $TEST_SUITE -v --keep_files --create_cut --html=$HTML_REPORT_MAIN --self-contained-html --junit-xml=$XML_REPORT_MAIN $comp_args --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $MERGE_TARGET_ENCODER_PATH --dut_decoder_path $MERGE_TARGET_DECODER_PATH -n auto --testcase_timeout $testcase_timeout || true - python3 scripts/parse_xml_report.py $XML_REPORT_MAIN $CSV_MAIN ### compare the two csv files for regressions @@ -1496,6 +1496,7 @@ check-regressions-short-enc-0db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref @@ -1515,6 +1516,7 @@ check-regressions-short-enc-+10db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref @@ -1534,6 +1536,7 @@ check-regressions-short-enc--10db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_DECODER_PATH=./IVAS_dec_ref + - MERGE_TARGET_DECODER_PATH=./IVAS_dec_ref - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref @@ -1553,6 +1556,7 @@ check-regressions-short-dec-0db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=1.0 - rm -rf tests/dut tests/ref @@ -1572,6 +1576,7 @@ check-regressions-short-dec-+10db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=3.162 - rm -rf tests/dut tests/ref @@ -1591,6 +1596,7 @@ check-regressions-short-dec--10db: - *set-reference-for-basop-port-branch - USE_LTV=0 - DUT_ENCODER_PATH=./IVAS_cod_ref + - MERGE_TARGET_ENCODER_PATH=./IVAS_cod_ref - TEST_SUITE="$SHORT_TEST_SUITE" - LEVEL_SCALING=0.3162 - rm -rf tests/dut tests/ref -- GitLab From 2a5a43ca6eafc846bb80c3b32f1fb3b2e561ab80 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 29 Jul 2025 22:31:07 +0200 Subject: [PATCH 681/692] fix sampling-rate dependency, BASOPs --- lib_rend/ivas_reverb_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index bd1634c77..5156911f3 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -2447,10 +2447,10 @@ ivas_error ivas_binaural_reverb_init( } #ifdef FIX_1831_REVERB_REGRESSION - temp16 = BASOP_Util_Divide3216_Scale( sampling_rate, CLDFB_NO_CHANNELS_MAX, &s ); - temp16 = shl( temp16, s ); // Q0 - temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 ); // Q11 - preDelay = shr( add( temp32, shl( 1, 10 ) ), 11 ); // Q0 + temp16 = BASOP_Util_Divide3216_Scale( 48000, CLDFB_NO_CHANNELS_MAX, &s ); + temp16 = shl( temp16, s ); // Q0 + temp32 = Mult_32_16( roomAcoustics->acousticPreDelay_fx, temp16 ); // Q11 + preDelay = extract_l( L_shr( L_add( temp32, L_shl( 1, 10 ) ), 11 ) ); // Q0 #else preDelay = (int16_t) roundf( 48000.0f * roomAcoustics->acousticPreDelay / CLDFB_NO_CHANNELS_MAX ); #endif -- GitLab From 1d6f700a00654dbfb4962aad9b4232c7c3d8aa23 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 30 Jul 2025 09:54:31 +0200 Subject: [PATCH 682/692] add tags to regression jobs they were lost in the forest of "extends:" .... --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e8acbd24b..b33cceacd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1492,6 +1492,8 @@ check-regressions-short-enc-0db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1512,6 +1514,8 @@ check-regressions-short-enc-+10db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1532,6 +1536,8 @@ check-regressions-short-enc--10db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1552,6 +1558,8 @@ check-regressions-short-dec-0db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1572,6 +1580,8 @@ check-regressions-short-dec-+10db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 @@ -1592,6 +1602,8 @@ check-regressions-short-dec--10db: - job: build-codec-linux-make extends: - .rules-mr-to-main-or-main-pc + tags: + - ivas-basop-linux before_script: - *set-reference-for-basop-port-branch - USE_LTV=0 -- GitLab From e59a587856772bae4f7621cfbfb3346d52d4434f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 30 Jul 2025 10:00:30 +0200 Subject: [PATCH 683/692] ivas-linux -> ivas-basop-linux --- .gitlab-ci.yml | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b33cceacd..d48b9d67f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -448,7 +448,7 @@ stages: # templates to define stages and platforms .test-job-linux: tags: - - ivas-linux + - ivas-basop-linux .test-job-linux-compares-to-fixed-target: extends: .test-job-linux @@ -461,7 +461,7 @@ stages: stage: build timeout: "2 minutes" tags: - - ivas-linux + - ivas-basop-linux .build-job-windows: stage: build @@ -1001,7 +1001,7 @@ uninterruptible: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH when: always tags: - - ivas-linux + - ivas-basop-linux # --------------------------------------------------------------- # Validation jobs @@ -1016,7 +1016,7 @@ fail-pipeline-if-in-draft: when: never stage: postvalidate tags: - - ivas-linux + - ivas-basop-linux script: - echo "Your MR is still in Draft state, set it to ready to be mergable, then retrigger the pipeline." - exit 1 @@ -1027,7 +1027,7 @@ check-naming-of-branch-for-main-pc-merges: - .rules-merge-request-to-main-pc stage: prevalidate tags: - - ivas-linux + - ivas-basop-linux script: - *update-scripts-repo - if [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[skip[[:space:]_-]name[[:space:]_-]check\] ]] && [[ ! "$CI_MERGE_REQUEST_TITLE" =~ \[CI\] ]]; then @@ -1044,7 +1044,7 @@ branch-is-up-to-date-with-target-pre: stage: prevalidate needs: [] tags: - - ivas-linux + - ivas-basop-linux script: - *get-commits-behind-count - | @@ -1065,7 +1065,7 @@ branch-is-up-to-date-with-target-post: - .rules-merge-request stage: postvalidate tags: - - ivas-linux + - ivas-basop-linux script: - *get-commits-behind-count - | @@ -1090,7 +1090,7 @@ clang-format-check: ARTIFACT_BASE_NAME: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--formatting-fix" stage: prevalidate tags: - - ivas-linux + - ivas-basop-linux needs: [] timeout: "5 minutes" script: @@ -1173,7 +1173,7 @@ build-codec-linux-make: extends: - .build-job-linux tags: - - ivas-linux + - ivas-basop-linux timeout: "10 minutes" script: - *print-common-info @@ -1191,7 +1191,7 @@ build-codec-linux-cmake: extends: - .build-job-linux tags: - - ivas-linux + - ivas-basop-linux timeout: "10 minutes" script: - *print-common-info @@ -1212,7 +1212,7 @@ build-codec-linux-instrumented-make: - .build-job-linux timeout: "10 minutes" tags: - - ivas-linux + - ivas-basop-linux script: - *print-common-info - *update-scripts-repo @@ -1226,7 +1226,7 @@ build-codec-sanitizers-linux: - .build-job-linux - .rules-basis tags: - - ivas-linux + - ivas-basop-linux timeout: "10 minutes" script: - *update-scripts-repo @@ -1662,7 +1662,7 @@ ivas-pytest-enc-msan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1673,7 +1673,7 @@ ivas-pytest-enc-asan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1684,7 +1684,7 @@ ivas-pytest-enc-usan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_DECODER_PATH=./$REF_DECODER_PATH @@ -1752,7 +1752,7 @@ ivas-pytest-dec-msan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=1 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1763,7 +1763,7 @@ ivas-pytest-dec-asan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=2 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -1774,7 +1774,7 @@ ivas-pytest-dec-usan: extends: - .test-job-linux tags: - - ivas-linux-fast + - ivas-basop-linux-fast before_script: - CLANG_NUM=3 - DUT_ENCODER_PATH=./$REF_ENCODER_PATH @@ -2054,7 +2054,7 @@ voip-be-on-merge-request: - .rules-merge-request-no-draft timeout: "20 minutes" tags: - - ivas-linux + - ivas-basop-linux stage: test needs: ["build-codec-linux-make"] #, "build-codec-instrumented-linux", "build-codec-sanitizers-linux"] script: @@ -2088,7 +2088,7 @@ renderer-pytest-on-merge-request: # TODO: set reasonable timeout, will most likely take less timeout: "20 minutes" tags: - - ivas-linux + - ivas-basop-linux stage: compare script: - *print-common-info @@ -2148,7 +2148,7 @@ ivas-pytest-on-merge-request: # thus, overall, this should save time timeout: "40 minutes" tags: - - ivas-linux + - ivas-basop-linux script: - *print-common-info - *get-commits-behind-count @@ -2641,7 +2641,7 @@ complexity-osba-in-binaural_room_ir-out: pages: stage: deploy tags: - - ivas-linux + - ivas-basop-linux rules: - if: $UPDATE_PAGES script: -- GitLab From d93277c1f0fd62bfe882a9f566c0cc7ce307f3cb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Wed, 30 Jul 2025 17:12:24 +0200 Subject: [PATCH 684/692] fix missing TdRendWrapper init went missing due to a porting mistake --- lib_rend/lib_rend_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 619c4a8b2..1fa9801e1 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -2725,6 +2725,8 @@ static ivas_error setRendInputActiveMc( setZeroPanMatrix_fx( inputMc->panGains_fx ); inputMc->customLsInput = defaultCustomLs(); + inputMc->tdRendWrapper = defaultTdRendWrapper(); + if ( hrtfs->hHrtfTD ) { inputMc->tdRendWrapper.binaural_latency_ns = Mult_32_32( hrtfs->hHrtfTD->latency_s_fx, 1000000000 ); -- GitLab From ec0534a067a296eb648fa37f58e650be016d7420 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 18:31:29 +0200 Subject: [PATCH 685/692] - Fixed if-condition to properly activate reverb_with_bin_room_ir - Modified gain scaling in rotateFrame_sd_cldfd_fixed() - Corrected factEQ_fx calculation - Increased factEQ_fx calculation precision. --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 34 ++++++++++++++++++++++++-- lib_rend/ivas_rotation_fx.c | 3 +++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 929ae2b05..14fc1ef57 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,7 +164,7 @@ #define NONBE_FIX_991_PARAMBIN_BINARY_HRTF /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to activate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on ) */ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ - +#define FIX_1835_REVERB_ACTIVATION /* FhG: reverberation activation logic modification and factEQ calculation correction*/ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 68886c1ba..d6dcd7deb 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -992,7 +992,19 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } - +#ifdef FIX_1835_REVERB_ACTIVATION + Word16 scaleFactor = s_min( getScaleFactor32( RealBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), + getScaleFactor32( ImagBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) + { + scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), + getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + } + if ( scaleFactor > 6 ) + scaleFactor -= 6; // Adding headroom for subsequent calculations + else + scaleFactor = 0; +#endif FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1012,7 +1024,10 @@ static void ivas_binaural_obtain_DMX_fx( move32(); imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); - +#ifdef FIX_1835_REVERB_ACTIVATION + temp1_fx = L_shl( temp1_fx, scaleFactor ); + temp2_fx = L_shl( temp2_fx, scaleFactor ); +#endif P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } @@ -1025,10 +1040,17 @@ static void ivas_binaural_obtain_DMX_fx( move32(); FOR( k = 0; k < numTimeSlots; k++ ) { +#ifdef FIX_1835_REVERB_ACTIVATION + temp1_fx = L_shl(realDMX[chOutIdx][k][bandIdx], scaleFactor); + move32(); + temp2_fx = L_shl(imagDMX[chOutIdx][k][bandIdx], scaleFactor); + move32(); +#else temp1_fx = realDMX[chOutIdx][k][bandIdx]; move32(); temp2_fx = imagDMX[chOutIdx][k][bandIdx]; move32(); +#endif P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in } test(); @@ -1040,7 +1062,11 @@ static void ivas_binaural_obtain_DMX_fx( ELSE { Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); +#ifdef FIX_1835_REVERB_ACTIVATION + Word16 exp = 0; // divide3232 gives Q15 + following Q16 shift +#else Word16 exp = norm_l( div ); +#endif factEQ_fx = Sqrt32( L_shl( div, Q16 ), &exp ); factEQ_fx = L_shl( factEQ_fx, sub( exp, 1 ) ); // Q30 } @@ -1405,7 +1431,11 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); +#ifdef FIX_1835_REVERB_ACTIVATION + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) +#else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) +#endif { IF( NE_32( ( error = ivas_binaural_reverb_init( &( hBinRenderer->hReverb ), st_ivas->hHrtfStatistics, hBinRenderer->conv_band, hBinRenderer->timeSlots, &( st_ivas->hRenderConfig->roomAcoustics ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtfFastConv->fastconvReverberationTimes_fx, st_ivas->hHrtfFastConv->fastconvReverberationEneCorrections_fx ) ), IVAS_ERR_OK ) ) { diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 92ad8d36f..a2b55a19b 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1173,6 +1173,9 @@ void rotateFrame_sd_cldfb_fixed( IF( hEFAPdata != NULL && ( NE_16( extract_l( L_shr( hOutputSetup->ls_azimuth_fx[n], Q22 ) ), azimuth ) || NE_16( extract_l( L_shr( hOutputSetup->ls_elevation_fx[n], Q22 ) ), elevation ) ) ) { efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); +#ifdef FIX_1835_REVERB_ACTIVATION + scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); //gains_fx: Q31 +#endif } ELSE { -- GitLab From 8c599303f5166c32a98ccf881cf42253db60e5e8 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 18:47:47 +0200 Subject: [PATCH 686/692] Applied clang formatting patch. --- lib_com/options.h | 2 +- lib_dec/ivas_binRenderer_internal_fx.c | 10 +++++----- lib_rend/ivas_rotation_fx.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 60fd2e3aa..5257a5d6a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -166,7 +166,7 @@ #define FIX_1741_REVERB_TIMES_Q_FORMAT /* Philips: reverberation times in Q26 format instead of Q31 */ #define FIX_1831_REVERB_REGRESSION /* Philips: fixes reverb regression issues */ -#define FIX_1835_REVERB_ACTIVATION /* FhG: reverberation activation logic modification and factEQ calculation correction*/ +#define FIX_1835_REVERB_ACTIVATION /* FhG: Modified reverberation activation logic and corrected factEQ calculation */ /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index d6dcd7deb..e4ffb1549 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -998,13 +998,13 @@ static void ivas_binaural_obtain_DMX_fx( FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) { scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); + getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); } if ( scaleFactor > 6 ) scaleFactor -= 6; // Adding headroom for subsequent calculations else scaleFactor = 0; -#endif +#endif FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1041,9 +1041,9 @@ static void ivas_binaural_obtain_DMX_fx( FOR( k = 0; k < numTimeSlots; k++ ) { #ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl(realDMX[chOutIdx][k][bandIdx], scaleFactor); + temp1_fx = L_shl( realDMX[chOutIdx][k][bandIdx], scaleFactor ); move32(); - temp2_fx = L_shl(imagDMX[chOutIdx][k][bandIdx], scaleFactor); + temp2_fx = L_shl( imagDMX[chOutIdx][k][bandIdx], scaleFactor ); move32(); #else temp1_fx = realDMX[chOutIdx][k][bandIdx]; @@ -1432,7 +1432,7 @@ ivas_error ivas_binRenderer_open_fx( /* Allocate memories needed for reverb module */ test(); #ifdef FIX_1835_REVERB_ACTIVATION - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) #else IF( ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) ) && EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) #endif diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index a2b55a19b..5d2f393bb 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1174,7 +1174,7 @@ void rotateFrame_sd_cldfb_fixed( { efap_determine_gains_fx( hEFAPdata, gains_fx[n], L_shl( azimuth, Q22 ), L_shl( elevation, Q22 ), EFAP_MODE_EFAP ); #ifdef FIX_1835_REVERB_ACTIVATION - scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); //gains_fx: Q31 + scale_sig32( gains_fx[n], hEFAPdata->numSpk, Q1 ); // gains_fx: Q31 #endif } ELSE -- GitLab From 20cd84fab9f400d88e3c1a1e52471d8bf5c09360 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 30 Jul 2025 19:04:31 +0200 Subject: [PATCH 687/692] Reverted factEQ_fx precision improvement. --- lib_dec/ivas_binRenderer_internal_fx.c | 27 ++------------------------ 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index e4ffb1549..d241cd145 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -992,19 +992,7 @@ static void ivas_binaural_obtain_DMX_fx( set32_fx( imagDMX[chOutIdx][k], 0, CLDFB_NO_CHANNELS_MAX ); } } -#ifdef FIX_1835_REVERB_ACTIVATION - Word16 scaleFactor = s_min( getScaleFactor32( RealBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[0], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); - FOR( chIdx = 0; chIdx < hBinRenderer->nInChannels; chIdx++ ) - { - scaleFactor = s_min( getScaleFactor32( RealBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ), - getScaleFactor32( ImagBuffer[chIdx], CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX ) ); - } - if ( scaleFactor > 6 ) - scaleFactor -= 6; // Adding headroom for subsequent calculations - else - scaleFactor = 0; -#endif + FOR( chOutIdx = 0; chOutIdx < BINAURAL_CHANNELS; chOutIdx++ ) { set32_fx( P_in_fx, 0, hBinRenderer->conv_band ); @@ -1024,10 +1012,6 @@ static void ivas_binaural_obtain_DMX_fx( move32(); imagDMX[chOutIdx][k][bandIdx] = L_add( imagDMX[chOutIdx][k][bandIdx], temp2_fx ); // Q_in move32(); -#ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl( temp1_fx, scaleFactor ); - temp2_fx = L_shl( temp2_fx, scaleFactor ); -#endif P_in_fx[bandIdx] = L_add( P_in_fx[bandIdx], L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in move32(); } @@ -1040,17 +1024,10 @@ static void ivas_binaural_obtain_DMX_fx( move32(); FOR( k = 0; k < numTimeSlots; k++ ) { -#ifdef FIX_1835_REVERB_ACTIVATION - temp1_fx = L_shl( realDMX[chOutIdx][k][bandIdx], scaleFactor ); - move32(); - temp2_fx = L_shl( imagDMX[chOutIdx][k][bandIdx], scaleFactor ); - move32(); -#else temp1_fx = realDMX[chOutIdx][k][bandIdx]; move32(); temp2_fx = imagDMX[chOutIdx][k][bandIdx]; move32(); -#endif P_out_fx = L_add( P_out_fx, L_add( Mpy_32_32( temp1_fx, temp1_fx ), Mpy_32_32( temp2_fx, temp2_fx ) ) ); // Q31-2*Q_in } test(); @@ -1063,7 +1040,7 @@ static void ivas_binaural_obtain_DMX_fx( { Word16 div = divide3232( P_in_fx[bandIdx], P_out_fx ); #ifdef FIX_1835_REVERB_ACTIVATION - Word16 exp = 0; // divide3232 gives Q15 + following Q16 shift + Word16 exp = 0; // divide3232 returns Q15 + following Q16 shift #else Word16 exp = norm_l( div ); #endif -- GitLab From 45e6092b0e49f16bc6b08fc14e3c8fad865fb7d1 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 31 Jul 2025 09:55:56 +0200 Subject: [PATCH 688/692] disable implicit fallthrough check in CMake build this is to fix build pipeline and align with the Makefile an individual handling of this cases is better, but portability is annoying here --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9a9afe76..ecd8f11c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ if(UNIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off") # disable floating point operation contraction set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-implicit-fallthrough") # to be uncommented in CI # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") -- GitLab From 79920ac7623418fb68e81977b3a6c2a3286e2793 Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 31 Jul 2025 12:56:43 +0200 Subject: [PATCH 689/692] set CI repo ref back to main --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba4f1fe3d..8136fa46b 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 kiene/basop-ci-merge-test-unified-config + IVAS_CODEC_CI_REF: &IVAS_CODEC_CI_REF main include: - local: .gitlab-ci/variables.yml -- GitLab From acc23d5056ef9e554f9621e8dc2e174608ddae7f Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Thu, 31 Jul 2025 14:49:49 +0200 Subject: [PATCH 690/692] move variable into CI repo --- .gitlab-ci/variables.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci/variables.yml b/.gitlab-ci/variables.yml index ddbfe614a..31d69a643 100644 --- a/.gitlab-ci/variables.yml +++ b/.gitlab-ci/variables.yml @@ -53,7 +53,6 @@ variables: MERGE_SOURCE_FLOAT_REF_POST_RENDERER_PATH_FOR_BUILD_DO_NOT_MODIFY: "./ISAR_post_rend_merge_source_float_ref" LEVEL_SCALING: "1.0" IVAS_PIPELINE_NAME: '' - BASOP_CI_BRANCH_PC_REPO: "basop-ci-branch-pc" PRM_FILES: "scripts/config/self_test.prm scripts/config/self_test_ltv.prm" TESTCASE_TIMEOUT_STV: 900 TESTCASE_TIMEOUT_LTV: 2400 -- GitLab From 94b2ca0c84f45330244e81eb4d402d2557882e6a Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Fri, 1 Aug 2025 10:16:09 +0200 Subject: [PATCH 691/692] dummy commit to trigger CI -- GitLab From 7597ffcfde3cd6e13a55313dc3f165d7bcbe48ee Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Fri, 1 Aug 2025 12:09:46 +0300 Subject: [PATCH 692/692] fix warning --- lib_dec/ivas_init_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index a3df9ed2c..80cad2c96 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -388,7 +388,7 @@ ivas_error ivas_dec_setup( } #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT /* this should be non-zero if original input format was MASA_ISM_FORMAT */ - st_ivas->nchan_ism = add( st_ivas->bit_stream[sub( res_dec, 3 )], shl( st_ivas->bit_stream[sub( res_dec, 2 )], 1 ) ); + st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) ); IF( GT_16( st_ivas->nchan_ism, 0 ) ) { -- GitLab