Commit 8711cf5f authored by Stanislav Vitvitskyy's avatar Stanislav Vitvitskyy Committed by Stan Vitvitskyy

Using CDFs for read_partition special case

Test results:
akiyo	    -0.05%
bowing	    -0.072%
bridge	    -0.042%
bus	    -0.156%
coastguard  -0.645%
container   -0.087%
deadline     0.007%
flower       0.02%
football    -0.009%
foreman      0.03%
hall         0.087%
highway     -0.041%
husky       -0.031%
mad900       0.015%
mobile      -0.007%
mother       0.012%
news         0.039%
pamphlet     0.061%
paris       -0.003%
sign        -0.148%
silent       0.003%
students    -0.009%
tempete     -0.061%
waterfall    0.666

Change-Id: I96c2fd3a6fbc5f8e5cf7f3b881ef89335e58d5ac
parent c84c21c4
......@@ -895,6 +895,43 @@ static INLINE BLOCK_SIZE scale_chroma_bsize(BLOCK_SIZE bsize, int subsampling_x,
}
#endif
static INLINE aom_cdf_prob cdf_element_prob(const aom_cdf_prob *cdf,
size_t element) {
#if CONFIG_EC_SMALLMUL
return (element > 0 ? cdf[element - 1] : CDF_PROB_TOP) - cdf[element];
#else
return cdf[element] - (element > 0 ? cdf[element - 1] : 0);
#endif
}
static INLINE void partition_gather_horz_alike(aom_cdf_prob *out,
const aom_cdf_prob *const in) {
out[0] = CDF_PROB_TOP;
out[0] -= cdf_element_prob(in, PARTITION_HORZ);
out[0] -= cdf_element_prob(in, PARTITION_SPLIT);
#if CONFIG_EXT_PARTITION_TYPES
out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
out[0] -= cdf_element_prob(in, PARTITION_HORZ_B);
out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
#endif
out[0] = AOM_ICDF(out[0]);
out[1] = AOM_ICDF(CDF_PROB_TOP);
}
static INLINE void partition_gather_vert_alike(aom_cdf_prob *out,
const aom_cdf_prob *const in) {
out[0] = CDF_PROB_TOP;
out[0] -= cdf_element_prob(in, PARTITION_VERT);
out[0] -= cdf_element_prob(in, PARTITION_SPLIT);
#if CONFIG_EXT_PARTITION_TYPES
out[0] -= cdf_element_prob(in, PARTITION_HORZ_A);
out[0] -= cdf_element_prob(in, PARTITION_VERT_A);
out[0] -= cdf_element_prob(in, PARTITION_VERT_B);
#endif
out[0] = AOM_ICDF(out[0]);
out[1] = AOM_ICDF(CDF_PROB_TOP);
}
#if CONFIG_EXT_PARTITION_TYPES
static INLINE void update_ext_partition_context(MACROBLOCKD *xd, int mi_row,
int mi_col, BLOCK_SIZE subsize,
......
......@@ -2139,13 +2139,8 @@ 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 < 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];
FRAME_COUNTS *const counts = xd->counts;
#endif
PARTITION_TYPE p;
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
......@@ -2164,15 +2159,22 @@ static PARTITION_TYPE read_partition(AV1_COMMON *cm, MACROBLOCKD *xd,
ACCT_STR);
#endif // CONFIG_EXT_PARTITION_TYPES
} else if (!has_rows && has_cols) {
p = aom_read(r, probs[1], ACCT_STR) ? PARTITION_SPLIT : PARTITION_HORZ;
assert(bsize > BLOCK_8X8);
aom_cdf_prob cdf[2];
partition_gather_vert_alike(cdf, partition_cdf);
assert(cdf[1] == AOM_ICDF(CDF_PROB_TOP));
p = aom_read_cdf(r, cdf, 2, ACCT_STR) ? PARTITION_SPLIT : PARTITION_HORZ;
// gather cols
} else if (has_rows && !has_cols) {
p = aom_read(r, probs[2], ACCT_STR) ? PARTITION_SPLIT : PARTITION_VERT;
assert(bsize > BLOCK_8X8);
aom_cdf_prob cdf[2];
partition_gather_horz_alike(cdf, partition_cdf);
assert(cdf[1] == AOM_ICDF(CDF_PROB_TOP));
p = aom_read_cdf(r, cdf, 2, ACCT_STR) ? PARTITION_SPLIT : PARTITION_VERT;
} else {
p = PARTITION_SPLIT;
}
if (counts) ++counts->partition[ctx][p];
return p;
}
......
......@@ -2873,13 +2873,6 @@ static void write_partition(const AV1_COMMON *const cm,
#endif
bsize)
: 0;
#if CONFIG_UNPOISON_PARTITION_CTX
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
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
(void)cm;
......@@ -2896,10 +2889,16 @@ static void write_partition(const AV1_COMMON *const cm,
#endif // CONFIG_EXT_PARTITION_TYPES
} else if (!has_rows && has_cols) {
assert(p == PARTITION_SPLIT || p == PARTITION_HORZ);
aom_write(w, p == PARTITION_SPLIT, probs[1]);
assert(bsize > BLOCK_8X8);
aom_cdf_prob cdf[2];
partition_gather_vert_alike(cdf, ec_ctx->partition_cdf[ctx]);
aom_write_cdf(w, p == PARTITION_SPLIT, cdf, 2);
} else if (has_rows && !has_cols) {
assert(p == PARTITION_SPLIT || p == PARTITION_VERT);
aom_write(w, p == PARTITION_SPLIT, probs[2]);
assert(bsize > BLOCK_8X8);
aom_cdf_prob cdf[2];
partition_gather_horz_alike(cdf, ec_ctx->partition_cdf[ctx]);
aom_write_cdf(w, p == PARTITION_SPLIT, cdf, 2);
} else {
assert(p == PARTITION_SPLIT);
}
......
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