Commit 6c8584f6 authored by Hui Su's avatar Hui Su

intrabc: replace prob with cdf

Improves keyframe coding by 0.1% on the screen_content testset.

Change-Id: I5793a67eaae21010ef200038af99ebb9029fc770
parent 772dee37
......@@ -2244,6 +2244,12 @@ const aom_cdf_prob default_mrc_mask_inter_cdf
};
#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 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
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
}
......
......@@ -70,10 +70,6 @@ extern "C" {
#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 @@ typedef struct frame_contexts {
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
......
......@@ -4928,11 +4928,6 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
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);
......
......@@ -1108,7 +1108,7 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
#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;
......
......@@ -2187,7 +2187,7 @@ static void write_mb_modes_kf(AV1_COMMON *cm,
#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 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
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);
......
......@@ -295,6 +295,9 @@ struct macroblock {
#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;
......
......@@ -213,6 +213,9 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
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) {
......
......@@ -9648,7 +9648,6 @@ static int64_t rd_pick_intrabc_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x,
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 @@ static int64_t rd_pick_intrabc_mode_sb(const AV1_COMP *cpi, MACROBLOCK *x,
// 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);
......
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