summaryrefslogtreecommitdiff
path: root/gst/videoparsers
diff options
context:
space:
mode:
authorVineeth T M <vineeth.tm@samsung.com>2014-11-13 15:56:07 +0530
committerLuis de Bethencourt <luis.bg@samsung.com>2015-01-07 16:32:49 +0000
commit59e7f0597d1cc524174e847de7b91407922304c8 (patch)
tree3b173111191b71f4173a394346d176d8f32d3f87 /gst/videoparsers
parente7c6eb6326b4f4fe9e4019c658e0b3d888dd5cb9 (diff)
downloadgstreamer-plugins-bad-59e7f0597d1cc524174e847de7b91407922304c8.tar.gz
pngparse: improve parsing of the image
Everytime a buffer is being provided from baseparse, we are parsing all the data from the beginning. But since we would have already parsed some of the data in the previous iterations, it doesnt make much sense to keep parsing the same everytime. Hence skipping the data which is already read in previous iterations to improve the parsing performance. https://bugzilla.gnome.org/show_bug.cgi?id=740058
Diffstat (limited to 'gst/videoparsers')
-rw-r--r--gst/videoparsers/gstpngparse.c9
-rw-r--r--gst/videoparsers/gstpngparse.h1
2 files changed, 9 insertions, 1 deletions
diff --git a/gst/videoparsers/gstpngparse.c b/gst/videoparsers/gstpngparse.c
index c4dbe3cf5..86fd9bcdb 100644
--- a/gst/videoparsers/gstpngparse.c
+++ b/gst/videoparsers/gstpngparse.c
@@ -130,7 +130,7 @@ gst_png_parse_handle_frame (GstBaseParse * parse,
GstByteReader reader;
GstFlowReturn ret = GST_FLOW_OK;
guint64 signature;
- guint width = 0, height = 0;
+ static guint width = 0, height = 0;
gst_buffer_map (frame->buffer, &map, GST_MAP_READ);
gst_byte_reader_init (&reader, map.data, map.size);
@@ -165,6 +165,8 @@ gst_png_parse_handle_frame (GstBaseParse * parse,
}
gst_byte_reader_skip (&reader, 8);
+ /* Skipping the data read in previous iterations */
+ gst_byte_reader_skip (&reader, pngparse->skip_length);
for (;;) {
guint32 length;
@@ -191,6 +193,8 @@ gst_png_parse_handle_frame (GstBaseParse * parse,
if (!gst_byte_reader_skip (&reader, length + 4))
goto beach;
+ /* We have already read the data till now. Hence skip the read data next time we enter handle_frame() */
+ pngparse->skip_length = gst_byte_reader_get_pos (&reader) + length + 4;
if (code == GST_MAKE_FOURCC ('I', 'E', 'N', 'D')) {
/* the start code and at least 2 empty frames (IHDR and IEND) */
@@ -234,6 +238,9 @@ gst_png_parse_handle_frame (GstBaseParse * parse,
gst_buffer_unmap (frame->buffer, &map);
+ pngparse->skip_length = 0;
+ width = 0;
+ height = 0;
return gst_base_parse_finish_frame (parse, frame,
gst_byte_reader_get_pos (&reader));
}
diff --git a/gst/videoparsers/gstpngparse.h b/gst/videoparsers/gstpngparse.h
index 35744813c..2142358b4 100644
--- a/gst/videoparsers/gstpngparse.h
+++ b/gst/videoparsers/gstpngparse.h
@@ -49,6 +49,7 @@ struct _GstPngParse
guint width;
guint height;
+ guint32 skip_length;
gboolean sent_codec_tag;
};