@@ -580,22 +580,22 @@ public void run(
580
580
assertEquals (ImageType .AVIF , parser .getType (byteBuffer ));
581
581
}
582
582
});
583
- // Change the brand from 'avif' to 'avis'.
583
+ // Change the major brand from 'avif' to 'avis'. Now, the expected output is ANIMATED_AVIF .
584
584
data [11 ] = 0x73 ;
585
585
runTest (
586
586
data ,
587
587
new ParserTestCase () {
588
588
@ Override
589
589
public void run (DefaultImageHeaderParser parser , InputStream is , ArrayPool byteArrayPool )
590
590
throws IOException {
591
- assertEquals (ImageType .AVIF , parser .getType (is ));
591
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (is ));
592
592
}
593
593
594
594
@ Override
595
595
public void run (
596
596
DefaultImageHeaderParser parser , ByteBuffer byteBuffer , ArrayPool byteArrayPool )
597
597
throws IOException {
598
- assertEquals (ImageType .AVIF , parser .getType (byteBuffer ));
598
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (byteBuffer ));
599
599
}
600
600
});
601
601
}
@@ -654,22 +654,101 @@ public void run(
654
654
assertEquals (ImageType .AVIF , parser .getType (byteBuffer ));
655
655
}
656
656
});
657
- // Change the brand from 'avif' to 'avis'.
658
- data [13 ] = 0x73 ;
657
+ // Change the last minor brand from 'MA1B' to 'avis'. Now, the expected output is ANIMATED_AVIF.
658
+ data [24 ] = 0x61 ;
659
+ data [25 ] = 0x76 ;
660
+ data [26 ] = 0x69 ;
661
+ data [27 ] = 0x73 ;
659
662
runTest (
660
663
data ,
661
664
new ParserTestCase () {
662
665
@ Override
663
666
public void run (DefaultImageHeaderParser parser , InputStream is , ArrayPool byteArrayPool )
664
667
throws IOException {
665
- assertEquals (ImageType .AVIF , parser .getType (is ));
668
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (is ));
666
669
}
667
670
668
671
@ Override
669
672
public void run (
670
673
DefaultImageHeaderParser parser , ByteBuffer byteBuffer , ArrayPool byteArrayPool )
671
674
throws IOException {
672
- assertEquals (ImageType .AVIF , parser .getType (byteBuffer ));
675
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (byteBuffer ));
676
+ }
677
+ });
678
+ }
679
+
680
+ @ Test
681
+ public void testCanParseAvifAndAvisBrandsAsAnimatedAvif () throws IOException {
682
+ byte [] data =
683
+ new byte [] {
684
+ // Box Size.
685
+ 0x00 ,
686
+ 0x00 ,
687
+ 0x00 ,
688
+ 0x1C ,
689
+ // ftyp.
690
+ 0x66 ,
691
+ 0x74 ,
692
+ 0x79 ,
693
+ 0x70 ,
694
+ // avis (major brand).
695
+ 0x61 ,
696
+ 0x76 ,
697
+ 0x69 ,
698
+ 0x73 ,
699
+ // minor version.
700
+ 0x00 ,
701
+ 0x00 ,
702
+ 0x00 ,
703
+ 0x00 ,
704
+ // other minor brands (miaf, avif, MA1B).
705
+ 0x6d ,
706
+ 0x69 ,
707
+ 0x61 ,
708
+ 0x66 ,
709
+ 0x61 ,
710
+ 0x76 ,
711
+ 0x69 ,
712
+ 0x66 ,
713
+ 0x4d ,
714
+ 0x41 ,
715
+ 0x31 ,
716
+ 0x42
717
+ };
718
+ runTest (
719
+ data ,
720
+ new ParserTestCase () {
721
+ @ Override
722
+ public void run (DefaultImageHeaderParser parser , InputStream is , ArrayPool byteArrayPool )
723
+ throws IOException {
724
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (is ));
725
+ }
726
+
727
+ @ Override
728
+ public void run (
729
+ DefaultImageHeaderParser parser , ByteBuffer byteBuffer , ArrayPool byteArrayPool )
730
+ throws IOException {
731
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (byteBuffer ));
732
+ }
733
+ });
734
+ // Change the major brand from 'avis' to 'avif'.
735
+ data [11 ] = 0x66 ;
736
+ // Change the minor brand from 'avif' to 'avis'.
737
+ data [23 ] = 0x73 ;
738
+ runTest (
739
+ data ,
740
+ new ParserTestCase () {
741
+ @ Override
742
+ public void run (DefaultImageHeaderParser parser , InputStream is , ArrayPool byteArrayPool )
743
+ throws IOException {
744
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (is ));
745
+ }
746
+
747
+ @ Override
748
+ public void run (
749
+ DefaultImageHeaderParser parser , ByteBuffer byteBuffer , ArrayPool byteArrayPool )
750
+ throws IOException {
751
+ assertEquals (ImageType .ANIMATED_AVIF , parser .getType (byteBuffer ));
673
752
}
674
753
});
675
754
}
@@ -743,6 +822,27 @@ public void run(
743
822
});
744
823
}
745
824
825
+ @ Test
826
+ public void testCanParseRealAnimatedAvifFile () throws IOException {
827
+ byte [] data = Util .readBytes (TestResourceUtil .openResource (getClass (), "animated_avif.avif" ));
828
+ runTest (
829
+ data ,
830
+ new ParserTestCase () {
831
+ @ Override
832
+ public void run (DefaultImageHeaderParser parser , InputStream is , ArrayPool byteArrayPool )
833
+ throws IOException {
834
+ assertThat (parser .getType (is )).isEqualTo (ImageType .ANIMATED_AVIF );
835
+ }
836
+
837
+ @ Override
838
+ public void run (
839
+ DefaultImageHeaderParser parser , ByteBuffer byteBuffer , ArrayPool byteArrayPool )
840
+ throws IOException {
841
+ assertThat (parser .getType (byteBuffer )).isEqualTo (ImageType .ANIMATED_AVIF );
842
+ }
843
+ });
844
+ }
845
+
746
846
@ Test
747
847
public void testReturnsUnknownTypeForUnknownImageHeaders () throws IOException {
748
848
byte [] data = new byte [] {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 };
0 commit comments