Skip to content

Fix bug in avifToLinearIEC61966#3218

Merged
maryla-uc merged 2 commits into
AOMediaCodec:mainfrom
maryla-uc:eotf
May 22, 2026
Merged

Fix bug in avifToLinearIEC61966#3218
maryla-uc merged 2 commits into
AOMediaCodec:mainfrom
maryla-uc:eotf

Conversation

@maryla-uc
Copy link
Copy Markdown
Contributor

The negative portion of the curve did not match the spec, and was not the inverse of the fromLinear function.

@maryla-uc maryla-uc changed the title Fix but in avifToLinearIEC61966 Fix bug in avifToLinearIEC61966 May 21, 2026
Comment thread src/colr.c
{
if (gamma < -4.5f * 0.018053968510807f) {
return powf((-gamma + 0.09929682680944f) / -1.09929682680944f, 1.0f / 0.45f);
return -powf((gamma - 0.09929682680944f) / -1.09929682680944f, 1.0f / 0.45f);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this bug fix worth documenting in the changelog?

Note: I didn't compare the new code with the spec, but the original code is incorrect mathematically because the base of the power, (-gamma + 0.09929682680944f) / -1.09929682680944f, is negative.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a changelog entry, I think it's good hygiene, thanks for reminding me.
Fortunately I think this bug is unlikely to have ever affected anyone. It only affects negative values, and only for transfer function 11 which probably nobody uses. And the transfer functions are only used by the gain map code (creation/tone mapping).

@maryla-uc maryla-uc merged commit eb6e0e6 into AOMediaCodec:main May 22, 2026
25 checks passed
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.

2 participants