summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/non_greedy_mv/non_greedy_mv.py11
-rw-r--r--vp9/encoder/vp9_encoder.c27
2 files changed, 22 insertions, 16 deletions
diff --git a/tools/non_greedy_mv/non_greedy_mv.py b/tools/non_greedy_mv/non_greedy_mv.py
index b653abce7..cd99027e3 100644
--- a/tools/non_greedy_mv/non_greedy_mv.py
+++ b/tools/non_greedy_mv/non_greedy_mv.py
@@ -89,8 +89,10 @@ def read_frame_dpl_stats(fp):
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 @@ def read_frame_dpl_stats(fp):
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 @@ 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=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)
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 85800725e..802a6888b 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5993,7 +5993,8 @@ void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
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 @@ void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx) {
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_frame_buf(const YV12_BUFFER_CONFIG *frame_buf) {
}
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 @@ static void dump_tpl_stats(const VP9_COMP *cpi, int tpl_group_frames,
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 @@ static void setup_tpl_stats(VP9_COMP *cpi) {
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 @@ static void setup_tpl_stats(VP9_COMP *cpi) {
// 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
}