Commit 181dd3b5 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_2348_REPLACE_FEC_ENC

parent 9b79821c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@
/* any switch which is non-be wrt. TS 26.251 V3.0 */

#define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT  /* Dolby: Issue 2250:  random vector generation in GenShapedSHBExcitation() */
#define FIX_2348_REPLACE_FEC_ENC                        /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx  */
#define FIX_2338_HARM_GSC_GAIN_COMP                     /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */
#define FIX_BASOP_2317_UNINIT_VALUE_IN_STEREO_CNG       /* Eri: Basop issue 2317: Uninitialized value read in case of DTX and BW switching   */

+0 −15
Original line number Diff line number Diff line
@@ -10550,21 +10550,6 @@ Word16 msvq_stage1_dct_recalc_candidates_fdcng_wb_fx(
    Word16 *dist_ptr_e                /* i/o: exp for updated  MSE vector for stage1 */
);
#ifndef FIX_2348_REPLACE_FEC_ENC
void FEC_encode_ivas_fx(
    BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                                   */
    const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP                                 */
    const Word16 *synth,          /* i  : pointer to synthesized speech for E computation    Q_Synth*/
    const Word16 coder_type,      /* i  : type of coder                                           Q0*/
    Word16 clas,                  /* i  : signal clas for current frame                           Q0*/
    const Word16 *fpit,           /* i  : close loop fractional pitch buffer                      Q6*/
    const Word16 *res,            /* i  : LP residual signal frame                                Qx*/
    Word16 *last_pulse_pos,       /* i/o: Position of the last pulse                              Q0*/
    const Word16 L_frame,         /* i  : Frame length                                            Q0*/
    const Word32 total_brate,     /* i  : total codec bitrate                                     Q0*/
    const Word16 Q_synth          /* i  : input scaling                                             */
);
#endif
ivas_error IGF_Reconfig_fx(
    IGF_ENC_INSTANCE_HANDLE *hIGFEnc, /* i/o: instance handle of IGF Encoder  */
    const Word16 igf,                 /* i  : IGF on/off                      */
+0 −173
Original line number Diff line number Diff line
@@ -299,176 +299,3 @@ void FEC_lsf_estim_enc_fx(

    return;
}
#ifndef FIX_2348_REPLACE_FEC_ENC
/*-------------------------------------------------------------------*
 * FEC_encode()
 *
 * Encoder supplementary information for FEC
 *-------------------------------------------------------------------*/

void FEC_encode_ivas_fx(
    BSTR_ENC_HANDLE hBstr,        /* i/o: encoder bitstream handle                                  */
    const ACELP_config acelp_cfg, /* i/o: configuration of the ACELP                                */
    const Word16 *synth,          /* i  : pointer to synthesized speech for E computation    Q_Synth*/
    const Word16 coder_type,      /* i  : type of coder                                           Q0*/
    Word16 clas,                  /* i  : signal clas for current frame                           Q0*/
    const Word16 *fpit,           /* i  : close loop fractional pitch buffer                      Q6*/
    const Word16 *res,            /* i  : LP residual signal frame                                Qx*/
    Word16 *last_pulse_pos,       /* i/o: Position of the last pulse                              Q0*/
    const Word16 L_frame,         /* i  : Frame length                                            Q0*/
    const Word32 total_brate,     /* i  : total codec bitrate                                     Q0*/
    const Word16 Q_synth          /* i  : input scaling                                   */
)
{
    Word16 tmpS, index;
    Word16 maxi, sign, tmp_FER_pitch;
    Word32 enr_q, Ltmp;
    Word16 exp_enrq;

    tmpS = 0;
    move16();
    enr_q = 1;
    move16();
    sign = 0;
    move16();
    test();
    test();
    IF( GT_16( coder_type, UNVOICED ) && LT_16( coder_type, AUDIO ) && acelp_cfg.FEC_mode > 0 )
    {
        /*-----------------------------------------------------------------*
         * encode signal class (not needed for VC mode since it is clearly voiced) (2 bits)
         *-----------------------------------------------------------------*/
        IF( NE_16( coder_type, VOICED ) )
        {
            /* encode signal clas with 2 bits */
            test();
            IF( clas == UNVOICED_CLAS )
            {
                index = 0;
                move16();
            }
            ELSE IF( EQ_16( clas, VOICED_TRANSITION ) || EQ_16( clas, UNVOICED_TRANSITION ) )
            {
                index = 1;
                move16();
            }
            ELSE IF( EQ_16( clas, VOICED_CLAS ) )
            {
                index = 2;
                move16();
            }
            ELSE
            {
                index = 3;
                move16();
            }
            push_indice( hBstr, IND_FEC_CLAS, index, FEC_BITS_CLS );
        }

        /*-----------------------------------------------------------------*
         * encode frame energy (5 bits)
         *-----------------------------------------------------------------*/
        IF( GT_16( acelp_cfg.FEC_mode, 1 ) ) /* GENERIC and VOICED frames */
        {
            /* frame energy (maximum energy per pitch period for voiced frames or mean energy per sample over 2nd halframe for unvoiced frames) */
            /*frame_ener( L_frame, clas, synth, fpit[(L_frame>>6)-1], &enr_q, 0 );*/
            Word32 synth32[L_FRAME16k];
            Copy_Scale_sig_16_32_DEPREC( synth, synth32, L_FRAME16k, 0 ); /* Qsynth */
            fer_energy_fx( L_frame, clas, synth32, Q_synth, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), &enr_q, L_frame );
            exp_enrq = sub( 31, shl( Q_synth, 1 ) );

            test();
            test();
            if ( EQ_16( clas, VOICED_CLAS ) || EQ_16( clas, ONSET ) || EQ_16( clas, SIN_ONSET ) ) /* Voiced or Onset current frame */
            {
                exp_enrq = 31;
                move16();
            }
            /* linearly quantize the energy in the range 0 : FEC_ENR_STEP : 96 dB */
            /*tmpS = (short)( 10.0 * log10( enr_q + 0.001f ) / FEC_ENR_STEP )*/ /*To be converted fl_2_fx*/

            Ltmp = Mpy_32_32( BASOP_Util_Log10( enr_q, exp_enrq ), 894784853 /* 10 / FEC_ENR_STEP Q28 */ ); // Q 25 + 28 - 31 = Q22
            IF( Ltmp < 0 )
            {
                tmpS = extract_l( L_negate( L_shr( L_negate( Ltmp ), Q22 ) ) ); /* Q0 */
            }
            ELSE
            {
                tmpS = extract_l( L_shr( Ltmp, Q22 ) ); /* Q0 */
            }

            tmpS = s_min( tmpS, FEC_ENR_QLIMIT );
            tmpS = s_max( tmpS, 0 );

            push_indice( hBstr, IND_FEC_ENR, tmpS, FEC_BITS_ENR );
        }
        /*-----------------------------------------------------------------*
         * Encode last glottal pulse position (8 bits)
         *-----------------------------------------------------------------*/

        IF( GT_16( acelp_cfg.FEC_mode, 2 ) ) /* GENERIC frames */
        {
            /* retrieve the last glottal pulse position of the previous frame */
            /* use the current pitch information to scale or not the quantization */
            tmp_FER_pitch = shr( fpit[0], 6 ); /* take the 1st subframe pit, since it is easier to get on decoder side */
            sign = 0;
            move16();
            maxi = *last_pulse_pos; /* Q0 */
            move16();
            IF( maxi < 0 )
            {
                sign = 1;
                move16();
                /*maxi = -maxi; */
                maxi = negate( maxi );
            }

            if ( GE_16( tmp_FER_pitch, 128 ) )
            {
                maxi = shr( maxi, 1 );
            }

            if ( GT_16( maxi, 127 ) )
            {
                /* better not use the glottal pulse position at all instead of using a wrong pulse */
                /* can happen only with pitch > 254 and max pit = 289 and should happen very rarely */
                maxi = 0;
                move16();
            }

            if ( EQ_16( sign, 1 ) )
            {
                maxi = add( maxi, 128 ); /* use 8 bits (MSB represent the sign of the pulse)    Q0*/
            }

            push_indice( hBstr, IND_FEC_POS, maxi, FEC_BITS_POS );
        }
        maxi = 0;
        move16();

        /* If bitrate < 24k4, then the pitch
        is not represented in the same domain (12.k instead of 16k) */
        test();
        IF( GE_16( clas, VOICED_CLAS ) && GE_32( total_brate, ACELP_24k40 ) )
        {
            /*maxi = findpulse( L_frame, res, (short)(fpit[(L_frame>>6)-1]), 0, &sign ); */
            maxi = findpulse_fx( L_frame, res, shr_r( fpit[( L_frame >> 6 ) - 1], 6 ), 0, &sign );
            if ( EQ_16( sign, 1 ) )
            {
                /*maxi = -maxi;*/
                maxi = negate( maxi );
            }
        }

        *last_pulse_pos = maxi; /* Q0 */
        move16();
    }
    ELSE
    {
        *last_pulse_pos = 0;
        move16();
    }

    return;
}
#endif
+0 −6
Original line number Diff line number Diff line
@@ -1336,13 +1336,7 @@ ivas_error acelp_core_enc_ivas_fx(
         * Encode supplementary information for Frame Error Concealment
         *-----------------------------------------------------------------*/

#ifndef FIX_2348_REPLACE_FEC_ENC
        Scale_sig( syn_fx, L_FRAME, sub( s_min( st->Q_syn, Q_new ), st->Q_syn ) ); // min( st->Q_syn, Q_new )
        Scale_sig( res_fx, st->L_frame, sub( s_min( st->Q_syn, Q_new ), Q_new ) ); // min( st->Q_syn, Q_new )
        FEC_encode_ivas_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, s_min( st->Q_syn, Q_new ) );
#else
        FEC_encode_fx( hBstr, st->acelp_cfg, syn_fx, st->coder_type, st->clas, pitch_buf, res_fx, &st->Last_pulse_pos, st->L_frame, st->total_brate, add( st->Q_syn, 1 ), 0 );
#endif

        IF( st->hBWE_TD != NULL )
        {