Commit abd4149f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh Committed by Fabian Bauer
Browse files

MLD improvements and Q-info updates for lib_enc

parent b3ceced1
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
@@ -228,6 +228,67 @@ void edct_fx(
    return;
}

void edct_ivas_fx(
    const Word32 *x, /* i  : input signal        Qq         */
    Word32 *y,       /* o  : output transform    Qq         */
    Word16 length,   /* i  : length                         Q0*/
    Word16 *q        /* i  : Q value of input signal        */
)
{
    Word16 i;
    const Word16 *edct_table; /*Q16 */
    Word32 re[L_FRAME_PLUS / 2];
    Word32 im[L_FRAME_PLUS / 2];
    Word32 L_tmp;
    Word16 tmp;
    Word16 len1;

    edct_table = get_edct_table( length, q ); /*q*/
    len1 = shr( length, 1 );                  /*Q0*/
                                              /* Twiddling and Pre-rotate */
    FOR( i = 0; i < len1; i++ )
    {
        L_tmp = Mult_32_16( x[2 * i], edct_table[i] );                                                    /*Q(q+1) */
        re[i] = Madd_32_16( L_tmp, x[( length - ( 1 + ( i * 2 ) ) )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
        move32();

        L_tmp = Mult_32_16( x[( length - ( 1 + ( i * 2 ) ) )], edct_table[i] );      /*Q(q+1) */
        im[i] = Msub_32_16( L_tmp, x[( i * 2 )], edct_table[( len1 - ( 1 + i ) )] ); /*Q(q+1) */
        move32();
    }

    *q = sub( 31, *q );
    move16();
    tmp = sub( s_min( getScaleFactor32( re, len1 ), getScaleFactor32( im, len1 ) ), find_guarded_bits_fx( len1 ) );
    scale_sig32( re, len1, tmp );
    scale_sig32( im, len1, tmp );

    fft_fx( re, im, len1, 1 );
    *q = sub( *q, tmp );
    move16();

    tmp = div_s( 4, length );                                         /*Q17 */
    tmp = round_fx( L_mult( tmp, 19302 /*0.75f * EVS_PI in Q13*/ ) ); /*Q15 */
    FOR( i = 0; i < len1; i++ )
    {
        L_tmp = Msub_32_16( re[i], im[i], tmp );
        im[i] = Madd_32_16( im[i], re[i], tmp ); /*Q(q+1) */
        re[i] = L_tmp;                           /*Q(q+1) */
        move32();
        move32();
    }
    FOR( i = 0; i < len1; i++ )
    {
        y[2 * i] = L_add( Mult_32_16( re[i], edct_table[i] ), Mult_32_16( im[i], edct_table[( len1 - ( 1 + i ) )] ) ); /*Q(q+2)*/
        move32();
        y[( length - ( 1 + ( i * 2 ) ) )] = L_sub( Mult_32_16( re[i], edct_table[( len1 - ( 1 + i ) )] ), Mult_32_16( im[i], edct_table[i] ) ); /*Q(q+2)*/
        move32();
    } /*Q(q-2) */

    *q = sub( 31 + 2, *q );
    move16();
    return;
}
/*-------------------------------------------------------------------------*
 * FUNCTION : edst_fx()
 *
+4 −0
Original line number Diff line number Diff line
@@ -2633,7 +2633,11 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                                test();
                                IF( W_norm( re ) == 0 || W_norm( recon_uu_re[i][j] ) == 0 )
                                {
#ifdef FIX_ISSUE_1122
                                    recon_uu_re[i][j] = L_shr( recon_uu_re[i][j], 1 ); // q_recon_uu_re[i][j] - 1
#else
                                    re1[m] = L_shr( re1[m], 1 ); // q_recon_uu_re[i][j]-1
#endif
                                    move32();
                                    q_recon_uu_re[i][j] = sub( q_recon_uu_re[i][j], 1 );
                                    move16();
+1 −0
Original line number Diff line number Diff line
@@ -103,4 +103,5 @@
#define FIX_1110_OPTIM_DIRAC_DECORR_PROC        /* FhG: optimize ivas_dirac_dec_decorr_process() */
#define FIX_1100_REMOVE_LPC_RESCALING           /* VA: Remove the rescaling of LPC coefficient to Q12 as residu and syn-filt are already taking care of it*/

#define FIX_ISSUE_1122                          /* Ittiam: Fix issue 1122: corrected incorrect scaling of a buffer leading to incorrect metadata bits */
#endif
+7 −0
Original line number Diff line number Diff line
@@ -4437,6 +4437,13 @@ void edct_fx(
    Word16 *q        /* i  : Q value of i   signal                  */
);
void edct_ivas_fx(
    const Word32 *x, /* i  : input signal        Qq         */
    Word32 *y,       /* o  : output transform    Qq         */
    Word16 length,   /* i  : length                         Q0*/
    Word16 *q        /* i  : Q value of input signal        */
);
void edst_fx(
    const Word32 *x, /* i  : i   signal         Qq                  */
    Word32 *y,       /* o  : output transform     Qq                  */
+23 −14
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ Word16 EncodeIndex_ivas_fx(
 *
 *-------------------------------------------------------------------*/
static Word16 SearchPeriodicityIndex_Single(
    const Word16 AbsMdct3[],
    const Word16 AbsMdct3[], // Qx
    const Word16 NumToConsider,
    const Word32 Lag,
    const Word16 FractionalResolution )
@@ -131,7 +131,7 @@ static Word16 SearchPeriodicityIndex_Single(
 *
 *-------------------------------------------------------------------*/
static void SearchPeriodicityIndex_Range(
    const Word16 AbsMdct3[],
    const Word16 AbsMdct3[], // Qx
    const Word16 NumToConsider,
    const Word16 Lo,
    const Word16 Hi,
@@ -139,7 +139,8 @@ static void SearchPeriodicityIndex_Range(
    const Word16 Adj,
    const Word16 Spacing,
    Word16 *PeriodicityIndex,
    Word16 *Score )
    Word16 *Score // Q0
)
{
    Word16 Index, BestIndex;
    Word16 CurrentScore, BestScore;
@@ -194,7 +195,7 @@ static void SearchPeriodicityIndex_Range(

    B = add( BestIndex, shr( Spacing, 1 ) );

    FOR( Index = add( BestIndex, 1 ); Index <= B; ++Index )
    FOR( Index = BestIndex + 1; Index <= B; ++Index )
    {
        CurrentScore = SearchPeriodicityIndex_Single(
            AbsMdct3,
@@ -225,7 +226,7 @@ Word16 SearchPeriodicityIndex_fx(
    Word16 NumToConsider,          /* i  : Number of coefficients                                  */
    const Word16 TargetBits,       /* i  : Target bit budget (excl. Done flag)                     */
    const Word16 LtpPitchLag,      /* i  : TCX-LTP pitch                                           */
    const Word16 LtpGain,          /* i  : LTP gain                                                */
    const Word16 LtpGain,          /* i  : LTP gain                                           Q15     */
    Word16 *RelativeScore          /* o  : Energy concentration factor                      (2Q13) */
)
{
@@ -244,11 +245,12 @@ Word16 SearchPeriodicityIndex_fx(
    Word32 tmp32;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    /* Debug init (not instrumented) */
    C = -3000;

    move32();
    PeriodicityIndex = 0;
    move16();
    Score = -1;
@@ -264,18 +266,22 @@ Word16 SearchPeriodicityIndex_fx(
    {
        C = L_shl( L_abs( Mdct[i + 1] ), s );
        AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
        move16();

        A = L_shl( L_abs( Mdct[i + 2] ), s );
        AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
        move16();

        B = L_shl( L_abs( Mdct[i + 3] ), s );
        AbsMdct3[i + 2] = round_fx( L_add( L_add( A, B ), C ) );
        move16();
    }

    IF( LT_16( i, sub( NumToConsider, 1 ) ) )
    {
        C = L_shl( L_abs( Mdct[i + 1] ), s );
        AbsMdct3[i] = round_fx( L_add( L_add( A, B ), C ) );
        move16();
    }

    IF( LT_16( i, sub( NumToConsider, 2 ) ) )
@@ -283,6 +289,7 @@ Word16 SearchPeriodicityIndex_fx(
        A = L_shl( L_abs( Mdct[i + 2] ), s );
        assert( C != -3000 );
        AbsMdct3[i + 1] = round_fx( L_add( L_add( A, B ), C ) );
        move16();
    }

    AbsTotal = L_deposit_l( 0 );
@@ -479,8 +486,8 @@ Word16 SearchPeriodicityIndex_fx(
 *-------------------------------------------------------------------*/

static void PeakFilter(
    const Word32 x[],    /* i  : absolute spectrum                              */
    Word32 y[],          /* O  : filtered absolute spectrum, must not alias x[] */
    const Word32 x[],    /* i  : absolute spectrum   Qx                        */
    Word32 y[],          /* O  : filtered absolute spectrum, must not alias x[] Q(x-4)*/
    const Word16 L_frame /* i  : number of spectral lines                       */
)
{
@@ -491,7 +498,7 @@ static void PeakFilter(

    flen = shr( L_frame, 4 );
    /* m = kPeakElevationThreshold / (float)(2*flen + 1); */
    m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 );
    m = shr( div_s( 8 /*kPeakElevationThreshold Q3*/, add( shl( flen, 1 ), 1 ) ), 3 ); // Q15

    a = L_deposit_l( 0 );
    FOR( i = 0; i < flen; ++i )
@@ -501,14 +508,14 @@ static void PeakFilter(

    FOR( i = 0; i < flen; ++i )
    {
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
        move32();
        a = L_add( a, L_shr( x[i + flen], 4 ) );
    }
    sub( 0, 0 );
    FOR( ; i < L_frame - flen; ++i )
    {
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
        move32();
        a = L_sub( a, L_shr( x[i - flen], 4 ) );
        a = L_add( a, L_shr( x[i + flen], 4 ) );
@@ -516,7 +523,7 @@ static void PeakFilter(

    FOR( ; i < L_frame; ++i )
    {
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) );
        y[i] = L_max( 0, L_sub( L_shr( x[i], 4 ), Mpy_32_16_1( a, m ) ) ); // Q(x-4)
        move32();
        a = L_sub( a, L_shr( x[i - flen], 4 ) );
    }
@@ -598,7 +605,7 @@ static Word32 tcx_hm_get_re(
 *-------------------------------------------------------------------*/

static void tcx_hm_quantize_gain(
    const Word32 x[],        /* i: absolute spectrum                 Q31-e */
    const Word32 x[],        /* i: absolute spectrum                 Q31-x_e */
    const Word16 *x_e,       /* i: absolute spectrum exponent        Q0    */
    const Word32 env[],      /* i: envelope                          Q16   */
    const Word32 lag,        /* i: pitch lag                         Q0    */
@@ -645,6 +652,7 @@ static void tcx_hm_quantize_gain(
    FOR( i = 0; i < L_frame; ++i )
    {
        x16[i] = extract_h( L_shl( x[i], s_x ) );
        move16();
    }

    be = tcx_hm_get_re( x16, *gain, lag, fract_res, p, env, L_frame );
@@ -698,7 +706,8 @@ static void tcx_hm_quantize_gain(
            /* Minimum selection, pe is Q14 */
            IF( LT_32( L_shl( Mpy_32_16_1( e, pe ), 1 ), be ) )
            {
                be = L_add( e, 0 );
                be = e;
                move32();
                *gain_idx = g;
                move16();
                *gain = qGains[s][g];
Loading