Files
gortsplib/pkg/formatdecenc/rtpmjpeg/headers/quantization_table_test.go
Alessandro Ros 91f18ab6d9 Add RTP/MJPEG decoder and encoder (#165)
* rename format.JPEG into format.MJPEG

* add examples/client-publish-format-mjpeg

* add rtp/mjpeg decoder and encoder
2022-12-27 13:43:23 +01:00

55 lines
1.2 KiB
Go

package headers
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
var casesQuantizationTable = []struct {
name string
enc []byte
dec QuantizationTable
}{
{
"base",
[]byte{
0x1, 0x0, 0x0, 0x40, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x4,
0x1, 0x2, 0x3, 0x4,
},
QuantizationTable{
MBZ: 1,
Precision: 0,
Tables: bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 64/4),
},
},
}
func TestQuantizationTableUnmarshal(t *testing.T) {
for _, ca := range casesQuantizationTable {
t.Run(ca.name, func(t *testing.T) {
var h QuantizationTable
_, err := h.Unmarshal(ca.enc)
require.NoError(t, err)
require.Equal(t, ca.dec, h)
})
}
}
func TestQuantizationTableMarshal(t *testing.T) {
for _, ca := range casesQuantizationTable {
t.Run(ca.name, func(t *testing.T) {
buf := ca.dec.Marshal(nil)
require.Equal(t, ca.enc, buf)
})
}
}