adapting IJG ( jpeg library ) to output decoded image to a YUV buffer directly

adapting IJG ( jpeg library ) to output decoded image to a YUV buffer directly

Hi All,
I am trying to adapt the IJG decoder sample to a DirectShow filter which outputs YV12, NV12, YUY2 etc to the renderer's input pin.

Initial quick code walkthrough :i found that the output of the jpeg decoder is to a DIB file. What changes are needed to make the core decoder library to output to a YUV buffer format of my choice ( NV12 etc.,)

files in question - djpeg.c , ....jinit_write_bmp(...)...

IPP version used -- / windows xp / intel core duo

Thanks in advance

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply


The output data for IJG sample is the RGB format. If you want to use other color spaces, you can call IPP color conversion functions to convert the RGB data to other format.(check the IPP manual, ippiman, "Image Color Conversion" part).

Attached is the sample code that decodes a JPEG files into an image buffer (RGB), which may provide some help to use IJG samples.



Downloadtext/x-c++src test.cpp490 bytes

Thanks Chao.
I just want to confirm that there is no way to avoid one more buffer-copying ( using host cpu cycles ) from RGB to some YUV foramt.

It would be nice if the decoder can write the scan lines directly to a YUV buffer


Hi Alex,

To directly get the YUV data, you can set the output color space as JCS_YCbCr, like the following code:


jpeg_stdio_src(&dinfo, file);
jpeg_read_header(&dinfo, TRUE);

dinfo.out_color_space = JCS_YCbCr;


while (dinfo.output_scanline < img->height)
jpeg_read_scanlines(&dinfo, img->data + dinfo.output_scanline, 16);



Leave a Comment

Please sign in to add a comment. Not a member? Join today