aom: cdef: add missing CONFIG_AV1_HIGHBITDEPTH check

From 416dbf19058a302cdc03d21062b2cdc2a825304a Mon Sep 17 00:00:00 2001
From: James Zern <[EMAIL REDACTED]>
Date: Wed, 21 Aug 2024 12:16:05 -0700
Subject: [PATCH] cdef: add missing CONFIG_AV1_HIGHBITDEPTH check

only define cdef_copy_rect8_16bit_to_16bit() when this config is set.

Bug: aomedia:3416
Change-Id: Id95583709133a977c21d8c8d71d3d2e2bd8332b9
---
 av1/common/arm/cdef_block_neon.c |  2 ++
 av1/common/av1_rtcd_defs.pl      |  8 ++++++--
 av1/common/cdef.c                |  2 ++
 av1/common/cdef_block_simd.h     |  3 +++
 test/cdef_test.cc                | 12 ++++++++++++
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/av1/common/arm/cdef_block_neon.c b/av1/common/arm/cdef_block_neon.c
index be6df922e..418314469 100644
--- a/av1/common/arm/cdef_block_neon.c
+++ b/av1/common/arm/cdef_block_neon.c
@@ -50,6 +50,7 @@ void cdef_copy_rect8_8bit_to_16bit_neon(uint16_t *dst, int dstride,
   } while (--height != 0);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void cdef_copy_rect8_16bit_to_16bit_neon(uint16_t *dst, int dstride,
                                          const uint16_t *src, int sstride,
                                          int width, int height) {
@@ -73,6 +74,7 @@ void cdef_copy_rect8_16bit_to_16bit_neon(uint16_t *dst, int dstride,
     dst += dstride;
   } while (--height != 0);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 // partial A is a 16-bit vector of the form:
 // [x8 x7 x6 x5 x4 x3 x2 x1] and partial B has the form:
diff --git a/av1/common/av1_rtcd_defs.pl b/av1/common/av1_rtcd_defs.pl
index 1254715f8..a8a01f1f0 100644
--- a/av1/common/av1_rtcd_defs.pl
+++ b/av1/common/av1_rtcd_defs.pl
@@ -488,7 +488,9 @@ ()
 add_proto qw/void cdef_filter_16_3/, "void *dst16, int dstride, const uint16_t *in, int pri_strength, int sec_strength, int dir, int pri_damping, int sec_damping, int coeff_shift, int block_width, int block_height";
 
 add_proto qw/void cdef_copy_rect8_8bit_to_16bit/, "uint16_t *dst, int dstride, const uint8_t *src, int sstride, int width, int height";
-add_proto qw/void cdef_copy_rect8_16bit_to_16bit/, "uint16_t *dst, int dstride, const uint16_t *src, int sstride, int width, int height";
+if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+  add_proto qw/void cdef_copy_rect8_16bit_to_16bit/, "uint16_t *dst, int dstride, const uint16_t *src, int sstride, int width, int height";
+}
 
 # VS compiling for 32 bit targets does not support vector types in
 # structs as arguments, which makes the v256 type of the intrinsics
@@ -508,7 +510,9 @@ ()
   specialize qw/cdef_filter_16_3 sse4_1 avx2 neon/, "$ssse3_x86";
 
   specialize qw/cdef_copy_rect8_8bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
-  specialize qw/cdef_copy_rect8_16bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
+  if (aom_config("CONFIG_AV1_HIGHBITDEPTH") eq "yes") {
+    specialize qw/cdef_copy_rect8_16bit_to_16bit sse4_1 avx2 neon/, "$ssse3_x86";
+  }
 }
 
 # WARPED_MOTION / GLOBAL_MOTION functions
diff --git a/av1/common/cdef.c b/av1/common/cdef.c
index a8d207c36..c39fca308 100644
--- a/av1/common/cdef.c
+++ b/av1/common/cdef.c
@@ -82,6 +82,7 @@ void cdef_copy_rect8_8bit_to_16bit_c(uint16_t *dst, int dstride,
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride,
                                       const uint16_t *src, int sstride,
                                       int width, int height) {
@@ -91,6 +92,7 @@ void cdef_copy_rect8_16bit_to_16bit_c(uint16_t *dst, int dstride,
     }
   }
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 void av1_cdef_copy_sb8_16_lowbd(uint16_t *const dst, int dstride,
                                 const uint8_t *src, int src_voffset,
diff --git a/av1/common/cdef_block_simd.h b/av1/common/cdef_block_simd.h
index 56c5baa61..35a729d5b 100644
--- a/av1/common/cdef_block_simd.h
+++ b/av1/common/cdef_block_simd.h
@@ -12,6 +12,7 @@
 #ifndef AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
 #define AOM_AV1_COMMON_CDEF_BLOCK_SIMD_H_
 
+#include "config/aom_config.h"
 #include "config/av1_rtcd.h"
 
 #include "av1/common/cdef_block.h"
@@ -824,6 +825,7 @@ void SIMD_FUNC(cdef_filter_16_3)(void *dest, int dstride, const uint16_t *in,
   }
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 void SIMD_FUNC(cdef_copy_rect8_16bit_to_16bit)(uint16_t *dst, int dstride,
                                                const uint16_t *src, int sstride,
                                                int width, int height) {
@@ -838,6 +840,7 @@ void SIMD_FUNC(cdef_copy_rect8_16bit_to_16bit)(uint16_t *dst, int dstride,
     }
   }
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 #undef CDEF_INLINE
 
diff --git a/test/cdef_test.cc b/test/cdef_test.cc
index 7ce278c05..772cc6fef 100644
--- a/test/cdef_test.cc
+++ b/test/cdef_test.cc
@@ -488,6 +488,7 @@ class CDEFCopyRect8to16Test
 };
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CDEFCopyRect8to16Test);
 
+#if CONFIG_AV1_HIGHBITDEPTH
 using CDEFCopyRect16To16 = void (*)(uint16_t *dst, int dstride,
                                     const uint16_t *src, int sstride, int width,
                                     int height);
@@ -571,6 +572,7 @@ class CDEFCopyRect16to16Test
   CDEFCopyRect16To16 ref_func_;
 };
 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CDEFCopyRect16to16Test);
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 TEST_P(CDEFBlockTest, TestSIMDNoMismatch) {
   test_cdef(bsize, 1, cdef, ref_cdef, boundary, depth);
@@ -608,9 +610,11 @@ TEST_P(CDEFCopyRect8to16Test, TestSIMDNoMismatch) {
   test_copy_rect_8_to_16(test_func_, ref_func_);
 }
 
+#if CONFIG_AV1_HIGHBITDEPTH
 TEST_P(CDEFCopyRect16to16Test, TestSIMDNoMismatch) {
   test_copy_rect_16_to_16(test_func_, ref_func_);
 }
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 
 using std::make_tuple;
 
@@ -663,10 +667,12 @@ INSTANTIATE_TEST_SUITE_P(
     ::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
                                  &cdef_copy_rect8_8bit_to_16bit_ssse3)));
 
+#if CONFIG_AV1_HIGHBITDEPTH
 INSTANTIATE_TEST_SUITE_P(
     SSSE3, CDEFCopyRect16to16Test,
     ::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
                                  &cdef_copy_rect8_16bit_to_16bit_ssse3)));
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif
 
 #if HAVE_SSE4_1
@@ -707,10 +713,12 @@ INSTANTIATE_TEST_SUITE_P(
     ::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
                                  &cdef_copy_rect8_8bit_to_16bit_sse4_1)));
 
+#if CONFIG_AV1_HIGHBITDEPTH
 INSTANTIATE_TEST_SUITE_P(
     SSE4_1, CDEFCopyRect16to16Test,
     ::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
                                  &cdef_copy_rect8_16bit_to_16bit_sse4_1)));
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif
 
 #if HAVE_AVX2
@@ -750,10 +758,12 @@ INSTANTIATE_TEST_SUITE_P(
     ::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
                                  &cdef_copy_rect8_8bit_to_16bit_avx2)));
 
+#if CONFIG_AV1_HIGHBITDEPTH
 INSTANTIATE_TEST_SUITE_P(
     AVX2, CDEFCopyRect16to16Test,
     ::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
                                  &cdef_copy_rect8_16bit_to_16bit_avx2)));
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif
 
 #if HAVE_NEON
@@ -793,10 +803,12 @@ INSTANTIATE_TEST_SUITE_P(
     ::testing::Values(make_tuple(&cdef_copy_rect8_8bit_to_16bit_c,
                                  &cdef_copy_rect8_8bit_to_16bit_neon)));
 
+#if CONFIG_AV1_HIGHBITDEPTH
 INSTANTIATE_TEST_SUITE_P(
     NEON, CDEFCopyRect16to16Test,
     ::testing::Values(make_tuple(&cdef_copy_rect8_16bit_to_16bit_c,
                                  &cdef_copy_rect8_16bit_to_16bit_neon)));
+#endif  // CONFIG_AV1_HIGHBITDEPTH
 #endif
 
 // Test speed for all supported architectures