Only one ME per reference picture (same ref in L0 and L1)
@@ -1227,9 +1227,8 @@ static void search_pu_inter_ref(inter_search_info_t *info,
// Must find at least one reference picture
assert(ref_list_active[0] || ref_list_active[1]);
- for (int ref_list = 0; ref_list < 2; ++ref_list) {
- if (ref_list_active[ref_list]) {
-
+ // Does not matter which list is used, if in both.
+ int ref_list = ref_list_active[0] ? 0 : 1;
int LX_idx = ref_list_idx[ref_list];
// Get MV candidates
@@ -1363,12 +1362,18 @@ static void search_pu_inter_ref(inter_search_info_t *info,
best_cost += best_bits * info->state->lambda_sqrt;
}
- // Only check when candidates are different
+ double LX_cost[2] = { best_cost, best_cost };
+ double LX_bits[2] = { best_bits, best_bits };
+
+ // Compute costs and add entries for both lists, if necessary
+ for (; ref_list_active[ref_list] && ref_list < 2; ++ref_list) {
+
+ LX_idx = ref_list_idx[ref_list];
uint8_t mv_ref_coded = LX_idx;
int cu_mv_cand = select_mv_cand(info->state, info->mv_cand, best_mv.x, best_mv.y, NULL);
const int extra_bits = ref_list + mv_ref_coded; // TODO: check if mv_dir bits are missing
- best_cost += extra_bits * info->state->lambda_sqrt;
- best_bits += extra_bits;
+ LX_cost[ref_list] += extra_bits * info->state->lambda_sqrt;
+ LX_bits[ref_list] += extra_bits;
// Update best unipreds for biprediction
bool valid_mv = fracmv_within_tile(info, best_mv.x, best_mv.y);
@@ -1393,7 +1398,6 @@ static void search_pu_inter_ref(inter_search_info_t *info,
}
}
}
-}
/**
