-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathsei6_hevc.go
More file actions
60 lines (52 loc) · 2.01 KB
/
Copy pathsei6_hevc.go
File metadata and controls
60 lines (52 loc) · 2.01 KB
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
56
57
58
59
60
package sei
import (
"bytes"
"fmt"
"github.com/Eyevinn/mp4ff/bits"
)
// RecoveryPointHevcSEI carries the data of an HEVC SEI 6 RecoveryPoint message.
// Defined in ISO/IEC 23008-2 Annex D.2.8 (syntax) and D.3.8 (semantics).
// The corresponding AVC message in RecoveryPointAvcSEI has a different syntax.
type RecoveryPointHevcSEI struct {
// RecoveryPocCnt specifies the recovery point of decoded pictures in output order.
RecoveryPocCnt int `json:"recovery_poc_cnt"`
// ExactMatchFlag indicates whether pictures at and after the recovery point exactly match.
ExactMatchFlag bool `json:"exact_match_flag"`
// BrokenLinkFlag indicates the presence of a broken link at the recovery point location.
BrokenLinkFlag bool `json:"broken_link_flag"`
}
// DecodeRecoveryPointHevcSEI decodes an HEVC SEI 6 RecoveryPoint message.
func DecodeRecoveryPointHevcSEI(sd *SEIData) (SEIMessage, error) {
buf := bytes.NewBuffer(sd.Payload())
br := bits.NewReader(buf)
rp := RecoveryPointHevcSEI{
RecoveryPocCnt: br.ReadSignedGolomb(),
ExactMatchFlag: br.ReadFlag(),
BrokenLinkFlag: br.ReadFlag(),
}
return &rp, br.AccError()
}
// Type returns the SEI payload type.
func (s *RecoveryPointHevcSEI) Type() uint {
return SEIRecoveryPointType
}
// Size is the size in bytes of the raw SEI message rbsp payload.
func (s *RecoveryPointHevcSEI) Size() uint {
nrBits := seNrBits(s.RecoveryPocCnt) + 1 + 1
return uint((nrBits + 7) / 8)
}
// Payload returns the SEI raw rbsp payload.
func (s *RecoveryPointHevcSEI) Payload() []byte {
sw := bits.NewFixedSliceWriter(int(s.Size()))
sw.WriteSignedGolomb(s.RecoveryPocCnt)
sw.WriteFlag(s.ExactMatchFlag)
sw.WriteFlag(s.BrokenLinkFlag)
sw.WriteFlag(true) // Final 1 and then byte align
sw.FlushBits()
return sw.Bytes()
}
// String returns a string representation of RecoveryPointHevcSEI.
func (s *RecoveryPointHevcSEI) String() string {
return fmt.Sprintf("%s, size=%d, recoveryPocCnt=%d, exactMatch=%t, brokenLink=%t",
SEIType(s.Type()), s.Size(), s.RecoveryPocCnt, s.ExactMatchFlag, s.BrokenLinkFlag)
}