Remove LPF_DIRECT experiment

This experiment has been abandonned for AV1.

Change-Id: I599608060ade646d6551dea7cfc680f83ee9d507
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index 7f5c4dc..3e8ce50 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -35,260 +35,6 @@
 #endif  // CONFIG_EXT_DELTA_Q
 #endif  // CONFIG_LOOPFILTER_LEVEL
 
-#if CONFIG_LPF_DIRECT
-static void pick_filter_pixel_left(uint8_t *const src, uint8_t *const line,
-                                   int *const orig_pos, int length, int row,
-                                   int col, int width, int height, int pitch,
-                                   int pivot, int direct) {
-  int i;
-  int pos = row * pitch + col;
-
-  for (i = 0; i < length; ++i) {
-    int dy = 0;
-    switch (direct) {
-      case VERT_HORZ: dy = 0; break;
-      case DEGREE_45: dy = 1; break;
-      case DEGREE_135: dy = -1; break;
-    }
-    col -= 1;
-    row += dy;
-    if (col >= 0 && col < width && row >= 0 && row < height) {
-      pos = row * pitch + col;
-      line[pivot - 1 - i] = src[pos];
-      orig_pos[pivot - 1 - i] = pos;
-    }
-  }
-}
-
-static void pick_filter_pixel_right(uint8_t *const src, uint8_t *const line,
-                                    int *const orig_pos, int length, int row,
-                                    int col, int width, int height, int pitch,
-                                    int pivot, int direct) {
-  int i;
-  int pos = row * pitch + col;
-
-  line[pivot] = src[pos];
-  orig_pos[pivot] = pos;
-
-  for (i = 1; i < length; ++i) {
-    int dy = 0;
-    switch (direct) {
-      case VERT_HORZ: dy = 0; break;
-      case DEGREE_45: dy = -1; break;
-      case DEGREE_135: dy = 1; break;
-    }
-    col += 1;
-    row += dy;
-    if (col >= 0 && col < width && row >= 0 && row < height) {
-      pos = row * pitch + col;
-      line[pivot + i] = src[pos];
-      orig_pos[pivot + i] = pos;
-    }
-  }
-}
-
-static void pick_filter_pixel_above(uint8_t *const src, uint8_t *const line,
-                                    int *const orig_pos, int length, int row,
-                                    int col, int width, int height, int pitch,
-                                    int pivot, int direct) {
-  int i;
-  int pos = row * pitch + col;
-
-  for (i = 0; i < length; ++i) {
-    int dx = 0;
-    switch (direct) {
-      case VERT_HORZ: dx = 0; break;
-      case DEGREE_45: dx = 1; break;
-      case DEGREE_135: dx = -1; break;
-    }
-    col += dx;
-    row -= 1;
-    if (col >= 0 && col < width && row >= 0 && row < height) {
-      pos = row * pitch + col;
-      line[pivot - 1 - i] = src[pos];
-      orig_pos[pivot - 1 - i] = pos;
-    }
-  }
-}
-
-static void pick_filter_pixel_bot(uint8_t *const src, uint8_t *const line,
-                                  int *const orig_pos, int length, int row,
-                                  int col, int width, int height, int pitch,
-                                  int pivot, int direct) {
-  int i;
-  int pos = row * pitch + col;
-
-  line[pivot] = src[pos];
-  orig_pos[pivot] = pos;
-
-  for (i = 1; i < length; ++i) {
-    int dx = 0;
-    switch (direct) {
-      case VERT_HORZ: dx = 0; break;
-      case DEGREE_45: dx = -1; break;
-      case DEGREE_135: dx = 1; break;
-    }
-    col += dx;
-    row += 1;
-    if (col >= 0 && col < width && row >= 0 && row < height) {
-      pos = row * pitch + col;
-      line[pivot + i] = src[pos];
-      orig_pos[pivot + i] = pos;
-    }
-  }
-}
-
-static void pick_filter_block_vert(uint8_t *const src, uint8_t *const block,
-                                   int *const orig_pos, int length, int row,
-                                   int col, int width, int height, int pitch,
-                                   int pivot, int line_length, int unit,
-                                   int direct) {
-  int i;
-  for (i = 0; i < 8 * unit; ++i) {
-    pick_filter_pixel_left(src, block + i * line_length,
-                           orig_pos + i * line_length, length, row + i, col,
-                           width, height, pitch, pivot, direct);
-    pick_filter_pixel_right(src, block + i * line_length,
-                            orig_pos + i * line_length, length, row + i, col,
-                            width, height, pitch, pivot, direct);
-  }
-}
-
-static void pick_filter_block_horz(uint8_t *const src, uint8_t *const block,
-                                   int *const orig_pos, int length, int row,
-                                   int col, int width, int height, int pitch,
-                                   int pivot, int line_length, int unit,
-                                   int direct) {
-  int i, j;
-  int num = 8 * unit;
-  for (i = 0; i < num; ++i) {
-    pick_filter_pixel_above(src, block + i * line_length,
-                            orig_pos + i * line_length, length, row, col + i,
-                            width, height, pitch, pivot, direct);
-    pick_filter_pixel_bot(src, block + i * line_length,
-                          orig_pos + i * line_length, length, row, col + i,
-                          width, height, pitch, pivot, direct);
-  }
-
-  // rearrange block
-  // TODO(chengchen): make it in-place or a stand alone function
-  uint8_t tmp_block[256];
-  int tmp_pos[256];
-  for (i = 0; i < 256; ++i) {
-    tmp_block[i] = 0;
-    tmp_pos[i] = -1;
-  }
-  for (i = 0; i < num; ++i) {
-    for (j = 0; j < line_length; ++j) {
-      tmp_block[j * line_length + i] = block[i * line_length + j];
-      tmp_pos[j * line_length + i] = orig_pos[i * line_length + j];
-    }
-  }
-  for (i = 0; i < 256; ++i) {
-    block[i] = tmp_block[i];
-    orig_pos[i] = tmp_pos[i];
-  }
-}
-
-static int compute_block_grad(uint8_t *const src, int length, int row, int col,
-                              int width, int height, int pitch, int unit,
-                              int vert_or_horz, int direct) {
-  int i, j;
-  int r0, c0, pos0, r1 = 0, c1 = 0, pos1;
-  int sum_grad = 0;
-  for (i = 0; i < 8 * unit; ++i) {
-    // vert_or_horz: 0 vertical edge, 1 horizontal edge
-    r0 = vert_or_horz ? row : row + i;
-    c0 = vert_or_horz ? col + i : col;
-    pos0 = r0 * pitch + c0;
-
-    for (j = 0; j < length; ++j) {
-      if (vert_or_horz == 0) {
-        switch (direct) {
-          case VERT_HORZ: r1 = r0; break;
-          case DEGREE_45: r1 = r0 + 1; break;
-          case DEGREE_135: r1 = r0 - 1; break;
-        }
-        c1 = c0 - 1;
-      } else {
-        r1 = r0 - 1;
-        switch (direct) {
-          case VERT_HORZ: c1 = c0; break;
-          case DEGREE_45: c1 = c0 + 1; break;
-          case DEGREE_135: c1 = c0 - 1; break;
-        }
-      }
-      pos1 = r1 * pitch + c1;
-
-      if (r0 >= 0 && r0 < height && c0 >= 0 && c0 < width && r1 >= 0 &&
-          r1 < height && c1 >= 0 && c1 < width) {
-        sum_grad += abs(src[pos1] - src[pos0]);
-      } else {
-        sum_grad += 255;  // penalize unreachable boundary
-      }
-      r0 = r1;
-      c0 = c1;
-      pos0 = pos1;
-    }
-
-    r0 = vert_or_horz ? row : row + i;
-    c0 = vert_or_horz ? col + i : col;
-    pos0 = r0 * pitch + c0;
-
-    for (j = 0; j < length - 1; ++j) {
-      if (vert_or_horz == 0) {
-        switch (direct) {
-          case VERT_HORZ: r1 = r0; break;
-          case DEGREE_45: r1 = r0 - 1; break;
-          case DEGREE_135: r1 = r0 + 1; break;
-        }
-        c1 = c0 + 1;
-      } else {
-        r1 = r0 + 1;
-        switch (direct) {
-          case VERT_HORZ: c1 = c0; break;
-          case DEGREE_45: c1 = c0 - 1; break;
-          case DEGREE_135: c1 = c0 + 1; break;
-        }
-      }
-      pos1 = r1 * pitch + c1;
-
-      if (r0 >= 0 && r0 < height && c0 >= 0 && c0 < width && r1 >= 0 &&
-          r1 < height && c1 >= 0 && c1 < width) {
-        sum_grad += abs(src[pos1] - src[pos0]);
-      } else {
-        sum_grad += 255;  // penalize unreachable boundary
-      }
-      r0 = r1;
-      c0 = c1;
-      pos0 = pos1;
-    }
-  }
-
-  return sum_grad;
-}
-
-static int pick_min_grad_direct(uint8_t *const src, int length, int row,
-                                int col, int width, int height, int pitch,
-                                int unit, int vert_or_horz) {
-  int direct = VERT_HORZ;
-  int min_grad = INT_MAX, sum_grad = 0;
-
-  int degree;
-  for (degree = 0; degree < FILTER_DEGREES; ++degree) {
-    // compute abs gradient along each line for the filter block
-    sum_grad = compute_block_grad(src, length, row, col, width, height, pitch,
-                                  unit, vert_or_horz, degree);
-    if (sum_grad < min_grad) {
-      min_grad = sum_grad;
-      direct = degree;
-    }
-  }
-
-  return direct;
-}
-#endif  // CONFIG_LPF_DIRECT
-
 #define PARALLEL_DEBLOCKING_15TAPLUMAONLY 1
 #define PARALLEL_DEBLOCKING_DISABLE_15TAP 0
 #if CONFIG_DEBLOCK_13TAP
@@ -987,21 +733,9 @@
 static void filter_selectively_horiz(
     uint8_t *s, int pitch, unsigned int mask_16x16, unsigned int mask_8x8,
     unsigned int mask_4x4, unsigned int mask_4x4_int,
-    const loop_filter_info_n *lfi_n, const uint8_t *lfl
-#if CONFIG_LPF_DIRECT
-    ,
-    uint8_t *const src, int mi_row, int mi_col, int idx_r, int col_step,
-    int width, int height, int ss_x, int ss_y
-#endif
-    ) {
+    const loop_filter_info_n *lfi_n, const uint8_t *lfl) {
   unsigned int mask;
   int count;
-#if CONFIG_LPF_DIRECT
-  // scale for u, v plane
-  width >>= ss_x;
-  height >>= ss_y;
-  int idx_c = 0;
-#endif
 
   for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int; mask;
        mask >>= count) {
@@ -1009,270 +743,6 @@
 
     count = 1;
     if (mask & 1) {
-#if CONFIG_LPF_DIRECT
-      int i;
-      const int line_length = 16;
-      const int pivot = 8;
-      const int above_filt_len = mask_16x16 & 1 ? 8 : 4;
-      const int bot_filt_len = mask_16x16 & 1 ? 8 : 4;
-      uint8_t block[256];  // line_length * size_of(BLOCK_8X8) * two_blocks
-      int orig_pos[256];
-      int direct;
-
-      assert(above_filt_len == bot_filt_len);
-      (void)bot_filt_len;
-      for (i = 0; i < 256; ++i) {
-        block[i] = 0;
-        orig_pos[i] = -1;
-      }
-
-      // actual position for current pixel
-      const int row = (mi_row + idx_r) * MI_SIZE >> ss_y;
-      const int col = (mi_col + idx_c) * MI_SIZE >> ss_x;
-
-      // Next block's thresholds.
-      const loop_filter_thresh *lfin = lfi_n->lfthr + *(lfl + 1);
-
-      if (mask_16x16 & 1) {
-        if ((mask_16x16 & 3) == 3) {
-          // Could use asymmetric length in the future
-          direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                        height, pitch, 2, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, above_filt_len, row, col,
-                                 width, height, pitch, pivot, line_length, 2,
-                                 direct);
-
-          aom_lpf_horizontal_edge_16(block + pivot * line_length, line_length,
-                                     lfi->mblim, lfi->lim, lfi->hev_thr);
-          count = 2;
-        } else {
-          direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                        height, pitch, 1, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, above_filt_len, row, col,
-                                 width, height, pitch, pivot, line_length, 1,
-                                 direct);
-
-          aom_lpf_horizontal_edge_8(block + pivot * line_length, line_length,
-                                    lfi->mblim, lfi->lim, lfi->hev_thr);
-        }
-
-        for (i = 0; i < 256; ++i)
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-      } else if (mask_8x8 & 1) {
-        if ((mask_8x8 & 3) == 3) {
-          count = 2;
-          direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                        height, pitch, 2, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, above_filt_len, row, col,
-                                 width, height, pitch, pivot, line_length, 2,
-                                 direct);
-
-          aom_lpf_horizontal_8_dual(block + pivot * line_length, line_length,
-                                    lfi->mblim, lfi->lim, lfi->hev_thr,
-                                    lfin->mblim, lfin->lim, lfin->hev_thr);
-
-          for (i = 0; i < 256; ++i)
-            if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-
-          if ((mask_4x4_int & 3) == 3) {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-
-            direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                          pitch, 2, 1);
-
-            pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col, width,
-                                   height, pitch, pivot, line_length, 2,
-                                   direct);
-
-            aom_lpf_horizontal_4_dual(block + pivot * line_length, line_length,
-                                      lfi->mblim, lfi->lim, lfi->hev_thr,
-                                      lfin->mblim, lfin->lim, lfin->hev_thr);
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          } else {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-
-            if (mask_4x4_int & 1) {
-              direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                            pitch, 1, 1);
-
-              pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col,
-                                     width, height, pitch, pivot, line_length,
-                                     1, direct);
-
-              aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                   lfi->mblim, lfi->lim, lfi->hev_thr);
-            } else if (mask_4x4_int & 2) {
-              direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                            pitch, 1, 1);
-
-              pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col + 8,
-                                     width, height, pitch, pivot, line_length,
-                                     1, direct);
-
-              aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                   lfin->mblim, lfin->lim, lfin->hev_thr);
-            }
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          }
-        } else {
-          direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                        height, pitch, 1, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, above_filt_len, row, col,
-                                 width, height, pitch, pivot, line_length, 1,
-                                 direct);
-
-          aom_lpf_horizontal_8(block + pivot * line_length, line_length,
-                               lfi->mblim, lfi->lim, lfi->hev_thr);
-
-          for (i = 0; i < 256; ++i)
-            if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-
-          if (mask_4x4_int & 1) {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-            direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                          pitch, 1, 1);
-
-            pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col, width,
-                                   height, pitch, pivot, line_length, 1,
-                                   direct);
-
-            aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                 lfi->mblim, lfi->lim, lfi->hev_thr);
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          }
-        }
-      } else if (mask_4x4 & 1) {
-        if ((mask_4x4 & 3) == 3) {
-          count = 2;
-          direct = pick_min_grad_direct(src, 4, row, col, width, height, pitch,
-                                        2, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, 4, row, col, width,
-                                 height, pitch, pivot, line_length, 2, direct);
-
-          aom_lpf_horizontal_4_dual(block + pivot * line_length, line_length,
-                                    lfi->mblim, lfi->lim, lfi->hev_thr,
-                                    lfin->mblim, lfin->lim, lfin->hev_thr);
-
-          for (i = 0; i < 256; ++i)
-            if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-
-          if ((mask_4x4_int & 3) == 3) {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-
-            direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                          pitch, 2, 1);
-
-            pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col, width,
-                                   height, pitch, pivot, line_length, 2,
-                                   direct);
-
-            aom_lpf_horizontal_4_dual(block + pivot * line_length, line_length,
-                                      lfi->mblim, lfi->lim, lfi->hev_thr,
-                                      lfin->mblim, lfin->lim, lfin->hev_thr);
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          } else {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-
-            if (mask_4x4_int & 1) {
-              direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                            pitch, 1, 1);
-
-              pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col,
-                                     width, height, pitch, pivot, line_length,
-                                     1, direct);
-
-              aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                   lfi->mblim, lfi->lim, lfi->hev_thr);
-            } else if (mask_4x4_int & 2) {
-              direct = pick_min_grad_direct(src, 4, row, col, width, height,
-                                            pitch, 1, 1);
-
-              pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col + 8,
-                                     width, height, pitch, pivot, line_length,
-                                     1, direct);
-
-              aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                   lfin->mblim, lfin->lim, lfin->hev_thr);
-            }
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          }
-        } else {
-          direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                        height, pitch, 1, 1);
-
-          pick_filter_block_horz(src, block, orig_pos, above_filt_len, row, col,
-                                 width, height, pitch, pivot, line_length, 1,
-                                 direct);
-
-          aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                               lfi->mblim, lfi->lim, lfi->hev_thr);
-
-          for (i = 0; i < 256; ++i)
-            if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-
-          if (mask_4x4_int & 1) {
-            for (i = 0; i < 256; ++i) {
-              block[i] = 0;
-              orig_pos[i] = -1;
-            }
-            direct = pick_min_grad_direct(src, above_filt_len, row, col, width,
-                                          height, pitch, 1, 1);
-
-            pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col, width,
-                                   height, pitch, pivot, line_length, 1,
-                                   direct);
-
-            aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                                 lfi->mblim, lfi->lim, lfi->hev_thr);
-
-            for (i = 0; i < 256; ++i)
-              if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-          }
-        }
-      } else if (mask_4x4_int & 1) {
-        direct =
-            pick_min_grad_direct(src, 4, row, col, width, height, pitch, 1, 1);
-
-        pick_filter_block_horz(src, block, orig_pos, 4, row + 4, col, width,
-                               height, pitch, pivot, line_length, 1, direct);
-
-        aom_lpf_horizontal_4(block + pivot * line_length, line_length,
-                             lfi->mblim, lfi->lim, lfi->hev_thr);
-
-        for (i = 0; i < 256; ++i)
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-      }
-#else   // CONFIG_LPF_DIRECT
       if (mask_16x16 & 1) {
         if ((mask_16x16 & 3) == 3) {
           aom_lpf_horizontal_edge_16(s, pitch, lfi->mblim, lfi->lim,
@@ -1344,11 +814,7 @@
         aom_lpf_horizontal_4(s + 4 * pitch, pitch, lfi->mblim, lfi->lim,
                              lfi->hev_thr);
       }
-#endif  // CONFIG_LPF_DIRECT
     }
-#if CONFIG_LPF_DIRECT
-    idx_c += col_step * count;
-#endif
     s += 8 * count;
     lfl += count;
     mask_16x16 >>= count;
@@ -1913,91 +1379,13 @@
 static void filter_selectively_vert(
     uint8_t *s, int pitch, unsigned int mask_16x16, unsigned int mask_8x8,
     unsigned int mask_4x4, unsigned int mask_4x4_int,
-    const loop_filter_info_n *lfi_n, const uint8_t *lfl
-#if CONFIG_LPF_DIRECT
-    ,
-    uint8_t *const src, int mi_row, int mi_col, int idx_r, int col_step,
-    int width, int height, int ss_x, int ss_y
-#endif
-    ) {
+    const loop_filter_info_n *lfi_n, const uint8_t *lfl) {
   unsigned int mask;
-#if CONFIG_LPF_DIRECT
-  // scale for u, v plane
-  width >>= ss_x;
-  height >>= ss_y;
-  int idx_c = 0;
-#endif
 
   for (mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int; mask;
        mask >>= 1) {
     const loop_filter_thresh *lfi = lfi_n->lfthr + *lfl;
 
-#if CONFIG_LPF_DIRECT
-    int i;
-    const int pivot = 8;
-    const int left_filt_len = mask_16x16 & 1 ? 8 : 4;
-    const int right_filt_len = mask_16x16 & 1 ? 8 : 4;
-    const int line_length = 16;
-    uint8_t block[128];
-    int orig_pos[128];
-
-    // actual position for current pixel
-    const int row = (mi_row + idx_r) * MI_SIZE >> ss_y;
-    const int col = (mi_col + idx_c) * MI_SIZE >> ss_x;
-
-    // Could use asymmetric length in the future
-    assert(left_filt_len == right_filt_len);
-    (void)right_filt_len;
-
-    if ((mask_16x16 & 1) || (mask_8x8 & 1) || (mask_4x4 & 1)) {
-      for (i = 0; i < 128; ++i) {
-        block[i] = 0;
-        orig_pos[i] = -1;
-      }
-
-      const int direct = pick_min_grad_direct(src, left_filt_len, row, col,
-                                              width, height, pitch, 1, 0);
-
-      pick_filter_block_vert(src, block, orig_pos, left_filt_len, row, col,
-                             width, height, pitch, pivot, line_length, 1,
-                             direct);
-
-      // apply filtering
-      if (mask_16x16 & 1) {
-        aom_lpf_vertical_16(block + pivot, line_length, lfi->mblim, lfi->lim,
-                            lfi->hev_thr);
-      } else if (mask_8x8 & 1) {
-        aom_lpf_vertical_8(block + pivot, line_length, lfi->mblim, lfi->lim,
-                           lfi->hev_thr);
-      } else if (mask_4x4 & 1) {
-        aom_lpf_vertical_4(block + pivot, line_length, lfi->mblim, lfi->lim,
-                           lfi->hev_thr);
-      }
-
-      for (i = 0; i < 128; ++i)
-        if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-    }
-
-    // filter inner 4x4
-    if (mask_4x4_int & 1) {
-      for (i = 0; i < 128; ++i) {
-        block[i] = 0;
-        orig_pos[i] = -1;
-      }
-
-      const int direct = pick_min_grad_direct(src, 4, row, col + 4, width,
-                                              height, pitch, 1, 0);
-
-      pick_filter_block_vert(src, block, orig_pos, 4, row, col + 4, width,
-                             height, pitch, pivot, line_length, 1, direct);
-
-      aom_lpf_vertical_4(block + pivot, line_length, lfi->mblim, lfi->lim,
-                         lfi->hev_thr);
-
-      for (i = 0; i < 128; ++i)
-        if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-    }
-#else
     if (mask & 1) {
       if (mask_16x16 & 1) {
         aom_lpf_vertical_16(s, pitch, lfi->mblim, lfi->lim, lfi->hev_thr);
@@ -2009,10 +1397,6 @@
     }
     if (mask_4x4_int & 1)
       aom_lpf_vertical_4(s + 4, pitch, lfi->mblim, lfi->lim, lfi->hev_thr);
-#endif  // CONFIG_LPF_DIRECT
-#if CONFIG_LPF_DIRECT
-    idx_c += col_step;
-#endif
     s += 8;
     lfl += 1;
     mask_16x16 >>= 1;
@@ -2272,10 +1656,6 @@
                                        int pl) {
   const int ss_y = plane->subsampling_y;
   const int row_step = mi_size_high[BLOCK_8X8] << ss_y;
-#if CONFIG_LPF_DIRECT
-  const int ss_x = plane->subsampling_x;
-  const int col_step = mi_size_wide[BLOCK_8X8] << ss_x;
-#endif
   struct buf_2d *const dst = &plane->dst;
   uint8_t *const dst0 = dst->buf;
   uint8_t lfl[MAX_MIB_SIZE][MAX_MIB_SIZE] = { { 0 } };
@@ -2312,13 +1692,7 @@
       filter_selectively_vert(
           dst->buf, dst->stride, col_masks.m16x16 & border_mask,
           col_masks.m8x8 & border_mask, col_masks.m4x4 & border_mask,
-          mask_4x4_int, &cm->lf_info, &lfl[r][0]
-#if CONFIG_LPF_DIRECT
-          ,
-          dst->buf0, mi_row, mi_col, idx_r, col_step, cm->width, cm->height,
-          ss_x, ss_y
-#endif  // CONFIG_LPF_DIRECT
-          );
+          mask_4x4_int, &cm->lf_info, &lfl[r][0]);
     dst->buf += 8 * dst->stride;
   }
 
@@ -2332,10 +1706,6 @@
                                        int pl) {
   const int ss_y = plane->subsampling_y;
   const int row_step = mi_size_high[BLOCK_8X8] << ss_y;
-#if CONFIG_LPF_DIRECT
-  const int ss_x = plane->subsampling_x;
-  const int col_step = mi_size_wide[BLOCK_8X8] << ss_x;
-#endif
   struct buf_2d *const dst = &plane->dst;
   uint8_t *const dst0 = dst->buf;
   uint8_t lfl[MAX_MIB_SIZE][MAX_MIB_SIZE] = { { 0 } };
@@ -2371,13 +1741,7 @@
 #endif  // CONFIG_HIGHBITDEPTH
       filter_selectively_horiz(dst->buf, dst->stride, row_masks.m16x16,
                                row_masks.m8x8, row_masks.m4x4, mask_4x4_int,
-                               &cm->lf_info, &lfl[r][0]
-#if CONFIG_LPF_DIRECT
-                               ,
-                               dst->buf0, mi_row, mi_col, idx_r, col_step,
-                               cm->width, cm->height, ss_x, ss_y
-#endif  // CONFIG_LPF_DIRECT
-                               );
+                               &cm->lf_info, &lfl[r][0]);
     dst->buf += 8 * dst->stride;
   }
   dst->buf = dst0;
@@ -2463,11 +1827,9 @@
           (int)cm->bit_depth);
     else
 #endif  // CONFIG_HIGHBITDEPTH
-#if !CONFIG_LPF_DIRECT
       filter_selectively_horiz(dst->buf, dst->stride, mask_16x16_r, mask_8x8_r,
                                mask_4x4_r, mask_4x4_int & 0xff, &cm->lf_info,
                                &lfm->lfl_y[r][0]);
-#endif  // CONFIG_LPF_DIRECT
 
     dst->buf += MI_SIZE * dst->stride;
     mask_16x16 >>= MI_SIZE;
@@ -2583,11 +1945,9 @@
           (int)cm->bit_depth);
     else
 #endif  // CONFIG_HIGHBITDEPTH
-#if !CONFIG_LPF_DIRECT
       filter_selectively_horiz(dst->buf, dst->stride, mask_16x16_r, mask_8x8_r,
                                mask_4x4_r, mask_4x4_int_r, &cm->lf_info,
                                &lfm->lfl_uv[r >> 1][0]);
-#endif  // CONFIG_LPF_DIRECT
 
     dst->buf += MI_SIZE * dst->stride;
     mask_16x16 >>= MI_SIZE / 2;
@@ -2967,108 +2327,6 @@
       set_lpf_parameters(&params, ((ptrdiff_t)1 << scale_horz), cm, VERT_EDGE,
                          curr_x, curr_y, plane, plane_ptr);
 
-#if CONFIG_LPF_DIRECT
-      uint8_t *const src = plane_ptr->dst.buf0;
-      const int width = cm->width >> scale_horz;
-      const int height = cm->height >> scale_vert;
-      const int pivot = 8;
-      const int line_length = 16;
-      uint8_t block[128];
-      int orig_pos[128];
-      const int vert_or_horz = 0;  // 0: vertical
-      const int unit = 1;
-      int i;
-      for (i = 0; i < 128; ++i) {
-        block[i] = 0;
-        orig_pos[i] = -1;
-      }
-
-      if (params.filter_length) {
-        const int filt_len = params.filter_length == 16 ? 8 : 4;
-        const int direct =
-            pick_min_grad_direct(src, filt_len, curr_y, curr_x, width, height,
-                                 dst_stride, unit, vert_or_horz);
-
-        pick_filter_block_vert(src, block, orig_pos, filt_len, curr_y, curr_x,
-                               width, height, dst_stride, pivot, line_length,
-                               unit, direct);
-        uint8_t *const filt_start = block + pivot;
-        switch (params.filter_length) {
-          // apply 4-tap filtering
-          case 4:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_vertical_4(CONVERT_TO_SHORTPTR(filt_start),
-                                        line_length, params.mblim, params.lim,
-                                        params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_vertical_4(filt_start, line_length, params.mblim,
-                                 params.lim, params.hev_thr);
-            break;
-          // apply 8-tap filtering
-          case 8:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_vertical_8(CONVERT_TO_SHORTPTR(filt_start),
-                                        line_length, params.mblim, params.lim,
-                                        params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_vertical_8(filt_start, line_length, params.mblim,
-                                 params.lim, params.hev_thr);
-            break;
-          // apply 16-tap filtering
-          case 16:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_vertical_16(CONVERT_TO_SHORTPTR(filt_start),
-                                         line_length, params.mblim, params.lim,
-                                         params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_vertical_16(filt_start, line_length, params.mblim,
-                                  params.lim, params.hev_thr);
-            break;
-          // no filtering
-          default: break;
-        }
-
-        for (i = 0; i < 128; ++i) {
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-        }
-      }
-
-      if (params.filter_length_internal) {
-        for (i = 0; i < 128; ++i) {
-          block[i] = 0;
-          orig_pos[i] = -1;
-        }
-
-        const int direct =
-            pick_min_grad_direct(src, 4, curr_y, curr_x + 4, width, height,
-                                 dst_stride, unit, vert_or_horz);
-
-        pick_filter_block_vert(src, block, orig_pos, 4, curr_y, curr_x + 4,
-                               width, height, dst_stride, pivot, line_length,
-                               unit, direct);
-
-        uint8_t *const filt_start = block + pivot;
-#if CONFIG_HIGHBITDEPTH
-        if (cm->use_highbitdepth)
-          aom_highbd_lpf_vertical_4(CONVERT_TO_SHORTPTR(filt_start),
-                                    line_length, params.mblim, params.lim,
-                                    params.hev_thr, cm->bit_depth);
-        else
-#endif  // CONFIG_HIGHBITDEPTH
-          aom_lpf_vertical_4(filt_start, line_length, params.mblim, params.lim,
-                             params.hev_thr);
-
-        for (i = 0; i < 128; ++i) {
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-        }
-      }
-#else  // !CONFIG_LPF_DIRECT
       switch (params.filter_length) {
         // apply 4-tap filtering
         case 4:
@@ -3147,7 +2405,6 @@
           aom_lpf_vertical_4(p + 4, dst_stride, params.mblim, params.lim,
                              params.hev_thr);
       }
-#endif  // CONFIG_LPF_DIRECT
       // advance the destination pointer
       p += MI_SIZE;
     }
@@ -3191,107 +2448,6 @@
       set_lpf_parameters(&params, (cm->mi_stride << scale_vert), cm, HORZ_EDGE,
                          curr_x, curr_y, plane, plane_ptr);
 
-#if CONFIG_LPF_DIRECT
-      uint8_t *const src = plane_ptr->dst.buf0;
-      const int width = cm->width >> scale_horz;
-      const int height = cm->height >> scale_vert;
-      const int pivot = 8;
-      const int line_length = 16;
-      uint8_t block[256];
-      int orig_pos[256];
-      const int vert_or_horz = 1;  // 1: horizontal
-      const int unit = 1;
-      int i;
-      for (i = 0; i < 256; ++i) {
-        block[i] = 0;
-        orig_pos[i] = -1;
-      }
-
-      if (params.filter_length) {
-        const int filt_len = params.filter_length == 16 ? 8 : 4;
-        const int direct =
-            pick_min_grad_direct(src, filt_len, curr_y, curr_x, width, height,
-                                 dst_stride, unit, vert_or_horz);
-
-        pick_filter_block_horz(src, block, orig_pos, filt_len, curr_y, curr_x,
-                               width, height, dst_stride, pivot, line_length,
-                               unit, direct);
-        uint8_t *const filt_start = block + pivot * line_length;
-        switch (params.filter_length) {
-          // apply 4-tap filtering
-          case 4:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_horizontal_4(CONVERT_TO_SHORTPTR(filt_start),
-                                          line_length, params.mblim, params.lim,
-                                          params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_horizontal_4(filt_start, line_length, params.mblim,
-                                   params.lim, params.hev_thr);
-            break;
-          // apply 8-tap filtering
-          case 8:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_horizontal_8(CONVERT_TO_SHORTPTR(filt_start),
-                                          line_length, params.mblim, params.lim,
-                                          params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_horizontal_8(filt_start, line_length, params.mblim,
-                                   params.lim, params.hev_thr);
-            break;
-          // apply 16-tap filtering
-          case 16:
-#if CONFIG_HIGHBITDEPTH
-            if (cm->use_highbitdepth)
-              aom_highbd_lpf_horizontal_edge_16(
-                  CONVERT_TO_SHORTPTR(filt_start), line_length, params.mblim,
-                  params.lim, params.hev_thr, cm->bit_depth);
-            else
-#endif  // CONFIG_HIGHBITDEPTH
-              aom_lpf_horizontal_edge_16(filt_start, line_length, params.mblim,
-                                         params.lim, params.hev_thr);
-            break;
-          // no filtering
-          default: break;
-        }
-
-        for (i = 0; i < 256; ++i) {
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-        }
-      }
-      if (params.filter_length_internal) {
-        for (i = 0; i < 256; ++i) {
-          block[i] = 0;
-          orig_pos[i] = -1;
-        }
-
-        const int direct =
-            pick_min_grad_direct(src, 4, curr_y + 4, curr_x, width, height,
-                                 dst_stride, unit, vert_or_horz);
-
-        pick_filter_block_horz(src, block, orig_pos, 4, curr_y + 4, curr_x,
-                               width, height, dst_stride, pivot, line_length,
-                               unit, direct);
-
-        uint8_t *const filt_start = block + pivot * line_length;
-#if CONFIG_HIGHBITDEPTH
-        if (cm->use_highbitdepth)
-          aom_highbd_lpf_horizontal_4(CONVERT_TO_SHORTPTR(filt_start),
-                                      line_length, params.mblim, params.lim,
-                                      params.hev_thr, cm->bit_depth);
-        else
-#endif  // CONFIG_HIGHBITDEPTH
-          aom_lpf_horizontal_4(filt_start, line_length, params.mblim,
-                               params.lim, params.hev_thr);
-
-        for (i = 0; i < 256; ++i) {
-          if (orig_pos[i] >= 0) src[orig_pos[i]] = block[i];
-        }
-      }
-#else  // !CONFIG_LPF_DIRECT
       switch (params.filter_length) {
         // apply 4-tap filtering
         case 4:
@@ -3370,7 +2526,6 @@
           aom_lpf_horizontal_4(p + 4 * dst_stride, dst_stride, params.mblim,
                                params.lim, params.hev_thr);
       }
-#endif  // CONFIG_LPF_DIRECT
       // advance the destination pointer
       p += MI_SIZE;
     }
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 8705f6d..404a5e9 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -697,19 +697,6 @@
 #define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
 #endif  // CONFIG_FRAME_SUPERRES
 
-#if CONFIG_LPF_DIRECT
-typedef enum {
-  VERT_HORZ,
-  DEGREE_30,
-  DEGREE_45,
-  DEGREE_60,
-  DEGREE_120,
-  DEGREE_135,
-  DEGREE_150,
-  FILTER_DEGREES,
-} FILTER_DEGREE;
-#endif  // CONFIG_LPF_DIRECT
-
 #if CONFIG_OBU
 // R19
 typedef enum ATTRIBUTE_PACKED {
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 88e5575..d3d7f21 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -160,7 +160,6 @@
 set(CONFIG_LOOPFILTERING_ACROSS_TILES 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LOOPFILTER_LEVEL 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LOOP_RESTORATION 1 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_LPF_DIRECT 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LPF_SB 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LV_MAP 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MASKED_TX 0 CACHE NUMBER "AV1 experiment flag.")
diff --git a/configure b/configure
index d62e4a7..6f716f4 100755
--- a/configure
+++ b/configure
@@ -317,7 +317,6 @@
     var_tx_no_tx_mode
     simplify_tx_mode
     mrc_tx
-    lpf_direct
     loopfilter_level
     no_frame_context_signaling
     txmg