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

Q information updates for lib_enc files

parent 25a7924e
Loading
Loading
Loading
Loading
Loading
+30 −21
Original line number Diff line number Diff line
@@ -44,9 +44,9 @@

Word16 signal_clas_fx(                       /* o  : classification for current frames              */
                       Encoder_State *st,    /* i/o: encoder state structure                           */
                       const Word16 *speech, /* i  : pointer to speech signal for E computation        */
                       const Word32 *ee,     /* i  : lf/hf E ration for 2 half-frames                  */
                       const Word16 relE,    /* i  : frame relative E to the long term average         */
                       const Word16 *speech, /* i  : pointer to speech signal for E computation in Qx */
                       const Word32 *ee,     /* i  : lf/hf E ration for 2 half-frames in Q6            */
                       const Word16 relE,    /* i  : frame relative E to the long term average in Q8   */
                       const Word16 L_look,  /* i  : look-ahead                                        */
                       Word16 *clas_mod      /* o  : class flag for NOOP detection                     */
)
@@ -58,6 +58,7 @@ Word16 signal_clas_fx( /* o : classification for current
    const Word16 *pt1;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    /*----------------------------------------------------------------*
@@ -68,7 +69,7 @@ Word16 signal_clas_fx( /* o : classification for current
     *----------------------------------------------------------------*/

    /* average voicing on second half-frame and look-ahead */
    Ltmp = L_mult( st->voicing_fx[1], 16384 );
    Ltmp = L_mult( st->voicing_fx[1], 16384 ); /* Q15*Q14->Q30 */
    mean_voi2 = mac_r( Ltmp, st->voicing_fx[2], 16384 );

    /* average spectral tilt in dB */
@@ -101,7 +102,7 @@ Word16 signal_clas_fx( /* o : classification for current
    }

    /* compute zero crossing rate */
    pt1 = speech + L_look - 1;
    pt1 = speech + sub( L_look, 1 );
    tmpS = shr( *pt1, 15 ); /* sets 'tmpS to -1 if *pt1 < 0 */
    Ltmp = L_deposit_l( 0 );
    FOR( i = 0; i < L_FRAME; i++ )
@@ -116,7 +117,7 @@ Word16 signal_clas_fx( /* o : classification for current
    /* compute pitch stability */
    pc = add( abs_s( sub( st->pitch[1], st->pitch[0] ) ), abs_s( sub( st->pitch[2], st->pitch[1] ) ) );
    st->tdm_pc = pc;

    move16();
    /*-----------------------------------------------------------------*
     * Transform parameters to the range <0:1>
     * Compute the merit function
@@ -135,7 +136,7 @@ Word16 signal_clas_fx( /* o : classification for current
    zcn = s_max( zcn, 0 );
    zcn = s_min( zcn, 512 );

    Ltmp = L_mult( C_RELE_FX, 256 );                                /*Q15 ->Q24*/
    Ltmp = L_mult( C_RELE_FX, 256 );                                /*Q15*Q8 ->Q24*/
    relEn = round_fx( L_shl( L_mac( Ltmp, relE, K_RELE_FX ), 1 ) ); /*relE in Q8 but relEn in Q9*/
    /* Limit [0.5, 1] */
    relEn = s_max( relEn, 256 );
@@ -163,7 +164,8 @@ Word16 signal_clas_fx( /* o : classification for current
     * FEC classification
     *-----------------------------------------------------------------*/

    st->fmerit_dt = sub( st->prev_fmerit, fmerit1 );
    st->fmerit_dt = sub( st->prev_fmerit, fmerit1 ); /*Q15*/
    move16();
    st->prev_fmerit = fmerit1;
    move16();

@@ -254,14 +256,14 @@ Word16 signal_clas_fx( /* o : classification for current
    /* tc_cnt ==  1: onset/transition frame, coded by GC coder type */
    /* tc_cnt ==  2: frame after onset/transition frame, coded by TC coder type */

    if ( EQ_16( clas, UNVOICED_CLAS ) )
    if ( clas == 0 )
    {
        st->tc_cnt = 0;
        move16();
    }

    test();
    if ( GE_16( clas, VOICED_TRANSITION ) && st->tc_cnt >= 0 )
    IF( GE_16( clas, VOICED_TRANSITION ) && st->tc_cnt >= 0 )
    {
        st->tc_cnt = add( st->tc_cnt, 1 );
        move16();
@@ -323,7 +325,7 @@ void select_TC_fx(

void coder_type_modif_fx(
    Encoder_State *st, /* i/o: encoder state structure                     */
    const Word16 relE  /* i  : frame relative E to the long term average   */
    const Word16 relE  /* i  : frame relative E to the long term average Q8*/
)
{
    Word16 unmod_coder_type, vbr_generic_ho;
@@ -354,8 +356,12 @@ void coder_type_modif_fx(

        /* At higher rates, use GC coding instead of UC coding to improve quality */
        test();
        if ( ( EQ_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
             ( GT_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
        test();
        test();
        test();
        test();
        if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
             ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
        {
            st->coder_type = GENERIC;
            move16();
@@ -395,13 +401,13 @@ void coder_type_modif_fx(
        test();
        IF( EQ_16( st->Opt_SC_VBR, 1 ) )
        {
            test();
            if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) )
            {
                hSC_VBR->vbr_generic_ho = 1;
                move16();
            }

            test();
            if ( GT_16( st->coder_type, UNVOICED ) )
            {
                hSC_VBR->vbr_generic_ho = 0;
@@ -419,12 +425,12 @@ void coder_type_modif_fx(
        }
        //}  closing bracket here in IVAS float, but not in EVS float. currently affects BE for switching bitrate on Linux 20220929 _DIFF_FLOAT_FIX_ !!

        IF( EQ_16( st->element_mode, EVS_MONO ) )
        IF( st->element_mode == 0 )
        {
            /* At higher rates and with 16kHz core, allow only GC and TC coder type */
            test();
            test();
            test();
            // test();
            if ( GT_32( st->total_brate, ACELP_16k40 ) && NE_16( st->coder_type, GENERIC ) && NE_16( st->coder_type, TRANSITION ) )
            {
                /* onset/transition frame is always coded using GC mode */
@@ -435,6 +441,9 @@ void coder_type_modif_fx(
        ELSE /*IVAS*/
        {
            /* At higher bitrates, disable UC and VC coder type; note that IC coder type is classified later */
            test();
            test();
            test();
            if ( ( GT_32( st->total_brate, MAX_VOICED_BRATE ) && EQ_16( st->coder_type, VOICED ) ) ||
                 ( GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
            {
@@ -447,7 +456,7 @@ void coder_type_modif_fx(
        test();
        test();
        test();
        if ( EQ_16( st->coder_type, VOICED ) && EQ_16( st->input_bwidth, NB ) && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) )
        if ( EQ_16( st->coder_type, VOICED ) && st->input_bwidth == 0 && LT_16( relE, -2560 ) && LE_32( st->total_brate, ACELP_8k00 ) )
        {
            st->coder_type = GENERIC;
            move16();
@@ -493,8 +502,8 @@ void coder_type_modif_ivas_fx(
        test();
        test();
        test();
        if ( ( EQ_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
             ( GT_16( st->element_mode, EVS_MONO ) && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
        if ( ( st->element_mode == 0 && GT_32( st->total_brate, ACELP_9k60 ) && EQ_16( st->coder_type, UNVOICED ) ) ||
             ( st->element_mode > 0 && GT_32( st->total_brate, MAX_UNVOICED_BRATE ) && EQ_16( st->coder_type, UNVOICED ) ) )
        {
            st->coder_type = GENERIC;
            move16();
@@ -530,7 +539,7 @@ void coder_type_modif_ivas_fx(
            move16();
        }

        IF( EQ_16( st->Opt_SC_VBR, 1 ) )
        if ( EQ_16( st->Opt_SC_VBR, 1 ) )
        {
            test();
            if ( EQ_16( st->coder_type, GENERIC ) && EQ_16( unmod_coder_type, UNVOICED ) )
@@ -555,7 +564,7 @@ void coder_type_modif_ivas_fx(
            }
        }

        IF( EQ_16( st->element_mode, EVS_MONO ) )
        IF( st->element_mode == 0 )
        {
            /* At higher rates and with 16kHz core, allow only GC and TC coder type */
            test();
+22 −17
Original line number Diff line number Diff line
@@ -18,9 +18,9 @@
 *-------------------------------------------------------------------*/

void spec_center_fx(
    Word32 *sb_power,      /* i  : energy of sub-band divided uniformly*/
    Word16 *sp_center,     /* o  : spectral center*/
    const Word32 bw_index, /* i  : band width*/
    Word32 *sb_power,      /* i  : energy of sub-band divided uniformly		Q31 */
    Word16 *sp_center,     /* o  : spectral center	Q10 */
    const Word32 bw_index, /* i  : band width	Q0 */
    const Word16 Q_sb_p    /* i  : the Scaling of sb_power*/
)
{
@@ -48,15 +48,15 @@ void spec_center_fx(

    FOR( i = 0; i < 10; i++ )
    {
        sb_power_shr[i] = L_shr( sb_power[i], 5 );
        sb_power_shr[i] = L_shr( sb_power[i], 5 ); /* Q26 */
        move32();
    }

    FOR( i = 0; i < 10; i++ )
    {
        sb_power_mlt = Mpy_32_16_1( sb_power[i], i_t_1[i] );
        t_sp_center = L_add( L_shr( sb_power_mlt, 6 ), t_sp_center );
        frame_power = L_add( sb_power_shr[i], frame_power ); /*0-9 */
        sb_power_mlt = Mpy_32_16_1( sb_power[i], i_t_1[i] );          /* Q16 + QB */
        t_sp_center = L_add( L_shr( sb_power_mlt, 6 ), t_sp_center ); /* Q11 + QB */
        frame_power = L_add( sb_power_shr[i], frame_power ); /*0-9 */ /* Q26 */
    }

    t_sp_center_nb = t_sp_center;
@@ -68,16 +68,17 @@ void spec_center_fx(
    Q_t_sc = sub( Q_sb_p, 10 );
    IF( GE_16( Q_t_sc, 34 ) )
    {
        t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) );
        zerop1 = L_shr( CNT0P1, 1 );
        t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) ); /* Q44 + QB - Q_t_sc)*/
        zerop1 = CNT0P1 >> 1;                                  /* Q33 */
        move32();
        Q_t_sc = 33;
        move16();
    }
    ELSE
    {
        Q_t_sc = sub( Q_t_sc, 1 );
        t_sp_center = L_shr( t_sp_center, 1 );
        zerop1 = L_shr( CNT0P1, sub( 34, Q_t_sc ) );
        Q_t_sc = sub( Q_t_sc, 1 );                   /* Q_t_sc - 1 */
        t_sp_center = L_shr( t_sp_center, 1 );       /* Q10 + QB */
        zerop1 = L_shr( CNT0P1, sub( 34, Q_t_sc ) ); /* Q_t_sc */
    }
    t_sp_center_num = L_add( t_sp_center, zerop1 );

@@ -85,7 +86,8 @@ void spec_center_fx(
    IF( GE_16( Q_f_p, 34 ) )
    {
        frame_power = L_shr( frame_power, sub( Q_f_p, 33 ) );
        zerop1 = L_shr( CNT0P1, 1 );
        zerop1 = ( CNT0P1 >> 1 );
        move32();
        Q_f_p = 33;
        move16();
    }
@@ -120,9 +122,9 @@ void spec_center_fx(

    d_t_sp_center = shr( d_t_sp_center, d_t_sp_center_Qtmp );
    sp_center[0] = add( mult( sp_center[0], 0x5999 ), mult( d_t_sp_center, 0x2666 ) );
    move16();
    sp_center[2] = d_t_sp_center;
    move16();
    move16();

    t_sp_center = 0;
    move32();
@@ -148,7 +150,8 @@ void spec_center_fx(
        IF( GE_16( Q_t_sc, 34 ) )
        {
            t_sp_center = L_shr( t_sp_center, sub( Q_t_sc, 33 ) );
            zerop1 = L_shr( CNT0P1, 1 );
            zerop1 = ( CNT0P1 >> 1 );
            move32();
            Q_t_sc = 33;
            move16();
        }
@@ -221,7 +224,8 @@ void spec_center_fx(
        IF( GE_16( Q_t_sc, 34 ) )
        {
            t_sp_center = L_shr( t_sp_center, limitScale32( sub( Q_t_sc, 33 ) ) );
            zerop1 = L_shr( CNT0P1, 1 );
            zerop1 = ( CNT0P1 >> 1 );
            move32();
            Q_t_sc = 33;
            move16();
        }
@@ -237,7 +241,8 @@ void spec_center_fx(
        IF( GE_16( Q_f_p, 34 ) )
        {
            frame_power = L_shr( frame_power, sub( Q_f_p, 33 ) );
            zerop1 = L_shr( CNT0P1, 1 );
            zerop1 = ( CNT0P1 >> 1 );
            move32();
            Q_f_p = 33;
            move16();
        }
+4 −4
Original line number Diff line number Diff line
@@ -1370,14 +1370,14 @@ void wb_tbe_enc_ivas_fx(

    autocorr_fx( hb_old_speech, LPC_SHB_ORDER_WB + 1, R_h, R_l, &Q_R, ( ( NS2SA( INT_FS_12k8, 5000000L ) + L_SUBFR + L_FRAME ) * 5 / 16 ), win_lpc_hb_wb_fx, 0, 1 );

    E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL );
    E_LPC_lev_dur( R_h, R_l, lpc_wb_temp_fx, LepsP, LPC_SHB_ORDER_WB, NULL ); // Since 0th index will be 1 in floating point buffer, in fixed point one has to take norm of 0th index to identify the Q-factor

    Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) );
    Copy_Scale_sig( lpc_wb_temp_fx, lpc_wb_temp_fx, LPC_SHB_ORDER_WB + 1, sub( norm_s( lpc_wb_temp_fx[0] ), 2 ) ); // Q12

    /* convert into lsps and calculate weights */
    FOR( i = 0; i <= LPC_SHB_ORDER_WB; i++ )
    {
        lpc_wb_32_fx[i] = L_negate( L_shr( L_deposit_h( lpc_wb_temp_fx[i] ), 1 ) );
        lpc_wb_32_fx[i] = L_negate( L_deposit_h( L_shr( lpc_wb_temp_fx[i], 1 ) ) ); // Q27
        move32();
    }

+45 −13
Original line number Diff line number Diff line
@@ -57,6 +57,13 @@ ivas_error tcq_core_LR_enc_fx(
    Word32 Rk_sort_fx[NB_SFM];
    Word32 step_scale_fx[NB_SFM];
    Word16 pulses_fx, nzp_fx;
    move16();
    move16();
    move16();
    move16();
    move16();
    move16();
    move32();

    Word32 gain_fx, crosscorr_fx, selfcorr_fx;
    Word16 hi, lo, exp;
@@ -66,6 +73,9 @@ ivas_error tcq_core_LR_enc_fx(
    Word32 sepbits = 0;
    Word32 divider = 0;
    ivas_error error;
    move32();
    move32();
    move32();

    error = IVAS_ERR_OK;
    move16();
@@ -82,7 +92,7 @@ ivas_error tcq_core_LR_enc_fx(

    test();
    test();
    IF( input_frame <= L_FRAME16k && adjustFlag == 0 && is_transient == 0 )
    IF( LE_16( input_frame, L_FRAME16k ) && adjustFlag == 0 && is_transient == 0 )
    {
        flag_wbnb = 1;
        move16();
@@ -100,6 +110,8 @@ ivas_error tcq_core_LR_enc_fx(
    move16();
    pbs_fx->numbits = L_deposit_l( 0 );
    pbs_fx->numByte = L_deposit_l( 0 );
    move32();
    move32();
    FOR( i = 0; i < MAX_SIZEBUF_PBITSTREAM; i++ )
    {
        pbs_fx->buf[i] = 0;
@@ -134,7 +146,7 @@ ivas_error tcq_core_LR_enc_fx(
    {
        IF( R_fx[j] > 0 )
        {
            nzb++;
            nzb = add( nzb, 1 );
        }
    }

@@ -148,11 +160,13 @@ ivas_error tcq_core_LR_enc_fx(
        IF( R_fx[j] > 0 )
        {
            R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) );
            move32();

            IF( R_fx[j] < 0 )
            {
                bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) );
                R_fx[j] = L_deposit_l( 0 );
                move32();
            }
            ELSE
            {
@@ -186,10 +200,11 @@ ivas_error tcq_core_LR_enc_fx(
        move16();
        FOR( j = 0; j < BANDS; j++ )
        {
            test();
            IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) )
            {
                leftbits = L_add( leftbits, R_fx[k_sort[j]] );
                if ( R_fx[k_sort[j]] > 0 )
                IF( R_fx[k_sort[j]] > 0 )
                {
                    nzbands = add( nzbands, 1 );
                }
@@ -226,7 +241,7 @@ ivas_error tcq_core_LR_enc_fx(
                    encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
                    encode_magnitude_tcq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, savedstates, &est_frame_bits_fx );
                    encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
                    nzbands--;
                    nzbands = sub( nzbands, 1 );
                }
                /* Have USQ coded band */
                ELSE IF( R_fx[k_sort[k]] > 0 && EQ_16( USQ_TCQ[k_sort[k]], 1 ) )
@@ -245,7 +260,7 @@ ivas_error tcq_core_LR_enc_fx(
                    encode_position_ari_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, &est_frame_bits_fx );
                    encode_magnitude_usq_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, npulses[k_sort[k]], nzp_fx, &est_frame_bits_fx );
                    encode_signs_fx( parenc_fx, &coefs_norm_dec_fx[sfm_start[k_sort[k]]], size, nzp_fx, &est_frame_bits_fx );
                    nzbands--;
                    nzbands = sub( nzbands, 1 );
                }
                ELSE /* Then have  zero block  */
                {
@@ -260,13 +275,15 @@ ivas_error tcq_core_LR_enc_fx(
                IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 )
                {
                    /* delta_fx   = L_deposit_h( div_l( surplus_fx, nzbands ) ); */
                    IF( nzbands <= 1 )
                    IF( LE_16( nzbands, 1 ) )
                    {
                        divider = 0;
                        move32();
                    }
                    ELSE
                    {
                        divider = 2;
                        move32();
                    }

                    IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 )
@@ -274,7 +291,7 @@ ivas_error tcq_core_LR_enc_fx(
                        /* Overflow possible => start to distribute negative surplus */
                        delta_fx = ar_div( surplus_fx + sepbits, nzbands );
                    }
                    else
                    ELSE
                    {
                        delta_fx = 0;
                    }
@@ -290,12 +307,15 @@ ivas_error tcq_core_LR_enc_fx(
        {
            bit_surplus_fx[0] = Mult_32_16( surplus_fx, 24576 ); /* Q16 */
            bit_surplus_fx[1] = Mult_32_16( surplus_fx, 8192 );  /* Q16 */
            move32();
            move32();
        }
        ELSE
        {
            bit_surplus_fx[0] = surplus_fx;
            move32();
            bit_surplus_fx[1] = L_deposit_l( 0 );
            move32();
        }

        FOR( k = 0; k < BANDS; k++ )
@@ -305,6 +325,7 @@ ivas_error tcq_core_LR_enc_fx(
                IF( EQ_16( k, k_num[j] ) )
                {
                    R_fx[k_sort[k]] = L_add( R_fx[k_sort[k]], bit_surplus_fx[j] );
                    move32();

                    test();
                    test();
@@ -409,7 +430,9 @@ ivas_error tcq_core_LR_enc_fx(
    FOR( i = 0; i < L_FRAME32k; i++ )
    {
        coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) );
        move16();
    }

    IF( !flag_wbnb )
    {
        FOR( k = 0; k < BANDS; k++ )
@@ -467,6 +490,7 @@ ivas_error tcq_core_LR_enc_fx(
                move16();
                coefs_quant_fx[sfm_start[k_sort[i]] + j] = L_add( L_shl( L_mult0( hi, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 12 ),
                                                                  L_shr( L_mult0( lo, coefs_norm_dec_fx[sfm_start[k_sort[i]] + j] ), 3 ) ); /* Q12 */
                move32();
            }
        }
    }
@@ -518,7 +542,7 @@ ivas_error tcq_core_LR_enc_ivas_fx(
    move16();
    move16();
    move16();
    move16();
    move32();
    Word32 abuffer_fx[MAX_PULSES];
    Word16 mbuffer_fx[MAX_PULSES];
    Word32 sbuffer_fx[MAX_PULSES];
@@ -534,9 +558,9 @@ ivas_error tcq_core_LR_enc_ivas_fx(
    Word32 leftbits = 0;
    Word32 sepbits = 0;
    Word32 divider = 0;
    move16();
    move16();
    move16();
    move32();
    move32();
    move32();
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -622,11 +646,13 @@ ivas_error tcq_core_LR_enc_ivas_fx(
        IF( R_fx[j] > 0 )
        {
            R_fx[j] = L_sub( R_fx[j], ar_div( bsub_fx, nzb ) );
            move32();

            IF( R_fx[j] < 0 )
            {
                bsub_fx = L_sub( bsub_fx, L_add( ar_div( bsub_fx, nzb ), R_fx[j] ) );
                R_fx[j] = L_deposit_l( 0 );
                move32();
            }
            ELSE
            {
@@ -660,10 +686,11 @@ ivas_error tcq_core_LR_enc_ivas_fx(
        move16();
        FOR( j = 0; j < BANDS; j++ )
        {
            test();
            IF( NE_16( j, k_num[0] ) && NE_16( j, k_num[1] ) )
            {
                leftbits = L_add( leftbits, R_fx[k_sort[j]] );
                if ( R_fx[k_sort[j]] > 0 )
                IF( R_fx[k_sort[j]] > 0 )
                {
                    nzbands = add( nzbands, 1 );
                }
@@ -734,13 +761,15 @@ ivas_error tcq_core_LR_enc_ivas_fx(
                IF( R_fx[k_sort[k]] > 0 && surplus_fx < 0 )
                {
                    /* delta_fx   = L_deposit_h( div_l( surplus_fx, nzbands ) ); */
                    IF( nzbands <= 1 )
                    IF( LE_16( nzbands, 1 ) )
                    {
                        divider = 0;
                        move32();
                    }
                    ELSE
                    {
                        divider = 2;
                        move32();
                    }

                    IF( L_add( L_add( surplus_fx, sepbits ), ar_div( leftbits, divider ) ) < 0 )
@@ -888,7 +917,9 @@ ivas_error tcq_core_LR_enc_ivas_fx(
    FOR( i = 0; i < L_FRAME32k; i++ )
    {
        coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) );
        move16();
    }

    IF( !flag_wbnb )
    {
        FOR( k = 0; k < BANDS; k++ )
@@ -903,6 +934,7 @@ ivas_error tcq_core_LR_enc_ivas_fx(
    }

    nb_bytes = shr( bit_budget, 3 );

    j = sub( bit_budget, shl( nb_bytes, 3 ) );
    FOR( i = 0; i < nb_bytes; i++ )
    {
+28 −13
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ static void tcx_ltp_pitch_search(
    Word16 wsp2[L_FRAME_PLUS + PIT_MAX_MAX + L_INTERPOL1];
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif


@@ -129,12 +130,15 @@ static void tcx_ltp_pitch_search(
        move16();
    }
    wsp = wsp2 + t_max;
    move16();

    pt_cor = cor;
    move32();

    FOR( t = t_min; t <= t_max; t++ )
    {
        *pt_cor = dot( wsp, wsp - t, len );
        move32();
        pt_cor++;
    }

@@ -142,13 +146,16 @@ static void tcx_ltp_pitch_search(
    cor_max = L_add( *pt_cor++, 0 );
    t1 = t0_min;
    move16();
    move32();

    FOR( t = add( t0_min, 1 ); t <= t0_max; t++ )
    FOR( t = t0_min + 1; t <= t0_max; t++ )
    {
        IF( *pt_cor > cor_max )
        IF( GT_32( *pt_cor, cor_max ) )
        {
            cor_max = *pt_cor;
            move32();
            t1 = t;
            move16();
        }
        pt_cor++;
    }
@@ -227,7 +234,7 @@ static void tcx_ltp_pitch_search(
        t0 = sub( t0, 1 );
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );

        FOR( i = add( fraction, step ); i < pitres; i += step )
        FOR( i = fraction + step; i < pitres; i += step )
        {
            temp = interpolate_corr( &pt_cor[t0], i, pitres );

@@ -241,6 +248,7 @@ static void tcx_ltp_pitch_search(
    }

    i = 0;
    move16();
    FOR( i = 0; i < pitres; i += step ) /* Process positive fractions */
    {
        temp = interpolate_corr( &pt_cor[t1], i, pitres );
@@ -341,6 +349,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
    FOR( t = t_min; t <= t_max; t++ )
    {
        *pt_cor = dot( wsp, wsp - t, len ); // 2*(x + s_wsp)
        move32();
        pt_cor++;
    }

@@ -349,7 +358,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
    t1 = t0_min;
    move16();

    FOR( t = add( t0_min, 1 ); t <= t0_max; t++ )
    FOR( t = t0_min + 1; t <= t0_max; t++ )
    {
        IF( GT_32( *pt_cor, cor_max ) )
        {
@@ -415,6 +424,7 @@ static void tcx_ltp_pitch_search_ivas_fx(

        *index = add( sub( t1, pitfr1 ), extract_l( L_mac0( L_mult0( sub( pitfr2, pitmin ), pitres ),
                                                            sub( pitfr1, pitfr2 ), shr( pitres, 1 ) ) ) );
        move16();

        return;
    }
@@ -450,7 +460,7 @@ static void tcx_ltp_pitch_search_ivas_fx(
        t0 = sub( t0, 1 );
        cor_max = interpolate_corr( &pt_cor[t0], fraction, pitres );

        FOR( i = add( fraction, step ); i < pitres; i += step )
        FOR( i = fraction + step; i < pitres; i += step )
        {
            temp = interpolate_corr( &pt_cor[t0], i, pitres );

@@ -487,10 +497,12 @@ static void tcx_ltp_pitch_search_ivas_fx(
        *index = add( extract_l( L_mac0( L_mult0( sub( t0, pitfr2 ), shr( pitres, 1 ) ),
                                         sub( pitfr2, pitmin ), pitres ) ),
                      shr( fraction, 1 ) );
        move16();
    }
    ELSE
    {
        *index = add( imult1616( sub( t0, pitmin ), pitres ), fraction );
        move16();
    }
}

@@ -501,6 +513,7 @@ static void tcx_ltp_find_gain( Word16 *speech, Word16 *pred_speech, Word16 L_fra
    Word16 i, g, s1, s2, tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif


@@ -672,6 +685,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on,
    Word16 alpha, step;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif


@@ -801,14 +815,14 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on,
        *ltp_bits = 0;
        move16();
        test();
        if ( tcxltp_on != 0 || SideInfoOnly != 0 )
        IF( tcxltp_on != 0 || SideInfoOnly != 0 )
        {
            *ltp_bits = 1;
            move16();
        }
    }

    if ( SideInfoOnly != 0 )
    IF( SideInfoOnly != 0 )
    {
        *gain = 0;
        move16();
@@ -826,7 +840,7 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on,

        /* step = 1.f/(float)(L_subfr); */
        step = shl( 2, norm_s( L_subfr ) );
        if ( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 )
        IF( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 )
        {
            step = mult_r( step, 26214 /*64.f/80.f Q15*/ );
        }
@@ -882,14 +896,15 @@ void tcx_ltp_encode_fx( Word16 tcxltp_on,
        E_UTIL_synthesis( 0, A, zir, zir, L_subfr, buf_zir, 0, lpcorder );

        alpha = 0x7FFF;
        move16();
        /* step = 1.f/(float)(L_subfr/2); */
        step = shl( 4, norm_s( L_subfr ) );
        if ( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 )
        IF( s_and( L_subfr, sub( L_subfr, 1 ) ) != 0 )
        {
            step = mult_r( step, 26214 /*64.f/80.f Q15*/ );
        }

        FOR( n = shr( L_subfr, 1 ); n < L_subfr; n++ )
        FOR( n = ( L_subfr >> 1 ); n < L_subfr; n++ )
        {
            zir[n] = mult_r( zir[n], alpha );
            move16();
@@ -1040,13 +1055,12 @@ void tcx_ltp_encode_ivas_fx(
                IF( GT_16( norm_corr_2_fx[1], norm_corr_2_fx[0] ) )
                {
                    i = 1;
                    move16();
                }
                ELSE
                {
                    i = 0;
                    move16();
                }
                move16();

                hTcxEnc->tcxltp_pitch_int = pitch_int_2[i];
                move16();
@@ -1055,6 +1069,7 @@ void tcx_ltp_encode_ivas_fx(
                ltp_param[1] = pit_param_2[i];
                move16();
                norm_corr_fx = norm_corr_2_fx[i];
                move16();
            }
        }
        ELSE
@@ -1304,7 +1319,7 @@ void tcx_ltp_encode_ivas_fx(
                step_fx = mult_r( step_fx, 26214 /*64.f/80.f Q15*/ );
            }

            FOR( n = shr( L_subfr, 1 ); n < L_subfr; n++ )
            FOR( n = L_subfr >> 1; n < L_subfr; n++ )
            {
                zir_fx[n] = mult_r( zir_fx[n], alpha_fx );
                move16();
Loading