-
Notifications
You must be signed in to change notification settings - Fork 84
/
mime_test.go
54 lines (50 loc) · 1.07 KB
/
mime_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
package hevc
import (
"encoding/hex"
"math/bits"
"testing"
)
func TestCodecString(t *testing.T) {
testCases := []struct {
hexSPS string
codecString string
}{
{
"420101016000000300b0000003000003007ba003c08010e59447924525ac041400000300040000030067c36bdcf50007a12000f42640",
"hvc1.1.6.L123.B0",
},
{
"420101016000000300900000030000030078a0021c801e0596566924caf01680800001f480003a9804",
"hvc1.1.6.L120.90",
},
}
for _, tc := range testCases {
spsBytes, err := hex.DecodeString(tc.hexSPS)
if err != nil {
t.Error(err)
}
sps, err := ParseSPSNALUnit(spsBytes)
if err != nil {
t.Error(err)
}
got := CodecString("hvc1", sps)
if got != tc.codecString {
t.Errorf("Got %q wanted %q", got, tc.codecString)
}
}
}
func TestReverseUint32bits(t *testing.T) {
testCases := []struct {
bits uint32
rev uint32
}{
{0x00000002, 0x40000000},
{0x12345678, 0x1e6a2c48},
}
for _, tc := range testCases {
got := bits.Reverse32(tc.bits)
if got != tc.rev {
t.Errorf("Got %04x instead of %04x for %04x", got, tc.rev, tc.bits)
}
}
}