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

AVIF_CHROMA_UPSAMPLING_AUTOMATIC doesn't use kFilterBilinear with libyuv functions after commit 95d96ea6c8428e6c796b94f880b6e7a5979cb3a3 #1475

Closed
wantehchang opened this issue Jul 25, 2023 · 0 comments · Fixed by #1476
Assignees

Comments

@wantehchang
Copy link
Collaborator

A bug was introduced in commit 95d96ea (#1264). Here is the relevant code before and after the commit.

Before:

            const enum FilterMode filter = ((rgb->chromaUpsampling == AVIF_CHROMA_UPSAMPLING_FASTEST) ||
                                            (rgb->chromaUpsampling == AVIF_CHROMA_UPSAMPLING_NEAREST))
                                               ? kFilterNone
                                               : kFilterBilinear;

After:

// Only allow nearest-neighbor filter if explicitly specified or left as default.
static avifBool nearestNeighborFilterAllowed(int chromaUpsampling)
{
    return chromaUpsampling != AVIF_CHROMA_UPSAMPLING_BILINEAR && chromaUpsampling != AVIF_CHROMA_UPSAMPLING_BEST_QUALITY;
}

...

const enum FilterMode filter = nearestNeighborFilterAllowed(rgb->chromaUpsampling) ? kFilterNone : kFilterBilinear;

Suppose rgb->chromaUpsampling is AVIF_CHROMA_UPSAMPLING_AUTOMATIC. Before the commit, filter is set equal to kFilterBilinear. After the commit, filter is set equal to kFilterNone.

The effect of the bug is that AVIF_CHROMA_UPSAMPLING_AUTOMATIC doesn't use kFilterBilinear with libyuv functions.

I will write a fix.

@wantehchang wantehchang self-assigned this Jul 25, 2023
wantehchang added a commit to wantehchang/libavif that referenced this issue Jul 25, 2023
The condition for determining whether kFilterNone or kFilterBilinear
should be used was changed incorrectly in commit 95d96ea
(Refactor YUV->RGB conversion with libyuv), causing
AVIF_CHROMA_UPSAMPLING_AUTOMATIC to not use kFilterBilinear with libyuv.
Fix the condition by reverting to the original code.

Fix AOMediaCodec#1475.
wantehchang added a commit that referenced this issue Jul 26, 2023
The condition for determining whether kFilterNone or kFilterBilinear
should be used was changed incorrectly in commit 95d96ea
(Refactor YUV->RGB conversion with libyuv), causing
AVIF_CHROMA_UPSAMPLING_AUTOMATIC to not use kFilterBilinear with libyuv.
Fix the condition by reverting to the original code.

Fix #1475.
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 a pull request may close this issue.

1 participant