Accumulate the overall rdcost across a tpl frame
Change-Id: I20cc212270a688a30cfdce87fa037e31d0851c9d
diff --git a/av1/qmode_rc/ratectrl_qmode.cc b/av1/qmode_rc/ratectrl_qmode.cc
index f560b1f..8e5bfaf 100644
--- a/av1/qmode_rc/ratectrl_qmode.cc
+++ b/av1/qmode_rc/ratectrl_qmode.cc
@@ -1018,6 +1018,9 @@
}
}
}
+
+ frame_dep_stats.rdcost = TplFrameDepStatsAccumulateInterCost(frame_dep_stats);
+
return frame_dep_stats;
}
@@ -1062,6 +1065,18 @@
return std::max(sum, 1.0);
}
+double TplFrameDepStatsAccumulateInterCost(
+ const TplFrameDepStats &frame_dep_stats) {
+ auto getInterCost = [](double sum, const TplUnitDepStats &unit) {
+ return sum + unit.inter_cost;
+ };
+ double sum = 0;
+ for (const auto &row : frame_dep_stats.unit_stats) {
+ sum = std::accumulate(row.begin(), row.end(), sum, getInterCost);
+ }
+ return std::max(sum, 1.0);
+}
+
double TplFrameDepStatsAccumulate(const TplFrameDepStats &frame_dep_stats) {
auto getOverallCost = [](double sum, const TplUnitDepStats &unit) {
return sum + unit.propagation_cost + unit.intra_cost;
diff --git a/av1/qmode_rc/ratectrl_qmode.h b/av1/qmode_rc/ratectrl_qmode.h
index 78b59c3..e5a1e2c 100644
--- a/av1/qmode_rc/ratectrl_qmode.h
+++ b/av1/qmode_rc/ratectrl_qmode.h
@@ -36,6 +36,7 @@
struct TplFrameDepStats {
int unit_size; // equivalent to min_block_size
+ double rdcost; // overall rate-distortion cost
std::vector<std::vector<TplUnitDepStats>> unit_stats;
};
@@ -78,6 +79,9 @@
double TplFrameDepStatsAccumulateIntraCost(
const TplFrameDepStats &frame_dep_stats);
+double TplFrameDepStatsAccumulateInterCost(
+ const TplFrameDepStats &frame_dep_stats);
+
double TplFrameDepStatsAccumulate(const TplFrameDepStats &frame_dep_stats);
void TplFrameDepStatsPropagate(int coding_idx,