Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6764 Discussions

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

ippalex
Beginner
951 Views

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 -- 6.1.2.041 / windows xp / intel core duo

Thanks in advance
alex
0 Kudos
1 Solution
Chao_Y_Intel
Moderator
951 Views


Alex,

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.

Thanks,
Chao

View solution in original post

0 Kudos
3 Replies
Chao_Y_Intel
Moderator
952 Views


Alex,

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.

Thanks,
Chao

0 Kudos
ippalex
Beginner
951 Views

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

--alex

0 Kudos
Chao_Y_Intel
Moderator
951 Views


Hi Alex,

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

...

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

dinfo.out_color_space = JCS_YCbCr;

jpeg_start_decompress(&dinfo);


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

....


Thanks,
Chao

0 Kudos
Reply