Commit 058b7ab2 authored by vaillancour's avatar vaillancour
Browse files

Fix ISM HR

parent a96f24f3
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@

/* ################### Start DEBUGGING switches ######################## */

/*#define DEBUGGING*/                             /* Allows debugging message to be printed out during runtime */
#define DEBUGGING                             /* Allows debugging message to be printed out during runtime */
#ifdef DEBUGGING
/*#define DBG_BITSTREAM_ANALYSIS*/            /* Write bitstream with annotations to a text file */
#define DEBUG_MODE_INFO                       /* Define to output most important parameters to the subdirectory "res/" */
@@ -123,9 +123,12 @@
#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 VOICE_GEN
    #define REUSE_EVS_GSC            // Replace GSC by EVS GSC
    //#define REUSE_EVS_GSC            // Replace GSC by EVS GSC
    //#define REUSE_EVS_GSC_part1            // Replace GSC by EVS GSC
    #define USE_NEW_TARGET          /* Ittiam target computation allows for -> this seems not to give improvement on stv */
    


#endif
#endif

+2 −2
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ void encod_gen_voic_fx(
    shift_wsp = add( Q_new, shift );
#if defined USE_NEW_TARGET || defined REUSE_EVS_ACELP_GEN
    test();
    if ( st_fx->element_mode > EVS_MONO )
    if ( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
    {
        shift_wsp = sub( shift_wsp, 1 );
    }
@@ -225,7 +225,7 @@ 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 )
        IF( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {
            Word16 q_h1;
            find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr_fx, &hLPDmem->mem_w0, p_Aq_fx,
+90 −23
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
/* RETURN ARGUMENTS :													 */
/* _ None																 */
/*=======================================================================*/

void enc_pit_exc_fx(
    Encoder_State *st_fx,              /* i/o: State structure                                  */
    const Word16 *speech,              /* i  : Input speech                                     Q_new-1*/
@@ -69,6 +70,9 @@ void enc_pit_exc_fx(
    Word16 xn2[PIT_EXC_L_SUBFR];            /* Target vector for codebook search */
    Word16 h1[PIT_EXC_L_SUBFR + ( M + 1 )]; /* Impulse response vector           */
    Word16 y1[PIT_EXC_L_SUBFR];             /* Filtered adaptive excitation      */
#ifdef REUSE_EVS_GSC_part1
    Word16 cn[PIT_EXC_L_SUBFR]; /* Filtered adaptive excitation      */
#endif
    Word16 code[2 * L_SUBFR];               /* Fixed codebook excitation         */
    Word16 y2[2 * L_SUBFR];                 /* Filtered algebraic excitation     */
    Word16 voice_fac;                       /* Voicing factor                    */
@@ -80,7 +84,9 @@ void enc_pit_exc_fx(
    Word16 g_corr[10];                      /* ACELP correlation values + gain pitch */
    Word16 clip_gain, i;                    /* LSF clip gain and LP flag         */
    const Word16 *p_Aw, *p_Aq;              /* pointer to LP filter coefficient vector */
#ifndef REUSE_EVS_GSC_part1
    Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain  */
#endif
    Word16 *pt_pitch;                       /* pointer to floating pitch         */
    Word16 L_subfr;
    Word16 cum_gpit, gpit_tmp;
@@ -228,17 +234,30 @@ void enc_pit_exc_fx(
    /*------------------------------------------------------------------*
     * ACELP subframe loop
     *------------------------------------------------------------------*/
#ifndef REUSE_EVS_GSC_part1
    cn = NULL;
    if ( EQ_16( L_subfr, L_SUBFR ) )
    {
        cn = cn1;
        move16();
    }
#else
    set16_fx( cn, 0, PIT_EXC_L_SUBFR );
#endif
    p_Aw = Aw;

    p_Aq = Aq;
    pt_pitch = pitch_buf; /* pointer to the pitch buffer */
    shift_wsp = add( Q_new, shift );

#if defined USE_NEW_TARGET || defined REUSE_EVS_ACELP_GEN
    test();
    if ( st_fx->element_mode > EVS_MONO )
    {
        shift_wsp = sub( shift_wsp, 1 );
    }
#endif
//#undef USE_NEW_TARGET
    FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_subfr )
    {

@@ -250,11 +269,25 @@ 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 USE_NEW_TARGET
        IF( st_fx->element_mode > EVS_MONO )
        {
            Word16 q_h1;
            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 );

            q_h1 = sub( 14, norm_s( h1[0] ) );
            Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/
            Scale_sig( h1, L_subfr, add( sub( 14, q_h1 ), shift ) );
        }
        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 */

@@ -320,7 +353,7 @@ void enc_pit_exc_fx(
                push_indice( hBstr, IND_PIT_IDX, pit_idx, 4 );
            }
        }
        else if ( use_fcb == 2 )
        ELSE IF ( EQ_16( use_fcb, 2 ) )
        {
            /*-----------------------------------------------------------------*
             * Innovation encoding
@@ -358,7 +391,17 @@ void enc_pit_exc_fx(

        Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_sat( Lgcode );
#ifdef REUSE_EVS_GSC_part1
        IF( EQ_16( use_fcb, 2 ) )
        {
            hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); // Q15 /* Q15 */                 //TV this has to be reviewed as saturations are most likely

            move16();
        }
        ELSE IF( use_fcb > 0 )
#else
        IF( use_fcb != 0 )
#endif
        {
            hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */
            move16();
@@ -371,6 +414,30 @@ void enc_pit_exc_fx(
        /*-----------------------------------------------------------------*
         * Update memory of the weighting filter
         *-----------------------------------------------------------------*/
#ifdef USE_NEW_TARGET
        IF( st_fx->element_mode > EVS_MONO )
        {
            IF( use_fcb != 0 )
            {
                Ltmp = L_mult( gcode16, y2[L_subfr - 1] );
                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
                Ltmp = L_msu_o( Ltmp, y1[L_subfr - 1], gain_pit, &Overflow ); // Q_new-1+15+shift
                Ltmp = L_shl_o( Ltmp, sub( 1, shift ), &Overflow );           // Q_new+15
                hGSCEnc->mem_w0_tmp_fx = round_fx_o( Ltmp, &Overflow );       /*Q_new-1         */
            }
            ELSE
            {
                Ltmp = L_mult( xn[L_subfr - 1], 16384 );             // Q_new-1+15+shift
                Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); // Q_new-1+15+shift
                Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) );           // Q_new+15
                hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp );       /*Q_new-1         */
            }
        }
        ELSE
#endif
        {
            IF( use_fcb != 0 )
            {
                Ltmp = L_mult( gcode16, y2[L_subfr - 1] );          /* Q10 + Q_new */
@@ -390,7 +457,7 @@ void enc_pit_exc_fx(
                hLPDmem->mem_w0 = round_fx_sat( Ltmp );              /*Q_new-1         */
                move16();
            }

        }
        /*-----------------------------------------------------------------*
         * Construct adaptive part of the excitation
         * Save the non-enhanced excitation for FEC_exc
@@ -534,7 +601,7 @@ void enc_pit_exc_fx(
#endif
    *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/
}

#ifndef REUSE_EVS_GSC_part1
void enc_pit_exc_ivas_fx(
    Encoder_State *st_fx,              /* i/o: State structure                                  */
    const Word16 *speech,              /* i  : Input speech                                     Q_new-1*/
@@ -790,7 +857,6 @@ void enc_pit_exc_ivas_fx(
        {
            push_indice( hBstr, IND_LP_FILT_SELECT, lp_select, 1 );
        }

        st_fx->hSpMusClas->lowrate_pitchGain = mac_r( L_mult( 29491 /* 0.9 in Q15 */, st_fx->hSpMusClas->lowrate_pitchGain ), 3277 /* 0.1 in Q15 */, gain_pit ); /* Q14 */

        gpit_tmp = gain_pit;
@@ -1038,3 +1104,4 @@ void enc_pit_exc_ivas_fx(
#endif
    *gpit = round_fx( L_mac( L_mult( 3277, *gpit ), 29491, cum_gpit ) ); /*Q15*/
}
#endif
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ Word16 encod_tran_fx(
    shift_wsp = add( Q_new, shift );
#if defined USE_NEW_TARGET || defined REUSE_EVS_ACELP_TC
    test();
    if ( st_fx->element_mode > EVS_MONO )
    if ( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
    {
        shift_wsp = sub( shift_wsp, 1 );
    }
@@ -165,7 +165,7 @@ 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 )
        IF( st_fx->element_mode > EVS_MONO && LT_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) )
        {
            Word16 q_h1;
            find_targets_ivas_fx( speech_fx, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq,
+5 −2
Original line number Diff line number Diff line
@@ -596,10 +596,13 @@ void encod_audio_ivas_fx(
        Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new );
        push_indice( hBstr, IND_ES_PRED, indice, nb_bits );
    }

#ifndef REUSE_EVS_GSC_part1
    enc_pit_exc_ivas_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
                         &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );

#else
    enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp,
                         &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift );
#endif
    /*---------------------------------------------------------------*
     * DCT transform
     *---------------------------------------------------------------*/
Loading