rocDecode: Added decode buffer pool implementation for AVC and HEVC. (#355)

* * rocDecode: Initial check in for decode buffer pool.

* * rocDecode: All 135 streams pass.

* * rocDecode: Fixed a build error in debug mode.

* * rocDecode/HEVC: Removed two workaround in HEVC DPB management, after decode buffer pool implementa
tion.
 - WR 1: Conditional bumping (when max_num_reorder_pics > 0) to avoid synchronous job submission in
C.5.2.3.
 - WR 2: Add two more buffers in DPB to avoid buffer over-writing.

* * rocDecode/HEVC: Added display delay feature.

* * rocDecode/HEVC: Fixed the -z option issue within the context of the new decode buffer pool implementation.

* * rocDecode/HEVC: Removed redundent code.

* * rocDecode/AVC: Added decode buffer pool implementation for AVC.

* * rocDecode: Added a few changes.
 - Added display delay feature to AVC.
 - Removed a workaround for AVC: AVC_MAX_DPB_FRAMES was increased to 18. Now it is back to 16.
 - Removed a workaround for AVC: increased DPB buffer size by 2. Now it is back to normal.
 - Code format changes for HEVC.

* * rocDecode/AVC: Fixed the -z option issue within the context of the new decode buffer pool implementation.

* * rocDecode: Merged OutputDecodedPictures() method to upper class RocVideoParser.

* * rocDecode: Code cleanup. No functional changes.

* * rocDecode: Made decode buffer pool size adaptive.
 - Removed the hard coded decode buffer pool size set in the decoder.
 - Exposed the display delay parameter from RocVideoDecoder class to the user.
 - Now the decoder buffer pool size is determined from the DPB buffer size and display delay parameter.

* * rocDecode: Several changes based on code review.
 - Merged decode and display use status into one parameter.
 - Removed the surface index from DecodeFrameBuffer, which is now implicitly referred by the array index.
 - Changed a function name for better clarity.

* * rocDecode: Added a comment.

[ROCm/rocdecode commit: 61c8661b9c]
Этот коммит содержится в:
jeffqjiangNew
2024-05-31 13:14:02 -04:00
коммит произвёл GitHub
родитель 4a6e9d709b
Коммит 3230cca447
11 изменённых файлов: 418 добавлений и 179 удалений
+39
Просмотреть файл
@@ -78,6 +78,15 @@ typedef struct {
#define INIT_SLICE_LIST_NUM 16 // initial slice information/parameter struct list size
#define INIT_SEI_MESSAGE_COUNT 16 // initial SEI message count
#define INIT_SEI_PAYLOAD_BUF_SIZE 1024 * 1024 // initial SEI payload buffer size, 1 MB
#define DECODE_BUF_POOL_EXTENSION 2
enum {
kNotUsed = 0,
kTopFieldUsedForDecode = 1,
kBottomFieldUsedForDecode = 1 << 1,
kFrameUsedForDecode = kTopFieldUsedForDecode | kBottomFieldUsedForDecode,
kFrameUsedForDisplay = 1 << 2
} FrameBufUseStatus;
/**
* @brief Base class for video parsing
@@ -109,6 +118,21 @@ protected:
uint32_t pic_height_;
bool new_sps_activated_;
// Decoded buffer pool
typedef struct {
uint32_t use_status; // refer to FrameBufUseStatus
uint32_t pic_order_cnt;
} DecodeFrameBuffer;
uint32_t dec_buf_pool_size_; /* Number of decoded frame surfaces in the pool which are recycled. The size should be greater
than or equal to DPB size (normally greater to guarantee smooth operations). The value is
set to max_num_decode_surfaces from the decoder but parser checks and increases if needed. */
/* This array maps to VA surface array allocated at VA-API layer. A frame in the pool is identified by its index in the array, which
* is used to retrieve the VA surface Id.
*/
std::vector<DecodeFrameBuffer> decode_buffer_pool_;
uint32_t num_output_pics_; // number of pictures that are ready to be ouput
std::vector<uint32_t> output_pic_list_; // sorted output frame index to decode_buffer_pool_
Rational frame_rate_;
RocdecVideoFormat video_format_params_;
@@ -141,6 +165,17 @@ protected:
uint32_t sei_payload_buf_size_;
uint32_t sei_payload_size_; // total SEI payload size of the current frame
/*! \brief Function to check the initially set (by decoder) decode buffer pool size and adjust if needed
* \param dpb_size The DPB buffer size of the current sequence
*/
void CheckAndAdjustDecBufPoolSize(int dpb_size);
/*! \brief Callback function to output decoded pictures from DPB for post-processing.
* \param [in] no_delay Indicator to override the display delay parameter wth no delay
* \return <tt>ParserResult</tt>
*/
ParserResult OutputDecodedPictures(bool no_delay);
/*! \brief Function to get the NAL Unit data
* \return Returns OK if successful, else error code
*/
@@ -161,6 +196,10 @@ protected:
* \return No return value
*/
void ParseSeiMessage(uint8_t *nalu, size_t size);
/*! \brief Function to initialize the decoded buffer pool
*/
void InitDecBufPool();
};
// helpers