AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.53k stars 195 forks source link

Noticeable color shift #2121

Open hiforrest opened 5 months ago

hiforrest commented 5 months ago

The avif image compression resulted in a noticeable color shift, with the cyan area in the top-left area becoming darker. This issue isn't just a one-off; I've tested multiple images, and they all show a clear discrepancy in colors.

Command: avifenc.exe "SP_2024-04-17_18-42-48.png" "SP_2024-04-17_18-42-48.avif" --min 15 --max 20

Windows 10 libavif v1.0.4

https://github.com/AOMediaCodec/libavif/assets/2953848/d1de19de-336b-447a-8fa3-48144e4caac1

Image files: avif before after.zip

As a reference, here is a compressed version using convertio.co. This version does not have obvious color deviation. SP_2024-04-17_18-42-48_1(by web).zip

vrabaud commented 5 months ago

Though I see the color shit in your video, I do not see it in Chrome. Can you please try in your favorite browser to see if the color shift is there too? Thx.

hiforrest commented 5 months ago

hi @vrabaud, Thank you for paying attention to this issue. I was playing around with the Edge browser and decided to compare how an avif format and its original png version looked across different apps - Edge, Windows Photo Viewer, and Directory Opus. I made a video to show what I found: the colors match perfectly in Edge, but not in the other apps. It's pretty strange.

This makes me wonder why avif images look different depending on the app use. I'm really hoping to get that consistent, true-to-color experience across the board, like what Chrome offers. Got any ideas or fixes? Would love to hear your thoughts!

https://github.com/AOMediaCodec/libavif/assets/2953848/31d8e8fb-5c27-4452-b8cf-6222d0767748

tongyuantongyu commented 4 months ago

The color shift is due to Windows's decoder using BT709 matrix, despite signaled as BT601 in file. If you add --cicp 1/13/1 the color will match. This is a bug in Windows AVIF decoder.

Note that on some old Windows version, the AVIF decoder also ignores the color range and always use limited range.

The web version is using RGB colorspace so is not affected.

hiforrest commented 4 months ago

@tongyuantongyu,

Wow, you're an absolute legend! 🙌 You explained the color shift and delivered the solution effortlessly. Thanks a lot for clarifying this tricky color shift issue.

wantehchang commented 4 months ago

@tongyuantongyu Hi Yuan. Have you reported the bug in the Windows AVIF decoder to Microsoft? If not, I can try to report it.

tongyuantongyu commented 4 months ago

@wantehchang I didn't report myself, but there's a report: https://aka.ms/AAqboe7 that likely refers to this bug. It may help if you are able to report it to the team in Microsoft more directly.