]> granicus.if.org Git - libvpx/commitdiff
Moving _error counts to macroblock struct
authorScott LaVarnway <slavarnway@google.com>
Tue, 6 Nov 2012 01:30:49 +0000 (17:30 -0800)
committerScott LaVarnway <slavarnway@google.com>
Tue, 6 Nov 2012 17:21:54 +0000 (09:21 -0800)
Change-Id: I28ac1519d1594801fef9a623cb64598d3d751eb0

vp8/encoder/block.h
vp8/encoder/encodeframe.c
vp8/encoder/ethreading.c
vp8/encoder/onyx_if.c
vp8/encoder/onyx_int.h

index d5496a7e227c11e9ac516980cdc66eaa35ddabeb..f9d63eb5056b902651fcabb619ba8fa6df93b419 100644 (file)
@@ -130,10 +130,10 @@ typedef struct macroblock
     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);
index 6364f7d7eb1e66cdc74622fae5faa2849e427295..732b77b66ace5abdf2a305377e99cc57450d877c 100644 (file)
@@ -676,6 +676,8 @@ static void init_encode_frame_mb_context(VP8_COMP *cpi)
     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 @@ void vp8_encode_frame(VP8_COMP *cpi)
         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 @@ void vp8_encode_frame(VP8_COMP *cpi)
                         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 @@ int vp8cx_encode_inter_macroblock
                             &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)
     {
index 81fbe52c734dbf692d108d3775adcd80e12dc38a..39340f236897e48c923326e56c43006932d2403e 100644 (file)
@@ -476,6 +476,8 @@ void vp8cx_init_mbrthread_data(VP8_COMP *cpi,
         vp8_zero(x->ymode_count);
         mb->skip_true_count = 0;
         vp8_zero(mb->MVcount);
+        mb->prediction_error = 0;
+        mb->intra_error = 0;
     }
 }
 
index 4235662f12d77d475c2c05b3a5588392170ebdb0..4e2cd0ff716fa8c6e1a8a8c3eb6dae957b9dcdd5 100644 (file)
@@ -2864,38 +2864,17 @@ static int decide_key_frame(VP8_COMP *cpi)
 
     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
-
-        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;
+        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
+        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*/
index 395287dbf6823ccb898392e05e7e2cefd053be08..5cff899ac2f64726705845a8fce38bf227c32e87 100644 (file)
@@ -363,9 +363,7 @@ typedef struct VP8_COMP
     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;