Add adapt_scan APIs and some helping functions

av1_init_scan_order
initialize data structures related to adaptive scan order

av1_update_scan_prob
update nonzero probabilities from nonzero counts

av1_augment_prob
embed r + c and coeff_idx info with nonzero probabilities.
When sorting the nonzero probabilities, if there is a tie,
the coefficient with smaller r + c will be scanned first

av1_update_sort_order
apply quick sort on nonzero probabilities to obtain a sort order

av1_update_scan_order
apply topological sort on the nonzero probabilities sorting order to
guarantee each to-be-scanned coefficient's upper and left coefficient
will be scanned before the to-be-scanned coefficient.

av1_update_neighbors
For each coeff_idx in scan[], update its above and left neighbors in
neighbors[] accordingly.

Change-Id: I64c4938057daf8e30e48609a00ecc08d2e3062f4
diff --git a/av1/common/scan.h b/av1/common/scan.h
index 35b7de1..7b6698f 100644
--- a/av1/common/scan.h
+++ b/av1/common/scan.h
@@ -16,6 +16,7 @@
 #include "aom_ports/mem.h"
 
 #include "av1/common/enums.h"
+#include "av1/common/onyxc_int.h"
 #include "av1/common/blockd.h"
 
 #ifdef __cplusplus
@@ -27,6 +28,37 @@
 extern const SCAN_ORDER av1_default_scan_orders[TX_SIZES];
 extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES][TX_TYPES];
 
+#if CONFIG_ADAPT_SCAN
+void av1_update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
+                          int rate_16);
+void av1_update_scan_count_facade(AV1_COMMON *cm, TX_SIZE tx_size,
+                                  TX_TYPE tx_type, const tran_low_t *dqcoeffs,
+                                  int max_scan);
+
+// embed r + c and coeff_idx info with nonzero probabilities. When sorting the
+// nonzero probabilities, if there is a tie, the coefficient with smaller r + c
+// will be scanned first
+void av1_augment_prob(uint32_t *prob, int size, int tx1d_size);
+
+// apply quick sort on nonzero probabilities to obtain a sort order
+void av1_update_sort_order(TX_SIZE tx_size, const uint32_t *non_zero_prob,
+                           int16_t *sort_order);
+
+// apply topological sort on the nonzero probabilities sorting order to
+// guarantee each to-be-scanned coefficient's upper and left coefficient will be
+// scanned before the to-be-scanned coefficient.
+void av1_update_scan_order(TX_SIZE tx_size, int16_t *sort_order, int16_t *scan,
+                           int16_t *iscan);
+
+// For each coeff_idx in scan[], update its above and left neighbors in
+// neighbors[] accordingly.
+void av1_update_neighbors(int tx_size, const int16_t *scan,
+                          const int16_t *iscan, int16_t *neighbors);
+void av1_update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
+                                  TX_TYPE tx_type);
+void av1_init_scan_order(AV1_COMMON *cm);
+#endif
+
 static INLINE int get_coef_context(const int16_t *neighbors,
                                    const uint8_t *token_cache, int c) {
   return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +