diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 735086a7c14c79dc80e6b4d748155890738548db..b384e8dee563a9c33a470e806c116fecd0eb4fbd 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -86,6 +86,9 @@ typedef enum IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT, IVAS_ERR_ISM_INVALID_METADATA_VALUE, IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE, +#ifdef FIX_372_LIB_REND_VALIDATE_IO + IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED, +#endif #ifdef DEBUGGING IVAS_ERR_INVALID_FORCE_MODE, #ifdef DEBUG_AGC_ENCODER_CMD_OPTION @@ -145,18 +148,7 @@ typedef enum static inline const char *ivas_error_to_string( ivas_error error_code ) { - /* For error categories that are likely to still have many changes to - * specific error codes, return one string per category */ - if ( ( error_code & 0xF000 ) == 0x1000 ) - { - return "API error"; - } - if ( ( error_code & 0xF000 ) == 0x2000 ) - { - return "data error"; - } - - /* For categories that are unlikely to change, use more specific strings */ + /* Try to match to a specific string */ switch ( error_code ) { case IVAS_ERR_OK: @@ -179,6 +171,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Wrong number of channels"; case IVAS_ERR_INVALID_BUFFER_SIZE: return "Invalid buffer size"; +#ifdef FIX_372_LIB_REND_VALIDATE_IO + case IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED: + return "Unsupported input/output config pair"; +#endif case IVAS_ERR_FAILED_FILE_OPEN: return "File open error"; case IVAS_ERR_FAILED_FILE_WRITE: @@ -193,6 +189,17 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) break; } + /* For error categories that are likely to still have many changes to + * specific error codes, return one string per category */ + if ( ( error_code & 0xF000 ) == 0x1000 ) + { + return "API error"; + } + if ( ( error_code & 0xF000 ) == 0x2000 ) + { + return "data error"; + } + return "Unknown error"; } diff --git a/lib_com/options.h b/lib_com/options.h index 5fd4b3d2a6723053649c06f5ce171ecd02e29503..940d3857fad75229f517ff78fc4d663237851ce3 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,7 @@ #define ISM_HIGHEST_BITRATE /* VA: Issue 284: Update highest bitrate limit in ISM format */ #define TUNE_360_OBJECT_WITH_NOISE /* VA: issue 360: consider objects being speech+noise for active speech coding */ #define FIX_350_MASA_DELAY_COMP /* Nokia: Issue 350: MASA audio/meta delay compensation */ +#define FIX_372_LIB_REND_VALIDATE_IO /* FhG: Issue 372: IVAS_rend segfaults with unsupported I/O configs - add validation checks of I/O config */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d0e33a2d83849a6c66c6f2e41f75bece79ff3b04..8a4807c8fc6decad9b635a896b09850ac67b8b69 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -1050,6 +1050,21 @@ static CREND_WRAPPER defaultCrendWrapper( return w; } +#ifdef FIX_372_LIB_REND_VALIDATE_IO +static bool isIoConfigPairSupported( IVAS_REND_AudioConfig inConfig, IVAS_REND_AudioConfig outConfig ) +{ + /* Rendering mono or stereo to binaural is not supported */ + if ( ( inConfig == IVAS_REND_AUDIO_CONFIG_MONO || inConfig == IVAS_REND_AUDIO_CONFIG_STEREO ) && + getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) + { + return false; + } + + /* If not returned so far, config pair is supported */ + return true; +} +#endif + static ivas_error setRendInputActiveIsm( void *input, const IVAS_REND_AudioConfig inConfig, @@ -1065,6 +1080,13 @@ static ivas_error setRendInputActiveIsm( rendCtx = inputIsm->base.ctx; outConfig = *rendCtx.pOutConfig; +#ifdef FIX_372_LIB_REND_VALIDATE_IO + if ( !isIoConfigPairSupported( inConfig, outConfig ) ) + { + return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; + } +#endif + initRendInputBase( &inputIsm->base, inConfig, id, rendCtx ); inputIsm->currentPos = defaultObjectPosition(); @@ -1956,6 +1978,13 @@ static ivas_error setRendInputActiveMc( rendCtx = inputMc->base.ctx; outConfig = *rendCtx.pOutConfig; +#ifdef FIX_372_LIB_REND_VALIDATE_IO + if ( !isIoConfigPairSupported( inConfig, outConfig ) ) + { + return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; + } +#endif + initRendInputBase( &inputMc->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputMc->panGains ); inputMc->customLsInput = defaultCustomLs(); @@ -2216,6 +2245,13 @@ static ivas_error setRendInputActiveSba( rendCtx = inputSba->base.ctx; outConfig = *rendCtx.pOutConfig; +#ifdef FIX_372_LIB_REND_VALIDATE_IO + if ( !isIoConfigPairSupported( inConfig, outConfig ) ) + { + return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; + } +#endif + initRendInputBase( &inputSba->base, inConfig, id, rendCtx ); setZeroPanMatrix( inputSba->hoaDecMtx ); #ifdef FIX_197_CREND_INTERFACE @@ -2618,6 +2654,13 @@ static ivas_error setRendInputActiveMasa( outConfig = *rendCtx.pOutConfig; (void) hRendCfg; /* Suppress warning */ +#ifdef FIX_372_LIB_REND_VALIDATE_IO + if ( !isIoConfigPairSupported( inConfig, outConfig ) ) + { + return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED; + } +#endif + initRendInputBase( &inputMasa->base, inConfig, id, rendCtx ); if ( ( error = getAudioConfigNumChannels( inConfig, &numInChannels ) ) != IVAS_ERR_OK )