Loading lib_dec/ivas_sba_dirac_stereo_dec_fx.c +6 −1 Original line number Diff line number Diff line Loading @@ -686,6 +686,7 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( Word16 i; #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word32 hb_nrg = EPSILON_FIX; Word16 q_hb_nrg = Q31; Word32 max_val; Word16 shift; move32(); Loading Loading @@ -744,6 +745,8 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( move16(); hb_nrg = L_add( hStereoDft->hb_nrg_subr_fx[0], hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (q_hb_synth + shift) - 45 q_hb_nrg = hStereoDft->q_hb_nrg_subr; move16(); #else FOR( i = 0; i < shr( output_frame, 2 ); i++ ) { Loading Loading @@ -802,8 +805,10 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( hStereoDft->hb_nrg_subr_fx[1], shl( shr( hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (q_hb_synth + shift) - 40 move32(); hStereoDft->q_hb_nrg_subr = sub( shl( ( q_hb_synth + shift ), 1 ), 45 + 9 ); hStereoDft->hb_nrg_fx[0] = hb_nrg; /* todo: which Q-value is this supposed to be? */ hStereoDft->hb_nrg_fx[0] = hb_nrg; move32(); hStereoDft->q_hb_nrg[0] = q_hb_nrg; move16(); #else hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/ move32(); Loading lib_dec/ivas_stat_dec.h +5 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,9 @@ typedef struct stereo_dft_dec_data_struct Word32 hb_nrg_fx[STEREO_DFT_CORE_HIST_MAX]; /* Q(q_hb_nrg) */ Word32 hb_nrg_subr_fx[STEREO_DFT_NBDIV]; /* Q(q_hb_nrg_subr) */ #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg[STEREO_DFT_CORE_HIST_MAX]; #endif Word16 Q_nrg_subr; Word16 prev_Q_stefi_sig; Word16 q_td_gain[STEREO_DFT_CORE_HIST_MAX]; Loading @@ -224,7 +227,9 @@ typedef struct stereo_dft_dec_data_struct Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q(q_smooth_buf_fx) */ Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ Word16 q_smooth_buf_fx; #ifndef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg; #endif Word16 q_hb_nrg_subr; Word16 q_res_mem; Loading lib_dec/ivas_stereo_dft_dec_fx.c +52 −2 Original line number Diff line number Diff line Loading @@ -194,6 +194,9 @@ void stereo_dft_dec_reset_fx( set32_fx( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); set32_fx( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX ); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS set16_fx( hStereoDft->q_hb_nrg, Q31, STEREO_DFT_CORE_HIST_MAX ); #endif set32_fx( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX ); set16_fx( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX ); hStereoDft->q_dft = 0; Loading Loading @@ -659,7 +662,12 @@ void stereo_dft_dec_update_fx( } Copy32( hStereoDft->hb_stefi_sig_fx + output_frame, hStereoDft->hb_stefi_sig_fx, hStereoDft->hb_stefi_delay ); /* Qx */ #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_hb_nrg */ Copy( hStereoDft->q_hb_nrg, hStereoDft->q_hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); #else Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* Qx */ #endif Copy32( hStereoDft->td_gain_fx, hStereoDft->td_gain_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_td_gain */ Copy( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); Loading Loading @@ -2778,6 +2786,16 @@ static void stereo_dft_compute_td_stefi_params_fx( move32(); nrg_pred_DMX = hStereoDft->hb_nrg_fx[1]; move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS IF( GT_16( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) ) { nrg_DMX = L_shr( nrg_DMX, sub( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) ); } ELSE { nrg_pred_DMX = L_shr( nrg_pred_DMX, sub( hStereoDft->q_hb_nrg[1], hStereoDft->q_hb_nrg[0] ) ); } #endif op1 = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, nrg_DMX ), L_add( EPSILON_FIX, nrg_pred_DMX ), &q_div ); /* q_div */ q_sqrt = add( Q16, q_div ); Loading Loading @@ -3223,6 +3241,12 @@ void stereo_dft_generate_res_pred_fx( } ELSE IF( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE ) { #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_dmx_nrg, q_diff; Word16 norm_dmx_nrg; Word16 temp_e; Word32 L_temp; #endif /* ACELP -> TCX/HQ core transition */ /* calculate high band energy only */ dmx_nrg = EPSILON_FIX; Loading @@ -3232,8 +3256,34 @@ void stereo_dft_generate_res_pred_fx( dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ); /* 2 * q_dft - 31 */ } #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS norm_dmx_nrg = norm_l( dmx_nrg ); dmx_nrg = L_shl( dmx_nrg, norm_dmx_nrg ); q_dmx_nrg = add( sub( shl( hStereoDft->q_dft, 1 ), 31 ), norm_dmx_nrg ); q_diff = sub( hStereoDft->q_hb_nrg[0], q_dmx_nrg ); /* dmx_nrg * 2 / hStereoDft->NFFT */ L_temp = BASOP_Util_Divide3232_Scale_newton( dmx_nrg, shr( hStereoDft->NFFT, 1 ), &temp_e ); L_temp = L_shr( L_temp, sub( 31, temp_e ) ); IF( GT_16( q_diff, 0 ) ) { hStereoDft->hb_nrg_fx[0] = L_add( L_shr( hStereoDft->hb_nrg_fx[0], q_diff ), L_temp ); move32(); hStereoDft->q_hb_nrg[0] = sub( hStereoDft->q_hb_nrg[0], q_diff ); move16(); } ELSE { hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], L_shl( L_temp, q_diff ) ); move32(); /* hStereoDft->q_hb_nrg[0] stays as is */ } #else hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], div_l( dmx_nrg, shr( hStereoDft->NFFT, 2 ) ) ); /* Q15 */ move32(); #endif *stop = bin0; move16(); } Loading lib_dec/ivas_stereo_icbwe_dec_fx.c +14 −1 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ void stereo_icBWE_dec_fx( Word16 icbweM2Ref_fx, ratio_L_fx; Word16 gsMapping_fx; Word32 hb_nrg_fx; #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg; #endif Word16 Q_syn_shb; Word16 shift_prev_pow, synthRef_shift; Word32 L_tmp; Loading Loading @@ -199,6 +202,9 @@ void stereo_icBWE_dec_fx( { hb_nrg_fx = 0; move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS q_hb_nrg = Q31; #endif move32(); maximum_abs_32_fx( synthRef_fx, output_frame, &maxVal ); synthRef_shift = norm_l( maxVal ); Loading Loading @@ -235,7 +241,10 @@ void stereo_icBWE_dec_fx( hCPE->hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_tmp ); // 2 * (Qsyn + SynthRef_shift) - 45 hb_nrg_fx = L_add( hCPE->hStereoDft->hb_nrg_subr_fx[0], hCPE->hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (Qsyn + SynthRef_shift) - 45 #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS q_hb_nrg = hStereoDft->q_hb_nrg_subr; move16(); #endif Copy32( synthRef_fx, hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, output_frame ); /* Qsynth */ } Loading @@ -254,6 +263,10 @@ void stereo_icBWE_dec_fx( hCPE->hStereoDft->q_hb_nrg_subr = sub( shl( ( *Q_syn + synthRef_shift ), 1 ), 45 + 9 ); hCPE->hStereoDft->hb_nrg_fx[0] = hb_nrg_fx; // 2 * (Qx + SynthRef_shift) - 31 move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS hCPE->hStereoDft->q_hb_nrg[0] = q_hb_nrg; move16(); #endif hCPE->hStereoDft->td_gain_fx[0] = 0; move32(); hCPE->hStereoDft->core_hist[0] = st->core; Loading Loading
lib_dec/ivas_sba_dirac_stereo_dec_fx.c +6 −1 Original line number Diff line number Diff line Loading @@ -686,6 +686,7 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( Word16 i; #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word32 hb_nrg = EPSILON_FIX; Word16 q_hb_nrg = Q31; Word32 max_val; Word16 shift; move32(); Loading Loading @@ -744,6 +745,8 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( move16(); hb_nrg = L_add( hStereoDft->hb_nrg_subr_fx[0], hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (q_hb_synth + shift) - 45 q_hb_nrg = hStereoDft->q_hb_nrg_subr; move16(); #else FOR( i = 0; i < shr( output_frame, 2 ); i++ ) { Loading Loading @@ -802,8 +805,10 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( hStereoDft->hb_nrg_subr_fx[1] = ( Mpy_32_16_1( hStereoDft->hb_nrg_subr_fx[1], shl( shr( hStereoDft->NFFT, 1 ), 6 ) ) ); // 2 * (q_hb_synth + shift) - 40 move32(); hStereoDft->q_hb_nrg_subr = sub( shl( ( q_hb_synth + shift ), 1 ), 45 + 9 ); hStereoDft->hb_nrg_fx[0] = hb_nrg; /* todo: which Q-value is this supposed to be? */ hStereoDft->hb_nrg_fx[0] = hb_nrg; move32(); hStereoDft->q_hb_nrg[0] = q_hb_nrg; move16(); #else hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/ move32(); Loading
lib_dec/ivas_stat_dec.h +5 −0 Original line number Diff line number Diff line Loading @@ -199,6 +199,9 @@ typedef struct stereo_dft_dec_data_struct Word32 hb_nrg_fx[STEREO_DFT_CORE_HIST_MAX]; /* Q(q_hb_nrg) */ Word32 hb_nrg_subr_fx[STEREO_DFT_NBDIV]; /* Q(q_hb_nrg_subr) */ #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg[STEREO_DFT_CORE_HIST_MAX]; #endif Word16 Q_nrg_subr; Word16 prev_Q_stefi_sig; Word16 q_td_gain[STEREO_DFT_CORE_HIST_MAX]; Loading @@ -224,7 +227,9 @@ typedef struct stereo_dft_dec_data_struct Word32 smooth_buf_fx[SBA_DIRAC_STEREO_NUM_BANDS][SBA_DIRAC_NRG_SMOOTH_LONG + 1]; /* Q(q_smooth_buf_fx) */ Word16 smooth_fac_fx[NB_DIV][SBA_DIRAC_STEREO_NUM_BANDS]; /* Q15 */ Word16 q_smooth_buf_fx; #ifndef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg; #endif Word16 q_hb_nrg_subr; Word16 q_res_mem; Loading
lib_dec/ivas_stereo_dft_dec_fx.c +52 −2 Original line number Diff line number Diff line Loading @@ -194,6 +194,9 @@ void stereo_dft_dec_reset_fx( set32_fx( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); set32_fx( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX ); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS set16_fx( hStereoDft->q_hb_nrg, Q31, STEREO_DFT_CORE_HIST_MAX ); #endif set32_fx( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX ); set16_fx( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX ); hStereoDft->q_dft = 0; Loading Loading @@ -659,7 +662,12 @@ void stereo_dft_dec_update_fx( } Copy32( hStereoDft->hb_stefi_sig_fx + output_frame, hStereoDft->hb_stefi_sig_fx, hStereoDft->hb_stefi_delay ); /* Qx */ #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_hb_nrg */ Copy( hStereoDft->q_hb_nrg, hStereoDft->q_hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); #else Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* Qx */ #endif Copy32( hStereoDft->td_gain_fx, hStereoDft->td_gain_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); /* q_td_gain */ Copy( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); Loading Loading @@ -2778,6 +2786,16 @@ static void stereo_dft_compute_td_stefi_params_fx( move32(); nrg_pred_DMX = hStereoDft->hb_nrg_fx[1]; move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS IF( GT_16( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) ) { nrg_DMX = L_shr( nrg_DMX, sub( hStereoDft->q_hb_nrg[0], hStereoDft->q_hb_nrg[1] ) ); } ELSE { nrg_pred_DMX = L_shr( nrg_pred_DMX, sub( hStereoDft->q_hb_nrg[1], hStereoDft->q_hb_nrg[0] ) ); } #endif op1 = BASOP_Util_Divide3232_Scale( L_add( EPSILON_FIX, nrg_DMX ), L_add( EPSILON_FIX, nrg_pred_DMX ), &q_div ); /* q_div */ q_sqrt = add( Q16, q_div ); Loading Loading @@ -3223,6 +3241,12 @@ void stereo_dft_generate_res_pred_fx( } ELSE IF( hStereoDft->core_hist[STEREO_DFT_STEFFI_DELAY_SHORT / 2] == ACELP_CORE ) { #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_dmx_nrg, q_diff; Word16 norm_dmx_nrg; Word16 temp_e; Word32 L_temp; #endif /* ACELP -> TCX/HQ core transition */ /* calculate high band energy only */ dmx_nrg = EPSILON_FIX; Loading @@ -3232,8 +3256,34 @@ void stereo_dft_generate_res_pred_fx( dmx_nrg = L_add( dmx_nrg, Madd_32_32( Mpy_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ), pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ); /* 2 * q_dft - 31 */ } #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS norm_dmx_nrg = norm_l( dmx_nrg ); dmx_nrg = L_shl( dmx_nrg, norm_dmx_nrg ); q_dmx_nrg = add( sub( shl( hStereoDft->q_dft, 1 ), 31 ), norm_dmx_nrg ); q_diff = sub( hStereoDft->q_hb_nrg[0], q_dmx_nrg ); /* dmx_nrg * 2 / hStereoDft->NFFT */ L_temp = BASOP_Util_Divide3232_Scale_newton( dmx_nrg, shr( hStereoDft->NFFT, 1 ), &temp_e ); L_temp = L_shr( L_temp, sub( 31, temp_e ) ); IF( GT_16( q_diff, 0 ) ) { hStereoDft->hb_nrg_fx[0] = L_add( L_shr( hStereoDft->hb_nrg_fx[0], q_diff ), L_temp ); move32(); hStereoDft->q_hb_nrg[0] = sub( hStereoDft->q_hb_nrg[0], q_diff ); move16(); } ELSE { hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], L_shl( L_temp, q_diff ) ); move32(); /* hStereoDft->q_hb_nrg[0] stays as is */ } #else hStereoDft->hb_nrg_fx[0] = L_add( hStereoDft->hb_nrg_fx[0], div_l( dmx_nrg, shr( hStereoDft->NFFT, 2 ) ) ); /* Q15 */ move32(); #endif *stop = bin0; move16(); } Loading
lib_dec/ivas_stereo_icbwe_dec_fx.c +14 −1 Original line number Diff line number Diff line Loading @@ -146,6 +146,9 @@ void stereo_icBWE_dec_fx( Word16 icbweM2Ref_fx, ratio_L_fx; Word16 gsMapping_fx; Word32 hb_nrg_fx; #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS Word16 q_hb_nrg; #endif Word16 Q_syn_shb; Word16 shift_prev_pow, synthRef_shift; Word32 L_tmp; Loading Loading @@ -199,6 +202,9 @@ void stereo_icBWE_dec_fx( { hb_nrg_fx = 0; move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS q_hb_nrg = Q31; #endif move32(); maximum_abs_32_fx( synthRef_fx, output_frame, &maxVal ); synthRef_shift = norm_l( maxVal ); Loading Loading @@ -235,7 +241,10 @@ void stereo_icBWE_dec_fx( hCPE->hStereoDft->hb_nrg_subr_fx[1] = W_round48_L( W_tmp ); // 2 * (Qsyn + SynthRef_shift) - 45 hb_nrg_fx = L_add( hCPE->hStereoDft->hb_nrg_subr_fx[0], hCPE->hStereoDft->hb_nrg_subr_fx[1] ); // 2 * (Qsyn + SynthRef_shift) - 45 #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS q_hb_nrg = hStereoDft->q_hb_nrg_subr; move16(); #endif Copy32( synthRef_fx, hCPE->hStereoDft->hb_stefi_sig_fx + hCPE->hStereoDft->hb_stefi_delay, output_frame ); /* Qsynth */ } Loading @@ -254,6 +263,10 @@ void stereo_icBWE_dec_fx( hCPE->hStereoDft->q_hb_nrg_subr = sub( shl( ( *Q_syn + synthRef_shift ), 1 ), 45 + 9 ); hCPE->hStereoDft->hb_nrg_fx[0] = hb_nrg_fx; // 2 * (Qx + SynthRef_shift) - 31 move32(); #ifdef FIX_BASOP_2521_DIRAC_STEREO_STEFFI_NRGS hCPE->hStereoDft->q_hb_nrg[0] = q_hb_nrg; move16(); #endif hCPE->hStereoDft->td_gain_fx[0] = 0; move32(); hCPE->hStereoDft->core_hist[0] = st->core; Loading