summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-09-24 16:10:45 +0200
committerTim-Philipp Müller <tim@centricular.com>2015-06-21 11:28:38 +0100
commitd279e12c8f93cf88e397f40155079fa4439e3ccc (patch)
tree374a79bd3ebdfc9ede4a888ac3ec5062b4c7b9b8
parent41ed5c0266489f7247a8f6a2fc13bb4e0c73c516 (diff)
codecparsers: jpeg: fix and optimize scan for next marker code.
Fix scan for next marker code when there is an odd number of filler (0xff) bytes before the actual marker code. Also optimize the loop to execute with fewer instructions (~10%). This fixes parsing for Spectralfan.mov.
-rw-r--r--gst-libs/gst/codecparsers/gstjpegparser.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gst-libs/gst/codecparsers/gstjpegparser.c b/gst-libs/gst/codecparsers/gstjpegparser.c
index ac1ba9a49..30c67f3ec 100644
--- a/gst-libs/gst/codecparsers/gstjpegparser.c
+++ b/gst-libs/gst/codecparsers/gstjpegparser.c
@@ -232,17 +232,16 @@ gst_jpeg_scan_for_marker_code (const guint8 * data, gsize size, guint offset)
guint i;
g_return_val_if_fail (data != NULL, -1);
- g_return_val_if_fail (size > offset, -1);
- for (i = offset; i < size - 1;) {
- if (data[i] != 0xff)
- i++;
- else {
- const guint8 v = data[i + 1];
- if (v >= 0xc0 && v <= 0xfe)
- return i;
+ i = offset + 1;
+ while (i < size) {
+ const guint8 v = data[i];
+ if (v < 0xc0)
i += 2;
- }
+ else if (v < 0xff && data[i - 1] == 0xff)
+ return i - 1;
+ else
+ i++;
}
return -1;
}