Commit de79ff63 authored by Arash Azizi's avatar Arash Azizi
Browse files

Merge branch 'main' into basop_issue_2594

parents b58f62ff 6b289e01
Loading
Loading
Loading
Loading
Loading
+26 −7
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include "rom_com.h" /* Static table prototypes                */
#include "prot_fx.h" /* Function prototypes                    */
#include "assert.h"  /* Debug prototypes                       */
#include "stl.h"
#include "ivas_prot_fx.h"


@@ -375,9 +374,10 @@ void bands_and_bit_alloc_fx(
            nb_bands_max = s_min( nb_bands_max, MBANDS_GN_BITALLOC16k );

            /*------------------------------------------------------------------------
             * Ajustement of the maximum number of bands in function of the
             * Adjustement of the maximum number of bands in function of the
             * dynamics of the spectrum (more or less speech like)
             *-----------------------------------------------------------------------*/

            test();
            test();
            test();
@@ -444,6 +444,7 @@ void bands_and_bit_alloc_fx(
            /*------------------------------------------------------------------------
             * Find extra number of band to code according to bit rate availables
             *-----------------------------------------------------------------------*/

            test();
            WHILE( GE_16( bit_tmp, bit_new_bands ) && LE_16( nb_bands, sub( nb_bands_max, 1 ) ) )
            {
@@ -470,6 +471,7 @@ void bands_and_bit_alloc_fx(
            /*------------------------------------------------------------------------
             * Complete the bit allocation per frequency band
             *-----------------------------------------------------------------------*/

            imax = 5;
            move16();

@@ -587,6 +589,7 @@ void bands_and_bit_alloc_fx(
             * For the first x bands to be included in th final sorted vector
             * Sort the remaining bands in decrease energy order
             *--------------------------------------------------------------------------*/

            FOR( j = 0; j < nb_tot_bands; j++ )
            {
                max_ener_band[j] = -10;
@@ -669,6 +672,7 @@ void bands_and_bit_alloc_fx(
         * The maximum number of bits per band of length 16 is 112
         * Redistribute the overage bits if needed
         *--------------------------------------------------------------------------*/

        sum_bit = 0;
        move16();
        j = 0;
@@ -736,6 +740,7 @@ void bands_and_bit_alloc_fx(
        /*--------------------------------------------------------------------------
         * Recompute the real number/length of frequency bands to encode
         *--------------------------------------------------------------------------*/

        *nb_subbands = nb_bands;
        move16();
        *pvq_len = shl( *nb_subbands, 4 );
@@ -744,6 +749,7 @@ void bands_and_bit_alloc_fx(
        /*--------------------------------------------------------------------------
         * Concatenate bands (encoder only)
         *--------------------------------------------------------------------------*/

        IF( exc_diff != NULL )
        {
            FOR( j = 0; j < nb_bands; j++ )
@@ -834,6 +840,7 @@ static void reajust_bits_fx(
    return;
}


/*-------------------------------------------------------------------*
 * Find_bit_frac()
 *
@@ -886,6 +893,12 @@ static Word32 Find_bit_frac_fx(
}


/*-------------------------------------------------------------------*
 * Find_bit_alloc_IVAS()
 *
 *
 *-------------------------------------------------------------------*/

/* o  : Number of band to encode */
static Word16 Find_bit_alloc_IVAS_fx(
    const Word32 core_brate,      /* i  : core bit rate                                         */
@@ -907,12 +920,10 @@ static Word16 Find_bit_alloc_IVAS_fx(
    Word16 d_tmp, e_div, tmp16;
    Word32 Ltmp, etmp_32fx;

    SWB_bit_budgetQ18 = L_shl( *bit, 18 ); /* Q0 -> Q18 */
    SWB_bit_budgetQ5 = L_shl( *bit, 5 );   /* Q0 -> Q5 */
    SWB_bit_budgetQ18 = L_shl( *bit, Q18 ); /* Q0 -> Q18 */
    SWB_bit_budgetQ5 = L_shl( *bit, Q5 );   /* Q0 -> Q5 */
    st_band = 5;
    nb_bands_max = nb_tot_bands_in;

    move16();
    move16();
    move16();

@@ -1135,14 +1146,22 @@ static Word16 Find_bit_alloc_IVAS_fx(
            /* bits_per_bands[i] = 112; */
            bits_per_bands[i] = Q18_112;
            move32();
#ifndef FIX_2585_BIT_ALLOCATION_DIFF
            j = add( j, add( i, 1 ) );
#else
            j = add( i, 1 );
#endif
        }

        /* safety check for overage bit reallocation */
        /* else if (bits_per_bands[i] + sum_bit / 3 > 112) */
        ELSE IF( GT_32( L_add( bits_per_bands[i], Mpy_32_16_1( sum_bit, Q15_0_33 ) ), Q18_112 ) )
        {
#ifndef FIX_2585_BIT_ALLOCATION_DIFF
            j = add( j, add( i, 1 ) );
#else
            j = add( i, 1 );
#endif
        }
    }

+21 −1
Original line number Diff line number Diff line
@@ -204,13 +204,25 @@ void tdm_bit_alloc(
        }
        ELSE
        {
#ifdef FIX_2585_BIT_ALLOCATION_DIFF
            Word16 neg = 0;
            move16();
            if ( bit_rate_diff_fx < 0 )
            {
                neg = 1;
                move16();
            }
#endif
            IF( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) )
            {

                bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) ); /*Q0*/
                bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );                                                  /*Q0*/
                bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ );                /*Q0*/
#ifdef FIX_2585_BIT_ALLOCATION_DIFF
                if ( neg != 0 )
#else
                if ( bit_rate_diff_fx < 0 )
#endif
                {
                    bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
                }
@@ -220,7 +232,11 @@ void tdm_bit_alloc(
                bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ); /*Q0*/
                bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );                                                  /*Q0*/
                bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ );                /*Q0*/
#ifdef FIX_2585_BIT_ALLOCATION_DIFF
                if ( neg != 0 )
#else
                if ( bit_rate_diff_fx < 0 )
#endif
                {
                    bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
                }
@@ -322,7 +338,11 @@ void tdm_bit_alloc(
            *tdm_low_rate_mode = 0;
            move16();
        }
#ifndef FIX_2585_BIT_ALLOCATION_DIFF
        ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LE_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) )
#else
        ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) )
#endif
        {
            *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE ); /*Q0*/
            move32();

lib_com/options.h

100755 → 100644
+3 −1
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@
#define NONBE_FIX_2575                                  /* Fhg: Fix issue 2575, precision loss in FD CNG */
#define FIX_2584_TD_SM_ISSUE                            /* VA: Fix inconsistencies in the SM part of the TD stereo */
#define FIX_2556_ALIGN_CONDITIONS                       /* VA: Fix different conditions that were not exact between float and fix, BE on self-test */
#define FIX_2585_BIT_ALLOCATION_DIFF                    /* VA : issue 2585, bit allocation different behaviors between float and fixed-point for corner cases */
#define FIX_NONBE_2579_INCORRECT_LAG_CALCULATION        /* Dolby: fix 2579: Incorrect lag calculation */

/* Macros for issue 1966 are independent, phase diff is always BE for EVS_MONO */
@@ -154,6 +155,7 @@
#define FIX_BASOP_2519_ICBWE_DEC_Q_TRACK                /* FhG: BASOP #2519: Track Q-format of dec_2over3_mem_fx across frames in stereo_icBWE_preproc_fx */
#define FIX_BASOP_2592_OVERFLOW                         /* FhG: BASOP #2592: fix overflow in GetF0() */
#define FIX_BASOP_2591_EDGE_DETECT_COMP                 /* FhG: BASOP #2591: Wrong comparison in edge_detect_fx() */
#define FIX_NONBE_2580_USE_LENGTH_NOT_CONSTANT          /* Dolby: fix 2580: use dynamic length denominator for average energy in unclr_calc_corr_features_fx() */

/* ##################### End NON-BE switches ########################### */

+3 −0
Original line number Diff line number Diff line
@@ -2282,6 +2282,9 @@ static void unclr_calc_corr_features_fx(
    }

    /* average energy of L and R channels */
#ifdef FIX_NONBE_2580_USE_LENGTH_NOT_CONSTANT
    /* Note, that length is a fixed value equal to L_FRAME_DS, so 1/length = 1/160 = 13421772 */
#endif
    hStereoClassif->ave_ener_L_fx = Mpy_32_32( hStereoTCA->E1_mem_fx, 13421772 /* 1/length in Q31*/ ); /* Q31-hStereoClassif->ave_ener_L_fx_e */
    move32();
    hStereoClassif->ave_ener_L_fx_e = hStereoTCA->E1_mem_exp;