460380 Support HDR in the JPEG XL plugin
This MR adds support for HDR in the JPEG XL plugin. Like AVIF, JPEG XL has two ways of embedding a colour profile:
- CICP values
- ICC profile blob
of which only the former is recognised by Chrome as HDR directly. And even then, only PQ, HLG and linear are recognised as valid transfer curves 1.
Additionally, I found three bugs in Krita:
-
(from)NormalisedChannelValues
is arbitrarily clamping the range to SDR, which means all exported images (in particular HLG) are in fact being imported/exported as SDR (fixed here) - the Little CMS machinery doesn't recognise linear gamma profiles, assigning
TRC_UNDEFINED
to them (not fixed yet) - the transfer curves are mistakenly applied across all the channels, including (erroneously) alpha
Bugs found so far
- Chromium bug re: SMPTE 428 https://bugs.chromium.org/p/chromium/issues/detail?id=1363685
- LcmsProfileStorage bug: https://bugs.kde.org/show_bug.cgi?id=459117
- JPEG XL data type conversion bug: https://github.com/libjxl/libjxl/issues/1745
Test Plan
Build Krita. Open JPEG XL images such as the ones in https://people.csail.mit.edu/ericchan/hdr/hdr-jxl.php and export them using the different options.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
Edited by Amy spark