From 111068923b4ca778a680330d00161d7ee93f61e1 Mon Sep 17 00:00:00 2001 From: Salome Thirot Date: Thu, 23 Feb 2023 12:05:30 +0000 Subject: [PATCH] Add Neon implementation of high bitdepth 32x32 hadamard transform Add Neon implementation of vpx_highbd_hadamard_32x32 as well as the corresponding tests. Change-Id: I65d8603896649de1996b353aa79eee54824b4708 --- test/hadamard_test.cc | 5 +++-- vpx_dsp/arm/highbd_hadamard_neon.c | 39 ++++++++++++++++++++++++++++++++++++++ vpx_dsp/vpx_dsp_rtcd_defs.pl | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/test/hadamard_test.cc b/test/hadamard_test.cc index 2482e87..9f6c99f 100644 --- a/test/hadamard_test.cc +++ b/test/hadamard_test.cc @@ -328,8 +328,9 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( NEON, HadamardHighbdTest, ::testing::Values(HadamardFuncWithSize(&vpx_highbd_hadamard_8x8_neon, 8), - HadamardFuncWithSize(&vpx_highbd_hadamard_16x16_neon, - 16))); + HadamardFuncWithSize(&vpx_highbd_hadamard_16x16_neon, 16), + HadamardFuncWithSize(&vpx_highbd_hadamard_32x32_neon, + 32))); #endif #endif // CONFIG_VP9_HIGHBITDEPTH diff --git a/vpx_dsp/arm/highbd_hadamard_neon.c b/vpx_dsp/arm/highbd_hadamard_neon.c index 013f714..499eb65 100644 --- a/vpx_dsp/arm/highbd_hadamard_neon.c +++ b/vpx_dsp/arm/highbd_hadamard_neon.c @@ -174,3 +174,42 @@ void vpx_highbd_hadamard_16x16_neon(const int16_t *src_diff, store_s32q_to_tran_low(coeff + 4 * i + 192, c3); } while (++i < 16); } + +void vpx_highbd_hadamard_32x32_neon(const int16_t *src_diff, + ptrdiff_t src_stride, tran_low_t *coeff) { + int i = 0; + + // Rearrange 32x32 to 16x64 and remove stride. + // Top left first. + vpx_highbd_hadamard_16x16_neon(src_diff, src_stride, coeff); + // Top right. + vpx_highbd_hadamard_16x16_neon(src_diff + 16, src_stride, coeff + 256); + // Bottom left. + vpx_highbd_hadamard_16x16_neon(src_diff + 16 * src_stride, src_stride, + coeff + 512); + // Bottom right. + vpx_highbd_hadamard_16x16_neon(src_diff + 16 * src_stride + 16, src_stride, + coeff + 768); + + do { + int32x4_t a0 = load_tran_low_to_s32q(coeff + 4 * i); + int32x4_t a1 = load_tran_low_to_s32q(coeff + 4 * i + 256); + int32x4_t a2 = load_tran_low_to_s32q(coeff + 4 * i + 512); + int32x4_t a3 = load_tran_low_to_s32q(coeff + 4 * i + 768); + + int32x4_t b0 = vhaddq_s32(a0, a1); + int32x4_t b1 = vhsubq_s32(a0, a1); + int32x4_t b2 = vhaddq_s32(a2, a3); + int32x4_t b3 = vhsubq_s32(a2, a3); + + int32x4_t c0 = vhaddq_s32(b0, b2); + int32x4_t c1 = vhaddq_s32(b1, b3); + int32x4_t c2 = vhsubq_s32(b0, b2); + int32x4_t c3 = vhsubq_s32(b1, b3); + + store_s32q_to_tran_low(coeff + 4 * i, c0); + store_s32q_to_tran_low(coeff + 4 * i + 256, c1); + store_s32q_to_tran_low(coeff + 4 * i + 512, c2); + store_s32q_to_tran_low(coeff + 4 * i + 768, c3); + } while (++i < 64); +} diff --git a/vpx_dsp/vpx_dsp_rtcd_defs.pl b/vpx_dsp/vpx_dsp_rtcd_defs.pl index 276d55b..eef7224 100644 --- a/vpx_dsp/vpx_dsp_rtcd_defs.pl +++ b/vpx_dsp/vpx_dsp_rtcd_defs.pl @@ -808,7 +808,7 @@ if (vpx_config("CONFIG_VP9_ENCODER") eq "yes") { specialize qw/vpx_highbd_hadamard_16x16 avx2 neon/; add_proto qw/void vpx_highbd_hadamard_32x32/, "const int16_t *src_diff, ptrdiff_t src_stride, tran_low_t *coeff"; - specialize qw/vpx_highbd_hadamard_32x32 avx2/; + specialize qw/vpx_highbd_hadamard_32x32 avx2 neon/; add_proto qw/int vpx_satd/, "const tran_low_t *coeff, int length"; specialize qw/vpx_satd avx2 sse2 neon/; -- 2.7.4