shithub: libvpx

Download patch

ref: 7fccd0bef53093a3d246ad2900ecfb34e038a707
parent: 39c02a7eb101b9b4a3b7437b96df3b7b5ddaa5a6
author: Angie Chiang <[email protected]>
date: Wed Sep 12 13:44:45 EDT 2018

Dump tpl mvs for mv search block

Change-Id: Ibe14a02391b960e030c4a48e61718e43a5a65788

--- a/tools/non_greedy_mv/non_greedy_mv.py
+++ b/tools/non_greedy_mv/non_greedy_mv.py
@@ -89,8 +89,10 @@
   frame_idx = int(word_ls[1])
   mi_rows = int(word_ls[3])
   mi_cols = int(word_ls[5])
+  bs = int(word_ls[7])
+  mi_size = bs / 8
   mv_ls = []
-  for i in range(mi_rows * mi_cols):
+  for i in range((mi_rows / mi_size) * (mi_cols / mi_size)):
     line = fp.readline()
     word_ls = line.split()
     row = int(word_ls[0]) * 8.
@@ -105,7 +107,7 @@
   word_ls = line.split()
   if int(word_ls[1]):
     ref = yuv_to_rgb(read_frame(fp))
-  return frame_idx, mv_ls, img, ref
+  return frame_idx, mv_ls, img, ref, bs
 
 
 def read_dpl_stats_file(filename, frame_num=0):
@@ -125,9 +127,8 @@
 
 if __name__ == '__main__':
   filename = sys.argv[1]
-  data_ls = read_dpl_stats_file(filename, frame_num=2)
-  bs = 8
-  for frame_idx, mv_ls, img, ref in data_ls:
+  data_ls = read_dpl_stats_file(filename, frame_num=5)
+  for frame_idx, mv_ls, img, ref, bs in data_ls:
     fig, axes = plt.subplots(1, 2)
 
     axes[0].imshow(img)
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5993,7 +5993,8 @@
   tpl_stats->mv.as_int = best_mv.as_int;
 }
 
-void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx) {
+void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx,
+                       BLOCK_SIZE bsize) {
   TplDepFrame *tpl_frame = &cpi->tpl_stats[frame_idx];
   YV12_BUFFER_CONFIG *this_frame = gf_picture[frame_idx].frame;
   YV12_BUFFER_CONFIG *ref_frame[3] = { NULL, NULL, NULL };
@@ -6018,7 +6019,6 @@
   DECLARE_ALIGNED(16, tran_low_t, qcoeff[32 * 32]);
   DECLARE_ALIGNED(16, tran_low_t, dqcoeff[32 * 32]);
 
-  const BLOCK_SIZE bsize = BLOCK_32X32;
   const TX_SIZE tx_size = max_txsize_lookup[bsize];
   const int mi_height = num_8x8_blocks_high_lookup[bsize];
   const int mi_width = num_8x8_blocks_wide_lookup[bsize];
@@ -6108,7 +6108,7 @@
 }
 
 static void dump_tpl_stats(const VP9_COMP *cpi, int tpl_group_frames,
-                           const GF_PICTURE *gf_picture) {
+                           const GF_PICTURE *gf_picture, BLOCK_SIZE bsize) {
   int frame_idx;
   const VP9_COMMON *cm = &cpi->common;
   for (frame_idx = 1; frame_idx < tpl_group_frames; ++frame_idx) {
@@ -6116,15 +6116,19 @@
     int idx = 0;
     int mi_row, mi_col;
     int rf_idx;
+    const int mi_height = num_8x8_blocks_high_lookup[bsize];
+    const int mi_width = num_8x8_blocks_wide_lookup[bsize];
     printf("=\n");
-    printf("frame_idx %d mi_rows %d mi_cols %d\n", frame_idx, cm->mi_rows,
-           cm->mi_cols);
+    printf("frame_idx %d mi_rows %d mi_cols %d bsize %d\n", frame_idx,
+           cm->mi_rows, cm->mi_cols, mi_width * MI_SIZE);
     for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row) {
       for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) {
-        const TplDepStats *tpl_ptr =
-            &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
-        int_mv mv = tpl_ptr->mv_arr[idx];
-        printf("%d %d %d %d\n", mi_row, mi_col, mv.as_mv.row, mv.as_mv.col);
+        if ((mi_row % mi_height) == 0 && (mi_col % mi_width) == 0) {
+          const TplDepStats *tpl_ptr =
+              &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col];
+          int_mv mv = tpl_ptr->mv_arr[idx];
+          printf("%d %d %d %d\n", mi_row, mi_col, mv.as_mv.row, mv.as_mv.col);
+        }
       }
     }
 
@@ -6146,6 +6150,7 @@
   const GF_GROUP *gf_group = &cpi->twopass.gf_group;
   int tpl_group_frames = 0;
   int frame_idx;
+  const BLOCK_SIZE bsize = BLOCK_32X32;
 
   init_gop_frames(cpi, gf_picture, gf_group, &tpl_group_frames);
 
@@ -6153,11 +6158,11 @@
 
   // Backward propagation from tpl_group_frames to 1.
   for (frame_idx = tpl_group_frames - 1; frame_idx > 0; --frame_idx) {
-    mc_flow_dispenser(cpi, gf_picture, frame_idx);
+    mc_flow_dispenser(cpi, gf_picture, frame_idx, bsize);
   }
 #if CONFIG_NON_GREEDY_MV
 #if DUMP_TPL_STATS
-  dump_tpl_stats(cpi, tpl_group_frames, gf_picture);
+  dump_tpl_stats(cpi, tpl_group_frames, gf_picture, bsize);
 #endif  // DUMP_TPL_STATS
 #endif  // CONFIG_NON_GREEDY_MV
 }