[NORMATIVE, jnt-comp] Disable compound_idx if !enable_jnt_comp If enable_jnt_comp is 0, the code still signals the compound_idx symbol, but both choices result in the exact same compound prediction. This patch fixes that redundancy by forcing compound_idx = 1 whenever enable_jnt_comp = 0. Also add an assert in bitstream.c, to make sure that the encoder always selects the correct value of compound_idx. BUG=aomedia:1442 Change-Id: I905052f7f85c53eadbd6ba43c905dabd4c3cb65c
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c index 0b08503..fa47f5f 100644 --- a/av1/common/reconinter.c +++ b/av1/common/reconinter.c
@@ -870,7 +870,7 @@ int order_idx, int *fwd_offset, int *bck_offset, int *use_jnt_comp_avg, int is_compound) { assert(fwd_offset != NULL && bck_offset != NULL); - if (!is_compound || mbmi->compound_idx || !cm->seq_params.enable_jnt_comp) { + if (!is_compound || mbmi->compound_idx) { *use_jnt_comp_avg = 0; return; }
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c index 40833bd..d6bfc4d 100644 --- a/av1/decoder/decodemv.c +++ b/av1/decoder/decodemv.c
@@ -1930,9 +1930,14 @@ } if (mbmi->comp_group_idx == 0) { - const int comp_index_ctx = get_comp_index_context(cm, xd); - mbmi->compound_idx = aom_read_symbol( - r, ec_ctx->compound_index_cdf[comp_index_ctx], 2, ACCT_STR); + if (cm->seq_params.enable_jnt_comp) { + const int comp_index_ctx = get_comp_index_context(cm, xd); + mbmi->compound_idx = aom_read_symbol( + r, ec_ctx->compound_index_cdf[comp_index_ctx], 2, ACCT_STR); + } else { + // Distance-weighted compound is disabled, so always use average + mbmi->compound_idx = 1; + } } else { assert(cm->reference_mode != SINGLE_REFERENCE && is_inter_compound_mode(mbmi->mode) &&
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 6220340..c461273 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -1290,9 +1290,13 @@ if (mbmi->compound_idx) assert(mbmi->interinter_compound_type == COMPOUND_AVERAGE); - const int comp_index_ctx = get_comp_index_context(cm, xd); - aom_write_symbol(w, mbmi->compound_idx, - ec_ctx->compound_index_cdf[comp_index_ctx], 2); + if (cm->seq_params.enable_jnt_comp) { + const int comp_index_ctx = get_comp_index_context(cm, xd); + aom_write_symbol(w, mbmi->compound_idx, + ec_ctx->compound_index_cdf[comp_index_ctx], 2); + } else { + assert(mbmi->compound_idx == 1); + } } else { assert(cpi->common.reference_mode != SINGLE_REFERENCE && is_inter_compound_mode(mbmi->mode) &&
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 3c9bd7a..ba4bd63 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -8136,10 +8136,11 @@ const MB_MODE_INFO backup_mbmi = *mbmi; MB_MODE_INFO best_mbmi = *mbmi; int64_t early_terminate = 0; - const int search_jnt_comp = is_comp_pred & cm->seq_params.enable_jnt_comp; int comp_idx; - for (comp_idx = 0; comp_idx < 1 + search_jnt_comp; ++comp_idx) { + const int search_jnt_comp = is_comp_pred & cm->seq_params.enable_jnt_comp; + // If !search_jnt_comp, we need to force mbmi->compound_idx = 1. + for (comp_idx = !search_jnt_comp; comp_idx < 2; ++comp_idx) { compmode_interinter_cost = 0; early_terminate = 0; *rd_stats = backup_rd_stats;