av/codec/h264/decode/slice_test.go

50 lines
1.2 KiB
Go
Raw Normal View History

package h264
import "testing"
var subWidthCTests = []struct {
in SPS
want int
}{
{SPS{}, 17},
{SPS{ChromaFormat: 0}, 17},
{SPS{ChromaFormat: 1}, 2},
{SPS{ChromaFormat: 2}, 2},
{SPS{ChromaFormat: 3}, 1},
{SPS{ChromaFormat: 3, UseSeparateColorPlane: true}, 17},
{SPS{ChromaFormat: 999}, 17},
}
// TestSubWidthC tests that the correct SubWidthC is returned given
// SPS inputs with various chroma formats.
func TestSubWidthC(t *testing.T) {
for _, tt := range subWidthCTests {
if got := SubWidthC(&tt.in); got != tt.want {
t.Errorf("SubWidthC(%#v) = %d, want %d", tt.in, got, tt.want)
}
}
}
var subHeightCTests = []struct {
in SPS
want int
}{
{SPS{}, 17},
{SPS{ChromaFormat: 0}, 17},
{SPS{ChromaFormat: 1}, 2},
{SPS{ChromaFormat: 2}, 1},
{SPS{ChromaFormat: 3}, 1},
{SPS{ChromaFormat: 3, UseSeparateColorPlane: true}, 17},
{SPS{ChromaFormat: 999}, 17},
}
// TestSubHeightC tests that the correct SubHeightC is returned given
// SPS inputs with various chroma formats.
func TestSubHeightC(t *testing.T) {
for _, tt := range subHeightCTests {
if got := SubHeightC(&tt.in); got != tt.want {
t.Errorf("SubHeight(%#v) = %d, want %d", tt.in, got, tt.want)
}
}
}