Commit c4bc4474 authored by multrus's avatar multrus
Browse files

[cleanup] accept OPT_BE_2311_HARM_GSC_GAIN

parent 01232dd2
Loading
Loading
Loading
Loading
+0 −164
Original line number Diff line number Diff line
@@ -967,164 +967,6 @@ Word16 gsc_gainQ_ivas_fx(
    return mean_4g_fx[0];
}
#endif
#ifndef OPT_BE_2311_HARM_GSC_GAIN
/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_fx()                                       */
/*--------------------------------------------------------------------------*/
/* PURPOSE  :  Generic signal frequency band decoding and application       */
/*--------------------------------------------------------------------------*/
/*    INPUT ARGUMENTS :                                                     */
/* _ (Word16) pvq_bits_fx      : core used                  Q0              */
/* _ (Word16) coder_type       : coding type                Q0              */
/* _ (Word16) core_fx          : core used                  Q0              */
/* _ (Word16) bwidth_fx        : input signal bandwidth     Q0              */
/*--------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                       */
/* _ (Word16[]) y_gainQ_fx     : quantized gain per band                    */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :                                                 */
/* _ (Word16[]) old_y_gain_fx  : AR gain quantizer for low rate             */
/*--------------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                       */
/* _ (Word16)                  : average frequency gain                     */
/*==========================================================================*/
Word16 gsc_gaindec_fx(                             /* o  : average frequency gain    */
                       Decoder_State *st_fx,       /* i/o: decoder state structure   */
                       Word16 y_gainQ_fx[],        /* o  : quantized gain per band   */
                       const Word32 core_brate_fx, /* i  : core used                 */
                       Word16 old_y_gain_fx[],     /* i/o: AR gain quantizer for low rate */
                       const Word16 coder_type,    /* i  : coding type               */
                       const Word16 bwidth_fx      /* i  : input signal bandwidth    */
)
{
    Word16 idx_g_fx, i;
    Word16 mean_4g_fx;
    Word16 y_gain_tmp3_fx[MBANDS_GN];

    test();
    test();
    IF( ( EQ_16( coder_type, AUDIO ) || ( coder_type == INACTIVE ) ) && EQ_16( bwidth_fx, NB ) )
    {
        idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
        VDQ_vec_fx( &mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );

        idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
        VDQ_vec_fx( y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );

        IF( LT_32( core_brate_fx, ACELP_9k60 ) )
        {
            idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 5 ) );
            VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3 );

            idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 4 ) );
            VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4 );
        }
        ELSE
        {
            idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 6 ) );
            VDQ_vec_fx( y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );

            idx_g_fx = (Word16) ( get_next_indice_fx( st_fx, 7 ) );
            VDQ_vec_fx( y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
        }
        test();
        IF( LE_32( core_brate_fx, ACELP_9k60 ) && ( coder_type == INACTIVE ) )
        {
            /* Some energy is needed in high band for stat_noise_uv_enc
              to be functional in inactive speech */
            y_gainQ_fx[10] = mean_fx( y_gainQ_fx + 6, 3 );
            move16();
            y_gainQ_fx[11] = mean_fx( y_gainQ_fx + 7, 3 );
            move16();
            y_gainQ_fx[12] = mean_fx( y_gainQ_fx + 8, 3 );
            move16();
            y_gainQ_fx[13] = mean_fx( y_gainQ_fx + 9, 3 );
            move16();
            y_gainQ_fx[14] = mean_fx( y_gainQ_fx + 10, 3 );
            move16();
            y_gainQ_fx[15] = mean_fx( y_gainQ_fx + 11, 3 );
            move16();
        }
        ELSE
        {
            set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 );
        }
    }
    ELSE
    {
        idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );

        VDQ_vec_fx( &mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );

        IF( LE_32( core_brate_fx, ACELP_9k60 ) )
        {
            /*--------------------------------------------------------------------------------------*
             * UQ of the first 8 bands and half of the last 8 bands
             *--------------------------------------------------------------------------------------*/
            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
            VDQ_vec_fx( y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );

            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
            VDQ_vec_fx( y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4 );

            /*----------------------------------------------------------------------*
             * Interpolation of the last 4 Q bands to create bands 8-16
             * And scaling
             *----------------------------------------------------------------------*/

            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );

            VDQ_vec_fx( y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5 );

            Copy( y_gainQ_fx + 8, y_gain_tmp3_fx, 4 );
            set16_fx( y_gainQ_fx + 12, 0, 4 );

            fft_rel_fx( y_gainQ_fx + 8, 4, 2 );

            y_gainQ_fx[15] = y_gainQ_fx[11];
            move16();
            y_gainQ_fx[11] = 0;
            move16();
            ifft_rel_fx( y_gainQ_fx + 8, 8, 3 );
            FOR( i = 8; i < 16; i++ )
            {
                y_gainQ_fx[i] = round_fx( L_shl( L_mult( y_gainQ_fx[i], 23101 ), 1 ) ); /*Q12 */
                move16();
            }
            /*----------------------------------------------------------------------*
             * Copy the true Q values in the specific bands
             *----------------------------------------------------------------------*/
            y_gainQ_fx[8] = y_gain_tmp3_fx[0];
            move16();
            y_gainQ_fx[10] = y_gain_tmp3_fx[1];
            move16();
            y_gainQ_fx[12] = y_gain_tmp3_fx[2];
            move16();
            y_gainQ_fx[14] = y_gain_tmp3_fx[3];
            move16();
        }
        ELSE
        {
            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
            VDQ_vec_fx( y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );

            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
            VDQ_vec_fx( y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4 );

            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
            VDQ_vec_fx( y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4 );

            idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
            VDQ_vec_fx( y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4 );
        }
    }

    /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
    GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );

    return mean_4g_fx;
}
#endif

/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_ivas_fx()                                  */
@@ -1147,12 +989,8 @@ Word16 gsc_gaindec_fx( /* o : average frequency gai
/* _ (Word16)                    : average frequency gain                   */
/*==========================================================================*/

#ifndef OPT_BE_2311_HARM_GSC_GAIN
Word16 gsc_gaindec_ivas_fx( /* o  : average frequency gain    */
#else
/*! r: average frequency gain    */
Word16 gsc_gaindec_fx(
#endif
                            Decoder_State *st_fx,       /* i/o: decoder state structure         */
                            Word16 y_gainQ_fx[],        /* o  : quantized gain per band     Q12 */
                            const Word32 core_brate_fx, /* i  : core used                       */
@@ -1325,13 +1163,11 @@ Word16 gsc_gaindec_fx(
    }

#ifndef OPT_NBE_2311_HARM_GSC_GAIN
#ifdef OPT_BE_2311_HARM_GSC_GAIN
    IF( st_fx->element_mode == EVS_MONO )
    {
        GSC_gain_adj( coder_type, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
    }
    ELSE
#endif
    {
        /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
        GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@
#define FIX_1904_HARM_GSC_ENC                           /* VA: #1904 Harmonization of EVS and IVAS GSC code */
#define FIX_1478_UNINIT_ON_BFI                          /* VA: Fix issue 1478 where a vector is partly un-initialized during bfi */
#define FIX_2318_CLANG_DECODER                          /* VA: basop issue 2318: Initialize command-line parameter arg.non_diegetic_pan_gain_fx */
#define OPT_BE_2311_HARM_GSC_GAIN                       /* VA: issue 2311: BE part of the GSC gain harmonization pipeline #70380 shows the BE */
#define HARM_CORECODER_UPDT                             /* VA: basop issue 2342: Remove duplicated code in core-coder common update functions */
#define HARM_CORE_SW                                    /* VA: basop issue 2314: Remove duplicated code in the core switching */
#define HARM_PREPROC                                    /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX  */
+0 −11
Original line number Diff line number Diff line
@@ -1504,17 +1504,6 @@ Word16 gsc_gaindec_fx(
    const Word16 bwidth_fx      /* i  : i   signal bandwidth      */
);
#ifndef OPT_BE_2311_HARM_GSC_GAIN
/*! r: average frequency gain    */
Word16 gsc_gaindec_ivas_fx(
    Decoder_State *st_fx,       /* i/o: decoder state structure   */
    Word16 y_gainQ_fx[],        /* o  : quantized gain per band   */
    const Word32 core_brate_fx, /* i  : core used                 */
    Word16 old_y_gain_fx[],     /* i/o: AR gain quantizer for low rate */
    const Word16 coder_type,    /* i  : coding type               */
    const Word16 bwidth_fx      /* i  : input signal bandwidth    */
);
#endif
#ifndef OPT_NBE_2311_HARM_GSC_GAIN
Word16 gsc_gainQ_fx(
    BSTR_ENC_HANDLE hBstr,   /* i/o: bitstream handle                   */
+0 −11
Original line number Diff line number Diff line
@@ -667,18 +667,7 @@ void gsc_dec_fx(
            i--;
        }

#ifndef OPT_BE_2311_HARM_GSC_GAIN
        IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
        {
            mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
        }
        ELSE
        {
            mean_gain = gsc_gaindec_ivas_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
        }
#else
        mean_gain = gsc_gaindec_fx( st_fx, Ener_per_bd_iQ, brate_intermed_tbl[i], hGSCDec->old_y_gain_fx, coder_type, st_fx->bwidth ); /* Q3 */
#endif

        st_fx->lp_gainc_fx = mult_r( 640, mean_gain ); /*10 in Q6 x Q12 -> lp_gainc in Q3 */
        move16();