Wedge refactoring to handle signs better

Mostly refactoring. Handles signs better though results are
more or less neutral.

Change-Id: If499537c8f8da4f34d104ebfda072eb4c85fb12f
This commit is contained in:
Debargha Mukherjee
2016-05-17 07:10:39 -07:00
parent 011f020447
commit e5de2ad632
5 changed files with 358 additions and 356 deletions

View File

@@ -23,7 +23,11 @@
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
#define NSMOOTHERS 2
// Set to one to use larger codebooks
#define USE_LARGE_WEDGE_CODEBOOK 0
#define NSMOOTHERS 1
static int get_masked_weight(int m, int smoothness) {
#define SMOOTHER_LEN 32
static const uint8_t smoothfn[NSMOOTHERS][2 * SMOOTHER_LEN + 1] = {
@@ -37,16 +41,6 @@ static int get_masked_weight(int m, int smoothness) {
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64,
}, {
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 2, 2,
3, 3, 4, 4, 5, 6, 8, 9,
11, 13, 15, 17, 20, 23, 26, 29,
32,
35, 38, 41, 44, 47, 49, 51, 53,
55, 56, 58, 59, 60, 60, 61, 61,
62, 62, 63, 63, 63, 63, 63, 63,
64, 64, 64, 64, 64, 64, 64, 64,
}
};
if (m < -SMOOTHER_LEN)
@@ -57,18 +51,6 @@ static int get_masked_weight(int m, int smoothness) {
return smoothfn[smoothness][m + SMOOTHER_LEN];
}
// Angles are with respect to horizontal anti-clockwise
typedef enum {
WEDGE_HORIZONTAL = 0,
WEDGE_VERTICAL = 1,
WEDGE_OBLIQUE27 = 2,
WEDGE_OBLIQUE63 = 3,
WEDGE_OBLIQUE117 = 4,
WEDGE_OBLIQUE153 = 5,
WEDGE_DIRECTIONS
} WedgeDirectionType;
#define WEDGE_PARMS 4
// [smoother][negative][direction]
DECLARE_ALIGNED(
@@ -76,6 +58,314 @@ DECLARE_ALIGNED(
wedge_mask_obl[NSMOOTHERS][2][WEDGE_DIRECTIONS]
[MASK_MASTER_SIZE * MASK_MASTER_SIZE]);
DECLARE_ALIGNED(
16, static uint8_t,
wedge_signflip_lookup[BLOCK_SIZES][MAX_WEDGE_TYPES]);
// Some unused wedge codebooks left temporarily to facilitate experiments.
// To be removed when setteld.
static wedge_code_type wedge_codebook_8_hgtw[8] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 6},
};
static wedge_code_type wedge_codebook_8_hltw[8] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 6, 4},
};
static wedge_code_type wedge_codebook_8_heqw[8] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_HORIZONTAL, 4, 2},
{WEDGE_HORIZONTAL, 4, 6},
{WEDGE_VERTICAL, 2, 4},
{WEDGE_VERTICAL, 6, 4},
};
#if !USE_LARGE_WEDGE_CODEBOOK
static const wedge_code_type wedge_codebook_16_hgtw[16] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_HORIZONTAL, 4, 2},
{WEDGE_HORIZONTAL, 4, 4},
{WEDGE_HORIZONTAL, 4, 6},
{WEDGE_VERTICAL, 4, 4},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 6, 4},
};
static const wedge_code_type wedge_codebook_16_hltw[16] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_VERTICAL, 2, 4},
{WEDGE_VERTICAL, 4, 4},
{WEDGE_VERTICAL, 6, 4},
{WEDGE_HORIZONTAL, 4, 4},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 6, 4},
};
static const wedge_code_type wedge_codebook_16_heqw[16] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_HORIZONTAL, 4, 2},
{WEDGE_HORIZONTAL, 4, 6},
{WEDGE_VERTICAL, 2, 4},
{WEDGE_VERTICAL, 6, 4},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 6, 4},
};
const wedge_params_type wedge_params_lookup[BLOCK_SIZES] = {
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{4, wedge_codebook_16_heqw, wedge_signflip_lookup[3], 0},
{4, wedge_codebook_16_hgtw, wedge_signflip_lookup[4], 0},
{4, wedge_codebook_16_hltw, wedge_signflip_lookup[5], 0},
{4, wedge_codebook_16_heqw, wedge_signflip_lookup[6], 0},
{4, wedge_codebook_16_hgtw, wedge_signflip_lookup[7], 0},
{4, wedge_codebook_16_hltw, wedge_signflip_lookup[8], 0},
{4, wedge_codebook_16_heqw, wedge_signflip_lookup[9], 0},
{0, wedge_codebook_8_hgtw, wedge_signflip_lookup[10], 0},
{0, wedge_codebook_8_hltw, wedge_signflip_lookup[11], 0},
{0, wedge_codebook_8_heqw, wedge_signflip_lookup[12], 0},
#if CONFIG_EXT_PARTITION
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
#endif // CONFIG_EXT_PARTITION
};
#else
static const wedge_code_type wedge_codebook_32_hgtw[32] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_HORIZONTAL, 4, 2},
{WEDGE_HORIZONTAL, 4, 4},
{WEDGE_HORIZONTAL, 4, 6},
{WEDGE_VERTICAL, 4, 4},
{WEDGE_OBLIQUE27, 4, 1},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 3},
{WEDGE_OBLIQUE27, 4, 5},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE27, 4, 7},
{WEDGE_OBLIQUE153, 4, 1},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 3},
{WEDGE_OBLIQUE153, 4, 5},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE153, 4, 7},
{WEDGE_OBLIQUE63, 1, 4},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 3, 4},
{WEDGE_OBLIQUE63, 5, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE63, 7, 4},
{WEDGE_OBLIQUE117, 1, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 3, 4},
{WEDGE_OBLIQUE117, 5, 4},
{WEDGE_OBLIQUE117, 6, 4},
{WEDGE_OBLIQUE117, 7, 4},
};
static const wedge_code_type wedge_codebook_32_hltw[32] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_VERTICAL, 2, 4},
{WEDGE_VERTICAL, 4, 4},
{WEDGE_VERTICAL, 6, 4},
{WEDGE_HORIZONTAL, 4, 4},
{WEDGE_OBLIQUE27, 4, 1},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 3},
{WEDGE_OBLIQUE27, 4, 5},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE27, 4, 7},
{WEDGE_OBLIQUE153, 4, 1},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 3},
{WEDGE_OBLIQUE153, 4, 5},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE153, 4, 7},
{WEDGE_OBLIQUE63, 1, 4},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 3, 4},
{WEDGE_OBLIQUE63, 5, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE63, 7, 4},
{WEDGE_OBLIQUE117, 1, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 3, 4},
{WEDGE_OBLIQUE117, 5, 4},
{WEDGE_OBLIQUE117, 6, 4},
{WEDGE_OBLIQUE117, 7, 4},
};
static const wedge_code_type wedge_codebook_32_heqw[32] = {
{WEDGE_OBLIQUE27, 4, 4},
{WEDGE_OBLIQUE63, 4, 4},
{WEDGE_OBLIQUE117, 4, 4},
{WEDGE_OBLIQUE153, 4, 4},
{WEDGE_HORIZONTAL, 4, 2},
{WEDGE_HORIZONTAL, 4, 6},
{WEDGE_VERTICAL, 2, 4},
{WEDGE_VERTICAL, 6, 4},
{WEDGE_OBLIQUE27, 4, 1},
{WEDGE_OBLIQUE27, 4, 2},
{WEDGE_OBLIQUE27, 4, 3},
{WEDGE_OBLIQUE27, 4, 5},
{WEDGE_OBLIQUE27, 4, 6},
{WEDGE_OBLIQUE27, 4, 7},
{WEDGE_OBLIQUE153, 4, 1},
{WEDGE_OBLIQUE153, 4, 2},
{WEDGE_OBLIQUE153, 4, 3},
{WEDGE_OBLIQUE153, 4, 5},
{WEDGE_OBLIQUE153, 4, 6},
{WEDGE_OBLIQUE153, 4, 7},
{WEDGE_OBLIQUE63, 1, 4},
{WEDGE_OBLIQUE63, 2, 4},
{WEDGE_OBLIQUE63, 3, 4},
{WEDGE_OBLIQUE63, 5, 4},
{WEDGE_OBLIQUE63, 6, 4},
{WEDGE_OBLIQUE63, 7, 4},
{WEDGE_OBLIQUE117, 1, 4},
{WEDGE_OBLIQUE117, 2, 4},
{WEDGE_OBLIQUE117, 3, 4},
{WEDGE_OBLIQUE117, 5, 4},
{WEDGE_OBLIQUE117, 6, 4},
{WEDGE_OBLIQUE117, 7, 4},
};
const wedge_params_type wedge_params_lookup[BLOCK_SIZES] = {
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{5, wedge_codebook_32_heqw, wedge_signflip_lookup[3], 0},
{5, wedge_codebook_32_hgtw, wedge_signflip_lookup[4], 0},
{5, wedge_codebook_32_hltw, wedge_signflip_lookup[5], 0},
{5, wedge_codebook_32_heqw, wedge_signflip_lookup[6], 0},
{5, wedge_codebook_32_hgtw, wedge_signflip_lookup[7], 0},
{5, wedge_codebook_32_hltw, wedge_signflip_lookup[8], 0},
{5, wedge_codebook_32_heqw, wedge_signflip_lookup[9], 0},
{0, wedge_codebook_8_hgtw, wedge_signflip_lookup[10], 0},
{0, wedge_codebook_8_hltw, wedge_signflip_lookup[11], 0},
{0, wedge_codebook_8_heqw, wedge_signflip_lookup[12], 0},
#if CONFIG_EXT_PARTITION
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
{0, NULL, NULL, 0},
#endif // CONFIG_EXT_PARTITION
};
#endif // USE_LARGE_WEDGE_CODEBOOK
static const uint8_t *get_wedge_mask_inplace(int wedge_index,
int neg,
BLOCK_SIZE sb_type) {
const uint8_t *master;
const int bh = 4 << b_height_log2_lookup[sb_type];
const int bw = 4 << b_width_log2_lookup[sb_type];
const wedge_code_type *a =
wedge_params_lookup[sb_type].codebook + wedge_index;
const int smoother = wedge_params_lookup[sb_type].smoother;
int woff, hoff;
const uint8_t wsignflip = wedge_params_lookup[sb_type].signflip[wedge_index];
assert(wedge_index >= 0 &&
wedge_index < (1 << get_wedge_bits_lookup(sb_type)));
woff = (a->x_offset * bw) >> 3;
hoff = (a->y_offset * bh) >> 3;
master = wedge_mask_obl[smoother][neg ^ wsignflip][a->direction] +
MASK_MASTER_STRIDE * (MASK_MASTER_SIZE / 2 - hoff) +
MASK_MASTER_SIZE / 2 - woff;
return master;
}
const uint8_t *vp10_get_soft_mask(int wedge_index,
int wedge_sign,
BLOCK_SIZE sb_type,
int offset_x,
int offset_y) {
const uint8_t *mask =
get_wedge_mask_inplace(wedge_index, wedge_sign, sb_type);
if (mask)
mask -= (offset_x + offset_y * MASK_MASTER_STRIDE);
return mask;
}
// If the signs for the wedges for various blocksizes are
// inconsistent flip the sign flag. Do it only once for every
// wedge codebook.
static void init_wedge_signs() {
BLOCK_SIZE sb_type;
memset(wedge_signflip_lookup, 0, sizeof(wedge_signflip_lookup));
for (sb_type = BLOCK_4X4; sb_type < BLOCK_SIZES; ++sb_type) {
const int bw = 4 * num_4x4_blocks_wide_lookup[sb_type];
const int bh = 4 * num_4x4_blocks_high_lookup[sb_type];
const wedge_params_type wedge_params = wedge_params_lookup[sb_type];
const int wbits = wedge_params.bits;
const int wtypes = 1 << wbits;
int i, w;
if (wbits == 0) continue;
for (w = 0; w < wtypes; ++w) {
const uint8_t *mask = get_wedge_mask_inplace(w, 0, sb_type);
int sum = 0;
for (i = 0; i < bw; ++i)
sum += mask[i];
for (i = 0; i < bh; ++i)
sum += mask[i * MASK_MASTER_STRIDE];
sum = (sum + (bw + bh) / 2) / (bw + bh);
wedge_params.signflip[w] = (sum < 32);
}
}
}
// Equation of line: f(x, y) = a[0]*(x - a[2]*w/8) + a[1]*(y - a[3]*h/8) = 0
void vp10_init_wedge_masks() {
int i, j, s;
@@ -110,304 +400,7 @@ void vp10_init_wedge_masks() {
(1 << WEDGE_WEIGHT_BITS) - get_masked_weight(x, s);
}
}
}
static const int wedge_params_4[1 << WEDGE_BITS_2]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 1},
{WEDGE_OBLIQUE63, 4, 4, 1},
{WEDGE_OBLIQUE117, 4, 4, 1},
{WEDGE_OBLIQUE153, 4, 4, 1},
};
static const int wedge_params_8_hgtw[1 << WEDGE_BITS_3]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 1},
{WEDGE_OBLIQUE63, 4, 4, 1},
{WEDGE_OBLIQUE117, 4, 4, 1},
{WEDGE_OBLIQUE153, 4, 4, 1},
{WEDGE_OBLIQUE27, 4, 2, 1},
{WEDGE_OBLIQUE27, 4, 6, 1},
{WEDGE_OBLIQUE153, 4, 2, 1},
{WEDGE_OBLIQUE153, 4, 6, 1},
};
static const int wedge_params_8_hltw[1 << WEDGE_BITS_3]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 1},
{WEDGE_OBLIQUE63, 4, 4, 1},
{WEDGE_OBLIQUE117, 4, 4, 1},
{WEDGE_OBLIQUE153, 4, 4, 1},
{WEDGE_OBLIQUE63, 2, 4, 1},
{WEDGE_OBLIQUE63, 6, 4, 1},
{WEDGE_OBLIQUE117, 2, 4, 1},
{WEDGE_OBLIQUE117, 6, 4, 1},
};
static const int wedge_params_8_heqw[1 << WEDGE_BITS_3]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 1},
{WEDGE_OBLIQUE63, 4, 4, 1},
{WEDGE_OBLIQUE117, 4, 4, 1},
{WEDGE_OBLIQUE153, 4, 4, 1},
{WEDGE_HORIZONTAL, 4, 2, 1},
{WEDGE_HORIZONTAL, 4, 6, 1},
{WEDGE_VERTICAL, 2, 4, 1},
{WEDGE_VERTICAL, 6, 4, 1},
};
static const int wedge_params_16_hgtw[1 << WEDGE_BITS_4]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 2, 0},
{WEDGE_HORIZONTAL, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 6, 0},
{WEDGE_VERTICAL, 4, 4, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
};
static const int wedge_params_16_hltw[1 << WEDGE_BITS_4]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_VERTICAL, 2, 4, 0},
{WEDGE_VERTICAL, 4, 4, 0},
{WEDGE_VERTICAL, 6, 4, 0},
{WEDGE_HORIZONTAL, 4, 4, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
};
static const int wedge_params_16_heqw[1 << WEDGE_BITS_4]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 2, 0},
{WEDGE_HORIZONTAL, 4, 6, 0},
{WEDGE_VERTICAL, 2, 4, 0},
{WEDGE_VERTICAL, 6, 4, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
};
static const int wedge_params_32_hgtw[1 << WEDGE_BITS_5]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 2, 0},
{WEDGE_HORIZONTAL, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 6, 0},
{WEDGE_VERTICAL, 4, 4, 0},
{WEDGE_OBLIQUE27, 4, 1, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 3, 0},
{WEDGE_OBLIQUE27, 4, 5, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE27, 4, 7, 0},
{WEDGE_OBLIQUE153, 4, 1, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 3, 0},
{WEDGE_OBLIQUE153, 4, 5, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 7, 0},
{WEDGE_OBLIQUE63, 1, 4, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 3, 4, 0},
{WEDGE_OBLIQUE63, 5, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE63, 7, 4, 0},
{WEDGE_OBLIQUE117, 1, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 3, 4, 0},
{WEDGE_OBLIQUE117, 5, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
{WEDGE_OBLIQUE117, 7, 4, 0},
};
static const int wedge_params_32_hltw[1 << WEDGE_BITS_5]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_VERTICAL, 2, 4, 0},
{WEDGE_VERTICAL, 4, 4, 0},
{WEDGE_VERTICAL, 6, 4, 0},
{WEDGE_HORIZONTAL, 4, 4, 0},
{WEDGE_OBLIQUE27, 4, 1, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 3, 0},
{WEDGE_OBLIQUE27, 4, 5, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE27, 4, 7, 0},
{WEDGE_OBLIQUE153, 4, 1, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 3, 0},
{WEDGE_OBLIQUE153, 4, 5, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 7, 0},
{WEDGE_OBLIQUE63, 1, 4, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 3, 4, 0},
{WEDGE_OBLIQUE63, 5, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE63, 7, 4, 0},
{WEDGE_OBLIQUE117, 1, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 3, 4, 0},
{WEDGE_OBLIQUE117, 5, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
{WEDGE_OBLIQUE117, 7, 4, 0},
};
static const int wedge_params_32_heqw[1 << WEDGE_BITS_5]
[WEDGE_PARMS] = {
{WEDGE_OBLIQUE27, 4, 4, 0},
{WEDGE_OBLIQUE63, 4, 4, 0},
{WEDGE_OBLIQUE117, 4, 4, 0},
{WEDGE_OBLIQUE153, 4, 4, 0},
{WEDGE_HORIZONTAL, 4, 2, 0},
{WEDGE_HORIZONTAL, 4, 6, 0},
{WEDGE_VERTICAL, 2, 4, 0},
{WEDGE_VERTICAL, 6, 4, 0},
{WEDGE_OBLIQUE27, 4, 1, 0},
{WEDGE_OBLIQUE27, 4, 2, 0},
{WEDGE_OBLIQUE27, 4, 3, 0},
{WEDGE_OBLIQUE27, 4, 5, 0},
{WEDGE_OBLIQUE27, 4, 6, 0},
{WEDGE_OBLIQUE27, 4, 7, 0},
{WEDGE_OBLIQUE153, 4, 1, 0},
{WEDGE_OBLIQUE153, 4, 2, 0},
{WEDGE_OBLIQUE153, 4, 3, 0},
{WEDGE_OBLIQUE153, 4, 5, 0},
{WEDGE_OBLIQUE153, 4, 6, 0},
{WEDGE_OBLIQUE153, 4, 7, 0},
{WEDGE_OBLIQUE63, 1, 4, 0},
{WEDGE_OBLIQUE63, 2, 4, 0},
{WEDGE_OBLIQUE63, 3, 4, 0},
{WEDGE_OBLIQUE63, 5, 4, 0},
{WEDGE_OBLIQUE63, 6, 4, 0},
{WEDGE_OBLIQUE63, 7, 4, 0},
{WEDGE_OBLIQUE117, 1, 4, 0},
{WEDGE_OBLIQUE117, 2, 4, 0},
{WEDGE_OBLIQUE117, 3, 4, 0},
{WEDGE_OBLIQUE117, 5, 4, 0},
{WEDGE_OBLIQUE117, 6, 4, 0},
{WEDGE_OBLIQUE117, 7, 4, 0},
};
static const int *get_wedge_params_lookup[BLOCK_SIZES] = {
NULL,
NULL,
NULL,
&wedge_params_16_heqw[0][0],
&wedge_params_16_hgtw[0][0],
&wedge_params_16_hltw[0][0],
&wedge_params_16_heqw[0][0],
&wedge_params_16_hgtw[0][0],
&wedge_params_16_hltw[0][0],
&wedge_params_16_heqw[0][0],
NULL,
NULL,
NULL,
#if CONFIG_EXT_PARTITION
NULL,
NULL,
NULL,
#endif // CONFIG_EXT_PARTITION
};
static const int *get_wedge_params(int wedge_index,
BLOCK_SIZE sb_type) {
const int *a = NULL;
if (wedge_index != WEDGE_NONE) {
return get_wedge_params_lookup[sb_type] + WEDGE_PARMS * wedge_index;
}
return a;
}
static const uint8_t *get_wedge_mask_inplace(int wedge_index,
int neg,
BLOCK_SIZE sb_type) {
const uint8_t *master;
const int bh = 4 << b_height_log2_lookup[sb_type];
const int bw = 4 << b_width_log2_lookup[sb_type];
const int *a = get_wedge_params(wedge_index, sb_type);
int woff, hoff;
if (!a) return NULL;
woff = (a[1] * bw) >> 3;
hoff = (a[2] * bh) >> 3;
master = wedge_mask_obl[a[3]][neg][a[0]] +
MASK_MASTER_STRIDE * (MASK_MASTER_SIZE / 2 - hoff) +
MASK_MASTER_SIZE / 2 - woff;
return master;
}
const uint8_t *vp10_get_soft_mask(int wedge_index,
int wedge_sign,
BLOCK_SIZE sb_type,
int offset_x,
int offset_y) {
const uint8_t *mask =
get_wedge_mask_inplace(wedge_index, wedge_sign, sb_type);
if (mask)
mask -= (offset_x + offset_y * MASK_MASTER_STRIDE);
return mask;
init_wedge_signs();
}
static void build_masked_compound(uint8_t *dst, int dst_stride,

View File

@@ -147,51 +147,60 @@ static INLINE void highbd_inter_predictor(const uint8_t *src, int src_stride,
#endif // CONFIG_VP9_HIGHBITDEPTH
#if CONFIG_EXT_INTER
#define WEDGE_BITS_2 2
#define WEDGE_BITS_3 3
#define WEDGE_BITS_4 4
#define WEDGE_BITS_5 5
#define WEDGE_NONE -1
#define MAX_WEDGE_TYPES (1 << 5)
#define WEDGE_WEIGHT_BITS 6
static const int get_wedge_bits_lookup[BLOCK_SIZES] = {
0,
0,
0,
WEDGE_BITS_4,
WEDGE_BITS_4,
WEDGE_BITS_4,
WEDGE_BITS_4,
WEDGE_BITS_4,
WEDGE_BITS_4,
WEDGE_BITS_4,
0,
0,
0,
#if CONFIG_EXT_PARTITION
0,
0,
0,
#endif // CONFIG_EXT_PARTITION
};
#define WEDGE_NONE -1
// Angles are with respect to horizontal anti-clockwise
typedef enum {
WEDGE_HORIZONTAL = 0,
WEDGE_VERTICAL = 1,
WEDGE_OBLIQUE27 = 2,
WEDGE_OBLIQUE63 = 3,
WEDGE_OBLIQUE117 = 4,
WEDGE_OBLIQUE153 = 5,
WEDGE_DIRECTIONS
} WedgeDirectionType;
// 3-tuple: {direction, x_offset, y_offset}
typedef struct {
WedgeDirectionType direction;
int x_offset;
int y_offset;
} wedge_code_type;
typedef struct {
int bits;
const wedge_code_type *codebook;
uint8_t *signflip;
int smoother;
} wedge_params_type;
extern const wedge_params_type wedge_params_lookup[BLOCK_SIZES];
static INLINE int get_wedge_bits_lookup(BLOCK_SIZE sb_type) {
return wedge_params_lookup[sb_type].bits;
}
static INLINE int is_interinter_wedge_used(BLOCK_SIZE sb_type) {
(void) sb_type;
return get_wedge_bits_lookup[sb_type] > 0;
return wedge_params_lookup[sb_type].bits > 0;
}
static INLINE int get_interinter_wedge_bits(BLOCK_SIZE sb_type) {
const int wbits = get_wedge_bits_lookup[sb_type];
const int wbits = wedge_params_lookup[sb_type].bits;
return (wbits > 0) ? wbits + 1 : 0;
}
static INLINE int is_interintra_wedge_used(BLOCK_SIZE sb_type) {
(void) sb_type;
return get_wedge_bits_lookup[sb_type] > 0;
return wedge_params_lookup[sb_type].bits > 0;
}
static INLINE int get_interintra_wedge_bits(BLOCK_SIZE sb_type) {
return get_wedge_bits_lookup[sb_type];
return wedge_params_lookup[sb_type].bits;
}
#endif // CONFIG_EXT_INTER

View File

@@ -1577,7 +1577,7 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
xd->counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++;
if (mbmi->use_wedge_interintra) {
mbmi->interintra_wedge_index =
vp10_read_literal(r, get_wedge_bits_lookup[bsize]);
vp10_read_literal(r, get_wedge_bits_lookup(bsize));
mbmi->interintra_wedge_sign = 0;
}
}
@@ -1610,7 +1610,7 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
xd->counts->wedge_interinter[bsize][mbmi->use_wedge_interinter]++;
if (mbmi->use_wedge_interinter) {
mbmi->interinter_wedge_index =
vp10_read_literal(r, get_wedge_bits_lookup[bsize]);
vp10_read_literal(r, get_wedge_bits_lookup(bsize));
mbmi->interinter_wedge_sign = vp10_read_bit(r);
}
}

View File

@@ -1338,7 +1338,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
cm->fc->wedge_interintra_prob[bsize]);
if (mbmi->use_wedge_interintra) {
vp10_write_literal(w, mbmi->interintra_wedge_index,
get_wedge_bits_lookup[bsize]);
get_wedge_bits_lookup(bsize));
assert(mbmi->interintra_wedge_sign == 0);
}
}
@@ -1368,7 +1368,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
cm->fc->wedge_interinter_prob[bsize]);
if (mbmi->use_wedge_interinter) {
vp10_write_literal(w, mbmi->interinter_wedge_index,
get_wedge_bits_lookup[bsize]);
get_wedge_bits_lookup(bsize));
vp10_write_bit(w, mbmi->interinter_wedge_sign);
}
}

View File

@@ -7146,7 +7146,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
mbmi->use_wedge_interinter = 1;
rs = vp10_cost_literal(get_interinter_wedge_bits(bsize)) +
vp10_cost_bit(cm->fc->wedge_interinter_prob[bsize], 1);
wedge_types = (1 << get_wedge_bits_lookup[bsize]);
wedge_types = (1 << get_wedge_bits_lookup(bsize));
vp10_build_inter_predictors_for_planes_single_buf(
xd, bsize, 0, 0, mi_row, mi_col, 0, preds0, strides);
@@ -7384,7 +7384,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
// Disbale wedge search if source variance is small
if (x->source_variance > cpi->sf.disable_wedge_search_var_thresh) {
mbmi->use_wedge_interintra = 1;
wedge_types = (1 << get_wedge_bits_lookup[bsize]);
wedge_types = (1 << get_wedge_bits_lookup(bsize));
rwedge = vp10_cost_literal(get_interintra_wedge_bits(bsize)) +
vp10_cost_bit(cm->fc->wedge_interintra_prob[bsize], 1);
for (wedge_index = 0; wedge_index < wedge_types; ++wedge_index) {