Simplify rate computation in rate_estimator()
The rate computation in rate_estimator() function
accumulates (log(abs_level + 1.0) / log(2.0)) for each of
the quantized coefficients. This is replaced by
get_msb(abs_level + 1) to enable the usage of built-in
platform-specific instructions.
For 'good' encoding,
Instruction Count BD-Rate Loss(%)
cpu Resolution Reduction(%) avg.psnr ovr.psnr ssim
3 LOWRES2 0.407 0.0000 0.0000 0.0000
3 MIDRES2 0.273 0.0000 0.0000 0.0000
3 HDRES2 0.174 0.0000 0.0000 0.0000
4 LOWRES2 0.705 0.0000 0.0000 0.0000
4 MIDRES2 0.466 0.0000 0.0000 0.0000
4 HDRES2 0.312 0.0000 0.0000 0.0000
5 LOWRES2 1.365 0.0000 0.0000 0.0000
5 MIDRES2 0.881 0.0000 0.0000 0.0000
5 HDRES2 0.594 0.0000 0.0000 0.0000
6 LOWRES2 1.841 0.0000 0.0000 0.0000
6 MIDRES2 1.190 0.0000 0.0000 0.0000
6 HDRES2 0.802 0.0000 0.0000 0.0000
STATS_CHANGED possible, but not seen
Change-Id: Ie9f4a94c76436a1c2a6c9f4c34ed7898ddc3a3d7
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 2ad1122..07cc9a3 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -217,8 +217,8 @@
int rate_cost = 1;
for (int idx = 0; idx < eob; ++idx) {
- int abs_level = abs(qcoeff[scan_order->scan[idx]]);
- rate_cost += (int)(log(abs_level + 1.0) / log(2.0)) + 1 + (abs_level > 0);
+ unsigned int abs_level = abs(qcoeff[scan_order->scan[idx]]);
+ rate_cost += get_msb(abs_level + 1) + 1 + (abs_level > 0);
}
return (rate_cost << AV1_PROB_COST_SHIFT);