Commit cfb02ddc authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Add code to compute in-order mappings for tokens.

Add av1_indices_from_tree() function that computes a forward and inverse
 mapping of the tree leaf-node symbols to their in-order traversal.
This is necessary because many of the aom_tree binary trees have their
 leaf nodes out of order (e.g., an in-order traversal of a tree with n
 nodes does not start at symbol 0 and go to symbol n - 1), but the CDFs
 created by tree_to_cdf() are indexed in-order.

Change-Id: Icd0dbed4c171a67c9e84a634106c4fdb5b1b3488
parent 439c5025
......@@ -32,6 +32,22 @@ void av1_tokens_from_tree(struct av1_token *tokens,
tree2tok(tokens, tree, 0, 0, 0);
/* This code assumes that tree contains as unique leaf nodes the integer values
0 to len - 1 and produces the forward and inverse mapping tables in ind[]
and inv[] respectively. */
void av1_indices_from_tree(int *ind, int *inv, int len,
const aom_tree_index *tree) {
int i;
int index;
for (i = index = 0; i < TREE_SIZE(len); i++) {
const aom_tree_index j = tree[i];
if (j <= 0) {
inv[index] = -j;
ind[-j] = index++;
static unsigned int convert_distribution(unsigned int i, aom_tree tree,
unsigned int branch_ct[][2],
const unsigned int num_events[]) {
......@@ -28,6 +28,8 @@ struct av1_token {
void av1_tokens_from_tree(struct av1_token *, const aom_tree_index *);
void av1_indices_from_tree(int *ind, int *inv, int len,
const aom_tree_index *tree);
static INLINE void av1_write_token(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment