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

Validate the num_channels field of the 'pixi' box #642

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wantehchang
Copy link
Collaborator

Validate the num_channels field of the 'pixi' box against the av1C
property.

Validate the num_channels field of the 'pixi' box against the av1C
property.
@wantehchang wantehchang requested a review from joedrago May 27, 2021 00:26
@joedrago
Copy link
Collaborator

joedrago commented Jun 1, 2021

We talked about this elsewhere, but just as a reminder for myself/others: I'm waiting on this one until I can ensure that the monochrome check is safe for really old AVIFs. (I can't remember how pixi was written in early versions of libavif before AV1 codecs could properly write monochrome.)

@wantehchang
Copy link
Collaborator Author

Joe: I checked the relevant code in src/write.c.

In v0.3.5, the code is:

            if (hasAlpha) {
                avifBoxMarker pixiA = avifStreamWriteBox(&s, "pixi", 0, 0);
                avifStreamWriteU8(&s, 1);                     // unsigned int (8) num_channels;

In the current trunk, the code is:

        uint8_t channelCount = (item->alpha || (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV400)) ? 1 : 3;
        avifBoxMarker pixi = avifRWStreamWriteFullBox(&s, "pixi", AVIF_BOX_SIZE_TBD, 0, 0);
        avifRWStreamWriteU8(&s, channelCount); // unsigned int (8) num_channels;

So libavif has been setting num_channels to 1 in the 'pixi' box for the alpha auxiliary image for a long time.

I am requesting a sample image from Dirk Farin to see how libheif handles this.

@farindk
Copy link

farindk commented Jun 2, 2021

libheif behaves in the same way. Even if the encoder needs to save the alpha image in 4:2:0, libheif writes a one channel pixi box because there actually is only 1 channel of intended information. The other 2 channels are just dummy data without any use.

This is with libheif v1.12.0. Earlier versions of libheif did not write pixi boxes for AVIF.

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