added api initial implementation

Αυτή η υποβολή περιλαμβάνεται σε:
rrawther
2023-08-14 14:14:09 -07:00
γονέας 3c998f6ddb
υποβολή 35f7154e0c
9 αρχεία άλλαξαν με 539 προσθήκες και 15 διαγραφές
+102
Προβολή Αρχείου
@@ -19,3 +19,105 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "rocdecoder.h"
#include "commons.h"
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");
}
initDRMnodes();
}
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
// 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) {
// 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) {
// 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)
// return status
return ROCDEC_NOT_IMPLEMENTED;
}
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
// pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately
return ROCDEC_NOT_IMPLEMENTED;
}
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) {
hipError_t hipStatus = hipSuccess;
hipStatus = hipGetDeviceCount(&num_devices_);
rocDecStatus decStatus = ROCDEC_SUCCESS;
if (hipStatus != hipSuccess) {
ERR("ERROR: hipGetDeviceCount failed!" + TOSTR(hipStatus));
decStatus = ROCDEC_DEVICE_INVALID;
}
if (num_devices_ < 1) {
ERR("ERROR: didn't find any GPU!");
decStatus = ROCDEC_DEVICE_INVALID;
}
if (device_id >= num_devices_) {
ERR("ERROR: the requested device_id is not found! ");
decStatus = ROCDEC_DEVICE_INVALID;
}
hipStatus = hipSetDevice(device_id);
if (hipStatus != hipSuccess) {
ERR("ERROR: hipSetDevice( " + TOSTR(device_id) + ") failed! (" + TOSTR(hipStatus) + ")" );
decStatus = ROCDEC_DEVICE_INVALID;
}
hipStatus = hipGetDeviceProperties(&hip_dev_prop_, device_id);
if (hipStatus != hipSuccess) {
ERR("ERROR: hipGetDeviceProperties for device (" +TOSTR(device_id) + " ) failed! (" + TOSTR(hipStatus) + ")" );
decStatus = ROCDEC_DEVICE_INVALID;
}
hipStatus = hipStreamCreate(&hip_stream_);
if (hipStatus != hipSuccess) {
ERR("ERROR: hipStream_Create failed! (" + TOSTR(hipStatus) + ")");
decStatus = ROCDEC_DEVICE_INVALID;
}
return decStatus;
}
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));
}
}