Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: source/libvpx/vp9/encoder/vp9_bitstream.c

Issue 23600008: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_treereader.h ('k') | source/libvpx/vp9/encoder/vp9_block.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/encoder/vp9_bitstream.c
===================================================================
--- source/libvpx/vp9/encoder/vp9_bitstream.c (revision 219822)
+++ source/libvpx/vp9/encoder/vp9_bitstream.c (working copy)
@@ -41,21 +41,21 @@
#endif
#ifdef ENTROPY_STATS
-int intra_mode_stats[VP9_INTRA_MODES]
- [VP9_INTRA_MODES]
- [VP9_INTRA_MODES];
-vp9_coeff_stats tree_update_hist[TX_SIZE_MAX_SB][BLOCK_TYPES];
+int intra_mode_stats[INTRA_MODES]
+ [INTRA_MODES]
+ [INTRA_MODES];
+vp9_coeff_stats tree_update_hist[TX_SIZES][BLOCK_TYPES];
extern unsigned int active_section;
#endif
#ifdef MODE_STATS
-int64_t tx_count_32x32p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB];
-int64_t tx_count_16x16p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 1];
-int64_t tx_count_8x8p_stats[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB - 2];
-int64_t switchable_interp_stats[VP9_SWITCHABLE_FILTERS+1]
- [VP9_SWITCHABLE_FILTERS];
+int64_t tx_count_32x32p_stats[TX_SIZE_CONTEXTS][TX_SIZES];
+int64_t tx_count_16x16p_stats[TX_SIZE_CONTEXTS][TX_SIZES - 1];
+int64_t tx_count_8x8p_stats[TX_SIZE_CONTEXTS][TX_SIZES - 2];
+int64_t switchable_interp_stats[SWITCHABLE_FILTERS+1]
+ [SWITCHABLE_FILTERS];
void init_tx_count_stats() {
vp9_zero(tx_count_32x32p_stats);
@@ -70,17 +70,17 @@
static void update_tx_count_stats(VP9_COMMON *cm) {
int i, j;
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
- for (j = 0; j < TX_SIZE_MAX_SB; j++) {
+ for (j = 0; j < TX_SIZES; j++) {
tx_count_32x32p_stats[i][j] += cm->fc.tx_count_32x32p[i][j];
}
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
- for (j = 0; j < TX_SIZE_MAX_SB - 1; j++) {
+ for (j = 0; j < TX_SIZES - 1; j++) {
tx_count_16x16p_stats[i][j] += cm->fc.tx_count_16x16p[i][j];
}
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
- for (j = 0; j < TX_SIZE_MAX_SB - 2; j++) {
+ for (j = 0; j < TX_SIZES - 2; j++) {
tx_count_8x8p_stats[i][j] += cm->fc.tx_count_8x8p[i][j];
}
}
@@ -88,8 +88,8 @@
static void update_switchable_interp_stats(VP9_COMMON *cm) {
int i, j;
- for (i = 0; i < VP9_SWITCHABLE_FILTERS+1; ++i)
- for (j = 0; j < VP9_SWITCHABLE_FILTERS; ++j) {
+ for (i = 0; i < SWITCHABLE_FILTERS+1; ++i)
+ for (j = 0; j < SWITCHABLE_FILTERS; ++j) {
switchable_interp_stats[i][j] += cm->fc.switchable_interp_count[i][j];
}
}
@@ -103,30 +103,30 @@
fclose(fp);
printf(
- "vp9_default_tx_count_32x32p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB] = {\n");
+ "vp9_default_tx_count_32x32p[TX_SIZE_CONTEXTS][TX_SIZES] = {\n");
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
printf(" { ");
- for (j = 0; j < TX_SIZE_MAX_SB; j++) {
+ for (j = 0; j < TX_SIZES; j++) {
printf("%"PRId64", ", tx_count_32x32p_stats[i][j]);
}
printf("},\n");
}
printf("};\n");
printf(
- "vp9_default_tx_count_16x16p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB-1] = {\n");
+ "vp9_default_tx_count_16x16p[TX_SIZE_CONTEXTS][TX_SIZES-1] = {\n");
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
printf(" { ");
- for (j = 0; j < TX_SIZE_MAX_SB - 1; j++) {
+ for (j = 0; j < TX_SIZES - 1; j++) {
printf("%"PRId64", ", tx_count_16x16p_stats[i][j]);
}
printf("},\n");
}
printf("};\n");
printf(
- "vp9_default_tx_count_8x8p[TX_SIZE_CONTEXTS][TX_SIZE_MAX_SB-2] = {\n");
+ "vp9_default_tx_count_8x8p[TX_SIZE_CONTEXTS][TX_SIZES-2] = {\n");
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
printf(" { ");
- for (j = 0; j < TX_SIZE_MAX_SB - 2; j++) {
+ for (j = 0; j < TX_SIZES - 2; j++) {
printf("%"PRId64", ", tx_count_8x8p_stats[i][j]);
}
printf("},\n");
@@ -141,11 +141,11 @@
fclose(fp);
printf(
- "vp9_default_switchable_filter_count[VP9_SWITCHABLE_FILTERS+1]"
- "[VP9_SWITCHABLE_FILTERS] = {\n");
- for (i = 0; i < VP9_SWITCHABLE_FILTERS+1; i++) {
+ "vp9_default_switchable_filter_count[SWITCHABLE_FILTERS+1]"
+ "[SWITCHABLE_FILTERS] = {\n");
+ for (i = 0; i < SWITCHABLE_FILTERS+1; i++) {
printf(" { ");
- for (j = 0; j < VP9_SWITCHABLE_FILTERS; j++) {
+ for (j = 0; j < SWITCHABLE_FILTERS; j++) {
printf("%"PRId64", ", switchable_interp_stats[i][j]);
}
printf("},\n");
@@ -169,7 +169,6 @@
static void update_mode(
vp9_writer *w,
int n,
- const struct vp9_token tok[/* n */],
vp9_tree tree,
vp9_prob Pnew[/* n-1 */],
vp9_prob Pcur[/* n-1 */],
@@ -182,7 +181,7 @@
n--;
for (i = 0; i < n; ++i) {
- vp9_cond_prob_diff_update(w, &Pcur[i], VP9_MODE_UPDATE_PROB, bct[i]);
+ vp9_cond_prob_diff_update(w, &Pcur[i], MODE_UPDATE_PROB, bct[i]);
}
}
@@ -190,24 +189,23 @@
vp9_writer* const bc) {
VP9_COMMON *const cm = &cpi->common;
int j;
- vp9_prob pnew[VP9_INTRA_MODES - 1];
- unsigned int bct[VP9_INTRA_MODES - 1][2];
+ vp9_prob pnew[INTRA_MODES - 1];
+ unsigned int bct[INTRA_MODES - 1][2];
for (j = 0; j < BLOCK_SIZE_GROUPS; j++)
- update_mode(bc, VP9_INTRA_MODES, vp9_intra_mode_encodings,
- vp9_intra_mode_tree, pnew,
+ update_mode(bc, INTRA_MODES, vp9_intra_mode_tree, pnew,
cm->fc.y_mode_prob[j], bct,
(unsigned int *)cpi->y_mode_count[j]);
}
-static void write_selected_txfm_size(const VP9_COMP *cpi, TX_SIZE tx_size,
- BLOCK_SIZE_TYPE bsize, vp9_writer *w) {
+static void write_selected_tx_size(const VP9_COMP *cpi, TX_SIZE tx_size,
+ BLOCK_SIZE bsize, vp9_writer *w) {
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs);
vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
- if (bsize >= BLOCK_SIZE_MB16X16 && tx_size != TX_4X4) {
+ if (bsize >= BLOCK_16X16 && tx_size != TX_4X4) {
vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
- if (bsize >= BLOCK_SIZE_SB32X32 && tx_size != TX_8X8)
+ if (bsize >= BLOCK_32X32 && tx_size != TX_8X8)
vp9_write(w, tx_size != TX_16X16, tx_probs[2]);
}
}
@@ -215,10 +213,10 @@
static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
vp9_writer *w) {
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) {
+ if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
- const int skip_coeff = m->mbmi.mb_skip_coeff;
+ const int skip_coeff = m->mbmi.skip_coeff;
vp9_write(w, skip_coeff, vp9_get_pred_prob_mbskip(&cpi->common, xd));
return skip_coeff;
}
@@ -230,7 +228,7 @@
for (k = 0; k < MBSKIP_CONTEXTS; ++k)
vp9_cond_prob_diff_update(w, &cm->fc.mbskip_probs[k],
- VP9_MODE_UPDATE_PROB, cm->counts.mbskip[k]);
+ MODE_UPDATE_PROB, cm->counts.mbskip[k]);
}
static void write_intra_mode(vp9_writer *bc, int m, const vp9_prob *p) {
@@ -240,20 +238,20 @@
static void update_switchable_interp_probs(VP9_COMP *const cpi,
vp9_writer* const bc) {
VP9_COMMON *const pc = &cpi->common;
- unsigned int branch_ct[VP9_SWITCHABLE_FILTERS + 1]
- [VP9_SWITCHABLE_FILTERS - 1][2];
- vp9_prob new_prob[VP9_SWITCHABLE_FILTERS + 1][VP9_SWITCHABLE_FILTERS - 1];
+ unsigned int branch_ct[SWITCHABLE_FILTERS + 1]
+ [SWITCHABLE_FILTERS - 1][2];
+ vp9_prob new_prob[SWITCHABLE_FILTERS + 1][SWITCHABLE_FILTERS - 1];
int i, j;
- for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j) {
+ for (j = 0; j <= SWITCHABLE_FILTERS; ++j) {
vp9_tree_probs_from_distribution(
vp9_switchable_interp_tree,
new_prob[j], branch_ct[j],
pc->counts.switchable_interp[j], 0);
}
- for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j) {
- for (i = 0; i < VP9_SWITCHABLE_FILTERS - 1; ++i) {
+ for (j = 0; j <= SWITCHABLE_FILTERS; ++j) {
+ for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i) {
vp9_cond_prob_diff_update(bc, &pc->fc.switchable_interp_prob[j][i],
- VP9_MODE_UPDATE_PROB, branch_ct[j][i]);
+ MODE_UPDATE_PROB, branch_ct[j][i]);
}
}
#ifdef MODE_STATS
@@ -265,12 +263,17 @@
static void update_inter_mode_probs(VP9_COMMON *pc, vp9_writer* const bc) {
int i, j;
- for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
- for (j = 0; j < VP9_INTER_MODES - 1; j++) {
+ for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
+ unsigned int branch_ct[INTER_MODES - 1][2];
+ vp9_prob new_prob[INTER_MODES - 1];
+
+ vp9_tree_probs_from_distribution(vp9_inter_mode_tree,
+ new_prob, branch_ct,
+ pc->counts.inter_mode[i], NEARESTMV);
+
+ for (j = 0; j < INTER_MODES - 1; ++j)
vp9_cond_prob_diff_update(bc, &pc->fc.inter_mode_probs[i][j],
- VP9_MODE_UPDATE_PROB,
- pc->counts.inter_mode[i][j]);
- }
+ MODE_UPDATE_PROB, branch_ct[j]);
}
}
@@ -358,7 +361,7 @@
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mi = &xd->mode_info_context->mbmi;
const int segment_id = mi->segment_id;
- int seg_ref_active = vp9_segfeature_active(&xd->seg, segment_id,
+ int seg_ref_active = vp9_segfeature_active(&pc->seg, segment_id,
SEG_LVL_REF_FRAME);
// If segment level coding of this signal is disabled...
// or the segment allows multiple reference frame options
@@ -385,7 +388,7 @@
}
} else {
assert(mi->ref_frame[1] <= INTRA_FRAME);
- assert(vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) ==
+ assert(vp9_get_segdata(&pc->seg, segment_id, SEG_LVL_REF_FRAME) ==
mi->ref_frame[0]);
}
@@ -393,19 +396,19 @@
// the reference frame is fully coded by the segment
}
-static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
- vp9_writer *bc, int mi_row, int mi_col) {
+static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
VP9_COMMON *const pc = &cpi->common;
const nmv_context *nmvc = &pc->fc.nmvc;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- struct segmentation *seg = &xd->seg;
+ struct segmentation *seg = &pc->seg;
MB_MODE_INFO *const mi = &m->mbmi;
const MV_REFERENCE_FRAME rf = mi->ref_frame[0];
const MB_PREDICTION_MODE mode = mi->mode;
const int segment_id = mi->segment_id;
int skip_coeff;
- const BLOCK_SIZE_TYPE bsize = mi->sb_type;
+ const BLOCK_SIZE bsize = mi->sb_type;
+ const int allow_hp = xd->allow_high_precision_mv;
x->partition_info = x->pi + (m - pc->mi);
@@ -416,7 +419,7 @@
if (seg->update_map) {
if (seg->temporal_update) {
const int pred_flag = mi->seg_id_predicted;
- vp9_prob pred_prob = vp9_get_pred_prob_seg_id(xd);
+ vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
vp9_write(bc, pred_flag, pred_prob);
if (!pred_flag)
write_segment_id(bc, seg, segment_id);
@@ -431,10 +434,10 @@
vp9_write(bc, rf != INTRA_FRAME,
vp9_get_pred_prob_intra_inter(pc, xd));
- if (bsize >= BLOCK_SIZE_SB8X8 && pc->tx_mode == TX_MODE_SELECT &&
+ if (bsize >= BLOCK_8X8 && pc->tx_mode == TX_MODE_SELECT &&
!(rf != INTRA_FRAME &&
(skip_coeff || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) {
- write_selected_txfm_size(cpi, mi->txfm_size, bsize, bc);
+ write_selected_tx_size(cpi, mi->txfm_size, bsize, bc);
}
if (rf == INTRA_FRAME) {
@@ -442,25 +445,24 @@
active_section = 6;
#endif
- if (bsize >= BLOCK_SIZE_SB8X8) {
- const int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize);
- const int bsl = MIN(bwl, bhl);
- write_intra_mode(bc, mode, pc->fc.y_mode_prob[MIN(3, bsl)]);
+ if (bsize >= BLOCK_8X8) {
+ write_intra_mode(bc, mode, pc->fc.y_mode_prob[size_group_lookup[bsize]]);
} else {
int idx, idy;
- int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
- int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
- for (idy = 0; idy < 2; idy += num_4x4_blocks_high)
+ const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
+ const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
+ for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
const MB_PREDICTION_MODE bm = m->bmi[idy * 2 + idx].as_mode;
write_intra_mode(bc, bm, pc->fc.y_mode_prob[0]);
}
+ }
}
write_intra_mode(bc, mi->uv_mode, pc->fc.uv_mode_prob[mode]);
} else {
vp9_prob *mv_ref_p;
encode_ref_frame(cpi, bc);
- mv_ref_p = cpi->common.fc.inter_mode_probs[mi->mb_mode_context[rf]];
+ mv_ref_p = cpi->common.fc.inter_mode_probs[mi->mode_context[rf]];
#ifdef ENTROPY_STATS
active_section = 3;
@@ -468,27 +470,28 @@
// If segment skip is not enabled code the mode.
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
- if (bsize >= BLOCK_SIZE_SB8X8) {
+ if (bsize >= BLOCK_8X8) {
write_sb_mv_ref(bc, mode, mv_ref_p);
- vp9_accum_mv_refs(&cpi->common, mode, mi->mb_mode_context[rf]);
+ ++pc->counts.inter_mode[mi->mode_context[rf]]
+ [inter_mode_offset(mode)];
}
}
- if (cpi->common.mcomp_filter_type == SWITCHABLE) {
+ if (pc->mcomp_filter_type == SWITCHABLE) {
+ const int ctx = vp9_get_pred_context_switchable_interp(xd);
write_token(bc, vp9_switchable_interp_tree,
- vp9_get_pred_probs_switchable_interp(&cpi->common, xd),
- vp9_switchable_interp_encodings +
- vp9_switchable_interp_map[mi->interp_filter]);
+ pc->fc.switchable_interp_prob[ctx],
+ &vp9_switchable_interp_encodings[mi->interp_filter]);
} else {
- assert(mi->interp_filter == cpi->common.mcomp_filter_type);
+ assert(mi->interp_filter == pc->mcomp_filter_type);
}
- if (bsize < BLOCK_SIZE_SB8X8) {
+ if (bsize < BLOCK_8X8) {
int j;
MB_PREDICTION_MODE blockmode;
int_mv blockmv;
- int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
- int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
+ const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
+ const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
int idx, idy;
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
@@ -496,19 +499,21 @@
blockmode = x->partition_info->bmi[j].mode;
blockmv = m->bmi[j].as_mv[0];
write_sb_mv_ref(bc, blockmode, mv_ref_p);
- vp9_accum_mv_refs(&cpi->common, blockmode, mi->mb_mode_context[rf]);
+ ++pc->counts.inter_mode[mi->mode_context[rf]]
+ [inter_mode_offset(blockmode)];
+
if (blockmode == NEWMV) {
#ifdef ENTROPY_STATS
active_section = 11;
#endif
vp9_encode_mv(cpi, bc, &blockmv.as_mv, &mi->best_mv.as_mv,
- nmvc, xd->allow_high_precision_mv);
+ nmvc, allow_hp);
if (mi->ref_frame[1] > INTRA_FRAME)
vp9_encode_mv(cpi, bc,
&m->bmi[j].as_mv[1].as_mv,
&mi->best_second_mv.as_mv,
- nmvc, xd->allow_high_precision_mv);
+ nmvc, allow_hp);
}
}
}
@@ -516,47 +521,45 @@
#ifdef ENTROPY_STATS
active_section = 5;
#endif
- vp9_encode_mv(cpi, bc,
- &mi->mv[0].as_mv, &mi->best_mv.as_mv,
- nmvc, xd->allow_high_precision_mv);
+ vp9_encode_mv(cpi, bc, &mi->mv[0].as_mv, &mi->best_mv.as_mv,
+ nmvc, allow_hp);
if (mi->ref_frame[1] > INTRA_FRAME)
- vp9_encode_mv(cpi, bc,
- &mi->mv[1].as_mv, &mi->best_second_mv.as_mv,
- nmvc, xd->allow_high_precision_mv);
+ vp9_encode_mv(cpi, bc, &mi->mv[1].as_mv, &mi->best_second_mv.as_mv,
+ nmvc, allow_hp);
}
}
}
-static void write_mb_modes_kf(const VP9_COMP *cpi,
- MODE_INFO *m,
- vp9_writer *bc, int mi_row, int mi_col) {
+static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO *m,
+ vp9_writer *bc) {
const VP9_COMMON *const c = &cpi->common;
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
+ const struct segmentation *const seg = &c->seg;
const int ym = m->mbmi.mode;
const int mis = c->mode_info_stride;
const int segment_id = m->mbmi.segment_id;
- if (xd->seg.update_map)
- write_segment_id(bc, &xd->seg, m->mbmi.segment_id);
+ if (seg->update_map)
+ write_segment_id(bc, seg, m->mbmi.segment_id);
write_skip_coeff(cpi, segment_id, m, bc);
- if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8 && c->tx_mode == TX_MODE_SELECT)
- write_selected_txfm_size(cpi, m->mbmi.txfm_size, m->mbmi.sb_type, bc);
+ if (m->mbmi.sb_type >= BLOCK_8X8 && c->tx_mode == TX_MODE_SELECT)
+ write_selected_tx_size(cpi, m->mbmi.txfm_size, m->mbmi.sb_type, bc);
- if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
+ if (m->mbmi.sb_type >= BLOCK_8X8) {
const MB_PREDICTION_MODE A = above_block_mode(m, 0, mis);
const MB_PREDICTION_MODE L = xd->left_available ?
left_block_mode(m, 0) : DC_PRED;
write_intra_mode(bc, ym, vp9_kf_y_mode_prob[A][L]);
} else {
int idx, idy;
- int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[m->mbmi.sb_type];
- int num_4x4_blocks_high = num_4x4_blocks_high_lookup[m->mbmi.sb_type];
+ const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[m->mbmi.sb_type];
+ const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[m->mbmi.sb_type];
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
- int i = idy * 2 + idx;
+ const int i = idy * 2 + idx;
const MB_PREDICTION_MODE A = above_block_mode(m, i, mis);
const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
left_block_mode(m, i) : DC_PRED;
@@ -578,7 +581,7 @@
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- if (m->mbmi.sb_type < BLOCK_SIZE_SB8X8)
+ if (m->mbmi.sb_type < BLOCK_8X8)
if (xd->ab_index > 0)
return;
xd->mode_info_context = m;
@@ -586,12 +589,12 @@
1 << mi_height_log2(m->mbmi.sb_type),
mi_col, 1 << mi_width_log2(m->mbmi.sb_type));
if ((cm->frame_type == KEY_FRAME) || cm->intra_only) {
- write_mb_modes_kf(cpi, m, bc, mi_row, mi_col);
+ write_mb_modes_kf(cpi, m, bc);
#ifdef ENTROPY_STATS
active_section = 8;
#endif
} else {
- pack_inter_mode_mvs(cpi, m, bc, mi_row, mi_col);
+ pack_inter_mode_mvs(cpi, m, bc);
#ifdef ENTROPY_STATS
active_section = 1;
#endif
@@ -603,8 +606,7 @@
static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
TOKENEXTRA **tok, TOKENEXTRA *tok_end,
- int mi_row, int mi_col,
- BLOCK_SIZE_TYPE bsize) {
+ int mi_row, int mi_col, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
const int mis = cm->mode_info_stride;
@@ -612,20 +614,21 @@
int bs = (1 << bsl) / 4; // mode_info step for subsize
int n;
PARTITION_TYPE partition = PARTITION_NONE;
- BLOCK_SIZE_TYPE subsize;
+ BLOCK_SIZE subsize;
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
partition = partition_lookup[bsl][m->mbmi.sb_type];
- if (bsize < BLOCK_SIZE_SB8X8)
+ if (bsize < BLOCK_8X8)
if (xd->ab_index > 0)
return;
- if (bsize >= BLOCK_SIZE_SB8X8) {
+ if (bsize >= BLOCK_8X8) {
int pl;
- const int idx = check_bsize_coverage(cm, xd, mi_row, mi_col, bsize);
+ const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
+ mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
pl = partition_plane_context(xd, bsize);
// encode the partition information
@@ -670,8 +673,8 @@
}
// update partition context
- if (bsize >= BLOCK_SIZE_SB8X8 &&
- (bsize == BLOCK_SIZE_SB8X8 || partition != PARTITION_SPLIT)) {
+ if (bsize >= BLOCK_8X8 &&
+ (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) {
set_partition_seg_context(cm, xd, mi_row, mi_col);
update_partition_context(xd, subsize, bsize);
}
@@ -692,8 +695,7 @@
vp9_zero(c->left_seg_context);
for (mi_col = c->cur_tile_mi_col_start; mi_col < c->cur_tile_mi_col_end;
mi_col += MI_BLOCK_SIZE, m += MI_BLOCK_SIZE)
- write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col,
- BLOCK_SIZE_SB64X64);
+ write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col, BLOCK_64X64);
}
}
@@ -726,12 +728,12 @@
fclose(f);
}
-static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE txfm_size) {
- vp9_coeff_probs_model *coef_probs = cpi->frame_coef_probs[txfm_size];
- vp9_coeff_count *coef_counts = cpi->coef_counts[txfm_size];
+static void build_tree_distribution(VP9_COMP *cpi, TX_SIZE tx_size) {
+ vp9_coeff_probs_model *coef_probs = cpi->frame_coef_probs[tx_size];
+ vp9_coeff_count *coef_counts = cpi->coef_counts[tx_size];
unsigned int (*eob_branch_ct)[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS] =
- cpi->common.counts.eob_branch[txfm_size];
- vp9_coeff_stats *coef_branch_ct = cpi->frame_branch_ct[txfm_size];
+ cpi->common.counts.eob_branch[tx_size];
+ vp9_coeff_stats *coef_branch_ct = cpi->frame_branch_ct[tx_size];
vp9_prob full_probs[ENTROPY_NODES];
int i, j, k, l;
@@ -756,9 +758,9 @@
if (!cpi->dummy_packing) {
int t;
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
- context_counters[txfm_size][i][j][k][l][t] +=
+ context_counters[tx_size][i][j][k][l][t] +=
coef_counts[i][j][k][l][t];
- context_counters[txfm_size][i][j][k][l][MAX_ENTROPY_TOKENS] +=
+ context_counters[tx_size][i][j][k][l][MAX_ENTROPY_TOKENS] +=
eob_branch_ct[i][j][k][l];
}
#endif
@@ -966,7 +968,7 @@
struct vp9_write_bit_buffer *wb) {
int i, j;
- struct segmentation *seg = &cpi->mb.e_mbd.seg;
+ struct segmentation *seg = &cpi->common.seg;
vp9_wb_write_bit(wb, seg->enabled);
if (!seg->enabled)
@@ -1036,32 +1038,32 @@
// Probabilities
if (cm->tx_mode == TX_MODE_SELECT) {
int i, j;
- unsigned int ct_8x8p[TX_SIZE_MAX_SB - 3][2];
- unsigned int ct_16x16p[TX_SIZE_MAX_SB - 2][2];
- unsigned int ct_32x32p[TX_SIZE_MAX_SB - 1][2];
+ unsigned int ct_8x8p[TX_SIZES - 3][2];
+ unsigned int ct_16x16p[TX_SIZES - 2][2];
+ unsigned int ct_32x32p[TX_SIZES - 1][2];
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_8x8(cm->counts.tx.p8x8[i],
ct_8x8p);
- for (j = 0; j < TX_SIZE_MAX_SB - 3; j++)
+ for (j = 0; j < TX_SIZES - 3; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p8x8[i][j],
- VP9_MODE_UPDATE_PROB, ct_8x8p[j]);
+ MODE_UPDATE_PROB, ct_8x8p[j]);
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_16x16(cm->counts.tx.p16x16[i],
ct_16x16p);
- for (j = 0; j < TX_SIZE_MAX_SB - 2; j++)
+ for (j = 0; j < TX_SIZES - 2; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p16x16[i][j],
- VP9_MODE_UPDATE_PROB, ct_16x16p[j]);
+ MODE_UPDATE_PROB, ct_16x16p[j]);
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
tx_counts_to_branch_counts_32x32(cm->counts.tx.p32x32[i], ct_32x32p);
- for (j = 0; j < TX_SIZE_MAX_SB - 1; j++)
+ for (j = 0; j < TX_SIZES - 1; j++)
vp9_cond_prob_diff_update(w, &cm->fc.tx_probs.p32x32[i][j],
- VP9_MODE_UPDATE_PROB, ct_32x32p[j]);
+ MODE_UPDATE_PROB, ct_32x32p[j]);
}
#ifdef MODE_STATS
if (!cpi->dummy_packing)
@@ -1072,9 +1074,11 @@
static void write_interp_filter_type(INTERPOLATIONFILTERTYPE type,
struct vp9_write_bit_buffer *wb) {
+ const int type_to_literal[] = { 1, 0, 2 };
+
vp9_wb_write_bit(wb, type == SWITCHABLE);
if (type != SWITCHABLE)
- vp9_wb_write_literal(wb, type, 2);
+ vp9_wb_write_literal(wb, type_to_literal[type], 2);
}
static void fix_mcomp_filter_type(VP9_COMP *cpi) {
@@ -1082,19 +1086,19 @@
if (cm->mcomp_filter_type == SWITCHABLE) {
// Check to see if only one of the filters is actually used
- int count[VP9_SWITCHABLE_FILTERS];
+ int count[SWITCHABLE_FILTERS];
int i, j, c = 0;
- for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
+ for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
count[i] = 0;
- for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j)
+ for (j = 0; j <= SWITCHABLE_FILTERS; ++j)
count[i] += cm->counts.switchable_interp[j][i];
c += (count[i] > 0);
}
if (c == 1) {
// Only one filter is used. So set the filter at frame level
- for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
+ for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
if (count[i]) {
- cm->mcomp_filter_type = vp9_switchable_interp[i];
+ cm->mcomp_filter_type = i;
break;
}
}
@@ -1339,7 +1343,7 @@
vp9_wb_write_literal(wb, cm->frame_context_idx, NUM_FRAME_CONTEXTS_LOG2);
- encode_loopfilter(&xd->lf, wb);
+ encode_loopfilter(&cm->lf, wb);
encode_quantization(cm, wb);
encode_segmentation(cpi, wb);
@@ -1381,7 +1385,7 @@
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
vp9_cond_prob_diff_update(&header_bc, &fc->intra_inter_prob[i],
- VP9_MODE_UPDATE_PROB,
+ MODE_UPDATE_PROB,
cpi->intra_inter_count[i]);
if (cm->allow_comp_inter_inter) {
@@ -1395,7 +1399,7 @@
if (use_hybrid_pred)
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
vp9_cond_prob_diff_update(&header_bc, &fc->comp_inter_prob[i],
- VP9_MODE_UPDATE_PROB,
+ MODE_UPDATE_PROB,
cpi->comp_inter_count[i]);
}
}
@@ -1403,10 +1407,10 @@
if (cm->comp_pred_mode != COMP_PREDICTION_ONLY) {
for (i = 0; i < REF_CONTEXTS; i++) {
vp9_cond_prob_diff_update(&header_bc, &fc->single_ref_prob[i][0],
- VP9_MODE_UPDATE_PROB,
+ MODE_UPDATE_PROB,
cpi->single_ref_count[i][0]);
vp9_cond_prob_diff_update(&header_bc, &fc->single_ref_prob[i][1],
- VP9_MODE_UPDATE_PROB,
+ MODE_UPDATE_PROB,
cpi->single_ref_count[i][1]);
}
}
@@ -1414,7 +1418,7 @@
if (cm->comp_pred_mode != SINGLE_PREDICTION_ONLY)
for (i = 0; i < REF_CONTEXTS; i++)
vp9_cond_prob_diff_update(&header_bc, &fc->comp_ref_prob[i],
- VP9_MODE_UPDATE_PROB,
+ MODE_UPDATE_PROB,
cpi->comp_ref_count[i]);
update_mbintra_mode_probs(cpi, &header_bc);
@@ -1422,7 +1426,7 @@
for (i = 0; i < NUM_PARTITION_CONTEXTS; ++i) {
vp9_prob pnew[PARTITION_TYPES - 1];
unsigned int bct[PARTITION_TYPES - 1][2];
- update_mode(&header_bc, PARTITION_TYPES, vp9_partition_encodings,
+ update_mode(&header_bc, PARTITION_TYPES,
vp9_partition_tree, pnew,
fc->partition_prob[cm->frame_type][i], bct,
(unsigned int *)cpi->partition_count[i]);
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_treereader.h ('k') | source/libvpx/vp9/encoder/vp9_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698