Commit 9ee3e525 authored by vaillancour's avatar vaillancour
Browse files

adding basop sat for signal with extreme saturation

parent 78b45a03
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -2290,8 +2290,11 @@ void ton_ene_est_fx(
		exp_pow = sub(14, temp_hi_fx);
		L_band_energy_Linear[i] = Pow2(14, temp_lo_fx);
		move32();      /* Qexp_pow */
#ifdef BASOP_NOGLOB
        L_band_energy_Linear[i] = L_shl_sat( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) );
#else
        L_band_energy_Linear[i] = L_shl( L_band_energy_Linear[i], sub( *QbeL, exp_pow ) );

#endif
		/* Div Part */
		E_r_fx = 0x7fff;
		move16();
@@ -2584,16 +2587,22 @@ void Gettonl_scalfact_fx
			exp_pow = sub(14, temp_hi_fx);
			L_band_energy_Linear[band_pos_fx] = Pow2(14, temp_lo_fx);
			move32();      /* Qexp_pow */
#ifdef BASOP_NOGLOB
            L_band_energy_Linear[band_pos_fx] = L_shl_sat( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) );
#else
            L_band_energy_Linear[band_pos_fx] = L_shl( L_band_energy_Linear[band_pos_fx], sub( QbeL, exp_pow ) );

#endif
			/* Div Part */
			exp_normd = norm_l(L_be_tonal[band_pos_fx]);
			exp_normd = sub(exp_normd, 1);
			exp_normn = norm_l(L_band_energy_Linear[band_pos_fx]);
			temp_fx = div_l(L_shl(L_be_tonal[band_pos_fx], exp_normd), extract_h(L_shl(L_band_energy_Linear[band_pos_fx], exp_normn))); /* QbeL+exp_normd-(QbeL+exp_normn-16)-1 */
			sqrt_32n_16_fx(L_deposit_h(temp_fx), add(sub(exp_normd, exp_normn), 31), &temp_fx, &Qtemp);
#ifdef BASOP_NOGLOB
            enrd_r_fx = extract_h( L_shl_sat( L_mult( enrd_r_fx, temp_fx ), sub( 15, Qtemp ) ) );
#else
            enrd_r_fx = extract_h( L_shl( L_mult( enrd_r_fx, temp_fx ), sub( 15, Qtemp ) ) );

#endif
			enrd_r_fx = sub(enrd_r_fx, step_fx);
		}
		ELSE
+5 −1
Original line number Diff line number Diff line
@@ -123,7 +123,11 @@ void AVQ_cod_fx( /* o: comfort noise gain factor */
    /* estimated gain (when offset=0, estimated gain=1) */
    f_tmp = L_Extract_lc(Ltmp, &e_tmp);
    tmp16 = extract_l(Pow2(14, f_tmp));
#ifdef BASOP_NOGLOB
    Lgain = L_shl_sat( tmp16, e_tmp );
#else
    Lgain = L_shl( tmp16, e_tmp );
#endif
    /* gain_inv = 1.0f / gain */
    e_tmp = norm_l(Lgain);
    tmp16 = extract_h(L_shl(Lgain, e_tmp));
+2 −1
Original line number Diff line number Diff line
@@ -387,10 +387,11 @@ Word16 coder_acelp_fx( /* o : SEGSNR for CL decision */
#endif

            Ltmp2 = Mpy_32_16_1(gain_code, code[i]);
            Ltmp2 = L_shl(Ltmp2, Q_new_p5);
#ifdef BASOP_NOGLOB
            Ltmp2 = L_shl_sat( Ltmp2, Q_new_p5 );
            Ltmp = L_add_sat( Ltmp, Ltmp2 );
#else
            Ltmp2 = L_shl( Ltmp2, Q_new_p5 );
            Ltmp = L_add( Ltmp, Ltmp2 );
#endif
#ifdef BASOP_NOGLOB
+12 −2
Original line number Diff line number Diff line
@@ -222,8 +222,13 @@ void transf_cdbk_enc_fx(
            index = usquant_fx( stmp, &stmp, G_AVQ_MIN_INACT_Q12, G_AVQ_DELTA_INACT_Q12>>1, (1 << G_AVQ_BITS) );
        }
        Ltmp = Mult_32_16(gain_code,stmp);   /* Q16 * Q12 - 15 -> Q13*/
#ifdef BASOP_NOGLOB
        Ltmp = L_shl_sat( Ltmp, 5 );       /* Q13 -> Q18*/
        *gain_preQ = round_fx_sat(Ltmp);           /* Q2*/
#else
        Ltmp = L_shl( Ltmp, 5 );       /* Q13 -> Q18*/
        *gain_preQ = round_fx(Ltmp);           /* Q2*/
#endif
    }
    ELSE
    {
@@ -477,8 +482,13 @@ Word16 gain_quant_fx( /* o: quantization index */
    /*tmp1 = sub(c_max,c_min); Q14*/
    /*tmp2 = sub(c_gain,c_min); Q14*/

#ifdef BASOP_NOGLOB
    tmp1 = msu_r_sat( L_deposit_h( c_max /*in Q13 already*/ ), c_min, 16384 );  /*Q13*/
    tmp2 = msu_r_sat(L_deposit_h(c_gain/*in Q13 already*/),c_min,16384); /*Q13*/
#else
    tmp1 = msu_r( L_deposit_h( c_max /*in Q13 already*/ ), c_min, 16384 );  /*Q13*/
    tmp2 = msu_r(L_deposit_h(c_gain/*in Q13 already*/),c_min,16384); /*Q13*/
#endif
    IF(tmp1 != 0)
    {
        exp = norm_s(tmp1);
+7 −2
Original line number Diff line number Diff line
@@ -469,10 +469,15 @@ static Word16 WB_BWE_fenv_q_fx( /* o: quantized gain index */
        dist = L_deposit_l(0);
        FOR (j=0; j<cb_dim; j++)
        {
#ifdef BASOP_NOGLOB
            tmp = sub_sat( x[j], *pit );     /*Q10 */
            L_tmp = L_mult0(tmp, tmp);/*Q(10+10)->Q20 */
            dist = L_add_sat(dist, L_tmp);
#else
            tmp = sub( x[j], *pit );     /*Q10 */
            L_tmp = L_mult0(tmp, tmp);/*Q(10+10)->Q20 */
            dist = L_add(dist, L_tmp);

#endif
            pit++;
        }

Loading