github.com/bluenviron/mediacommon@v1.9.3/pkg/codecs/av1/obu_header.go (about) 1 package av1 2 3 import ( 4 "fmt" 5 ) 6 7 // OBUHeader is a OBU header. 8 // Specification: https://aomediacodec.github.io/av1-spec/#obu-header-syntax 9 type OBUHeader struct { 10 Type OBUType 11 HasSize bool 12 } 13 14 // Unmarshal decodes a OBUHeader. 15 func (h *OBUHeader) Unmarshal(buf []byte) error { 16 if len(buf) < 1 { 17 return fmt.Errorf("not enough bytes") 18 } 19 20 forbidden := (buf[0] >> 7) != 0 21 if forbidden { 22 return fmt.Errorf("forbidden bit is set") 23 } 24 25 h.Type = OBUType(buf[0] >> 3) 26 27 extensionFlag := ((buf[0] >> 2) & 0b1) != 0 28 if extensionFlag { 29 return fmt.Errorf("extension flag is not supported yet") 30 } 31 32 h.HasSize = ((buf[0] >> 1) & 0b1) != 0 33 34 return nil 35 }