Commit 31c8476c authored by vaillancour's avatar vaillancour
Browse files

fixing BE issue

parent 15ba25a9
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@
#define HARM_GSC_ENC                                    /* VA: Harmonization of EVS and IVAS GSC code */
#define HARM_GSC_ENC_PART2
#define HARM_GSC_ENC_PART3
#define HARM_GSC_ENC_PART4
#define BE_COMPL_RED
/* #################### End BE switches ################################## */

+72 −56
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ void enc_pit_exc_fx(
    Word16 clip_gain, i;                    /* LSF clip gain and LP flag         */
    const Word16 *p_Aw, *p_Aq;              /* pointer to LP filter coefficient vector */
#ifdef HARM_GSC_ENC
    Word16 cn1[PIT_EXC_L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain  */
    Word16 cn[PIT_EXC_L_SUBFR]; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain  */
#else
    Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain  */
#endif
@@ -231,12 +231,16 @@ void enc_pit_exc_fx(
     * ACELP subframe loop
     *------------------------------------------------------------------*/

#ifdef HARM_GSC_ENC
    set16_fx( cn, 0, PIT_EXC_L_SUBFR );
#else
    cn = NULL;
    if ( EQ_16( L_subfr, L_SUBFR ) )
    {
        cn = cn1;
        move16();
    }
#endif
    p_Aw = Aw;

    p_Aq = Aq;
@@ -261,16 +265,7 @@ void enc_pit_exc_fx(
        Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */
                                                       /* condition on target (compared to float) has been put outside the loop */
#ifdef HARM_GSC_ENC
        IF ( EQ_16( st_fx->element_mode, EVS_MONO ) )
        {
#endif
            find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
                             res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
            Copy_Scale_sig( h1, h2, L_subfr, -2 );     /* Q13 */
            Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
#ifdef HARM_GSC_ENC
        }
        ELSE
        IF( NE_16( st_fx->element_mode, EVS_MONO ) )
        {
            find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq,
                                  res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
@@ -278,7 +273,15 @@ void enc_pit_exc_fx(
            q_h1 = sub( 14, norm_s( h1[0] ) );
            Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/
        }
        ELSE
#endif
        {
            find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
                             res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
            Copy_Scale_sig( h1, h2, L_subfr, -2 );     /* Q13 */
            Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
        }

        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */

@@ -300,17 +303,16 @@ void enc_pit_exc_fx(
         * Find adaptive exitation
         *-----------------------------------------------------------------*/
#ifdef HARM_GSC_ENC
        IF ( EQ_16( st_fx->element_mode, EVS_MONO ) )
        IF( NE_16( st_fx->element_mode, EVS_MONO ) )
        {
#endif
            pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
#ifdef HARM_GSC_ENC
            pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
        }
        ELSE
#endif
        {
            pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
            pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP );
        }
#endif

        /*-----------------------------------------------------------------*
         * Gain clipping test to avoid unstable synthesis on frame erasure
         * or in case of floating point encoder & fixed p. decoder
@@ -332,7 +334,16 @@ void enc_pit_exc_fx(

        /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/
#ifndef FIX_EVS_LR_PG_BUG
#ifdef HARM_GSC_ENC
        IF( NE_16( st_fx->element_mode, EVS_MONO ) )
        {
            hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit );                 /* Q14*Q16(0.1) + Q15 -> Q15  Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */
        }
        ELSE
#endif
        {
            hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/
        }
#else
        hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15  Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */
#endif
@@ -363,23 +374,21 @@ void enc_pit_exc_fx(
        ELSE IF( use_fcb == 2 )
        {
#ifdef HARM_GSC_ENC
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq,
                                     gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new );
            }
            ELSE
#endif            
            {
                /*-----------------------------------------------------------------*
                 * Innovation encoding
                 *-----------------------------------------------------------------*/

                inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq,
                                gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift );
#ifdef HARM_GSC_ENC
            }
            ELSE
            {
                inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq,
                                     gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new );
            }
#endif            
            /*-----------------------------------------------------------------*
             * Gain encoding
             *-----------------------------------------------------------------*/
@@ -392,25 +401,29 @@ void enc_pit_exc_fx(
             * Innovation & gain encoding
             *-----------------------------------------------------------------*/
#ifdef HARM_GSC_ENC
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            {
#endif
                inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq,
                                gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift );
#ifdef HARM_GSC_ENC
            }
            ELSE
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq,
                                     gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new );
            }
            ELSE
#endif
            {
                inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq,
                                gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift );
            }

            /*-----------------------------------------------------------------*
             * Gain encoding
             *-----------------------------------------------------------------*/

#ifdef HARM_GSC_ENC
            gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred,
                               &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
#else
            gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred,
                               &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
#endif
        }

        gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx );
@@ -420,17 +433,15 @@ void enc_pit_exc_fx(
        IF( use_fcb != 0 )
        {
#ifdef HARM_GSC_ENC
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
#endif
                hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
#ifdef HARM_GSC_ENC
                hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */
            }
            ELSE
#endif
            {
                hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */
                hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
            }
#endif
            move16();
        }
        ELSE
@@ -446,23 +457,30 @@ void enc_pit_exc_fx(
        IF( use_fcb != 0 )
        {
#ifdef HARM_GSC_ENC
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
#endif
                Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
#ifdef HARM_GSC_ENC
                Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
            }
            ELSE
#endif
            {
                Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
                Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */
            }
#endif            
            Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */
            Ltmp = L_negate( Ltmp );
            Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 );    /* Q_new + Q15 + shift */
            Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */
            Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );           /* Q_new + 15 */
#ifdef HARM_GSC_ENC
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
                hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1         */
            }
            ELSE
#endif
            {
                hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1         */
            }
            move16();
        }
        ELSE
@@ -471,17 +489,15 @@ void enc_pit_exc_fx(
            Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */
            Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );           /* Q_new + 15 */
#ifdef HARM_GSC_ENC
            IF( EQ_16( st_fx->element_mode, EVS_MONO ) )
            IF( NE_16( st_fx->element_mode, EVS_MONO ) )
            {
#endif
                hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1         */
#ifdef HARM_GSC_ENC
                hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1         */
            }
            ELSE
#endif
            {
                hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1         */
                hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1         */
            }
#endif
            move16();
        }

@@ -628,7 +644,7 @@ void enc_pit_exc_fx(
    return;
}

#ifndef HARM_GSC_ENC
#if 1//ndef HARM_GSC_ENC
void enc_pit_exc_ivas_fx(
    Encoder_State *st_fx,              /* i/o: State structure                                  */
    const Word16 *speech,              /* i  : Input speech                                     Q_new-1*/
+2 −2
Original line number Diff line number Diff line
@@ -887,7 +887,7 @@ void gsc_enc_fx(
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
#ifdef HARM_GSC_ENC_PART3
    Word32 L_tmp;
    Word16 max_eq;
    Word16 max_eq = 0;
#endif
    set16_fx( inpulses_fx, 0, NB_SFM );
    set16_fx( imaxpulse_fx, 0, NB_SFM );
@@ -1116,7 +1116,7 @@ void gsc_enc_fx(
            move16();
        }
    }
    ELSE IF( LT_16( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) )
    ELSE IF( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) )
    {
        FOR( i = 0; i < L_FRAME; i++ )
        {