Skip to content
Snippets Groups Projects
Commit 4531b85a authored by Nathan E. Egge's avatar Nathan E. Egge
Browse files

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 e7640c36
No related branches found
No related tags found
2 merge requests!6Rav1e 11 yushin 1,!3Rav1e 10 yushin
...@@ -32,6 +32,22 @@ void av1_tokens_from_tree(struct av1_token *tokens, ...@@ -32,6 +32,22 @@ void av1_tokens_from_tree(struct av1_token *tokens,
tree2tok(tokens, tree, 0, 0, 0); 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, static unsigned int convert_distribution(unsigned int i, aom_tree tree,
unsigned int branch_ct[][2], unsigned int branch_ct[][2],
const unsigned int num_events[]) { const unsigned int num_events[]) {
......
...@@ -28,6 +28,8 @@ struct av1_token { ...@@ -28,6 +28,8 @@ struct av1_token {
}; };
void av1_tokens_from_tree(struct av1_token *, const aom_tree_index *); 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, static INLINE void av1_write_token(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs, const aom_prob *probs,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment