Implemented proper slice parameter buffer submission for multiple slice streams. (#226)
* * rocDecode: Implemented proper slice parameter buffer submission for multiple slice streams. - We were submitting single slice parameter buffer for multiple slice streams. This works for other APIs but not for VAAPI, which requires to send slice parameter buffer once per slice. - At step 1, all the multi-slice structures are fixed sized (256). Will make them dynamic in the next step. - With this change, all 135 HEVC conformance streams now pass. * * rocDecode: Multiple slice change step 2: make the fixed size slice info structure lists dynamic. * * rocDecode: Minor changes in comments. No functional changes. * *rocDecode: Changed INIT_SLICE_PARAM_LIST_NUM from 256 back to 16. 256 was set during debug process. * * rocDecode: Add suggest changes from code review. * * rocDecode: Moved slice_params_buf_id_ initialization to class VaapiVideoDecoder declaration, as suggested by code review.
This commit is contained in:
@@ -24,7 +24,8 @@ THE SOFTWARE.
|
||||
|
||||
VaapiVideoDecoder::VaapiVideoDecoder(RocDecoderCreateInfo &decoder_create_info) : decoder_create_info_{decoder_create_info},
|
||||
drm_fd_{-1}, va_display_{0}, va_config_attrib_{{}}, va_config_id_{0}, va_profile_ {VAProfileNone}, va_context_id_{0}, va_surface_ids_{{}},
|
||||
pic_params_buf_id_{0}, iq_matrix_buf_id_{0}, slice_params_buf_id_{0}, slice_data_buf_id_{0} {};
|
||||
pic_params_buf_id_{0}, iq_matrix_buf_id_{0}, num_slices_{0}, slice_data_buf_id_{0} {
|
||||
};
|
||||
|
||||
VaapiVideoDecoder::~VaapiVideoDecoder() {
|
||||
if (drm_fd_ != -1) {
|
||||
@@ -185,9 +186,11 @@ rocDecStatus VaapiVideoDecoder::DestroyDataBuffers() {
|
||||
CHECK_VAAPI(vaDestroyBuffer(va_display_, iq_matrix_buf_id_));
|
||||
iq_matrix_buf_id_ = 0;
|
||||
}
|
||||
if (slice_params_buf_id_) {
|
||||
CHECK_VAAPI(vaDestroyBuffer(va_display_, slice_params_buf_id_));
|
||||
slice_params_buf_id_ = 0;
|
||||
for (int i = 0; i < num_slices_; i++) {
|
||||
if (slice_params_buf_id_[i]) {
|
||||
CHECK_VAAPI(vaDestroyBuffer(va_display_, slice_params_buf_id_[i]));
|
||||
slice_params_buf_id_[i] = 0;
|
||||
}
|
||||
}
|
||||
if (slice_data_buf_id_) {
|
||||
CHECK_VAAPI(vaDestroyBuffer(va_display_, slice_data_buf_id_));
|
||||
@@ -231,7 +234,7 @@ rocDecStatus VaapiVideoDecoder::SubmitDecode(RocdecPicParams *pPicParams) {
|
||||
iq_matrix_size = sizeof(RocdecHevcIQMatrix);
|
||||
}
|
||||
|
||||
slice_params_ptr = (void*)&pPicParams->slice_params.hevc;
|
||||
slice_params_ptr = (void*)pPicParams->slice_params.hevc;
|
||||
slice_params_size = sizeof(RocdecHevcSliceParams);
|
||||
|
||||
if ((pic_params_size != sizeof(VAPictureParameterBufferHEVC)) || (scaling_list_enabled && (iq_matrix_size != sizeof(VAIQMatrixBufferHEVC))) ||
|
||||
@@ -260,7 +263,7 @@ rocDecStatus VaapiVideoDecoder::SubmitDecode(RocdecPicParams *pPicParams) {
|
||||
iq_matrix_ptr = (void*)&pPicParams->iq_matrix.avc;
|
||||
iq_matrix_size = sizeof(RocdecAvcIQMatrix);
|
||||
|
||||
slice_params_ptr = (void*)&pPicParams->slice_params.avc;
|
||||
slice_params_ptr = (void*)pPicParams->slice_params.avc;
|
||||
slice_params_size = sizeof(RocdecAvcSliceParams);
|
||||
|
||||
if ((pic_params_size != sizeof(VAPictureParameterBufferH264)) || (iq_matrix_size != sizeof(VAIQMatrixBufferH264)) || (slice_params_size != sizeof(VASliceParameterBufferH264))) {
|
||||
@@ -276,16 +279,26 @@ rocDecStatus VaapiVideoDecoder::SubmitDecode(RocdecPicParams *pPicParams) {
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the data buffers of the previous frame
|
||||
rocDecStatus rocdec_status = DestroyDataBuffers();
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("Failed to destroy VAAPI buffer.");
|
||||
return rocdec_status;
|
||||
}
|
||||
|
||||
CHECK_VAAPI(vaCreateBuffer(va_display_, va_context_id_, VAPictureParameterBufferType, pic_params_size, 1, pic_params_ptr, &pic_params_buf_id_));
|
||||
if (scaling_list_enabled) {
|
||||
CHECK_VAAPI(vaCreateBuffer(va_display_, va_context_id_, VAIQMatrixBufferType, iq_matrix_size, 1, iq_matrix_ptr, &iq_matrix_buf_id_));
|
||||
}
|
||||
CHECK_VAAPI(vaCreateBuffer(va_display_, va_context_id_, VASliceParameterBufferType, slice_params_size, 1, slice_params_ptr, &slice_params_buf_id_));
|
||||
// Resize if needed
|
||||
num_slices_ = pPicParams->num_slices;
|
||||
if (num_slices_ > slice_params_buf_id_.size()) {
|
||||
slice_params_buf_id_.resize(num_slices_, {0});
|
||||
}
|
||||
for (int i = 0; i < num_slices_; i++) {
|
||||
CHECK_VAAPI(vaCreateBuffer(va_display_, va_context_id_, VASliceParameterBufferType, slice_params_size, 1, slice_params_ptr, &slice_params_buf_id_[i]));
|
||||
slice_params_ptr = (void*)((uint8_t*)slice_params_ptr + slice_params_size);
|
||||
}
|
||||
CHECK_VAAPI(vaCreateBuffer(va_display_, va_context_id_, VASliceDataBufferType, pPicParams->bitstream_data_len, 1, (void*)pPicParams->bitstream_data, &slice_data_buf_id_));
|
||||
|
||||
// Sumbmit buffers to VAAPI driver
|
||||
@@ -294,7 +307,7 @@ rocDecStatus VaapiVideoDecoder::SubmitDecode(RocdecPicParams *pPicParams) {
|
||||
if (scaling_list_enabled) {
|
||||
CHECK_VAAPI(vaRenderPicture(va_display_, va_context_id_, &iq_matrix_buf_id_, 1));
|
||||
}
|
||||
CHECK_VAAPI(vaRenderPicture(va_display_, va_context_id_, &slice_params_buf_id_, 1));
|
||||
CHECK_VAAPI(vaRenderPicture(va_display_, va_context_id_, slice_params_buf_id_.data(), num_slices_));
|
||||
CHECK_VAAPI(vaRenderPicture(va_display_, va_context_id_, &slice_data_buf_id_, 1));
|
||||
CHECK_VAAPI(vaEndPicture(va_display_, va_context_id_));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user