From bf1979e55fc525f4e26354fa03edf9bbe41b54c1 Mon Sep 17 00:00:00 2001 From: KimTaeSoo Date: Thu, 15 Nov 2018 00:17:09 +0900 Subject: [PATCH] baseparse: Use buffer from short reads instead of pulling again baseparse internally uses a 64kb buffer for pulling data from upstream. If a 64kb pull is failing with a short read, it would previously pull again the requested size. Doing so is not only inefficient but also seems to cause problems with some elements (rawvideoparse) where the second pull would fail with EOS. Short reads are only allowed in GStreamer at EOS. Closes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/294 --- libs/gst/base/gstbaseparse.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 6b153be136..53baa1e312 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -3343,28 +3343,6 @@ gst_base_parse_pull_range (GstBaseParse * parse, guint size, return ret; } - if (gst_buffer_get_size (parse->priv->cache) >= size) { - *buffer = - gst_buffer_copy_region (parse->priv->cache, GST_BUFFER_COPY_ALL, 0, - size); - GST_BUFFER_OFFSET (*buffer) = parse->priv->offset; - return GST_FLOW_OK; - } - - /* Not possible to get enough data, try a last time with - * requesting exactly the size we need */ - gst_buffer_unref (parse->priv->cache); - parse->priv->cache = NULL; - - ret = gst_pad_pull_range (parse->sinkpad, parse->priv->offset, size, - &parse->priv->cache); - - if (ret != GST_FLOW_OK) { - GST_DEBUG_OBJECT (parse, "pull_range returned %d", ret); - *buffer = NULL; - return ret; - } - if (gst_buffer_get_size (parse->priv->cache) < size) { GST_DEBUG_OBJECT (parse, "Returning short buffer at offset %" G_GUINT64_FORMAT ": wanted %u bytes, got %" G_GSIZE_FORMAT " bytes",