ref: 03276bf6e6ddab1501ec2937a6bba1a49c1f8407
parent: 7a8a68e2bdf618b2542548b30d18933583ee8e0e
author: Jim Bankoski <[email protected]>
date: Wed Nov 20 05:06:04 EST 2013
remove the model and copy in pack_mb_tokens Change-Id: I00a5203c8ed76c184d936fccf93d76e7c06773d3
--- a/vp9/common/vp9_entropy.c
+++ b/vp9/common/vp9_entropy.c
@@ -128,6 +128,20 @@
-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
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -46,6 +46,8 @@
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[];
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -268,19 +268,9 @@
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) {
n -= p->skip_eob_node;
@@ -287,12 +277,25 @@
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_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
--- a/vp9/encoder/vp9_treewriter.h
+++ b/vp9/encoder/vp9_treewriter.h
@@ -35,9 +35,8 @@
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 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,