-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathdec3_test.go
64 lines (60 loc) · 1.4 KB
/
dec3_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
package mp4
import (
"encoding/hex"
"testing"
"github.com/Eyevinn/mp4ff/bits"
)
func TestEncDecDec3(t *testing.T) {
b := &Dec3Box{DataRate: 448,
NumIndSub: 0,
EC3Subs: []EC3Sub{
{FSCod: 2}},
Reserved: []byte{}}
boxDiffAfterEncodeAndDecode(t, b)
}
func TestGetChannelInfoDec3(t *testing.T) {
testCases := []struct {
name string
hexIn string
wantedNrChannels int
wantedChannelMap uint16
}{
{
name: "7+1",
hexIn: "0000000e646563330c00200f0202",
wantedNrChannels: 8,
wantedChannelMap: 0xfa01,
},
{
name: "5+1",
hexIn: "0000000d646563330800200f00",
wantedNrChannels: 6,
wantedChannelMap: 0xf801,
},
{
name: "2+0",
hexIn: "0000000d646563330400200400",
wantedNrChannels: 2,
wantedChannelMap: 0xa000,
},
}
for _, tc := range testCases {
dec3Bytes, err := hex.DecodeString(tc.hexIn)
if err != nil {
t.Error(err)
}
sr := bits.NewFixedSliceReader(dec3Bytes)
box, err := DecodeBoxSR(0, sr)
if err != nil {
t.Error(err)
}
dec3 := box.(*Dec3Box)
gotNrChannels, gotChanmap := dec3.ChannelInfo()
if gotNrChannels != tc.wantedNrChannels {
t.Errorf("got %d channels instead of %d", gotNrChannels, tc.wantedNrChannels)
}
if gotChanmap != tc.wantedChannelMap {
t.Errorf("got chanmap %d instead of %d", gotChanmap, tc.wantedChannelMap)
}
}
}