Commit 51c8bd98 authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 16: corr_hh fixes

parent 16f63032
Loading
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -197,6 +197,35 @@ void E_ACELP_conv(
    }
}

void E_ACELP_conv_ivas(
    const Word16 xn2[], /* i */
    const Word16 h2[],  /* i */
    Word16 cn2[]        /* o */
)
{
    Word16 i, k;
    Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
    FOR( k = 0; k < L_SUBFR; k++ )
    {
        /*cn2[k] = xn2[k];     */
        Word64 L_tmp_64;
        L_tmp_64 = W_deposit32_l( L_mult0( xn2[k], 0x800 ) );
        FOR( i = 0; i < k; i++ )
        {
            /*cn2[k]-=cn2[i]*h2[k-i];*/
            L_tmp_64 = W_msu0_16_16( L_tmp_64, cn2[i], h2[k - i] ); /*h2 4Q11*/
        }
        L_tmp = W_sat_l( L_tmp_64 );
#ifdef BASOP_NOGLOB
        cn2[k] = round_fx_o( L_shl_o( L_tmp, 5, &Overflow ), &Overflow );
#else
        cn2[k] = round_fx( L_shl( L_tmp, 5 ) );
#endif
    }
}
void E_ACELP_build_code(
    Word16 nb_pulse,       /* i */
    const Word16 codvec[], /* i */
+45 −12
Original line number Diff line number Diff line
@@ -113,29 +113,62 @@ void corr_xh_ivas_fx(
void corr_hh_ivas_fx(
    const Word16 *h,     /* i  : target signal                                  e(norm_s(h1[0])+1) */
    Word16 *y,           /* o  : correlation between x[] and h[]                Q_new + 1 */
    Word16 *Qy,
    const Word16 L_subfr /* i  : length of the subframe                          */
)
{
    Word16 i, j, scale;
    Word64 s64;
    Word16 i, j, k;
    Word32 L_tmp, y32[L_SUBFR * 2], L_maxloc, L_tot;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif

    Word16 shift = add(norm_s(h[0]), 1);
    scale = sub(sub(15, shift), -2 );
    FOR(i = 0; i < L_subfr; i++)
    /* first keep the result on 32 bits and find absolute maximum */
    L_tot = L_deposit_l(1);

    FOR(k = 0; k < NB_TRACK; k++)
    {
        s64 = 0;
        move16();
        FOR(j = i; j < L_subfr; j++)
        L_maxloc = L_deposit_l(0);
        FOR(i = k; i < L_subfr; i += STEP)
        {
            L_tmp = L_mac(1L, h[i], h[0]); /* 1 -> to avoid null dn[] */ //2*(15 - norm_s(h[0])) - 1
            FOR(j = i; j < L_subfr - 1; j++)
            {
            s64 = W_mac0_16_16(s64, h[j], h[j - i]); // Q_new - 1 + 15 - shift
#ifdef BASOP_NOGLOB
                L_tmp = L_mac_o(L_tmp, h[j + 1], h[j + 1 - i], &Overflow); //2*(15 - norm_s(h[0])) - 1
#else
                L_tmp = L_mac(L_tmp, x[j + 1], h[j + 1 - i]);
#endif
            }

        y[i] = extract_l(W_extract_l(W_shr(s64, scale))); // Q_new + 1
        move16();
            y32[i] = L_tmp;
            move32();
            L_tmp = L_abs(L_tmp);
            L_maxloc = L_max(L_tmp, L_maxloc);
        }
        /* tot += 3*max / 8 */
        L_maxloc = L_shr(L_maxloc, 2);
#ifdef BASOP_NOGLOB
        L_tot = L_add_o(L_tot, L_maxloc, &Overflow);             /* +max/4 */
        L_tot = L_add_o(L_tot, L_shr(L_maxloc, 1), &Overflow); /* +max/8 */
#else
        L_tot = L_add(L_tot, L_maxloc);             /* +max/4 */
        L_tot = L_add(L_tot, L_shr(L_maxloc, 1)); /* +max/8 */
#endif
    }

    return;
    /* Find the number of right shifts to do on y32[] so that    */
    /* 6.0 x sumation of max of dn[] in each track not saturate. */

    j = sub(norm_l(L_tot), 4); /* 4 -> 16 x tot */

    FOR(i = 0; i < L_subfr; i++)
    {
        y[i] = round_fx(L_shl(y32[i], j)); //2*(15 - norm_s(h[0])) - 1 +j - 16
    }

    *Qy = sub(add(shl(sub(15, norm_s(h[0])),1), j), 17);
    return;
}

void corr_xh_ivas_fx2(
+6 −5
Original line number Diff line number Diff line
@@ -493,15 +493,16 @@ Word16 inov_encode_ivas_fx(

        cb_shape_fx( 1, 1, 0, sharpFlag, 0, g1, g2, p_Aq, h2, tilt_code, shr( add( pt_pitch, 26 ), 6 ), 0, L_SUBFR );
        /* h2: Q11, Rw: (Rw_e)Q */
        Word16 Rw_e = E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
        //corr_hh_ivas_fx( h2, Rw, L_subfr); // Q(Rw) = Q11-2
        //Word16 Rw_e = E_ACELP_hh_corr( h2, Rw, L_SUBFR, 3 );
        Word16 Rw_q;
        corr_hh_ivas_fx( h2, Rw, &Rw_q, L_subfr); // Q(Rw) = Q11-2

        E_ACELP_conv( xn2, h2, cn );
        E_ACELP_conv_ivas( xn2, h2, cn ); //Qcn = Qxn2

        /* dn_e -> Rw_e*Q_xn */
        //Scale_sig(Rw, L_SUBFR, sub(5, Rw_e)); //Q9
        Word16 dn_e = E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 );
        Qdn = add(13, dn_e) - sub(5, Rw_e);
        Word16 j = E_ACELP_toeplitz_mul_fx( Rw, cn, dn, L_SUBFR, 1 );
        Qdn = add(add(Q_new - 1 + shift, Rw_q), j + 1);
        //Scale_sig(Rw, L_subfr, -3); //Q9->Q6
    }
    ELSE
+13 −6
Original line number Diff line number Diff line
@@ -2652,6 +2652,12 @@ void E_ACELP_conv(
    Word16 cn2[]        /* o */
);

void E_ACELP_conv_ivas(
    const Word16 xn2[], /* i */
    const Word16 h2[],  /* i */
    Word16 cn2[]        /* o */
);

void gPLC_encInfo_fx(
    PLC_ENC_EVS_HANDLE self,
    const Word32 modeBitrate,
@@ -2853,6 +2859,13 @@ void corr_xh_ivas_fx(
    const Word16 L_subfr /* i  : length of the subframe                          */
);

void corr_hh_ivas_fx(
    const Word16 *h,     /* i  : target signal                                  e(norm_s(h1[0])+1) */
    Word16 *y,           /* o  : correlation between x[] and h[]                Q_new + 1 */
    Word16 *Qy,
    const Word16 L_subfr /* i  : length of the subframe                          */
);

void corr_xh_ivas_fx2(
    const Word16 x[], /* i  : target signal                                   */
    const Word16 Qx,
@@ -2862,12 +2875,6 @@ void corr_xh_ivas_fx2(
    const Word16 L_subfr /* i  : length of the subframe                          */
);

void corr_hh_ivas_fx(
    const Word16 *h,     /* i  : target signal                                  e(norm_s(h1[0])+1) */
    Word16 *y,           /* o  : correlation between x[] and h[]                Q_new + 1 */
    const Word16 L_subfr /* i  : length of the subframe                          */
);

void qlpc_avq_fx(
    const Word16 *lsf,    /* i  : Input LSF vectors             (14Q1*1.28)    */
    const Word16 *lsfmid, /* i  : Input LSF vectors             (14Q1*1.28)    */