Commit d4d8b868 authored by Zoe Liu's avatar Zoe Liu

Update the experiment of ref-adapt

This experiment allows two choices for the frame-level reference
mode flag: SINGLE_REFERENCE and REFERENCE_MODE_SELECT. It removes
the choice of COMPOUND_REFERENCE, as it has been barely used.

Change-Id: I8af18acd2fe3c0d4928f2b05f35aad0ebcb1556a
parent ef3893bf
......@@ -2460,11 +2460,17 @@ void read_sequence_header(SequenceHeader *seq_params,
static void read_compound_tools(AV1_COMMON *cm,
struct aom_read_bit_buffer *rb) {
#if CONFIG_REF_ADAPT
cm->allow_interintra_compound =
!frame_is_intra_only(cm) ? aom_rb_read_bit(rb) : 0;
#else
if (!frame_is_intra_only(cm) && cm->reference_mode != COMPOUND_REFERENCE) {
cm->allow_interintra_compound = aom_rb_read_bit(rb);
} else {
cm->allow_interintra_compound = 0;
}
#endif // CONFIG_REF_ADAPT
if (!frame_is_intra_only(cm) && cm->reference_mode != SINGLE_REFERENCE) {
cm->allow_masked_compound = aom_rb_read_bit(rb);
} else {
......
......@@ -1298,6 +1298,9 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
if (counts) ++counts->comp_inter[ctx][mode];
return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE
} else {
#if CONFIG_REF_ADAPT
assert(cm->reference_mode == SINGLE_REFERENCE);
#endif // CONFIG_REF_ADAPT
return cm->reference_mode;
}
}
......@@ -2112,11 +2115,14 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#endif // CONFIG_EXT_SKIP
mbmi->use_wedge_interintra = 0;
if (cm->reference_mode != COMPOUND_REFERENCE &&
if (cm->allow_interintra_compound &&
#if !CONFIG_REF_ADAPT
cm->reference_mode != COMPOUND_REFERENCE &&
#endif // !CONFIG_REF_ADAPT
#if CONFIG_EXT_SKIP
!mbmi->skip_mode &&
#endif // CONFIG_EXT_SKIP
cm->allow_interintra_compound && is_interintra_allowed(mbmi)) {
is_interintra_allowed(mbmi)) {
const int bsize_group = size_group_lookup[bsize];
const int interintra =
aom_read_symbol(r, ec_ctx->interintra_cdf[bsize_group], 2, ACCT_STR);
......
......@@ -1130,9 +1130,11 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
if (has_second_ref(mbmi))
// This flag is also updated for 4x4 blocks
rdc->compound_ref_used_flag = 1;
#if !CONFIG_REF_ADAPT
else
// This flag is also updated for 4x4 blocks
rdc->single_ref_used_flag = 1;
#endif // !CONFIG_REF_ADAPT
if (is_comp_ref_allowed(bsize)) {
counts->comp_inter[av1_get_reference_mode_context(cm, xd)]
[has_second_ref(mbmi)]++;
......@@ -1209,8 +1211,11 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
}
}
if (cm->reference_mode != COMPOUND_REFERENCE &&
cm->allow_interintra_compound && is_interintra_allowed(mbmi)) {
if (cm->allow_interintra_compound &&
#if !CONFIG_REF_ADAPT
cm->reference_mode != COMPOUND_REFERENCE &&
#endif // !CONFIG_REF_ADAPT
is_interintra_allowed(mbmi)) {
const int bsize_group = size_group_lookup[bsize];
if (mbmi->ref_frame[1] == INTRA_FRAME) {
counts->interintra[bsize_group][1]++;
......@@ -4362,7 +4367,11 @@ static void encode_frame_internal(AV1_COMP *cpi) {
static void make_consistent_compound_tools(AV1_COMMON *cm) {
(void)cm;
#if CONFIG_REF_ADAPT
if (frame_is_intra_only(cm))
#else
if (frame_is_intra_only(cm) || cm->reference_mode == COMPOUND_REFERENCE)
#endif // CONFIG_REF_ADAPT
cm->allow_interintra_compound = 0;
if (frame_is_intra_only(cm) || cm->reference_mode == SINGLE_REFERENCE)
cm->allow_masked_compound = 0;
......@@ -4450,7 +4459,7 @@ void av1_encode_frame(AV1_COMP *cpi) {
cm->reference_mode = SINGLE_REFERENCE;
else
cm->reference_mode = REFERENCE_MODE_SELECT;
#else
#else // !CONFIG_REF_ADAPT
#if CONFIG_BGSPRITE
(void)is_alt_ref;
if (!cpi->allow_comp_inter_inter)
......@@ -4479,7 +4488,9 @@ void av1_encode_frame(AV1_COMP *cpi) {
make_consistent_compound_tools(cm);
#if !CONFIG_REF_ADAPT
rdc->single_ref_used_flag = 0;
#endif // !CONFIG_REF_ADAPT
rdc->compound_ref_used_flag = 0;
#if CONFIG_EXT_SKIP
rdc->skip_mode_used_flag = 0;
......
......@@ -325,7 +325,9 @@ typedef struct RD_COUNTS {
int64_t comp_pred_diff[REFERENCE_MODES];
// Stores number of 4x4 blocks using global motion per reference frame.
int global_motion_used[TOTAL_REFS_PER_FRAME];
#if !CONFIG_REF_ADAPT
int single_ref_used_flag;
#endif // !CONFIG_REF_ADAPT
int compound_ref_used_flag;
#if CONFIG_EXT_SKIP
int skip_mode_used_flag;
......
......@@ -24,7 +24,9 @@ static void accumulate_rd_opt(ThreadData *td, ThreadData *td_t) {
td->rd_counts.compound_ref_used_flag |=
td_t->rd_counts.compound_ref_used_flag;
#if !CONFIG_REF_ADAPT
td->rd_counts.single_ref_used_flag |= td_t->rd_counts.single_ref_used_flag;
#endif // !CONFIG_REF_ADAPT
#if CONFIG_EXT_SKIP
td->rd_counts.skip_mode_used_flag |= td_t->rd_counts.skip_mode_used_flag;
#endif // CONFIG_EXT_SKIP
......
......@@ -6038,7 +6038,11 @@ static void estimate_ref_frame_costs(
ref_costs_single[INTRA_FRAME] = x->intra_inter_cost[intra_inter_ctx][0];
unsigned int base_cost = x->intra_inter_cost[intra_inter_ctx][1];
#if !CONFIG_REF_ADAPT
if (cm->reference_mode != COMPOUND_REFERENCE) {
#endif // !CONFIG_REF_ADAPT
aom_prob ref_single_p1 = av1_get_pred_prob_single_ref_p1(cm, xd);
aom_prob ref_single_p2 = av1_get_pred_prob_single_ref_p2(cm, xd);
aom_prob ref_single_p3 = av1_get_pred_prob_single_ref_p3(cm, xd);
......@@ -6046,8 +6050,6 @@ static void estimate_ref_frame_costs(
aom_prob ref_single_p5 = av1_get_pred_prob_single_ref_p5(cm, xd);
aom_prob ref_single_p6 = av1_get_pred_prob_single_ref_p6(cm, xd);
unsigned int base_cost = x->intra_inter_cost[intra_inter_ctx][1];
ref_costs_single[LAST_FRAME] = ref_costs_single[LAST2_FRAME] =
ref_costs_single[LAST3_FRAME] = ref_costs_single[BWDREF_FRAME] =
ref_costs_single[ALTREF2_FRAME] = ref_costs_single[GOLDEN_FRAME] =
......@@ -6078,6 +6080,7 @@ static void estimate_ref_frame_costs(
ref_costs_single[BWDREF_FRAME] += av1_cost_bit(ref_single_p6, 0);
ref_costs_single[ALTREF2_FRAME] += av1_cost_bit(ref_single_p6, 1);
#if !CONFIG_REF_ADAPT
} else {
ref_costs_single[LAST_FRAME] = 512;
ref_costs_single[LAST2_FRAME] = 512;
......@@ -6087,6 +6090,7 @@ static void estimate_ref_frame_costs(
ref_costs_single[GOLDEN_FRAME] = 512;
ref_costs_single[ALTREF_FRAME] = 512;
}
#endif // !CONFIG_REF_ADAPT
if (cm->reference_mode != SINGLE_REFERENCE) {
aom_prob ref_comp_p = av1_get_pred_prob_comp_ref_p(cm, xd);
......@@ -6095,8 +6099,6 @@ static void estimate_ref_frame_costs(
aom_prob bwdref_comp_p = av1_get_pred_prob_comp_bwdref_p(cm, xd);
aom_prob bwdref_comp_p1 = av1_get_pred_prob_comp_bwdref_p1(cm, xd);
unsigned int base_cost = x->intra_inter_cost[intra_inter_ctx][1];
#if CONFIG_EXT_COMP_REFS
aom_prob comp_ref_type_p = av1_get_comp_reference_type_prob(cm, xd);
unsigned int ref_bicomp_costs[TOTAL_REFS_PER_FRAME] = { 0 };
......@@ -9624,8 +9626,12 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
mode_excluded = cm->reference_mode == SINGLE_REFERENCE;
} else {
#if CONFIG_REF_ADAPT
if (ref_frame != INTRA_FRAME) mode_excluded = 0;
#else
if (ref_frame != INTRA_FRAME)
mode_excluded = cm->reference_mode == COMPOUND_REFERENCE;
#endif // CONFIG_REF_ADAPT
}
if (ref_frame == INTRA_FRAME) {
......
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