Commit 0d786875 authored by Jingning Han's avatar Jingning Han
Browse files

Apply early termination in non-RD partition search

This commit allows the recursive non-RD partition search to early
terminate sub search tree when the cumulative rate-distortion is
already above the best available.

Change-Id: Ifdbcbb4bee229f47fde3033200829577c9f1fc1d
parent c4e807ae
...@@ -2620,13 +2620,17 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2620,13 +2620,17 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
} }
static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x, static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x,
int mi_row, int mi_col, int bsize, int subsize) { int mi_row, int mi_col,
BLOCK_SIZE bsize, BLOCK_SIZE subsize) {
MACROBLOCKD *xd = &x->e_mbd; MACROBLOCKD *xd = &x->e_mbd;
int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4;
PARTITION_TYPE partition = partition_lookup[bsl][subsize]; PARTITION_TYPE partition = partition_lookup[bsl][subsize];
assert(bsize >= BLOCK_8X8); assert(bsize >= BLOCK_8X8);
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
switch (partition) { switch (partition) {
case PARTITION_NONE: case PARTITION_NONE:
set_modeinfo_offsets(cm, xd, mi_row, mi_col); set_modeinfo_offsets(cm, xd, mi_row, mi_col);
...@@ -2789,7 +2793,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2789,7 +2793,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
int pl = partition_plane_context(xd, mi_row, mi_col, bsize); int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; sum_rate += x->partition_cost[pl][PARTITION_SPLIT];
subsize = get_subsize(bsize, PARTITION_SPLIT); subsize = get_subsize(bsize, PARTITION_SPLIT);
for (i = 0; i < 4; ++i) { for (i = 0; i < 4 && sum_rd < best_rd; ++i) {
const int x_idx = (i & 1) * ms; const int x_idx = (i & 1) * ms;
const int y_idx = (i >> 1) * ms; const int y_idx = (i >> 1) * ms;
...@@ -2800,7 +2804,8 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2800,7 +2804,8 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
load_pred_mv(x, ctx); load_pred_mv(x, ctx);
nonrd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, nonrd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx,
subsize, &this_rate, &this_dist, 0, INT64_MAX); subsize, &this_rate, &this_dist, 0,
best_rd - sum_rd);
if (this_rate == INT_MAX) { if (this_rate == INT_MAX) {
sum_rd = INT64_MAX; sum_rd = INT64_MAX;
...@@ -2906,10 +2911,12 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile, ...@@ -2906,10 +2911,12 @@ static void nonrd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
} }
} }
(void) best_rd;
*rate = best_rate; *rate = best_rate;
*dist = best_dist; *dist = best_dist;
if (best_rate == INT_MAX)
return;
// update mode info array // update mode info array
fill_mode_info_sb(cm, x, mi_row, mi_col, bsize, fill_mode_info_sb(cm, x, mi_row, mi_col, bsize,
*(get_sb_partitioning(x, bsize))); *(get_sb_partitioning(x, bsize)));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment