Skip to content

Test alphaPresent when decoder ignores alpha#3301

Merged
wantehchang merged 2 commits into
AOMediaCodec:mainfrom
wantehchang:test-alpha-present
Jul 16, 2026
Merged

Test alphaPresent when decoder ignores alpha#3301
wantehchang merged 2 commits into
AOMediaCodec:mainfrom
wantehchang:test-alpha-present

Conversation

@wantehchang

@wantehchang wantehchang commented Jul 15, 2026

Copy link
Copy Markdown
Member

Modify GainMapTest.IgnoreColorAndAlpha and GainMapTest.IgnoreAll to check whether alphaPresent and other main image metadata are set when the decoder ignores color and alpha.

Since this requires examining the decoder's fields after avifDecoderParse() is called, the avifDecoderReadMemory() call in GainMapTest.IgnoreColorAndAlpha is replaced with calls to the equivalent avifDecoder functions (except avifImageCopy()).

@wantehchang
wantehchang requested a review from maryla-uc July 15, 2026 17:03
Comment thread tests/gtest/avifgainmaptest.cc Outdated
result = avifDecoderNextImage(decoder.get());
ASSERT_EQ(result, AVIF_RESULT_OK)
<< avifResultToString(result) << ": " << decoder->diag.error;
result = avifImageCopy(decoded.get(), decoder->image, AVIF_PLANES_ALL);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This avifImageCopy() call is here to emulate the original avifDecoderReadMemory() call. We could omit this avifImageCopy() call and use decoder->image instead of decoded. Would you like me to do that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indeed I think there's no reason to do a copy here but it doesn't matter much to be honest, I'm ok with it either way.

@wantehchang wantehchang Jul 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. I removed the avifImageCopy() call. Several tests in this file call avifDecoderReadMemory() or avifDecoderReadFile(), so we have sufficient test coverage for avifImageCopy() when the decoded image has a gain map.

EXPECT_EQ(decoder->image->height, 34u);
EXPECT_EQ(decoder->image->depth, 10);
EXPECT_EQ(decoder->image->yuvFormat, AVIF_PIXEL_FORMAT_YUV420);
EXPECT_EQ(decoder->alphaPresent, AVIF_TRUE);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This shows that decoder->alphaPresent is assigned a value exactly according to the comment "This is true when avifDecoderParse() detects an alpha plane."

Modify GainMapTest.IgnoreColorAndAlpha and GainMapTest.IgnoreAll to
check whether alphaPresent and other main image metadata are set when
the decoder ignores color and alpha.

Since this requires examining the decoder's fields after
avifDecoderParse() is called, the avifDecoderReadMemory() call in
GainMapTest.IgnoreColorAndAlpha is replaced with calls to the
equivalent avifDecoder functions.

@maryla-uc maryla-uc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Comment thread tests/gtest/avifgainmaptest.cc Outdated
result = avifDecoderNextImage(decoder.get());
ASSERT_EQ(result, AVIF_RESULT_OK)
<< avifResultToString(result) << ": " << decoder->diag.error;
result = avifImageCopy(decoded.get(), decoder->image, AVIF_PLANES_ALL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indeed I think there's no reason to do a copy here but it doesn't matter much to be honest, I'm ok with it either way.

@wantehchang
wantehchang merged commit 4783644 into AOMediaCodec:main Jul 16, 2026
25 checks passed
@wantehchang
wantehchang deleted the test-alpha-present branch July 16, 2026 16:37
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