diff options
author | Aurélien Zanelli <aurelien.zanelli@parrot.com> | 2016-01-11 15:47:24 +0100 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2016-01-28 10:02:55 -0500 |
commit | fd33314f03e7b4d499c3ab813338aedf37acf57e (patch) | |
tree | dd72c909c92765c046aa7505f7cf4a2cb04aec77 | |
parent | 354f16a5cafbb2b543b7873cf30bedcc8935523a (diff) | |
download | gstreamer-plugins-bad-fd33314f03e7b4d499c3ab813338aedf37acf57e.tar.gz |
videoparse: use decide_allocation to check if downstream supports videometa
If yes, we add them to each output buffers and we avoid frame copy.
https://bugzilla.gnome.org/show_bug.cgi?id=760270
-rw-r--r-- | gst/rawparse/gstvideoparse.c | 34 | ||||
-rw-r--r-- | gst/rawparse/gstvideoparse.h | 1 |
2 files changed, 32 insertions, 3 deletions
diff --git a/gst/rawparse/gstvideoparse.c b/gst/rawparse/gstvideoparse.c index 2d7a2b672..92733c6ac 100644 --- a/gst/rawparse/gstvideoparse.c +++ b/gst/rawparse/gstvideoparse.c @@ -39,6 +39,8 @@ static void gst_video_parse_get_property (GObject * object, guint prop_id, static GstCaps *gst_video_parse_get_caps (GstRawParse * rp); static void gst_video_parse_pre_push_buffer (GstRawParse * rp, GstBuffer * buffer); +static void gst_video_parse_decide_allocation (GstRawParse * rp, + GstQuery * query); static void gst_video_parse_update_info (GstVideoParse * vp); static gboolean gst_video_parse_deserialize_int_array (const gchar * str, @@ -78,6 +80,7 @@ gst_video_parse_class_init (GstVideoParseClass * klass) rp_class->get_caps = gst_video_parse_get_caps; rp_class->pre_push_buffer = gst_video_parse_pre_push_buffer; + rp_class->decide_allocation = gst_video_parse_decide_allocation; g_object_class_install_property (gobject_class, PROP_FORMAT, g_param_spec_enum ("format", "Format", "Format of images in raw stream", @@ -536,9 +539,7 @@ gst_video_parse_pre_push_buffer (GstRawParse * rp, GstBuffer * buffer) { GstVideoParse *vp = GST_VIDEO_PARSE (rp); - /* for now, we don't add video meta to buffer, so if we have non standard - * stride and offset, just copy frame to new buffer */ - if (vp->need_videometa) { + if (vp->do_copy) { GstVideoInfo info; GstBuffer *outbuf; @@ -554,6 +555,16 @@ gst_video_parse_pre_push_buffer (GstRawParse * rp, GstBuffer * buffer) gst_buffer_replace_all_memory (buffer, gst_buffer_get_all_memory (outbuf)); gst_buffer_unref (outbuf); + } else { + GstVideoInfo *info = &vp->info; + GstVideoFrameFlags flags = GST_VIDEO_FRAME_FLAG_NONE; + + if (vp->interlaced && vp->top_field_first) + flags = GST_VIDEO_FRAME_FLAG_TFF; + + gst_buffer_add_video_meta_full (buffer, flags, GST_VIDEO_INFO_FORMAT (info), + GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info), + GST_VIDEO_INFO_N_PLANES (info), info->offset, info->stride); } if (vp->interlaced) { @@ -564,3 +575,20 @@ gst_video_parse_pre_push_buffer (GstRawParse * rp, GstBuffer * buffer) } } } + +static void +gst_video_parse_decide_allocation (GstRawParse * rp, GstQuery * query) +{ + GstVideoParse *vp = GST_VIDEO_PARSE (rp); + gboolean has_videometa; + + has_videometa = gst_query_find_allocation_meta (query, + GST_VIDEO_META_API_TYPE, NULL); + + /* no need to copy if downstream supports videometa or if we don't need + * them */ + if (has_videometa || !vp->need_videometa) + return; + + vp->do_copy = TRUE; +} diff --git a/gst/rawparse/gstvideoparse.h b/gst/rawparse/gstvideoparse.h index 7f0677285..dd540c54d 100644 --- a/gst/rawparse/gstvideoparse.h +++ b/gst/rawparse/gstvideoparse.h @@ -49,6 +49,7 @@ struct _GstVideoParse GstRawParse parent; GstVideoInfo info; + gboolean do_copy; gboolean need_videometa; gboolean stride_set; gboolean offset_set; |