mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
vkencoder-private: don't store output data size
There's no need to store in encoder helper the output data size, that's responsibility of the caller when an output buffer is allocated. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8007>
This commit is contained in:
parent
091fe0c1e7
commit
4a221aad8a
4 changed files with 12 additions and 16 deletions
|
@ -72,7 +72,6 @@ struct _GstVulkanEncoderPrivate
|
|||
guint quality_level;
|
||||
} prop;
|
||||
|
||||
guint out_buffer_size_aligned;
|
||||
gboolean layered_dpb;
|
||||
GstBufferPool *dpb_pool;
|
||||
GstBuffer *layered_buffer;
|
||||
|
@ -388,10 +387,11 @@ gst_vulkan_encoder_new_video_session_parameters (GstVulkanEncoder * self,
|
|||
*/
|
||||
GstVulkanEncoderPicture *
|
||||
gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
||||
int width, int height, gboolean is_ref, gint nb_refs)
|
||||
int width, int height, gsize size, gboolean is_ref, gint nb_refs)
|
||||
{
|
||||
GstVulkanEncoderPicture *pic;
|
||||
GstVulkanEncoderPrivate *priv;
|
||||
gsize size_aligned;
|
||||
|
||||
g_return_val_if_fail (GST_IS_VULKAN_ENCODER (self), NULL);
|
||||
g_return_val_if_fail (GST_IS_BUFFER (in_buffer), NULL);
|
||||
|
@ -400,6 +400,9 @@ gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
|||
|
||||
pic = g_new0 (GstVulkanEncoderPicture, 1);
|
||||
|
||||
size_aligned = GST_ROUND_UP_N (size,
|
||||
priv->caps.caps.minBitstreamBufferSizeAlignment);
|
||||
|
||||
if (priv->layered_dpb) {
|
||||
g_assert (priv->layered_buffer);
|
||||
pic->dpb_buffer = gst_buffer_ref (priv->layered_buffer);
|
||||
|
@ -417,7 +420,7 @@ gst_vulkan_encoder_picture_new (GstVulkanEncoder * self, GstBuffer * in_buffer,
|
|||
pic->in_buffer = gst_buffer_ref (in_buffer);
|
||||
pic->out_buffer =
|
||||
gst_vulkan_video_codec_buffer_new (self->queue->device, &priv->profile,
|
||||
VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR, priv->out_buffer_size_aligned);
|
||||
VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR, size_aligned);
|
||||
pic->width = width;
|
||||
pic->height = height;
|
||||
pic->is_ref = is_ref;
|
||||
|
@ -564,7 +567,6 @@ gst_vulkan_encoder_stop (GstVulkanEncoder * self)
|
|||
* gst_vulkan_encoder_start:
|
||||
* @self: a #GstVulkanEncoder
|
||||
* @profile: a #GstVulkanVideoProfile
|
||||
* @out_buffer_size: a maximal buffer size to be used by the encoder to store the output
|
||||
* @error: (out) : an error result in case of failure or %NULL
|
||||
*
|
||||
* Start the encoding session according to a valid Vulkan profile
|
||||
|
@ -574,7 +576,7 @@ gst_vulkan_encoder_stop (GstVulkanEncoder * self)
|
|||
*/
|
||||
gboolean
|
||||
gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
||||
GstVulkanVideoProfile * profile, guint out_buffer_size, GError ** error)
|
||||
GstVulkanVideoProfile * profile, GError ** error)
|
||||
{
|
||||
GstVulkanEncoderPrivate *priv;
|
||||
VkResult res;
|
||||
|
@ -819,9 +821,6 @@ gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
|||
goto failed;
|
||||
|
||||
|
||||
priv->out_buffer_size_aligned = GST_ROUND_UP_N (out_buffer_size,
|
||||
priv->caps.caps.minBitstreamBufferSizeAlignment);
|
||||
|
||||
priv->started = TRUE;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -153,7 +153,6 @@ GstVulkanEncoder * gst_vulkan_encoder_create_from_queue (GstVulkanQueue
|
|||
GST_VULKAN_API
|
||||
gboolean gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
||||
GstVulkanVideoProfile * profile,
|
||||
guint32 out_buffer_size,
|
||||
GError ** error);
|
||||
GST_VULKAN_API
|
||||
gboolean gst_vulkan_encoder_stop (GstVulkanEncoder * self);
|
||||
|
@ -187,6 +186,7 @@ GstVulkanEncoderPicture* gst_vulkan_encoder_picture_new (GstVulkanEncode
|
|||
GstBuffer * in_buffer,
|
||||
gint width,
|
||||
gint height,
|
||||
gsize size,
|
||||
gboolean is_ref,
|
||||
gint nb_refs);
|
||||
GST_VULKAN_API
|
||||
|
|
|
@ -357,7 +357,7 @@ allocate_frame (GstVulkanEncoder * enc, int width,
|
|||
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
||||
|
||||
frame = _h264_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
||||
img_buffer, width, height, is_ref, nb_refs));
|
||||
img_buffer, width, height, width * height * 3, is_ref, nb_refs));
|
||||
fail_unless (frame);
|
||||
fail_unless (frame->picture);
|
||||
gst_buffer_unref (in_buffer);
|
||||
|
@ -693,8 +693,7 @@ setup_h264_encoder (guint32 width, gint32 height, gint sps_id, gint pps_id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, width * height * 3,
|
||||
&err));
|
||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, &err));
|
||||
|
||||
mbAlignedWidth = GST_ROUND_UP_16 (width);
|
||||
mbAlignedHeight = GST_ROUND_UP_16 (height);
|
||||
|
|
|
@ -363,9 +363,8 @@ allocate_frame (GstVulkanEncoder * enc, int width,
|
|||
/* get a Vulkan image buffer out of the input buffer */
|
||||
upload_buffer_to_image(img_pool, in_buffer, &img_buffer);
|
||||
|
||||
|
||||
frame = _h265_encode_frame_new (gst_vulkan_encoder_picture_new (enc,
|
||||
img_buffer, width, height, is_ref, nb_refs));
|
||||
img_buffer, width, height, width * height * 3, is_ref, nb_refs));
|
||||
fail_unless (frame);
|
||||
fail_unless (frame->picture);
|
||||
gst_buffer_unref (in_buffer);
|
||||
|
@ -797,8 +796,7 @@ setup_h265_encoder (uint32_t width, uint32_t height, gint vps_id,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, width * height * 3,
|
||||
&err));
|
||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, &err));
|
||||
|
||||
fail_unless (gst_vulkan_encoder_caps (enc, &enc_caps));
|
||||
|
||||
|
|
Loading…
Reference in a new issue