image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.87k stars 602 forks source link

10-bit avif support #2232

Open FlyingWombat opened 4 months ago

FlyingWombat commented 4 months ago

Please support 10-bit avif. 10-bit is the standard for AV1, because it offers significant BD-rate gain over 8-bit at the expense of marginally higher en/decoding complexity. Everything in my library is 10-bit -- both downloaded from other sources and what I've encoded myself.

A more specific use case I have for this is using ssimulacra2_rs, which uses image-rs for decoding, to help evaluate encoding quality.

Another use case is wpaperd, which uses image-rs for decoding.

1504 is related, but is more about handling improperly formatted avif files.

kornelski commented 4 months ago

Indeed, AVIF works better with more than 8 bits. The quality improvement is significant enough that it makes up for extra computation (you'd need even slower encoding options to achieve the same quality in 8 bits).

fintelia commented 4 months ago

This would be a welcome improvement. The key changes needed would be to have the AVIF decoder report the color type as ColorType::Rgba16 for 10-bit and 12-bit files, and then have the read_image method expand each color component to 16-bits when writing to the output.