Commit 2be211e9 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Fix interpolation values and decouple interintra

Decouples interintra modes and probability models from regular
intra modes, to enable creating/optimizing new interintra modes.
Also, fixes interpolation values for 128x128 interintra and obmc.

Change-Id: I5c2016db49b8f029164e5fe84c6274d4e02ff90e
parent 8d3a4aa8
......@@ -190,8 +190,8 @@ typedef struct {
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER
PREDICTION_MODE interintra_mode;
PREDICTION_MODE interintra_uv_mode;
INTERINTRA_MODE interintra_mode;
INTERINTRA_MODE interintra_uv_mode;
// TODO(debargha): Consolidate these flags
int use_wedge_interintra;
int interintra_wedge_index;
......
......@@ -310,7 +310,7 @@ const vpx_tree_index vp10_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
-D135_PRED, -D117_PRED, /* 5 = D135_NODE */
-D45_PRED, 14, /* 6 = D45_NODE */
-D63_PRED, 16, /* 7 = D63_NODE */
-D153_PRED, -D207_PRED /* 8 = D153_NODE */
-D153_PRED, -D207_PRED /* 8 = D153_NODE */
};
const vpx_tree_index vp10_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
......@@ -325,6 +325,26 @@ const vpx_tree_index vp10_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
};
#if CONFIG_EXT_INTER
const vpx_tree_index vp10_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
-II_DC_PRED, 2, /* 0 = II_DC_NODE */
-II_TM_PRED, 4, /* 1 = II_TM_NODE */
-II_V_PRED, 6, /* 2 = II_V_NODE */
8, 12, /* 3 = II_COM_NODE */
-II_H_PRED, 10, /* 4 = II_H_NODE */
-II_D135_PRED, -II_D117_PRED, /* 5 = II_D135_NODE */
-II_D45_PRED, 14, /* 6 = II_D45_NODE */
-II_D63_PRED, 16, /* 7 = II_D63_NODE */
-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,
......@@ -1211,6 +1231,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_EXT_INTER
vp10_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
vp10_copy(fc->interintra_prob, default_interintra_prob);
vp10_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
vp10_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
vp10_copy(fc->wedge_interinter_prob, default_wedge_interinter_prob);
#endif // CONFIG_EXT_INTER
......@@ -1322,6 +1343,11 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
fc->interintra_prob[i] = mode_mv_merge_probs(pre_fc->interintra_prob[i],
counts->interintra[i]);
}
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
vpx_tree_merge_probs(
vp10_interintra_mode_tree, pre_fc->interintra_mode_prob[i],
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))
fc->wedge_interintra_prob[i] = mode_mv_merge_probs(
......
......@@ -71,6 +71,7 @@ typedef struct frame_contexts {
vpx_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES - 1];
vpx_prob interintra_prob[BLOCK_SIZES];
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];
#endif // CONFIG_EXT_INTER
......@@ -138,6 +139,7 @@ typedef struct FRAME_COUNTS {
#if CONFIG_EXT_INTER
unsigned int inter_compound_mode[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
unsigned int interintra[BLOCK_SIZES][2];
unsigned int interintra_mode[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
unsigned int wedge_interintra[BLOCK_SIZES][2];
unsigned int wedge_interinter[BLOCK_SIZES][2];
#endif // CONFIG_EXT_INTER
......@@ -195,6 +197,8 @@ extern const vpx_prob vp10_default_palette_uv_color_prob
extern const vpx_tree_index vp10_intra_mode_tree[TREE_SIZE(INTRA_MODES)];
extern const vpx_tree_index vp10_inter_mode_tree[TREE_SIZE(INTER_MODES)];
#if CONFIG_EXT_INTER
extern const vpx_tree_index vp10_interintra_mode_tree
[TREE_SIZE(INTERINTRA_MODES)];
extern const vpx_tree_index vp10_inter_compound_mode_tree
[TREE_SIZE(INTER_COMPOUND_MODES)];
#endif // CONFIG_EXT_INTER
......
......@@ -252,6 +252,23 @@ typedef uint8_t PREDICTION_MODE;
#define INTRA_MODES (TM_PRED + 1)
#if CONFIG_EXT_INTER
typedef enum {
II_DC_PRED = 0,
II_V_PRED,
II_H_PRED,
II_D45_PRED,
II_D135_PRED,
II_D117_PRED,
II_D153_PRED,
II_D207_PRED,
II_D63_PRED,
II_TM_PRED,
INTERINTRA_MODES
} INTERINTRA_MODE;
#endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTRA
typedef enum {
FILTER_DC_PRED,
......
This diff is collapsed.
......@@ -432,6 +432,10 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
for (j = 0; j < 2; j++)
cm->counts.interintra[i][j] += counts->interintra[i][j];
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
for (j = 0; j < INTERINTRA_MODES; j++)
cm->counts.interintra_mode[i][j] += counts->interintra_mode[i][j];
for (i = 0; i < BLOCK_SIZES; i++)
for (j = 0; j < 2; j++)
cm->counts.wedge_interintra[i][j] += counts->wedge_interintra[i][j];
......
......@@ -4039,6 +4039,10 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
vp10_diff_update_prob(&r, &fc->interintra_prob[i]);
}
}
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
for (j = 0; j < INTERINTRA_MODES - 1; j++)
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)) {
vp10_diff_update_prob(&r, &fc->wedge_interintra_prob[i]);
......
......@@ -62,6 +62,19 @@ static PREDICTION_MODE read_intra_mode_uv(VP10_COMMON *cm, MACROBLOCKD *xd,
return uv_mode;
}
#if CONFIG_EXT_INTER
static INTERINTRA_MODE read_interintra_mode(VP10_COMMON *cm, MACROBLOCKD *xd,
vpx_reader *r, int size_group) {
const INTERINTRA_MODE ii_mode =
(INTERINTRA_MODE)vpx_read_tree(r, vp10_interintra_mode_tree,
cm->fc->interintra_mode_prob[size_group]);
FRAME_COUNTS *counts = xd->counts;
if (counts)
++counts->interintra_mode[size_group][ii_mode];
return ii_mode;
}
#endif // CONFIG_EXT_INTER
static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
MB_MODE_INFO *mbmi,
......@@ -1518,8 +1531,8 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
xd->counts->interintra[bsize][interintra]++;
assert(mbmi->ref_frame[1] == NONE);
if (interintra) {
const PREDICTION_MODE interintra_mode =
read_intra_mode_y(cm, xd, r, size_group_lookup[bsize]);
const INTERINTRA_MODE interintra_mode =
read_interintra_mode(cm, xd, r, size_group_lookup[bsize]);
mbmi->ref_frame[1] = INTRA_FRAME;
mbmi->interintra_mode = interintra_mode;
mbmi->interintra_uv_mode = interintra_mode;
......
......@@ -115,6 +115,9 @@ static struct vp10_token ext_tx_encodings[TX_TYPES];
#if CONFIG_EXT_INTRA
static struct vp10_token intra_filter_encodings[INTRA_FILTERS];
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER
static struct vp10_token interintra_mode_encodings[INTERINTRA_MODES];
#endif // CONFIG_EXT_INTER
void vp10_encode_token_init() {
#if CONFIG_EXT_TX
......@@ -131,6 +134,9 @@ void vp10_encode_token_init() {
#if CONFIG_EXT_INTRA
vp10_tokens_from_tree(intra_filter_encodings, vp10_intra_filter_tree);
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER
vp10_tokens_from_tree(interintra_mode_encodings, vp10_interintra_mode_tree);
#endif // CONFIG_EXT_INTER
}
static void write_intra_mode(vpx_writer *w, PREDICTION_MODE mode,
......@@ -138,6 +144,14 @@ static void write_intra_mode(vpx_writer *w, PREDICTION_MODE mode,
vp10_write_token(w, vp10_intra_mode_tree, probs, &intra_mode_encodings[mode]);
}
#if CONFIG_EXT_INTER
static void write_interintra_mode(vpx_writer *w, INTERINTRA_MODE mode,
const vpx_prob *probs) {
vp10_write_token(w, vp10_interintra_mode_tree, probs,
&interintra_mode_encodings[mode]);
}
#endif // CONFIG_EXT_INTER
static void write_inter_mode(VP10_COMMON *cm,
vpx_writer *w, PREDICTION_MODE mode,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
......@@ -1282,8 +1296,9 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
const int interintra = mbmi->ref_frame[1] == INTRA_FRAME;
vpx_write(w, interintra, cm->fc->interintra_prob[bsize]);
if (interintra) {
write_intra_mode(w, mbmi->interintra_mode,
cm->fc->y_mode_prob[size_group_lookup[bsize]]);
write_interintra_mode(
w, mbmi->interintra_mode,
cm->fc->interintra_mode_prob[size_group_lookup[bsize]]);
assert(mbmi->interintra_mode == mbmi->interintra_uv_mode);
if (get_wedge_bits(bsize)) {
vpx_write(w, mbmi->use_wedge_interintra,
......@@ -3151,6 +3166,12 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
cm->counts.interintra[i]);
}
}
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
prob_diff_update(vp10_interintra_mode_tree,
cm->fc->interintra_mode_prob[i],
counts->interintra_mode[i],
INTERINTRA_MODES, &header_bc);
}
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i) && get_wedge_bits(i))
vp10_cond_prob_diff_update(&header_bc,
......
......@@ -2023,8 +2023,9 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td
#endif
is_interintra_allowed(mbmi)) {
if (mbmi->ref_frame[1] == INTRA_FRAME) {
counts->y_mode[size_group_lookup[bsize]][mbmi->interintra_mode]++;
counts->interintra[bsize][1]++;
counts->interintra_mode[size_group_lookup[bsize]]
[mbmi->interintra_mode]++;
if (get_wedge_bits(bsize))
counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++;
} else {
......
......@@ -507,6 +507,7 @@ typedef struct VP10_COMP {
#if CONFIG_EXT_INTER
unsigned int inter_compound_mode_cost[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES];
unsigned int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
int obmc_cost[BLOCK_SIZES][2];
......
......@@ -445,12 +445,16 @@ void vp10_initialize_rd_consts(VP10_COMP *cpi) {
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
vp10_cost_tokens((int *)cpi->inter_mode_cost[i],
cm->fc->inter_mode_probs[i], vp10_inter_mode_tree);
#endif
#endif // CONFIG_REF_MV
#if CONFIG_EXT_INTER
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
vp10_cost_tokens((int *)cpi->inter_compound_mode_cost[i],
cm->fc->inter_compound_mode_probs[i],
vp10_inter_compound_mode_tree);
for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
vp10_cost_tokens((int *)cpi->interintra_mode_cost[i],
cm->fc->interintra_mode_prob[i],
vp10_interintra_mode_tree);
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
for (i = BLOCK_8X8; i < BLOCK_SIZES; i++) {
......
......@@ -6202,8 +6202,8 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
#if CONFIG_EXT_INTER
int mv_idx = (this_mode == NEWFROMNEARMV) ? 1 : 0;
int_mv single_newmv[MAX_REF_FRAMES];
const int * const intra_mode_cost =
cpi->mbmode_cost[size_group_lookup[bsize]];
const unsigned int *const interintra_mode_cost =
cpi->interintra_mode_cost[size_group_lookup[bsize]];
const int is_comp_interintra_pred = (mbmi->ref_frame[1] == INTRA_FRAME);
#if CONFIG_REF_MV
uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
......@@ -6778,7 +6778,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
}
if (is_comp_interintra_pred) {
PREDICTION_MODE interintra_mode, best_interintra_mode = DC_PRED;
INTERINTRA_MODE best_interintra_mode = II_DC_PRED;
int64_t best_interintra_rd = INT64_MAX;
int rmode, rate_sum;
int64_t dist_sum;
......@@ -6810,11 +6810,10 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
restore_dst_buf(xd, orig_dst, orig_dst_stride);
mbmi->ref_frame[1] = INTRA_FRAME;
for (interintra_mode = DC_PRED; interintra_mode <= TM_PRED;
++interintra_mode) {
mbmi->interintra_mode = interintra_mode;
mbmi->interintra_uv_mode = interintra_mode;
rmode = intra_mode_cost[mbmi->interintra_mode];
for (j = 0; j < INTERINTRA_MODES; ++j) {
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,
......@@ -6828,7 +6827,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
rd = RDCOST(x->rdmult, x->rddiv, rate_mv + rmode + rate_sum, dist_sum);
if (rd < best_interintra_rd) {
best_interintra_rd = rd;
best_interintra_mode = interintra_mode;
best_interintra_mode = mbmi->interintra_mode;
}
}
mbmi->interintra_mode = best_interintra_mode;
......@@ -6845,7 +6844,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
xd, bsize, 2, intrapred + 2 * MAX_SB_SQUARE, MAX_SB_SIZE);
wedge_bits = get_wedge_bits(bsize);
rmode = intra_mode_cost[mbmi->interintra_mode];
rmode = interintra_mode_cost[mbmi->interintra_mode];
if (wedge_bits) {
vp10_combine_interintra(xd, bsize, 0, tmp_buf, MAX_SB_SIZE,
intrapred, MAX_SB_SIZE);
......@@ -6932,7 +6931,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
tmp_rd = best_interintra_rd;
*compmode_interintra_cost =
vp10_cost_bit(cm->fc->interintra_prob[bsize], 1);
*compmode_interintra_cost += intra_mode_cost[mbmi->interintra_mode];
*compmode_interintra_cost += interintra_mode_cost[mbmi->interintra_mode];
if (get_wedge_bits(bsize)) {
*compmode_interintra_cost += vp10_cost_bit(
cm->fc->wedge_interintra_prob[bsize], mbmi->use_wedge_interintra);
......
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