Commit 33116eaa authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'hq_core_dec_fxd' into 'main'

hq_core_dec fixed implementation

See merge request !168
parents 13a8c860 5144c09b
Loading
Loading
Loading
Loading
Loading
+263 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@
#include "wmc_auto.h"
#include "prot_fx1.h"
#include "prot_fx2.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif

/*--------------------------------------------------------------------------*
 * fill_spectrum()
@@ -267,6 +270,266 @@ void fill_spectrum(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void ivas_fill_spectrum_fx(
    Word16 *coeff,                    /* i/o: normalized MLT spectrum / nf spectrum                Q12 */
    Word32 *L_coeff_out,              /* i/o: Noisefilled MLT spectrum                             Q12 */
    const Word16 *R,                  /* i  : number of pulses per band                            Q0  */
    const Word16 is_transient,        /* i  : transient flag                                       Q0  */
    Word16 norm[],                    /* i  : quantization indices for norms                       Q0  */
    const Word16 *hq_generic_fenv,    /* i  : HQ GENERIC envelope                                  Q1  */
    const Word16 hq_generic_offset,   /* i  : HQ GENERIC offset                                    Q0  */
    const Word16 nf_idx,              /* i  : noise fill index                                     Q0  */
    const Word16 length,              /* i  : Length of spectrum (32 or 48 kHz)                    Q0  */
    const Word16 env_stab,            /* i  : Envelope stability measure [0..1]                    Q15 */
    Word16 *no_att_hangover,          /* i/o: Frame counter for attenuation hangover               Q0  */
    Word32 *L_energy_lt,              /* i/o: Long-term energy measure for transient detection     Q13 */
    Word16 *bwe_seed,                 /* i/o: random seed for generating BWE input                 Q0  */
    const Word16 hq_generic_exc_clas, /* i  : BWE excitation class                                 Q0  */
    const Word16 core_sfm,            /* i  : index of the end band for core                       Q0  */
    const Word16 HQ_mode,             /* i  : HQ mode                                              Q0  */
    Word16 noise_level[],             /* i  : noise levels for harmonic modes                      Q15 */
    const Word32 L_core_brate,        /* i  : target bit-rate                                      Q0  */
    Word16 prev_noise_level[],        /* i/o: noise factor in previous frame                       Q15 */
    Word16 *prev_R,                   /* i/o: bit allocation info. in previous frame               Q0  */
    Word32 *prev_coeff_out,           /* i/o: decoded spectrum in previous frame                   Q12 */
    const Word16 *peak_idx,           /* i  : peak indices for hvq                                 Q0  */
    const Word16 Npeaks,              /* i  : number of peaks in hvq                               Q0  */
    const Word16 *npulses,            /* i  : number of pulses per band                            Q0  */
    const Word16 prev_is_transient,   /* i  : previous transient flag                              Q0  */
    Word32 *prev_normq,               /* i/o: previous norms                                       Q14 */
    Word32 *prev_env,                 /* i/o: previous noise envelopes                             Q(prev_env_Q) */
    const Word16 prev_bfi,            /* i  : previous bad frame indicator                         Q0  */
    const Word16 *sfmsize,            /* i  : Length of bands                                      Q0  */
    const Word16 *sfm_start,          /* i  : Start of bands                                       Q0  */
    const Word16 *sfm_end,            /* i  : End of bands                                         Q0  */
    Word16 *prev_L_swb_norm,          /* i/o: HVQ/Harmonic mode normalization length               Q0  */
    const Word16 prev_hq_mode,        /* i  : Previous HQ mode                                     Q0  */
    const Word16 num_sfm,             /* i  : Total number of bands                                Q0  */
    Word16 *prev_env_Q,
    const Word16 num_env_bands, /* i  : Number sub bands to be encoded for HQ_GEN            Q0  */
    const Word16 element_mode   /* i  : IVAS element mode */
)
{
    Word16 CodeBook[L_SPEC48k_EXT]; /* Q12 */
    Word16 cb_size;
    Word16 last_sfm;
    Word16 CodeBook_mod[L_SPEC48k_EXT]; /*Q12 */
    Word16 norm_adj[NB_SFM];            /*Q15 */
    Word16 high_sfm;
    Word16 flag_32K_env_hangover;
    Word16 bin_th;
    Word16 peak_pos[L_HARMONIC_EXC];
    Word16 bwe_peaks[L_FRAME48k];
    Word32 L_normq_v[NB_SFM];           /*Q14 */
    Word16 coeff_fine[L_SPEC48k_EXT];   /*Q15 */
    Word32 L_coeff_out1[L_SPEC48k_EXT]; /*Q12 */
    set16_fx( peak_pos, 0, L_HARMONIC_EXC );
    set16_fx( bwe_peaks, 0, L_FRAME48k );
    set16_fx( norm_adj, 32767, num_sfm ); /* 1.0, Q15 */
    cb_size = 0;
    move16();
    bin_th = 0;
    move16();
    high_sfm = 23;
    move16();

    test();
    IF( EQ_16( HQ_mode, HQ_TRANSIENT ) )
    {
        last_sfm = sub( num_sfm, 1 );
    }
    ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) )
    {
        last_sfm = s_max( core_sfm, sub( num_env_bands, 1 ) );
    }
    ELSE
    {
        last_sfm = core_sfm;
        move16();
    }

    IF( EQ_16( HQ_mode, HQ_HARMONIC ) )
    {
        /*high_sfm = (core_brate == HQ_BWE_CROSSOVER_BRATE) ? HVQ_THRES_SFM_24k-1 : HVQ_THRES_SFM_32k-3; */
        high_sfm = sub( HVQ_THRES_SFM_32k, 1 );
        IF( LT_32( L_core_brate, HQ_BWE_CROSSOVER_BRATE ) )
        {
            high_sfm = sub( HVQ_THRES_SFM_24k, 1 );
        }

        IF( LT_16( last_sfm, high_sfm ) )
        {
            last_sfm = high_sfm;
            move16();
        }
    }
    ELSE IF( EQ_16( HQ_mode, HQ_HVQ ) )
    {
        bin_th = sfm_end[last_sfm];
        move16();
    }

    /* Transient analysis for envelope stability measure */
    IF( EQ_16( length, L_FRAME32k ) )
    {
        env_stab_transient_detect_fx( is_transient, length, norm, no_att_hangover, L_energy_lt, HQ_mode, bin_th, L_coeff_out, 12 );
    }

    test();
    test();
    test();
    test();
    IF( EQ_16( length, L_FRAME16k ) ||
        ( ( EQ_16( length, L_FRAME32k ) && NE_16( HQ_mode, HQ_HARMONIC ) && NE_16( HQ_mode, HQ_HVQ ) ) && EQ_16( *no_att_hangover, 0 ) ) )
    {
        /* Norm adjustment function */
        env_adj_fx( npulses, length, last_sfm, norm_adj, env_stab, sfmsize );
    }

    /*flag_32K_env_hangover = ( length == L_FRAME32k && ( (env_stab < 0.5f && *no_att_hangover == 0) || HQ_mode == HQ_HVQ ) );   */
    flag_32K_env_hangover = 0;
    move16();
    test();
    test();
    test();
    IF( EQ_16( length, L_FRAME32k ) && ( ( LT_16( env_stab, 16384 ) && *no_att_hangover == 0 ) || EQ_16( HQ_mode, HQ_HVQ ) ) )
    {
        flag_32K_env_hangover = 1;
        move16();
    }


    /*----------------------------------------------------------------*
     * Build noise-fill codebook
     *----------------------------------------------------------------*/

    IF( NE_16( HQ_mode, HQ_HVQ ) )
    {
        cb_size = build_nf_codebook_fx( flag_32K_env_hangover, coeff, sfm_start, sfmsize, sfm_end, last_sfm, R, CodeBook, CodeBook_mod );
    }
    /*----------------------------------------------------------------*
     * Prepare fine structure for Harmonic and HVQ
     *----------------------------------------------------------------*/

    IF( EQ_16( HQ_mode, HQ_HARMONIC ) )
    {
        harm_bwe_fine_fx( R, last_sfm, high_sfm, num_sfm, norm, sfm_start, sfm_end, prev_L_swb_norm, coeff, L_coeff_out, coeff_fine );
    }
    ELSE IF( EQ_16( HQ_mode, HQ_HVQ ) )
    {
        hvq_bwe_fine_fx( last_sfm, num_sfm, sfm_end, peak_idx, Npeaks, peak_pos, prev_L_swb_norm, L_coeff_out, bwe_peaks, coeff_fine );
    }

    /*----------------------------------------------------------------*
     * Apply noise-fill
     *----------------------------------------------------------------*/

    test();
    IF( NE_16( HQ_mode, HQ_HVQ ) && GT_16( cb_size, 0 ) )
    {
        apply_noisefill_HQ_fx( R, length, flag_32K_env_hangover, L_core_brate, last_sfm, CodeBook,
                               CodeBook_mod, cb_size, sfm_start, sfm_end, sfmsize, coeff );
    }

    /*----------------------------------------------------------------*
     * Normal mode BWE
     *----------------------------------------------------------------*/

    IF( EQ_16( HQ_mode, HQ_NORMAL ) )
    {
        hq_fold_bwe_fx( last_sfm, sfm_end, num_sfm, coeff );
    }

    /*----------------------------------------------------------------*
     * Apply noise-fill adjustment
     *----------------------------------------------------------------*/

    test();
    test();
    test();
    IF( ( GE_16( length, L_FRAME32k ) || GT_32( L_core_brate, HQ_32k ) || LT_32( L_core_brate, HQ_24k40 ) ) && NE_16( HQ_mode, HQ_HVQ ) )
    {
        apply_nf_gain_fx( nf_idx, last_sfm, R, sfm_start, sfm_end, coeff );
    }

    /*----------------------------------------------------------------*
     * Prepare fine strucutre for HQ GENERIC
     *----------------------------------------------------------------*/
    test();
    IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) )
    {
        hq_generic_fine_fx( coeff, last_sfm, sfm_start, sfm_end, bwe_seed, coeff_fine );
    }

    /*----------------------------------------------------------------*
     * Apply envelope
     *----------------------------------------------------------------*/

    test();
    IF( NE_16( HQ_mode, HQ_HARMONIC ) && NE_16( HQ_mode, HQ_HVQ ) )
    {
        apply_envelope_fx( coeff, norm, norm_adj, num_sfm, last_sfm, HQ_mode, length, sfm_start, sfm_end,
                           L_normq_v, L_coeff_out, coeff_fine, L_coeff_out1 );
    }

    /*----------------------------------------------------------------*
     * Harmonic BWE, HVQ BWE and HQ SWB BWE
     *----------------------------------------------------------------*/
    test();
    IF( EQ_16( HQ_mode, HQ_HARMONIC ) )
    {
        ivas_harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out, element_mode );
    }
    ELSE IF( EQ_16( HQ_mode, HQ_HVQ ) )
    {
        hvq_bwe_fx( L_coeff_out, coeff_fine, sfm_start, sfm_end, sfmsize, last_sfm, prev_hq_mode, bwe_peaks, bin_th, num_sfm, L_core_brate, R, norm,
                    noise_level, prev_noise_level, bwe_seed, L_coeff_out, 15, 12 );
    }
    ELSE IF( EQ_16( HQ_mode, HQ_GEN_SWB ) || EQ_16( HQ_mode, HQ_GEN_FB ) )
    {
        hq_bwe_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R );
    }

    /*----------------------------------------------------------------*
     * HQ WB BWE refinements
     *----------------------------------------------------------------*/
    test();
    IF( EQ_16( length, L_FRAME16k ) && LE_32( L_core_brate, HQ_32k ) )
    {
        hq_wb_nf_bwe_fx( coeff, is_transient, prev_bfi, L_normq_v, num_sfm, sfm_start, sfm_end, sfmsize, last_sfm, R,
                         prev_is_transient, prev_normq, prev_env, bwe_seed, prev_coeff_out, prev_R, L_coeff_out, prev_env_Q );
    }

    /*----------------------------------------------------------------*
     * Update memories
     *----------------------------------------------------------------*/

    test();
    IF( NE_16( HQ_mode, HQ_HARMONIC ) && NE_16( HQ_mode, HQ_HVQ ) )
    {
        prev_noise_level[0] = 3277;
        move16(); /* 0.1 in Q15 */
        prev_noise_level[1] = 3277;
        move16(); /* 0.1 in Q15 */
    }
    test();
    IF( !( EQ_16( length, L_FRAME16k ) && LE_32( L_core_brate, HQ_32k ) ) )
    {
        set32_fx( prev_env, 0, SFM_N_WB );
        set32_fx( prev_normq, 0, SFM_N_WB );
    }

    test();
    IF( EQ_16( length, L_FRAME32k ) && LE_32( L_core_brate, HQ_32k ) )
    {
        *prev_R = R[SFM_N_WB - 1];
        Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE );
    }

    return;
}
#endif

void fill_spectrum_fx(
  Word16 *coeff,                      /* i/o: normalized MLT spectrum / nf spectrum                Q12 */
+87 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
#include "rom_com.h"     /* Static table prototypes                */
#include "prot_fx1.h"        /* Function prototypes                    */
#include "prot_fx2.h"        /* Function prototypes                    */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif


/*--------------------------------------------------------------------------
@@ -103,3 +106,87 @@ Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits

    return gain_bits_tot;
}

#ifdef IVAS_FLOAT_FIXED
static void ivas_subband_gain_bits_fx(
    const Word16 *Rk,     /* i  : bit allocation per band Q3 */
    const Word16 N,       /* i  : number of bands         */
    Word16 *bits,         /* o  : gain bits per band      */
    const Word16 *sfmsize /* i  : Size of bands           */
)
{
    Word16 i, b, tot;
    Word16 bps;

    tot = 0;
    move16();

    FOR( i = 0; i < N; i++ )
    {
        /*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]);  inexact C-integer division approx. */
        bps = extract_l( L_shr( L_mult0( Rk[i], fg_inv_tbl_fx[sfmsize[i] >> 3] ), 18 ) ); /* 3+15 */
        IF( EQ_32( L_shl( L_mult0( sfmsize[i], add( bps, 1 ) ), 3 ), Rk[i] ) )
        {
            bps = add( bps, 1 );
        }

        bps = s_min( 7, bps );
        b = fine_gain_bits[bps];
        move16();
        bits[i] = b;
        move16();
        tot = add( tot, b );
    }

    IF( EQ_16( tot, 0 ) )
    {
        /* If no gain bits were assigned, use one bit anyway for potential PVQ overage */
        bits[0] = 1;
        move16();
    }

    return;
}

Word16 ivas_assign_gain_bits_fx(                           /* o  : Number of assigned gain bits          */
                                 const Word16 core,        /* i  : HQ core                               */
                                 const Word16 BANDS,       /* i  : Number of bands                       */
                                 const Word16 *band_width, /* i  : Sub band bandwidth                    */
                                 Word16 *Rk,               /* i/o: Bit allocation/Adjusted bit alloc. Q3 */
                                 Word16 *gain_bits_array,  /* o  : Assigned gain bits                    */
                                 Word16 *Rcalc             /* o  : Bit budget for shape quantizer     Q3 */
)
{
    Word16 gain_bits_tot;
    Word16 i;

    /* Allocate gain bits for every subband used, based on bit rate and bandwidth */
    IF( EQ_16( core, HQ_CORE ) )
    {
        ivas_subband_gain_bits_fx( Rk, BANDS, gain_bits_array, band_width );
    }
    ELSE
    {
        set16_fx( gain_bits_array, 0, BANDS );
    }

    /* Re-adjust bit budget for gain quantization */
    gain_bits_tot = 0;
    move16();
    *Rcalc = 0;
    move16();
    FOR( i = 0; i < BANDS; i++ )
    {
        IF( GT_16( Rk[i], 0 ) )
        {
            Rk[i] = sub( Rk[i], shl( gain_bits_array[i], 3 ) );
            move16();
            gain_bits_tot = add( gain_bits_tot, gain_bits_array[i] );
            *Rcalc = add( *Rcalc, Rk[i] );
            move16();
        }
    }

    return gain_bits_tot;
}
#endif
+210 −0
Original line number Diff line number Diff line
@@ -7,6 +7,9 @@
#include "prot_fx1.h"    /* Function prototypes                    */
#include "prot_fx2.h"    /* Function prototypes                    */
#include "cnst.h"    /* Common constants                       */
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#endif

/*--------------------------------------------------------------------------*
 * hq_bit_allocation_fx()
@@ -14,6 +17,213 @@
 * Assign bits for HQ fine structure coding with PVQ
 *--------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
void ivas_hq_bit_allocation_fx(
    const Word32 core_brate,   /* i  : Core bit-rate                    Q0  */
    const Word16 length,       /* i  : Frame length                     Q0  */
    const Word16 hqswb_clas,   /* i  : HQ class                         Q0  */
    Word16 *num_bits,          /* i/o: Remaining bit budget             Q0  */
    const Word16 *normqlg2,    /* i  : Quantized norms                  Q0  */
    const Word16 nb_sfm,       /* i  : Number sub bands to be encoded   Q0  */
    const Word16 *sfmsize,     /* i  : Sub band bandwidths              Q0  */
    Word16 *noise_level,       /* o  : HVQ noise level                    */
    Word16 *R,                 /* o  : Bit allocation per sub band      Q0  */
    Word16 *Rsubband,          /* o  : Fractional bit allocation        Q3  */
    Word16 *sum,               /* o  : Sum of allocated shape bits      Q0  */
    Word16 *core_sfm,          /* o  : Last coded band in core          Q0  */
    const Word16 num_env_bands /* i  : Number sub bands to be encoded for HQ_GEN Q0  */
)
{
    Word16 i;
    Word16 idx[NB_SFM];
    Word16 wnorm[NB_SFM];
    Word16 avrg_wnorm;
    Word16 tmp, tmp2;
    Word16 E_low;
    Word16 E_hb_mean;
    Word16 E_max;
    Word16 i_max;
    /* Temp */

    Word16 sfm_limit = nb_sfm;
    move16();

    set16_fx( R, 0, NB_SFM );
    FOR( i = 0; i < nb_sfm; i++ )
    {
        idx[i] = i;
        move16();
    }
    test();
    test();
    test();
    IF( NE_16( hqswb_clas, HQ_TRANSIENT ) && NE_16( hqswb_clas, HQ_HVQ ) && !( EQ_16( length, L_FRAME16k ) && LE_32( core_brate, HQ_32k ) ) )
    {
        /* 'nf_idx' 2-bits index written later */
        *num_bits = sub( *num_bits, 2 );
    }

    test();
    IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
    {
        IF( GE_32( core_brate, HQ_32k ) )
        {
            *num_bits = sub( *num_bits, HQ_GENERIC_SWB_NBITS2 );
        }
        ELSE
        {
            *num_bits = sub( *num_bits, HQ_GENERIC_SWB_NBITS );
        }

        IF( EQ_16( length, L_SPEC48k ) )
        {
            *num_bits = sub( *num_bits, HQ_GENERIC_FB_NBITS );
        }
    }

    test();
    test();
    IF( ( EQ_16( length, L_SPEC48k ) ) && ( NE_16( hqswb_clas, HQ_HARMONIC ) ) && ( NE_16( hqswb_clas, HQ_HVQ ) ) )
    {
        tmp = 0;
        move16();
        IF( EQ_16( hqswb_clas, HQ_TRANSIENT ) )
        {
            tmp = 1;
            move16();
        }
        map_quant_weight_fx( normqlg2, wnorm, tmp );
    }
    ELSE
    {
        Copy( normqlg2, wnorm, nb_sfm );
    }

    IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
    {
        /* classification and limit bandwidth for bit allocation */
        sfm_limit = sub( sfm_limit, 2 );
        limit_band_noise_level_calc_fx( wnorm, &sfm_limit, core_brate, noise_level );

        /* Detect important band in high frequency region */
        E_low = sum16_fx( wnorm, SFM_G1 );
        i_max = 0;
        move16();
        E_max = MIN16B;
        move16();
        E_hb_mean = 0;
        move16();
        FOR( i = SFM_G1; i < nb_sfm; i++ )
        {
            E_hb_mean = add( E_hb_mean, wnorm[i] );
            IF( GT_16( wnorm[i], E_max ) )
            {
                E_max = wnorm[i];
                move16();
                i_max = i;
                move16();
            }
        }
        E_hb_mean = shr( E_hb_mean, 4 ); /* Truncated division by SFM_G1 */
        set16_fx( wnorm + sfm_limit, -20, sub( nb_sfm, sfm_limit ) );
        IF( LE_32( L_msu0( L_deposit_l( E_low ), E_max, 15 ), 0 ) )
        {
            IF( LE_32( L_msu( L_deposit_h( E_hb_mean ), E_max, 21955 ), 0 ) ) /* 21955 = 0.67 (Q15) */
            {
                IF( GE_16( i_max, sfm_limit ) )
                {
                    wnorm[i_max] = E_max;
                    move16();
                }
            }
        }
    }
    test();
    test();
    test();
    test();
    IF( EQ_16( hqswb_clas, HQ_HVQ ) )
    {
        *sum = 0;
        move16();
    }
    ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || ( EQ_16( hqswb_clas, HQ_TRANSIENT ) && EQ_16( length, L_FRAME32k ) && LE_32( core_brate, HQ_32k ) ) )
    {
        *sum = BitAllocF_fx( wnorm, core_brate, *num_bits, nb_sfm, R, Rsubband, hqswb_clas, num_env_bands );
    }
    ELSE IF( EQ_16( length, L_FRAME16k ) && LE_32( core_brate, HQ_32k ) )
    {
        IF( NE_16( hqswb_clas, HQ_TRANSIENT ) )
        {
            avrg_wnorm = wnorm[10];
            move16();
            FOR( i = 11; i < 18; i++ )
            {
                avrg_wnorm = add( avrg_wnorm, wnorm[i] );
            }

            avrg_wnorm = shr( avrg_wnorm, 3 );
            FOR( i = 0; i < 4; i++ )
            {
                IF( LT_16( wnorm[i], avrg_wnorm ) )
                {
                    wnorm[i] = avrg_wnorm;
                    move16();
                }
            }

            /* Estimate number of bits per band */
            *sum = BitAllocWB_fx( wnorm, *num_bits, nb_sfm, R, Rsubband );
        }
        ELSE
        {
            reordvct_fx( wnorm, nb_sfm, idx );
            bitalloc_fx( wnorm, idx, *num_bits, nb_sfm, QBIT_MAX2, R, sfmsize, hqswb_clas );
            bitallocsum_fx( R, nb_sfm, sum, Rsubband, *num_bits, length, sfmsize );
        }
    }
    ELSE
    {
        reordvct_fx( wnorm, nb_sfm, idx );

        /* enlarge the wnorm value so that more bits can be allocated to (sfm_limit/2 ~ sfm_limit) range */
        IF( EQ_16( hqswb_clas, HQ_HARMONIC ) )
        {
            tmp = shr( sfm_limit, 1 );
            tmp2 = sub( tmp, 1 );
            FOR( i = tmp; i < sfm_limit; i++ )
            {
                wnorm[i] = wnorm[tmp2];
                move16();
            }
        }
        bitalloc_fx( wnorm, idx, *num_bits, nb_sfm, QBIT_MAX2, R, sfmsize, hqswb_clas );
        bitallocsum_fx( R, nb_sfm, sum, Rsubband, *num_bits, length, sfmsize );
    }

    /* Find last coded core band */
    *core_sfm = sub( nb_sfm, 1 );
    test();
    test();
    IF( hqswb_clas == HQ_NORMAL || EQ_16( hqswb_clas, HQ_HARMONIC ) )
    {
        *core_sfm = find_last_band_fx( R, nb_sfm );
    }
    ELSE IF( EQ_16( hqswb_clas, HQ_GEN_SWB ) || EQ_16( hqswb_clas, HQ_GEN_FB ) )
    {
        *core_sfm = find_last_band_fx( R, nb_sfm );
        IF( LT_16( *core_sfm, num_env_bands ) )
        {
            *core_sfm = sub( num_env_bands, 1 );
        }
    }

    *num_bits = sub( *num_bits, *sum );

    return;
}
#endif

void hq_bit_allocation_fx(
    const Word32 core_brate,     /* i  : Core bit-rate                    Q0  */
    const Word16 length,         /* i  : Frame length                     Q0  */
+293 −0

File changed.

Preview size limit exceeded, changes collapsed.

+189 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading