* rocDecode/AVC: Added SEI message extraction support. Also merged common AVC and HEVC SEI support code to super class. (#250)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ca3333f7b9
Коммит
9b006616ed
@@ -48,31 +48,34 @@ HevcVideoParser::HevcVideoParser() {
|
||||
slice_info_list_.assign(INIT_SLICE_LIST_NUM, {0});
|
||||
slice_param_list_.assign(INIT_SLICE_LIST_NUM, {0});
|
||||
|
||||
sei_rbsp_buf_ = nullptr;
|
||||
sei_rbsp_buf_size_ = 0;
|
||||
sei_payload_buf_ = nullptr;
|
||||
sei_payload_buf_size_ = 0;
|
||||
sei_message_list_.assign(INIT_SEI_MESSAGE_COUNT, {0});
|
||||
|
||||
memset(&curr_pic_info_, 0, sizeof(HevcPicInfo));
|
||||
InitDpb();
|
||||
}
|
||||
|
||||
HevcVideoParser::~HevcVideoParser() {
|
||||
if (m_vps_) {
|
||||
delete [] m_vps_;
|
||||
}
|
||||
if (m_sps_) {
|
||||
delete [] m_sps_;
|
||||
}
|
||||
if (m_pps_) {
|
||||
delete [] m_pps_;
|
||||
}
|
||||
if (m_sh_copy_) {
|
||||
delete m_sh_copy_;
|
||||
}
|
||||
}
|
||||
|
||||
rocDecStatus HevcVideoParser::Initialize(RocdecParserParams *p_params) {
|
||||
return RocVideoParser::Initialize(p_params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief function to uninitialize hevc parser
|
||||
*
|
||||
* @return rocDecStatus
|
||||
*/
|
||||
rocDecStatus HevcVideoParser::UnInitialize() {
|
||||
//todo:: do any uninitialization here
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
rocDecStatus HevcVideoParser::ParseVideoData(RocdecSourceDataPacket *p_data) {
|
||||
if (p_data->payload && p_data->payload_size) {
|
||||
// Clear DPB output/display buffer number
|
||||
@@ -94,7 +97,7 @@ rocDecStatus HevcVideoParser::ParseVideoData(RocdecSourceDataPacket *p_data) {
|
||||
|
||||
// Whenever new sei message found
|
||||
if (pfn_get_sei_message_cb_ && sei_message_count_ > 0) {
|
||||
FillSeiMessageCallbackFn();
|
||||
SendSeiMsgPayload();
|
||||
}
|
||||
|
||||
// Decode the picture
|
||||
@@ -125,27 +128,6 @@ rocDecStatus HevcVideoParser::ParseVideoData(RocdecSourceDataPacket *p_data) {
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
HevcVideoParser::~HevcVideoParser() {
|
||||
if (m_vps_) {
|
||||
delete [] m_vps_;
|
||||
}
|
||||
if (m_sps_) {
|
||||
delete [] m_sps_;
|
||||
}
|
||||
if (m_pps_) {
|
||||
delete [] m_pps_;
|
||||
}
|
||||
if (m_sh_copy_) {
|
||||
delete m_sh_copy_;
|
||||
}
|
||||
if (sei_rbsp_buf_) {
|
||||
delete [] sei_rbsp_buf_;
|
||||
}
|
||||
if (sei_payload_buf_) {
|
||||
delete [] sei_payload_buf_;
|
||||
}
|
||||
}
|
||||
|
||||
int HevcVideoParser::FillSeqCallbackFn(HevcSeqParamSet* sps_data) {
|
||||
video_format_params_.codec = rocDecVideoCodec_HEVC;
|
||||
video_format_params_.frame_rate.numerator = frame_rate_.numerator;
|
||||
@@ -247,7 +229,7 @@ int HevcVideoParser::FillSeqCallbackFn(HevcSeqParamSet* sps_data) {
|
||||
}
|
||||
}
|
||||
|
||||
void HevcVideoParser::FillSeiMessageCallbackFn() {
|
||||
void HevcVideoParser::SendSeiMsgPayload() {
|
||||
sei_message_info_params_.sei_message_count = sei_message_count_;
|
||||
sei_message_info_params_.sei_message = sei_message_list_.data();
|
||||
sei_message_info_params_.sei_data = (void*)sei_payload_buf_;
|
||||
@@ -1846,57 +1828,6 @@ bool HevcVideoParser::ParseSliceHeader(uint8_t *nalu, size_t size, HevcSliceSegH
|
||||
return false;
|
||||
}
|
||||
|
||||
void HevcVideoParser::ParseSeiMessage(uint8_t *nalu, size_t size) {
|
||||
int offset = 0; // byte offset
|
||||
int payload_type;
|
||||
int payload_size;
|
||||
|
||||
do {
|
||||
payload_type = 0;
|
||||
while (nalu[offset] == 0xFF) {
|
||||
payload_type += 255; // ff_byte
|
||||
offset++;
|
||||
}
|
||||
payload_type += nalu[offset]; // last_payload_type_byte
|
||||
offset++;
|
||||
|
||||
payload_size = 0;
|
||||
while (nalu[offset] == 0xFF) {
|
||||
payload_size += 255; // ff_byte
|
||||
offset++;
|
||||
}
|
||||
payload_size += nalu[offset]; // last_payload_size_byte
|
||||
offset++;
|
||||
|
||||
// We start with INIT_SEI_MESSAGE_COUNT. Should be enough for normal use cases. If not, resize.
|
||||
if((sei_message_count_ + 1) > sei_message_list_.size()) {
|
||||
sei_message_list_.resize((sei_message_count_ + 1));
|
||||
}
|
||||
sei_message_list_[sei_message_count_].sei_message_type = payload_type;
|
||||
sei_message_list_[sei_message_count_].sei_message_size = payload_size;
|
||||
|
||||
if (sei_payload_buf_) {
|
||||
if ((payload_size + sei_payload_size_) > sei_payload_buf_size_) {
|
||||
uint8_t *tmp_ptr = new uint8_t [payload_size + sei_payload_size_];
|
||||
memcpy(tmp_ptr, sei_payload_buf_, sei_payload_size_); // save the existing payload
|
||||
delete [] sei_payload_buf_;
|
||||
sei_payload_buf_ = tmp_ptr;
|
||||
}
|
||||
} else {
|
||||
// First payload, sei_payload_size_ is 0.
|
||||
sei_payload_buf_size_ = payload_size > INIT_SEI_PAYLOAD_BUF_SIZE ? payload_size : INIT_SEI_PAYLOAD_BUF_SIZE;
|
||||
sei_payload_buf_ = new uint8_t [sei_payload_buf_size_];
|
||||
}
|
||||
// Append the current payload to sei_payload_buf_
|
||||
memcpy(sei_payload_buf_ + sei_payload_size_, nalu + offset, payload_size);
|
||||
|
||||
sei_payload_size_ += payload_size;
|
||||
sei_message_count_++;
|
||||
|
||||
offset += payload_size;
|
||||
} while (offset < size && nalu[offset] != 0x80);
|
||||
}
|
||||
|
||||
bool HevcVideoParser::IsIdrPic(HevcNalUnitHeader *nal_header_ptr) {
|
||||
return (nal_header_ptr->nal_unit_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nal_header_ptr->nal_unit_type == NAL_UNIT_CODED_SLICE_IDR_N_LP);
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user