diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c index 48abe96335946404aafaae714aa16c905522f18d..f7ec90df406002840b6bdf57b316f110ae574aef 100644 --- a/lib_com/gs_bitallocation.c +++ b/lib_com/gs_bitallocation.c @@ -47,7 +47,6 @@ #include "wmc_auto.h" -#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -71,7 +70,6 @@ #define Q31_0_17 365072220 /* 0.17 */ #define Q31_0_23 493921239 /* 0.23 */ -#endif /*-------------------------------------------------------------------* * Local function prototypes @@ -81,14 +79,12 @@ static float Find_bit_frac( const int16_t nb_band, const int16_t remaining_bits static void reajust_bits( float *bits_per_bands, const int16_t st_band, const int16_t end_band, const int16_t sum_bit_in, const int16_t bit_bdgt_in ); -#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div ); static Word16 Find_bit_alloc_IVAS_int( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, const Word16 L_frame, Word16 *bit, Word16 *max_ener_band, float *ener_vec, float *bits_per_bands ); static Word16 maximum_fx( const Word16 *vec_fx, const Word16 lvec_fx, Word16 *max_fx ); -#endif /*-------------------------------------------------------------------* * bands_and_bit_alloc() @@ -127,12 +123,8 @@ void bands_and_bit_alloc( int16_t pos, band; float SWB_bit_budget; float bits_per_bands[MBANDS_GN_BITALLOC16k]; -#ifndef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING - float fzero_val, mp, mb, nb_bands_adj, bit_adj; - int16_t nb_pulse_per_band[MBANDS_GN_BITALLOC16k]; -#else float fzero_val; -#endif + /* initializations */ nb_tot_bands = 16; set_f( bits_per_bands, 0.0f, MBANDS_GN_BITALLOC16k ); @@ -231,189 +223,8 @@ void bands_and_bit_alloc( { if ( GSC_IVAS_mode > 0 ) { -#ifndef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING - SWB_bit_budget = *bit; - st_band = 5; - - set_f( bits_per_bands, 0, MBANDS_GN_BITALLOC16k ); - - /* 2- Decide the pourcentage of bits allocated to LF (between 50-75%) depending of the temporal contribution in GSC */ - bit_fracf = ( -0.125f * Diff_len + 76.0f ) / 100; - bit_fracf = check_bounds( bit_fracf, 0.50f, 0.75f ); - - /* Adjusment of the bitrate between LF and HF base on the content type */ - /* 1 = new GSC bit alloc - 2 = GSC bit alloc for tc frame - 3 = more music like (should not happen often given music is coded with dft) */ - - if ( GSC_IVAS_mode <= 3 ) - { - nb_bands_max -= 6; - } - - if ( GSC_IVAS_mode == 2 ) - { - bit_fracf += 0.1f; - nb_bands_max--; - } - - if ( GSC_IVAS_mode == 3 ) - { - bit_fracf -= 0.1f; - nb_bands_max += 3; - } - - /* First find how much we want to share between LF and HF, at low bitrate, a miminum of bits is needed in LF by limitating the number of bands*/ - /* Adjust the number of band based on the content type and bitrate */ - nb_bands_adj = 1.0f; - if ( GSC_IVAS_mode == 1 && core_brate < GSC_L_RATE_STG ) - { - nb_bands_adj = 0.0125f * SWB_bit_budget - 0.75f; - } - else if ( GSC_IVAS_mode != 2 && core_brate > GSC_H_RATE_STG ) - { - nb_bands_adj = 0.02f * SWB_bit_budget - 1.2f; - } - nb_bands_max = (int16_t) ( nb_bands_max * nb_bands_adj + 0.5f ); - nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands ); - - bit_fracf *= SWB_bit_budget; - - /* Estimation of the number of bit used in HF */ - /* with only the first weigthing The number of bits in max_ener_band[st_band-1] = 17% of bit_fracf */ - mb = .17f * bit_fracf; - mp = ( 2.0f * DSR_NB_PULSE ); - if ( core_brate < GSC_L_RATE_STG && GSC_IVAS_mode == 3 ) - { - mp = 1.5f * DSR_NB_PULSE; - } - else if ( core_brate < GSC_L_RATE_STG ) - { - mp = DSR_NB_PULSE; - } - - /* We want max_ener_band[st_band] <= max_ener_band[st_band-1] and max_ener_band[nb_bands_max-1] <= max_ener_band[st_band]*/ - /* We will estimate the number of bits to allocate of HF and put the remaining bits, if any, back on LF */ - /* compute the total possible number of band to be coded */ - nb_tot_bands = (int16_t) ( ( SWB_bit_budget - bit_fracf ) / ( mp + ( mb - mp ) / 2.0f ) ); - mp = min( mp, mb ); - if ( nb_tot_bands + st_band > nb_bands_max ) - { - bit_adj = ( ( mb + mp ) / 2 ) * ( nb_tot_bands + st_band - nb_bands_max ); - bit_adj = max( 0, bit_adj ); - nb_tot_bands = nb_bands_max - st_band; - bit_fracf += bit_adj; - } - nb_tot_bands += st_band; - - /* Allocate bits to LF */ - etmp = 0.23f; - for ( j = 0; j < st_band; j++ ) - { - i = j; - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - bits_per_bands[j] = etmp * bit_fracf; - etmp -= 0.015f; - } - - SWB_bit_budget -= bit_fracf; - - /* Find low energy band in HF */ - set_s( nb_pulse_per_band, 2, MBANDS_GN_BITALLOC16k ); - for ( i = st_band + 2; i < nb_tot_bands - 1; i++ ) - { - if ( ener_vec[i] < ener_vec[i - 1] && ener_vec[i] < ener_vec[i + 1] ) - { - nb_pulse_per_band[i] = 1; - } - } - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( j > 6 ) - { - i = maximum( ener_vec, nb_tot_bands, &etmp ); - } - else - { - i = j; - } - - max_ener_band[j] = i; - ener_vec[i] = MIN16B; - } - - /* Recompute the final bit distribution for HF */ - if ( nb_tot_bands > st_band ) - { - bit_fracf = DSR_NB_PULSE; - mb = ( SWB_bit_budget * 2 / ( nb_tot_bands - st_band ) ) - mp; - bit_fracf = ( mb - mp ) / ( nb_tot_bands - st_band ); - mb -= bit_fracf; - /* Do the distribution */ - for ( j = st_band; j < nb_tot_bands; j++ ) - { - if ( nb_pulse_per_band[max_ener_band[j]] > 1 ) - { - bits_per_bands[max_ener_band[j]] = mb; - } - else - { - bits_per_bands[max_ener_band[j]] = 4.5f; - } - mb -= bit_fracf; - SWB_bit_budget -= bits_per_bands[max_ener_band[j]]; - } - } - - /* Series of verification in case bit allocated != the budget */ - if ( SWB_bit_budget > 0 ) - { - i = st_band - 1; - while ( SWB_bit_budget > 0 ) - { - bits_per_bands[i]++; - SWB_bit_budget--; - i--; - if ( i == -1 ) - { - i = st_band - 1; - } - } - } - - nb_bands = nb_tot_bands; - - sum_bit = 0; - j = 0; - for ( i = 0; i < nb_bands; i++ ) - { - if ( bits_per_bands[i] > 112 ) - { - sum_bit += bits_per_bands[i] - 112; - bits_per_bands[i] = 112; - j = i + 1; - } - - /* safety check for overage bit reallocation */ - else if ( bits_per_bands[i] + sum_bit / 3 > 112 ) - { - j = i + 1; - } - } - - if ( sum_bit != 0 ) - { - sum_bit /= ( nb_bands - j ); - for ( i = j; i < nb_bands; i++ ) - { - bits_per_bands[i] += sum_bit; - } - } -#else nb_tot_bands = (int16_t) Find_bit_alloc_IVAS_int( (Word32) core_brate, (Word16) GSC_IVAS_mode, (Word16) Diff_len, (Word16) nb_tot_bands, (Word16) L_frame, (Word16 *) bit, (Word16 *) max_ener_band, ener_vec, bits_per_bands ); nb_bands = nb_tot_bands; -#endif } else if ( GSC_noisy_speech ) { @@ -976,7 +787,6 @@ static float Find_bit_frac( return ( var_out ); } -#ifdef NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /*-------------------------------------------------------------------* * Find_bit_alloc_IVAS_int() @@ -1159,7 +969,7 @@ static Word16 Find_bit_alloc_IVAS_int( } /* Recompute the final bit distribution for HF */ - IF( nb_tot_bands_loc > st_band ) + if ( nb_tot_bands_loc > st_band ) { /* mb = ( SWB_bit_budget * 2 / ( nb_tot_bands_loc - st_band ) ) - mp; */ d_tmp = Find_norm_inv( L_deposit_h( sub( nb_tot_bands_loc, st_band ) ), &e_div ); @@ -1295,4 +1105,3 @@ static Word16 maximum_fx( return ind; } -#endif diff --git a/lib_com/options.h b/lib_com/options.h index 1efaa714cc9369da4f42aef141057b0388fb56a3..edd27064d4221b7e6a93906047c1abffea1eea83 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,8 +160,6 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define FIX_CREND_SIMPLIFY_CODE /* Ora : simplify line code in crend */ -#define FIX_1138_SBA_EXT_ERROR_PRINTOUT /* VA: issue 1138: Fix SBA EXT output call of audioCfg2channels() */ -#define FIX_1117_ISAR_MALLOC /* VA: issue 1117: call ISAR malloc() only at the initialization. */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1113_EXTREND_ISAR /* FhG: issue 1113: fix external renderer asserts for FOA/HOA2 and CLDFB config */ #define FIX_1113_CLDFB_REND_IN_ISAR /* issue 1113: fix the use of CLDFB renderer in split-rendering at the external renderer */ @@ -181,7 +179,6 @@ /* any switch which is non-be wrt selection floating point code */ /* all switches in this category should start with "NONBE_" */ -#define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */ #define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ #define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8b732e66ab02f6b4be2025a41c15480b930e044e..f975814e2f1cdf14ea693f3f1b57052e24cced45 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -268,13 +268,6 @@ static ivas_error isar_set_split_rend_setup( splitRendBits->isar_frame_size_ms = 0; splitRendBits->lc3plus_highres = 0; -#ifndef FIX_1117_ISAR_MALLOC - if ( ( hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); - } - -#endif ISAR_PRE_REND_GetMultiBinPoseData( hSplitBinConfig, &hSplitBinRend->splitrend.multiBinPoseData, ( hCombinedOrientationData != NULL ) ? hCombinedOrientationData->sr_pose_pred_axis : DEFAULT_AXIS ); if ( hCombinedOrientationData != NULL ) @@ -1240,10 +1233,6 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( ivas_syn_output( pOutput, numSamplesPerChannelToDecode, st_ivas->hDecoderConfig->nchan_out, (int16_t *) pcmBuf_out ); } -#ifndef FIX_1117_ISAR_MALLOC - free( st_ivas->hSplitBinRend->hMultiBinCldfbData ); - -#endif return error; } @@ -3939,11 +3928,9 @@ static void ivas_destroy_handle_isar( { if ( *hSplitBinRend != NULL ) { -#ifdef FIX_1117_ISAR_MALLOC free( ( *hSplitBinRend )->hMultiBinCldfbData ); ( *hSplitBinRend )->hMultiBinCldfbData = NULL; -#endif ISAR_PRE_REND_close( &( *hSplitBinRend )->splitrend, NULL ); if ( ( *hSplitBinRend )->hCldfbDataOut != NULL ) @@ -4139,14 +4126,12 @@ static ivas_error ivas_dec_init_split_rend( cldfb_in_flag = 1; } -#ifdef FIX_1117_ISAR_MALLOC /* note: this is intra-frame heap memory */ if ( ( st_ivas->hSplitBinRend->hMultiBinCldfbData = (ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA_HANDLE) malloc( sizeof( ISAR_DEC_SPLIT_REND_MULTI_BIN_CLDFB_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for split rendering structure" ); } -#endif ISAR_PRE_REND_GetMultiBinPoseData( &st_ivas->hRenderConfig->split_rend_config, &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->sr_pose_pred_axis : DEFAULT_AXIS ); if ( cldfb_in_flag == 1 && ( st_ivas->hSplitBinRend->splitrend.multiBinPoseData.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) diff --git a/lib_rend/ivas_output_init.c b/lib_rend/ivas_output_init.c index a78b7fe2c38c641d12af097f81b50c28dff64f94..594f09ea472f3bc23f4c8db727cde9d294e8e22d 100644 --- a/lib_rend/ivas_output_init.c +++ b/lib_rend/ivas_output_init.c @@ -304,11 +304,7 @@ int16_t ivas_get_nchan_buffers_dec( { nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe ); } -#ifdef FIX_1138_SBA_EXT_ERROR_PRINTOUT else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL ) -#else - else -#endif { nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );