I'm taking captures from the PWC webcam driver and converting them to
jpeg. PWC produces frames in YUV420P, which I then decode to RGB and
then run through the standard jpeglib. Just include jpeglib.h and link
with -ljpeg. Of course your YUV422P requires different decoding, but
the same idea applies.
And don't do this in kernel space. "If it can be done in userspace
efficiently it should be done in userspace" - Linus.
JSAMPROW row_ptr[1];
struct jpeg_compress_struct cjpeg;
struct jpeg_error_mgr jerr;
char line[width * 3];
int x, y;
char *Y_ptr, *U_ptr, *V_ptr;
cjpeg.err = jpeg_std_error(&jerr);
jpeg_create_compress (&cjpeg);
cjpeg.image_width = width;
cjpeg.image_height = height;
cjpeg.input_components = 3;
cjpeg.in_color_space = JCS_YCbCr;
jpeg_set_defaults(&cjpeg);
jpeg_set_quality(&cjpeg, quality, TRUE);
cjpeg.dct_method = JDCT_FASTEST;
jpeg_mem_dest(&cjpeg);
jpeg_start_compress(&cjpeg, TRUE);
row_ptr[0] = line;
Y_ptr = buf; //array of the Y values
U_ptr = Y_ptr + height * width; //array of the U values
V_ptr = U_ptr + height * width / 4; //array of the V values
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
line[x*3] = Y_ptr[y*width + x]; //Y
line[x*3 +1] = U_ptr[y/2 * width/2 + x/2]; //U
line[x*3 +2] = V_ptr[y/2 * width/2 + x/2]; //V
}
jpeg_write_scanlines (&cjpeg, row_ptr, 1);
}
jpeg_finish_compress (&cjpeg);
luca_ing@xxxxxxxxx wrote:
Hello, i am searching for a jpeg decompressor ( better someone who wants to write it :-) ) to include in my kernel driver for a webcam/chip which supports standard jpeg compression with yuv422/0 planar 8/16 bit encoding, non-interleaved scan.
I found a jpeg decompression function in the kernel sources (linunx/drivers/video/fb-jpeg.c) but it seems to decode only encoded yuv411 format.
I am not an expert about j pegs and, before studying the whole standard to write a jpeg decompressor by myself, i would like to have it in a easier way.
Any ideas? (Exact vendor specifications about how the chip does the compression can be found here: go.lamarinapunto.com , download section)
Thanks
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/video4linux-list