added api initial implementation

This commit is contained in:
rrawther
2023-08-14 14:14:09 -07:00
szülő 3c998f6ddb
commit 35f7154e0c
9 fájl változott, egészen pontosan 539 új sor hozzáadva és 15 régi sor törölve
+157
Fájl megtekintése
@@ -19,3 +19,160 @@ 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 "dec_handle.h"
#include "rocdecode.h"
#include "commons.h"
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci)
//! Create the decoder object based on pdci. A handle to the created decoder is returned
/*****************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecCreateDecoder(rocDecDecoderHandle *phDecoder, ROCDECDECODECREATEINFO *pdci) {
rocDecDecoderHandle handle = nullptr;
try {
handle = new decHandle();
}
catch(const std::exception& e)
{
ERR( STR("Failed to init the rocDecode handle, ") + STR(e.what()))
}
*phDecoder = handle;
return ROCDEC_SUCCESS;
}
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecDestroyDecoder(rocDecDecoderHandle hDecoder)
//! Destroy the decoder object
/*****************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecDestroyDecoder(rocDecDecoderHandle hDecoder) {
auto handle = static_cast<decHandle *> (hDecoder);
delete handle;
return ROCDEC_SUCCESS;
}
/**********************************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocdecGetDecoderCaps(rocDecDecoderHandle hDecoder, ROCDECDECODECAPS *pdc)
//! Queries decode capabilities of AMD's VCN decoder based on CodecType, ChromaFormat and BitDepthMinus8 parameters.
//! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of ROCDECDECODECAPS structure
//! 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;
}
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams)
//! Decodes a single picture
//! Submits the frame for HW decoding
/*****************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecDecodeFrame(rocDecDecoderHandle hDecoder, ROCDECPICPARAMS *pPicParams) {
auto handle = static_cast<decHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->decodeFrame(pPicParams);
}
catch(const std::exception& e) {
handle->capture_error(e.what());
ERR(e.what())
return ROCDEC_RUNTIME_ERROR;
}
return ret;
}
/************************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus);
//! Get the decode status for frame corresponding to nPicIdx
//! API is currently supported for HEVC, H264 and JPEG codecs.
//! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec.
/************************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecGetDecodeStatus(rocDecDecoderHandle hDecoder, int nPicIdx, ROCDECGETDECODESTATUS* pDecodeStatus) {
auto handle = static_cast<decHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->getDecodeStatus(nPicIdx, pDecodeStatus);
}
catch(const std::exception& e) {
handle->capture_error(e.what());
ERR(e.what())
return ROCDEC_RUNTIME_ERROR;
}
return ret;
}
/*********************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams)
//! Used to reuse single decoder for multiple clips. Currently supports resolution change, resize params
//! params, target area params change for same codec. Must be called during ROCDECPARSERPARAMS::pfnSequenceCallback
/*********************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecReconfigureDecoder(rocDecDecoderHandle hDecoder, ROCDECRECONFIGUREDECODERINFO *pDecReconfigParams) {
auto handle = static_cast<decHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->reconfigureDecoder(pDecReconfigParams);
}
catch(const std::exception& e) {
handle->capture_error(e.what());
ERR(e.what())
return ROCDEC_RUNTIME_ERROR;
}
return ret;
}
/************************************************************************************************************************/
//! \fn extern rocDecStatus ROCDECAPI rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx,
//! unsigned int *pDevMemPtr, unsigned int *pHorizontalPitch,
//! ROCDECPROCPARAMS *pVidPostprocParams);
//! 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
/************************************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecMapVideoFrame(rocDecDecoderHandle hDecoder, int nPicIdx,
void *pDevMemPtr[3], unsigned int *pHorizontalPitch[3], ROCDECPROCPARAMS *pVidPostprocParams) {
auto handle = static_cast<decHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->mapVideoFrame(nPicIdx, pDevMemPtr, pHorizontalPitch, pVidPostprocParams);
}
catch(const std::exception& e) {
handle->capture_error(e.what());
ERR(e.what())
return ROCDEC_RUNTIME_ERROR;
}
return ret;
}
/*****************************************************************************************************/
//! \fn rocDecStatus ROCDECAPI rocDecUnMapVideoFrame(rocDecDecoderHandle hDecoder, void *pMappedDevPtr)
//! Unmap a previously mapped video frame with the associated mapped raw pointer (pMappedDevPtr)
/*****************************************************************************************************/
rocDecStatus ROCDECAPI
rocDecUnMapVideoFrame(rocDecDecoderHandle hDecoder, void *pMappedDevPtr) {
auto handle = static_cast<decHandle *> (hDecoder);
rocDecStatus ret;
try {
ret = handle->roc_decoder->unMapVideoFrame(pMappedDevPtr);
}
catch(const std::exception& e) {
handle->capture_error(e.what());
ERR(e.what())
return ROCDEC_RUNTIME_ERROR;
}
return ret;
}