diff options
author | Angie Chiang <angiebird@google.com> | 2019-03-08 18:31:57 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-03-08 18:31:57 +0000 |
commit | af5e63091555b015f05c90940143eb86dfc0b32f (patch) | |
tree | 69f8335855a4b3bfcc0d27607f1c79f027bd4405 | |
parent | 47f8ce0f7c6ee95598d336263d6714abe19aa204 (diff) | |
parent | cbd966f1ab4d44af7c3de84316a543f3d3516d15 (diff) | |
download | libvpx-af5e63091555b015f05c90940143eb86dfc0b32f.tar libvpx-af5e63091555b015f05c90940143eb86dfc0b32f.tar.gz libvpx-af5e63091555b015f05c90940143eb86dfc0b32f.tar.bz2 libvpx-af5e63091555b015f05c90940143eb86dfc0b32f.zip |
Merge changes Ib8e635fc,If868f67c,Ibfeae411
* changes:
Include mv_mode_arr info in dump_tpl_stats
Include gf_frame_offset in dump_tpl_stats
Refactor dump_tpl_stats
-rw-r--r-- | tools/non_greedy_mv/non_greedy_mv.py | 42 | ||||
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 87 |
2 files changed, 79 insertions, 50 deletions
diff --git a/tools/non_greedy_mv/non_greedy_mv.py b/tools/non_greedy_mv/non_greedy_mv.py index a63af246d..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() @@ -99,6 +106,10 @@ def read_frame_dpl_stats(fp): mi_rows = int(word_ls[3]) mi_cols = int(word_ls[5]) bs = int(word_ls[7]) + ref_frame_idx = int(word_ls[9]) + rf_idx = int(word_ls[11]) + gf_frame_offset = int(word_ls[13]) + ref_gf_frame_offset = int(word_ls[15]) mi_size = bs / 8 mv_ls = [] mv_rows = int((math.ceil(mi_rows * 1. / mi_size))) @@ -112,14 +123,11 @@ def read_frame_dpl_stats(fp): 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 + 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, 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 frame_idx, 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() - print frame_idx, len(mv_ls) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 72e72176f..57900b8fc 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -6750,46 +6750,65 @@ static void dump_frame_buf(const YV12_BUFFER_CONFIG *frame_buf) { } static void dump_tpl_stats(const VP9_COMP *cpi, int tpl_group_frames, + const GF_GROUP *gf_group, 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; + const int gf_frame_offset = gf_group->frame_gop_index[frame_idx]; + const int ref_gf_frame_offset = + gf_group->frame_gop_index[ref_frame_idx]; + printf("=\n"); + printf( + "frame_idx %d mi_rows %d mi_cols %d bsize %d ref_frame_idx %d " + "rf_idx %d gf_frame_offset %d ref_gf_frame_offset %d\n", + frame_idx, cm->mi_rows, cm->mi_cols, mi_width * MI_SIZE, + ref_frame_idx, rf_idx, gf_frame_offset, ref_gf_frame_offset); + 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"); + + 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"); - 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); + } } } } @@ -6896,7 +6915,7 @@ static void setup_tpl_stats(VP9_COMP *cpi) { #if CONFIG_NON_GREEDY_MV cpi->tpl_ready = 1; #if DUMP_TPL_STATS - dump_tpl_stats(cpi, tpl_group_frames, gf_picture, cpi->tpl_bsize); + dump_tpl_stats(cpi, tpl_group_frames, gf_group, gf_picture, cpi->tpl_bsize); #endif // DUMP_TPL_STATS #endif // CONFIG_NON_GREEDY_MV } |