From e723871cbaacd84baec8d61a26a8c8fdb83f3c0d Mon Sep 17 00:00:00 2001 From: Aryan Salmanpour Date: Wed, 17 Jan 2024 14:00:54 -0500 Subject: [PATCH] Add support for rocDecGetErrorName for getting the rocDecStatus error string (#185) * Add support for rocDecGetErrorName for getting the rocDecStatus error string * Add description of the API [ROCm/rocdecode commit: f7997b716d8bbb2c91e76da1cad0531808e6d92f] --- projects/rocdecode/api/rocdecode.h | 7 +++++ .../rocdecode/src/rocdecode/rocdecode_api.cpp | 28 +++++++++++++++++++ .../utils/rocvideodecode/roc_video_dec.h | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/projects/rocdecode/api/rocdecode.h b/projects/rocdecode/api/rocdecode.h index afc7964531..70ead343aa 100644 --- a/projects/rocdecode/api/rocdecode.h +++ b/projects/rocdecode/api/rocdecode.h @@ -908,6 +908,13 @@ extern rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle decoder_ha /*****************************************************************************************************/ extern rocDecStatus ROCDECAPI rocDecUnMapVideoFrame(rocDecDecoderHandle decoder_handle, int pic_idx); +/*****************************************************************************************************/ +//! \fn const char* ROCDECAPI rocDecGetErrorName(rocDecStatus rocdec_status) +//! \ingroup group_amd_rocdecode +//! Return name of the specified error code in text form. +/*****************************************************************************************************/ +extern const char* ROCDECAPI rocDecGetErrorName(rocDecStatus rocdec_status); + #ifdef __cplusplus } #endif diff --git a/projects/rocdecode/src/rocdecode/rocdecode_api.cpp b/projects/rocdecode/src/rocdecode/rocdecode_api.cpp index 840d700903..c32dceed69 100644 --- a/projects/rocdecode/src/rocdecode/rocdecode_api.cpp +++ b/projects/rocdecode/src/rocdecode/rocdecode_api.cpp @@ -214,3 +214,31 @@ rocDecUnMapVideoFrame(rocDecDecoderHandle decoder_handle, int pic_idx) { } return ret; } + +/*****************************************************************************************************/ +//! \fn const char* ROCDECAPI rocDecGetErrorName(rocDecStatus rocdec_status) +//! \ingroup group_amd_rocdecode +//! Return name of the specified error code in text form. +/*****************************************************************************************************/ +const char* ROCDECAPI rocDecGetErrorName(rocDecStatus rocdec_status) { + switch (rocdec_status) { + case ROCDEC_DEVICE_INVALID: + return "ROCDEC_DEVICE_INVALID"; + case ROCDEC_CONTEXT_INVALID: + return "ROCDEC_CONTEXT_INVALID"; + case ROCDEC_RUNTIME_ERROR: + return "ROCDEC_RUNTIME_ERROR"; + case ROCDEC_OUTOF_MEMORY: + return "ROCDEC_OUTOF_MEMORY"; + case ROCDEC_INVALID_PARAMETER: + return "ROCDEC_INVALID_PARAMETER"; + case ROCDEC_NOT_IMPLEMENTED: + return "ROCDEC_NOT_IMPLEMENTED"; + case ROCDEC_NOT_INITIALIZED: + return "ROCDEC_NOT_INITIALIZED"; + case ROCDEC_NOT_SUPPORTED: + return "ROCDEC_NOT_SUPPORTED"; + default: + return "UNKNOWN_ERROR"; + } +} \ No newline at end of file diff --git a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h index 81288ed7b4..8de5de15a6 100644 --- a/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h +++ b/projects/rocdecode/utils/rocvideodecode/roc_video_dec.h @@ -96,7 +96,7 @@ private: rocDecStatus error_code = rocDecAPI; \ if( error_code != ROCDEC_SUCCESS) { \ std::ostringstream error_log; \ - error_log << #rocDecAPI << " returned err " << error_code << " at " <<__FILE__ <<":" << __LINE__;\ + error_log << #rocDecAPI << " returned err " << rocDecGetErrorName(error_code) << " at " <<__FILE__ <<":" << __LINE__;\ ROCDEC_THROW(error_log.str(), error_code); \ } \ } while (0)