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
This commit is contained in:
Nigel Tao 2014-09-22 12:52:41 +10:00
parent 34eb6b7c8b
commit 95764ac466
2 changed files with 12 additions and 11 deletions

View File

@ -130,8 +130,9 @@ func (d *decoder) decodeTransform(w int32, h int32) (t transform, newWidth int32
pix[p+2] += pix[p-2] pix[p+2] += pix[p-2]
pix[p+3] += pix[p-1] pix[p+3] += pix[p-1]
} }
// The C code fills in palette entries past the nColors upper limit as // The spec says that "if the index is equal or larger than color_table_size,
// transparent black. In Go, we re-slice up to 256 4-byte pixels. // 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] t.pix = pix[:4*256]
} }
return t, w, nil return t, w, nil
@ -530,7 +531,7 @@ func decodeHeader(r io.Reader) (d *decoder, w int32, h int32, err error) {
return nil, 0, 0, err return nil, 0, 0, err
} }
if version != 0 { 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 return d, int32(width), int32(height), nil
} }

View File

@ -142,7 +142,7 @@ func inversePredictor(t *transform, pix []byte, h int32) []byte {
pix[p+2] += avg2(avg2(pix[p-2], pix[top-2]), avg2(pix[top+2], pix[top+6])) 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])) 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]) l0 := int32(pix[p-4])
l1 := int32(pix[p-3]) l1 := int32(pix[p-3])
l2 := int32(pix[p-2]) l2 := int32(pix[p-2])
@ -155,18 +155,18 @@ func inversePredictor(t *transform, pix []byte, h int32) []byte {
t1 := int32(pix[top+1]) t1 := int32(pix[top+1])
t2 := int32(pix[top+2]) t2 := int32(pix[top+2])
t3 := int32(pix[top+3]) 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) l := abs(c0-t0) + abs(c1-t1) + abs(c2-t2) + abs(c3-t3)
if t <= l { t := abs(c0-l0) + abs(c1-l1) + abs(c2-l2) + abs(c3-l3)
pix[p+0] += uint8(t0) if l < t {
pix[p+1] += uint8(t1)
pix[p+2] += uint8(t2)
pix[p+3] += uint8(t3)
} else {
pix[p+0] += uint8(l0) pix[p+0] += uint8(l0)
pix[p+1] += uint8(l1) pix[p+1] += uint8(l1)
pix[p+2] += uint8(l2) pix[p+2] += uint8(l2)
pix[p+3] += uint8(l3) 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). case 12: // ClampAddSubtractFull(L, T, TL).