diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2016-10-29 11:17:38 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-11-01 20:33:56 +0200 |
commit | 2e278aeb7128e8732f5324ab8c8b22a47950c80a (patch) | |
tree | a99bc364b5493cb178235e82d56736bfde6e06f7 | |
parent | 287645c2d7de8d1fa0c4753b479375c48c14709a (diff) |
baseparse: fix draining with less data than min frame size available
baseparse would pass whatever is left in the adapter to the
subclass when draining, even if it's less than the minimum
frame size required. This is bogus, baseparse should just
discard that data then. The original intention of that code
seems to have been that if we have more data available than
the minimum required we should pass all of the data available
and not just the minimum required, which does make sense, so
we'll continue to do that in the case that more data is available.
Fixes assertions in rawvideoparse on EOS after not-negotiated with
fakesrc sizetype=random ! queue ! rawvideoparse format=rgb ! appsink caps=video/x-raw,format=I420
https://bugzilla.gnome.org/show_bug.cgi?id=773666
-rw-r--r-- | libs/gst/base/gstbaseparse.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 816b7ab4b..168b81b0b 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -3184,9 +3184,17 @@ gst_base_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) av = gst_adapter_available (parse->priv->adapter); if (G_UNLIKELY (parse->priv->drain)) { - min_size = av; - GST_DEBUG_OBJECT (parse, "draining, data left: %d", min_size); - if (G_UNLIKELY (!min_size)) { + GST_DEBUG_OBJECT (parse, "draining, data left: %u, min %u", av, min_size); + /* pass all available data to subclass, not just the minimum, + * but never pass less than the minimum required to the subclass */ + if (av >= min_size) { + min_size = av; + if (G_UNLIKELY (!min_size)) + goto done; + } else if (av > 0) { + GST_DEBUG_OBJECT (parse, "draining, but not enough data available, " + "discarding %u bytes", av); + gst_adapter_clear (parse->priv->adapter); goto done; } } |