Commit 7ded038a authored by Geza Lore's avatar Geza Lore Committed by Debargha Mukherjee

Port interintra experiment from nextgen.

The interintra experiment, which combines an inter prediction and an
inter prediction have been ported from the nextgen branch. The
experiment is merged into ext_inter, so there is no separate configure
option to enable it.

Change-Id: I0cc20cefd29e9b77ab7bbbb709abc11512320325
parent 3287f551
......@@ -170,6 +170,11 @@ typedef struct {
INTRA_FILTER intra_filter;
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER
PREDICTION_MODE interintra_mode;
PREDICTION_MODE interintra_uv_mode;
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
int8_t obmc;
#endif // CONFIG_OBMC
......@@ -624,6 +629,30 @@ void vp10_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, int has_eob,
int aoff, int loff);
#if CONFIG_EXT_INTER
static INLINE int is_interintra_allowed_bsize(const BLOCK_SIZE bsize) {
return (bsize >= BLOCK_8X8) && (bsize < BLOCK_64X64);
}
static INLINE int is_interintra_allowed_mode(const PREDICTION_MODE mode) {
return (mode >= NEARESTMV) && (mode <= NEWMV);
}
static INLINE int is_interintra_allowed_ref(const MV_REFERENCE_FRAME rf[2]) {
return (rf[0] > INTRA_FRAME) && (rf[1] <= INTRA_FRAME);
}
static INLINE int is_interintra_allowed(const MB_MODE_INFO *mbmi) {
return is_interintra_allowed_bsize(mbmi->sb_type)
&& is_interintra_allowed_mode(mbmi->mode)
&& is_interintra_allowed_ref(mbmi->ref_frame);
}
static INLINE int is_interintra_pred(const MB_MODE_INFO *mbmi) {
return (mbmi->ref_frame[1] == INTRA_FRAME) && is_interintra_allowed(mbmi);
}
#endif // CONFIG_EXT_INTER
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -226,6 +226,10 @@ static const vpx_prob default_inter_compound_mode_probs
{17, 81, 52, 192, 192, 128, 180, 180}, // 5 = one intra neighbour
{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,
};
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
......@@ -1326,6 +1330,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
vp10_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
vp10_copy(fc->interintra_prob, default_interintra_prob);
#endif // CONFIG_EXT_INTER
#if CONFIG_SUPERTX
vp10_copy(fc->supertx_prob, default_supertx_prob);
......@@ -1434,6 +1439,12 @@ 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))
fc->interintra_prob[i] = mode_mv_merge_probs(pre_fc->interintra_prob[i],
counts->interintra[i]);
}
#endif // CONFIG_EXT_INTER
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
......
......@@ -80,6 +80,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];
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
vpx_prob obmc_prob[BLOCK_SIZES];
......@@ -141,6 +142,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];
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
unsigned int obmc[BLOCK_SIZES][2];
......
This diff is collapsed.
......@@ -369,6 +369,31 @@ void vp10_build_obmc_inter_prediction(VP10_COMMON *cm,
int tmp_stride2[MAX_MB_PLANE]);
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
void vp10_build_interintra_predictors(MACROBLOCKD *xd,
uint8_t *ypred,
uint8_t *upred,
uint8_t *vpred,
int ystride,
int ustride,
int vstride,
BLOCK_SIZE bsize);
void vp10_build_interintra_predictors_sby(MACROBLOCKD *xd,
uint8_t *ypred,
int ystride,
BLOCK_SIZE bsize);
void vp10_build_interintra_predictors_sbc(MACROBLOCKD *xd,
uint8_t *upred,
int ustride,
int plane,
BLOCK_SIZE bsize);
void vp10_build_interintra_predictors_sbuv(MACROBLOCKD *xd,
uint8_t *upred,
uint8_t *vpred,
int ustride, int vstride,
BLOCK_SIZE bsize);
#endif // CONFIG_EXT_INTER
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -403,6 +403,10 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
for (j = 0; j < INTER_COMPOUND_MODES; j++)
cm->counts.inter_compound_mode[i][j] +=
counts->inter_compound_mode[i][j];
for (i = 0; i < BLOCK_SIZES; i++)
for (j = 0; j < 2; j++)
cm->counts.interintra[i][j] += counts->interintra[i][j];
#endif // CONFIG_EXT_INTER
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
......
......@@ -871,6 +871,17 @@ static void dec_build_inter_predictors_sb(VP10Decoder *const pbi,
}
}
}
#if CONFIG_EXT_INTER
if (is_interintra_pred(&xd->mi[0]->mbmi))
vp10_build_interintra_predictors(xd,
xd->plane[0].dst.buf,
xd->plane[1].dst.buf,
xd->plane[2].dst.buf,
xd->plane[0].dst.stride,
xd->plane[1].dst.stride,
xd->plane[2].dst.stride,
sb_type);
#endif // CONFIG_EXT_INTER
}
#if CONFIG_SUPERTX
......@@ -915,6 +926,17 @@ static void dec_build_inter_predictors_sb_sub8x8(VP10Decoder *const pbi,
&mv, ref_frame_buf, is_scaled, ref);
}
}
#if CONFIG_EXT_INTER
if (is_interintra_pred(&xd->mi[0]->mbmi))
vp10_build_interintra_predictors(xd,
xd->plane[0].dst.buf,
xd->plane[1].dst.buf,
xd->plane[2].dst.buf,
xd->plane[0].dst.stride,
xd->plane[1].dst.stride,
xd->plane[2].dst.stride,
xd->mi[0]->mbmi.sb_type);
#endif // CONFIG_EXT_INTER
}
#endif // CONFIG_SUPERTX
......@@ -3569,6 +3591,14 @@ 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)) {
vp10_diff_update_prob(&r, &fc->interintra_prob[i]);
}
}
}
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
......@@ -3634,6 +3664,8 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) {
assert(!memcmp(cm->counts.inter_compound_mode,
zero_counts.inter_compound_mode,
sizeof(cm->counts.inter_compound_mode)));
assert(!memcmp(cm->counts.interintra, zero_counts.interintra,
sizeof(cm->counts.interintra)));
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
assert(!memcmp(cm->counts.obmc, zero_counts.obmc,
......
......@@ -1133,7 +1133,7 @@ static void fpm_sync(void *const data, int mi_row) {
static void read_inter_block_mode_info(VP10Decoder *const pbi,
MACROBLOCKD *const xd,
MODE_INFO *const mi,
#if CONFIG_OBMC && CONFIG_SUPERTX
#if (CONFIG_OBMC || CONFIG_EXT_INTER) && CONFIG_SUPERTX
int mi_row, int mi_col, vpx_reader *r,
int supertx_enabled) {
#else
......@@ -1430,6 +1430,37 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
#endif // CONFIG_EXT_INTER
nearestmv, nearmv, is_compound, allow_hp, r);
}
#if CONFIG_EXT_INTER
if (cm->reference_mode != COMPOUND_REFERENCE &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif
is_interintra_allowed(mbmi)) {
const int interintra = vpx_read(r, cm->fc->interintra_prob[bsize]);
if (xd->counts)
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]);
mbmi->ref_frame[1] = INTRA_FRAME;
mbmi->interintra_mode = interintra_mode;
mbmi->interintra_uv_mode = interintra_mode;
#if CONFIG_EXT_INTRA
// TODO(debargha|geza.lore):
// Should we use ext_intra modes for interintra?
mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
mbmi->angle_delta[0] = 0;
mbmi->angle_delta[1] = 0;
mbmi->intra_filter = INTRA_FILTER_LINEAR;
#endif // CONFIG_EXT_INTRA
}
}
#endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTERP
mbmi->interp_filter = (cm->interp_filter == SWITCHABLE)
? read_switchable_interp_filter(cm, xd, r)
......@@ -1514,7 +1545,8 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi,
if (inter_block)
read_inter_block_mode_info(pbi, xd,
#if CONFIG_OBMC && CONFIG_SUPERTX
#if (CONFIG_OBMC || CONFIG_EXT_INTER) && CONFIG_SUPERTX
mi, mi_row, mi_col, r, supertx_enabled);
#else
mi, mi_row, mi_col, r);
......
......@@ -1028,7 +1028,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_EXT_INTER
write_inter_mode(cm, w, mode,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
has_second_ref(mbmi),
is_compound,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
mode_ctx);
......@@ -1163,6 +1163,22 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
}
}
#if CONFIG_EXT_INTER
if (cpi->common.reference_mode != COMPOUND_REFERENCE &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#endif // CONFIG_SUPERTX
is_interintra_allowed(mbmi)) {
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]]);
assert(mbmi->interintra_mode == mbmi->interintra_uv_mode);
}
}
#endif // CONFIG_EXT_INTER
#if CONFIG_EXT_INTERP
write_switchable_interp_filter(cpi, xd, w);
#endif // CONFIG_EXT_INTERP
......@@ -2444,6 +2460,16 @@ static size_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
#if CONFIG_EXT_INTER
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)) {
vp10_cond_prob_diff_update(&header_bc,
&fc->interintra_prob[i],
cm->counts.interintra[i]);
}
}
}
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
......
......@@ -1810,6 +1810,22 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td
#endif // CONFIG_OBMC
}
}
#if CONFIG_EXT_INTER
if (cm->reference_mode != COMPOUND_REFERENCE &&
#if CONFIG_SUPERTX
!supertx_enabled &&
#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]++;
} else {
counts->interintra[bsize][0]++;
}
}
#endif // CONFIG_EXT_INTER
if (inter_block &&
!segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
int16_t mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
......@@ -4573,7 +4589,13 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
#if CONFIG_SUPERTX
static int check_intra_b(PICK_MODE_CONTEXT *ctx) {
return !is_inter_mode((&ctx->mic)->mbmi.mode);
if (!is_inter_mode((&ctx->mic)->mbmi.mode))
return 1;
#if CONFIG_EXT_INTER
if (ctx->mic.mbmi.ref_frame[1] == INTRA_FRAME)
return 1;
#endif // CONFIG_EXT_INTER
return 0;
}
static int check_intra_sb(VP10_COMP *cpi, const TileInfo *const tile,
......
......@@ -73,7 +73,11 @@ static unsigned int do_16x16_motion_iteration(VP10_COMP *cpi,
else
#endif // CONFIG_EXT_INTER
xd->mi[0]->mbmi.mode = NEWMV;
xd->mi[0]->mbmi.mv[0].as_mv = *dst_mv;
#if CONFIG_EXT_INTER
xd->mi[0]->mbmi.ref_frame[1] = NONE;
#endif // CONFIG_EXT_INTER
vp10_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16);
......
......@@ -859,6 +859,44 @@ void vp10_set_rd_speed_thresholds(VP10_COMP *cpi) {
rd->thresh_mult[THR_D153_PRED] += 2500;
rd->thresh_mult[THR_D207_PRED] += 2500;
rd->thresh_mult[THR_D63_PRED] += 2500;
#if CONFIG_EXT_INTER
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL ] += 1500;
#if CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL2 ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL3 ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL4 ] += 1500;
#endif // CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROA ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL] += 1500;
#if CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL2] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL3] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL4] += 1500;
#endif // CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL ] += 1500;
#if CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL2 ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL3 ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL4 ] += 1500;
#endif // CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEARG ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEARA ] += 1500;
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL ] += 2000;
#if CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL2 ] += 2000;
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL3 ] += 2000;
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL4 ] += 2000;
#endif // CONFIG_EXT_REFS
rd->thresh_mult[THR_COMP_INTERINTRA_NEWG ] += 2000;
rd->thresh_mult[THR_COMP_INTERINTRA_NEWA ] += 2000;
#endif // CONFIG_EXT_INTER
}
void vp10_set_rd_speed_thresholds_sub8x8(VP10_COMP *cpi) {
......
......@@ -42,13 +42,13 @@ extern "C" {
#if CONFIG_EXT_REFS
#if CONFIG_EXT_INTER
#define MAX_MODES 85
#define MAX_MODES 109
#else
#define MAX_MODES 54
#endif // CONFIG_EXT_INTER
#else
#if CONFIG_EXT_INTER
#define MAX_MODES 43
#define MAX_MODES 55
#else
#define MAX_MODES 30
#endif // CONFIG_EXT_INTER
......@@ -212,6 +212,40 @@ typedef enum {
THR_D63_PRED,
THR_D117_PRED,
THR_D45_PRED,
#if CONFIG_EXT_INTER
THR_COMP_INTERINTRA_ZEROL,
THR_COMP_INTERINTRA_NEARESTL,
THR_COMP_INTERINTRA_NEARL,
THR_COMP_INTERINTRA_NEWL,
#if CONFIG_EXT_REFS
THR_COMP_INTERINTRA_ZEROL2,
THR_COMP_INTERINTRA_NEARESTL2,
THR_COMP_INTERINTRA_NEARL2,
THR_COMP_INTERINTRA_NEWL2,
THR_COMP_INTERINTRA_ZEROL3,
THR_COMP_INTERINTRA_NEARESTL3,
THR_COMP_INTERINTRA_NEARL3,
THR_COMP_INTERINTRA_NEWL3,
THR_COMP_INTERINTRA_ZEROL4,
THR_COMP_INTERINTRA_NEARESTL4,
THR_COMP_INTERINTRA_NEARL4,
THR_COMP_INTERINTRA_NEWL4,
#endif // CONFIG_EXT_REFS
THR_COMP_INTERINTRA_ZEROG,
THR_COMP_INTERINTRA_NEARESTG,
THR_COMP_INTERINTRA_NEARG,
THR_COMP_INTERINTRA_NEWG,
THR_COMP_INTERINTRA_ZEROA,
THR_COMP_INTERINTRA_NEARESTA,
THR_COMP_INTERINTRA_NEARA,
THR_COMP_INTERINTRA_NEWA,
#endif // CONFIG_EXT_INTER
} THR_MODES;
typedef enum {
......
This diff is collapsed.
......@@ -168,7 +168,6 @@ static void set_good_speed_feature(VP10_COMP *cpi, VP10_COMMON *cm,
if (speed >= 2) {
sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD
: USE_LARGESTALL;
sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 :
FLAG_SKIP_INTRA_DIRMISMATCH |
FLAG_SKIP_INTRA_BESTINTER |
......
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