ref: 543aeef873a4ec8169e6dbe7acc576c590e006ae
parent: 03a0ced87a54c38253bdba98b3337505e5df84fa
	author: Angie Chiang <angiebird@google.com>
	date: Tue Mar  5 06:59:00 EST 2019
	
Refactor dump_tpl_stats Only dump stats when ref frame exists. Dump ref_frame_idx Change-Id: Ibfeae4111697b8ce97d7fe9b56c2487623615748
--- a/tools/non_greedy_mv/non_greedy_mv.py
+++ b/tools/non_greedy_mv/non_greedy_mv.py
@@ -99,6 +99,7 @@
mi_rows = int(word_ls[3])
mi_cols = int(word_ls[5])
bs = int(word_ls[7])
+ ref_frame_idx = int(word_ls[9])
mi_size = bs / 8
mv_ls = []
mv_rows = int((math.ceil(mi_rows * 1. / mi_size)))
@@ -112,14 +113,10 @@
mv_col = int(word_ls[3]) / 8.
mv_ls.append([col, row, mv_col, mv_row])
mv_ls = np.array(mv_ls)
- img = yuv_to_rgb(read_frame(fp))
feature_score = read_feature_score(fp, mv_rows, mv_cols)
- ref = None
- line = fp.readline()
- word_ls = line.split()
- if int(word_ls[1]):
- ref = yuv_to_rgb(read_frame(fp))
- return frame_idx, mv_ls, img, ref, bs, feature_score
+ img = yuv_to_rgb(read_frame(fp))
+ ref = yuv_to_rgb(read_frame(fp))
+ return frame_idx, ref_frame_idx, mv_ls, img, ref, bs, feature_score
def read_dpl_stats_file(filename, frame_num=0):
@@ -140,7 +137,7 @@
if __name__ == '__main__':
filename = sys.argv[1]
data_ls = read_dpl_stats_file(filename, frame_num=5)
- for frame_idx, mv_ls, img, ref, bs, feature_score in data_ls:
+ for frame_idx, ref_frame_idx, mv_ls, img, ref, bs, feature_score in data_ls:
fig, axes = plt.subplots(2, 2)
axes[0][0].imshow(img)
@@ -166,5 +163,5 @@
feature_score_bins = np.arange(feature_score_min, feature_score_max, step)
axes[1][1].hist(feature_score_arr, bins=feature_score_bins)
+ print frame_idx, ref_frame_idx, len(mv_ls)
plt.show()
- print frame_idx, len(mv_ls)
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -6749,43 +6749,46 @@
                            const GF_PICTURE *gf_picture, BLOCK_SIZE bsize) {int frame_idx;
const VP9_COMMON *cm = &cpi->common;
+ int rf_idx;
   for (frame_idx = 1; frame_idx < tpl_group_frames; ++frame_idx) {- const TplDepFrame *tpl_frame = &cpi->tpl_stats[frame_idx];
- 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 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) {-        if ((mi_row % mi_height) == 0 && (mi_col % mi_width) == 0) {- int_mv mv = *get_pyramid_mv(tpl_frame, idx, bsize, mi_row, mi_col);
-          printf("%d %d %d %d\n", mi_row, mi_col, mv.as_mv.row, mv.as_mv.col);+    for (rf_idx = 0; rf_idx < 3; ++rf_idx) {+ const TplDepFrame *tpl_frame = &cpi->tpl_stats[frame_idx];
+ int mi_row, mi_col;
+ int ref_frame_idx;
+ const int mi_height = num_8x8_blocks_high_lookup[bsize];
+ const int mi_width = num_8x8_blocks_wide_lookup[bsize];
+ ref_frame_idx = gf_picture[frame_idx].ref_frame[rf_idx];
+      if (ref_frame_idx != -1) {+ YV12_BUFFER_CONFIG *ref_frame_buf = gf_picture[ref_frame_idx].frame;
+        printf("=\n");+        printf("frame_idx %d mi_rows %d mi_cols %d bsize %d ref_frame_idx %d\n",+ frame_idx, cm->mi_rows, cm->mi_cols, mi_width * MI_SIZE,
+ ref_frame_idx);
+        for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row) {+          for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) {+            if ((mi_row % mi_height) == 0 && (mi_col % mi_width) == 0) {+ int_mv mv =
+ *get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row, mi_col);
+              printf("%d %d %d %d\n", mi_row, mi_col, mv.as_mv.row,+ mv.as_mv.col);
+ }
+ }
}
- }
- }
-
- dump_frame_buf(gf_picture[frame_idx].frame);
-
-    for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row) {-      for (mi_col = 0; mi_col < cm->mi_cols; ++mi_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];
-          printf("%f ", tpl_ptr->feature_score);+        for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row) {+          for (mi_col = 0; mi_col < cm->mi_cols; ++mi_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];
+              printf("%f ", tpl_ptr->feature_score);+ }
+ }
}
- }
- }
-    printf("\n");+        printf("\n");- rf_idx = gf_picture[frame_idx].ref_frame[idx];
-    printf("has_ref %d\n", rf_idx != -1);-    if (rf_idx != -1) {- YV12_BUFFER_CONFIG *ref_frame_buf = gf_picture[rf_idx].frame;
- dump_frame_buf(ref_frame_buf);
+ dump_frame_buf(gf_picture[frame_idx].frame);
+ dump_frame_buf(ref_frame_buf);
+ }
}
}
}
--
⑨