Commit 1eed2df9 authored by Zoe Liu's avatar Zoe Liu

Use CDFs to calcualte cost for the skip bit

Change-Id: I262d9b538988ddcbcac13a217c786fa5df17f8a4
parent eaf128a9
......@@ -2450,14 +2450,15 @@ static const aom_cdf_prob
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_VAR_TX
static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob default_skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 }
};
#endif
#else
static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
#endif // CONFIG_NEW_MULTISYMBOL
#if CONFIG_LGT_FROM_PRED
static const aom_prob default_intra_lgt_prob[LGT_SIZES][INTRA_MODES] = {
......@@ -6276,7 +6277,6 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->txfm_partition_cdf, default_txfm_partition_cdf);
#endif
#endif
av1_copy(fc->skip_probs, default_skip_probs);
av1_copy(fc->newmv_prob, default_newmv_prob);
av1_copy(fc->zeromv_prob, default_zeromv_prob);
av1_copy(fc->refmv_prob, default_refmv_prob);
......@@ -6356,7 +6356,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->skip_cdfs, default_skip_cdfs);
av1_copy(fc->intra_inter_cdf, default_intra_inter_cdf);
#endif
#else
av1_copy(fc->skip_probs, default_skip_probs);
#endif // CONFIG_NEW_MULTISYMBOL
av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
av1_copy(fc->tx_size_cdf, default_tx_size_cdf);
av1_copy(fc->delta_q_prob, default_delta_q_probs);
......@@ -6528,9 +6530,11 @@ void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
}
#endif
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < SKIP_CONTEXTS; ++i)
fc->skip_probs[i] =
av1_mode_mv_merge_probs(pre_fc->skip_probs[i], counts->skip[i]);
#endif // !CONFIG_NEW_MULTISYMBOL
#if CONFIG_LGT_FROM_PRED
int j;
......
......@@ -303,11 +303,12 @@ typedef struct frame_contexts {
aom_cdf_prob txfm_partition_cdf[TXFM_PARTITION_CONTEXTS][CDF_SIZE(2)];
#endif
#endif // CONFIG_VAR_TX
aom_prob skip_probs[SKIP_CONTEXTS];
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob intra_inter_cdf[INTRA_INTER_CONTEXTS][CDF_SIZE(2)];
#endif
#else
aom_prob skip_probs[SKIP_CONTEXTS];
#endif // CONFIG_NEW_MULTISYMBOL
nmv_context nmvc[NMV_CONTEXTS];
#if CONFIG_INTRABC
nmv_context ndvc;
......
......@@ -69,10 +69,12 @@ static INLINE int av1_get_skip_context(const MACROBLOCKD *xd) {
return above_skip + left_skip;
}
#if !CONFIG_NEW_MULTISYMBOL
static INLINE aom_prob av1_get_skip_prob(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
return cm->fc->skip_probs[av1_get_skip_context(xd)];
}
#endif // !CONFIG_NEW_MULTISYMBOL
#if CONFIG_DUAL_FILTER
int av1_get_pred_context_switchable_interp(const MACROBLOCKD *xd, int dir);
......
......@@ -219,6 +219,8 @@ struct macroblock {
int skip_chroma_rd;
#endif
int skip_cost[SKIP_CONTEXTS][2];
#if CONFIG_LV_MAP
LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES];
uint16_t cb_offset;
......
......@@ -1029,6 +1029,17 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
int super_block_upper_left =
((mi_row & MAX_MIB_MASK) == 0) && ((mi_col & MAX_MIB_MASK) == 0);
const int seg_ref_active =
segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_REF_FRAME);
if (!seg_ref_active) {
const int skip_ctx = av1_get_skip_context(xd);
td->counts->skip[skip_ctx][mbmi->skip]++;
#if CONFIG_NEW_MULTISYMBOL
update_cdf(fc->skip_cdfs[skip_ctx], mbmi->skip, 2);
#endif // CONFIG_NEW_MULTISYMBOL
}
if (cm->delta_q_present_flag && (bsize != cm->sb_size || !mbmi->skip) &&
super_block_upper_left) {
const int dq = (mbmi->current_q_index - xd->prev_qindex) / cm->delta_q_res;
......@@ -1087,8 +1098,6 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
FRAME_COUNTS *const counts = td->counts;
RD_COUNTS *rdc = &td->rd_counts;
const int inter_block = is_inter_block(mbmi);
const int seg_ref_active =
segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_REF_FRAME);
if (!seg_ref_active) {
counts->intra_inter[av1_get_intra_inter_context(xd)][inter_block]++;
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -120,6 +120,15 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
#endif // CONFIG_UNPOISON_PARTITION_CTX
}
for (i = 0; i < SKIP_CONTEXTS; ++i) {
#if CONFIG_NEW_MULTISYMBOL
av1_cost_tokens_from_cdf(x->skip_cost[i], fc->skip_cdfs[i], NULL);
#else
x->skip_cost[i][0] = av1_cost_bit(fc->skip_probs[i], 0);
x->skip_cost[i][1] = av1_cost_bit(fc->skip_probs[i], 1);
#endif // CONFIG_NEW_MULTISYMBOL
}
#if CONFIG_KF_CTX
for (i = 0; i < KF_MODE_CONTEXTS; ++i)
for (j = 0; j < KF_MODE_CONTEXTS; ++j)
......
This diff is collapsed.
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