Created COMPOUND_MODES experiment.

COMPOUND_MODES experiment encodes separate MV modes for each frame in a compound
reference prediction.  Added modes NEAREST_NEARESTMV, ZERO_ZEROMV,
NEW_NEWMV, NEAREST_NEARMV, NEAR_NEARESTMV, NEW_NEARESTMV, NEAR_NEWMV,
NEW_NEARMV, and NEAREST_NEWMV.

Also enhances the wedge-partition expt to work better with compound
modes.

Results:
derflr +0.227
All experiments on: derflr +5.218

Change-Id: I719e8a34826bf1f1fe3988dac5733a845a89ef2b
This commit is contained in:
Spencer Egart 2014-11-14 11:55:58 -08:00 committed by Deb Mukherjee
parent db5dd49996
commit 347c31b48f
20 changed files with 1302 additions and 86 deletions

1
configure vendored
View File

@ -290,6 +290,7 @@ EXPERIMENT_LIST="
copy_mode
interintra
wedge_partition
compound_modes
"
CONFIG_LIST="
external_build

View File

@ -77,6 +77,17 @@ typedef enum {
NEARMV,
ZEROMV,
NEWMV,
#if CONFIG_COMPOUND_MODES
NEAREST_NEARESTMV,
NEAREST_NEARMV,
NEAR_NEARESTMV,
NEAREST_NEWMV,
NEW_NEARESTMV,
NEAR_NEWMV,
NEW_NEARMV,
ZERO_ZEROMV,
NEW_NEWMV,
#endif
MB_MODE_COUNT
} PREDICTION_MODE;
@ -94,12 +105,26 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= NEWMV;
}
#if CONFIG_COMPOUND_MODES
static INLINE int is_inter_compound_mode(PREDICTION_MODE mode) {
return mode >= NEAREST_NEARESTMV && mode <= NEW_NEWMV;
}
#endif
#define INTRA_MODES (TM_PRED + 1)
#define INTER_MODES (1 + NEWMV - NEARESTMV)
#define INTER_OFFSET(mode) ((mode) - NEARESTMV)
#if CONFIG_COMPOUND_MODES
#define INTER_COMPOUND_MODES (1 + NEW_NEWMV - NEAREST_NEARESTMV)
#define INTER_COMPOUND_OFFSET(mode) ((mode) - NEAREST_NEARESTMV)
#endif
#if CONFIG_TX64X64
#define MAXTXLEN 64
#else
@ -296,6 +321,7 @@ extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES];
#if CONFIG_SUPERTX
#define PARTITION_SUPERTX_CONTEXTS 2
#if CONFIG_TX64X64
#define MAX_SUPERTX_BLOCK_SIZE BLOCK_64X64
#else

View File

@ -188,4 +188,4 @@ const TX_SIZE uvsupertx_size_lookup[TX_SIZES][2][2] = {
const int partition_supertx_context_lookup[PARTITION_TYPES] = {
-1, 0, 0, 1
};
#endif
#endif // CONFIG_SUPERTX

View File

@ -246,6 +246,19 @@ static const vp9_prob default_inter_mode_probs[INTER_MODE_CONTEXTS]
{25, 29, 30}, // 6 = two intra neighbours
};
#if CONFIG_COMPOUND_MODES
static const vp9_prob default_inter_compound_mode_probs
[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES - 1] = {
{ 2, 173, 68, 192, 192, 128, 180, 180}, // 0 = both zero mv
{ 7, 145, 160, 192, 192, 128, 180, 180}, // 1 = 1 zero + 1 predicted
{ 7, 166, 126, 192, 192, 128, 180, 180}, // 2 = two predicted mvs
{ 7, 94, 132, 192, 192, 128, 180, 180}, // 3 = 1 pred/zero, 1 new
{ 8, 64, 64, 192, 192, 128, 180, 180}, // 4 = two new mvs
{17, 81, 52, 192, 192, 128, 180, 180}, // 5 = one intra neighbour
{25, 29, 50, 192, 192, 128, 180, 180}, // 6 = two intra neighbours
};
#endif // CONFIG_COMPOUND_MODES
/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
const vp9_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
-DC_PRED, 2, /* 0 = DC_NODE */
@ -265,6 +278,21 @@ const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
-INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV)
};
#if CONFIG_COMPOUND_MODES
const vp9_tree_index vp9_inter_compound_mode_tree
[TREE_SIZE(INTER_COMPOUND_MODES)] = {
-INTER_COMPOUND_OFFSET(ZERO_ZEROMV), 2,
-INTER_COMPOUND_OFFSET(NEAREST_NEARESTMV), 4,
6, -INTER_COMPOUND_OFFSET(NEW_NEWMV),
8, 10,
-INTER_COMPOUND_OFFSET(NEAREST_NEARMV),
-INTER_COMPOUND_OFFSET(NEAR_NEARESTMV),
12, 14,
-INTER_COMPOUND_OFFSET(NEAREST_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARESTMV),
-INTER_COMPOUND_OFFSET(NEAR_NEWMV), -INTER_COMPOUND_OFFSET(NEW_NEARMV),
};
#endif // CONFIG_COMPOUND_MODES
const vp9_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)] = {
-PARTITION_NONE, 2,
-PARTITION_HORZ, 4,
@ -451,6 +479,9 @@ void vp9_init_mode_probs(FRAME_CONTEXT *fc) {
fc->tx_probs = default_tx_probs;
vp9_copy(fc->skip_probs, default_skip_probs);
vp9_copy(fc->inter_mode_probs, default_inter_mode_probs);
#if CONFIG_COMPOUND_MODES
vp9_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
#endif // CONFIG_COMPOUND_MODES
#if CONFIG_FILTERINTRA
vp9_copy(fc->filterintra_prob, default_filterintra_prob);
#endif // CONFIG_FILTERINTRA
@ -521,6 +552,14 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
adapt_probs(vp9_inter_mode_tree, pre_fc->inter_mode_probs[i],
counts->inter_mode[i], fc->inter_mode_probs[i]);
#if CONFIG_COMPOUND_MODES
for (i = 0; i < INTER_MODE_CONTEXTS; i++)
adapt_probs(vp9_inter_compound_mode_tree,
pre_fc->inter_compound_mode_probs[i],
counts->inter_compound_mode[i],
fc->inter_compound_mode_probs[i]);
#endif // CONFIG_COMPOUND_MODES
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
adapt_probs(vp9_intra_mode_tree, pre_fc->y_mode_prob[i],
counts->y_mode[i], fc->y_mode_prob[i]);

View File

@ -49,6 +49,10 @@ typedef struct frame_contexts {
vp9_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS - 1];
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
#if CONFIG_COMPOUND_MODES
vp9_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES - 1];
#endif // CONFIG_COMPOUND_MODES
vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob single_ref_prob[REF_CONTEXTS][2];
@ -92,6 +96,9 @@ typedef struct {
unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
#if CONFIG_COMPOUND_MODES
unsigned int inter_compound_mode[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
#endif // CONFIG_COMPOUND_MODES
unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
unsigned int single_ref[REF_CONTEXTS][2][2];
@ -144,6 +151,11 @@ extern const vp9_tree_index vp9_copy_mode_tree_l2[TREE_SIZE(2)];
extern const vp9_tree_index vp9_copy_mode_tree[TREE_SIZE(COPY_MODE_COUNT - 1)];
#endif // CONFIG_COPY_MODE
#if CONFIG_COMPOUND_MODES
extern const vp9_tree_index vp9_inter_compound_mode_tree
[TREE_SIZE(INTER_COMPOUND_MODES)];
#endif
void vp9_setup_past_independence(struct VP9Common *cm);
void vp9_init_mode_probs(FRAME_CONTEXT *fc);

View File

@ -215,7 +215,10 @@ static const uint16_t above_border_uv = 0x000f;
static const int mode_lf_lut[MB_MODE_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // INTRA_MODES
1, 1, 0, 1 // INTER_MODES (ZEROMV == 0)
1, 1, 0, 1, // INTER_MODES (ZEROMV == 0)
#if CONFIG_COMPOUND_MODES
1, 1, 1, 1, 1, 1, 1, 0, 1 // INTER_COMPOUND_MODES (ZERO_ZEROMV == 0)
#endif
};
static void update_sharpness(loop_filter_info_n *lfi, int sharpness_lvl) {

View File

@ -59,6 +59,17 @@ static const int mode_2_counter[MB_MODE_COUNT] = {
0, // NEARMV
3, // ZEROMV
1, // NEWMV
#if CONFIG_COMPOUND_MODES
0, // NEAREST_NEARESTMV
0, // NEAREST_NEARMV
0, // NEAR_NEARESTMV
1, // NEAREST_NEWMV
1, // NEW_NEARESTMV
1, // NEAR_NEWMV
1, // NEAR_NEWMV
3, // ZERO_ZEROMV
1, // NEW_NEWMV
#endif
};
// There are 3^3 different combinations of 3 counts that can be either 0,1 or

View File

@ -1024,12 +1024,13 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
#else
MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r);
#endif
#endif // CONFIG_SUPERTX
#if CONFIG_TX_SKIP
q_idx = vp9_get_qindex(&cm->seg, mbmi->segment_id, cm->base_qindex);
mbmi->tx_skip_shift = q_idx > TX_SKIP_SHIFT_THRESH ?
TX_SKIP_SHIFT_HQ : TX_SKIP_SHIFT_LQ;
#endif
#if CONFIG_SUPERTX
if (!supertx_enabled) {
#endif
@ -1039,11 +1040,11 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (mbmi->skip) {
reset_skip_context(xd, bsize);
} else {
if (cm->seg.enabled)
if (cm->seg.enabled) {
setup_plane_dequants(cm, xd, vp9_get_qindex(&cm->seg, mbmi->segment_id,
cm->base_qindex));
}
}
if (!is_inter_block(mbmi)) {
struct intra_args arg = { cm, xd, r };
vp9_foreach_transformed_block(xd, bsize,
@ -1056,6 +1057,7 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (!mbmi->skip) {
int eobtotal = 0;
struct inter_args arg = { cm, xd, r, &eobtotal };
vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg);
if (!less8x8 && eobtotal == 0)
mbmi->skip = 1; // skip loopfilter
@ -1709,10 +1711,13 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi,
tile_data->xd = pbi->mb;
tile_data->xd.corrupted = 0;
vp9_tile_init(&tile, tile_data->cm, tile_row, tile_col);
setup_token_decoder(buf->data, data_end, buf->size, &cm->error,
&tile_data->bit_reader, pbi->decrypt_cb,
pbi->decrypt_state);
init_macroblockd(cm, &tile_data->xd);
vp9_zero(tile_data->xd.dqcoeff);
}
}
@ -2179,6 +2184,17 @@ static void read_supertx_probs(FRAME_CONTEXT *fc, vp9_reader *r) {
}
#endif // CONFIG_SUPERTX
#if CONFIG_COMPOUND_MODES
static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, vp9_reader *r) {
int i, j;
if (vp9_read(r, GROUP_DIFF_UPDATE_PROB)) {
for (j = 0; j < INTER_MODE_CONTEXTS; ++j)
for (i = 0; i < INTER_COMPOUND_MODES - 1; ++i)
vp9_diff_update_prob(r, &fc->inter_compound_mode_probs[j][i]);
}
}
#endif // CONFIG_COMPOUND_MODES
static int read_compressed_header(VP9Decoder *pbi, const uint8_t *data,
size_t partition_size) {
VP9_COMMON *const cm = &pbi->common;
@ -2211,6 +2227,9 @@ static int read_compressed_header(VP9Decoder *pbi, const uint8_t *data,
int i, j;
read_inter_mode_probs(fc, &r);
#if CONFIG_COMPOUND_MODES
read_inter_compound_mode_probs(fc, &r);
#endif
if (cm->interp_filter == SWITCHABLE)
read_switchable_interp_probs(fc, &r);
@ -2325,6 +2344,11 @@ static void debug_check_frame_counts(const VP9_COMMON *const cm) {
assert(!memcmp(cm->counts.ext_tx, zero_counts.ext_tx,
sizeof(cm->counts.ext_tx)));
#endif
#if CONFIG_COMPOUND_MODES
assert(!memcmp(cm->counts.inter_compound_mode,
zero_counts.inter_compound_mode,
sizeof(cm->counts.inter_compound_mode)));
#endif
}
#endif // NDEBUG
@ -2407,7 +2431,6 @@ void vp9_decode_frame(VP9Decoder *pbi,
}
new_fb->corrupted |= xd->corrupted;
if (!new_fb->corrupted) {
if (!cm->error_resilient_mode && !cm->frame_parallel_decoding_mode) {
vp9_adapt_coef_probs(cm);

View File

@ -45,12 +45,26 @@ static PREDICTION_MODE read_intra_mode_uv(VP9_COMMON *cm, vp9_reader *r,
return uv_mode;
}
static PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r, int ctx) {
#if CONFIG_COMPOUND_MODES
static PREDICTION_MODE read_inter_compound_mode(VP9_COMMON *cm, vp9_reader *r,
int ctx) {
int mode = 0;
mode = vp9_read_tree(r, vp9_inter_compound_mode_tree,
cm->fc.inter_compound_mode_probs[ctx]);
if (!cm->frame_parallel_decoding_mode) {
++cm->counts.inter_compound_mode[ctx][mode];
}
assert(is_inter_compound_mode(NEAREST_NEARESTMV + mode));
return NEAREST_NEARESTMV + mode;
}
#endif
static PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r,
int ctx) {
const int mode = vp9_read_tree(r, vp9_inter_mode_tree,
cm->fc.inter_mode_probs[ctx]);
if (!cm->frame_parallel_decoding_mode)
++cm->counts.inter_mode[ctx][mode];
return NEARESTMV + mode;
}
@ -564,7 +578,11 @@ static INLINE int assign_mv(VP9_COMMON *cm, PREDICTION_MODE mode,
int is_compound, int allow_hp, vp9_reader *r) {
int i;
int ret = 1;
#if CONFIG_COMPOUND_MODES
assert(is_inter_mode(mode) || is_inter_compound_mode(mode));
#else
assert(is_inter_mode(mode));
#endif
switch (mode) {
case NEWMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
@ -573,6 +591,7 @@ static INLINE int assign_mv(VP9_COMMON *cm, PREDICTION_MODE mode,
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[i].as_mv);
assert(ret);
}
break;
}
@ -594,10 +613,88 @@ static INLINE int assign_mv(VP9_COMMON *cm, PREDICTION_MODE mode,
mv[1].as_int = 0;
break;
}
#if CONFIG_COMPOUND_MODES
case NEW_NEWMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
NULL : &cm->counts.mv;
assert(is_compound);
for (i = 0; i < 2; ++i) {
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[i].as_mv);
}
break;
}
case NEAREST_NEARESTMV: {
assert(is_compound);
mv[0].as_int = nearest_mv[0].as_int;
mv[1].as_int = nearest_mv[1].as_int;
break;
}
case NEAREST_NEARMV: {
assert(is_compound);
mv[0].as_int = nearest_mv[0].as_int;
mv[1].as_int = near_mv[1].as_int;
break;
}
case NEAR_NEARESTMV: {
assert(is_compound);
mv[0].as_int = near_mv[0].as_int;
mv[1].as_int = nearest_mv[1].as_int;
break;
}
case NEW_NEARESTMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
NULL : &cm->counts.mv;
assert(is_compound);
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[0].as_mv);
mv[1].as_int = nearest_mv[1].as_int;
break;
}
case NEAREST_NEWMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
NULL : &cm->counts.mv;
assert(is_compound);
mv[0].as_int = nearest_mv[0].as_int;
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[1].as_mv);
break;
}
case NEAR_NEWMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
NULL : &cm->counts.mv;
assert(is_compound);
mv[0].as_int = near_mv[0].as_int;
read_mv(r, &mv[1].as_mv, &ref_mv[1].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[1].as_mv);
break;
}
case NEW_NEARMV: {
nmv_context_counts *const mv_counts = cm->frame_parallel_decoding_mode ?
NULL : &cm->counts.mv;
assert(is_compound);
read_mv(r, &mv[0].as_mv, &ref_mv[0].as_mv, &cm->fc.nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[0].as_mv);
mv[1].as_int = near_mv[1].as_int;
break;
}
case ZERO_ZEROMV: {
assert(is_compound);
mv[0].as_int = 0;
mv[1].as_int = 0;
break;
}
#endif
default: {
return 0;
}
}
return ret;
}
@ -660,7 +757,6 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
#endif
inter_mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]];
if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
mbmi->mode = ZEROMV;
if (bsize < BLOCK_8X8) {
@ -669,11 +765,25 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
return;
}
} else {
if (bsize >= BLOCK_8X8)
if (bsize >= BLOCK_8X8) {
#if CONFIG_COMPOUND_MODES
if (is_compound) {
mbmi->mode = read_inter_compound_mode(cm, r, inter_mode_ctx);
} else {
mbmi->mode = read_inter_mode(cm, r, inter_mode_ctx);
}
#else
mbmi->mode = read_inter_mode(cm, r, inter_mode_ctx);
#endif
}
}
#if CONFIG_COMPOUND_MODES
if (bsize < BLOCK_8X8 ||
(mbmi->mode != ZEROMV && mbmi->mode != ZERO_ZEROMV)) {
#else
if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) {
#endif
for (ref = 0; ref < 1 + is_compound; ++ref) {
vp9_find_best_ref_mvs(xd, allow_hp, mbmi->ref_mvs[mbmi->ref_frame[ref]],
&nearestmv[ref], &nearmv[ref]);
@ -712,9 +822,24 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
for (idx = 0; idx < 2; idx += num_4x4_w) {
int_mv block[2];
const int j = idy * 2 + idx;
#if CONFIG_COMPOUND_MODES
if (is_compound) {
b_mode = read_inter_compound_mode(cm, r, inter_mode_ctx);
} else {
b_mode = read_inter_mode(cm, r, inter_mode_ctx);
}
#else
b_mode = read_inter_mode(cm, r, inter_mode_ctx);
#endif
#if CONFIG_COMPOUND_MODES
if (b_mode == NEARESTMV || b_mode == NEARMV ||
b_mode == NEAREST_NEARESTMV || b_mode == NEAREST_NEARMV ||
b_mode == NEAR_NEARESTMV || b_mode == NEAREST_NEWMV ||
b_mode == NEW_NEARESTMV || b_mode == NEAR_NEWMV ||
b_mode == NEW_NEARMV)
#else
if (b_mode == NEARESTMV || b_mode == NEARMV)
#endif
for (ref = 0; ref < 1 + is_compound; ++ref)
vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, j, ref, mi_row, mi_col,
&nearest_sub8x8[ref],
@ -725,7 +850,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
is_compound, allow_hp, r)) {
xd->corrupted |= 1;
break;
};
}
mi->bmi[j].as_mv[0].as_int = block[0].as_int;
if (is_compound)
@ -739,7 +864,6 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
}
mi->mbmi.mode = b_mode;
mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
} else {
@ -752,7 +876,7 @@ static void read_inter_block_mode_info(VP9_COMMON *const cm,
#if CONFIG_WEDGE_PARTITION
mbmi->use_wedge_interinter = 0;
if (cm->reference_mode != SINGLE_REFERENCE &&
is_inter_mode(mbmi->mode) &&
is_inter_compound_mode(mbmi->mode) &&
get_wedge_bits(bsize) &&
mbmi->ref_frame[1] > INTRA_FRAME) {
mbmi->use_wedge_interinter =
@ -849,6 +973,9 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
mbmi->tx_size <= TX_16X16 &&
cm->base_qindex > 0 &&
mbmi->sb_type >= BLOCK_8X8 &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif
!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
!mbmi->skip) {
mbmi->ext_txfrm = vp9_read_tree(r, vp9_ext_tx_tree,

View File

@ -45,6 +45,9 @@ static struct vp9_token ext_tx_encodings[EXT_TX_TYPES];
static struct vp9_token copy_mode_encodings_l2[2];
static struct vp9_token copy_mode_encodings[COPY_MODE_COUNT - 1];
#endif
#if CONFIG_COMPOUND_MODES
static struct vp9_token inter_compound_mode_encodings[INTER_COMPOUND_MODES];
#endif // CONFIG_COMPOUND_MODES
#if CONFIG_SUPERTX
static int vp9_check_supertx(VP9_COMMON *cm, int mi_row, int mi_col,
@ -66,6 +69,10 @@ void vp9_entropy_mode_init() {
#if CONFIG_EXT_TX
vp9_tokens_from_tree(ext_tx_encodings, vp9_ext_tx_tree);
#endif
#if CONFIG_COMPOUND_MODES
vp9_tokens_from_tree(inter_compound_mode_encodings,
vp9_inter_compound_mode_tree);
#endif // CONFIG_COMPOUND_MODES
#if CONFIG_COPY_MODE
vp9_tokens_from_tree(copy_mode_encodings_l2, vp9_copy_mode_tree_l2);
vp9_tokens_from_tree(copy_mode_encodings, vp9_copy_mode_tree);
@ -99,6 +106,15 @@ static void write_copy_mode(VP9_COMMON *cm, vp9_writer *w, COPY_MODE mode,
}
#endif // CONFIG_COPY_MODE
#if CONFIG_COMPOUND_MODES
static void write_inter_compound_mode(vp9_writer *w, PREDICTION_MODE mode,
const vp9_prob *probs) {
assert(is_inter_compound_mode(mode));
vp9_write_token(w, vp9_inter_compound_mode_tree, probs,
&inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]);
}
#endif // CONFIG_COMPOUND_MODES
static void encode_unsigned_max(struct vp9_write_bit_buffer *wb,
int data, int max) {
vp9_wb_write_literal(wb, data, get_unsigned_bits(max));
@ -231,6 +247,32 @@ static void update_supertx_probs(VP9_COMMON *cm, vp9_writer *w) {
}
#endif // CONFIG_SUPERTX
#if CONFIG_COMPOUND_MODES
static void update_inter_compound_mode_probs(VP9_COMMON *cm, vp9_writer *w) {
const int savings_thresh = vp9_cost_one(GROUP_DIFF_UPDATE_PROB) -
vp9_cost_zero(GROUP_DIFF_UPDATE_PROB);
int i;
int savings = 0;
int do_update = 0;
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
savings += prob_diff_update_savings(vp9_inter_compound_mode_tree,
cm->fc.inter_compound_mode_probs[i],
cm->counts.inter_compound_mode[i],
INTER_COMPOUND_MODES);
}
do_update = savings > savings_thresh;
vp9_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
if (do_update) {
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
prob_diff_update(vp9_inter_compound_mode_tree,
cm->fc.inter_compound_mode_probs[i],
cm->counts.inter_compound_mode[i],
INTER_COMPOUND_MODES, w);
}
}
}
#endif // CONFIG_COMPOUND_MODES
static void pack_mb_tokens(vp9_writer *w,
TOKENEXTRA **tp, const TOKENEXTRA *const stop,
vpx_bit_depth_t bit_depth) {
@ -505,13 +547,24 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
#endif
const int mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]];
const vp9_prob *const inter_probs = cm->fc.inter_mode_probs[mode_ctx];
#if CONFIG_COMPOUND_MODES
const vp9_prob *const inter_compound_probs =
cm->fc.inter_compound_mode_probs[mode_ctx];
#endif
write_ref_frames(cm, xd, w);
// If segment skip is not enabled code the mode.
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
if (bsize >= BLOCK_8X8) {
#if CONFIG_COMPOUND_MODES
if (is_inter_compound_mode(mode)) {
write_inter_compound_mode(w, mode, inter_compound_probs);
} else if (is_inter_mode(mode)) {
write_inter_mode(w, mode, inter_probs);
}
#else
write_inter_mode(w, mode, inter_probs);
++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(mode)];
#endif // CONFIG_COMPOUND_MODES
}
}
@ -549,27 +602,65 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int j = idy * 2 + idx;
const PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
#if CONFIG_COMPOUND_MODES
if (is_inter_compound_mode(b_mode)) {
write_inter_compound_mode(w, b_mode, inter_compound_probs);
} else if (is_inter_mode(b_mode)) {
write_inter_mode(w, b_mode, inter_probs);
}
#else
write_inter_mode(w, b_mode, inter_probs);
++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(b_mode)];
#endif // CONFIG_COMPOUND_MODES
#if CONFIG_COMPOUND_MODES
if (b_mode == NEWMV || b_mode == NEW_NEWMV) {
#else
if (b_mode == NEWMV) {
#endif
for (ref = 0; ref < 1 + is_compound; ++ref)
vp9_encode_mv(cpi, w, &mi->bmi[j].as_mv[ref].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[ref]][0].as_mv,
nmvc, allow_hp);
}
#if CONFIG_COMPOUND_MODES
else if (b_mode == NEAREST_NEWMV || b_mode == NEAR_NEWMV) {
vp9_encode_mv(cpi, w, &mi->bmi[j].as_mv[1].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[1]][0].as_mv,
nmvc, allow_hp);
} else if (b_mode == NEW_NEARESTMV || b_mode == NEW_NEARMV) {
vp9_encode_mv(cpi, w, &mi->bmi[j].as_mv[0].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[0]][0].as_mv,
nmvc, allow_hp);
}
#endif
}
}
} else {
#if CONFIG_COMPOUND_MODES
if (mode == NEWMV || mode == NEW_NEWMV) {
#else
if (mode == NEWMV) {
#endif
for (ref = 0; ref < 1 + is_compound; ++ref)
vp9_encode_mv(cpi, w, &mbmi->mv[ref].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[ref]][0].as_mv, nmvc,
allow_hp);
}
#if CONFIG_COMPOUND_MODES
else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) {
vp9_encode_mv(cpi, w, &mbmi->mv[1].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[1]][0].as_mv, nmvc,
allow_hp);
} else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) {
vp9_encode_mv(cpi, w, &mbmi->mv[0].as_mv,
&mbmi->ref_mvs[mbmi->ref_frame[0]][0].as_mv, nmvc,
allow_hp);
}
#endif
}
#if CONFIG_WEDGE_PARTITION
if (cm->reference_mode != SINGLE_REFERENCE &&
is_inter_mode(mode) &&
is_inter_compound_mode(mode) &&
get_wedge_bits(bsize) &&
mbmi->ref_frame[1] > INTRA_FRAME) {
vp9_write(w, mbmi->use_wedge_interinter,
@ -1572,12 +1663,14 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
if (!frame_is_intra_only(cm)) {
int i;
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
prob_diff_update(vp9_inter_mode_tree, cm->fc.inter_mode_probs[i],
cm->counts.inter_mode[i], INTER_MODES, &header_bc);
}
vp9_zero(cm->counts.inter_mode);
#if CONFIG_COMPOUND_MODES
update_inter_compound_mode_probs(cm, &header_bc);
#endif
if (cm->interp_filter == SWITCHABLE)
update_switchable_interp_probs(cm, &header_bc);
@ -1588,7 +1681,8 @@ static size_t write_compressed_header(VP9_COMP *cpi, uint8_t *data) {
if (cm->allow_comp_inter_inter) {
const int use_compound_pred = cm->reference_mode != SINGLE_REFERENCE;
const int use_hybrid_pred = cm->reference_mode == REFERENCE_MODE_SELECT;
const int use_hybrid_pred =
cm->reference_mode == REFERENCE_MODE_SELECT;
vp9_write_bit(&header_bc, use_compound_pred);
if (use_compound_pred) {

View File

@ -253,10 +253,26 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser,
frame = ctx->best_zeromv_reference_frame;
mbmi->ref_frame[0] = ctx->best_zeromv_reference_frame;
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
mbmi->mode = ZERO_ZEROMV;
} else {
mbmi->mode = ZERO_MV;
}
#else
mbmi->mode = ZEROMV;
#endif
mbmi->mv[0].as_int = 0;
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
ctx->best_sse_inter_mode = ZERO_ZEROMV;
} else {
ctx->best_sse_inter_mode = ZEROMV;
}
#else
ctx->best_sse_inter_mode = ZEROMV;
#endif
ctx->best_sse_mv.as_int = 0;
ctx->newmv_sse = ctx->zeromv_sse;
}
@ -409,8 +425,12 @@ void vp9_denoiser_update_frame_stats(MB_MODE_INFO *mbmi, unsigned int sse,
ctx->zeromv_sse = sse;
ctx->best_zeromv_reference_frame = mbmi->ref_frame[0];
}
#if CONFIG_COMPOUND_MODES
if (mode == NEW_NEWMV || mode == NEWMV || mode == NEW_NEARESTMV ||
mode == NEAREST_NEWMV) {
#else
if (mode == NEWMV) {
#endif
ctx->newmv_sse = sse;
ctx->best_sse_inter_mode = mode;
ctx->best_sse_mv = mbmi->mv[0];

View File

@ -1366,17 +1366,18 @@ static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) {
const MACROBLOCKD *const xd = &x->e_mbd;
const MODE_INFO *const mi = xd->mi[0].src_mi;
const MB_MODE_INFO *const mbmi = &mi->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
#if CONFIG_COPY_MODE
if (!frame_is_intra_only(cm) && mbmi->copy_mode == NOREF) {
#else
if (!frame_is_intra_only(cm)) {
#endif
FRAME_COUNTS *const counts = &cm->counts;
const int inter_block = is_inter_block(mbmi);
const int seg_ref_active = vp9_segfeature_active(&cm->seg, mbmi->segment_id,
SEG_LVL_REF_FRAME);
if (!seg_ref_active) {
FRAME_COUNTS *const counts = &cm->counts;
const int inter_block = is_inter_block(mbmi);
counts->intra_inter[vp9_get_intra_inter_context(xd)][inter_block]++;
@ -1402,6 +1403,42 @@ static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) {
}
}
}
if (inter_block &&
!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
const int mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]];
if (bsize >= BLOCK_8X8) {
const PREDICTION_MODE mode = mbmi->mode;
#if CONFIG_COMPOUND_MODES
if (is_inter_compound_mode(mode)) {
++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)];
} else {
++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)];
}
#else
++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)];
#endif
} else {
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
int idx, idy;
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int j = idy * 2 + idx;
const PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
#if CONFIG_COMPOUND_MODES
if (is_inter_compound_mode(b_mode)) {
++counts->inter_compound_mode[mode_ctx]
[INTER_COMPOUND_OFFSET(b_mode)];
} else {
++counts->inter_mode[mode_ctx][INTER_OFFSET(b_mode)];
}
#else
++counts->inter_mode[mode_ctx][INTER_OFFSET(b_mode)];
#endif
}
}
}
}
}
}
@ -2944,8 +2981,12 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
0);
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_COMPOUND_MODES
if (is_inter_mode(pc_tree->leaf_split[0]->mic.mbmi.mode) ||
is_inter_compound_mode(pc_tree->leaf_split[0]->mic.mbmi.mode)) {
#else
if (is_inter_mode(pc_tree->leaf_split[0]->mic.mbmi.mode)) {
#endif
#if CONFIG_EXT_TX
EXT_TX_TYPE best_tx = NORM;
#endif
@ -4691,7 +4732,11 @@ static void sum_intra_stats(FRAME_COUNTS *counts,
static int get_zbin_mode_boost(const MB_MODE_INFO *mbmi, int enabled) {
if (enabled) {
if (is_inter_block(mbmi)) {
#if CONFIG_COMPOUND_MODES
if (mbmi->mode == ZEROMV || mbmi->mode == ZERO_ZEROMV) {
#else
if (mbmi->mode == ZEROMV) {
#endif // CONFIG_COMPOUND_MODES
return mbmi->ref_frame[0] != LAST_FRAME ? GF_ZEROMV_ZBIN_BOOST
: LF_ZEROMV_ZBIN_BOOST;
} else {
@ -4828,12 +4873,23 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
#if CONFIG_SUPERTX
static int check_intra_b(PICK_MODE_CONTEXT *ctx) {
#if CONFIG_COMPOUND_MODES
#if CONFIG_INTERINTRA
return (!is_inter_mode((&ctx->mic)->mbmi.mode) &&
!is_inter_compound_mode((&ctx->mic)->mbmi.mode)) ||
(ctx->mic.mbmi.ref_frame[1] == INTRA_FRAME);
#else
return !is_inter_mode((&ctx->mic)->mbmi.mode) &&
!is_inter_compound_mode((&ctx->mic)->mbmi.mode);
#endif // CONFIG_INTERINTRA
#else // CONFIG_COMPOUND_MODES
#if CONFIG_INTERINTRA
return !is_inter_mode((&ctx->mic)->mbmi.mode) ||
(ctx->mic.mbmi.ref_frame[1] == INTRA_FRAME);
#else
return !is_inter_mode((&ctx->mic)->mbmi.mode);
#endif // CONFIG_INTERINTRA
#endif // CONFIG_COMPOUND_MODES
}
static int check_intra_sb(VP9_COMP *cpi, const TileInfo *const tile,

View File

@ -241,6 +241,18 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const int_mv mvs[2],
}
}
#if CONFIG_COMPOUND_MODES
static void inc_compound_single_mv(const MB_MODE_INFO *mbmi,
int ref_idx,
const int_mv mvs[2],
nmv_context_counts *counts) {
const MV *ref = &mbmi->ref_mvs[mbmi->ref_frame[ref_idx]][0].as_mv;
const MV diff = {mvs[ref_idx].as_mv.row - ref->row,
mvs[ref_idx].as_mv.col - ref->col};
vp9_inc_mv(&diff, counts);
}
#endif
void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd) {
const MODE_INFO *mi = xd->mi[0].src_mi;
const MB_MODE_INFO *const mbmi = &mi->mbmi;
@ -253,13 +265,35 @@ void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd) {
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int i = idy * 2 + idx;
#if CONFIG_COMPOUND_MODES
if (mi->bmi[i].as_mode == NEWMV || mi->bmi[i].as_mode == NEW_NEWMV)
#else
if (mi->bmi[i].as_mode == NEWMV)
#endif
inc_mvs(mbmi, mi->bmi[i].as_mv, &cm->counts.mv);
#if CONFIG_COMPOUND_MODES
else if (mi->bmi[i].as_mode == NEAREST_NEWMV ||
mi->bmi[i].as_mode == NEAR_NEWMV)
inc_compound_single_mv(mbmi, 1, mi->bmi[i].as_mv, &cm->counts.mv);
else if (mi->bmi[i].as_mode == NEW_NEARESTMV ||
mi->bmi[i].as_mode == NEW_NEARMV)
inc_compound_single_mv(mbmi, 0, mi->bmi[i].as_mv, &cm->counts.mv);
#endif
}
}
} else {
#if CONFIG_COMPOUND_MODES
if (mbmi->mode == NEWMV || mbmi->mode == NEW_NEWMV)
#else
if (mbmi->mode == NEWMV)
#endif
inc_mvs(mbmi, mbmi->mv, &cm->counts.mv);
#if CONFIG_COMPOUND_MODES
else if (mbmi->mode == NEAREST_NEWMV || mbmi->mode == NEAR_NEWMV)
inc_compound_single_mv(mbmi, 1, mbmi->mv, &cm->counts.mv);
else if (mbmi->mode == NEW_NEARESTMV || mbmi->mode == NEW_NEARMV)
inc_compound_single_mv(mbmi, 0, mbmi->mv, &cm->counts.mv);
#endif
}
}

View File

@ -391,6 +391,10 @@ typedef struct VP9_COMP {
int mbmode_cost[INTRA_MODES];
unsigned int inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
#if CONFIG_COMPOUND_MODES
unsigned int inter_compound_mode_cost[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES];
#endif
int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES];
int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];

View File

@ -62,8 +62,15 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
NULL, NULL,
&distortion, &sse, NULL, 0, 0);
}
#if CONFIG_COMPOUND_MODES
if (has_second_ref(&xd->mi[0].src_mi->mbmi)) {
xd->mi[0].src_mi->mbmi.mode = NEW_NEWMV;
} else {
#endif
xd->mi[0].src_mi->mbmi.mode = NEWMV;
#if CONFIG_COMPOUND_MODES
}
#endif
xd->mi[0].src_mi->mbmi.mv[0].as_mv = *dst_mv;
#if CONFIG_INTERINTRA
xd->mi[0].src_mi->mbmi.ref_frame[1] = NONE;

View File

@ -174,9 +174,17 @@ static int combined_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
*rate_mv = vp9_mv_bit_cost(&mvp_full, &ref_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
rate_mode = cpi->inter_compound_mode_cost[mbmi->mode_context[ref]]
[INTER_COMPOUND_OFFSET(NEW_NEWMV)];
} else {
#endif
rate_mode = cpi->inter_mode_cost[mbmi->mode_context[ref]]
[INTER_OFFSET(NEWMV)];
#if CONFIG_COMPOUND_MODES
}
#endif
rv = !(RDCOST(x->rdmult, x->rddiv, (*rate_mv + rate_mode), 0) >
best_rd_sofar);
@ -386,9 +394,18 @@ static void encode_breakout_test(VP9_COMP *cpi, MACROBLOCK *x,
x->skip = 1;
// The cost of skip bit needs to be added.
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
*rate = cpi->inter_compound_mode_cost[mbmi->mode_context[ref_frame]]
[INTER_COMPOUND_OFFSET(this_mode)];
} else {
#endif
*rate = cpi->inter_mode_cost[mbmi->mode_context[ref_frame]]
[INTER_OFFSET(this_mode)];
#if CONFIG_COMPOUND_MODES
}
#endif
// More on this part of rate
// rate += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1);
@ -598,25 +615,48 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->ref_frame[0] = ref_frame;
#if CONFIG_COMPOUND_MODES
for (this_mode = NEARESTMV; this_mode <= NEW_NEWMV; ++this_mode) {
#else
for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
#endif
int rate_mv = 0;
int mode_rd_thresh;
#if CONFIG_COMPOUND_MODES
if (const_motion[ref_frame] &&
(this_mode == NEARMV || this_mode == ZEROMV ||
this_mode == ZERO_ZEROMV))
#else
if (const_motion[ref_frame] &&
(this_mode == NEARMV || this_mode == ZEROMV))
#endif
continue;
if (!(cpi->sf.inter_mode_mask[bsize] & (1 << this_mode)))
continue;
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
mode_rd_thresh =
rd_threshes[mode_idx[ref_frame - LAST_FRAME]
[INTER_COMPOUND_OFFSET(this_mode)]];
} else {
#endif
mode_rd_thresh =
rd_threshes[mode_idx[ref_frame -
LAST_FRAME][INTER_OFFSET(this_mode)]];
#if CONFIG_COMPOUND_MODES
}
#endif
if (rd_less_than_thresh(best_rdc.rdcost, mode_rd_thresh,
rd_thresh_freq_fact[this_mode]))
continue;
#if CONFIG_COMPOUND_MODES
if (this_mode == NEWMV || this_mode == NEW_NEWMV) {
#else
if (this_mode == NEWMV) {
#endif
if (cpi->sf.partition_search_type != VAR_BASED_PARTITION &&
this_rdc.rdcost < (int64_t)(1 << num_pels_log2_lookup[bsize]))
continue;
@ -626,7 +666,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
continue;
}
#if CONFIG_COMPOUND_MODES
if (this_mode != NEARESTMV && this_mode != NEAREST_NEARESTMV &&
#else
if (this_mode != NEARESTMV &&
#endif
frame_mv[this_mode][ref_frame].as_int ==
frame_mv[NEARESTMV][ref_frame].as_int)
continue;
@ -638,7 +682,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
// motion vector is at sub-pixel accuracy level for luma component, i.e.,
// the last three bits are all zeros.
if (cpi->sf.reuse_inter_pred_sby) {
#if CONFIG_COMPOUND_MODES
if (this_mode == NEARESTMV || this_mode == NEAREST_NEARESTMV) {
#else
if (this_mode == NEARESTMV) {
#endif
this_mode_pred = &tmp[3];
} else {
this_mode_pred = &tmp[get_pred_buffer(tmp, 3)];
@ -647,7 +695,12 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
}
#if CONFIG_COMPOUND_MODES
if ((this_mode == NEWMV || this_mode == NEW_NEWMV ||
filter_ref == SWITCHABLE) &&
#else
if ((this_mode == NEWMV || filter_ref == SWITCHABLE) &&
#endif
pred_filter_search &&
((mbmi->mv[0].as_mv.row & 0x07) != 0 ||
(mbmi->mv[0].as_mv.col & 0x07) != 0)) {
@ -708,8 +761,18 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
this_rdc.rate += rate_mv;
#if CONFIG_COMPOUND_MODES
if (has_second_ref(mbmi)) {
this_rdc.rate += cpi->inter_compound_mode_cost
[mbmi->mode_context[ref_frame]]
[INTER_COMPOUND_OFFSET(this_mode)];
} else {
#endif
this_rdc.rate += cpi->inter_mode_cost[mbmi->mode_context[ref_frame]]
[INTER_OFFSET(this_mode)];
#if CONFIG_COMPOUND_MODES
}
#endif
this_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
this_rdc.rate, this_rdc.dist);

View File

@ -304,6 +304,13 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) {
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
vp9_cost_tokens((int *)cpi->inter_mode_cost[i],
cm->fc.inter_mode_probs[i], vp9_inter_mode_tree);
#if CONFIG_COMPOUND_MODES
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
vp9_cost_tokens((int *)cpi->inter_compound_mode_cost[i],
cm->fc.inter_compound_mode_probs[i],
vp9_inter_compound_mode_tree);
#endif
}
}
@ -584,22 +591,43 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEARMV] += 1000;
rd->thresh_mult[THR_NEARA] += 1000;
rd->thresh_mult[THR_COMP_NEARESTLA] += 1000;
rd->thresh_mult[THR_COMP_NEARESTGA] += 1000;
rd->thresh_mult[THR_TM] += 1000;
rd->thresh_mult[THR_COMP_NEARLA] += 1500;
rd->thresh_mult[THR_COMP_NEWLA] += 2000;
rd->thresh_mult[THR_NEARG] += 1000;
rd->thresh_mult[THR_COMP_NEARGA] += 1500;
rd->thresh_mult[THR_COMP_NEWGA] += 2000;
rd->thresh_mult[THR_ZEROMV] += 2000;
rd->thresh_mult[THR_ZEROG] += 2000;
rd->thresh_mult[THR_ZEROA] += 2000;
#if CONFIG_COMPOUND_MODES
rd->thresh_mult[THR_COMP_NEAREST_NEARESTLA] += 1000;
rd->thresh_mult[THR_COMP_NEAREST_NEARESTGA] += 1000;
rd->thresh_mult[THR_COMP_NEAREST_NEARLA] += 1200;
rd->thresh_mult[THR_COMP_NEAREST_NEARGA] += 1200;
rd->thresh_mult[THR_COMP_NEAR_NEARESTLA] += 1200;
rd->thresh_mult[THR_COMP_NEAR_NEARESTGA] += 1200;
rd->thresh_mult[THR_COMP_NEAREST_NEWLA] += 1500;
rd->thresh_mult[THR_COMP_NEAREST_NEWGA] += 1500;
rd->thresh_mult[THR_COMP_NEW_NEARESTLA] += 1500;
rd->thresh_mult[THR_COMP_NEW_NEARESTGA] += 1500;
rd->thresh_mult[THR_COMP_NEAR_NEWLA] += 1700;
rd->thresh_mult[THR_COMP_NEAR_NEWGA] += 1700;
rd->thresh_mult[THR_COMP_NEW_NEARLA] += 1700;
rd->thresh_mult[THR_COMP_NEW_NEARGA] += 1700;
rd->thresh_mult[THR_COMP_NEW_NEWLA] += 2000;
rd->thresh_mult[THR_COMP_NEW_NEWGA] += 2000;
rd->thresh_mult[THR_COMP_ZERO_ZEROLA] += 2500;
rd->thresh_mult[THR_COMP_ZERO_ZEROGA] += 2500;
#else
rd->thresh_mult[THR_COMP_NEARESTLA] += 1000;
rd->thresh_mult[THR_COMP_NEARESTGA] += 1000;
rd->thresh_mult[THR_COMP_NEARLA] += 1500;
rd->thresh_mult[THR_COMP_NEARGA] += 1500;
rd->thresh_mult[THR_COMP_NEWLA] += 2000;
rd->thresh_mult[THR_COMP_NEWGA] += 2000;
rd->thresh_mult[THR_COMP_ZEROLA] += 2500;
rd->thresh_mult[THR_COMP_ZEROGA] += 2500;
#endif // CONFIG_COMPOUND_MODES
rd->thresh_mult[THR_H_PRED] += 2000;
rd->thresh_mult[THR_V_PRED] += 2000;

View File

@ -33,12 +33,26 @@ extern "C" {
#define INVALID_MV 0x80008000
#if CONFIG_COMPOUND_MODES
#if CONFIG_INTERINTRA
#define MAX_MODES 52
#define INTERINTRA_START_MODE 40
#else
#define MAX_MODES 40
#endif // CONFIG_INTERINTRA
#else // CONFIG_COMPOUND_MODES
#if CONFIG_INTERINTRA
#define MAX_MODES 42
#define INTERINTRA_START_MODE 30
#else
#define MAX_MODES 30
#endif // CONFIG_INTERINTRA
#endif // CONFIG_COMPOUND_MODES
#define MAX_REFS 6
// This enumerator type needs to be kept aligned with the mode order in
@ -62,11 +76,38 @@ typedef enum {
THR_ZEROG,
THR_ZEROA,
#if CONFIG_COMPOUND_MODES
THR_COMP_NEAREST_NEARESTLA,
THR_COMP_NEAREST_NEARESTGA,
#else
THR_COMP_NEARESTLA,
THR_COMP_NEARESTGA,
#endif
THR_TM,
#if CONFIG_COMPOUND_MODES
THR_COMP_NEAR_NEARESTLA,
THR_COMP_NEAR_NEARESTGA,
THR_COMP_NEAREST_NEARLA,
THR_COMP_NEAREST_NEARGA,
THR_COMP_NEW_NEARESTLA,
THR_COMP_NEW_NEARESTGA,
THR_COMP_NEAREST_NEWLA,
THR_COMP_NEAREST_NEWGA,
THR_COMP_NEW_NEARLA,
THR_COMP_NEW_NEARGA,
THR_COMP_NEAR_NEWLA,
THR_COMP_NEAR_NEWGA,
THR_COMP_NEW_NEWLA,
THR_COMP_NEW_NEWGA,
THR_COMP_ZERO_ZEROLA,
THR_COMP_ZERO_ZEROGA,
#else
THR_COMP_NEARLA,
THR_COMP_NEWLA,
THR_COMP_NEARGA,
@ -74,6 +115,7 @@ typedef enum {
THR_COMP_ZEROLA,
THR_COMP_ZEROGA,
#endif // CONFIG_COMPOUND_MODES
THR_H_PRED,
THR_V_PRED,

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,45 @@ enum {
(1 << H_PRED)
};
#if CONFIG_COMPOUND_MODES
enum {
INTER_ALL =
(1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV) |
(1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) | (1 << NEAREST_NEARMV) |
(1 << NEAR_NEARESTMV) | (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) |
(1 << NEAR_NEWMV) | (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV),
INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) |
(1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) |
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV),
INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV) |
(1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
(1 << NEAR_NEARESTMV) | (1 << NEAREST_NEARMV) |
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV),
INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << ZEROMV) |
(1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) |
(1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) |
(1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV),
INTER_NEAREST_NEW_ZERO =
(1 << NEARESTMV) | (1 << ZEROMV) | (1 << NEWMV) |
(1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) | (1 << NEW_NEWMV) |
(1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) |
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV),
INTER_NEAREST_NEAR_NEW =
(1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV) |
(1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
(1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) |
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV),
INTER_NEAREST_NEAR_ZERO =
(1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) |
(1 << NEAREST_NEARESTMV) | (1 << ZERO_ZEROMV) |
(1 << NEAREST_NEARMV) | (1 << NEAR_NEARESTMV) |
(1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV)
};
#else
enum {
INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV),
INTER_NEAREST = (1 << NEARESTMV),
@ -40,6 +79,7 @@ enum {
INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV),
INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV),
};
#endif
enum {
DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) |