Remove PEF

Remove PEF due to sub-block filtering has been moved to deblocking stage

Closes #230 and #231

STATS_CHANGED
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h
index eec06f2..7ad52e4 100644
--- a/aom/aom_encoder.h
+++ b/aom/aom_encoder.h
@@ -452,10 +452,6 @@
    *
    */
   unsigned int enable_ccso;
-  /*!\brief enable prediction enhancement filter
-   *
-   */
-  unsigned int enable_pef;
 #if CONFIG_LF_SUB_PU
   /*!\brief enable loop filter on sub-block
    *
diff --git a/apps/aomenc.c b/apps/aomenc.c
index 3670d6e..c5b2bfc 100644
--- a/apps/aomenc.c
+++ b/apps/aomenc.c
@@ -475,7 +475,6 @@
   &g_av1_codec_arg_defs.enable_affine_refine,
 #endif  // CONFIG_AFFINE_REFINEMENT
   &g_av1_codec_arg_defs.enable_ccso,
-  &g_av1_codec_arg_defs.enable_pef,
 #if CONFIG_LF_SUB_PU
   &g_av1_codec_arg_defs.enable_lf_sub_pu,
 #endif  // CONFIG_LF_SUB_PU
@@ -698,10 +697,7 @@
   config->enable_wiener_nonsep = 1;
   config->enable_ccso = 1;
 #if CONFIG_LF_SUB_PU
-  config->enable_pef = 0;
   config->enable_lf_sub_pu = 1;
-#else
-  config->enable_pef = 1;
 #endif  // CONFIG_LF_SUB_PU
   config->enable_obmc = 0;
   config->enable_warped_motion = 1;
@@ -1639,8 +1635,6 @@
   fprintf(stdout, "                               : AffineRefinement (%d)\n",
           encoder_cfg->enable_affine_refine);
 #endif  // CONFIG_AFFINE_REFINEMENT
-  fprintf(stdout, "                               : PEF (%d)\n",
-          encoder_cfg->enable_pef);
 
   fprintf(stdout,
           "Tool setting (Transform)       : Flip & IDT (%d), "
diff --git a/av1/arg_defs.c b/av1/arg_defs.c
index ea88891..74e4e5d 100644
--- a/av1/arg_defs.c
+++ b/av1/arg_defs.c
@@ -354,9 +354,6 @@
   .enable_ccso = ARG_DEF(NULL, "enable-ccso", 1,
                          "Enable cross component sample offset (0: false "
                          "1: true)"),
-  .enable_pef = ARG_DEF(NULL, "enable-pef", 1,
-                        "Enable prediction enhancement filter (0: false "
-                        "1: true)"),
 #if CONFIG_LF_SUB_PU
   .enable_lf_sub_pu = ARG_DEF(NULL, "enable-lf-sub-pu", 1,
                               "Enable the deblocking filter on sub prediction "
diff --git a/av1/arg_defs.h b/av1/arg_defs.h
index 8538acf..cd41e3e 100644
--- a/av1/arg_defs.h
+++ b/av1/arg_defs.h
@@ -136,7 +136,6 @@
   arg_def_t enable_pc_wiener;
   arg_def_t enable_wiener_nonsep;
   arg_def_t enable_ccso;
-  arg_def_t enable_pef;
 #if CONFIG_LF_SUB_PU
   arg_def_t enable_lf_sub_pu;
 #endif  // CONFIG_LF_SUB_PU
diff --git a/av1/av1.cmake b/av1/av1.cmake
index a1e4f9a..6967448 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -97,8 +97,6 @@
   "${AOM_ROOT}/av1/common/warped_motion.h"
   "${AOM_ROOT}/av1/common/hr_coding.h"
   "${AOM_ROOT}/av1/common/hr_coding.c")
-list(APPEND AOM_AV1_COMMON_SOURCES "${AOM_ROOT}/av1/common/pef.h")
-list(APPEND AOM_AV1_COMMON_SOURCES "${AOM_ROOT}/av1/common/pef.c")
 
 if(CONFIG_LPF_MASK)
   list(APPEND AOM_AV1_COMMON_SOURCES "${AOM_ROOT}/av1/common/loopfiltermask.c")
@@ -348,8 +346,6 @@
   "${AOM_ROOT}/av1/common/x86/highbd_warp_affine_avx2.c"
   "${AOM_ROOT}/av1/common/x86/reconinter_avx2.c"
   "${AOM_ROOT}/av1/common/x86/selfguided_avx2.c")
-list(APPEND AOM_AV1_COMMON_INTRIN_AVX2
-     "${AOM_ROOT}/av1/common/x86/highbd_pef_avx2.c")
 
 list(APPEND AOM_AV1_ENCODER_ASM_SSE2 "${AOM_ROOT}/av1/encoder/x86/dct_sse2.asm")
 
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 9ff98bd..c72af1f 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -73,7 +73,6 @@
   unsigned int enable_pc_wiener;
   unsigned int enable_wiener_nonsep;
   unsigned int enable_ccso;
-  unsigned int enable_pef;
 #if CONFIG_LF_SUB_PU
   unsigned int enable_lf_sub_pu;
 #endif  // CONFIG_LF_SUB_PU
@@ -413,10 +412,7 @@
   1,                                         // enable_wiener_nonsep
   1,                                         // enable_ccso
 #if CONFIG_LF_SUB_PU
-  0,  // enable_pef
-  1,  // enable_lf_sub_pu
-#else
-  1,                        // enable_pef
+  1,                            // enable_lf_sub_pu
 #endif                          // CONFIG_LF_SUB_PU
   0,                            // force_video_mode
   0,                            // enable_obmc
@@ -963,7 +959,6 @@
   cfg->enable_pc_wiener = extra_cfg->enable_pc_wiener;
   cfg->enable_wiener_nonsep = extra_cfg->enable_wiener_nonsep;
   cfg->enable_ccso = extra_cfg->enable_ccso;
-  cfg->enable_pef = extra_cfg->enable_pef;
 #if CONFIG_LF_SUB_PU
   cfg->enable_lf_sub_pu = extra_cfg->enable_lf_sub_pu;
 #endif  // CONFIG_LF_SUB_PU
@@ -1089,7 +1084,6 @@
   extra_cfg->enable_pc_wiener = cfg->enable_pc_wiener;
   extra_cfg->enable_wiener_nonsep = cfg->enable_wiener_nonsep;
   extra_cfg->enable_ccso = cfg->enable_ccso;
-  extra_cfg->enable_pef = cfg->enable_pef;
 #if CONFIG_LF_SUB_PU
   extra_cfg->enable_lf_sub_pu = cfg->enable_lf_sub_pu;
 #endif  // CONFIG_LF_SUB_PU
@@ -1398,16 +1392,6 @@
       (tool_cfg->enable_wiener | tool_cfg->enable_sgrproj |
        tool_cfg->enable_pc_wiener | tool_cfg->enable_wiener_nonsep);
   tool_cfg->enable_ccso = extra_cfg->enable_ccso;
-  tool_cfg->enable_pef = extra_cfg->enable_pef;
-  if (tool_cfg->enable_pef) {
-    if (cfg->g_lag_in_frames == 0) {
-      tool_cfg->enable_pef = 0;
-    }
-
-    if (cfg->kf_max_dist == 0) {
-      tool_cfg->enable_pef = 0;
-    }
-  }
 #if CONFIG_LF_SUB_PU
   tool_cfg->enable_lf_sub_pu = extra_cfg->enable_lf_sub_pu;
   if (tool_cfg->enable_lf_sub_pu) {
@@ -3779,9 +3763,6 @@
   } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_ccso, argv,
                               err_string)) {
     extra_cfg.enable_ccso = arg_parse_int_helper(&arg, err_string);
-  } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_pef, argv,
-                              err_string)) {
-    extra_cfg.enable_pef = arg_parse_int_helper(&arg, err_string);
 #if CONFIG_LF_SUB_PU
   } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_lf_sub_pu,
                               argv, err_string)) {
@@ -4477,8 +4458,6 @@
 #endif  // CONFIG_DERIVED_MVD_SIGN
         1, 1,   1,   1, 1, 1, 1, 1, 1,
 #if CONFIG_LF_SUB_PU
-        0, 1,
-#else
         1,
 #endif  // CONFIG_LF_SUB_PU
         1, 1,
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index 82a1dcf..2065255 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -20,7 +20,6 @@
 #include "aom_util/aom_thread.h"
 #include "av1/common/alloccommon.h"
 #include "av1/common/av1_loopfilter.h"
-#include "av1/common/pef.h"
 #include "av1/common/blockd.h"
 #include "av1/common/entropy.h"
 #include "av1/common/entropymode.h"
@@ -539,7 +538,6 @@
 
   uint8_t enable_restoration;  // To turn on/off loop restoration
   uint8_t enable_ccso;         // To turn on/off CCSO
-  uint8_t enable_pef;          // To turn on/off prediction enhancement filter
 #if CONFIG_LF_SUB_PU
   uint8_t enable_lf_sub_pu;          // To turn on/off sub-block deblocking
 #endif                               // CONFIG_LF_SUB_PU
@@ -758,10 +756,6 @@
    * Enables/disables hole fill for TIP
    */
   bool allow_tip_hole_fill;
-  /*!
-   * Enables/disables prediction enhancement filter
-   */
-  bool allow_pef;
 #if CONFIG_LF_SUB_PU
   /*!
    * Enables/disables loop filtering on sub block
@@ -1598,14 +1592,6 @@
   /**@}*/
 
   /**
-   * \name Prediction enhancement filter parameters.
-   */
-  /**@{*/
-  PefInfo pef_info;     /*!< Prediction enhancement filter info*/
-  PefParams pef_params; /*!< Prediction enhancement filter parameters*/
-  /**@}*/
-
-  /**
    * \name Loop Restoration filter parameters.
    */
   /**@{*/
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 8d405a4..53589c6 100644
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -600,12 +600,6 @@
   specialize qw/ccso_derive_src_block avx2/
 }
 
-# Prediction enhancement filter
-  add_proto qw / void highbd_filt_horz_pred /, "uint16_t *s, int stride, int bd, uint16_t q_thresh, uint16_t side_thresh, int q_mult, int w_mult, int n, int filt_len ";
-  specialize qw / highbd_filt_horz_pred avx2/;
-  add_proto qw / void highbd_filt_vert_pred/, "uint16_t *s, int stride, int bd, uint16_t q_thresh, uint16_t side_thresh, int q_mult, int w_mult, int n, int filt_len ";
-  specialize qw / highbd_filt_vert_pred avx2/;
-
 # WARPED_MOTION / GLOBAL_MOTION functions
 
 add_proto qw/void av1_highbd_warp_affine/, "const int32_t *mat, const uint16_t *ref, int width, int height, int stride, uint16_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int bd, ConvolveParams *conv_params, int16_t alpha, int16_t beta, int16_t gamma, int16_t delta";
diff --git a/av1/common/pef.c b/av1/common/pef.c
deleted file mode 100644
index 4a346c3..0000000
--- a/av1/common/pef.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Copyright (c) 2022, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 3-Clause Clear License
- * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
- * License was not distributed with this source code in the LICENSE file, you
- * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/.  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
- * aomedia.org/license/patent-license/.
- */
-
-#include <math.h>
-
-#include "config/aom_config.h"
-#include "config/aom_dsp_rtcd.h"
-#include "aom_dsp/aom_dsp_common.h"
-#include "aom_mem/aom_mem.h"
-#include "aom_ports/mem.h"
-#include "av1/common/av1_common_int.h"
-#include "av1/common/av1_loopfilter.h"
-#include "av1/common/reconinter.h"
-#include "av1/common/seg_common.h"
-static const int pef_w_mult[4] = { 85, 51, 37, 28 };
-static const int pef_q_mult[4] = { 32, 25, 19, 19 };
-
-void init_pef_parameter(AV1_COMMON *cm, int plane_start, int plane_end) {
-  int q_ind[MAX_MB_PLANE], q_ind_r[MAX_MB_PLANE], side_ind[MAX_MB_PLANE],
-      side_ind_r[MAX_MB_PLANE];
-  PefInfo *const pefi = &cm->pef_info;
-  PefParams *const pef = &cm->pef_params;
-  const int pef_delta = pef->pef_delta;
-  pef->filter_level[0] = 1;
-  pef->filter_level[1] = 1;
-  pef->filter_level_u = 1;
-  pef->filter_level_v = 1;
-  pef->delta_q_luma[0] = pef_delta;
-  pef->delta_q_luma[1] = pef_delta;
-  pef->delta_side_luma[0] = pef_delta;
-  pef->delta_side_luma[1] = pef_delta;
-  pef->delta_q_u = pef_delta;
-  pef->delta_side_u = pef_delta;
-  pef->delta_q_v = pef_delta;
-  pef->delta_side_v = pef_delta;
-  const int base_qindex = cm->quant_params.base_qindex;
-  const int u_ac_delta_q = cm->quant_params.u_ac_delta_q;
-  const int v_ac_delta_q = cm->quant_params.v_ac_delta_q;
-
-  q_ind[0] = base_qindex + pef->delta_q_luma[0] * PEF_DELTA_SCALE;
-  side_ind[0] = base_qindex + pef->delta_side_luma[0] * PEF_DELTA_SCALE;
-
-  q_ind[1] = base_qindex + u_ac_delta_q + pef->delta_q_u * PEF_DELTA_SCALE;
-  side_ind[1] =
-      base_qindex + u_ac_delta_q + pef->delta_side_u * PEF_DELTA_SCALE;
-
-  q_ind[2] = base_qindex + v_ac_delta_q + pef->delta_q_v * PEF_DELTA_SCALE;
-  side_ind[2] =
-      base_qindex + v_ac_delta_q + pef->delta_side_v * PEF_DELTA_SCALE;
-
-  q_ind_r[0] = base_qindex + pef->delta_q_luma[1] * PEF_DELTA_SCALE;
-  side_ind_r[0] = base_qindex + pef->delta_side_luma[1] * PEF_DELTA_SCALE;
-
-  q_ind_r[1] = base_qindex + u_ac_delta_q + pef->delta_q_u * PEF_DELTA_SCALE;
-  side_ind_r[1] =
-      base_qindex + u_ac_delta_q + pef->delta_side_u * PEF_DELTA_SCALE;
-
-  q_ind_r[2] = base_qindex + v_ac_delta_q + pef->delta_q_v * PEF_DELTA_SCALE;
-  side_ind_r[2] =
-      base_qindex + v_ac_delta_q + pef->delta_side_v * PEF_DELTA_SCALE;
-
-  assert(plane_start >= AOM_PLANE_Y);
-  assert(plane_end <= MAX_MB_PLANE);
-  int plane;
-  for (plane = plane_start; plane < plane_end; plane++) {
-    if (plane == 0 && !pef->filter_level[0] && !pef->filter_level[1])
-      break;
-    else if (plane == 1 && !pef->filter_level_u)
-      continue;
-    else if (plane == 2 && !pef->filter_level_v)
-      continue;
-    for (int dir = 0; dir < 2; ++dir) {
-      const int q_ind_plane = (dir == 0) ? q_ind[plane] : q_ind_r[plane];
-      const int side_ind_plane =
-          (dir == 0) ? side_ind[plane] : side_ind_r[plane];
-
-      const int q_thr =
-          df_quant_from_qindex(q_ind_plane, cm->seq_params.bit_depth);
-      const int side_thr =
-          df_side_from_qindex(side_ind_plane, cm->seq_params.bit_depth);
-      pefi->q_thr[plane][dir] = q_thr >> PEF_THR_SHIFT;
-      pefi->side_thr[plane][dir] = side_thr >> PEF_THR_SHIFT;
-    }
-  }
-}
-
-// derive the number of samples to filter
-static INLINE int derive_filter_length(uint16_t *s, int pitch,
-                                       uint16_t side_thresh, int filt_len) {
-  if (filt_len < 1 || filt_len > 3) return 0;
-  const int16_t second_deriv_m2 =
-      abs(s[-3 * pitch] - (s[-2 * pitch] << 1) + s[-pitch]);
-  const int16_t second_deriv_p1 = abs(s[0] - (s[pitch] << 1) + s[2 * pitch]);
-  int8_t mask = 0;
-  mask |= (second_deriv_m2 > side_thresh);
-  mask |= (second_deriv_p1 > side_thresh);
-  if (mask)
-    return 0;
-  else
-    return filt_len;
-}
-
-// filter vertical prediction samples
-static INLINE void filt_vert_pred(int length, uint16_t *s, const int stride,
-                                  int bd, uint16_t q_thresh, int q_mult,
-                                  int w_mult) {
-  if (length < 1) return;
-  int delta_m2 = (3 * (s[0] - s[-1]) - (s[stride] - s[-2])) * 4;
-  const int q_thresh_clamp = q_thresh * q_mult;
-  delta_m2 = clamp(delta_m2, -q_thresh_clamp, q_thresh_clamp);
-  delta_m2 *= w_mult;
-
-  for (int i = 0; i < length; i++) {
-    const int offset = ROUND_POWER_OF_TWO(delta_m2 * (length - i), PEF_SHIFT);
-    s[(-i - 1)] = clip_pixel_highbd(s[(-i - 1)] + offset, bd);
-    s[i] = clip_pixel_highbd(s[i] - offset, bd);
-  }
-}
-
-// filter horizontal prediction samples
-static INLINE void filt_horz_pred(int length, uint16_t *s, const int stride,
-                                  int bd, uint16_t q_thresh, int q_mult,
-                                  int w_mult) {
-  if (length < 1) return;
-  int delta_m2 =
-      (3 * (s[0] - s[-1 * stride]) - (s[stride] - s[-2 * stride])) * 4;
-  const int q_thresh_clamp = q_thresh * q_mult;
-  delta_m2 = clamp(delta_m2, -q_thresh_clamp, q_thresh_clamp);
-  delta_m2 *= w_mult;
-
-  for (int i = 0; i < length; i++) {
-    const int offset = ROUND_POWER_OF_TWO(delta_m2 * (length - i), PEF_SHIFT);
-    s[(-i - 1) * stride] = clip_pixel_highbd(s[(-i - 1) * stride] + offset, bd);
-    s[i * stride] = clip_pixel_highbd(s[i * stride] - offset, bd);
-  }
-}
-
-// Loop through each sample on the vertical edge
-void highbd_filt_vert_pred_c(uint16_t *s, int stride, int bd, uint16_t q_thresh,
-                             uint16_t side_thresh, int q_mult, int w_mult,
-                             int n, int filt_len) {
-  for (int i = 0; i < n; ++i) {
-    const int length = derive_filter_length(s, 1, side_thresh, filt_len);
-    filt_vert_pred(length, s, 1, bd, q_thresh, q_mult, w_mult);
-    s += stride;
-  }
-}
-
-// Loop through each sample on the horizontal edge
-void highbd_filt_horz_pred_c(uint16_t *s, int stride, int bd, uint16_t q_thresh,
-                             uint16_t side_thresh, int q_mult, int w_mult,
-                             int n, int filt_len) {
-  for (int i = 0; i < n; ++i) {
-    const int length = derive_filter_length(s, stride, side_thresh, filt_len);
-    filt_horz_pred(length, s, stride, bd, q_thresh, q_mult, w_mult);
-    ++s;
-  }
-}
-
-// setup PEF input structure
-void setup_pef_input(MACROBLOCKD *xd, int pef_mode, int plane, uint16_t *dst,
-                     int dst_stride, int bw, int bh, int_mv *mv_refined,
-#if CONFIG_REFINEMV
-                     REFINEMV_SUBMB_INFO *refinemv_subinfo,
-#endif  // CONFIG_REFINEMV
-                     PefFuncInput *pef_input) {
-  pef_input->pef_mode = pef_mode;
-  pef_input->plane = plane;
-  pef_input->bw = bw;
-  pef_input->bh = bh;
-  pef_input->ss_x = xd->plane[plane].subsampling_x;
-  pef_input->ss_y = xd->plane[plane].subsampling_y;
-  pef_input->bit_depth = xd->bd;
-  pef_input->dst = dst;
-  pef_input->dst_stride = dst_stride;
-  pef_input->mv_refined = mv_refined;
-#if CONFIG_REFINEMV
-  pef_input->refinemv_subinfo = refinemv_subinfo;
-#endif  // CONFIG_REFINEMV
-}
-
-// check if the neighboring mvs are the same
-void check_mv(bool *diff_mv, int pef_mode, int mv_rows, int mv_cols,
-              int mvs_stride, const TPL_MV_REF *tpl_mvs, int tip_step,
-              int offset, int_mv *mv_refined, int step
-#if CONFIG_REFINEMV
-              ,
-              REFINEMV_SUBMB_INFO *refinemv_subinfo, int refinemv_step
-#endif  // CONFIG_REFINEMV
-#if CONFIG_AFFINE_REFINEMENT
-              ,
-              const int avg_mv_422
-#endif  // CONFIG_AFFINE_REFINEMENT
-) {
-#if CONFIG_EXT_WARP_FILTER
-  if (pef_mode < 0 || pef_mode > 4) return;
-#else
-#if CONFIG_REFINEMV
-  if (pef_mode < 0 || pef_mode > 3) return;
-#else
-  if (pef_mode < 0 || pef_mode > 2) return;
-#endif  // CONFIG_REFINEMV
-#endif  // CONFIG_EXT_WARP_FILTER
-#if CONFIG_AFFINE_REFINEMENT
-  // For this special case, check the average MVs at the horizontal boundary
-  if (pef_mode == 0 && avg_mv_422) {
-    int mv1y = ROUND_POWER_OF_TWO_SIGNED(
-        mv_refined[0].as_mv.row + mv_refined[1].as_mv.row, 1);
-    int mv1x = ROUND_POWER_OF_TWO_SIGNED(
-        mv_refined[0].as_mv.col + mv_refined[1].as_mv.col, 1);
-    int mv2y = ROUND_POWER_OF_TWO_SIGNED(
-        mv_refined[2].as_mv.row + mv_refined[3].as_mv.row, 1);
-    int mv2x = ROUND_POWER_OF_TWO_SIGNED(
-        mv_refined[2].as_mv.col + mv_refined[3].as_mv.col, 1);
-    *diff_mv = (mv1y != mv2y || mv1x != mv2x);
-    return;
-  }
-#endif                                   // CONFIG_AFFINE_REFINEMENT
-  if (pef_mode == 0 || pef_mode == 1) {  // opfl mv || refined tip mv
-    const int_mv *cur_mv_refined_ref0 = &mv_refined[offset];
-    const int_mv *cur_mv_refined_ref1 = &mv_refined[offset + 1];
-    *diff_mv =
-        cur_mv_refined_ref0[0].as_int != cur_mv_refined_ref0[-step].as_int;
-    *diff_mv |=
-        cur_mv_refined_ref1[0].as_int != cur_mv_refined_ref1[-step].as_int;
-#if CONFIG_REFINEMV
-  } else if (pef_mode == 3) {  // refinemv mv
-    const int_mv *cur_mv_refined_ref0 = &refinemv_subinfo->refinemv[0];
-    const int_mv *cur_mv_refined_ref1 = &refinemv_subinfo->refinemv[1];
-    const int_mv *prev_mv_refined_ref0 =
-        &refinemv_subinfo[-refinemv_step].refinemv[0];
-    const int_mv *prev_mv_refined_ref1 =
-        &refinemv_subinfo[-refinemv_step].refinemv[1];
-    *diff_mv = cur_mv_refined_ref0[0].as_int != prev_mv_refined_ref0[0].as_int;
-    *diff_mv |= cur_mv_refined_ref1[0].as_int != prev_mv_refined_ref1[0].as_int;
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-  } else if (pef_mode == 4) {  // Extended warp filter
-    // Filter every 4x4 unit boundary
-    *diff_mv = true;
-#endif      // CONFIG_EXT_WARP_FILTER
-  } else {  // tip mv
-    const TPL_MV_REF *cur_tpl_mv = tpl_mvs + mv_rows * mvs_stride + mv_cols;
-    const TPL_MV_REF *prev_tpl_mv = cur_tpl_mv - tip_step;
-    *diff_mv = cur_tpl_mv->mfmv0.as_int != prev_tpl_mv->mfmv0.as_int;
-  }
-  return;
-}
-
-// main function for enhancing prediction block boundaries
-static INLINE void enhance_sub_prediction_blocks(const AV1_COMMON *cm,
-                                                 MACROBLOCKD *xd,
-                                                 PefFuncInput *pef_input) {
-  const int bw = pef_input->bw;
-  const int bh = pef_input->bh;
-  const int pef_mode = pef_input->pef_mode;
-  if (pef_mode == 1 && (bw < PEF_MCU_SZ || bh < PEF_MCU_SZ)) return;
-  const int plane = pef_input->plane;
-
-  const int sub_bsize_y = PEF_MCU_SZ;  // n is motion compensation unit size
-  int sub_bw = sub_bsize_y;
-  int sub_bh = sub_bsize_y;
-  if (pef_mode == 0) {
-    opfl_subblock_size_plane(xd, plane
-#if CONFIG_OPTFLOW_ON_TIP
-                             ,
-                             1
-#endif  // CONFIG_OPTFLOW_ON_TIP
-                             ,
-                             &sub_bw, &sub_bh);
-  }
-#if CONFIG_EXT_WARP_FILTER
-  if (pef_mode == 4) {
-    sub_bw = PEF_MCU_SZ / 2;
-    sub_bh = PEF_MCU_SZ / 2;
-  }
-#endif  // CONFIG_EXT_WARP_FILTER
-
-  const int bit_depth = pef_input->bit_depth;
-  const int dst_stride = pef_input->dst_stride;
-  const int ss_x = pef_input->ss_x;
-  const int ss_y = pef_input->ss_y;
-#if CONFIG_AFFINE_REFINEMENT
-  // Special case: when subsampling is 422 and luma block is 8x8 (with 4x8
-  // chroma), this chroma block has two subblocks refinement units. Each uses
-  // the average MV of two colocated 4x4 luma blocks. In this case, PEF checks
-  // the diff of the two average MVs at this subblock boundary.
-  const int avg_mv_422 = plane && ss_x == 1 && ss_y == 0 && bw == 4 && bh == 8;
-#endif  // CONFIG_AFFINE_REFINEMENT
-  uint16_t *dst = pef_input->dst;
-
-  // retrieve filter parameters
-  const PefInfo *pefi = &cm->pef_info;
-  const uint16_t q_horz = pefi->q_thr[plane][HORZ_EDGE];
-  const uint16_t side_horz = pefi->side_thr[plane][HORZ_EDGE];
-  const uint16_t q_vert = pefi->q_thr[plane][VERT_EDGE];
-  const uint16_t side_vert = pefi->side_thr[plane][VERT_EDGE];
-  const bool filter_horz = q_horz && side_horz;
-  const bool filter_vert = q_vert && side_vert;
-  if (!filter_horz && !filter_vert) return;
-  const int filt_len = sub_bw == PEF_MCU_SZ ? 3 : 1;
-  const int q_mult = pef_q_mult[filt_len - 1];
-  const int w_mult = pef_w_mult[filt_len - 1];
-
-  // derive blockiness location
-  int max_tpl_row = 0;
-  int max_tpl_col = 0;
-  int tpl_start_row = 0;
-  int tpl_start_col = 0;
-  int tpl_offset = 0;
-  int mvs_stride = ROUND_POWER_OF_TWO(cm->mi_params.mi_cols, TMVP_SHIFT_BITS);
-  const TPL_MV_REF *tpl_mvs_base = cm->tpl_mvs;
-
-  if (pef_mode == 1) {
-    const int mi_row = xd->mi_row;
-    const int mi_col = xd->mi_col;
-    int ref_start_pixel_row = (mi_row << MI_SIZE_LOG2);
-    int ref_start_pixel_col = (mi_col << MI_SIZE_LOG2);
-
-    max_tpl_row = ROUND_POWER_OF_TWO(cm->mi_params.mi_rows, TMVP_SHIFT_BITS);
-    max_tpl_col = ROUND_POWER_OF_TWO(cm->mi_params.mi_cols, TMVP_SHIFT_BITS);
-    tpl_start_row = ref_start_pixel_row >> TMVP_MI_SZ_LOG2;
-    tpl_start_col = ref_start_pixel_col >> TMVP_MI_SZ_LOG2;
-  }
-
-  const TPL_MV_REF *tpl_mvs = tpl_mvs_base + tpl_offset;
-
-  // initialize x_step and y_step based on blockiness location
-  int last_col_x_step = sub_bw;
-  int x_step = sub_bw;
-
-  int last_row_y_step = sub_bh;
-  int y_step = sub_bh;
-
-  // start filtering
-  const int wn = bw / sub_bw;
-  const int h = bh - last_row_y_step;
-  const int w = bw - last_col_x_step;
-  const int rw = bw - (bw % sub_bw);
-  int prev_y_step = y_step;
-  int prev_x_step = x_step;
-  int n_blocks = 0;
-  int mv_rows = 0;
-  for (int j = 0; j <= h; j += y_step) {
-    int mv_cols = 0;
-    for (int i = 0; i <= w; i += x_step) {
-      bool within_tpl_boundary = 1;
-      if (pef_mode == 1) {
-        within_tpl_boundary = (tpl_start_col + mv_cols) < max_tpl_col &&
-                              (tpl_start_row + mv_rows) < max_tpl_row;
-      }
-
-      const int luma_j = (j << ss_y);
-      const int luma_i = (i << ss_x);
-      const int mv_offset =
-          (pef_mode == 1) ? 2 * ((luma_j >> TMVP_MI_SZ_LOG2) * TIP_MV_STRIDE +
-                                 (luma_i >> TMVP_MI_SZ_LOG2))
-                          : 2 * n_blocks;
-
-      // filter vertical boundary
-      if (filter_vert && i > 0 && within_tpl_boundary &&
-          AOMMIN(prev_x_step, x_step) >= filt_len) {
-        bool diff_mv = 0;
-        check_mv(&diff_mv, pef_mode, mv_rows, mv_cols, mvs_stride, tpl_mvs, 1,
-                 mv_offset, pef_input->mv_refined, 2
-#if CONFIG_REFINEMV
-                 ,
-                 (pef_mode == 3) ? (pef_input->refinemv_subinfo +
-                                    (luma_j >> MI_SIZE_LOG2) * MAX_MIB_SIZE +
-                                    (luma_i >> MI_SIZE_LOG2))
-                                 : NULL,
-                 1
-#endif  // CONFIG_REFINEMV
-#if CONFIG_AFFINE_REFINEMENT
-                 ,
-                 0
-#endif  // CONFIG_AFFINE_REFINEMENT
-        );
-        if (diff_mv) {
-          filt_func filt_vert_func =
-              (y_step == PEF_MCU_SZ && x_step == PEF_MCU_SZ)
-                  ? highbd_filt_vert_pred
-                  : highbd_filt_vert_pred_c;
-          filt_vert_func(dst, dst_stride, bit_depth, q_vert, side_vert, q_mult,
-                         w_mult, y_step, filt_len);
-        }
-      }
-      // filter horizontal boundary
-      if (filter_horz && j > 0 && within_tpl_boundary &&
-          AOMMIN(prev_y_step, y_step) >= filt_len) {
-        bool diff_mv = 0;
-        const int vstep = (pef_mode == 0) ? 2 * wn : 2 * TIP_MV_STRIDE;
-        check_mv(&diff_mv, pef_mode, mv_rows, mv_cols, mvs_stride, tpl_mvs,
-                 mvs_stride, mv_offset, pef_input->mv_refined, vstep
-#if CONFIG_REFINEMV
-                 ,
-                 (pef_mode == 3) ? (pef_input->refinemv_subinfo +
-                                    (luma_j >> MI_SIZE_LOG2) * MAX_MIB_SIZE +
-                                    (luma_i >> MI_SIZE_LOG2))
-                                 : NULL,
-                 MAX_MIB_SIZE
-#endif  // CONFIG_REFINEMV
-#if CONFIG_AFFINE_REFINEMENT
-                 ,
-                 avg_mv_422
-#endif  // CONFIG_AFFINE_REFINEMENT
-        );
-        if (diff_mv) {
-          filt_func filt_horz_func = x_step == PEF_MCU_SZ
-                                         ? highbd_filt_horz_pred
-                                         : highbd_filt_horz_pred_c;
-          filt_horz_func(dst, dst_stride, bit_depth, q_horz, side_horz, q_mult,
-                         w_mult, x_step, filt_len);
-        }
-      }
-      n_blocks++;
-      mv_cols += (1 << ss_x);
-      dst += x_step;
-    }
-    mv_rows += (1 << ss_y);
-    dst -= rw;
-    dst += y_step * dst_stride;
-  }
-}
-
-// setup dst buffer for each color component
-static INLINE void pef_setup_pred_plane(struct buf_2d *dst, uint16_t *src,
-                                        int width, int height, int stride,
-                                        int tpl_row, int tpl_col,
-                                        const struct scale_factors *scale,
-                                        int subsampling_x, int subsampling_y) {
-  const int x = tpl_col >> subsampling_x;
-  const int y = tpl_row >> subsampling_y;
-  dst->buf = src + scaled_buffer_offset(x, y, stride, scale);
-  dst->buf0 = src;
-  dst->width = width;
-  dst->height = height;
-  dst->stride = stride;
-}
-
-// setup dst buffer
-static AOM_INLINE void pef_component_setup_dst_planes(AV1_COMMON *const cm,
-                                                      const int plane,
-                                                      const int tpl_row,
-                                                      const int tpl_col) {
-  const YV12_BUFFER_CONFIG *src = &cm->tip_ref.tip_frame->buf;
-  TIP_PLANE *const pd = &cm->tip_ref.tip_plane[plane];
-  int is_uv = 0;
-  int subsampling_x = 0;
-  int subsampling_y = 0;
-  if (plane > 0) {
-    is_uv = 1;
-    subsampling_x = cm->seq_params.subsampling_x;
-    subsampling_y = cm->seq_params.subsampling_y;
-  }
-  pef_setup_pred_plane(&pd->dst, src->buffers[plane], src->crop_widths[is_uv],
-                       src->crop_heights[is_uv], src->strides[is_uv], tpl_row,
-                       tpl_col, NULL, subsampling_x, subsampling_y);
-}
-
-void enhance_tip_frame(AV1_COMMON *cm, MACROBLOCKD *xd) {
-  const int num_planes = av1_num_planes(cm);
-  for (int plane = 0; plane < num_planes; ++plane) {
-    TIP *tip_ref = &cm->tip_ref;
-    pef_component_setup_dst_planes(cm, plane, 0, 0);
-    TIP_PLANE *const tip = &tip_ref->tip_plane[plane];
-    struct buf_2d *const dst_buf = &tip->dst;
-    uint16_t *const dst = dst_buf->buf;
-    const int dst_stride = dst_buf->stride;
-    PefFuncInput pef_input;
-    setup_pef_input(xd, 2, plane, dst, dst_stride, dst_buf->width,
-                    dst_buf->height, NULL,
-#if CONFIG_REFINEMV
-
-                    NULL,
-#endif  // CONFIG_REFINEMV
-                    &pef_input);
-    enhance_sub_prediction_blocks(cm, xd, &pef_input);
-  }
-}
-
-void enhance_prediction(const AV1_COMMON *cm, MACROBLOCKD *xd, int plane,
-                        uint16_t *dst, int dst_stride, int bw, int bh,
-                        int_mv *const mv_refined, int use_opfl
-#if CONFIG_REFINEMV
-                        ,
-                        int use_refinemv, REFINEMV_SUBMB_INFO *refinemv_subinfo
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-                        ,
-                        bool ext_warp_used
-#endif  // CONFIG_EXT_WARP_FILTER
-) {
-  if (!cm->seq_params.enable_pef) return;
-  if (!cm->features.allow_pef) return;
-
-  MB_MODE_INFO *mbmi = xd->mi[0];
-  const int use_tip = is_tip_ref_frame(mbmi->ref_frame[0]);
-  if (use_tip) {
-    PefFuncInput pef_input;
-    setup_pef_input(xd, 1, plane, dst, dst_stride, bw, bh, mv_refined,
-#if CONFIG_REFINEMV
-                    NULL,
-#endif  // CONFIG_REFINEMV
-                    &pef_input);
-    enhance_sub_prediction_blocks(cm, xd, &pef_input);
-    return;
-  }
-
-#if !CONFIG_AFFINE_REFINEMENT
-  use_opfl &= (plane == 0);
-#endif  // !CONFIG_AFFINE_REFINEMENT
-  if (use_opfl) {
-    PefFuncInput pef_input;
-    setup_pef_input(xd, 0, plane, dst, dst_stride, bw, bh, mv_refined,
-#if CONFIG_REFINEMV
-                    NULL,
-#endif  // CONFIG_REFINEMV
-                    &pef_input);
-    enhance_sub_prediction_blocks(cm, xd, &pef_input);
-    return;
-  }
-#if CONFIG_REFINEMV
-  if (use_refinemv) {
-    PefFuncInput pef_input;
-    setup_pef_input(xd, 3, plane, dst, dst_stride, bw, bh, mv_refined,
-                    refinemv_subinfo, &pef_input);
-    enhance_sub_prediction_blocks(cm, xd, &pef_input);
-    return;
-  }
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-  if (ext_warp_used) {
-    PefFuncInput pef_input;
-    setup_pef_input(xd, 4, plane, dst, dst_stride, bw, bh, 0,
-#if CONFIG_REFINEMV
-                    NULL,
-#endif  // CONFIG_REFINEMV
-                    &pef_input);
-    enhance_sub_prediction_blocks(cm, xd, &pef_input);
-    return;
-  }
-#endif  // CONFIG_EXT_WARP_FILTER
-  return;
-}
diff --git a/av1/common/pef.h b/av1/common/pef.h
deleted file mode 100644
index 721258b..0000000
--- a/av1/common/pef.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2022, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 3-Clause Clear License
- * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
- * License was not distributed with this source code in the LICENSE file, you
- * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/.  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
- * aomedia.org/license/patent-license/.
- */
-
-#ifndef AOM_AV1_COMMON_PEF_H_
-#define AOM_AV1_COMMON_PEF_H_
-
-#include "config/aom_config.h"
-
-#include "aom_ports/mem.h"
-#include "av1/common/blockd.h"
-#include "av1/common/seg_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PEF_SHIFT 11
-#define PEF_QTHR 150
-#define PEF_DELTA 2
-#define PEF_THR_SHIFT 3
-#define PEF_DELTA_SCALE 8
-#define PEF_BD_FACTOR 24
-#define PEF_MCU_SZ 8
-
-// Structure for PEF parameters
-typedef struct {
-  int filter_level[2];
-  int filter_level_u;
-  int filter_level_v;
-  int delta_q_luma[2];
-  int delta_side_luma[2];
-  int delta_q_u;
-  int delta_side_u;
-  int delta_q_v;
-  int delta_side_v;
-  int pef_delta;
-} PefParams;
-
-// Structure for intermediate thresholds
-typedef struct {
-  uint16_t q_thr[MAX_MB_PLANE][2];
-  uint16_t side_thr[MAX_MB_PLANE][2];
-} PefInfo;
-
-// Structure for PEF function input
-typedef struct {
-  // 0 for OPFL prediciton, 1 for TIP prediciton, 2 for TIP frame, 3 for
-  // refinemv prediction, 4 for extended warp filter
-  int pef_mode;
-  int plane;
-  int bw;
-  int bh;
-  int ss_x;
-  int ss_y;
-  int bit_depth;
-  uint16_t *dst;
-  int dst_stride;
-  int_mv *mv_refined;
-#if CONFIG_REFINEMV
-  REFINEMV_SUBMB_INFO *refinemv_subinfo;
-#endif  // CONFIG_REFINEMV
-} PefFuncInput;
-
-typedef void (*filt_func)(uint16_t *s, int stride, int bd, uint16_t q_thresh,
-                          uint16_t side_thresh, int q_mult, int w_mult, int n,
-                          int filt_len);
-
-// Initialize PEF parameters
-void init_pef_parameter(struct AV1Common *const cm, int plane_start,
-                        int plane_end);
-
-// enhance TIP frame
-void enhance_tip_frame(struct AV1Common *const cm, MACROBLOCKD *xd);
-
-// enhance prediction blocks
-void enhance_prediction(const struct AV1Common *cm, MACROBLOCKD *xd, int plane,
-                        uint16_t *dst, int dst_stride, int bw, int bh,
-                        int_mv *const mv_refined, int use_opfl
-#if CONFIG_REFINEMV
-                        ,
-                        int use_refinemv, REFINEMV_SUBMB_INFO *refinemv_subinfo
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-                        ,
-                        bool ext_warp_used
-#endif  // CONFIG_EXT_WARP_FILTER
-);
-
-#ifdef __cplusplus
-}  // extern "C"
-#endif
-
-#endif  // AOM_AV1_COMMON_PEF_H_
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 49f86d8..ee8ff3b 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -4687,30 +4687,6 @@
                                   mi_x, mi_y, ref, mc_buf,
                                   calc_subpel_params_func);
   }
-
-#if CONFIG_AFFINE_REFINEMENT
-  const int apply_pef_opfl =
-      (mi->comp_refine_type == COMP_REFINE_SUBBLK2P && plane == 0) ||
-      (damr_refine_subblock(plane, bw, bh, mi->comp_refine_type, opfl_sub_bw,
-                            opfl_sub_bh) &&
-       use_affine_opfl);
-#endif  // CONFIG_AFFINE_REFINEMENT
-  if (use_optflow_refinement && plane == 0 && !tip_ref_frame) {
-    enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh, mv_refined_sb,
-                       use_optflow_refinement
-#if CONFIG_AFFINE_REFINEMENT
-                           && apply_pef_opfl
-#endif  // CONFIG_AFFINE_REFINEMENT
-#if CONFIG_REFINEMV
-                       ,
-                       0, NULL
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-                       ,
-                       false
-#endif  // CONFIG_EXT_WARP_FILTER
-    );
-  }
 }
 #endif  // CONFIG_REFINEMV
 
@@ -5288,46 +5264,6 @@
 #endif  // CONFIG_REFINEMV
                                           &ext_warp_used, xd->mv_refined);
   }
-  int apply_sub_block_refinemv =
-      !tip_ref_frame && is_sub_block_refinemv_enabled(cm, mi, build_for_obmc,
-                                                      plane, tip_ref_frame);
-  int use_optflow_refinement =
-      !tip_ref_frame && !apply_sub_block_refinemv &&
-      is_optflow_refinement_enabled(cm,
-#if CONFIG_COMPOUND_4XN
-                                    xd,
-#endif  // CONFIG_COMPOUND_4XN
-                                    mi, plane, tip_ref_frame);
-  int use_4x4 = tip_ref_frame ? 0 : 1;
-
-  int opfl_sub_bw = OF_BSIZE;
-  int opfl_sub_bh = OF_BSIZE;
-  opfl_subblock_size_plane(xd, plane,
-#if CONFIG_OPTFLOW_ON_TIP
-                           use_4x4,
-#endif  // CONFIG_OPTFLOW_ON_TIP
-                           &opfl_sub_bw, &opfl_sub_bh);
-
-#if CONFIG_AFFINE_REFINEMENT
-  const int apply_pef_opfl =
-      (mi->comp_refine_type == COMP_REFINE_SUBBLK2P && plane == 0) ||
-      damr_refine_subblock(plane, bw, bh, mi->comp_refine_type, opfl_sub_bw,
-                           opfl_sub_bh);
-#endif  // CONFIG_AFFINE_REFINEMENT
-  enhance_prediction(cm, xd, plane, dst, dst_stride, bw, bh, xd->mv_refined,
-                     use_optflow_refinement
-#if CONFIG_AFFINE_REFINEMENT
-                         && apply_pef_opfl
-#endif  // CONFIG_AFFINE_REFINEMENT
-#if CONFIG_REFINEMV
-                     ,
-                     apply_sub_block_refinemv, &xd->refinemv_subinfo[0]
-#endif  // CONFIG_REFINEMV
-#if CONFIG_EXT_WARP_FILTER
-                     ,
-                     ext_warp_used
-#endif  // CONFIG_EXT_WARP_FILTER
-  );
 }
 
 void av1_build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
diff --git a/av1/common/x86/highbd_pef_avx2.c b/av1/common/x86/highbd_pef_avx2.c
deleted file mode 100644
index 11a81e3..0000000
--- a/av1/common/x86/highbd_pef_avx2.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2022, Alliance for Open Media. All rights reserved
- *
- * This source code is subject to the terms of the BSD 3-Clause Clear License
- * and the Alliance for Open Media Patent License 1.0. If the BSD 3-Clause Clear
- * License was not distributed with this source code in the LICENSE file, you
- * can obtain it at aomedia.org/license/software-license/bsd-3-c-c/.  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
- * aomedia.org/license/patent-license/.
- */
-
-#include <immintrin.h>
-#include "config/av1_rtcd.h"
-#include "av1/common/pef.h"
-#include "aom_dsp/x86/lpf_common_sse2.h"
-
-static INLINE void highbd_filt_pred_generic_avx2(__m128i *p2, __m128i *p1,
-                                                 __m128i *p0, __m128i *m2,
-                                                 __m128i *m1, __m128i *m0,
-                                                 int bd, uint16_t q_thresh,
-                                                 uint16_t side_thresh,
-                                                 int q_mult, int w_mult) {
-  __m128i s_m1 = _mm_slli_epi16(*m1, 1);
-  __m128i s_p1 = _mm_slli_epi16(*p1, 1);
-  __m128i d_m1 = _mm_sub_epi16(*m2, s_m1);
-  d_m1 = _mm_add_epi16(d_m1, *m0);
-  d_m1 = _mm_abs_epi16(d_m1);
-  __m128i d_p1 = _mm_sub_epi16(*p0, s_p1);
-  d_p1 = _mm_add_epi16(d_p1, *p2);
-  d_p1 = _mm_abs_epi16(d_p1);
-
-  __m128i side_thr = _mm_set1_epi16(side_thresh);
-  __m128i mask_0 = _mm_cmpgt_epi16(d_m1, side_thr);
-  __m128i mask_1 = _mm_cmpgt_epi16(d_p1, side_thr);
-  __m128i mask = _mm_or_si128(mask_0, mask_1);
-  mask = _mm_add_epi16(mask, _mm_set1_epi16(1));
-
-  __m128i delta = _mm_sub_epi16(*p0, *m0);
-  delta = _mm_mullo_epi16(delta, _mm_set1_epi16(3));
-  __m128i delta_1 = _mm_sub_epi16(*p1, *m1);
-  delta = _mm_sub_epi16(delta, delta_1);
-  delta = _mm_slli_epi16(delta, 2);
-  delta = _mm_mullo_epi16(delta, mask);
-
-  int q_thr = q_thresh * q_mult;
-  __m128i min_q_thr = _mm_set1_epi16(q_thr * -1);
-  __m128i max_q_thr = _mm_set1_epi16(q_thr);
-  delta = _mm_min_epi16(delta, max_q_thr);
-  delta = _mm_max_epi16(delta, min_q_thr);
-  __m256i delta_256 = _mm256_mullo_epi32(_mm256_cvtepi16_epi32(delta),
-                                         _mm256_set1_epi32(w_mult));
-
-  __m256i rounding = _mm256_set1_epi32(1 << PEF_SHIFT >> 1);
-  __m128i pel_min = _mm_set1_epi16(0);
-  __m128i pel_max = _mm_set1_epi16((1 << bd) - 1);
-
-  __m256i offset;
-  __m128i offset_128;
-  // derive offset and filter m0 and p0
-  offset = _mm256_add_epi32(delta_256, delta_256);
-  offset = _mm256_add_epi32(offset, delta_256);
-  offset = _mm256_add_epi32(offset, rounding);
-  offset = _mm256_srai_epi32(offset, PEF_SHIFT);
-  offset = _mm256_packs_epi32(offset, offset);
-  offset = _mm256_permute4x64_epi64(offset, 0xD8);
-  offset_128 = _mm256_extractf128_si256(offset, 0);
-  *m0 = _mm_add_epi16(*m0, offset_128);
-  *m0 = _mm_min_epi16(*m0, pel_max);
-  *m0 = _mm_max_epi16(*m0, pel_min);
-  *p0 = _mm_sub_epi16(*p0, offset_128);
-  *p0 = _mm_min_epi16(*p0, pel_max);
-  *p0 = _mm_max_epi16(*p0, pel_min);
-
-  // derive offset and filter m1 and p1
-  offset = _mm256_add_epi32(delta_256, delta_256);
-  offset = _mm256_add_epi32(offset, rounding);
-  offset = _mm256_srai_epi32(offset, PEF_SHIFT);
-  offset = _mm256_packs_epi32(offset, offset);
-  offset = _mm256_permute4x64_epi64(offset, 0xD8);
-  offset_128 = _mm256_extractf128_si256(offset, 0);
-  *m1 = _mm_add_epi16(*m1, offset_128);
-  *m1 = _mm_min_epi16(*m1, pel_max);
-  *m1 = _mm_max_epi16(*m1, pel_min);
-  *p1 = _mm_sub_epi16(*p1, offset_128);
-  *p1 = _mm_min_epi16(*p1, pel_max);
-  *p1 = _mm_max_epi16(*p1, pel_min);
-
-  // derive offset and filter m2 and p2
-  offset = _mm256_add_epi32(delta_256, rounding);
-  offset = _mm256_srai_epi32(offset, PEF_SHIFT);
-  offset = _mm256_packs_epi32(offset, offset);
-  offset = _mm256_permute4x64_epi64(offset, 0xD8);
-  offset_128 = _mm256_extractf128_si256(offset, 0);
-  *m2 = _mm_add_epi16(*m2, offset_128);
-  *m2 = _mm_min_epi16(*m2, pel_max);
-  *m2 = _mm_max_epi16(*m2, pel_min);
-  *p2 = _mm_sub_epi16(*p2, offset_128);
-  *p2 = _mm_min_epi16(*p2, pel_max);
-  *p2 = _mm_max_epi16(*p2, pel_min);
-  return;
-}
-
-void highbd_filt_vert_pred_avx2(uint16_t *s, int stride, int bd,
-                                uint16_t q_thresh, uint16_t side_thresh,
-                                int q_mult, int w_mult, int n, int filt_len) {
-  if (n == 0 || filt_len == 0) return;
-  __m128i m2, m1, m0, p0, p1, p2, dum0, dum1;
-  __m128i x0, x1, x2, x3, x4, x5, x6, x7;
-  x0 = _mm_loadu_si128((__m128i *)(s - 3 + 0 * stride));
-  x1 = _mm_loadu_si128((__m128i *)(s - 3 + 1 * stride));
-  x2 = _mm_loadu_si128((__m128i *)(s - 3 + 2 * stride));
-  x3 = _mm_loadu_si128((__m128i *)(s - 3 + 3 * stride));
-  x4 = _mm_loadu_si128((__m128i *)(s - 3 + 4 * stride));
-  x5 = _mm_loadu_si128((__m128i *)(s - 3 + 5 * stride));
-  x6 = _mm_loadu_si128((__m128i *)(s - 3 + 6 * stride));
-  x7 = _mm_loadu_si128((__m128i *)(s - 3 + 7 * stride));
-
-  highbd_transpose8x8_sse2(&x0, &x1, &x2, &x3, &x4, &x5, &x6, &x7, &m2, &m1,
-                           &m0, &p0, &p1, &p2, &dum0, &dum1);
-
-  highbd_filt_pred_generic_avx2(&p2, &p1, &p0, &m2, &m1, &m0, bd, q_thresh,
-                                side_thresh, q_mult, w_mult);
-
-  highbd_transpose8x8_sse2(&m2, &m1, &m0, &p0, &p1, &p2, &dum0, &dum1, &x0, &x1,
-                           &x2, &x3, &x4, &x5, &x6, &x7);
-
-  _mm_storeu_si128((__m128i *)(s - 3 + 0 * stride), x0);
-  _mm_storeu_si128((__m128i *)(s - 3 + 1 * stride), x1);
-  _mm_storeu_si128((__m128i *)(s - 3 + 2 * stride), x2);
-  _mm_storeu_si128((__m128i *)(s - 3 + 3 * stride), x3);
-  _mm_storeu_si128((__m128i *)(s - 3 + 4 * stride), x4);
-  _mm_storeu_si128((__m128i *)(s - 3 + 5 * stride), x5);
-  _mm_storeu_si128((__m128i *)(s - 3 + 6 * stride), x6);
-  _mm_storeu_si128((__m128i *)(s - 3 + 7 * stride), x7);
-
-  return;
-}
-
-void highbd_filt_horz_pred_avx2(uint16_t *s, int stride, int bd,
-                                uint16_t q_thresh, uint16_t side_thresh,
-                                int q_mult, int w_mult, int n, int filt_len) {
-  if (n == 0 || filt_len == 0) return;
-  __m128i p0 = _mm_loadu_si128((__m128i *)(s + 0 * stride));
-  __m128i p1 = _mm_loadu_si128((__m128i *)(s + 1 * stride));
-  __m128i p2 = _mm_loadu_si128((__m128i *)(s + 2 * stride));
-  __m128i m0 = _mm_loadu_si128((__m128i *)(s - 1 * stride));
-  __m128i m1 = _mm_loadu_si128((__m128i *)(s - 2 * stride));
-  __m128i m2 = _mm_loadu_si128((__m128i *)(s - 3 * stride));
-
-  highbd_filt_pred_generic_avx2(&p2, &p1, &p0, &m2, &m1, &m0, bd, q_thresh,
-                                side_thresh, q_mult, w_mult);
-
-  _mm_storeu_si128((__m128i *)(s + 0 * stride), p0);
-  _mm_storeu_si128((__m128i *)(s + 1 * stride), p1);
-  _mm_storeu_si128((__m128i *)(s + 2 * stride), p2);
-  _mm_storeu_si128((__m128i *)(s - 1 * stride), m0);
-  _mm_storeu_si128((__m128i *)(s - 2 * stride), m1);
-  _mm_storeu_si128((__m128i *)(s - 3 * stride), m2);
-
-  return;
-}
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 2c40293..1d6c914 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -903,24 +903,15 @@
         avg_u_ac_delta_q;
     cm->cur_frame->v_ac_delta_q = cm->quant_params.v_ac_delta_q =
         avg_v_ac_delta_q;
-    if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-      init_pef_parameter(cm, 0, av1_num_planes(cm));
-    }
   }
 #endif  // CONFIG_TIP_IMPLICIT_QUANT
-#if CONFIG_TIP_DIRECT_FRAME_MV
-  if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-    enhance_tip_frame(cm, xd);
-    aom_extend_frame_borders(&cm->tip_ref.tip_frame->buf, av1_num_planes(cm));
-  }
-#if CONFIG_LF_SUB_PU
+#if CONFIG_TIP_DIRECT_FRAME_MV && CONFIG_LF_SUB_PU
   if (cm->seq_params.enable_lf_sub_pu && cm->features.allow_lf_sub_pu) {
     init_tip_lf_parameter(cm, 0, av1_num_planes(cm));
     loop_filter_tip_frame(cm, 0, av1_num_planes(cm));
     aom_extend_frame_borders(&cm->tip_ref.tip_frame->buf, av1_num_planes(cm));
   }
-#endif  // CONFIG_LF_SUB_PU
-#endif  // CONFIG_TIP_DIRECT_FRAME_MV
+#endif  // CONFIG_TIP_DIRECT_FRAME_MV && CONFIG_LF_SUB_PU
 }
 
 static AOM_INLINE void decode_mbmi_block(AV1Decoder *const pbi,
@@ -6465,7 +6456,6 @@
 #endif  // CONFIG_D071_IMP_MSK_BLD
   seq_params->enable_fsc = aom_rb_read_bit(rb);
   seq_params->enable_ccso = aom_rb_read_bit(rb);
-  seq_params->enable_pef = aom_rb_read_bit(rb);
 #if CONFIG_LF_SUB_PU
   seq_params->enable_lf_sub_pu = aom_rb_read_bit(rb);
 #endif  // CONFIG_LF_SUB_PU
@@ -6473,8 +6463,6 @@
   if (seq_params->enable_tip == 1 &&
 #if CONFIG_LF_SUB_PU
       seq_params->enable_lf_sub_pu
-#else
-      seq_params->enable_pef
 #endif  // CONFIG_LF_SUB_PU
   ) {
     seq_params->enable_tip_explicit_qp = aom_rb_read_bit(rb);
@@ -7546,13 +7534,6 @@
       else
         features->allow_ref_frame_mvs = 0;
 
-      features->allow_pef = false;
-      if (cm->seq_params.enable_pef) {
-        features->allow_pef = aom_rb_read_bit(rb);
-        if (features->allow_pef) {
-          cm->pef_params.pef_delta = aom_rb_read_bit(rb) + 1;
-        }
-      }
 #if CONFIG_LF_SUB_PU
       if (cm->seq_params.enable_lf_sub_pu) {
         features->allow_lf_sub_pu = aom_rb_read_bit(rb);
@@ -8088,17 +8069,12 @@
   if (cm->features.allow_ref_frame_mvs && cm->has_bwd_ref) {
     if (cm->features.tip_frame_mode == TIP_FRAME_AS_OUTPUT) {
       av1_dec_setup_tip_frame(cm, xd, pbi->td.mc_buf, pbi->td.tmp_conv_dst);
-#if !CONFIG_TIP_DIRECT_FRAME_MV
-      if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-        enhance_tip_frame(cm, xd);
-      }
-#if CONFIG_LF_SUB_PU
+#if !CONFIG_TIP_DIRECT_FRAME_MV && CONFIG_LF_SUB_PU
       if (cm->seq_params.enable_lf_sub_pu && cm->features.allow_lf_sub_pu) {
         init_tip_lf_parameter(cm, 0, num_planes);
         loop_filter_tip_frame(cm, 0, num_planes);
       }
-#endif  // CONFIG_LF_SUB_PU
-#endif  // !CONFIG_TIP_DIRECT_FRAME_MV
+#endif  // !CONFIG_TIP_DIRECT_FRAME_MV && CONFIG_LF_SUB_PU
     } else if (cm->features.tip_frame_mode == TIP_FRAME_AS_REF) {
       av1_setup_tip_motion_field(cm, 0);
     }
@@ -8202,10 +8178,6 @@
     av1_setup_ref_frame_sides(cm);
 #endif  // CONFIG_MVP_IMPROVEMENT
 
-  if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-    init_pef_parameter(cm, 0, num_planes);
-  }
-
   process_tip_mode(pbi);
   if (cm->features.tip_frame_mode == TIP_FRAME_AS_OUTPUT) {
     *p_data_end = data + uncomp_hdr_size;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 8fde4d8..a775f81 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -5547,7 +5547,6 @@
 #endif  // CONFIG_D071_IMP_MSK_BLD
   aom_wb_write_bit(wb, seq_params->enable_fsc);
   aom_wb_write_bit(wb, seq_params->enable_ccso);
-  aom_wb_write_bit(wb, seq_params->enable_pef);
 #if CONFIG_LF_SUB_PU
   aom_wb_write_bit(wb, seq_params->enable_lf_sub_pu);
 #endif  // CONFIG_LF_SUB_PU
@@ -5555,8 +5554,6 @@
   if (seq_params->enable_tip == 1 &&
 #if CONFIG_LF_SUB_PU
       seq_params->enable_lf_sub_pu
-#else
-      seq_params->enable_pef
 #endif  // CONFIG_LF_SUB_PU
   ) {
     aom_wb_write_bit(wb, seq_params->enable_tip_explicit_qp);
@@ -6113,12 +6110,6 @@
       } else {
         assert(features->allow_ref_frame_mvs == 0);
       }
-      if (cm->seq_params.enable_pef) {
-        aom_wb_write_bit(wb, features->allow_pef);
-        if (features->allow_pef) {
-          aom_wb_write_bit(wb, cm->pef_params.pef_delta - 1);
-        }
-      }
 #if CONFIG_LF_SUB_PU
       if (cm->seq_params.enable_lf_sub_pu) {
         aom_wb_write_bit(wb, features->allow_lf_sub_pu);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 0eb3e32..27d51c1 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1613,15 +1613,6 @@
   end_timing(cpi, av1_setup_motion_field_time);
 #endif
 
-  const int pef_qp_thr =
-      PEF_QTHR + (cm->seq_params.bit_depth - AOM_BITS_8) * PEF_BD_FACTOR;
-  if (!cm->seq_params.enable_pef || cm->quant_params.base_qindex < pef_qp_thr) {
-    cm->features.allow_pef = 0;
-  } else {
-    cm->features.allow_pef = 1;
-    cm->pef_params.pef_delta = PEF_DELTA;
-  }
-  if (cm->features.allow_pef) init_pef_parameter(cm, 0, av1_num_planes(cm));
 #if CONFIG_LF_SUB_PU
   const int sub_pu_qp_thr =
       SUB_PU_QTHR + (cm->seq_params.bit_depth - AOM_BITS_8) * SUB_PU_BD_FACTOR;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 13f96ec..dc4391d 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -412,7 +412,6 @@
   seq->enable_cdef = tool_cfg->enable_cdef;
   seq->enable_restoration = tool_cfg->enable_restoration;
   seq->enable_ccso = tool_cfg->enable_ccso;
-  seq->enable_pef = tool_cfg->enable_pef;
 #if CONFIG_LF_SUB_PU
   seq->enable_lf_sub_pu = tool_cfg->enable_lf_sub_pu;
 #endif  // CONFIG_LF_SUB_PU
@@ -3066,49 +3065,6 @@
     }
 #endif  // CONFIG_LF_SUB_PU
 
-    if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-#if CONFIG_TIP_IMPLICIT_QUANT
-      const int u_ac_delta_q_backup = cm->quant_params.u_ac_delta_q;
-      const int v_ac_delta_q_backup = cm->quant_params.v_ac_delta_q;
-      const int base_qindex_backup = cm->quant_params.base_qindex;
-      if (cm->seq_params.enable_tip_explicit_qp == 0) {
-        const int avg_u_ac_delta_q =
-            (cm->tip_ref.ref_frame_buffer[0]->u_ac_delta_q +
-             cm->tip_ref.ref_frame_buffer[1]->u_ac_delta_q + 1) >>
-            1;
-        const int avg_v_ac_delta_q =
-            (cm->tip_ref.ref_frame_buffer[0]->v_ac_delta_q +
-             cm->tip_ref.ref_frame_buffer[1]->v_ac_delta_q + 1) >>
-            1;
-        const int avg_base_qindex =
-            (cm->tip_ref.ref_frame_buffer[0]->base_qindex +
-             cm->tip_ref.ref_frame_buffer[1]->base_qindex + 1) >>
-            1;
-        cm->cur_frame->u_ac_delta_q = cm->quant_params.u_ac_delta_q =
-            avg_u_ac_delta_q;
-        cm->cur_frame->v_ac_delta_q = cm->quant_params.v_ac_delta_q =
-            avg_v_ac_delta_q;
-        cm->cur_frame->base_qindex = cm->quant_params.base_qindex =
-            avg_base_qindex;
-        init_pef_parameter(cm, 0, av1_num_planes(cm));
-      }
-#endif  // CONFIG_TIP_IMPLICIT_QUANT
-      enhance_tip_frame(cm, &cpi->td.mb.e_mbd);
-#if CONFIG_TIP_IMPLICIT_QUANT
-      if (cm->seq_params.enable_tip_explicit_qp == 0) {
-        cm->cur_frame->u_ac_delta_q = cm->quant_params.u_ac_delta_q =
-            u_ac_delta_q_backup;
-        cm->cur_frame->v_ac_delta_q = cm->quant_params.v_ac_delta_q =
-            v_ac_delta_q_backup;
-        cm->cur_frame->base_qindex = cm->quant_params.base_qindex =
-            base_qindex_backup;
-      }
-#endif  // CONFIG_TIP_IMPLICIT_QUANT
-#if CONFIG_TIP_DIRECT_FRAME_MV
-      aom_extend_frame_borders(&cm->tip_ref.tip_frame->buf, av1_num_planes(cm));
-#endif  // CONFIG_TIP_DIRECT_FRAME_MV
-    }
-
     // Compute sse and rate.
     YV12_BUFFER_CONFIG *tip_frame_buf = &cm->tip_ref.tip_frame->buf;
 #if CONFIG_TIP_DIRECT_FRAME_MV
@@ -3146,8 +3102,6 @@
         cm->tip_global_motion.as_int = ref_mv.as_int;
         av1_setup_tip_frame(cm, &td->mb.e_mbd, NULL, td->mb.tmp_conv_dst,
                             av1_enc_calc_subpel_params);
-        if (cm->seq_params.enable_pef && cm->features.allow_pef)
-          enhance_tip_frame(cm, &cpi->td.mb.e_mbd);
 #if CONFIG_LF_SUB_PU
         if (cm->seq_params.enable_lf_sub_pu && cm->features.allow_lf_sub_pu) {
           loop_filter_tip_frame(cm, 0, av1_num_planes(cm));
@@ -3189,8 +3143,6 @@
       cm->tip_interp_filter = interp_filter;
       av1_setup_tip_frame(cm, &td->mb.e_mbd, NULL, td->mb.tmp_conv_dst,
                           av1_enc_calc_subpel_params);
-      if (cm->seq_params.enable_pef && cm->features.allow_pef)
-        enhance_tip_frame(cm, &cpi->td.mb.e_mbd);
 #if CONFIG_LF_SUB_PU
       if (cm->seq_params.enable_lf_sub_pu && cm->features.allow_lf_sub_pu) {
         loop_filter_tip_frame(cm, 0, av1_num_planes(cm));
@@ -3296,10 +3248,6 @@
     ThreadData *const td = &cpi->td;
     av1_setup_tip_frame(cm, &td->mb.e_mbd, NULL, td->mb.tmp_conv_dst,
                         av1_enc_calc_subpel_params);
-    if (cm->seq_params.enable_pef && cm->features.allow_pef) {
-      enhance_tip_frame(cm, &cpi->td.mb.e_mbd);
-      aom_extend_frame_borders(&cm->tip_ref.tip_frame->buf, av1_num_planes(cm));
-    }
 #if CONFIG_LF_SUB_PU
     if (cm->seq_params.enable_lf_sub_pu && cm->features.allow_lf_sub_pu) {
       init_tip_lf_parameter(cm, 0, av1_num_planes(cm));
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 429d78b..e900823 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -853,8 +853,6 @@
   bool enable_wiener_nonsep;
   // Indicates if ccso should be enabled.
   bool enable_ccso;
-  // Indicates if prediction enhancement filter should be enabled.
-  bool enable_pef;
 #if CONFIG_LF_SUB_PU
   bool enable_lf_sub_pu;
   // Indicates if deblocking on sub block should be enabled.
diff --git a/common/args.c b/common/args.c
index 6318b67..f35e34d 100644
--- a/common/args.c
+++ b/common/args.c
@@ -131,7 +131,6 @@
     GET_PARAMS(enable_cdef);
     GET_PARAMS(enable_restoration);
     GET_PARAMS(enable_ccso);
-    GET_PARAMS(enable_pef);
 #if CONFIG_LF_SUB_PU
     GET_PARAMS(enable_lf_sub_pu);
 #endif  // CONFIG_LF_SUB_PU
diff --git a/common/av1_config.c b/common/av1_config.c
index 4cd6a9f..b2441c3 100644
--- a/common/av1_config.c
+++ b/common/av1_config.c
@@ -273,7 +273,6 @@
 #endif  // CONFIG_D071_IMP_MSK_BLD
   AV1C_READ_BIT_OR_RETURN_ERROR(enable_fsc);
   AV1C_READ_BIT_OR_RETURN_ERROR(enable_ccso);
-  AV1C_READ_BIT_OR_RETURN_ERROR(enable_pef);
 #if CONFIG_LF_SUB_PU
   AV1C_READ_BIT_OR_RETURN_ERROR(enable_lf_sub_pu);
 #endif  // CONFIG_LF_SUB_PU