Commit 0fc82ea1 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Refactoring and cosmetic changes to ext-inter expt

Change-Id: Icd457480744b7734b3c412c9fed43be738373334
parent d649065e
......@@ -70,6 +70,16 @@ static INLINE int get_wedge_bits(BLOCK_SIZE sb_type) {
return WEDGE_BITS_BIG;
}
static INLINE int is_interinter_wedge_used(BLOCK_SIZE sb_type) {
(void) sb_type;
return get_wedge_bits(sb_type) > 0;
}
static INLINE int is_interintra_wedge_used(BLOCK_SIZE sb_type) {
(void) sb_type;
return 0; // get_wedge_bits(sb_type) > 0;
}
static INLINE int is_inter_singleref_mode(PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWFROMNEARMV;
}
......@@ -701,6 +711,16 @@ static INLINE int is_interintra_allowed(const MB_MODE_INFO *mbmi) {
&& is_interintra_allowed_ref(mbmi->ref_frame);
}
static INLINE int is_interintra_allowed_bsize_group(const int group) {
int i;
for (i = 0; i < BLOCK_SIZES; i++) {
if (size_group_lookup[i] == group &&
is_interintra_allowed_bsize(i))
return 1;
}
return 0;
}
static INLINE int is_interintra_pred(const MB_MODE_INFO *mbmi) {
return (mbmi->ref_frame[1] == INTRA_FRAME) && is_interintra_allowed(mbmi);
}
......
......@@ -268,24 +268,29 @@ static const vpx_prob default_inter_compound_mode_probs
{25, 29, 50, 192, 192, 128, 180, 180}, // 6 = two intra neighbours
};
static const vpx_prob default_interintra_prob[BLOCK_SIZES] = {
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
#if CONFIG_EXT_PARTITION
192, 192, 192
#endif // CONFIG_EXT_PARTITION
static const vpx_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
208, 208, 208, 208,
};
static const vpx_prob
default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
{ 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
{ 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
{ 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
{ 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
};
static const vpx_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
#if CONFIG_EXT_PARTITION
192, 192, 192
208, 208, 208
#endif // CONFIG_EXT_PARTITION
};
static const vpx_prob default_wedge_interinter_prob[BLOCK_SIZES] = {
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208, 208,
#if CONFIG_EXT_PARTITION
192, 192, 192
208, 208, 208
#endif // CONFIG_EXT_PARTITION
};
#endif // CONFIG_EXT_INTER
......@@ -337,14 +342,6 @@ const vpx_tree_index vp10_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
-II_D153_PRED, -II_D207_PRED /* 8 = II_D153_NODE */
};
static const vpx_prob
default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
{ 65, 32, 18, 144, 162, 194, 41, 51, 98 }, // block_size < 8x8
{ 132, 68, 18, 165, 217, 196, 45, 40, 78 }, // block_size < 16x16
{ 173, 80, 19, 176, 240, 193, 64, 35, 46 }, // block_size < 32x32
{ 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
};
const vpx_tree_index vp10_inter_compound_mode_tree
[TREE_SIZE(INTER_COMPOUND_MODES)] = {
-INTER_COMPOUND_OFFSET(ZERO_ZEROMV), 2,
......@@ -1172,11 +1169,11 @@ static const vpx_prob default_inter_ext_tx_prob[EXT_TX_SIZES]
#if CONFIG_EXT_INTRA
static const vpx_prob
default_intra_filter_probs[INTRA_FILTERS + 1][INTRA_FILTERS - 1] = {
{ 98, 63, 60, },
{ 98, 82, 80, },
{ 94, 65, 103, },
{ 49, 25, 24, },
{ 72, 38, 50, },
{ 98, 63, 60, },
{ 98, 82, 80, },
{ 94, 65, 103, },
{ 49, 25, 24, },
{ 72, 38, 50, },
};
static const vpx_prob default_ext_intra_probs[2] = {230, 230};
......@@ -1338,8 +1335,8 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
pre_fc->inter_compound_mode_probs[i],
counts->inter_compound_mode[i],
fc->inter_compound_mode_probs[i]);
for (i = 0; i < BLOCK_SIZES; ++i) {
if (is_interintra_allowed_bsize(i))
for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
if (is_interintra_allowed_bsize_group(i))
fc->interintra_prob[i] = mode_mv_merge_probs(pre_fc->interintra_prob[i],
counts->interintra[i]);
}
......@@ -1349,12 +1346,12 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
counts->interintra_mode[i], fc->interintra_mode_prob[i]);
}
for (i = 0; i < BLOCK_SIZES; ++i) {
if (is_interintra_allowed_bsize(i) && get_wedge_bits(i))
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
fc->wedge_interintra_prob[i] = mode_mv_merge_probs(
pre_fc->wedge_interintra_prob[i], counts->wedge_interintra[i]);
}
for (i = 0; i < BLOCK_SIZES; ++i) {
if (get_wedge_bits(i))
if (is_interinter_wedge_used(i))
fc->wedge_interinter_prob[i] = mode_mv_merge_probs(
pre_fc->wedge_interinter_prob[i], counts->wedge_interinter[i]);
}
......
......@@ -71,7 +71,7 @@ typedef struct frame_contexts {
#if CONFIG_EXT_INTER
vpx_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES - 1];
vpx_prob interintra_prob[BLOCK_SIZES];
vpx_prob interintra_prob[BLOCK_SIZE_GROUPS];
vpx_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
vpx_prob wedge_interintra_prob[BLOCK_SIZES];
vpx_prob wedge_interinter_prob[BLOCK_SIZES];
......@@ -139,7 +139,7 @@ typedef struct FRAME_COUNTS {
unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
#if CONFIG_EXT_INTER
unsigned int inter_compound_mode[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
unsigned int interintra[BLOCK_SIZES][2];
unsigned int interintra[BLOCK_SIZE_GROUPS][2];
unsigned int interintra_mode[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
unsigned int wedge_interintra[BLOCK_SIZES][2];
unsigned int wedge_interinter[BLOCK_SIZES][2];
......
This diff is collapsed.
......@@ -445,6 +445,15 @@ void vp10_combine_interintra(
BLOCK_SIZE bsize, int plane,
uint8_t *inter_pred, int inter_stride,
uint8_t *intra_pred, int intra_stride);
void vp10_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
uint8_t *upred,
uint8_t *vpred,
int ustride, int vstride,
BLOCK_SIZE bsize);
void vp10_build_interintra_predictors_sby(MACROBLOCKD *xd,
uint8_t *ypred,
int ystride,
BLOCK_SIZE bsize);
// Encoder only
void vp10_build_inter_predictors_for_planes_single_buf(
......
......@@ -428,7 +428,7 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
cm->counts.inter_compound_mode[i][j] +=
counts->inter_compound_mode[i][j];
for (i = 0; i < BLOCK_SIZES; i++)
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
for (j = 0; j < 2; j++)
cm->counts.interintra[i][j] += counts->interintra[i][j];
......
......@@ -502,7 +502,7 @@ static void extend_and_predict_highbd(const uint8_t *buf_ptr1,
buf_ptr = ((uint8_t *)mc_buf_high) + border_offset;
}
#if CONFIG_EXT_INTER
if (ref && get_wedge_bits(xd->mi[0]->mbmi.sb_type) &&
if (ref && is_interinter_wedge_used(xd->mi[0]->mbmi.sb_type) &&
xd->mi[0]->mbmi.use_wedge_interinter)
vp10_make_masked_inter_predictor(
buf_ptr, b_w, dst, dst_buf_stride,
......@@ -543,7 +543,7 @@ static void extend_and_predict(const uint8_t *buf_ptr1, int pre_buf_stride,
x0, y0, b_w, b_h, frame_width, frame_height);
buf_ptr = mc_buf + border_offset;
#if CONFIG_EXT_INTER
if (ref && get_wedge_bits(xd->mi[0]->mbmi.sb_type) &&
if (ref && is_interinter_wedge_used(xd->mi[0]->mbmi.sb_type) &&
xd->mi[0]->mbmi.use_wedge_interinter)
vp10_make_masked_inter_predictor(
buf_ptr, b_w, dst, dst_buf_stride,
......@@ -752,7 +752,7 @@ static void dec_build_inter_predictors(VP10Decoder *const pbi,
}
}
#if CONFIG_EXT_INTER
if (ref && get_wedge_bits(mi->mbmi.sb_type) &&
if (ref && is_interinter_wedge_used(mi->mbmi.sb_type) &&
mi->mbmi.use_wedge_interinter) {
vp10_make_masked_inter_predictor(
buf_ptr, buf_stride, dst, dst_buf->stride,
......@@ -3968,8 +3968,8 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
#if CONFIG_EXT_INTER
read_inter_compound_mode_probs(fc, &r);
if (cm->reference_mode != COMPOUND_REFERENCE) {
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i)) {
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
if (is_interintra_allowed_bsize_group(i)) {
vp10_diff_update_prob(&r, &fc->interintra_prob[i]);
}
}
......@@ -3978,14 +3978,14 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
vp10_diff_update_prob(&r, &fc->interintra_mode_prob[i][j]);
}
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i) && get_wedge_bits(i)) {
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i)) {
vp10_diff_update_prob(&r, &fc->wedge_interintra_prob[i]);
}
}
}
if (cm->reference_mode != SINGLE_REFERENCE) {
for (i = 0; i < BLOCK_SIZES; i++) {
if (get_wedge_bits(i)) {
if (is_interinter_wedge_used(i)) {
vp10_diff_update_prob(&r, &fc->wedge_interinter_prob[i]);
}
}
......
......@@ -1526,13 +1526,14 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
!supertx_enabled &&
#endif
is_interintra_allowed(mbmi)) {
const int interintra = vp10_read(r, cm->fc->interintra_prob[bsize]);
const int bsize_group = size_group_lookup[bsize];
const int interintra = vpx_read(r, cm->fc->interintra_prob[bsize_group]);
if (xd->counts)
xd->counts->interintra[bsize][interintra]++;
xd->counts->interintra[bsize_group][interintra]++;
assert(mbmi->ref_frame[1] == NONE);
if (interintra) {
const INTERINTRA_MODE interintra_mode =
read_interintra_mode(cm, xd, r, size_group_lookup[bsize]);
read_interintra_mode(cm, xd, r, bsize_group);
mbmi->ref_frame[1] = INTRA_FRAME;
mbmi->interintra_mode = interintra_mode;
mbmi->interintra_uv_mode = interintra_mode;
......@@ -1543,7 +1544,7 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
mbmi->angle_delta[1] = 0;
mbmi->intra_filter = INTRA_FILTER_LINEAR;
#endif // CONFIG_EXT_INTRA
if (get_wedge_bits(bsize)) {
if (is_interintra_wedge_used(bsize)) {
mbmi->use_wedge_interintra =
vp10_read(r, cm->fc->wedge_interintra_prob[bsize]);
if (xd->counts)
......@@ -1561,7 +1562,7 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
#if CONFIG_OBMC
!(is_obmc_allowed(mbmi) && mbmi->obmc) &&
#endif // CONFIG_OBMC
get_wedge_bits(bsize)) {
is_interinter_wedge_used(bsize)) {
mbmi->use_wedge_interinter =
vp10_read(r, cm->fc->wedge_interinter_prob[bsize]);
if (xd->counts)
......
......@@ -1294,14 +1294,15 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_SUPERTX
is_interintra_allowed(mbmi)) {
const int interintra = mbmi->ref_frame[1] == INTRA_FRAME;
vp10_write(w, interintra, cm->fc->interintra_prob[bsize]);
const int bsize_group = size_group_lookup[bsize];
vpx_write(w, interintra, cm->fc->interintra_prob[bsize_group]);
if (interintra) {
write_interintra_mode(
w, mbmi->interintra_mode,
cm->fc->interintra_mode_prob[size_group_lookup[bsize]]);
cm->fc->interintra_mode_prob[bsize_group]);
assert(mbmi->interintra_mode == mbmi->interintra_uv_mode);
if (get_wedge_bits(bsize)) {
vp10_write(w, mbmi->use_wedge_interintra,
if (is_interintra_wedge_used(bsize)) {
vpx_write(w, mbmi->use_wedge_interintra,
cm->fc->wedge_interintra_prob[bsize]);
if (mbmi->use_wedge_interintra) {
vp10_write_literal(w, mbmi->interintra_wedge_index,
......@@ -1315,8 +1316,8 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
#if CONFIG_OBMC
!(is_obmc_allowed(mbmi) && mbmi->obmc) &&
#endif // CONFIG_OBMC
get_wedge_bits(bsize)) {
vp10_write(w, mbmi->use_wedge_interinter,
is_interinter_wedge_used(bsize)) {
vpx_write(w, mbmi->use_wedge_interinter,
cm->fc->wedge_interinter_prob[bsize]);
if (mbmi->use_wedge_interinter)
vp10_write_literal(w, mbmi->interinter_wedge_index,
......@@ -3096,8 +3097,8 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
update_inter_compound_mode_probs(cm, &header_bc);
if (cm->reference_mode != COMPOUND_REFERENCE) {
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i)) {
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
if (is_interintra_allowed_bsize_group(i)) {
vp10_cond_prob_diff_update(&header_bc,
&fc->interintra_prob[i],
cm->counts.interintra[i]);
......@@ -3110,7 +3111,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
INTERINTRA_MODES, &header_bc);
}
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i) && get_wedge_bits(i))
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
vp10_cond_prob_diff_update(&header_bc,
&fc->wedge_interintra_prob[i],
cm->counts.wedge_interintra[i]);
......@@ -3118,7 +3119,7 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
}
if (cm->reference_mode != SINGLE_REFERENCE) {
for (i = 0; i < BLOCK_SIZES; i++)
if (get_wedge_bits(i))
if (is_interinter_wedge_used(i))
vp10_cond_prob_diff_update(&header_bc,
&fc->wedge_interinter_prob[i],
cm->counts.wedge_interinter[i]);
......
......@@ -2023,14 +2023,14 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td
!supertx_enabled &&
#endif
is_interintra_allowed(mbmi)) {
const int bsize_group = size_group_lookup[bsize];
if (mbmi->ref_frame[1] == INTRA_FRAME) {
counts->interintra[bsize][1]++;
counts->interintra_mode[size_group_lookup[bsize]]
[mbmi->interintra_mode]++;
if (get_wedge_bits(bsize))
counts->interintra[bsize_group][1]++;
counts->interintra_mode[bsize_group][mbmi->interintra_mode]++;
if (is_interintra_wedge_used(bsize))
counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++;
} else {
counts->interintra[bsize][0]++;
counts->interintra[bsize_group][0]++;
}
}
if (cm->reference_mode != SINGLE_REFERENCE &&
......@@ -2038,7 +2038,7 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td
#if CONFIG_OBMC
!(is_obmc_allowed(mbmi) && mbmi->obmc) &&
#endif // CONFIG_OBMC
get_wedge_bits(bsize)) {
is_interinter_wedge_used(bsize)) {
counts->wedge_interinter[bsize][mbmi->use_wedge_interinter]++;
}
#endif // CONFIG_EXT_INTER
......
......@@ -6644,7 +6644,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
rs = cm->interp_filter == SWITCHABLE ? vp10_get_switchable_rate(cpi, xd) : 0;
#if CONFIG_EXT_INTER
if (is_comp_pred && get_wedge_bits(bsize)) {
if (is_comp_pred && is_interinter_wedge_used(bsize)) {
int wedge_index, best_wedge_index = WEDGE_NONE, rs;
int rate_sum;
int64_t dist_sum;
......@@ -6830,14 +6830,20 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
mbmi->interintra_mode = (INTERINTRA_MODE)j;
mbmi->interintra_uv_mode = (INTERINTRA_MODE)j;
rmode = interintra_mode_cost[mbmi->interintra_mode];
vp10_build_interintra_predictors(xd,
tmp_buf,
tmp_buf + MAX_SB_SQUARE,
tmp_buf + 2 * MAX_SB_SQUARE,
MAX_SB_SIZE,
MAX_SB_SIZE,
MAX_SB_SIZE,
bsize);
vp10_build_intra_predictors_for_interintra(
xd, bsize, 0, intrapred, MAX_SB_SIZE);
vp10_combine_interintra(xd, bsize, 0, tmp_buf, MAX_SB_SIZE,
intrapred, MAX_SB_SIZE);
vp10_build_intra_predictors_for_interintra(
xd, bsize, 1, intrapred + MAX_SB_SQUARE, MAX_SB_SIZE);
vp10_build_intra_predictors_for_interintra(
xd, bsize, 2, intrapred + 2 * MAX_SB_SQUARE, MAX_SB_SIZE);
vp10_combine_interintra(xd, bsize, 1,
tmp_buf + MAX_SB_SQUARE, MAX_SB_SIZE,
intrapred + MAX_SB_SQUARE, MAX_SB_SIZE);
vp10_combine_interintra(xd, bsize, 2,
tmp_buf + 2 * MAX_SB_SQUARE, MAX_SB_SIZE,
intrapred + 2 * MAX_SB_SQUARE, MAX_SB_SIZE);
model_rd_for_sb(cpi, bsize, x, xd, &rate_sum, &dist_sum,
&skip_txfm_sb, &skip_sse_sb);
rd = RDCOST(x->rdmult, x->rddiv, rate_mv + rmode + rate_sum, dist_sum);
......@@ -6859,9 +6865,9 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
vp10_build_intra_predictors_for_interintra(
xd, bsize, 2, intrapred + 2 * MAX_SB_SQUARE, MAX_SB_SIZE);
wedge_bits = get_wedge_bits(bsize);
rmode = interintra_mode_cost[mbmi->interintra_mode];
if (wedge_bits) {
if (is_interintra_wedge_used(bsize)) {
wedge_bits = get_wedge_bits(bsize);
vp10_combine_interintra(xd, bsize, 0, tmp_buf, MAX_SB_SIZE,
intrapred, MAX_SB_SIZE);
vp10_combine_interintra(xd, bsize, 1,
......@@ -6946,9 +6952,9 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
pred_exists = 0;
tmp_rd = best_interintra_rd;
*compmode_interintra_cost =
vp10_cost_bit(cm->fc->interintra_prob[bsize], 1);
vp10_cost_bit(cm->fc->interintra_prob[size_group_lookup[bsize]], 1);
*compmode_interintra_cost += interintra_mode_cost[mbmi->interintra_mode];
if (get_wedge_bits(bsize)) {
if (is_interintra_wedge_used(bsize)) {
*compmode_interintra_cost += vp10_cost_bit(
cm->fc->wedge_interintra_prob[bsize], mbmi->use_wedge_interintra);
if (mbmi->use_wedge_interintra) {
......@@ -6957,7 +6963,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
}
} else if (is_interintra_allowed(mbmi)) {
*compmode_interintra_cost =
vp10_cost_bit(cm->fc->interintra_prob[bsize], 0);
vp10_cost_bit(cm->fc->interintra_prob[size_group_lookup[bsize]], 0);
}
#if CONFIG_EXT_INTERP
......
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