package h264dec import "testing" var subWidthCTests = []struct { in SPS want int }{ {SPS{}, 17}, {SPS{ChromaFormatIDC: 0}, 17}, {SPS{ChromaFormatIDC: 1}, 2}, {SPS{ChromaFormatIDC: 2}, 2}, {SPS{ChromaFormatIDC: 3}, 1}, {SPS{ChromaFormatIDC: 3, SeparateColorPlaneFlag: true}, 17}, {SPS{ChromaFormatIDC: 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{ChromaFormatIDC: 0}, 17}, {SPS{ChromaFormatIDC: 1}, 2}, {SPS{ChromaFormatIDC: 2}, 1}, {SPS{ChromaFormatIDC: 3}, 1}, {SPS{ChromaFormatIDC: 3, SeparateColorPlaneFlag: true}, 17}, {SPS{ChromaFormatIDC: 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) } } }