Commit 7fec98d5 authored by vaillancour's avatar vaillancour
Browse files

proposed fix to 2585

parent 06686cc2
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1135,14 +1135,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
        }
    }

+22 −2
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();
+3 −1
Original line number Diff line number Diff line
@@ -134,6 +134,8 @@
#define FIX_1521_SBA_LOUDNESS_STEREO                    /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */
#define FIX_1559                                        /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */

#define FIX_2585_BIT_ALLOCATION_DIFF                    /* VA : issue 2585, bit allocation different behaviors between float and fixed-point for corner cases */

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

/* ################## End MAINTENANCE switches ######################### */