Remove CONFIG_DIST_8X8

CONFIG_DIST_8X8 has not been used in the codebase. Removing it improves
code readability.

Change-Id: I670529e26fd0f57f53be9a8bc14714d5ecb21a4d
diff --git a/apps/aomenc.c b/apps/aomenc.c
index cdc37ad..1f814bd 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -593,11 +593,6 @@
     ARG_DEF(NULL, "mv-cost-upd-freq", 1,
             "Update freq for mv costs"
             "0: SB, 1: SB Row per Tile, 2: Tile, 3: Off");
-#if CONFIG_DIST_8X8
-static const arg_def_t enable_dist_8x8 =
-    ARG_DEF(NULL, "enable-dist-8x8", 1,
-            "Enable dist-8x8 (0: false (default), 1: true)");
-#endif  // CONFIG_DIST_8X8
 static const arg_def_t num_tg = ARG_DEF(
     NULL, "num-tile-groups", 1, "Maximum number of tile groups, default is 1");
 static const arg_def_t mtu_size =
@@ -873,9 +868,6 @@
                                        &coeff_cost_upd_freq,
                                        &mode_cost_upd_freq,
                                        &mv_cost_upd_freq,
-#if CONFIG_DIST_8X8
-                                       &enable_dist_8x8,
-#endif
                                        &frame_parallel_decoding,
                                        &error_resilient_mode,
                                        &aq_mode,
@@ -981,9 +973,6 @@
                                         AV1E_SET_COEFF_COST_UPD_FREQ,
                                         AV1E_SET_MODE_COST_UPD_FREQ,
                                         AV1E_SET_MV_COST_UPD_FREQ,
-#if CONFIG_DIST_8X8
-                                        AV1E_SET_ENABLE_DIST_8X8,
-#endif
                                         AV1E_SET_FRAME_PARALLEL_DECODING,
                                         AV1E_SET_ERROR_RESILIENT_MODE,
                                         AV1E_SET_AQ_MODE,
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 0930b72..d5cef3f 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -64,9 +64,6 @@
   unsigned int qm_v;
   unsigned int qm_min;
   unsigned int qm_max;
-#if CONFIG_DIST_8X8
-  unsigned int enable_dist_8x8;
-#endif
   unsigned int num_tg;
   unsigned int mtu_size;
 
@@ -189,11 +186,8 @@
   DEFAULT_QM_V,                              // qm_v
   DEFAULT_QM_FIRST,                          // qm_min
   DEFAULT_QM_LAST,                           // qm_max
-#if CONFIG_DIST_8X8
-  0,
-#endif
-  1,                            // max number of tile groups
-  0,                            // mtu_size
+  1,                                         // max number of tile groups
+  0,                                         // mtu_size
   AOM_TIMING_UNSPECIFIED,       // No picture timing signaling in bitstream
   0,                            // frame_parallel_decoding_mode
   1,                            // enable dual filter
@@ -518,8 +512,6 @@
 #if CONFIG_TUNE_VMAF
   RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR,
               AOM_TUNE_VMAF_WITHOUT_PREPROCESSING);
-#elif CONFIG_DIST_8X8
-  RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_DAALA_DIST);
 #else
   RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_SSIM);
 #endif
@@ -534,10 +526,6 @@
       ERROR("Only --aq_mode=0 can be used with --lossless=1.");
     if (extra_cfg->enable_chroma_deltaq)
       ERROR("Only --enable_chroma_deltaq=0 can be used with --lossless=1.");
-#if CONFIG_DIST_8X8
-    if (extra_cfg->enable_dist_8x8)
-      ERROR("dist-8x8 cannot be used with lossless compression.");
-#endif
   }
 
   if (cfg->rc_resize_mode != RESIZE_NONE &&
@@ -776,12 +764,6 @@
   oxcf->coeff_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->coeff_cost_upd_freq;
   oxcf->mode_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->mode_cost_upd_freq;
   oxcf->mv_cost_upd_freq = (COST_UPDATE_TYPE)extra_cfg->mv_cost_upd_freq;
-#if CONFIG_DIST_8X8
-  oxcf->using_dist_8x8 = extra_cfg->enable_dist_8x8;
-  if (extra_cfg->tuning == AOM_TUNE_CDEF_DIST ||
-      extra_cfg->tuning == AOM_TUNE_DAALA_DIST)
-    oxcf->using_dist_8x8 = 1;
-#endif
   oxcf->num_tile_groups = extra_cfg->num_tg;
   // In large-scale tile encoding mode, num_tile_groups is always 1.
   if (cfg->large_scale_tile) oxcf->num_tile_groups = 1;
@@ -1291,14 +1273,7 @@
   extra_cfg.qm_max = CAST(AV1E_SET_QM_MAX, args);
   return update_extra_cfg(ctx, &extra_cfg);
 }
-#if CONFIG_DIST_8X8
-static aom_codec_err_t ctrl_set_enable_dist_8x8(aom_codec_alg_priv_t *ctx,
-                                                va_list args) {
-  struct av1_extracfg extra_cfg = ctx->extra_cfg;
-  extra_cfg.enable_dist_8x8 = CAST(AV1E_SET_ENABLE_DIST_8X8, args);
-  return update_extra_cfg(ctx, &extra_cfg);
-}
-#endif
+
 static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx,
                                        va_list args) {
   struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -2643,9 +2618,6 @@
   { AV1E_SET_QM_V, ctrl_set_qm_v },
   { AV1E_SET_QM_MIN, ctrl_set_qm_min },
   { AV1E_SET_QM_MAX, ctrl_set_qm_max },
-#if CONFIG_DIST_8X8
-  { AV1E_SET_ENABLE_DIST_8X8, ctrl_set_enable_dist_8x8 },
-#endif
   { AV1E_SET_NUM_TG, ctrl_set_num_tg },
   { AV1E_SET_MTU, ctrl_set_mtu },
   { AV1E_SET_TIMING_INFO_TYPE, ctrl_set_timing_info_type },
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index b6a5ec4..0c439d4 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -22,9 +22,6 @@
 #endif
 
 #include "av1/encoder/hash.h"
-#if CONFIG_DIST_8X8
-#include "aom/aomcx.h"
-#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -422,10 +419,6 @@
   int use_default_intra_tx_type;
   // use default transform and skip transform type search for inter modes
   int use_default_inter_tx_type;
-#if CONFIG_DIST_8X8
-  int using_dist_8x8;
-  aom_tune_metric tune_metric;
-#endif  // CONFIG_DIST_8X8
   int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
   int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
   int must_find_valid_partition;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index ca46152..3b06cdf 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -2845,15 +2845,6 @@
   unsigned int pb_simple_motion_pred_sse = UINT_MAX;
   (void)pb_simple_motion_pred_sse;
 
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8) {
-    if (block_size_high[bsize] <= 8) partition_horz_allowed = 0;
-    if (block_size_wide[bsize] <= 8) partition_vert_allowed = 0;
-    if (block_size_high[bsize] <= 8 || block_size_wide[bsize] <= 8)
-      do_square_split = 0;
-  }
-#endif
-
   // PARTITION_NONE
   if (is_le_min_sq_part && has_rows && has_cols) partition_none_allowed = 1;
   int64_t part_none_rd = INT64_MAX;
@@ -3276,15 +3267,6 @@
   int vertab_partition_allowed =
       ext_partition_allowed & cpi->oxcf.enable_ab_partitions;
 
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8) {
-    if (block_size_high[bsize] <= 8 || block_size_wide[bsize] <= 8) {
-      horzab_partition_allowed = 0;
-      vertab_partition_allowed = 0;
-    }
-  }
-#endif
-
   if (cpi->sf.part_sf.prune_ext_partition_types_search_level) {
     if (cpi->sf.part_sf.prune_ext_partition_types_search_level == 1) {
       // TODO(debargha,huisu@google.com): may need to tune the threshold for
@@ -3571,15 +3553,6 @@
                              pb_source_variance, mi_row, mi_col);
   }
 
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8) {
-    if (block_size_high[bsize] <= 16 || block_size_wide[bsize] <= 16) {
-      partition_horz4_allowed = 0;
-      partition_vert4_allowed = 0;
-    }
-  }
-#endif
-
   if (blksize < (min_partition_size << 2)) {
     partition_horz4_allowed = 0;
     partition_vert4_allowed = 0;
@@ -5328,11 +5301,6 @@
   RD_COUNTS *const rdc = &cpi->td.rd_counts;
   int i;
 
-#if CONFIG_DIST_8X8
-  x->using_dist_8x8 = cpi->oxcf.using_dist_8x8;
-  x->tune_metric = cpi->oxcf.tuning;
-#endif
-
   if (!cpi->sf.rt_sf.use_nonrd_pick_mode) {
     cm->setup_mi(cm);
   }
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index fdb1165..997844c 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -277,9 +277,6 @@
   int qm_v;
   int qm_minlevel;
   int qm_maxlevel;
-#if CONFIG_DIST_8X8
-  int using_dist_8x8;
-#endif
   unsigned int num_tile_groups;
   unsigned int mtu;
 
diff --git a/av1/encoder/pickcdef.c b/av1/encoder/pickcdef.c
index 5f195c6..dd1f637 100644
--- a/av1/encoder/pickcdef.c
+++ b/av1/encoder/pickcdef.c
@@ -174,36 +174,6 @@
     memcpy(dst + r * dstride, base + r * sstride, hsize * sizeof(*base));
 }
 
-#if CONFIG_DIST_8X8
-static INLINE uint64_t dist_8x8_16bit(uint16_t *dst, int dstride, uint16_t *src,
-                                      int sstride, int coeff_shift) {
-  uint64_t svar = 0;
-  uint64_t dvar = 0;
-  uint64_t sum_s = 0;
-  uint64_t sum_d = 0;
-  uint64_t sum_s2 = 0;
-  uint64_t sum_d2 = 0;
-  uint64_t sum_sd = 0;
-  int i, j;
-  for (i = 0; i < 8; i++) {
-    for (j = 0; j < 8; j++) {
-      sum_s += src[i * sstride + j];
-      sum_d += dst[i * dstride + j];
-      sum_s2 += src[i * sstride + j] * src[i * sstride + j];
-      sum_d2 += dst[i * dstride + j] * dst[i * dstride + j];
-      sum_sd += src[i * sstride + j] * dst[i * dstride + j];
-    }
-  }
-  /* Compute the variance -- the calculation cannot go negative. */
-  svar = sum_s2 - ((sum_s * sum_s + 32) >> 6);
-  dvar = sum_d2 - ((sum_d * sum_d + 32) >> 6);
-  return (uint64_t)floor(
-      .5 + (sum_d2 + sum_s2 - 2 * sum_sd) * .5 *
-               (svar + dvar + (400 << 2 * coeff_shift)) /
-               (sqrt((20000 << 4 * coeff_shift) + svar * (double)dvar)));
-}
-#endif  // CONFIG_DIST_8X8
-
 static INLINE uint64_t mse_8x8_16bit(uint16_t *dst, int dstride, uint16_t *src,
                                      int sstride) {
   uint64_t sum = 0;
@@ -241,14 +211,8 @@
       by = dlist[bi].by;
       bx = dlist[bi].bx;
       if (pli == 0) {
-#if CONFIG_DIST_8X8
-        sum += dist_8x8_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
-                              &src[bi << (3 + 3)], 8, coeff_shift);
-#else
-
         sum += mse_8x8_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
                              &src[bi << (3 + 3)], 8);
-#endif  // CONFIG_DIST_8X8
 
       } else {
         sum += mse_8x8_16bit(&dst[(by << 3) * dstride + (bx << 3)], dstride,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index bd1a800..89dcc4c 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -478,403 +478,6 @@
         compare_rd_idx_pair);
 }
 
-#if CONFIG_DIST_8X8
-static uint64_t cdef_dist_8x8_16bit(uint16_t *dst, int dstride, uint16_t *src,
-                                    int sstride, int coeff_shift) {
-  uint64_t svar = 0;
-  uint64_t dvar = 0;
-  uint64_t sum_s = 0;
-  uint64_t sum_d = 0;
-  uint64_t sum_s2 = 0;
-  uint64_t sum_d2 = 0;
-  uint64_t sum_sd = 0;
-  uint64_t dist = 0;
-
-  int i, j;
-  for (i = 0; i < 8; i++) {
-    for (j = 0; j < 8; j++) {
-      sum_s += src[i * sstride + j];
-      sum_d += dst[i * dstride + j];
-      sum_s2 += src[i * sstride + j] * src[i * sstride + j];
-      sum_d2 += dst[i * dstride + j] * dst[i * dstride + j];
-      sum_sd += src[i * sstride + j] * dst[i * dstride + j];
-    }
-  }
-  /* Compute the variance -- the calculation cannot go negative. */
-  svar = sum_s2 - ((sum_s * sum_s + 32) >> 6);
-  dvar = sum_d2 - ((sum_d * sum_d + 32) >> 6);
-
-  // Tuning of jm's original dering distortion metric used in CDEF tool,
-  // suggested by jm
-  const uint64_t a = 4;
-  const uint64_t b = 2;
-  const uint64_t c1 = (400 * a << 2 * coeff_shift);
-  const uint64_t c2 = (b * 20000 * a * a << 4 * coeff_shift);
-
-  dist = (uint64_t)floor(.5 + (sum_d2 + sum_s2 - 2 * sum_sd) * .5 *
-                                  (svar + dvar + c1) /
-                                  (sqrt(svar * (double)dvar + c2)));
-
-  // Calibrate dist to have similar rate for the same QP with MSE only
-  // distortion (as in master branch)
-  dist = (uint64_t)((float)dist * 0.75);
-
-  return dist;
-}
-
-static int od_compute_var_4x4(uint16_t *x, int stride) {
-  int sum;
-  int s2;
-  int i;
-  sum = 0;
-  s2 = 0;
-  for (i = 0; i < 4; i++) {
-    int j;
-    for (j = 0; j < 4; j++) {
-      int t;
-
-      t = x[i * stride + j];
-      sum += t;
-      s2 += t * t;
-    }
-  }
-
-  return (s2 - (sum * sum >> 4)) >> 4;
-}
-
-/* OD_DIST_LP_MID controls the frequency weighting filter used for computing
-   the distortion. For a value X, the filter is [1 X 1]/(X + 2) and
-   is applied both horizontally and vertically. For X=5, the filter is
-   a good approximation for the OD_QM8_Q4_HVS quantization matrix. */
-#define OD_DIST_LP_MID (5)
-#define OD_DIST_LP_NORM (OD_DIST_LP_MID + 2)
-
-static double od_compute_dist_8x8(int use_activity_masking, uint16_t *x,
-                                  uint16_t *y, od_coeff *e_lp, int stride) {
-  double sum;
-  int min_var;
-  double mean_var;
-  double var_stat;
-  double activity;
-  double calibration;
-  int i;
-  int j;
-  double vardist;
-
-  vardist = 0;
-
-#if 1
-  min_var = INT_MAX;
-  mean_var = 0;
-  for (i = 0; i < 3; i++) {
-    for (j = 0; j < 3; j++) {
-      int varx;
-      int vary;
-      varx = od_compute_var_4x4(x + 2 * i * stride + 2 * j, stride);
-      vary = od_compute_var_4x4(y + 2 * i * stride + 2 * j, stride);
-      min_var = OD_MINI(min_var, varx);
-      mean_var += 1. / (1 + varx);
-      /* The cast to (double) is to avoid an overflow before the sqrt.*/
-      vardist += varx - 2 * sqrt(varx * (double)vary) + vary;
-    }
-  }
-  /* We use a different variance statistic depending on whether activity
-     masking is used, since the harmonic mean appeared slightly worse with
-     masking off. The calibration constant just ensures that we preserve the
-     rate compared to activity=1. */
-  if (use_activity_masking) {
-    calibration = 1.95;
-    var_stat = 9. / mean_var;
-  } else {
-    calibration = 1.62;
-    var_stat = min_var;
-  }
-  /* 1.62 is a calibration constant, 0.25 is a noise floor and 1/6 is the
-     activity masking constant. */
-  activity = calibration * pow(.25 + var_stat, -1. / 6);
-#else
-  activity = 1;
-#endif  // 1
-  sum = 0;
-  for (i = 0; i < 8; i++) {
-    for (j = 0; j < 8; j++)
-      sum += e_lp[i * stride + j] * (double)e_lp[i * stride + j];
-  }
-  /* Normalize the filter to unit DC response. */
-  sum *= 1. / (OD_DIST_LP_NORM * OD_DIST_LP_NORM * OD_DIST_LP_NORM *
-               OD_DIST_LP_NORM);
-  return activity * activity * (sum + vardist);
-}
-
-// Note : Inputs x and y are in a pixel domain
-static double od_compute_dist_common(int activity_masking, uint16_t *x,
-                                     uint16_t *y, int bsize_w, int bsize_h,
-                                     int qindex, od_coeff *tmp,
-                                     od_coeff *e_lp) {
-  int i, j;
-  double sum = 0;
-  const int mid = OD_DIST_LP_MID;
-
-  for (j = 0; j < bsize_w; j++) {
-    e_lp[j] = mid * tmp[j] + 2 * tmp[bsize_w + j];
-    e_lp[(bsize_h - 1) * bsize_w + j] = mid * tmp[(bsize_h - 1) * bsize_w + j] +
-                                        2 * tmp[(bsize_h - 2) * bsize_w + j];
-  }
-  for (i = 1; i < bsize_h - 1; i++) {
-    for (j = 0; j < bsize_w; j++) {
-      e_lp[i * bsize_w + j] = mid * tmp[i * bsize_w + j] +
-                              tmp[(i - 1) * bsize_w + j] +
-                              tmp[(i + 1) * bsize_w + j];
-    }
-  }
-  for (i = 0; i < bsize_h; i += 8) {
-    for (j = 0; j < bsize_w; j += 8) {
-      sum += od_compute_dist_8x8(activity_masking, &x[i * bsize_w + j],
-                                 &y[i * bsize_w + j], &e_lp[i * bsize_w + j],
-                                 bsize_w);
-    }
-  }
-  /* Scale according to linear regression against SSE, for 8x8 blocks. */
-  if (activity_masking) {
-    sum *= 2.2 + (1.7 - 2.2) * (qindex - 99) / (210 - 99) +
-           (qindex < 99 ? 2.5 * (qindex - 99) / 99 * (qindex - 99) / 99 : 0);
-  } else {
-    sum *= qindex >= 128
-               ? 1.4 + (0.9 - 1.4) * (qindex - 128) / (209 - 128)
-               : qindex <= 43 ? 1.5 + (2.0 - 1.5) * (qindex - 43) / (16 - 43)
-                              : 1.5 + (1.4 - 1.5) * (qindex - 43) / (128 - 43);
-  }
-
-  return sum;
-}
-
-static double od_compute_dist(uint16_t *x, uint16_t *y, int bsize_w,
-                              int bsize_h, int qindex) {
-  assert(bsize_w >= 8 && bsize_h >= 8);
-
-  int activity_masking = 0;
-
-  int i, j;
-  DECLARE_ALIGNED(16, od_coeff, e[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, od_coeff, tmp[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, od_coeff, e_lp[MAX_SB_SQUARE]);
-  for (i = 0; i < bsize_h; i++) {
-    for (j = 0; j < bsize_w; j++) {
-      e[i * bsize_w + j] = x[i * bsize_w + j] - y[i * bsize_w + j];
-    }
-  }
-  int mid = OD_DIST_LP_MID;
-  for (i = 0; i < bsize_h; i++) {
-    tmp[i * bsize_w] = mid * e[i * bsize_w] + 2 * e[i * bsize_w + 1];
-    tmp[i * bsize_w + bsize_w - 1] =
-        mid * e[i * bsize_w + bsize_w - 1] + 2 * e[i * bsize_w + bsize_w - 2];
-    for (j = 1; j < bsize_w - 1; j++) {
-      tmp[i * bsize_w + j] = mid * e[i * bsize_w + j] + e[i * bsize_w + j - 1] +
-                             e[i * bsize_w + j + 1];
-    }
-  }
-  return od_compute_dist_common(activity_masking, x, y, bsize_w, bsize_h,
-                                qindex, tmp, e_lp);
-}
-
-static double od_compute_dist_diff(uint16_t *x, int16_t *e, int bsize_w,
-                                   int bsize_h, int qindex) {
-  assert(bsize_w >= 8 && bsize_h >= 8);
-
-  int activity_masking = 0;
-
-  DECLARE_ALIGNED(16, uint16_t, y[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, od_coeff, tmp[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, od_coeff, e_lp[MAX_SB_SQUARE]);
-  int i, j;
-  for (i = 0; i < bsize_h; i++) {
-    for (j = 0; j < bsize_w; j++) {
-      y[i * bsize_w + j] = x[i * bsize_w + j] - e[i * bsize_w + j];
-    }
-  }
-  int mid = OD_DIST_LP_MID;
-  for (i = 0; i < bsize_h; i++) {
-    tmp[i * bsize_w] = mid * e[i * bsize_w] + 2 * e[i * bsize_w + 1];
-    tmp[i * bsize_w + bsize_w - 1] =
-        mid * e[i * bsize_w + bsize_w - 1] + 2 * e[i * bsize_w + bsize_w - 2];
-    for (j = 1; j < bsize_w - 1; j++) {
-      tmp[i * bsize_w + j] = mid * e[i * bsize_w + j] + e[i * bsize_w + j - 1] +
-                             e[i * bsize_w + j + 1];
-    }
-  }
-  return od_compute_dist_common(activity_masking, x, y, bsize_w, bsize_h,
-                                qindex, tmp, e_lp);
-}
-
-int64_t av1_dist_8x8(const AV1_COMP *const cpi, const MACROBLOCK *x,
-                     const uint8_t *src, int src_stride, const uint8_t *dst,
-                     int dst_stride, const BLOCK_SIZE tx_bsize, int bsw,
-                     int bsh, int visible_w, int visible_h, int qindex) {
-  int64_t d = 0;
-  int i, j;
-  const MACROBLOCKD *xd = &x->e_mbd;
-
-  DECLARE_ALIGNED(16, uint16_t, orig[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, uint16_t, rec[MAX_SB_SQUARE]);
-
-  assert(bsw >= 8);
-  assert(bsh >= 8);
-  assert((bsw & 0x07) == 0);
-  assert((bsh & 0x07) == 0);
-
-  if (x->tune_metric == AOM_TUNE_CDEF_DIST ||
-      x->tune_metric == AOM_TUNE_DAALA_DIST) {
-    if (is_cur_buf_hbd(xd)) {
-      for (j = 0; j < bsh; j++)
-        for (i = 0; i < bsw; i++)
-          orig[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
-
-      if ((bsw == visible_w) && (bsh == visible_h)) {
-        for (j = 0; j < bsh; j++)
-          for (i = 0; i < bsw; i++)
-            rec[j * bsw + i] = CONVERT_TO_SHORTPTR(dst)[j * dst_stride + i];
-      } else {
-        for (j = 0; j < visible_h; j++)
-          for (i = 0; i < visible_w; i++)
-            rec[j * bsw + i] = CONVERT_TO_SHORTPTR(dst)[j * dst_stride + i];
-
-        if (visible_w < bsw) {
-          for (j = 0; j < bsh; j++)
-            for (i = visible_w; i < bsw; i++)
-              rec[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
-        }
-
-        if (visible_h < bsh) {
-          for (j = visible_h; j < bsh; j++)
-            for (i = 0; i < bsw; i++)
-              rec[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
-        }
-      }
-    } else {
-      for (j = 0; j < bsh; j++)
-        for (i = 0; i < bsw; i++) orig[j * bsw + i] = src[j * src_stride + i];
-
-      if ((bsw == visible_w) && (bsh == visible_h)) {
-        for (j = 0; j < bsh; j++)
-          for (i = 0; i < bsw; i++) rec[j * bsw + i] = dst[j * dst_stride + i];
-      } else {
-        for (j = 0; j < visible_h; j++)
-          for (i = 0; i < visible_w; i++)
-            rec[j * bsw + i] = dst[j * dst_stride + i];
-
-        if (visible_w < bsw) {
-          for (j = 0; j < bsh; j++)
-            for (i = visible_w; i < bsw; i++)
-              rec[j * bsw + i] = src[j * src_stride + i];
-        }
-
-        if (visible_h < bsh) {
-          for (j = visible_h; j < bsh; j++)
-            for (i = 0; i < bsw; i++)
-              rec[j * bsw + i] = src[j * src_stride + i];
-        }
-      }
-    }
-  }
-
-  if (x->tune_metric == AOM_TUNE_DAALA_DIST) {
-    d = (int64_t)od_compute_dist(orig, rec, bsw, bsh, qindex);
-  } else if (x->tune_metric == AOM_TUNE_CDEF_DIST) {
-    int coeff_shift = AOMMAX(xd->bd - 8, 0);
-
-    for (i = 0; i < bsh; i += 8) {
-      for (j = 0; j < bsw; j += 8) {
-        d += cdef_dist_8x8_16bit(&rec[i * bsw + j], bsw, &orig[i * bsw + j],
-                                 bsw, coeff_shift);
-      }
-    }
-    if (is_cur_buf_hbd(xd)) d = ((uint64_t)d) >> 2 * coeff_shift;
-  } else {
-    // Otherwise, MSE by default
-    d = pixel_dist_visible_only(cpi, x, src, src_stride, dst, dst_stride,
-                                tx_bsize, bsh, bsw, visible_h, visible_w);
-  }
-
-  return d;
-}
-
-static int64_t dist_8x8_diff(const MACROBLOCK *x, const uint8_t *src,
-                             int src_stride, const int16_t *diff,
-                             int diff_stride, int bsw, int bsh, int visible_w,
-                             int visible_h, int qindex) {
-  int64_t d = 0;
-  int i, j;
-  const MACROBLOCKD *xd = &x->e_mbd;
-
-  DECLARE_ALIGNED(16, uint16_t, orig[MAX_SB_SQUARE]);
-  DECLARE_ALIGNED(16, int16_t, diff16[MAX_SB_SQUARE]);
-
-  assert(bsw >= 8);
-  assert(bsh >= 8);
-  assert((bsw & 0x07) == 0);
-  assert((bsh & 0x07) == 0);
-
-  if (x->tune_metric == AOM_TUNE_CDEF_DIST ||
-      x->tune_metric == AOM_TUNE_DAALA_DIST) {
-    if (is_cur_buf_hbd(xd)) {
-      for (j = 0; j < bsh; j++)
-        for (i = 0; i < bsw; i++)
-          orig[j * bsw + i] = CONVERT_TO_SHORTPTR(src)[j * src_stride + i];
-    } else {
-      for (j = 0; j < bsh; j++)
-        for (i = 0; i < bsw; i++) orig[j * bsw + i] = src[j * src_stride + i];
-    }
-
-    if ((bsw == visible_w) && (bsh == visible_h)) {
-      for (j = 0; j < bsh; j++)
-        for (i = 0; i < bsw; i++)
-          diff16[j * bsw + i] = diff[j * diff_stride + i];
-    } else {
-      for (j = 0; j < visible_h; j++)
-        for (i = 0; i < visible_w; i++)
-          diff16[j * bsw + i] = diff[j * diff_stride + i];
-
-      if (visible_w < bsw) {
-        for (j = 0; j < bsh; j++)
-          for (i = visible_w; i < bsw; i++) diff16[j * bsw + i] = 0;
-      }
-
-      if (visible_h < bsh) {
-        for (j = visible_h; j < bsh; j++)
-          for (i = 0; i < bsw; i++) diff16[j * bsw + i] = 0;
-      }
-    }
-  }
-
-  if (x->tune_metric == AOM_TUNE_DAALA_DIST) {
-    d = (int64_t)od_compute_dist_diff(orig, diff16, bsw, bsh, qindex);
-  } else if (x->tune_metric == AOM_TUNE_CDEF_DIST) {
-    int coeff_shift = AOMMAX(xd->bd - 8, 0);
-    DECLARE_ALIGNED(16, uint16_t, dst16[MAX_SB_SQUARE]);
-
-    for (i = 0; i < bsh; i++) {
-      for (j = 0; j < bsw; j++) {
-        dst16[i * bsw + j] = orig[i * bsw + j] - diff16[i * bsw + j];
-      }
-    }
-
-    for (i = 0; i < bsh; i += 8) {
-      for (j = 0; j < bsw; j += 8) {
-        d += cdef_dist_8x8_16bit(&dst16[i * bsw + j], bsw, &orig[i * bsw + j],
-                                 bsw, coeff_shift);
-      }
-    }
-    // Don't scale 'd' for HBD since it will be done by caller side for diff
-    // input
-  } else {
-    // Otherwise, MSE by default
-    d = aom_sum_squares_2d_i16(diff, diff_stride, visible_w, visible_h);
-  }
-
-  return d;
-}
-#endif  // CONFIG_DIST_8X8
-
 // Similar to get_horver_correlation, but also takes into account first
 // row/column, when computing horizontal/vertical correlation.
 void av1_get_horver_correlation_full_c(const int16_t *diff, int stride,
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index e6aa75c..3a59ea4 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -42,13 +42,6 @@
 int av1_count_colors_highbd(const uint8_t *src8, int stride, int rows, int cols,
                             int bit_depth, int *val_count);
 
-#if CONFIG_DIST_8X8
-int64_t av1_dist_8x8(const struct AV1_COMP *const cpi, const MACROBLOCK *x,
-                     const uint8_t *src, int src_stride, const uint8_t *dst,
-                     int dst_stride, const BLOCK_SIZE tx_bsize, int bsw,
-                     int bsh, int visible_w, int visible_h, int qindex);
-#endif
-
 static INLINE int av1_cost_skip_txb(MACROBLOCK *x, const TXB_CTX *const txb_ctx,
                                     int plane, TX_SIZE tx_size) {
   const TX_SIZE txs_ctx = get_txsize_entropy_ctx(tx_size);
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 5088b55..d558343 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1256,11 +1256,6 @@
          tx_size_search_methods[cpi->sf.winner_mode_sf.tx_size_search_level],
          sizeof(cpi->tx_size_search_methods));
 
-#if CONFIG_DIST_8X8
-  if (sf->tx_domain_dist_level > 0) cpi->oxcf.using_dist_8x8 = 0;
-
-  if (cpi->oxcf.using_dist_8x8) x->min_partition_size = BLOCK_8X8;
-#endif  // CONFIG_DIST_8X8
   if (cpi->oxcf.row_mt == 1 && (cpi->oxcf.max_threads > 1)) {
     if (sf->inter_sf.inter_mode_rd_model_estimation == 1) {
       // Revert to type 2
diff --git a/av1/encoder/tx_search.c b/av1/encoder/tx_search.c
index 8398917..02b7b64 100644
--- a/av1/encoder/tx_search.c
+++ b/av1/encoder/tx_search.c
@@ -374,19 +374,7 @@
                      NULL, &visible_cols, &visible_rows);
   const int diff_stride = block_size_wide[plane_bsize];
   const int16_t *diff = x->plane[plane].src_diff;
-#if CONFIG_DIST_8X8
-  int txb_height = block_size_high[tx_bsize];
-  int txb_width = block_size_wide[tx_bsize];
-  if (x->using_dist_8x8 && plane == 0) {
-    const int src_stride = x->plane[plane].src.stride;
-    const int src_idx = (blk_row * src_stride + blk_col) << MI_SIZE_LOG2;
-    const int diff_idx = (blk_row * diff_stride + blk_col) << MI_SIZE_LOG2;
-    const uint8_t *src = &x->plane[plane].src.buf[src_idx];
-    return dist_8x8_diff(x, src, src_stride, diff + diff_idx, diff_stride,
-                         txb_width, txb_height, visible_cols, visible_rows,
-                         x->qindex);
-  }
-#endif
+
   diff += ((blk_row * diff_stride + blk_col) << MI_SIZE_LOG2);
   uint64_t sse =
       aom_sum_squares_2d_i16(diff, diff_stride, visible_cols, visible_rows);
@@ -1199,13 +1187,6 @@
   assert(visible_rows > 0);
   assert(visible_cols > 0);
 
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8 && plane == 0)
-    return (unsigned)av1_dist_8x8(cpi, x, src, src_stride, dst, dst_stride,
-                                  tx_bsize, txb_cols, txb_rows, visible_cols,
-                                  visible_rows, x->qindex);
-#endif  // CONFIG_DIST_8X8
-
   unsigned sse = pixel_dist_visible_only(cpi, x, src, src_stride, dst,
                                          dst_stride, tx_bsize, txb_rows,
                                          txb_cols, visible_rows, visible_cols);
@@ -2211,9 +2192,6 @@
       // Therefore transform domain distortion is not valid for these
       // transform sizes.
       txsize_sqr_up_map[tx_size] != TX_64X64;
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8) use_transform_domain_distortion = 0;
-#endif
   int calc_pixel_domain_distortion_final =
       x->use_transform_domain_distortion == 1 &&
       use_transform_domain_distortion && x->rd_model != LOW_TXFM_RD;
@@ -2608,10 +2586,6 @@
   const int try_no_split =
       cpi->oxcf.enable_tx64 || txsize_sqr_up_map[tx_size] != TX_64X64;
   int try_split = tx_size > TX_4X4 && depth < MAX_VARTX_DEPTH;
-#if CONFIG_DIST_8X8
-  if (x->using_dist_8x8)
-    try_split &= tx_size_wide[tx_size] >= 16 && tx_size_high[tx_size] >= 16;
-#endif
   TxCandidateInfo no_split = { INT64_MAX, 0, TX_TYPES };
 
   // TX no split
@@ -2787,11 +2761,6 @@
   int64_t rd[MAX_TX_DEPTH + 1] = { INT64_MAX, INT64_MAX, INT64_MAX };
   for (int n = start_tx; depth <= MAX_TX_DEPTH;
        depth++, n = sub_tx_size_map[n]) {
-#if CONFIG_DIST_8X8
-    if (x->using_dist_8x8) {
-      if (tx_size_wide[n] < 8 || tx_size_high[n] < 8) continue;
-    }
-#endif
     if (!cpi->oxcf.enable_tx64 && txsize_sqr_up_map[n] == TX_64X64) continue;
 
     RD_STATS this_rd_stats;