ref: c53a9c70fbf766107501e7b981f047d4bd2ae8b7
parent: f6baa62cd8aa861f7370bb782624bd76615f2f86
parent: 815189613bcf61aebe808047f5a35f14d25c4f69
author: Dmitry Kovalev <[email protected]>
date: Mon Nov 11 06:12:06 EST 2013
Merge "Localizing NEARESTMV special cases in the code."
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -82,9 +82,8 @@
#define INTER_MODES (1 + NEWMV - NEARESTMV)
-static INLINE int inter_mode_offset(MB_PREDICTION_MODE mode) {
- return (mode - NEARESTMV);
-}
+#define INTER_OFFSET(mode) ((mode) - NEARESTMV)
+
/* For keyframes, intra block modes are predicted by the (already decoded)
modes for the Y blocks to the left and above us; for interframes, there
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -332,7 +332,7 @@
if (l >= 3 && k == 0)
continue;
vp9_tree_probs_from_distribution(vp9_coefmodel_tree, branch_ct,
- coef_counts[i][j][k][l], 0);
+ coef_counts[i][j][k][l]);
branch_ct[0][1] = eob_branch_count[i][j][k][l] - branch_ct[0][0];
for (m = 0; m < UNCONSTRAINED_NODES; ++m)
dst_coef_probs[i][j][k][l][m] = merge_probs(
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -235,9 +235,9 @@
struct vp9_token vp9_intra_mode_encodings[INTRA_MODES];
const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)] = {
- -ZEROMV, 2,
- -NEARESTMV, 4,
- -NEARMV, -NEWMV
+ -INTER_OFFSET(ZEROMV), 2,
+ -INTER_OFFSET(NEARESTMV), 4,
+ -INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV)
};
struct vp9_token vp9_inter_mode_encodings[INTER_MODES];
@@ -343,8 +343,7 @@
vp9_tokens_from_tree(vp9_switchable_interp_encodings,
vp9_switchable_interp_tree);
vp9_tokens_from_tree(vp9_partition_encodings, vp9_partition_tree);
- vp9_tokens_from_tree_offset(vp9_inter_mode_encodings,
- vp9_inter_mode_tree, NEARESTMV);
+ vp9_tokens_from_tree(vp9_inter_mode_encodings, vp9_inter_mode_tree);
}
#define COUNT_SAT 20
@@ -356,9 +355,9 @@
static void adapt_probs(const vp9_tree_index *tree,
const vp9_prob *pre_probs, const unsigned int *counts,
- unsigned int offset, vp9_prob *probs) {
- tree_merge_probs(tree, pre_probs, counts, offset,
- COUNT_SAT, MAX_UPDATE_FACTOR, probs);
+ vp9_prob *probs) {
+ tree_merge_probs(tree, pre_probs, counts, COUNT_SAT, MAX_UPDATE_FACTOR,
+ probs);
}
void vp9_adapt_mode_probs(VP9_COMMON *cm) {
@@ -383,25 +382,24 @@
for (i = 0; i < INTER_MODE_CONTEXTS; i++)
adapt_probs(vp9_inter_mode_tree, pre_fc->inter_mode_probs[i],
- counts->inter_mode[i], NEARESTMV, fc->inter_mode_probs[i]);
+ counts->inter_mode[i], fc->inter_mode_probs[i]);
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
adapt_probs(vp9_intra_mode_tree, pre_fc->y_mode_prob[i],
- counts->y_mode[i], 0, fc->y_mode_prob[i]);
+ counts->y_mode[i], fc->y_mode_prob[i]);
for (i = 0; i < INTRA_MODES; ++i)
adapt_probs(vp9_intra_mode_tree, pre_fc->uv_mode_prob[i],
- counts->uv_mode[i], 0, fc->uv_mode_prob[i]);
+ counts->uv_mode[i], fc->uv_mode_prob[i]);
for (i = 0; i < PARTITION_CONTEXTS; i++)
adapt_probs(vp9_partition_tree, pre_fc->partition_prob[i],
- counts->partition[i], 0, fc->partition_prob[i]);
+ counts->partition[i], fc->partition_prob[i]);
if (cm->mcomp_filter_type == SWITCHABLE) {
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++)
adapt_probs(vp9_switchable_interp_tree, pre_fc->switchable_interp_prob[i],
- counts->switchable_interp[i], 0,
- fc->switchable_interp_prob[i]);
+ counts->switchable_interp[i], fc->switchable_interp_prob[i]);
}
if (cm->tx_mode == TX_MODE_SELECT) {
--- a/vp9/common/vp9_entropymv.c
+++ b/vp9/common/vp9_entropymv.c
@@ -196,8 +196,8 @@
static void adapt_probs(const vp9_tree_index *tree, const vp9_prob *pre_probs,
const unsigned int *counts, vp9_prob *probs) {
- tree_merge_probs(tree, pre_probs, counts, 0,
- MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR, probs);
+ tree_merge_probs(tree, pre_probs, counts, MV_COUNT_SAT, MV_MAX_UPDATE_FACTOR,
+ probs);
}
void vp9_adapt_mv_probs(VP9_COMMON *cm, int allow_hp) {
@@ -207,8 +207,7 @@
const nmv_context *pre_fc = &cm->frame_contexts[cm->frame_context_idx].nmvc;
const nmv_context_counts *counts = &cm->counts.mv;
- adapt_probs(vp9_mv_joint_tree, pre_fc->joints, counts->joints,
- fc->joints);
+ adapt_probs(vp9_mv_joint_tree, pre_fc->joints, counts->joints, fc->joints);
for (i = 0; i < 2; ++i) {
nmv_component *comp = &fc->comps[i];
--- a/vp9/common/vp9_treecoder.c
+++ b/vp9/common/vp9_treecoder.c
@@ -35,28 +35,20 @@
tree2tok(p, t, 0, 0, 0);
}
-void vp9_tokens_from_tree_offset(struct vp9_token *p, vp9_tree t,
- int offset) {
- tree2tok(p - offset, t, 0, 0, 0);
-}
-
static unsigned int convert_distribution(unsigned int i, vp9_tree tree,
unsigned int branch_ct[][2],
- const unsigned int num_events[],
- unsigned int tok0_offset) {
+ const unsigned int num_events[]) {
unsigned int left, right;
- if (tree[i] <= 0) {
- left = num_events[-tree[i] - tok0_offset];
- } else {
- left = convert_distribution(tree[i], tree, branch_ct, num_events,
- tok0_offset);
- }
+ if (tree[i] <= 0)
+ left = num_events[-tree[i]];
+ else
+ left = convert_distribution(tree[i], tree, branch_ct, num_events);
+
if (tree[i + 1] <= 0)
- right = num_events[-tree[i + 1] - tok0_offset];
+ right = num_events[-tree[i + 1]];
else
- right = convert_distribution(tree[i + 1], tree, branch_ct, num_events,
- tok0_offset);
+ right = convert_distribution(tree[i + 1], tree, branch_ct, num_events);
branch_ct[i >> 1][0] = left;
branch_ct[i >> 1][1] = right;
@@ -65,9 +57,8 @@
void vp9_tree_probs_from_distribution(vp9_tree tree,
unsigned int branch_ct[/* n-1 */][2],
- const unsigned int num_events[/* n */],
- unsigned int tok0_offset) {
- convert_distribution(0, tree, branch_ct, num_events, tok0_offset);
+ const unsigned int num_events[/* n */]) {
+ convert_distribution(0, tree, branch_ct, num_events);
}
--- a/vp9/common/vp9_treecoder.h
+++ b/vp9/common/vp9_treecoder.h
@@ -42,7 +42,6 @@
/* Construct encoding array from tree. */
void vp9_tokens_from_tree(struct vp9_token*, vp9_tree);
-void vp9_tokens_from_tree_offset(struct vp9_token*, vp9_tree, int offset);
/* Convert array of token occurrence counts into a table of probabilities
for the associated binary encoding tree. Also writes count of branches
@@ -51,8 +50,7 @@
void vp9_tree_probs_from_distribution(vp9_tree tree,
unsigned int branch_ct[ /* n - 1 */ ][2],
- const unsigned int num_events[ /* n */ ],
- unsigned int tok0_offset);
+ const unsigned int num_events[ /* n */ ]);
static INLINE vp9_prob clip_prob(int p) {
@@ -116,10 +114,10 @@
static void tree_merge_probs(const vp9_tree_index *tree,
const vp9_prob *pre_probs,
- const unsigned int *counts, int offset,
+ const unsigned int *counts,
unsigned int count_sat,
unsigned int max_update_factor, vp9_prob *probs) {
- tree_merge_probs_impl(0, tree, pre_probs, &counts[-offset],
+ tree_merge_probs_impl(0, tree, pre_probs, counts,
count_sat, max_update_factor, probs);
}
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -48,12 +48,13 @@
}
static MB_PREDICTION_MODE read_inter_mode(VP9_COMMON *cm, vp9_reader *r,
- uint8_t context) {
- const MB_PREDICTION_MODE mode = treed_read(r, vp9_inter_mode_tree,
- cm->fc.inter_mode_probs[context]);
+ int ctx) {
+ const int mode = treed_read(r, vp9_inter_mode_tree,
+ cm->fc.inter_mode_probs[ctx]);
if (!cm->frame_parallel_decoding_mode)
- ++cm->counts.inter_mode[context][inter_mode_offset(mode)];
- return mode;
+ ++cm->counts.inter_mode[ctx][mode];
+
+ return NEARESTMV + mode;
}
static int read_segment_id(vp9_reader *r, const struct segmentation *seg) {
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -169,10 +169,8 @@
const unsigned int num_events[/* n */]) {
int i = 0;
- vp9_tree_probs_from_distribution(tree, bct, num_events, 0);
- n--;
-
- for (i = 0; i < n; ++i)
+ vp9_tree_probs_from_distribution(tree, bct, num_events);
+ for (i = 0; i < n - 1; ++i)
vp9_cond_prob_diff_update(w, &Pcur[i], bct[i]);
}
@@ -231,7 +229,7 @@
int i, j;
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
vp9_tree_probs_from_distribution(vp9_switchable_interp_tree, branch_ct,
- cm->counts.switchable_interp[j], 0);
+ cm->counts.switchable_interp[j]);
for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i)
vp9_cond_prob_diff_update(w, &cm->fc.switchable_interp_prob[j][i],
@@ -250,7 +248,7 @@
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
unsigned int branch_ct[INTER_MODES - 1][2];
vp9_tree_probs_from_distribution(vp9_inter_mode_tree, branch_ct,
- cm->counts.inter_mode[i], NEARESTMV);
+ cm->counts.inter_mode[i]);
for (j = 0; j < INTER_MODES - 1; ++j)
vp9_cond_prob_diff_update(w, &cm->fc.inter_mode_probs[i][j],
@@ -321,7 +319,7 @@
const vp9_prob *p) {
assert(is_inter_mode(mode));
write_token(w, vp9_inter_mode_tree, p,
- &vp9_inter_mode_encodings[inter_mode_offset(mode)]);
+ &vp9_inter_mode_encodings[INTER_OFFSET(mode)]);
}
@@ -448,7 +446,7 @@
if (bsize >= BLOCK_8X8) {
write_sb_mv_ref(bc, mode, mv_ref_p);
++cm->counts.inter_mode[mi->mode_context[rf]]
- [inter_mode_offset(mode)];
+ [INTER_OFFSET(mode)];
}
}
@@ -471,7 +469,7 @@
const MB_PREDICTION_MODE blockmode = m->bmi[j].as_mode;
write_sb_mv_ref(bc, blockmode, mv_ref_p);
++cm->counts.inter_mode[mi->mode_context[rf]]
- [inter_mode_offset(blockmode)];
+ [INTER_OFFSET(blockmode)];
if (blockmode == NEWMV) {
#ifdef ENTROPY_STATS
@@ -703,7 +701,7 @@
continue;
vp9_tree_probs_from_distribution(vp9_coef_tree,
coef_branch_ct[i][j][k][l],
- coef_counts[i][j][k][l], 0);
+ coef_counts[i][j][k][l]);
coef_branch_ct[i][j][k][l][0][1] = eob_branch_ct[i][j][k][l] -
coef_branch_ct[i][j][k][l][0][0];
for (m = 0; m < UNCONSTRAINED_NODES; ++m)
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -155,9 +155,8 @@
unsigned int (*branch_ct_class0_hp)[2],
unsigned int (*branch_ct_hp)[2]) {
int i, j, k;
- vp9_tree_probs_from_distribution(vp9_mv_joint_tree,
- branch_ct_joint,
- nmv_count->joints, 0);
+ vp9_tree_probs_from_distribution(vp9_mv_joint_tree, branch_ct_joint,
+ nmv_count->joints);
for (i = 0; i < 2; ++i) {
const uint32_t s0 = nmv_count->comps[i].sign[0];
const uint32_t s1 = nmv_count->comps[i].sign[1];
@@ -166,10 +165,10 @@
branch_ct_sign[i][1] = s1;
vp9_tree_probs_from_distribution(vp9_mv_class_tree,
branch_ct_classes[i],
- nmv_count->comps[i].classes, 0);
+ nmv_count->comps[i].classes);
vp9_tree_probs_from_distribution(vp9_mv_class0_tree,
branch_ct_class0[i],
- nmv_count->comps[i].class0, 0);
+ nmv_count->comps[i].class0);
for (j = 0; j < MV_OFFSET_BITS; ++j) {
const uint32_t b0 = nmv_count->comps[i].bits[j][0];
const uint32_t b1 = nmv_count->comps[i].bits[j][1];
@@ -182,11 +181,11 @@
for (k = 0; k < CLASS0_SIZE; ++k) {
vp9_tree_probs_from_distribution(vp9_mv_fp_tree,
branch_ct_class0_fp[i][k],
- nmv_count->comps[i].class0_fp[k], 0);
+ nmv_count->comps[i].class0_fp[k]);
}
vp9_tree_probs_from_distribution(vp9_mv_fp_tree,
branch_ct_fp[i],
- nmv_count->comps[i].fp, 0);
+ nmv_count->comps[i].fp);
}
if (usehp) {
for (i = 0; i < 2; ++i) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -268,10 +268,10 @@
MB_PREDICTION_MODE m;
for (m = NEARESTMV; m < MB_MODE_COUNT; m++)
- cpi->mb.inter_mode_cost[i][inter_mode_offset(m)] =
+ cpi->mb.inter_mode_cost[i][INTER_OFFSET(m)] =
cost_token(vp9_inter_mode_tree,
cm->fc.inter_mode_probs[i],
- &vp9_inter_mode_encodings[inter_mode_offset(m)]);
+ &vp9_inter_mode_encodings[INTER_OFFSET(m)]);
}
}
}
@@ -1416,7 +1416,7 @@
// Don't account for mode here if segment skip is enabled.
if (!vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
assert(is_inter_mode(mode));
- return x->inter_mode_cost[mode_context][inter_mode_offset(mode)];
+ return x->inter_mode_cost[mode_context][INTER_OFFSET(mode)];
} else {
return 0;
}
@@ -1707,7 +1707,7 @@
const struct buf_2d orig_src = x->plane[0].src;
struct buf_2d orig_pre[2];
- mode_idx = inter_mode_offset(this_mode);
+ mode_idx = INTER_OFFSET(this_mode);
bsi->rdstat[i][mode_idx].brdcost = INT64_MAX;
// if we're near/nearest and mv == 0,0, compare to zeromv
@@ -2002,7 +2002,7 @@
return;
}
- mode_idx = inter_mode_offset(mode_selected);
+ mode_idx = INTER_OFFSET(mode_selected);
vpx_memcpy(t_above, bsi->rdstat[i][mode_idx].ta, sizeof(t_above));
vpx_memcpy(t_left, bsi->rdstat[i][mode_idx].tl, sizeof(t_left));
@@ -2078,7 +2078,7 @@
return INT64_MAX;
/* set it to the best */
for (i = 0; i < 4; i++) {
- mode_idx = inter_mode_offset(bsi->modes[i]);
+ mode_idx = INTER_OFFSET(bsi->modes[i]);
mi->bmi[i].as_mv[0].as_int = bsi->rdstat[i][mode_idx].mvs[0].as_int;
if (has_second_ref(mbmi))
mi->bmi[i].as_mv[1].as_int = bsi->rdstat[i][mode_idx].mvs[1].as_int;