Loading lib_enc/ppp_enc_fx.c +46 −0 Original line number Diff line number Diff line Loading @@ -622,9 +622,11 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X Word16 n, fshift_fx, HalfLag, ab1[MAXLAG_WI], ab2[MAXLAG_WI]; Word32 corr_fx; Word32 maxcorr_fx, wcorr_fx, diff_corr; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif IF( LT_16( X1_fx.lag_fx, X2_fx.lag_fx ) ) { Loading Loading @@ -663,9 +665,15 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat temp = add_sat( temp, temp1 ); //??sat #else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); temp = add_o( temp, temp1, &Overflow ); #endif } temp = sub( 32767, extract_l( L_shr( L_mult( 82, abs_s( n ) ), 1 ) ) ); /* Q15 */ Qcorr = norm_l( corr_fx ); Loading @@ -675,23 +683,40 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X move16(); } #ifdef ISSUE_1867_replace_overflow_libenc temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat #else temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #endif IF( GE_16( Qmaxcorr, Qcorr ) ) { #ifdef ISSUE_1867_replace_overflow_libenc diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat #else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat #else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ #endif } if ( diff_corr > 0 ) { fshift_fx = n; move16(); #ifdef ISSUE_1867_replace_overflow_libenc maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat #else maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif Qmaxcorr = Qcorr; move16(); } Loading Loading @@ -739,9 +764,11 @@ static void LPCPowSpect_fx( Word32 Ltemp, Lw; Word32 Lacc; Word16 tmp, exp; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif FOR( k = 0; k < Nf; k++ ) { Loading Loading @@ -773,9 +800,15 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat #else Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ #endif w = extract_h( Ltemp ); /* w is equivalent cos index */ dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); Loading @@ -797,8 +830,13 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat #else Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ #endif } /* If necessary, we can block-normalize Re and Im to improve precision */ dh = extract_h( Re ); Loading @@ -813,7 +851,11 @@ static void LPCPowSpect_fx( ELSE Lacc = L_mult0( dh, dl ); #ifdef ISSUE_1867_replace_overflow_libenc Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat #else Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif dh = extract_h( Im ); dl = extract_l( Im ); Loading Loading @@ -844,7 +886,11 @@ static void LPCPowSpect_fx( move16(); } Ltemp = L_deposit_h( tmp ); #ifdef ISSUE_1867_replace_overflow_libenc out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat #else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); #endif move16(); /* out[k] = shl(tmp,-exp-8); in Q7 */ Loading lib_enc/pre_proc_fx.c +4 −2 Original line number Diff line number Diff line Loading @@ -127,10 +127,12 @@ void pre_proc_fx( FD_BWE_ENC_HANDLE hBWE_FD = st->hBWE_FD; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif #endif /*------------------------------------------------------------------* Loading Loading @@ -1048,8 +1050,8 @@ void pre_proc_fx( test(); IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { #ifdef ISSUE_1796_replace_shl_o st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); #ifdef ISSUE_1867_replace_overflow_libenc st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat #else st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); #endif Loading lib_enc/pvq_core_enc_fx.c +12 −12 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ void pvq_encode_frame_ivas_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading Loading @@ -333,8 +333,8 @@ void pvq_encode_frame_ivas_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); #ifdef ISSUE_1796_replace_shl_o gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #ifdef ISSUE_1867_replace_overflow_libenc gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif Loading Loading @@ -397,7 +397,7 @@ void pvq_encode_frame_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading Loading @@ -463,8 +463,8 @@ void pvq_encode_frame_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); #ifdef ISSUE_1796_replace_shl_o gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #ifdef ISSUE_1867_replace_overflow_libenc gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif Loading Loading @@ -943,7 +943,7 @@ static void densityIndexSymbolEncode_ivas_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading @@ -955,8 +955,8 @@ static void densityIndexSymbolEncode_ivas_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1796_replace_shl_o angle = shl_sat( angle, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif Loading Loading @@ -1026,7 +1026,7 @@ static void densityIndexSymbolEncode_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading @@ -1038,8 +1038,8 @@ static void densityIndexSymbolEncode_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1796_replace_shl_o angle = shl_sat( angle, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif Loading lib_enc/pvq_encode_fx.c +19 −6 Original line number Diff line number Diff line Loading @@ -60,9 +60,11 @@ static Word16 one_pulse_search( UWord32 UL_left_l, UL_right_l, UL_dummy; Word32 L_tmp; UWord16 u_sgn; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif en_tmp = en_dn_shift; /* dummy assignment to avoid compiler warning for unused parameter */ Loading @@ -85,8 +87,13 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat #else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ #endif corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ Loading Loading @@ -202,9 +209,11 @@ void pvq_encode_ivas_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif L_proj_fac = 4096; Loading Loading @@ -359,12 +368,13 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); Loading Loading @@ -414,9 +424,11 @@ void pvq_encode_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif L_proj_fac = 4096; Loading Loading @@ -571,12 +583,13 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); Loading lib_enc/q_gain2p_fx.c +28 −0 Original line number Diff line number Diff line Loading @@ -145,10 +145,12 @@ static Word16 gain_enc( /* o : quantization pitch index const Word16 *p; const Word16 *t_qua_gain; Word32 L_tmp, dist_min, L_tmp1; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif assert( ( func_type != FUNC_GAIN_ENC_UV ) && ( func_type != FUNC_GAIN_ENC_GACELP_UV ) ); Loading @@ -165,7 +167,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat #else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ #endif move16(); /*----------------------------------------------------------------* * calculate the predicted gain code Loading Loading @@ -377,7 +383,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* Here, we use L_mult0 to compensate the factor 0.5 applied to coeff[1..4] before */ L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS if ( L_tmp1 < 0 ) { Loading @@ -397,13 +407,21 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat #else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ #endif *gain_code = L_tmp; move32(); /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); #ifdef ISSUE_1867_replace_overflow_libenc *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat #else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); #endif move16(); return index; Loading Loading @@ -436,9 +454,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind Word16 index2; const Word16 log2_scale = 16; move16(); #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif pred_nrg_frame = 0; /* to suppress compilation warnings */ g_code2 = 0; /* to suppress compilation warnings */ Loading Loading @@ -595,7 +615,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind } s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif s1 = sub( 15, s1 ); tmp1 = mult_r( mult_r( tmp1, tmp1 ), g_coeff->y2y2 ); Loading @@ -608,7 +632,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind L_tmp1 = L_add( L_tmp, 0 ); s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif s1 = sub( 15, s1 ); c_index2 = 0x7FFF; Loading Loading
lib_enc/ppp_enc_fx.c +46 −0 Original line number Diff line number Diff line Loading @@ -622,9 +622,11 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X Word16 n, fshift_fx, HalfLag, ab1[MAXLAG_WI], ab2[MAXLAG_WI]; Word32 corr_fx; Word32 maxcorr_fx, wcorr_fx, diff_corr; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif IF( LT_16( X1_fx.lag_fx, X2_fx.lag_fx ) ) { Loading Loading @@ -663,9 +665,15 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X FOR( k = 0; k <= HalfLag; k++ ) { #ifdef ISSUE_1867_replace_overflow_libenc corr_fx = L_mac_sat( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat corr_fx = L_mac_sat( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )] ); //??sat temp = add_sat( temp, temp1 ); //??sat #else corr_fx = L_mac_o( corr_fx, ab1[k], C_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); corr_fx = L_mac_o( corr_fx, ab2[k], S_fx[temp % ( 4 * X2_fx.lag_fx )], &Overflow ); temp = add_o( temp, temp1, &Overflow ); #endif } temp = sub( 32767, extract_l( L_shr( L_mult( 82, abs_s( n ) ), 1 ) ) ); /* Q15 */ Qcorr = norm_l( corr_fx ); Loading @@ -675,23 +683,40 @@ static Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE X1_fx, DTFS_STRUCTURE X move16(); } #ifdef ISSUE_1867_replace_overflow_libenc temp1 = round_fx_sat( (Word32) L_shl_sat( corr_fx, Qcorr ) ); /* Q(Qcorr-16) */ //??sat //??sat wcorr_fx = L_mult_sat( temp1, temp ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ //??sat #else temp1 = round_fx_o( (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ), &Overflow ); /* Q(Qcorr-16) */ wcorr_fx = L_mult_o( temp1, temp, &Overflow ); /* Q(Qcorr-16+15+1)=Q(Qcorr) */ #endif IF( GE_16( Qmaxcorr, Qcorr ) ) { #ifdef ISSUE_1867_replace_overflow_libenc diff_corr = L_sub_sat( wcorr_fx, L_shl_sat( maxcorr_fx, sub( Qcorr, Qmaxcorr ) ) ); /* Qcorr */ //??sat //??sat #else diff_corr = L_sub_o( wcorr_fx, L_shl_o( maxcorr_fx, sub( Qcorr, Qmaxcorr ), &Overflow ), &Overflow ); /* Qcorr */ #endif } ELSE { #ifdef ISSUE_1867_replace_overflow_libenc diff_corr = L_sub_sat( L_shl_sat( wcorr_fx, sub( Qmaxcorr, Qcorr ) ), maxcorr_fx ); /* Qmaxcorr */ //??sat //??sat #else diff_corr = L_sub_o( L_shl_o( wcorr_fx, sub( Qmaxcorr, Qcorr ), &Overflow ), maxcorr_fx, &Overflow ); /* Qmaxcorr */ #endif } if ( diff_corr > 0 ) { fshift_fx = n; move16(); #ifdef ISSUE_1867_replace_overflow_libenc maxcorr_fx = (Word32) L_shl_sat( corr_fx, Qcorr ); /* Qcorr */ //??sat #else maxcorr_fx = (Word32) L_shl_o( corr_fx, Qcorr, &Overflow ); /* Qcorr */ #endif Qmaxcorr = Qcorr; move16(); } Loading Loading @@ -739,9 +764,11 @@ static void LPCPowSpect_fx( Word32 Ltemp, Lw; Word32 Lacc; Word16 tmp, exp; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif FOR( k = 0; k < Nf; k++ ) { Loading Loading @@ -773,9 +800,15 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc Re = L_add_sat( Re, Ltemp ); /* Re=1-sum(LPC[i]*cos(Lw)); */ //??sat Ltemp = L_add_sat( Lw, 0x6000 ); /* add 0.75, which is 3pi/2 to convert sin to cos */ //??sat Ltemp = L_shl_sat( Ltemp, 10 ); /* Q25 */ //??sat #else Re = L_add_o( Re, Ltemp, &Overflow ); /* Re=1-sum(LPC[i]*cos(Lw)); */ Ltemp = L_add_o( Lw, 0x6000, &Overflow ); /* add 0.75, which is 3pi/2 to convert sin to cos */ Ltemp = L_shl_o( Ltemp, 10, &Overflow ); /* Q25 */ #endif w = extract_h( Ltemp ); /* w is equivalent cos index */ dl = extract_l( Ltemp ); /* dl is 6 bit left-over for interpolation */ w = s_and( w, 511 ); Loading @@ -797,8 +830,13 @@ static void LPCPowSpect_fx( t1 = add( t1, (Word16) L_shr( Ltemp, 16 ) ); /* t1 is interpolated cos(w) */ Ltemp = L_shr( L_mult( LPC[i], t1 ), 1 ); /* Ltemp in Q27 */ #ifdef ISSUE_1867_replace_overflow_libenc Im = L_sub_sat( Im, Ltemp ); /* Im=sum(LPC[i]*sin(Lw)) */ //??sat Lw = L_add_sat( Lw, freq[k] ); /* Lw=(i+1)*freq[k] */ //??sat #else Im = L_sub_o( Im, Ltemp, &Overflow ); /* Im=sum(LPC[i]*sin(Lw)) */ Lw = L_add_o( Lw, freq[k], &Overflow ); /* Lw=(i+1)*freq[k] */ #endif } /* If necessary, we can block-normalize Re and Im to improve precision */ dh = extract_h( Re ); Loading @@ -813,7 +851,11 @@ static void LPCPowSpect_fx( ELSE Lacc = L_mult0( dh, dl ); #ifdef ISSUE_1867_replace_overflow_libenc Lacc = L_add_sat( L_shr( Lacc, 15 ), L_shr( L_mult_sat( dh, dh ), 1 ) ); /* Lacc=Re*Re */ //??sat //??sat #else Lacc = L_add_o( L_shr( Lacc, 15 ), L_shr( L_mult_o( dh, dh, &Overflow ), 1 ), &Overflow ); /* Lacc=Re*Re */ #endif dh = extract_h( Im ); dl = extract_l( Im ); Loading Loading @@ -844,7 +886,11 @@ static void LPCPowSpect_fx( move16(); } Ltemp = L_deposit_h( tmp ); #ifdef ISSUE_1867_replace_overflow_libenc out[k] = round_fx_sat( L_shl_sat( Ltemp, negate( add( exp, 8 ) ) ) ); //??sat //??sat #else out[k] = round_fx_o( L_shl_o( Ltemp, negate( add( exp, 8 ) ), &Overflow ), &Overflow ); #endif move16(); /* out[k] = shl(tmp,-exp-8); in Q7 */ Loading
lib_enc/pre_proc_fx.c +4 −2 Original line number Diff line number Diff line Loading @@ -127,10 +127,12 @@ void pre_proc_fx( FD_BWE_ENC_HANDLE hBWE_FD = st->hBWE_FD; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif #endif /*------------------------------------------------------------------* Loading Loading @@ -1048,8 +1050,8 @@ void pre_proc_fx( test(); IF( ( ( st->tcxonly == 0 ) || ( EQ_16( st->codec_mode, MODE1 ) ) ) && GT_32( st->input_Fs, 8000 ) ) { #ifdef ISSUE_1796_replace_shl_o st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); #ifdef ISSUE_1867_replace_overflow_libenc st->mem_preemph_enc = shl_sat( new_inp_16k[sub( L_frame_tmp, 1 )], 1 ); //??sat #else st->mem_preemph_enc = shl_o( new_inp_16k[sub( L_frame_tmp, 1 )], 1, &Overflow ); #endif Loading
lib_enc/pvq_core_enc_fx.c +12 −12 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ void pvq_encode_frame_ivas_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading Loading @@ -333,8 +333,8 @@ void pvq_encode_frame_ivas_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); #ifdef ISSUE_1796_replace_shl_o gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #ifdef ISSUE_1867_replace_overflow_libenc gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif Loading Loading @@ -397,7 +397,7 @@ void pvq_encode_frame_fx( Word32 xy_corr, yy_corr; PVQ_ENC_DATA pvq_enc; PVQ_ENC_HANDLE hPVQ = &pvq_enc; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading Loading @@ -463,8 +463,8 @@ void pvq_encode_frame_fx( } tmp = ratio( xy_corr, yy_corr, &exp ); #ifdef ISSUE_1796_replace_shl_o gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); #ifdef ISSUE_1867_replace_overflow_libenc gopt[is] = shl_sat( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ) ); //??sat #else gopt[is] = shl_o( tmp, sub( sub( sub( 14, Q_coefs ), shift ), exp ), &Overflow ); #endif Loading Loading @@ -943,7 +943,7 @@ static void densityIndexSymbolEncode_ivas_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading @@ -955,8 +955,8 @@ static void densityIndexSymbolEncode_ivas_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1796_replace_shl_o angle = shl_sat( angle, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif Loading Loading @@ -1026,7 +1026,7 @@ static void densityIndexSymbolEncode_fx( Word32 sym_freq, cum_freq, tot; Word32 acc; UWord16 lsb; #ifndef ISSUE_1796_replace_shl_o #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); Loading @@ -1038,8 +1038,8 @@ static void densityIndexSymbolEncode_fx( IF( s_and( (Word16) 0xFFFE, density ) != 0 ) /* even */ { angle = atan2_fx( SQRT_DIM_fx[r_dim], SQRT_DIM_fx[l_dim] ); #ifdef ISSUE_1796_replace_shl_o angle = shl_sat( angle, 1 ); #ifdef ISSUE_1867_replace_overflow_libenc angle = shl_sat( angle, 1 ); //??sat #else angle = shl_o( angle, 1, &Overflow ); #endif Loading
lib_enc/pvq_encode_fx.c +19 −6 Original line number Diff line number Diff line Loading @@ -60,9 +60,11 @@ static Word16 one_pulse_search( UWord32 UL_left_l, UL_right_l, UL_dummy; Word32 L_tmp; UWord16 u_sgn; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif en_tmp = en_dn_shift; /* dummy assignment to avoid compiler warning for unused parameter */ Loading @@ -85,8 +87,13 @@ static Word16 one_pulse_search( FOR( i = 0; i < dim; i++ ) /* FOR 3 ops */ { #ifdef ISSUE_1867_replace_overflow_libenc L_tmp_corr = L_shl_sat( L_mac_sat( *L_xy_ptr, 1, x_abs[i] ), corr_up_shift ); /* actual in-loop target value, 2 ops */ //??sat //??sat corr_tmp = round_fx_sat( L_tmp_corr ); /* 1 op */ //??sat #else L_tmp_corr = L_shl_o( L_mac_o( *L_xy_ptr, 1, x_abs[i], &Overflow ), corr_up_shift, &Overflow ); /* actual in-loop target value, 2 ops */ corr_tmp = round_fx_o( L_tmp_corr, &Overflow ); /* 1 op */ #endif corr_sq_tmp = mult( corr_tmp, corr_tmp ); /* CorrSq, is a 16bit for low compelxity cross multiplication 1 op */ L_tmp_en_lc = L_mac( *L_yy_ptr, 1, y[i] ); /*Q1 result , energy may span up to ~14+1(Q1)+1(sign)=16 bits, 1 op */ Loading Loading @@ -202,9 +209,11 @@ void pvq_encode_ivas_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif L_proj_fac = 4096; Loading Loading @@ -359,12 +368,13 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); Loading Loading @@ -414,9 +424,11 @@ void pvq_encode_fx( Word16 neg_gain_norm, shift_tot; Word16 high_pulse_density_flag; PvqEntry entry; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif L_proj_fac = 4096; Loading Loading @@ -571,12 +583,13 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ //??sat xq[i] = round_fx_sat( L_tmp ); /* Q15, array move */ //??sat #else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ #endif move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); Loading
lib_enc/q_gain2p_fx.c +28 −0 Original line number Diff line number Diff line Loading @@ -145,10 +145,12 @@ static Word16 gain_enc( /* o : quantization pitch index const Word16 *p; const Word16 *t_qua_gain; Word32 L_tmp, dist_min, L_tmp1; #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif assert( ( func_type != FUNC_GAIN_ENC_UV ) && ( func_type != FUNC_GAIN_ENC_GACELP_UV ) ); Loading @@ -165,7 +167,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* gain_inov = 1.0f / sqrt((dot_product(code, code, L_SUBFR) + 0.01) / L_SUBFR) */ L_tmp = calc_gain_inov( code, lcode, &L_tmp1, &exp_L_tmp1 ); move16(); #ifdef ISSUE_1867_replace_overflow_libenc *gain_inov = round_fx_sat( L_shl_sat( L_tmp, 15 - 3 ) ); /* gain_inov in Q12 */ //??sat //??sat #else *gain_inov = round_fx_o( L_shl_o( L_tmp, 15 - 3, &Overflow ), &Overflow ); /* gain_inov in Q12 */ #endif move16(); /*----------------------------------------------------------------* * calculate the predicted gain code Loading Loading @@ -377,7 +383,11 @@ static Word16 gain_enc( /* o : quantization pitch index /* Here, we use L_mult0 to compensate the factor 0.5 applied to coeff[1..4] before */ L_tmp = L_add( L_tmp, L_shr( L_mult0( p[2 * i + 0], p[2 * i + 0] ), shr_coeff0 ) ); L_tmp = L_sub( L_tmp, L_shr( L_mult( p[2 * i + 0], coeff1 ), shr_coeff1 ) ); #ifdef ISSUE_1867_replace_overflow_libenc L_tmp1 = L_sub_sat( L_tmp, dist_min ); //??sat #else L_tmp1 = L_sub_o( L_tmp, dist_min, &Overflow ); #endif BASOP_SATURATE_WARNING_ON_EVS if ( L_tmp1 < 0 ) { Loading @@ -397,13 +407,21 @@ static Word16 gain_enc( /* o : quantization pitch index L_tmp = L_mult( g_code, gcode0 ); /* Q11*Q15 -> Q27 */ exp_gcode0 = add( exp_gcode0, -11 ); #ifdef ISSUE_1867_replace_overflow_libenc L_tmp = L_shl_sat( L_tmp, exp_gcode0 ); /* Q27 -> Q16 */ //??sat #else L_tmp = L_shl_o( L_tmp, exp_gcode0, &Overflow ); /* Q27 -> Q16 */ #endif *gain_code = L_tmp; move32(); /* Q16/Q12 => Q5 */ L_tmp = L_deposit_h( BASOP_Util_Divide3216_Scale( L_tmp, *gain_inov, &i ) ); #ifdef ISSUE_1867_replace_overflow_libenc *past_gcode = L_shl_sat( L_tmp, sub( i, 15 - 12 ) ); //??sat #else *past_gcode = L_shl_o( L_tmp, sub( i, 15 - 12 ), &Overflow ); #endif move16(); return index; Loading Loading @@ -436,9 +454,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind Word16 index2; const Word16 log2_scale = 16; move16(); #ifndef ISSUE_1867_replace_overflow_libenc #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); #endif #endif pred_nrg_frame = 0; /* to suppress compilation warnings */ g_code2 = 0; /* to suppress compilation warnings */ Loading Loading @@ -595,7 +615,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind } s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif s1 = sub( 15, s1 ); tmp1 = mult_r( mult_r( tmp1, tmp1 ), g_coeff->y2y2 ); Loading @@ -608,7 +632,11 @@ Word16 gain_enc_uv_fx( /* o : quantization pitch ind L_tmp1 = L_add( L_tmp, 0 ); s1 = norm_l( *gain_code ); #ifdef ISSUE_1867_replace_overflow_libenc tmp1 = round_fx_sat( L_shl( *gain_code, s1 ) ); //??sat #else tmp1 = round_fx_o( L_shl_o( *gain_code, s1, &Overflow ), &Overflow ); #endif s1 = sub( 15, s1 ); c_index2 = 0x7FFF; Loading