From 9884516f92fdfef048ff0999c140a879537e7fab Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 20 Aug 2025 15:10:35 +0200 Subject: [PATCH] port MRs --- apps/decoder.c | 8 +++ lib_com/options.h | 1 + lib_dec/lib_dec.c | 133 ++++++++++++++++++++++++++++++++++++++-------- lib_dec/lib_dec.h | 28 +++++----- 4 files changed, 136 insertions(+), 34 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 34df9b682..5408d4507 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -594,8 +594,16 @@ int main( fprintf( stdout, "FEC: %.2f %%\n", arg.FER ); } } +#else +#ifdef FIX_VOIP_FUNCTIONS + if ( ( error = IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_PrintConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } #else IVAS_DEC_PrintConfig( hIvasDec, 1, arg.voipMode ); +#endif #endif /*-------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index 9077fa821..d15eee174 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -207,6 +207,7 @@ #define FIX_1101_CLEANING_JBM_CALL /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */ #define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */ #define FIX_1348_OVERFLOW /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */ +#define FIX_VOIP_FUNCTIONS /* VA: fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to API functions */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index fbb413ab1..3375f540b 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -422,7 +422,6 @@ ivas_error IVAS_DEC_Configure( DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - error = IVAS_ERR_OK; if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -520,7 +519,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; - return error; + return IVAS_ERR_OK; } @@ -556,7 +555,7 @@ ivas_error IVAS_DEC_EnableSplitRendering( * Get the 5ms flag *---------------------------------------------------------------------*/ -int16_t get_render_frame_size_ms( +static int16_t get_render_frame_size_ms( const IVAS_RENDER_FRAMESIZE render_framesize ) { return (int16_t) ( render_framesize * ( 1000 / ( FRAMES_PER_SEC * IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); @@ -716,9 +715,6 @@ ivas_error IVAS_DEC_EnableVoIP( DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - error = IVAS_ERR_OK; - - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -775,7 +771,7 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } - return error; + return IVAS_ERR_OK; } @@ -1089,6 +1085,13 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( int16_t ro_md_flag; IVAS_QUATERNION Quaternion; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } +#endif + error = IVAS_ERR_OK; st_ivas = hIvasDec->st_ivas; output_config = st_ivas->hDecoderConfig->output_config; @@ -1525,6 +1528,13 @@ ivas_error IVAS_DEC_GetFormat( IVAS_DEC_BS_FORMAT *format /* o : format detected from bitstream fed to the decoder */ ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif if ( hIvasDec->hasDecodedFirstGoodFrame ) { *format = mapIvasFormat( hIvasDec->st_ivas->ivas_format ); @@ -1533,12 +1543,14 @@ ivas_error IVAS_DEC_GetFormat( { *format = IVAS_DEC_BS_UNKOWN; } + #ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT if ( *format == IVAS_DEC_BS_MASA && hIvasDec->st_ivas->hMasa->config.input_ivas_format == MASA_ISM_FORMAT ) { *format = IVAS_DEC_BS_MASA_ISM; } #endif + return IVAS_ERR_OK; } @@ -1618,6 +1630,13 @@ ivas_error IVAS_DEC_GetNumOutputChannels( int16_t *numOutputChannels /* o : number of PCM output channels */ ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif if ( hIvasDec->hasDecodedFirstGoodFrame ) { *numOutputChannels = hIvasDec->st_ivas->hDecoderConfig->nchan_out; @@ -2387,7 +2406,11 @@ static bool isSidFrame( return false; } -static void bsCompactToSerial( const uint8_t *compact, uint16_t *serial, uint16_t num_bits ) + +static void bsCompactToSerial( + const uint8_t *compact, + uint16_t *serial, + const uint16_t num_bits ) { /* Bitstream conversion is not counted towards complexity and memory usage */ #define WMC_TOOL_SKIP @@ -2436,6 +2459,13 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( int16_t partialCopyFrameType, partialCopyOffset; int16_t result; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || au == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif if ( auSize == 0 ) { return IVAS_ERR_OK; /* ignore empty/NO_DATA frame - shouldn't be transmitted in RTP */ @@ -2514,9 +2544,12 @@ ivas_error IVAS_DEC_VoIP_SetScale( const int16_t scale /* i : TSM scale to set in percent of the default frame size */ ) { - ivas_error error; - - error = IVAS_ERR_OK; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } +#endif if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) { @@ -2528,25 +2561,36 @@ ivas_error IVAS_DEC_VoIP_SetScale( hIvasDec->tsm_max_scaling = maxScaling; } - return error; + return IVAS_ERR_OK; } /*---------------------------------------------------------------------* - * IVAS_DEC_VoIP_SetScale( ) + * IVAS_DEC_TSM_SetQuality( ) * - * Set the TSM scale + * set the quality theshold for the time scale modiciation that is used + * to determine if the TSM yielded a signal that satisfies the minimum + * quality requirements. + * quality is lower limit for minimum quality + * Range is [-2;2] - where positive values allow + * only pasting with same phase information + * Negative values would yield cross phased pasting + * When not setting the minimum quality with this function the default + * value used is 1.0f *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_TSM_SetQuality( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const float quality /* i : target TSM quality */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const float quality /* i : target TSM quality */ ) { - ivas_error error; - - error = IVAS_ERR_OK; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) +#endif + if ( !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) { return IVAS_ERR_TSM_NOT_ENABLED; } @@ -2555,7 +2599,7 @@ ivas_error IVAS_DEC_TSM_SetQuality( hIvasDec->tsm_quality = quality; } - return error; + return IVAS_ERR_OK; } @@ -2589,6 +2633,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( int16_t nSamplesRendered; uint8_t nOutChannels; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->hVoIP == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; hVoIP = hIvasDec->hVoIP; @@ -2759,13 +2810,18 @@ static void update_voip_rendered20ms( const int16_t nSamplesRendered ) { int16_t nSamplesRenderedTotal; + nSamplesRenderedTotal = hIvasDec->hVoIP->nSamplesRendered20ms + nSamplesRendered; + /* we have crossed a 20ms border, reset the time scaling done flag */ if ( nSamplesRenderedTotal >= hIvasDec->hVoIP->nSamplesFrame ) { hIvasDec->timeScalingDone = 0; } + hIvasDec->hVoIP->nSamplesRendered20ms = nSamplesRenderedTotal % hIvasDec->hVoIP->nSamplesFrame; + + return; } @@ -2787,6 +2843,13 @@ ivas_error IVAS_DEC_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif *nSamplesFlushed = min( nSamplesPerChannel, hIvasDec->nSamplesAvailableNext ); nSamplesToRender = (uint16_t) *nSamplesFlushed; @@ -2801,6 +2864,7 @@ ivas_error IVAS_DEC_Flush( { *nSamplesFlushed = 0; } + return error; } @@ -2815,6 +2879,13 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif return ( ( JB4_bufferedDataUnits( hIvasDec->hVoIP->hJBM ) == 0 ) && ( hIvasDec->nSamplesAvailableNext < nSamplesAsked ) ); } @@ -2918,10 +2989,13 @@ static void store_JbmData( ivas_error IVAS_DEC_GetJbmData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ IVAS_JBM_TRACE_DATA *JbmTraceData /* o : JBM Trace data */ - ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || JbmTraceData == NULL ) +#else if ( hIvasDec->hVoIP == NULL ) +#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -3146,14 +3220,29 @@ static ivas_error printConfigInfo_dec( * Print decoder set-up info *---------------------------------------------------------------------*/ +#ifdef FIX_VOIP_FUNCTIONS +ivas_error IVAS_DEC_PrintConfig( +#else void IVAS_DEC_PrintConfig( +#endif const IVAS_DEC_HANDLE hIvasDec, const bool quietModeEnabled, const bool voipMode ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + +#endif printConfigInfo_dec( hIvasDec->st_ivas, hIvasDec->bitstreamformat, voipMode, quietModeEnabled ); +#ifdef FIX_VOIP_FUNCTIONS + return IVAS_ERR_OK; +#else return; +#endif } diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index df0101627..09c5eefc0 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -304,33 +304,33 @@ ivas_error IVAS_DEC_EnableSplitRendering( ); ivas_error IVAS_DEC_SetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const IVAS_RENDER_FRAMESIZE render_framesize /* i : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesize( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_RENDER_FRAMESIZE *render_framesize /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *render_framesize /* o : render framesize in samples */ ); ivas_error IVAS_DEC_GetReferencesUpdateFrequency( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *update_frequency /* o : update frequency */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *update_frequency /* o : update frequency */ ); ivas_error IVAS_DEC_GetNumOrientationSubframes( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - int16_t *num_subframes /* o : render framesize */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *num_subframes /* o : render framesize */ ); ivas_error IVAS_DEC_GetRenderFramesizeMs( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint32_t *render_framesize /* o : render framesize in samples */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint32_t *render_framesize /* o : render framesize in samples */ ); #ifdef DEBUGGING @@ -483,7 +483,11 @@ const char *IVAS_DEC_GetErrorMessage( ivas_error error /* i : decoder error code enum */ ); +#ifdef FIX_VOIP_FUNCTIONS +ivas_error IVAS_DEC_PrintConfig( +#else void IVAS_DEC_PrintConfig( +#endif const IVAS_DEC_HANDLE hIvasDec, /* i : IVAS decoder handle */ const bool quietModeEnabled, /* i : quiet mode flag: if true, reduces the amount of config info printed */ const bool voipMode -- GitLab