vp8l: update comments to match latest spec.
The spec change is at
https://gerrit.chromium.org/gerrit/#/c/71605/
LGTM=robsc
R=robsc
CC=golang-codereviews
https://golang.org/cl/146910043
diff --git a/vp8l/decode.go b/vp8l/decode.go
index 13fa6d9..ee7afb0 100644
--- a/vp8l/decode.go
+++ b/vp8l/decode.go
@@ -130,8 +130,9 @@
pix[p+2] += pix[p-2]
pix[p+3] += pix[p-1]
}
- // The C code fills in palette entries past the nColors upper limit as
- // transparent black. In Go, we re-slice up to 256 4-byte pixels.
+ // The spec says that "if the index is equal or larger than color_table_size,
+ // the argb color value should be set to 0x00000000 (transparent black)."
+ // We re-slice up to 256 4-byte pixels.
t.pix = pix[:4*256]
}
return t, w, nil
@@ -530,7 +531,7 @@
return nil, 0, 0, err
}
if version != 0 {
- return nil, 0, 0, errors.New("vp8l: unsupported version")
+ return nil, 0, 0, errors.New("vp8l: invalid version")
}
return d, int32(width), int32(height), nil
}
diff --git a/vp8l/transform.go b/vp8l/transform.go
index f79431c..06543da 100644
--- a/vp8l/transform.go
+++ b/vp8l/transform.go
@@ -142,7 +142,7 @@
pix[p+2] += avg2(avg2(pix[p-2], pix[top-2]), avg2(pix[top+2], pix[top+6]))
pix[p+3] += avg2(avg2(pix[p-1], pix[top-1]), avg2(pix[top+3], pix[top+7]))
- case 11: // Select(T, L, TL).
+ case 11: // Select(L, T, TL).
l0 := int32(pix[p-4])
l1 := int32(pix[p-3])
l2 := int32(pix[p-2])
@@ -155,18 +155,18 @@
t1 := int32(pix[top+1])
t2 := int32(pix[top+2])
t3 := int32(pix[top+3])
- t := abs(c0-l0) + abs(c1-l1) + abs(c2-l2) + abs(c3-l3)
l := abs(c0-t0) + abs(c1-t1) + abs(c2-t2) + abs(c3-t3)
- if t <= l {
- pix[p+0] += uint8(t0)
- pix[p+1] += uint8(t1)
- pix[p+2] += uint8(t2)
- pix[p+3] += uint8(t3)
- } else {
+ t := abs(c0-l0) + abs(c1-l1) + abs(c2-l2) + abs(c3-l3)
+ if l < t {
pix[p+0] += uint8(l0)
pix[p+1] += uint8(l1)
pix[p+2] += uint8(l2)
pix[p+3] += uint8(l3)
+ } else {
+ pix[p+0] += uint8(t0)
+ pix[p+1] += uint8(t1)
+ pix[p+2] += uint8(t2)
+ pix[p+3] += uint8(t3)
}
case 12: // ClampAddSubtractFull(L, T, TL).