From abfb5dd06cc7cdfa920707fc8f5553f81014e5e3 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 18 Jun 2014 13:47:36 +0200 Subject: [PATCH] vaapidecode: parse source data until a frame is obtained. Parse any pending data until a complete frame is obtained. This is a memory optimization to avoid expansion of video packets stuffed into the GstAdapter, and a fix to EOS condition to detect there is actually pending data that needs to be decoded, and subsequently output. https://bugzilla.gnome.org/show_bug.cgi?id=731831 --- gst/vaapi/gstvaapidecode.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index aef4864..2d2e319 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -54,6 +54,8 @@ #define GST_PLUGIN_NAME "vaapidecode" #define GST_PLUGIN_DESC "A VA-API based video decoder" +#define GST_VAAPI_DECODE_FLOW_PARSE_DATA GST_FLOW_CUSTOM_SUCCESS_2 + GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapidecode); #define GST_CAT_DEFAULT gst_debug_vaapidecode @@ -785,7 +787,7 @@ gst_vaapidecode_set_format(GstVideoDecoder *vdec, GstVideoCodecState *state) } static GstFlowReturn -gst_vaapidecode_parse(GstVideoDecoder *vdec, +gst_vaapidecode_parse_frame(GstVideoDecoder *vdec, GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos) { GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec); @@ -808,7 +810,7 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec, decode->current_frame_size = 0; } else - ret = GST_FLOW_OK; + ret = GST_VAAPI_DECODE_FLOW_PARSE_DATA; break; case GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: ret = GST_VIDEO_DECODER_FLOW_NEED_DATA; @@ -829,6 +831,18 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec, return ret; } +static GstFlowReturn +gst_vaapidecode_parse(GstVideoDecoder *vdec, + GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos) +{ + GstFlowReturn ret; + + do { + ret = gst_vaapidecode_parse_frame(vdec, frame, adapter, at_eos); + } while (ret == GST_VAAPI_DECODE_FLOW_PARSE_DATA); + return ret; +} + static GstStateChangeReturn gst_vaapidecode_change_state (GstElement * element, GstStateChange transition) { -- 2.7.4