Commit 5b11052a authored by Ronald S. Bultje's avatar Ronald S. Bultje

Support 32x32 intra modes in non-keyframe superblocks.

Change-Id: Icf8ad313c543462e523bff89690e5daa8d49bcc0
parent a57dbd95
...@@ -290,7 +290,8 @@ struct vp9_token_struct vp9_bmode_encodings[VP9_NKF_BINTRAMODES]; ...@@ -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_kf_bmode_encodings[VP9_KF_BINTRAMODES];
struct vp9_token_struct vp9_ymode_encodings[VP9_YMODES]; struct vp9_token_struct vp9_ymode_encodings[VP9_YMODES];
#if CONFIG_SUPERBLOCKS #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 #endif
struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES]; struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES];
struct vp9_token_struct vp9_uv_mode_encodings[VP9_UV_MODES]; struct vp9_token_struct vp9_uv_mode_encodings[VP9_UV_MODES];
...@@ -309,6 +310,11 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) { ...@@ -309,6 +310,11 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
vp9_tree_probs_from_distribution(VP9_YMODES, vp9_ymode_encodings, vp9_tree_probs_from_distribution(VP9_YMODES, vp9_ymode_encodings,
vp9_ymode_tree, x->fc.ymode_prob, vp9_ymode_tree, x->fc.ymode_prob,
bct, y_mode_cts, 256, 1); 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; int i;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -318,7 +324,7 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) { ...@@ -318,7 +324,7 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
#if CONFIG_SUPERBLOCKS #if CONFIG_SUPERBLOCKS
vp9_tree_probs_from_distribution(VP9_I32X32_MODES, vp9_tree_probs_from_distribution(VP9_I32X32_MODES,
vp9_sb_kf_ymode_encodings, vp9_sb_kf_ymode_encodings,
vp9_sb_ymode_tree, vp9_sb_kf_ymode_tree,
x->sb_kf_ymode_prob[i], bct, x->sb_kf_ymode_prob[i], bct,
kf_y_mode_cts[i], 256, 1); kf_y_mode_cts[i], 256, 1);
#endif #endif
...@@ -421,7 +427,8 @@ void vp9_entropy_mode_init() { ...@@ -421,7 +427,8 @@ void vp9_entropy_mode_init() {
vp9_tokens_from_tree(vp9_ymode_encodings, vp9_ymode_tree); vp9_tokens_from_tree(vp9_ymode_encodings, vp9_ymode_tree);
vp9_tokens_from_tree(vp9_kf_ymode_encodings, vp9_kf_ymode_tree); vp9_tokens_from_tree(vp9_kf_ymode_encodings, vp9_kf_ymode_tree);
#if CONFIG_SUPERBLOCKS #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 #endif
vp9_tokens_from_tree(vp9_uv_mode_encodings, vp9_uv_mode_tree); vp9_tokens_from_tree(vp9_uv_mode_encodings, vp9_uv_mode_tree);
vp9_tokens_from_tree(vp9_i8x8_mode_encodings, vp9_i8x8_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) { ...@@ -505,8 +512,7 @@ void vp9_update_mode_context(VP9_COMMON *pc) {
factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT); factor = (MVREF_MAX_UPDATE_FACTOR * count / MVREF_COUNT_SAT);
this_prob = (pc->fc.vp9_mode_contexts[j][i] * (256 - factor) + this_prob = (pc->fc.vp9_mode_contexts[j][i] * (256 - factor) +
this_prob * factor + 128) >> 8; this_prob * factor + 128) >> 8;
this_prob = this_prob ? (this_prob < 255 ? this_prob : 255) : 1; mode_context[j][i] = clip_prob(this_prob);
mode_context[j][i] = this_prob;
} }
} }
} }
...@@ -540,6 +546,9 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -540,6 +546,9 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
int i, t, count, factor; int i, t, count, factor;
unsigned int branch_ct[32][2]; unsigned int branch_ct[32][2];
vp9_prob ymode_probs[VP9_YMODES - 1]; 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 uvmode_probs[VP9_UV_MODES - 1];
vp9_prob bmode_probs[VP9_NKF_BINTRAMODES - 1]; vp9_prob bmode_probs[VP9_NKF_BINTRAMODES - 1];
vp9_prob i8x8_mode_probs[VP9_I8X8_MODES - 1]; vp9_prob i8x8_mode_probs[VP9_I8X8_MODES - 1];
...@@ -600,10 +609,24 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -600,10 +609,24 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_ymode_prob[t] * (256 - factor) + prob = ((int)cm->fc.pre_ymode_prob[t] * (256 - factor) +
(int)ymode_probs[t] * factor + 128) >> 8; (int)ymode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.ymode_prob[t] = 1; cm->fc.ymode_prob[t] = clip_prob(prob);
else if (prob > 255) cm->fc.ymode_prob[t] = 255; }
else cm->fc.ymode_prob[t] = 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) { for (i = 0; i < VP9_YMODES; ++i) {
vp9_tree_probs_from_distribution(VP9_UV_MODES, vp9_uv_mode_encodings, vp9_tree_probs_from_distribution(VP9_UV_MODES, vp9_uv_mode_encodings,
vp9_uv_mode_tree, uvmode_probs, branch_ct, vp9_uv_mode_tree, uvmode_probs, branch_ct,
...@@ -615,9 +638,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -615,9 +638,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256 - factor) + prob = ((int)cm->fc.pre_uv_mode_prob[i][t] * (256 - factor) +
(int)uvmode_probs[t] * factor + 128) >> 8; (int)uvmode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.uv_mode_prob[i][t] = 1; cm->fc.uv_mode_prob[i][t] = clip_prob(prob);
else if (prob > 255) cm->fc.uv_mode_prob[i][t] = 255;
else cm->fc.uv_mode_prob[i][t] = prob;
} }
} }
vp9_tree_probs_from_distribution(VP9_NKF_BINTRAMODES, vp9_bmode_encodings, vp9_tree_probs_from_distribution(VP9_NKF_BINTRAMODES, vp9_bmode_encodings,
...@@ -630,9 +651,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -630,9 +651,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_bmode_prob[t] * (256 - factor) + prob = ((int)cm->fc.pre_bmode_prob[t] * (256 - factor) +
(int)bmode_probs[t] * factor + 128) >> 8; (int)bmode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.bmode_prob[t] = 1; cm->fc.bmode_prob[t] = clip_prob(prob);
else if (prob > 255) cm->fc.bmode_prob[t] = 255;
else cm->fc.bmode_prob[t] = prob;
} }
vp9_tree_probs_from_distribution(VP9_I8X8_MODES, vp9_i8x8_mode_encodings, vp9_tree_probs_from_distribution(VP9_I8X8_MODES, vp9_i8x8_mode_encodings,
vp9_i8x8_mode_tree, i8x8_mode_probs, vp9_i8x8_mode_tree, i8x8_mode_probs,
...@@ -644,9 +663,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -644,9 +663,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256 - factor) + prob = ((int)cm->fc.pre_i8x8_mode_prob[t] * (256 - factor) +
(int)i8x8_mode_probs[t] * factor + 128) >> 8; (int)i8x8_mode_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.i8x8_mode_prob[t] = 1; cm->fc.i8x8_mode_prob[t] = clip_prob(prob);
else if (prob > 255) cm->fc.i8x8_mode_prob[t] = 255;
else cm->fc.i8x8_mode_prob[t] = prob;
} }
for (i = 0; i < SUBMVREF_COUNT; ++i) { for (i = 0; i < SUBMVREF_COUNT; ++i) {
vp9_tree_probs_from_distribution(VP9_SUBMVREFS, vp9_tree_probs_from_distribution(VP9_SUBMVREFS,
...@@ -661,9 +678,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -661,9 +678,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256 - factor) + prob = ((int)cm->fc.pre_sub_mv_ref_prob[i][t] * (256 - factor) +
(int)sub_mv_ref_probs[t] * factor + 128) >> 8; (int)sub_mv_ref_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.sub_mv_ref_prob[i][t] = 1; cm->fc.sub_mv_ref_prob[i][t] = clip_prob(prob);
else if (prob > 255) cm->fc.sub_mv_ref_prob[i][t] = 255;
else cm->fc.sub_mv_ref_prob[i][t] = prob;
} }
} }
vp9_tree_probs_from_distribution(VP9_NUMMBSPLITS, vp9_mbsplit_encodings, vp9_tree_probs_from_distribution(VP9_NUMMBSPLITS, vp9_mbsplit_encodings,
...@@ -676,9 +691,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) { ...@@ -676,9 +691,7 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT); factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) + prob = ((int)cm->fc.pre_mbsplit_prob[t] * (256 - factor) +
(int)mbsplit_probs[t] * factor + 128) >> 8; (int)mbsplit_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.mbsplit_prob[t] = 1; cm->fc.mbsplit_prob[t] = clip_prob(prob);
else if (prob > 255) cm->fc.mbsplit_prob[t] = 255;
else cm->fc.mbsplit_prob[t] = prob;
} }
#if CONFIG_COMP_INTERINTRA_PRED #if CONFIG_COMP_INTERINTRA_PRED
if (cm->use_interintra) { if (cm->use_interintra) {
......
...@@ -53,6 +53,7 @@ extern const vp9_tree_index vp9_ymode_tree[]; ...@@ -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_kf_ymode_tree[];
extern const vp9_tree_index vp9_uv_mode_tree[]; extern const vp9_tree_index vp9_uv_mode_tree[];
#define vp9_sb_ymode_tree 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_i8x8_mode_tree[];
extern const vp9_tree_index vp9_mbsplit_tree[]; extern const vp9_tree_index vp9_mbsplit_tree[];
extern const vp9_tree_index vp9_mv_ref_tree[]; extern const vp9_tree_index vp9_mv_ref_tree[];
...@@ -62,6 +63,7 @@ extern const vp9_tree_index vp9_sub_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_bmode_encodings[VP9_NKF_BINTRAMODES];
extern struct vp9_token_struct vp9_kf_bmode_encodings[VP9_KF_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_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_sb_kf_ymode_encodings[VP9_I32X32_MODES];
extern struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES]; extern struct vp9_token_struct vp9_kf_ymode_encodings[VP9_YMODES];
extern struct vp9_token_struct vp9_i8x8_mode_encodings[VP9_I8X8_MODES]; extern struct vp9_token_struct vp9_i8x8_mode_encodings[VP9_I8X8_MODES];
......
...@@ -46,6 +46,9 @@ void vp9_initialize_common(void); ...@@ -46,6 +46,9 @@ void vp9_initialize_common(void);
typedef struct frame_contexts { typedef struct frame_contexts {
vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1]; vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1];
vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ 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 uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1]; vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1];
vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
...@@ -61,12 +64,18 @@ typedef struct frame_contexts { ...@@ -61,12 +64,18 @@ typedef struct frame_contexts {
nmv_context pre_nmvc; nmv_context pre_nmvc;
vp9_prob pre_bmode_prob[VP9_NKF_BINTRAMODES - 1]; vp9_prob pre_bmode_prob[VP9_NKF_BINTRAMODES - 1];
vp9_prob pre_ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ 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_uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
vp9_prob pre_i8x8_mode_prob[VP9_I8X8_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_sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob pre_mbsplit_prob[VP9_NUMMBSPLITS - 1]; vp9_prob pre_mbsplit_prob[VP9_NUMMBSPLITS - 1];
unsigned int bmode_counts[VP9_NKF_BINTRAMODES]; unsigned int bmode_counts[VP9_NKF_BINTRAMODES];
unsigned int ymode_counts[VP9_YMODES]; /* interframe intra mode probs */ 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 uv_mode_counts[VP9_YMODES][VP9_UV_MODES];
unsigned int i8x8_mode_counts[VP9_I8X8_MODES]; /* interframe intra probs */ unsigned int i8x8_mode_counts[VP9_I8X8_MODES]; /* interframe intra probs */
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS]; unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
......
...@@ -70,6 +70,14 @@ void vp9_tree_probs_from_distribution( ...@@ -70,6 +70,14 @@ void vp9_tree_probs_from_distribution(
int Round 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]); vp9_prob vp9_bin_prob_from_distribution(const unsigned int counts[2]);
#endif #endif
...@@ -48,6 +48,10 @@ static int read_ymode(vp9_reader *bc, const vp9_prob *p) { ...@@ -48,6 +48,10 @@ static int read_ymode(vp9_reader *bc, const vp9_prob *p) {
} }
#if CONFIG_SUPERBLOCKS #if CONFIG_SUPERBLOCKS
static int read_sb_ymode(vp9_reader *bc, const vp9_prob *p) {
return treed_read(bc, vp9_sb_ymode_tree, p);
}
static int read_kf_sb_ymode(vp9_reader *bc, const vp9_prob *p) { static int read_kf_sb_ymode(vp9_reader *bc, const vp9_prob *p) {
return treed_read(bc, vp9_uv_mode_tree, p); return treed_read(bc, vp9_uv_mode_tree, p);
} }
...@@ -564,6 +568,16 @@ static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *bc) { ...@@ -564,6 +568,16 @@ static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *bc) {
} while (++i < VP9_YMODES - 1); } while (++i < VP9_YMODES - 1);
} }
#if CONFIG_SUPERBLOCKS
if (vp9_read_bit(bc)) {
int i = 0;
do {
cm->fc.sb_ymode_prob[i] = (vp9_prob) vp9_read_literal(bc, 8);
} while (++i < VP9_I32X32_MODES - 1);
}
#endif
#if CONFIG_NEW_MVREF #if CONFIG_NEW_MVREF
// Temp defaults probabilities for ecnoding the MV ref id signal // Temp defaults probabilities for ecnoding the MV ref id signal
vpx_memset(xd->mb_mv_ref_id_probs, 192, sizeof(xd->mb_mv_ref_id_probs)); vpx_memset(xd->mb_mv_ref_id_probs, 192, sizeof(xd->mb_mv_ref_id_probs));
...@@ -1106,11 +1120,16 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, ...@@ -1106,11 +1120,16 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
/* required for left and above block mv */ /* required for left and above block mv */
mbmi->mv[0].as_int = 0; mbmi->mv[0].as_int = 0;
if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) if (vp9_segfeature_active(xd, mbmi->segment_id, SEG_LVL_MODE)) {
mbmi->mode = (MB_PREDICTION_MODE) mbmi->mode = (MB_PREDICTION_MODE)
vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE); vp9_get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE);
else { #if CONFIG_SUPERBLOCKS
// FIXME write using SB mode tree } else if (mbmi->encoded_as_sb) {
mbmi->mode = (MB_PREDICTION_MODE)
read_sb_ymode(bc, pbi->common.fc.sb_ymode_prob);
pbi->common.fc.sb_ymode_counts[mbmi->mode]++;
#endif
} else {
mbmi->mode = (MB_PREDICTION_MODE) mbmi->mode = (MB_PREDICTION_MODE)
read_ymode(bc, pbi->common.fc.ymode_prob); read_ymode(bc, pbi->common.fc.ymode_prob);
pbi->common.fc.ymode_counts[mbmi->mode]++; pbi->common.fc.ymode_counts[mbmi->mode]++;
......
...@@ -1353,6 +1353,9 @@ int vp9_decode_frame(VP9D_COMP *pbi) { ...@@ -1353,6 +1353,9 @@ int vp9_decode_frame(VP9D_COMP *pbi) {
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16, vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16,
pbi->common.fc.hybrid_coef_probs_16x16); pbi->common.fc.hybrid_coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob); vp9_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
#if CONFIG_SUPERBLOCKS
vp9_copy(pbi->common.fc.pre_sb_ymode_prob, pbi->common.fc.sb_ymode_prob);
#endif
vp9_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob); vp9_copy(pbi->common.fc.pre_uv_mode_prob, pbi->common.fc.uv_mode_prob);
vp9_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob); vp9_copy(pbi->common.fc.pre_bmode_prob, pbi->common.fc.bmode_prob);
vp9_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob); vp9_copy(pbi->common.fc.pre_i8x8_mode_prob, pbi->common.fc.i8x8_mode_prob);
...@@ -1369,6 +1372,9 @@ int vp9_decode_frame(VP9D_COMP *pbi) { ...@@ -1369,6 +1372,9 @@ int vp9_decode_frame(VP9D_COMP *pbi) {
vp9_zero(pbi->common.fc.coef_counts_16x16); vp9_zero(pbi->common.fc.coef_counts_16x16);
vp9_zero(pbi->common.fc.hybrid_coef_counts_16x16); vp9_zero(pbi->common.fc.hybrid_coef_counts_16x16);
vp9_zero(pbi->common.fc.ymode_counts); vp9_zero(pbi->common.fc.ymode_counts);
#if CONFIG_SUPERBLOCKS
vp9_zero(pbi->common.fc.sb_ymode_counts);
#endif
vp9_zero(pbi->common.fc.uv_mode_counts); vp9_zero(pbi->common.fc.uv_mode_counts);
vp9_zero(pbi->common.fc.bmode_counts); vp9_zero(pbi->common.fc.bmode_counts);
vp9_zero(pbi->common.fc.i8x8_mode_counts); vp9_zero(pbi->common.fc.i8x8_mode_counts);
......
...@@ -164,6 +164,11 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi, ...@@ -164,6 +164,11 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi,
bc, VP9_YMODES, vp9_ymode_encodings, vp9_ymode_tree, bc, VP9_YMODES, vp9_ymode_encodings, vp9_ymode_tree,
Pnew, cm->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count Pnew, cm->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count
); );
#if CONFIG_SUPERBLOCKS
update_mode(bc, VP9_I32X32_MODES, vp9_sb_ymode_encodings,
vp9_sb_ymode_tree, Pnew, cm->fc.sb_ymode_prob, bct,
(unsigned int *)cpi->sb_ymode_count);
#endif
} }
} }
...@@ -172,11 +177,7 @@ static int get_prob(int num, int den) { ...@@ -172,11 +177,7 @@ static int get_prob(int num, int den) {
if (den <= 0) if (den <= 0)
return 128; return 128;
p = (num * 255 + (den >> 1)) / den; p = (num * 255 + (den >> 1)) / den;
if (p > 255) return clip_prob(p);
return 255;
else if (p < 1)
return 1;
return p;
} }
static int get_binary_prob(int n0, int n1) { static int get_binary_prob(int n0, int n1) {
...@@ -300,6 +301,10 @@ static void kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) { ...@@ -300,6 +301,10 @@ static void kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) {
} }
#if CONFIG_SUPERBLOCKS #if CONFIG_SUPERBLOCKS
static void write_sb_ymode(vp9_writer *bc, int m, const vp9_prob *p) {
write_token(bc, vp9_sb_ymode_tree, p, vp9_sb_ymode_encodings + m);
}
static void sb_kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) { static void sb_kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) {
write_token(bc, vp9_uv_mode_tree, p, vp9_sb_kf_ymode_encodings + m); write_token(bc, vp9_uv_mode_tree, p, vp9_sb_kf_ymode_encodings + m);
} }
...@@ -926,9 +931,12 @@ static void pack_inter_mode_mvs(VP9_COMP *const cpi, vp9_writer *const bc) { ...@@ -926,9 +931,12 @@ static void pack_inter_mode_mvs(VP9_COMP *const cpi, vp9_writer *const bc) {
active_section = 6; active_section = 6;
#endif #endif
// TODO(rbultje) write using SB tree structure
if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_MODE)) { if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
#if CONFIG_SUPERBLOCKS
if (m->mbmi.encoded_as_sb)
write_sb_ymode(bc, mode, pc->fc.sb_ymode_prob);
else
#endif
write_ymode(bc, mode, pc->fc.ymode_prob); write_ymode(bc, mode, pc->fc.ymode_prob);
} }
...@@ -2144,6 +2152,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, ...@@ -2144,6 +2152,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_8x8, cpi->common.fc.hybrid_coef_probs_8x8); vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_8x8, cpi->common.fc.hybrid_coef_probs_8x8);
vp9_copy(cpi->common.fc.pre_coef_probs_16x16, cpi->common.fc.coef_probs_16x16); vp9_copy(cpi->common.fc.pre_coef_probs_16x16, cpi->common.fc.coef_probs_16x16);
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_16x16, cpi->common.fc.hybrid_coef_probs_16x16); vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_16x16, cpi->common.fc.hybrid_coef_probs_16x16);
#if CONFIG_SUPERBLOCKS
vp9_copy(cpi->common.fc.pre_sb_ymode_prob, cpi->common.fc.sb_ymode_prob);
#endif
vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob); vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob); vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
vp9_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob); vp9_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob);
......
...@@ -2139,10 +2139,6 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2139,10 +2139,6 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
} }
} }
if (output_enabled && cm->frame_type == KEY_FRAME) {
sum_intra_stats(cpi, x);
}
if (!x->skip) { if (!x->skip) {
#ifdef ENC_DEBUG #ifdef ENC_DEBUG
if (enc_debug) { if (enc_debug) {
...@@ -2286,6 +2282,7 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2286,6 +2282,7 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x,
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) { if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME) {
vp9_build_intra_predictors_sby_s(&x->e_mbd); vp9_build_intra_predictors_sby_s(&x->e_mbd);
vp9_build_intra_predictors_sbuv_s(&x->e_mbd); vp9_build_intra_predictors_sbuv_s(&x->e_mbd);
sum_intra_stats(cpi, x);
} else { } else {
int ref_fb_idx; int ref_fb_idx;
...@@ -2376,10 +2373,6 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2376,10 +2373,6 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x,
} }
} }
if (cm->frame_type == KEY_FRAME) {
sum_intra_stats(cpi, x);
}
xd->mode_info_context = mi; xd->mode_info_context = mi;
update_sb_skip_coeff_state(cpi, x, ta, tl, tp, t, skip); update_sb_skip_coeff_state(cpi, x, ta, tl, tp, t, skip);
if (cm->txfm_mode == TX_MODE_SELECT && if (cm->txfm_mode == TX_MODE_SELECT &&
......
...@@ -32,6 +32,7 @@ void vp9_init_mode_costs(VP9_COMP *c) { ...@@ -32,6 +32,7 @@ void vp9_init_mode_costs(VP9_COMP *c) {
vp9_cost_tokens((int *)c->mb.inter_bmode_costs, vp9_cost_tokens((int *)c->mb.inter_bmode_costs,
x->fc.sub_mv_ref_prob[0], vp9_sub_mv_ref_tree); x->fc.sub_mv_ref_prob[0], vp9_sub_mv_ref_tree);
// TODO(rbultje) separate tables for superblock costing?
vp9_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp9_ymode_tree); vp9_cost_tokens(c->mb.mbmode_cost[1], x->fc.ymode_prob, vp9_ymode_tree);
vp9_cost_tokens(c->mb.mbmode_cost[0], vp9_cost_tokens(c->mb.mbmode_cost[0],
x->kf_ymode_prob[c->common.kf_ymode_probs_index], x->kf_ymode_prob[c->common.kf_ymode_probs_index],
......
...@@ -3725,6 +3725,9 @@ static void encode_frame_to_data_rate ...@@ -3725,6 +3725,9 @@ static void encode_frame_to_data_rate
cpi->hybrid_coef_counts_16x16); cpi->hybrid_coef_counts_16x16);
vp9_adapt_coef_probs(&cpi->common); vp9_adapt_coef_probs(&cpi->common);
if (cpi->common.frame_type != KEY_FRAME) { if (cpi->common.frame_type != KEY_FRAME) {
#if CONFIG_SUPERBLOCKS
vp9_copy(cpi->common.fc.sb_ymode_counts, cpi->sb_ymode_count);
#endif
vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count); vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
vp9_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count); vp9_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count); vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
......
...@@ -110,6 +110,9 @@ typedef struct { ...@@ -110,6 +110,9 @@ typedef struct {
vp9_prob hybrid_coef_probs_16x16[BLOCK_TYPES_16X16] vp9_prob hybrid_coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; [COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
#if CONFIG_SUPERBLOCKS
vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
#endif
vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1]; vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1]; vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1];
......
...@@ -139,6 +139,9 @@ void vp9_save_coding_context(VP9_COMP *cpi) { ...@@ -139,6 +139,9 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->mode_context_a, cm->fc.mode_context_a); vp9_copy(cc->mode_context_a, cm->fc.mode_context_a);
vp9_copy(cc->ymode_prob, cm->fc.ymode_prob); vp9_copy(cc->ymode_prob, cm->fc.ymode_prob);
#if CONFIG_SUPERBLOCKS
vp9_copy(cc->sb_ymode_prob, cm->fc.sb_ymode_prob);
#endif
vp9_copy(cc->bmode_prob, cm->fc.bmode_prob); vp9_copy(cc->bmode_prob, cm->fc.bmode_prob);
vp9_copy(cc->uv_mode_prob, cm->fc.uv_mode_prob); vp9_copy(cc->uv_mode_prob, cm->fc.uv_mode_prob);
vp9_copy(cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob); vp9_copy(cc->i8x8_mode_prob, cm->fc.i8x8_mode_prob);
...@@ -195,6 +198,9 @@ void vp9_restore_coding_context(VP9_COMP *cpi) { ...@@ -195,6 +198,9 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(cm->fc.mode_context_a, cc->mode_context_a); vp9_copy(cm->fc.mode_context_a, cc->mode_context_a);
vp9_copy(cm->fc.ymode_prob, cc->ymode_prob); vp9_copy(cm->fc.ymode_prob, cc->ymode_prob);
#if CONFIG_SUPERBLOCKS
vp9_copy(cm->fc.sb_ymode_prob, cc->sb_ymode_prob);
#endif
vp9_copy(cm->fc.bmode_prob, cc->bmode_prob); vp9_copy(cm->fc.bmode_prob, cc->bmode_prob);
vp9_copy(cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob); vp9_copy(cm->fc.i8x8_mode_prob, cc->i8x8_mode_prob);
vp9_copy(cm->fc.uv_mode_prob, cc->uv_mode_prob); vp9_copy(cm->fc.uv_mode_prob, cc->uv_mode_prob);
......
...@@ -4578,6 +4578,9 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -4578,6 +4578,9 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
int64_t best_intra16_rd = INT64_MAX;