shithub: libvpx

Download patch

ref: 4f3398a26a18719c5a8866aae36a437d22737174
parent: 0c5fd59efdb234fe0231615c858e1f9c9945cbfa
author: Yunqing Wang <yunqingwang@google.com>
date: Fri Oct 12 13:21:23 EDT 2018

Optimize vp9_highbd_temporal_filter_apply_c

Following the previous patch:
(https://chromium-review.googlesource.com/c/webm/libvpx/+/1277913),
this patch modified the highbd version of applying temporal filter
in the similar way.

Change-Id: I2bb6f1fff6e32bca86f7139a497181d34aa9f3ec

--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -327,13 +327,23 @@
   const uint16_t *frame2 = CONVERT_TO_SHORTPTR(frame2_8);
   unsigned int i, j, k;
   int modifier;
-  int byte = 0;
   const int rounding = strength > 0 ? 1 << (strength - 1) : 0;
 
+  int diff_sse[256] = { 0 };
+  int this_idx = 0;
+
+  for (i = 0; i < block_height; i++) {
+    for (j = 0; j < block_width; j++) {
+      const int diff =
+          frame1[i * (int)stride + j] - frame2[i * (int)block_width + j];
+      diff_sse[this_idx++] = diff * diff;
+    }
+  }
+
+  modifier = 0;
   for (i = 0, k = 0; i < block_height; i++) {
     for (j = 0; j < block_width; j++, k++) {
-      int pixel_value = *frame2;
-      int diff_sse[9] = { 0 };
+      int pixel_value = frame2[i * (int)block_width + j];
       int idx, idy, index = 0;
 
       for (idy = -1; idy <= 1; ++idy) {
@@ -343,9 +353,7 @@
 
           if (row >= 0 && row < (int)block_height && col >= 0 &&
               col < (int)block_width) {
-            int diff = frame1[byte + idy * (int)stride + idx] -
-                       frame2[idy * (int)block_width + idx];
-            diff_sse[index] = diff * diff;
+            modifier += diff_sse[row * (int)block_width + col];
             ++index;
           }
         }
@@ -352,13 +360,9 @@
       }
       assert(index > 0);
 
-      modifier = 0;
-      for (idx = 0; idx < 9; ++idx) modifier += diff_sse[idx];
-
       modifier *= 3;
       modifier /= index;
 
-      ++frame2;
       modifier += rounding;
       modifier >>= strength;
 
@@ -369,11 +373,7 @@
 
       count[k] += modifier;
       accumulator[k] += modifier * pixel_value;
-
-      byte++;
     }
-
-    byte += stride - block_width;
   }
 }
 #endif  // CONFIG_VP9_HIGHBITDEPTH