update parallel_deblocking experiment with more filter tap options
this change adds the following filter tap options:
1. add options to replace 15 tap filter with 9 or 11 tap filter
2. force chroma plane to only use maximum 7 tap filter
above options are disabled by default
Change-Id: Iab90a613210c1adaf4475976e9ed7e78ac30803b
diff --git a/aom_dsp/loopfilter.c b/aom_dsp/loopfilter.c
index 494d9aa..e2e8392 100644
--- a/aom_dsp/loopfilter.c
+++ b/aom_dsp/loopfilter.c
@@ -20,6 +20,9 @@
return (int8_t)clamp(t, -128, 127);
}
+#define PARALLEL_DEBLOCKING_11_TAP 0
+#define PARALLEL_DEBLOCKING_9_TAP 0
+
#if CONFIG_HIGHBITDEPTH
static INLINE int16_t signed_char_clamp_high(int t, int bd) {
switch (bd) {
@@ -68,6 +71,29 @@
return ~mask;
}
+#if PARALLEL_DEBLOCKING_9_TAP
+static INLINE int8_t flat_mask2(uint8_t thresh, uint8_t p4, uint8_t p0,
+ uint8_t q0, uint8_t q4) {
+ int8_t mask = 0;
+ mask |= (abs(p4 - p0) > thresh) * -1;
+ mask |= (abs(q4 - q0) > thresh) * -1;
+ return ~mask;
+}
+#endif
+
+#if PARALLEL_DEBLOCKING_11_TAP
+static INLINE int8_t flat_mask3(uint8_t thresh, uint8_t p5, uint8_t p4,
+ uint8_t p0, uint8_t q0, uint8_t q4,
+ uint8_t q5) {
+ int8_t mask = 0;
+ mask |= (abs(p4 - p0) > thresh) * -1;
+ mask |= (abs(q4 - q0) > thresh) * -1;
+ mask |= (abs(p5 - p0) > thresh) * -1;
+ mask |= (abs(q5 - q0) > thresh) * -1;
+ return ~mask;
+}
+#endif
+
static INLINE int8_t flat_mask5(uint8_t thresh, uint8_t p4, uint8_t p3,
uint8_t p2, uint8_t p1, uint8_t p0, uint8_t q0,
uint8_t q1, uint8_t q2, uint8_t q3,
@@ -251,6 +277,61 @@
aom_lpf_vertical_8_c(s + 8 * pitch, pitch, blimit1, limit1, thresh1);
}
+#if PARALLEL_DEBLOCKING_11_TAP
+static INLINE void filter12(int8_t mask, uint8_t thresh, uint8_t flat,
+ uint8_t flat2, uint8_t *op5, uint8_t *op4,
+ uint8_t *op3, uint8_t *op2, uint8_t *op1,
+ uint8_t *op0, uint8_t *oq0, uint8_t *oq1,
+ uint8_t *oq2, uint8_t *oq3, uint8_t *oq4,
+ uint8_t *oq5) {
+ if (flat2 && flat && mask) {
+ const uint8_t p5 = *op5, p4 = *op4, p3 = *op3, p2 = *op2, p1 = *op1,
+ p0 = *op0;
+ const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3, q4 = *oq4,
+ q5 = *oq5;
+
+ // 11-tap filter [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]
+ *op4 = (p5 * 5 + p4 * 2 + p3 + p2 + p1 + p0 + q0 + 6) / 12;
+ *op3 = (p5 * 4 + p4 + p3 * 2 + p2 + p1 + p0 + q0 + q1 + 6) / 12;
+ *op2 = (p5 * 3 + p4 + p3 + p2 * 2 + p1 + p0 + q0 + q1 + q2 + 6) / 12;
+ *op1 = (p5 * 2 + p4 + p3 + p2 + p1 * 2 + p0 + q0 + q1 + q2 + q3 + 6) / 12;
+ *op0 = (p5 + p4 + p3 + p2 + p1 + p0 * 2 + q0 + q1 + q2 + q3 + q4 + 6) / 12;
+ *oq0 = (p4 + p3 + p2 + p1 + p0 + q0 * 2 + q1 + q2 + q3 + q4 + q5 + 6) / 12;
+ *oq1 = (p3 + p2 + p1 + p0 + q0 + q1 * 2 + q2 + q3 + q4 + q5 * 2 + 6) / 12;
+ *oq2 = (p2 + p1 + p0 + q0 + q1 + q2 * 2 + q3 + q4 + q5 * 3 + 6) / 12;
+ *oq3 = (p1 + p0 + q0 + q1 + q2 + q3 * 2 + q4 + q5 * 4 + 6) / 12;
+ *oq4 = (p0 + q0 + q1 + q2 + q3 + q4 * 2 + q5 * 5 + 6) / 12;
+ } else {
+ filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3);
+ }
+}
+#endif
+
+#if PARALLEL_DEBLOCKING_9_TAP
+static INLINE void filter10(int8_t mask, uint8_t thresh, uint8_t flat,
+ uint8_t flat2, uint8_t *op4, uint8_t *op3,
+ uint8_t *op2, uint8_t *op1, uint8_t *op0,
+ uint8_t *oq0, uint8_t *oq1, uint8_t *oq2,
+ uint8_t *oq3, uint8_t *oq4) {
+ if (flat2 && flat && mask) {
+ const uint8_t p4 = *op4, p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
+ const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3, q4 = *oq4;
+
+ // 9-tap filter [1, 1, 1, 1, 2, 1, 1, 1, 1]
+ *op3 = (p4 * 4 + p3 * 2 + p2 + p1 + p0 + q0 + 5) / 10;
+ *op2 = (p4 * 3 + p3 + p2 * 2 + p1 + p0 + q0 + q1 + 5) / 10;
+ *op1 = (p4 * 2 + p3 + p2 + p1 * 2 + p0 + q0 + q1 + q2 + 5) / 10;
+ *op0 = (p4 + p3 + p2 + p1 + p0 * 2 + q0 + q1 + q2 + q3 + 5) / 10;
+ *oq0 = (p3 + p2 + p1 + p0 + q0 * 2 + q1 + q2 + q3 + q4 + 5) / 10;
+ *oq1 = (p2 + p1 + p0 + q0 + q1 * 2 + q2 + q3 + q4 * 2 + 5) / 10;
+ *oq2 = (p1 + p0 + q0 + q1 + q2 * 2 + q3 + q4 * 3 + 5) / 10;
+ *oq3 = (p0 + q0 + q1 + q2 + q3 * 2 + q4 * 4 + 5) / 10;
+ } else {
+ filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3);
+ }
+}
+#endif
+
static INLINE void filter16(int8_t mask, uint8_t thresh, uint8_t flat,
uint8_t flat2, uint8_t *op7, uint8_t *op6,
uint8_t *op5, uint8_t *op4, uint8_t *op3,
@@ -313,19 +394,37 @@
// loop filter designed to work using chars so that we can make maximum use
// of 8 bit simd instructions.
for (i = 0; i < 8 * count; ++i) {
- const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
- const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
+ const uint8_t p7 = s[-8 * p], p6 = s[-7 * p], p5 = s[-6 * p],
+ p4 = s[-5 * p], p3 = s[-4 * p], p2 = s[-3 * p],
+ p1 = s[-2 * p], p0 = s[-p];
+ const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p],
+ q4 = s[4 * p], q5 = s[5 * p], q6 = s[6 * p], q7 = s[7 * p];
const int8_t mask =
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
- const int8_t flat2 =
- flat_mask5(1, s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], p0, q0,
- s[4 * p], s[5 * p], s[6 * p], s[7 * p]);
+
+#if PARALLEL_DEBLOCKING_11_TAP
+ const int8_t flat2 = flat_mask3(1, p5, p4, p0, q0, q4, q5);
+
+ filter12(mask, *thresh, flat, flat2, s - 6 * p, s - 5 * p, s - 4 * p,
+ s - 3 * p, s - 2 * p, s - 1 * p, s, s + 1 * p, s + 2 * p,
+ s + 3 * p, s + 4 * p, s + 5 * p);
+
+#elif PARALLEL_DEBLOCKING_9_TAP
+ const int8_t flat2 = flat_mask2(1, p4, p0, q0, q4);
+
+ filter10(mask, *thresh, flat, flat2, s - 5 * p, s - 4 * p, s - 3 * p,
+ s - 2 * p, s - 1 * p, s, s + 1 * p, s + 2 * p, s + 3 * p,
+ s + 4 * p);
+#else
+ const int8_t flat2 = flat_mask5(1, p7, p6, p5, p4, p0, q0, q4, q5, q6, q7);
filter16(mask, *thresh, flat, flat2, s - 8 * p, s - 7 * p, s - 6 * p,
s - 5 * p, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s,
s + 1 * p, s + 2 * p, s + 3 * p, s + 4 * p, s + 5 * p, s + 6 * p,
s + 7 * p);
+#endif
+
++s;
}
}
@@ -346,17 +445,33 @@
int i;
for (i = 0; i < count; ++i) {
- const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
- const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
+ const uint8_t p7 = s[-8], p6 = s[-7], p5 = s[-6], p4 = s[-5], p3 = s[-4],
+ p2 = s[-3], p1 = s[-2], p0 = s[-1];
+ const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3], q4 = s[4],
+ q5 = s[5], q6 = s[6], q7 = s[7];
const int8_t mask =
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
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]);
+
+#if PARALLEL_DEBLOCKING_11_TAP
+ const int8_t flat2 = flat_mask3(1, p5, p4, p0, q0, q4, q5);
+
+ filter12(mask, *thresh, flat, flat2, s - 6, s - 5, s - 4, s - 3, s - 2,
+ s - 1, s, s + 1, s + 2, s + 3, s + 4, s + 5);
+#elif PARALLEL_DEBLOCKING_9_TAP
+ const int8_t flat2 = flat_mask2(1, p4, p0, q0, q4);
+
+ filter10(mask, *thresh, flat, flat2, s - 5, s - 4, s - 3, s - 2, s - 1, s,
+ s + 1, s + 2, s + 3, s + 4);
+
+#else
+ const int8_t flat2 = flat_mask5(1, p7, p6, p5, p4, p0, q0, q4, q5, q6, q7);
filter16(mask, *thresh, flat, flat2, s - 8, s - 7, s - 6, s - 5, s - 4,
s - 3, s - 2, s - 1, s, s + 1, s + 2, s + 3, s + 4, s + 5, s + 6,
s + 7);
+#endif
+
s += p;
}
}