Add CONFIG_INTERINTRA flags and reduce # of interintra modes to 4
Use CONFIG_INTERINTRA to properly separate interintra from the basic
ext_inter experiment.
When macro REDUCE_INTERINTRA_MODES is 1, only 4 ii modes are enabled
so as to reduce the complexity overhead.
(Right now the flag is off)
Change-Id: Iec6f36a1000f181adbb822ad66c7d5b2625e9cc7
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index f5fa542..e70b06c 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -383,8 +383,10 @@
#endif // CONFIG_EXT_INTRA
#if CONFIG_EXT_INTER
+#if CONFIG_INTERINTRA
// interintra members
INTERINTRA_MODE interintra_mode;
+#endif
// TODO(debargha): Consolidate these flags
int use_wedge_interintra;
int interintra_wedge_index;
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 369eb6e..67dfce6 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1081,10 +1081,20 @@
[COMPOUND_TYPES - 1];
#endif // CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
+#if CONFIG_INTERINTRA
static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
208, 208, 208, 208,
};
+#if REDUCED_INTERINTRA_MODES == 1
+static const aom_prob
+ default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
+ { 65, 32, 144 }, // block_size < 8x8
+ { 132, 68, 165 }, // block_size < 16x16
+ { 173, 80, 176 }, // block_size < 32x32
+ { 221, 135, 194 } // block_size >= 32x32
+ };
+#else // REDUCED_INTERINTRA_MODES
#if CONFIG_ALT_INTRA
static const aom_prob
default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
@@ -1102,6 +1112,7 @@
{ 221, 135, 38, 194, 248, 121, 96, 85, 29 } // block_size >= 32x32
};
#endif // CONFIG_ALT_INTRA
+#endif // REDUCED_INTERINTRA_MODES
static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
#if CONFIG_CB4X4
@@ -1112,6 +1123,7 @@
208, 208, 208
#endif // CONFIG_EXT_PARTITION
};
+#endif // CONFIG_INTERINTRA
#endif // CONFIG_EXT_INTER
// Change this section appropriately once warped motion is supported
@@ -1272,6 +1284,18 @@
#if CONFIG_EXT_INTER
/* clang-format off */
+#if CONFIG_INTERINTRA
+#if REDUCED_INTERINTRA_MODES == 1
+const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
+ -II_DC_PRED, 2, /* 0 = II_DC_NODE */
+#if CONFIG_ALT_INTRA
+ -II_SMOOTH_PRED, 4, /* 1 = II_SMOOTH_PRED */
+#else
+ -II_TM_PRED, 4, /* 1 = II_TM_NODE */
+#endif
+ -II_V_PRED, -II_H_PRED /* 2 = II_V_NODE */
+};
+#else // REDUCED_INTERINTRA_MODES
#if CONFIG_ALT_INTRA
const aom_tree_index av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)] = {
-II_DC_PRED, 2, /* 0 = II_DC_NODE */
@@ -1298,6 +1322,8 @@
-II_D153_PRED, -II_D207_PRED /* 8 = II_D153_NODE */
};
#endif
+#endif // REDUCED_INTERINTRA_MODES
+#endif // CONFIG_INTERINTRA
const aom_tree_index av1_inter_compound_mode_tree
[TREE_SIZE(INTER_COMPOUND_MODES)] = {
@@ -4385,9 +4411,11 @@
default_inter_singleref_comp_mode_probs);
#endif // CONFIG_COMPOUND_SINGLEREF
av1_copy(fc->compound_type_prob, default_compound_type_probs);
+#if CONFIG_INTERINTRA
av1_copy(fc->interintra_prob, default_interintra_prob);
av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
+#endif
#endif // CONFIG_EXT_INTER
#if CONFIG_SUPERTX
av1_copy(fc->supertx_prob, default_supertx_prob);
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index c774702..31244fd 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -199,9 +199,11 @@
[INTER_SINGLEREF_COMP_MODES - 1];
#endif // CONFIG_COMPOUND_SINGLEREF
aom_prob compound_type_prob[BLOCK_SIZES][COMPOUND_TYPES - 1];
+#if CONFIG_INTERINTRA
aom_prob interintra_prob[BLOCK_SIZE_GROUPS];
aom_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
aom_prob wedge_interintra_prob[BLOCK_SIZES];
+#endif // CONFIG_INTERINTRA
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
aom_prob motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1];
@@ -369,9 +371,11 @@
unsigned int inter_singleref_comp_mode[INTER_MODE_CONTEXTS]
[INTER_SINGLEREF_COMP_MODES];
#endif // CONFIG_COMPOUND_SINGLEREF
+#if CONFIG_INTERINTRA
unsigned int interintra[BLOCK_SIZE_GROUPS][2];
unsigned int interintra_mode[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
unsigned int wedge_interintra[BLOCK_SIZES][2];
+#endif // CONFIG_INTERINTRA
unsigned int compound_interinter[BLOCK_SIZES][COMPOUND_TYPES];
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
@@ -479,8 +483,10 @@
#endif
#if CONFIG_EXT_INTER
+#if CONFIG_INTERINTRA
extern const aom_tree_index
av1_interintra_mode_tree[TREE_SIZE(INTERINTRA_MODES)];
+#endif
extern const aom_tree_index
av1_inter_compound_mode_tree[TREE_SIZE(INTER_COMPOUND_MODES)];
#if CONFIG_COMPOUND_SINGLEREF
diff --git a/av1/common/enums.h b/av1/common/enums.h
index d6237a6..58c8a7e 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -368,6 +368,21 @@
} MOTION_MODE;
#if CONFIG_EXT_INTER
+#if CONFIG_INTERINTRA
+#define REDUCED_INTERINTRA_MODES 0
+#if REDUCED_INTERINTRA_MODES == 1
+typedef enum {
+ II_DC_PRED = 0,
+ II_V_PRED,
+ II_H_PRED,
+#if CONFIG_ALT_INTRA
+ II_SMOOTH_PRED,
+#else
+ II_TM_PRED,
+#endif // CONFIG_ALT_INTRA
+ INTERINTRA_MODES
+} INTERINTRA_MODE;
+#else
typedef enum {
II_DC_PRED = 0,
II_V_PRED,
@@ -384,6 +399,8 @@
II_TM_PRED,
INTERINTRA_MODES
} INTERINTRA_MODE;
+#endif
+#endif
typedef enum {
COMPOUND_AVERAGE = 0,
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 7ddda6f..5a161a4 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -1333,7 +1333,7 @@
int mi_row, int mi_col, BUFFER_SET *ctx,
BLOCK_SIZE bsize) {
build_inter_predictors_for_planes(cm, xd, bsize, mi_row, mi_col, 0, 0);
-#if CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
if (is_interintra_pred(&xd->mi[0]->mbmi)) {
BUFFER_SET default_ctx = { { xd->plane[0].dst.buf, NULL, NULL },
{ xd->plane[0].dst.stride, 0, 0 } };
@@ -1343,7 +1343,7 @@
}
#else
(void)ctx;
-#endif // CONFIG_EXT_INTER
+#endif // CONFIG_EXT_INTER && CONFIG_INTERINTRA
}
void av1_build_inter_predictors_sbuv(const AV1_COMMON *cm, MACROBLOCKD *xd,
@@ -1351,7 +1351,7 @@
BLOCK_SIZE bsize) {
build_inter_predictors_for_planes(cm, xd, bsize, mi_row, mi_col, 1,
MAX_MB_PLANE - 1);
-#if CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
if (is_interintra_pred(&xd->mi[0]->mbmi)) {
BUFFER_SET default_ctx = {
{ NULL, xd->plane[1].dst.buf, xd->plane[2].dst.buf },
@@ -1364,7 +1364,7 @@
}
#else
(void)ctx;
-#endif // CONFIG_EXT_INTER
+#endif // CONFIG_EXT_INTER && CONFIG_INTERINTRA
}
// TODO(afergs): Check if ctx can be made constant
@@ -1373,7 +1373,7 @@
BLOCK_SIZE bsize) {
build_inter_predictors_for_planes(cm, xd, bsize, mi_row, mi_col, 0,
MAX_MB_PLANE - 1);
-#if CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
if (is_interintra_pred(&xd->mi[0]->mbmi)) {
BUFFER_SET default_ctx = {
{ xd->plane[0].dst.buf, xd->plane[1].dst.buf, xd->plane[2].dst.buf },
@@ -1388,7 +1388,7 @@
}
#else
(void)ctx;
-#endif // CONFIG_EXT_INTER
+#endif // CONFIG_EXT_INTER && CONFIG_INTERINTRA
}
void av1_setup_dst_planes(struct macroblockd_plane planes[MAX_MB_PLANE],
@@ -2534,6 +2534,7 @@
#if CONFIG_EXT_INTER
/* clang-format off */
+#if CONFIG_INTERINTRA
#if CONFIG_EXT_PARTITION
static const int ii_weights1d[MAX_SB_SIZE] = {
60, 58, 56, 54, 52, 50, 48, 47, 45, 44, 42, 41, 39, 38, 37, 35, 34, 33, 32,
@@ -2615,6 +2616,7 @@
}
break;
+#if REDUCED_INTERINTRA_MODES == 0
case II_D63_PRED:
case II_D117_PRED:
for (i = 0; i < bh; ++i) {
@@ -2643,20 +2645,6 @@
}
break;
- case II_D135_PRED:
-#if CONFIG_ALT_INTRA
- case II_SMOOTH_PRED:
-#endif
- for (i = 0; i < bh; ++i) {
- for (j = 0; j < bw; ++j) {
- int scale = ii_weights1d[(i < j ? i : j) * size_scale];
- comppred[i * compstride + j] =
- AOM_BLEND_A64(scale, intrapred[i * intrastride + j],
- interpred[i * interstride + j]);
- }
- }
- break;
-
case II_D45_PRED:
for (i = 0; i < bh; ++i) {
for (j = 0; j < bw; ++j) {
@@ -2669,8 +2657,29 @@
}
}
break;
+#endif
+#if REDUCED_INTERINTRA_MODES == 0 || CONFIG_ALT_INTRA
+#if REDUCED_INTERINTRA_MODES == 0
+ case II_D135_PRED:
+#endif
+#if CONFIG_ALT_INTRA
+ case II_SMOOTH_PRED:
+#endif
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
+ int scale = ii_weights1d[(i < j ? i : j) * size_scale];
+ comppred[i * compstride + j] =
+ AOM_BLEND_A64(scale, intrapred[i * intrastride + j],
+ interpred[i * interstride + j]);
+ }
+ }
+ break;
+#endif
+
+#if !(REDUCED_INTERINTRA_MODES == 1 && CONFIG_ALT_INTRA)
case II_TM_PRED:
+#endif
case II_DC_PRED:
default:
for (i = 0; i < bh; ++i) {
@@ -2734,6 +2743,7 @@
}
break;
+#if REDUCED_INTERINTRA_MODES == 0
case II_D63_PRED:
case II_D117_PRED:
for (i = 0; i < bh; ++i) {
@@ -2762,20 +2772,6 @@
}
break;
- case II_D135_PRED:
-#if CONFIG_ALT_INTRA
- case II_SMOOTH_PRED:
-#endif
- for (i = 0; i < bh; ++i) {
- for (j = 0; j < bw; ++j) {
- int scale = ii_weights1d[(i < j ? i : j) * size_scale];
- comppred[i * compstride + j] =
- AOM_BLEND_A64(scale, intrapred[i * intrastride + j],
- interpred[i * interstride + j]);
- }
- }
- break;
-
case II_D45_PRED:
for (i = 0; i < bh; ++i) {
for (j = 0; j < bw; ++j) {
@@ -2788,8 +2784,29 @@
}
}
break;
+#endif
+#if REDUCED_INTERINTRA_MODES == 0 || CONFIG_ALT_INTRA
+#if REDUCED_INTERINTRA_MODES == 0
+ case II_D135_PRED:
+#endif
+#if CONFIG_ALT_INTRA
+ case II_SMOOTH_PRED:
+#endif
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
+ int scale = ii_weights1d[(i < j ? i : j) * size_scale];
+ comppred[i * compstride + j] =
+ AOM_BLEND_A64(scale, intrapred[i * intrastride + j],
+ interpred[i * interstride + j]);
+ }
+ }
+ break;
+#endif
+
+#if !(REDUCED_INTERINTRA_MODES == 1 && CONFIG_ALT_INTRA)
case II_TM_PRED:
+#endif
case II_DC_PRED:
default:
for (i = 0; i < bh; ++i) {
@@ -2901,6 +2918,7 @@
av1_build_interintra_predictors_sbuv(xd, upred, vpred, ustride, vstride, ctx,
bsize);
}
+#endif // CONFIG_INTERINTRA
// Builds the inter-predictor for the single ref case
// for use in the encoder to search the wedges efficiently.
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index 7485264..887651f 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -798,7 +798,7 @@
const uint8_t *av1_get_compound_type_mask(
const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type);
-
+#if CONFIG_INTERINTRA
void av1_build_interintra_predictors(MACROBLOCKD *xd, uint8_t *ypred,
uint8_t *upred, uint8_t *vpred,
int ystride, int ustride, int vstride,
@@ -822,7 +822,7 @@
void av1_combine_interintra(MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane,
const uint8_t *inter_pred, int inter_stride,
const uint8_t *intra_pred, int intra_stride);
-
+#endif // CONFIG_INTERINTRA
// Encoder only
void av1_build_inter_predictors_for_planes_single_buf(
MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int mi_row,
diff --git a/av1/common/reconintra.h b/av1/common/reconintra.h
index 6d4a86a..fa8865f 100644
--- a/av1/common/reconintra.h
+++ b/av1/common/reconintra.h
@@ -27,8 +27,34 @@
const uint8_t *ref, int ref_stride, uint8_t *dst,
int dst_stride, int aoff, int loff, int plane);
-#if CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
// Mapping of interintra to intra mode for use in the intra component
+#if REDUCED_INTERINTRA_MODES == 1
+static const PREDICTION_MODE interintra_to_intra_mode[INTERINTRA_MODES] = {
+ DC_PRED, V_PRED, H_PRED,
+#if CONFIG_ALT_INTRA
+ SMOOTH_PRED
+#else
+ TM_PRED
+#endif
+};
+
+// Mapping of intra mode to the interintra mode
+static const INTERINTRA_MODE intra_to_interintra_mode[INTRA_MODES] = {
+ II_DC_PRED, II_V_PRED, II_H_PRED, II_V_PRED,
+#if CONFIG_ALT_INTRA
+ II_SMOOTH_PRED,
+#else
+ II_TM_PRED,
+#endif
+ II_V_PRED, II_H_PRED, II_H_PRED, II_V_PRED,
+#if CONFIG_ALT_INTRA
+ II_SMOOTH_PRED, II_SMOOTH_PRED
+#else
+ II_TM_PRED
+#endif
+};
+#else
static const PREDICTION_MODE interintra_to_intra_mode[INTERINTRA_MODES] = {
DC_PRED, V_PRED, H_PRED, D45_PRED, D135_PRED,
D117_PRED, D153_PRED, D207_PRED, D63_PRED,
@@ -47,7 +73,8 @@
#endif
II_TM_PRED
};
-#endif // CONFIG_EXT_INTER
+#endif
+#endif // CONFIG_EXT_INTER && CONFIG_INTERINTRA
#ifdef __cplusplus
} // extern "C"
#endif