]> granicus.if.org Git - libvpx/commitdiff
Fix inter_zz_count calculation bug
authorYunqing Wang <yunqingwang@google.com>
Tue, 21 Aug 2012 00:31:44 +0000 (17:31 -0700)
committerYunqing Wang <yunqingwang@google.com>
Tue, 21 Aug 2012 00:43:06 +0000 (17:43 -0700)
The current way of counting inter_zz_count doesn't work correctly
in multi-threaded encoding. Calculating it after the frame is
encoded fixed the problem.

Change-Id: Ifcb1972cde950b8cc194f75c6d7b6af09e8b0e65

vp8/encoder/encodeframe.c
vp8/encoder/ethreading.c
vp8/encoder/onyx_if.c

index 4d73d470fe98492ca58a33fa5381ed2e899ce0d4..600e815dd64a07eaa2f8325cd44461e6e7d4165b 100644 (file)
@@ -523,10 +523,6 @@ void encode_mb_row(VP8_COMP *cpi,
 
 #endif
 
-            /* Count of last ref frame 0,0 usage */
-            if ((xd->mode_info_context->mbmi.mode == ZEROMV) && (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME))
-                cpi->inter_zz_count ++;
-
             /* Special case code for cyclic refresh
              * If cyclic update enabled then copy xd->mbmi.segment_id; (which
              * may have been updated based on mode during
@@ -721,9 +717,6 @@ void vp8_encode_frame(VP8_COMP *cpi)
         xd->subpixel_predict16x16   = vp8_bilinear_predict16x16;
     }
 
-    /* Reset frame count of inter 0,0 motion vector usage. */
-    cpi->inter_zz_count = 0;
-
     cpi->prediction_error = 0;
     cpi->intra_error = 0;
     cpi->skip_true_count = 0;
index e0bb1b09fd90538fce4b3dc267b32ef7857d20fe..d92462b857e175790cf6c6dd34a58ea7d31daa5a 100644 (file)
@@ -213,10 +213,6 @@ THREAD_FUNCTION thread_encoding_proc(void *p_data)
 
 #endif
 
-                        /* Count of last ref frame 0,0 usage */
-                        if ((xd->mode_info_context->mbmi.mode == ZEROMV) && (xd->mode_info_context->mbmi.ref_frame == LAST_FRAME))
-                            cpi->inter_zz_count++;
-
                         /* Special case code for cyclic refresh
                          * If cyclic update enabled then copy
                          * xd->mbmi.segment_id; (which may have been updated
index 22da51a7cfb75462fb695982f98f1089e6b05257..dc6080340cf57dece24804ed7308ff8f32bfccbe 100644 (file)
@@ -4298,6 +4298,30 @@ static void encode_frame_to_data_rate
         }
     }
 
+    /* Count last ref frame 0,0 usage on current encoded frame. */
+    {
+        int mb_row;
+        int mb_col;
+        /* Point to beginning of MODE_INFO arrays. */
+        MODE_INFO *tmp = cm->mi;
+
+        cpi->inter_zz_count = 0;
+
+        if(cm->frame_type != KEY_FRAME)
+        {
+            for (mb_row = 0; mb_row < cm->mb_rows; mb_row ++)
+            {
+                for (mb_col = 0; mb_col < cm->mb_cols; mb_col ++)
+                {
+                    if(tmp->mbmi.mode == ZEROMV && tmp->mbmi.ref_frame == LAST_FRAME)
+                        cpi->inter_zz_count++;
+                    tmp++;
+                }
+                tmp++;
+            }
+        }
+    }
+
 #if CONFIG_MULTI_RES_ENCODING
     vp8_cal_dissimilarity(cpi);
 #endif