-
Notifications
You must be signed in to change notification settings - Fork 8
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
rgb to yuv limitations, lossless avif for storage? #26
Comments
I have tried converting png to ycocg avif using ffmpeg and rav1e. Still there is some color difference.
|
Hello! There are multiple things at play here, for sure. First, rav1e doesn't support lossless mode yet. From my understanding, there is a different transform that is supposed to be used in AV1 encoding when lossless is requested, and rav1e hasn't plumbed that through. Here's the relevant rav1e issue: So for this first issue, using The second issue (as arun54321 hints at) is YUV conversion. Normal YUV conversion has a drift of ~1 codepoint when roundtripping, so lossless is out the window for it. However, by signaling a different conversion method, you can avoid this. I'm currently in the process of supporting more "interesting" CICP matrixCoefficients (see my As arun54321 suggests, one possible avenue for this is to YCgCo (CICP 8), which I haven't implemented yet, but I'd like to get added this week, and another (much worse but technically "valid") method is Identity (CICP 0), where RGB pixels are just directly jammed into the YUV planes instead of actually converting them. If I run these commands in my
As expected, If we switch to AOM (which supports the lossless transform), I think using CICP0 (Identity) is as far from "best practices" as you can go, as AV1 encoders are definitely going to make all kinds of assumptions about the Y channel actually being luma and the other channels making up the chroma, but YCgCo (CICP 8) might end up being the sweet spot for this. I could even see emitting helpful warnings in You should see some new matrixCoeffs code coming in at some point this week to libavif, and perhaps we can finally pin down some nice lossless recipes for people. I'll leave this GitHub Issue open so we have a place to chat about it. |
Oops, I didn't realize this was the colorist repo; my comments about the |
Thanks. This works very well. |
I hope you read my whole message; this will make very inefficient encodes as you are not actually handing YUV data to the AV1 encoders. I would wait for other implemented matrix coefficients before deciding on a recipe. we don't really know what assumptions other AV1 decoders are going to have. |
How much is the size difference when you encode GBR? |
EDIT: please ignore this comment. I was using master branch. The compression ratio is not good on identity branch. |
They certainly shouldn't be identical in file size. Are you sure you are running the correct branch of code? |
With avif now supported by Firefox and Chrome, the format becomes more relevant. Are there any news on how to do actual lossless conversion? This is the one point webp is currently better at (and might be still better at, even after solvign the yuv/rgb problem on av1's encoder sides). |
Lossless SRGB can be easily done now with
If you aren't trying to do wild ICC-abusing HDR tricks with AVIF, I recommend just using avifenc over colorist. It will be much more supported in the future. |
As a note, lossless is easy to do now and correct, but don't expect large gains over other lossless formats. AV1 encoders aren't currently optimizing for lossless, unfortunately. Maybe we will see gains in the future of the encoder authors make it a priority. |
@joedrago Out of curiosity (sorry if this is off topic) but what is the main difference between From how I understand the tools there is none. |
It is a question of scope and standards, honestly.
Maybe the simplest answer is one of support. |
I used
colorist convert 1.png 2.avif --quantizer 0,0
and converted back and there seems to be rounding errors as the image isn't the same?
I suspect it is the limitations of rgb24 to yuv444p. I was planning to use only for archival... is it possible to convert to YCoCg24 so that yuv444p -> rgb24 conversion can be lossless?...
The text was updated successfully, but these errors were encountered: