forked from Eyevinn/mp4ff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhevc_test.go
110 lines (102 loc) · 2.08 KB
/
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package hevc
import (
"testing"
"github.com/go-test/deep"
)
func TestGetNaluTypes(t *testing.T) {
testCases := []struct {
name string
input []byte
wanted []NaluType
}{
{
"AUD",
[]byte{0, 0, 0, 2, 70, 0},
[]NaluType{NALU_AUD},
},
{
"AUD, VPS, SPS, PPS, and IDR ",
[]byte{
0, 0, 0, 2, 70, 2,
0, 0, 0, 3, 64, 1, 1,
0, 0, 0, 3, 66, 2, 2,
0, 0, 0, 3, 68, 3, 3,
0, 0, 0, 3, 40, 4, 4},
[]NaluType{NALU_AUD, NALU_VPS, NALU_SPS, NALU_PPS, NALU_IDR_N_LP},
},
}
for _, tc := range testCases {
got := FindNaluTypes(tc.input)
if diff := deep.Equal(got, tc.wanted); diff != nil {
t.Errorf("%s: %v", tc.name, diff)
}
}
}
func TestHasParameterSets(t *testing.T) {
testCases := []struct {
name string
input []byte
wanted bool
}{
{
"AUD",
[]byte{0, 0, 0, 2, 70, 0},
false,
},
{
"AUD, VPS, SPS, PPS, and IDR ",
[]byte{
0, 0, 0, 2, 70, 2,
0, 0, 0, 3, 64, 1, 1,
0, 0, 0, 3, 66, 2, 2,
0, 0, 0, 3, 68, 3, 3,
0, 0, 0, 3, 40, 4, 4},
true,
},
}
for _, tc := range testCases {
got := HasParameterSets(tc.input)
if got != tc.wanted {
t.Errorf("%s: got %t instead of %t", tc.name, got, tc.wanted)
}
}
}
func TestGetParameterSets(t *testing.T) {
testCases := []struct {
name string
input []byte
wantedVPS [][]byte
wantedSPS [][]byte
wantedPPS [][]byte
}{
{
"AUD",
[]byte{0, 0, 0, 2, 70, 0},
nil, nil, nil,
},
{
"AUD, VPS, SPS, PPS, and IDR ",
[]byte{
0, 0, 0, 2, 70, 2,
0, 0, 0, 3, 64, 1, 1,
0, 0, 0, 3, 66, 2, 2,
0, 0, 0, 3, 68, 3, 3,
0, 0, 0, 3, 40, 4, 4},
[][]byte{{64, 1, 1}},
[][]byte{{66, 2, 2}},
[][]byte{{68, 3, 3}},
},
}
for _, tc := range testCases {
gotVPS, gotSPS, gotPPS := GetParameterSets(tc.input)
if diff := deep.Equal(gotVPS, tc.wantedVPS); diff != nil {
t.Errorf("%s VPS: %v", tc.name, diff)
}
if diff := deep.Equal(gotSPS, tc.wantedSPS); diff != nil {
t.Errorf("%s SPS: %v", tc.name, diff)
}
if diff := deep.Equal(gotPPS, tc.wantedPPS); diff != nil {
t.Errorf("%s PPS: %v", tc.name, diff)
}
}
}