Rr/roc video decode class (#20)
* WIP: class implementation
* add more definitions
* rocvideodecode implementation
* formatting fixes
* address review comments
[ROCm/rocdecode commit: d0e6743872]
This commit is contained in:
@@ -49,4 +49,14 @@ rocDecStatus H264VideoParser::Initialize(RocdecParserParams *pParams) {
|
||||
*/
|
||||
rocDecStatus H264VideoParser::ParseVideoData(RocdecSourceDataPacket *pData) {
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief function to uninitialize h264 parser
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
rocDecStatus H264VideoParser::UnInitialize() {
|
||||
//todo::
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,13 @@ public:
|
||||
* @return rocDecStatus: returns success on completion, else error_code for failure
|
||||
*/
|
||||
virtual rocDecStatus ParseVideoData(RocdecSourceDataPacket *pData);
|
||||
/**
|
||||
* @brief function to uninitialize h264 parser
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
virtual rocDecStatus UnInitialize(); // derived method
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -43,6 +43,17 @@ rocDecStatus HEVCVideoParser::Initialize(RocdecParserParams *p_params) {
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief function to uninitialize hevc parser
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
rocDecStatus HEVCVideoParser::UnInitialize() {
|
||||
//todo:: do any uninitialization here
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
rocDecStatus HEVCVideoParser::ParseVideoData(RocdecSourceDataPacket *p_data) {
|
||||
bool status = ParseFrameData(p_data->payload, p_data->payload_size);
|
||||
if (!status) {
|
||||
|
||||
@@ -59,12 +59,20 @@ public:
|
||||
*/
|
||||
virtual rocDecStatus ParseVideoData(RocdecSourceDataPacket *p_data);
|
||||
|
||||
/*! \brief HEVCParser object destructor
|
||||
/**
|
||||
* @brief function to uninitialize hevc parser
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
virtual rocDecStatus UnInitialize(); // derived method
|
||||
|
||||
/**
|
||||
* @brief HEVCParser object destructor
|
||||
*/
|
||||
virtual ~HEVCVideoParser();
|
||||
|
||||
protected:
|
||||
/*! \brief Enumerator for the NAL Unit types - ISO-IEC 14496-15-2004.pdf, page 14, table 1 " NAL unit types in elementary streams.
|
||||
/*! \brief Enumerator for the NAL Unit types - ISO-IEC 14496-15-2004.pdf, page 14, table 1 " NAL unit types in elementary streams
|
||||
*/
|
||||
enum NalUnitType {
|
||||
NAL_UNIT_CODED_SLICE_TRAIL_N = 0, // 0
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
const char* error_msg() { return error.c_str(); }
|
||||
void capture_error(const std::string& err_msg) { error = err_msg; }
|
||||
rocDecStatus ParseVideoData(RocdecSourceDataPacket *pPacket) { return roc_parser_->ParseVideoData(pPacket); }
|
||||
rocDecStatus DestroyParser() { return destroy_parser(); };
|
||||
|
||||
private:
|
||||
std::shared_ptr<RocVideoParser> roc_parser_ = nullptr; // class instantiation
|
||||
@@ -59,5 +60,15 @@ private:
|
||||
THROW("rocParser Initialization failed with error: "+ TOSTR(ret));
|
||||
}
|
||||
}
|
||||
rocDecStatus destroy_parser() {
|
||||
rocDecStatus ret = ROCDEC_NOT_INITIALIZED;
|
||||
if (roc_parser_ ) {
|
||||
ret = roc_parser_->UnInitialize();
|
||||
if (ret != ROCDEC_SUCCESS)
|
||||
THROW("rocParser UnInitialization failed with error: "+ TOSTR(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string error;
|
||||
};
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
RocdecParserParams *GetParserParams() {return parser_params_;};
|
||||
virtual rocDecStatus Initialize(RocdecParserParams *pParams);
|
||||
virtual rocDecStatus ParseVideoData(RocdecSourceDataPacket *pData) = 0; // pure virtual: implemented by derived class
|
||||
virtual rocDecStatus UnInitialize() = 0; // pure virtual: implemented by derived class
|
||||
|
||||
protected:
|
||||
RocdecParserParams *parser_params_ = nullptr;
|
||||
|
||||
@@ -65,3 +65,23 @@ rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \ingroup FUNCTS
|
||||
//! \fn rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser handle)
|
||||
//! Destroy the video parser object
|
||||
/************************************************************************************************/
|
||||
extern rocDecStatus ROCDECAPI
|
||||
rocDecDestroyVideoParser(RocdecVideoParser handle) {
|
||||
auto parser_hdl = static_cast<RocParserHandle *> (handle);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
ret = parser_hdl->DestroyParser();
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
parser_hdl->capture_error(e.what());
|
||||
ERR(e.what())
|
||||
return ROCDEC_RUNTIME_ERROR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -42,13 +42,6 @@ RocDecoder::RocDecoder(int device_id):device_id_ {device_id}, num_devices_{0} {
|
||||
}
|
||||
}
|
||||
}
|
||||
rocDecStatus RocDecoder::getDecoderCaps(RocdecDecodeCaps *pdc) {
|
||||
// todo:: return appropriate decStatus if fails
|
||||
//vaQueryConfigProfiles
|
||||
// fill the RocdecDecodeCaps struct
|
||||
// return status
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
rocDecStatus RocDecoder::decodeFrame(RocdecPicParams *pPicParams) {
|
||||
// todo:: return appropriate decStatus if fails
|
||||
@@ -73,7 +66,7 @@ rocDecStatus RocDecoder::reconfigureDecoder(RocdecReconfigureDecoderInfo *pDecRe
|
||||
}
|
||||
|
||||
rocDecStatus RocDecoder::mapVideoFrame(int nPicIdx, void *pDevMemPtr[3],
|
||||
unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams) {
|
||||
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
|
||||
// pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately
|
||||
|
||||
@@ -38,11 +38,10 @@ class RocDecoder {
|
||||
public:
|
||||
RocDecoder(int device_id = 0);
|
||||
~RocDecoder();
|
||||
rocDecStatus getDecoderCaps(RocdecDecodeCaps *pdc);
|
||||
rocDecStatus decodeFrame(RocdecPicParams *pPicParams);
|
||||
rocDecStatus getDecodeStatus(int nPicIdx, RocdecDecodeStatus* pDecodeStatus);
|
||||
rocDecStatus reconfigureDecoder(RocdecReconfigureDecoderInfo *pDecReconfigParams);
|
||||
rocDecStatus mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams);
|
||||
rocDecStatus mapVideoFrame(int nPicIdx, void *pDevMemPtr[3], unsigned int pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams);
|
||||
rocDecStatus unMapVideoFrame(void *pMappedDevPtr);
|
||||
|
||||
private:
|
||||
|
||||
@@ -58,19 +58,9 @@ rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) {
|
||||
//! 2. On calling rocdecGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported
|
||||
//! If IN parameters passed to the driver are not supported by AMD-VCN-HW, then all OUT params are set to 0.
|
||||
/**********************************************************************************************************************/
|
||||
rocDecStatus ROCDECAPI
|
||||
rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, RocdecDecodeCaps *pdc) {
|
||||
auto handle = static_cast<DecHandle *> (hDecoder);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
ret = handle->roc_decoder->getDecoderCaps(pdc);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
handle->capture_error(e.what());
|
||||
ERR(e.what())
|
||||
return ROCDEC_RUNTIME_ERROR;
|
||||
}
|
||||
return ret;
|
||||
rocDecStatus ROCDECAPI
|
||||
rocDecGetDecoderCaps(RocdecDecodeCaps *pdc) {
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/*****************************************************************************************************/
|
||||
@@ -100,7 +90,7 @@ rocDecDecodeFrame(rocDecDecoderHandle hDecoder, RocdecPicParams *pPicParams) {
|
||||
//! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec.
|
||||
/************************************************************************************************************/
|
||||
rocDecStatus ROCDECAPI
|
||||
RocdecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus) {
|
||||
rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, RocdecDecodeStatus* pDecodeStatus) {
|
||||
auto handle = static_cast<DecHandle *> (hDecoder);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
@@ -143,7 +133,7 @@ rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, RocdecReconfigureDecoderI
|
||||
/************************************************************************************************************************/
|
||||
rocDecStatus ROCDECAPI
|
||||
rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx,
|
||||
void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], RocdecProcParams *pVidPostprocParams) {
|
||||
void *pDevMemPtr[3], uint32_t (&pHorizontalPitch)[3], RocdecProcParams *pVidPostprocParams) {
|
||||
auto handle = static_cast<DecHandle *> (hDecoder);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user