Skip to content
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

avifImageRGBToYUV should set color space to default values #2099

Open
rzumer opened this issue Apr 11, 2024 · 2 comments
Open

avifImageRGBToYUV should set color space to default values #2099

rzumer opened this issue Apr 11, 2024 · 2 comments

Comments

@rzumer
Copy link

rzumer commented Apr 11, 2024

When converting RGB to YCbCr with libavif, the default color properties are known and mentioned here (sRGB with BT.601 coefficients), but those properties are not set in the AVIF image structure, so unless the user explicitly sets the color space, decoders tend to assume BT.709 and distort the colors. In my opinion libavif should set those fields since it has to make assumptions when converting from RGB anyway.

@vrabaud
Copy link
Collaborator

vrabaud commented Apr 12, 2024

Hi, according to the spec (

// (As of ISO/IEC 23000-22:2019 Amendment 2)
), leaving it as undefined is fine as it should be interpreted as BT.601.
Which decoders default to BT.709 ? They seem to not respect the spec.

@rzumer
Copy link
Author

rzumer commented Apr 12, 2024

FFmpeg libraries keep the color space parameters as unspecified instead of overriding the values to the specified defaults which I think is reasonable if conservative. Maybe it has special-case handling for color-space conversion operations from AVIF internally, but if FFmpeg is used as the decoder and another library performs the color space conversion then having special default color spaces based on the format is impractical (when input is not constrained).

In my case I only ingest files converted from RGB with libavif, so the omission feels like a trap. The encode example isn't explicit about setting the correct color space parameters when converting from RGB, and the defaults are buried in a wiki page (or spec I guess). If there are specific situations where you would not want to set color space parameters when performing the conversion through libavif then I can understand the omission and would just advise setting the defaults in the RGB path of examples/avif_example_encode.c, but if not it just seems like good hygiene to be explicit about the color space when libavif performs the conversion.

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

No branches or pull requests

2 participants