From cbd966f1ab4d44af7c3de84316a543f3d3516d15 Mon Sep 17 00:00:00 2001 From: Angie Chiang Date: Tue, 5 Mar 2019 18:13:45 -0800 Subject: [PATCH] Include mv_mode_arr info in dump_tpl_stats Change-Id: Ib8e635fc7522d27ff7fdb62661597115e5bbc9b8 --- tools/non_greedy_mv/non_greedy_mv.py | 26 ++++++++++++++++++-------- vp9/encoder/vp9_encoder.c | 10 ++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/non_greedy_mv/non_greedy_mv.py b/tools/non_greedy_mv/non_greedy_mv.py index 431f2434b..5ec5f4ad4 100644 --- a/tools/non_greedy_mv/non_greedy_mv.py +++ b/tools/non_greedy_mv/non_greedy_mv.py @@ -91,6 +91,13 @@ def read_feature_score(fp, mv_rows, mv_cols): feature_score = feature_score.reshape(mv_rows, mv_cols) return feature_score +def read_mv_mode_arr(fp, mv_rows, mv_cols): + line = fp.readline() + word_ls = line.split() + mv_mode_arr = np.array([int(v) for v in word_ls]) + mv_mode_arr = mv_mode_arr.reshape(mv_rows, mv_cols) + return mv_mode_arr + def read_frame_dpl_stats(fp): line = fp.readline() @@ -117,9 +124,10 @@ def read_frame_dpl_stats(fp): mv_ls.append([col, row, mv_col, mv_row]) mv_ls = np.array(mv_ls) feature_score = read_feature_score(fp, mv_rows, mv_cols) + mv_mode_arr = read_mv_mode_arr(fp, mv_rows, mv_cols) img = yuv_to_rgb(read_frame(fp)) ref = yuv_to_rgb(read_frame(fp)) - return rf_idx, frame_idx, ref_frame_idx, gf_frame_offset, ref_gf_frame_offset, mv_ls, img, ref, bs, feature_score + return rf_idx, frame_idx, ref_frame_idx, gf_frame_offset, ref_gf_frame_offset, mv_ls, img, ref, bs, feature_score, mv_mode_arr def read_dpl_stats_file(filename, frame_num=0): @@ -140,7 +148,7 @@ def read_dpl_stats_file(filename, frame_num=0): if __name__ == '__main__': filename = sys.argv[1] data_ls = read_dpl_stats_file(filename, frame_num=5) - for rf_idx, frame_idx, ref_frame_idx, gf_frame_offset, ref_gf_frame_offset, mv_ls, img, ref, bs, feature_score in data_ls: + for rf_idx, frame_idx, ref_frame_idx, gf_frame_offset, ref_gf_frame_offset, mv_ls, img, ref, bs, feature_score, mv_mode_arr in data_ls: fig, axes = plt.subplots(2, 2) axes[0][0].imshow(img) @@ -159,12 +167,14 @@ if __name__ == '__main__': axes[0][1].set_xlim(0, ref.shape[1]) axes[1][0].imshow(feature_score) - feature_score_arr = feature_score.flatten() - feature_score_max = feature_score_arr.max() - feature_score_min = feature_score_arr.min() - step = (feature_score_max - feature_score_min) / 20. - feature_score_bins = np.arange(feature_score_min, feature_score_max, step) - axes[1][1].hist(feature_score_arr, bins=feature_score_bins) + #feature_score_arr = feature_score.flatten() + #feature_score_max = feature_score_arr.max() + #feature_score_min = feature_score_arr.min() + #step = (feature_score_max - feature_score_min) / 20. + #feature_score_bins = np.arange(feature_score_min, feature_score_max, step) + #axes[1][1].hist(feature_score_arr, bins=feature_score_bins) + im = axes[1][1].imshow(mv_mode_arr) + #axes[1][1].figure.colorbar(im, ax=axes[1][1]) print rf_idx, frame_idx, ref_frame_idx, gf_frame_offset, ref_gf_frame_offset, len(mv_ls) plt.show() diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index f70ded054..cf973fb15 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -6792,6 +6792,16 @@ static void dump_tpl_stats(const VP9_COMP *cpi, int tpl_group_frames, } printf("\n"); + for (mi_row = 0; mi_row < cm->mi_rows; mi_row += mi_height) { + for (mi_col = 0; mi_col < cm->mi_cols; mi_col += mi_width) { + const int mv_mode = + tpl_frame + ->mv_mode_arr[rf_idx][mi_row * tpl_frame->stride + mi_col]; + printf("%d ", mv_mode); + } + } + printf("\n"); + dump_frame_buf(gf_picture[frame_idx].frame); dump_frame_buf(ref_frame_buf); } -- 2.40.0