Remove CONFIG_SKIP_SGR config flag

This tool is fully adopted.

Change-Id: I55c10215c04ff6af8546cddf8cac9130e9afebdd
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 8b650e1..acf5cda 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -25,19 +25,12 @@
 #include "aom_ports/mem.h"
 
 const sgr_params_type sgr_params[SGRPROJ_PARAMS] = {
-// r1, eps1, r2, eps2
-#if CONFIG_SKIP_SGR
+  // r1, eps1, r2, eps2
   // Setting r = 0 skips the filter
   { 2, 12, 1, 4 },  { 2, 15, 1, 6 },  { 2, 18, 1, 8 },  { 2, 21, 1, 9 },
   { 2, 24, 1, 10 }, { 2, 29, 1, 11 }, { 2, 36, 1, 12 }, { 2, 45, 1, 13 },
   { 2, 56, 1, 14 }, { 2, 68, 1, 15 }, { 0, 0, 1, 5 },   { 0, 0, 1, 8 },
   { 0, 0, 1, 11 },  { 0, 0, 1, 14 },  { 2, 30, 0, 0 },  { 2, 75, 0, 0 },
-#else   // CONFIG_SKIP_SGR
-  { 2, 12, 1, 4 },  { 2, 15, 1, 6 },  { 2, 18, 1, 8 },  { 2, 20, 1, 9 },
-  { 2, 22, 1, 10 }, { 2, 25, 1, 11 }, { 2, 35, 1, 12 }, { 2, 45, 1, 13 },
-  { 2, 55, 1, 14 }, { 2, 65, 1, 15 }, { 2, 75, 1, 16 }, { 2, 30, 1, 6 },
-  { 2, 50, 1, 12 }, { 2, 60, 1, 13 }, { 2, 70, 1, 14 }, { 2, 80, 1, 15 },
-#endif  // CONFIG_SKIP_SGR
 };
 
 // Count horizontal or vertical units per tile (use a width or height for
@@ -565,7 +558,6 @@
     assert(0 && "Invalid value of r in self-guided filter");
 }
 
-#if CONFIG_SKIP_SGR
 void decode_xq(const int *xqd, int *xq, const sgr_params_type *params) {
   if (params->r0 == 0) {
     xq[0] = 0;
@@ -578,12 +570,6 @@
     xq[1] = (1 << SGRPROJ_PRJ_BITS) - xq[0] - xqd[1];
   }
 }
-#else   // CONFIG_SKIP_SGR
-void decode_xq(const int *xqd, int *xq) {
-  xq[0] = xqd[0];
-  xq[1] = (1 << SGRPROJ_PRJ_BITS) - xq[0] - xqd[1];
-}
-#endif  // CONFIG_SKIP_SGR
 
 const int32_t x_by_xplus1[256] = {
   // Special case: Map 0 -> 1 (corresponding to a value of 1/256)
@@ -892,7 +878,6 @@
     }
   }
 
-#if CONFIG_SKIP_SGR
   // If params->r == 0 we skip the corresponding filter. We only allow one of
   // the radii to be 0, as having both equal to 0 would be equivalent to
   // skipping SGR entirely.
@@ -906,16 +891,6 @@
     selfguided_restoration_internal(dgd32, width, height, dgd32_stride, flt1,
                                     flt_stride, bit_depth, params->r1,
                                     params->e1);
-#else   // CONFIG_SKIP_SGR
-  // r == 2 filter
-  selfguided_restoration_fast_internal(dgd32, width, height, dgd32_stride, flt0,
-                                       flt_stride, bit_depth, params->r0,
-                                       params->e0);
-  // r == 1 filter
-  selfguided_restoration_internal(dgd32, width, height, dgd32_stride, flt1,
-                                  flt_stride, bit_depth, params->r1,
-                                  params->e1);
-#endif  // CONFIG_SKIP_SGR
 }
 
 void apply_selfguided_restoration_c(const uint8_t *dat8, int width, int height,
@@ -927,18 +902,11 @@
   int32_t *flt1 = flt0 + RESTORATION_UNITPELS_MAX;
   assert(width * height <= RESTORATION_UNITPELS_MAX);
 
-#if CONFIG_SKIP_SGR
   const sgr_params_type *params = &sgr_params[eps];
   av1_selfguided_restoration_c(dat8, width, height, stride, flt0, flt1, width,
                                params, bit_depth, highbd);
   int xq[2];
   decode_xq(xqd, xq, params);
-#else   // CONFIG_SKIP_SGR
-  av1_selfguided_restoration_c(dat8, width, height, stride, flt0, flt1, width,
-                               &sgr_params[eps], bit_depth, highbd);
-  int xq[2];
-  decode_xq(xqd, xq);
-#endif  // CONFIG_SKIP_SGR
   for (int i = 0; i < height; ++i) {
     for (int j = 0; j < width; ++j) {
       const int k = i * width + j;
@@ -947,17 +915,11 @@
 
       const uint16_t pre_u = highbd ? *CONVERT_TO_SHORTPTR(dat8ij) : *dat8ij;
       const int32_t u = (int32_t)pre_u << SGRPROJ_RST_BITS;
-#if CONFIG_SKIP_SGR
       int32_t v = u << SGRPROJ_PRJ_BITS;
       // If params->r == 0 then we skipped the filtering in
       // av1_selfguided_restoration_c, i.e. flt[k] == u
       if (params->r0 > 0) v += xq[0] * (flt0[k] - u);
       if (params->r1 > 0) v += xq[1] * (flt1[k] - u);
-#else   // CONFIG_SKIP_SGR
-      const int32_t f1 = flt0[k] - u;
-      const int32_t f2 = flt1[k] - u;
-      const int32_t v = xq[0] * f1 + xq[1] * f2 + (u << SGRPROJ_PRJ_BITS);
-#endif  // CONFIG_SKIP_SGR
       const int16_t w =
           (int16_t)ROUND_POWER_OF_TWO(v, SGRPROJ_PRJ_BITS + SGRPROJ_RST_BITS);
 
diff --git a/av1/common/restoration.h b/av1/common/restoration.h
index 932115d..2e20e50 100644
--- a/av1/common/restoration.h
+++ b/av1/common/restoration.h
@@ -260,11 +260,7 @@
 
 void extend_frame(uint8_t *data, int width, int height, int stride,
                   int border_horz, int border_vert, int highbd);
-#if CONFIG_SKIP_SGR
 void decode_xq(const int *xqd, int *xq, const sgr_params_type *params);
-#else   // CONFIG_SKIP_SGR
-void decode_xq(const int *xqd, int *xq);
-#endif  // CONFIG_SKIP_SGR
 
 // Filter a single loop restoration unit.
 //
diff --git a/av1/common/x86/selfguided_avx2.c b/av1/common/x86/selfguided_avx2.c
index 7b8334b..fce2cd8 100644
--- a/av1/common/x86/selfguided_avx2.c
+++ b/av1/common/x86/selfguided_avx2.c
@@ -581,8 +581,7 @@
     integral_images(dgd0, dgd_stride, width_ext, height_ext, Ctl, Dtl,
                     buf_stride);
 
-// Write to flt0 and flt1
-#if CONFIG_SKIP_SGR
+  // Write to flt0 and flt1
   // If params->r == 0 we skip the corresponding filter. We only allow one of
   // the radii to be 0, as having both equal to 0 would be equivalent to
   // skipping SGR entirely.
@@ -603,23 +602,6 @@
     final_filter(flt1, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
                  height, highbd);
   }
-#else   // CONFIG_SKIP_SGR
-  assert(params->r0 < AOMMIN(SGRPROJ_BORDER_VERT, SGRPROJ_BORDER_HORZ));
-
-  // r == 2 filter
-  assert(params->r0 == 2);
-  calc_ab_fast(A, B, C, D, width, height, buf_stride, params->e0, bit_depth,
-               params->r0);
-  final_filter_fast(flt0, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
-                    height, highbd);
-
-  // r == 1 filter
-  assert(params->r1 == 1);
-  calc_ab(A, B, C, D, width, height, buf_stride, params->e1, bit_depth,
-          params->r1);
-  final_filter(flt1, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
-               height, highbd);
-#endif  // CONFIG_SKIP_SGR
 }
 
 void apply_selfguided_restoration_avx2(const uint8_t *dat8, int width,
@@ -630,18 +612,11 @@
   int32_t *flt0 = tmpbuf;
   int32_t *flt1 = flt0 + RESTORATION_UNITPELS_MAX;
   assert(width * height <= RESTORATION_UNITPELS_MAX);
-#if CONFIG_SKIP_SGR
   const sgr_params_type *params = &sgr_params[eps];
   av1_selfguided_restoration_avx2(dat8, width, height, stride, flt0, flt1,
                                   width, params, bit_depth, highbd);
   int xq[2];
   decode_xq(xqd, xq, params);
-#else   // CONFIG_SKIP_SGR
-  av1_selfguided_restoration_avx2(dat8, width, height, stride, flt0, flt1,
-                                  width, &sgr_params[eps], bit_depth, highbd);
-  int xq[2];
-  decode_xq(xqd, xq);
-#endif  // CONFIG_SKIP_SGR
 
   __m256i xq0 = _mm256_set1_epi32(xq[0]);
   __m256i xq1 = _mm256_set1_epi32(xq[1]);
@@ -669,7 +644,6 @@
       const __m256i u_0 = _mm256_slli_epi32(ep_0, SGRPROJ_RST_BITS);
       const __m256i u_1 = _mm256_slli_epi32(ep_1, SGRPROJ_RST_BITS);
 
-#if CONFIG_SKIP_SGR
       __m256i v_0 = _mm256_slli_epi32(u_0, SGRPROJ_PRJ_BITS);
       __m256i v_1 = _mm256_slli_epi32(u_1, SGRPROJ_PRJ_BITS);
 
@@ -688,22 +662,6 @@
         const __m256i f2_1 = _mm256_sub_epi32(yy_loadu_256(&flt1[k + 8]), u_1);
         v_1 = _mm256_add_epi32(v_1, _mm256_mullo_epi32(xq1, f2_1));
       }
-#else   // CONFIG_SKIP_SGR
-      const __m256i f1_0 = _mm256_sub_epi32(yy_loadu_256(&flt0[k]), u_0);
-      const __m256i f1_1 = _mm256_sub_epi32(yy_loadu_256(&flt0[k + 8]), u_1);
-
-      const __m256i f2_0 = _mm256_sub_epi32(yy_loadu_256(&flt1[k]), u_0);
-      const __m256i f2_1 = _mm256_sub_epi32(yy_loadu_256(&flt1[k + 8]), u_1);
-
-      const __m256i v_0 =
-          _mm256_add_epi32(_mm256_add_epi32(_mm256_mullo_epi32(xq0, f1_0),
-                                            _mm256_mullo_epi32(xq1, f2_0)),
-                           _mm256_slli_epi32(u_0, SGRPROJ_PRJ_BITS));
-      const __m256i v_1 =
-          _mm256_add_epi32(_mm256_add_epi32(_mm256_mullo_epi32(xq0, f1_1),
-                                            _mm256_mullo_epi32(xq1, f2_1)),
-                           _mm256_slli_epi32(u_1, SGRPROJ_PRJ_BITS));
-#endif  // CONFIG_SKIP_SGR
 
       const __m256i rounding =
           round_for_shift(SGRPROJ_PRJ_BITS + SGRPROJ_RST_BITS);
diff --git a/av1/common/x86/selfguided_sse4.c b/av1/common/x86/selfguided_sse4.c
index 68ad3be..2a523e5 100644
--- a/av1/common/x86/selfguided_sse4.c
+++ b/av1/common/x86/selfguided_sse4.c
@@ -536,8 +536,7 @@
     integral_images(dgd0, dgd_stride, width_ext, height_ext, Ctl, Dtl,
                     buf_stride);
 
-// Write to flt0 and flt1
-#if CONFIG_SKIP_SGR
+  // Write to flt0 and flt1
   // If params->r == 0 we skip the corresponding filter. We only allow one of
   // the radii to be 0, as having both equal to 0 would be equivalent to
   // skipping SGR entirely.
@@ -558,23 +557,6 @@
     final_filter(flt1, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
                  height, highbd);
   }
-#else   // CONFIG_SKIP_SGR
-  assert(params->r0 < AOMMIN(SGRPROJ_BORDER_VERT, SGRPROJ_BORDER_HORZ));
-
-  // r == 2 filter
-  assert(params->r0 == 2);
-  calc_ab_fast(A, B, C, D, width, height, buf_stride, params->e0, bit_depth,
-               params->r0);
-  final_filter_fast(flt0, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
-                    height, highbd);
-
-  // r == 1 filter
-  assert(params->r1 == 1);
-  calc_ab(A, B, C, D, width, height, buf_stride, params->e1, bit_depth,
-          params->r1);
-  final_filter(flt1, flt_stride, A, B, buf_stride, dgd8, dgd_stride, width,
-               height, highbd);
-#endif  // CONFIG_SKIP_SGR
 }
 
 void apply_selfguided_restoration_sse4_1(const uint8_t *dat8, int width,
@@ -585,18 +567,11 @@
   int32_t *flt0 = tmpbuf;
   int32_t *flt1 = flt0 + RESTORATION_UNITPELS_MAX;
   assert(width * height <= RESTORATION_UNITPELS_MAX);
-#if CONFIG_SKIP_SGR
   const sgr_params_type *params = &sgr_params[eps];
   av1_selfguided_restoration_sse4_1(dat8, width, height, stride, flt0, flt1,
                                     width, params, bit_depth, highbd);
   int xq[2];
   decode_xq(xqd, xq, params);
-#else   // CONFIG_SKIP_SGR
-  av1_selfguided_restoration_sse4_1(dat8, width, height, stride, flt0, flt1,
-                                    width, &sgr_params[eps], bit_depth, highbd);
-  int xq[2];
-  decode_xq(xqd, xq);
-#endif  // CONFIG_SKIP_SGR
 
   __m128i xq0 = _mm_set1_epi32(xq[0]);
   __m128i xq1 = _mm_set1_epi32(xq[1]);
@@ -619,7 +594,6 @@
       const __m128i u_0 = _mm_cvtepu16_epi32(u);
       const __m128i u_1 = _mm_cvtepu16_epi32(_mm_srli_si128(u, 8));
 
-#if CONFIG_SKIP_SGR
       __m128i v_0 = _mm_slli_epi32(u_0, SGRPROJ_PRJ_BITS);
       __m128i v_1 = _mm_slli_epi32(u_1, SGRPROJ_PRJ_BITS);
 
@@ -638,19 +612,6 @@
         const __m128i f2_1 = _mm_sub_epi32(xx_loadu_128(&flt1[k + 4]), u_1);
         v_1 = _mm_add_epi32(v_1, _mm_mullo_epi32(xq1, f2_1));
       }
-#else   // CONFIG_SKIP_SGR
-      const __m128i f1_0 = _mm_sub_epi32(xx_loadu_128(&flt0[k]), u_0);
-      const __m128i f2_0 = _mm_sub_epi32(xx_loadu_128(&flt1[k]), u_0);
-      const __m128i f1_1 = _mm_sub_epi32(xx_loadu_128(&flt0[k + 4]), u_1);
-      const __m128i f2_1 = _mm_sub_epi32(xx_loadu_128(&flt1[k + 4]), u_1);
-
-      const __m128i v_0 = _mm_add_epi32(
-          _mm_add_epi32(_mm_mullo_epi32(xq0, f1_0), _mm_mullo_epi32(xq1, f2_0)),
-          _mm_slli_epi32(u_0, SGRPROJ_PRJ_BITS));
-      const __m128i v_1 = _mm_add_epi32(
-          _mm_add_epi32(_mm_mullo_epi32(xq0, f1_1), _mm_mullo_epi32(xq1, f2_1)),
-          _mm_slli_epi32(u_1, SGRPROJ_PRJ_BITS));
-#endif  // CONFIG_SKIP_SGR
 
       const __m128i rounding =
           round_for_shift(SGRPROJ_PRJ_BITS + SGRPROJ_RST_BITS);
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 283aa44..d6a2b9c 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1016,7 +1016,6 @@
   memcpy(ref_wiener_info, wiener_info, sizeof(*wiener_info));
 }
 
-#if CONFIG_SKIP_SGR
 static void read_sgrproj_filter(SgrprojInfo *sgrproj_info,
                                 SgrprojInfo *ref_sgrproj_info, aom_reader *rb) {
   sgrproj_info->ep = aom_read_literal(rb, SGRPROJ_PARAMS_BITS, ACCT_STR);
@@ -1052,23 +1051,6 @@
 
   memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
 }
-#else   // CONFIG_SKIP_SGR
-static void read_sgrproj_filter(SgrprojInfo *sgrproj_info,
-                                SgrprojInfo *ref_sgrproj_info, aom_reader *rb) {
-  sgrproj_info->ep = aom_read_literal(rb, SGRPROJ_PARAMS_BITS, ACCT_STR);
-  sgrproj_info->xqd[0] =
-      aom_read_primitive_refsubexpfin(
-          rb, SGRPROJ_PRJ_MAX0 - SGRPROJ_PRJ_MIN0 + 1, SGRPROJ_PRJ_SUBEXP_K,
-          ref_sgrproj_info->xqd[0] - SGRPROJ_PRJ_MIN0, ACCT_STR) +
-      SGRPROJ_PRJ_MIN0;
-  sgrproj_info->xqd[1] =
-      aom_read_primitive_refsubexpfin(
-          rb, SGRPROJ_PRJ_MAX1 - SGRPROJ_PRJ_MIN1 + 1, SGRPROJ_PRJ_SUBEXP_K,
-          ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1, ACCT_STR) +
-      SGRPROJ_PRJ_MIN1;
-  memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
-}
-#endif  // CONFIG_SKIP_SGR
 
 static void loop_restoration_read_sb_coeffs(const AV1_COMMON *const cm,
                                             MACROBLOCKD *xd,
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index f516e8b..1b07e9a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1896,7 +1896,6 @@
   memcpy(ref_wiener_info, wiener_info, sizeof(*wiener_info));
 }
 
-#if CONFIG_SKIP_SGR
 static void write_sgrproj_filter(const SgrprojInfo *sgrproj_info,
                                  SgrprojInfo *ref_sgrproj_info,
                                  aom_writer *wb) {
@@ -1927,22 +1926,6 @@
 
   memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
 }
-#else   // CONFIG_SKIP_SGR
-static void write_sgrproj_filter(const SgrprojInfo *sgrproj_info,
-                                 SgrprojInfo *ref_sgrproj_info,
-                                 aom_writer *wb) {
-  aom_write_literal(wb, sgrproj_info->ep, SGRPROJ_PARAMS_BITS);
-  aom_write_primitive_refsubexpfin(wb, SGRPROJ_PRJ_MAX0 - SGRPROJ_PRJ_MIN0 + 1,
-                                   SGRPROJ_PRJ_SUBEXP_K,
-                                   ref_sgrproj_info->xqd[0] - SGRPROJ_PRJ_MIN0,
-                                   sgrproj_info->xqd[0] - SGRPROJ_PRJ_MIN0);
-  aom_write_primitive_refsubexpfin(wb, SGRPROJ_PRJ_MAX1 - SGRPROJ_PRJ_MIN1 + 1,
-                                   SGRPROJ_PRJ_SUBEXP_K,
-                                   ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1,
-                                   sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1);
-  memcpy(ref_sgrproj_info, sgrproj_info, sizeof(*sgrproj_info));
-}
-#endif  // CONFIG_SKIP_SGR
 
 static void loop_restoration_write_sb_coeffs(const AV1_COMMON *const cm,
                                              MACROBLOCKD *xd,
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 5322da9..9e283c9 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -171,20 +171,12 @@
                                     int src_stride, const uint8_t *dat8,
                                     int dat_stride, int use_highbitdepth,
                                     int32_t *flt0, int flt0_stride,
-                                    int32_t *flt1, int flt1_stride, int *xqd
-#if CONFIG_SKIP_SGR
-                                    ,
-                                    const sgr_params_type *params
-#endif  // CONFIG_SKIP_SGR
-) {
+                                    int32_t *flt1, int flt1_stride, int *xqd,
+                                    const sgr_params_type *params) {
   int i, j;
   int64_t err = 0;
   int xq[2];
-#if CONFIG_SKIP_SGR
   decode_xq(xqd, xq, params);
-#else   // CONFIG_SKIP_SGR
-  decode_xq(xqd, xq);
-#endif  // CONFIG_SKIP_SGR
   if (!use_highbitdepth) {
     const uint8_t *src = src8;
     const uint8_t *dat = dat8;
@@ -192,15 +184,9 @@
       for (j = 0; j < width; ++j) {
         const int32_t u =
             (int32_t)(dat[i * dat_stride + j] << SGRPROJ_RST_BITS);
-#if CONFIG_SKIP_SGR
         int32_t v = u << SGRPROJ_PRJ_BITS;
         if (params->r0 > 0) v += xq[0] * (flt0[i * flt0_stride + j] - u);
         if (params->r1 > 0) v += xq[1] * (flt1[i * flt1_stride + j] - u);
-#else   // CONFIG_SKIP_SGR
-        const int32_t f1 = (int32_t)flt0[i * flt0_stride + j] - u;
-        const int32_t f2 = (int32_t)flt1[i * flt1_stride + j] - u;
-        const int32_t v = xq[0] * f1 + xq[1] * f2 + (u << SGRPROJ_PRJ_BITS);
-#endif  // CONFIG_SKIP_SGR
         const int32_t e =
             ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) -
             src[i * src_stride + j];
@@ -214,15 +200,9 @@
       for (j = 0; j < width; ++j) {
         const int32_t u =
             (int32_t)(dat[i * dat_stride + j] << SGRPROJ_RST_BITS);
-#if CONFIG_SKIP_SGR
         int32_t v = u << SGRPROJ_PRJ_BITS;
         if (params->r0 > 0) v += xq[0] * (flt0[i * flt0_stride + j] - u);
         if (params->r1 > 0) v += xq[1] * (flt1[i * flt1_stride + j] - u);
-#else   // CONFIG_SKIP_SGR
-        const int32_t f1 = (int32_t)flt0[i * flt0_stride + j] - u;
-        const int32_t f2 = (int32_t)flt1[i * flt1_stride + j] - u;
-        const int32_t v = xq[0] * f1 + xq[1] * f2 + (u << SGRPROJ_PRJ_BITS);
-#endif  // CONFIG_SKIP_SGR
         const int32_t e =
             ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) -
             src[i * src_stride + j];
@@ -237,21 +217,11 @@
 static int64_t finer_search_pixel_proj_error(
     const uint8_t *src8, int width, int height, int src_stride,
     const uint8_t *dat8, int dat_stride, int use_highbitdepth, int32_t *flt0,
-    int flt0_stride, int32_t *flt1, int flt1_stride, int start_step, int *xqd
-#if CONFIG_SKIP_SGR
-    ,
-    const sgr_params_type *params
-#endif  // CONFIG_SKIP_SGR
-) {
-#if CONFIG_SKIP_SGR
+    int flt0_stride, int32_t *flt1, int flt1_stride, int start_step, int *xqd,
+    const sgr_params_type *params) {
   int64_t err = get_pixel_proj_error(
       src8, width, height, src_stride, dat8, dat_stride, use_highbitdepth, flt0,
       flt0_stride, flt1, flt1_stride, xqd, params);
-#else   // CONFIG_SKIP_SGR
-  int64_t err = get_pixel_proj_error(src8, width, height, src_stride, dat8,
-                                     dat_stride, use_highbitdepth, flt0,
-                                     flt0_stride, flt1, flt1_stride, xqd);
-#endif  // CONFIG_SKIP_SGR
   (void)start_step;
 #if USE_SGRPROJ_REFINEMENT_SEARCH
   int64_t err2;
@@ -259,23 +229,15 @@
   int tap_max[] = { SGRPROJ_PRJ_MAX0, SGRPROJ_PRJ_MAX1 };
   for (int s = start_step; s >= 1; s >>= 1) {
     for (int p = 0; p < 2; ++p) {
-#if CONFIG_SKIP_SGR
       if ((params->r0 == 0 && p == 0) || (params->r1 == 0 && p == 1)) continue;
-#endif
       int skip = 0;
       do {
         if (xqd[p] - s >= tap_min[p]) {
           xqd[p] -= s;
-#if CONFIG_SKIP_SGR
           err2 =
               get_pixel_proj_error(src8, width, height, src_stride, dat8,
                                    dat_stride, use_highbitdepth, flt0,
                                    flt0_stride, flt1, flt1_stride, xqd, params);
-#else   // CONFIG_SKIP_SGR
-          err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8,
-                                      dat_stride, use_highbitdepth, flt0,
-                                      flt0_stride, flt1, flt1_stride, xqd);
-#endif  // CONFIG_SKIP_SGR
           if (err2 > err) {
             xqd[p] += s;
           } else {
@@ -291,16 +253,10 @@
       do {
         if (xqd[p] + s <= tap_max[p]) {
           xqd[p] += s;
-#if CONFIG_SKIP_SGR
           err2 =
               get_pixel_proj_error(src8, width, height, src_stride, dat8,
                                    dat_stride, use_highbitdepth, flt0,
                                    flt0_stride, flt1, flt1_stride, xqd, params);
-#else   // CONFIG_SKIP_SGR
-          err2 = get_pixel_proj_error(src8, width, height, src_stride, dat8,
-                                      dat_stride, use_highbitdepth, flt0,
-                                      flt0_stride, flt1, flt1_stride, xqd);
-#endif  // CONFIG_SKIP_SGR
           if (err2 > err) {
             xqd[p] -= s;
           } else {
@@ -321,12 +277,8 @@
                               int src_stride, const uint8_t *dat8,
                               int dat_stride, int use_highbitdepth,
                               int32_t *flt0, int flt0_stride, int32_t *flt1,
-                              int flt1_stride, int *xq
-#if CONFIG_SKIP_SGR
-                              ,
-                              const sgr_params_type *params
-#endif  // CONFIG_SKIP_SGR
-) {
+                              int flt1_stride, int *xq,
+                              const sgr_params_type *params) {
   int i, j;
   double H[2][2] = { { 0, 0 }, { 0, 0 } };
   double C[2] = { 0, 0 };
@@ -347,15 +299,10 @@
         const double u = (double)(dat[i * dat_stride + j] << SGRPROJ_RST_BITS);
         const double s =
             (double)(src[i * src_stride + j] << SGRPROJ_RST_BITS) - u;
-#if CONFIG_SKIP_SGR
         const double f1 =
             (params->r0 > 0) ? (double)flt0[i * flt0_stride + j] - u : 0;
         const double f2 =
             (params->r1 > 0) ? (double)flt1[i * flt1_stride + j] - u : 0;
-#else   // CONFIG_SKIP_SGR
-        const double f1 = (double)flt0[i * flt0_stride + j] - u;
-        const double f2 = (double)flt1[i * flt1_stride + j] - u;
-#endif  // CONFIG_SKIP_SGR
         H[0][0] += f1 * f1;
         H[1][1] += f2 * f2;
         H[0][1] += f1 * f2;
@@ -371,15 +318,10 @@
         const double u = (double)(dat[i * dat_stride + j] << SGRPROJ_RST_BITS);
         const double s =
             (double)(src[i * src_stride + j] << SGRPROJ_RST_BITS) - u;
-#if CONFIG_SKIP_SGR
         const double f1 =
             (params->r0 > 0) ? (double)flt0[i * flt0_stride + j] - u : 0;
         const double f2 =
             (params->r1 > 0) ? (double)flt1[i * flt1_stride + j] - u : 0;
-#else   // CONFIG_SKIP_SGR
-        const double f1 = (double)flt0[i * flt0_stride + j] - u;
-        const double f2 = (double)flt1[i * flt1_stride + j] - u;
-#endif  // CONFIG_SKIP_SGR
         H[0][0] += f1 * f1;
         H[1][1] += f2 * f2;
         H[0][1] += f1 * f2;
@@ -394,7 +336,6 @@
   H[1][0] = H[0][1];
   C[0] /= size;
   C[1] /= size;
-#if CONFIG_SKIP_SGR
   if (params->r0 == 0) {
     // H matrix is now only the scalar H[1][1]
     // C vector is now only the scalar C[1]
@@ -424,17 +365,8 @@
     xq[0] = (int)rint(x[0] * (1 << SGRPROJ_PRJ_BITS));
     xq[1] = (int)rint(x[1] * (1 << SGRPROJ_PRJ_BITS));
   }
-#else   // CONFIG_SKIP_SGR
-  Det = (H[0][0] * H[1][1] - H[0][1] * H[1][0]);
-  if (Det < 1e-8) return;  // ill-posed, return default values
-  x[0] = (H[1][1] * C[0] - H[0][1] * C[1]) / Det;
-  x[1] = (H[0][0] * C[1] - H[1][0] * C[0]) / Det;
-  xq[0] = (int)rint(x[0] * (1 << SGRPROJ_PRJ_BITS));
-  xq[1] = (int)rint(x[1] * (1 << SGRPROJ_PRJ_BITS));
-#endif  // CONFIG_SKIP_SGR
 }
 
-#if CONFIG_SKIP_SGR
 void encode_xq(int *xq, int *xqd, const sgr_params_type *params) {
   if (params->r0 == 0) {
     xqd[0] = 0;
@@ -450,14 +382,6 @@
                    SGRPROJ_PRJ_MAX1);
   }
 }
-#else   // CONFIG_SKIP_SGR
-void encode_xq(int *xq, int *xqd) {
-  xqd[0] = xq[0];
-  xqd[0] = clamp(xqd[0], SGRPROJ_PRJ_MIN0, SGRPROJ_PRJ_MAX0);
-  xqd[1] = (1 << SGRPROJ_PRJ_BITS) - xqd[0] - xq[1];
-  xqd[1] = clamp(xqd[1], SGRPROJ_PRJ_MIN1, SGRPROJ_PRJ_MAX1);
-}
-#endif  // CONFIG_SKIP_SGR
 
 // Apply the self-guided filter across an entire restoration unit.
 static void apply_sgr(const sgr_params_type *params, const uint8_t *dat8,
@@ -502,27 +426,14 @@
     apply_sgr(params, dat8, width, height, dat_stride, use_highbitdepth,
               bit_depth, pu_width, pu_height, flt0, flt1, flt_stride);
     aom_clear_system_state();
-#if CONFIG_SKIP_SGR
     get_proj_subspace(src8, width, height, src_stride, dat8, dat_stride,
                       use_highbitdepth, flt0, flt_stride, flt1, flt_stride, exq,
                       params);
-#else   // CONFIG_SKIP_SGR
-    get_proj_subspace(src8, width, height, src_stride, dat8, dat_stride,
-                      use_highbitdepth, flt0, flt_stride, flt1, flt_stride,
-                      exq);
-#endif  // CONFIG_SKIP_SGR
     aom_clear_system_state();
-#if CONFIG_SKIP_SGR
     encode_xq(exq, exqd, params);
     int64_t err = finer_search_pixel_proj_error(
         src8, width, height, src_stride, dat8, dat_stride, use_highbitdepth,
         flt0, flt_stride, flt1, flt_stride, 2, exqd, params);
-#else   // CONFIG_SKIP_SGR
-    encode_xq(exq, exqd);
-    int64_t err = finer_search_pixel_proj_error(
-        src8, width, height, src_stride, dat8, dat_stride, use_highbitdepth,
-        flt0, flt_stride, flt1, flt_stride, 2, exqd);
-#endif  // CONFIG_SKIP_SGR
     if (besterr == -1 || err < besterr) {
       bestep = ep;
       besterr = err;
@@ -541,7 +452,6 @@
 static int count_sgrproj_bits(SgrprojInfo *sgrproj_info,
                               SgrprojInfo *ref_sgrproj_info) {
   int bits = SGRPROJ_PARAMS_BITS;
-#if CONFIG_SKIP_SGR
   const sgr_params_type *params = &sgr_params[sgrproj_info->ep];
   if (params->r0 > 0)
     bits += aom_count_primitive_refsubexpfin(
@@ -553,16 +463,6 @@
         SGRPROJ_PRJ_MAX1 - SGRPROJ_PRJ_MIN1 + 1, SGRPROJ_PRJ_SUBEXP_K,
         ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1,
         sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1);
-#else   // CONFIG_SKIP_SGR
-  bits += aom_count_primitive_refsubexpfin(
-      SGRPROJ_PRJ_MAX0 - SGRPROJ_PRJ_MIN0 + 1, SGRPROJ_PRJ_SUBEXP_K,
-      ref_sgrproj_info->xqd[0] - SGRPROJ_PRJ_MIN0,
-      sgrproj_info->xqd[0] - SGRPROJ_PRJ_MIN0);
-  bits += aom_count_primitive_refsubexpfin(
-      SGRPROJ_PRJ_MAX1 - SGRPROJ_PRJ_MIN1 + 1, SGRPROJ_PRJ_SUBEXP_K,
-      ref_sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1,
-      sgrproj_info->xqd[1] - SGRPROJ_PRJ_MIN1);
-#endif  // CONFIG_SKIP_SGR
   return bits;
 }
 
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index d42fd0e..4aff649 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -107,7 +107,6 @@
 set(CONFIG_OPERATING_POINTS 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SCALABILITY 1 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_SKIP_SGR 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_SPATIAL_SEGMENTATION 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TRAILING_BITS 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_FILEOPTIONS 1 CACHE NUMBER "AV1 config option flag.")