Commit 2b9d19d2 authored by Alex Converse's avatar Alex Converse
Browse files

unpoison_partition_ctx: Move the fake context to the end

It's less invasive and helps make future changes easier.

Change-Id: I0f858462f14109ace4d76a31daeac4289c94bc6e
parent 493623ea
......@@ -792,7 +792,7 @@ static INLINE int partition_plane_context(const MACROBLOCKD *xd, int mi_row,
else if (!has_rows && has_cols)
return PARTITION_CONTEXTS_PRIMARY + PARTITION_BLOCK_SIZES + bsl;
else
return -1; // Bogus context, forced SPLIT
return PARTITION_CONTEXTS; // Bogus context, forced SPLIT
#else
const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx =
......
......@@ -1961,8 +1961,9 @@ static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_UNPOISON_PARTITION_CTX
const int ctx =
partition_plane_context(xd, mi_row, mi_col, has_rows, has_cols, bsize);
const aom_prob *const probs = ctx >= 0 ? cm->fc->partition_prob[ctx] : NULL;
FRAME_COUNTS *const counts = ctx >= 0 ? xd->counts : NULL;
const aom_prob *const probs =
ctx < PARTITION_CONTEXTS ? cm->fc->partition_prob[ctx] : NULL;
FRAME_COUNTS *const counts = ctx < PARTITION_CONTEXTS ? xd->counts : NULL;
#else
const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
const aom_prob *const probs = cm->fc->partition_prob[ctx];
......
......@@ -2533,7 +2533,8 @@ static void write_partition(const AV1_COMMON *const cm,
bsize)
: 0;
#if CONFIG_UNPOISON_PARTITION_CTX
const aom_prob *const probs = ctx >= 0 ? cm->fc->partition_prob[ctx] : NULL;
const aom_prob *const probs =
ctx < PARTITION_CONTEXTS ? cm->fc->partition_prob[ctx] : NULL;
#else
const aom_prob *const probs = cm->fc->partition_prob[ctx];
#endif
......
......@@ -2843,14 +2843,11 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
bsize, ctx_none, INT64_MAX);
if (none_rdc.rate < INT_MAX) {
none_rdc.rate += cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_NONE];
none_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
none_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, none_rdc.rate, none_rdc.dist);
#if CONFIG_SUPERTX
none_rate_nocoef +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_NONE];
none_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
#endif
}
......@@ -3024,13 +3021,11 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
}
if (last_part_rdc.rate < INT_MAX) {
last_part_rdc.rate +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX][partition];
last_part_rdc.rate += cpi->partition_cost[pl][partition];
last_part_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, last_part_rdc.rate, last_part_rdc.dist);
#if CONFIG_SUPERTX
last_part_rate_nocoef +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX][partition];
last_part_rate_nocoef += cpi->partition_cost[pl][partition];
#endif
}
......@@ -3105,23 +3100,17 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
encode_sb(cpi, td, tile_info, tp, mi_row + y_idx, mi_col + x_idx,
OUTPUT_ENABLED, split_subsize, pc_tree->split[i], NULL);
chosen_rdc.rate += cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_NONE];
chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
#if CONFIG_SUPERTX
chosen_rate_nocoef +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_SPLIT];
chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_SPLIT];
#endif
}
if (chosen_rdc.rate < INT_MAX) {
chosen_rdc.rate += cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_SPLIT];
chosen_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
chosen_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, chosen_rdc.rate, chosen_rdc.dist);
#if CONFIG_SUPERTX
chosen_rate_nocoef +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_NONE];
chosen_rate_nocoef += cpi->partition_cost[pl][PARTITION_NONE];
#endif
}
}
......@@ -3643,13 +3632,11 @@ static void rd_test_partition3(
has_rows, has_cols,
#endif
bsize);
sum_rdc.rate +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX][partition];
sum_rdc.rate += cpi->partition_cost[pl][partition];
sum_rdc.rdcost =
RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
#if CONFIG_SUPERTX
sum_rate_nocoef +=
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX][partition];
sum_rate_nocoef += cpi->partition_cost[pl][partition];
#endif
if (sum_rdc.rdcost < best_rdc->rdcost) {
#if CONFIG_SUPERTX
......@@ -3712,8 +3699,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif
bsize);
#endif // CONFIG_CB4X4
const int *partition_cost =
cpi->partition_cost[pl + CONFIG_UNPOISON_PARTITION_CTX];
const int *partition_cost = cpi->partition_cost[pl];
#if CONFIG_SUPERTX
int this_rate_nocoef, sum_rate_nocoef = 0, best_rate_nocoef = INT_MAX;
int abort_flag;
......
......@@ -398,42 +398,40 @@ void av1_initialize_rd_consts(AV1_COMP *cpi) {
if (cpi->sf.partition_search_type != VAR_BASED_PARTITION ||
cm->frame_type == KEY_FRAME) {
#if CONFIG_UNPOISON_PARTITION_CTX
cpi->partition_cost[0][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[0][PARTITION_HORZ] = INT_MAX;
cpi->partition_cost[0][PARTITION_VERT] = INT_MAX;
cpi->partition_cost[0][PARTITION_SPLIT] = 0;
#endif
#if CONFIG_EXT_PARTITION_TYPES
for (i = 0; i < PARTITION_PLOFFSET; ++i)
av1_cost_tokens(cpi->partition_cost[CONFIG_UNPOISON_PARTITION_CTX + i],
cm->fc->partition_prob[i], av1_partition_tree);
av1_cost_tokens(cpi->partition_cost[i], cm->fc->partition_prob[i],
av1_partition_tree);
for (; i < PARTITION_CONTEXTS_PRIMARY; ++i)
av1_cost_tokens(cpi->partition_cost[CONFIG_UNPOISON_PARTITION_CTX + i],
cm->fc->partition_prob[i], av1_ext_partition_tree);
av1_cost_tokens(cpi->partition_cost[i], cm->fc->partition_prob[i],
av1_ext_partition_tree);
#else
for (i = 0; i < PARTITION_CONTEXTS_PRIMARY; ++i)
av1_cost_tokens(cpi->partition_cost[CONFIG_UNPOISON_PARTITION_CTX + i],
cm->fc->partition_prob[i], av1_partition_tree);
av1_cost_tokens(cpi->partition_cost[i], cm->fc->partition_prob[i],
av1_partition_tree);
#endif // CONFIG_EXT_PARTITION_TYPES
#if CONFIG_UNPOISON_PARTITION_CTX
for (; i < PARTITION_CONTEXTS_PRIMARY + PARTITION_BLOCK_SIZES; ++i) {
aom_prob p = cm->fc->partition_prob[i][PARTITION_VERT];
assert(p > 0);
cpi->partition_cost[1 + i][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[1 + i][PARTITION_HORZ] = INT_MAX;
cpi->partition_cost[1 + i][PARTITION_VERT] = av1_cost_bit(p, 0);
cpi->partition_cost[1 + i][PARTITION_SPLIT] = av1_cost_bit(p, 1);
cpi->partition_cost[i][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[i][PARTITION_HORZ] = INT_MAX;
cpi->partition_cost[i][PARTITION_VERT] = av1_cost_bit(p, 0);
cpi->partition_cost[i][PARTITION_SPLIT] = av1_cost_bit(p, 1);
}
for (; i < PARTITION_CONTEXTS_PRIMARY + 2 * PARTITION_BLOCK_SIZES; ++i) {
aom_prob p = cm->fc->partition_prob[i][PARTITION_HORZ];
assert(p > 0);
cpi->partition_cost[1 + i][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[1 + i][PARTITION_HORZ] = av1_cost_bit(p, 0);
cpi->partition_cost[1 + i][PARTITION_VERT] = INT_MAX;
cpi->partition_cost[1 + i][PARTITION_SPLIT] = av1_cost_bit(p, 1);
cpi->partition_cost[i][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[i][PARTITION_HORZ] = av1_cost_bit(p, 0);
cpi->partition_cost[i][PARTITION_VERT] = INT_MAX;
cpi->partition_cost[i][PARTITION_SPLIT] = av1_cost_bit(p, 1);
}
#endif
cpi->partition_cost[PARTITION_CONTEXTS][PARTITION_NONE] = INT_MAX;
cpi->partition_cost[PARTITION_CONTEXTS][PARTITION_HORZ] = INT_MAX;
cpi->partition_cost[PARTITION_CONTEXTS][PARTITION_VERT] = INT_MAX;
cpi->partition_cost[PARTITION_CONTEXTS][PARTITION_SPLIT] = 0;
#endif // CONFIG_UNPOISON_PARTITION_CTX
}
fill_mode_costs(cpi);
......
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