]> granicus.if.org Git - libvpx/blobdiff - vp9/encoder/vp9_firstpass.c
break at the end of clauses with assert(0) to avoid gcc warning
[libvpx] / vp9 / encoder / vp9_firstpass.c
index 2a5f594e99e0ab9a38537cab5d531a7e497702ad..59a9d83d1bc5e19c9bebaec9d2f1328587a5900c 100644 (file)
@@ -148,16 +148,6 @@ static void output_stats(FIRSTPASS_STATS *stats,
 }
 
 #if CONFIG_FP_MB_STATS
-static int input_fpmb_stats(FIRSTPASS_MB_STATS *firstpass_mb_stats,
-                            VP9_COMMON *cm, uint8_t **this_frame_mb_stats) {
-  if (firstpass_mb_stats->mb_stats_in > firstpass_mb_stats->mb_stats_end)
-    return EOF;
-
-  *this_frame_mb_stats = firstpass_mb_stats->mb_stats_in;
-  firstpass_mb_stats->mb_stats_in += cm->MBs * sizeof(uint8_t);
-  return 1;
-}
-
 static void output_fpmb_stats(uint8_t *this_frame_mb_stats, VP9_COMMON *cm,
                          struct vpx_codec_pkt_list *pktlist) {
   struct vpx_codec_cx_pkt pkt;
@@ -563,6 +553,9 @@ void vp9_first_pass(VP9_COMP *cpi) {
       const int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
       double error_weight = 1.0;
       const BLOCK_SIZE bsize = get_bsize(cm, mb_row, mb_col);
+#if CONFIG_FP_MB_STATS
+      const int mb_index = mb_row * cm->mb_cols + mb_col;
+#endif
 
       vp9_clear_system_state();
 
@@ -609,7 +602,8 @@ void vp9_first_pass(VP9_COMP *cpi) {
 
 #if CONFIG_FP_MB_STATS
       if (cpi->use_fp_mb_stats) {
-        // TODO(pengchong): store some related block statistics here
+        // initialization
+        cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
       }
 #endif
 
@@ -710,6 +704,27 @@ void vp9_first_pass(VP9_COMP *cpi) {
         // Start by assuming that intra mode is best.
         best_ref_mv.as_int = 0;
 
+#if CONFIG_FP_MB_STATS
+        if (cpi->use_fp_mb_stats) {
+          // intra predication statistics
+          cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
+          cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_DCINTRA_MASK;
+          cpi->twopass.frame_mb_stats_buf[mb_index] &=
+              ~FPMB_NONZERO_MOTION_MASK;
+          if (this_error > FPMB_ERROR_LEVEL4_TH) {
+            cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL4_MASK;
+          } else if (this_error > FPMB_ERROR_LEVEL3_TH) {
+            cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL3_MASK;
+          } else if (this_error > FPMB_ERROR_LEVEL2_TH) {
+            cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL2_MASK;
+          } else if (this_error > FPMB_ERROR_LEVEL1_TH) {
+            cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL1_MASK;
+          } else {
+            cpi->twopass.frame_mb_stats_buf[mb_index] |= FPMB_ERROR_LEVEL0_MASK;
+          }
+        }
+#endif
+
         if (motion_error <= this_error) {
           // Keep a count of cases where the inter and intra were very close
           // and very low. This helps with scene cut detection for example in
@@ -740,13 +755,40 @@ void vp9_first_pass(VP9_COMP *cpi) {
 
 #if CONFIG_FP_MB_STATS
           if (cpi->use_fp_mb_stats) {
-            // TODO(pengchong): save some related block statistics here
+            // inter predication statistics
+            cpi->twopass.frame_mb_stats_buf[mb_index] = 0;
+            cpi->twopass.frame_mb_stats_buf[mb_index] &= ~FPMB_DCINTRA_MASK;
+            cpi->twopass.frame_mb_stats_buf[mb_index] &=
+                ~FPMB_NONZERO_MOTION_MASK;
+            if (this_error > FPMB_ERROR_LEVEL4_TH) {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_ERROR_LEVEL4_MASK;
+            } else if (this_error > FPMB_ERROR_LEVEL3_TH) {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_ERROR_LEVEL3_MASK;
+            } else if (this_error > FPMB_ERROR_LEVEL2_TH) {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_ERROR_LEVEL2_MASK;
+            } else if (this_error > FPMB_ERROR_LEVEL1_TH) {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_ERROR_LEVEL1_MASK;
+            } else {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_ERROR_LEVEL0_MASK;
+            }
           }
 #endif
 
           if (mv.as_int) {
             ++mvcount;
 
+#if CONFIG_FP_MB_STATS
+            if (cpi->use_fp_mb_stats) {
+              cpi->twopass.frame_mb_stats_buf[mb_index] |=
+                  FPMB_NONZERO_MOTION_MASK;
+            }
+#endif
+
             // Non-zero vector, was it different from the last non zero vector?
             if (mv.as_int != lastmv_as_int)
               ++new_mv_count;
@@ -2075,6 +2117,7 @@ void configure_buffer_updates(VP9_COMP *cpi) {
       break;
     default:
       assert(0);
+      break;
   }
   if (cpi->use_svc && cpi->svc.number_temporal_layers == 1) {
     cpi->refresh_golden_frame = 0;
@@ -2206,14 +2249,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
       cpi->refresh_golden_frame = 1;
   }
 
-  {
-    FIRSTPASS_STATS next_frame;
-    if (lookup_next_frame_stats(twopass, &next_frame) != EOF) {
-      twopass->next_iiratio = (int)(next_frame.intra_error /
-                                 DOUBLE_DIVIDE_CHECK(next_frame.coded_error));
-    }
-  }
-
   configure_buffer_updates(cpi);
 
   target_rate = twopass->gf_group.bit_allocation[twopass->gf_group.index];
@@ -2232,13 +2267,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
 
   // Update the total stats remaining structure.
   subtract_stats(&twopass->total_left_stats, &this_frame);
-
-#if CONFIG_FP_MB_STATS
-  if (cpi->use_fp_mb_stats) {
-    input_fpmb_stats(&twopass->firstpass_mb_stats, cm,
-                     &twopass->this_frame_mb_stats);
-  }
-#endif
 }
 
 void vp9_twopass_postencode_update(VP9_COMP *cpi) {