Remove cdfs and costs for dist-wtd comp
as part of CONFIG_REMOVE_DIST_WTD_COMP config flag.
Change-Id: Idfeca9545280b7b11f12e34351629b1eca390c94
diff --git a/av1/common/entropy.c b/av1/common/entropy.c
index eda7a36..ff0422f 100644
--- a/av1/common/entropy.c
+++ b/av1/common/entropy.c
@@ -127,7 +127,9 @@
RESET_CDF_COUNTER(fc->comp_ref_cdf, 2);
RESET_CDF_COUNTER(fc->comp_bwdref_cdf, 2);
RESET_CDF_COUNTER(fc->txfm_partition_cdf, 2);
+#if !CONFIG_REMOVE_DIST_WTD_COMP
RESET_CDF_COUNTER(fc->compound_index_cdf, 2);
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
RESET_CDF_COUNTER(fc->comp_group_idx_cdf, 2);
RESET_CDF_COUNTER(fc->skip_mode_cdfs, 2);
RESET_CDF_COUNTER(fc->skip_txfm_cdfs, 2);
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 0d184e1..1d90acb 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -800,11 +800,13 @@
static const aom_cdf_prob default_skip_mode_cdfs[SKIP_MODE_CONTEXTS][CDF_SIZE(
2)] = { { AOM_CDF2(32621) }, { AOM_CDF2(20708) }, { AOM_CDF2(8127) } };
+#if !CONFIG_REMOVE_DIST_WTD_COMP
static const aom_cdf_prob
default_compound_idx_cdfs[COMP_INDEX_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_CDF2(18244) }, { AOM_CDF2(12865) }, { AOM_CDF2(7053) },
{ AOM_CDF2(13259) }, { AOM_CDF2(9334) }, { AOM_CDF2(4644) }
};
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
static const aom_cdf_prob
default_comp_group_idx_cdfs[COMP_GROUP_IDX_CONTEXTS][CDF_SIZE(2)] = {
@@ -1099,7 +1101,9 @@
av1_copy(fc->comp_bwdref_cdf, default_comp_bwdref_cdf);
av1_copy(fc->single_ref_cdf, default_single_ref_cdf);
av1_copy(fc->txfm_partition_cdf, default_txfm_partition_cdf);
+#if !CONFIG_REMOVE_DIST_WTD_COMP
av1_copy(fc->compound_index_cdf, default_compound_idx_cdfs);
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
av1_copy(fc->comp_group_idx_cdf, default_comp_group_idx_cdfs);
av1_copy(fc->newmv_cdf, default_newmv_cdf);
av1_copy(fc->zeromv_cdf, default_zeromv_cdf);
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index c4275a6..ef08f79 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -96,6 +96,7 @@
return above_sip + left_sip;
}
+#if !CONFIG_REMOVE_DIST_WTD_COMP
static INLINE int get_comp_index_context(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
MB_MODE_INFO *mbmi = xd->mi[0];
@@ -134,6 +135,7 @@
return above_ctx + left_ctx + 3 * offset;
}
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
static INLINE int get_comp_group_idx_context(const MACROBLOCKD *xd) {
const MB_MODE_INFO *const above_mi = xd->above_mbmi;
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index d0af97e..869b9aa 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -685,8 +685,10 @@
* \name Inter Costs: Compound Masks
****************************************************************************/
/**@{*/
+#if !CONFIG_REMOVE_DIST_WTD_COMP
//! comp_idx_cost
int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
//! comp_group_idx_cost
int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
/**@}*/
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index f5ba036..e083e99 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -891,9 +891,14 @@
}
// Calculates the cost for compound type mask
-static INLINE void calc_masked_type_cost(
- const ModeCosts *mode_costs, BLOCK_SIZE bsize, int comp_group_idx_ctx,
- int comp_index_ctx, int masked_compound_used, int *masked_type_cost) {
+static INLINE void calc_masked_type_cost(const ModeCosts *mode_costs,
+ BLOCK_SIZE bsize,
+ int comp_group_idx_ctx,
+#if !CONFIG_REMOVE_DIST_WTD_COMP
+ int comp_index_ctx,
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
+ int masked_compound_used,
+ int *masked_type_cost) {
av1_zero_array(masked_type_cost, COMPOUND_TYPES);
// Account for group index cost when wedge and/or diffwtd prediction are
// enabled
@@ -909,10 +914,12 @@
}
// Compute the cost to signal compound index/type
+#if !CONFIG_REMOVE_DIST_WTD_COMP
masked_type_cost[COMPOUND_AVERAGE] +=
mode_costs->comp_idx_cost[comp_index_ctx][1];
masked_type_cost[COMPOUND_DISTWTD] +=
mode_costs->comp_idx_cost[comp_index_ctx][0];
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
masked_type_cost[COMPOUND_WEDGE] += mode_costs->compound_type_cost[bsize][0];
masked_type_cost[COMPOUND_DIFFWTD] +=
mode_costs->compound_type_cost[bsize][1];
@@ -1322,11 +1329,17 @@
// The following context indices are independent of compound type
const int comp_group_idx_ctx = get_comp_group_idx_context(xd);
+#if !CONFIG_REMOVE_DIST_WTD_COMP
const int comp_index_ctx = get_comp_index_context(cm, xd);
// Populates masked_type_cost local array for the 4 compound types
calc_masked_type_cost(&x->mode_costs, bsize, comp_group_idx_ctx,
comp_index_ctx, masked_compound_used, masked_type_cost);
+#else
+ // Populates masked_type_cost local array for the 4 compound types
+ calc_masked_type_cost(&x->mode_costs, bsize, comp_group_idx_ctx,
+ masked_compound_used, masked_type_cost);
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
int64_t comp_model_rd_cur = INT64_MAX;
int64_t best_rd_cur = INT64_MAX;
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index 9ba0324..372b7c3 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -1031,7 +1031,9 @@
AVERAGE_CDF(ctx_left->comp_ref_cdf, ctx_tr->comp_ref_cdf, 2);
AVERAGE_CDF(ctx_left->comp_bwdref_cdf, ctx_tr->comp_bwdref_cdf, 2);
AVERAGE_CDF(ctx_left->txfm_partition_cdf, ctx_tr->txfm_partition_cdf, 2);
+#if !CONFIG_REMOVE_DIST_WTD_COMP
AVERAGE_CDF(ctx_left->compound_index_cdf, ctx_tr->compound_index_cdf, 2);
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
AVERAGE_CDF(ctx_left->comp_group_idx_cdf, ctx_tr->comp_group_idx_cdf, 2);
AVERAGE_CDF(ctx_left->skip_mode_cdfs, ctx_tr->skip_mode_cdfs, 2);
AVERAGE_CDF(ctx_left->skip_txfm_cdfs, ctx_tr->skip_txfm_cdfs, 2);
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 30ecb1c..35cad44 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -1028,12 +1028,16 @@
}
if (mbmi->comp_group_idx == 0) {
+#if !CONFIG_REMOVE_DIST_WTD_COMP
const int comp_index_ctx = get_comp_index_context(cm, xd);
#if CONFIG_ENTROPY_STATS
++counts->compound_index[comp_index_ctx][mbmi->compound_idx];
#endif
update_cdf(fc->compound_index_cdf[comp_index_ctx], mbmi->compound_idx,
2);
+#else
+ assert(mbmi->compound_idx == 1);
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
} else {
assert(masked_compound_used);
if (is_interinter_compound_used(COMPOUND_WEDGE, bsize)) {
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 14fc97a..f124b2f 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -304,10 +304,12 @@
av1_cost_tokens_from_cdf(mode_costs->motion_mode_cost1[i],
fc->obmc_cdf[i], NULL);
}
+#if !CONFIG_REMOVE_DIST_WTD_COMP
for (i = 0; i < COMP_INDEX_CONTEXTS; ++i) {
av1_cost_tokens_from_cdf(mode_costs->comp_idx_cost[i],
fc->compound_index_cdf[i], NULL);
}
+#endif // !CONFIG_REMOVE_DIST_WTD_COMP
for (i = 0; i < COMP_GROUP_IDX_CONTEXTS; ++i) {
av1_cost_tokens_from_cdf(mode_costs->comp_group_idx_cost[i],
fc->comp_group_idx_cdf[i], NULL);