Debian Codegraph @

matchers/isobmff/isobmff.go

raw symbols SCIP
1 package isobmff
2
3 import "encoding/binary"
4
5 // IsISOBMFF checks whether the given buffer represents ISO Base Media File Format data
6 func IsISOBMFF(buf []byte) bool {
7 if len(buf) < 16 || string(buf[4:8]) != "ftyp" {
8 return false
9 }
10
11 if ftypLength := binary.BigEndian.Uint32(buf[0:4]); len(buf) < int(ftypLength) {
12 return false
13 }
14
15 return true
16 }
17
18 // GetFtyp returns the major brand, minor version and compatible brands of the ISO-BMFF data
19 func GetFtyp(buf []byte) (string, string, []string) {
20 if len(buf) < 17 {
21 return "", "", []string{""}
22 }
23
24 ftypLength := binary.BigEndian.Uint32(buf[0:4])
25
26 majorBrand := string(buf[8:12])
27 minorVersion := string(buf[12:16])
28
29 compatibleBrands := []string{}
30 for i := 16; i < int(ftypLength); i += 4 {
31 if len(buf) >= (i + 4) {
32 compatibleBrands = append(compatibleBrands, string(buf[i:i+4]))
33 }
34 }
35
36 return majorBrand, minorVersion, compatibleBrands
37 }