address review comments and some other code formatting

[ROCm/rocdecode commit: 8f692d8118]
This commit is contained in:
rrawther
2023-08-21 11:38:17 -07:00
parent c522837dcc
commit 203a84ced0
6 changed files with 31 additions and 43 deletions
+2 -4
View File
@@ -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:
+7 -5
View File
@@ -20,15 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#include <memory>
#include <string>
#include "rocdecoder.h"
struct decHandle {
#include "roc_decoder.h"
explicit decHandle(); //constructor
~decHandle() { clear_errors(); }
std::shared_ptr<rocDecoder> roc_decoder; // class intantiation
struct DecHandle {
explicit DecHandle(); //constructor
~DecHandle() { clear_errors(); }
std::shared_ptr<RocDecoder> 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; }
@@ -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));
@@ -34,10 +34,10 @@ THE SOFTWARE.
#include <hip/hip_runtime.h>
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);
+9 -10
View File
@@ -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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (hDecoder);
delete handle;
return ROCDEC_SUCCESS;
}
@@ -61,7 +60,7 @@ rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) {
/**********************************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc) {
auto handle = static_cast<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (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<decHandle *> (hDecoder);
auto handle = static_cast<DecHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->unMapVideoFrame(pMappedDevPtr);
@@ -22,16 +22,6 @@ THE SOFTWARE.
#pragma once
#include <assert.h>
#include <stdint.h>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <string.h>
#include "commons.h"
#include "vaapi_videodecoder.h"
// class implementing highlevel vaapi decoder
/***********************************************************************************************************/