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

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