Commit 4cb37bff authored by Dmitry Kovalev's avatar Dmitry Kovalev

Removing redundant {above, left}_seg_context manipulation code.

Change-Id: Ib3c1746e61220c629cbd971b2458aa686b5c9e36
parent a57de9da
......@@ -286,12 +286,12 @@ static INLINE int frame_is_intra_only(const VP9_COMMON *const cm) {
return cm->frame_type == KEY_FRAME || cm->intra_only;
}
static INLINE void update_partition_context(
PARTITION_CONTEXT *above_seg_context,
PARTITION_CONTEXT left_seg_context[8],
int mi_row, int mi_col, BLOCK_SIZE subsize, BLOCK_SIZE bsize) {
PARTITION_CONTEXT *const above_ctx = above_seg_context + mi_col;
PARTITION_CONTEXT *const left_ctx = left_seg_context + (mi_row & MI_MASK);
static INLINE void update_partition_context(MACROBLOCKD *xd,
int mi_row, int mi_col,
BLOCK_SIZE subsize,
BLOCK_SIZE bsize) {
PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col;
PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
// num_4x4_blocks_wide_lookup[bsize] / 2
const int bs = num_8x8_blocks_wide_lookup[bsize];
......@@ -303,12 +303,11 @@ static INLINE void update_partition_context(
vpx_memset(left_ctx, partition_context_lookup[subsize].left, bs);
}
static INLINE int partition_plane_context(
const PARTITION_CONTEXT *above_seg_context,
const PARTITION_CONTEXT left_seg_context[8],
int mi_row, int mi_col, BLOCK_SIZE bsize) {
const PARTITION_CONTEXT *above_ctx = above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = left_seg_context + (mi_row & MI_MASK);
static INLINE int partition_plane_context(const MACROBLOCKD *xd,
int mi_row, int mi_col,
BLOCK_SIZE bsize) {
const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
const int bsl = mi_width_log2(bsize);
const int bs = 1 << bsl;
......
......@@ -407,9 +407,7 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
static PARTITION_TYPE read_partition(VP9_COMMON *cm, MACROBLOCKD *xd, int hbs,
int mi_row, int mi_col, BLOCK_SIZE bsize,
vp9_reader *r) {
const int ctx = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
const vp9_prob *const probs = get_partition_probs(cm, ctx);
const int has_rows = (mi_row + hbs) < cm->mi_rows;
const int has_cols = (mi_col + hbs) < cm->mi_cols;
......@@ -474,8 +472,7 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
// update partition context
if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize);
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
static void setup_token_decoder(const uint8_t *data,
......
......@@ -395,9 +395,7 @@ static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile,
static void write_partition(VP9_COMMON *cm, MACROBLOCKD *xd,
int hbs, int mi_row, int mi_col,
PARTITION_TYPE p, BLOCK_SIZE bsize, vp9_writer *w) {
const int ctx = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
const vp9_prob *const probs = get_partition_probs(cm, ctx);
const int has_rows = (mi_row + hbs) < cm->mi_rows;
const int has_cols = (mi_col + hbs) < cm->mi_cols;
......@@ -468,8 +466,7 @@ static void write_modes_sb(VP9_COMP *cpi,
// update partition context
if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize);
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
static void write_modes(VP9_COMP *cpi,
......
......@@ -1295,8 +1295,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
return;
if (bsize >= BLOCK_8X8) {
ctx = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize);
ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
subsize = *get_sb_partitioning(x, bsize);
} else {
ctx = 0;
......@@ -1351,8 +1350,7 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize);
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
// Check to see if the given partition size is allowed for a specified number
......@@ -1526,8 +1524,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const int idx_str = xd->mode_info_stride * mi_row + mi_col;
MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str;
ctx = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize);
ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
subsize = mi_8x8[0]->mbmi.sb_type;
} else {
ctx = 0;
......@@ -1586,8 +1583,7 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, subsize, bsize);
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
}
static void rd_use_partition(VP9_COMP *cpi,
......@@ -1672,9 +1668,7 @@ static void rd_use_partition(VP9_COMP *cpi,
rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize,
get_block_context(x, bsize), INT64_MAX);
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
if (none_rate < INT_MAX) {
none_rate += x->partition_cost[pl][PARTITION_NONE];
......@@ -1774,8 +1768,7 @@ static void rd_use_partition(VP9_COMP *cpi,
assert(0);
}
pl = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
if (last_part_rate < INT_MAX) {
last_part_rate += x->partition_cost[pl][partition];
last_part_rd = RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist);
......@@ -1828,14 +1821,11 @@ static void rd_use_partition(VP9_COMP *cpi,
encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0,
split_subsize);
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row + y_idx, mi_col + x_idx,
pl = partition_plane_context(xd, mi_row + y_idx, mi_col + x_idx,
split_subsize);
chosen_rate += x->partition_cost[pl][PARTITION_NONE];
}
pl = partition_plane_context(xd->above_seg_context, xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
if (chosen_rate < INT_MAX) {
chosen_rate += x->partition_cost[pl][PARTITION_SPLIT];
chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist);
......@@ -2110,9 +2100,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
ctx, best_rd);
if (this_rate != INT_MAX) {
if (bsize >= BLOCK_8X8) {
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
this_rate += x->partition_cost[pl][PARTITION_NONE];
}
sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist);
......@@ -2182,9 +2170,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
}
}
if (sum_rd < best_rd && i == 4) {
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_SPLIT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) {
......@@ -2240,9 +2226,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
}
}
if (sum_rd < best_rd) {
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_HORZ];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) {
......@@ -2293,9 +2277,7 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
}
}
if (sum_rd < best_rd) {
pl = partition_plane_context(xd->above_seg_context,
xd->left_seg_context,
mi_row, mi_col, bsize);
pl = partition_plane_context(xd, mi_row, mi_col, bsize);
sum_rate += x->partition_cost[pl][PARTITION_VERT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) {
......
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