Commit 238d725d authored by vaillancour's avatar vaillancour
Browse files

replace gen_voic

parent 09676b20
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -119,8 +119,11 @@
#ifdef EVS_NONBE_REUSAGE_1906
    #define REUSE_EVS_ACELP_SHIFT    // Add shift parameter as expected by EVS acelp subfunctions
    #define REUSE_EVS_ACELP_HL_AVQ   // Replace ACELP high layers by EVS
    #define REUSE_EVS_ACELP_TC       // Replace TC by EVS TC
    #define REUSE_EVS_ACELP_INOV
#ifdef REUSE_EVS_ACELP_INOV
    #define REUSE_EVS_ACELP_TC       // Replace TC by EVS TC
    #define REUSE_EVS_ACELP_GEN      // Replace VOICE_GEN by EVS TC
#endif
#endif


+9 −1
Original line number Diff line number Diff line
@@ -1315,7 +1315,7 @@ ivas_error acelp_core_enc_ivas_fx(

        calc_residu_fx( st, inp, res_fx, Aq );
        calculate_hangover_attenuation_gain_ivas_fx( st, &att_fx, vad_hover_flag );
#ifdef REUSE_EVS_ACELP_SHIFT 
#if 1//def REUSE_EVS_ACELP_SHIFT 
        /* This could be moved outside of ACELP and compute on wsp or can be estimated on residual, idea is to prevent correlation to saturate, and from here they are all derived from residual*/
        {
            Word16 loc_max;
@@ -1425,7 +1425,11 @@ ivas_error acelp_core_enc_ivas_fx(
                move16();

                /* VOICED frames in SC-VBR */
#ifdef REUSE_EVS_ACELP_GEN
                encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
#else
                encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
#endif
            }
        }
        ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) )
@@ -1436,7 +1440,11 @@ ivas_error acelp_core_enc_ivas_fx(
        ELSE
        {
            /* GENERIC, VOICED and INACTIVE frames (coded by AVQ technology) */
#ifdef REUSE_EVS_ACELP_GEN
            encod_gen_voic_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, shift, Q_new );
#else
            encod_gen_voic_ivas_fx( st, inp, Aw, Aq, Es_pred_fx, res_fx, syn_fx, exc_fx, exc2_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, unbits, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, 0, Q_new );
#endif
        }

        /* update mem_syn1_flt for ACELP core switching */
+53 −12
Original line number Diff line number Diff line
@@ -188,7 +188,13 @@ void encod_gen_voic_fx(
    set16_fx( code_preQ_fx, 0, L_SUBFR );

    shift_wsp = add( Q_new, shift );

#ifdef REUSE_EVS_ACELP_GEN
    test();
    if ( st_fx->element_mode > EVS_MONO )
    {
        shift_wsp = sub( shift_wsp, 1 );
    }
#endif
    /* set and write harmonicity flag */
    harm_flag_acelp = 0;
    move16();
@@ -208,7 +214,7 @@ void encod_gen_voic_fx(
    /*------------------------------------------------------------------*
     * ACELP subframe loop
     *------------------------------------------------------------------*/

#define USE_NEW_TARGET
    FOR( i_subfr_fx = 0; i_subfr_fx < L_frame; i_subfr_fx += L_SUBFR )
    {

@@ -219,16 +225,38 @@ void encod_gen_voic_fx(
         *----------------------------------------------------------------*/

        Copy( &res_fx[i_subfr_fx], &exc_fx[i_subfr_fx], L_SUBFR ); /*Q_new*/
#ifdef USE_NEW_TARGET
        IF( st_fx->element_mode > EVS_MONO )
        {
            Word16 q_h1;
            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 );

            q_h1 = sub( 14, norm_s( h1_fx[0] ) );
            Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
            Scale_sig( h1_fx, L_SUBFR, add( sub( 14, q_h1 ), shift ) );
        }
        ELSE
#endif
        {
            find_targets_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 );

            Copy_Scale_sig( h1_fx, h2_fx, L_SUBFR, -2 );  /*Q11*/
            Scale_sig( h1_fx, L_SUBFR, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution Q(14+shift)*/

        }
        /* scaling of xn[] to limit dynamic at 12 bits */
        Scale_sig( xn_fx, L_SUBFR, shift );

#ifdef FIX_1766_TCX2ACELP_BWE_ISSUE
        test();
        test();
        IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) )
        {
            /* During core transition, when the temporal correlation is non existent  */
            rem_offset( xn_fx, xn_fx, L_SUBFR );
            rem_offset( cn_fx, cn_fx, L_SUBFR );
        }
#endif
        *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
#if defined REUSE_EVS_BE_ACELP_PITCH 
@@ -236,8 +264,16 @@ void encod_gen_voic_fx(
                                      st_fx->element_mode, Q_new
#endif
        ); /* Q6 */
#ifndef REUSE_EVS_TBE_CELP_EXC
        IF( st_fx->element_mode > EVS_MONO )
        {
            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 );
        }
        ELSE
#endif
        {
            tbe_celp_exc( L_frame, i_subfr_fx, T0_fx, T0_frac_fx, &error_fx, bwe_exc_fx );

        }
        /*-----------------------------------------------------------------*
         * Find adaptive exitation
         *-----------------------------------------------------------------*/
@@ -335,9 +371,13 @@ void encod_gen_voic_fx(
        /*-----------------------------------------------------------------*
         * Transform domain contribution encoding - inactive frames
         *-----------------------------------------------------------------*/

#ifdef REUSE_EVS_ACELP_GEN
        test();
        IF( !st_fx->inactive_coder_type_flag && EQ_16( st_fx->coder_type, INACTIVE ) )
#else
        test();
        IF( GE_32( st_fx->core_brate, MAX_GSC_INACTIVE_BRATE ) && EQ_16( st_fx->coder_type, INACTIVE ) )
#endif
        {
            transf_cdbk_enc_fx( st_fx, 0, i_subfr_fx, cn_fx, exc_fx, p_Aq_fx, p_Aw_fx, h1_fx, xn_fx, xn2_fx, y1_fx, y2_fx,
                                Es_pred_fx, &gain_pit_fx, gain_code_fx, g_corr_fx, clip_gain_fx, &gain_preQ_fx, code_preQ_fx, unbits_fx, Q_new, shift );
@@ -436,7 +476,7 @@ void encod_gen_voic_fx(
    return;
}


#ifndef REUSE_EVS_ACELP_GEN
void encod_gen_voic_ivas_fx(
    Encoder_State *st_fx,              /* i/o: state structure                                  */
    const Word16 speech_fx[],          /* i  : input speech                                     Qnew -1 */
@@ -869,3 +909,4 @@ void encod_gen_voic_ivas_fx(
    }
    return;
}
#endif
 No newline at end of file
+21 −9
Original line number Diff line number Diff line
@@ -145,9 +145,9 @@ Word16 encod_tran_fx(
    move16();
    set16_fx( code_preQ, 0, L_SUBFR );
    shift_wsp = add( Q_new, shift );
#if defined REUSE_EVS_ACELP_TC && !defined REUSE_EVS_ACELP_INOV
#if defined REUSE_EVS_ACELP_TC
    test();
    if ( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
    if ( st_fx->element_mode > EVS_MONO )
    {
        shift_wsp = sub( shift_wsp, 1 );
    }
@@ -155,7 +155,7 @@ Word16 encod_tran_fx(
    /*----------------------------------------------------------------*
     * ACELP subframe loop
     *----------------------------------------------------------------*/

#define USE_NEW_TARGET
    FOR( i_subfr = 0; i_subfr < L_frame_fx; i_subfr += L_SUBFR )
    {
        /*----------------------------------------------------------------*
@@ -165,13 +165,25 @@ Word16 encod_tran_fx(
         *----------------------------------------------------------------*/

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

#ifdef USE_NEW_TARGET
        IF( st_fx->element_mode > EVS_MONO )
        {
            Word16 q_h1;
            find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
                                  res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );
            q_h1 = sub( 14, norm_s( h1[0] ) );
            Copy_Scale_sig( h1, h2_fx, L_SUBFR, sub( 11, q_h1 ) ); /*Q11*/
            Scale_sig( h1, L_SUBFR, add( sub( 14, q_h1 ), shift ) );
        }
        ELSE
#endif
        {
            find_targets_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
                             res_fx, L_SUBFR, p_Aw, st_fx->preemph_fac, xn, cn, h1 );

            Copy_Scale_sig( h1, h2_fx, L_SUBFR, -2 );
            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 );

+12 −0
Original line number Diff line number Diff line
@@ -65,7 +65,18 @@ void find_targets_fx(
     *--------------------------------------------------------------*/
    IF( cn != NULL )
    {
#ifdef REUSE_EVS_ACELP_INOV
        /* first half: xn[] --> cn[] */
        temp[0] = 0;
        move16();
        preemph_copy_fx( xn, cn, tilt_fac, L_subfr / 2, temp );
        syn_filt_s_lc_fx( 1, Ap, cn, temp, L_subfr / 2 );   /* Q-1 -> Q-2 */
        Residu3_lc_fx( p_Aq, M, temp, cn, L_subfr / 2, 1 ); /* Q-2 -> Q-1 */
        Scale_sig( cn, L_subfr / 2, 1 );

        /* second half: res[] --> cn[] (approximated and faster) */
        Copy( &res[i_subfr + ( L_subfr / 2 )], cn + ( L_subfr / 2 ), L_subfr / 2 ); /* Q_new */
#else                                                                               /* first half: xn[] --> cn[] */
        temp[0] = 0;
        move16();
        preemph_copy_fx( xn, cn, tilt_fac, L_SUBFR / 2, temp );
@@ -75,6 +86,7 @@ void find_targets_fx(

        /* second half: res[] --> cn[] (approximated and faster) */
        Copy( &res[i_subfr + ( L_SUBFR / 2 )], cn + ( L_SUBFR / 2 ), L_SUBFR / 2 ); /* Q_new */
#endif
    }

    /*---------------------------------------------------------------*