Rework non-RD mode decision coding flow

In the first coding run of a 64x64 block, check the coding mode
for each 8x8 block. Will need a second annealing stage to decide
the partition size to be encoded.

Change-Id: Ida9417805ff3358979b0c0429d4099c023c88866
This commit is contained in:
Jingning Han 2014-02-18 11:23:11 -08:00
parent e3178d0c1c
commit b99ed1ec5a
2 changed files with 20 additions and 46 deletions

View File

@ -2260,58 +2260,33 @@ static void rtc_use_partition(VP9_COMP *cpi,
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &cpi->mb.e_mbd; MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int mis = cm->mode_info_stride;
int mi_width = num_8x8_blocks_wide_lookup[cpi->sf.always_this_block_size];
int mi_height = num_8x8_blocks_high_lookup[cpi->sf.always_this_block_size];
int i, j; int i, j;
int chosen_rate = INT_MAX; int chosen_rate = INT_MAX;
int64_t chosen_dist = INT_MAX; int64_t chosen_dist = INT_MAX;
MB_PREDICTION_MODE mode = DC_PRED; MB_PREDICTION_MODE mode = DC_PRED;
int row8x8_remaining = tile->mi_row_end - mi_row; int row8x8_remaining = MIN(MI_BLOCK_SIZE, tile->mi_row_end - mi_row);
int col8x8_remaining = tile->mi_col_end - mi_col; int col8x8_remaining = MIN(MI_BLOCK_SIZE, tile->mi_col_end - mi_col);
int b32i;
for (b32i = 0; b32i < 4; b32i++) {
int b16i;
for (b16i = 0; b16i < 4; b16i++) {
int b8i;
int block_row = get_block_row(b32i, b16i, 0);
int block_col = get_block_col(b32i, b16i, 0);
int index = block_row * mis + block_col;
int rate;
int64_t dist;
// Find a partition size that fits int rows = mi_row + row8x8_remaining;
bsize = find_partition_size(cpi->sf.always_this_block_size, int cols = mi_col + col8x8_remaining;
(row8x8_remaining - block_row),
(col8x8_remaining - block_col),
&mi_height, &mi_width);
mi_8x8[index] = mi_8x8[0] + index;
set_mi_row_col(xd, tile, mi_row + block_row, mi_height, int brate;
mi_col + block_col, mi_width, cm->mi_rows, cm->mi_cols); int64_t bdist;
*rate = 0;
*dist = 0;
xd->mi_8x8 = mi_8x8 + index; // find prediction mode for each 8x8 block
for (j = mi_row; j < rows; ++j) {
for (i = mi_col; i < cols; ++i) {
set_offsets(cpi, tile, j, i, BLOCK_8X8);
if (cm->frame_type != KEY_FRAME) { if (cm->frame_type != KEY_FRAME)
set_offsets(cpi, tile, mi_row + block_row, mi_col + block_col, bsize); vp9_pick_inter_mode(cpi, x, tile, j, i, &brate, &bdist, BLOCK_8X8);
else
set_mode_info(&xd->mi_8x8[0]->mbmi, BLOCK_8X8, mode, j, i);
vp9_pick_inter_mode(cpi, x, tile, *rate += brate;
mi_row + block_row, mi_col + block_col, *dist += bdist;
&rate, &dist, bsize);
} else {
set_mode_info(&mi_8x8[index]->mbmi, bsize, mode,
mi_row + block_row, mi_col + block_col);
}
for (j = 0; j < mi_height; j++)
for (i = 0; i < mi_width; i++)
if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > i
&& (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > j) {
mi_8x8[index+ i + j * mis] = mi_8x8[index];
}
for (b8i = 0; b8i < 4; b8i++) {
}
} }
} }
@ -2340,7 +2315,6 @@ static void encode_rtc_sb_row(VP9_COMP *cpi, const TileInfo *const tile,
MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str; MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str;
cpi->mb.source_variance = UINT_MAX; cpi->mb.source_variance = UINT_MAX;
set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col);
rtc_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, rtc_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64,
&dummy_rate, &dummy_dist, 1); &dummy_rate, &dummy_dist, 1);
} }

View File

@ -192,7 +192,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
VP9_ALT_FLAG }; VP9_ALT_FLAG };
int64_t best_rd = INT64_MAX; int64_t best_rd = INT64_MAX;
int64_t this_rd; int64_t this_rd;
int cost[4]= { 0, 100, 150, 205 }; int64_t cost[4]= { 0, 50, 75, 100 };
x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH;
@ -264,7 +264,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
} }
} }
// TODO(jingning) sub-pixel motion search, if NEWMV is chosen // Perform sub-pixel motion search, if NEWMV is chosen
if (mbmi->mode == NEWMV) { if (mbmi->mode == NEWMV) {
ref_frame = mbmi->ref_frame[0]; ref_frame = mbmi->ref_frame[0];
sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col, sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,