Test alphaPresent when decoder ignores alpha#3301
Conversation
| result = avifDecoderNextImage(decoder.get()); | ||
| ASSERT_EQ(result, AVIF_RESULT_OK) | ||
| << avifResultToString(result) << ": " << decoder->diag.error; | ||
| result = avifImageCopy(decoded.get(), decoder->image, AVIF_PLANES_ALL); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
7d25af3 to
6783cd2
Compare
| result = avifDecoderNextImage(decoder.get()); | ||
| ASSERT_EQ(result, AVIF_RESULT_OK) | ||
| << avifResultToString(result) << ": " << decoder->diag.error; | ||
| result = avifImageCopy(decoded.get(), decoder->image, AVIF_PLANES_ALL); |
There was a problem hiding this comment.
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.
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()).