mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 15:56:42 +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;
|
guint quality_level;
|
||||||
} prop;
|
} prop;
|
||||||
|
|
||||||
guint out_buffer_size_aligned;
|
|
||||||
gboolean layered_dpb;
|
gboolean layered_dpb;
|
||||||
GstBufferPool *dpb_pool;
|
GstBufferPool *dpb_pool;
|
||||||
GstBuffer *layered_buffer;
|
GstBuffer *layered_buffer;
|
||||||
|
@ -388,10 +387,11 @@ 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, gboolean is_ref, gint nb_refs)
|
int width, int height, gsize size, gboolean is_ref, gint nb_refs)
|
||||||
{
|
{
|
||||||
GstVulkanEncoderPicture *pic;
|
GstVulkanEncoderPicture *pic;
|
||||||
GstVulkanEncoderPrivate *priv;
|
GstVulkanEncoderPrivate *priv;
|
||||||
|
gsize size_aligned;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_VULKAN_ENCODER (self), NULL);
|
g_return_val_if_fail (GST_IS_VULKAN_ENCODER (self), NULL);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (in_buffer), 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);
|
pic = g_new0 (GstVulkanEncoderPicture, 1);
|
||||||
|
|
||||||
|
size_aligned = GST_ROUND_UP_N (size,
|
||||||
|
priv->caps.caps.minBitstreamBufferSizeAlignment);
|
||||||
|
|
||||||
if (priv->layered_dpb) {
|
if (priv->layered_dpb) {
|
||||||
g_assert (priv->layered_buffer);
|
g_assert (priv->layered_buffer);
|
||||||
pic->dpb_buffer = gst_buffer_ref (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->in_buffer = gst_buffer_ref (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, priv->out_buffer_size_aligned);
|
VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR, size_aligned);
|
||||||
pic->width = width;
|
pic->width = width;
|
||||||
pic->height = height;
|
pic->height = height;
|
||||||
pic->is_ref = is_ref;
|
pic->is_ref = is_ref;
|
||||||
|
@ -564,7 +567,6 @@ gst_vulkan_encoder_stop (GstVulkanEncoder * self)
|
||||||
* gst_vulkan_encoder_start:
|
* gst_vulkan_encoder_start:
|
||||||
* @self: a #GstVulkanEncoder
|
* @self: a #GstVulkanEncoder
|
||||||
* @profile: a #GstVulkanVideoProfile
|
* @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
|
* @error: (out) : an error result in case of failure or %NULL
|
||||||
*
|
*
|
||||||
* Start the encoding session according to a valid Vulkan profile
|
* Start the encoding session according to a valid Vulkan profile
|
||||||
|
@ -574,7 +576,7 @@ gst_vulkan_encoder_stop (GstVulkanEncoder * self)
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
||||||
GstVulkanVideoProfile * profile, guint out_buffer_size, GError ** error)
|
GstVulkanVideoProfile * profile, GError ** error)
|
||||||
{
|
{
|
||||||
GstVulkanEncoderPrivate *priv;
|
GstVulkanEncoderPrivate *priv;
|
||||||
VkResult res;
|
VkResult res;
|
||||||
|
@ -819,9 +821,6 @@ gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
|
|
||||||
priv->out_buffer_size_aligned = GST_ROUND_UP_N (out_buffer_size,
|
|
||||||
priv->caps.caps.minBitstreamBufferSizeAlignment);
|
|
||||||
|
|
||||||
priv->started = TRUE;
|
priv->started = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -153,7 +153,6 @@ GstVulkanEncoder * gst_vulkan_encoder_create_from_queue (GstVulkanQueue
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
gboolean gst_vulkan_encoder_start (GstVulkanEncoder * self,
|
||||||
GstVulkanVideoProfile * profile,
|
GstVulkanVideoProfile * profile,
|
||||||
guint32 out_buffer_size,
|
|
||||||
GError ** error);
|
GError ** error);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
gboolean gst_vulkan_encoder_stop (GstVulkanEncoder * self);
|
gboolean gst_vulkan_encoder_stop (GstVulkanEncoder * self);
|
||||||
|
@ -187,6 +186,7 @@ GstVulkanEncoderPicture* gst_vulkan_encoder_picture_new (GstVulkanEncode
|
||||||
GstBuffer * in_buffer,
|
GstBuffer * in_buffer,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
|
gsize size,
|
||||||
gboolean is_ref,
|
gboolean is_ref,
|
||||||
gint nb_refs);
|
gint nb_refs);
|
||||||
GST_VULKAN_API
|
GST_VULKAN_API
|
||||||
|
|
|
@ -357,7 +357,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, is_ref, nb_refs));
|
img_buffer, width, height, width * height * 3, is_ref, nb_refs));
|
||||||
fail_unless (frame);
|
fail_unless (frame);
|
||||||
fail_unless (frame->picture);
|
fail_unless (frame->picture);
|
||||||
gst_buffer_unref (in_buffer);
|
gst_buffer_unref (in_buffer);
|
||||||
|
@ -693,8 +693,7 @@ setup_h264_encoder (guint32 width, gint32 height, gint sps_id, gint pps_id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, width * height * 3,
|
fail_unless (gst_vulkan_encoder_start (enc, &profile, &err));
|
||||||
&err));
|
|
||||||
|
|
||||||
mbAlignedWidth = GST_ROUND_UP_16 (width);
|
mbAlignedWidth = GST_ROUND_UP_16 (width);
|
||||||
mbAlignedHeight = GST_ROUND_UP_16 (height);
|
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 */
|
/* get a Vulkan image buffer out of the input buffer */
|
||||||
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, is_ref, nb_refs));
|
img_buffer, width, height, width * height * 3, is_ref, nb_refs));
|
||||||
fail_unless (frame);
|
fail_unless (frame);
|
||||||
fail_unless (frame->picture);
|
fail_unless (frame->picture);
|
||||||
gst_buffer_unref (in_buffer);
|
gst_buffer_unref (in_buffer);
|
||||||
|
@ -797,8 +796,7 @@ setup_h265_encoder (uint32_t width, uint32_t height, gint vps_id,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_unless (gst_vulkan_encoder_start (enc, &profile, width * height * 3,
|
fail_unless (gst_vulkan_encoder_start (enc, &profile, &err));
|
||||||
&err));
|
|
||||||
|
|
||||||
fail_unless (gst_vulkan_encoder_caps (enc, &enc_caps));
|
fail_unless (gst_vulkan_encoder_caps (enc, &enc_caps));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue