diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c index 47249853010147070a1b8649054b253f282e1c57..19c1943986ec2ed08392b2e084348615bc9dea3a 100644 --- a/lib_com/swb_tbe_com.c +++ b/lib_com/swb_tbe_com.c @@ -1554,7 +1554,7 @@ void ScaleShapedSHB_32( Word32 *synSHB_fx, /* i/o: synthesized shb signal Q_inp/Q_new */ Word32 *overlap_fx, /* i/o: buffer for overlap-add Q_inp/Q_new */ const Word16 *subgain_fx, /* i : subframe gain Q15 */ - const Word32 frame_gain_fx, /* i : frame gain Ql*/ + const Word32 frame_gain_fx, /* i : frame gain Q18*/ const Word16 *win_fx, /* i : window Q15 */ const Word16 *subwin_fx, /* i : subframes window Q15 */ Word16 *Q_inp, @@ -1648,9 +1648,10 @@ void ScaleShapedSHB_32( norm_shift = 31; } + norm_shift = s_min( norm_shift, 14 ); norm_shift = sub( norm_shift, 1 ); - *Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); + *Q_new = add( *Q_inp, sub( norm_shift, 13 ) ); // Q_new = Q_inp + min(norm_shift,14) - 14; FOR( i = 0; i < L_SHB_LAHEAD; i++ ) { @@ -1659,20 +1660,20 @@ void ScaleShapedSHB_32( FOR( i = 0; i < l_shb_lahead; i++ ) { - synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Qx + Qn + 18 - 1 - 31 + synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[i] ) ); // Q_new synSHB_fx[i] = L_add( synSHB_fx[i], overlap_fx[i] ); - synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Qx + Qn + 18 - 1 - 31 + synSHB_fx[i + l_shb_lahead] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new } FOR( ; i < l_frame; i++ ) { - synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Qx + Qn + 18 - 1 - 31 + synSHB_fx[i] = Mpy_32_32( mod_syn_fx[i], L_shl( frame_gain_fx, norm_shift ) ); // Q_new } FOR( ; i < l_frame + l_shb_lahead; i++ ) { synSHB_fx[i] = L_shl( synSHB_fx[i], *Q_new - *Q_inp ); - overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Qx + Qn + 18 - 1 - 31 + overlap_fx[i - l_frame] = Mpy_32_32( mod_syn_fx[i], Mpy_32_16_1( L_shl( frame_gain_fx, norm_shift ), win_fx[l_frame + l_shb_lahead - 1 - i] ) ); // Q_new } *Q_inp = *Q_new;