]> granicus.if.org Git - libvpx/commitdiff
changed mode_context update strategy
authorYaowu Xu <yaowu@google.com>
Wed, 21 Dec 2011 20:05:10 +0000 (12:05 -0800)
committerYaowu Xu <yaowu@google.com>
Wed, 21 Dec 2011 20:05:10 +0000 (12:05 -0800)
Previously, the mode context is always udpated based on stats of current
frame, when there is no count, 50% is used for both left and right branch.
However, it is observed that with such strategy, a small count or no count
at all can skew the probability distribution significantly. This commmit
changed the mode_context update strategy to prevent small counts from
skewing the probability distributions.

Tests on derf set showed a small gain:  .06% in psnr and .09% in ssim

Change-Id: Ic812e64ae5f70251c170b0717f7b7fa587055488

vp8/common/entropymode.c

index 6d0f562c1c7c47a925e5d74afcfda245a2345694..a51473d991ccba210420362e9df07f8c3b348a72 100644 (file)
@@ -442,17 +442,13 @@ void vp8_update_mode_context(VP8_COMMON *pc)
         {
             int this_prob;
             int count = mv_ref_ct[j][i][0] + mv_ref_ct[j][i][1];
-
-            if (count)
+            /* preventing rare occurances from skewing the probs */
+            if (count>=4)
+            {
                 this_prob = 256 * mv_ref_ct[j][i][0] / count;
-            else
-                this_prob = 128;
-            this_prob = this_prob? (this_prob<255?this_prob:255):1;
-            if (this_prob == 0)
-                this_prob = 1;
-            if (this_prob == 256)
-                this_prob = 255;
-            mode_context[j][i] = this_prob;
+                this_prob = this_prob? (this_prob<255?this_prob:255):1;
+                mode_context[j][i] = this_prob;
+            }
         }
     }
 }