shithub: libvpx

Download patch

ref: ee28bb87b47094abb9cb7549d5a14f3cdf0955d3
parent: 01824d1848c1feeb727ea7dfd6522f8966133953
author: Scott LaVarnway <slavarnway@google.com>
date: Mon Nov 5 12:30:49 EST 2012

Moving _error counts to macroblock struct

Change-Id: I28ac1519d1594801fef9a623cb64598d3d751eb0

--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -130,10 +130,10 @@
     int skip_true_count;
     unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
     unsigned int MVcount [2] [MVvals];  /* (row,col) MV cts this frame */
-
     int ymode_count [VP8_YMODES];        /* intra MB type cts this frame */
     int uv_mode_count[VP8_UV_MODES];     /* intra MB type cts this frame */
-
+    int64_t prediction_error;
+    int64_t intra_error;
 
 
     void (*short_fdct4x4)(short *input, short *output, int pitch);
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -676,6 +676,8 @@
     vp8_zero(x->coef_counts);
     vp8_zero(x->ymode_count);
     vp8_zero(x->uv_mode_count)
+    x->prediction_error = 0;
+    x->intra_error = 0;
 }
 
 static void sum_coef_counts(MACROBLOCK *x, MACROBLOCK *x_thread)
@@ -749,8 +751,6 @@
         xd->subpixel_predict16x16   = vp8_bilinear_predict16x16;
     }
 
-    cpi->prediction_error = 0;
-    cpi->intra_error = 0;
     cpi->mb.skip_true_count = 0;
     cpi->tok_count = 0;
 
@@ -889,6 +889,10 @@
                         cpi->mb_row_ei[i].mb.MVcount[1][mv_vals];
                 }
 
+                cpi->mb.prediction_error +=
+                    cpi->mb_row_ei[i].mb.prediction_error;
+                cpi->mb.intra_error += cpi->mb_row_ei[i].mb.intra_error;
+
                 /* add up counts for each thread */
                 sum_coef_counts(x, &cpi->mb_row_ei[i].mb);
             }
@@ -1252,8 +1256,8 @@
                             &distortion, &intra_error, mb_row, mb_col);
     }
 
-    cpi->prediction_error += distortion;
-    cpi->intra_error += intra_error;
+    x->prediction_error += distortion;
+    x->intra_error += intra_error;
 
     if(cpi->oxcf.tuning == VP8_TUNE_SSIM)
     {
--- a/vp8/encoder/ethreading.c
+++ b/vp8/encoder/ethreading.c
@@ -476,6 +476,8 @@
         vp8_zero(x->ymode_count);
         mb->skip_true_count = 0;
         vp8_zero(mb->MVcount);
+        mb->prediction_error = 0;
+        mb->intra_error = 0;
     }
 }
 
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -2864,38 +2864,17 @@
 
     if ((cpi->compressor_speed == 2) && (cpi->Speed >= 5) && (cpi->sf.RD == 0))
     {
-        double change = 1.0 * abs((int)(cpi->intra_error - cpi->last_intra_error)) / (1 + cpi->last_intra_error);
-        double change2 = 1.0 * abs((int)(cpi->prediction_error - cpi->last_prediction_error)) / (1 + cpi->last_prediction_error);
+        double change = 1.0 * abs((int)(cpi->mb.intra_error -
+            cpi->last_intra_error)) / (1 + cpi->last_intra_error);
+        double change2 = 1.0 * abs((int)(cpi->mb.prediction_error -
+            cpi->last_prediction_error)) / (1 + cpi->last_prediction_error);
         double minerror = cm->MBs * 256;
 
-#if 0
+        cpi->last_intra_error = cpi->mb.intra_error;
+        cpi->last_prediction_error = cpi->mb.prediction_error;
 
-        if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
-            && cpi->prediction_error > minerror
-            && (change > .25 || change2 > .25))
-        {
-            FILE *f = fopen("intra_inter.stt", "a");
-
-            if (cpi->prediction_error <= 0)
-                cpi->prediction_error = 1;
-
-            fprintf(f, "%d %d %d %d %14.4f\n",
-                    cm->current_video_frame,
-                    (int) cpi->prediction_error,
-                    (int) cpi->intra_error,
-                    (int)((10 * cpi->intra_error) / cpi->prediction_error),
-                    change);
-
-            fclose(f);
-        }
-
-#endif
-
-        cpi->last_intra_error = cpi->intra_error;
-        cpi->last_prediction_error = cpi->prediction_error;
-
-        if (10 * cpi->intra_error / (1 + cpi->prediction_error) < 15
-            && cpi->prediction_error > minerror
+        if (10 * cpi->mb.intra_error / (1 + cpi->mb.prediction_error) < 15
+            && cpi->mb.prediction_error > minerror
             && (change > .25 || change2 > .25))
         {
             /*(change > 1.4 || change < .75)&& cpi->this_frame_percent_intra > cpi->last_frame_percent_intra + 3*/
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -363,9 +363,7 @@
     CODING_CONTEXT coding_context;
 
     /* Rate targetting variables */
-    int64_t prediction_error;
     int64_t last_prediction_error;
-    int64_t intra_error;
     int64_t last_intra_error;
 
     int this_frame_target;
--