From 152ce6b2b901279d1154ef45e8b387eb23cad3a0 Mon Sep 17 00:00:00 2001 From: Yaowu Xu <yaowu@google.com> Date: Wed, 12 Oct 2011 10:49:49 -0700 Subject: [PATCH] fixed the wrong rounding in inverse haar transform Given the current forward haar transform: f0 = I0 + I1 + I2 + I3 f1 = I0 + I1 - I2 - I3 f2 = I0 - I1 + I2 - I3 f3 = I0 - I1 - I2 + I3 the output of the inverse haar prior rounding: i0 = f0 + f1 + f2 + f3 = I0 * 4; i1 = f0 + f1 - f2 - f3 = I1 * 4; i2 = f0 - f1 + f2 - f3 = I2 * 4; i3 = f0 - f1 - f2 + f3 = I3 * 4; As all the numbers are 4 multiples, simply >>2 always produces prefect results in term of forward-inverse transform round trip error. Change-Id: Id6658b00ea819ee61cfeef8c5985d4cd3e77f44e --- vp8/common/idctllm.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/vp8/common/idctllm.c b/vp8/common/idctllm.c index 4f3a01b1b2..567aa1dccd 100644 --- a/vp8/common/idctllm.c +++ b/vp8/common/idctllm.c @@ -512,14 +512,10 @@ void vp8_short_ihaar2x2_c(short *input, short *output, int pitch) op[i] = 0; } - x = (ip[0] + ip[1] + ip[4] + ip[8]); - op[0] = (x>=0?x+1:x-1)>>2; - x = (ip[0] - ip[1] + ip[4] - ip[8]); - op[1] = (x>=0?x+1:x-1)>>2; - x = (ip[0] + ip[1] - ip[4] - ip[8]); - op[4] = (x>=0?x+1:x-1)>>2; - x = (ip[0] - ip[1] - ip[4] + ip[8]); - op[8] = (x>=0?x+1:x-1)>>2; + op[0] = (ip[0] + ip[1] + ip[4] + ip[8])>>2; + op[1] = (ip[0] - ip[1] + ip[4] - ip[8])>>2; + op[4] = (ip[0] + ip[1] - ip[4] - ip[8])>>2; + op[8] = (ip[0] - ip[1] - ip[4] + ip[8])>>2; } void vp8_short_ihaar2x2_1_c(short *input, short *output, int pitch) @@ -527,7 +523,7 @@ void vp8_short_ihaar2x2_1_c(short *input, short *output, int pitch) int a1; short *ip = input; short *op = output; - a1 = ((ip[0]>=0?ip[0]+1:ip[0]-1) >> 2); + a1 = ip[0]>> 2; op[0] = a1; op[2] = a1; op[8] = a1; -- GitLab