maxTq = 3
maxComponents = 4
-
- // We only support 4:4:4, 4:4:0, 4:2:2 and 4:2:0 downsampling, and therefore the
- // number of luma samples per chroma sample is at most 2 in the horizontal
- // and 2 in the vertical direction.
- maxH = 2
- maxV = 2
)
const (
d.comp[i].v = int(hv & 0x0f)
switch d.nComp {
case 3:
- // For YCbCr images, we only support 4:4:4, 4:4:0, 4:2:2 or 4:2:0 chroma
- // downsampling ratios. This implies that the (h, v) values for the Y
- // component are either (1, 1), (1, 2), (2, 1) or (2, 2), and the (h, v)
- // values for the Cr and Cb components must be (1, 1).
+ // For YCbCr images, we only support 4:4:4, 4:4:0, 4:2:2, 4:2:0,
+ // 4:1:1 or 4:1:0 chroma downsampling ratios. This implies that the
+ // (h, v) values for the Y component are either (1, 1), (1, 2),
+ // (2, 1), (2, 2), (4, 1) or (4, 2), and the (h, v) values for the Cr
+ // and Cb components must be (1, 1).
if i == 0 {
- if hv != 0x11 && hv != 0x21 && hv != 0x22 && hv != 0x12 {
+ if hv != 0x11 && hv != 0x21 && hv != 0x22 && hv != 0x12 && hv != 0x41 && hv != 0x42 {
return UnsupportedError("luma/chroma downsample ratio")
}
} else if hv != 0x11 {
func TestDecodeProgressive(t *testing.T) {
testCases := []string{
"../testdata/video-001",
+ "../testdata/video-001.q50.410",
+ "../testdata/video-001.q50.411",
"../testdata/video-001.q50.420",
"../testdata/video-001.q50.422",
"../testdata/video-001.q50.440",
subsampleRatio = image.YCbCrSubsampleRatio422
case h0 == 2 && v0 == 2:
subsampleRatio = image.YCbCrSubsampleRatio420
+ case h0 == 4 && v0 == 1:
+ subsampleRatio = image.YCbCrSubsampleRatio411
+ case h0 == 4 && v0 == 2:
+ subsampleRatio = image.YCbCrSubsampleRatio410
default:
panic("unreachable")
}
// 0 1 2
// 3 4 5
if nComp != 1 {
- bx, by = d.comp[compIndex].h*mx, d.comp[compIndex].v*my
- if h0 == 1 {
- by += j
- } else {
- bx += j % 2
- by += j / 2
- }
+ bx = d.comp[compIndex].h*mx + j%h0
+ by = d.comp[compIndex].v*my + j/h0
} else {
q := mxx * d.comp[compIndex].h
bx = blockCount % q