Loading lib_com/gs_bitallocation_ivas_fx.c +85 −10 Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ #include "stl.h" static void reajust_bits_fx( Word32 *bits_per_bands, const Word16 st_band, const Word16 end_band, const Word16 sum_bit_in, const Word16 bit_bdgt_in ); #ifdef FIX_802__NON_BE_DECODING static Word32 Find_bit_frac( const Word16 nb_band, const Word16 remaining_bits ); #endif /*==================================================================================*/ /* FUNCTION : void bands_and_bit_alloc_ivas_fx(); */ /*----------------------------------------------------------------------------------*/ Loading Loading @@ -460,8 +462,11 @@ void bands_and_bit_alloc_ivas_fx( set32_fx( bits_per_bands, 0, MBANDS_GN ); /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ #ifdef FIX_802__NON_BE_DECODING bit_fracf = Find_bit_frac( nb_bands, extract_l( SWB_bit_budget ) ); #else bit_fracf = L_mult( div_s( 1, nb_bands ), shl( (Word16) SWB_bit_budget, 2 ) ); /* Q18 */ #endif nb_tot_bands = sub( nb_bands_max, 6 ); nb_tot_bands = s_min( nb_tot_bands, 16 ); Loading Loading @@ -642,7 +647,11 @@ void bands_and_bit_alloc_ivas_fx( ELSE #endif { #ifdef FIX_802__NON_BE_DECODING bit_fracf = Find_bit_frac( st_band, bit_tmp ); #else bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ #endif } /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band Loading Loading @@ -968,43 +977,109 @@ static void reajust_bits_fx( Word16 bit_bdgt, sum_bit; incr = 1; IF( end_band < st_band ) move16(); if( LT_16( end_band, st_band) ) { incr = -1; move16(); } IF( bit_bdgt_in < sum_bit_in ) IF( LT_16( bit_bdgt_in, sum_bit_in ) ) { amount_to_add = -1; bit_bdgt = sum_bit_in; sum_bit = bit_bdgt_in; move16(); move16(); move16(); } ELSE { bit_bdgt = bit_bdgt_in; sum_bit = sum_bit_in; amount_to_add = 1; move16(); move16(); move16(); } i = st_band; WHILE( bit_bdgt > sum_bit ) move16(); WHILE( GT_16( bit_bdgt, sum_bit ) ) { // if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1)) IF( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 262144 ) ) /* if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1))*/ test(); test(); IF( amount_to_add > 0 || ( amount_to_add < 0 && GT_32( bits_per_bands[i], 262144 ) ) ) { // bits_per_bands[i] += amount_to_add; /* bits_per_bands[i] += amount_to_add;*/ bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( amount_to_add, Q18 ) ); move32(); sum_bit = add( sum_bit, abs_s( amount_to_add ) ); } i += incr; IF( i == end_band ) i = add( i, incr ); IF( EQ_16( i, end_band ) ) { i = st_band; move16(); } } return; } #ifdef FIX_802__NON_BE_DECODING /*-------------------------------------------------------------------* * Find_bit_frac() * * Computes the fraction of the remaining bit budget to allocate to the bands *-------------------------------------------------------------------*/ static Word32 Find_bit_frac( const Word16 nb_band, const Word16 remaining_bits ) { int16_t inv_bandQ15; int32_t L_out; inv_bandQ15 = 6553; move16(); IF( nb_band == 7 ) { inv_bandQ15 = 4681; move16(); } ELSE IF( nb_band == 3 ) { inv_bandQ15 = 10922; move16(); } ELSE IF( nb_band == 4 ) { inv_bandQ15 = 8192; move16(); } ELSE IF( nb_band == 5 ) { inv_bandQ15 = 6536; move16(); } ELSE IF( nb_band == 10 ) { inv_bandQ15 = 3277; move16(); } ELSE { #ifdef DEBUGGING printf( "1/%d NOT DEFINED in Find_bit_frac\n", nb_band ); #endif } L_out = L_mult( inv_bandQ15, shl( remaining_bits, 2 ) ); return ( L_out ); } #endif #endif lib_com/options.h +3 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ #define FIX_729_MISSING_RESCALING #define FIX_798_LSF_SECONDARY_CH_MISSING_CODE /* Adding the missing code to properly render the secondary channel of TD stereo*/ #define FIX_798_WRONG_CPY_OF_PITCH /* The copy of the pitch from primary to secondary channel was wrong AND safety check was really wrong */ #define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading Loading
lib_com/gs_bitallocation_ivas_fx.c +85 −10 Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ #include "stl.h" static void reajust_bits_fx( Word32 *bits_per_bands, const Word16 st_band, const Word16 end_band, const Word16 sum_bit_in, const Word16 bit_bdgt_in ); #ifdef FIX_802__NON_BE_DECODING static Word32 Find_bit_frac( const Word16 nb_band, const Word16 remaining_bits ); #endif /*==================================================================================*/ /* FUNCTION : void bands_and_bit_alloc_ivas_fx(); */ /*----------------------------------------------------------------------------------*/ Loading Loading @@ -460,8 +462,11 @@ void bands_and_bit_alloc_ivas_fx( set32_fx( bits_per_bands, 0, MBANDS_GN ); /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */ #ifdef FIX_802__NON_BE_DECODING bit_fracf = Find_bit_frac( nb_bands, extract_l( SWB_bit_budget ) ); #else bit_fracf = L_mult( div_s( 1, nb_bands ), shl( (Word16) SWB_bit_budget, 2 ) ); /* Q18 */ #endif nb_tot_bands = sub( nb_bands_max, 6 ); nb_tot_bands = s_min( nb_tot_bands, 16 ); Loading Loading @@ -642,7 +647,11 @@ void bands_and_bit_alloc_ivas_fx( ELSE #endif { #ifdef FIX_802__NON_BE_DECODING bit_fracf = Find_bit_frac( st_band, bit_tmp ); #else bit_fracf = L_mult( div_s( 1, st_band ), shl( bit_tmp, 2 ) ); /* Q18 */ #endif } /*------------------------------------------------------------------------ * Complete the bit allocation per frequency band Loading Loading @@ -968,43 +977,109 @@ static void reajust_bits_fx( Word16 bit_bdgt, sum_bit; incr = 1; IF( end_band < st_band ) move16(); if( LT_16( end_band, st_band) ) { incr = -1; move16(); } IF( bit_bdgt_in < sum_bit_in ) IF( LT_16( bit_bdgt_in, sum_bit_in ) ) { amount_to_add = -1; bit_bdgt = sum_bit_in; sum_bit = bit_bdgt_in; move16(); move16(); move16(); } ELSE { bit_bdgt = bit_bdgt_in; sum_bit = sum_bit_in; amount_to_add = 1; move16(); move16(); move16(); } i = st_band; WHILE( bit_bdgt > sum_bit ) move16(); WHILE( GT_16( bit_bdgt, sum_bit ) ) { // if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1)) IF( amount_to_add > 0 || ( amount_to_add < 0 && bits_per_bands[i] > 262144 ) ) /* if (amount_to_add > 0 || (amount_to_add < 0 && bits_per_bands[i] > 1))*/ test(); test(); IF( amount_to_add > 0 || ( amount_to_add < 0 && GT_32( bits_per_bands[i], 262144 ) ) ) { // bits_per_bands[i] += amount_to_add; /* bits_per_bands[i] += amount_to_add;*/ bits_per_bands[i] = L_add( bits_per_bands[i], L_shl( amount_to_add, Q18 ) ); move32(); sum_bit = add( sum_bit, abs_s( amount_to_add ) ); } i += incr; IF( i == end_band ) i = add( i, incr ); IF( EQ_16( i, end_band ) ) { i = st_band; move16(); } } return; } #ifdef FIX_802__NON_BE_DECODING /*-------------------------------------------------------------------* * Find_bit_frac() * * Computes the fraction of the remaining bit budget to allocate to the bands *-------------------------------------------------------------------*/ static Word32 Find_bit_frac( const Word16 nb_band, const Word16 remaining_bits ) { int16_t inv_bandQ15; int32_t L_out; inv_bandQ15 = 6553; move16(); IF( nb_band == 7 ) { inv_bandQ15 = 4681; move16(); } ELSE IF( nb_band == 3 ) { inv_bandQ15 = 10922; move16(); } ELSE IF( nb_band == 4 ) { inv_bandQ15 = 8192; move16(); } ELSE IF( nb_band == 5 ) { inv_bandQ15 = 6536; move16(); } ELSE IF( nb_band == 10 ) { inv_bandQ15 = 3277; move16(); } ELSE { #ifdef DEBUGGING printf( "1/%d NOT DEFINED in Find_bit_frac\n", nb_band ); #endif } L_out = L_mult( inv_bandQ15, shl( remaining_bits, 2 ) ); return ( L_out ); } #endif #endif
lib_com/options.h +3 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,9 @@ #define FIX_729_MISSING_RESCALING #define FIX_798_LSF_SECONDARY_CH_MISSING_CODE /* Adding the missing code to properly render the secondary channel of TD stereo*/ #define FIX_798_WRONG_CPY_OF_PITCH /* The copy of the pitch from primary to secondary channel was wrong AND safety check was really wrong */ #define FIX_802__NON_BE_DECODING /* Fix possible difference float and fixed point when computing the GSC bit allocation */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading