Fix DAALA_EC when EC_MULTISYMBOL disabled.

When DAALA_EC is enabled, calls to aom_read_tree() and aom_write_tree()
 would automatically convert the aom_tree_index and aom_prob into a CDF
 and call the aom_read_cdf() or aom_write_cdf(), which causes an
 error if DAALA_EC is enabled without EC_MULTISYMBOL.
This patch moves the conversion functions from daalaboolreader.h and
 daalaboolwriter.h into bitreader.h and bitwriter.h respectively, and
 only calls the conversion functions if EC_MULTISYMBOL is enabled.
This allows DAALA_EC to be enabled without EC_MULTISYMBOL and is a
 bitstream change when both ANS and EC_MULTISYMBOL are enabled as calls
 to read and write trees will automatically be converted into calls that
 read and write cdfs.

Change-Id: Id2f9aa9b5113292998cadfe69e4ba547324643ac
diff --git a/aom_dsp/bitreader.h b/aom_dsp/bitreader.h
index 621a5d3..c7546c6 100644
--- a/aom_dsp/bitreader.h
+++ b/aom_dsp/bitreader.h
@@ -200,20 +200,6 @@
   return -i;
 }
 
-static INLINE int aom_read_tree_(aom_reader *r, const aom_tree_index *tree,
-                                 const aom_prob *probs ACCT_STR_PARAM) {
-  int ret;
-#if CONFIG_DAALA_EC
-  ret = daala_read_tree_bits(r, tree, probs);
-#else
-  ret = aom_read_tree_bits(r, tree, probs, NULL);
-#endif
-#if CONFIG_ACCOUNTING
-  if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
-#endif
-  return ret;
-}
-
 #if CONFIG_EC_MULTISYMBOL
 static INLINE int aom_read_cdf_(aom_reader *r, const aom_cdf_prob *cdf,
                                 int nsymbs ACCT_STR_PARAM) {
@@ -261,8 +247,41 @@
   return ret;
 }
 #endif
+
+static INLINE int aom_read_tree_as_cdf(aom_reader *r,
+                                       const aom_tree_index *tree,
+                                       const aom_prob *probs) {
+  aom_tree_index i = 0;
+  do {
+    aom_cdf_prob cdf[16];
+    aom_tree_index index[16];
+    int path[16];
+    int dist[16];
+    int nsymbs;
+    int symb;
+    nsymbs = tree_to_cdf(tree, probs, i, cdf, index, path, dist);
+    symb = aom_read_cdf(r, cdf, nsymbs, NULL);
+    OD_ASSERT(symb >= 0 && symb < nsymbs);
+    i = index[symb];
+  } while (i > 0);
+  return -i;
+}
 #endif  // CONFIG_EC_MULTISYMBOL
 
+static INLINE int aom_read_tree_(aom_reader *r, const aom_tree_index *tree,
+                                 const aom_prob *probs ACCT_STR_PARAM) {
+  int ret;
+#if CONFIG_EC_MULTISYMBOL
+  ret = aom_read_tree_as_cdf(r, tree, probs);
+#else
+  ret = aom_read_tree_bits(r, tree, probs, NULL);
+#endif
+#if CONFIG_ACCOUNTING
+  if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
+#endif
+  return ret;
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif