Commit a53bb94c authored by multrus's avatar multrus
Browse files

[cleanup] accept HARM_COREDECODER_FUNCTIONS

parent 83790683
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@
#define FIX_2255_ISAR_RENDER_POSES                      /* VA: issue 2255: fix missing check in isar_render_poses() */
#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 HARM_COREDECODER_FUNCTIONS                      /* VA: basop issue 2347: Remove various duplicated code in core-decoder  */
#define FIX_BASOP_2358_SCALING_OOB                      /* Eri: Basip issue 2358: Clang-18 reports OOB access where scaling is applied to L_FRAME48k instead of output_frame */
#define FIX_BASOP_2351_EXTREND_SCALE                    /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */
#define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE           /* FhG: Fix issue 2331: Uninitialized variable */
+0 −89
Original line number Diff line number Diff line
@@ -25,26 +25,6 @@ static Word16 PutIntoBitstream_fx(

    return value;
}
#ifndef HARM_COREDECODER_FUNCTIONS
static Word16 PutIntoBitstream_ivas_fx(
    const Word16 **pStream,
    TEncodeValue EncodeValue,
    Word16 index,
    BSTR_ENC_HANDLE hBstr,
    const Word16 nBits )
{
    Word16 value;
    Word16 codedValue;

    move16();
    value = *( *pStream )++;
    codedValue = EncodeValue( value, index );

    push_next_indice( hBstr, codedValue, nBits );

    return value;
}
#endif

static Word16 FixedWidthEncoding( Word16 value, Word16 index )
{
@@ -327,75 +307,6 @@ void WriteToBitstream_fx(
    return;
}

#ifndef HARM_COREDECODER_FUNCTIONS
void WriteToBitstream_ivas_fx(
    ParamsBitMap const *paramsBitMap,
    const Word16 nArrayLength,
    const Word16 **pStream,
    Word16 *pnSize,
    BSTR_ENC_HANDLE hBstr,
    Word16 *pnBits )
{
    Word16 index;
    Word16 iParam, nParams;


    assert( ( paramsBitMap != NULL ) && ( nArrayLength > 0 ) && ( pStream != NULL ) && ( pnSize != NULL ) && ( hBstr != NULL ) && ( pnBits != NULL ) );
    nParams = paramsBitMap->nParams;
    move16();

    FOR( index = 0; index < nArrayLength; index++ )
    {

        FOR( iParam = 0; iParam < nParams; iParam++ )
        {
            ParamBitMap const *param;
            Word16 nBits;
            /* If a function for encoding/decoding value is defined than it should take care of 0 */
            Word16 fShiftValue;
            TEncodeValue EncodeValue;
            Word16 value;

            move16();
            param = &paramsBitMap->params[iParam];

            move16();
            nBits = param->nBits;
            IF( param->nBits == 0 )
            {
#define WMC_TOOL_SKIP
                nBits = param->GetNumberOfBits( **pStream, index );
#undef WMC_TOOL_SKIP
            }

            fShiftValue = s_and( param->fZeroAllowed == 0, param->EncodeValue == NULL );

            EncodeValue = param->EncodeValue;
            if ( param->EncodeValue == NULL )
            {
                move16();
                EncodeValue = &FixedWidthEncoding;
            }
            value = PutIntoBitstream_ivas_fx( pStream, EncodeValue, index, hBstr, nBits );
            IF( fShiftValue )
            {
                value = add( value, 1 );
            }

            move16();
            *pnSize = add( *pnSize, 1 );
            move16();
            *pnBits = add( *pnBits, nBits );

            test();
            IF( ( param->pSubParamBitMap != NULL ) && ( value > 0 ) )
            {
                WriteToBitstream_ivas_fx( param->pSubParamBitMap, value, pStream, pnSize, hBstr, pnBits );
            }
        }
    }
}
#endif

/** Get nBits long value from bitstream into *pStream. */
static Word16 GetFromBitstream(
+0 −46
Original line number Diff line number Diff line
@@ -6038,11 +6038,9 @@ void concealment_init_x(
    const Word16 L_frameTCX,
    T_PLCInfo_HANDLE hPlcInfo );
#ifdef HARM_COREDECODER_FUNCTIONS
void concealment_init_ivas_fx(
    const Word16 L_frameTCX,
    T_PLCInfo_HANDLE hPlcInfo );
#endif
void concealment_update_x(
    const Word16 bfi,
    const Word16 core,
@@ -6438,21 +6436,6 @@ void formant_post_filt_fx(
    const Word16 off_flag  /* i  : off flag                          */
);
#ifndef HARM_COREDECODER_FUNCTIONS
void Filt_mu_fx(
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3)     */
    Word16 L_subfr   /* i  : the length of subframe              */
);
void Filt_mu_ivas_fx(
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3)     */
    Word16 L_subfr,  /* i  : the length of subframe              */
    const Word16 extl );
#endif
void scale_st_fx(
    const Word16 *sig_in, /* i  : postfilter i signal             */
    Word16 *sig_out,      /* i/o: postfilter o signal             */
@@ -6639,18 +6622,6 @@ void gain_dec_tc_fx(
    Word32 *norm_gain_code_fx /* o  : norm. gain of the codebook excit.   */
);
#ifndef HARM_COREDECODER_FUNCTIONS
void gain_dec_tc_ivas_fx(
    Decoder_State *st_fx,     /* i/o: decoder state structure */
    const Word16 *code_fx,    /* i  : algebraic code excitation           */
    const Word16 i_subfr_fx,  /* i  : subframe number                     */
    const Word16 Es_pred_fx,  /* i  :  predicted scaled innov. energy     */
    Word16 *gain_pit_fx,      /* o  : pitch gain                          */
    Word32 *gain_code_fx,     /* o  : Quantized codeebook gain            */
    Word16 *gain_inov_fx,     /* o  : unscaled innovation gain            */
    Word32 *norm_gain_code_fx /* o  : norm. gain of the codebook excit.   */
);
#endif
void gain_dec_mless_fx(
    Decoder_State *st_fx,     /* i/o: decoder state structure                   */
    const Word16 L_frame_fx,  /* i  : length of the frame                       */
@@ -8606,14 +8577,6 @@ Word16 dlpc_avq_fx(
    Word32 sr_core );
Word16 decode_lpc_avq_fx(
#ifndef HARM_COREDECODER_FUNCTIONS
    Decoder_State *st,   /* i/o: decoder state structure     */
    const Word16 numlpc, /* i  : Number of sets of lpc       */
    Word16 *param_lpc    /* o  : lpc parameters              */
);
Word16 decode_lpc_avq_ivas_fx(
#endif
    Decoder_State *st,           /* i/o: decoder state structure     */
    const Word16 numlpc,         /* i  : Number of sets of lpc       */
    Word16 *param_lpc,           /* o  : lpc parameters              */
@@ -10656,15 +10619,6 @@ void WriteToBitstream_fx(
    BSTR_ENC_HANDLE hBstr,
    Word16 *pnBits );
#ifndef HARM_COREDECODER_FUNCTIONS
void WriteToBitstream_ivas_fx(
    ParamsBitMap const *paramsBitMap,
    const Word16 nArrayLength,
    const Word16 **pStream,
    Word16 *pnSize,
    BSTR_ENC_HANDLE hBstr,
    Word16 *pnBits );
#endif
/*===========================================================================================*/
/*----------------------------------------------------------------------------------*
+0 −4
Original line number Diff line number Diff line
@@ -1978,11 +1978,7 @@ void open_decoder_LPD_ivas_fx(

        IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) )
        {
#ifdef HARM_COREDECODER_FUNCTIONS
            concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo );
#else
            concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo );
#endif
        }
    }
    ELSE
+0 −164
Original line number Diff line number Diff line
@@ -35,11 +35,7 @@ static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2,

static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );

#ifdef HARM_COREDECODER_FUNCTIONS
static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr );
#else
static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl );
#endif


/*--------------------------------------------------------------------------
@@ -448,11 +444,7 @@ static void Dec_formant_postfilt_fx(
    }

    /* Controls short term pst filter gain and compute parcor0 */
#ifdef HARM_COREDECODER_FUNCTIONS
    calc_st_filt_local_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero );
#else
    calc_st_filt_ivas_fx( apond2, apond1, &parcor0, res2, hPFstat->mem_zero, -1 );
#endif

    /* 1/A(gamma1) filtering, mem_stp is updated */
    resynth[0] = *( hPFstat->mem_stp + sub( L_SYN_MEM, 1 ) );
@@ -470,11 +462,7 @@ static void Dec_formant_postfilt_fx(
    }

    /* Tilt filtering */
#ifdef HARM_COREDECODER_FUNCTIONS
    Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR );
#else
    Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 );
#endif

    IF( scale_down )
    {
@@ -1345,62 +1333,6 @@ static void calc_st_filt_local_fx(
    return;
}

#ifndef HARM_COREDECODER_FUNCTIONS
static void calc_st_filt_ivas_fx(
    Word16 *apond2,      /* i  : coefficients of numerator Q12             */
    Word16 *apond1,      /* i  : coefficients of denominator Q12          */
    Word16 *parcor0,     /* o  : 1st parcor calcul. on composed filter Q15 */
    Word16 *sig_ltp_ptr, /* i/o: i  of 1/A(gamma1) : scaled by 1/g0    Qx*/
    Word16 *mem_zero,    /* i  : All zero memory                       */
    const Word16 extl    /* i  : extension layer info                  */
)
{
    Word32 L_g0;

    Word16 h[LONG_H_ST]; // Q12

    Word16 g0, temp;
    Word16 i;


    temp = sub( 2, norm_s( apond2[0] ) );

    /* compute i.r. of composed filter apond2 / apond1 */
    IF( EQ_16( extl, SWB_TBE ) )
    {
        E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, LPC_SHB_ORDER );
    }
    ELSE
    {
        E_UTIL_synthesis( temp, apond1, apond2, h, LONG_H_ST, mem_zero, 0, M );
    }

    /* compute 1st parcor */
    Calc_rc0_h( h, parcor0 );

    /* compute g0 */
    L_g0 = L_mult0( 1, abs_s( h[0] ) ); // Q12
    FOR( i = 1; i < LONG_H_ST; i++ )
    {
        L_g0 = L_mac0( L_g0, 1, abs_s( h[i] ) ); // Q12
    }
    g0 = extract_h( L_shl( L_g0, 14 ) ); // Q10

    /* Scale signal i  of 1/A(gamma1) */
    IF( GT_16( g0, 1024 ) ) /*1024 = 1.Q10*/
    {
        temp = div_s( 1024, g0 ); /* temp => Q15 / gain0 */ /*1024 = 1.Q10*/
        FOR( i = 0; i < L_SUBFR; i++ )
        {
            sig_ltp_ptr[i] = mult_r( sig_ltp_ptr[i], temp ); // Qx
            move16();
        }
    }


    return;
}
#endif

/*----------------------------------------------------------------------------
 * filt_mu
@@ -1409,11 +1341,7 @@ static void calc_st_filt_ivas_fx(
 *      computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1])
 *---------------------------------------------------------------------------*/

#ifdef HARM_COREDECODER_FUNCTIONS
static void Filt_mu_fx(
#else
void Filt_mu_fx(
#endif
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3)     */
@@ -1474,98 +1402,6 @@ void Filt_mu_fx(
    return;
}

#ifndef HARM_COREDECODER_FUNCTIONS
void Filt_mu_ivas_fx(
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3) Q15     */
    Word16 L_subfr,  /* i  : the length of subframe              */
    const Word16 extl )
{
    Word32 L_acc, L_temp, L_fact;

    Word16 *ptrs;

    Word16 n;
    Word16 mu, mu2, ga, temp;
    Word16 fact, sh_fact;

    IF( EQ_16( extl, SWB_TBE ) )
    {
        IF( parcor0 > 0 )
        {
            mu = mult_r( parcor0, GAMMA3_PLUS_WB_FX ); // Q15
            /* GAMMA3_PLUS_FX < 0.5 */
            sh_fact = 14;
            move16(); /* sh_fact */
            fact = (Word16) 0x4000;
            move16();                       /* Q(sh_fact) */
            L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */
        }
        ELSE
        {
            mu = mult_r( parcor0, GAMMA3_MINUS_WB_FX ); // Q15
            /* GAMMA3_MINUS_FX < 0.9375 */
            sh_fact = 11;
            move16(); /* sh_fact */
            fact = (Word16) 0x0800;
            move16();                       /* Q(sh_fact) */
            L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */
        }
    }
    ELSE
    {
        IF( parcor0 > 0 )
        {
            mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15
            /* GAMMA3_PLUS_FX < 0.5 */
            sh_fact = 14;
            move16(); /* sh_fact */
            fact = (Word16) 0x4000;
            move16();                       /* Q(sh_fact) */
            L_fact = L_deposit_l( 0x2000 ); /* fact >> 1 */
        }
        ELSE
        {
            mu = mult_r( parcor0, GAMMA3_MINUS_FX ); // Q15
            /* GAMMA3_MINUS_FX < 0.9375 */
            sh_fact = 11;
            move16(); /* sh_fact */
            fact = (Word16) 0x0800;
            move16();                       /* Q(sh_fact) */
            L_fact = L_deposit_l( 0x0400 ); /* fact >> 1 */
        }
    }

    temp = sub( 1, abs_s( mu ) );
    BASOP_SATURATE_WARNING_OFF_EVS;
    mu2 = add_sat( 32767, temp ); /* Q15 (1 - |mu|) */
    BASOP_SATURATE_WARNING_ON_EVS;
    ga = div_s( fact, mu2 ); /* Q(sh_fact) / (1 - |mu|) */

    ptrs = sig_in; /* points on sig_in(-1) */

    sh_fact = sub( sh_fact, 16 ); /* to remove the saturate(), should shl by 16 before rounding */

    FOR( n = 0; n < L_subfr; n++ )
    {
        L_acc = L_mult0( mu, *ptrs++ );
        L_temp = L_mac( L_acc, 16384, *ptrs ); /* sig_in(n) * 2**15 */

        L_temp = Madd_32_16( L_fact, L_temp, ga );
        L_temp = L_shr( L_temp, sh_fact ); /* mult. temp x ga */

        BASOP_SATURATE_WARNING_OFF_EVS;
        /*sig_out[n] = saturate(L_temp); move16();*/
        sig_out[n] = round_fx_sat( L_temp );
        BASOP_SATURATE_WARNING_ON_EVS;
    }


    return;
}

#endif

/*----------------------------------------------------------------------------
 * scale_st_fx()
Loading