From f8b67dce4f68da105e3f15f704d386a0cb0ca196 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 3 Nov 2022 10:43:17 +0100 Subject: [PATCH 1/2] Issue 62: lower agc_com.winFunc memory consumption; under FIX_AGC_WINFUNC_MEMORY --- lib_com/options.h | 2 ++ lib_dec/ivas_agc_dec.c | 15 +++++++++++++++ lib_enc/ivas_agc_enc.c | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8c9e60ab79..f0801028cb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,8 @@ #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 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 81039651d8..e522574bb2 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 53a6df3a13..b7f69b38b0 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; -- GitLab From 4d63f4fc27774ca8acb7b6930116a6e11b59b11e Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 4 Nov 2022 10:07:11 +0100 Subject: [PATCH 2/2] merge main --- lib_com/options.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index cad2176e3e..c8740088c3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,9 +155,10 @@ #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 */ #endif -- GitLab