Commit 6c044130 authored by multrus's avatar multrus
Browse files

rename encoder-handle, small optimization

parent 758a7a01
Loading
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -1942,7 +1942,7 @@ void perform_noise_estimation_enc_ivas_fx(
 *-------------------------------------------------------------------*/
#ifdef FIX_2489_HARMONIZE_FdCng_encodeSID
void FdCng_encodeSID_fx(
    Encoder_State *corest /* i/o: encoder state structure     */
    Encoder_State *st /* i/o: encoder state structure     */
)
{
    Word16 i, index, N;
@@ -1951,32 +1951,34 @@ void FdCng_encodeSID_fx(
    Word32 temp, gain_fx, e_fx;
    Word32 v_fx[32];
    Word32 *E_fx;
    Word16 element_mode = corest->element_mode;
    Word16 element_mode = st->element_mode;
    move16();
    Word16 preemph_fac = corest->preemph_fac; // Q15
    Word16 preemph_fac = st->preemph_fac; // Q15
    move16();

    BSTR_ENC_HANDLE hBstr = corest->hBstr;
    HANDLE_FD_CNG_ENC hFdCngEnc = corest->hFdCngEnc;
    BSTR_ENC_HANDLE hBstr = st->hBstr;
    HANDLE_FD_CNG_ENC hFdCngEnc = st->hFdCngEnc;
    HANDLE_FD_CNG_COM hFdCngCom = hFdCngEnc->hFdCngCom;


    /* Init */

    E_fx = hFdCngEnc->msNoiseEst_fx;
    N = hFdCngEnc->npartDec;
    move16();

    E_fx = hFdCngEnc->msNoiseEst_fx;
    E_Exp = hFdCngEnc->msNoiseEst_fx_exp;
    move16();

    /* Convert to LOG */
    e_fx = L_deposit_l( 0 );
    e_fx = 0;
    move32();

    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        Word16 normShiftN = BASOP_util_norm_s_bands2shift( N );
        Word16 normFacN = getNormReciprocalWord16( N );
        Word32 E_ExpLd64 = L_shl( E_Exp, WORD32_BITS - 1 - LD_DATA_SCALE );

        /* e: Q14.23 format, v_fx: Q9.23 format */
        temp = Mpy_32_32_r( L_shl( 1, sub( 31, E_Exp ) ), 214748 ); /* 1e-4f, Q31-E_Exp */
        FOR( i = 0; i < N; i++ )
@@ -1993,14 +1995,11 @@ void FdCng_encodeSID_fx(
    {
        set_zero_fx( v_fx, FDCNG_VQ_MAX_LEN );
        FOR( i = 0; i < N; i++ )
        {
            IF( E_fx[i] == 0 )
        {
            /* 10 * log(1e-4) = 10 * (-4) = -40 */
            v_fx[i] = -41943040; // -40.0 in Q20
            move32();
            }
            ELSE
            IF( E_fx[i] != 0 )
            {
                v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], E_Exp ) ); // Q20 = 26+25-31
                move32();
@@ -2010,13 +2009,13 @@ void FdCng_encodeSID_fx(
    }

    /* Normalize MSVQ input */

    gain_fx = 0;
    move32();
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        Word16 normFacGain = getNormReciprocalWord16( N_GAIN_MAX - N_GAIN_MIN );
        Word16 normShiftGain = BASOP_util_norm_s_bands2shift( N_GAIN_MAX - N_GAIN_MIN );

        /* gain: Q9.23 format */
        FOR( i = N_GAIN_MIN; i < N_GAIN_MAX; i++ )
        {
@@ -2236,7 +2235,7 @@ void FdCng_encodeSID_fx(


    /* Write bitstream */
    IF( EQ_16( corest->codec_mode, MODE2 ) )
    IF( EQ_16( st->codec_mode, MODE2 ) )
    {
        FOR( i = 0; i < FD_CNG_stages_37bits; i++ )
        {
@@ -2256,8 +2255,8 @@ void FdCng_encodeSID_fx(
            IDX = IND_BWIDTH;
            move16();
        }
        push_indice( hBstr, IDX, corest->bwidth, 2 );
        if ( EQ_16( corest->L_frame, L_FRAME16k ) )
        push_indice( hBstr, IDX, st->bwidth, 2 );
        if ( EQ_16( st->L_frame, L_FRAME16k ) )
        {
            is_frame_len_16k = 1;
            move16();