From 5b11052ac1b5f7454c380731173c88919556085f Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 15 Nov 2012 15:50:07 -0800 Subject: Support 32x32 intra modes in non-keyframe superblocks. Change-Id: Icf8ad313c543462e523bff89690e5daa8d49bcc0 --- vp9/common/entropymode.c | 59 +++++++++++++++++++++++++++++------------------- vp9/common/entropymode.h | 2 ++ vp9/common/onyxc_int.h | 9 ++++++++ vp9/common/treecoder.h | 8 +++++++ 4 files changed, 55 insertions(+), 23 deletions(-) (limited to 'vp9/common') diff --git a/vp9/common/entropymode.c b/vp9/common/entropymode.c index 665528d48..5d3336916 100644 --- a/vp9/common/entropymode.c +++ b/vp9/common/entropymode.c @@ -290,7 +290,8 @@ struct vp9_token_struct vp9_bmode_encodings[VP9_NKF_BINTRAMODES]; struct vp9_token_struct vp9_kf_bmode_encodings[VP9_KF_BINTRAMODES]; struct vp9_token_struct vp9_ymode_encodings[VP9_YMODES]; #if CONFIG_SUPERBLOCKS -struct vp9_token_struct vp9_sb_kf_ymode_encodings [VP9_I32X32_MODES]; +struct vp9_token_struct vp9_sb_ymode_encodings[VP9_I32X32_MODES]; +struct vp9_token_struct vp9_sb_kf_ymode_encodings[VP9_I32X32_MODES]; #endif struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES]; struct vp9_token_struct vp9_uv_mode_encodings[VP9_UV_MODES]; @@ -309,6 +310,11 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) { vp9_tree_probs_from_distribution(VP9_YMODES, vp9_ymode_encodings, vp9_ymode_tree, x->fc.ymode_prob, bct, y_mode_cts, 256, 1); +#if CONFIG_SUPERBLOCKS + vp9_tree_probs_from_distribution(VP9_I32X32_MODES, vp9_sb_ymode_encodings, + vp9_sb_ymode_tree, x->fc.sb_ymode_prob, + bct, y_mode_cts, 256, 1); +#endif { int i; for (i = 0; i < 8; i++) { @@ -318,7 +324,7 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) { #if CONFIG_SUPERBLOCKS vp9_tree_probs_from_distribution(VP9_I32X32_MODES, vp9_sb_kf_ymode_encodings, - vp9_sb_ymode_tree, + vp9_sb_kf_ymode_tree, x->sb_kf_ymode_prob[i], bct, kf_y_mode_cts[i], 256, 1); #endif @@ -421,7 +427,8 @@ void vp9_entropy_mode_init() { vp9_tokens_from_tree(vp9_ymode_encodings, vp9_ymode_tree); vp9_tokens_from_tree(vp9_kf_ymode_encodings, vp9_kf_ymode_tree); #if CONFIG_SUPERBLOCKS - vp9_tokens_from_tree(vp9_sb_kf_ymode_encodings, vp9_sb_ymode_tree); + vp9_tokens_from_tree(vp9_sb_ymode_encodings, vp9_sb_ymode_tree); + vp9_tokens_from_tree(vp9_sb_kf_ymode_encodings, vp9_sb_kf_ymode_tree); #endif vp9_tokens_from_tree(vp9_uv_mode_encodings, vp9_uv_mode_tree); vp9_tokens_from_tree(vp9_i8x8_mode_encodings, vp9_i8x8_mode_tree); @@ -505,8 +512,7 @@ void vp9_update_mode_context(VP9_COMMON *pc) { factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT); this_prob = (pc->fc.vp9_mode_contexts[j][i] * (256 - factor) + this_prob * factor + 128) >> 8; - this_prob = this_prob ? (this_prob < 255 ? this_prob : 255) : 1; - mode_context[j][i] = this_prob; + mode_context[j][i] = clip_prob(this_prob); } } } @@ -540,6 +546,9 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { int i, t, count, factor; unsigned int branch_ct[32][2]; vp9_prob ymode_probs[VP9_YMODES - 1]; +#if CONFIG_SUPERBLOCKS + vp9_prob sb_ymode_probs[VP9_I32X32_MODES - 1]; +#endif vp9_prob uvmode_probs[VP9_UV_MODES - 1]; vp9_prob bmode_probs[VP9_NKF_BINTRAMODES - 1]; vp9_prob i8x8_mode_probs[VP9_I8X8_MODES - 1]; @@ -600,10 +609,24 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_ymode_prob[t] * (256 - factor) + (int)ymode_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.ymode_prob[t] = 1; - else if (prob > 255) cm->fc.ymode_prob[t] = 255; - else cm->fc.ymode_prob[t] = prob; + cm->fc.ymode_prob[t] = clip_prob(prob); + } +#if CONFIG_SUPERBLOCKS + vp9_tree_probs_from_distribution(VP9_I32X32_MODES, + vp9_sb_ymode_encodings, vp9_sb_ymode_tree, + sb_ymode_probs, branch_ct, + cm->fc.sb_ymode_counts, + 256, 1); + for (t = 0; t < VP9_I32X32_MODES - 1; ++t) { + int prob; + count = branch_ct[t][0] + branch_ct[t][1]; + count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count; + factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); + prob = ((int)cm->fc.pre_sb_ymode_prob[t] * (256 - factor) + + (int)sb_ymode_probs[t] * factor + 128) >> 8; + cm->fc.sb_ymode_prob[t] = clip_prob(prob); } +#endif for (i = 0; i < VP9_YMODES; ++i) { vp9_tree_probs_from_distribution(VP9_UV_MODES, vp9_uv_mode_encodings, vp9_uv_mode_tree, uvmode_probs, branch_ct, @@ -615,9 +638,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256 - factor) + (int)uvmode_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.uv_mode_prob[i][t] = 1; - else if (prob > 255) cm->fc.uv_mode_prob[i][t] = 255; - else cm->fc.uv_mode_prob[i][t] = prob; + cm->fc.uv_mode_prob[i][t] = clip_prob(prob); } } vp9_tree_probs_from_distribution(VP9_NKF_BINTRAMODES, vp9_bmode_encodings, @@ -630,9 +651,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_bmode_prob[t] * (256 - factor) + (int)bmode_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.bmode_prob[t] = 1; - else if (prob > 255) cm->fc.bmode_prob[t] = 255; - else cm->fc.bmode_prob[t] = prob; + cm->fc.bmode_prob[t] = clip_prob(prob); } vp9_tree_probs_from_distribution(VP9_I8X8_MODES, vp9_i8x8_mode_encodings, vp9_i8x8_mode_tree, i8x8_mode_probs, @@ -644,9 +663,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256 - factor) + (int)i8x8_mode_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.i8x8_mode_prob[t] = 1; - else if (prob > 255) cm->fc.i8x8_mode_prob[t] = 255; - else cm->fc.i8x8_mode_prob[t] = prob; + cm->fc.i8x8_mode_prob[t] = clip_prob(prob); } for (i = 0; i < SUBMVREF_COUNT; ++i) { vp9_tree_probs_from_distribution(VP9_SUBMVREFS, @@ -661,9 +678,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256 - factor) + (int)sub_mv_ref_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.sub_mv_ref_prob[i][t] = 1; - else if (prob > 255) cm->fc.sub_mv_ref_prob[i][t] = 255; - else cm->fc.sub_mv_ref_prob[i][t] = prob; + cm->fc.sub_mv_ref_prob[i][t] = clip_prob(prob); } } vp9_tree_probs_from_distribution(VP9_NUMMBSPLITS, vp9_mbsplit_encodings, @@ -676,9 +691,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) + (int)mbsplit_probs[t] * factor + 128) >> 8; - if (prob <= 0) cm->fc.mbsplit_prob[t] = 1; - else if (prob > 255) cm->fc.mbsplit_prob[t] = 255; - else cm->fc.mbsplit_prob[t] = prob; + cm->fc.mbsplit_prob[t] = clip_prob(prob); } #if CONFIG_COMP_INTERINTRA_PRED if (cm->use_interintra) { diff --git a/vp9/common/entropymode.h b/vp9/common/entropymode.h index 790f5597b..9f20ae94d 100644 --- a/vp9/common/entropymode.h +++ b/vp9/common/entropymode.h @@ -53,6 +53,7 @@ extern const vp9_tree_index vp9_ymode_tree[]; extern const vp9_tree_index vp9_kf_ymode_tree[]; extern const vp9_tree_index vp9_uv_mode_tree[]; #define vp9_sb_ymode_tree vp9_uv_mode_tree +#define vp9_sb_kf_ymode_tree vp9_uv_mode_tree extern const vp9_tree_index vp9_i8x8_mode_tree[]; extern const vp9_tree_index vp9_mbsplit_tree[]; extern const vp9_tree_index vp9_mv_ref_tree[]; @@ -62,6 +63,7 @@ extern const vp9_tree_index vp9_sub_mv_ref_tree[]; extern struct vp9_token_struct vp9_bmode_encodings[VP9_NKF_BINTRAMODES]; extern struct vp9_token_struct vp9_kf_bmode_encodings[VP9_KF_BINTRAMODES]; extern struct vp9_token_struct vp9_ymode_encodings[VP9_YMODES]; +extern struct vp9_token_struct vp9_sb_ymode_encodings[VP9_I32X32_MODES]; extern struct vp9_token_struct vp9_sb_kf_ymode_encodings[VP9_I32X32_MODES]; extern struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES]; extern struct vp9_token_struct vp9_i8x8_mode_encodings[VP9_I8X8_MODES]; diff --git a/vp9/common/onyxc_int.h b/vp9/common/onyxc_int.h index f76c8a008..beefdbc05 100644 --- a/vp9/common/onyxc_int.h +++ b/vp9/common/onyxc_int.h @@ -46,6 +46,9 @@ void vp9_initialize_common(void); typedef struct frame_contexts { vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1]; vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ +#if CONFIG_SUPERBLOCKS + vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1]; +#endif vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1]; vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1]; vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; @@ -61,12 +64,18 @@ typedef struct frame_contexts { nmv_context pre_nmvc; vp9_prob pre_bmode_prob[VP9_NKF_BINTRAMODES - 1]; vp9_prob pre_ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ +#if CONFIG_SUPERBLOCKS + vp9_prob pre_sb_ymode_prob[VP9_I32X32_MODES - 1]; +#endif vp9_prob pre_uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1]; vp9_prob pre_i8x8_mode_prob[VP9_I8X8_MODES - 1]; vp9_prob pre_sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; vp9_prob pre_mbsplit_prob[VP9_NUMMBSPLITS - 1]; unsigned int bmode_counts[VP9_NKF_BINTRAMODES]; unsigned int ymode_counts[VP9_YMODES]; /* interframe intra mode probs */ +#if CONFIG_SUPERBLOCKS + unsigned int sb_ymode_counts[VP9_I32X32_MODES]; +#endif unsigned int uv_mode_counts[VP9_YMODES][VP9_UV_MODES]; unsigned int i8x8_mode_counts[VP9_I8X8_MODES]; /* interframe intra probs */ unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS]; diff --git a/vp9/common/treecoder.h b/vp9/common/treecoder.h index 1ebc82d36..92b92ef55 100644 --- a/vp9/common/treecoder.h +++ b/vp9/common/treecoder.h @@ -70,6 +70,14 @@ void vp9_tree_probs_from_distribution( int Round ); +static __inline int clip_prob(int p) { + if (p > 255) + return 255; + else if (p < 1) + return 1; + return p; +} + vp9_prob vp9_bin_prob_from_distribution(const unsigned int counts[2]); #endif -- cgit v1.2.3