mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
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.
This commit is contained in:
parent
41ed5c0266
commit
d279e12c8f
1 changed files with 8 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue