diff --git a/apps/encoder.c b/apps/encoder.c index b3c4602b634e1d6d1ed37ce3b60409b9ba315582..4bd5e3ab4bf84ba4efb1ce2c347d344c20ca7b5a 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -121,11 +121,7 @@ typedef struct bool mimeOutput; #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR IVAS_ENC_AGC agc; -#else - bool agc; -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ bool pca; #ifdef DEBUG_FOA_AGC @@ -891,11 +887,7 @@ static void initArgStruct( EncArguments *arg ) arg->mimeOutput = false; #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR arg->agc = IVAS_ENC_AGC_UNDEFINED; -#else - arg->agc = IVAS_DEFAULT_AGC; -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ arg->pca = false; #ifdef DEBUG_FOA_AGC @@ -1408,11 +1400,7 @@ static bool parseCmdlIVAS_enc( i++; if ( i < argc - 4 ) { -#ifdef AGC_ENABLE_FOR_LBR arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED; -#else - arg->agc = (int16_t) atoi( argv[i] ); -#endif if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 ) { fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) ); @@ -1669,13 +1657,9 @@ static void usage_enc( void ) fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR fprintf( stdout, "-agc op : SBA Adaptive gain control, op = (0, 1). \n" ); fprintf( stdout, " By default op is 1 (activated) for bitrates between 24400 and 32000,\n" ); fprintf( stdout, " otherwise it is 0 (deactivated) for all other bitrates\n" ); -#else - fprintf( stdout, "-agc op : SBA Adaptive gain control, op = (0, 1), by default op is 0 or deactivated\n" ); -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ fprintf( stdout, "-bypass mode : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" ); diff --git a/lib_com/ivas_agc_com.c b/lib_com/ivas_agc_com.c index 63dda27afd3cf264a418bdd00d42fab4295bb28f..b02853555b0be40eb3a9e173628419269c9ae3ed 100644 --- a/lib_com/ivas_agc_com.c +++ b/lib_com/ivas_agc_com.c @@ -40,21 +40,17 @@ #endif #include #include "wmops.h" -#ifdef AGC_TUNING_IMPROVEMENT #include "prot.h" -#endif /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ -#define SQRKMAX ( 1.5f ) -#define NBITS_DIFFG ( 2 ) -#ifdef AGC_TUNING_IMPROVEMENT +#define SQRKMAX ( 1.5f ) +#define NBITS_DIFFG ( 2 ) #define DBSTEP ( -6.f ) /* desired dB step value in dB*/ #define ABS_EMIN_MAX ( 3 ) #define MAXATTEXP ( 1 ) /* the desired maximum attenuation exponent range per frame*/ -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_agc_initWindowFunc() @@ -68,22 +64,14 @@ void ivas_agc_initWindowFunc( { int16_t i; float N; -#ifdef AGC_TUNING_IMPROVEMENT float a; -#endif N = (float) ( length - 1 ); -#ifdef AGC_TUNING_IMPROVEMENT a = 0.5f * ( 1.f - powf( 10.f, DBSTEP / 20.f ) ); -#endif for ( i = 0; i < length; i++ ) { -#ifdef AGC_TUNING_IMPROVEMENT pWinFunc[i] = 1.f + a * ( cosf( EVS_PI * i / N ) - 1.f ); -#else - pWinFunc[i] = 0.75f + 0.25f * cosf( EVS_PI * i / N ); -#endif } return; @@ -107,11 +95,7 @@ void ivas_agc_calcGainParams( nbits = NBITS_DIFFG; -#ifdef AGC_TUNING_IMPROVEMENT *absEmin = max( ABS_EMIN_MAX, (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 ) ); -#else - *absEmin = (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 ); -#endif totExp = *absEmin + AGC_EMAX + 1; *betaE = (uint16_t) ceilf( logf( totExp ) * INV_LOG_2 ); @@ -120,17 +104,11 @@ void ivas_agc_calcGainParams( if ( nbits > 0 ) { -#ifdef AGC_TUNING_IMPROVEMENT Bm = min( AGC_BITS_PER_CH - 1, NBITS_DIFFG ); -#else - Bm = NBITS_DIFFG; -#endif } *maxAttExp = ( (uint16_t) powf( 2, Bm ) ) - 2; -#ifdef AGC_TUNING_IMPROVEMENT *maxAttExp = min( MAXATTEXP, *maxAttExp ); -#endif return; } diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 7051caf9a541a11fd5ec445d9b2422c44391bc41..b42feca458c3be1f82883e0d9a88488fc1d57cbe 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -841,9 +841,7 @@ typedef enum { #define SBA_MIN_BRATE_HOA IVAS_256k #define SBA_NHARM_HOA3 16 #define SBA_T_DESIGN_11_SIZE 70 -#ifdef FIX_SBA_DTX_DECODE_ERROR #define SBA_DTX_BITRATE_THRESHOLD IVAS_80k -#endif typedef enum { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 39d9d237c01468d6f441dcf42caefbce9737c18a..82697d37c68d716e9110b10e97e0b7a4fd7f648e 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -3767,7 +3767,6 @@ void ivas_sba_prototype_renderer( ); /* AGC */ -#ifdef AGC_ENABLE_FOR_LBR /*! r: AGC enable flag */ int16_t ivas_agc_enc_get_flag( #ifdef DEBUG_AGC_ENCODER_CMD_OPTION @@ -3775,7 +3774,6 @@ int16_t ivas_agc_enc_get_flag( #endif int16_t nchan_transport /* i : number of transport channels */ ); -#endif ivas_error ivas_spar_agc_enc_open( ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */ diff --git a/lib_com/options.h b/lib_com/options.h index 23af39c6838652512083012d205945ef2dee3ecf..14cd7cdecdbe0f66db317808ac96210cc772241d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -145,22 +145,12 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define FIX_I1_113 /* under review : MCT bit distribution optimization for SBA high bitrates*/ #define PRINT_SBA_ORDER /* Issue 179: print-out also the SBA order of IVAS SBA format to stdout */ -#define SPAR_STEREO_NO_DIRAC /* Issue 180: skip DirAC processing channels for stereo output */ -#define AGC_TUNING_IMPROVEMENT /* Issue 168: Enable AGC for low bit rate (1 TC) */ -#ifdef AGC_TUNING_IMPROVEMENT -#define AGC_ENABLE_FOR_LBR /* Issue 168: Enable AGC for low bit rate (1 TC) */ -#endif -#define FIX_I173_I174 /* Issues 173 and 174: Remove frame and subframe index from ISm metadata and headtracking respectively. */ -#define FIX_TCX_DEC_RECONF_BFI -#define FIX_SBA_DTX_DECODE_ERROR /* Issue 176: SBA decoder error with DTX at 80kbps SWB, Issue 21: SBA front-VAD threshold (203) */ #define FIX_124_DONT_ALLOC_PLCINFO_IN_IVAS /* Issue 124: do not allocate unused plc struct in IVAS modes which is only used in EVS mono */ /*#define FIX_MCT_PLC_RECOVERY*/ /* Issue 184: scale the old synthesis part correctly in the first good frame after lost frames in MCT modes - to be activated after previous switch is merged */ -#define FIX_MSAN_ERROR_STEREO_RATE_SWITCHING /* addresses Issue 177 */ #define SBA_BR_SWITCHING /* Issue 114: Changes for sba bit rate switching*/ #define FIX_AGC_WINFUNC_MEMORY /* Issue 62: lower agc_com.winFunc memory consumption */ - /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index e522574bb241dae3c01be57adac0b72244151d57..0b25c8216c3b78fe99f47436e69fa944855ec9b1 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -205,20 +205,12 @@ void ivas_agc_dec_process( if ( ( pState->gain_state[i].gainExpVal > (int32_t) ( pState->agc_com.maxAttExp + 1 ) ) || ( pState->gain_state[i].gainExpVal < -1 ) ) { -#ifdef AGC_TUNING_IMPROVEMENT /* Such conditions indicate packet loss, better reset and do nothing*/ pState->gain_data[i].absGainExp = pState->agc_com.absEmin; pState->gain_state[i].gainExpVal = 0; -#else - assert( 0 ); -#endif } -#ifdef AGC_TUNING_IMPROVEMENT pState->gain_state[i].lastGain = powf( pState->agc_com.winFunc[offset - 1], ( -1.f * (float) ( pState->gain_data[i].absGainExp - pState->agc_com.absEmin ) ) ); -#else - pState->gain_state[i].lastGain = powf( 2, (float) ( pState->gain_data[i].absGainExp - pState->agc_com.absEmin ) ); -#endif gainLast = 1.f / pState->gain_state[i].lastGain; if ( !pState->gain_data[i].gainException ) @@ -252,11 +244,7 @@ void ivas_agc_dec_process( } else { -#ifdef AGC_TUNING_IMPROVEMENT float gainCurr = powf( pState->agc_com.winFunc[offset - 1], ( -1.f * (float) pState->gain_state[i].gainExpVal ) ); -#else - float gainCurr = powf( 2, (float) pState->gain_state[i].gainExpVal ); -#endif float gainTot = gainCurr * gainLast; for ( idx = 0; idx < output_frame; idx++ ) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5cc318b86fc4699cf78333d9b01f3ca9a463647a..e51b46779c33ea1a468d63af12ef4c8a16b6dac2 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -803,11 +803,7 @@ ivas_error ivas_init_decoder( return error; } - if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA -#ifdef SPAR_STEREO_NO_DIRAC - && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO -#endif - ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) { if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_output_init.c b/lib_dec/ivas_output_init.c index 005db1d4ac09ec5aaccee1e0a2ff5b911c309589..9486ee7d05f38790272b2f7a7d903335b312f040 100644 --- a/lib_dec/ivas_output_init.c +++ b/lib_dec/ivas_output_init.c @@ -515,12 +515,10 @@ void ivas_renderer_select( { *internal_config = output_config; } -#ifdef SPAR_STEREO_NO_DIRAC else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO ) { *internal_config = AUDIO_CONFIG_FOA; } -#endif else { *internal_config = AUDIO_CONFIG_HOA3; diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index b2cc27d5efdc50fd48ead6fb003758d5ec57ed86..1dce7978c208136bc8bd9bc806195df5e468b2ea 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -478,11 +478,7 @@ void stereo_dft_dec_core_switching( mvr2r( output, pAp_input, st->L_frame ); } -#ifdef FIX_MSAN_ERROR_STEREO_RATE_SWITCHING if ( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) && !st->tcxonly ) /* ACELP -> TCX/HQ-Core */ -#else - if ( st->last_core == ACELP_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) /* ACELP -> TCX/HQ-Core */ -#endif { mvr2r( tcx_core_buf, tmp_fade, ap_fade_len ); for ( i = 0; i < ap_fade_len; i++ ) diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index d196cda9b6f958bc33d8c3cea45144eb957d7d24..ceed901c1ad0ef8b65c61a7adc1e785f21f8e3b0 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -1132,11 +1132,7 @@ void ivas_spar_dec_upmixer( } } - if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA -#ifdef SPAR_STEREO_NO_DIRAC - && hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != AUDIO_CONFIG_MONO -#endif - ) + if ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA && hDecoderConfig->output_config != AUDIO_CONFIG_STEREO && hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) { ivas_dirac_dec( st_ivas, output, nchan_internal, cldfb_in_ts_re, cldfb_in_ts_im, i_sf ); } diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 54af577fd14bbf8831c857707352d70fa43bcc9f..52c95fe4412b9896f0be9ecdb0b38b628df0df3f 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -51,14 +51,8 @@ * Local prototypes *-------------------------------------------------------------*/ -#ifdef FIX_TCX_DEC_RECONF_BFI static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, const int16_t last_element_mode, int16_t *bitsRead ); -#else -static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[], int16_t *total_nbbits, int16_t *bitsRead ); -#endif -#ifdef FIX_TCX_DEC_RECONF_BFI static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, const int16_t last_element_mode ); -#endif /*-------------------------------------------------------------* @@ -73,9 +67,6 @@ void stereo_tcx_init_dec( const int16_t last_element_mode /* i : element mode of previous frame */ ) { -#ifndef FIX_TCX_DEC_RECONF_BFI - int16_t frame_size_index; -#endif TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; TCX_DEC_HANDLE hTcxDec = st->hTcxDec; @@ -134,43 +125,13 @@ void stereo_tcx_init_dec( } } -#ifdef FIX_TCX_DEC_RECONF_BFI if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) ) -#else - if ( ( st->bits_frame_nominal != st->last_bits_frame_nominal ) || ( st->bwidth != st->last_bwidth ) || ( st->last_core != TCX_20_CORE && st->last_core != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) || ( st->idchan == 1 && st->element_mode == IVAS_CPE_MDCT && last_element_mode != IVAS_CPE_MDCT ) ) -#endif { /*re-initialization*/ -#ifdef FIX_TCX_DEC_RECONF_BFI stereo_tcx_dec_mode_switch_reconf( st, MCT_flag, last_element_mode ); -#else - st->rate_switching_init = 1; - - /* Identify frame type - TCX Reconfiguration */ - for ( frame_size_index = 0; frame_size_index < FRAME_SIZE_NB; frame_size_index++ ) - { - if ( frame_size_index < FRAME_SIZE_NB - 1 ) - { - if ( ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal ) && ( FrameSizeConfig[frame_size_index + 1].frame_bits > st->bits_frame_nominal ) ) - { - break; - } - } - else - { - if ( FrameSizeConfig[frame_size_index].frame_bits <= st->bits_frame_nominal ) - { - break; - } - } - } - - /* Reconfigure Core */ - mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode ); -#endif } return; @@ -304,11 +265,7 @@ void stereo_tcx_core_dec( tcx_current_overlap_mode = st->hTcxCfg->tcx_curr_overlap_mode; #endif -#ifdef FIX_TCX_DEC_RECONF_BFI dec_prm_tcx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead ); -#else - dec_prm_tcx( st, param, param_lpc, &total_nbbits, &bitsRead ); -#endif #ifdef FIX_IVAS_337 /*IVAS-337 consider BER */ if ( !st->rate_switching_init && st->BER_detect ) @@ -832,9 +789,7 @@ static void dec_prm_tcx( int16_t param[], /* o : decoded parameters */ int16_t param_lpc[], /* o : LPC parameters */ int16_t *total_nbbits, /* i/o: number of bits / decoded bits */ -#ifdef FIX_TCX_DEC_RECONF_BFI const int16_t last_element_mode, -#endif int16_t *bitsRead /* o : number of read bits */ ) { @@ -888,13 +843,11 @@ static void dec_prm_tcx( st->prev_bfi = 1; } -#ifdef FIX_TCX_DEC_RECONF_BFI /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */ if ( ( st->last_core != st->last_core_from_bs ) && ( st->last_core_from_bs != TCX_20_CORE && st->last_core_from_bs != TCX_10_CORE && !( st->prev_bfi == 1 && st->last_core_from_bs == ACELP_CORE && st->last_con_tcx == 1 ) ) ) { stereo_tcx_dec_mode_switch_reconf( st, 0, last_element_mode ); } -#endif st->last_core = st->last_core_from_bs; @@ -959,7 +912,6 @@ static void dec_prm_tcx( return; } -#ifdef FIX_TCX_DEC_RECONF_BFI static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, @@ -991,4 +943,3 @@ static void stereo_tcx_dec_mode_switch_reconf( /* Reconfigure Core */ mode_switch_decoder_LPD( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode ); } -#endif diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index b7f69b38b009f8c5f72dd587fadac86878a66da0..8207336b82d67e466aac9da00d0aa2f1d1949f8f 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -59,7 +59,6 @@ extern FILE *agcOut; static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_agc_enc_state_t *pState ); #endif -#ifdef AGC_ENABLE_FOR_LBR #ifdef DEBUG_AGC_ENCODER_CMD_OPTION /*-----------------------------------------------------------------------------------------* * Function ivas_agc_enc_get_flag() @@ -95,7 +94,6 @@ int16_t ivas_agc_enc_get_flag( return (int16_t) ( nchan_transport == 1 ); #endif } -#endif /* AGC_ENABLE_FOR_LBR */ /*-----------------------------------------------------------------------------------------* * Function ivas_agc_enc_init() @@ -270,11 +268,7 @@ void ivas_agc_enc_process( { float sampleAbsVal; int16_t isClipped = FALSE; -#ifdef AGC_TUNING_IMPROVEMENT int16_t clippedIdx = 0; -#else - int16_t clippedIdx = offset - 1; -#endif int16_t MaxAbsValIdx = 0; float MaxAbsVal = pState->gain_state[i].MaxAbsVal_del; float predMaxAbsVal = fabsf( ppPcm_in[i][offset] ); @@ -303,25 +297,12 @@ void ivas_agc_enc_process( { if ( ( ppPcm_out[i][j] > ( 1.f - pState->minDelta ) * PCM16_TO_FLT_FAC ) || ( ppPcm_out[i][j] < MIN16B_FLT ) ) { -#ifdef AGC_TUNING_IMPROVEMENT clippedIdx = j; -#else - if ( j < offset ) - { - clippedIdx = j; - } -#endif isClipped = TRUE; } } } -#ifndef AGC_TUNING_IMPROVEMENT - if ( MaxAbsValIdx >= offset ) - { - MaxAbsValIdx = offset - 1; - } -#endif pState->gain_state[i].MaxAbsVal_del = predMaxAbsVal; isGainAdjusted = FALSE; @@ -371,80 +352,59 @@ void ivas_agc_enc_process( { int16_t isCompensated = FALSE; actualMaxAbsVal = pState->gain_state[i].lastMaxAbs * pState->gain_state[i].lastGain; -#ifndef AGC_TUNING_IMPROVEMENT - if ( MaxAbsValIdx == 0 ) - { - pState->gain_data[i].gainException = TRUE; - } - else + pState->gain_data[i].gainException = FALSE; + pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[min( offset - 1, MaxAbsValIdx )] ) ); + + while ( !isCompensated ) { -#endif - pState->gain_data[i].gainException = FALSE; -#ifdef AGC_TUNING_IMPROVEMENT - pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[min( offset - 1, MaxAbsValIdx )] ) ); -#else - pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[MaxAbsValIdx] ) ); -#endif + float tmpSignal; + isCompensated = TRUE; - while ( !isCompensated ) + for ( idx = clippedIdx; idx <= MaxAbsValIdx; idx++ ) { - float tmpSignal; - isCompensated = TRUE; - - for ( idx = clippedIdx; idx <= MaxAbsValIdx; idx++ ) + if ( idx >= offset ) { -#ifdef AGC_TUNING_IMPROVEMENT - if ( idx >= offset ) - { - idx = MaxAbsValIdx; - tmpSignal = ppPcm_out[i][idx] * powf( pState->agc_com.winFunc[offset - 1], (float) pState->gain_state[i].gainExpVal ); - } - else - { -#endif - tmpSignal = ppPcm_out[i][idx] * powf( pState->agc_com.winFunc[idx], (float) pState->gain_state[i].gainExpVal ); -#ifdef AGC_TUNING_IMPROVEMENT - } -#endif - - if ( ( tmpSignal > ( 1.f - pState->minDelta ) * PCM16_TO_FLT_FAC ) || ( tmpSignal < MIN16B_FLT ) ) - { - isCompensated = FALSE; - break; - } + idx = MaxAbsValIdx; + tmpSignal = ppPcm_out[i][idx] * powf( pState->agc_com.winFunc[offset - 1], (float) pState->gain_state[i].gainExpVal ); } - - if ( !isCompensated ) + else { - pState->gain_state[i].gainExpVal++; + tmpSignal = ppPcm_out[i][idx] * powf( pState->agc_com.winFunc[idx], (float) pState->gain_state[i].gainExpVal ); } -#ifdef AGC_TUNING_IMPROVEMENT - if ( pState->gain_state[i].gainExpVal > currMaxAttExp ) + if ( ( tmpSignal > ( 1.f - pState->minDelta ) * PCM16_TO_FLT_FAC ) || ( tmpSignal < MIN16B_FLT ) ) { - pState->gain_state[i].gainExpVal = min( pState->gain_state[i].gainExpVal, currMaxAttExp ); + isCompensated = FALSE; break; } -#endif + } - if ( pState->gain_state[i].gainExpVal > currMaxAttExp ) - { - pState->gain_data[i].gainException = TRUE; + if ( !isCompensated ) + { + pState->gain_state[i].gainExpVal++; + } - if ( pState->gain_state[i].gainExpVal == gainExpValMaxRange ) + if ( pState->gain_state[i].gainExpVal > currMaxAttExp ) + { + pState->gain_state[i].gainExpVal = min( pState->gain_state[i].gainExpVal, currMaxAttExp ); + break; + } + + if ( pState->gain_state[i].gainExpVal > currMaxAttExp ) + { + pState->gain_data[i].gainException = TRUE; + + if ( pState->gain_state[i].gainExpVal == gainExpValMaxRange ) + { + extendedExpVal = TRUE; + if ( isCompensated ) { - extendedExpVal = TRUE; - if ( isCompensated ) - { - pState->gain_data[i].gainException = FALSE; - } + pState->gain_data[i].gainException = FALSE; } - break; } + break; } -#ifndef AGC_TUNING_IMPROVEMENT } -#endif } if ( !pState->gain_data[i].gainException ) @@ -470,11 +430,7 @@ void ivas_agc_enc_process( pState->gain_state[i].gainExpVal = (int16_t) ( -floorf( -logf( ( actualMaxAbsVal + pState->minDelta ) * MDFT_NORM_SCALING ) * INV_LOG_2 ) ); pState->gain_state[i].gainExpVal = min( gainExpValMaxRange, pState->gain_state[i].gainExpVal ); -#ifdef AGC_TUNING_IMPROVEMENT gain = powf( pState->agc_com.winFunc[offset - 1], pState->gain_state[i].gainExpVal ); -#else - gain = powf( 2.0f, -1.0f * pState->gain_state[i].gainExpVal ); -#endif for ( idx = 0; idx < input_frame; idx++ ) { ppPcm_out[i][idx] *= gain; @@ -563,9 +519,7 @@ void ivas_agc_enc_process( { push_next_indice( hMetaData, (uint16_t) pState->gain_data[i].absGainExpCurr, (int16_t) pState->agc_com.betaE ); push_next_indice( hMetaData, (uint16_t) pState->gain_data[i].gainException, 1 ); -#ifdef AGC_TUNING_IMPROVEMENT assert( pState->gain_data[i].gainException == FALSE ); -#endif } } } diff --git a/lib_enc/ivas_front_vad.c b/lib_enc/ivas_front_vad.c index 62eeee5a021b49f148e1b2b73f6dfb4175699f18..e9818cb7ae3456af2e5af698b27c85ac85691669 100644 --- a/lib_enc/ivas_front_vad.c +++ b/lib_enc/ivas_front_vad.c @@ -396,11 +396,7 @@ ivas_error front_vad_spar( hFrontVad = hSpar->hFrontVad; st = hSpar->hCoreCoderVAD; -#ifdef FIX_SBA_DTX_DECODE_ERROR if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= SBA_DTX_BITRATE_THRESHOLD ) -#else - if ( hEncoderConfig->Opt_DTX_ON && hEncoderConfig->ivas_total_brate <= IVAS_80k ) -#endif { /*------------------------------------------------------------------* * Initialization diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index 00d185fe08da83a10f9d1ee7320df703879e0174..99f198ff616fdd72dc5399608adf6b368ac6861b 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -120,18 +120,14 @@ ivas_error ivas_spar_enc_open( } /* AGC handle */ -#ifdef AGC_ENABLE_FOR_LBR #ifdef DEBUG_AGC_ENCODER_CMD_OPTION hSpar->AGC_Enable = ivas_agc_enc_get_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport ); #else hSpar->AGC_Enable = ivas_agc_enc_get_flag( nchan_transport ); #endif -#endif -#ifdef AGC_ENABLE_FOR_LBR hSpar->hAgcEnc = NULL; if ( hSpar->AGC_Enable ) -#endif { if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK ) { @@ -319,13 +315,8 @@ ivas_error ivas_spar_enc( *nb_bits_metadata = hMetaData->nb_bits_tot; -#ifdef FIX_SBA_DTX_DECODE_ERROR /* Force IVAS front pre-proc decision for higher bitrates */ if ( hEncoderConfig->ivas_total_brate > SBA_DTX_BITRATE_THRESHOLD || hEncoderConfig->Opt_DTX_ON == 0 ) -#else - /* temp hack to not force IVAS front pre-proc decision for higher bitrates */ - if ( hEncoderConfig->ivas_total_brate > IVAS_64k || hEncoderConfig->Opt_DTX_ON == 0 ) -#endif { st_ivas->hSpar->front_vad_flag = 0; } @@ -715,11 +706,7 @@ static ivas_error ivas_spar_enc_process( if ( dtx_vad == 1 ) { -#ifdef AGC_ENABLE_FOR_LBR if ( hSpar->AGC_Enable != 0 ) -#else - if ( hEncoderConfig->Opt_AGC_ON > 0 ) -#endif { ivas_agc_enc_process( hSpar->hAgcEnc, hMetaData, p_pcm_tmp, p_pcm_tmp, hSpar->hFbMixer->fb_cfg->num_out_chans, hEncoderConfig ); } diff --git a/lib_enc/ivas_stat_enc.h b/lib_enc/ivas_stat_enc.h index 4ae2e2f41fc1318599b71df9c0d83ba7802d2f6f..9d04506d7991230ff2d7d799c79befbd92b29c9f 100644 --- a/lib_enc/ivas_stat_enc.h +++ b/lib_enc/ivas_stat_enc.h @@ -671,9 +671,7 @@ typedef struct ivas_spar_enc_lib_t ivas_agc_enc_state_t *hAgcEnc; int16_t dirac_to_spar_md_bands[DIRAC_MAX_NBANDS]; int16_t enc_param_start_band; -#ifdef AGC_ENABLE_FOR_LBR int16_t AGC_Enable; -#endif PCA_ENC_STATE *hPCA; int32_t core_nominal_brate; /* Nominal bitrate for core coding */ FRONT_VAD_ENC_HANDLE hFrontVad; /* front-VAD handle */ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index be12701cdc722940f49d520e9dfb8f99fcfec00e..4dff969a4f3928fa04de45b2c27148731a4a2e89 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -453,13 +453,9 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ -#else - const bool Opt_AGC_ON, /* i : AGC on/off flag */ -#endif /* AGC_ENABLE_FOR_LBR */ -#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ - const bool Opt_PCA_ON /* i : PCA option flag */ +#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ + const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP , int16_t *numTransportChannels @@ -485,14 +481,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( hEncoderConfig->nchan_inp = ivas_sba_get_nchan( hEncoderConfig->sba_order, 0 ); /*planar input arg. deliberately set to zero since input always in ACN/SN3D*/ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR if ( ( error = agcAPIToInternal( Opt_AGC_ON, &( hEncoderConfig->Opt_AGC_ON ) ) ) != IVAS_ERR_OK ) { return error; } -#else - hEncoderConfig->Opt_AGC_ON = (int16_t) Opt_AGC_ON; -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ hEncoderConfig->Opt_PCA_ON = (int16_t) Opt_PCA_ON; @@ -890,11 +882,7 @@ static ivas_error configureEncoder( } #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR if ( hEncoderConfig->Opt_AGC_ON == SBA_AGC_FORCE_ENABLE && !( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_sba_mode_select( hEncoderConfig->ivas_total_brate ) == SBA_MODE_SPAR ) ) -#else - if ( hEncoderConfig->Opt_AGC_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_sba_mode_select( hEncoderConfig->ivas_total_brate ) == SBA_MODE_SPAR ) ) -#endif /* AGC_ENABLE_FOR_LBR */ { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "AGC supported in SBA format at bitrates >= 24.4 kbps only." ); } @@ -1518,7 +1506,6 @@ static ivas_error printConfigInfo_enc( fprintf( stdout, "- PCA configured with signal adaptive decision " ); } #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR switch ( hEncoderConfig->Opt_AGC_ON ) { case SBA_AGC_FORCE_ENABLE: @@ -1534,12 +1521,6 @@ static ivas_error printConfigInfo_enc( fprintf( stdout, "- AGC unknown " ); break; } -#else - if ( hEncoderConfig->Opt_AGC_ON ) - { - fprintf( stdout, "- AGC ON " ); - } -#endif /* AGC_ENABLE_FOR_LBR */ #else fprintf( stdout, "- AGC default mode " ); #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ @@ -2235,11 +2216,7 @@ static void init_encoder_config( hEncoderConfig->sba_order = 0; hEncoderConfig->sba_planar = 0; #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR hEncoderConfig->Opt_AGC_ON = SBA_AGC_DEFAULT; -#else - hEncoderConfig->Opt_AGC_ON = 0; -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ hEncoderConfig->Opt_PCA_ON = 0; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 373da97f966087d1f4a3ff5da7f118f0d1d5b3a7..09be11c6c816739c5b780c8be56d896c5b32ef94 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -123,7 +123,6 @@ typedef enum _IVAS_ENC_FORCED_MODE } IVAS_ENC_FORCED_MODE; #endif -#ifdef AGC_ENABLE_FOR_LBR #ifdef DEBUG_AGC_ENCODER_CMD_OPTION typedef enum _IVAS_ENC_AGC { @@ -132,7 +131,6 @@ typedef enum _IVAS_ENC_AGC IVAS_ENC_AGC_UNDEFINED = 0xffff } IVAS_ENC_AGC; #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ -#endif /* AGC_ENABLE_FOR_LBR */ /*---------------------------------------------------------------------* * Encoder structures @@ -200,11 +198,7 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const IVAS_ENC_SBA_ORDER order, /* i : order of the Ambisonics input */ const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ #ifdef DEBUG_AGC_ENCODER_CMD_OPTION -#ifdef AGC_ENABLE_FOR_LBR const IVAS_ENC_AGC Opt_AGC_ON, /* i : AGC on/off/undefined flag */ -#else - const bool Opt_AGC_ON, /* i : AGC on/off flag */ -#endif /* AGC_ENABLE_FOR_LBR */ #endif /* DEBUG_AGC_ENCODER_CMD_OPTION */ const bool Opt_PCA_ON /* i : PCA option flag */ #ifdef DEBUG_SBA_AUDIO_DUMP diff --git a/lib_util/head_rotation_file_reader.c b/lib_util/head_rotation_file_reader.c index f6f6b6ae0edd0d3d24f776669e408662ffc34062..cd1dd7bcf32904d6ae14682904e5bf14be0c2f3b 100644 --- a/lib_util/head_rotation_file_reader.c +++ b/lib_util/head_rotation_file_reader.c @@ -45,28 +45,6 @@ struct HeadRotFileReader bool fileRewind; }; -#ifndef FIX_I173_I174 -/*-----------------------------------------------------------------------* - * HeadRotationFrameCheck() - * - * Check if the read frame number corresponds to the decoder frame - *-----------------------------------------------------------------------*/ - -static ivas_error HeadRotationFrameCheck( - HeadRotFileReader *headRotReader, /* i/o: HeadRotFileReader handle */ - const int32_t frame_dec ) -{ - if ( headRotReader->fileRewind == false ) - { - if ( headRotReader->frameCounter / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES != frame_dec + 1 ) - { - return IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH; - } - } - - return IVAS_ERR_OK; -} -#endif /*-----------------------------------------------------------------------* * HeadRotationFileReader_open() @@ -121,18 +99,11 @@ ivas_error HeadRotationFileReading( ) { uint16_t i; -#ifndef FIX_I173_I174 - int32_t time_stamp = 0; -#endif float w, x, y, z; for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) { -#ifdef FIX_I173_I174 if ( 4 != fscanf( headRotReader->trajFile, "%f,%f,%f,%f", &w, &x, &y, &z ) ) -#else - if ( 5 != fscanf( headRotReader->trajFile, "%d,%f,%f,%f,%f", &time_stamp, &w, &x, &y, &z ) ) -#endif { if ( feof( headRotReader->trajFile ) ) { @@ -143,12 +114,6 @@ ivas_error HeadRotationFileReading( return IVAS_ERR_FAILED_FILE_PARSE; } -#ifndef FIX_I173_I174 - if ( headRotReader->fileRewind == false && headRotReader->frameCounter != time_stamp ) - { - return IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH; - } -#endif ( headRotReader->frameCounter )++; @@ -157,20 +122,6 @@ ivas_error HeadRotationFileReading( Quaternions[i].y = y; Quaternions[i].z = z; } -#ifndef FIX_I173_I174 - if ( headRotReader->fileRewind == false ) - { - if ( ( time_stamp + 1 ) % IVAS_MAX_PARAM_SPATIAL_SUBFRAMES != 0 ) - { - return IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH; - } - } - - if ( HeadRotationFrameCheck( headRotReader, frame_dec ) != IVAS_ERR_OK ) - { - return IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH; - } -#endif return IVAS_ERR_OK; } diff --git a/lib_util/ism_file_reader.c b/lib_util/ism_file_reader.c index 665c7ea1349dadaa9116755996540b596744074e..d60c3ec8a82420125290e1324a36329596463284 100644 --- a/lib_util/ism_file_reader.c +++ b/lib_util/ism_file_reader.c @@ -43,9 +43,6 @@ struct IsmFileReader { FILE *file; -#ifndef FIX_I173_I174 - int32_t frameCounter; -#endif char *file_path; }; @@ -77,9 +74,6 @@ IsmFileReader *IsmFileReader_open( self = calloc( sizeof( IsmFileReader ), 1 ); self->file = file; -#ifndef FIX_I173_I174 - self->frameCounter = 0; -#endif self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); strcpy( self->file_path, filePath ); @@ -102,9 +96,6 @@ ivas_error IsmFileReader_readNextFrame( float meta_prm[NUM_ISM_METADATA_PER_LINE]; char *char_ptr; int16_t i; -#ifndef FIX_I173_I174 - int32_t time_stamp; -#endif FILE *file; if ( ismMetadata == NULL || self->file == NULL ) @@ -120,18 +111,8 @@ ivas_error IsmFileReader_readNextFrame( } char_ptr = strtok( char_buff, "," ); -#ifndef FIX_I173_I174 - time_stamp = (int32_t) atoi( char_ptr ); - - if ( time_stamp != self->frameCounter ) - { - return IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH; - } -#endif i = 0; -#ifdef FIX_I173_I174 meta_prm[i++] = (float) atof( char_ptr ); -#endif while ( ( char_ptr = strtok( NULL, "," ) ) != NULL && i < NUM_ISM_METADATA_PER_LINE ) { meta_prm[i++] = (float) atof( char_ptr ); @@ -149,9 +130,6 @@ ivas_error IsmFileReader_readNextFrame( ismMetadata->spread = meta_prm[3]; ismMetadata->gainFactor = meta_prm[4]; -#ifndef FIX_I173_I174 - ++self->frameCounter; -#endif return IVAS_ERR_OK; } diff --git a/lib_util/ism_file_writer.c b/lib_util/ism_file_writer.c index 65bd72a9444eb7b7527ce24a7b1d0e0e5cfea0ed..ac90e7b1ebcb0f43275df3b725f21a53df88ebe4 100644 --- a/lib_util/ism_file_writer.c +++ b/lib_util/ism_file_writer.c @@ -43,9 +43,6 @@ struct IsmFileWriter { FILE *file; -#ifndef FIX_I173_I174 - int32_t frameCounter; -#endif char *file_path; }; @@ -88,9 +85,6 @@ ivas_error IsmFileWriter_open( self = calloc( sizeof( IsmFileWriter ), 1 ); self->file = file; -#ifndef FIX_I173_I174 - self->frameCounter = 0; -#endif self->file_path = calloc( sizeof( char ), strlen( filePath ) + 1 ); strcpy( self->file_path, filePath ); @@ -122,11 +116,7 @@ ivas_error IsmFileWriter_writeFrame( file = ismWriter->file; /* IVAS_fmToDo: work in progress; currently position_azimuth, position_elevation, position_radius, spread, gain_factor */ -#ifdef FIX_I173_I174 sprintf( char_buff, "%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); -#else - sprintf( char_buff, "%04d,%+07.2f,%+06.2f,%05.2f,%06.2f,%04.2f\n", ismWriter->frameCounter, ismMetadata.azimuth, ismMetadata.elevation, ismMetadata.radius, ismMetadata.spread, ismMetadata.gainFactor ); -#endif if ( file ) { @@ -136,9 +126,6 @@ ivas_error IsmFileWriter_writeFrame( { return IVAS_ERR_FAILED_FILE_WRITE; } -#ifndef FIX_I173_I174 - ++ismWriter->frameCounter; -#endif return IVAS_ERR_OK; }