Search code examples
floating-pointjpegjpeg-xl

JPEG-XL: Does lossless mode supports 32bits float?


I am trying to make sense of the following sentence (quote from here):

✓ Lossless up to 32 bits per channel (float or int)

My question is: can I store arbitrary 32-bit IEEE 754 single-precision floating point values in JPEG-XL ?

Starring at the reference implementation, it seems I really only have two options:

  1. 32-bit single-precision floating point values, with range 0.0-1.0
  2. 16-bit IEEE 754 half-precision floating point values

Solution

  • You can store arbitrary float values, it's just that the nominal range is 0.0 to 1.0, so outside that range you're outside the color gamut and/or brighter than the nominal maximum intensity of the colorspace signalled in the image header.

    The spec does not define how to render NaN and infinities, but other than that there is no issue representing arbitrary binary32 floats losslessly in JPEG XL.