Commit f53d007b authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review
Browse files

Merge "Loop filter code cleanup."

parents 9482a0bf 2de3c8d2
......@@ -50,7 +50,6 @@ static void update_sharpness(loop_filter_info_n *const lfi, int sharpness_lvl) {
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 @@ static int build_lfi(const loop_filter_info_n *const lfi_n,
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 @@ static void filter_selectively_horiz(uint8_t *s, int pitch,
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 @@ static void filter_block_plane(VP9_COMMON *const cm, MACROBLOCKD *const xd,
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;
......
......@@ -27,8 +27,6 @@
typedef struct {
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,
......@@ -39,11 +37,11 @@ typedef struct {
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;
struct macroblockd;
......
......@@ -39,14 +39,14 @@ static INLINE int8_t flat_mask4(uint8_t thresh,
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 @@ static INLINE int8_t flat_mask5(uint8_t thresh,
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 @@ static INLINE void filter4(int8_t mask, uint8_t hev, uint8_t *op1,
*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 @@ static INLINE void filter8(int8_t mask, uint8_t hev, uint8_t flat,
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 @@ static INLINE void filter16(int8_t mask, uint8_t hev,
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 @@ static INLINE void filter16(int8_t mask, uint8_t hev,
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 @@ void vp9_mb_lpf_vertical_edge_w_c(uint8_t *s, int p,
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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment