av/codec/h264/h264dec/nalunit_test.go

53 lines
1.2 KiB
Go
Raw Normal View History

package h264dec
import (
"bytes"
"reflect"
"testing"
"bitbucket.org/ausocean/av/codec/h264/h264dec/bits"
)
func TestNewMVCExtension(t *testing.T) {
tests := []struct {
in string
want MVCExtension
err error
}{
{
in: "0" + // u(1) non_idr_flag = false
"00 0010" + // u(6) priority_id = 2
"00 0001 1000" + // u(10) view_id = 24
"100" + // u(3) temporal_id = 4
"1" + // u(1) anchor_pic_flag = true
"0" + // u(1) inter_view_flag = false
"1", // u(1) reserved_one_bit = 1
want: MVCExtension{
NonIdrFlag: false,
PriorityID: 2,
ViewID: 24,
TemporalID: 4,
AnchorPicFlag: true,
InterViewFlag: false,
ReservedOneBit: 1,
},
},
}
for i, test := range tests {
inBytes, err := binToSlice(test.in)
if err != nil {
t.Fatalf("did not expect error %v from binToSlice for test %d", err, i)
}
got, err := NewMVCExtension(bits.NewBitReader(bytes.NewReader(inBytes)))
if err != test.err {
t.Errorf("did not get expected error for test %d\nGot: %v\nWant: %v\n", i, err, test.err)
}
if !reflect.DeepEqual(*got, test.want) {
t.Errorf("did not get expected result for test %d\nGot: %v\nWant: %v\n", i, *got, test.want)
}
}
}