ref: 4cb37bff965b150baf1d3e2eb3b6ffd398563c88
parent: a57de9da0374231dc08a97533baabaca9f28ec00
author: Dmitry Kovalev <[email protected]>
date: Fri Mar 21 08:12:55 EDT 2014
Removing redundant {above, left}_seg_context manipulation code. Change-Id: Ib3c1746e61220c629cbd971b2458aa686b5c9e36
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -286,12 +286,12 @@
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 @@
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;
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -407,9 +407,7 @@
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 @@
// 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,
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -395,9 +395,7 @@
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 @@
// 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,
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1295,8 +1295,7 @@
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 @@
}
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
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 @@
}
}
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 @@
}
}
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) {