Loading apps/encoder.c +19 −0 Original line number Diff line number Diff line Loading @@ -120,7 +120,11 @@ typedef struct const char *ca_config_file; bool mimeOutput; #ifdef AGC_ENABLE_FOR_LBR IVAS_ENC_AGC agc; #else bool agc; #endif bool pca; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ Loading Loading @@ -870,7 +874,11 @@ static void initArgStruct( EncArguments *arg ) arg->ca_config_file = NULL; arg->mimeOutput = false; #ifdef AGC_ENABLE_FOR_LBR arg->agc = IVAS_ENC_AGC_UNDEFINED; #else arg->agc = IVAS_DEFAULT_AGC; #endif arg->pca = false; #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; Loading Loading @@ -1381,7 +1389,11 @@ 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] ) ); Loading Loading @@ -1636,7 +1648,14 @@ static void usage_enc( void ) #ifdef DEBUG_SBA fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif #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 fprintf( stdout, "-bypass mode : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" ); #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); Loading lib_com/ivas_agc_com.c +29 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ #endif #include <math.h> #include "wmops.h" #ifdef AGC_TUNING_IMPROVEMENT #include "prot.h" #endif /*------------------------------------------------------------------------------------------* * Local constants Loading @@ -47,6 +50,11 @@ #define SQRKMAX ( 1.5f ) #define NBITS_DIFFG ( 2 ) #ifdef AGC_TUNING_IMPROVEMENT #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() Loading @@ -60,12 +68,22 @@ 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; Loading @@ -89,7 +107,11 @@ 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 ); Loading @@ -98,10 +120,17 @@ 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; } Loading lib_com/ivas_prot.h +10 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,9 @@ #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" #ifdef AGC_ENABLE_FOR_LBR #include "lib_enc.h" #endif /* clang-format off */ Loading Loading @@ -3770,6 +3772,13 @@ void ivas_sba_prototype_renderer( ); /* AGC */ #ifdef AGC_ENABLE_FOR_LBR int16_t ivas_agc_enc_get_enablement_flag( IVAS_ENC_AGC agc_configuration, /* i : configuration used when encoder was initialised from cmd line */ 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 */ const int32_t input_Fs, /* i : input sampling rate */ Loading lib_com/options.h +5 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,11 @@ #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 /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif lib_dec/ivas_agc_dec.c +14 −0 Original line number Diff line number Diff line Loading @@ -190,10 +190,20 @@ 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 ) Loading Loading @@ -227,7 +237,11 @@ 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++ ) Loading Loading
apps/encoder.c +19 −0 Original line number Diff line number Diff line Loading @@ -120,7 +120,11 @@ typedef struct const char *ca_config_file; bool mimeOutput; #ifdef AGC_ENABLE_FOR_LBR IVAS_ENC_AGC agc; #else bool agc; #endif bool pca; #ifdef DEBUG_FOA_AGC FILE *agcBitstream; /* temporary */ Loading Loading @@ -870,7 +874,11 @@ static void initArgStruct( EncArguments *arg ) arg->ca_config_file = NULL; arg->mimeOutput = false; #ifdef AGC_ENABLE_FOR_LBR arg->agc = IVAS_ENC_AGC_UNDEFINED; #else arg->agc = IVAS_DEFAULT_AGC; #endif arg->pca = false; #ifdef DEBUG_FOA_AGC arg->agcBitstream = NULL; Loading Loading @@ -1381,7 +1389,11 @@ 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] ) ); Loading Loading @@ -1636,7 +1648,14 @@ static void usage_enc( void ) #ifdef DEBUG_SBA fprintf( stdout, "-tag : Tag name for intermediate debug files\n" ); #endif #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 fprintf( stdout, "-bypass mode : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" ); #ifdef DEBUGGING fprintf( stdout, "-force T : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" ); Loading
lib_com/ivas_agc_com.c +29 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ #endif #include <math.h> #include "wmops.h" #ifdef AGC_TUNING_IMPROVEMENT #include "prot.h" #endif /*------------------------------------------------------------------------------------------* * Local constants Loading @@ -47,6 +50,11 @@ #define SQRKMAX ( 1.5f ) #define NBITS_DIFFG ( 2 ) #ifdef AGC_TUNING_IMPROVEMENT #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() Loading @@ -60,12 +68,22 @@ 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; Loading @@ -89,7 +107,11 @@ 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 ); Loading @@ -98,10 +120,17 @@ 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; } Loading
lib_com/ivas_prot.h +10 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,9 @@ #include "ivas_stat_dec.h" #include "ivas_stat_com.h" #include "ivas_error_utils.h" #ifdef AGC_ENABLE_FOR_LBR #include "lib_enc.h" #endif /* clang-format off */ Loading Loading @@ -3770,6 +3772,13 @@ void ivas_sba_prototype_renderer( ); /* AGC */ #ifdef AGC_ENABLE_FOR_LBR int16_t ivas_agc_enc_get_enablement_flag( IVAS_ENC_AGC agc_configuration, /* i : configuration used when encoder was initialised from cmd line */ 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 */ const int32_t input_Fs, /* i : input sampling rate */ Loading
lib_com/options.h +5 −0 Original line number Diff line number Diff line Loading @@ -158,6 +158,11 @@ #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 /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif
lib_dec/ivas_agc_dec.c +14 −0 Original line number Diff line number Diff line Loading @@ -190,10 +190,20 @@ 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 ) Loading Loading @@ -227,7 +237,11 @@ 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++ ) Loading