Remove ADAPT_SCAN experiment

This experiment has been abandonned for AV1.

Change-Id: Ib3bb07d62f2025ce50dc9bc1b3f9fc22488519a7
diff --git a/aom_dsp/txfm_common.h b/aom_dsp/txfm_common.h
index 31aabda..7deb0ae 100644
--- a/aom_dsp/txfm_common.h
+++ b/aom_dsp/txfm_common.h
@@ -32,10 +32,7 @@
   // bd==8 implies !is_hbd, but that's not certain right now.
   int is_hbd;
   TxSetType tx_set_type;
-// for inverse transforms only
-#if CONFIG_ADAPT_SCAN
-  const int16_t *eob_threshold;
-#endif
+  // for inverse transforms only
   int eob;
 } TxfmParam;
 
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 562da62..5076708 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -514,10 +514,6 @@
   struct scale_factors sf;
 } RefBuffer;
 
-#if CONFIG_ADAPT_SCAN
-typedef int16_t EobThresholdMD[TX_TYPES][EOB_THRESHOLD_NUM];
-#endif
-
 #if CONFIG_LOOP_RESTORATION
 typedef struct {
   DECLARE_ALIGNED(16, InterpKernel, vfilter);
@@ -696,9 +692,6 @@
   int curr_delta_lf[FRAME_LF_COUNT];
 #endif  // CONFIG_LOOPFILTER_LEVEL
 #endif
-#if CONFIG_ADAPT_SCAN
-  const EobThresholdMD *eob_threshold_md;
-#endif
 
   DECLARE_ALIGNED(16, uint8_t, seg_mask[2 * MAX_SB_SQUARE]);
 
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index 7199518..8373695 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -1749,10 +1749,6 @@
 };
 #endif
 
-#if CONFIG_ADAPT_SCAN
-#define EOB_THRESHOLD_NUM 2
-#endif
-
 #if CONFIG_JNT_COMP
 // Note: this is also used in unit tests. So whenever one changes the table,
 // the unit tests need to be changed accordingly.
diff --git a/av1/common/entropy.h b/av1/common/entropy.h
index 7ffc5a4..c6d6482 100644
--- a/av1/common/entropy.h
+++ b/av1/common/entropy.h
@@ -358,14 +358,6 @@
 #define COEF_COUNT_SAT_AFTER_KEY 24
 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
 
-#if CONFIG_ADAPT_SCAN
-#define ADAPT_SCAN_PROB_PRECISION 10
-// 1/8 update rate
-#define ADAPT_SCAN_UPDATE_LOG_RATE 3
-#define ADAPT_SCAN_UPDATE_RATE \
-  (1 << (ADAPT_SCAN_PROB_PRECISION - ADAPT_SCAN_UPDATE_LOG_RATE))
-#endif
-
 static INLINE aom_prob av1_merge_probs(aom_prob pre_prob,
                                        const unsigned int ct[2],
                                        unsigned int count_sat,
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 29f2239..d11ff1b 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -3075,9 +3075,6 @@
 #if CONFIG_LV_MAP
   av1_init_lv_map(cm);
 #endif
-#if CONFIG_ADAPT_SCAN
-  av1_init_scan_order(cm);
-#endif
   av1_convolve_init(cm);
   cm->fc->initialized = 1;
   av1_setup_frame_contexts(cm);
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index 9fa9609..f7b1b1d 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -72,83 +72,9 @@
   unsigned int pred[PREDICTION_PROBS][2];
 };
 
-#if CONFIG_ADAPT_SCAN
-typedef struct NON_ZERO_COUNT {
-  unsigned int non_zero_count_4X4[TX_TYPES][16];
-  unsigned int non_zero_count_8X8[TX_TYPES][64];
-  unsigned int non_zero_count_16X16[TX_TYPES][256];
-  unsigned int non_zero_count_32X32[TX_TYPES][1024];
-
-  unsigned int non_zero_count_4x8[TX_TYPES][32];
-  unsigned int non_zero_count_8x4[TX_TYPES][32];
-  unsigned int non_zero_count_8x16[TX_TYPES][128];
-  unsigned int non_zero_count_16x8[TX_TYPES][128];
-  unsigned int non_zero_count_16x32[TX_TYPES][512];
-  unsigned int non_zero_count_32x16[TX_TYPES][512];
-
-  unsigned int txb_count[TX_SIZES_ALL][TX_TYPES];
-} NON_ZERO_COUNT;
-#endif
-
 typedef struct frame_contexts {
   coeff_cdf_model coef_tail_cdfs[TX_SIZES][PLANE_TYPES];
   coeff_cdf_model coef_head_cdfs[TX_SIZES][PLANE_TYPES];
-#if CONFIG_ADAPT_SCAN
-  struct NON_ZERO_COUNT non_zero_count;
-
-  // TODO(angiebird): try aom_prob
-  uint32_t non_zero_prob_4X4[TX_TYPES][16];
-  uint32_t non_zero_prob_8X8[TX_TYPES][64];
-  uint32_t non_zero_prob_16X16[TX_TYPES][256];
-  uint32_t non_zero_prob_32X32[TX_TYPES][1024];
-
-  uint32_t non_zero_prob_4X8[TX_TYPES][32];
-  uint32_t non_zero_prob_8X4[TX_TYPES][32];
-  uint32_t non_zero_prob_16X8[TX_TYPES][128];
-  uint32_t non_zero_prob_8X16[TX_TYPES][128];
-  uint32_t non_zero_prob_32X16[TX_TYPES][512];
-  uint32_t non_zero_prob_16X32[TX_TYPES][512];
-
-  DECLARE_ALIGNED(16, int16_t, scan_4X4[TX_TYPES][16]);
-  DECLARE_ALIGNED(16, int16_t, scan_8X8[TX_TYPES][64]);
-  DECLARE_ALIGNED(16, int16_t, scan_16X16[TX_TYPES][256]);
-  DECLARE_ALIGNED(16, int16_t, scan_32X32[TX_TYPES][1024]);
-
-  DECLARE_ALIGNED(16, int16_t, scan_4X8[TX_TYPES][32]);
-  DECLARE_ALIGNED(16, int16_t, scan_8X4[TX_TYPES][32]);
-  DECLARE_ALIGNED(16, int16_t, scan_8X16[TX_TYPES][128]);
-  DECLARE_ALIGNED(16, int16_t, scan_16X8[TX_TYPES][128]);
-  DECLARE_ALIGNED(16, int16_t, scan_16X32[TX_TYPES][512]);
-  DECLARE_ALIGNED(16, int16_t, scan_32X16[TX_TYPES][512]);
-
-  DECLARE_ALIGNED(16, int16_t, iscan_4X4[TX_TYPES][16]);
-  DECLARE_ALIGNED(16, int16_t, iscan_8X8[TX_TYPES][64]);
-  DECLARE_ALIGNED(16, int16_t, iscan_16X16[TX_TYPES][256]);
-  DECLARE_ALIGNED(16, int16_t, iscan_32X32[TX_TYPES][1024]);
-
-  DECLARE_ALIGNED(16, int16_t, iscan_4X8[TX_TYPES][32]);
-  DECLARE_ALIGNED(16, int16_t, iscan_8X4[TX_TYPES][32]);
-  DECLARE_ALIGNED(16, int16_t, iscan_8X16[TX_TYPES][128]);
-  DECLARE_ALIGNED(16, int16_t, iscan_16X8[TX_TYPES][128]);
-  DECLARE_ALIGNED(16, int16_t, iscan_16X32[TX_TYPES][512]);
-  DECLARE_ALIGNED(16, int16_t, iscan_32X16[TX_TYPES][512]);
-
-  int16_t nb_4X4[TX_TYPES][(16 + 1) * 2];
-  int16_t nb_8X8[TX_TYPES][(64 + 1) * 2];
-  int16_t nb_16X16[TX_TYPES][(256 + 1) * 2];
-  int16_t nb_32X32[TX_TYPES][(1024 + 1) * 2];
-
-  int16_t nb_4X8[TX_TYPES][(32 + 1) * 2];
-  int16_t nb_8X4[TX_TYPES][(32 + 1) * 2];
-  int16_t nb_8X16[TX_TYPES][(128 + 1) * 2];
-  int16_t nb_16X8[TX_TYPES][(128 + 1) * 2];
-  int16_t nb_16X32[TX_TYPES][(512 + 1) * 2];
-  int16_t nb_32X16[TX_TYPES][(512 + 1) * 2];
-
-  SCAN_ORDER sc[TX_SIZES_ALL][TX_TYPES];
-
-  int16_t eob_threshold[TX_SIZES_ALL][TX_TYPES][EOB_THRESHOLD_NUM];
-#endif  // CONFIG_ADAPT_SCAN
 
 #if CONFIG_LV_MAP
   aom_prob txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS];
diff --git a/av1/common/idct.c b/av1/common/idct.c
index a49e788..1eda2a8 100644
--- a/av1/common/idct.c
+++ b/av1/common/idct.c
@@ -1808,18 +1808,14 @@
 #if !CONFIG_DAALA_TX8
 static void idct8x8_add(const tran_low_t *input, uint8_t *dest, int stride,
                         const TxfmParam *txfm_param) {
-// If dc is 1, then input[0] is the reconstructed value, do not need
-// dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.
+  // If dc is 1, then input[0] is the reconstructed value, do not need
+  // dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.
 
-// The calculation can be simplified if there are not many non-zero dct
-// coefficients. Use eobs to decide what to do.
-// TODO(yunqingwang): "eobs = 1" case is also handled in av1_short_idct8x8_c.
-// Combine that with code here.
-#if CONFIG_ADAPT_SCAN
-  const int16_t half = txfm_param->eob_threshold[0];
-#else
+  // The calculation can be simplified if there are not many non-zero dct
+  // coefficients. Use eobs to decide what to do.
+  // TODO(yunqingwang): "eobs = 1" case is also handled in av1_short_idct8x8_c.
+  // Combine that with code here.
   const int16_t half = 12;
-#endif
 
   const int eob = txfm_param->eob;
   if (eob == 1)
@@ -1835,15 +1831,10 @@
 #if !CONFIG_DAALA_TX16
 static void idct16x16_add(const tran_low_t *input, uint8_t *dest, int stride,
                           const TxfmParam *txfm_param) {
-// The calculation can be simplified if there are not many non-zero dct
-// coefficients. Use eobs to separate different cases.
-#if CONFIG_ADAPT_SCAN
-  const int16_t half = txfm_param->eob_threshold[0];
-  const int16_t quarter = txfm_param->eob_threshold[1];
-#else
+  // The calculation can be simplified if there are not many non-zero dct
+  // coefficients. Use eobs to separate different cases.
   const int16_t half = 38;
   const int16_t quarter = 10;
-#endif
 
   const int eob = txfm_param->eob;
   if (eob == 1) /* DC only DCT coefficient. */
@@ -1860,13 +1851,8 @@
 #if !CONFIG_DAALA_TX32
 static void idct32x32_add(const tran_low_t *input, uint8_t *dest, int stride,
                           const TxfmParam *txfm_param) {
-#if CONFIG_ADAPT_SCAN
-  const int16_t half = txfm_param->eob_threshold[0];
-  const int16_t quarter = txfm_param->eob_threshold[1];
-#else
   const int16_t half = 135;
   const int16_t quarter = 34;
-#endif
 
   const int eob = txfm_param->eob;
   if (eob == 1)
@@ -2556,10 +2542,6 @@
   txfm_param->tx_set_type =
       get_ext_tx_set_type(txfm_param->tx_size, plane_bsize,
                           is_inter_block(&xd->mi[0]->mbmi), reduced_tx_set);
-#if CONFIG_ADAPT_SCAN
-  txfm_param->eob_threshold =
-      (const int16_t *)&xd->eob_threshold_md[tx_size][tx_type][0];
-#endif
 }
 
 typedef void (*InvTxfmFunc)(const tran_low_t *dqcoeff, uint8_t *dst, int stride,
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 089fd3d..d153333 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -566,9 +566,6 @@
 #if CONFIG_LV_MAP
   LV_MAP_CTX_TABLE coeff_ctx_table;
 #endif
-#if CONFIG_ADAPT_SCAN
-  int use_adapt_scan;
-#endif
 #if CONFIG_MFMV
   TPL_MV_REF *tpl_mvs;
   // TODO(jingning): This can be combined with sign_bias later.
diff --git a/av1/common/scan.c b/av1/common/scan.c
index 3b30a83..749e932 100644
--- a/av1/common/scan.c
+++ b/av1/common/scan.c
@@ -4524,740 +4524,3 @@
   },
 #endif  // CONFIG_TX64X64
 };
-
-#if CONFIG_ADAPT_SCAN
-// TX_32X32 will has 1024 coefficients whose indexes can be represented in 10
-// bits
-#define COEFF_IDX_BITS (10 + CONFIG_TX64X64)
-#define COEFF_IDX_SIZE (1 << COEFF_IDX_BITS)
-#define COEFF_IDX_MASK (COEFF_IDX_SIZE - 1)
-
-static uint32_t *get_non_zero_prob(FRAME_CONTEXT *fc, TX_SIZE tx_size,
-                                   TX_TYPE tx_type) {
-  switch (tx_size) {
-    case TX_4X4: return fc->non_zero_prob_4X4[tx_type];
-    case TX_8X8: return fc->non_zero_prob_8X8[tx_type];
-    case TX_16X16: return fc->non_zero_prob_16X16[tx_type];
-    case TX_32X32: return fc->non_zero_prob_32X32[tx_type];
-    case TX_4X8: return fc->non_zero_prob_4X8[tx_type];
-    case TX_8X4: return fc->non_zero_prob_8X4[tx_type];
-    case TX_8X16: return fc->non_zero_prob_8X16[tx_type];
-    case TX_16X8: return fc->non_zero_prob_16X8[tx_type];
-    case TX_16X32: return fc->non_zero_prob_16X32[tx_type];
-    case TX_32X16: return fc->non_zero_prob_32X16[tx_type];
-    default: assert(0); return NULL;
-  }
-}
-
-static int16_t *get_adapt_scan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
-                               TX_TYPE tx_type) {
-  switch (tx_size) {
-    case TX_4X4: return fc->scan_4X4[tx_type];
-    case TX_8X8: return fc->scan_8X8[tx_type];
-    case TX_16X16: return fc->scan_16X16[tx_type];
-    case TX_32X32: return fc->scan_32X32[tx_type];
-    case TX_4X8: return fc->scan_4X8[tx_type];
-    case TX_8X4: return fc->scan_8X4[tx_type];
-    case TX_8X16: return fc->scan_8X16[tx_type];
-    case TX_16X8: return fc->scan_16X8[tx_type];
-    case TX_16X32: return fc->scan_16X32[tx_type];
-    case TX_32X16: return fc->scan_32X16[tx_type];
-    default: assert(0); return NULL;
-  }
-}
-
-static int16_t *get_adapt_iscan(FRAME_CONTEXT *fc, TX_SIZE tx_size,
-                                TX_TYPE tx_type) {
-  switch (tx_size) {
-    case TX_4X4: return fc->iscan_4X4[tx_type];
-    case TX_8X8: return fc->iscan_8X8[tx_type];
-    case TX_16X16: return fc->iscan_16X16[tx_type];
-    case TX_32X32: return fc->iscan_32X32[tx_type];
-    case TX_4X8: return fc->iscan_4X8[tx_type];
-    case TX_8X4: return fc->iscan_8X4[tx_type];
-    case TX_8X16: return fc->iscan_8X16[tx_type];
-    case TX_16X8: return fc->iscan_16X8[tx_type];
-    case TX_16X32: return fc->iscan_16X32[tx_type];
-    case TX_32X16: return fc->iscan_32X16[tx_type];
-    default: assert(0); return NULL;
-  }
-}
-
-static int16_t *get_adapt_nb(FRAME_CONTEXT *fc, TX_SIZE tx_size,
-                             TX_TYPE tx_type) {
-  switch (tx_size) {
-    case TX_4X4: return fc->nb_4X4[tx_type];
-    case TX_8X8: return fc->nb_8X8[tx_type];
-    case TX_16X16: return fc->nb_16X16[tx_type];
-    case TX_32X32: return fc->nb_32X32[tx_type];
-    case TX_4X8: return fc->nb_4X8[tx_type];
-    case TX_8X4: return fc->nb_8X4[tx_type];
-    case TX_8X16: return fc->nb_8X16[tx_type];
-    case TX_16X8: return fc->nb_16X8[tx_type];
-    case TX_16X32: return fc->nb_16X32[tx_type];
-    case TX_32X16: return fc->nb_32X16[tx_type];
-    default: assert(0); return NULL;
-  }
-}
-
-static uint32_t *get_non_zero_counts(struct NON_ZERO_COUNT *counts,
-                                     TX_SIZE tx_size, TX_TYPE tx_type) {
-  switch (tx_size) {
-    case TX_4X4: return counts->non_zero_count_4X4[tx_type];
-    case TX_8X8: return counts->non_zero_count_8X8[tx_type];
-    case TX_16X16: return counts->non_zero_count_16X16[tx_type];
-    case TX_32X32: return counts->non_zero_count_32X32[tx_type];
-    case TX_4X8: return counts->non_zero_count_4x8[tx_type];
-    case TX_8X4: return counts->non_zero_count_8x4[tx_type];
-    case TX_8X16: return counts->non_zero_count_8x16[tx_type];
-    case TX_16X8: return counts->non_zero_count_16x8[tx_type];
-    case TX_16X32: return counts->non_zero_count_16x32[tx_type];
-    case TX_32X16: return counts->non_zero_count_32x16[tx_type];
-    default: assert(0); return NULL;
-  }
-}
-
-static INLINE int clamp_64(int64_t value, int low, int high) {
-  return value < low ? low : (value > high ? high : (int)value);
-}
-
-#if USE_2X2_PROB
-static int do_down_sample(TX_SIZE tx_size) {
-  const int tx_w = tx_size_wide[tx_size];
-  const int tx_h = tx_size_high[tx_size];
-  if (tx_w > 8 || tx_h > 8) {
-    return 1;
-  } else {
-    return 0;
-  }
-}
-
-void av1_down_sample_scan_count(uint32_t *non_zero_count_ds,
-                                const uint32_t *non_zero_count,
-                                TX_SIZE tx_size) {
-  const int tx_w = tx_size_wide[tx_size];
-  const int tx_h = tx_size_high[tx_size];
-  if (tx_w > 8 && tx_h > 8) {
-    const int tx_w_ds = tx_w >> 1;
-    const int tx_h_ds = tx_h >> 1;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds << 1;
-        const int c = c_ds << 1;
-        const int ci = r * tx_w + c;
-        non_zero_count_ds[ci_ds] = non_zero_count[ci];
-      }
-    }
-  } else if (tx_w > 8 && tx_h <= 8) {
-    const int tx_w_ds = tx_w >> 1;
-    const int tx_h_ds = tx_h;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds;
-        const int c = c_ds << 1;
-        const int ci = r * tx_w + c;
-        non_zero_count_ds[ci_ds] = non_zero_count[ci];
-      }
-    }
-  } else if (tx_w <= 8 && tx_h > 8) {
-    const int tx_w_ds = tx_w;
-    const int tx_h_ds = tx_h >> 1;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds << 1;
-        const int c = c_ds;
-        const int ci = r * tx_w + c;
-        non_zero_count_ds[ci_ds] = non_zero_count[ci];
-      }
-    }
-  } else {
-    assert(0);
-  }
-}
-
-void av1_up_sample_scan_count(uint32_t *non_zero_count,
-                              const uint32_t *non_zero_count_ds,
-                              TX_SIZE tx_size, unsigned int block_num) {
-  const int tx_w = tx_size_wide[tx_size];
-  const int tx_h = tx_size_high[tx_size];
-  if (tx_w > 8 && tx_h > 8) {
-    const int tx_w_ds = tx_w >> 1;
-    const int tx_h_ds = tx_h >> 1;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds << 1;
-        const int c = c_ds << 1;
-        const int ci = r * tx_w + c;
-        non_zero_count[ci] = non_zero_count_ds[ci_ds];
-        if (c_ds + 1 < tx_w_ds) {
-          uint32_t count =
-              non_zero_count_ds[ci_ds] + non_zero_count_ds[ci_ds + 1];
-          count = ROUND_POWER_OF_TWO(count, 1);
-          count = clamp32u(count, 0, block_num);
-          non_zero_count[ci + 1] = count;
-        } else {
-          non_zero_count[ci + 1] = non_zero_count_ds[ci_ds];
-        }
-      }
-    }
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c = 0; c < tx_w; ++c) {
-        const int r = r_ds << 1;
-        const int ci = r * tx_w + c;
-        if (r + 2 < tx_h) {
-          uint32_t count = non_zero_count[ci] + non_zero_count[ci + 2 * tx_w];
-          count = ROUND_POWER_OF_TWO(count, 1);
-          count = clamp32u(count, 0, block_num);
-          non_zero_count[ci + tx_w] = count;
-        } else {
-          non_zero_count[ci + tx_w] = non_zero_count[ci];
-        }
-      }
-    }
-  } else if (tx_w > 8 && tx_h <= 8) {
-    const int tx_w_ds = tx_w >> 1;
-    const int tx_h_ds = tx_h;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds;
-        const int c = c_ds << 1;
-        const int ci = r * tx_w + c;
-        non_zero_count[ci] = non_zero_count_ds[ci_ds];
-        if (c_ds + 1 < tx_w_ds) {
-          uint32_t count =
-              non_zero_count_ds[ci_ds] + non_zero_count_ds[ci_ds + 1];
-          count = ROUND_POWER_OF_TWO(count, 1);
-          count = clamp32u(count, 0, block_num);
-          non_zero_count[ci + 1] = count;
-        } else {
-          non_zero_count[ci + 1] = non_zero_count_ds[ci_ds];
-        }
-      }
-    }
-  } else if (tx_w <= 8 && tx_h > 8) {
-    const int tx_w_ds = tx_w;
-    const int tx_h_ds = tx_h >> 1;
-    for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
-      for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
-        const int ci_ds = r_ds * tx_w_ds + c_ds;
-        const int r = r_ds << 1;
-        const int c = c_ds;
-        const int ci = r * tx_w + c;
-        non_zero_count[ci] = non_zero_count_ds[ci_ds];
-        if (r_ds + 1 < tx_h_ds) {
-          uint32_t count =
-              non_zero_count_ds[ci_ds] + non_zero_count_ds[ci_ds + tx_w_ds];
-          count = ROUND_POWER_OF_TWO(count, 1);
-          count = clamp32u(count, 0, block_num);
-          non_zero_count[ci + tx_w] = count;
-        } else {
-          non_zero_count[ci + tx_w] = non_zero_count_ds[ci_ds];
-        }
-      }
-    }
-  } else {
-    assert(0);
-  }
-}
-#endif
-
-static void update_scan_prob(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type,
-                             int rate) {
-  FRAME_CONTEXT *pre_fc = cm->pre_fc;
-  uint32_t *prev_non_zero_prob = get_non_zero_prob(pre_fc, tx_size, tx_type);
-  uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
-  uint32_t *non_zero_count =
-      get_non_zero_counts(&cm->fc->non_zero_count, tx_size, tx_type);
-  const int tx2d_size = tx_size_2d[tx_size];
-  unsigned int block_num = cm->fc->non_zero_count.txb_count[tx_size][tx_type];
-#if USE_2X2_PROB
-#if CONFIG_TX64X64
-  DECLARE_ALIGNED(16, uint32_t, non_zero_count_ds[1024]);
-  assert((tx2d_size >> 2) <= 1024);
-#else   // CONFIG_TX64X64
-  DECLARE_ALIGNED(16, uint32_t, non_zero_count_ds[256]);
-  assert((tx2d_size >> 2) <= 256);
-#endif  // CONFIG_TX64X64
-  if (do_down_sample(tx_size)) {
-    av1_down_sample_scan_count(non_zero_count_ds, non_zero_count, tx_size);
-    av1_up_sample_scan_count(non_zero_count, non_zero_count_ds, tx_size,
-                             block_num);
-  }
-#endif
-  int i;
-  const int inv_precision = 30;
-  int32_t inv_block_num = block_num == 0 ? 0 : (1 << inv_precision) / block_num;
-  for (i = 0; i < tx2d_size; i++) {
-    int64_t curr_prob =
-        block_num == 0 ? 0 : ((non_zero_count[i] * inv_block_num) >>
-                              (inv_precision - ADAPT_SCAN_PROB_PRECISION));
-    int64_t prev_prob = prev_non_zero_prob[i];
-    int64_t pred_prob =
-        (curr_prob * rate +
-         prev_prob * ((1 << ADAPT_SCAN_PROB_PRECISION) - rate)) >>
-        ADAPT_SCAN_PROB_PRECISION;
-    // TODO(angiebird): reduce the bit usage of probabilities and remove
-    // clamp_64()
-    non_zero_prob[i] =
-        clamp_64(pred_prob, 0, (1 << ADAPT_SCAN_PROB_PRECISION) - 1);
-  }
-}
-
-static void update_scan_count(int16_t *scan, int max_scan,
-                              const tran_low_t *dqcoeffs,
-                              uint32_t *non_zero_count) {
-  int i;
-  for (i = 0; i < max_scan; ++i) {
-    int coeff_idx = scan[i];
-    non_zero_count[coeff_idx] += (dqcoeffs[coeff_idx] != 0);
-  }
-}
-
-void av1_update_scan_count_facade(const AV1_COMMON *const cm, MACROBLOCKD *xd,
-                                  int mi_row, TX_SIZE tx_size, TX_TYPE tx_type,
-                                  const tran_low_t *dqcoeffs, int max_scan) {
-#if SUB_FRAME_COUNT
-  if (((mi_row >> 5) << 5) + 32 >= cm->mi_rows) return;
-#else
-  (void)mi_row;
-#endif
-
-  if (cm->use_adapt_scan && do_adapt_scan(tx_size, tx_type) && max_scan) {
-    FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
-#if SUB_REGION_COUNT
-    if (ec_ctx->non_zero_count.txb_count[tx_size][tx_type] >= UINT8_MAX) return;
-#endif
-    int16_t *scan = get_adapt_scan(cm->fc, tx_size, tx_type);
-    uint32_t *non_zero_count =
-        get_non_zero_counts(&ec_ctx->non_zero_count, tx_size, tx_type);
-    update_scan_count(scan, max_scan, dqcoeffs, non_zero_count);
-    ++ec_ctx->non_zero_count.txb_count[tx_size][tx_type];
-  }
-}
-
-static int cmp_prob(const void *a, const void *b) {
-  return *(const uint32_t *)b > *(const uint32_t *)a ? 1 : -1;
-}
-
-void av1_augment_prob(TX_SIZE tx_size, TX_TYPE tx_type, uint32_t *prob) {
-  // TODO(angiebird): check if we need is_inter here
-  const SCAN_ORDER *sc = get_default_scan(tx_size, tx_type, 0);
-  const int tx1d_wide = tx_size_wide[tx_size];
-  const int tx1d_high = tx_size_high[tx_size];
-  int r, c;
-  for (r = 0; r < tx1d_high; r++) {
-    for (c = 0; c < tx1d_wide; c++) {
-      const int idx = r * tx1d_wide + c;
-      const uint32_t mask_16 = ((1 << 16) - 1);
-      const uint32_t tie_breaker = ~((uint32_t)sc->iscan[idx]);
-      // prob[idx]: 16 bits  dummy: 6 bits  scan_idx: 10 bits
-      prob[idx] = (prob[idx] << 16) | (mask_16 & tie_breaker);
-    }
-  }
-}
-
-void av1_update_neighbors(TX_SIZE tx_size, const int16_t *scan,
-                          const int16_t *iscan, int16_t *neighbors) {
-  const int tx1d_wide = tx_size_wide[tx_size];
-  const int tx1d_high = tx_size_high[tx_size];
-  const int tx2d_size = tx_size_2d[tx_size];
-  int scan_idx;
-  for (scan_idx = 0; scan_idx < tx2d_size; ++scan_idx) {
-    const int coeff_idx = scan[scan_idx];
-    const int r = coeff_idx / tx1d_wide;
-    const int c = coeff_idx % tx1d_wide;
-    const int nb_offset_r[5] = { -1, 0, -1, -1, 1 };
-    const int nb_offset_c[5] = { 0, -1, -1, 1, -1 };
-    const int nb_num = 5;
-    int nb_count = 0;
-    int nb_idx;
-
-    for (nb_idx = 0; nb_idx < nb_num; ++nb_idx) {
-      if (nb_count < 2) {
-        int nb_r = r + nb_offset_r[nb_idx];
-        int nb_c = c + nb_offset_c[nb_idx];
-        int nb_coeff_idx = nb_r * tx1d_wide + nb_c;
-        int valid_pos =
-            nb_r >= 0 && nb_r < tx1d_high && nb_c >= 0 && nb_c < tx1d_wide;
-        if (valid_pos && iscan[nb_coeff_idx] < scan_idx) {
-          neighbors[scan_idx * MAX_NEIGHBORS + nb_count] = nb_coeff_idx;
-          ++nb_count;
-        }
-      } else {
-        break;
-      }
-    }
-
-    if (nb_count == 1) {
-      neighbors[scan_idx * MAX_NEIGHBORS + 1] =
-          neighbors[scan_idx * MAX_NEIGHBORS + 0];
-    } else if (nb_count == 0) {
-      neighbors[scan_idx * MAX_NEIGHBORS + 0] = scan[0];
-      neighbors[scan_idx * MAX_NEIGHBORS + 1] = scan[0];
-    }
-  }
-  neighbors[tx2d_size * MAX_NEIGHBORS + 0] = scan[0];
-  neighbors[tx2d_size * MAX_NEIGHBORS + 1] = scan[0];
-}
-
-#if USE_LIMIT_SCAN_DISTANCE
-typedef struct SCAN_NB_QUEUE {
-  int nb_ci_queue[COEFF_IDX_SIZE + 1];
-  int pr_si_queue[COEFF_IDX_SIZE + 1];
-  int size;
-  int start;
-  int end;
-} SCAN_NB_QUEUE;
-
-static void assign_scan_idx(int16_t coeff_idx, int16_t *scan_idx, int tx_width,
-                            int tx_height, int16_t *scan, int16_t *iscan,
-                            int16_t *visit, SCAN_NB_QUEUE *queue) {
-  if (visit[coeff_idx] != 2) {
-    assert(*scan_idx < tx_width * tx_height);
-    scan[*scan_idx] = coeff_idx;
-    iscan[coeff_idx] = *scan_idx;
-    visit[coeff_idx] = 2;
-    int row = coeff_idx / tx_width;
-    int col = coeff_idx % tx_width;
-    int right_ci = coeff_idx + 1;
-    if (col + 1 < tx_width && visit[right_ci] == 0) {
-      visit[right_ci] = 1;
-      queue->pr_si_queue[queue->end] = *scan_idx;
-      queue->nb_ci_queue[queue->end] = right_ci;
-      queue->end = (queue->end + 1) % queue->size;
-    }
-    int down_ci = coeff_idx + tx_width;
-    if (row + 1 < tx_height && visit[down_ci] == 0) {
-      visit[down_ci] = 1;
-      queue->pr_si_queue[queue->end] = *scan_idx;
-      queue->nb_ci_queue[queue->end] = down_ci;
-      queue->end = (queue->end + 1) % queue->size;
-    }
-    ++(*scan_idx);
-  }
-}
-static void limit_nb_scan_distance(TX_SIZE tx_size, int16_t *scan,
-                                   int16_t *iscan) {
-  const int tx2d_size = tx_size_2d[tx_size];
-  int16_t visit[COEFF_IDX_SIZE] = { 0 };
-  int16_t org_scan[COEFF_IDX_SIZE];
-  memcpy(org_scan, scan, tx2d_size * sizeof(*scan));
-  const int tx_width = tx_size_wide[tx_size];
-  const int tx_height = tx_size_high[tx_size];
-  const int limit = 2 * AOMMAX(tx_width, tx_height);
-  SCAN_NB_QUEUE queue;
-  queue.size = tx2d_size;
-  queue.start = 0;
-  queue.end = 0;
-  int16_t new_si = 0;
-  for (int16_t si = 0; si < tx2d_size; ++si) {
-    while (queue.start != queue.end &&
-           queue.pr_si_queue[queue.start] + limit <= new_si) {
-      int nb_ci = queue.nb_ci_queue[queue.start];
-      assign_scan_idx(nb_ci, &new_si, tx_width, tx_height, scan, iscan, visit,
-                      &queue);
-      queue.start = (queue.start + 1) % queue.size;
-    }
-
-    int16_t ci = org_scan[si];
-    assign_scan_idx(ci, &new_si, tx_width, tx_height, scan, iscan, visit,
-                    &queue);
-  }
-  assert(new_si == tx2d_size);
-}
-#endif  // USE_LIMIT_SCAN_DISTANCE
-
-#if USE_TOPOLOGICAL_SORT
-void av1_update_sort_order(TX_SIZE tx_size, TX_TYPE tx_type,
-                           const uint32_t *non_zero_prob, int16_t *sort_order) {
-  const SCAN_ORDER *sc = get_default_scan(tx_size, tx_type, 0);
-  uint32_t temp[COEFF_IDX_SIZE];
-  const int tx2d_size = tx_size_2d[tx_size];
-  int sort_idx;
-  assert(tx2d_size <= COEFF_IDX_SIZE);
-  memcpy(temp, non_zero_prob, tx2d_size * sizeof(*non_zero_prob));
-  av1_augment_prob(tx_size, tx_type, temp);
-  qsort(temp, tx2d_size, sizeof(*temp), cmp_prob);
-  for (sort_idx = 0; sort_idx < tx2d_size; ++sort_idx) {
-    const int default_scan_idx =
-        (temp[sort_idx] & COEFF_IDX_MASK) ^ COEFF_IDX_MASK;
-    const int coeff_idx = sc->scan[default_scan_idx];
-    sort_order[sort_idx] = coeff_idx;
-  }
-}
-
-// topological sort
-static void dfs_scan(int tx1d_size, int *scan_idx, int coeff_idx, int16_t *scan,
-                     int16_t *iscan) {
-  const int r = coeff_idx / tx1d_size;
-  const int c = coeff_idx % tx1d_size;
-
-  if (iscan[coeff_idx] != -1) return;
-
-  if (r > 0) dfs_scan(tx1d_size, scan_idx, coeff_idx - tx1d_size, scan, iscan);
-
-  if (c > 0) dfs_scan(tx1d_size, scan_idx, coeff_idx - 1, scan, iscan);
-
-  scan[*scan_idx] = coeff_idx;
-  iscan[coeff_idx] = *scan_idx;
-  ++(*scan_idx);
-}
-
-void av1_update_scan_order(TX_SIZE tx_size, int16_t *sort_order, int16_t *scan,
-                           int16_t *iscan) {
-  int coeff_idx;
-  int scan_idx;
-  int sort_idx;
-  const int tx1d_size = tx_size_wide[tx_size];
-  const int tx2d_size = tx_size_2d[tx_size];
-
-  for (coeff_idx = 0; coeff_idx < tx2d_size; ++coeff_idx) {
-    iscan[coeff_idx] = -1;
-  }
-
-  scan_idx = 0;
-  for (sort_idx = 0; sort_idx < tx2d_size; ++sort_idx) {
-    coeff_idx = sort_order[sort_idx];
-    dfs_scan(tx1d_size, &scan_idx, coeff_idx, scan, iscan);
-  }
-}
-#else
-
-static void filter_prob(TX_SIZE tx_size, uint32_t *prob) {
-  const int tx1d_wide = tx_size_wide[tx_size];
-  const int tx1d_high = tx_size_high[tx_size];
-  for (int r = tx1d_high - 1; r >= 0; --r) {
-    for (int c = tx1d_wide - 1; c >= 0; --c) {
-      int idx = r * tx1d_wide + c;
-      uint32_t v = prob[idx];
-      if (r > 0 && prob[idx - tx1d_wide] < v) prob[idx - tx1d_wide] = v;
-      if (c > 0 && prob[idx - 1] < v) prob[idx - 1] = v;
-    }
-  }
-}
-
-void av1_update_scan_order(TX_SIZE tx_size, TX_TYPE tx_type,
-                           uint32_t *non_zero_prob, int16_t *scan,
-                           int16_t *iscan) {
-  const SCAN_ORDER *sc = get_default_scan(tx_size, tx_type, 0);
-  uint32_t temp[COEFF_IDX_SIZE];
-  const int tx2d_size = tx_size_2d[tx_size];
-  int scan_idx;
-  assert(tx2d_size <= COEFF_IDX_SIZE);
-  memcpy(temp, non_zero_prob, tx2d_size * sizeof(*non_zero_prob));
-  filter_prob(tx_size, temp);
-  av1_augment_prob(tx_size, tx_type, temp);
-  qsort(temp, tx2d_size, sizeof(*temp), cmp_prob);
-  for (scan_idx = 0; scan_idx < tx2d_size; ++scan_idx) {
-    const int default_scan_idx =
-        (temp[scan_idx] & COEFF_IDX_MASK) ^ COEFF_IDX_MASK;
-    const int coeff_idx = sc->scan[default_scan_idx];
-    scan[scan_idx] = coeff_idx;
-    iscan[coeff_idx] = scan_idx;
-  }
-}
-#endif
-
-static void update_scan_order_facade(AV1_COMMON *cm, TX_SIZE tx_size,
-                                     TX_TYPE tx_type, int use_curr_frame) {
-#if USE_TOPOLOGICAL_SORT
-  int16_t sort_order[COEFF_IDX_SIZE];
-#endif
-  uint32_t *non_zero_prob;
-  if (use_curr_frame)
-    non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
-  else
-    non_zero_prob = get_non_zero_prob(cm->pre_fc, tx_size, tx_type);
-  int16_t *scan = get_adapt_scan(cm->fc, tx_size, tx_type);
-  int16_t *iscan = get_adapt_iscan(cm->fc, tx_size, tx_type);
-  int16_t *nb = get_adapt_nb(cm->fc, tx_size, tx_type);
-  assert(tx_size_2d[tx_size] <= COEFF_IDX_SIZE);
-#if USE_TOPOLOGICAL_SORT
-  av1_update_sort_order(tx_size, tx_type, non_zero_prob, sort_order);
-  av1_update_scan_order(tx_size, sort_order, scan, iscan);
-#else
-  av1_update_scan_order(tx_size, tx_type, non_zero_prob, scan, iscan);
-#endif
-#if USE_LIMIT_SCAN_DISTANCE
-  limit_nb_scan_distance(tx_size, scan, iscan);
-#endif  // USE_LIMIT_SCAN_DISTANCE
-  av1_update_neighbors(tx_size, scan, iscan, nb);
-}
-
-static void update_eob_threshold(AV1_COMMON *cm, TX_SIZE tx_size,
-                                 TX_TYPE tx_type) {
-  int i, row, col, row_limit, col_limit, cal_idx = 0;
-  const int tx_width = tx_size_wide[tx_size];
-  const int tx_height = tx_size_high[tx_size];
-
-  row_limit = tx_width >> 1;
-  col_limit = tx_height >> 1;
-
-  if (tx_width >= 8 && tx_height >= 8) {
-    SCAN_ORDER *sc = &cm->fc->sc[tx_size][tx_type];
-    int16_t *threshold = &cm->fc->eob_threshold[tx_size][tx_type][0];
-    const int tx2d_size = tx_size_2d[tx_size];
-
-    while (cal_idx < EOB_THRESHOLD_NUM) {
-      for (i = 0; i < tx2d_size; ++i) {
-        row = sc->scan[i] / tx_height;
-        col = sc->scan[i] % tx_width;
-        if (row >= row_limit || col >= col_limit) break;
-      }
-      row_limit >>= 1;
-      col_limit >>= 1;
-      threshold[cal_idx] = i;
-      cal_idx++;
-    }
-  }
-}
-
-void av1_init_scan_order(AV1_COMMON *cm) {
-  TX_SIZE tx_size;
-  TX_TYPE tx_type;
-  for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
-    for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
-      if (do_adapt_scan(tx_size, tx_type)) {
-        uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
-        const int tx2d_size = tx_size_2d[tx_size];
-        int i;
-        SCAN_ORDER *sc = &cm->fc->sc[tx_size][tx_type];
-        for (i = 0; i < tx2d_size; ++i) {
-          non_zero_prob[i] = (1 << ADAPT_SCAN_PROB_PRECISION) /
-                             2;  // init non_zero_prob to 0.5
-        }
-#if SIG_REGION
-        const int bw = tx_size_wide[tx_size];
-        const int bh = tx_size_high[tx_size];
-        const int txw_lim = (bw > 16) ? 16 : 8;
-        const int txh_lim = (bh > 16) ? 16 : 8;
-        for (int idy = 0; idy < bh; ++idy)
-          for (int idx = 0; idx < bw; ++idx)
-            if (idy >= txh_lim || idx >= txw_lim)
-              non_zero_prob[idy * bw + idx] = 0;
-#endif
-        update_scan_order_facade(cm, tx_size, tx_type, 1);
-        sc->scan = get_adapt_scan(cm->fc, tx_size, tx_type);
-        sc->iscan = get_adapt_iscan(cm->fc, tx_size, tx_type);
-        sc->neighbors = get_adapt_nb(cm->fc, tx_size, tx_type);
-        update_eob_threshold(cm, tx_size, tx_type);
-      }
-    }
-  }
-}
-
-#if UNI_RECT
-void unify_rect_tx_count(AV1_COMMON *cm, TX_SIZE tx_size, TX_TYPE tx_type) {
-  uint32_t tmp_non_zero_counts[MAX_TX_SQUARE] = { 0 };
-  uint32_t *non_zero_count =
-      get_non_zero_counts(&cm->fc->non_zero_count, tx_size, tx_type);
-  int bw = tx_size_wide[tx_size];
-  int bh = tx_size_high[tx_size];
-  int tx_size_length = bw * bh;
-  for (int idx = 0; idx < tx_size_length; ++idx)
-    tmp_non_zero_counts[idx] = non_zero_count[idx];
-
-  TX_SIZE stx_size = TX_SIZES_ALL;
-  if (tx_size == TX_8X4) stx_size = TX_4X8;
-  if (tx_size == TX_16X8) stx_size = TX_8X16;
-  if (tx_size == TX_32X16) stx_size = TX_16X32;
-
-  bw = tx_size_wide[stx_size];
-  bh = tx_size_high[stx_size];
-  non_zero_count =
-      get_non_zero_counts(&cm->fc->non_zero_count, stx_size, tx_type);
-  for (int idy = 0; idy < bh; ++idy)
-    for (int idx = 0; idx < bw; ++idx)
-      tmp_non_zero_counts[idx * bh + idy] += non_zero_count[idy * bw + idx];
-
-  non_zero_count =
-      get_non_zero_counts(&cm->fc->non_zero_count, tx_size, tx_type);
-  for (int idx = 0; idx < tx_size_length; ++idx)
-    non_zero_count[idx] = tmp_non_zero_counts[idx];
-
-  non_zero_count =
-      get_non_zero_counts(&cm->fc->non_zero_count, stx_size, tx_type);
-  for (int idy = 0; idy < bh; ++idy)
-    for (int idx = 0; idx < bw; ++idx)
-      non_zero_count[idy * bw + idx] = tmp_non_zero_counts[idx * bh + idy];
-}
-
-void unify_rect_tx_count_facade(AV1_COMMON *cm) {
-  for (TX_TYPE tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
-    unify_rect_tx_count(cm, TX_8X4, tx_type);
-    unify_rect_tx_count(cm, TX_16X8, tx_type);
-    unify_rect_tx_count(cm, TX_32X16, tx_type);
-  }
-}
-#endif
-
-void av1_adapt_scan_order(AV1_COMMON *cm, FRAME_CONTEXT *ec_ctxs[],
-                          int num_tiles) {
-  if (cm->use_adapt_scan) {
-    TX_SIZE tx_size;
-#if CACHE_SCAN_PROB
-    int use_curr_frame = 0;
-#else   // CACHE_SCAN_PROB
-    int use_curr_frame = 1;
-#endif  // CACHE_SCAN_PROB
-
-    for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
-      const int length = tx_size_2d[tx_size];
-      TX_TYPE tx_type;
-      for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
-        if (!do_adapt_scan(tx_size, tx_type)) continue;
-        uint32_t *non_zero_count =
-            get_non_zero_counts(&cm->fc->non_zero_count, tx_size, tx_type);
-        for (int i = 0; i < length; ++i) non_zero_count[i] = 0;
-        cm->fc->non_zero_count.txb_count[tx_size][tx_type] = 0;
-
-        for (int i = 0; i < num_tiles; ++i) {
-          uint32_t *tile_count = get_non_zero_counts(
-              &ec_ctxs[i]->non_zero_count, tx_size, tx_type);
-          for (int idx = 0; idx < length; ++idx)
-            non_zero_count[idx] += tile_count[idx];
-          cm->fc->non_zero_count.txb_count[tx_size][tx_type] +=
-              ec_ctxs[i]->non_zero_count.txb_count[tx_size][tx_type];
-        }
-      }
-    }
-
-#if UNI_RECT
-    unify_rect_tx_count_facade(cm);
-#endif
-
-    for (tx_size = 0; tx_size < TX_SIZES_ALL; ++tx_size) {
-      TX_TYPE tx_type;
-      for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
-        if (do_adapt_scan(tx_size, tx_type)) {
-          update_scan_prob(cm, tx_size, tx_type, ADAPT_SCAN_UPDATE_RATE);
-
-#if SIG_REGION
-          uint32_t *non_zero_prob = get_non_zero_prob(cm->fc, tx_size, tx_type);
-          const int bw = tx_size_wide[tx_size];
-          const int bh = tx_size_high[tx_size];
-          const int txw_lim = (bw > 16) ? 16 : 8;
-          const int txh_lim = (bh > 16) ? 16 : 8;
-          for (int idy = 0; idy < bh; ++idy)
-            for (int idx = 0; idx < bw; ++idx)
-              if (idy >= txh_lim || idx >= txw_lim)
-                non_zero_prob[idy * bw + idx] = 0;
-#endif
-
-          update_scan_order_facade(cm, tx_size, tx_type, use_curr_frame);
-          update_eob_threshold(cm, tx_size, tx_type);
-        }
-      }
-    }
-  }
-}
-
-void av1_deliver_eob_threshold(const AV1_COMMON *cm, MACROBLOCKD *xd) {
-  xd->eob_threshold_md = (const EobThresholdMD *)cm->fc->eob_threshold;
-}
-#endif  // CONFIG_ADAPT_SCAN
diff --git a/av1/common/scan.h b/av1/common/scan.h
index c84bd24..588fe47 100644
--- a/av1/common/scan.h
+++ b/av1/common/scan.h
@@ -29,54 +29,6 @@
 extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES_ALL][TX_TYPES];
 extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
 
-#if CONFIG_ADAPT_SCAN
-#define USE_2X2_PROB 0
-#define CACHE_SCAN_PROB 1
-#define REDUCED_SET 1
-#define SUB_REGION_COUNT 1
-#define SUB_FRAME_COUNT 0
-#define SIG_REGION 0
-#define UNI_RECT 1
-#define USE_TOPOLOGICAL_SORT 0
-#define USE_LIMIT_SCAN_DISTANCE 0
-void av1_update_scan_count_facade(const AV1_COMMON *const cm, MACROBLOCKD *xd,
-                                  int mi_row, 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(TX_SIZE tx_size, TX_TYPE tx_type, uint32_t *prob);
-
-#if USE_TOPOLOGICAL_SORT
-// apply quick sort on nonzero probabilities to obtain a sort order
-void av1_update_sort_order(TX_SIZE tx_size, TX_TYPE tx_type,
-                           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);
-#else   // USE_TOPOLOGICAL_SORT
-void av1_update_scan_order(TX_SIZE tx_size, TX_TYPE tx_type,
-                           uint32_t *non_zero_prob, int16_t *scan,
-                           int16_t *iscan);
-#endif  // USE_TOPOLOGICAL_SORT
-
-// For each coeff_idx in scan[], update its above and left neighbors in
-// neighbors[] accordingly.
-void av1_update_neighbors(TX_SIZE tx_size, const int16_t *scan,
-                          const int16_t *iscan, int16_t *neighbors);
-void av1_init_scan_order(AV1_COMMON *cm);
-void av1_adapt_scan_order(AV1_COMMON *cm, FRAME_CONTEXT *ec_ctxs[],
-                          int num_tiles);
-#if USE_2X2_PROB
-void av1_down_sample_scan_count(uint32_t *non_zero_count_ds,
-                                const uint32_t *non_zero_count,
-                                TX_SIZE tx_size);
-#endif  // USE_2X2_PROB
-#endif  // CONFIG_ADAPT_SCAN
 void av1_deliver_eob_threshold(const AV1_COMMON *cm, MACROBLOCKD *xd);
 
 static INLINE int get_coef_context(const int16_t *neighbors,
@@ -97,15 +49,6 @@
   (void)tx_size;
   if (tx_size_2d[tx_size] >= 1024 && tx_type != DCT_DCT) return 0;
   if (tx_size > TX_32X16) return 0;
-#if CONFIG_ADAPT_SCAN
-#if REDUCED_SET
-  const int txw = tx_size_wide[tx_size];
-  const int txh = tx_size_high[tx_size];
-
-  if (txw == 16 && txh == 16) return tx_type == DCT_DCT;
-  if (txw >= 16 || txh >= 16) return tx_type <= ADST_ADST;
-#endif
-#endif
   return tx_type < IDTX;
 }
 
@@ -113,17 +56,8 @@
                                          TX_TYPE tx_type,
                                          const MB_MODE_INFO *mbmi) {
   const int is_inter = is_inter_block(mbmi);
-#if CONFIG_ADAPT_SCAN
-  (void)mbmi;
-  (void)is_inter;
-  if (!do_adapt_scan(tx_size, tx_type))
-    return get_default_scan(tx_size, tx_type, is_inter);
-  else
-    return &cm->fc->sc[tx_size][tx_type];
-#else   // CONFIG_ADAPT_SCAN
   (void)cm;
   return get_default_scan(tx_size, tx_type, is_inter);
-#endif  // CONFIG_ADAPT_SCAN
 }
 
 #ifdef __cplusplus
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 14c2d7f..d09abd3 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3062,18 +3062,6 @@
 
   cm->reduced_tx_set_used = aom_rb_read_bit(rb);
 
-#if CONFIG_ADAPT_SCAN
-#if CONFIG_EXT_TILE
-  if (cm->large_scale_tile)
-    cm->use_adapt_scan = 0;
-  else
-#endif  // CONFIG_EXT_TILE
-    cm->use_adapt_scan = aom_rb_read_bit(rb);
-  // TODO(angiebird): call av1_init_scan_order only when use_adapt_scan
-  // switches from 1 to 0
-  if (cm->use_adapt_scan == 0) av1_init_scan_order(cm);
-#endif  // CONFIG_ADAPT_SCAN
-
 #if !CONFIG_TEMPMV_SIGNALING
   // NOTE(zoeliu): As cm->prev_frame can take neither a frame of
   //               show_exisiting_frame=1, nor can it take a frame not used as
@@ -3273,9 +3261,6 @@
   RefBuffer *last_fb_ref_buf = &cm->frame_refs[LAST_FRAME - LAST_FRAME];
 #endif
 
-#if CONFIG_ADAPT_SCAN
-  av1_deliver_eob_threshold(cm, xd);
-#endif
 #if CONFIG_BITSTREAM_DEBUG
   bitstream_queue_set_frame_read(cm->current_video_frame * 2 + cm->show_frame);
 #endif
@@ -3561,9 +3546,6 @@
                                   num_bwd_ctxs);
       av1_average_tile_loopfilter_cdfs(pbi->common.fc, tile_ctxs, cdf_ptrs,
                                        num_bwd_ctxs);
-#if CONFIG_ADAPT_SCAN
-      av1_adapt_scan_order(cm, tile_ctxs, num_bwd_ctxs);
-#endif  // CONFIG_ADAPT_SCAN
 
       if (!frame_is_intra_only(cm)) {
         av1_adapt_inter_frame_probs(cm);
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index 1040a20..26b73f4 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -409,15 +409,6 @@
               pd->left_context + row, &txb_ctx);
   uint8_t cul_level = av1_read_coeffs_txb(cm, xd, r, row, col, plane, &txb_ctx,
                                           tx_size, max_scan_line, eob);
-#if CONFIG_ADAPT_SCAN
-  PLANE_TYPE plane_type = get_plane_type(plane);
-  TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, row, col, tx_size);
-  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-
-  if (xd->counts && *eob > 0)
-    av1_update_scan_count_facade(cm, xd, mi_row, tx_size, tx_type, pd->dqcoeff,
-                                 *eob);
-#endif
   av1_set_contexts(xd, pd, plane, tx_size, cul_level, col, row);
   return cul_level;
 }
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c
index 834c3fc..54ebdeb 100644
--- a/av1/decoder/detokenize.c
+++ b/av1/decoder/detokenize.c
@@ -311,14 +311,6 @@
 #endif  // CONFIG_NEW_QUANT
                    ctx, sc->scan, sc->neighbors, max_scan_line, r);
   av1_set_contexts(xd, pd, plane, tx_size, eob > 0, x, y);
-#if CONFIG_ADAPT_SCAN
-  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-
-  if (xd->counts)
-    av1_update_scan_count_facade(cm, xd, mi_row, tx_size, tx_type, pd->dqcoeff,
-                                 eob);
-#else
   (void)cm;
-#endif
   return eob;
 }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ff2df96..3aedcdb 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3896,15 +3896,6 @@
 
   aom_wb_write_bit(wb, cm->reduced_tx_set_used);
 
-#if CONFIG_ADAPT_SCAN
-#if CONFIG_EXT_TILE
-  if (cm->large_scale_tile)
-    assert(cm->use_adapt_scan == 0);
-  else
-#endif  // CONFIG_EXT_TILE
-    aom_wb_write_bit(wb, cm->use_adapt_scan);
-#endif
-
   if (!frame_is_intra_only(cm)) write_global_motion(cpi, wb);
 
   write_tile_info(cm, wb);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 77d3fea..d7225d1 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3697,10 +3697,6 @@
   int i;
   const int last_fb_buf_idx = get_ref_frame_buf_idx(cpi, LAST_FRAME);
 
-#if CONFIG_ADAPT_SCAN
-  av1_deliver_eob_threshold(cm, xd);
-#endif
-
   x->min_partition_size = AOMMIN(x->min_partition_size, cm->sb_size);
   x->max_partition_size = AOMMIN(x->max_partition_size, cm->sb_size);
 #if CONFIG_DIST_8X8
@@ -4094,17 +4090,6 @@
   // Indicates whether or not to use a default reduced set for ext-tx
   // rather than the potential full set of 16 transforms
   cm->reduced_tx_set_used = 0;
-#if CONFIG_ADAPT_SCAN
-#if CONFIG_EXT_TILE
-  if (cm->large_scale_tile)
-    cm->use_adapt_scan = 0;
-  else
-#endif  // CONFIG_EXT_TILE
-    cm->use_adapt_scan = 1;
-  // TODO(angiebird): call av1_init_scan_order only when use_adapt_scan
-  // switches from 1 to 0
-  if (cm->use_adapt_scan == 0) av1_init_scan_order(cm);
-#endif
 
 #if CONFIG_FRAME_MARKER
   if (cm->show_frame == 0) {
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 73cbe88..f7bd121 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -6371,9 +6371,6 @@
                                 num_bwd_ctxs);
     av1_average_tile_loopfilter_cdfs(cpi->common.fc, tile_ctxs, cdf_ptrs,
                                      num_bwd_ctxs);
-#if CONFIG_ADAPT_SCAN
-    av1_adapt_scan_order(cm, tile_ctxs, num_bwd_ctxs);
-#endif  // CONFIG_ADAPT_SCAN
   }
 
   if (!frame_is_intra_only(cm)) {
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 2986c3d..2d5842a 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -523,11 +523,6 @@
                    abs(tcoeff[pos]) - COEFF_BASE_RANGE - 1 - NUM_BASE_LEVELS);
     }
   }
-
-#if CONFIG_ADAPT_SCAN
-  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-  av1_update_scan_count_facade(cm, xd, mi_row, tx_size, tx_type, tcoeff, eob);
-#endif
 }
 
 typedef struct encode_txb_args {
@@ -2306,16 +2301,6 @@
 
   int cul_level = av1_get_txb_entropy_context(tcoeff, scan_order, eob);
   av1_set_contexts(xd, pd, plane, tx_size, cul_level, blk_col, blk_row);
-
-#if CONFIG_ADAPT_SCAN
-  // Since dqcoeff is not available here, we pass qcoeff into
-  // av1_update_scan_count_facade(). The update behavior should be the same
-  // because av1_update_scan_count_facade() only cares if coefficients are zero
-  // or not.
-  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-  av1_update_scan_count_facade((AV1_COMMON *)cm, xd, mi_row, tx_size, tx_type,
-                               qcoeff, eob);
-#endif
 }
 
 void av1_update_txb_context(const AV1_COMP *cpi, ThreadData *td,
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 7dc8a9a..0572901 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -588,10 +588,6 @@
 #if CONFIG_LV_MAP
   av1_init_lv_map(cm);
 #endif
-#if CONFIG_ADAPT_SCAN
-  av1_init_scan_order(cm);
-  av1_deliver_eob_threshold(cm, xd);
-#endif
   av1_convolve_init(cm);
   av1_initialize_rd_consts(cpi);
 
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 4348d68..892a54d 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -468,16 +468,6 @@
 
   *tp = t;
 
-#if CONFIG_ADAPT_SCAN
-  // Since dqcoeff is not available here, we pass qcoeff into
-  // av1_update_scan_count_facade(). The update behavior should be the same
-  // because av1_update_scan_count_facade() only cares if coefficients are zero
-  // or not.
-  const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
-  av1_update_scan_count_facade((AV1_COMMON *)cm, xd, mi_row, tx_size, tx_type,
-                               qcoeff, c);
-#endif
-
   av1_set_contexts(xd, pd, plane, tx_size, c > 0, blk_col, blk_row);
 }
 
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 075e808..5e9499e 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -106,7 +106,6 @@
 set(CONFIG_SYMBOLRATE 0 CACHE NUMBER "Enables symbol rate accounting.")
 
 # AV1 experiment flags.
-set(CONFIG_ADAPT_SCAN 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_ADD_4BYTES_OBUSIZE 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_AMVR 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_AOM_QM 1 CACHE NUMBER "AV1 experiment flag.")
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake
index a166c9c..cdf6d3a 100644
--- a/build/cmake/aom_experiment_deps.cmake
+++ b/build/cmake/aom_experiment_deps.cmake
@@ -14,12 +14,6 @@
 # Adjusts CONFIG_* CMake variables to address conflicts between active AV1
 # experiments.
 macro (fix_experiment_configs)
-  if (CONFIG_ADAPT_SCAN)
-    if (NOT CONFIG_LV_MAP)
-      change_config_and_warn(CONFIG_LV_MAP 1 CONFIG_ADAPT_SCAN)
-    endif()
-  endif()
-
   if (CONFIG_AMVR)
     if (NOT CONFIG_HASH_ME)
       change_config_and_warn(CONFIG_HASH_ME 1 CONFIG_AMVR)
diff --git a/configure b/configure
index f2d7b6a..59d3d4a 100755
--- a/configure
+++ b/configure
@@ -282,7 +282,6 @@
     daala_tx_dst32
     frame_size
     ext_delta_q
-    adapt_scan
     parallel_deblocking
     deblock_13tap
     loopfiltering_across_tiles
diff --git a/test/av1_inv_txfm_test.cc b/test/av1_inv_txfm_test.cc
index 873e806..eb4d632 100644
--- a/test/av1_inv_txfm_test.cc
+++ b/test/av1_inv_txfm_test.cc
@@ -93,9 +93,7 @@
 typedef void (*InvTxfmFunc)(const tran_low_t *in, uint8_t *out, int stride);
 typedef std::tr1::tuple<FwdTxfmFunc, InvTxfmFunc, InvTxfmFunc, TX_SIZE, int>
     PartialInvTxfmParam;
-#if !CONFIG_ADAPT_SCAN
 const int kMaxNumCoeffs = 1024;
-#endif
 class AV1PartialIDctTest
     : public ::testing::TestWithParam<PartialInvTxfmParam> {
  public:
@@ -118,7 +116,6 @@
   InvTxfmFunc partial_itxfm_;
 };
 
-#if !CONFIG_ADAPT_SCAN
 static MB_MODE_INFO get_mbmi() {
   MB_MODE_INFO mbmi;
   mbmi.ref_frame[0] = LAST_FRAME;
@@ -248,7 +245,6 @@
   EXPECT_EQ(0, max_error)
       << "Error: partial inverse transform produces different results";
 }
-#endif
 using std::tr1::make_tuple;
 
 INSTANTIATE_TEST_CASE_P(
diff --git a/test/scan_test.cc b/test/scan_test.cc
index 2b11bd1..e69de29 100644
--- a/test/scan_test.cc
+++ b/test/scan_test.cc
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2016, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 2 Clause License and
- * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
- * was not distributed with this source code in the LICENSE file, you can
- * obtain it at www.aomedia.org/license/software. If the Alliance for Open
- * Media Patent License 1.0 was not distributed with this source code in the
- * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
- */
-
-#include "av1/common/common_data.h"
-#include "av1/common/scan.h"
-#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
-
-namespace {
-
-TEST(ScanTest, av1_augment_prob) {
-  const TX_SIZE tx_size = TX_4X4;
-  const TX_TYPE tx_type = DCT_DCT;
-  const int tx1d_size = tx_size_wide[tx_size];
-  uint32_t prob[16] = { 8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2 };
-  const uint32_t ref_prob[16] = {
-    8, 8, 7, 7, 8, 8, 4, 2, 3, 3, 2, 2, 2, 2, 2, 2
-  };
-  av1_augment_prob(tx_size, tx_type, prob);
-  for (int r = 0; r < tx1d_size; ++r) {
-    for (int c = 0; c < tx1d_size; ++c) {
-      const uint32_t idx = r * tx1d_size + c;
-      EXPECT_EQ(ref_prob[idx], prob[idx] >> 16);
-    }
-  }
-
-  const SCAN_ORDER *sc = get_default_scan(tx_size, tx_type, 0);
-  const uint32_t mask = (1 << 16) - 1;
-  for (int r = 0; r < tx1d_size; ++r) {
-    for (int c = 0; c < tx1d_size; ++c) {
-      const uint32_t ref_idx = r * tx1d_size + c;
-      const uint32_t scan_idx = mask ^ (prob[r * tx1d_size + c] & mask);
-      const uint32_t idx = sc->scan[scan_idx];
-      EXPECT_EQ(ref_idx, idx);
-    }
-  }
-}
-
-#if USE_TOPOLOGICAL_SORT
-TEST(ScanTest, av1_update_sort_order) {
-  const TX_SIZE tx_size = TX_4X4;
-  const TX_TYPE tx_type = DCT_DCT;
-  const uint32_t prob[16] = { 15, 14, 11, 10, 13, 12, 9, 5,
-                              8,  7,  4,  2,  6,  3,  1, 0 };
-  const int16_t ref_sort_order[16] = { 0, 1,  4, 5,  2,  3,  6,  8,
-                                       9, 12, 7, 10, 13, 11, 14, 15 };
-  int16_t sort_order[16];
-  av1_update_sort_order(tx_size, tx_type, prob, sort_order);
-  for (int i = 0; i < 16; ++i) EXPECT_EQ(ref_sort_order[i], sort_order[i]);
-}
-#endif
-
-#if USE_TOPOLOGICAL_SORT
-TEST(ScanTest, av1_update_scan_order) {
-  TX_SIZE tx_size = TX_4X4;
-  const TX_TYPE tx_type = DCT_DCT;
-  const uint32_t prob[16] = { 10, 12, 14, 9, 11, 13, 15, 5,
-                              8,  7,  4,  2, 6,  3,  1,  0 };
-  int16_t sort_order[16];
-  int16_t scan[16];
-  int16_t iscan[16];
-  const int16_t ref_iscan[16] = { 0, 1, 2,  6,  3, 4,  5,  10,
-                                  7, 8, 11, 13, 9, 12, 14, 15 };
-
-  av1_update_sort_order(tx_size, tx_type, prob, sort_order);
-  av1_update_scan_order(tx_size, sort_order, scan, iscan);
-
-  for (int i = 0; i < 16; ++i) {
-    EXPECT_EQ(ref_iscan[i], iscan[i]);
-    EXPECT_EQ(i, scan[ref_iscan[i]]);
-  }
-}
-#endif
-
-TEST(ScanTest, av1_update_neighbors) {
-  TX_SIZE tx_size = TX_4X4;
-  // raster order
-  const int16_t scan[16] = { 0, 1, 2,  3,  4,  5,  6,  7,
-                             8, 9, 10, 11, 12, 13, 14, 15 };
-  int16_t nb[(16 + 1) * 2];
-  const int16_t ref_nb[(16 + 1) * 2] = { 0,  0,  0,  0,  1,  1,  2, 2, 0,
-                                         1,  1,  4,  2,  5,  3,  6, 4, 5,
-                                         5,  8,  6,  9,  7,  10, 8, 9, 9,
-                                         12, 10, 13, 11, 14, 0,  0 };
-
-  // raster order's scan and iscan are the same
-  av1_update_neighbors(tx_size, scan, scan, nb);
-
-  for (int i = 0; i < (16 + 1) * 2; ++i) {
-    EXPECT_EQ(ref_nb[i], nb[i]);
-  }
-}
-
-#if USE_2X2_PROB
-TEST(ScanTest, av1_down_sample_scan_count) {
-  const uint32_t non_zero_count[256] = {
-    13, 12, 11, 10, 0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 13, 9, 10, 8, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 11, 12, 9, 8, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  13, 9, 9, 10, 0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0, 0, 0, 0,  0, 0,  0, 0, 0,
-    0,  0,  0,  0,  0,  0, 0, 0,  0, 0, 0,  0,  0, 0,
-  };
-  const uint32_t ref_non_zero_count_ds[64] = {
-    13, 11, 0, 0, 0, 0, 0, 0, 11, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0,  0,  0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0,  0,  0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-  };
-  uint32_t non_zero_count_ds[64];
-  av1_down_sample_scan_count(non_zero_count_ds, non_zero_count, TX_16X16);
-  for (int i = 0; i < 64; ++i) {
-    EXPECT_EQ(ref_non_zero_count_ds[i], non_zero_count_ds[i]);
-  }
-}
-#endif
-
-}  // namespace
diff --git a/test/test.cmake b/test/test.cmake
index b106f3a..2101800 100644
--- a/test/test.cmake
+++ b/test/test.cmake
@@ -73,12 +73,6 @@
         "${AOM_ROOT}/test/accounting_test.cc")
   endif ()
 
-  if (CONFIG_ADAPT_SCAN)
-    set(AOM_UNIT_TEST_COMMON_SOURCES
-        ${AOM_UNIT_TEST_COMMON_SOURCES}
-        "${AOM_ROOT}/test/scan_test.cc")
-  endif ()
-
   if (HAVE_SSE2)
     set(AOM_UNIT_TEST_COMMON_SOURCES
         ${AOM_UNIT_TEST_COMMON_SOURCES}
diff --git a/test/test.mk b/test/test.mk
index 09e6977..29722a7 100644
--- a/test/test.mk
+++ b/test/test.mk
@@ -125,7 +125,6 @@
 #LIBAOM_TEST_SRCS-yes                   += encoder_parms_get_to_decoder.cc
 endif
 
-LIBAOM_TEST_SRCS-$(CONFIG_ADAPT_SCAN)  += scan_test.cc
 LIBAOM_TEST_SRCS-yes                   += convolve_test.cc
 LIBAOM_TEST_SRCS-yes                   += lpf_test.cc
 ifeq ($(CONFIG_CDEF_SINGLEPASS),yes)