diff options
author | Johann <johannkoenig@google.com> | 2017-05-02 07:31:05 -0700 |
---|---|---|
committer | Johann <johannkoenig@google.com> | 2017-05-17 17:35:01 -0700 |
commit | 7b742da63e4b829ba013670dd838d263f5df8956 (patch) | |
tree | 223562c9789d8fbcbc3b71fba016da4b99eeacc1 /vpx_dsp/arm/variance_neon.c | |
parent | 2057d3ef757a18e6bb005812a9912748ae4c7610 (diff) | |
download | libvpx-7b742da63e4b829ba013670dd838d263f5df8956.tar libvpx-7b742da63e4b829ba013670dd838d263f5df8956.tar.gz libvpx-7b742da63e4b829ba013670dd838d263f5df8956.tar.bz2 libvpx-7b742da63e4b829ba013670dd838d263f5df8956.zip |
neon variance: process 4x blocks
Continue processing sets of 16 values. Plenty of improvement for 4x8
(doubles the speed) but only about 30% for 4x4.
BUG=webm:1422
Change-Id: Ib8dd96f75d474f0348800271d11e58356b620905
Diffstat (limited to 'vpx_dsp/arm/variance_neon.c')
-rw-r--r-- | vpx_dsp/arm/variance_neon.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/vpx_dsp/arm/variance_neon.c b/vpx_dsp/arm/variance_neon.c index c0828e8f6..aac960b3a 100644 --- a/vpx_dsp/arm/variance_neon.c +++ b/vpx_dsp/arm/variance_neon.c @@ -14,6 +14,7 @@ #include "./vpx_config.h" #include "vpx/vpx_integer.h" +#include "vpx_dsp/arm/mem_neon.h" #include "vpx_ports/mem.h" static INLINE int horizontal_add_s16x8(const int16x8_t v_16x8) { @@ -32,6 +33,47 @@ static INLINE int horizontal_add_s32x4(const int32x4_t v_32x4) { } // w * h must be less than 2048 or sum_s16 may overflow. +// Process a block of width 4 four rows at a time. +static void variance_neon_w4x4(const uint8_t *a, int a_stride, const uint8_t *b, + int b_stride, int h, uint32_t *sse, int *sum) { + int i; + int16x8_t sum_s16 = vdupq_n_s16(0); + int32x4_t sse_lo_s32 = vdupq_n_s32(0); + int32x4_t sse_hi_s32 = vdupq_n_s32(0); + + for (i = 0; i < h; i += 4) { + const uint8x16_t a_u8 = load_unaligned_u8q(a, a_stride); + const uint8x16_t b_u8 = load_unaligned_u8q(b, b_stride); + const uint16x8_t diff_lo_u16 = + vsubl_u8(vget_low_u8(a_u8), vget_low_u8(b_u8)); + const uint16x8_t diff_hi_u16 = + vsubl_u8(vget_high_u8(a_u8), vget_high_u8(b_u8)); + + const int16x8_t diff_lo_s16 = vreinterpretq_s16_u16(diff_lo_u16); + const int16x8_t diff_hi_s16 = vreinterpretq_s16_u16(diff_hi_u16); + + sum_s16 = vaddq_s16(sum_s16, diff_lo_s16); + sum_s16 = vaddq_s16(sum_s16, diff_hi_s16); + + sse_lo_s32 = vmlal_s16(sse_lo_s32, vget_low_s16(diff_lo_s16), + vget_low_s16(diff_lo_s16)); + sse_lo_s32 = vmlal_s16(sse_lo_s32, vget_high_s16(diff_lo_s16), + vget_high_s16(diff_lo_s16)); + + sse_hi_s32 = vmlal_s16(sse_hi_s32, vget_low_s16(diff_hi_s16), + vget_low_s16(diff_hi_s16)); + sse_hi_s32 = vmlal_s16(sse_hi_s32, vget_high_s16(diff_hi_s16), + vget_high_s16(diff_hi_s16)); + + a += 4 * a_stride; + b += 4 * b_stride; + } + + *sum = horizontal_add_s16x8(sum_s16); + *sse = (uint32_t)horizontal_add_s32x4(vaddq_s32(sse_lo_s32, sse_hi_s32)); +} + +// w * h must be less than 2048 or sum_s16 may overflow. // Process a block of any size where the width is divisible by 16. static void variance_neon_w16(const uint8_t *a, int a_stride, const uint8_t *b, int b_stride, int w, int h, uint32_t *sse, @@ -127,7 +169,9 @@ void vpx_get16x16var_neon(const uint8_t *a, int a_stride, const uint8_t *b, const uint8_t *b, int b_stride, \ unsigned int *sse) { \ int sum; \ - if (n == 8) \ + if (n == 4) \ + variance_neon_w4x4(a, a_stride, b, b_stride, m, sse, &sum); \ + else if (n == 8) \ variance_neon_w8x2(a, a_stride, b, b_stride, m, sse, &sum); \ else \ variance_neon_w16(a, a_stride, b, b_stride, n, m, sse, &sum); \ @@ -137,6 +181,8 @@ void vpx_get16x16var_neon(const uint8_t *a, int a_stride, const uint8_t *b, return *sse - (uint32_t)(((int64_t)sum * sum) >> shift); \ } +varianceNxM(4, 4, 4); +varianceNxM(4, 8, 5); varianceNxM(8, 4, 5); varianceNxM(8, 8, 6); varianceNxM(8, 16, 7); |