Skip to content

Conversation

@0fbcb238c0
Copy link

This PR adds a JPEG XL encoder and an option to select the image format used in screenshot capture.
The user can choose between AVIF (default) and JXL via the --screenshot-format parameter.

A JXL decoder was recently included into chromium and will land in stable in a few weeks.
Mozilla is working on including the same JXL decoder into Firefox.
Windows, macOS and Linux all have support for JXL.

JXL allows for the same HDR capture as AVIF, while being faster to encode and offering greater density.

I have previously compared AVIF to JXL in #1525.
In gamescope JXL encode at effort 2 is 2-4 times faster than AVIF.
At this effort it results in smaller filesizes and is still faster than AVIF, which uses AVIF_SPEED_FASTEST.
Theoretically, since JXL is faster and denser than PNG as well, JXL would be able to replace both entirely in gamescope at some point in the future.

Similar to AVIF, the JXL will always be 10 bit and lossless.
JXL also supports higher bit depths than AVIF, making scRGB 16 bit float capture theoretically possible.

A small selection of games I've compared AVIF and JXL in (1920x1080):

Deep Rock Galactic

AVIF
373 ms
330 ms
311 ms
261 ms
370 ms
Total file size: 17.8 MiB

JXL
84 ms
76 ms
78 ms
58 ms
79 ms
Total file size: 12.9 MiB

Factorio

AVIF
427 ms
402 ms
485 ms
448 ms
478 ms
Total file size: 27,6 MiB

JXL
113 ms
109 ms
104 ms
110 ms
106 ms
Total file size: 17,7 MiB

Holocure

AVIF
268 ms
208 ms
194 ms
141 ms
239 ms
Total file size: 10.6 MiB

JXL
95 ms
95 ms
63 ms
61 ms
59 ms
Total file size: 1.9 MiB

To get the encode time I measured from start of the encoder to after the file is written. This code is still included at the moment, but can be removed.
The comments can be removed later, I just added them to explain some of the new code.

@goodusername123
Copy link

Maybe it would make sense to make JXL the default since it seems to do better on all metrics (size and speed)? If Microsoft is able to get away with making the only HDR screenshot format on Windows be JXR which is a format that has wayyy less support across software compared to AVIF and JXL despite being around for much longer then I personally see no widespread issue from making JXL the default here, Though I guess in the end that's up to the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants