Add new API rocDecParserMarkFrameForReuse() for Parser (#430)
* added new API to release video frame for decoder and parser * removed ReleseFrame() from low level parser classes * Removed rocDecReleaseFrame() from decoder and added in parser * address review comments * revert un-necessary files * minor fix * remove unused function * minor formatting fix
This commit is contained in:
zatwierdzone przez
GitHub
rodzic
64078a58cb
commit
29bfe5e3bd
@@ -48,6 +48,7 @@ Documentation for rocDecode is available at
|
||||
### Additions
|
||||
|
||||
* Clang - Default CXX compiler
|
||||
* Parser - Add new API rocDecParserMarkFrameForReuse()
|
||||
|
||||
### Optimizations
|
||||
|
||||
|
||||
@@ -275,6 +275,13 @@ extern rocDecStatus ROCDECAPI rocDecCreateVideoParser(RocdecVideoParser *parser_
|
||||
/************************************************************************************************/
|
||||
extern rocDecStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser parser_handle, RocdecSourceDataPacket *packet);
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \ingroup group_rocparser
|
||||
//! \fn rocDecStatus ROCDECAPI rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int pic_idx)
|
||||
//! Mark frame with index pic_idx in parser's buffer pool for reuse (means the frame has been consumed)
|
||||
/************************************************************************************************/
|
||||
extern rocDecStatus ROCDECAPI rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int pic_idx);
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \ingroup group_rocparser
|
||||
//! \fn rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser parser_handle)
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
const char* ErrorMsg() { return error_.c_str(); }
|
||||
void CaptureError(const std::string& err_msg) { error_ = err_msg; }
|
||||
rocDecStatus ParseVideoData(RocdecSourceDataPacket *packet) { return roc_parser_->ParseVideoData(packet); }
|
||||
rocDecStatus MarkFrameForReuse(int pic_idx) { return roc_parser_->MarkFrameForReuse(pic_idx); }
|
||||
rocDecStatus DestroyParser() { return DestroyParserInternal(); };
|
||||
|
||||
private:
|
||||
|
||||
@@ -73,6 +73,14 @@ rocDecStatus RocVideoParser::Initialize(RocdecParserParams *pParams) {
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
rocDecStatus RocVideoParser::MarkFrameForReuse(int pic_idx) {
|
||||
if (pic_idx < 0) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
//todo::
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void RocVideoParser::InitDecBufPool() {
|
||||
for (int i = 0; i < dec_buf_pool_size_; i++) {
|
||||
decode_buffer_pool_[i].use_status = kNotUsed;
|
||||
@@ -106,7 +114,6 @@ ParserResult RocVideoParser::OutputDecodedPictures(bool no_delay) {
|
||||
pfn_display_picture_cb_(parser_params_.user_data, &disp_info);
|
||||
decode_buffer_pool_[output_pic_list_[i]].use_status &= ~kFrameUsedForDisplay;
|
||||
}
|
||||
|
||||
num_output_pics_ = disp_delay;
|
||||
// Shift the remaining frames to the top
|
||||
if (num_output_pics_) {
|
||||
|
||||
@@ -102,6 +102,14 @@ public:
|
||||
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
|
||||
/**
|
||||
* @brief function to to release surface with pic_idx and mark it for reuse, can be called from a different thread than decode thread
|
||||
* @brief calling thread is responsible for syncronizing
|
||||
* \param [in] pic_idx surface index for the picture to be released
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
virtual rocDecStatus MarkFrameForReuse(int pic_idx);
|
||||
|
||||
protected:
|
||||
RocdecParserParams parser_params_ = {};
|
||||
|
||||
@@ -81,6 +81,30 @@ rocDecParseVideoData(RocdecVideoParser parser_handle, RocdecSourceDataPacket *pa
|
||||
return ret;
|
||||
}
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \ingroup group_rocparser
|
||||
//! \fn rocDecStatus ROCDECAPI rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int pic_idx)
|
||||
//! Release frame with index pic_idx from parser's buffer pool and mark it for reuse
|
||||
/************************************************************************************************/
|
||||
rocDecStatus ROCDECAPI
|
||||
rocDecParserMarkFrameForReuse(RocdecVideoParser parser_handle, int pic_idx) {
|
||||
if (parser_handle == nullptr || pic_idx < 0) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
auto roc_parser_handle = static_cast<RocParserHandle *>(parser_handle);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
ret = roc_parser_handle->MarkFrameForReuse(pic_idx);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
roc_parser_handle->CaptureError(e.what());
|
||||
ERR(e.what())
|
||||
return ROCDEC_RUNTIME_ERROR;
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************************************/
|
||||
//! \ingroup FUNCTS
|
||||
//! \fn rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser parser_handle)
|
||||
|
||||
@@ -93,7 +93,7 @@ rocDecStatus RocDecoder::ReconfigureDecoder(RocdecReconfigureDecoderInfo *reconf
|
||||
}
|
||||
rocDecStatus rocdec_status;
|
||||
for (int pic_idx = 0; pic_idx < hip_interop_.size(); pic_idx++) {
|
||||
rocdec_status = ReleaseVideoFrame(pic_idx);
|
||||
rocdec_status = FreeVideoFrame(pic_idx);
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("Releasing the video frame for picture idx = " + TOSTR(pic_idx) + " failed during reconfiguration.");
|
||||
return rocdec_status;
|
||||
@@ -172,7 +172,7 @@ rocDecStatus RocDecoder::GetVideoFrame(int pic_idx, void *dev_mem_ptr[3], uint32
|
||||
return rocdec_status;
|
||||
}
|
||||
|
||||
rocDecStatus RocDecoder::ReleaseVideoFrame(int pic_idx) {
|
||||
rocDecStatus RocDecoder::FreeVideoFrame(int pic_idx) {
|
||||
if (pic_idx >= hip_interop_.size()) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
|
||||
private:
|
||||
rocDecStatus InitHIP(int device_id);
|
||||
rocDecStatus ReleaseVideoFrame(int pic_idx);
|
||||
rocDecStatus FreeVideoFrame(int pic_idx);
|
||||
int num_devices_;
|
||||
RocDecoderCreateInfo decoder_create_info_;
|
||||
VaapiVideoDecoder va_video_decoder_;
|
||||
|
||||
Reference in New Issue
Block a user