Skip to content

Add support for AV1/AVIF images

Wolthera van Hövell requested to merge wolthera/libheif-1-9-1-update into master

This requires Krita to be build with libheif 1.10 compiled libaom/rav1e/dav1d for avif support.

It adds...

  • Loading and saving to 8bit and 12bit monochrome, as well as loading 10bit monochrome.
  • Loading and saving to 12 bit rgb(a) and loading from 10bit rgb(a) images.
  • Saving color profiles.
  • Generating icc profiles on the fly with enum compatibility with the itu-t h.273 cicp.
  • Giving KoColorSpaceRegistery the ability to search for a profile based on enum values and a colorant list.
  • Loading PQ, HLG and smpte st 428 heif/avif as 32bit linear images, converted on the fly, because icc profiles cannot store these curves (the icc hdr working group seems to be considering just putting cicp inside the iccprofiles, but I am unsure how that would be interpreted).
  • HLG OOTF application options, as this needs to be applied to make the result the same as PQ, but applying it may not always be desired (working with ocio, for example).
  • converting floating point spaces to the appropriate cicp with a selection menu for which type, and dynamic checking if you can save the current image's primaries to cicp (if not, your only options are 'rec2100 pq, rec2100 hlg and clip, embed icc profile).
  • functionality in KisImportExportFilter to get various hdr related things so the UI can be adapted.
  • loading and saving avif files (needs libheif with libaom or rav1e/dav1d, warning: libaom is kinda slow and bulky).

Special thanks to Amyspark, Daniel Novomesk, and Lynx3d.

!722 (merged) contains some of the library changes necessary for this. Tiny image-saving is broken with libaom and we should warn people.

TODO

I need help with these things.

  • There's a bug with loading profiles. (https://github.com/strukturag/libheif/issues/353)
  • The CMAKE 3rd party stuff and libheif version needs to be updated... I want to delay this until the profile bug is fixed.
  • We need to figure out a way to generate profiles from an nclx config. We can do this with lcms, but I am somewhat lost on where to do that... As well, this is also affected by the profile bug.
  • We should proly use some of the test-files below to create unit tests.
  • I am also wondering if it'd make sense to give people the option to save an nclx config instead of a profile for profiles which have corresponding nclx configs, like the bt2100-pq profile.
  • How much of an issue is big/little endian going to be? Do we have code elsewhere that switches between the two?

I thought I would need maxfall and maxcll for HDR support, but it doesn't seem like libheif supports those yet (even though heif itself does want it).

Test Plan

heif files can be gotten from Nokia's repository, not all of them load, which I suspect is more related to libheif(which doesn't support frames yet) than with our plugin.

Avifs can be gotten from the av1-avif repository. Not all of them load, not sure why.

Avifs can be loaded in chrome and firefox(with image.avif.enabled flags toggled). You can try to load heif files in... gimp? macos file viewer?

There's also a test in ./plugins/impex/heif/tests/KisHeifTest which is pretty thorough.

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 Wolthera van Hövell

Merge request reports