Alex313031 / Mercury

Firefox fork with compiler optimizations and patches from Librewolf, Waterfox, and GNU IceCat.
https://thorium.rocks/mercury
Mozilla Public License 2.0
1.16k stars 25 forks source link

High-dynamic-range JXL images reinterpret-rendered as sRGB #51

Closed Traneptora closed 1 month ago

Traneptora commented 11 months ago

Consider the following image: https://people.csail.mit.edu/ericchan/hdr/jxl_images/20140606_102418_IMGP0297.jxl

This image is an HDR image tagged with BT.2100 primaries and PQ transfer. Mercury appears to be requesting BT.2100/PQ pixel data from libjxl, and then subsequently rendering that pixel data as though it were sRGB pixel data, which is incorrect. My monitor is SDR/sRGB.

Possible solutions: (1) Request BT.2100/PQ and then send it through the color management engine as BT.2100/PQ (2) Request sRGB from libjxl anyway, if sRGB needs to be the final target.

Somewhere along the line, HDR pixel data is being requested from libjxl and then it's being treated as though it were sRGB. You can do this explicitly by decoding the image with djxl via:

djxl 20140606_102418_IMGP0297.jxl --color_space=RGB_D65_202_Rel_PeQ djxl.png

and then use a utility like tweakpng or umbrielpng to strip the cICP chunk and replace it with an sRGB chunk.

Then, if you view the sRGB-tagged image in an image viewer, you can see that it looks exactly like the JXL file does when displayed via mercury, which means this is the problem that's occurring in the render pipeline somewhere.

gz83 commented 11 months ago

Thank you for reporting this issue. We will try to investigate this issue. We also recommend that you report this issue to upstream.

@Traneptora

Traneptora commented 11 months ago

I won't be able to report it upstream because Firefox doesn't support JXL. Mercury relies on unmerged patches that are on mozilla's bug tracker to support it.