For Programmers: Free Programming Magazines  


Home > Archive > Compression > May 2004 > How to compress YUYV with libjpeg?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to compress YUYV with libjpeg?
Daniel Haude

2004-05-12, 9:29 pm

Hello folks,

this is probably an easy one... given an image in YUYV color space (Y0 U0
Y1 V0 Y2 U2 Y3 V2... ; 8 bit Y stored for every pixel and 8bit U/V stored
for every other pixel), is there a straightforward way to store it using
libjpeg, or do I first have to create full 24bit YUV triplets before
passing the scanlines into libjpeg? I couldn't really understand this from
the libjpeg doc, and my experiments so far have yielded a lot of garbage.

I have successfully dealt with RGB data using libjpeg, but since I
understand that libjpeg uses YUV (or YCbCr) internally, I thought I might
want to skip the redundant color space conversions.

Thanks,
**Daniel


--
"With me is nothing wrong! And with you?" (from r.a.m.p)
Guido Vollbeding

2004-05-12, 9:29 pm

Daniel Haude wrote:
>
> this is probably an easy one... given an image in YUYV color space (Y0 U0
> Y1 V0 Y2 U2 Y3 V2... ; 8 bit Y stored for every pixel and 8bit U/V stored
> for every other pixel), is there a straightforward way to store it using
> libjpeg, or do I first have to create full 24bit YUV triplets before
> passing the scanlines into libjpeg? I couldn't really understand this from
> the libjpeg doc, and my experiments so far have yielded a lot of garbage.
>
> I have successfully dealt with RGB data using libjpeg, but since I
> understand that libjpeg uses YUV (or YCbCr) internally, I thought I might
> want to skip the redundant color space conversions.


Read the section "Raw (downsampled) image data" in libjpeg doc.
Problem is you not only want to bypass color conversion, but also
color downsampling, since your input format already has downsampled
color, though in weired component order. Particularly, your input
format has 2x1 horizontal downsapled color in JPEG notation (4:2:2
in video notation).
In order to pass this format unaltered through JPEG compression,
you have to supply to the JPEG library the image in JSAMPIMAGE/JSAMPARRAY
format. That is, you have to supply each of the Y, U, and V components
in *separate* sample arrays! libjpeg doc describes this in the
"Raw (downsampled) image data" section.

Regards
Guido
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com