shithub: libvpx

Download patch

ref: 63bdc574e52951bcda3e6f19c4d37b25452bcdaf
parent: 6bac3f80ee21b754e17d0f32ddc18d1bbe9dfc6a
author: Johann <johannkoenig@google.com>
date: Wed Jun 28 10:11:35 EDT 2017

sad neon: avg for 8x[4,8,16]

BUG=webm:1425

Change-Id: If2ab51e3050e078b0011b174efe41fcb65a15f44

--- a/test/sad_test.cc
+++ b/test/sad_test.cc
@@ -658,6 +658,9 @@
 INSTANTIATE_TEST_CASE_P(NEON, SADTest, ::testing::ValuesIn(neon_tests));
 
 const SadMxNAvgParam avg_neon_tests[] = {
+  SadMxNAvgParam(8, 16, &vpx_sad8x16_avg_neon),
+  SadMxNAvgParam(8, 8, &vpx_sad8x8_avg_neon),
+  SadMxNAvgParam(8, 4, &vpx_sad8x4_avg_neon),
   SadMxNAvgParam(4, 8, &vpx_sad4x8_avg_neon),
   SadMxNAvgParam(4, 4, &vpx_sad4x4_avg_neon),
 };
--- a/vpx_dsp/arm/sad_neon.c
+++ b/vpx_dsp/arm/sad_neon.c
@@ -114,6 +114,49 @@
   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) {
+  int i;
+  uint16x8_t abs = vdupq_n_u16(0);
+
+  for (i = 0; i < height; ++i) {
+    const uint8x8_t a_u8 = vld1_u8(a);
+    const uint8x8_t b_u8 = vld1_u8(b);
+    const uint8x8_t c_u8 = vld1_u8(c);
+    const uint8x8_t avg = vrhadd_u8(b_u8, c_u8);
+    a += a_stride;
+    b += b_stride;
+    c += 8;
+    abs = vabal_u8(abs, a_u8, avg);
+  }
+  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);
+}
+
+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);
+}
+
 static INLINE uint16x8_t sad16x(const uint8_t *a, int a_stride,
                                 const uint8_t *b, int b_stride,
                                 const int height) {
--- a/vpx_dsp/vpx_dsp_rtcd_defs.pl
+++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl
@@ -804,13 +804,13 @@
 specialize qw/vpx_sad16x8_avg msa sse2 vsx/;
 
 add_proto qw/unsigned int vpx_sad8x16_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
-specialize qw/vpx_sad8x16_avg msa sse2/;
+specialize qw/vpx_sad8x16_avg neon msa sse2/;
 
 add_proto qw/unsigned int vpx_sad8x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
-specialize qw/vpx_sad8x8_avg msa sse2/;
+specialize qw/vpx_sad8x8_avg neon msa sse2/;
 
 add_proto qw/unsigned int vpx_sad8x4_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
-specialize qw/vpx_sad8x4_avg msa sse2/;
+specialize qw/vpx_sad8x4_avg neon msa sse2/;
 
 add_proto qw/unsigned int vpx_sad4x8_avg/, "const uint8_t *src_ptr, int src_stride, const uint8_t *ref_ptr, int ref_stride, const uint8_t *second_pred";
 specialize qw/vpx_sad4x8_avg neon msa sse2/;