diff --git a/apps/decoder.c b/apps/decoder.c index fc003928e92dcd7154c8bbba7f3e93d177058bca..b317b9a53996d400d03cf16f914414074910db63 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -590,8 +590,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 ff1bc4ed7ac2e0512e86d17fefc9f74901b44859..367583eb90832fda74f176fdbb7859591948dbc0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -170,6 +170,7 @@ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1158_FASTCONV_REVERB_HRTF /* Philips: issue 1158: Rendering with FastConv to BINAURAL_ROOM_REVERB uses BRIR convolution instead of HRTF */ +#define FIX_VOIP_FUNCTIONS /* VA: fix data type mismatch in IVAS_DEC_VoIP_SetScale() + add sanity checks to API functions */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a3d3c7492a650c8a1bd9f0e5362e8b94480f2708..900b879cb61323200c26964cdaa804e90063c42f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -444,7 +444,9 @@ ivas_error IVAS_DEC_Configure( DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; +#ifndef FIX_VOIP_FUNCTIONS error = IVAS_ERR_OK; +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -547,7 +549,11 @@ ivas_error IVAS_DEC_Configure( } #endif +#ifdef FIX_VOIP_FUNCTIONS + return IVAS_ERR_OK; +#else return error; +#endif } @@ -743,9 +749,9 @@ ivas_error IVAS_DEC_EnableVoIP( { DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; - +#ifndef FIX_VOIP_FUNCTIONS error = IVAS_ERR_OK; - +#endif if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { @@ -813,7 +819,11 @@ ivas_error IVAS_DEC_EnableVoIP( } #endif +#ifdef FIX_VOIP_FUNCTIONS + return IVAS_ERR_OK; +#else return error; +#endif } @@ -1669,6 +1679,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; @@ -2112,6 +2129,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 ); @@ -2205,6 +2229,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; @@ -3002,7 +3033,10 @@ 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 @@ -3051,6 +3085,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 */ @@ -3129,11 +3170,22 @@ ivas_error IVAS_DEC_VoIP_SetScale( const int16_t scale /* i : TSM scale to set in percent of the default frame size */ ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } +#else ivas_error error; error = IVAS_ERR_OK; +#endif +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == 0 ) +#else if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm == false ) +#endif { return IVAS_ERR_TSM_NOT_ENABLED; } @@ -3143,7 +3195,11 @@ ivas_error IVAS_DEC_VoIP_SetScale( hIvasDec->tsm_max_scaling = maxScaling; } +#ifdef FIX_VOIP_FUNCTIONS + return IVAS_ERR_OK; +#else return error; +#endif } @@ -3167,6 +3223,13 @@ ivas_error IVAS_DEC_TSM_SetQuality( const float quality /* i : target TSM quality */ ) { +#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 ) { return IVAS_ERR_TSM_NOT_ENABLED; @@ -3217,6 +3280,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif 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; @@ -3454,13 +3524,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; } @@ -3482,6 +3557,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; @@ -3510,6 +3592,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 ) ); } @@ -3616,7 +3705,11 @@ ivas_error IVAS_DEC_GetJbmData( ) { +#ifdef FIX_VOIP_FUNCTIONS + if ( hIvasDec == NULL || hIvasDec->hVoIP == NULL || JbmTraceData == NULL ) +#else if ( hIvasDec->hVoIP == NULL ) +#endif { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } @@ -3928,14 +4021,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 dafae6518ed95256ce27d9c077a1dc2996b11647..50476c964bda0a25f0e19907be177b64ad6a0533 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -513,7 +513,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