Unverified Commit 6df2d3a3 authored by norvell's avatar norvell
Browse files

Update harmonization of mdct_classifier_fx

parent c3d6f9f6
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2720,7 +2720,7 @@ void ivas_param_mc_metadata_open_fx(
    const Word32 ivas_total_brate,                              /* i  : IVAS total bitrate                                  */
    HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC                  /* o  : handle for the Parametric MC parameter coding state */
);
#ifndef HQ_ALIGN_DUPLICATED_CODE

Word16 mdct_classifier_ivas_fx(
    Encoder_State *st,                                          /* i/o: Encoder state variable                  */
    const Word16 *fft_buff,                                     /* i  : FFT spectrum from fft_rel               */
@@ -2728,7 +2728,6 @@ Word16 mdct_classifier_ivas_fx(
    Word16 enerBuffer_exp,                                      /* i: enenrgy buffer exponent                   */
    const Word32 brate                                          /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
);
#endif

/*----------------------------------------------------------------------------------*
 * Range Coder prototypes
+1 −9
Original line number Diff line number Diff line
@@ -191,15 +191,7 @@ void ivas_decision_matrix_enc_fx(
        ELSE
        {
            /* select TCX core or HQ core using bits_frame_nominal to match the TCX configuration bitrate */
#ifdef HQ_ALIGN_DUPLICATED_CODE
            st->core = mdct_classifier_fx( fft_buff,
                                           st,
                                           enerBuffer,
                                           enerBuffer_exp,
                                           L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */
#else
            st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, enerBuffer_exp, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ) ); /* Q0 */
#endif
            move16();
        }
    }
+79 −12
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static void dft_mag_square_fx(
    return;
}


#ifndef HQ_ALIGN_DUPLICATED_CODE
/*-------------------------------------------------------------------*
 * mdct_classifier()
 *
@@ -92,13 +92,8 @@ static void dft_mag_square_fx(
Word16 mdct_classifier_fx(
    const Word16 *fft_buff, /* i  : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */
    Encoder_State *st_fx,   /* i/o: Encoder state variable                  */
#ifdef HQ_ALIGN_DUPLICATED_CODE
    const Word32 *cldfbBuf_Ener, /* i  : Sum array of energy values of CLDFB buffer                       */
    const Word16 enerBuffer_exp, /* i  : Exponent of cldfbBuf_Ener                                        */
#else
    Word32 *cldfbBuf_Ener,  // enerBuffer_exp
    Word16 enerBuffer_exp,
#endif
    const Word32 brate /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
)
{
@@ -509,7 +504,7 @@ Word16 mdct_classifier_fx(

    return clas_final; /* Q0 */
}
#ifndef HQ_ALIGN_DUPLICATED_CODE
#endif
Word16 mdct_classifier_ivas_fx(
    Encoder_State *st,         /* i/o: Encoder state variable                  */
    const Word16 *fft_buff,    /* i  : FFT spectrum from fft_rel               */
@@ -550,7 +545,11 @@ Word16 mdct_classifier_ivas_fx(
    move16();

    test();
#ifdef HQ_ALIGN_DUPLICATED_CODE
    IF( EQ_32( st->input_Fs, 32000 ) || EQ_32( st->input_Fs, 48000 ) || EQ_16( st->element_mode, EVS_MONO ) )
#else
    IF( EQ_32( st->input_Fs, 32000 ) || EQ_32( st->input_Fs, 48000 ) )
#endif
    {
        gain2_start = GAIN2_START_SWB;
        gain3_start = GAIN3_START_SWB;
@@ -764,6 +763,23 @@ Word16 mdct_classifier_ivas_fx(
        }
    }

#ifdef HQ_ALIGN_DUPLICATED_CODE
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        peak_H1 = L_add( enerBuffer[H1_start], 0 );
        Mpy_32_16_ss( enerBuffer[H1_start], 6554 /*0.4.Q15*/, &avrg_H1, &lsb16 );
        FOR( k = 1; k < 5; k++ )
        {
            IF( GT_32( enerBuffer[H1_start + k], peak_H1 ) )
            {
                peak_H1 = L_add( enerBuffer[H1_start + k], 0 );
            }
            avrg_H1 = L_add( avrg_H1, Mult_32_16( enerBuffer[H1_start + k], 6554 /*0.4.Q15*/ ) );
        }
    }
    ELSE
    {
        // Todo (EN): This is introduced for IVAS, but looks strange
        peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp
        move32();

@@ -779,7 +795,42 @@ Word16 mdct_classifier_ivas_fx(
            }
            avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp
        }
    }
#else
    peak_H1 = enerBuffer[H1_start]; // enerBuffer_exp
    move32();

    avrg_H1 = enerBuffer[H1_start]; // enerBuffer_exp
    move32();

    FOR( i = 1; i < H_length; i++ )
    {
        IF( GT_32( enerBuffer[H1_start + i], peak_H1 ) )
        {
            peak_H1 = enerBuffer[H1_start + i]; // enerBuffer_exp
            move32();
        }
        avrg_H1 = L_add( avrg_H1, enerBuffer[H1_start + i] ); // enerBuffer_exp
    }
#endif

#ifdef HQ_ALIGN_DUPLICATED_CODE
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        peak_H2 = L_add( enerBuffer[H2_start], 0 );
        Mpy_32_16_ss( enerBuffer[H2_start], 6554 /*0.4.Q15*/, &avrg_H2, &lsb16 );
        FOR( i = 1; i < H_length; i++ )
        {
            IF( GT_32( enerBuffer[H2_start + i], peak_H2 ) )
            {
                peak_H2 = L_add( enerBuffer[H2_start + i], 0 );
            }
            avrg_H2 = L_add( avrg_H2, Mult_32_16( enerBuffer[H2_start + i], 6554 /*0.4.Q15*/ ) );
        }
    }
    ELSE
    {
        // Todo (EN): This is introduced for IVAS, but looks strange
        peak_H2 = enerBuffer[H2_start];
        move32();

@@ -795,7 +846,24 @@ Word16 mdct_classifier_ivas_fx(
            }
            avrg_H2 = L_add( avrg_H2, enerBuffer[H2_start + i] );
        }
    }
#else
    peak_H2 = enerBuffer[H2_start];
    move32();

    avrg_H2 = enerBuffer[H2_start];
    move32();

    FOR( i = 1; i < H_length; i++ )
    {
        IF( GT_32( enerBuffer[H2_start + i], peak_H2 ) )
        {
            peak_H2 = enerBuffer[H2_start + i];
            move32();
        }
        avrg_H2 = L_add( avrg_H2, enerBuffer[H2_start + i] );
    }
#endif
    peak_l = L_deposit_l( 0 );
    avrg_l = L_deposit_l( 0 );
    peak_h = L_deposit_l( 0 );
@@ -1050,4 +1118,3 @@ Word16 mdct_classifier_ivas_fx(

    return clas_final;
}
#endif
+11 −0
Original line number Diff line number Diff line
@@ -9,6 +9,9 @@
#include "prot_fx.h"     /* Function prototypes                    */
#include "prot_fx_enc.h" /* Function prototypes                    */
#include "basop_util.h"  /* Function prototypes                    */
#ifdef HQ_ALIGN_DUPLICATED_CODE
#include "ivas_prot_fx.h"
#endif


/*-------------------------------------------------------------------*
@@ -785,7 +788,11 @@ void pre_proc_fx(
            IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && EQ_32( st->total_brate, ACELP_32k ) )
            {
                /* Select MDCT Core */
#ifdef HQ_ALIGN_DUPLICATED_CODE
                st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate );
#else
                st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate );
#endif
            }
            test();
            IF( ( EQ_32( st->total_brate, ACELP_13k20 ) ) && ( NE_16( st->bwidth, FB ) ) )
@@ -1226,7 +1233,11 @@ void pre_proc_fx(
                test();
                IF( ( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) && EQ_32( st->total_brate, ACELP_24k40 ) )
                {
#ifdef HQ_ALIGN_DUPLICATED_CODE
                    st->core = mdct_classifier_ivas_fx( st, fft_buff, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate );
#else
                    st->core = mdct_classifier_fx( fft_buff, st, enerBuffer, sub( enerBuffer_exp, 31 ), st->total_brate );
#endif
                }
                test();
                IF( ( EQ_32( st->total_brate, ACELP_16k40 ) ) && ( NE_16( st->bwidth, FB ) ) )
+2 −5
Original line number Diff line number Diff line
@@ -244,19 +244,16 @@ void ivas_long_enr_fx(
    const Word16 Etot_LR[]             /* i  : total channel energy LR channels         Q=8*/
);

#ifndef HQ_ALIGN_DUPLICATED_CODE
/* o: MDCT A/B decision  */
Word16 mdct_classifier_fx(
    const Word16 *Y,      /* i  : re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */
    Encoder_State *st_fx, /* i/o: Encoder state variable                                           */
#ifdef HQ_ALIGN_DUPLICATED_CODE
    const Word32 *cldfbBuf_Ener, /* i  : Sum array of energy values of CLDFB buffer                       */
    const Word16 enerBuffer_exp, /* i  : Exponent of cldfbBuf_Ener                                        */
#else
    Word32 *cldfbBuf_Ener,
    Word16 enerBuffer_exp,
#endif
    const Word32 brate /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate       */
);
#endif

void noise_est_down_fx(
    const Word32 fr_bands[], /* i  : per band i   energy (contains 2 vectors) */