From 8a2d4aba20aa58123877f0841e51a5a9b4b2d9ac Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 1 Oct 2014 09:39:28 +1000 Subject: [PATCH] go.image/vp8: clamp the UV DC quantization factor to 132. This fixes the lossy_extreme_probabilities.webp conformance test. LGTM=pascal.massimino, r R=r, pascal.massimino CC=golang-codereviews https://golang.org/cl/145600043 --- vp8/quant.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vp8/quant.go b/vp8/quant.go index 8bf12a0..da43616 100644 --- a/vp8/quant.go +++ b/vp8/quant.go @@ -49,7 +49,10 @@ func (d *Decoder) parseQuant() { if d.quant[i].y2[1] < 8 { d.quant[i].y2[1] = 8 } - d.quant[i].uv[0] = dequantTableDC[clip(q+dquvDC, 0, 127)] + // The 117 is not a typo. The dequant_init function in the spec's Reference + // Decoder Source Code (http://tools.ietf.org/html/rfc6386#section-9.6 Page 145) + // says to clamp the LHS value at 132, which is equal to dequantTableDC[117]. + d.quant[i].uv[0] = dequantTableDC[clip(q+dquvDC, 0, 117)] d.quant[i].uv[1] = dequantTableAC[clip(q+dquvAC, 0, 127)] } }