diff --git a/projects/rocdecode/src/commons.h b/projects/rocdecode/src/commons.h index 81851e2daa..be8a76a9c2 100644 --- a/projects/rocdecode/src/commons.h +++ b/projects/rocdecode/src/commons.h @@ -41,10 +41,8 @@ class rocDecodeException : public std::exception { public: - explicit rocDecodeException(const std::string& message):_message(message) - {} - virtual const char* what() const throw() override - { + explicit rocDecodeException(const std::string& message):_message(message){} + virtual const char* what() const throw() override { return _message.c_str(); } private: diff --git a/projects/rocdecode/src/dec_handle.h b/projects/rocdecode/src/dec_handle.h index 8b44526a85..fc6ca7615e 100644 --- a/projects/rocdecode/src/dec_handle.h +++ b/projects/rocdecode/src/dec_handle.h @@ -20,15 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once + #include #include -#include "rocdecoder.h" -struct decHandle { +#include "roc_decoder.h" - explicit decHandle(); //constructor - ~decHandle() { clear_errors(); } - std::shared_ptr roc_decoder; // class intantiation +struct DecHandle { + + explicit DecHandle(); //constructor + ~DecHandle() { clear_errors(); } + std::shared_ptr roc_decoder; // class instantiation bool no_error() { return error.empty(); } const char* error_msg() { return error.c_str(); } void capture_error(const std::string& err_msg) { error = err_msg; } diff --git a/projects/rocdecode/src/rocdecoder.cpp b/projects/rocdecode/src/roc_decoder.cpp similarity index 88% rename from projects/rocdecode/src/rocdecoder.cpp rename to projects/rocdecode/src/roc_decoder.cpp index c60e767aaa..9b71b937e3 100644 --- a/projects/rocdecode/src/rocdecoder.cpp +++ b/projects/rocdecode/src/roc_decoder.cpp @@ -20,11 +20,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include "rocdecoder.h" #include "commons.h" +#include "roc_decoder.h" -rocDecoder::rocDecoder(int device_id, int num_devices):device_id_ {device_id}, num_devices_{num_devices} { +RocDecoder::RocDecoder(int device_id, int num_devices):device_id_ {device_id}, num_devices_{num_devices} { // todo:: if (ROCDEC_SUCCESS != initHIP(device_id_)) { THROW("Failed to initilize the HIP"); @@ -33,7 +32,7 @@ rocDecoder::rocDecoder(int device_id, int num_devices):device_id_ {device_id}, n } -rocDecStatus rocDecoder::getDecoderCaps(ROCDECDECODECAPS *pdc) { +rocDecStatus RocDecoder::getDecoderCaps(ROCDECDECODECAPS *pdc) { // todo:: return appropriate decStatus if fails //vaQueryConfigProfiles // fill the ROCDECDECODECAPS struct @@ -41,21 +40,21 @@ rocDecStatus rocDecoder::getDecoderCaps(ROCDECDECODECAPS *pdc) { return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::decodeFrame(ROCDECPICPARAMS *pPicParams) { +rocDecStatus RocDecoder::decodeFrame(ROCDECPICPARAMS *pPicParams) { // todo:: return appropriate decStatus if fails // call funsction to do va-api decoding using the picture parameters structure // return status return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::getDecodeStatus(int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) { +rocDecStatus RocDecoder::getDecodeStatus(int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) { // todo:: return appropriate decStatus // init vaapi decoder to get the decoding status of the picture specified by nPicIndex // return status return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) { +rocDecStatus RocDecoder::reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) { // todo:: return appropriate decStatus // this will be called when the current configuration is changed during decoding // release the current va-api decoder instance and create a new one with the new parameters (or reinit if available) @@ -63,7 +62,7 @@ rocDecStatus rocDecoder::reconfigureDecoder(ROCDECRECONFIGUREDECODERINFO *pDecRe return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], +rocDecStatus RocDecoder::mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams) { // todo:: return appropriate decStatus // Post-process and map video frame corresponding to nPicIdx for use in HIP. Returns HIP device pointer and associated @@ -71,14 +70,14 @@ rocDecStatus rocDecoder::mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::unMapVideoFrame(void *pMappedDevPtr) { +rocDecStatus RocDecoder::unMapVideoFrame(void *pMappedDevPtr) { // todo:: return appropriate decStatus // Unmap a previously mapped video frame with the associated mapped raw pointer (pMappedDevPtr) return ROCDEC_NOT_IMPLEMENTED; } -rocDecStatus rocDecoder::initHIP(int device_id) { +rocDecStatus RocDecoder::initHIP(int device_id) { hipError_t hipStatus = hipSuccess; hipStatus = hipGetDeviceCount(&num_devices_); rocDecStatus decStatus = ROCDEC_SUCCESS; @@ -114,7 +113,7 @@ rocDecStatus rocDecoder::initHIP(int device_id) { return decStatus; } -void rocDecoder::initDRMnodes() { +void RocDecoder::initDRMnodes() { // build the DRM render node names for (int i = 0; i < num_devices_; i++) { drm_nodes_.push_back("/dev/dri/renderD" + std::to_string(128 + i)); diff --git a/projects/rocdecode/src/rocdecoder.h b/projects/rocdecode/src/roc_decoder.h similarity index 95% rename from projects/rocdecode/src/rocdecoder.h rename to projects/rocdecode/src/roc_decoder.h index 4b14110738..76b8db4e61 100644 --- a/projects/rocdecode/src/rocdecoder.h +++ b/projects/rocdecode/src/roc_decoder.h @@ -34,10 +34,10 @@ THE SOFTWARE. #include -class rocDecoder { +class RocDecoder { public: - rocDecoder(int device_id, int num_devices); - ~rocDecoder(); + RocDecoder(int device_id, int num_devices); + ~RocDecoder(); rocDecStatus getDecoderCaps(ROCDECDECODECAPS *pdc); rocDecStatus decodeFrame(ROCDECPICPARAMS *pPicParams); rocDecStatus getDecodeStatus(int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus); diff --git a/projects/rocdecode/src/rocdecode_api.cpp b/projects/rocdecode/src/rocdecode_api.cpp index bbbbcd4a02..0197102ffd 100644 --- a/projects/rocdecode/src/rocdecode_api.cpp +++ b/projects/rocdecode/src/rocdecode_api.cpp @@ -31,10 +31,9 @@ rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci) { rocDecDecoderHandle handle = nullptr; try { - handle = new decHandle(); + handle = new DecHandle(); } - catch(const std::exception& e) - { + catch(const std::exception& e) { ERR( STR("Failed to init the rocDecode handle, ") + STR(e.what())) } *phDecoder = handle; @@ -47,7 +46,7 @@ rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci /*****************************************************************************************************/ rocDecStatus ROCDECAPI rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); delete handle; return ROCDEC_SUCCESS; } @@ -61,7 +60,7 @@ rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) { /**********************************************************************************************************************/ rocDecStatus ROCDECAPI rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->getDecoderCaps(pdc); @@ -81,7 +80,7 @@ rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) { /*****************************************************************************************************/ rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->decodeFrame(pPicParams); @@ -102,7 +101,7 @@ rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) { /************************************************************************************************************/ rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->getDecodeStatus(nPicIdx, pDecodeStatus); @@ -122,7 +121,7 @@ rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODE /*********************************************************************************************************/ rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->reconfigureDecoder(pDecReconfigParams); @@ -145,7 +144,7 @@ rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERI rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->mapVideoFrame(nPicIdx, pDevMemPtr, pHorizontalPitch, pVidPostprocParams); @@ -164,7 +163,7 @@ rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx, /*****************************************************************************************************/ rocDecStatus ROCDECAPI rocDecUnMapVideoFrame(rocDecDecoderHandle hDecoder, void *pMappedDevPtr) { - auto handle = static_cast (hDecoder); + auto handle = static_cast (hDecoder); rocDecStatus ret; try { ret = handle->roc_decoder->unMapVideoFrame(pMappedDevPtr); diff --git a/projects/rocdecode/src/vaapi/vaapi_videodecoder.h b/projects/rocdecode/src/vaapi/vaapi_videodecoder.h index 70c82c8c19..772ad0e16e 100644 --- a/projects/rocdecode/src/vaapi/vaapi_videodecoder.h +++ b/projects/rocdecode/src/vaapi/vaapi_videodecoder.h @@ -22,16 +22,6 @@ THE SOFTWARE. #pragma once -#include -#include -#include -#include -#include -#include -#include - -#include "commons.h" -#include "vaapi_videodecoder.h" // class implementing highlevel vaapi decoder /***********************************************************************************************************/