nonrd: remove ref frame cost estimation for comp ref frames.
comp reference isn't used in non rd pickmode.
Change-Id: I53dac06530d9f1d2e10c8346d1707d1d10ee19b2
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 1c0f03b..259e3c0 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -468,18 +468,14 @@
mbmi->num_proj_ref = 1;
}
-static void estimate_ref_frame_costs(
- const AV1_COMMON *cm, const MACROBLOCKD *xd, const MACROBLOCK *x,
- int segment_id, unsigned int *ref_costs_single,
- unsigned int (*ref_costs_comp)[REF_FRAMES]) {
+static void estimate_single_ref_frame_costs(const AV1_COMMON *cm,
+ const MACROBLOCKD *xd,
+ const MACROBLOCK *x, int segment_id,
+ unsigned int *ref_costs_single) {
int seg_ref_active =
segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME);
if (seg_ref_active) {
memset(ref_costs_single, 0, REF_FRAMES * sizeof(*ref_costs_single));
- int ref_frame;
- for (ref_frame = 0; ref_frame < REF_FRAMES; ++ref_frame)
- memset(ref_costs_comp[ref_frame], 0,
- REF_FRAMES * sizeof((*ref_costs_comp)[0]));
} else {
int intra_inter_ctx = av1_get_intra_inter_context(xd);
ref_costs_single[INTRA_FRAME] = x->intra_inter_cost[intra_inter_ctx][0];
@@ -530,91 +526,6 @@
// Level 2: bwdref or altref2
ref_costs_single[BWDREF_FRAME] += x->single_ref_cost[ctx_p6][5][0];
ref_costs_single[ALTREF2_FRAME] += x->single_ref_cost[ctx_p6][5][1];
-
- if (cm->current_frame.reference_mode != SINGLE_REFERENCE) {
- // Similar to single ref, determine cost of compound ref frames.
- // cost_compound_refs = cost_first_ref + cost_second_ref
- const int bwdref_comp_ctx_p = av1_get_pred_context_comp_bwdref_p(xd);
- const int bwdref_comp_ctx_p1 = av1_get_pred_context_comp_bwdref_p1(xd);
- const int ref_comp_ctx_p = av1_get_pred_context_comp_ref_p(xd);
- const int ref_comp_ctx_p1 = av1_get_pred_context_comp_ref_p1(xd);
- const int ref_comp_ctx_p2 = av1_get_pred_context_comp_ref_p2(xd);
-
- const int comp_ref_type_ctx = av1_get_comp_reference_type_context(xd);
- unsigned int ref_bicomp_costs[REF_FRAMES] = { 0 };
-
- ref_bicomp_costs[LAST_FRAME] = ref_bicomp_costs[LAST2_FRAME] =
- ref_bicomp_costs[LAST3_FRAME] = ref_bicomp_costs[GOLDEN_FRAME] =
- base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][1];
- ref_bicomp_costs[BWDREF_FRAME] = ref_bicomp_costs[ALTREF2_FRAME] = 0;
- ref_bicomp_costs[ALTREF_FRAME] = 0;
-
- // cost of first ref frame
- ref_bicomp_costs[LAST_FRAME] += x->comp_ref_cost[ref_comp_ctx_p][0][0];
- ref_bicomp_costs[LAST2_FRAME] += x->comp_ref_cost[ref_comp_ctx_p][0][0];
- ref_bicomp_costs[LAST3_FRAME] += x->comp_ref_cost[ref_comp_ctx_p][0][1];
- ref_bicomp_costs[GOLDEN_FRAME] += x->comp_ref_cost[ref_comp_ctx_p][0][1];
-
- ref_bicomp_costs[LAST_FRAME] += x->comp_ref_cost[ref_comp_ctx_p1][1][0];
- ref_bicomp_costs[LAST2_FRAME] += x->comp_ref_cost[ref_comp_ctx_p1][1][1];
-
- ref_bicomp_costs[LAST3_FRAME] += x->comp_ref_cost[ref_comp_ctx_p2][2][0];
- ref_bicomp_costs[GOLDEN_FRAME] += x->comp_ref_cost[ref_comp_ctx_p2][2][1];
-
- // cost of second ref frame
- ref_bicomp_costs[BWDREF_FRAME] +=
- x->comp_bwdref_cost[bwdref_comp_ctx_p][0][0];
- ref_bicomp_costs[ALTREF2_FRAME] +=
- x->comp_bwdref_cost[bwdref_comp_ctx_p][0][0];
- ref_bicomp_costs[ALTREF_FRAME] +=
- x->comp_bwdref_cost[bwdref_comp_ctx_p][0][1];
-
- ref_bicomp_costs[BWDREF_FRAME] +=
- x->comp_bwdref_cost[bwdref_comp_ctx_p1][1][0];
- ref_bicomp_costs[ALTREF2_FRAME] +=
- x->comp_bwdref_cost[bwdref_comp_ctx_p1][1][1];
-
- // cost: if one ref frame is forward ref, the other ref is backward ref
- int ref0, ref1;
- for (ref0 = LAST_FRAME; ref0 <= GOLDEN_FRAME; ++ref0) {
- for (ref1 = BWDREF_FRAME; ref1 <= ALTREF_FRAME; ++ref1) {
- ref_costs_comp[ref0][ref1] =
- ref_bicomp_costs[ref0] + ref_bicomp_costs[ref1];
- }
- }
-
- // cost: if both ref frames are the same side.
- const int uni_comp_ref_ctx_p = av1_get_pred_context_uni_comp_ref_p(xd);
- const int uni_comp_ref_ctx_p1 = av1_get_pred_context_uni_comp_ref_p1(xd);
- const int uni_comp_ref_ctx_p2 = av1_get_pred_context_uni_comp_ref_p2(xd);
- ref_costs_comp[LAST_FRAME][LAST2_FRAME] =
- base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][0];
- ref_costs_comp[LAST_FRAME][LAST3_FRAME] =
- base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][1] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p2][2][0];
- ref_costs_comp[LAST_FRAME][GOLDEN_FRAME] =
- base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][1] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p2][2][1];
- ref_costs_comp[BWDREF_FRAME][ALTREF_FRAME] =
- base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
- x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][1];
- } else {
- int ref0, ref1;
- for (ref0 = LAST_FRAME; ref0 <= GOLDEN_FRAME; ++ref0) {
- for (ref1 = BWDREF_FRAME; ref1 <= ALTREF_FRAME; ++ref1)
- ref_costs_comp[ref0][ref1] = 512;
- }
- ref_costs_comp[LAST_FRAME][LAST2_FRAME] = 512;
- ref_costs_comp[LAST_FRAME][LAST3_FRAME] = 512;
- ref_costs_comp[LAST_FRAME][GOLDEN_FRAME] = 512;
- ref_costs_comp[BWDREF_FRAME][ALTREF_FRAME] = 512;
- }
}
}
@@ -971,8 +882,7 @@
int ref_frame_skip_mask = 0;
int best_pred_sad = INT_MAX;
int best_early_term = 0;
- unsigned int ref_costs_single[REF_FRAMES],
- ref_costs_comp[REF_FRAMES][REF_FRAMES];
+ unsigned int ref_costs_single[REF_FRAMES];
int use_golden_nonzeromv = 1;
int force_skip_low_temp_var = 0;
int skip_ref_find_pred[5] = { 0 };
@@ -1017,8 +927,7 @@
av1_collect_neighbors_ref_counts(xd);
av1_count_overlappable_neighbors(cm, xd, mi_row, mi_col);
- estimate_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single,
- ref_costs_comp);
+ estimate_single_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single);
memset(&mode_checked[0][0], 0, MB_MODE_COUNT * REF_FRAMES);
if (reuse_inter_pred) {