Open 0fbcb238c0 opened 1 month ago
The poor performance of lossless AVIF has been known for years. I'm surprised it was added at all, yet alone made the only option. https://github.com/AOMediaCodec/av1-avif/issues/111
In an ideal scenario there could be JXL compression with adjustable speed and/or quality, since it excels at the high range wanted for screenshots and photos, especially in HDR.
gamescope will currently always save screenshots as lossless AVIF. While AVIF has support for HDR and mostly offers better compression than PNG, it is soundly beaten by JPEG XL (JXL) in terms of speed AND compression while also supporting HDR.
To quantify this I created two datasets and encoded them losslessly to AVIF and JXL. First set: 560 PNG screenshots, 1920x1080, sourced from over 60 games, 1182MB in size Second set: 1300 PNG screenshots, 3840x2160, sourced from over 80 games, 13421MB in size
Encoding
Used were the latest releases of the reference encoders, v0.11.0 for libjxl and v1.1.1 for libavif. Since gamescope uses AVIF_SPEED_FASTEST, which is 10, I used the fastest settings with no additional parameters for both encoders. Since writing to disk always adds a delay I also measured the encoding time if written to /tmp, a RAM disk, same as gamescope's default behaviour. I repeated each encode ten times, five for SSD, five for RAM and averaged the encoding times.
The commands to encode: AVIF:
/usr/bin/time -f "%E seconds" parallel -j 16 /usr/bin/avifenc -l --speed 10 {} DEST ::: *.png
JXL:/usr/bin/time -f "%E seconds" parallel -j 16 /usr/bin/cjxl -d 0 --effort 1 {} DEST ::: *.png
Encoding results 1920x1080
Encoding results 3840x2160