libv4l: skip false Pixart markers
authorMárton Németh <nm127@freemail.hu>
Tue, 2 Feb 2010 10:23:03 +0000 (11:23 +0100)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 24 Feb 2010 00:44:40 +0000 (21:44 -0300)
The byte sequence 0xff, 0xff, 0xff 0xff is not a real marker to skip, instead
it is one byte from the image and the following three 0xff bytes might belong
to a real marker. Modify pixart_fill_nbits() macro to pass the first 0xff byte
as an image data.

Priority: normal

Signed-off-by: Márton Németh <nm127@freemail.hu>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
lib/ChangeLog
lib/libv4lconvert/tinyjpeg.c

index e2654f6..4d7e5ad 100644 (file)
@@ -1,6 +1,8 @@
 libv4l-0.6.5
 ------------
 * Add more laptop models to the upside down devices table
+* Small fix to pixart jpeg decoding, this fixes the occasional corrupt
+  frame we used to get (Németh Márton)
 
 libv4l-0.6.4
 ------------
index 43cb54c..8103ab4 100644 (file)
@@ -339,10 +339,15 @@ do { \
            } \
            break; \
          case 0xff: \
-           if (stream[1] == 0xff && (stream[2] < 7 || stream[2] == 0xff)) { \
-             stream += 3; \
-             c = *stream++; \
-             break; \
+           if (stream[1] == 0xff) { \
+               if (stream[2] < 7) { \
+                   stream += 3; \
+                   c = *stream++; \
+                   break; \
+               } else if (stream[2] == 0xff) { \
+                   /* four 0xff in a row: the first belongs to the image data */ \
+                   break; \
+               }\
            } \
            /* Error fall through */ \
          default: \