From 1fba1e38ea4298c78e5c7ed72bb76a14706f11a1 Mon Sep 17 00:00:00 2001
From: Yaowu Xu <yaowu@google.com>
Date: Tue, 7 Jun 2011 13:59:46 -0700
Subject: [PATCH] Adjust errorperbit according to RDMULT in activity masking

In activity masking, RDO constant RDMULT is adjusted on a per MB basis
adaptive to activity with the MB. errorperbit, which is defined as
RDMULT/RDDIV, is a constant used in motion estimation. Previously, in
activity masking, errorperbit is not changed even when RDMULT is changed.
This commit changed to adjust errorperbit according to the change in
RDMULT.

Test in cif set showed a very small but consistent gain by all quality
metrics (average, overall psnr and ssim) when activity masking is on.

Change-Id: I07ded3e852919ab76757691939fe435328273823
---
 vp8/encoder/encodeframe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vp8/encoder/encodeframe.c b/vp8/encoder/encodeframe.c
index a972f8942f..5cae99f410 100644
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -336,6 +336,7 @@ void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x)
 {
 #if USE_ACT_INDEX
     x->rdmult += *(x->mb_activity_ptr) * (x->rdmult >> 2);
+    x->errorperbit = x->rdmult/x->rddiv;
 #else
     INT64 a;
     INT64 b;
@@ -346,6 +347,8 @@ void vp8_activity_masking(VP8_COMP *cpi, MACROBLOCK *x)
     b = (2*act) + cpi->activity_avg;
 
     x->rdmult = (unsigned int)(((INT64)x->rdmult*b + (a>>1))/a);
+    x->errorperbit = x->rdmult/x->rddiv;
+
 #endif
 
     // Activity based Zbin adjustment
-- 
GitLab