2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
13 #include "./vpx_dsp_rtcd.h"
14 #include "vpx_dsp/arm/idct_neon.h"
15 #include "vpx_dsp/txfm_common.h"
17 static INLINE void wrap_low_4x2(const int32x4_t *const t32, int16x4_t *const d0,
18 int16x4_t *const d1) {
19 *d0 = vrshrn_n_s32(t32[0], 14);
20 *d1 = vrshrn_n_s32(t32[1], 14);
23 static INLINE void idct_cospi_2_30(const int16x8_t s0, const int16x8_t s1,
24 const int16x4_t cospi_2_30_10_22,
25 int16x8_t *const d0, int16x8_t *const d1) {
28 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_2_30_10_22, 1);
29 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_2_30_10_22, 1);
30 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_2_30_10_22, 1);
31 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_2_30_10_22, 1);
32 t32[0] = vmlsl_lane_s16(t32[0], vget_low_s16(s1), cospi_2_30_10_22, 0);
33 t32[1] = vmlsl_lane_s16(t32[1], vget_high_s16(s1), cospi_2_30_10_22, 0);
34 t32[2] = vmlal_lane_s16(t32[2], vget_low_s16(s0), cospi_2_30_10_22, 0);
35 t32[3] = vmlal_lane_s16(t32[3], vget_high_s16(s0), cospi_2_30_10_22, 0);
36 idct16x16_add_wrap_low_8x2(t32, d0, d1);
39 static INLINE void idct_cospi_4_28(const int16x8_t s0, const int16x8_t s1,
40 const int16x4_t cospi_4_12_20N_28,
41 int16x8_t *const d0, int16x8_t *const d1) {
44 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_4_12_20N_28, 3);
45 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_4_12_20N_28, 3);
46 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_4_12_20N_28, 3);
47 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_4_12_20N_28, 3);
48 t32[0] = vmlsl_lane_s16(t32[0], vget_low_s16(s1), cospi_4_12_20N_28, 0);
49 t32[1] = vmlsl_lane_s16(t32[1], vget_high_s16(s1), cospi_4_12_20N_28, 0);
50 t32[2] = vmlal_lane_s16(t32[2], vget_low_s16(s0), cospi_4_12_20N_28, 0);
51 t32[3] = vmlal_lane_s16(t32[3], vget_high_s16(s0), cospi_4_12_20N_28, 0);
52 idct16x16_add_wrap_low_8x2(t32, d0, d1);
55 static INLINE void idct_cospi_6_26(const int16x8_t s0, const int16x8_t s1,
56 const int16x4_t cospi_6_26_14_18N,
57 int16x8_t *const d0, int16x8_t *const d1) {
60 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_6_26_14_18N, 0);
61 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_6_26_14_18N, 0);
62 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_6_26_14_18N, 0);
63 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_6_26_14_18N, 0);
64 t32[0] = vmlal_lane_s16(t32[0], vget_low_s16(s1), cospi_6_26_14_18N, 1);
65 t32[1] = vmlal_lane_s16(t32[1], vget_high_s16(s1), cospi_6_26_14_18N, 1);
66 t32[2] = vmlsl_lane_s16(t32[2], vget_low_s16(s0), cospi_6_26_14_18N, 1);
67 t32[3] = vmlsl_lane_s16(t32[3], vget_high_s16(s0), cospi_6_26_14_18N, 1);
68 idct16x16_add_wrap_low_8x2(t32, d0, d1);
71 static INLINE void idct_cospi_8_24_d_kernel(const int16x4_t s0,
73 const int16x4_t cospi_0_8_16_24,
74 int32x4_t *const t32) {
75 t32[0] = vmull_lane_s16(s0, cospi_0_8_16_24, 3);
76 t32[1] = vmull_lane_s16(s1, cospi_0_8_16_24, 3);
77 t32[0] = vmlsl_lane_s16(t32[0], s1, cospi_0_8_16_24, 1);
78 t32[1] = vmlal_lane_s16(t32[1], s0, cospi_0_8_16_24, 1);
81 static INLINE void idct_cospi_8_24_d(const int16x4_t s0, const int16x4_t s1,
82 const int16x4_t cospi_0_8_16_24,
83 int16x4_t *const d0, int16x4_t *const d1) {
86 idct_cospi_8_24_d_kernel(s0, s1, cospi_0_8_16_24, t32);
87 wrap_low_4x2(t32, d0, d1);
90 static INLINE void idct_cospi_8_24_neg_d(const int16x4_t s0, const int16x4_t s1,
91 const int16x4_t cospi_0_8_16_24,
93 int16x4_t *const d1) {
96 idct_cospi_8_24_d_kernel(s0, s1, cospi_0_8_16_24, t32);
97 t32[1] = vnegq_s32(t32[1]);
98 wrap_low_4x2(t32, d0, d1);
101 static INLINE void idct_cospi_10_22(const int16x8_t s0, const int16x8_t s1,
102 const int16x4_t cospi_2_30_10_22,
103 int16x8_t *const d0, int16x8_t *const d1) {
106 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_2_30_10_22, 3);
107 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_2_30_10_22, 3);
108 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_2_30_10_22, 3);
109 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_2_30_10_22, 3);
110 t32[0] = vmlsl_lane_s16(t32[0], vget_low_s16(s1), cospi_2_30_10_22, 2);
111 t32[1] = vmlsl_lane_s16(t32[1], vget_high_s16(s1), cospi_2_30_10_22, 2);
112 t32[2] = vmlal_lane_s16(t32[2], vget_low_s16(s0), cospi_2_30_10_22, 2);
113 t32[3] = vmlal_lane_s16(t32[3], vget_high_s16(s0), cospi_2_30_10_22, 2);
114 idct16x16_add_wrap_low_8x2(t32, d0, d1);
117 static INLINE void idct_cospi_12_20(const int16x8_t s0, const int16x8_t s1,
118 const int16x4_t cospi_4_12_20N_28,
119 int16x8_t *const d0, int16x8_t *const d1) {
122 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_4_12_20N_28, 1);
123 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_4_12_20N_28, 1);
124 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_4_12_20N_28, 1);
125 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_4_12_20N_28, 1);
126 t32[0] = vmlal_lane_s16(t32[0], vget_low_s16(s1), cospi_4_12_20N_28, 2);
127 t32[1] = vmlal_lane_s16(t32[1], vget_high_s16(s1), cospi_4_12_20N_28, 2);
128 t32[2] = vmlsl_lane_s16(t32[2], vget_low_s16(s0), cospi_4_12_20N_28, 2);
129 t32[3] = vmlsl_lane_s16(t32[3], vget_high_s16(s0), cospi_4_12_20N_28, 2);
130 idct16x16_add_wrap_low_8x2(t32, d0, d1);
133 static INLINE void idct_cospi_14_18(const int16x8_t s0, const int16x8_t s1,
134 const int16x4_t cospi_6_26_14_18N,
135 int16x8_t *const d0, int16x8_t *const d1) {
138 t32[0] = vmull_lane_s16(vget_low_s16(s0), cospi_6_26_14_18N, 2);
139 t32[1] = vmull_lane_s16(vget_high_s16(s0), cospi_6_26_14_18N, 2);
140 t32[2] = vmull_lane_s16(vget_low_s16(s1), cospi_6_26_14_18N, 2);
141 t32[3] = vmull_lane_s16(vget_high_s16(s1), cospi_6_26_14_18N, 2);
142 t32[0] = vmlal_lane_s16(t32[0], vget_low_s16(s1), cospi_6_26_14_18N, 3);
143 t32[1] = vmlal_lane_s16(t32[1], vget_high_s16(s1), cospi_6_26_14_18N, 3);
144 t32[2] = vmlsl_lane_s16(t32[2], vget_low_s16(s0), cospi_6_26_14_18N, 3);
145 t32[3] = vmlsl_lane_s16(t32[3], vget_high_s16(s0), cospi_6_26_14_18N, 3);
146 idct16x16_add_wrap_low_8x2(t32, d0, d1);
149 static INLINE void idct_cospi_16_16_d(const int16x4_t s0, const int16x4_t s1,
150 const int16x4_t cospi_0_8_16_24,
152 int16x4_t *const d1) {
155 t32[2] = vmull_lane_s16(s1, cospi_0_8_16_24, 2);
156 t32[0] = vmlsl_lane_s16(t32[2], s0, cospi_0_8_16_24, 2);
157 t32[1] = vmlal_lane_s16(t32[2], s0, cospi_0_8_16_24, 2);
158 wrap_low_4x2(t32, d0, d1);
161 static void idct16x16_256_add_half1d(const void *const input, int16_t *output,
162 uint8_t *dest, int stride) {
163 const int16x8_t cospis0 = vld1q_s16(kCospi);
164 const int16x8_t cospis1 = vld1q_s16(kCospi + 8);
165 const int16x4_t cospi_0_8_16_24 = vget_low_s16(cospis0);
166 const int16x4_t cospi_4_12_20N_28 = vget_high_s16(cospis0);
167 const int16x4_t cospi_2_30_10_22 = vget_low_s16(cospis1);
168 const int16x4_t cospi_6_26_14_18N = vget_high_s16(cospis1);
169 int16x8_t in[16], step1[16], step2[16], out[16];
173 const tran_low_t *inputT = (const tran_low_t *)input;
174 in[0] = load_tran_low_to_s16q(inputT);
176 in[8] = load_tran_low_to_s16q(inputT);
178 in[1] = load_tran_low_to_s16q(inputT);
180 in[9] = load_tran_low_to_s16q(inputT);
182 in[2] = load_tran_low_to_s16q(inputT);
184 in[10] = load_tran_low_to_s16q(inputT);
186 in[3] = load_tran_low_to_s16q(inputT);
188 in[11] = load_tran_low_to_s16q(inputT);
190 in[4] = load_tran_low_to_s16q(inputT);
192 in[12] = load_tran_low_to_s16q(inputT);
194 in[5] = load_tran_low_to_s16q(inputT);
196 in[13] = load_tran_low_to_s16q(inputT);
198 in[6] = load_tran_low_to_s16q(inputT);
200 in[14] = load_tran_low_to_s16q(inputT);
202 in[7] = load_tran_low_to_s16q(inputT);
204 in[15] = load_tran_low_to_s16q(inputT);
206 const int16_t *inputT = (const int16_t *)input;
207 in[0] = vld1q_s16(inputT);
209 in[8] = vld1q_s16(inputT);
211 in[1] = vld1q_s16(inputT);
213 in[9] = vld1q_s16(inputT);
215 in[2] = vld1q_s16(inputT);
217 in[10] = vld1q_s16(inputT);
219 in[3] = vld1q_s16(inputT);
221 in[11] = vld1q_s16(inputT);
223 in[4] = vld1q_s16(inputT);
225 in[12] = vld1q_s16(inputT);
227 in[5] = vld1q_s16(inputT);
229 in[13] = vld1q_s16(inputT);
231 in[6] = vld1q_s16(inputT);
233 in[14] = vld1q_s16(inputT);
235 in[7] = vld1q_s16(inputT);
237 in[15] = vld1q_s16(inputT);
241 transpose_s16_8x8(&in[0], &in[1], &in[2], &in[3], &in[4], &in[5], &in[6],
243 transpose_s16_8x8(&in[8], &in[9], &in[10], &in[11], &in[12], &in[13], &in[14],
247 step1[0] = in[0 / 2];
248 step1[1] = in[16 / 2];
249 step1[2] = in[8 / 2];
250 step1[3] = in[24 / 2];
251 step1[4] = in[4 / 2];
252 step1[5] = in[20 / 2];
253 step1[6] = in[12 / 2];
254 step1[7] = in[28 / 2];
255 step1[8] = in[2 / 2];
256 step1[9] = in[18 / 2];
257 step1[10] = in[10 / 2];
258 step1[11] = in[26 / 2];
259 step1[12] = in[6 / 2];
260 step1[13] = in[22 / 2];
261 step1[14] = in[14 / 2];
262 step1[15] = in[30 / 2];
273 idct_cospi_2_30(step1[8], step1[15], cospi_2_30_10_22, &step2[8], &step2[15]);
274 idct_cospi_14_18(step1[9], step1[14], cospi_6_26_14_18N, &step2[9],
276 idct_cospi_10_22(step1[10], step1[13], cospi_2_30_10_22, &step2[10],
278 idct_cospi_6_26(step1[11], step1[12], cospi_6_26_14_18N, &step2[11],
286 idct_cospi_4_28(step2[4], step2[7], cospi_4_12_20N_28, &step1[4], &step1[7]);
287 idct_cospi_12_20(step2[5], step2[6], cospi_4_12_20N_28, &step1[5], &step1[6]);
288 step1[8] = vaddq_s16(step2[8], step2[9]);
289 step1[9] = vsubq_s16(step2[8], step2[9]);
290 step1[10] = vsubq_s16(step2[11], step2[10]);
291 step1[11] = vaddq_s16(step2[11], step2[10]);
292 step1[12] = vaddq_s16(step2[12], step2[13]);
293 step1[13] = vsubq_s16(step2[12], step2[13]);
294 step1[14] = vsubq_s16(step2[15], step2[14]);
295 step1[15] = vaddq_s16(step2[15], step2[14]);
298 idct_cospi_16_16_q(step1[1], step1[0], cospi_0_8_16_24, &step2[1], &step2[0]);
299 idct_cospi_8_24_q(step1[2], step1[3], cospi_0_8_16_24, &step2[2], &step2[3]);
300 step2[4] = vaddq_s16(step1[4], step1[5]);
301 step2[5] = vsubq_s16(step1[4], step1[5]);
302 step2[6] = vsubq_s16(step1[7], step1[6]);
303 step2[7] = vaddq_s16(step1[7], step1[6]);
305 idct_cospi_8_24_q(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
307 idct_cospi_8_24_neg_q(step1[13], step1[10], cospi_0_8_16_24, &step2[13],
309 step2[11] = step1[11];
310 step2[12] = step1[12];
311 step2[15] = step1[15];
314 step1[0] = vaddq_s16(step2[0], step2[3]);
315 step1[1] = vaddq_s16(step2[1], step2[2]);
316 step1[2] = vsubq_s16(step2[1], step2[2]);
317 step1[3] = vsubq_s16(step2[0], step2[3]);
319 idct_cospi_16_16_q(step2[5], step2[6], cospi_0_8_16_24, &step1[5], &step1[6]);
321 step1[8] = vaddq_s16(step2[8], step2[11]);
322 step1[9] = vaddq_s16(step2[9], step2[10]);
323 step1[10] = vsubq_s16(step2[9], step2[10]);
324 step1[11] = vsubq_s16(step2[8], step2[11]);
325 step1[12] = vsubq_s16(step2[15], step2[12]);
326 step1[13] = vsubq_s16(step2[14], step2[13]);
327 step1[14] = vaddq_s16(step2[14], step2[13]);
328 step1[15] = vaddq_s16(step2[15], step2[12]);
331 step2[0] = vaddq_s16(step1[0], step1[7]);
332 step2[1] = vaddq_s16(step1[1], step1[6]);
333 step2[2] = vaddq_s16(step1[2], step1[5]);
334 step2[3] = vaddq_s16(step1[3], step1[4]);
335 step2[4] = vsubq_s16(step1[3], step1[4]);
336 step2[5] = vsubq_s16(step1[2], step1[5]);
337 step2[6] = vsubq_s16(step1[1], step1[6]);
338 step2[7] = vsubq_s16(step1[0], step1[7]);
339 idct_cospi_16_16_q(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
341 idct_cospi_16_16_q(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
345 step2[14] = step1[14];
346 step2[15] = step1[15];
349 out[0] = vaddq_s16(step2[0], step2[15]);
350 out[1] = vaddq_s16(step2[1], step2[14]);
351 out[2] = vaddq_s16(step2[2], step2[13]);
352 out[3] = vaddq_s16(step2[3], step2[12]);
353 out[4] = vaddq_s16(step2[4], step2[11]);
354 out[5] = vaddq_s16(step2[5], step2[10]);
355 out[6] = vaddq_s16(step2[6], step2[9]);
356 out[7] = vaddq_s16(step2[7], step2[8]);
357 out[8] = vsubq_s16(step2[7], step2[8]);
358 out[9] = vsubq_s16(step2[6], step2[9]);
359 out[10] = vsubq_s16(step2[5], step2[10]);
360 out[11] = vsubq_s16(step2[4], step2[11]);
361 out[12] = vsubq_s16(step2[3], step2[12]);
362 out[13] = vsubq_s16(step2[2], step2[13]);
363 out[14] = vsubq_s16(step2[1], step2[14]);
364 out[15] = vsubq_s16(step2[0], step2[15]);
367 // pass 1: save the result into output
368 vst1q_s16(output, out[0]);
370 vst1q_s16(output, out[1]);
372 vst1q_s16(output, out[2]);
374 vst1q_s16(output, out[3]);
376 vst1q_s16(output, out[4]);
378 vst1q_s16(output, out[5]);
380 vst1q_s16(output, out[6]);
382 vst1q_s16(output, out[7]);
384 vst1q_s16(output, out[8]);
386 vst1q_s16(output, out[9]);
388 vst1q_s16(output, out[10]);
390 vst1q_s16(output, out[11]);
392 vst1q_s16(output, out[12]);
394 vst1q_s16(output, out[13]);
396 vst1q_s16(output, out[14]);
398 vst1q_s16(output, out[15]);
400 // pass 2: add the result to dest.
401 idct16x16_add8x1(out[0], &dest, stride);
402 idct16x16_add8x1(out[1], &dest, stride);
403 idct16x16_add8x1(out[2], &dest, stride);
404 idct16x16_add8x1(out[3], &dest, stride);
405 idct16x16_add8x1(out[4], &dest, stride);
406 idct16x16_add8x1(out[5], &dest, stride);
407 idct16x16_add8x1(out[6], &dest, stride);
408 idct16x16_add8x1(out[7], &dest, stride);
409 idct16x16_add8x1(out[8], &dest, stride);
410 idct16x16_add8x1(out[9], &dest, stride);
411 idct16x16_add8x1(out[10], &dest, stride);
412 idct16x16_add8x1(out[11], &dest, stride);
413 idct16x16_add8x1(out[12], &dest, stride);
414 idct16x16_add8x1(out[13], &dest, stride);
415 idct16x16_add8x1(out[14], &dest, stride);
416 idct16x16_add8x1(out[15], &dest, stride);
420 static void idct16x16_10_add_half1d_pass1(const tran_low_t *input,
422 const int16x8_t cospis0 = vld1q_s16(kCospi);
423 const int16x8_t cospis1 = vld1q_s16(kCospi + 8);
424 const int16x8_t cospisd0 = vaddq_s16(cospis0, cospis0);
425 const int16x8_t cospisd1 = vaddq_s16(cospis1, cospis1);
426 const int16x4_t cospi_0_8_16_24 = vget_low_s16(cospis0);
427 const int16x4_t cospid_0_8_16_24 = vget_low_s16(cospisd0);
428 const int16x4_t cospid_4_12_20N_28 = vget_high_s16(cospisd0);
429 const int16x4_t cospid_2_30_10_22 = vget_low_s16(cospisd1);
430 const int16x4_t cospid_6_26_14_18N = vget_high_s16(cospisd1);
431 int16x4_t in[4], step1[16], step2[16], out[16];
434 in[0] = load_tran_low_to_s16d(input);
436 in[1] = load_tran_low_to_s16d(input);
438 in[2] = load_tran_low_to_s16d(input);
440 in[3] = load_tran_low_to_s16d(input);
443 transpose_s16_4x4d(&in[0], &in[1], &in[2], &in[3]);
446 step1[0] = in[0 / 2];
447 step1[4] = in[4 / 2];
448 step1[8] = in[2 / 2];
449 step1[12] = in[6 / 2];
454 step2[8] = vqrdmulh_lane_s16(step1[8], cospid_2_30_10_22, 1);
455 step2[11] = vqrdmulh_lane_s16(step1[12], cospid_6_26_14_18N, 1);
456 step2[12] = vqrdmulh_lane_s16(step1[12], cospid_6_26_14_18N, 0);
457 step2[15] = vqrdmulh_lane_s16(step1[8], cospid_2_30_10_22, 0);
461 step1[4] = vqrdmulh_lane_s16(step2[4], cospid_4_12_20N_28, 3);
462 step1[7] = vqrdmulh_lane_s16(step2[4], cospid_4_12_20N_28, 0);
465 step1[10] = step2[11];
466 step1[11] = step2[11];
467 step1[12] = step2[12];
468 step1[13] = step2[12];
469 step1[14] = step2[15];
470 step1[15] = step2[15];
473 step2[0] = step2[1] = vqrdmulh_lane_s16(step1[0], cospid_0_8_16_24, 2);
479 idct_cospi_8_24_d(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
481 idct_cospi_8_24_neg_d(step1[13], step1[10], cospi_0_8_16_24, &step2[13],
483 step2[11] = step1[11];
484 step2[12] = step1[12];
485 step2[15] = step1[15];
493 idct_cospi_16_16_d(step2[5], step2[6], cospi_0_8_16_24, &step1[5], &step1[6]);
495 step1[8] = vadd_s16(step2[8], step2[11]);
496 step1[9] = vadd_s16(step2[9], step2[10]);
497 step1[10] = vsub_s16(step2[9], step2[10]);
498 step1[11] = vsub_s16(step2[8], step2[11]);
499 step1[12] = vsub_s16(step2[15], step2[12]);
500 step1[13] = vsub_s16(step2[14], step2[13]);
501 step1[14] = vadd_s16(step2[14], step2[13]);
502 step1[15] = vadd_s16(step2[15], step2[12]);
505 step2[0] = vadd_s16(step1[0], step1[7]);
506 step2[1] = vadd_s16(step1[1], step1[6]);
507 step2[2] = vadd_s16(step1[2], step1[5]);
508 step2[3] = vadd_s16(step1[3], step1[4]);
509 step2[4] = vsub_s16(step1[3], step1[4]);
510 step2[5] = vsub_s16(step1[2], step1[5]);
511 step2[6] = vsub_s16(step1[1], step1[6]);
512 step2[7] = vsub_s16(step1[0], step1[7]);
513 idct_cospi_16_16_d(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
515 idct_cospi_16_16_d(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
519 step2[14] = step1[14];
520 step2[15] = step1[15];
523 out[0] = vadd_s16(step2[0], step2[15]);
524 out[1] = vadd_s16(step2[1], step2[14]);
525 out[2] = vadd_s16(step2[2], step2[13]);
526 out[3] = vadd_s16(step2[3], step2[12]);
527 out[4] = vadd_s16(step2[4], step2[11]);
528 out[5] = vadd_s16(step2[5], step2[10]);
529 out[6] = vadd_s16(step2[6], step2[9]);
530 out[7] = vadd_s16(step2[7], step2[8]);
531 out[8] = vsub_s16(step2[7], step2[8]);
532 out[9] = vsub_s16(step2[6], step2[9]);
533 out[10] = vsub_s16(step2[5], step2[10]);
534 out[11] = vsub_s16(step2[4], step2[11]);
535 out[12] = vsub_s16(step2[3], step2[12]);
536 out[13] = vsub_s16(step2[2], step2[13]);
537 out[14] = vsub_s16(step2[1], step2[14]);
538 out[15] = vsub_s16(step2[0], step2[15]);
540 // pass 1: save the result into output
541 vst1_s16(output, out[0]);
543 vst1_s16(output, out[1]);
545 vst1_s16(output, out[2]);
547 vst1_s16(output, out[3]);
549 vst1_s16(output, out[4]);
551 vst1_s16(output, out[5]);
553 vst1_s16(output, out[6]);
555 vst1_s16(output, out[7]);
557 vst1_s16(output, out[8]);
559 vst1_s16(output, out[9]);
561 vst1_s16(output, out[10]);
563 vst1_s16(output, out[11]);
565 vst1_s16(output, out[12]);
567 vst1_s16(output, out[13]);
569 vst1_s16(output, out[14]);
571 vst1_s16(output, out[15]);
574 static void idct16x16_10_add_half1d_pass2(const int16_t *input, int16_t *output,
575 uint8_t *dest, int stride) {
576 const int16x8_t cospis0 = vld1q_s16(kCospi);
577 const int16x8_t cospis1 = vld1q_s16(kCospi + 8);
578 const int16x8_t cospisd0 = vaddq_s16(cospis0, cospis0);
579 const int16x8_t cospisd1 = vaddq_s16(cospis1, cospis1);
580 const int16x4_t cospi_0_8_16_24 = vget_low_s16(cospis0);
581 const int16x4_t cospid_0_8_16_24 = vget_low_s16(cospisd0);
582 const int16x4_t cospid_4_12_20N_28 = vget_high_s16(cospisd0);
583 const int16x4_t cospid_2_30_10_22 = vget_low_s16(cospisd1);
584 const int16x4_t cospid_6_26_14_18N = vget_high_s16(cospisd1);
586 int16x8_t in[4], step1[16], step2[16], out[16];
589 ind[0] = vld1_s16(input);
591 ind[1] = vld1_s16(input);
593 ind[2] = vld1_s16(input);
595 ind[3] = vld1_s16(input);
597 ind[4] = vld1_s16(input);
599 ind[5] = vld1_s16(input);
601 ind[6] = vld1_s16(input);
603 ind[7] = vld1_s16(input);
606 transpose_s16_4x8(ind[0], ind[1], ind[2], ind[3], ind[4], ind[5], ind[6],
607 ind[7], &in[0], &in[1], &in[2], &in[3]);
610 step1[0] = in[0 / 2];
611 step1[4] = in[4 / 2];
612 step1[8] = in[2 / 2];
613 step1[12] = in[6 / 2];
618 step2[8] = vqrdmulhq_lane_s16(step1[8], cospid_2_30_10_22, 1);
619 step2[11] = vqrdmulhq_lane_s16(step1[12], cospid_6_26_14_18N, 1);
620 step2[12] = vqrdmulhq_lane_s16(step1[12], cospid_6_26_14_18N, 0);
621 step2[15] = vqrdmulhq_lane_s16(step1[8], cospid_2_30_10_22, 0);
625 step1[4] = vqrdmulhq_lane_s16(step2[4], cospid_4_12_20N_28, 3);
626 step1[7] = vqrdmulhq_lane_s16(step2[4], cospid_4_12_20N_28, 0);
629 step1[10] = step2[11];
630 step1[11] = step2[11];
631 step1[12] = step2[12];
632 step1[13] = step2[12];
633 step1[14] = step2[15];
634 step1[15] = step2[15];
637 step2[0] = step2[1] = vqrdmulhq_lane_s16(step1[0], cospid_0_8_16_24, 2);
643 idct_cospi_8_24_q(step1[14], step1[9], cospi_0_8_16_24, &step2[9],
645 idct_cospi_8_24_neg_q(step1[13], step1[10], cospi_0_8_16_24, &step2[13],
647 step2[11] = step1[11];
648 step2[12] = step1[12];
649 step2[15] = step1[15];
657 idct_cospi_16_16_q(step2[5], step2[6], cospi_0_8_16_24, &step1[5], &step1[6]);
659 step1[8] = vaddq_s16(step2[8], step2[11]);
660 step1[9] = vaddq_s16(step2[9], step2[10]);
661 step1[10] = vsubq_s16(step2[9], step2[10]);
662 step1[11] = vsubq_s16(step2[8], step2[11]);
663 step1[12] = vsubq_s16(step2[15], step2[12]);
664 step1[13] = vsubq_s16(step2[14], step2[13]);
665 step1[14] = vaddq_s16(step2[14], step2[13]);
666 step1[15] = vaddq_s16(step2[15], step2[12]);
669 step2[0] = vaddq_s16(step1[0], step1[7]);
670 step2[1] = vaddq_s16(step1[1], step1[6]);
671 step2[2] = vaddq_s16(step1[2], step1[5]);
672 step2[3] = vaddq_s16(step1[3], step1[4]);
673 step2[4] = vsubq_s16(step1[3], step1[4]);
674 step2[5] = vsubq_s16(step1[2], step1[5]);
675 step2[6] = vsubq_s16(step1[1], step1[6]);
676 step2[7] = vsubq_s16(step1[0], step1[7]);
677 idct_cospi_16_16_q(step1[10], step1[13], cospi_0_8_16_24, &step2[10],
679 idct_cospi_16_16_q(step1[11], step1[12], cospi_0_8_16_24, &step2[11],
683 step2[14] = step1[14];
684 step2[15] = step1[15];
687 out[0] = vaddq_s16(step2[0], step2[15]);
688 out[1] = vaddq_s16(step2[1], step2[14]);
689 out[2] = vaddq_s16(step2[2], step2[13]);
690 out[3] = vaddq_s16(step2[3], step2[12]);
691 out[4] = vaddq_s16(step2[4], step2[11]);
692 out[5] = vaddq_s16(step2[5], step2[10]);
693 out[6] = vaddq_s16(step2[6], step2[9]);
694 out[7] = vaddq_s16(step2[7], step2[8]);
695 out[8] = vsubq_s16(step2[7], step2[8]);
696 out[9] = vsubq_s16(step2[6], step2[9]);
697 out[10] = vsubq_s16(step2[5], step2[10]);
698 out[11] = vsubq_s16(step2[4], step2[11]);
699 out[12] = vsubq_s16(step2[3], step2[12]);
700 out[13] = vsubq_s16(step2[2], step2[13]);
701 out[14] = vsubq_s16(step2[1], step2[14]);
702 out[15] = vsubq_s16(step2[0], step2[15]);
705 // pass 1: save the result into output
706 vst1q_s16(output, out[0]);
708 vst1q_s16(output, out[1]);
710 vst1q_s16(output, out[2]);
712 vst1q_s16(output, out[3]);
714 vst1q_s16(output, out[4]);
716 vst1q_s16(output, out[5]);
718 vst1q_s16(output, out[6]);
720 vst1q_s16(output, out[7]);
722 vst1q_s16(output, out[8]);
724 vst1q_s16(output, out[9]);
726 vst1q_s16(output, out[10]);
728 vst1q_s16(output, out[11]);
730 vst1q_s16(output, out[12]);
732 vst1q_s16(output, out[13]);
734 vst1q_s16(output, out[14]);
736 vst1q_s16(output, out[15]);
738 // pass 2: add the result to dest.
739 idct16x16_add8x1(out[0], &dest, stride);
740 idct16x16_add8x1(out[1], &dest, stride);
741 idct16x16_add8x1(out[2], &dest, stride);
742 idct16x16_add8x1(out[3], &dest, stride);
743 idct16x16_add8x1(out[4], &dest, stride);
744 idct16x16_add8x1(out[5], &dest, stride);
745 idct16x16_add8x1(out[6], &dest, stride);
746 idct16x16_add8x1(out[7], &dest, stride);
747 idct16x16_add8x1(out[8], &dest, stride);
748 idct16x16_add8x1(out[9], &dest, stride);
749 idct16x16_add8x1(out[10], &dest, stride);
750 idct16x16_add8x1(out[11], &dest, stride);
751 idct16x16_add8x1(out[12], &dest, stride);
752 idct16x16_add8x1(out[13], &dest, stride);
753 idct16x16_add8x1(out[14], &dest, stride);
754 idct16x16_add8x1(out[15], &dest, stride);
758 void vpx_idct16x16_256_add_neon(const tran_low_t *input, uint8_t *dest,
760 int16_t row_idct_output[16 * 16];
763 // Parallel idct on the upper 8 rows
764 idct16x16_256_add_half1d(input, row_idct_output, dest, stride);
766 // Parallel idct on the lower 8 rows
767 idct16x16_256_add_half1d(input + 8 * 16, row_idct_output + 8, dest, stride);
770 // Parallel idct to get the left 8 columns
771 idct16x16_256_add_half1d(row_idct_output, NULL, dest, stride);
773 // Parallel idct to get the right 8 columns
774 idct16x16_256_add_half1d(row_idct_output + 16 * 8, NULL, dest + 8, stride);
777 void vpx_idct16x16_10_add_neon(const tran_low_t *input, uint8_t *dest,
779 int16_t row_idct_output[4 * 16];
782 // Parallel idct on the upper 8 rows
783 idct16x16_10_add_half1d_pass1(input, row_idct_output);
786 // Parallel idct to get the left 8 columns
787 idct16x16_10_add_half1d_pass2(row_idct_output, NULL, dest, stride);
789 // Parallel idct to get the right 8 columns
790 idct16x16_10_add_half1d_pass2(row_idct_output + 4 * 8, NULL, dest + 8,