-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsei.go
55 lines (48 loc) · 1.03 KB
/
sei.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package h264parse
func (n *NAL) parseSEI() error {
bbr := BitByteReader{}
bbr.New(n.RBSPByte)
n.SEI.PayloadType = 0
n.SEI.PayloadSize = 0
nextBits, err := bbr.ReadByte()
if err != nil {
return err
}
for nextBits == 0xff {
n.SEI.PayloadType += 255
nextBits, err = bbr.ReadByte()
if err != nil {
return err
}
}
n.SEI.PayloadType += int(nextBits) // last_payload_type_byte
// read size
nextBits, err = bbr.ReadByte()
if err != nil {
return err
}
for nextBits == 0xff {
n.SEI.PayloadSize += 255
nextBits, err = bbr.ReadByte()
if err != nil {
return err
}
}
n.SEI.PayloadSize += int(nextBits) // last_payload_size_byte
if n.SEI.PayloadSize >= 8 {
n.SEI.PayloadBytes, err = bbr.ReadBytes(n.SEI.PayloadSize / 8)
if err != nil {
return err
}
}
if n.SEI.PayloadSize%8 != 0 {
r, err := bbr.ReadBits(n.SEI.PayloadSize % 8)
if err != nil {
return err
}
n.SEI.PayloadBytes = append(n.SEI.PayloadBytes, byte(r))
}
// FIXME: implement SEI.parsePayload
// n.SEI.parsePayload()
return nil
}