Merging the dering and clpf experiments into a single experiment: CDEF

The result is identical to enabling both deringing and CLPF

Change-Id: I71db5ba9e21fcaf11ad87e94841eaf80be58c0a8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c12b6b..13fb5a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -442,7 +442,7 @@
 set(AOM_AV1_COMMON_SSE4_1_INTRIN
     # Requires CONFIG_FILTER_INTRA
     #"${AOM_ROOT}/av1/common/x86/filterintra_sse4.c"
-    # Requires CONFIG_DERING
+    # Requires CONFIG_CDEF
     #"${AOM_ROOT}/av1/common/x86/od_dering_sse4.c"
     "${AOM_ROOT}/av1/common/x86/av1_fwd_txfm1d_sse4.c"
     "${AOM_ROOT}/av1/common/x86/av1_fwd_txfm2d_sse4.c")
@@ -611,7 +611,7 @@
   list(REMOVE_ITEM AOM_UNIT_TEST_SOURCES "${AOM_ROOT}/test/boolcoder_test.cc")
 endif ()
 
-if (CONFIG_CLPF)
+if (CONFIG_CDEF)
   set(AOM_AV1_COMMON_SOURCES
       ${AOM_AV1_COMMON_SOURCES}
       "${AOM_ROOT}/av1/common/clpf.c"
diff --git a/aom_dsp/aom_dsp_rtcd_defs.pl b/aom_dsp/aom_dsp_rtcd_defs.pl
index cd3e613..b64de8e 100644
--- a/aom_dsp/aom_dsp_rtcd_defs.pl
+++ b/aom_dsp/aom_dsp_rtcd_defs.pl
@@ -851,7 +851,7 @@
 add_proto qw/void aom_lpf_horizontal_4_dual/, "uint8_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0, const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1, const uint8_t *thresh1";
 specialize qw/aom_lpf_horizontal_4_dual sse2 neon dspr2 msa/;
 
-if (aom_config("CONFIG_CLPF") eq "yes") {
+if (aom_config("CONFIG_CDEF") eq "yes") {
   if (aom_config("CONFIG_AOM_HIGHBITDEPTH") eq "yes") {
     add_proto qw/void aom_clpf_block_hbd/, "const uint16_t *src, uint16_t *dst, int sstride, int dstride, int x0, int y0, int sizex, int sizey, unsigned int strength, BOUNDARY_TYPE bt, unsigned int bd";
     add_proto qw/void aom_clpf_detect_hbd/, "const uint16_t *rec, const uint16_t *org, int rstride, int ostride, int x0, int y0, int width, int height, int *sum0, int *sum1, unsigned int strength, int size, unsigned int bd";
diff --git a/av1/av1_common.mk b/av1/av1_common.mk
index 958dc45..d648448 100644
--- a/av1/av1_common.mk
+++ b/av1/av1_common.mk
@@ -81,7 +81,7 @@
 AV1_COMMON_SRCS-yes += common/warped_motion.h
 AV1_COMMON_SRCS-yes += common/warped_motion.c
 endif
-ifeq ($(CONFIG_CLPF),yes)
+ifeq ($(CONFIG_CDEF),yes)
 AV1_COMMON_SRCS-yes += common/clpf.c
 AV1_COMMON_SRCS-yes += common/clpf.h
 AV1_COMMON_SRCS-yes += common/clpf_simd.h
@@ -90,8 +90,6 @@
 AV1_COMMON_SRCS-$(HAVE_SSSE3) += common/clpf_ssse3.c
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/clpf_sse4.c
 AV1_COMMON_SRCS-$(HAVE_NEON) += common/clpf_neon.c
-endif
-ifeq ($(CONFIG_DERING),yes)
 AV1_COMMON_SRCS-yes += common/od_dering.c
 AV1_COMMON_SRCS-yes += common/od_dering.h
 AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/od_dering_sse4.c
diff --git a/av1/av1_cx.mk b/av1/av1_cx.mk
index e812e9e..d9eead5 100644
--- a/av1/av1_cx.mk
+++ b/av1/av1_cx.mk
@@ -106,10 +106,8 @@
 AV1_CX_SRCS-yes += encoder/temporal_filter.h
 AV1_CX_SRCS-yes += encoder/mbgraph.c
 AV1_CX_SRCS-yes += encoder/mbgraph.h
-ifeq ($(CONFIG_DERING),yes)
+ifeq ($(CONFIG_CDEF),yes)
 AV1_CX_SRCS-yes += encoder/pickdering.c
-endif
-ifeq ($(CONFIG_CLPF),yes)
 AV1_CX_SRCS-yes += encoder/clpf_rdo.c
 AV1_CX_SRCS-yes += encoder/clpf_rdo.h
 AV1_CX_SRCS-yes += encoder/clpf_rdo_simd.h
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 0805fd7..86ede12 100644
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -749,7 +749,7 @@
 
 # Deringing Functions
 
-if (aom_config("CONFIG_DERING") eq "yes") {
+if (aom_config("CONFIG_CDEF") eq "yes") {
   add_proto qw/int od_dir_find8/, "const od_dering_in *img, int stride, int32_t *var, int coeff_shift";
   specialize qw/od_dir_find8 sse4_1/;
 
@@ -758,12 +758,6 @@
 
   add_proto qw/int od_filter_dering_direction_8x8/, "int16_t *y, int ystride, const int16_t *in, int threshold, int dir";
   specialize qw/od_filter_dering_direction_8x8 sse4_1/;
-
-  add_proto qw/void od_filter_dering_orthogonal_4x4/, "int16_t *y, int ystride, const int16_t *in, int threshold, int dir";
-  specialize qw/od_filter_dering_orthogonal_4x4 sse4_1/;
-
-  add_proto qw/void od_filter_dering_orthogonal_8x8/, "int16_t *y, int ystride, const int16_t *in, int threshold, int dir";
-  specialize qw/od_filter_dering_orthogonal_8x8 sse4_1/;
 }
 
 # WARPED_MOTION / GLOBAL_MOTION functions
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 37f4b54..178a7ee 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -295,7 +295,7 @@
 } PALETTE_COLOR;
 #endif  // CONFIG_PALETTE
 
-#ifdef CONFIG_CLPF
+#ifdef CONFIG_CDEF
 #define CLPF_NOFLAG -1
 typedef enum {
   CLPF_NOSIZE = 0,
diff --git a/av1/common/od_dering.c b/av1/common/od_dering.c
index 4f26a19..82fd09e 100644
--- a/av1/common/od_dering.c
+++ b/av1/common/od_dering.c
@@ -177,64 +177,6 @@
   return (total_abs + 2) >> 2;
 }
 
-/* Smooth in the direction orthogonal to what was detected. */
-void od_filter_dering_orthogonal_8x8_c(int16_t *y, int ystride,
-                                       const int16_t *in, int threshold,
-                                       int dir) {
-  int i;
-  int j;
-  int offset;
-  if (dir > 0 && dir < 4)
-    offset = OD_FILT_BSTRIDE;
-  else
-    offset = 1;
-  for (i = 0; i < 8; i++) {
-    for (j = 0; j < 8; j++) {
-      int16_t yy;
-      int16_t sum;
-      int16_t p;
-      yy = in[i * OD_FILT_BSTRIDE + j];
-      sum = 0;
-      p = in[i * OD_FILT_BSTRIDE + j + offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      p = in[i * OD_FILT_BSTRIDE + j - offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      p = in[i * OD_FILT_BSTRIDE + j + 2 * offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      p = in[i * OD_FILT_BSTRIDE + j - 2 * offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      y[i * ystride + j] = yy + ((3 * sum + 8) >> 4);
-    }
-  }
-}
-
-/* Smooth in the direction orthogonal to what was detected. */
-void od_filter_dering_orthogonal_4x4_c(int16_t *y, int ystride,
-                                       const int16_t *in, int threshold,
-                                       int dir) {
-  int i;
-  int j;
-  int offset;
-  if (dir > 0 && dir < 4)
-    offset = OD_FILT_BSTRIDE;
-  else
-    offset = 1;
-  for (i = 0; i < 4; i++) {
-    for (j = 0; j < 4; j++) {
-      int16_t yy;
-      int16_t sum;
-      int16_t p;
-      yy = in[i * OD_FILT_BSTRIDE + j];
-      sum = 0;
-      p = in[i * OD_FILT_BSTRIDE + j + offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      p = in[i * OD_FILT_BSTRIDE + j - offset] - yy;
-      if (abs(p) < threshold) sum += p;
-      y[i * ystride + j] = yy + ((5 * sum + 8) >> 4);
-    }
-  }
-}
-
 /* This table approximates x^0.16 with the index being log2(x). It is clamped
    to [-.5, 3]. The table is computed as:
    round(256*min(3, max(.5, 1.08*(sqrt(2)*2.^([0:17]+8)/256/256).^.16))) */
@@ -303,12 +245,6 @@
   od_filter_dering_direction_func filter_dering_direction[OD_DERINGSIZES] = {
     od_filter_dering_direction_4x4, od_filter_dering_direction_8x8
   };
-#ifndef CONFIG_CLPF
-  int filter2_thresh[OD_DERING_NBLOCKS][OD_DERING_NBLOCKS];
-  od_filter_dering_orthogonal_func filter_dering_orthogonal[OD_DERINGSIZES] = {
-    od_filter_dering_orthogonal_4x4, od_filter_dering_orthogonal_8x8
-  };
-#endif
   bsize = OD_DERING_SIZE_LOG2 - xdec;
   if (pli == 0) {
     for (bi = 0; bi < dering_count; bi++) {
@@ -317,46 +253,29 @@
       bx = dlist[bi].bx;
       dir[by][bx] = od_dir_find8(&in[8 * by * OD_FILT_BSTRIDE + 8 * bx],
                                  OD_FILT_BSTRIDE, &var, coeff_shift);
-/* Deringing orthogonal to the direction uses a tighter threshold
-   because we want to be conservative. We've presumably already
-   achieved some deringing, so the amount of change is expected
-   to be low. Also, since we might be filtering across an edge, we
-   want to make sure not to blur it. That being said, we might want
-   to be a little bit more aggressive on pure horizontal/vertical
-   since the ringing there tends to be directional, so it doesn't
-   get removed by the directional filtering. */
-#ifndef CONFIG_CLPF
-      filter2_thresh[by][bx] =
-#endif
-          (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
-              &y[bi << 2 * bsize], 1 << bsize,
-              &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
-              od_adjust_thresh(threshold, var), dir[by][bx]);
+      /* Deringing orthogonal to the direction uses a tighter threshold
+         because we want to be conservative. We've presumably already
+         achieved some deringing, so the amount of change is expected
+         to be low. Also, since we might be filtering across an edge, we
+         want to make sure not to blur it. That being said, we might want
+         to be a little bit more aggressive on pure horizontal/vertical
+         since the ringing there tends to be directional, so it doesn't
+         get removed by the directional filtering. */
+      (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
+          &y[bi << 2 * bsize], 1 << bsize,
+          &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
+          od_adjust_thresh(threshold, var), dir[by][bx]);
     }
   } else {
     for (bi = 0; bi < dering_count; bi++) {
       by = dlist[bi].by;
       bx = dlist[bi].bx;
-#ifndef CONFIG_CLPF
-      filter2_thresh[by][bx] =
-#endif
-          (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
-              &y[bi << 2 * bsize], 1 << bsize,
-              &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], threshold,
-              dir[by][bx]);
+      (filter_dering_direction[bsize - OD_LOG_BSIZE0])(
+          &y[bi << 2 * bsize], 1 << bsize,
+          &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)], threshold,
+          dir[by][bx]);
     }
   }
   copy_dering_16bit_to_16bit(in, OD_FILT_BSTRIDE, y, dlist, dering_count,
                              bsize);
-#ifndef CONFIG_CLPF
-  for (bi = 0; bi < dering_count; bi++) {
-    by = dlist[bi].by;
-    bx = dlist[bi].bx;
-    if (filter2_thresh[by][bx] == 0) continue;
-    (filter_dering_orthogonal[bsize - OD_LOG_BSIZE0])(
-        &y[bi << 2 * bsize], 1 << bsize,
-        &in[(by * OD_FILT_BSTRIDE << bsize) + (bx << bsize)],
-        filter2_thresh[by][bx], dir[by][bx]);
-  }
-#endif
 }
diff --git a/av1/common/od_dering.h b/av1/common/od_dering.h
index 16d4f5d..e61e7fa 100644
--- a/av1/common/od_dering.h
+++ b/av1/common/od_dering.h
@@ -41,9 +41,6 @@
 typedef int (*od_filter_dering_direction_func)(int16_t *y, int ystride,
                                                const int16_t *in, int threshold,
                                                int dir);
-typedef void (*od_filter_dering_orthogonal_func)(int16_t *y, int ystride,
-                                                 const int16_t *in,
-                                                 int threshold, int dir);
 void copy_dering_16bit_to_16bit(int16_t *dst, int dstride, int16_t *src,
                                 dering_list *dlist, int dering_count,
                                 int bsize);
@@ -56,10 +53,4 @@
                                      int threshold, int dir);
 int od_filter_dering_direction_8x8_c(int16_t *y, int ystride, const int16_t *in,
                                      int threshold, int dir);
-void od_filter_dering_orthogonal_4x4_c(int16_t *y, int ystride,
-                                       const int16_t *in, int threshold,
-                                       int dir);
-void od_filter_dering_orthogonal_8x8_c(int16_t *y, int ystride,
-                                       const int16_t *in, int threshold,
-                                       int dir);
 #endif
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 023a7e3..fbe9400 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -166,7 +166,7 @@
   // Marks if we need to use 16bit frame buffers (1: yes, 0: no).
   int use_highbitdepth;
 #endif
-#if CONFIG_CLPF
+#if CONFIG_CDEF
   // Two bits are used to signal the strength for all blocks and the
   // valid values are:
   // 0: no filtering
@@ -408,7 +408,7 @@
   BLOCK_SIZE sb_size;  // Size of the superblock used for this frame
   int mib_size;        // Size of the superblock in units of MI blocks
   int mib_size_log2;   // Log 2 of above.
-#if CONFIG_DERING
+#if CONFIG_CDEF
   int dering_level;
 #endif
 
diff --git a/av1/common/x86/od_dering_sse4.c b/av1/common/x86/od_dering_sse4.c
index 80bdba7..455bb2c 100644
--- a/av1/common/x86/od_dering_sse4.c
+++ b/av1/common/x86/od_dering_sse4.c
@@ -385,115 +385,3 @@
   }
   return (hsum_epi16(total_abs) + 8) >> 4;
 }
-
-void od_filter_dering_orthogonal_4x4_sse4_1(int16_t *y, int ystride,
-                                            const int16_t *in, int threshold,
-                                            int dir) {
-  int i;
-  int offset;
-  __m128i res;
-  __m128i p;
-  __m128i cmp;
-  __m128i row;
-  __m128i sum;
-  __m128i tmp;
-  __m128i thresh;
-  thresh = _mm_set1_epi16(threshold);
-  if (dir > 0 && dir < 4)
-    offset = OD_FILT_BSTRIDE;
-  else
-    offset = 1;
-  for (i = 0; i < 4; i += 2) {
-    sum = _mm_set1_epi16(0);
-    row = _mm_unpacklo_epi64(
-        _mm_loadl_epi64((__m128i *)&in[i * OD_FILT_BSTRIDE]),
-        _mm_loadl_epi64((__m128i *)&in[(i + 1) * OD_FILT_BSTRIDE]));
-
-    /*p = in[i*OD_FILT_BSTRIDE + k*offset] - row*/
-    tmp = _mm_unpacklo_epi64(
-        _mm_loadl_epi64((__m128i *)&in[i * OD_FILT_BSTRIDE + offset]),
-        _mm_loadl_epi64((__m128i *)&in[(i + 1) * OD_FILT_BSTRIDE + offset]));
-    p = _mm_sub_epi16(tmp, row);
-    /*if (abs(p) < threshold) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-    /*p = in[i*OD_FILT_BSTRIDE - k*offset] - row*/
-    tmp = _mm_unpacklo_epi64(
-        _mm_loadl_epi64((__m128i *)&in[i * OD_FILT_BSTRIDE - offset]),
-        _mm_loadl_epi64((__m128i *)&in[(i + 1) * OD_FILT_BSTRIDE - offset]));
-    p = _mm_sub_epi16(tmp, row);
-    /*if (abs(p) < threshold) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-
-    /*row + ((5*sum + 8) >> 4)*/
-    res = _mm_mullo_epi16(sum, _mm_set1_epi16(5));
-    res = _mm_add_epi16(res, _mm_set1_epi16(8));
-    res = _mm_srai_epi16(res, 4);
-    res = _mm_add_epi16(res, row);
-    _mm_storel_epi64((__m128i *)&y[i * ystride], res);
-    _mm_storel_epi64((__m128i *)&y[(i + 1) * ystride],
-                     _mm_unpackhi_epi64(res, res));
-  }
-}
-
-void od_filter_dering_orthogonal_8x8_sse4_1(int16_t *y, int ystride,
-                                            const int16_t *in, int threshold,
-                                            int dir) {
-  int i;
-  int offset;
-  __m128i res;
-  __m128i p;
-  __m128i cmp;
-  __m128i row;
-  __m128i sum;
-  __m128i thresh;
-  thresh = _mm_set1_epi16(threshold);
-  if (dir > 0 && dir < 4)
-    offset = OD_FILT_BSTRIDE;
-  else
-    offset = 1;
-  for (i = 0; i < 8; i++) {
-    sum = _mm_set1_epi16(0);
-    row = _mm_loadu_si128((__m128i *)&in[i * OD_FILT_BSTRIDE]);
-
-    /*p = in[i*OD_FILT_BSTRIDE + k*offset] - row*/
-    p = _mm_sub_epi16(
-        _mm_loadu_si128((__m128i *)&in[i * OD_FILT_BSTRIDE + 1 * offset]), row);
-    /*if (abs(p) < thresh) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-    /*p = in[i*OD_FILT_BSTRIDE - k*offset] - row*/
-    p = _mm_sub_epi16(
-        _mm_loadu_si128((__m128i *)&in[i * OD_FILT_BSTRIDE - 1 * offset]), row);
-    /*if (abs(p) < threshold) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-
-    /*p = in[i*OD_FILT_BSTRIDE + k*offset] - row*/
-    p = _mm_sub_epi16(
-        _mm_loadu_si128((__m128i *)&in[i * OD_FILT_BSTRIDE + 2 * offset]), row);
-    /*if (abs(p) < threshold) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-    /*p = in[i*OD_FILT_BSTRIDE - k*offset] - row*/
-    p = _mm_sub_epi16(
-        _mm_loadu_si128((__m128i *)&in[i * OD_FILT_BSTRIDE - 2 * offset]), row);
-    /*if (abs(p) < threshold) sum += p*/
-    cmp = od_cmplt_abs_epi16(p, thresh);
-    p = _mm_and_si128(p, cmp);
-    sum = _mm_add_epi16(sum, p);
-
-    /*row + ((3*sum + 8) >> 4)*/
-    res = _mm_mullo_epi16(sum, _mm_set1_epi16(3));
-    res = _mm_add_epi16(res, _mm_set1_epi16(8));
-    res = _mm_srai_epi16(res, 4);
-    res = _mm_add_epi16(res, row);
-    _mm_storeu_si128((__m128i *)&y[i * ystride], res);
-  }
-}
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 5290968..766df9d 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -28,14 +28,12 @@
 #include "aom_util/aom_thread.h"
 
 #include "av1/common/alloccommon.h"
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 #include "aom/aom_image.h"
 #include "av1/common/clpf.h"
+#include "av1/common/dering.h"
 #endif
 #include "av1/common/common.h"
-#if CONFIG_DERING
-#include "av1/common/dering.h"
-#endif  // CONFIG_DERING
 #include "av1/common/entropy.h"
 #include "av1/common/entropymode.h"
 #include "av1/common/entropymv.h"
@@ -1949,7 +1947,7 @@
   }
 }
 #endif  // CONFIG_SUPERTX
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 static int clpf_all_skip(const AV1_COMMON *cm, int mi_col, int mi_row,
                          int size) {
   int r, c;
@@ -2318,7 +2316,7 @@
     update_partition_context(xd, mi_row, mi_col, subsize, bsize);
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
-#if CONFIG_DERING
+#if CONFIG_CDEF
 #if CONFIG_EXT_PARTITION
   if (cm->sb_size == BLOCK_128X128 && bsize == BLOCK_128X128) {
     if (cm->dering_level != 0 && !sb_all_skip(cm, mi_row, mi_col)) {
@@ -2340,9 +2338,6 @@
           0;
     }
   }
-#endif
-
-#if CONFIG_CLPF
 #if CONFIG_EXT_PARTITION
   if (cm->sb_size == BLOCK_128X128 && bsize == BLOCK_128X128 &&
       cm->clpf_strength_y && cm->clpf_size != CLPF_NOSIZE) {
@@ -2420,7 +2415,7 @@
         cm->clpf_blocks[br] = aom_read_literal(r, 1, ACCT_STR);
     }
   }
-#endif  // CONFIG_CLPF
+#endif  // CONFIG_CDEF
 }
 
 static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
@@ -2694,7 +2689,7 @@
   }
 }
 
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 static void setup_clpf(AV1Decoder *pbi, struct aom_read_bit_buffer *rb) {
   AV1_COMMON *const cm = &pbi->common;
   const int width = pbi->cur_buf->buf.y_crop_width;
@@ -2727,13 +2722,11 @@
                     UNUSED unsigned int fb_size_log2, int8_t *bit) {
   return *bit;
 }
-#endif
 
-#if CONFIG_DERING
 static void setup_dering(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
   cm->dering_level = aom_rb_read_literal(rb, DERING_LEVEL_BITS);
 }
-#endif  // CONFIG_DERING
+#endif  // CONFIG_CDEF
 
 static INLINE int read_delta_q(struct aom_read_bit_buffer *rb) {
   return aom_rb_read_bit(rb) ? aom_rb_read_inv_signed_literal(rb, 6) : 0;
@@ -4326,10 +4319,8 @@
 #endif  // CONFIG_EXT_PARTITION
 
   setup_loopfilter(cm, rb);
-#if CONFIG_DERING
+#if CONFIG_CDEF
   setup_dering(cm, rb);
-#endif
-#if CONFIG_CLPF
   setup_clpf(pbi, rb);
 #endif
 #if CONFIG_LOOP_RESTORATION
@@ -4957,13 +4948,10 @@
   }
 #endif  // CONFIG_LOOP_RESTORATION
 
-#if CONFIG_DERING
+#if CONFIG_CDEF
   if (cm->dering_level && !cm->skip_loop_filter) {
     av1_dering_frame(&pbi->cur_buf->buf, cm, &pbi->mb, cm->dering_level);
   }
-#endif  // CONFIG_DERING
-
-#if CONFIG_CLPF
   if (!cm->skip_loop_filter) {
     const YV12_BUFFER_CONFIG *const frame = &pbi->cur_buf->buf;
     if (cm->clpf_strength_y) {
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 3afdc03..b7b85a3 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -23,12 +23,10 @@
 #include "aom_util/debug_util.h"
 #endif  // CONFIG_BITSTREAM_DEBUG
 
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 #include "av1/common/clpf.h"
-#endif
-#if CONFIG_DERING
 #include "av1/common/dering.h"
-#endif  // CONFIG_DERING
+#endif  // CONFIG_CDEF
 #include "av1/common/entropy.h"
 #include "av1/common/entropymode.h"
 #include "av1/common/entropymv.h"
@@ -2672,7 +2670,7 @@
     update_partition_context(xd, mi_row, mi_col, subsize, bsize);
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
-#if CONFIG_DERING
+#if CONFIG_CDEF
 #if CONFIG_EXT_PARTITION
   if (cm->sb_size == BLOCK_128X128 && bsize == BLOCK_128X128 &&
       cm->dering_level != 0 && !sb_all_skip(cm, mi_row, mi_col)) {
@@ -2692,7 +2690,7 @@
   }
 #endif
 
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 #if CONFIG_EXT_PARTITION
   if (cm->sb_size == BLOCK_128X128 && bsize == BLOCK_128X128 &&
       cm->clpf_blocks && cm->clpf_strength_y && cm->clpf_size != CLPF_NOSIZE) {
@@ -2763,7 +2761,7 @@
         cm->clpf_blocks[br] != CLPF_NOFLAG)
       aom_write_literal(w, cm->clpf_blocks[br], 1);
   }
-#endif  // CONFIG_CLPF
+#endif  // CONFIG_CDEF
 }
 
 static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
@@ -3491,7 +3489,7 @@
   }
 }
 
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 static void encode_clpf(const AV1_COMMON *cm, struct aom_write_bit_buffer *wb) {
   aom_wb_write_literal(wb, cm->clpf_strength_y, 2);
   aom_wb_write_literal(wb, cm->clpf_strength_u, 2);
@@ -3502,11 +3500,11 @@
 }
 #endif
 
-#if CONFIG_DERING
+#if CONFIG_CDEF
 static void encode_dering(int level, struct aom_write_bit_buffer *wb) {
   aom_wb_write_literal(wb, level, DERING_LEVEL_BITS);
 }
-#endif  // CONFIG_DERING
+#endif  // CONFIG_CDEF
 
 static void write_delta_q(struct aom_write_bit_buffer *wb, int delta_q) {
   if (delta_q != 0) {
@@ -4443,10 +4441,8 @@
 #endif  // CONFIG_EXT_PARTITION
 
   encode_loopfilter(cm, wb);
-#if CONFIG_DERING
+#if CONFIG_CDEF
   encode_dering(cm->dering_level, wb);
-#endif  // CONFIG_DERING
-#if CONFIG_CLPF
   encode_clpf(cm, wb);
 #endif
 #if CONFIG_LOOP_RESTORATION
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 5bc8e60..eb1acd9 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -16,14 +16,12 @@
 #include "./aom_config.h"
 
 #include "av1/common/alloccommon.h"
-#if CONFIG_CLPF
+#if CONFIG_CDEF
 #include "aom/aom_image.h"
 #include "av1/common/clpf.h"
 #include "av1/encoder/clpf_rdo.h"
-#endif
-#if CONFIG_DERING
 #include "av1/common/dering.h"
-#endif  // CONFIG_DERING
+#endif  // CONFIG_CDEF
 #include "av1/common/filter.h"
 #include "av1/common/idct.h"
 #include "av1/common/reconinter.h"
@@ -3491,7 +3489,7 @@
       av1_loop_filter_frame(cm->frame_to_show, cm, xd, lf->filter_level, 0, 0);
 #endif
   }
-#if CONFIG_DERING
+#if CONFIG_CDEF
   if (is_lossless_requested(&cpi->oxcf)) {
     cm->dering_level = 0;
   } else {
@@ -3499,9 +3497,6 @@
         av1_dering_search(cm->frame_to_show, cpi->Source, cm, xd);
     av1_dering_frame(cm->frame_to_show, cm, xd, cm->dering_level);
   }
-#endif  // CONFIG_DERING
-
-#if CONFIG_CLPF
   cm->clpf_strength_y = cm->clpf_strength_u = cm->clpf_strength_v = 0;
   cm->clpf_size = CLPF_64X64;
 
@@ -4909,7 +4904,7 @@
   if (cm->show_frame) dump_filtered_recon_frames(cpi);
 #endif  // DUMP_RECON_FRAMES
 
-#if CONFIG_CLPF
+#if CONFIG_CDEF
   aom_free(cm->clpf_blocks);
   cm->clpf_blocks = 0;
 #endif
diff --git a/build/cmake/aom_config.asm.cmake b/build/cmake/aom_config.asm.cmake
index 2bda39a..6aa9ed1 100644
--- a/build/cmake/aom_config.asm.cmake
+++ b/build/cmake/aom_config.asm.cmake
@@ -75,8 +75,7 @@
 CONFIG_AOM_QM equ ${CONFIG_AOM_QM}
 CONFIG_FP_MB_STATS equ ${CONFIG_FP_MB_STATS}
 CONFIG_EMULATE_HARDWARE equ ${CONFIG_EMULATE_HARDWARE}
-CONFIG_CLPF equ ${CONFIG_CLPF}
-CONFIG_DERING equ ${CONFIG_DERING}
+CONFIG_CDEF equ ${CONFIG_CDEF}
 CONFIG_VAR_TX equ ${CONFIG_VAR_TX}
 CONFIG_RECT_TX equ ${CONFIG_RECT_TX}
 CONFIG_REF_MV equ ${CONFIG_REF_MV}
diff --git a/build/cmake/aom_config.h.cmake b/build/cmake/aom_config.h.cmake
index b9f0013..dba3259 100644
--- a/build/cmake/aom_config.h.cmake
+++ b/build/cmake/aom_config.h.cmake
@@ -92,8 +92,7 @@
 #define CONFIG_AOM_QM ${CONFIG_AOM_QM}
 #define CONFIG_FP_MB_STATS ${CONFIG_FP_MB_STATS}
 #define CONFIG_EMULATE_HARDWARE ${CONFIG_EMULATE_HARDWARE}
-#define CONFIG_CLPF ${CONFIG_CLPF}
-#define CONFIG_DERING ${CONFIG_DERING}
+#define CONFIG_CDEF ${CONFIG_CDEF}
 #define CONFIG_VAR_TX ${CONFIG_VAR_TX}
 #define CONFIG_RECT_TX ${CONFIG_RECT_TX}
 #define CONFIG_REF_MV ${CONFIG_REF_MV}
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 07e892a..df7fd40 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -92,8 +92,7 @@
 set(CONFIG_AOM_QM 0 CACHE BOOL "Internal flag.")
 set(CONFIG_FP_MB_STATS 0 CACHE BOOL "Internal flag.")
 set(CONFIG_EMULATE_HARDWARE 0 CACHE BOOL "Internal flag.")
-set(CONFIG_CLPF 0 CACHE BOOL "Internal flag.")
-set(CONFIG_DERING 0 CACHE BOOL "Internal flag.")
+set(CONFIG_CDEF 0 CACHE BOOL "Internal flag.")
 set(CONFIG_VAR_TX 0 CACHE BOOL "Internal flag.")
 set(CONFIG_RECT_TX 0 CACHE BOOL "Internal flag.")
 set(CONFIG_REF_MV 0 CACHE BOOL "Internal flag.")
diff --git a/build/cmake/targets/generic.cmake b/build/cmake/targets/generic.cmake
index 80d58f4..be3f6b6 100644
--- a/build/cmake/targets/generic.cmake
+++ b/build/cmake/targets/generic.cmake
@@ -33,8 +33,8 @@
 if (CONFIG_AOM_HIGHBITDEPTH)
   set(RTCD_CONFIG_AOM_HIGHBITDEPTH "yes")
 endif ()
-if (CONFIG_CLPF)
-  set(RTCD_CONFIG_CLPF "yes")
+if (CONFIG_CDEF)
+  set(RTCD_CONFIG_CDEF "yes")
 endif ()
 if (CONFIG_EXT_INTER)
   set(RTCD_CONFIG_EXT_INTER "yes")
diff --git a/build/cmake/targets/rtcd_templates/generic.rtcd.cmake b/build/cmake/targets/rtcd_templates/generic.rtcd.cmake
index d0257fc..5595e84 100644
--- a/build/cmake/targets/rtcd_templates/generic.rtcd.cmake
+++ b/build/cmake/targets/rtcd_templates/generic.rtcd.cmake
@@ -25,6 +25,6 @@
 CONFIG_OS_SUPPORT=${RTCD_CONFIG_OS_SUPPORT}
 CONFIG_TEMPORAL_DENOISING=${RTCD_CONFIG_TEMPORAL_DENOISING}
 CONFIG_AOM_HIGHBITDEPTH=${RTCD_CONFIG_AOM_HIGHBITDEPTH}
-CONFIG_CLPF=${RTCD_CONFIG_CLPF}
+CONFIG_CDEF=${RTCD_CONFIG_CDEF}
 CONFIG_EXT_INTER=${RTCD_CONFIG_EXT_INTER}
 CONFIG_INTERNAL_STATS=${RTCD_CONFIG_INTERNAL_STATS}
diff --git a/build/cmake/targets/rtcd_templates/x86.rtcd.cmake b/build/cmake/targets/rtcd_templates/x86.rtcd.cmake
index 17541d6..bc042c9 100644
--- a/build/cmake/targets/rtcd_templates/x86.rtcd.cmake
+++ b/build/cmake/targets/rtcd_templates/x86.rtcd.cmake
@@ -36,7 +36,7 @@
 CONFIG_TEMPORAL_DENOISING=${RTCD_CONFIG_TEMPORAL_DENOISING}
 CONFIG_RUNTIME_CPU_DETECT=${RTCD_CONFIG_RUNTIME_CPU_DETECT}
 CONFIG_AOM_HIGHBITDEPTH=${RTCD_CONFIG_AOM_HIGHBITDEPTH}
-CONFIG_CLPF=${RTCD_CONFIG_CLPF}
+CONFIG_CDEF=${RTCD_CONFIG_CDEF}
 CONFIG_EXT_INTER=${RTCD_CONFIG_EXT_INTER}
 CONFIG_INTERNAL_STATS=${RTCD_CONFIG_INTERNAL_STATS}
 CONFIG_MOTION_VAR=${RTCD_CONFIG_MOTION_VAR}
diff --git a/build/cmake/targets/rtcd_templates/x86_64.rtcd.cmake b/build/cmake/targets/rtcd_templates/x86_64.rtcd.cmake
index f4c50bf..3a14a34 100644
--- a/build/cmake/targets/rtcd_templates/x86_64.rtcd.cmake
+++ b/build/cmake/targets/rtcd_templates/x86_64.rtcd.cmake
@@ -36,7 +36,7 @@
 CONFIG_TEMPORAL_DENOISING=${RTCD_CONFIG_TEMPORAL_DENOISING}
 CONFIG_RUNTIME_CPU_DETECT=${RTCD_CONFIG_RUNTIME_CPU_DETECT}
 CONFIG_AOM_HIGHBITDEPTH=${RTCD_CONFIG_AOM_HIGHBITDEPTH}
-CONFIG_CLPF=${RTCD_CONFIG_CLPF}
+CONFIG_CDEF=${RTCD_CONFIG_CDEF}
 CONFIG_EXT_INTER=${RTCD_CONFIG_EXT_INTER}
 CONFIG_INTERNAL_STATS=${RTCD_CONFIG_INTERNAL_STATS}
 CONFIG_MOTION_VAR=${RTCD_CONFIG_MOTION_VAR}
diff --git a/build/cmake/targets/x86.cmake b/build/cmake/targets/x86.cmake
index ef82b9e..9da61d6 100644
--- a/build/cmake/targets/x86.cmake
+++ b/build/cmake/targets/x86.cmake
@@ -55,8 +55,8 @@
 if (CONFIG_AOM_HIGHBITDEPTH)
   set(RTCD_CONFIG_AOM_HIGHBITDEPTH "yes")
 endif ()
-if (CONFIG_CLPF)
-  set(RTCD_CONFIG_CLPF "yes")
+if (CONFIG_CDEF)
+  set(RTCD_CONFIG_CDEF "yes")
 endif ()
 if (CONFIG_EXT_INTER)
   set(RTCD_CONFIG_EXT_INTER "yes")
diff --git a/build/cmake/targets/x86_64.cmake b/build/cmake/targets/x86_64.cmake
index ed43483..875b4e1 100644
--- a/build/cmake/targets/x86_64.cmake
+++ b/build/cmake/targets/x86_64.cmake
@@ -55,8 +55,8 @@
 if (CONFIG_AOM_HIGHBITDEPTH)
   set(RTCD_CONFIG_AOM_HIGHBITDEPTH "yes")
 endif ()
-if (CONFIG_CLPF)
-  set(RTCD_CONFIG_CLPF "yes")
+if (CONFIG_CDEF)
+  set(RTCD_CONFIG_CDEF "yes")
 endif ()
 if (CONFIG_EXT_INTER)
   set(RTCD_CONFIG_EXT_INTER "yes")
diff --git a/configure b/configure
index 8a0dfa4..556c2cf 100755
--- a/configure
+++ b/configure
@@ -250,8 +250,7 @@
 EXPERIMENT_LIST="
     fp_mb_stats
     emulate_hardware
-    clpf
-    dering
+    cdef
     var_tx
     rect_tx
     ref_mv
diff --git a/test/test.mk b/test/test.mk
index 92be4c7..5c19118 100644
--- a/test/test.mk
+++ b/test/test.mk
@@ -120,7 +120,7 @@
 LIBAOM_TEST_SRCS-$(CONFIG_ADAPT_SCAN)  += scan_test.cc
 LIBAOM_TEST_SRCS-yes                   += convolve_test.cc
 LIBAOM_TEST_SRCS-yes                   += lpf_8_test.cc
-LIBAOM_TEST_SRCS-$(CONFIG_CLPF)        += clpf_test.cc
+LIBAOM_TEST_SRCS-$(CONFIG_CDEF)        += clpf_test.cc
 LIBAOM_TEST_SRCS-yes                   += simd_cmp_impl.h
 LIBAOM_TEST_SRCS-$(HAVE_SSE2)          += simd_cmp_sse2.cc
 LIBAOM_TEST_SRCS-$(HAVE_SSSE3)         += simd_cmp_ssse3.cc