From bee11a909648b0fcf0d23951fe5565c6292ef939 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 3 Aug 2023 23:43:20 +0200 Subject: [PATCH 1/2] formal improvements --- lib_rend/lib_rend.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index e30368606a..11cf5d087a 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4112,16 +4112,22 @@ static ivas_error findFreeInputSlot( } #ifdef SPLIT_REND_WITH_HEAD_ROT -static void closeSplitRend( SPLIT_REND_WRAPPER *pSplitRendWrapper, IVAS_REND_AudioBuffer *pSplitRendEncBuffer ) +static void closeSplitRend( + SPLIT_REND_WRAPPER *pSplitRendWrapper, + IVAS_REND_AudioBuffer *pSplitRendEncBuffer ) { ivas_split_renderer_close( pSplitRendWrapper ); + if ( pSplitRendEncBuffer->data != NULL ) { free( pSplitRendEncBuffer->data ); pSplitRendEncBuffer->data = NULL; } + pSplitRendEncBuffer->config.numChannels = 0; pSplitRendEncBuffer->config.numSamplesPerChannel = 0; + + return; } #endif @@ -8654,7 +8660,7 @@ ivas_error IVAS_REND_GetSamples( &bits, Cldfb_RealBuffer_Binaural, Cldfb_ImagBuffer_Binaural, - ( const int16_t )( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), + (const int16_t) ( ( BINAURAL_MAXBANDS * hIvasRend->sampleRateOut ) / 48000 ), tmpBinaural, 1, td_input, -- GitLab From fb5e70bc09d9c189882725b30ac581af5e28133b Mon Sep 17 00:00:00 2001 From: vaclav Date: Sun, 13 Aug 2023 16:55:22 +0200 Subject: [PATCH 2/2] fix segfault when first frame is lost --- lib_dec/ivas_dec.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 044eebd1e6..62e1479ec9 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,17 @@ ivas_error ivas_dec( st_ivas->last_ivas_format = st_ivas->ivas_format; #endif +#ifdef FIX_264_AUDIO_CHANNELS_TO_HEAP + 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" ); -- GitLab