Commit 88d79eab authored by James Zern's avatar James Zern
Browse files

vp9: pass context directly to partition functions

update_partition_context / partition_plane_context: this will allow for
separate storage to be used in tile decoding

Change-Id: Ie0bc393531ab7e9d2ce35c95111849b294aad4ed
parent 71097d9c
......@@ -307,12 +307,14 @@ 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(VP9_COMMON *cm,
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 sb_type,
BLOCK_SIZE sb_size) {
PARTITION_CONTEXT *above_ctx = cm->above_seg_context + mi_col;
PARTITION_CONTEXT *left_ctx = cm->left_seg_context + (mi_row & MI_MASK);
PARTITION_CONTEXT *above_ctx = above_seg_context + mi_col;
PARTITION_CONTEXT *left_ctx = left_seg_context + (mi_row & MI_MASK);
const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2;
const int bwl = b_width_log2(sb_type);
......@@ -331,11 +333,13 @@ static INLINE void update_partition_context(VP9_COMMON *cm,
vpx_memset(left_ctx, pcvalue[bhl == bsl], bs);
}
static INLINE int partition_plane_context(const VP9_COMMON *cm,
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 sb_type) {
const PARTITION_CONTEXT *above_ctx = cm->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = cm->left_seg_context + (mi_row & MI_MASK);
const PARTITION_CONTEXT *above_ctx = above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = left_seg_context + (mi_row & MI_MASK);
int bsl = mi_width_log2(sb_type), bs = 1 << bsl;
int above = 0, left = 0, i;
......
......@@ -418,7 +418,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
int pl;
const int idx = check_bsize_coverage(hbs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col);
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
if (idx == 0)
partition = treed_read(r, vp9_partition_tree,
......@@ -464,7 +465,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
// update partition context
if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
update_partition_context(cm, mi_row, mi_col, subsize, bsize);
update_partition_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, subsize, bsize);
}
static void setup_token_decoder(const uint8_t *data,
......
......@@ -618,7 +618,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
int pl;
const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col);
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
// encode the partition information
if (idx == 0)
write_token(bc, vp9_partition_tree,
......@@ -661,7 +662,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
// update partition context
if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
update_partition_context(cm, mi_row, mi_col, subsize, bsize);
update_partition_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, subsize, bsize);
}
static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
......
......@@ -818,7 +818,8 @@ static void encode_sb(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row, int mi_col,
c1 = BLOCK_4X4;
if (bsize >= BLOCK_8X8) {
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
c1 = *(get_sb_partitioning(x, bsize));
}
partition = partition_lookup[bsl][c1];
......@@ -861,7 +862,8 @@ static void encode_sb(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row, int mi_col,
}
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
update_partition_context(cm, mi_row, mi_col, c1, bsize);
update_partition_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, c1, bsize);
}
// Check to see if the given partition size is allowed for a specified number
......@@ -1052,7 +1054,8 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
pick_sb_modes(cpi, mi_row, mi_col, &none_rate, &none_dist, bsize,
get_block_context(x, bsize), INT64_MAX);
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
none_rate += x->partition_cost[pl][PARTITION_NONE];
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
......@@ -1143,7 +1146,8 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
assert(0);
}
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
if (last_part_rate < INT_MAX)
last_part_rate += x->partition_cost[pl][partition];
......@@ -1193,10 +1197,12 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
split_rate += rt;
split_dist += dt;
pl = partition_plane_context(cm, mi_row + y_idx, mi_col + x_idx, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row + y_idx, mi_col + x_idx, bsize);
split_rate += x->partition_cost[pl][PARTITION_NONE];
}
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, bsize);
if (split_rate < INT_MAX) {
split_rate += x->partition_cost[pl][PARTITION_SPLIT];
......@@ -1525,7 +1531,9 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
get_block_context(x, bsize), best_rd);
if (this_rate != INT_MAX) {
if (bsize >= BLOCK_8X8) {
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context,
cm->left_seg_context,
mi_row, mi_col, bsize);
this_rate += x->partition_cost[pl][PARTITION_NONE];
}
sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist);
......@@ -1585,7 +1593,8 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
}
}
if (sum_rd < best_rd && i == 4) {
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
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) {
......@@ -1641,7 +1650,8 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
}
}
if (sum_rd < best_rd) {
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
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) {
......@@ -1683,7 +1693,8 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
}
}
if (sum_rd < best_rd) {
pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
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) {
......@@ -1734,7 +1745,8 @@ static void rd_pick_reference_frame(VP9_COMP *cpi, int mi_row, int mi_col) {
cpi->set_ref_frame_mask = 1;
pick_sb_modes(cpi, mi_row, mi_col, &r, &d, BLOCK_64X64,
get_block_context(x, BLOCK_64X64), INT64_MAX);
pl = partition_plane_context(cm, mi_row, mi_col, BLOCK_64X64);
pl = partition_plane_context(cm->above_seg_context, cm->left_seg_context,
mi_row, mi_col, BLOCK_64X64);
r += x->partition_cost[pl][PARTITION_NONE];
*(get_sb_partitioning(x, BLOCK_64X64)) = BLOCK_64X64;
......
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