Update rdcost after the change of block size
This is a preparation for adding tune=ssim mode. In tuning for SSIM
mode rdmult will be different in different blocks. So, we need to
recalculate the rdcost using the accumulated rates and distortions
whenever the block size changes in the recursive partition searching
stage.
STATS_CHANGED:
avg_psnr ovr_psnr ssim
low_res (33 frames) -0.008 -0.011 0.001
mid_res (33 frames) 0.006 0.010 0.013
Change-Id: Ica461b25ca85748bf4e9be59dc6bf5d8d310c809
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index 6819fcf..0f6cd7e 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -387,14 +387,16 @@
}
static INLINE void av1_rd_cost_update(int mult, RD_STATS *rd_cost) {
- if (rd_cost->rate < INT_MAX && rd_cost->dist < INT64_MAX) {
+ if (rd_cost->rate < INT_MAX && rd_cost->dist < INT64_MAX &&
+ rd_cost->rdcost < INT64_MAX) {
rd_cost->rdcost = av1_calculate_rd_cost(mult, rd_cost->rate, rd_cost->dist);
} else {
av1_invalid_rd_stats(rd_cost);
}
}
-static INLINE void av1_rd_stats_subtraction(const RD_STATS *const left,
+static INLINE void av1_rd_stats_subtraction(int mult,
+ const RD_STATS *const left,
const RD_STATS *const right,
RD_STATS *result) {
if (left->rate == INT_MAX || right->rate == INT_MAX ||
@@ -404,7 +406,7 @@
} else {
result->rate = left->rate - right->rate;
result->dist = left->dist - right->dist;
- result->rdcost = left->rdcost - right->rdcost;
+ result->rdcost = av1_calculate_rd_cost(mult, result->rate, result->dist);
}
}