From 63bdc574e52951bcda3e6f19c4d37b25452bcdaf Mon Sep 17 00:00:00 2001 From: Johann Date: Wed, 28 Jun 2017 14:11:35 -0700 Subject: [PATCH] sad neon: avg for 8x[4,8,16] BUG=webm:1425 Change-Id: If2ab51e3050e078b0011b174efe41fcb65a15f44 --- test/sad_test.cc | 3 +++ vpx_dsp/arm/sad_neon.c | 43 ++++++++++++++++++++++++++++++++++++ vpx_dsp/vpx_dsp_rtcd_defs.pl | 6 ++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/test/sad_test.cc b/test/sad_test.cc index da1511639..3df430504 100644 --- a/test/sad_test.cc +++ b/test/sad_test.cc @@ -658,6 +658,9 @@ const SadMxNParam neon_tests[] = { 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), }; diff --git a/vpx_dsp/arm/sad_neon.c b/vpx_dsp/arm/sad_neon.c index c227ddc9d..e7aaf81c5 100644 --- a/vpx_dsp/arm/sad_neon.c +++ b/vpx_dsp/arm/sad_neon.c @@ -114,6 +114,49 @@ uint32_t vpx_sad8x16_neon(const uint8_t *src, int src_stride, 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) { diff --git a/vpx_dsp/vpx_dsp_rtcd_defs.pl b/vpx_dsp/vpx_dsp_rtcd_defs.pl index 0dd496765..d2ebaa975 100644 --- a/vpx_dsp/vpx_dsp_rtcd_defs.pl +++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl @@ -804,13 +804,13 @@ add_proto qw/unsigned int vpx_sad16x8_avg/, "const uint8_t *src_ptr, int src_str 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/; -- 2.50.1