diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2019-05-15 14:04:47 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.com> | 2019-11-05 17:30:21 +0530 |
commit | 2939a46dd26c7562a108bf050413c875536df346 (patch) | |
tree | e9ddfed390eeea43d801bf82b8281c4fe6397dd1 | |
parent | 800cc4bd6710b60da09982d1efdfde2613d950a9 (diff) | |
download | gst-omx-2939a46dd26c7562a108bf050413c875536df346.tar.gz |
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.
-rw-r--r-- | omx/gstomxvideoenc.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index de8a902..15f55f9 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; |