shithub: libvpx

Download patch

ref: 2de3c8d29b7a820bd70260536cb1d6fa2fac4179
parent: 98e132bde099c760289ba1dc8b1ae06183ec611d
author: Dmitry Kovalev <[email protected]>
date: Tue Jul 16 10:39:31 EDT 2013

Loop filter code cleanup.

Cosmetic code changes, renaming 'flat' local var to 'mask', removing
unused field 'blim' from loopfilter_info_n and loop_filter_info structs.

Change-Id: I51e6ccf727fe361ad9a08e29e1201aa7abd4987f

--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -50,7 +50,6 @@
       block_inside_limit = 1;
 
     vpx_memset(lfi->lim[lvl], block_inside_limit, SIMD_WIDTH);
-    vpx_memset(lfi->blim[lvl], (2 * lvl + block_inside_limit), SIMD_WIDTH);
     vpx_memset(lfi->mblim[lvl], (2 * (lvl + 2) + block_inside_limit),
                SIMD_WIDTH);
   }
@@ -127,7 +126,6 @@
 
   if (filter_level > 0) {
     lfi->mblim = lfi_n->mblim[filter_level];
-    lfi->blim = lfi_n->blim[filter_level];
     lfi->lim = lfi_n->lim[filter_level];
     lfi->hev_thr = lfi_n->hev_thr[filter_level >> 4];
     return 1;
@@ -189,7 +187,7 @@
 
   for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int;
        mask; mask >>= count) {
-    count =1;
+    count = 1;
     if (mask & 1) {
       if (!only_4x4_1) {
         if (mask_16x16 & 1) {
@@ -244,6 +242,7 @@
   unsigned int mask_4x4_int[MI_BLOCK_SIZE] = {0};
   struct loop_filter_info lfi[MI_BLOCK_SIZE][MI_BLOCK_SIZE];
   int r, c;
+
   const MODE_INFO *mi = xd->mode_info_context;
   const int row_step_stride = cm->mode_info_stride * row_step;
 
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -28,8 +28,6 @@
   DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
                   mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
   DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
-                  blim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
-  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
                   lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
   DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
                   hev_thr[4][SIMD_WIDTH]);
@@ -39,10 +37,10 @@
 
 struct loop_filter_info {
   const uint8_t *mblim;
-  const uint8_t *blim;
   const uint8_t *lim;
   const uint8_t *hev_thr;
 };
+
 
 /* assorted loopfilter functions which get used elsewhere */
 struct VP9Common;
--- a/vp9/common/vp9_loopfilter_filters.c
+++ b/vp9/common/vp9_loopfilter_filters.c
@@ -39,14 +39,14 @@
                                 uint8_t p1, uint8_t p0,
                                 uint8_t q0, uint8_t q1,
                                 uint8_t q2, uint8_t q3) {
-  int8_t flat = 0;
-  flat |= (abs(p1 - p0) > thresh) * -1;
-  flat |= (abs(q1 - q0) > thresh) * -1;
-  flat |= (abs(p2 - p0) > thresh) * -1;
-  flat |= (abs(q2 - q0) > thresh) * -1;
-  flat |= (abs(p3 - p0) > thresh) * -1;
-  flat |= (abs(q3 - q0) > thresh) * -1;
-  return ~flat;
+  int8_t mask = 0;
+  mask |= (abs(p1 - p0) > thresh) * -1;
+  mask |= (abs(q1 - q0) > thresh) * -1;
+  mask |= (abs(p2 - p0) > thresh) * -1;
+  mask |= (abs(q2 - q0) > thresh) * -1;
+  mask |= (abs(p3 - p0) > thresh) * -1;
+  mask |= (abs(q3 - q0) > thresh) * -1;
+  return ~mask;
 }
 
 static INLINE int8_t flat_mask5(uint8_t thresh,
@@ -55,10 +55,10 @@
                                 uint8_t p0, uint8_t q0,
                                 uint8_t q1, uint8_t q2,
                                 uint8_t q3, uint8_t q4) {
-  int8_t flat = ~flat_mask4(thresh, p3, p2, p1, p0, q0, q1, q2, q3);
-  flat |= (abs(p4 - p0) > thresh) * -1;
-  flat |= (abs(q4 - q0) > thresh) * -1;
-  return ~flat;
+  int8_t mask = ~flat_mask4(thresh, p3, p2, p1, p0, q0, q1, q2, q3);
+  mask |= (abs(p4 - p0) > thresh) * -1;
+  mask |= (abs(q4 - q0) > thresh) * -1;
+  return ~mask;
 }
 
 // is there high edge variance internal edge: 11111111 yes, 00000000 no
@@ -95,7 +95,7 @@
   *op0 = signed_char_clamp(ps0 + filter2) ^ 0x80;
 
   // outer tap adjustments
-  filter = ((filter1 + 1) >> 1) & ~hev;
+  filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
 
   *oq1 = signed_char_clamp(qs1 - filter) ^ 0x80;
   *op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
@@ -146,17 +146,17 @@
                            uint8_t *op1, uint8_t *op0,
                            uint8_t *oq0, uint8_t *oq1,
                            uint8_t *oq2, uint8_t *oq3) {
-  // 7-tap filter [1, 1, 1, 2, 1, 1, 1]
   if (flat && mask) {
     const uint8_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
     const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3;
 
-    *op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + p2 + p2 + p1 + p0 + q0, 3);
-    *op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + p1 + p1 + p0 + q0 + q1, 3);
-    *op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + p0 + p0 + q0 + q1 + q2, 3);
-    *oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + q0 + q0 + q1 + q2 + q3, 3);
-    *oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + q1 + q1 + q2 + q3 + q3, 3);
-    *oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + q2 + q2 + q3 + q3 + q3, 3);
+    // 7-tap filter [1, 1, 1, 2, 1, 1, 1]
+    *op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3);
+    *op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3);
+    *op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3);
+    *oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3);
+    *oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3);
+    *oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3);
   } else {
     filter4(mask, hev, op1,  op0, oq0, oq1);
   }
@@ -215,7 +215,6 @@
                             uint8_t *oq2, uint8_t *oq3,
                             uint8_t *oq4, uint8_t *oq5,
                             uint8_t *oq6, uint8_t *oq7) {
-  // 15-tap filter [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
   if (flat2 && flat && mask) {
     const uint8_t p7 = *op7, p6 = *op6, p5 = *op5, p4 = *op4,
                   p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
@@ -223,6 +222,7 @@
     const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3,
                   q4 = *oq4, q5 = *oq5, q6 = *oq6, q7 = *oq7;
 
+    // 15-tap filter [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
     *op6 = ROUND_POWER_OF_TWO(p7 * 7 + p6 * 2 + p5 + p4 + p3 + p2 + p1 + p0 +
                               q0, 4);
     *op5 = ROUND_POWER_OF_TWO(p7 * 6 + p6 + p5 * 2 + p4 + p3 + p2 + p1 + p0 +
@@ -299,7 +299,7 @@
     const int8_t hev = hev_mask(*thresh, p1, p0, q0, q1);
     const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
     const int8_t flat2 = flat_mask5(1, s[-8], s[-7], s[-6], s[-5], p0,
-                                   q0, s[4], s[5], s[6], s[7]);
+                                    q0, s[4], s[5], s[6], s[7]);
 
     filter16(mask, hev, flat, flat2,
              s - 8, s - 7, s - 6, s - 5, s - 4, s - 3, s - 2, s - 1,