vkencoder-private: add VkVideoReferenceSlotInfoKHR in GstVulkanEncoderPicture

And remove slotIndex since it's part of VkVideoReferenceSlotInfoKHR, simplifying
the reference slots array creation, and changing the tests accordingly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8007>
This commit is contained in:
Víctor Manuel Jáquez Leal 2024-09-19 12:21:04 +02:00 committed by GStreamer Marge Bot
parent 75a6ddf2be
commit d4de932664
4 changed files with 15 additions and 31 deletions

View file

@ -418,7 +418,6 @@ gst_vulkan_encoder_picture_init (GstVulkanEncoderPicture * pic,
gst_clear_buffer (&pic->dpb_buffer);
return FALSE;
}
pic->slotIndex = -1;
pic->offset = 0;
pic->img_view = gst_vulkan_video_image_create_view (pic->in_buffer,
@ -1080,7 +1079,6 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self, GstVideoInfo * info,
VkVideoEndCodingInfoKHR end_coding;
gint maxDpbSlots;
VkVideoReferenceSlotInfoKHR ref_slots[37];
gint ref_slot_num = 0;
GstVulkanCommandBuffer *cmd_buf;
GArray *barriers;
@ -1167,33 +1165,22 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self, GstVideoInfo * info,
.baseArrayLayer = 0,
.imageViewBinding = pic->dpb_view->view,
};
/* *INDENT-ON* */
for (i = 0; i < nb_refs; i++) {
/* *INDENT-OFF* */
ref_slots[i] = (VkVideoReferenceSlotInfoKHR) {
.sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
.pNext = ref_pics[i]->codec_dpb_slot_info,
.slotIndex = ref_pics[i]->slotIndex,
.pPictureResource = &ref_pics[i]->dpb,
};
/* *INDENT-ON* */
ref_slot_num++;
}
/* *INDENT-OFF* */
ref_slots[ref_slot_num] = (VkVideoReferenceSlotInfoKHR) {
pic->dpb_slot = (VkVideoReferenceSlotInfoKHR) {
.sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
.pNext = pic->codec_dpb_slot_info,
.slotIndex = pic->slotIndex,
.slotIndex = priv->current_slot_index,
.pPictureResource = &pic->dpb,
};
/* *INDENT-ON* */
ref_slot_num++;
for (i = 0; i < nb_refs; i++)
ref_slots[i] = ref_pics[i]->dpb_slot;
ref_slots[nb_refs] = pic->dpb_slot;
ref_slots[nb_refs].slotIndex = -1;
/* Setup the begin coding structure using the reference slots */
begin_coding.referenceSlotCount = ref_slot_num;
begin_coding.referenceSlotCount = nb_refs + 1;
begin_coding.pReferenceSlots = ref_slots;
cmd_buf = priv->exec->cmd_buf;
@ -1244,8 +1231,6 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self, GstVideoInfo * info,
/* Attribute a free slot index to the picture to be used later as a reference.
* The picture is kept until it remains useful to the encoding process.*/
pic->slotIndex = priv->current_slot_index;
ref_slots[ref_slot_num - 1].slotIndex = pic->slotIndex;
priv->current_slot_index++;
if (priv->current_slot_index >= maxDpbSlots)
priv->current_slot_index = 0;
@ -1270,9 +1255,9 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self, GstVideoInfo * info,
.baseArrayLayer = 0,
.imageViewBinding = pic->img_view->view,
},
.pSetupReferenceSlot = &ref_slots[ref_slot_num - 1],
.pSetupReferenceSlot = &pic->dpb_slot,
.referenceSlotCount = nb_refs,
.pReferenceSlots = nb_refs ? ref_slots : NULL,
.pReferenceSlots = ref_slots,
.precedingExternallyEncodedBytes = 0,
};
/* *INDENT-ON* */

View file

@ -51,8 +51,6 @@ typedef struct _GstVulkanEncoderPicture GstVulkanEncoderPicture;
*/
struct _GstVulkanEncoderPicture
{
gint slotIndex;
guint64 offset;
GstBuffer *in_buffer;
@ -64,6 +62,7 @@ struct _GstVulkanEncoderPicture
GstVulkanImageView *dpb_view;
VkVideoPictureResourceInfoKHR dpb;
VkVideoReferenceSlotInfoKHR dpb_slot;
gpointer codec_rc_info;
gpointer codec_pic_info;

View file

@ -545,11 +545,11 @@ encode_frame (GstVulkanEncoder * enc, GstVulkanH264EncodeFrame * frame,
for (i = 0; i < list0_num; i++) {
ref_pics[i] = &list0[i]->picture;
frame->ref_list_info.RefPicList0[0] = list0[i]->picture.slotIndex;
frame->ref_list_info.RefPicList0[0] = list0[i]->picture.dpb_slot.slotIndex;
}
for (i = 0; i < list1_num; i++) {
ref_pics[i + list0_num] = &list1[i]->picture;
frame->ref_list_info.RefPicList1[i] = list1[i]->picture.slotIndex;
frame->ref_list_info.RefPicList1[i] = list1[i]->picture.dpb_slot.slotIndex;
}
fail_unless (gst_vulkan_encoder_encode (enc, &in_info, picture, ref_pics_num,

View file

@ -611,11 +611,11 @@ encode_frame (GstVulkanEncoder * enc, GstVulkanH265EncodeFrame * frame,
for (i = 0; i < list0_num; i++) {
ref_pics[i] = &list0[i]->picture;
frame->ref_list_info.RefPicList0[0] = list0[i]->picture.slotIndex;
frame->ref_list_info.RefPicList0[0] = list0[i]->picture.dpb_slot.slotIndex;
}
for (i = 0; i < list1_num; i++) {
ref_pics[i + list0_num] = &list1[i]->picture;
frame->ref_list_info.RefPicList1[i] = list1[i]->picture.slotIndex;
frame->ref_list_info.RefPicList1[i] = list1[i]->picture.dpb_slot.slotIndex;
}
fail_unless (gst_vulkan_encoder_encode (enc, &in_info, picture, ref_pics_num,