diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 044eebd1e649442e8db00f6e94ee98609e83477f..eb8e13c65a4cf9b17857ff1a1a92815fb991ea03 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -179,6 +179,19 @@ ivas_error ivas_dec( if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) { +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + for ( n = 0; n < nchan_out; n++ ) + { + /* note: these are intra-frame heap memories */ + if ( ( st_ivas->p_output_f[n] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) ); + } + output[n] = st_ivas->p_output_f[n]; + p_output[n] = output[n]; + } +#endif + /* zero output when first frame(s) is lost */ for ( n = 0; n < nchan_out; n++ ) { @@ -1255,6 +1268,18 @@ ivas_error ivas_dec( st_ivas->last_ivas_format = st_ivas->ivas_format; #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + /* in case first frame(s) was/were lost, deallocate output buffers */ + if ( st_ivas->bfi && st_ivas->ini_frame == 0 ) + { + for ( n = 0; n < nchan_out; n++ ) + { + free( st_ivas->p_output_f[n] ); + st_ivas->p_output_f[n] = NULL; + } + } +#endif + #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" );