1 /*
2 * Copyright (c) 2023, Alliance for Open Media. All rights reserved.
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #ifndef AOM_AV1_COMMON_ARM_HIGHBD_CONVOLVE_SVE2_H_
13 #define AOM_AV1_COMMON_ARM_HIGHBD_CONVOLVE_SVE2_H_
14
15 #include <arm_neon.h>
16
17 #include "aom_dsp/arm/aom_neon_sve2_bridge.h"
18
19 // clang-format off
20 DECLARE_ALIGNED(16, static const uint16_t, kDotProdMergeBlockTbl[24]) = {
21 // Shift left and insert new last column in transposed 4x4 block.
22 1, 2, 3, 0, 5, 6, 7, 4,
23 // Shift left and insert two new columns in transposed 4x4 block.
24 2, 3, 0, 1, 6, 7, 4, 5,
25 // Shift left and insert three new columns in transposed 4x4 block.
26 3, 0, 1, 2, 7, 4, 5, 6,
27 };
28 // clang-format on
29
transpose_concat_4x4(int16x4_t s0,int16x4_t s1,int16x4_t s2,int16x4_t s3,int16x8_t res[2])30 static inline void transpose_concat_4x4(int16x4_t s0, int16x4_t s1,
31 int16x4_t s2, int16x4_t s3,
32 int16x8_t res[2]) {
33 // Transpose 16-bit elements and concatenate result rows as follows:
34 // s0: 00, 01, 02, 03
35 // s1: 10, 11, 12, 13
36 // s2: 20, 21, 22, 23
37 // s3: 30, 31, 32, 33
38 //
39 // res[0]: 00 10 20 30 01 11 21 31
40 // res[1]: 02 12 22 32 03 13 23 33
41
42 int16x8_t s0q = vcombine_s16(s0, vdup_n_s16(0));
43 int16x8_t s1q = vcombine_s16(s1, vdup_n_s16(0));
44 int16x8_t s2q = vcombine_s16(s2, vdup_n_s16(0));
45 int16x8_t s3q = vcombine_s16(s3, vdup_n_s16(0));
46
47 int32x4_t s01 = vreinterpretq_s32_s16(vzip1q_s16(s0q, s1q));
48 int32x4_t s23 = vreinterpretq_s32_s16(vzip1q_s16(s2q, s3q));
49
50 int32x4x2_t s0123 = vzipq_s32(s01, s23);
51
52 res[0] = vreinterpretq_s16_s32(s0123.val[0]);
53 res[1] = vreinterpretq_s16_s32(s0123.val[1]);
54 }
55
transpose_concat_8x4(int16x8_t s0,int16x8_t s1,int16x8_t s2,int16x8_t s3,int16x8_t res[4])56 static inline void transpose_concat_8x4(int16x8_t s0, int16x8_t s1,
57 int16x8_t s2, int16x8_t s3,
58 int16x8_t res[4]) {
59 // Transpose 16-bit elements and concatenate result rows as follows:
60 // s0: 00, 01, 02, 03, 04, 05, 06, 07
61 // s1: 10, 11, 12, 13, 14, 15, 16, 17
62 // s2: 20, 21, 22, 23, 24, 25, 26, 27
63 // s3: 30, 31, 32, 33, 34, 35, 36, 37
64 //
65 // res[0]: 00 10 20 30 01 11 21 31
66 // res[1]: 02 12 22 32 03 13 23 33
67 // res[2]: 04 14 24 34 05 15 25 35
68 // res[3]: 06 16 26 36 07 17 27 37
69
70 int16x8x2_t tr01_16 = vzipq_s16(s0, s1);
71 int16x8x2_t tr23_16 = vzipq_s16(s2, s3);
72 int32x4x2_t tr01_32 = vzipq_s32(vreinterpretq_s32_s16(tr01_16.val[0]),
73 vreinterpretq_s32_s16(tr23_16.val[0]));
74 int32x4x2_t tr23_32 = vzipq_s32(vreinterpretq_s32_s16(tr01_16.val[1]),
75 vreinterpretq_s32_s16(tr23_16.val[1]));
76
77 res[0] = vreinterpretq_s16_s32(tr01_32.val[0]);
78 res[1] = vreinterpretq_s16_s32(tr01_32.val[1]);
79 res[2] = vreinterpretq_s16_s32(tr23_32.val[0]);
80 res[3] = vreinterpretq_s16_s32(tr23_32.val[1]);
81 }
82
aom_tbl2x4_s16(int16x8_t t0[4],int16x8_t t1[4],uint16x8_t tbl,int16x8_t res[4])83 static inline void aom_tbl2x4_s16(int16x8_t t0[4], int16x8_t t1[4],
84 uint16x8_t tbl, int16x8_t res[4]) {
85 res[0] = aom_tbl2_s16(t0[0], t1[0], tbl);
86 res[1] = aom_tbl2_s16(t0[1], t1[1], tbl);
87 res[2] = aom_tbl2_s16(t0[2], t1[2], tbl);
88 res[3] = aom_tbl2_s16(t0[3], t1[3], tbl);
89 }
90
aom_tbl2x2_s16(int16x8_t t0[2],int16x8_t t1[2],uint16x8_t tbl,int16x8_t res[2])91 static inline void aom_tbl2x2_s16(int16x8_t t0[2], int16x8_t t1[2],
92 uint16x8_t tbl, int16x8_t res[2]) {
93 res[0] = aom_tbl2_s16(t0[0], t1[0], tbl);
94 res[1] = aom_tbl2_s16(t0[1], t1[1], tbl);
95 }
96
97 #endif // AOM_AV1_COMMON_ARM_HIGHBD_CONVOLVE_SVE2_H_
98