diff --git a/lib_com/options.h b/lib_com/options.h index db4c245a05bcbc77a90bedd0380240d146da7de1..c8740088c3757b7c65b709c1192b588320dfaa30 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,9 @@ #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_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 */ diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 81039651d882bba17c0643d655d4a9e24b40d29b..e522574bb241dae3c01be57adac0b72244151d57 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -98,7 +98,11 @@ ivas_error ivas_spar_agc_dec_open( ) { ivas_agc_dec_state_t *hAgc; +#ifdef FIX_AGC_WINFUNC_MEMORY + int16_t output_frame, delay; +#else int16_t output_frame; +#endif if ( ( hAgc = (ivas_agc_dec_state_t *) count_malloc( sizeof( ivas_agc_dec_state_t ) ) ) == NULL ) { @@ -106,8 +110,15 @@ ivas_error ivas_spar_agc_dec_open( } output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); +#ifdef FIX_AGC_WINFUNC_MEMORY + delay = NS2SA( output_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) ); +#endif +#ifdef FIX_AGC_WINFUNC_MEMORY + if ( ( hAgc->agc_com.winFunc = (float *) count_malloc( sizeof( float ) * ( output_frame - delay ) ) ) == NULL ) +#else if ( ( hAgc->agc_com.winFunc = (float *) count_malloc( sizeof( float ) * output_frame ) ) == NULL ) +#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AGC decoder" ); } @@ -122,7 +133,11 @@ ivas_error ivas_spar_agc_dec_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for AGC decoder" ); } +#ifdef FIX_AGC_WINFUNC_MEMORY + ivas_agc_dec_init( hAgc, output_frame, delay ); +#else ivas_agc_dec_init( hAgc, output_frame, NS2SA( output_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) ) ); +#endif *hAgcDec = hAgc; diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 53a6df3a137714123e51563ecb542de1968445c8..b7f69b38b009f8c5f72dd587fadac86878a66da0 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -159,7 +159,11 @@ ivas_error ivas_spar_agc_enc_open( ) { ivas_agc_enc_state_t *hAgc; +#ifdef FIX_AGC_WINFUNC_MEMORY + int16_t input_frame, delay; +#else int16_t input_frame; +#endif if ( ( hAgc = (ivas_agc_enc_state_t *) count_malloc( sizeof( ivas_agc_enc_state_t ) ) ) == NULL ) { @@ -167,8 +171,15 @@ ivas_error ivas_spar_agc_enc_open( } input_frame = (int16_t) ( input_Fs / FRAMES_PER_SEC ); +#ifdef FIX_AGC_WINFUNC_MEMORY + delay = NS2SA( input_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) ); +#endif +#ifdef FIX_AGC_WINFUNC_MEMORY + if ( ( hAgc->agc_com.winFunc = (float *) count_malloc( sizeof( float ) * ( input_frame - delay ) ) ) == NULL ) +#else if ( ( hAgc->agc_com.winFunc = (float *) count_malloc( sizeof( float ) * input_frame ) ) == NULL ) +#endif { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR AGC encoder" ); } @@ -183,7 +194,11 @@ ivas_error ivas_spar_agc_enc_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR AGC encoder" ); } +#ifdef FIX_AGC_WINFUNC_MEMORY + ivas_agc_enc_init( hAgc, input_frame, nchan_inp, delay ); +#else ivas_agc_enc_init( hAgc, input_frame, nchan_inp, NS2SA( input_Fs, ( IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS ) ) ); +#endif *hAgcEnc = hAgc;