From 869a39ba60379b031573ed5ba1911088d353a3c1 Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Fri, 7 Jun 2013 13:24:14 -0700 Subject: Cleans up mbskip encoding Refactors mbskip coding to be compatible with coding of the rest of the symbols. Adds forward/backward adaptation and removes a lot of the legacy code. Results: fast50: +1.6% derfraw300: +0.317% Change-Id: I395a2976d15af044d3b8ded5acfa45f6f065f980 --- vp9/common/vp9_entropymode.c | 13 +++++++++++-- vp9/common/vp9_onyxc_int.h | 6 ++++-- vp9/common/vp9_pred_common.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'vp9/common') diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c index bf57e7ecc..a70d1a5d4 100644 --- a/vp9/common/vp9_entropymode.c +++ b/vp9/common/vp9_entropymode.c @@ -197,6 +197,10 @@ const vp9_prob vp9_default_tx_probs[TX_SIZE_PROBS] = { }; #endif +const vp9_prob vp9_default_mbskip_probs[MBSKIP_CONTEXTS] = { + 192, 128, 64 +}; + void vp9_init_mbmode_probs(VP9_COMMON *x) { vpx_memcpy(x->fc.uv_mode_prob, default_if_uv_probs, sizeof(default_if_uv_probs)); @@ -221,6 +225,8 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) { sizeof(default_single_ref_p)); vpx_memcpy(x->fc.tx_probs, vp9_default_tx_probs, sizeof(vp9_default_tx_probs)); + vpx_memcpy(x->fc.mbskip_probs, vp9_default_mbskip_probs, + sizeof(vp9_default_mbskip_probs)); } #if VP9_SWITCHABLE_FILTERS == 3 @@ -321,7 +327,7 @@ void vp9_adapt_mode_context(VP9_COMMON *pc) { #define MODE_COUNT_SAT 20 #define MODE_MAX_UPDATE_FACTOR 144 -static int update_mode_ct(int pre_prob, int prob, +static int update_mode_ct(vp9_prob pre_prob, vp9_prob prob, unsigned int branch_ct[2]) { int factor, count = branch_ct[0] + branch_ct[1]; count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count; @@ -344,7 +350,7 @@ static void update_mode_probs(int n_modes, dst_probs[t] = update_mode_ct(pre_probs[t], probs[t], branch_ct[t]); } -static int update_mode_ct2(int pre_prob, unsigned int branch_ct[2]) { +static int update_mode_ct2(vp9_prob pre_prob, unsigned int branch_ct[2]) { return update_mode_ct(pre_prob, get_binary_prob(branch_ct[0], branch_ct[1]), branch_ct); } @@ -438,6 +444,9 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { cm->fc.tx_probs[i] = weighted_prob(cm->fc.pre_tx_probs[i], prob, factor); } } + for (i = 0; i < MBSKIP_CONTEXTS; ++i) + fc->mbskip_probs[i] = update_mode_ct2(fc->pre_mbskip_probs[i], + fc->mbskip_count[i]); } static void set_default_lf_deltas(MACROBLOCKD *xd) { diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index dedda2069..4cb60f196 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -94,6 +94,10 @@ typedef struct frame_contexts { unsigned int tx_count_32x32p[TX_SIZE_MAX_SB]; unsigned int tx_count_16x16p[TX_SIZE_MAX_SB - 1]; unsigned int tx_count_8x8p[TX_SIZE_MAX_SB - 2]; + + vp9_prob mbskip_probs[MBSKIP_CONTEXTS]; + vp9_prob pre_mbskip_probs[MBSKIP_CONTEXTS]; + unsigned int mbskip_count[MBSKIP_CONTEXTS][2]; } FRAME_CONTEXT; typedef enum { @@ -244,8 +248,6 @@ typedef struct VP9Common { MV_REFERENCE_FRAME comp_var_ref[2]; COMPPREDMODE_TYPE comp_pred_mode; - vp9_prob mbskip_pred_probs[MBSKIP_CONTEXTS]; - FRAME_CONTEXT fc; /* this frame entropy */ FRAME_CONTEXT frame_contexts[NUM_FRAME_CONTEXTS]; unsigned int frame_context_idx; /* Context to use/update */ diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c index 73c7278b0..f5ea9a48a 100644 --- a/vp9/common/vp9_pred_common.c +++ b/vp9/common/vp9_pred_common.c @@ -368,7 +368,7 @@ vp9_prob vp9_get_pred_prob(const VP9_COMMON *const cm, case PRED_SEG_ID: return cm->segment_pred_probs[pred_context]; case PRED_MBSKIP: - return cm->mbskip_pred_probs[pred_context]; + return cm->fc.mbskip_probs[pred_context]; case PRED_INTRA_INTER: return cm->fc.intra_inter_prob[pred_context]; case PRED_COMP_INTER_INTER: -- cgit v1.2.3