-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathdac3_test.go
41 lines (37 loc) · 1.01 KB
/
dac3_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
package mp4
import (
"encoding/hex"
"testing"
"github.com/Eyevinn/mp4ff/bits"
)
func TestEncodeDedodeAC3(t *testing.T) {
t.Run("normal-dac3", func(t *testing.T) {
dac3 := &Dac3Box{FSCod: 1, BSID: 2, ACMod: 3, LFEOn: 1, BitRateCode: 7}
boxDiffAfterEncodeAndDecode(t, dac3)
})
t.Run("weird-dac3", func(t *testing.T) {
dac3 := &Dac3Box{FSCod: 1, BSID: 2, ACMod: 3, LFEOn: 1, BitRateCode: 7, InitialZeroes: 4}
boxDiffAfterEncodeAndDecode(t, dac3)
})
}
func TestGetChannelInfo(t *testing.T) {
dac3Hex := "0000000b646163330c3dc0"
dac3Bytes, err := hex.DecodeString(dac3Hex)
if err != nil {
t.Error(err)
}
sr := bits.NewFixedSliceReader(dac3Bytes)
box, err := DecodeBoxSR(0, sr)
if err != nil {
t.Error(err)
}
dac3 := box.(*Dac3Box)
gotNrChannels, gotChanmap := dac3.ChannelInfo()
if gotNrChannels != 6 {
t.Errorf("%d channels instead of 6", gotNrChannels)
}
expectedChanmap := uint16(0xf801)
if gotChanmap != expectedChanmap {
t.Errorf("got chanmap %d instead of %d", gotChanmap, expectedChanmap)
}
}