shithub: libvpx

Download patch

ref: ce42e79abcd0b361e5eedcd9a964984d3b58ff4d
parent: 3653fb473a66258c74d3a550e66c8c1e8f95368c
author: Attila Nagy <attilanagy@google.com>
date: Fri Feb 17 06:50:33 EST 2012

Update encoder mb_skip_coeff and prob_skip_false calculation

mode_info_context->mbmi.mb_skip_coeff has to always reflect the
existence or not of coeffs for a certain MB. The loopfilter needs this
info.
mb_skip_coeff is either set by the vp8_tokenize_mb or has to be set to
1 when the MB is skipped by mode selection. This has to be done
regardless of the mb_no_coeff_skip value.

prob_skip_false is needed just when mb_no_coeff_skip is 1. No need to
keep count of both skip_false and skip_true as they are complementary
(skip_true+skip_false = total_mbs)

Change-Id: I3c74c9a0ee37bec10de7bb796e408f3e77006813

--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -925,8 +925,10 @@
 
     if (pc->mb_no_coeff_skip)
     {
-        prob_skip_false = cpi->skip_false_count * 256 / (cpi->skip_false_count + cpi->skip_true_count);
+        int total_mbs = pc->mb_rows * pc->mb_cols;
 
+        prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs;
+
         if (prob_skip_false <= 1)
             prob_skip_false = 1;
 
@@ -1112,7 +1114,9 @@
 
     if (c->mb_no_coeff_skip)
     {
-        prob_skip_false = cpi->skip_false_count * 256 / (cpi->skip_false_count + cpi->skip_true_count);
+        int total_mbs = c->mb_rows * c->mb_cols;
+
+        prob_skip_false = (total_mbs - cpi->skip_true_count ) * 256 / total_mbs;
 
         if (prob_skip_false <= 1)
             prob_skip_false = 1;
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -696,7 +696,6 @@
     cpi->prediction_error = 0;
     cpi->intra_error = 0;
     cpi->skip_true_count = 0;
-    cpi->skip_false_count = 0;
 
 #if 0
     // Experimental code
@@ -1094,6 +1093,7 @@
     vp8_encode_intra16x16mbuv(x);
 
     sum_intra_stats(cpi, x);
+
     vp8_tokenize_mb(cpi, &x->e_mbd, t);
 
     if (xd->mode_info_context->mbmi.mode != B_PRED)
@@ -1260,11 +1260,6 @@
         if (!x->skip)
         {
             vp8_encode_inter16x16(x);
-
-            // Clear mb_skip_coeff if mb_no_coeff_skip is not set
-            if (!cpi->common.mb_no_coeff_skip)
-                xd->mode_info_context->mbmi.mb_skip_coeff = 0;
-
         }
         else
             vp8_build_inter16x16_predictors_mb(xd, xd->dst.y_buffer,
@@ -1287,9 +1282,11 @@
     }
     else
     {
+        /* always set mb_skip_coeff as it is needed by the loopfilter */
+        xd->mode_info_context->mbmi.mb_skip_coeff = 1;
+
         if (cpi->common.mb_no_coeff_skip)
         {
-            xd->mode_info_context->mbmi.mb_skip_coeff = 1;
             cpi->skip_true_count ++;
             vp8_fix_contexts(xd);
         }
@@ -1296,8 +1293,6 @@
         else
         {
             vp8_stuff_mb(cpi, xd, t);
-            xd->mode_info_context->mbmi.mb_skip_coeff = 0;
-            cpi->skip_false_count ++;
         }
     }
 
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -504,7 +504,6 @@
     int gf_bad_count;
     int gf_update_recommended;
     int skip_true_count;
-    int skip_false_count;
 
     unsigned char *segmentation_map;
     signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS];            // Segment data (can be deltas or absolute values)
--- a/vp8/encoder/tokenize.c
+++ b/vp8/encoder/tokenize.c
@@ -378,30 +378,27 @@
     x->mode_info_context->mbmi.mb_skip_coeff = mb_is_skippable(x, has_y2_block);
     if (x->mode_info_context->mbmi.mb_skip_coeff)
     {
-        cpi->skip_true_count++;
-
         if (!cpi->common.mb_no_coeff_skip)
-            vp8_stuff_mb(cpi, x, t) ;
+        {
+            vp8_stuff_mb(cpi, x, t);
+        }
         else
         {
             vp8_fix_contexts(x);
+            cpi->skip_true_count++;
         }
 
         return;
     }
 
-    cpi->skip_false_count++;
-
     plane_type = 3;
     if(has_y2_block)
     {
         tokenize2nd_order_b(x, t, cpi);
         plane_type = 0;
-
     }
 
     tokenize1st_order_b(x, t, plane_type, cpi);
-
 }
 
 
--