From 8abf8673e67a41ff8d426e7fbf3414dca6a53243 Mon Sep 17 00:00:00 2001 From: "Nathan E. Egge" Date: Wed, 20 Jul 2016 13:12:31 -0400 Subject: [PATCH] Move av1_indices_from_tree() to common code space. Move the av1_indices_from_tree() function from av1/encoder/treewriter.c to aom_dsp/prob.c so that it can be used by both the encoder and the decoder. Change-Id: Ie43c599f425c3503b1ff93f0c77b5033a05b1bb4 --- aom_dsp/prob.c | 16 ++++++++++++++++ aom_dsp/prob.h | 3 +++ av1/encoder/treewriter.c | 16 ---------------- av1/encoder/treewriter.h | 2 -- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/aom_dsp/prob.c b/aom_dsp/prob.c index 233ff4f71..d65ace899 100644 --- a/aom_dsp/prob.c +++ b/aom_dsp/prob.c @@ -205,4 +205,20 @@ int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs, } return nsymbs; } + +/* 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++; + } + } +} #endif diff --git a/aom_dsp/prob.h b/aom_dsp/prob.h index f0ea01bf2..3ae34b825 100644 --- a/aom_dsp/prob.h +++ b/aom_dsp/prob.h @@ -127,6 +127,9 @@ static INLINE void av1_tree_to_cdf(const aom_tree_index *tree, } \ } \ } while (0) + +void av1_indices_from_tree(int *ind, int *inv, int len, + const aom_tree_index *tree); #endif DECLARE_ALIGNED(16, extern const uint8_t, aom_norm[256]); diff --git a/av1/encoder/treewriter.c b/av1/encoder/treewriter.c index 742ffca23..50be72413 100644 --- a/av1/encoder/treewriter.c +++ b/av1/encoder/treewriter.c @@ -32,22 +32,6 @@ 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[]) { diff --git a/av1/encoder/treewriter.h b/av1/encoder/treewriter.h index e16b43fcd..9a4cb86cb 100644 --- a/av1/encoder/treewriter.h +++ b/av1/encoder/treewriter.h @@ -28,8 +28,6 @@ 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,