Commit 2901bf2d authored by Dmitry Kovalev's avatar Dmitry Kovalev

Reducing the number of recursive calls.

Both decode_modes_sb and decode_modes_b had conditions to immediately
return at the beginning. Eliminating these conditions here and calling
these functions only to do a real work. Also unrolling loop for
PARTITION_SPLIT.

Change-Id: I2fc41cb74ac491f045a2f04fe68d30ff4aaa555d
parent 54c2854f
......@@ -382,15 +382,11 @@ static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd,
static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize, int index) {
vp9_reader *r, BLOCK_SIZE bsize) {
const int less8x8 = bsize < BLOCK_8X8;
MB_MODE_INFO *mbmi;
int eobtotal;
if (less8x8)
if (index > 0)
return;
set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r);
......@@ -448,55 +444,51 @@ static PARTITION_TYPE read_partition(int hbs, int mi_rows, int mi_cols,
static void decode_modes_sb(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize, int index) {
vp9_reader* r, BLOCK_SIZE bsize) {
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
PARTITION_TYPE partition = PARTITION_NONE;
PARTITION_TYPE partition;
BLOCK_SIZE subsize;
int ctx;
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
if (bsize < BLOCK_8X8) {
if (index > 0)
return;
} else {
const int ctx = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
ctx = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize);
partition = read_partition(hbs, cm->mi_rows, cm->mi_cols, mi_row, mi_col,
cm->fc.partition_prob[cm->frame_type][ctx], r);
if (!cm->frame_parallel_decoding_mode)
++cm->counts.partition[ctx][partition];
}
subsize = get_subsize(bsize, partition);
if (subsize < BLOCK_8X8) {
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize);
} else {
switch (partition) {
case PARTITION_NONE:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize);
break;
case PARTITION_HORZ:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize);
if (mi_row + hbs < cm->mi_rows)
decode_modes_b(cm, xd, tile, mi_row + hbs, mi_col, r, subsize, 1);
decode_modes_b(cm, xd, tile, mi_row + hbs, mi_col, r, subsize);
break;
case PARTITION_VERT:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, 0);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize);
if (mi_col + hbs < cm->mi_cols)
decode_modes_b(cm, xd, tile, mi_row, mi_col + hbs, r, subsize, 1);
decode_modes_b(cm, xd, tile, mi_row, mi_col + hbs, r, subsize);
break;
case PARTITION_SPLIT:
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, subsize);
decode_modes_sb(cm, xd, tile, mi_row, mi_col + hbs, r, subsize);
decode_modes_sb(cm, xd, tile, mi_row + hbs, mi_col, r, subsize);
decode_modes_sb(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, subsize);
break;
case PARTITION_SPLIT: {
int n;
for (n = 0; n < 4; n++) {
const int j = n >> 1, i = n & 1;
decode_modes_sb(cm, xd, tile, mi_row + j * hbs, mi_col + i * hbs,
r, subsize, n);
}
} break;
default:
assert(!"Invalid partition type");
}
}
// update partition context
if (bsize >= BLOCK_8X8 &&
......@@ -780,7 +772,7 @@ static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile,
vp9_zero(xd->left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE)
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, BLOCK_64X64, 0);
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, BLOCK_64X64);
if (pbi->do_loopfilter_inline) {
const int lf_start = mi_row - MI_BLOCK_SIZE;
......@@ -935,7 +927,7 @@ static int tile_worker_hook(void *arg1, void *arg2) {
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE)
decode_modes_sb(tile_data->cm, &tile_data->xd, tile,
mi_row, mi_col, &tile_data->bit_reader, BLOCK_64X64, 0);
mi_row, mi_col, &tile_data->bit_reader, BLOCK_64X64);
}
return !tile_data->xd.corrupted;
}
......
Markdown is supported
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