diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2009-04-23 13:33:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:55 -0400 |
commit | 59746e1390835ce889e56fa4e792019462465623 (patch) | |
tree | f87fb8b9294899d472949bff79d6ed4b4a53f61c /drivers | |
parent | ed47119fb7c7890605379b23180d1b09717b6b5d (diff) |
V4L/DVB (11714): gspca - spca500 and sunplus: Change the 0x00 insertion mechanism.
The new mechanism does not use any temporary buffer.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/spca500.c | 33 | ||||
-rw-r--r-- | drivers/media/video/gspca/sunplus.c | 33 |
2 files changed, 26 insertions, 40 deletions
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index 6f38fa6d86b6..8806b2ff82be 100644 --- a/drivers/media/video/gspca/spca500.c +++ b/drivers/media/video/gspca/spca500.c | |||
@@ -32,9 +32,6 @@ MODULE_LICENSE("GPL"); | |||
32 | struct sd { | 32 | struct sd { |
33 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 33 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
34 | 34 | ||
35 | __u8 packet[ISO_MAX_SIZE + 128]; | ||
36 | /* !! no more than 128 ff in an ISO packet */ | ||
37 | |||
38 | unsigned char brightness; | 35 | unsigned char brightness; |
39 | unsigned char contrast; | 36 | unsigned char contrast; |
40 | unsigned char colors; | 37 | unsigned char colors; |
@@ -906,7 +903,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
906 | { | 903 | { |
907 | struct sd *sd = (struct sd *) gspca_dev; | 904 | struct sd *sd = (struct sd *) gspca_dev; |
908 | int i; | 905 | int i; |
909 | __u8 *s, *d; | ||
910 | static __u8 ffd9[] = {0xff, 0xd9}; | 906 | static __u8 ffd9[] = {0xff, 0xd9}; |
911 | 907 | ||
912 | /* frames are jpeg 4.1.1 without 0xff escape */ | 908 | /* frames are jpeg 4.1.1 without 0xff escape */ |
@@ -930,22 +926,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
930 | } | 926 | } |
931 | 927 | ||
932 | /* add 0x00 after 0xff */ | 928 | /* add 0x00 after 0xff */ |
933 | for (i = len; --i >= 0; ) | 929 | i = 0; |
934 | if (data[i] == 0xff) | 930 | do { |
935 | break; | 931 | if (data[i] == 0xff) { |
936 | if (i < 0) { /* no 0xff */ | 932 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
937 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 933 | data, i + 1); |
938 | return; | 934 | len -= i; |
939 | } | 935 | data += i; |
940 | s = data; | 936 | *data = 0x00; |
941 | d = sd->packet; | 937 | i = 0; |
942 | for (i = 0; i < len; i++) { | 938 | } |
943 | *d++ = *s++; | 939 | i++; |
944 | if (s[-1] == 0xff) | 940 | } while (i < len); |
945 | *d++ = 0x00; | 941 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
946 | } | ||
947 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
948 | sd->packet, d - sd->packet); | ||
949 | } | 942 | } |
950 | 943 | ||
951 | static void setbrightness(struct gspca_dev *gspca_dev) | 944 | static void setbrightness(struct gspca_dev *gspca_dev) |
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c index c2b8c10c075a..9623f294bdac 100644 --- a/drivers/media/video/gspca/sunplus.c +++ b/drivers/media/video/gspca/sunplus.c | |||
@@ -32,9 +32,6 @@ MODULE_LICENSE("GPL"); | |||
32 | struct sd { | 32 | struct sd { |
33 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 33 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
34 | 34 | ||
35 | __u8 packet[ISO_MAX_SIZE + 128]; | ||
36 | /* !! no more than 128 ff in an ISO packet */ | ||
37 | |||
38 | unsigned char brightness; | 35 | unsigned char brightness; |
39 | unsigned char contrast; | 36 | unsigned char contrast; |
40 | unsigned char colors; | 37 | unsigned char colors; |
@@ -1103,7 +1100,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1103 | { | 1100 | { |
1104 | struct sd *sd = (struct sd *) gspca_dev; | 1101 | struct sd *sd = (struct sd *) gspca_dev; |
1105 | int i, sof = 0; | 1102 | int i, sof = 0; |
1106 | unsigned char *s, *d; | ||
1107 | static unsigned char ffd9[] = {0xff, 0xd9}; | 1103 | static unsigned char ffd9[] = {0xff, 0xd9}; |
1108 | 1104 | ||
1109 | /* frames are jpeg 4.1.1 without 0xff escape */ | 1105 | /* frames are jpeg 4.1.1 without 0xff escape */ |
@@ -1177,22 +1173,19 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1177 | } | 1173 | } |
1178 | 1174 | ||
1179 | /* add 0x00 after 0xff */ | 1175 | /* add 0x00 after 0xff */ |
1180 | for (i = len; --i >= 0; ) | 1176 | i = 0; |
1181 | if (data[i] == 0xff) | 1177 | do { |
1182 | break; | 1178 | if (data[i] == 0xff) { |
1183 | if (i < 0) { /* no 0xff */ | 1179 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, |
1184 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 1180 | data, i + 1); |
1185 | return; | 1181 | len -= i; |
1186 | } | 1182 | data += i; |
1187 | s = data; | 1183 | *data = 0x00; |
1188 | d = sd->packet; | 1184 | i = 0; |
1189 | for (i = 0; i < len; i++) { | 1185 | } |
1190 | *d++ = *s++; | 1186 | i++; |
1191 | if (s[-1] == 0xff) | 1187 | } while (i < len); |
1192 | *d++ = 0x00; | 1188 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
1193 | } | ||
1194 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, | ||
1195 | sd->packet, d - sd->packet); | ||
1196 | } | 1189 | } |
1197 | 1190 | ||
1198 | static void setbrightness(struct gspca_dev *gspca_dev) | 1191 | static void setbrightness(struct gspca_dev *gspca_dev) |