ref: de1a9c77a7e54f6c0dce272850c43251f38b6c6c
parent: b11a37f5403c64099f0cf69024004caf86c207d9
parent: f6fcd3410d7277e67b2a46cbc9f48436011be4db
author: Johann Koenig <[email protected]>
date: Wed May 24 14:33:53 EDT 2017
Merge changes Iaab2b9a1,Idfb458d3 * changes: sub pel avg variance neon: 4x block sizes sub pel variance neon: 4x block sizes
--- a/test/variance_test.cc
+++ b/test/variance_test.cc
@@ -1275,7 +1275,9 @@
make_tuple(4, 3, &vpx_sub_pixel_variance16x8_neon, 0),
make_tuple(3, 4, &vpx_sub_pixel_variance8x16_neon, 0),
make_tuple(3, 3, &vpx_sub_pixel_variance8x8_neon, 0),
- make_tuple(3, 2, &vpx_sub_pixel_variance8x4_neon, 0)));
+ make_tuple(3, 2, &vpx_sub_pixel_variance8x4_neon, 0),
+ make_tuple(2, 3, &vpx_sub_pixel_variance4x8_neon, 0),
+ make_tuple(2, 2, &vpx_sub_pixel_variance4x4_neon, 0)));
INSTANTIATE_TEST_CASE_P(
NEON, VpxSubpelAvgVarianceTest,
@@ -1290,7 +1292,9 @@
make_tuple(4, 3, &vpx_sub_pixel_avg_variance16x8_neon, 0),
make_tuple(3, 4, &vpx_sub_pixel_avg_variance8x16_neon, 0),
make_tuple(3, 3, &vpx_sub_pixel_avg_variance8x8_neon, 0),
- make_tuple(3, 2, &vpx_sub_pixel_avg_variance8x4_neon, 0)));
+ make_tuple(3, 2, &vpx_sub_pixel_avg_variance8x4_neon, 0),
+ make_tuple(2, 3, &vpx_sub_pixel_avg_variance4x8_neon, 0),
+ make_tuple(2, 2, &vpx_sub_pixel_avg_variance4x4_neon, 0)));
#endif // HAVE_NEON
#if HAVE_MSA
--- a/vpx_dsp/arm/mem_neon.h
+++ b/vpx_dsp/arm/mem_neon.h
@@ -79,6 +79,32 @@
memcpy(buf, &a, 4);
}
+// Load 2 sets of 4 bytes when alignment is not guaranteed.
+static INLINE uint8x8_t load_unaligned_u8(const uint8_t *buf, int stride) {
+ uint32_t a;
+ uint32x2_t a_u32 = vdup_n_u32(0);
+ if (stride == 4) return vld1_u8(buf);
+ memcpy(&a, buf, 4);
+ buf += stride;
+ a_u32 = vld1_lane_u32(&a, a_u32, 0);
+ memcpy(&a, buf, 4);
+ a_u32 = vld1_lane_u32(&a, a_u32, 1);
+ return vreinterpret_u8_u32(a_u32);
+}
+
+// Store 2 sets of 4 bytes when alignment is not guaranteed.
+static INLINE void store_unaligned_u8(uint8_t *buf, int stride,
+ const uint8x8_t a) {
+ const uint32x2_t a_u32 = vreinterpret_u32_u8(a);
+ if (stride == 4) {
+ vst1_u8(buf, a);
+ return;
+ }
+ uint32_to_mem(buf, vget_lane_u32(a_u32, 0));
+ buf += stride;
+ uint32_to_mem(buf, vget_lane_u32(a_u32, 1));
+}
+
// Load 4 sets of 4 bytes when alignment is not guaranteed.
static INLINE uint8x16_t load_unaligned_u8q(const uint8_t *buf, int stride) {
uint32_t a;
--- a/vpx_dsp/arm/subpel_variance_neon.c
+++ b/vpx_dsp/arm/subpel_variance_neon.c
@@ -16,6 +16,7 @@
#include "vpx/vpx_integer.h"
#include "vpx_dsp/variance.h"
+#include "vpx_dsp/arm/mem_neon.h"
static const uint8_t bilinear_filters[8][2] = {
{ 128, 0 }, { 112, 16 }, { 96, 32 }, { 80, 48 },
@@ -22,6 +23,30 @@
{ 64, 64 }, { 48, 80 }, { 32, 96 }, { 16, 112 },
};
+// Process a block exactly 4 wide and a multiple of 2 high.
+static void var_filter_block2d_bil_w4(const uint8_t *src_ptr,
+ uint8_t *output_ptr,
+ unsigned int src_pixels_per_line,
+ int pixel_step,
+ unsigned int output_height,
+ const uint8_t *filter) {
+ const uint8x8_t f0 = vmov_n_u8(filter[0]);
+ const uint8x8_t f1 = vmov_n_u8(filter[1]);
+ unsigned int i;
+ for (i = 0; i < output_height; i += 2) {
+ const uint8x8_t src_0 = load_unaligned_u8(src_ptr, src_pixels_per_line);
+ const uint8x8_t src_1 =
+ load_unaligned_u8(src_ptr + pixel_step, src_pixels_per_line);
+ const uint16x8_t a = vmull_u8(src_0, f0);
+ const uint16x8_t b = vmlal_u8(a, src_1, f1);
+ const uint8x8_t out = vrshrn_n_u16(b, FILTER_BITS);
+ store_unaligned_u8(output_ptr, 4, out);
+ // Next row...
+ src_ptr += 2 * src_pixels_per_line;
+ output_ptr += 8;
+ }
+}
+
// Process a block exactly 8 wide and any height.
static void var_filter_block2d_bil_w8(const uint8_t *src_ptr,
uint8_t *output_ptr,
@@ -74,28 +99,36 @@
}
}
-// TODO(johannkoenig): support 4xM block sizes.
-#define sub_pixel_varianceNxM(n, m) \
- uint32_t vpx_sub_pixel_variance##n##x##m##_neon( \
- const uint8_t *a, int a_stride, int xoffset, int yoffset, \
- const uint8_t *b, int b_stride, uint32_t *sse) { \
- DECLARE_ALIGNED(16, uint8_t, fdata3[n * (m + 1)]); \
- DECLARE_ALIGNED(16, uint8_t, temp2[n * m]); \
- \
- if (n == 8) { \
- var_filter_block2d_bil_w8(a, fdata3, a_stride, 1, (m + 1), \
- bilinear_filters[xoffset]); \
- var_filter_block2d_bil_w8(fdata3, temp2, n, n, m, \
- bilinear_filters[yoffset]); \
- } else { \
- var_filter_block2d_bil_w16(a, fdata3, a_stride, 1, (m + 1), n, \
- bilinear_filters[xoffset]); \
- var_filter_block2d_bil_w16(fdata3, temp2, n, n, m, n, \
- bilinear_filters[yoffset]); \
- } \
- return vpx_variance##n##x##m(temp2, n, b, b_stride, sse); \
+// 4xM filter writes an extra row to fdata because it processes two rows at a
+// time.
+#define sub_pixel_varianceNxM(n, m) \
+ uint32_t vpx_sub_pixel_variance##n##x##m##_neon( \
+ const uint8_t *a, int a_stride, int xoffset, int yoffset, \
+ const uint8_t *b, int b_stride, uint32_t *sse) { \
+ DECLARE_ALIGNED(16, uint8_t, fdata3[n * (m + (n == 4 ? 2 : 1))]); \
+ DECLARE_ALIGNED(16, uint8_t, temp2[n * m]); \
+ \
+ if (n == 4) { \
+ var_filter_block2d_bil_w4(a, fdata3, a_stride, 1, (m + 2), \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w4(fdata3, temp2, n, n, m, \
+ bilinear_filters[yoffset]); \
+ } else if (n == 8) { \
+ var_filter_block2d_bil_w8(a, fdata3, a_stride, 1, (m + 1), \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w8(fdata3, temp2, n, n, m, \
+ bilinear_filters[yoffset]); \
+ } else { \
+ var_filter_block2d_bil_w16(a, fdata3, a_stride, 1, (m + 1), n, \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w16(fdata3, temp2, n, n, m, n, \
+ bilinear_filters[yoffset]); \
+ } \
+ return vpx_variance##n##x##m(temp2, n, b, b_stride, sse); \
}
+sub_pixel_varianceNxM(4, 4);
+sub_pixel_varianceNxM(4, 8);
sub_pixel_varianceNxM(8, 4);
sub_pixel_varianceNxM(8, 8);
sub_pixel_varianceNxM(8, 16);
@@ -108,33 +141,41 @@
sub_pixel_varianceNxM(64, 32);
sub_pixel_varianceNxM(64, 64);
-// TODO(johannkoenig): support 4xM block sizes.
-#define sub_pixel_avg_varianceNxM(n, m) \
- uint32_t vpx_sub_pixel_avg_variance##n##x##m##_neon( \
- const uint8_t *a, int a_stride, int xoffset, int yoffset, \
- const uint8_t *b, int b_stride, uint32_t *sse, \
- const uint8_t *second_pred) { \
- DECLARE_ALIGNED(16, uint8_t, fdata3[n * (m + 1)]); \
- DECLARE_ALIGNED(16, uint8_t, temp2[n * m]); \
- DECLARE_ALIGNED(16, uint8_t, temp3[n * m]); \
- \
- if (n == 8) { \
- var_filter_block2d_bil_w8(a, fdata3, a_stride, 1, (m + 1), \
- bilinear_filters[xoffset]); \
- var_filter_block2d_bil_w8(fdata3, temp2, n, n, m, \
- bilinear_filters[yoffset]); \
- } else { \
- var_filter_block2d_bil_w16(a, fdata3, a_stride, 1, (m + 1), n, \
- bilinear_filters[xoffset]); \
- var_filter_block2d_bil_w16(fdata3, temp2, n, n, m, n, \
- bilinear_filters[yoffset]); \
- } \
- \
- vpx_comp_avg_pred(temp3, second_pred, n, m, temp2, n); \
- \
- return vpx_variance##n##x##m(temp3, n, b, b_stride, sse); \
+// 4xM filter writes an extra row to fdata because it processes two rows at a
+// time.
+#define sub_pixel_avg_varianceNxM(n, m) \
+ uint32_t vpx_sub_pixel_avg_variance##n##x##m##_neon( \
+ const uint8_t *a, int a_stride, int xoffset, int yoffset, \
+ const uint8_t *b, int b_stride, uint32_t *sse, \
+ const uint8_t *second_pred) { \
+ DECLARE_ALIGNED(16, uint8_t, fdata3[n * (m + (n == 4 ? 2 : 1))]); \
+ DECLARE_ALIGNED(16, uint8_t, temp2[n * m]); \
+ DECLARE_ALIGNED(16, uint8_t, temp3[n * m]); \
+ \
+ if (n == 4) { \
+ var_filter_block2d_bil_w4(a, fdata3, a_stride, 1, (m + 2), \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w4(fdata3, temp2, n, n, m, \
+ bilinear_filters[yoffset]); \
+ } else if (n == 8) { \
+ var_filter_block2d_bil_w8(a, fdata3, a_stride, 1, (m + 1), \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w8(fdata3, temp2, n, n, m, \
+ bilinear_filters[yoffset]); \
+ } else { \
+ var_filter_block2d_bil_w16(a, fdata3, a_stride, 1, (m + 1), n, \
+ bilinear_filters[xoffset]); \
+ var_filter_block2d_bil_w16(fdata3, temp2, n, n, m, n, \
+ bilinear_filters[yoffset]); \
+ } \
+ \
+ vpx_comp_avg_pred(temp3, second_pred, n, m, temp2, n); \
+ \
+ return vpx_variance##n##x##m(temp3, n, b, b_stride, sse); \
}
+sub_pixel_avg_varianceNxM(4, 4);
+sub_pixel_avg_varianceNxM(4, 8);
sub_pixel_avg_varianceNxM(8, 4);
sub_pixel_avg_varianceNxM(8, 8);
sub_pixel_avg_varianceNxM(8, 16);
--- a/vpx_dsp/vpx_dsp_rtcd_defs.pl
+++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl
@@ -1214,10 +1214,10 @@
specialize qw/vpx_sub_pixel_variance8x4 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
- specialize qw/vpx_sub_pixel_variance4x8 msa sse2 ssse3/;
+ specialize qw/vpx_sub_pixel_variance4x8 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse";
- specialize qw/vpx_sub_pixel_variance4x4 msa sse2 ssse3/;
+ specialize qw/vpx_sub_pixel_variance4x4 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance64x64/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
specialize qw/vpx_sub_pixel_avg_variance64x64 neon avx2 msa sse2 ssse3/;
@@ -1253,10 +1253,10 @@
specialize qw/vpx_sub_pixel_avg_variance8x4 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance4x8/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
- specialize qw/vpx_sub_pixel_avg_variance4x8 msa sse2 ssse3/;
+ specialize qw/vpx_sub_pixel_avg_variance4x8 neon msa sse2 ssse3/;
add_proto qw/uint32_t vpx_sub_pixel_avg_variance4x4/, "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, uint32_t *sse, const uint8_t *second_pred";
- specialize qw/vpx_sub_pixel_avg_variance4x4 msa sse2 ssse3/;
+ specialize qw/vpx_sub_pixel_avg_variance4x4 neon msa sse2 ssse3/;
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
add_proto qw/unsigned int vpx_highbd_12_variance64x64/, "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse";