Commit f8b67dce authored by vaclav's avatar vaclav
Browse files

Issue 62: lower agc_com.winFunc memory consumption; under FIX_AGC_WINFUNC_MEMORY

parent d76dee82
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+15 −0
Original line number Diff line number Diff line
@@ -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;

+15 −0
Original line number Diff line number Diff line
@@ -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;