shithub: libvpx

Download patch

ref: 884c2ddc48677dc9384f51dcebfaa298266aac9e
parent: 51aad61c8c37062ba413b6a4c7fd3b0e109d6d96
author: Yaowu Xu <yaowu@google.com>
date: Wed Jul 6 09:58:34 EDT 2016

Enable HBD support in real time encoding path

BUG=webm:1223

Change-Id: If83a613784e3b2a33c9c93f9ad0ba39dd4d23056

--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -16,6 +16,7 @@
 #include "./vp9_rtcd.h"
 #include "./vpx_dsp_rtcd.h"
 
+#include "vpx/vpx_codec.h"
 #include "vpx_dsp/vpx_dsp_common.h"
 #include "vpx_mem/vpx_mem.h"
 #include "vpx_ports/mem.h"
@@ -238,8 +239,8 @@
 static void block_variance(const uint8_t *src, int src_stride,
                            const uint8_t *ref, int ref_stride,
                            int w, int h, unsigned int *sse, int *sum,
-                           int block_size, unsigned int *sse8x8,
-                           int *sum8x8, unsigned int *var8x8) {
+                           int block_size, vpx_bit_depth_t bd,
+                           uint32_t *sse8x8, int *sum8x8, uint32_t *var8x8) {
   int i, j, k = 0;
 
   *sse = 0;
@@ -247,9 +248,30 @@
 
   for (i = 0; i < h; i += block_size) {
     for (j = 0; j < w; j += block_size) {
+#if CONFIG_VP9_HIGHBITDEPTH
+      switch (bd) {
+        case VPX_BITS_8:
+          vpx_highbd_8_get8x8var(src + src_stride * i + j, src_stride,
+                                 ref + ref_stride * i + j, ref_stride,
+                                 &sse8x8[k], &sum8x8[k]);
+          break;
+        case VPX_BITS_10:
+          vpx_highbd_10_get8x8var(src + src_stride * i + j, src_stride,
+                                  ref + ref_stride * i + j, ref_stride,
+                                  &sse8x8[k], &sum8x8[k]);
+          break;
+        case VPX_BITS_12:
+          vpx_highbd_12_get8x8var(src + src_stride * i + j, src_stride,
+                                  ref + ref_stride * i + j, ref_stride,
+                                  &sse8x8[k], &sum8x8[k]);
+          break;
+      }
+#else
+      (void)bd;
       vpx_get8x8var(src + src_stride * i + j, src_stride,
                     ref + ref_stride * i + j, ref_stride,
                     &sse8x8[k], &sum8x8[k]);
+#endif
       *sse += sse8x8[k];
       *sum += sum8x8[k];
       var8x8[k] = sse8x8[k] - (uint32_t)(((int64_t)sum8x8[k] * sum8x8[k]) >> 6);
@@ -310,11 +332,12 @@
   unsigned int var8x8[64] = {0};
   TX_SIZE tx_size;
   int i, k;
+  const vpx_bit_depth_t bd = cpi->common.bit_depth;
 
   // Calculate variance for whole partition, and also save 8x8 blocks' variance
   // to be used in following transform skipping test.
   block_variance(p->src.buf, p->src.stride, pd->dst.buf, pd->dst.stride,
-                 4 << bw, 4 << bh, &sse, &sum, 8, sse8x8, sum8x8, var8x8);
+                 4 << bw, 4 << bh, &sse, &sum, 8, bd, sse8x8, sum8x8, var8x8);
   var = sse - (((int64_t)sum * sum) >> (bw + bh + 4));
 
   *var_y = var;