From 042e70e45e74ad5105d1c9f35375350000b56b39 Mon Sep 17 00:00:00 2001 From: Yaowu Xu <yaowu@google.com> Date: Thu, 30 May 2013 14:24:12 -0700 Subject: [PATCH] Changed to use a new variant of WHT The commit changed to use a new variant of Walsh-Hadamard Transform by Tim Terriberry. This new variant has the best compression among a number of variants that developed by Tim. Change-Id: Icb3a88515463cfc644b17ca046fcd139db2557e9 --- vp9/common/vp9_idct.c | 42 +++++++++++++++++++----------------------- vp9/common/vp9_idct.h | 1 + vp9/encoder/vp9_dct.c | 30 ++++++++++++++---------------- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/vp9/common/vp9_idct.c b/vp9/common/vp9_idct.c index 026ba913df..dcc7f03307 100644 --- a/vp9/common/vp9_idct.c +++ b/vp9/common/vp9_idct.c @@ -32,20 +32,17 @@ void vp9_short_iwalsh4x4_add_c(int16_t *input, uint8_t *dest, int dest_stride) { c1 = ip[1] >> WHT_UPSCALE_FACTOR; d1 = ip[2] >> WHT_UPSCALE_FACTOR; b1 = ip[3] >> WHT_UPSCALE_FACTOR; - - c1 = a1 - c1; - b1 += d1; - e1 = (c1 - b1) >> 1; - a1 -= e1; - d1 += e1; - b1 = a1 - b1; - c1 -= d1; - + a1 += c1; + d1 -= b1; + e1 = (a1 - d1) >> 1; + b1 = e1 - b1; + c1 = e1 - c1; + a1 -= b1; + d1 += c1; op[0] = a1; op[1] = b1; op[2] = c1; op[3] = d1; - ip += 4; op += 4; } @@ -56,15 +53,13 @@ void vp9_short_iwalsh4x4_add_c(int16_t *input, uint8_t *dest, int dest_stride) { c1 = ip[4 * 1]; d1 = ip[4 * 2]; b1 = ip[4 * 3]; - - c1 = a1 - c1; - b1 += d1; - e1 = (c1 - b1) >> 1; - a1 -= e1; - d1 += e1; - b1 = a1 - b1; - c1 -= d1; - + a1 += c1; + d1 -= b1; + e1 = (a1 - d1) >> 1; + b1 = e1 - b1; + c1 = e1 - c1; + a1 -= b1; + d1 += c1; dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] + a1); dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] + b1); dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] + c1); @@ -84,16 +79,17 @@ void vp9_short_iwalsh4x4_1_add_c(int16_t *in, uint8_t *dest, int dest_stride) { a1 = ip[0] >> WHT_UPSCALE_FACTOR; e1 = a1 >> 1; - op[0] = op[1] = op[2] = a1 - e1; - op[3] = e1; + a1 -= e1; + op[0] = a1; + op[1] = op[2] = op[3] = e1; ip = tmp; for (i = 0; i < 4; i++) { e1 = ip[0] >> 1; a1 = ip[0] - e1; dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] + a1); - dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] + a1); - dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] + a1); + dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] + e1); + dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] + e1); dest[dest_stride * 3] = clip_pixel(dest[dest_stride * 3] + e1); ip++; dest++; diff --git a/vp9/common/vp9_idct.h b/vp9/common/vp9_idct.h index 176bf5da43..af35432c44 100644 --- a/vp9/common/vp9_idct.h +++ b/vp9/common/vp9_idct.h @@ -17,6 +17,7 @@ #include "vpx/vpx_integer.h" #include "vp9/common/vp9_common.h" + // Constants and Macros used by all idct/dct functions #define DCT_CONST_BITS 14 #define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1)) diff --git a/vp9/encoder/vp9_dct.c b/vp9/encoder/vp9_dct.c index d22644424e..8d4eec1394 100644 --- a/vp9/encoder/vp9_dct.c +++ b/vp9/encoder/vp9_dct.c @@ -606,14 +606,13 @@ void vp9_short_walsh4x4_c(short *input, short *output, int pitch) { c1 = ip[2 * pitch_short]; d1 = ip[3 * pitch_short]; - b1 = a1 - b1; - c1 += d1; - e1 = (c1 - b1) >> 1; - a1 += e1; - d1 -= e1; - c1 = a1 - c1; - b1 -= d1; - + a1 += b1; + d1 = d1 - c1; + e1 = (a1 - d1) >> 1; + b1 = e1 - b1; + c1 = e1 - c1; + a1 -= c1; + d1 += b1; op[0] = a1; op[4] = c1; op[8] = d1; @@ -631,14 +630,13 @@ void vp9_short_walsh4x4_c(short *input, short *output, int pitch) { c1 = ip[2]; d1 = ip[3]; - b1 = a1 - b1; - c1 += d1; - e1 = (c1 - b1) >> 1; - a1 += e1; - d1 -= e1; - c1 = a1 - c1; - b1 -= d1; - + a1 += b1; + d1 -= c1; + e1 = (a1 - d1) >> 1; + b1 = e1 - b1; + c1 = e1 - c1; + a1 -= c1; + d1 += b1; op[0] = a1 << WHT_UPSCALE_FACTOR; op[1] = c1 << WHT_UPSCALE_FACTOR; op[2] = d1 << WHT_UPSCALE_FACTOR; -- GitLab