Commit 108ffa09 authored by vaillancour's avatar vaillancour
Browse files

more saturation fixes on decode side

parent 974ce8be
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -252,9 +252,15 @@ Word16 env_stability_fx( /* in Q15 */
#endif

    L_tmp = L_mult0(26214, env_delta); /* 26214 is 0.1 in Q18. Q28 */
#ifdef BASOP_NOGLOB                                /* Critical Overflow */
    L_tmp = L_mac_sat( L_tmp, 29491, *mem_env_delta ); /* 29491 is 0.9 in Q15. Q28 */

    *mem_env_delta = round_fx_sat(L_tmp);   /* Q12 */
#else
    L_tmp = L_mac( L_tmp, 29491, *mem_env_delta ); /* 29491 is 0.9 in Q15. Q28 */

    *mem_env_delta = round_fx(L_tmp);   /* Q12 */
#endif
    Overflow = 0;
move16();
#ifdef BASOP_NOGLOB  /* Critical Overflow */
+12 −3
Original line number Diff line number Diff line
@@ -2442,12 +2442,21 @@ void hq_wb_nf_bwe_fx(
					test();
					test();
					test();
#ifdef BASOP_NOGLOB
                   IF( GT_32( L_abs( L_coeff_out[i] ), L_shl_sat( L_abs( *p_prev_coeff_out ), 2 ) )
						|| LT_32(L_abs(L_coeff_out[i]), L_shr(L_abs(*p_prev_coeff_out), 2))
						|| ((R[sfm] == 0 || *prev_R == 0) && add_sat(R[sfm], *prev_R) != 0))
#else
                   IF( GT_32( L_abs( L_coeff_out[i] ), L_shl( L_abs( *p_prev_coeff_out ), 2 ) )
						|| LT_32(L_abs(L_coeff_out[i]), L_shr(L_abs(*p_prev_coeff_out), 2))
						|| ((R[sfm] == 0 || *prev_R == 0) && add(R[sfm], *prev_R) != 0))
#endif
					{
#ifdef BASOP_NOGLOB
                       L_tmp = L_add_sat( L_shr( L_abs( L_coeff_out[i] ), 1 ), L_shr( L_abs( *p_prev_coeff_out ), 1 ) );
#else
                       L_tmp = L_add( L_shr( L_abs( L_coeff_out[i] ), 1 ), L_shr( L_abs( *p_prev_coeff_out ), 1 ) );

#endif
						if (L_coeff_out[i] <= 0)
						{
							L_tmp = L_negate(L_tmp);
+5 −1
Original line number Diff line number Diff line
@@ -2004,7 +2004,11 @@ void SWB_BWE_decoding_fx(
			FOR(n_freq = add(swb_bwe_subband[0],st_offset); n_freq < tmp2; n_freq++)
			{
				L_tmp1 = Mult_32_16(SWB_signal_32[n_freq], factor);
#ifdef BASOP_NOGLOB
                SWB_signal_32[n_freq] = L_shl_sat( L_tmp1, tmp - 1 );
#else
                SWB_signal_32[n_freq] = L_shl( L_tmp1, tmp - 1 );
#endif
				move32();/*15+Qsyn */
				factor = add(factor, factor1); /*Q3 */
			}
+69 −2
Original line number Diff line number Diff line
@@ -3834,6 +3834,73 @@ void elliptic_bpf_48k_generic_fx(
        memory2_fx_3[j] =L_shl(memory_fx2[3][j],sub(add(add(*Q_input_fx,1) ,Q_temp) ,memory_fx_Q[3]));
#endif
    }
#ifdef BASOP_NOGLOB
    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[sub(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[sub(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[sub( 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[sub( 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[sub( 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[sub( 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[sub( 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[sub( 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]));
    }
#else
    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(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(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*/
@@ -3894,7 +3961,7 @@ void elliptic_bpf_48k_generic_fx(
        L_output[i] = L_sub(L_tmpX,L_shl(Mult_32_16(L_output[sub(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[sub(L_FRAME48k,4)];
    memory_fx2[2][1] = L_tmp2[sub(L_FRAME48k,3)];
    memory_fx2[2][2] = L_tmp2[sub(L_FRAME48k,2)];
+25 −6
Original line number Diff line number Diff line
@@ -3722,8 +3722,11 @@ Word16 abs_iter_fx(Word16 re, Word16 im, Word16 N)
    i = s_min(sub(i,1), 9);
    tmp = abs_s(re);
    /*A = round_fx(L_shr(L_mult(tmp, cor[i]), exp)); //this can be ommited, if we don't need the exact abs value */
#ifdef BASOP_NOGLOB
    A = shr_sat( tmp, exp );
#else
    A = shr( tmp, exp );

#endif
    return A;
}
/*--------------------------------------------------------------------------
@@ -3984,7 +3987,11 @@ void singenerator_fx(

    ptr = xx;

#ifdef BASOP_NOGLOB
    *ptr = L_add_sat( *ptr, L_C0 );
#else
    *ptr = L_add( *ptr, L_C0 );
#endif
    move32();
    ptr++;

@@ -3995,7 +4002,11 @@ void singenerator_fx(
        L_C1 = L_msu(L_C1, S0, sinfreq); /*Qin+16 */
        L_S1 = L_mult(C0, sinfreq);
        S1 = mac_r(L_S1, S0, cosfreq);
#ifdef BASOP_NOGLOB
        *ptr = L_add_sat( *ptr, L_C1 );
#else
        *ptr = L_add( *ptr, L_C1 );
#endif
        move32(); /*Qin+16 */
        ptr++;

@@ -4004,7 +4015,11 @@ void singenerator_fx(
        L_C0 = L_msu(L_C0, S1, sinfreq);
        L_S0 = L_mult(C1, sinfreq);
        S0 = mac_r(L_S0, S1, cosfreq);
#ifdef BASOP_NOGLOB
        *ptr = L_add_sat( *ptr, L_C0 );
#else
        *ptr = L_add( *ptr, L_C0 );
#endif
        move32();
        ptr++;
    }
@@ -4013,7 +4028,11 @@ void singenerator_fx(
    S0 = extract_h(L_S0);
    L_C1 = L_mult(C0, cosfreq);
    L_C1 = L_msu(L_C1, S0, sinfreq);
#ifdef BASOP_NOGLOB
    *ptr = L_add_sat( *ptr, L_C1 );
#else
    *ptr = L_add( *ptr, L_C1 );
#endif
    move32();
    ptr++;

Loading