From b392b4f0642fa63cf89e28568460c81e1c02fbf6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Sun, 10 Jul 2016 18:18:57 +0200 Subject: [PATCH] vaapidecode: flush output adapter at drain() Calling drain() vmethod means "decode any data it can at this point, but that more data may arrive after". Hence, vaapidecode should check if there is data in the output adapter and process them, without destroying the decoded picture buffer (dpb). Since this operation is done by gst_vaapidecode_internal_flush(), the operation was refactored into a new function gst_vaapidecode_flush_output_adapter(). https://bugzilla.gnome.org/show_bug.cgi?id=768652 --- gst/vaapi/gstvaapidecode.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 2d3a558..a5ad731 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -682,6 +682,17 @@ not_negotiated: } } +/* If there is something in GstVideoDecoder's output adapter, then + submit the frame for decoding */ +static inline void +gst_vaapidecode_flush_output_adapter (GstVaapiDecode * decode) +{ + if (decode->current_frame_size == 0) + return; + gst_video_decoder_have_frame (GST_VIDEO_DECODER (decode)); + decode->current_frame_size = 0; +} + static GstFlowReturn gst_vaapidecode_drain (GstVideoDecoder * vdec) { @@ -690,6 +701,9 @@ gst_vaapidecode_drain (GstVideoDecoder * vdec) if (!decode->decoder) return GST_FLOW_NOT_NEGOTIATED; + GST_LOG_OBJECT (decode, "drain"); + + gst_vaapidecode_flush_output_adapter (decode); return gst_vaapidecode_push_all_decoded_frames (decode); } @@ -702,13 +716,7 @@ gst_vaapidecode_internal_flush (GstVideoDecoder * vdec) if (!decode->decoder) return TRUE; - /* If there is something in GstVideoDecoder's output adapter, then - submit the frame for decoding */ - if (decode->current_frame_size) { - gst_video_decoder_have_frame (vdec); - decode->current_frame_size = 0; - } - + gst_vaapidecode_flush_output_adapter (decode); status = gst_vaapi_decoder_flush (decode->decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) { GST_WARNING_OBJECT (decode, "failed to flush decoder (status %d)", status); -- 2.7.4