shithub: libvpx

Download patch

ref: d6423b316641ee55d1dda69f2e7fde8804405e4d
parent: 63bdc574e52951bcda3e6f19c4d37b25452bcdaf
author: Johann <[email protected]>
date: Thu Jul 6 03:51:59 EDT 2017

sad neon: macroize 8xN definitions

Change-Id: I7b36a57e893c1795a37ba7994995bec7ff021409

--- a/vpx_dsp/arm/sad_neon.c
+++ b/vpx_dsp/arm/sad_neon.c
@@ -96,24 +96,6 @@
   return abs;
 }
 
-uint32_t vpx_sad8x4_neon(const uint8_t *src, int src_stride, const uint8_t *ref,
-                         int ref_stride) {
-  const uint16x8_t abs = sad8x(src, src_stride, ref, ref_stride, 4);
-  return horizontal_add_16x8(abs);
-}
-
-uint32_t vpx_sad8x8_neon(const uint8_t *src, int src_stride, const uint8_t *ref,
-                         int ref_stride) {
-  const uint16x8_t abs = sad8x(src, src_stride, ref, ref_stride, 8);
-  return horizontal_add_16x8(abs);
-}
-
-uint32_t vpx_sad8x16_neon(const uint8_t *src, int src_stride,
-                          const uint8_t *ref, int ref_stride) {
-  const uint16x8_t abs = sad8x(src, src_stride, ref, ref_stride, 16);
-  return horizontal_add_16x8(abs);
-}
-
 static INLINE uint16x8_t sad8x_avg(const uint8_t *a, int a_stride,
                                    const uint8_t *b, int b_stride,
                                    const uint8_t *c, const int height) {
@@ -133,29 +115,24 @@
   return abs;
 }
 
-uint32_t vpx_sad8x4_avg_neon(const uint8_t *src, int src_stride,
-                             const uint8_t *ref, int ref_stride,
-                             const uint8_t *second_pred) {
-  const uint16x8_t abs =
-      sad8x_avg(src, src_stride, ref, ref_stride, second_pred, 4);
-  return horizontal_add_16x8(abs);
-}
+#define sad8xN(n)                                                      \
+  uint32_t vpx_sad8x##n##_neon(const uint8_t *src, int src_stride,     \
+                               const uint8_t *ref, int ref_stride) {   \
+    const uint16x8_t abs = sad8x(src, src_stride, ref, ref_stride, n); \
+    return horizontal_add_16x8(abs);                                   \
+  }                                                                    \
+                                                                       \
+  uint32_t vpx_sad8x##n##_avg_neon(const uint8_t *src, int src_stride, \
+                                   const uint8_t *ref, int ref_stride, \
+                                   const uint8_t *second_pred) {       \
+    const uint16x8_t abs =                                             \
+        sad8x_avg(src, src_stride, ref, ref_stride, second_pred, n);   \
+    return horizontal_add_16x8(abs);                                   \
+  }
 
-uint32_t vpx_sad8x8_avg_neon(const uint8_t *src, int src_stride,
-                             const uint8_t *ref, int ref_stride,
-                             const uint8_t *second_pred) {
-  const uint16x8_t abs =
-      sad8x_avg(src, src_stride, ref, ref_stride, second_pred, 8);
-  return horizontal_add_16x8(abs);
-}
-
-uint32_t vpx_sad8x16_avg_neon(const uint8_t *src, int src_stride,
-                              const uint8_t *ref, int ref_stride,
-                              const uint8_t *second_pred) {
-  const uint16x8_t abs =
-      sad8x_avg(src, src_stride, ref, ref_stride, second_pred, 16);
-  return horizontal_add_16x8(abs);
-}
+sad8xN(4);
+sad8xN(8);
+sad8xN(16);
 
 static INLINE uint16x8_t sad16x(const uint8_t *a, int a_stride,
                                 const uint8_t *b, int b_stride,