1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2019, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <arm_neon.h>
13*77c1e3ccSAndroid Build Coastguard Worker
14*77c1e3ccSAndroid Build Coastguard Worker #include "config/aom_dsp_rtcd.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/arm/mem_neon.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/arm/transpose_neon.h"
18*77c1e3ccSAndroid Build Coastguard Worker
hadamard_4x4_one_pass(int16x4_t * a0,int16x4_t * a1,int16x4_t * a2,int16x4_t * a3)19*77c1e3ccSAndroid Build Coastguard Worker static inline void hadamard_4x4_one_pass(int16x4_t *a0, int16x4_t *a1,
20*77c1e3ccSAndroid Build Coastguard Worker int16x4_t *a2, int16x4_t *a3) {
21*77c1e3ccSAndroid Build Coastguard Worker const int16x4_t b0 = vhadd_s16(*a0, *a1);
22*77c1e3ccSAndroid Build Coastguard Worker const int16x4_t b1 = vhsub_s16(*a0, *a1);
23*77c1e3ccSAndroid Build Coastguard Worker const int16x4_t b2 = vhadd_s16(*a2, *a3);
24*77c1e3ccSAndroid Build Coastguard Worker const int16x4_t b3 = vhsub_s16(*a2, *a3);
25*77c1e3ccSAndroid Build Coastguard Worker
26*77c1e3ccSAndroid Build Coastguard Worker *a0 = vadd_s16(b0, b2);
27*77c1e3ccSAndroid Build Coastguard Worker *a1 = vadd_s16(b1, b3);
28*77c1e3ccSAndroid Build Coastguard Worker *a2 = vsub_s16(b0, b2);
29*77c1e3ccSAndroid Build Coastguard Worker *a3 = vsub_s16(b1, b3);
30*77c1e3ccSAndroid Build Coastguard Worker }
31*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_4x4_neon(const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)32*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_4x4_neon(const int16_t *src_diff, ptrdiff_t src_stride,
33*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *coeff) {
34*77c1e3ccSAndroid Build Coastguard Worker int16x4_t a0 = vld1_s16(src_diff);
35*77c1e3ccSAndroid Build Coastguard Worker int16x4_t a1 = vld1_s16(src_diff + src_stride);
36*77c1e3ccSAndroid Build Coastguard Worker int16x4_t a2 = vld1_s16(src_diff + 2 * src_stride);
37*77c1e3ccSAndroid Build Coastguard Worker int16x4_t a3 = vld1_s16(src_diff + 3 * src_stride);
38*77c1e3ccSAndroid Build Coastguard Worker
39*77c1e3ccSAndroid Build Coastguard Worker hadamard_4x4_one_pass(&a0, &a1, &a2, &a3);
40*77c1e3ccSAndroid Build Coastguard Worker
41*77c1e3ccSAndroid Build Coastguard Worker transpose_elems_inplace_s16_4x4(&a0, &a1, &a2, &a3);
42*77c1e3ccSAndroid Build Coastguard Worker
43*77c1e3ccSAndroid Build Coastguard Worker hadamard_4x4_one_pass(&a0, &a1, &a2, &a3);
44*77c1e3ccSAndroid Build Coastguard Worker
45*77c1e3ccSAndroid Build Coastguard Worker store_s16_to_tran_low(coeff, a0);
46*77c1e3ccSAndroid Build Coastguard Worker store_s16_to_tran_low(coeff + 4, a1);
47*77c1e3ccSAndroid Build Coastguard Worker store_s16_to_tran_low(coeff + 8, a2);
48*77c1e3ccSAndroid Build Coastguard Worker store_s16_to_tran_low(coeff + 12, a3);
49*77c1e3ccSAndroid Build Coastguard Worker }
50*77c1e3ccSAndroid Build Coastguard Worker
hadamard8x8_one_pass(int16x8_t * a0,int16x8_t * a1,int16x8_t * a2,int16x8_t * a3,int16x8_t * a4,int16x8_t * a5,int16x8_t * a6,int16x8_t * a7)51*77c1e3ccSAndroid Build Coastguard Worker static void hadamard8x8_one_pass(int16x8_t *a0, int16x8_t *a1, int16x8_t *a2,
52*77c1e3ccSAndroid Build Coastguard Worker int16x8_t *a3, int16x8_t *a4, int16x8_t *a5,
53*77c1e3ccSAndroid Build Coastguard Worker int16x8_t *a6, int16x8_t *a7) {
54*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b0 = vaddq_s16(*a0, *a1);
55*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b1 = vsubq_s16(*a0, *a1);
56*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b2 = vaddq_s16(*a2, *a3);
57*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b3 = vsubq_s16(*a2, *a3);
58*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b4 = vaddq_s16(*a4, *a5);
59*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b5 = vsubq_s16(*a4, *a5);
60*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b6 = vaddq_s16(*a6, *a7);
61*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b7 = vsubq_s16(*a6, *a7);
62*77c1e3ccSAndroid Build Coastguard Worker
63*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c0 = vaddq_s16(b0, b2);
64*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c1 = vaddq_s16(b1, b3);
65*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c2 = vsubq_s16(b0, b2);
66*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c3 = vsubq_s16(b1, b3);
67*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c4 = vaddq_s16(b4, b6);
68*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c5 = vaddq_s16(b5, b7);
69*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c6 = vsubq_s16(b4, b6);
70*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c7 = vsubq_s16(b5, b7);
71*77c1e3ccSAndroid Build Coastguard Worker
72*77c1e3ccSAndroid Build Coastguard Worker *a0 = vaddq_s16(c0, c4);
73*77c1e3ccSAndroid Build Coastguard Worker *a1 = vsubq_s16(c2, c6);
74*77c1e3ccSAndroid Build Coastguard Worker *a2 = vsubq_s16(c0, c4);
75*77c1e3ccSAndroid Build Coastguard Worker *a3 = vaddq_s16(c2, c6);
76*77c1e3ccSAndroid Build Coastguard Worker *a4 = vaddq_s16(c3, c7);
77*77c1e3ccSAndroid Build Coastguard Worker *a5 = vsubq_s16(c3, c7);
78*77c1e3ccSAndroid Build Coastguard Worker *a6 = vsubq_s16(c1, c5);
79*77c1e3ccSAndroid Build Coastguard Worker *a7 = vaddq_s16(c1, c5);
80*77c1e3ccSAndroid Build Coastguard Worker }
81*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_8x8_neon(const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)82*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_8x8_neon(const int16_t *src_diff, ptrdiff_t src_stride,
83*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *coeff) {
84*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a0 = vld1q_s16(src_diff);
85*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a1 = vld1q_s16(src_diff + src_stride);
86*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a2 = vld1q_s16(src_diff + 2 * src_stride);
87*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a3 = vld1q_s16(src_diff + 3 * src_stride);
88*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a4 = vld1q_s16(src_diff + 4 * src_stride);
89*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a5 = vld1q_s16(src_diff + 5 * src_stride);
90*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a6 = vld1q_s16(src_diff + 6 * src_stride);
91*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a7 = vld1q_s16(src_diff + 7 * src_stride);
92*77c1e3ccSAndroid Build Coastguard Worker
93*77c1e3ccSAndroid Build Coastguard Worker hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
94*77c1e3ccSAndroid Build Coastguard Worker
95*77c1e3ccSAndroid Build Coastguard Worker transpose_elems_inplace_s16_8x8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
96*77c1e3ccSAndroid Build Coastguard Worker
97*77c1e3ccSAndroid Build Coastguard Worker hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
98*77c1e3ccSAndroid Build Coastguard Worker
99*77c1e3ccSAndroid Build Coastguard Worker // Skip the second transpose because it is not required.
100*77c1e3ccSAndroid Build Coastguard Worker
101*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 0, a0);
102*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 8, a1);
103*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 16, a2);
104*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 24, a3);
105*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 32, a4);
106*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 40, a5);
107*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 48, a6);
108*77c1e3ccSAndroid Build Coastguard Worker store_s16q_to_tran_low(coeff + 56, a7);
109*77c1e3ccSAndroid Build Coastguard Worker }
110*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_lp_8x8_neon(const int16_t * src_diff,ptrdiff_t src_stride,int16_t * coeff)111*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_lp_8x8_neon(const int16_t *src_diff, ptrdiff_t src_stride,
112*77c1e3ccSAndroid Build Coastguard Worker int16_t *coeff) {
113*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a0 = vld1q_s16(src_diff);
114*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a1 = vld1q_s16(src_diff + src_stride);
115*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a2 = vld1q_s16(src_diff + 2 * src_stride);
116*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a3 = vld1q_s16(src_diff + 3 * src_stride);
117*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a4 = vld1q_s16(src_diff + 4 * src_stride);
118*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a5 = vld1q_s16(src_diff + 5 * src_stride);
119*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a6 = vld1q_s16(src_diff + 6 * src_stride);
120*77c1e3ccSAndroid Build Coastguard Worker int16x8_t a7 = vld1q_s16(src_diff + 7 * src_stride);
121*77c1e3ccSAndroid Build Coastguard Worker
122*77c1e3ccSAndroid Build Coastguard Worker hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
123*77c1e3ccSAndroid Build Coastguard Worker
124*77c1e3ccSAndroid Build Coastguard Worker transpose_elems_inplace_s16_8x8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
125*77c1e3ccSAndroid Build Coastguard Worker
126*77c1e3ccSAndroid Build Coastguard Worker hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
127*77c1e3ccSAndroid Build Coastguard Worker
128*77c1e3ccSAndroid Build Coastguard Worker // Skip the second transpose because it is not required.
129*77c1e3ccSAndroid Build Coastguard Worker
130*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 0, a0);
131*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 8, a1);
132*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 16, a2);
133*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 24, a3);
134*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 32, a4);
135*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 40, a5);
136*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 48, a6);
137*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 56, a7);
138*77c1e3ccSAndroid Build Coastguard Worker }
139*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_lp_8x8_dual_neon(const int16_t * src_diff,ptrdiff_t src_stride,int16_t * coeff)140*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_lp_8x8_dual_neon(const int16_t *src_diff,
141*77c1e3ccSAndroid Build Coastguard Worker ptrdiff_t src_stride, int16_t *coeff) {
142*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < 2; i++) {
143*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_lp_8x8_neon(src_diff + (i * 8), src_stride, coeff + (i * 64));
144*77c1e3ccSAndroid Build Coastguard Worker }
145*77c1e3ccSAndroid Build Coastguard Worker }
146*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_lp_16x16_neon(const int16_t * src_diff,ptrdiff_t src_stride,int16_t * coeff)147*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_lp_16x16_neon(const int16_t *src_diff, ptrdiff_t src_stride,
148*77c1e3ccSAndroid Build Coastguard Worker int16_t *coeff) {
149*77c1e3ccSAndroid Build Coastguard Worker /* Rearrange 16x16 to 8x32 and remove stride.
150*77c1e3ccSAndroid Build Coastguard Worker * Top left first. */
151*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_lp_8x8_neon(src_diff + 0 + 0 * src_stride, src_stride,
152*77c1e3ccSAndroid Build Coastguard Worker coeff + 0);
153*77c1e3ccSAndroid Build Coastguard Worker /* Top right. */
154*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_lp_8x8_neon(src_diff + 8 + 0 * src_stride, src_stride,
155*77c1e3ccSAndroid Build Coastguard Worker coeff + 64);
156*77c1e3ccSAndroid Build Coastguard Worker /* Bottom left. */
157*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_lp_8x8_neon(src_diff + 0 + 8 * src_stride, src_stride,
158*77c1e3ccSAndroid Build Coastguard Worker coeff + 128);
159*77c1e3ccSAndroid Build Coastguard Worker /* Bottom right. */
160*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_lp_8x8_neon(src_diff + 8 + 8 * src_stride, src_stride,
161*77c1e3ccSAndroid Build Coastguard Worker coeff + 192);
162*77c1e3ccSAndroid Build Coastguard Worker
163*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < 64; i += 8) {
164*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t a0 = vld1q_s16(coeff + 0);
165*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t a1 = vld1q_s16(coeff + 64);
166*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t a2 = vld1q_s16(coeff + 128);
167*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t a3 = vld1q_s16(coeff + 192);
168*77c1e3ccSAndroid Build Coastguard Worker
169*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b0 = vhaddq_s16(a0, a1);
170*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b1 = vhsubq_s16(a0, a1);
171*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b2 = vhaddq_s16(a2, a3);
172*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t b3 = vhsubq_s16(a2, a3);
173*77c1e3ccSAndroid Build Coastguard Worker
174*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c0 = vaddq_s16(b0, b2);
175*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c1 = vaddq_s16(b1, b3);
176*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c2 = vsubq_s16(b0, b2);
177*77c1e3ccSAndroid Build Coastguard Worker const int16x8_t c3 = vsubq_s16(b1, b3);
178*77c1e3ccSAndroid Build Coastguard Worker
179*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 0, c0);
180*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 64, c1);
181*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 128, c2);
182*77c1e3ccSAndroid Build Coastguard Worker vst1q_s16(coeff + 192, c3);
183*77c1e3ccSAndroid Build Coastguard Worker
184*77c1e3ccSAndroid Build Coastguard Worker coeff += 8;
185*77c1e3ccSAndroid Build Coastguard Worker }
186*77c1e3ccSAndroid Build Coastguard Worker }
187*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_16x16_neon(const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)188*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_16x16_neon(const int16_t *src_diff, ptrdiff_t src_stride,
189*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *coeff) {
190*77c1e3ccSAndroid Build Coastguard Worker /* Rearrange 16x16 to 8x32 and remove stride.
191*77c1e3ccSAndroid Build Coastguard Worker * Top left first. */
192*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_8x8_neon(src_diff + 0 + 0 * src_stride, src_stride, coeff + 0);
193*77c1e3ccSAndroid Build Coastguard Worker /* Top right. */
194*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_8x8_neon(src_diff + 8 + 0 * src_stride, src_stride, coeff + 64);
195*77c1e3ccSAndroid Build Coastguard Worker /* Bottom left. */
196*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_8x8_neon(src_diff + 0 + 8 * src_stride, src_stride, coeff + 128);
197*77c1e3ccSAndroid Build Coastguard Worker /* Bottom right. */
198*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_8x8_neon(src_diff + 8 + 8 * src_stride, src_stride, coeff + 192);
199*77c1e3ccSAndroid Build Coastguard Worker
200*77c1e3ccSAndroid Build Coastguard Worker // Each iteration of the loop operates on entire rows (16 samples each)
201*77c1e3ccSAndroid Build Coastguard Worker // because we need to swap the second and third quarters of every row in the
202*77c1e3ccSAndroid Build Coastguard Worker // output to match AVX2 output (i.e., aom_hadamard_16x16_avx2). See the for
203*77c1e3ccSAndroid Build Coastguard Worker // loop at the end of aom_hadamard_16x16_c.
204*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < 64; i += 16) {
205*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a00 = vld1q_s32(coeff + 0);
206*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a01 = vld1q_s32(coeff + 64);
207*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a02 = vld1q_s32(coeff + 128);
208*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a03 = vld1q_s32(coeff + 192);
209*77c1e3ccSAndroid Build Coastguard Worker
210*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b00 = vhaddq_s32(a00, a01);
211*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b01 = vhsubq_s32(a00, a01);
212*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b02 = vhaddq_s32(a02, a03);
213*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b03 = vhsubq_s32(a02, a03);
214*77c1e3ccSAndroid Build Coastguard Worker
215*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c00 = vaddq_s32(b00, b02);
216*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c01 = vaddq_s32(b01, b03);
217*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c02 = vsubq_s32(b00, b02);
218*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c03 = vsubq_s32(b01, b03);
219*77c1e3ccSAndroid Build Coastguard Worker
220*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a10 = vld1q_s32(coeff + 4 + 0);
221*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a11 = vld1q_s32(coeff + 4 + 64);
222*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a12 = vld1q_s32(coeff + 4 + 128);
223*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a13 = vld1q_s32(coeff + 4 + 192);
224*77c1e3ccSAndroid Build Coastguard Worker
225*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b10 = vhaddq_s32(a10, a11);
226*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b11 = vhsubq_s32(a10, a11);
227*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b12 = vhaddq_s32(a12, a13);
228*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b13 = vhsubq_s32(a12, a13);
229*77c1e3ccSAndroid Build Coastguard Worker
230*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c10 = vaddq_s32(b10, b12);
231*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c11 = vaddq_s32(b11, b13);
232*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c12 = vsubq_s32(b10, b12);
233*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c13 = vsubq_s32(b11, b13);
234*77c1e3ccSAndroid Build Coastguard Worker
235*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a20 = vld1q_s32(coeff + 8 + 0);
236*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a21 = vld1q_s32(coeff + 8 + 64);
237*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a22 = vld1q_s32(coeff + 8 + 128);
238*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a23 = vld1q_s32(coeff + 8 + 192);
239*77c1e3ccSAndroid Build Coastguard Worker
240*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b20 = vhaddq_s32(a20, a21);
241*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b21 = vhsubq_s32(a20, a21);
242*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b22 = vhaddq_s32(a22, a23);
243*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b23 = vhsubq_s32(a22, a23);
244*77c1e3ccSAndroid Build Coastguard Worker
245*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c20 = vaddq_s32(b20, b22);
246*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c21 = vaddq_s32(b21, b23);
247*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c22 = vsubq_s32(b20, b22);
248*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c23 = vsubq_s32(b21, b23);
249*77c1e3ccSAndroid Build Coastguard Worker
250*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a30 = vld1q_s32(coeff + 12 + 0);
251*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a31 = vld1q_s32(coeff + 12 + 64);
252*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a32 = vld1q_s32(coeff + 12 + 128);
253*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a33 = vld1q_s32(coeff + 12 + 192);
254*77c1e3ccSAndroid Build Coastguard Worker
255*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b30 = vhaddq_s32(a30, a31);
256*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b31 = vhsubq_s32(a30, a31);
257*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b32 = vhaddq_s32(a32, a33);
258*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b33 = vhsubq_s32(a32, a33);
259*77c1e3ccSAndroid Build Coastguard Worker
260*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c30 = vaddq_s32(b30, b32);
261*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c31 = vaddq_s32(b31, b33);
262*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c32 = vsubq_s32(b30, b32);
263*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c33 = vsubq_s32(b31, b33);
264*77c1e3ccSAndroid Build Coastguard Worker
265*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 0 + 0, c00);
266*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 0 + 4, c20);
267*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 0 + 8, c10);
268*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 0 + 12, c30);
269*77c1e3ccSAndroid Build Coastguard Worker
270*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 64 + 0, c01);
271*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 64 + 4, c21);
272*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 64 + 8, c11);
273*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 64 + 12, c31);
274*77c1e3ccSAndroid Build Coastguard Worker
275*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 128 + 0, c02);
276*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 128 + 4, c22);
277*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 128 + 8, c12);
278*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 128 + 12, c32);
279*77c1e3ccSAndroid Build Coastguard Worker
280*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 192 + 0, c03);
281*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 192 + 4, c23);
282*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 192 + 8, c13);
283*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 192 + 12, c33);
284*77c1e3ccSAndroid Build Coastguard Worker
285*77c1e3ccSAndroid Build Coastguard Worker coeff += 16;
286*77c1e3ccSAndroid Build Coastguard Worker }
287*77c1e3ccSAndroid Build Coastguard Worker }
288*77c1e3ccSAndroid Build Coastguard Worker
aom_hadamard_32x32_neon(const int16_t * src_diff,ptrdiff_t src_stride,tran_low_t * coeff)289*77c1e3ccSAndroid Build Coastguard Worker void aom_hadamard_32x32_neon(const int16_t *src_diff, ptrdiff_t src_stride,
290*77c1e3ccSAndroid Build Coastguard Worker tran_low_t *coeff) {
291*77c1e3ccSAndroid Build Coastguard Worker /* Top left first. */
292*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_16x16_neon(src_diff + 0 + 0 * src_stride, src_stride, coeff + 0);
293*77c1e3ccSAndroid Build Coastguard Worker /* Top right. */
294*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_16x16_neon(src_diff + 16 + 0 * src_stride, src_stride,
295*77c1e3ccSAndroid Build Coastguard Worker coeff + 256);
296*77c1e3ccSAndroid Build Coastguard Worker /* Bottom left. */
297*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_16x16_neon(src_diff + 0 + 16 * src_stride, src_stride,
298*77c1e3ccSAndroid Build Coastguard Worker coeff + 512);
299*77c1e3ccSAndroid Build Coastguard Worker /* Bottom right. */
300*77c1e3ccSAndroid Build Coastguard Worker aom_hadamard_16x16_neon(src_diff + 16 + 16 * src_stride, src_stride,
301*77c1e3ccSAndroid Build Coastguard Worker coeff + 768);
302*77c1e3ccSAndroid Build Coastguard Worker
303*77c1e3ccSAndroid Build Coastguard Worker for (int i = 0; i < 256; i += 4) {
304*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a0 = vld1q_s32(coeff);
305*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a1 = vld1q_s32(coeff + 256);
306*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a2 = vld1q_s32(coeff + 512);
307*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t a3 = vld1q_s32(coeff + 768);
308*77c1e3ccSAndroid Build Coastguard Worker
309*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b0 = vshrq_n_s32(vaddq_s32(a0, a1), 2);
310*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b1 = vshrq_n_s32(vsubq_s32(a0, a1), 2);
311*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b2 = vshrq_n_s32(vaddq_s32(a2, a3), 2);
312*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t b3 = vshrq_n_s32(vsubq_s32(a2, a3), 2);
313*77c1e3ccSAndroid Build Coastguard Worker
314*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c0 = vaddq_s32(b0, b2);
315*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c1 = vaddq_s32(b1, b3);
316*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c2 = vsubq_s32(b0, b2);
317*77c1e3ccSAndroid Build Coastguard Worker const int32x4_t c3 = vsubq_s32(b1, b3);
318*77c1e3ccSAndroid Build Coastguard Worker
319*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 0, c0);
320*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 256, c1);
321*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 512, c2);
322*77c1e3ccSAndroid Build Coastguard Worker vst1q_s32(coeff + 768, c3);
323*77c1e3ccSAndroid Build Coastguard Worker
324*77c1e3ccSAndroid Build Coastguard Worker coeff += 4;
325*77c1e3ccSAndroid Build Coastguard Worker }
326*77c1e3ccSAndroid Build Coastguard Worker }
327