Rely on contentToDecode only in avifDecoderReset() (#3001)

Avoid unexpected effects when the value is changed between
avifDecoderReset() and avifDecoderNextImage().
diff --git a/include/avif/avif.h b/include/avif/avif.h
index 83d8c17..8eb84f5 100644
--- a/include/avif/avif.h
+++ b/include/avif/avif.h
@@ -1373,6 +1373,8 @@
     // --------------------------------------------------------------------------------------------
 
     // Image content to decode (if present). Defaults to AVIF_IMAGE_CONTENT_DECODE_DEFAULT.
+    // The value is only taken into account when calling avifDecoderRead*(), avifDecoderSetSource(),
+    // avifDecoderParse(), or avifDecoderReset().
     avifImageContentTypeFlags imageContentToDecode; // Changeable decoder setting.
 
     // Version 1.2.0 ends here. Add any new members after this line.
diff --git a/src/read.c b/src/read.c
index 6e9af85..8f22250 100644
--- a/src/read.c
+++ b/src/read.c
@@ -6952,7 +6952,10 @@
         AVIF_ASSERT_OR_RETURN(prepareTileResult[c] == AVIF_RESULT_OK);
     }
 
-    if ((decoder->imageContentToDecode & AVIF_IMAGE_CONTENT_COLOR_AND_ALPHA) && decoder->data->meta->sampleTransformExpression.count > 0) {
+    // If decoder->data->tileInfos[AVIF_ITEM_COLOR].tileCount == 0, it means
+    // decoder->imageContentToDecode & AVIF_IMAGE_CONTENT_COLOR_AND_ALPHA was equal to 0.
+    // Only apply Sample Transforms if there is a color item to apply it onto.
+    if (decoder->data->tileInfos[AVIF_ITEM_COLOR].tileCount != 0 && decoder->data->meta->sampleTransformExpression.count > 0) {
         // TODO(yguyon): Add a field in avifDecoder and only perform sample transformations upon request.
         AVIF_CHECKRES(avifDecoderApplySampleTransform(decoder, decoder->image));
     }