Skip to content

Commit

Permalink
[media] gspca - sonixj: Have the same JPEG quality for encoding and d…
Browse files Browse the repository at this point in the history
…ecoding

Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jean-François Moine authored and Mauro Carvalho Chehab committed Mar 21, 2011
1 parent a4a3076 commit dccdccc
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions drivers/media/video/gspca/sonixj.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ struct sd {
#define QUALITY_MIN 60
#define QUALITY_MAX 95
#define QUALITY_DEF 80
u8 jpegqual; /* webcam quality */

u8 reg01;
u8 reg17;
Expand Down Expand Up @@ -1786,7 +1785,6 @@ static int sd_config(struct gspca_dev *gspca_dev,

sd->ag_cnt = -1;
sd->quality = QUALITY_DEF;
sd->jpegqual = 80;

return 0;
}
Expand Down Expand Up @@ -2273,28 +2271,20 @@ static void setfreq(struct gspca_dev *gspca_dev)
static void setjpegqual(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
int i, sc;

if (sd->jpegqual < 50)
sc = 5000 / sd->jpegqual;
else
sc = 200 - sd->jpegqual * 2;
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
#if USB_BUF_SZ < 64
#error "No room enough in usb_buf for quantization table"
#endif
for (i = 0; i < 64; i++)
gspca_dev->usb_buf[i] =
(jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64);
usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0),
0x08,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
0x0100, 0,
gspca_dev->usb_buf, 64,
500);
for (i = 0; i < 64; i++)
gspca_dev->usb_buf[i] =
(jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
memcpy(gspca_dev->usb_buf, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64);
usb_control_msg(gspca_dev->dev,
usb_sndctrlpipe(gspca_dev->dev, 0),
0x08,
Expand Down Expand Up @@ -2340,7 +2330,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
/* create the JPEG header */
jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
0x21); /* JPEG 422 */
jpeg_set_qual(sd->jpeg_hdr, sd->quality);

/* initialize the bridge */
sn9c1xx = sn_tb[sd->sensor];
Expand Down Expand Up @@ -2901,7 +2890,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev,
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
setjpegqual(gspca_dev);
return 0;
}

Expand Down

0 comments on commit dccdccc

Please sign in to comment.