@@ -863,10 +863,23 @@ static avifResult avifEncoderAddImageInternal(avifEncoder * encoder,
863863 } else {
864864 // Another frame in an image sequence
865865
866- if (encoder -> data -> alphaPresent && !firstCell -> alphaPlane ) {
867- // If the first image in the sequence had an alpha plane (even if fully opaque), all
868- // subsequence images must have alpha as well.
869- return AVIF_RESULT_ENCODE_ALPHA_FAILED ;
866+ const avifImage * imageMetadata = encoder -> data -> imageMetadata ;
867+ // HEIF (ISO 23008-12:2017), Section 6.6.2.3.1:
868+ // All input images shall have exactly the same width and height; call those tile_width and tile_height.
869+ // MIAF (ISO 23000-22:2019), Section 7.3.11.4.1:
870+ // All input images of a grid image item shall use the same coding format, chroma sampling format, and the
871+ // same decoder configuration (see 7.3.6.2).
872+ // If the first image in the sequence had an alpha plane (even if fully opaque), all
873+ // subsequence images must have alpha as well.
874+ if ((imageMetadata -> width != firstCell -> width ) || (imageMetadata -> height != firstCell -> height ) ||
875+ (imageMetadata -> depth != firstCell -> depth ) || (imageMetadata -> yuvFormat != firstCell -> yuvFormat ) ||
876+ (imageMetadata -> yuvRange != firstCell -> yuvRange ) || (imageMetadata -> colorPrimaries != firstCell -> colorPrimaries ) ||
877+ (imageMetadata -> transferCharacteristics != firstCell -> transferCharacteristics ) ||
878+ (imageMetadata -> matrixCoefficients != firstCell -> matrixCoefficients ) ||
879+ (!!imageMetadata -> alphaPlane != !!firstCell -> alphaPlane ) ||
880+ (imageMetadata -> alphaPremultiplied != firstCell -> alphaPremultiplied ) ||
881+ (encoder -> data -> alphaPresent && !firstCell -> alphaPlane )) {
882+ return AVIF_RESULT_INCOMPATIBLE_IMAGE ;
870883 }
871884 }
872885
0 commit comments