Commit 98746718 authored by vaillancour's avatar vaillancour
Browse files

reusing EVS for GSC lr

parent 8a408c5c
Loading
Loading
Loading
Loading
+43 −4
Original line number Diff line number Diff line
@@ -730,8 +730,13 @@ void enc_pit_exc_ivas_fx(
                                  res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 );

        q_h1 = sub( 14, norm_s( h1[0] ) );
#ifndef REUSE_EVS_ACELP
        Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/

#else
        Copy_Scale_sig( h1, h2, L_subfr, add( sub( 11, q_h1 ), shift) ); /*Q11*/
        move16();
        Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
#endif
        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */

@@ -739,11 +744,15 @@ void enc_pit_exc_ivas_fx(
         * Close-loop pitch search and quantization
         * Adaptive exc. construction
         *----------------------------------------------------------------*/

#ifndef REUSE_EVS_ACELP
        *pt_pitch = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
                                        L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */
        move16();
        Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
#else
        *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc,
                                        L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
#endif

        /*-----------------------------------------------------------------*
         * Find adaptive exitation
@@ -761,8 +770,13 @@ void enc_pit_exc_ivas_fx(
         * Codebook target computation
         * (No LP filtering of the adaptive excitation)
         *-----------------------------------------------------------------*/
#ifndef REUSE_EVS_ACELP
        lp_select = lp_filt_exc_enc_ivas_fx( MODE1, AUDIO, i_subfr, exc, h1,
                                             xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
#else
        lp_select = lp_filt_exc_enc_fx( MODE1, AUDIO, i_subfr, exc, h1,
                                             xn, y1, xn2, L_subfr, st_fx->L_frame, g_corr, clip_gain, &gain_pit, &lp_flag ); /* Q0 */
#endif
        IF( EQ_16( lp_flag, NORMAL_OPERATION ) )
        {
            push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
@@ -773,13 +787,14 @@ void enc_pit_exc_ivas_fx(
        gpit_tmp = gain_pit;
        move16(); /*Q14*/
        test();
#ifndef REUSE_EVS_ACELP
        IF( use_fcb > 0 )
        {
            /* h2 in Q12 for codebook search */
            /* h1 has been scaled with 1 + shift so we need to remove 2 and (1+shift) = -3 - shift*/
            Copy_Scale_sig( h1, h2, L_subfr, sub( -2 - 1, shift ) );
        }

#endif
        IF( use_fcb == 0 )
        {
            IF( GE_32( st_fx->core_brate, MIN_RATE_FCB ) )
@@ -798,7 +813,7 @@ void enc_pit_exc_ivas_fx(
            /*-----------------------------------------------------------------*
             * Innovation encoding
             *-----------------------------------------------------------------*/

#ifndef REUSE_EVS_ACELP
            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 );

@@ -807,6 +822,16 @@ void enc_pit_exc_ivas_fx(
             *-----------------------------------------------------------------*/

            gain_enc_lbr_ivas_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, sub( shift_wsp, 1 ), y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR );
#else
            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 );

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

            gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR );
#endif
        }
        ELSE
        {
@@ -814,6 +839,7 @@ void enc_pit_exc_ivas_fx(
             * Innovation & gain encoding
             *-----------------------------------------------------------------*/

#ifndef REUSE_EVS_ACELP
            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 );
            /*-----------------------------------------------------------------*
@@ -821,6 +847,15 @@ void enc_pit_exc_ivas_fx(
             *-----------------------------------------------------------------*/
            gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, sub( shift_wsp, 1 ), y2, code, Es_pred,
                                    &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain );
#else
            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
             *-----------------------------------------------------------------*/
            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 );

@@ -841,7 +876,11 @@ void enc_pit_exc_ivas_fx(
         *-----------------------------------------------------------------*/
        IF( use_fcb != 0 )
        {
#ifndef REUSE_EVS_ACELP
            Ltmp = L_mult0( gcode16, y2[L_subfr - 1] );
#else
            Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
#endif
            Ltmp = L_shl_o( Ltmp, add( 5, shift ), &Overflow ); // Q_new+14+shift
            Ltmp = L_negate( Ltmp );
            Ltmp = L_mac_o( Ltmp, xn[L_subfr - 1], 16384, &Overflow );    // Q_new-1+15+shift