Skip to content

JPEG-XL: utilize internal profile for lossy export

Rasyuqa A H (Kampidh) requested to merge rasyuqaa/krita:rasyuqaa/jpegxl into master

Another attempt to use uses_original_profile = JXL_FALSE to reflect closer how libjxl did lossy encoding while maintaining color profile.

This will slice the bitrate further down on a similar quality setting (almost half the filesize at same setting with uint8/16 depths!).

Using JXL internal profile also improves lossy quality a bit, for example in float / HDR depths with extreme contrasts:

32bit-comparison

(That ringing comes from a border on bright highlights, in this example with white values > 40.0 in f32 depth)

However, this may break roundtrip on few color profiles, as the JXL internal profile can be used reliably with CICP values only (including custom CICP values). libjxl does have an ability to parse few ICC profiles, but on non-standard (custom) profiles it got converted to sRGB instead. So we need to pass the custom CICP values in order to maintain the color profile, especially on wide gamuts. ICC is still conserved though in non-matrix profiles and lossless export, using original profile again.

Also, libjxl accepts custom gamma input as inverted (1/g) instead. So I rewrite some gamma values on JXL export and import.

And I also rewrites the quality calculation to closely represent libjxl, with Quality 90 equals distance 1.0 for default. In my DSSIM tests, this results in a closer curve to jpeg export:

DSSIM_Result_Comparison_-_Krita_Export

Test Plan

Export lossy JXL files with different profiles (preferably with HDR images as well).

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

Merge request reports