Commit 5f616350 authored by vaillancour's avatar vaillancour
Browse files

fix issue with rescaling inside adpt_enr_fx()

parent 3b7dfbef
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -167,7 +167,33 @@ Word32 Pow2( /* (o) Q0 : result (range: 0<=v
 |       dot_product = sum(x[i]*y[i])     i=0..N-1                           |
 |___________________________________________________________________________|
*/
#ifdef BASOP_NOGLOB
Word32 Dot_product12_o(   /* (o) Q31: normalized result (1 < val <= -1) */
    const Word16 x[],  /* (i) 12bits: x vector                       */
    const Word16 y[],  /* (i) 12bits: y vector                       */
    const Word16 lg,   /* (i)    : vector length                     */
    Word16* exp,       /* (o)    : exponent of result (0..+30)       */
    Flag* Overflow_out /* o :  propagating the Overflow flag to upper level */
)
{
    Word16 i, sft;
    Word32 L_sum;

    L_sum = L_mac(1, x[0], y[0]);
    FOR(i = 1; i < lg; i++)
    {
        L_sum = L_mac_o(L_sum, x[i], y[i], Overflow_out);
    }
    /* Normalize acc in Q31 */

    sft = norm_l(L_sum);
    L_sum = L_shl(L_sum, sft);

    *exp = sub(30, sft);                   move16();  /* exponent = 0..30 */

    return L_sum;
}
#endif
Word32 Dot_product12(                      /* (o) Q31: normalized result (1 < val <= -1) */
     const Word16 x[],                     /* (i) 12bits: x vector                       */
     const Word16 y[],                     /* (i) 12bits: y vector                       */
+10 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 *--------------------------------------------------------------------------*/
#include "oper_32b.h"
#include "log2.h"
#include "stl.h"

Word32 Isqrt(           /* (o) Q31 : output value (range: 0<=val<1)         */
     Word32 L_x         /* (i) Q0  : input value  (range: 0<=val<=7fffffff) */
@@ -18,13 +19,21 @@ Word32 Pow2( /* (o) Q0 : result (range: 0<=val<=0x7fffffff) */
     Word16 exponant,   /* (i) Q0  : Integer part.      (range: 0<=val<=30)   */
     Word16 fraction    /* (i) Q15 : Fractionnal part.  (range: 0.0<=val<1.0) */
);
#ifdef BASOP_NOGLOB
Word32 Dot_product12_o(   /* (o) Q31: normalized result (1 < val <= -1) */
    const Word16 x[],  /* (i) 12bits: x vector                       */
    const Word16 y[],  /* (i) 12bits: y vector                       */
    const Word16 lg,   /* (i)    : vector length                     */
    Word16* exp,       /* (o)    : exponent of result (0..+30)       */
    Flag* Overflow_out /* o :  propagating the Overflow flag to upper level */
);
#endif
Word32 Dot_product12(   /* (o) Q31: normalized result (1 < val <= -1) */
     const Word16 x[],  /* (i) 12bits: x vector                       */
     const Word16 y[],  /* (i) 12bits: y vector                       */
     const Word16 lg,   /* (i)    : vector length                     */
     Word16 * exp       /* (o)    : exponent of result (0..+30)       */
);

Word32 Energy_scale(    /* (o) Q31: normalized result (1 < val <= -1) */
     const Word16 x[],  /* (i) 12bits: x vector                       */
     const Word16 lg,   /* (i)  : vector length                       */
+7 −0
Original line number Diff line number Diff line
@@ -3988,7 +3988,11 @@ Word16 var_fx( /* o: variance of vector Qx*/
    const Word16 Qx,
    const Word16 len          /* i: length of inputvector                 */
);
#ifdef BASOP_NOGLOB
Flag conv_fx(
#else
void conv_fx(
#endif
    const Word16 x[],   /* i  : i   vector                              Q_new*/
    const Word16 h[],   /* i  : impulse response (or second i   vector) Q(15)*/
    Word16 y[],   /* o  : output vetor (result of convolution)      12 bits*/
@@ -4138,6 +4142,9 @@ Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) *
    Word16 g_corr[],    /* o  : correlations <y1,y1>  and -2<xn,y1>   */
    const Word16 L_subfr,     /* i  : vector length                          */
    const Word16 norm_flag        /* i  : flag for constraining pitch contribution */
#ifdef BASOP_NOGLOB
    , Flag* Overflow_out     /* o :  propagating the Overflow flag to upper level */
#endif
);
void updt_tar_fx(
+18 −1
Original line number Diff line number Diff line
@@ -862,7 +862,11 @@ Word32 var_fx_32( /* o: variance of vector Qx+
 * convolution are considered.
 *-------------------------------------------------------------------*/

#ifdef BASOP_NOGLOB
Flag conv_fx(
#else
void conv_fx(
#endif
    const Word16 x[],   /* i  : input vector                              Q_new*/
    const Word16 h[],   /* i  : impulse response (or second input vector) Q(15)*/
    Word16 y[],   /* o  : output vetor (result of convolution)      12 bits*/
@@ -872,7 +876,9 @@ void conv_fx(

    Word16 i, n;
    Word32 L_sum;

#ifdef BASOP_NOGLOB
    Flag Overflow = 0;
#endif
    y[0] = mult_r(x[0], h[0]);
    move16();
    FOR (n = 1; n < L; n++)
@@ -880,11 +886,22 @@ void conv_fx(
        L_sum = L_mult(x[0], h[n]);
        FOR (i = 1; i < n; i++)
        {
#ifdef BASOP_NOGLOB
            L_sum = L_mac_o(L_sum, x[i], h[n - i], &Overflow);
#else
            L_sum = L_mac(L_sum, x[i], h[n - i]);
#endif
        }
#ifdef BASOP_NOGLOB
        y[n] = mac_ro(L_sum, x[i], h[0], &Overflow);
#else
        y[n] = mac_r(L_sum, x[i], h[0]);
#endif
        move16();
    }
#ifdef BASOP_NOGLOB
    return Overflow;
#endif
}

Word16 var_fx(                /* o: variance of vector                    Qx*/
+4 −1
Original line number Diff line number Diff line
@@ -372,8 +372,11 @@ void transf_cdbk_enc_fx(
        updt_tar_HR_fx( cn, cn, code_preQ, *gain_preQ, sub(Q_new, add(-15+2,Q_AVQ_OUT_DEC)), L_SUBFR );

        updt_tar_HR_fx( xn, xn, x_tran, *gain_preQ, sub(Q_new, add(-15+2,Q_AVQ_OUT_DEC)), L_SUBFR );
#ifdef BASOP_NOGLOB
        *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0, &Overflow );
#else
        *gain_pit = corr_xy1_fx( xn, y1, g_corr, L_SUBFR, 0 );

#endif
        /* clip gain if necessary to avoid problems at decoder */
        test();
        if( EQ_16(clip_gain,1)&&GT_16(*gain_pit,15565))
Loading