From 2939a46dd26c7562a108bf050413c875536df346 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 15 May 2019 14:04:47 +0200 Subject: [PATCH] omxvideoenc: pass padding requirements to ALLOCATION query By passing the expected video buffer layout, the upstream producer may be able to produce buffers fitting those requierements allowing gst-omx to use dynamic buffer mode rather than having to copy each input buffer. This is particularly useful with v4l2src as it can request the capture driver to produce buffers with the required paddings. --- omx/gstomxvideoenc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index de8a9024b3..15f55f99f6 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -3157,6 +3157,27 @@ create_input_pool (GstOMXVideoEnc * self, GstCaps * caps, guint num_buffers) } #endif +static GstStructure * +get_allocation_video_meta (GstOMXVideoEnc * self, GstVideoInfo * info) +{ + GstStructure *result; + GstVideoAlignment align; + + gst_omx_video_get_port_padding (self->enc_in_port, info, &align); + + result = gst_structure_new_empty ("video-meta"); + + gst_structure_set (result, "padding-top", G_TYPE_UINT, align.padding_top, + "padding-bottom", G_TYPE_UINT, align.padding_bottom, + "padding-left", G_TYPE_UINT, align.padding_left, + "padding-right", G_TYPE_UINT, align.padding_right, NULL); + + GST_LOG_OBJECT (self, "Request buffer layout to producer: %" GST_PTR_FORMAT, + result); + + return result; +} + static gboolean gst_omx_video_enc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query) @@ -3166,6 +3187,7 @@ gst_omx_video_enc_propose_allocation (GstVideoEncoder * encoder, GstCaps *caps; GstVideoInfo info; GstBufferPool *pool = NULL; + GstStructure *params; gst_query_parse_allocation (query, &caps, NULL); @@ -3179,7 +3201,9 @@ gst_omx_video_enc_propose_allocation (GstVideoEncoder * encoder, return FALSE; } - gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); + params = get_allocation_video_meta (self, &info); + gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, params); + gst_structure_free (params); num_buffers = self->enc_in_port->port_def.nBufferCountMin + 1;