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
diff --git a/aom_dsp/prob.c b/aom_dsp/prob.c
index 233ff4f..d65ace8 100644
--- a/aom_dsp/prob.c
+++ b/aom_dsp/prob.c
@@ -205,4 +205,20 @@
}
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 9731d01..12e0afe 100644
--- a/aom_dsp/prob.h
+++ b/aom_dsp/prob.h
@@ -124,6 +124,9 @@
} \
} \
} 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 742ffca..50be724 100644
--- a/av1/encoder/treewriter.c
+++ b/av1/encoder/treewriter.c
@@ -32,22 +32,6 @@
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 e16b43f..9a4cb86 100644
--- a/av1/encoder/treewriter.h
+++ b/av1/encoder/treewriter.h
@@ -28,8 +28,6 @@
};
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,