Commit c89d638e authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'q_doc_lib_enc_files' into 'main'

Q documentation for lib enc files

See merge request !1298
parents 14804829 6e0435fb
Loading
Loading
Loading
Loading
Loading
+102 −49
Original line number Diff line number Diff line
@@ -23,8 +23,8 @@ static Word16 edyn_fx( const Word16 *vec, const Word16 lvec, Word16 Qnew );
void encod_audio_fx(
    Encoder_State *st_fx,              /* i/o: State structure                                  	*/
    const Word16 speech[],             /* i  : input speech                                Q_new   */
    const Word16 Aw[],                 /* i  : weighted A(z) unquantized for subframes             */
    const Word16 Aq[],                 /* i  : 12k8 Lp coefficient                                 */
    const Word16 Aw[],                 /* i  : weighted A(z) unquantized for subframes       Q12      */
    const Word16 Aq[],                 /* i  : 12k8 Lp coefficient                           Q12      */
    const Word16 *res,                 /* i  : residual signal                             Q_new   */
    Word16 *synth,                     /* i/o: core synthesis                              Q-1     */
    Word16 *exc,                       /* i/o: current non-enhanced excitation             Q_new   */
@@ -32,10 +32,10 @@ void encod_audio_fx(
    Word16 *voice_factors,             /* o  : voicing factors                             Q15   	*/
    Word16 *bwe_exc,                   /* o  : excitation for SWB TBE						Q0		*/
    const Word16 attack_flag,          /* i  : Flag that point to an attack coded with AC mode (GSC)	*/
    Word16 *lsf_new,                   /* i  : current frame ISF vector 							*/
    Word16 *tmp_noise,                 /* o  : noise energy   */
    const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag             */
    const Word16 tdm_Pri_pitch_buf[],  /* i  : primary channel pitch buffer                 */
    Word16 *lsf_new,                   /* i  : current frame ISF vector 					Qx2.56		*/
    Word16 *tmp_noise,                 /* o  : noise energy   Q2*/
    const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag             Q0*/
    const Word16 tdm_Pri_pitch_buf[],  /* i  : primary channel pitch buffer                 Q6*/
    Word16 Q_new,
    Word16 shift )
{
@@ -43,9 +43,11 @@ void encod_audio_fx(
    Word16 i, i_subfr, nb_subfr, last_pit_bin;
    Word16 T0_tmp, T0_frac_tmp, nb_subfr_flag;
    Word16 tmp_nb_bits_tot = 0;
    move16();
    Word16 Es_pred;
    Word16 dct_res[L_FRAME16k], dct_epit[L_FRAME16k];
    Word16 m_mean = 0;
    move16();
    Word16 saved_bit_pos;
    Word16 exc_wo_nf[L_FRAME16k];
    Word32 Lm_mean;
@@ -65,7 +67,7 @@ void encod_audio_fx(
    move16();
    T0_frac_tmp = 0;
    move16();
    Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M );
    Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */
    hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0;
    move16();
    Es_pred = 0;
@@ -78,7 +80,7 @@ void encod_audio_fx(
     *---------------------------------------------------------------*/
#ifdef GSC_IVAS // TVB -->>>>>>
    test();
    if ( GT_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 )
    IF( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 )
    {
        push_indice_fx( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
    }
@@ -99,6 +101,7 @@ void encod_audio_fx(
    test();
    test();
    test();
    test();
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( NE_16( st_fx->coder_type, INACTIVE ) && ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
                                                                                        ( GT_16( st_fx->element_mode, EVS_MONO ) && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
    {
@@ -113,7 +116,7 @@ void encod_audio_fx(
        FOR( i = 0; i < 5; i++ )
        {
            test();
            if ( GT_16( abs_s( hSpMusClas->gsc_lt_diff_etot_fx[MAX_LT - i - 1] ), 1536 ) && EQ_16( hGSCEnc->cor_strong_limit, 1 ) )
            if ( GT_16( abs_s( hSpMusClas->gsc_lt_diff_etot_fx[MAX_LT - i - 1] ), 1536 /*6.0 in Q8*/ ) && EQ_16( hGSCEnc->cor_strong_limit, 1 ) )
            {
                hGSCEnc->cor_strong_limit = 0;
                move16();
@@ -121,6 +124,9 @@ void encod_audio_fx(
        }
    }
    test();
    test();
    test();
    test();
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->GSC_noisy_speech && st_fx->GSC_IVAS_mode == 0 ) )
    {
        nb_subfr = NB_SUBFR;
@@ -166,10 +172,14 @@ void encod_audio_fx(
            nb_subfr_flag = 1;
            move16();
        }

        test();
        test();
        test();
        IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( GT_16( hSpMusClas->mold_corr_fx, 26214 ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) && NE_16( st_fx->coder_type, INACTIVE ) ) )
        {
            nb_subfr = shl( nb_subfr, 1 );
            nb_subfr_flag |= 0x2;
            nb_subfr_flag = s_or( nb_subfr_flag, 0x2 );
            logic16();
        }

@@ -194,14 +204,22 @@ void encod_audio_fx(
     * Compute adaptive (pitch) excitation contribution
     *---------------------------------------------------------------*/

    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    IF( !( st_fx->GSC_IVAS_mode > 0 && EQ_16( st_fx->L_frame, i_mult( nb_subfr, 2 * L_SUBFR ) ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
        ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
          ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
    {
        IF( GT_16( st_fx->element_mode, EVS_MONO ) )
        IF( ( st_fx->element_mode > EVS_MONO ) )
        {
            nb_bits = 5;
            move16();
        }
        ELSE
        {
@@ -235,17 +253,20 @@ void encod_audio_fx(
    {
        /*st_fx->mid_dyn_fx = 0.2f * st_fx->mid_dyn_fx + 0.8f * m_mean;*/
        hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
        move16();
    }
    ELSE
    {
        /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
        hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
        move16();
    }
    IF( NE_16( st_fx->coder_type, INACTIVE ) )
    {
        hGSCEnc->noise_lev = sub( ( NOISE_LEVEL_SP3 + 1 ), usquant_fx( hGSCEnc->mid_dyn_fx, &m_mean, MIN_DYNAMIC_FX, shr( GSF_NF_DELTA_FX, 1 ), GSC_NF_STEPS ) );

        move16();
        hGSCEnc->noise_lev = s_min( hGSCEnc->noise_lev, NOISE_LEVEL_SP3 );
        move16();
    }

    hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
@@ -253,6 +274,7 @@ void encod_audio_fx(
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
    {
        hGSCEnc->noise_lev = NOISE_LEVEL_SP2;
        move16();
        IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
        {
            hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
@@ -267,12 +289,14 @@ void encod_audio_fx(
    ELSE IF( LE_32( st_fx->core_brate, ACELP_8k00 ) )
    {
        hGSCEnc->noise_lev = s_max( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 );
        move16();
        push_indice_fx( hBstr, IND_NOISE_LEVEL, sub( hGSCEnc->noise_lev, NOISE_LEVEL_SP2 ), 2 );
    }
    ELSE IF( st_fx->GSC_noisy_speech )
    {
        hGSCEnc->noise_lev = NOISE_LEVEL_SP3;
        move16();
        move16();
    }
    ELSE
    {
@@ -373,8 +397,8 @@ void encod_audio_fx(
void encod_audio_ivas_fx(
    Encoder_State *st_fx,              /* i/o: State structure                                  	*/
    const Word16 speech[],             /* i  : input speech                                Q_new   */
    const Word16 Aw[],                 /* i  : weighted A(z) unquantized for subframes             */
    const Word16 Aq[],                 /* i  : 12k8 Lp coefficient                                 */
    const Word16 Aw[],                 /* i  : weighted A(z) unquantized for subframes      Q12       */
    const Word16 Aq[],                 /* i  : 12k8 Lp coefficient                           Q12      */
    const Word16 *res,                 /* i  : residual signal                             Q_new   */
    Word16 *synth,                     /* i/o: core synthesis                              Q-1     */
    Word16 *exc,                       /* i/o: current non-enhanced excitation             Q_new   */
@@ -382,8 +406,8 @@ void encod_audio_ivas_fx(
    Word16 *voice_factors,             /* o  : voicing factors                             Q15   	*/
    Word16 *bwe_exc,                   /* o  : excitation for SWB TBE						Q0		*/
    const Word16 attack_flag,          /* i  : Flag that point to an attack coded with AC mode (GSC)	*/
    Word16 *lsf_new,                   /* i  : current frame ISF vector 							*/
    Word16 *tmp_noise,                 /* o  : noise energy   */
    Word16 *lsf_new,                   /* i  : current frame ISF vector 						Qx2.56	*/
    Word16 *tmp_noise,                 /* o  : noise energy   Q8*/
    const Word16 tdm_Pitch_reuse_flag, /* i  : primary channel pitch reuse flag             */
    const Word16 tdm_Pri_pitch_buf[],  /* i  : primary channel pitch buffer                 */
    Word16 Q_new,
@@ -428,7 +452,7 @@ void encod_audio_ivas_fx(
     *---------------------------------------------------------------*/

    test();
    if ( GT_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 )
    if ( ( st_fx->element_mode > EVS_MONO ) && st_fx->idchan == 0 )
    {
        push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 );
    }
@@ -449,6 +473,7 @@ void encod_audio_ivas_fx(
    test();
    test();
    test();
    test();
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( NE_16( st_fx->coder_type, INACTIVE ) && ( ( EQ_16( st_fx->element_mode, EVS_MONO ) && GE_32( st_fx->total_brate, ACELP_13k20 ) ) ||
                                                                                        ( GT_16( st_fx->element_mode, EVS_MONO ) && GT_32( st_fx->total_brate, MIN_BRATE_GSC_NOISY_FLAG ) && GE_16( st_fx->bwidth, SWB ) && !st_fx->flag_ACELP16k ) ) ) )
    {
@@ -471,6 +496,9 @@ void encod_audio_ivas_fx(
        }
    }
    test();
    test();
    test();
    test();
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) || ( st_fx->GSC_noisy_speech && st_fx->GSC_IVAS_mode == 0 ) )
    {
        nb_subfr = NB_SUBFR;
@@ -516,6 +544,10 @@ void encod_audio_ivas_fx(
            nb_subfr_flag = 1;
            move16();
        }

        test();
        test();
        test();
        IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && ( GT_16( hSpMusClas->mold_corr_fx, 26214 ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) && NE_16( st_fx->coder_type, INACTIVE ) ) )
        {
            nb_subfr = shl( nb_subfr, 1 );
@@ -523,6 +555,7 @@ void encod_audio_ivas_fx(
            logic16();
        }

        test();
        IF( EQ_16( st_fx->L_frame, L_FRAME16k ) && GE_32( st_fx->core_brate, MIN_RATE_4SBFR ) )
        {
            push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 2 );
@@ -544,14 +577,22 @@ void encod_audio_ivas_fx(
     * Compute adaptive (pitch) excitation contribution
     *---------------------------------------------------------------*/

    test();
    test();
    test();
    test();
    test();
    test();
    test();
    test();
    IF( !( st_fx->GSC_IVAS_mode > 0 && EQ_16( st_fx->L_frame, i_mult( nb_subfr, 2 * L_SUBFR ) ) && LT_16( st_fx->GSC_IVAS_mode, 3 ) ) &&
        ( ( GE_32( st_fx->core_brate, MIN_RATE_FCB ) || st_fx->GSC_noisy_speech ) &&
          ( ( EQ_16( nb_subfr, NB_SUBFR ) && EQ_16( st_fx->L_frame, L_FRAME ) ) || ( EQ_16( nb_subfr, NB_SUBFR16k ) && EQ_16( st_fx->L_frame, L_FRAME16k ) ) ) ) )
    {
        IF( GT_16( st_fx->element_mode, EVS_MONO ) )
        IF( ( st_fx->element_mode > EVS_MONO ) )
        {
            nb_bits = 5;
            move16();
        }
        ELSE
        {
@@ -585,17 +626,20 @@ void encod_audio_ivas_fx(
    {
        /*st_fx->mid_dyn_fx = 0.2f * st_fx->mid_dyn_fx + 0.8f * m_mean;*/
        hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 26214, m_mean ), 6554, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
        move16();
    }
    ELSE
    {
        /*st_fx->mid_dyn_fx = 0.6f * st_fx->mid_dyn_fx + 0.4f * m_mean;*/
        hGSCEnc->mid_dyn_fx = round_fx( L_mac( L_mult( 13107, m_mean ), 19661, hGSCEnc->mid_dyn_fx ) ); /*Q7*/
        move16();
    }
    IF( NE_16( st_fx->coder_type, INACTIVE ) )
    {
        hGSCEnc->noise_lev = sub( ( NOISE_LEVEL_SP3 + 1 ), usquant_fx( hGSCEnc->mid_dyn_fx, &m_mean, MIN_DYNAMIC_FX, shr( GSF_NF_DELTA_FX, 1 ), GSC_NF_STEPS ) );

        move16();
        hGSCEnc->noise_lev = s_min( hGSCEnc->noise_lev, NOISE_LEVEL_SP3 );
        move16();
    }

    hGSCEnc->past_dyn_dec = hGSCEnc->noise_lev;
@@ -603,6 +647,7 @@ void encod_audio_ivas_fx(
    IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) )
    {
        hGSCEnc->noise_lev = NOISE_LEVEL_SP2;
        move16();
        IF( EQ_16( st_fx->GSC_IVAS_mode, 3 ) ) /* Music like */
        {
            hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
@@ -708,7 +753,7 @@ void encod_audio_ivas_fx(
     * Synthesis
     *--------------------------------------------------------------------------------------*/

    p_Aq = Aq;
    p_Aq = Aq; /* Q12 */
    FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_SUBFR )
    {
        Syn_filt_s( 1, p_Aq, M, &exc_wo_nf[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1 );
@@ -721,7 +766,7 @@ void encod_audio_ivas_fx(

    hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; /*_DIFF_FLOAT_FIX_  The way it is written in the original fix point is that at this point mem_w0 falls back to its original value (before enc_pit_exc, seems not the case in float */
    move16();
    Copy( exc_wo_nf, exc, st_fx->L_frame );
    Copy( exc_wo_nf, exc, st_fx->L_frame ); /* Q_new */

    return;
}
@@ -753,14 +798,14 @@ void encod_audio_ivas_fx(

void gsc_enc_fx(
    Encoder_State *st_fx, /* i/o: State structure                               */
    Word16 res_dct_in[],  /* i  : dct of residual signal                        */
    Word16 exc_dct_in[],  /* i/o: dct of pitch-only excitation / total excitation */
    Word16 res_dct_in[],  /* i  : dct of residual signal                        Q_exc*/
    Word16 exc_dct_in[],  /* i/o: dct of pitch-only excitation / total excitation Q_exc*/
    const Word16 Diff_len,
    const Word16 bits_used,
    const Word16 nb_subfr,
    Word16 *lsf_new,   /* i  : ISFs at the end of the frame                  */
    Word16 *exc_wo_nf, /* o  : excitation (in f domain) without noisefill    */
    Word16 *tmp_noise, /* o  : noise energy                                  */
    Word16 *lsf_new,   /* i  : ISFs at the end of the frame                  Qx2.56*/
    Word16 *exc_wo_nf, /* o  : excitation (in f domain) without noisefill    Q_exc*/
    Word16 *tmp_noise, /* o  : noise energy                                  Q2*/
    Word16 Q_exc )
{
    Word16 y2_filt[L_FRAME16k];
@@ -794,6 +839,7 @@ void gsc_enc_fx(
     *--------------------------------------------------------------------------------------*/

    bit = bits_used;
    move16();
    test();
    test();
    test();
@@ -841,10 +887,14 @@ void gsc_enc_fx(
    {
        IF( LE_32( st_fx->core_brate, brate_intermed_tbl[i] ) )
        {
            break;
            BREAK;
        }
        i++;
    }

    test();
    test();
    test();
    if ( GT_16( st_fx->element_mode, EVS_MONO ) && EQ_16( st_fx->coder_type, AUDIO ) &&
         LE_32( st_fx->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
    {
@@ -854,6 +904,7 @@ void gsc_enc_fx(
    mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ );

    *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5  lp_gainc in Q3 */
    move16();

    /*--------------------------------------------------------------------------------------*
     * Frequency encoder
@@ -873,7 +924,7 @@ void gsc_enc_fx(
    {
        tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end,
                               gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE );
        Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) );
        Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */
        bit = sub( bit, tmp );
    }
    /* write unused bits */
@@ -974,11 +1025,11 @@ void gsc_enc_ivas_fx(
    const Word16 Diff_len,                                           /* i  : Lenght of the difference signal (before pure spectral)*/
    const Word16 bits_used,                                          /* i  : Number of bit used before frequency Q                 */
    const Word16 nb_subfr,                                           /* i  : Number of subframe considered                         */
    const Word16 *lsf_new_fx,
    const Word16 *lsf_new_fx,                                        /* Qx2.56 */
    /* i  : ISFs at the end of the frame                          */ // Q15
    Word16 *exc_wo_nf_fx,
    /* o  : excitation (in f domain) without noisefill            */ // Q_exc
    Word16 *tmp_noise_fx,                                            /* o  : long-term noise energy                                */
    Word16 *tmp_noise_fx,                                            /* o  : long-term noise energy                                Q8*/
    Word16 *Q_exc )
{
    Word16 i;
@@ -1031,7 +1082,7 @@ void gsc_enc_ivas_fx(
     * (non valuable temporal content present in exc_dct_in is already zeroed)
     *--------------------------------------------------------------------------------------*/

    v_sub_16( res_dct_in_fx, exc_dct_in_fx, exc_diff_fx, st->L_frame );
    v_sub_16( res_dct_in_fx, exc_dct_in_fx, exc_diff_fx, st->L_frame ); /* Q_exc */
    exc_diff_fx[0] = 0;
    move16();

@@ -1064,18 +1115,18 @@ void gsc_enc_ivas_fx(
    {
        IF( LE_32( st->core_brate, brate_intermed_tbl[i] ) )
        {
            break;
            BREAK;
        }
        i = add( i, 1 );
        i++;
    }

    test();
    test();
    test();
    IF( st->element_mode > EVS_MONO && EQ_16( st->coder_type, AUDIO ) &&
    if ( st->element_mode > EVS_MONO && EQ_16( st->coder_type, AUDIO ) &&
         LE_32( st->core_brate, STEREO_GSC_BIT_RATE_ALLOC ) && EQ_32( brate_intermed_tbl[i], ACELP_9k60 ) ) /* Bit allocation should be mapped to 8 kb/s instead of 9.6 kb/s in this case */
    {
        i = sub( i, 1 );
        i--;
    }

    mean_gain_fx = gsc_gainQ_ivas_fx( hBstr, st->element_mode, st->idchan, Ener_per_bd_iQ_fx, Ener_per_bd_iQ_fx, brate_intermed_tbl[i], st->coder_type, st->bwidth, st->L_frame, st->tdm_LRTD_flag, st->core_brate );
@@ -1129,18 +1180,18 @@ void gsc_enc_ivas_fx(
        j = emaximum_fx( Q12, concat_out_fx, shl( nb_subbands, 4 ), &L_tmp );
        IF( LE_16( add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ), ONE_IN_Q12 ) )
        {
            max_eq = 32767;
            max_eq = 32767; /* Q15 */
            move16();
        }
        ELSE
        {
            max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ) );
            max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out_fx[j] ), 41 /* 0.01f in Q12 */ ) ); /* Q15 */
        }
    }

    FOR( j = 0; j < nb_subbands; j++ )
    {
        Copy( concat_out_fx + i_mult( j, 16 ), exc_diffQ_fx + i_mult( max_ener_band[j], 16 ), 16 );
        Copy( concat_out_fx + i_mult( j, 16 ), exc_diffQ_fx + i_mult( max_ener_band[j], 16 ), 16 ); /* Q12 */

        IF( GT_16( max_ener_band[j], last_bin ) )
        {
@@ -1209,7 +1260,7 @@ void gsc_enc_ivas_fx(
    {
        FOR( i = 64; i < st->L_frame; i++ )
        {
            exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq );
            exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq ); /* Q12 */
            move16();
        }
    }
@@ -1217,7 +1268,7 @@ void gsc_enc_ivas_fx(
    {
        FOR( i = 0; i < L_FRAME; i++ )
        {
            exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq );
            exc_diffQ_fx[i] = mult( exc_diffQ_fx[i], max_eq ); /* Q12 */
            move16();
        }
    }
@@ -1229,13 +1280,13 @@ void gsc_enc_ivas_fx(
    Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in );
    IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) )
    {
        Scale_sig( hGSCEnc->last_exc_dct_in_fx, st->L_frame, sub( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) );
        Scale_sig( hGSCEnc->last_exc_dct_in_fx, st->L_frame, sub( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ); /* Q_exc_new */
        hGSCEnc->Q_last_exc_dct_in = Q_exc_new;
        move16();
    }
    ELSE
    {
        Scale_sig( exc_dct_in_fx, st->L_frame, sub( Q_exc_new, *Q_exc ) );
        Scale_sig( exc_dct_in_fx, st->L_frame, sub( Q_exc_new, *Q_exc ) ); /* Q_exc_new */
        *Q_exc = Q_exc_new;
        move16();
    }
@@ -1275,7 +1326,7 @@ void gsc_enc_ivas_fx(
/*=======================================================================*/

static Word16 edyn_fx(                    /* o  : ratio of max to mean    */
                       const Word16 *vec, /* i  : input vector            */
                       const Word16 *vec, /* i  : input vector            Qnew*/
                       const Word16 lvec, /* i  : length of input vector  */
                       Word16 Qnew )
{
@@ -1286,6 +1337,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */
    Word16 scale;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    ener_mean = L_shl( 1, shl( Qnew, 1 ) ); /*2*Qnew*/
@@ -1323,10 +1375,10 @@ static Word16 edyn_fx( /* o : ratio of max to mean */
    }
    ELSE
    {
        dyn = 1280;
        dyn = 1280; /* 10.0f in Q7 */
        move16();
    }
    return dyn;
    return dyn; /* Q7 */
}


@@ -1341,7 +1393,7 @@ void GSC_enc_init_fx(
)
{
    /* AC mode */
    hGSCEnc->seed_tcx = 15687;
    hGSCEnc->seed_tcx = 15687; /* Q0 */
    move16();
    hGSCEnc->cor_strong_limit = 1;
    move16();
@@ -1351,6 +1403,7 @@ void GSC_enc_init_fx(
    set16_fx( hGSCEnc->last_bitallocation_band, 0, 6 );

    hGSCEnc->mem_last_pit_band = BAND1k2 + 1;
    move16();
    hGSCEnc->Last_frame_ener_fx = MAX_32;
    move32();
    hGSCEnc->lt_gpitch_fx = 0;
@@ -1363,8 +1416,8 @@ void GSC_enc_init_fx(
    move16();

    set16_fx( hGSCEnc->mem_syn_tmp_fx, 0, M );
    hGSCEnc->mid_dyn_fx = 5120;
    move16(); /*40 -> Q7 */
    hGSCEnc->mid_dyn_fx = 5120; /*40 -> Q7 */
    move16();
    hGSCEnc->noise_lev = NOISE_LEVEL_SP0;
    move16();
    hGSCEnc->past_dyn_dec = 0;
+66 −58

File changed.

Preview size limit exceeded, changes collapsed.

+98 −93

File changed.

Preview size limit exceeded, changes collapsed.

+32 −32
Original line number Diff line number Diff line
@@ -51,17 +51,17 @@

void tdm_low_rate_enc(
    Encoder_State *st, /* i/o: State structure                         */
    const Word16 Aq[], /* i  : 12k8 Lp coefficient                     */
    const Word16 *res, /* i  : residual signal                         */
    Word16 *synth,     /* i/o: core synthesis                          */
    Word16 *exc_fx,    /* i/o: current non-enhanced excitation         */
    const Word16 Aq[], /* i  : 12k8 Lp coefficient                     Q12*/
    const Word16 *res, /* i  : residual signal                         Q_new*/
    Word16 *synth,     /* i/o: core synthesis                          Q_new*/
    Word16 *exc_fx,    /* i/o: current non-enhanced excitation         Q_new*/
    Word16 *pitch_buf,
    /* i/o: floating pitch values for each subframe */ // Q6
    Word16 *voice_factors,                             /* o  : voicing factors                         */
    Word16 *bwe_exc_fx,                                /* o  : excitation for SWB TBE                  */
    const Word16 attack_flag,                          /* i  : GSC attack flag                         */
    const Word16 *lsf_new,                             /* i  : current frame ISF vector                */
    Word16 *tmp_noise,                                 /* o  : long-term noise energy                  */
    Word16 *voice_factors,                             /* o  : voicing factors                         Q15*/
    Word16 *bwe_exc_fx,                                /* o  : excitation for SWB TBE                  Q_new*/
    const Word16 attack_flag,                          /* i  : GSC attack flag                         Q0*/
    const Word16 *lsf_new,                             /* i  : current frame ISF vector                Qx2.56*/
    Word16 *tmp_noise,                                 /* o  : long-term noise energy                  Q11*/
    Word16 Q_new )
{
    const Word16 *p_Aq;
@@ -88,7 +88,7 @@ void tdm_low_rate_enc(
    hLPDmem->tilt_code = 0;
    move16();
    set16_fx( dct_epit_fx, 0, L_FRAME );
    set16_fx( pitch_buf, L_SUBFR_Q6, NB_SUBFR );
    set16_fx( pitch_buf, L_SUBFR_Q6, NB_SUBFR ); /* Q6 */
    last_pit_bin = L_FRAME / 2;
    move16();

@@ -103,7 +103,7 @@ void tdm_low_rate_enc(
     *--------------------------------------------------------------------------------------*/

    /* Find the current total number of bits used */
    tmp_nb_bits_tot = st->hBstr->nb_bits_tot;
    tmp_nb_bits_tot = st->hBstr->nb_bits_tot; /* Q0 */
    move16();

    if ( st->extl_brate > 0 )
@@ -152,17 +152,17 @@ void tdm_low_rate_enc(
     * Synthesis
     *--------------------------------------------------------------------------------------*/

    p_Aq = Aq;
    p_Aq = Aq; /* Q12 */
    FOR( i_subfr = 0; i_subfr < L_FRAME; i_subfr += L_SUBFR )
    {
        E_UTIL_synthesis( 0, p_Aq, &exc_wo_nf_fx[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1, M );
        E_UTIL_synthesis( 0, p_Aq, &exc_wo_nf_fx[i_subfr], &synth[i_subfr], L_SUBFR, hLPDmem->mem_syn, 1, M ); /* Q_new */
        p_Aq += ( M + 1 );
    }

    /*--------------------------------------------------------------------------------------*
     * Updates
     *--------------------------------------------------------------------------------------*/
    Copy( exc_wo_nf_fx, exc_fx, L_FRAME );
    Copy( exc_wo_nf_fx, exc_fx, L_FRAME ); /* Q_new */

    return;
}
@@ -250,9 +250,9 @@ void encod_gen_2sbfr(
    coder_type = GENERIC;
    move16();

    p_Aw = Aw;
    p_Aq = Aq;
    pt_pitch = pitch_buf;
    p_Aw = Aw;            /* e(norm_s(Aw[0]+1) */
    p_Aq = Aq;            /* e(norm_s(Aw[0]+1) */
    pt_pitch = pitch_buf; /*Q6*/

    /*------------------------------------------------------------------*
     * ACELP subframe loop
@@ -314,7 +314,7 @@ void encod_gen_2sbfr(
        lp_filt_exc_enc_ivas_fx( MODE1, coder_type, i_subfr, exc, h1, xn, y1, xn2, 2 * L_SUBFR, L_frame, g_corr, clip_gain, &gain_pit, &st->acelp_cfg.ltf_mode );
#endif
        /* update long-term pitch gain for speech/music classifier */
        st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277, gain_pit ) ); // Q14
        st->hSpMusClas->lowrate_pitchGain = add( mult( 29491, st->hSpMusClas->lowrate_pitchGain ), mult( 3277 /*Q15*/, gain_pit ) ); // Q14
        move16();

        /*-----------------------------------------------------------------*
@@ -331,7 +331,7 @@ void encod_gen_2sbfr(

        IF( st->Opt_SC_VBR )
        {
            IF( EQ_16( st->hSC_VBR->last_ppp_mode, 1 ) )
            if ( EQ_16( st->hSC_VBR->last_ppp_mode, 1 ) )
            {
                /* SC-VBR - all other st->clip_var values will be updated even in a PPP frame */
                st->clip_var_fx[1] = gain_pit;
@@ -350,7 +350,7 @@ void encod_gen_2sbfr(
#else
        Lgcode = L_shl_sat( gain_code, Q_new );                                                                            /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_sat( Lgcode );                                                                                  /*Q0*/
        hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 );
        hLPDmem->tilt_code = est_tilt_ivas_fx( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, Q_new, 2 * L_SUBFR, 0 ); /* Q15 */
#endif
        move16();

@@ -388,7 +388,7 @@ void encod_gen_2sbfr(
        FOR( i = 0; i < 2 * L_SUBFR; i++ )
        {
            /* code in Q9, gain_pit in Q14 */
            exc2[i + i_subfr] = shl_sat( mult( gain_pit, exc[i + i_subfr] ), 1 );
            exc2[i + i_subfr] = shl_sat( mult( gain_pit, exc[i + i_subfr] ), 1 ); /* Q_new-1 */
            Ltmp = L_mult( gcode16, code[i] );                                    /* Q10 */
            Ltmp = L_shl_sat( Ltmp, 5 );                                          /* Q15 */
            Ltmp = L_mac_sat( Ltmp, exc[i + i_subfr], gain_pit );                 /* Q15 */
@@ -404,7 +404,7 @@ void encod_gen_2sbfr(

        prep_tbe_exc_ivas_fx( L_frame, L_SUBFR, i_subfr, gain_pit, gain_code, code, voice_fac, &voice_factors[i_subfr / L_SUBFR], bwe_exc, 0, NULL, Q_new, T0, T0_frac, coder_type, st->core_brate, st->element_mode, st->idchan, st->hBWE_TD != NULL, st->tdm_LRTD_flag );

        voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR];
        voice_factors[i_subfr / L_SUBFR + 1] = voice_factors[i_subfr / L_SUBFR]; /* Q15 */
        move16();

        /*-----------------------------------------------------------------*
@@ -428,8 +428,8 @@ void encod_gen_2sbfr(
    /* SC-VBR */
    IF( st->Opt_SC_VBR )
    {
        st->hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;
        st->hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code;
        st->hSC_VBR->prev_ppp_gain_pit_fx = gain_pit;        /* Q14 */
        st->hSC_VBR->prev_tilt_code_fx = hLPDmem->tilt_code; /* Q15 */
        move16();
        move16();
    }
+38 −35

File changed.

Preview size limit exceeded, changes collapsed.

Loading