diff --git a/apps/decoder.c b/apps/decoder.c index c869a5b50fb7fca7f2788a0e4ab52889d4f7114b..8a2d8a37b2cf04c53bacaa7e90f4114762230457 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 addbec25cc92305aa675cada71b2c8b587e07c88..b1f76d4691842b94af204db524dbba64fa4dd3c7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -208,6 +208,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 */ #define FIX_587_DEFAULT_REVERB /* Philips: issue 587: inconsistent default reverb parameters across renderers */ #define NONBE_1214_PLC_LSF_MEMORY /* VA: issue 1224: reset ACELP PLC FEC memory in case of switching from MDCT stereo to TD/DFT stereo */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b5c46644cacfd66b0a66fb9f9dbbe51bb9f95da8..29237e5790c5de6627422fa2286a38ae4ab40b93 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; @@ -521,7 +520,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->tsm_max_scaling = 0; hIvasDec->tsm_quality = 1.0f; - return error; + return IVAS_ERR_OK; } @@ -557,7 +556,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 ) ) ); @@ -717,9 +716,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; @@ -776,7 +772,7 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_FAILED_ALLOC; } - return error; + return IVAS_ERR_OK; } @@ -1090,6 +1086,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; @@ -1526,6 +1529,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 ); @@ -1534,12 +1544,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; } @@ -1619,6 +1631,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; @@ -2392,7 +2411,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 @@ -2441,6 +2464,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 */ @@ -2519,9 +2549,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 ) { @@ -2533,25 +2566,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; } @@ -2560,7 +2604,7 @@ ivas_error IVAS_DEC_TSM_SetQuality( hIvasDec->tsm_quality = quality; } - return error; + return IVAS_ERR_OK; } @@ -2594,6 +2638,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; @@ -2764,13 +2815,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; } @@ -2792,6 +2848,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; @@ -2806,6 +2869,7 @@ ivas_error IVAS_DEC_Flush( { *nSamplesFlushed = 0; } + return error; } @@ -2820,6 +2884,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 ) ); } @@ -2923,10 +2994,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; } @@ -3151,14 +3225,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 df01016278f65e14b692e7d5ef3ee211a966d0b6..09c5eefc05cbfa2bb1787994f21b93bfe1e15ebd 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