1 /*
2 * Copyright (c) 2020, 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 #include <arm_neon.h>
13
14 #include "aom_dsp/txfm_common.h"
15
transpose4x4(int16x8_t in[2],int16x4_t out[4])16 static void transpose4x4(int16x8_t in[2], int16x4_t out[4]) {
17 int32x4x2_t b0 =
18 vtrnq_s32(vreinterpretq_s32_s16(in[0]), vreinterpretq_s32_s16(in[1]));
19 int16x4x2_t c0 = vtrn_s16(vreinterpret_s16_s32(vget_low_s32(b0.val[0])),
20 vreinterpret_s16_s32(vget_high_s32(b0.val[0])));
21 int16x4x2_t c1 = vtrn_s16(vreinterpret_s16_s32(vget_low_s32(b0.val[1])),
22 vreinterpret_s16_s32(vget_high_s32(b0.val[1])));
23 out[0] = c0.val[0];
24 out[1] = c0.val[1];
25 out[2] = c1.val[0];
26 out[3] = c1.val[1];
27 }
28
av1_fwht4x4_neon(const int16_t * input,tran_low_t * output,int stride)29 void av1_fwht4x4_neon(const int16_t *input, tran_low_t *output, int stride) {
30 // Load the 4x4 source in transposed form.
31 int16x4_t a1, b1, c1, d1, e;
32 a1 = vld1_s16(&input[0]);
33 b1 = vld1_s16(&input[1 * stride]);
34 c1 = vld1_s16(&input[2 * stride]);
35 d1 = vld1_s16(&input[3 * stride]);
36
37 // WHT.
38
39 // Row transforms.
40 a1 = vadd_s16(a1, b1);
41 d1 = vsub_s16(d1, c1);
42 e = vhsub_s16(a1, d1);
43 b1 = vsub_s16(e, b1);
44 c1 = vsub_s16(e, c1);
45 a1 = vsub_s16(a1, c1);
46 d1 = vadd_s16(d1, b1);
47
48 int16x8_t x[2];
49 x[0] = vcombine_s16(a1, c1);
50 x[1] = vcombine_s16(d1, b1);
51
52 int16x4_t s[4];
53 transpose4x4(x, s);
54
55 a1 = s[0];
56 b1 = s[1];
57 c1 = s[2];
58 d1 = s[3];
59
60 // Row transforms.
61 a1 = vadd_s16(a1, b1);
62 d1 = vsub_s16(d1, c1);
63 e = vhsub_s16(a1, d1);
64 b1 = vsub_s16(e, b1);
65 c1 = vsub_s16(e, c1);
66 a1 = vsub_s16(a1, c1);
67 d1 = vadd_s16(d1, b1);
68
69 vst1q_s32(&output[0], vshll_n_s16(a1, UNIT_QUANT_SHIFT));
70 vst1q_s32(&output[4], vshll_n_s16(c1, UNIT_QUANT_SHIFT));
71 vst1q_s32(&output[8], vshll_n_s16(d1, UNIT_QUANT_SHIFT));
72 vst1q_s32(&output[12], vshll_n_s16(b1, UNIT_QUANT_SHIFT));
73 }
74