Commit 28a7e8aa authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

BASOP and instrumentation changes in lib_dec after review

parent 767e9ea4
Loading
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -397,8 +397,8 @@ void HQ_FEC_processing_fx(
                    k = add( k, 1 );
#else
                    hHQ_nbfec->Norm_gain_fx[k++] = shl( tmp_fx, 1 );
#endif
                    move16();
#endif
                }
            }
            ELSE
@@ -641,7 +641,6 @@ void ivas_HQ_FEC_Mem_update_fx(
        FOR( i = k; i < num_Sb; i++ )
        {
            en_high_fx[i] = L_deposit_l( 0 );
            move32();
            FOR( j = 0; j < 2; j++ )
            {
                /*en_high[i] += 0.5f*st->ynrm_values[i][j+1];*/
@@ -787,7 +786,7 @@ void HQ_FEC_Mem_update_fx(
            }
        }
#ifndef ADD_IVAS_HQ_CODE_FEC
        if ( EQ_16( output_frame, L_FRAME8k ) )
        IF( EQ_16( output_frame, L_FRAME8k ) )
        {
#endif
            /* if LR MDCT core is used, recalculate norms from decoded MDCT spectrum (using code from hq_hr_enc_fx()) */
@@ -1161,7 +1160,6 @@ static Word16 Search_Max_Corr_fx(

        /*in = mu_o + 2*L -lin;     */
        in_fx = mu_o_fx + sub( shl( L, 1 ), lin );
        move16();

        /* generate correlation */
        delta = 2;
@@ -1171,7 +1169,7 @@ static Word16 Search_Max_Corr_fx(

        pos = find_best_delay_fx( mu_o_fx, in_fx, mind1, maxd1, lin, delta, &false_flag );

        IF( false_flag )
        if ( false_flag )
        {
            return 0;
        }
@@ -1199,7 +1197,6 @@ static Word16 Search_Max_Corr_fx(
        mind1 = mult_r( L, 14746 ); /* min value of delay d1 to search for */
        maxd1 = mult_r( L, 22938 ); /* max value of delay d1 to search for */
        in_fx = mu_o_fx + sub( shl( L, 1 ), lin );
        move16();

        /* generate correlation */
        delta = 2;
@@ -1209,7 +1206,7 @@ static Word16 Search_Max_Corr_fx(

        pos = find_best_delay_fx( mu_o_fx, in_fx, mind1, maxd1, lin, delta, &false_flag );

        IF( false_flag )
        if ( false_flag )
        {
            return 0;
        }
@@ -1276,7 +1273,7 @@ static Word16 FEC_phase_matching_fx(

    pos = Search_Max_Corr_fx( st_fx->old_auOut_2fr_fx, st_fx->old_Min_ind, L );

    IF( pos == 0 )
    if ( pos == 0 )
    {
        return 1;
    }
@@ -1659,7 +1656,7 @@ static Word16 Repetition_smoothing_fx(
    }


    IF( GT_32( pow22_fx, L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) ) )
    if ( GT_32( pow22_fx, L_add( pow1_fx, L_shl( pow1_fx, 1 ) ) ) )
    {
        return 1;
    }
+2 −3
Original line number Diff line number Diff line
@@ -333,7 +333,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag
    IF( add( start_search, pos ) < 0 )
    {
        start_search = negate( pos );
        IF( LT_16( abs_s( start_search ), shr( Old_pitch, 3 ) ) )
        if ( LT_16( abs_s( start_search ), shr( Old_pitch, 3 ) ) )
        {
            /* it's not safe to remove/add point inside 1/8 of the pulse position */
            return 0;
@@ -423,6 +423,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag
        {
            /* points_by_pos[i-1] = (Word16)(fact*(sqi[i-2]) - total_point+0.5) */
            points_by_pos[i - 1] = sub( shr( extract_l( L_mac0( 64L, fact, sqi[i - 2] ) ), 7 ), total_point );
            move16();
            total_point = add( total_point, points_by_pos[i - 1] );

            /* ensure a constant increase */
@@ -515,9 +516,7 @@ Word16 FEC_synchro_exc_fx( /* o : do_WI flag
            Copy( pt_exc1, pt_exc, tmp_len );
            remaining_len = sub( remaining_len, tmp_len );
            pt_exc1 += tmp_len;
            move16();
            pt_exc += tmp_len;
            move16();
            /* Remove points */
            FOR( j = 0; j < points_by_pos[i]; j++ )
            {
+14 −7
Original line number Diff line number Diff line
@@ -101,6 +101,9 @@ void FEC_clas_estim_fx(
    Word16 pos_limit;
    Word16 codec_mode, narrowBand, tcxonly, preemph_fac;
    Word16 memmax;
    move16();
    move16();
    move16();

    nb_subfr = shr( L_frame, 6 );
    memmax = 0;
@@ -181,6 +184,7 @@ void FEC_clas_estim_fx(

            Scale_sig( mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM, tmp_scale_mem );
            *Q_mem_syn = add( *Q_mem_syn, tmp_scale_mem );
            move16();
        }
    }

@@ -192,6 +196,7 @@ void FEC_clas_estim_fx(

    /*Tell MODE2 decoder the scaling of the buffer*/
    *Q_mem_syn = add( add( Q_syn, tmp_scale_syn ), tmp_scale );
    move16();

    /**Q_mem_syn = *Q_syn;  move16();*/

@@ -340,7 +345,7 @@ void FEC_clas_estim_fx(
                pc = shr( abs_s( sub( add( pitch[3], sub( pitch[2], pitch[1] ) ), pitch[0] ) ), 6 );
#endif

                if ( EQ_16( L_frame, L_FRAME16k ) )
                IF( EQ_16( L_frame, L_FRAME16k ) )
                {
                    pc = mult_r( pc, 26214 ); /* Renormalization for 12.8kHz core*/
                }
@@ -453,13 +458,14 @@ void FEC_clas_estim_fx(
#endif
            BASOP_SATURATE_WARNING_ON_EVS
            test();
            if ( EQ_16( codec_mode, MODE2 ) && narrowBand != 0 )
            IF( EQ_16( codec_mode, MODE2 ) && narrowBand != 0 )
            {
                fmerit1 = mult_r( fmerit1, 29491 /*0.9f Q15*/ ); /* 0.90 */
            }
            IF( EQ_16( codec_mode, MODE1 ) )
            {
                *class_para = round_fx( L_shl( Ltmp, 14 - 8 ) ); /*Q14 - cannot be saturated, degrades HF synthesis */
                move16();
            }

            /*------------------------------------------------------------------------*
@@ -467,7 +473,7 @@ void FEC_clas_estim_fx(
             *------------------------------------------------------------------------*/
            test();
            test();
            if ( ( NE_16( coder_type, VOICED ) && LT_32( bitrate, ACELP_11k60 ) ) || Opt_AMR_WB )
            IF( ( NE_16( coder_type, VOICED ) && LT_32( bitrate, ACELP_11k60 ) ) || Opt_AMR_WB )
            {
                Word16 result = UNVOICED_CLAS;
                move16();
@@ -539,7 +545,7 @@ void FEC_clas_estim_fx(
                move16();
            }

            if ( EQ_16( coder_type, INACTIVE ) )
            IF( EQ_16( coder_type, INACTIVE ) )
            {
                *decision_hyst = sub( *decision_hyst, 10 );
                move16();
@@ -669,6 +675,7 @@ void FEC_clas_estim_fx(
                    Ltmp = L_mac( Ltmp, 29491 /*0.9f*/, *LT_UV_cnt ); /* Q22*/
                    /* Store */
                    *LT_UV_cnt = round_fx( Ltmp );
                    move16();
                }

                /*-----------------------------------------------------------------------------*
@@ -862,7 +869,7 @@ Word16 FEC_pos_dec_fx(
            test();
            test();
            test();
            IF( EQ_16( st_fx->coder_type, GENERIC ) && EQ_16( st_fx->clas_dec, VOICED_CLAS ) && ( LE_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) )
            if ( EQ_16( st_fx->coder_type, GENERIC ) && EQ_16( st_fx->clas_dec, VOICED_CLAS ) && ( LE_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) )
            {
                st_fx->clas_dec = SIN_ONSET;
                move16();
@@ -876,7 +883,7 @@ Word16 FEC_pos_dec_fx(
            bit_pos_pitch_index = add( add( st_fx->next_bit_pos, FEC_BITS_POS ), nBits_es_Pred );
            test();
            test();
            IF( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) )
            if ( GE_32( st_fx->core_brate, MIN_BRATE_AVQ_EXC ) && LE_32( st_fx->core_brate, MAX_BRATE_AVQ_EXC_TD ) && EQ_16( st_fx->coder_type, GENERIC ) )
            {
                /* Harmonic flag is present */
                bit_pos_pitch_index = add( bit_pos_pitch_index, 1 );
@@ -900,7 +907,7 @@ Word16 FEC_pos_dec_fx(
                *last_pulse_pos = negate( s_and( *last_pulse_pos, 0x7F ) );
                move16();
            }
            if ( GE_16( T0, 128 ) )
            IF( GE_16( T0, 128 ) )
            {
                *last_pulse_pos = add( *last_pulse_pos, *last_pulse_pos );
                move16();
+14 −5
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ void FEC_exc_estim_fx(
        {
            /* take the pitch value of last subframe of the previous frame */
            *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR - 1], 6 ) );
            move16();
        }
    }
    ELSE /* L_frame == L_FRAME16k */
@@ -222,6 +223,7 @@ void FEC_exc_estim_fx(
        {
            /* take the pitch value of last subframe of the previous frame */
            *tmp_tc = round_fx( L_shl( st_fx->old_pitch_buf_fx[2 * NB_SUBFR16k - 1], 6 ) );
            move16();
        }
    }

@@ -357,6 +359,7 @@ void FEC_exc_estim_fx(
            /* move pitch gain towards 1 for voiced to remove energy fluctuations */
            /*gain = (float)sqrt( st_fx->lp_gainp );*/
            st_fx->lp_gainp_fx = s_max( st_fx->lp_gainp_fx, 1 );
            move16();
            exp = norm_s( st_fx->lp_gainp_fx );
            tmp = shl( st_fx->lp_gainp_fx, exp );
            tmp = div_s( 16384, tmp );
@@ -394,9 +397,7 @@ void FEC_exc_estim_fx(
    {

        pt_exc = exc;
        move16();
        pt1_exc = pt_exc - Tc;
        move16();

        IF( EQ_16( st_fx->nbLostCmpt, 1 ) )
        {
@@ -488,6 +489,7 @@ void FEC_exc_estim_fx(
        {
            /* exc[i] *= gain */
            exc[i] = round_fx( L_shl( L_mult( exc[i], gain ), 1 ) ); /* in Q_exc */
            move16();
            /* gain -= step */
            gain = sub( gain, step );
        }
@@ -543,6 +545,7 @@ void FEC_exc_estim_fx(
            gsc_dec_ivas_fx( st_fx, exc_dct_in, hGSCDec->Last_GSC_pit_band_idx, Diff_len, 0, tmp, st_fx->last_coder_type, &last_bin_fx, lsf_new, NULL, st_fx->Q_exc );
        }
        *tmp_noise = shr_r( st_fx->lp_gainc_fx, 3 ); /*Q0*/
        move16();
        /* Transform back to time domain */
        edct_16fx( exc_dct_in, exc, st_fx->L_frame, 5, st_fx->element_mode );
    }
@@ -574,6 +577,7 @@ void FEC_exc_estim_fx(
            L_tmp = L_mult( alpha, st_fx->lp_gainc_fx );

            st_fx->lp_gainc_fx = msu_r( L_tmp, add( alpha, -32768 ), gainCNG );
            move16();
        }
        ELSE
        { /* Here alpha is in Q14, but lp_gainc still in Q3 */
@@ -581,6 +585,7 @@ void FEC_exc_estim_fx(
            L_tmp = L_mult( alpha, st_fx->lp_gainc_fx ); /* Q14*Q3->Q18 */

            st_fx->lp_gainc_fx = round_fx( L_shl( L_msu( L_tmp, add( alpha, -16384 ), gainCNG ), 1 ) ); /* (Q14*Q3<<1)>>16 ->Q3 */
            move16();
        }

        test();
@@ -596,7 +601,7 @@ void FEC_exc_estim_fx(
        /* step = (1.0f/L_FRAME) * (gain - *lp_gainc); */
        step = sub( gain, st_fx->lp_gainc_fx ); /* divide by L_FRAME done later */
        test();
        if ( EQ_16( L_frame, L_FRAME16k ) )
        IF( EQ_16( L_frame, L_FRAME16k ) )
        {
            step = mult_r( step, 26214 ); /* L_frame16k-> L_frame and division by L_frame done later*/
        }
@@ -622,7 +627,7 @@ void FEC_exc_estim_fx(
            L_tmp = L_add( L_tmp, L_shr( L_tmp2, 1 ) ); /* Q-7 */
        }
        test();
        if ( EQ_16( L_frame, L_FRAME16k ) )
        IF( EQ_16( L_frame, L_FRAME16k ) )
        {
            L_tmp = Mult_32_16( L_tmp, 26214 ); /* x0.8 to normalize to 256 samples */
        }
@@ -636,7 +641,7 @@ void FEC_exc_estim_fx(
        /* attenuate somewhat on unstable unvoiced */
        test();
        test();
        if ( ( EQ_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && NE_16( st_fx->last_coder_type, UNVOICED ) )
        IF( ( EQ_16( st_fx->last_good, UNVOICED_CLAS ) || EQ_16( st_fx->last_good, INACTIVE_CLAS ) ) && NE_16( st_fx->last_coder_type, UNVOICED ) )
        {
            gain_inov = mult_r( gain_inov, 26214 );
        }
@@ -798,6 +803,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1
    Word32 tmp_pit2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif

    tmp_pit = BASOP_Util_Divide1616_Scale( new_pit /*Q0*/, Tc /*Q0*/, &tmp_pit_e ) /*Q15*/;
@@ -814,8 +820,10 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1
#endif
    BASOP_SATURATE_WARNING_ON_EVS
    *cond1 = sub( tmp_pit, negate( tmp_frame ) );
    move16();

    *cond2 = sub( Tc, new_pit );
    move16();

    tmp_pit_e = BASOP_Util_Add_MantExp( new_pit, 15 - 0, negate( Tc ), 15 - 0, &tmp_pit ); /*Q15*/
    tmp_pit = abs_s( tmp_pit );
@@ -829,6 +837,7 @@ static void pulseRes_preCalc( Word16 *cond1, Word16 *cond2, Word32 *cond3, Word1
#endif
    BASOP_SATURATE_WARNING_ON_EVS
    *cond3 = L_sub( L_mult0( -1, tmp_pit ), tmp_pit2 );
    move32();
}

/*-------------------------------------------------------------------*
+0 −1
Original line number Diff line number Diff line
@@ -172,7 +172,6 @@ void FEC_scale_syn_fx(
     * Find the energy/gain at the end of the frame
     *-----------------------------------------------------------------*/

    /*fer_energy( L_frame, clas, synth, pitch[(L_frame>>6)-1], &enr2, L_frame );*/
    frame_ener_fx( L_frame, clas, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 );

    test();
Loading