]> granicus.if.org Git - libvpx/commitdiff
Set up decoder end coding statistics tracker
authorJingning Han <jingning@google.com>
Mon, 29 Jun 2015 17:53:02 +0000 (10:53 -0700)
committerJingning Han <jingning@google.com>
Mon, 29 Jun 2015 17:57:27 +0000 (10:57 -0700)
This commit allows the decoder to track the percentage of intra
coding mode and sub pixel filter usage, when it is configured. This
provides a measurable approach to generate the VP9 decoder
performance test suite.

Change-Id: I26d40b991f41b1408de2b206ecb0a322cdb561b8

vp9/decoder/vp9_decodeframe.c
vp9/decoder/vp9_decodemv.c
vp9/decoder/vp9_decoder.h

index 9311d8dad7d13e6738eaa46f2cb6bace2f4d45a7..a0a2fb82a1ece5fb1dbf2254f89abe76cc494a2f 100644 (file)
@@ -746,6 +746,12 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
   if (less8x8)
     bsize = BLOCK_8X8;
 
+#if CONFIG_INTERNAL_STATS
+  pbi->total_block_in_8x8 += (1 << (num_pels_log2_lookup[bsize] - 6));
+  if (!is_inter_block(mbmi))
+    pbi->intra_block_in_8x8 += (1 << (num_pels_log2_lookup[bsize] - 6));
+#endif
+
   if (mbmi->skip) {
     reset_skip_context(xd, bsize);
   }
@@ -2008,6 +2014,12 @@ void vp9_decode_frame(VP9Decoder *pbi,
                        "Uninitialized entropy context.");
 
   vp9_zero(cm->counts);
+#if CONFIG_INTERNAL_STATS
+  // Reset internal stats
+  pbi->total_block_in_8x8 = 0;
+  pbi->subpel_mc_block_in_4x4 = 0;
+  pbi->intra_block_in_8x8 = 0;
+#endif
 
   xd->corrupted = 0;
   new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size);
@@ -2076,4 +2088,18 @@ void vp9_decode_frame(VP9Decoder *pbi,
   // Non frame parallel update frame context here.
   if (cm->refresh_frame_context && !context_updated)
     cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
+
+#if CONFIG_INTERNAL_STATS
+  vp9_clear_system_state();
+  {
+    FILE *pf = fopen("frame_level_stats.stt", "a");
+    double subpel_mc = (double)pbi->subpel_mc_block_in_4x4 /
+        (double)pbi->total_block_in_8x8;
+    double intra_mode = (double)pbi->intra_block_in_8x8 /
+        (double)pbi->total_block_in_8x8;
+    fprintf(pf, "frame index %d, sub-pel mc %7.3f\tintra mode%7.3f\n",
+            cm->current_video_frame, 25 * subpel_mc, 100 * intra_mode);
+    fclose(pf);
+  }
+#endif
 }
index 8a8d8ddd8e6b2d746c83233ea8ec44357fbbca2f..7aed5a2760742eec862dbf262cebdb3b93158b90 100644 (file)
@@ -547,7 +547,22 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
         mi->bmi[j].as_mv[0].as_int = block[0].as_int;
         if (is_compound)
           mi->bmi[j].as_mv[1].as_int = block[1].as_int;
-
+#if CONFIG_INTERNAL_STATS
+        if (mi->bmi[j].as_mv[0].as_mv.row & 0x07)
+          pbi->subpel_mc_block_in_4x4 +=
+              (1 << (num_pels_log2_lookup[bsize] - 4));
+        if (mi->bmi[j].as_mv[0].as_mv.col & 0x07)
+          pbi->subpel_mc_block_in_4x4 +=
+              (1 << (num_pels_log2_lookup[bsize] - 4));
+        if (is_compound) {
+          if (mi->bmi[j].as_mv[1].as_mv.row & 0x07)
+            pbi->subpel_mc_block_in_4x4 +=
+                (1 << (num_pels_log2_lookup[bsize] - 4));
+          if (mi->bmi[j].as_mv[1].as_mv.col & 0x07)
+            pbi->subpel_mc_block_in_4x4 +=
+                (1 << (num_pels_log2_lookup[bsize] - 4));
+        }
+#endif
         if (num_4x4_h == 2)
           mi->bmi[j + 2] = mi->bmi[j];
         if (num_4x4_w == 2)
@@ -562,6 +577,18 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi,
   } else {
     xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, mbmi->mv, nearestmv,
                                 nearestmv, nearmv, is_compound, allow_hp, r);
+#if CONFIG_INTERNAL_STATS
+    if (mbmi->mv[0].as_mv.row & 0x07)
+      pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4));
+    if (mbmi->mv[0].as_mv.col & 0x07)
+      pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4));
+    if (is_compound) {
+      if (mbmi->mv[1].as_mv.row & 0x07)
+        pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4));
+      if (mbmi->mv[1].as_mv.col & 0x07)
+        pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4));
+    }
+#endif
   }
 }
 
index c19f0ac3bc78fab95c671d058d96f3fff091f5e6..216698e9bb66940cd1026b889e1d5e64b18acf1b 100644 (file)
@@ -75,6 +75,17 @@ typedef struct VP9Decoder {
   int inv_tile_order;
   int need_resync;  // wait for key/intra-only frame.
   int hold_ref_buf;  // hold the reference buffer.
+
+#if CONFIG_INTERNAL_STATS
+  // total blocks in unit of 8x8 inside the frame.
+  int total_block_in_8x8;
+  // number of blocks using 1-D sub-pixel filtering for motion compensated
+  // prediction. if a block is using sub-pixel filter in both vertical and
+  // horizontal directions, it counts as using 1-D sub-pixel filter twice.
+  int subpel_mc_block_in_4x4;
+  // nubmer of blocks using intra prediction mode.
+  int intra_block_in_8x8;
+#endif
 } VP9Decoder;
 
 int vp9_receive_compressed_data(struct VP9Decoder *pbi,