Commit 2693e3ff authored by vaillancour's avatar vaillancour
Browse files

Reuse EVS for GENERIC HR

parent 6b28ec96
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -87,5 +87,6 @@

#define TEST_HR
#define REUSE_EVS_ACELP
#define REUSE_EVS_ACELP_SHIFT

#endif
+13 −0
Original line number Diff line number Diff line
@@ -1296,7 +1296,20 @@ ivas_error acelp_core_enc_ivas_fx(
        /*---------------------------------------------------------------*
         * Calculation of LP residual (filtering through A[z] filter)
         *---------------------------------------------------------------*/
#ifdef REUSE_EVS_ACELP_SHIFT // This should be moved outside of ACELP
        {
            Word16 tmp, max;
            max = 0;
            FOR( i = 0; i < st->L_frame; i++ )
            {
                tmp = abs_s( inp[i] );
                max = s_max( max, tmp );
            }

            shift = sub( norm_s( max ), 3 );
            shift = s_min( shift, 0 );
        } 
#endif
        calc_residu_fx( st, inp, res_fx, Aq );
        calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );

+51 −1
Original line number Diff line number Diff line
@@ -182,7 +182,9 @@ void AVQ_encmux_fx(
    Word16 bitsMod, Nsvm1, Nsvm2;
    Word16 unusedbitsFlag;
    Word16 svOrder[NSV_MAX], k, nullVec, dummy_bits;

#ifdef REUSE_EVS_ACELP
    Word16 tmp;
#endif
    test();
    IF( EQ_16( extl, SWB_BWE_HIGHRATE ) || EQ_16( extl, FB_BWE_HIGHRATE ) )
    {
@@ -344,7 +346,19 @@ void AVQ_encmux_fx(
        test();
        test();
        test();
#ifdef REUSE_EVS_ACELP
        tmp = bits;
        move16();
        WHILE( GE_16( tmp, 5 ) )
        {
            tmp = sub( tmp, 5 );
        }
        assert( tmp == bits % 5 );
        IF( EQ_16( avq_bit_sFlag, 2 ) && EQ_16( tmp, 4 ) && GT_16( bits, 8 ) && LT_16( bits, 30 ) && GE_16( k, trgtSvPos ) && LT_16( i, Nsvm1 ) )

#else
        IF( EQ_16( avq_bit_sFlag, 2 ) && EQ_16( s_and( bits, 4 ), 4 ) && GT_16( bits, 8 ) && LT_16( bits, 30 ) && GE_16( k, trgtSvPos ) && LT_16( i, Nsvm1 ) )
#endif
        {
            ordr_esti( sub( Nsv, i ), &trgtSvPos, &svOrder[i], Nsv );
            k = svOrder[i];
@@ -408,8 +422,19 @@ void AVQ_encmux_fx(
    test();
    IF( avq_bit_sFlag > 0 && GT_16( bits, 8 ) )
    {
#ifndef REUSE_EVS_ACELP
        // PMT("code not validated yet")
        bitsMod = s_and( bits, 4 /*bits%5*/ );
#else
        /* bitsMod = bits % 5;*/
        bitsMod = bits;
        move16();
        WHILE( bitsMod >= 5 )
        {
            bitsMod = sub( bitsMod, 5 );
        }
        assert( bitsMod == bits % 5 );
#endif
        i = svOrder[Nsvm1];
        move16();
        IF( NE_16( i, Nsvm1 ) )
@@ -449,7 +474,17 @@ void AVQ_encmux_fx(
            {
                overflow = 0;
                move16();
#ifdef REUSE_EVS_ACELP
                tmp = add( bitsMod, nullVec );
                WHILE( tmp >= 5 )
                {
                    tmp = sub( tmp, 5 );
                }
                assert( tmp == add( bitsMod, nullVec ) % 5 );
                if ( tmp != 0 )
#else
                if ( s_and( add( bitsMod, nullVec ), 4 ) != 0 )
#endif
                {
                    overflow = 1;
                    move16();
@@ -476,7 +511,18 @@ void AVQ_encmux_fx(
            unused_bits = sub( unused_bits, 1 ); /*Stop Bit*/
        }
        /*unused_bits_idx = (int16_t)unused_bits / 5;*/
#ifdef REUSE_EVS_ACELP
        IF( unused_bits >= 0 )
        {
            unused_bits_idx = mult( unused_bits, 6554 /*1/5 in Q15*/ );
        }
        ELSE
        {
            unused_bits_idx = negate( mult( negate( unused_bits ), 6554 /*1/5 in Q15*/ ) );
        }
#else
        unused_bits_idx = mult( unused_bits, 6554 );
#endif
        assert( unused_bits_idx == unused_bits / 5 );
        unusedbitsFlag = 0;
        move16();
@@ -506,7 +552,11 @@ void AVQ_encmux_fx(
        IF( j > 0 )
        {
            /* write the unary code */
#ifdef REUSE_EVS_ACELP
            push_indice( hBstr, nq_ind, u_extract_l( L_sub( L_shl_sat( 1, j ), 1 ) ), j );
#else
            push_indice( hBstr, nq_ind, sub( shl( 1, j ), 1 ), j );
#endif
        }

        IF( nq[i] != 0 )
+20 −1
Original line number Diff line number Diff line
@@ -27,10 +27,18 @@ void corr_xh_fx(
    const Word16 x[], /* i  : target signal                                   Qx*/
    Word16 dn[],      /* o  : correlation between x[] and h[]                 Qdn = Qx+j-1*/
    const Word16 h[]  /* i  : impulse response (of weighted synthesis filter) Q14*/
#ifdef REUSE_EVS_ACELP
    ,
    const Word16 L_subfr /* i  : sub-frame lenght Q0 */
#endif
)
{
    Word16 i, j, k;
#ifdef REUSE_EVS_ACELP
    Word32 L_tmp, y32[2 * L_SUBFR], L_maxloc, L_tot;
#else
    Word32 L_tmp, y32[L_SUBFR], L_maxloc, L_tot;
#endif
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
@@ -42,10 +50,18 @@ void corr_xh_fx(
    FOR( k = 0; k < NB_TRACK; k++ )
    {
        L_maxloc = L_deposit_l( 0 );
#ifdef REUSE_EVS_ACELP
        FOR( i = k; i < L_subfr; i += STEP )
#else
        FOR( i = k; i < L_SUBFR; i += STEP )
#endif
        {
            L_tmp = L_mac( 1L, x[i], h[0] ); /* 1 -> to avoid null dn[] Qx+15*/
#ifdef REUSE_EVS_ACELP
            FOR( j = i; j < L_subfr - 1; j++ )
#else
            FOR( j = i; j < L_SUBFR - 1; j++ )
#endif
            {
                L_tmp = L_mac_o( L_tmp, x[j + 1], h[j + 1 - i], &Overflow ); /*Qx+15*/
            }
@@ -66,7 +82,11 @@ void corr_xh_fx(

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

#ifdef REUSE_EVS_ACELP
    FOR( i = 0; i < L_subfr; i++ )
#else
    FOR( i = 0; i < L_SUBFR; i++ )
#endif
    {
        dn[i] = round_fx( L_shl( y32[i], j ) ); /*Qx+15+j-16*/
    }
@@ -127,7 +147,6 @@ void corr_hh_ivas_fx(
    move16();
    return;
}

void corr_xh_ivas_fx(
    const Word16 x[], /* i  : target signal                                   Qx*/
    const Word16 Qx,
+8 −2
Original line number Diff line number Diff line
@@ -73,8 +73,11 @@ Word16 gaus_encode_fx(
     *----------------------------------------------------------------*/

    /* Correlation between target xn2[] and impulse response h1[] */
#ifdef REUSE_EVS_ACELP
    corr_xh_fx( xn, dn, h1, L_SUBFR );
#else
    corr_xh_fx( xn, dn, h1 );

#endif
    tmp_idx = shr( i_subfr, 6 );
    nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
    move16();
@@ -171,8 +174,11 @@ Word16 gaus_encode_ivas_fx(
     *----------------------------------------------------------------*/

    /* Correlation between target xn2[] and impulse response h1[] */
#ifdef REUSE_EVS_ACELP
    corr_xh_fx( xn, dn, h1, L_SUBFR );
#else
    corr_xh_fx( xn, dn, h1 );

#endif
    tmp_idx = shr( i_subfr, 6 );
    nb_bits = st_fx->acelp_cfg.fixed_cdk_index[tmp_idx]; /* Q0 */
    move16();
Loading