]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
[media] gspca - zc3xx: Discard the partial frames
authorJean-François Moine <moinejf@free.fr>
Mon, 24 Jan 2011 19:31:58 +0000 (16:31 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 31 Jan 2011 14:05:48 +0000 (12:05 -0200)
In some cases, some frames may not end with the JPEG end of frame.
Being not complete, they are now discarded.

Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/zc3xx.c

index cf65fb36e88f82a55f5512bcc43d59e34ca31fb0..47236a58bf335f00419fed7a2b58b3fa02e5d4d3 100644 (file)
@@ -6821,9 +6821,17 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
 {
        struct sd *sd = (struct sd *) gspca_dev;
 
-       if (data[0] == 0xff && data[1] == 0xd8) {       /* start of frame */
+       /* check the JPEG end of frame */
+       if (len >= 3
+        && data[len - 3] == 0xff && data[len - 2] == 0xd9) {
+/*fixme: what does the last byte mean?*/
                gspca_frame_add(gspca_dev, LAST_PACKET,
-                                       NULL, 0);
+                                       data, len - 1);
+               return;
+       }
+
+       /* check the JPEG start of a frame */
+       if (data[0] == 0xff && data[1] == 0xd8) {
                /* put the JPEG header in the new frame */
                gspca_frame_add(gspca_dev, FIRST_PACKET,
                        sd->jpeg_hdr, JPEG_HDR_SZ);