From 9c8937e17206b2477e3d20b4f2af4b9b20698510 Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Tue, 21 Jan 2025 13:52:35 +0100 Subject: [PATCH 1/2] use correct delay value for EXT output MASA metadata frames also for bad initial frames. switch: NONBE_FIX_1261_MASA_EXT_META_JBM --- apps/decoder.c | 14 ++++++++++++++ lib_com/options.h | 1 + 2 files changed, 15 insertions(+) diff --git a/apps/decoder.c b/apps/decoder.c index 79c825809e..f51e8ea2b1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2004,6 +2004,18 @@ static ivas_error initOnFirstGoodFrame( { /* Duplicate good first frame metadata to fill the beginning of stream. */ IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; +#ifdef NONBE_FIX_1261_MASA_EXT_META_JBM + int16_t fullDelayNumSamplesLocal[3]; + int32_t delayTimeScaleLocal; + float delayMs; + + /* fullDelayNumSamples is zeroed so need to re-fetch delay info */ + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamplesLocal, &delayTimeScaleLocal ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + } + delayMs = (float) ( fullDelayNumSamplesLocal[0] ) / (float) ( delayTimeScaleLocal ); +#endif if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) { @@ -2013,7 +2025,9 @@ static ivas_error initOnFirstGoodFrame( for ( int16_t j = 0; j < numInitialBadFrames; ++j ) { +#ifndef NONBE_FIX_1261_MASA_EXT_META_JBM float delayMs = (float) ( pFullDelayNumSamples[0] ) / (float) ( *delayTimeScale ); +#endif if ( ( error = MasaFileWriter_writeFrame( *ppMasaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) ); diff --git a/lib_com/options.h b/lib_com/options.h index f6aaeba759..c7c98ad64e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,7 @@ #define NONBE_1215_FIX_JBM_MAX_SCALING /* FhG: issue 1215: Fix assert hit in a specific VoIP decoder config. Caused by integer overflow in max scaling calculation. */ #define NONBE_FIX_1255_OBJ_EDIT_JBM /* VA: issue 1255: restore object editing in JBM */ +#define NONBE_FIX_1261_MASA_EXT_META_JBM /* Nokia: issue #1261: MASA metadata EXT output delay buffer init in JBM */ /* ##################### End NON-BE switches ########################### */ -- GitLab From ff2a02ef94ab40aeb65ffcbb730f05b0875cc22a Mon Sep 17 00:00:00 2001 From: Jouni Paulus Date: Wed, 22 Jan 2025 13:07:47 +0100 Subject: [PATCH 2/2] make sure all variable declarations are done before the first use in the scope --- apps/decoder.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index f51e8ea2b1..4b7bf91736 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2003,11 +2003,12 @@ static ivas_error initOnFirstGoodFrame( if ( numInitialBadFrames > 0 ) { /* Duplicate good first frame metadata to fill the beginning of stream. */ - IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; #ifdef NONBE_FIX_1261_MASA_EXT_META_JBM int16_t fullDelayNumSamplesLocal[3]; int32_t delayTimeScaleLocal; float delayMs; + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta; + hMasaExtOutMeta = NULL; /* fullDelayNumSamples is zeroed so need to re-fetch delay info */ if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamplesLocal, &delayTimeScaleLocal ) ) != IVAS_ERR_OK ) @@ -2015,6 +2016,8 @@ static ivas_error initOnFirstGoodFrame( fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); } delayMs = (float) ( fullDelayNumSamplesLocal[0] ) / (float) ( delayTimeScaleLocal ); +#else + IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta = NULL; #endif if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK ) -- GitLab