mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
vkencoder-private: remove width, height and fps from GstVulkanEncoderPicture
In GStreamer that buffer information is decoupled, holding other structures to describe the stream: GstCaps. So, to keep the GStreamer design this patch removes these information from GstVulkanEncoderPicture and pass to gst_vulkan_encoder_encode() a pointer to GstVideoInfo. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8007>
This commit is contained in:
parent
eef9717478
commit
c1e364ecdc
4 changed files with 16 additions and 29 deletions
|
@ -375,8 +375,7 @@ gst_vulkan_encoder_new_video_session_parameters (GstVulkanEncoder * self,
|
||||||
* gst_vulkan_encoder_picture_new:
|
* gst_vulkan_encoder_picture_new:
|
||||||
* @self: the #GstVulkanEncoder with the pool's configuration.
|
* @self: the #GstVulkanEncoder with the pool's configuration.
|
||||||
* @in_buffer: (transfer none): the input #GstBuffer.
|
* @in_buffer: (transfer none): the input #GstBuffer.
|
||||||
* @width: the picture width
|
* @size: size of the output buffer
|
||||||
* @height: the picture height
|
|
||||||
*
|
*
|
||||||
* Create a new vulkan encode picture from the input buffer.
|
* Create a new vulkan encode picture from the input buffer.
|
||||||
*
|
*
|
||||||
|
@ -385,7 +384,7 @@ gst_vulkan_encoder_new_video_session_parameters (GstVulkanEncoder * self,
|
||||||
*/
|
*/
|
||||||
GstVulkanEncoderPicture *
|
GstVulkanEncoderPicture *
|
||||||
gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
||||||
int width, int height, gsize size)
|
gsize size)
|
||||||
{
|
{
|
||||||
GstVulkanEncoderPicture *pic;
|
GstVulkanEncoderPicture *pic;
|
||||||
GstVulkanEncoderPrivate *priv;
|
GstVulkanEncoderPrivate *priv;
|
||||||
|
@ -419,8 +418,6 @@ gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
||||||
pic->out_buffer =
|
pic->out_buffer =
|
||||||
gst_vulkan_video_codec_buffer_new (self->queue->device, &priv->profile,
|
gst_vulkan_video_codec_buffer_new (self->queue->device, &priv->profile,
|
||||||
VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR, size_aligned);
|
VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR, size_aligned);
|
||||||
pic->width = width;
|
|
||||||
pic->height = height;
|
|
||||||
pic->slotIndex = -1;
|
pic->slotIndex = -1;
|
||||||
pic->offset = 0;
|
pic->offset = 0;
|
||||||
|
|
||||||
|
@ -1057,6 +1054,7 @@ bail:
|
||||||
/**
|
/**
|
||||||
* gst_vulkan_encoder_encode:
|
* gst_vulkan_encoder_encode:
|
||||||
* @self: a #GstVulkanEncoder
|
* @self: a #GstVulkanEncoder
|
||||||
|
* @info: the #GstVideoInfo of the @pic to process
|
||||||
* @pic: a #GstVulkanEncoderPicture
|
* @pic: a #GstVulkanEncoderPicture
|
||||||
* @nb_refs: number of @ref_pics
|
* @nb_refs: number of @ref_pics
|
||||||
* @ref_pics: an array of #GstVulkanEncoderPicture
|
* @ref_pics: an array of #GstVulkanEncoderPicture
|
||||||
|
@ -1067,7 +1065,7 @@ bail:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
gst_vulkan_encoder_encode (GstVulkanEncoder * self, GstVideoInfo * info,
|
||||||
GstVulkanEncoderPicture * pic, guint nb_refs,
|
GstVulkanEncoderPicture * pic, guint nb_refs,
|
||||||
GstVulkanEncoderPicture ** ref_pics)
|
GstVulkanEncoderPicture ** ref_pics)
|
||||||
{
|
{
|
||||||
|
@ -1090,7 +1088,7 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
GArray *barriers;
|
GArray *barriers;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_VULKAN_ENCODER (self), FALSE);
|
g_return_val_if_fail (GST_IS_VULKAN_ENCODER (self), FALSE);
|
||||||
g_return_val_if_fail (pic != NULL, FALSE);
|
g_return_val_if_fail (info != NULL && pic != NULL, FALSE);
|
||||||
|
|
||||||
priv = gst_vulkan_encoder_get_instance_private (self);
|
priv = gst_vulkan_encoder_get_instance_private (self);
|
||||||
|
|
||||||
|
@ -1123,8 +1121,8 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
.pNext = pic->codec_rc_layer_info,
|
.pNext = pic->codec_rc_layer_info,
|
||||||
.averageBitrate = priv->prop.average_bitrate,
|
.averageBitrate = priv->prop.average_bitrate,
|
||||||
.maxBitrate = priv->caps.encoder.caps.maxBitrate,
|
.maxBitrate = priv->caps.encoder.caps.maxBitrate,
|
||||||
.frameRateNumerator = pic->fps_n,
|
.frameRateNumerator = GST_VIDEO_INFO_FPS_N (info),
|
||||||
.frameRateDenominator = pic->fps_d,
|
.frameRateDenominator = GST_VIDEO_INFO_FPS_D (info),
|
||||||
};
|
};
|
||||||
priv->rate_control_info = (VkVideoEncodeRateControlInfoKHR) {
|
priv->rate_control_info = (VkVideoEncodeRateControlInfoKHR) {
|
||||||
.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR,
|
.sType = VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR,
|
||||||
|
@ -1166,8 +1164,8 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
.pNext = NULL,
|
.pNext = NULL,
|
||||||
.codedOffset = { 0, 0 },
|
.codedOffset = { 0, 0 },
|
||||||
.codedExtent = {
|
.codedExtent = {
|
||||||
.width = pic->width,
|
.width = GST_VIDEO_INFO_WIDTH (info),
|
||||||
.height = pic->height
|
.height = GST_VIDEO_INFO_HEIGHT (info),
|
||||||
},
|
},
|
||||||
.baseArrayLayer = 0,
|
.baseArrayLayer = 0,
|
||||||
.imageViewBinding = pic->dpb_view->view,
|
.imageViewBinding = pic->dpb_view->view,
|
||||||
|
@ -1269,8 +1267,8 @@ gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
.pNext = NULL,
|
.pNext = NULL,
|
||||||
.codedOffset = { 0, 0 },
|
.codedOffset = { 0, 0 },
|
||||||
.codedExtent = {
|
.codedExtent = {
|
||||||
.width = pic->width,
|
.width = GST_VIDEO_INFO_WIDTH (info),
|
||||||
.height = pic->height
|
.height = GST_VIDEO_INFO_HEIGHT (info),
|
||||||
},
|
},
|
||||||
.baseArrayLayer = 0,
|
.baseArrayLayer = 0,
|
||||||
.imageViewBinding = pic->img_view->view,
|
.imageViewBinding = pic->img_view->view,
|
||||||
|
|
|
@ -42,10 +42,6 @@ typedef struct _GstVulkanEncoderPicture GstVulkanEncoderPicture;
|
||||||
* GstVulkanEncoderPicture:
|
* GstVulkanEncoderPicture:
|
||||||
* @slotIndex: slot index
|
* @slotIndex: slot index
|
||||||
* @offset: headers offset
|
* @offset: headers offset
|
||||||
* @width: picture width
|
|
||||||
* @height: picture height
|
|
||||||
* @fps_n: fps numerator
|
|
||||||
* @fps_d: fps denominator
|
|
||||||
* @in_buffer: input buffer
|
* @in_buffer: input buffer
|
||||||
* @out_buffer: output buffer
|
* @out_buffer: output buffer
|
||||||
*
|
*
|
||||||
|
@ -59,12 +55,6 @@ struct _GstVulkanEncoderPicture
|
||||||
|
|
||||||
guint64 offset;
|
guint64 offset;
|
||||||
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
|
|
||||||
gint fps_n;
|
|
||||||
gint fps_d;
|
|
||||||
|
|
||||||
GstBuffer *in_buffer;
|
GstBuffer *in_buffer;
|
||||||
GstBuffer *dpb_buffer;
|
GstBuffer *dpb_buffer;
|
||||||
GstBuffer *out_buffer;
|
GstBuffer *out_buffer;
|
||||||
|
@ -164,6 +154,7 @@ gboolean gst_vulkan_encoder_create_dpb_pool (GstVulkanEncode
|
||||||
GstCaps * caps);
|
GstCaps * caps);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
gboolean gst_vulkan_encoder_encode (GstVulkanEncoder * self,
|
||||||
|
GstVideoInfo * info,
|
||||||
GstVulkanEncoderPicture * pic,
|
GstVulkanEncoderPicture * pic,
|
||||||
guint nb_refs,
|
guint nb_refs,
|
||||||
GstVulkanEncoderPicture ** ref_pics);
|
GstVulkanEncoderPicture ** ref_pics);
|
||||||
|
@ -175,8 +166,6 @@ GstCaps * gst_vulkan_encoder_profile_caps (GstVulkanEncode
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
GstVulkanEncoderPicture* gst_vulkan_encoder_picture_new (GstVulkanEncoder * self,
|
GstVulkanEncoderPicture* gst_vulkan_encoder_picture_new (GstVulkanEncoder * self,
|
||||||
GstBuffer * in_buffer,
|
GstBuffer * in_buffer,
|
||||||
gint width,
|
|
||||||
gint height,
|
|
||||||
gsize size);
|
gsize size);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
void gst_vulkan_encoder_picture_free (GstVulkanEncoderPicture * pic);
|
void gst_vulkan_encoder_picture_free (GstVulkanEncoderPicture * pic);
|
||||||
|
|
|
@ -362,7 +362,7 @@ allocate_frame (GstVulkanEncoder * enc, int width,
|
||||||
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
||||||
|
|
||||||
frame = _h264_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
frame = _h264_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
||||||
img_buffer, width, height, width * height * 3), is_ref);
|
img_buffer, width * height * 3), is_ref);
|
||||||
fail_unless (frame);
|
fail_unless (frame);
|
||||||
fail_unless (frame->picture);
|
fail_unless (frame->picture);
|
||||||
gst_buffer_unref (in_buffer);
|
gst_buffer_unref (in_buffer);
|
||||||
|
@ -552,7 +552,7 @@ encode_frame (GstVulkanEncoder * enc, GstVulkanH264EncodeFrame * frame,
|
||||||
frame->ref_list_info.RefPicList1[i] = list1[i]->picture->slotIndex;
|
frame->ref_list_info.RefPicList1[i] = list1[i]->picture->slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless (gst_vulkan_encoder_encode (enc, picture, ref_pics_num,
|
fail_unless (gst_vulkan_encoder_encode (enc, &in_info, picture, ref_pics_num,
|
||||||
ref_pics));
|
ref_pics));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ allocate_frame (GstVulkanEncoder * enc, int width,
|
||||||
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
||||||
|
|
||||||
frame = _h265_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
frame = _h265_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
||||||
img_buffer, width, height, width * height * 3), is_ref);
|
img_buffer, width * height * 3), is_ref);
|
||||||
fail_unless (frame);
|
fail_unless (frame);
|
||||||
fail_unless (frame->picture);
|
fail_unless (frame->picture);
|
||||||
gst_buffer_unref (in_buffer);
|
gst_buffer_unref (in_buffer);
|
||||||
|
@ -618,7 +618,7 @@ encode_frame (GstVulkanEncoder * enc, GstVulkanH265EncodeFrame * frame,
|
||||||
frame->ref_list_info.RefPicList1[i] = list1[i]->picture->slotIndex;
|
frame->ref_list_info.RefPicList1[i] = list1[i]->picture->slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless (gst_vulkan_encoder_encode (enc, picture, ref_pics_num,
|
fail_unless (gst_vulkan_encoder_encode (enc, &in_info, picture, ref_pics_num,
|
||||||
ref_pics));
|
ref_pics));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue