From 5955cf5e89e8bae012e5e534950a46db17f66a79 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 23 Jul 2012 14:21:30 -0700 Subject: [PATCH] replace x*155/100 by x*101581>>16 Don't expect a visible speed diff. it's just cool. (and, that's one less TODO in the code). Change-Id: Iaeb2f1c930debb51501e170ee806f2f945fb1a8d --- src/dec/quant.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dec/quant.c b/src/dec/quant.c index 95514114..d54097af 100644 --- a/src/dec/quant.c +++ b/src/dec/quant.c @@ -94,8 +94,10 @@ void VP8ParseQuant(VP8Decoder* const dec) { m->y1_mat_[1] = kAcTable[clip(q + 0, 127)]; m->y2_mat_[0] = kDcTable[clip(q + dqy2_dc, 127)] * 2; - // TODO(skal): make it another table? - m->y2_mat_[1] = kAcTable[clip(q + dqy2_ac, 127)] * 155 / 100; + // For all x in [0..284], x*155/100 is bitwise equal to (x*101581) >> 16. + // The smallest precision for that is '(x*6349) >> 12' but 16 is a good + // word size. + m->y2_mat_[1] = (kAcTable[clip(q + dqy2_ac, 127)] * 101581) >> 16; if (m->y2_mat_[1] < 8) m->y2_mat_[1] = 8; m->uv_mat_[0] = kDcTable[clip(q + dquv_dc, 117)];