Merge "remove the model and copy in pack_mb_tokens"

This commit is contained in:
Jim Bankoski 2013-11-20 11:34:30 -08:00 committed by Gerrit Code Review
commit 25aae73a30
4 changed files with 38 additions and 20 deletions

View File

@ -128,6 +128,20 @@ const vp9_tree_index vp9_coef_tree[TREE_SIZE(MAX_ENTROPY_TOKENS)] = {
-DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */
};
// Unconstrained Node Tree
const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(MAX_ENTROPY_TOKENS)] = {
2, 6, /* 0 = LOW_VAL */
-TWO_TOKEN, 4, /* 1 = TWO */
-THREE_TOKEN, -FOUR_TOKEN, /* 2 = THREE */
8, 10, /* 3 = HIGH_LOW */
-DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2, /* 4 = CAT_ONE */
12, 14, /* 5 = CAT_THREEFOUR */
-DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4, /* 6 = CAT_THREE */
-DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 7 = CAT_FIVE */
};
struct vp9_token vp9_coef_encodings[MAX_ENTROPY_TOKENS];
/* Trees for extra bits. Probabilities are constant and

View File

@ -46,6 +46,8 @@ extern DECLARE_ALIGNED(16, const uint8_t,
extern const vp9_tree_index vp9_coef_tree[TREE_SIZE(MAX_ENTROPY_TOKENS)];
extern const vp9_tree_index vp9_coef_con_tree[];
#define DCT_EOB_MODEL_TOKEN 3 /* EOB Extra Bits 0+0 */
extern const vp9_tree_index vp9_coefmodel_tree[];

View File

@ -268,18 +268,8 @@ static void pack_mb_tokens(vp9_writer* const w,
const struct vp9_token *const a = &vp9_coef_encodings[t];
const vp9_extra_bit *const b = &vp9_extra_bits[t];
int i = 0;
const vp9_prob *pp;
int v = a->value;
int n = a->len;
vp9_prob probs[ENTROPY_NODES];
if (t >= TWO_TOKEN) {
vp9_model_to_full_probs(p->context_tree, probs);
pp = probs;
} else {
pp = p->context_tree;
}
assert(pp != 0);
/* skip one or two nodes */
if (p->skip_eob_node) {
@ -287,11 +277,24 @@ static void pack_mb_tokens(vp9_writer* const w,
i = 2 * p->skip_eob_node;
}
do {
const int bb = (v >> --n) & 1;
vp9_write(w, bb, pp[i >> 1]);
i = vp9_coef_tree[i + bb];
} while (n);
// TODO(jbb): expanding this can lead to big gains. It allows
// much better branch prediction and would enable us to avoid numerous
// lookups and compares.
// If we have a token that's in the constrained set, the coefficient tree
// is split into two treed writes. The first treed write takes care of the
// unconstrained nodes. The second treed write takes care of the
// constrained nodes.
if (t >= TWO_TOKEN && t < DCT_EOB_TOKEN) {
int len = UNCONSTRAINED_NODES - p->skip_eob_node;
int bits = v >> (n - len);
treed_write(w, vp9_coef_tree, p->context_tree, bits, len, i);
treed_write(w, vp9_coef_con_tree,
vp9_pareto8_full[p->context_tree[PIVOT_NODE] - 1], v, n - len,
0);
} else {
treed_write(w, vp9_coef_tree, p->context_tree, v, n, i);
}
if (b->base_val) {
const int e = p->extra, l = b->len;
@ -328,7 +331,7 @@ static void write_sb_mv_ref(vp9_writer *w, MB_PREDICTION_MODE mode,
static void write_segment_id(vp9_writer *w, const struct segmentation *seg,
int segment_id) {
if (seg->enabled && seg->update_map)
treed_write(w, vp9_segment_tree, seg->tree_probs, segment_id, 3);
treed_write(w, vp9_segment_tree, seg->tree_probs, segment_id, 3, 0);
}
// This function encodes the reference frame

View File

@ -35,9 +35,8 @@ static INLINE unsigned int cost_branch256(const unsigned int ct[2],
static INLINE void treed_write(vp9_writer *w,
vp9_tree tree, const vp9_prob *probs,
int bits, int len) {
vp9_tree_index i = 0;
int bits, int len,
vp9_tree_index i) {
do {
const int bit = (bits >> --len) & 1;
vp9_write(w, bit, probs[i >> 1]);
@ -48,7 +47,7 @@ static INLINE void treed_write(vp9_writer *w,
static INLINE void write_token(vp9_writer *w, vp9_tree tree,
const vp9_prob *probs,
const struct vp9_token *token) {
treed_write(w, tree, probs, token->value, token->len);
treed_write(w, tree, probs, token->value, token->len, 0);
}
static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs,