diff options
author | Jean-François Moine <moinejf@free.fr> | 2011-02-10 05:30:03 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:32:06 -0400 |
commit | dccdcccdd36bf7570967ff53411c7401b8e645d6 (patch) | |
tree | 2f16087541f52e2b694b86036e788844a2ada40a /drivers/media/video/gspca/sonixj.c | |
parent | a4a3076ffcdbcf40358edc2068aa4d9103fe0a28 (diff) |
[media] gspca - sonixj: Have the same JPEG quality for encoding and decoding
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 21f0330885dd..d465022b8022 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -63,7 +63,6 @@ struct sd { | |||
63 | #define QUALITY_MIN 60 | 63 | #define QUALITY_MIN 60 |
64 | #define QUALITY_MAX 95 | 64 | #define QUALITY_MAX 95 |
65 | #define QUALITY_DEF 80 | 65 | #define QUALITY_DEF 80 |
66 | u8 jpegqual; /* webcam quality */ | ||
67 | 66 | ||
68 | u8 reg01; | 67 | u8 reg01; |
69 | u8 reg17; | 68 | u8 reg17; |
@@ -1786,7 +1785,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1786 | 1785 | ||
1787 | sd->ag_cnt = -1; | 1786 | sd->ag_cnt = -1; |
1788 | sd->quality = QUALITY_DEF; | 1787 | sd->quality = QUALITY_DEF; |
1789 | sd->jpegqual = 80; | ||
1790 | 1788 | ||
1791 | return 0; | 1789 | return 0; |
1792 | } | 1790 | } |
@@ -2273,18 +2271,12 @@ static void setfreq(struct gspca_dev *gspca_dev) | |||
2273 | static void setjpegqual(struct gspca_dev *gspca_dev) | 2271 | static void setjpegqual(struct gspca_dev *gspca_dev) |
2274 | { | 2272 | { |
2275 | struct sd *sd = (struct sd *) gspca_dev; | 2273 | struct sd *sd = (struct sd *) gspca_dev; |
2276 | int i, sc; | ||
2277 | 2274 | ||
2278 | if (sd->jpegqual < 50) | 2275 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); |
2279 | sc = 5000 / sd->jpegqual; | ||
2280 | else | ||
2281 | sc = 200 - sd->jpegqual * 2; | ||
2282 | #if USB_BUF_SZ < 64 | 2276 | #if USB_BUF_SZ < 64 |
2283 | #error "No room enough in usb_buf for quantization table" | 2277 | #error "No room enough in usb_buf for quantization table" |
2284 | #endif | 2278 | #endif |
2285 | for (i = 0; i < 64; i++) | 2279 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64); |
2286 | gspca_dev->usb_buf[i] = | ||
2287 | (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100; | ||
2288 | usb_control_msg(gspca_dev->dev, | 2280 | usb_control_msg(gspca_dev->dev, |
2289 | usb_sndctrlpipe(gspca_dev->dev, 0), | 2281 | usb_sndctrlpipe(gspca_dev->dev, 0), |
2290 | 0x08, | 2282 | 0x08, |
@@ -2292,9 +2284,7 @@ static void setjpegqual(struct gspca_dev *gspca_dev) | |||
2292 | 0x0100, 0, | 2284 | 0x0100, 0, |
2293 | gspca_dev->usb_buf, 64, | 2285 | gspca_dev->usb_buf, 64, |
2294 | 500); | 2286 | 500); |
2295 | for (i = 0; i < 64; i++) | 2287 | memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64); |
2296 | gspca_dev->usb_buf[i] = | ||
2297 | (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100; | ||
2298 | usb_control_msg(gspca_dev->dev, | 2288 | usb_control_msg(gspca_dev->dev, |
2299 | usb_sndctrlpipe(gspca_dev->dev, 0), | 2289 | usb_sndctrlpipe(gspca_dev->dev, 0), |
2300 | 0x08, | 2290 | 0x08, |
@@ -2340,7 +2330,6 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2340 | /* create the JPEG header */ | 2330 | /* create the JPEG header */ |
2341 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, | 2331 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, |
2342 | 0x21); /* JPEG 422 */ | 2332 | 0x21); /* JPEG 422 */ |
2343 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | ||
2344 | 2333 | ||
2345 | /* initialize the bridge */ | 2334 | /* initialize the bridge */ |
2346 | sn9c1xx = sn_tb[sd->sensor]; | 2335 | sn9c1xx = sn_tb[sd->sensor]; |
@@ -2901,7 +2890,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev, | |||
2901 | else | 2890 | else |
2902 | sd->quality = jcomp->quality; | 2891 | sd->quality = jcomp->quality; |
2903 | if (gspca_dev->streaming) | 2892 | if (gspca_dev->streaming) |
2904 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | 2893 | setjpegqual(gspca_dev); |
2905 | return 0; | 2894 | return 0; |
2906 | } | 2895 | } |
2907 | 2896 | ||