From 1364070eca040306ea42bfdd59d09c80022d166a Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Tue, 14 Jan 2020 11:17:49 -0800 Subject: [PATCH] vaapioverlay: ensure sinkpad has current buffer Use the gst_video_aggregator_pad_has_current_buffer API to check if the current sinkpad has a queued buffer before attempting to obtain a input buffer from the base plugin. If the sinkpad does not have a current buffer, then it is either not producing them yet (e.g. current time < sinkpad start time) or it has reached EOS. Previously, we only handled EOS case. Example: gst-launch-1.0 videotestsrc num-buffers=100 \ ! vaapipostproc ! vaapioverlay name=overlay \ ! vaapisink videotestsrc timestamp-offset=1000000000 \ num-buffers=100 ! video/x-raw,width=160,height=120 \ ! overlay. --- gst/vaapi/gstvaapioverlay.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gst/vaapi/gstvaapioverlay.c b/gst/vaapi/gstvaapioverlay.c index 7cdb21e..53efdac 100644 --- a/gst/vaapi/gstvaapioverlay.c +++ b/gst/vaapi/gstvaapioverlay.c @@ -385,6 +385,11 @@ gst_vaapi_overlay_surface_next (gpointer data) blend_surface = &generator->blend_surface; blend_surface->surface = NULL; + /* Current sinkpad may not be queueing buffers yet (e.g. timestamp-offset) + * or it may have reached EOS */ + if (!gst_video_aggregator_pad_has_current_buffer (vagg_pad)) + continue; + inframe = gst_video_aggregator_pad_get_prepared_frame (vagg_pad); buf = gst_video_aggregator_pad_get_current_buffer (vagg_pad); pad = GST_VAAPI_OVERLAY_SINK_PAD (vagg_pad); @@ -393,10 +398,6 @@ gst_vaapi_overlay_surface_next (gpointer data) (generator->overlay), GST_PAD (pad), buf, &inbuf) != GST_FLOW_OK) return blend_surface; - /* Current sinkpad may have reached EOS */ - if (!inframe || !inbuf) - continue; - inbuf_meta = gst_buffer_get_vaapi_video_meta (inbuf); if (inbuf_meta) { blend_surface->surface = gst_vaapi_video_meta_get_surface (inbuf_meta); -- 2.7.4