From 73ae6e495c7b232f3812e27818ef0f5125406654 Mon Sep 17 00:00:00 2001 From: Peter de Rivaz Date: Thu, 16 Oct 2014 14:36:07 +0100 Subject: [PATCH] Add highbitdepth function for vp9_avg_8x8 Cherry-picked from https://gerrit.chromium.org/gerrit/#/c/71914/ (a92f987a6b7819ae5c62a429e126e1c26bdb1b71) on highbitdepth branch. Change-Id: I6903e4e4cb57d90590725c8a1c64c23da7ae65e8 --- vp9/common/vp9_rtcd_defs.pl | 5 +++++ vp9/encoder/vp9_avg.c | 14 ++++++++++++++ vp9/encoder/vp9_encodeframe.c | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/vp9/common/vp9_rtcd_defs.pl b/vp9/common/vp9_rtcd_defs.pl index de389e7af..d15ddec73 100644 --- a/vp9/common/vp9_rtcd_defs.pl +++ b/vp9/common/vp9_rtcd_defs.pl @@ -1114,6 +1114,11 @@ specialize qw/vp9_get_mb_ss/, "$sse2_x86inc"; add_proto qw/unsigned int vp9_avg_8x8/, "const uint8_t *, int p"; specialize qw/vp9_avg_8x8 sse2/; +if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") { + add_proto qw/unsigned int vp9_highbd_avg_8x8/, "const uint8_t *, int p"; + specialize qw/vp9_highbd_avg_8x8/; +} + # ENCODEMB INVOKE add_proto qw/void vp9_subtract_block/, "int rows, int cols, int16_t *diff_ptr, ptrdiff_t diff_stride, const uint8_t *src_ptr, ptrdiff_t src_stride, const uint8_t *pred_ptr, ptrdiff_t pred_stride"; diff --git a/vp9/encoder/vp9_avg.c b/vp9/encoder/vp9_avg.c index 22c6cc4fc..e9810c894 100644 --- a/vp9/encoder/vp9_avg.c +++ b/vp9/encoder/vp9_avg.c @@ -7,6 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ +#include "vp9/common/vp9_common.h" #include "vpx_ports/mem.h" unsigned int vp9_avg_8x8_c(const uint8_t *s, int p) { @@ -17,3 +18,16 @@ unsigned int vp9_avg_8x8_c(const uint8_t *s, int p) { return (sum + 32) >> 6; } + +#if CONFIG_VP9_HIGHBITDEPTH +unsigned int vp9_highbd_avg_8x8_c(const uint8_t *s8, int p) { + int i, j; + int sum = 0; + const uint16_t* s = CONVERT_TO_SHORTPTR(s8); + for (i = 0; i < 8; ++i, s+=p) + for (j = 0; j < 8; sum += s[j], ++j) {} + + return (sum + 32) >> 6; +} +#endif // CONFIG_VP9_HIGHBITDEPTH + diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 197f54cfc..e428a62b5 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -533,8 +533,19 @@ static void choose_partitioning(VP9_COMP *cpi, int sum = 0; if (x_idx < pixels_wide && y_idx < pixels_high) { - int s_avg = vp9_avg_8x8(s + y_idx * sp + x_idx, sp); - int d_avg = vp9_avg_8x8(d + y_idx * dp + x_idx, dp); + int s_avg, d_avg; +#if CONFIG_VP9_HIGHBITDEPTH + if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { + s_avg = vp9_highbd_avg_8x8(s + y_idx * sp + x_idx, sp); + d_avg = vp9_highbd_avg_8x8(d + y_idx * dp + x_idx, dp); + } else { + s_avg = vp9_avg_8x8(s + y_idx * sp + x_idx, sp); + d_avg = vp9_avg_8x8(d + y_idx * dp + x_idx, dp); + } +#else + s_avg = vp9_avg_8x8(s + y_idx * sp + x_idx, sp); + d_avg = vp9_avg_8x8(d + y_idx * dp + x_idx, dp); +#endif sum = s_avg - d_avg; sse = sum * sum; }