Commit dbfb3825 authored by vaillancour's avatar vaillancour
Browse files

activation of Be EVS change

parent 143d7745
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -81,13 +81,24 @@

#define FORCE_GENERIC

#if 0        // diminish MLD by ~1 on NO_S
#if 1        // diminish MLD by ~1 on NO_S

#define TRY_SHIFT_ACELP         // Adding similar mecanism as shift for EVS, allows to use only 1 bit headroom instead of 2

#define USE_EVS_FUNC_LP        // -> BE for IVAS, but condition seems missing compared to float for rf condition
#define USE_EVS_FUNC_FT_T      // replacing the 32 bits find target with the EVS find target for transition
#define USE_EVS_FUNC_FT_G      // replacing the 32 bits find target with the EVS find target for generic        
//#define USE_EVS_Est_tilt2_FUNC
#ifdef USE_EVS_FUNC_LP        
//#define USE_EVS_FUNC_LP_GAIN  /* (BE) Deactivate gain Q function as they are identical to EVS, except for a couple of lines now added */
// Keep deactivated as they are only replaced in generic so far
#endif

//#define USE_EVS_FUNC_FT_T      // replacing the 32 bits find target with the EVS find target for transition
//#define USE_EVS_FUNC_FT_G      // replacing the 32 bits find target with the EVS find target for generic        

//#define TRY_SHIFT_ACELP         // Adding similar mecanism as shift for EVS, allows to use only 1 bit headroom instead of 2
#ifdef TRY_SHIFT_ACELP
    //#define TRY_SHIFT_ACELP_T
#endif

#endif

#endif
+35 −3
Original line number Diff line number Diff line
@@ -551,7 +551,6 @@ void encod_gen_voic_ivas_fx(
         *----------------------------------------------------------------*/

        Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/

#ifndef USE_EVS_FUNC_FT_G
        find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
                              res_fx, L_SUBFR, p_Aw_fx, st_fx->preemph_fac, xn_fx, cn_fx, h1_fx );
@@ -571,10 +570,18 @@ void encod_gen_voic_ivas_fx(
#endif
        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn_fx, L_SUBFR, shift );

#ifdef TRY_SHIFT_ACELP
        Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/
#endif
#ifndef USE_EVS_FUNC_FT_G
        *pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
                                           L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */
        move16();
#else
        *pt_pitch_fx = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx,
                                           L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf ); /* Q6 */
#endif
        move16();

        tbe_celp_exc_ivas( st_fx->element_mode, st_fx->idchan, L_frame, L_SUBFR, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx, st_fx->tdm_LRTD_flag );

@@ -637,22 +644,44 @@ void encod_gen_voic_ivas_fx(
        /*-----------------------------------------------------------------*
         * Gain encoding
         *-----------------------------------------------------------------*/
#ifdef TRY_SHIFT_ACELP2
        shift_wsp += 1;
#endif

        IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
        {
#ifndef USE_EVS_FUNC_LP
            gain_enc_lbr_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx,
                                  &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
#else
            gain_enc_lbr_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->coder_type, i_subfr_fx, xn_fx, y1_fx, shift_wsp-1, y2_fx, code_fx,
                                  &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, gc_mem, gp_mem, clip_gain_fx, L_SUBFR );
#endif
        }
        ELSE IF( GT_32( st_fx->core_brate, ACELP_32k ) )
        {
#ifndef USE_EVS_FUNC_LP
            gain_enc_SQ_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
                                 &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, sub( shift_wsp, 1 ) );
#else
            gain_enc_SQ_fx( hBstr, st_fx->acelp_cfg.gains_mode, i_subfr_fx, xn_fx, y1_fx, y2_fx, code_fx, Es_pred_fx,
                                 &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx, shift_wsp-1 );
#endif
        }
        ELSE
        {
#ifndef USE_EVS_FUNC_LP
            gain_enc_mless_ivas_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, sub( shift_wsp, 1 ), y2_fx, code_fx, Es_pred_fx,
                                    &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
#else
            gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_frame, i_subfr_fx, -1, xn_fx, y1_fx, shift_wsp-1, y2_fx, code_fx, Es_pred_fx,
                                    &gain_pit_fx, &gain_code_fx, &gain_inov_fx, &norm_gain_code_fx, g_corr_fx, clip_gain_fx );
#endif
        }
#ifdef TRY_SHIFT_ACELP2
        shift_wsp -= 1;
#endif

        IF( st_fx->Opt_SC_VBR )
        {
            if ( EQ_16( hSC_VBR->last_ppp_mode, 1 ) )
@@ -666,8 +695,11 @@ void encod_gen_voic_ivas_fx(

        Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_o( Lgcode, &Overflow );          /* Q0 */

#ifdef USE_EVS_Est_tilt2_FUNC
        hLPDmem->tilt_code = Est_tilt2(&exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift); /* Q15 */
#else
        hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */
#endif
        move16();

        /*-----------------------------------------------------------------*
+3 −0
Original line number Diff line number Diff line
@@ -573,7 +573,10 @@ Word16 encod_tran_ivas_fx(

        IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {

#if !defined TRY_SHIFT_ACELP_T   
            Scale_sig( h1, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */
#endif
            transf_cdbk_enc_ivas_fx( st_fx, 0, i_subfr, cn, exc_fx, p_Aq, Aw_fx, h1, xn, xn2, y1, y2, Es_pred_fx,
                                     &gain_pit, gain_code, g_corr, clip_gain, &gain_preQ, code_preQ, unbits, Q_new, shift );
        }
+14 −11
Original line number Diff line number Diff line
@@ -466,6 +466,9 @@ void gain_enc_mless_fx(
                qua_table = gain_qua_mless_6b_fx;
                if ( element_mode > EVS_MONO )
                {
#ifdef USE_EVS_FUNC_FT_G
                    qua_table = gain_qua_mless_6b_stereo_fx;
#endif
                }
                move16();
                if ( EQ_16( clip_gain, 1 ) )
@@ -521,7 +524,7 @@ void gain_enc_mless_fx(

    return;
}

#ifndef USE_EVS_FUNC_LP_GAIN
void gain_enc_mless_ivas_fx(
    BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle											*/
    const Word16 gains_mode[], /* i  : gain bits														Q0*/
@@ -851,7 +854,7 @@ void gain_enc_mless_ivas_fx(

    return;
}

#endif
/*---------------------------------------------------------------------*
 * gain_enc_SQ()
 *
@@ -1136,7 +1139,7 @@ void gain_enc_SQ_fx(

    return;
}

#ifndef USE_EVS_FUNC_LP_GAIN
void gain_enc_SQ_ivas_fx(
    BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle											*/
    const Word16 gains_mode[], /* i  : gain bits														Q0*/
@@ -1412,7 +1415,7 @@ void gain_enc_SQ_ivas_fx(

    return;
}

#endif
/*-------------------------------------------------------------------*
 * gain_enc_gaus()
 *
@@ -2083,7 +2086,7 @@ void gain_enc_lbr_fx(
    /* output gain_inov*/
    exp_inov = sub( exp_code, add( 18, L_subfr_sf ) );
    L_inov = Isqrt_lc( L_inov, &exp_inov );
    *gain_inov = extract_h( L_shl( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
    *gain_inov = extract_h( L_shl_sat( L_inov, sub( exp_inov, 3 ) ) ); /* gain_inov in Q12 */
    move16();


@@ -2261,9 +2264,9 @@ void gain_enc_lbr_fx(
        IF( EQ_16( nBits, 7 ) )
        {
            cdbk = gp_gamma_3sfr_7b_fx;
            if ( clip_gain == 1 )
            if ( EQ_16( clip_gain, 1 ) )
            {
                size -= 28;
                size = sub( size, 28 );
            }
        }
        ELSE
@@ -2360,9 +2363,9 @@ void gain_enc_lbr_fx(
        IF( EQ_16( nBits, 7 ) )
        {
            cdbk = gp_gamma_4sfr_7b_fx;
            if ( clip_gain == 1 )
            if ( EQ_16( clip_gain, 1 ) )
            {
                size -= 25;
                size = sub( size, 25 );
            }
        }
        ELSE
@@ -2442,7 +2445,7 @@ void gain_enc_lbr_fx(
    }
    return;
}

#ifndef USE_EVS_FUNC_LP_GAIN
void gain_enc_lbr_ivas_fx(
    BSTR_ENC_HANDLE hBstr,     /* i/o: encoder bitstream handle											 */
    const Word16 gains_mode[], /* i  : gain bits                                                       Q0*/
@@ -2889,7 +2892,7 @@ void gain_enc_lbr_ivas_fx(
    }
    return;
}

#endif
/*-------------------------------------------------------------------*
 * gain_enc_amr_wb()
 *
+6 −6
Original line number Diff line number Diff line
@@ -982,7 +982,7 @@ void transition_enc_ivas_fx(
        move16();
        *clip_gain = 0;
        move16();
#ifdef TRY_SHIFT_ACELP
#ifdef TRY_SHIFT_ACELP_T
        g_corr_fx[0] = 16384;
        move16();
        g_corr_fx[1] = add( shl( sub( shift_wsp, 1 ), 1 ), 1 );
@@ -1432,7 +1432,7 @@ void transition_enc_ivas_fx(
                *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, ( Q_new + shift - 1 ) );
                move16();

#ifndef TRY_SHIFT_ACELP
#ifndef TRY_SHIFT_ACELP_T
                Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
                lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
                                                     xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
@@ -1636,7 +1636,7 @@ void transition_enc_ivas_fx(
                move16();
                *clip_gain = 0;
                move16();
#ifndef TRY_SHIFT_ACELP
#ifndef TRY_SHIFT_ACELP_T
                g_corr_fx[0] = 328 /* 0.01f in Q15 */;
                move16();
                g_corr_fx[1] = 0;
@@ -1687,7 +1687,7 @@ void transition_enc_ivas_fx(
                *clip_gain = gp_clip_fx( st_fx->element_mode, st_fx->core_brate, st_fx->voicing_fx, i_subfr, TRANSITION, xn_fx, gp_cl_fx, Q_new );
                move16();

#ifndef TRY_SHIFT_ACELP
#ifndef TRY_SHIFT_ACELP_T
                Copy_Scale_sig( h1_fx, h1_fx_q15, L_SUBFR + ( M + 1 ), 1 );
                lp_select = lp_filt_exc_enc_ivas_fx( MODE1, TRANSITION, i_subfr, exc_fx, h1_fx_q15,
                                                     xn_fx, y1_fx, xn2_fx, L_SUBFR, st_fx->L_frame, g_corr_fx, *clip_gain, gain_pit_fx, &lp_flag );
@@ -1996,7 +1996,7 @@ static void tc_enc_ivas_fx(
)
{

#ifndef TRY_SHIFT_ACELP
#ifndef TRY_SHIFT_ACELP_T
    Word16 h1_fx[L_SUBFR + ( M + 1 )];
#endif
    Word16 imp_shape, imp_pos, index, nBits;
@@ -2121,7 +2121,7 @@ static void tc_enc_ivas_fx(
    /*--------------------------------------------------------------*
     * compute glottal-shape codebook excitation
     *--------------------------------------------------------------*/
#ifndef TRY_SHIFT_ACELP
#ifndef TRY_SHIFT_ACELP_T
    Copy_Scale_sig( h1, h1_fx, L_SUBFR + ( M + 1 ), 1 );
    /* create filtered glottal codebook contribution */
    conv_fx( &exc_fx[i_subfr], h1_fx, yy1_fx, L_SUBFR );