ref: 6d065ba3cb0110dea28661eee1ae2e9457f05cf7
parent: 1b60a14ef0c5c973848e6b64ac24a191aa580101
parent: 734c5ffa2c003e8668ae8b58413064c98591f3fd
author: Jingning Han <[email protected]>
date: Sat May 10 06:39:26 EDT 2014
Merge "Apply constrained partition search range to non-RD mode decision"
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1871,6 +1871,67 @@
*max_block_size = max_size;
}
+static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile,
+ int mi_row, int mi_col,
+ BLOCK_SIZE *min_block_size,
+ BLOCK_SIZE *max_block_size) {
+ VP9_COMMON *const cm = &cpi->common;
+ MACROBLOCKD *const xd = &cpi->mb.e_mbd;
+ MODE_INFO **mi_8x8 = xd->mi;
+ const int left_in_image = xd->left_available && mi_8x8[-1];
+ const int above_in_image = xd->up_available &&
+ mi_8x8[-xd->mi_stride];
+ int row8x8_remaining = tile->mi_row_end - mi_row;
+ int col8x8_remaining = tile->mi_col_end - mi_col;
+ int bh, bw;
+ BLOCK_SIZE min_size = BLOCK_32X32;
+ BLOCK_SIZE max_size = BLOCK_8X8;
+ int bsl = mi_width_log2_lookup[BLOCK_64X64];
+ int search_range_ctrl = (((mi_row + mi_col) >> bsl) +
+ cpi->sf.chessboard_index) & 0x01;
+ // Trap case where we do not have a prediction.
+ if (search_range_ctrl &&
+ (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) {
+ int block;
+ MODE_INFO **mi;
+ BLOCK_SIZE sb_type;
+
+ // Find the min and max partition sizes used in the left SB64.
+ if (left_in_image) {
+ MODE_INFO *cur_mi;
+ mi = &mi_8x8[-1];
+ for (block = 0; block < MI_BLOCK_SIZE; ++block) {
+ cur_mi = mi[block * xd->mi_stride];
+ sb_type = cur_mi ? cur_mi->mbmi.sb_type : 0;
+ min_size = MIN(min_size, sb_type);
+ max_size = MAX(max_size, sb_type);
+ }
+ }
+ // Find the min and max partition sizes used in the above SB64.
+ if (above_in_image) {
+ mi = &mi_8x8[-xd->mi_stride * MI_BLOCK_SIZE];
+ for (block = 0; block < MI_BLOCK_SIZE; ++block) {
+ sb_type = mi[block] ? mi[block]->mbmi.sb_type : 0;
+ min_size = MIN(min_size, sb_type);
+ max_size = MAX(max_size, sb_type);
+ }
+ }
+
+ min_size = min_partition_size[min_size];
+ max_size = find_partition_size(max_size, row8x8_remaining, col8x8_remaining,
+ &bh, &bw);
+ min_size = MIN(min_size, max_size);
+ min_size = MAX(min_size, BLOCK_8X8);
+ max_size = MIN(max_size, BLOCK_32X32);
+ } else {
+ min_size = BLOCK_8X8;
+ max_size = BLOCK_32X32;
+ }
+
+ *min_block_size = min_size;
+ *max_block_size = max_size;
+}
+
static INLINE void store_pred_mv(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx) {
vpx_memcpy(ctx->pred_mv, x->pred_mv, sizeof(x->pred_mv));
}
@@ -2623,9 +2684,7 @@
if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols)
continue;
-
load_pred_mv(x, ctx);
-
nonrd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx,
subsize, &this_rate, &this_dist, 0,
best_rd - sum_rd, pc_tree->split[i]);
@@ -2915,6 +2974,10 @@
case REFERENCE_PARTITION:
if (cpi->sf.partition_check ||
!is_background(cpi, tile, mi_row, mi_col)) {
+ set_modeinfo_offsets(cm, xd, mi_row, mi_col);
+ auto_partition_range(cpi, tile, mi_row, mi_col,
+ &cpi->sf.min_partition_size,
+ &cpi->sf.max_partition_size);
nonrd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64,
&dummy_rate, &dummy_dist, 1, INT64_MAX,
x->pc_root);