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

read.c: Clamp CICP enum values to valid range #2137

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

vigneshvg
Copy link
Collaborator

If invalid values are seen, replace them with UNSPECIFIED. This
change does not affect the color conversion paths in anyway, it just
changes what is reported in the public API.

If invalid values are seen, replace them with UNSPECIFIED. This
change does not affect the color conversion paths in anyway, it just
changes what is reported in the public API.
@vigneshvg vigneshvg requested review from jzern and y-guyon April 26, 2024 03:15
AVIF_CHECK(avifROStreamReadU16(&s, &colr->colorPrimaries)); // unsigned int(16) colour_primaries;
if (colr->colorPrimaries == 3 ||
(colr->colorPrimaries > AVIF_COLOR_PRIMARIES_DCI_P3 && colr->colorPrimaries < AVIF_COLOR_PRIMARIES_EBU3213) ||
colr->colorPrimaries > AVIF_COLOR_PRIMARIES_EBU3213) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding AVIF_COLOR_PRIMARIES_LAST too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i considered it but decided not to do it because it's not very useful here since there are other holes in the range anwyays. so the check won't be simple.

i also didn't wanna update the pubic ABI simply for such a corner case check. if you strongly feel otherwise please let me know and i can add it.

@vigneshvg vigneshvg merged commit 2f45ea4 into AOMediaCodec:main Apr 26, 2024
11 checks passed
@vigneshvg vigneshvg deleted the cl_clamp_cicp branch April 26, 2024 20:16
AVIF_CHECK(avifROStreamReadU16(&s, &colr->matrixCoefficients)); // unsigned int(16) matrix_coefficients;
if (colr->matrixCoefficients == 3 || colr->matrixCoefficients >= AVIF_MATRIX_COEFFICIENTS_LAST) {
colr->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_UNSPECIFIED;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that this pull request and the subsequent #2139 should be reverted. The reserved values may become valid in the future. The decoder should report the reserved values faithfully.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #2151

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

Successfully merging this pull request may close these issues.

3 participants