Skip to content

Commit 5f6ca18

Browse files
authored
Rely on contentToDecode only in avifDecoderReset() (AOMediaCodec#3001)
Avoid unexpected effects when the value is changed between avifDecoderReset() and avifDecoderNextImage().
1 parent 835d66a commit 5f6ca18

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

include/avif/avif.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,8 @@ typedef struct avifDecoder
13731373
// --------------------------------------------------------------------------------------------
13741374

13751375
// Image content to decode (if present). Defaults to AVIF_IMAGE_CONTENT_DECODE_DEFAULT.
1376+
// The value is only taken into account when calling avifDecoderRead*(), avifDecoderSetSource(),
1377+
// avifDecoderParse(), or avifDecoderReset().
13761378
avifImageContentTypeFlags imageContentToDecode; // Changeable decoder setting.
13771379

13781380
// Version 1.2.0 ends here. Add any new members after this line.

src/read.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6952,7 +6952,10 @@ avifResult avifDecoderNextImage(avifDecoder * decoder)
69526952
AVIF_ASSERT_OR_RETURN(prepareTileResult[c] == AVIF_RESULT_OK);
69536953
}
69546954

6955-
if ((decoder->imageContentToDecode & AVIF_IMAGE_CONTENT_COLOR_AND_ALPHA) && decoder->data->meta->sampleTransformExpression.count > 0) {
6955+
// If decoder->data->tileInfos[AVIF_ITEM_COLOR].tileCount == 0, it means
6956+
// decoder->imageContentToDecode & AVIF_IMAGE_CONTENT_COLOR_AND_ALPHA was equal to 0.
6957+
// Only apply Sample Transforms if there is a color item to apply it onto.
6958+
if (decoder->data->tileInfos[AVIF_ITEM_COLOR].tileCount != 0 && decoder->data->meta->sampleTransformExpression.count > 0) {
69566959
// TODO(yguyon): Add a field in avifDecoder and only perform sample transformations upon request.
69576960
AVIF_CHECKRES(avifDecoderApplySampleTransform(decoder, decoder->image));
69586961
}

0 commit comments

Comments
 (0)