-
Notifications
You must be signed in to change notification settings - Fork 84
/
sei1_hevc_test.go
67 lines (62 loc) · 1.76 KB
/
sei1_hevc_test.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
56
57
58
59
60
61
62
63
64
65
66
67
package sei
import (
"bytes"
"encoding/hex"
"testing"
"github.com/go-test/deep"
)
func TestHEVCSETI1PicTiming(t *testing.T) {
cases := []struct {
name string
naluPayloadHex string
extParams HEVCPicTimingParams
expected PicTimingHevcSEI
expNonFatalErr error
}{
{
name: "HEVC_SETI1PicTiming",
naluPayloadHex: "01071000001a0000030180",
extParams: HEVCPicTimingParams{
FrameFieldInfoPresentFlag: true,
CpbDpbDelaysPresentFlag: true,
SubPicHrdParamsPresentFlag: false,
SubPicCpbParamsInPicTimingSeiFlag: false,
AuCbpRemovalDelayLengthMinus1: 23,
DpbOutputDelayLengthMinus1: 0,
DpbOutputDelayDuLengthMinus1: 23,
DuCpbRemovalDelayIncrementLengthMinus1: 0,
},
expected: PicTimingHevcSEI{
FrameFieldInfo: &HEVCFrameFieldInfo{
PicStruct: 1,
SourceScanType: 0,
DuplicateFlag: false,
},
},
expNonFatalErr: nil,
},
}
for _, tc := range cases {
seiNaluPayload, _ := hex.DecodeString(tc.naluPayloadHex)
r := bytes.NewReader(seiNaluPayload)
seis, err := ExtractSEIData(r)
if err != nil && err != tc.expNonFatalErr {
t.Error(err)
}
if len(seis) != 1 {
t.Errorf("%s: Not %d but %d sei messages found", tc.name, 1, len(seis))
}
seiMessage, err := DecodePicTimingHevcSEI(&seis[0], tc.extParams)
if err != nil {
t.Error(err)
}
if seiMessage.Type() != SEIPicTimingType {
t.Errorf("%s: got SEI type %d instead of %d", tc.name, seiMessage.Type(), SEIPicTimingType)
}
seiPT := seiMessage.(*PicTimingHevcSEI)
diff := deep.Equal(seiPT.FrameFieldInfo, tc.expected.FrameFieldInfo)
if diff != nil {
t.Errorf("%s: %v %s", tc.name, diff, "frame field info mismatch")
}
}
}