Skip to content
......@@ -172,10 +172,11 @@ 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]; /*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
......@@ -617,6 +618,8 @@ extern const Word16 Hilbert_coeffs_fx[4 * NUM_HILBERTS][HILBERT_ORDER1 + 1]; //
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
......
......@@ -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];
......
......@@ -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 */
}
}
......
......@@ -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 */
};
......@@ -618,8 +619,11 @@ typedef struct cldfb_filter_bank_struct
Word16 da; /* delay analysis */
CLDFB_PROTOTYPE prototype;
const Word16 *p_filter; /*!< Pointer to filter coefficients */ // Q15
#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
......
......@@ -242,13 +242,25 @@ 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 do not multiply L_tmp by 3 to avoid overflow */
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 */
L_tmp = L_mult0( tmp1, WB_fenv[0] ); /*Q6 */
#endif
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();
......
......@@ -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 );
......@@ -6365,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 */
......@@ -6382,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] ) );
......@@ -6413,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++ )
......@@ -6450,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++ )
{
......@@ -6469,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; )
......@@ -6505,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; )
{
......@@ -6539,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];
......@@ -6607,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++ )
......@@ -6629,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++ )
{
......@@ -6646,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 );
......@@ -6721,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] ) );
......@@ -6730,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++ )
......@@ -6762,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++ )
{
......@@ -6783,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];
......@@ -6914,20 +6685,12 @@ 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
#ifdef FIX_1439_SPEEDUP_SIMPLIFY_elliptic_bpf_48k_generic_STAGE2
,
int16_t element_mode
#endif
)
Word16 Qout,
int16_t element_mode )
{
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;
......@@ -6952,33 +6715,22 @@ 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 );
L_tmp = L_max( 1, fb_exc_energy ); /*Q(2*Q_fb_exc + 1)*/
......@@ -6987,9 +6739,33 @@ void synthesise_fb_high_band_fx(
tmp1 = sub( add( Q_fb_exc, Q_fb_exc ), 8 ); /* 1-9*/
exp = sub( sub( 31, tmp1 ), exp );
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 ) )
......@@ -7301,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 */
......
......@@ -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
*-----------------------------------------------------------------------*/
......
......@@ -1207,8 +1207,13 @@ static Word32 FIRLattice(
move32();
FOR( i = 0; i < order - 1; i++ )
{
#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*/
......@@ -1216,7 +1221,11 @@ static Word32 FIRLattice(
}
/* 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*/
#endif
state[order - 1] = tmpSave; /*Q0*/
move32();
......
......@@ -687,7 +687,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 );
......@@ -717,7 +721,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 );
......@@ -776,7 +784,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 */
......@@ -794,7 +801,6 @@ void v_sub_fixed_no_hdrm(
return;
}
#endif /* VEC_ARITH_OPT_v1 */
/*-------------------------------------------------------------------*
* v_multc_fixed()
......
......@@ -798,7 +798,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 )
......@@ -820,15 +819,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(
......@@ -3134,7 +3124,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();
}
}
......@@ -3142,7 +3136,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_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
move16();
}
}
......@@ -4580,7 +4578,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 */
......@@ -4598,7 +4595,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 */
......
......@@ -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;
......
......@@ -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 )] );
......
......@@ -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 );
......@@ -1434,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. */
}
}
......@@ -2132,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 ) )
{
......
......@@ -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*/
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
*------------------------------------------------------------*/
......
......@@ -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
......@@ -2326,6 +2269,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 = Q15;
move16();
}
}
test();
......@@ -2341,9 +2289,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();
}
}
......
......@@ -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 ) );
......@@ -921,9 +906,14 @@ static void decod_gen_voic_core_switch_fx(
/*--------------------------------------------------------------*
* Find the adaptive codebook vector.
*--------------------------------------------------------------*/
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 +981,14 @@ static void decod_gen_voic_core_switch_fx(
/*-----------------------------------------------------------------*
* long term prediction on the 2nd sub frame
*-----------------------------------------------------------------*/
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++ )
......
......@@ -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();
......@@ -2090,6 +2105,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();
......
......@@ -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 );
......
......@@ -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*/
......
......@@ -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
......