Hey,

It was indeed doable, by hand. I've achieved roundtrip loading of YCbCr + JPEG TIFFs with the help of libjpeg-turbo.

The first step is to enable the library to prime the decoder with the tables stored in TIFFTAG_JPEGTABLES:

https://github.com/libjpeg-turbo/libjpeg-turbo/pull/605

The second step was to parse each raw strip into separate planes, massage them to match the lossless YCbCr sample format, and then treat the strip as a standard subsampled YCbCr. I've pushed the latter as part of this MR to Krita:

https://invent.kde.org/graphics/krita/-/merge_requests/1478

(check out the commit entitled "tiff: support YCbCr + JPEG imports")

amyspark

On 10/06/2022 17:37, Bob Friesenhahn wrote:
On Fri, 10 Jun 2022, L. E. Segovia via Tiff wrote:

That implies a conversion to RGB. We need the fully decoded, uncompressed YCbCr data, hence why I've been investigating how to make it happen.

That would mean that you would need to learn the sampling factors used for the JPEG, retrieve the uncompressed strips (or maybe compressed is necessary?) from libtiff, and then figure out how to decode it based on the sampling factors.  I assume it is possible.

Please let me know when I you figure out how since I am interested. :-)

In libtiff there is tools/rgb2ycbcr.c, which seems to be test code for testing writing YCbCr files.  It claims to support JPEG.

Bob

--
amyspark 🌸 https://www.amyspark.me
_______________________________________________
Tiff mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/tiff

Reply via email to