-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: HDR/color managed output #70
Comments
The My initial test branch (only supports PNG images with CICP chunks whose primaries and transfer functions are in the named list supported by the compositor, and (edit: no longer!) assumes immediate image description processing) is at mstoeckl/png-hdr. I've tested it against current KWin. CICP chunks are supported by libpng (since 1.6.45, released 2025-01-07), and by the JPEG XL and AVIF formats. In addition to the image processing issues noted above, adding full support for Also: doing color management with the background color may be complicated, both in how we specify out-of-sRGB-gamut colors and how to correctly blend non-sRGB images with alpha onto the background color. ( |
I think using libpng directly is reasonable (and we can always keep the current pipeline as a fallback). I'm not sure ICC profile support is desirable, partly because the background image is not really used for color critical work, partly because Sway will not support the ICC profile part of the color-management protocol (at least initially, only Weston supports it, KWin also has no plans to support it). So I think blocking while the image description is ready is a good way forward if it allows us to avoid refactoring everything.
Probably this can be left for later.
We could maybe convert the background color from sRGB to PQ before painting it onto the buffer. This would still blend electrical values instead of optical values, but at least we wouldn't mix sRGB and PQ anymore.
This will allocate more memory and require more bandwidth to read from the image. I think I'd prefer swaybg to do more processing at startup rather than have a higher runtime cost. We could probably do the EOTF + blend + inverse EOTF per-pixel and store the final result in a 10-bit buffer? |
Now that Wayland compositors are slowly moving toward supporting color management and HDR, having
swaybg
provide color-managed buffers to the compositor will soon start to become possible. Implementing color management wouldpermit cooler wallpapersallow for better representation of a wider range of images, specifically those with saturated colors and bright spots.Swaybg would also be a decent client to test color management protocols on, because it is relatively simple and directly uses Wayland protocols. Support for specific input/output features can be added piece by piece, without needing to wait for toolkit support.
The main challenge appears to be that, at the moment, image library support for color management is weak, and support for color management would need to be added format by format; or one would need to move away from gdk_pixbuf+Cairo; a few alternatives, none particularly great, are noted in #32. On the other hand, just adding support for PNG images would probably be good enough to start.
One route to incrementally add color management is to start by adding support for image formats providing their colorspace as CICP, and to test with the very restricted color management protocol currently being used by Kwin and VK_hdr_layer. I've made a test branch that does this, for PNG formats; see mstoeckl/frog-v1 .
The branch mstoeckl/frog-v1 is based on top of the current 10-bit output support PR.
It takes as input PNG files which have the (draft) cICP chunk set, and furthermore use one of the few primary/transfer combinations from frog-color-management-v1 (i.e, BT709 or BT2020 primaries, and sRGB, gamma2.2, PQ, or linear transfer function.) Such images can be created with ffmpeg from a video or from a

.hdr
file. For example, applying the following command to one of the files from https://hdri-haven.com/ffmpeg -i input_file.hdr -vf "libplacebo=color_primaries=bt2020:color_trc=smpte2084" -pix_fmt rgba64be output_file.png
would produce an image with a cICP chunk, like the following :
Other notes:
The text was updated successfully, but these errors were encountered: