intrabc: replace prob with cdf
Improves keyframe coding by 0.1% on the screen_content testset.
Change-Id: I5793a67eaae21010ef200038af99ebb9029fc770
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 707b7d0..05bf08c 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -2244,6 +2244,12 @@
};
#endif // CONFIG_MRC_TX
+#if CONFIG_INTRABC
+static const aom_cdf_prob default_intrabc_cdf[CDF_SIZE(2)] = {
+ AOM_ICDF(192 * 128), AOM_ICDF(32768), 0,
+};
+#endif // CONFIG_INTRABC
+
#define MAX_COLOR_CONTEXT_HASH 8
// Negative values are invalid
static const int palette_color_index_context_lookup[MAX_COLOR_CONTEXT_HASH +
@@ -5310,7 +5316,7 @@
av1_copy(fc->cfl_alpha_cdf, default_cfl_alpha_cdf);
#endif
#if CONFIG_INTRABC
- fc->intrabc_prob = INTRABC_PROB_DEFAULT;
+ av1_copy(fc->intrabc_cdf, default_intrabc_cdf);
#endif
}
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index 97275bd..05440e8 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -70,10 +70,6 @@
#define PALETTE_MAX_BLOCK_SIZE (64 * 64)
-#if CONFIG_INTRABC
-#define INTRABC_PROB_DEFAULT 192
-#endif // CONFIG_INTRABC
-
struct AV1Common;
typedef struct {
@@ -323,7 +319,7 @@
nmv_context nmvc[NMV_CONTEXTS];
#if CONFIG_INTRABC
nmv_context ndvc;
- aom_prob intrabc_prob;
+ aom_cdf_prob intrabc_cdf[CDF_SIZE(2)];
#endif
int initialized;
#if CONFIG_EXT_TX
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 7f83d22..fc50e73 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -4928,11 +4928,6 @@
if (frame_is_intra_only(cm)) {
av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
-#if CONFIG_INTRABC
- if (cm->allow_screen_content_tools) {
- av1_diff_update_prob(&r, &fc->intrabc_prob, ACCT_STR);
- }
-#endif
} else {
#if !CONFIG_NEW_MULTISYMBOL
read_inter_mode_probs(fc, &r);
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 6706abd..3a3c271 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1108,7 +1108,7 @@
#if CONFIG_INTRABC
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) {
- mbmi->use_intrabc = aom_read(r, ec_ctx->intrabc_prob, ACCT_STR);
+ mbmi->use_intrabc = aom_read_symbol(r, ec_ctx->intrabc_cdf, 2, ACCT_STR);
if (mbmi->use_intrabc) {
mbmi->tx_size = read_tx_size(cm, xd, 1, !mbmi->skip, r);
mbmi->mode = mbmi->uv_mode = UV_DC_PRED;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 6c91b0c..c6fa3f9 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2187,7 +2187,7 @@
#if CONFIG_INTRABC
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools) {
int use_intrabc = is_intrabc_block(mbmi);
- aom_write(w, use_intrabc, ec_ctx->intrabc_prob);
+ aom_write_symbol(w, use_intrabc, ec_ctx->intrabc_cdf, 2);
if (use_intrabc) {
assert(mbmi->mode == DC_PRED);
assert(mbmi->uv_mode == UV_DC_PRED);
@@ -4687,13 +4687,6 @@
if (frame_is_intra_only(cm)) {
av1_copy(cm->fc->kf_y_cdf, av1_kf_y_mode_cdf);
-
-#if CONFIG_INTRABC
- if (cm->allow_screen_content_tools) {
- av1_cond_prob_diff_update(header_bc, &fc->intrabc_prob,
- cm->counts.intrabc, probwt);
- }
-#endif
} else {
#if !CONFIG_NEW_MULTISYMBOL
update_inter_mode_probs(cm, header_bc, counts);
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 318d849..23aecdd 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -295,6 +295,9 @@
#if CONFIG_LOOP_RESTORATION
int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES];
#endif // CONFIG_LOOP_RESTORATION
+#if CONFIG_INTRABC
+ int intrabc_cost[2];
+#endif // CONFIG_INTRABC
int optimize;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 7894e4f..dc2e7c8 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -213,6 +213,9 @@
av1_cost_tokens(x->switchable_restore_cost, fc->switchable_restore_prob,
av1_switchable_restore_tree);
#endif // CONFIG_LOOP_RESTORATION
+#if CONFIG_INTRABC
+ av1_cost_tokens_from_cdf(x->intrabc_cost, fc->intrabc_cdf, NULL);
+#endif // CONFIG_INTRABC
if (!frame_is_intra_only(cm)) {
for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i) {
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d31dd32..d6ef343 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -9648,7 +9648,6 @@
MACROBLOCKD *const xd = &x->e_mbd;
const TileInfo *tile = &xd->tile;
- FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
MODE_INFO *const mi = xd->mi[0];
const int mi_row = -xd->mb_to_top_edge / (8 * MI_SIZE);
const int mi_col = -xd->mb_to_left_edge / (8 * MI_SIZE);
@@ -9768,8 +9767,7 @@
// in MV_COST_WEIGHT is too large. Explore other values.
int rate_mv = av1_mv_bit_cost(&dv, &dv_ref.as_mv, x->nmvjointcost,
x->mvcost, MV_COST_WEIGHT_SUB);
- const int rate_mode = av1_cost_bit(ec_ctx->intrabc_prob, 1);
-
+ const int rate_mode = x->intrabc_cost[1];
RD_STATS rd_stats, rd_stats_uv;
av1_subtract_plane(x, bsize, 0);
super_block_yrd(cpi, x, &rd_stats, bsize, INT64_MAX);