1 | // AVIF is a special case of HEIF. Image size methods are defined in there and should work for both.
|
2 | // Only difference is that we want to specify the image type as AVIF instead of wrapping it into HEIF.
|
3 | pub fn matches(header: &[u8]) -> bool {
|
4 | if header.len() < 12 || &header[4..8] != b"ftyp" {
|
5 | return false;
|
6 | }
|
7 |
|
8 | let header_brand: &[u8] = &header[8..12];
|
9 |
|
10 | // Since other non-AVIF files may contain ftype in the header
|
11 | // we try to use brands to distinguish image files specifically.
|
12 | // List of brands from here: https://mp4ra.org/#/brands
|
13 | let valid_brands: [&[u8; 4]; 5] = [
|
14 | b"avif" , b"avio" , b"avis" , b"MA1A" ,
|
15 | b"MA1B" ,
|
16 | ];
|
17 |
|
18 | for brand: &[u8; 4] in valid_brands {
|
19 | if brand == header_brand {
|
20 | return true;
|
21 | }
|
22 | }
|
23 |
|
24 | false
|
25 | }
|
26 | |