Hi all,

I am trying to implement (if possible ?) a lossless transform from a YCbCr 
4:2:2 raw input into JPEG.

I've written a quick sample application:

* 
https://github.com/malaterre/PublicRep/blob/master/dicom/yuv2jpg/yuv2jpg.cxx

Basically:

```
cinfo->in_color_space = JCS_YCbCr; /* colorspace of input image, 24bits */
jpeg_set_defaults(cinfo);
jpeg_set_quality(cinfo, 100, TRUE /* limit to baseline-JPEG values */);
``` 

I also made sure that chroma subsampling was setup to reflect input:

```
cinfo->comp_info[0].h_samp_factor = 2;
cinfo->comp_info[0].v_samp_factor = 1;
cinfo->comp_info[1].h_samp_factor = 1;
cinfo->comp_info[1].v_samp_factor = 1;
cinfo->comp_info[2].h_samp_factor = 1;
cinfo->comp_info[2].v_samp_factor = 1;
```

The above code seems to be giving the correct output for simple inputs (*), 
but I see difference at the bit-level when re-decompressing back to YCbCr 
4:2:2 raw for real-life examples.

Could someone confirm that:
1. My code properly skips color transform step,
2. Discrete cosine transform + quantization step are stable (feeding the 
output of this step back as input should produce the same output).

Thanks
-Mathieu

(*)
% convert -size 512x512 -depth 8 xc:#000000 black.ppm
% convert -size 512x512 -depth 8 xc:#ffffff white.ppm 
% convert -size 512x512 -depth 8 xc:#ff0000 red.ppm 
% convert -size 512x512 -depth 8 xc:#00ff00 green.ppm 
% convert -size 512x512 -depth 8 xc:#0000ff blue.ppm 
% for f in *.ppm; do cjpeg -sample 2x1,1x1,1x1 -optimize -quality 100 
-outfile $f.jpg $f; done

-- 
You received this message because you are subscribed to the Google Groups 
"libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to libjpeg-turbo-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/libjpeg-turbo-users/d2cffd89-1bc2-4790-9e9f-24faf62af87dn%40googlegroups.com.

Reply via email to