1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10
11 #include <arm_neon.h>
12
13 #include "./vpx_config.h"
14 #include "./vpx_dsp_rtcd.h"
15 #include "vpx_dsp/arm/idct_neon.h"
16 #include "vpx_dsp/arm/mem_neon.h"
17 #include "vpx_dsp/arm/transpose_neon.h"
18 #include "vpx_dsp/txfm_common.h"
19
add8x8(int16x8_t a0,int16x8_t a1,int16x8_t a2,int16x8_t a3,int16x8_t a4,int16x8_t a5,int16x8_t a6,int16x8_t a7,uint8_t * dest,const int stride)20 static INLINE void add8x8(int16x8_t a0, int16x8_t a1, int16x8_t a2,
21 int16x8_t a3, int16x8_t a4, int16x8_t a5,
22 int16x8_t a6, int16x8_t a7, uint8_t *dest,
23 const int stride) {
24 const uint8_t *dst = dest;
25 uint8x8_t d0, d1, d2, d3, d4, d5, d6, d7;
26 uint16x8_t d0_u16, d1_u16, d2_u16, d3_u16, d4_u16, d5_u16, d6_u16, d7_u16;
27
28 a0 = vrshrq_n_s16(a0, 5);
29 a1 = vrshrq_n_s16(a1, 5);
30 a2 = vrshrq_n_s16(a2, 5);
31 a3 = vrshrq_n_s16(a3, 5);
32 a4 = vrshrq_n_s16(a4, 5);
33 a5 = vrshrq_n_s16(a5, 5);
34 a6 = vrshrq_n_s16(a6, 5);
35 a7 = vrshrq_n_s16(a7, 5);
36
37 d0 = vld1_u8(dst);
38 dst += stride;
39 d1 = vld1_u8(dst);
40 dst += stride;
41 d2 = vld1_u8(dst);
42 dst += stride;
43 d3 = vld1_u8(dst);
44 dst += stride;
45 d4 = vld1_u8(dst);
46 dst += stride;
47 d5 = vld1_u8(dst);
48 dst += stride;
49 d6 = vld1_u8(dst);
50 dst += stride;
51 d7 = vld1_u8(dst);
52
53 d0_u16 = vaddw_u8(vreinterpretq_u16_s16(a0), d0);
54 d1_u16 = vaddw_u8(vreinterpretq_u16_s16(a1), d1);
55 d2_u16 = vaddw_u8(vreinterpretq_u16_s16(a2), d2);
56 d3_u16 = vaddw_u8(vreinterpretq_u16_s16(a3), d3);
57 d4_u16 = vaddw_u8(vreinterpretq_u16_s16(a4), d4);
58 d5_u16 = vaddw_u8(vreinterpretq_u16_s16(a5), d5);
59 d6_u16 = vaddw_u8(vreinterpretq_u16_s16(a6), d6);
60 d7_u16 = vaddw_u8(vreinterpretq_u16_s16(a7), d7);
61
62 d0 = vqmovun_s16(vreinterpretq_s16_u16(d0_u16));
63 d1 = vqmovun_s16(vreinterpretq_s16_u16(d1_u16));
64 d2 = vqmovun_s16(vreinterpretq_s16_u16(d2_u16));
65 d3 = vqmovun_s16(vreinterpretq_s16_u16(d3_u16));
66 d4 = vqmovun_s16(vreinterpretq_s16_u16(d4_u16));
67 d5 = vqmovun_s16(vreinterpretq_s16_u16(d5_u16));
68 d6 = vqmovun_s16(vreinterpretq_s16_u16(d6_u16));
69 d7 = vqmovun_s16(vreinterpretq_s16_u16(d7_u16));
70
71 vst1_u8(dest, d0);
72 dest += stride;
73 vst1_u8(dest, d1);
74 dest += stride;
75 vst1_u8(dest, d2);
76 dest += stride;
77 vst1_u8(dest, d3);
78 dest += stride;
79 vst1_u8(dest, d4);
80 dest += stride;
81 vst1_u8(dest, d5);
82 dest += stride;
83 vst1_u8(dest, d6);
84 dest += stride;
85 vst1_u8(dest, d7);
86 }
87
vpx_idct8x8_64_add_neon(const tran_low_t * input,uint8_t * dest,int stride)88 void vpx_idct8x8_64_add_neon(const tran_low_t *input, uint8_t *dest,
89 int stride) {
90 const int16x8_t cospis = vld1q_s16(kCospi);
91 const int16x4_t cospis0 = vget_low_s16(cospis); // cospi 0, 8, 16, 24
92 const int16x4_t cospis1 = vget_high_s16(cospis); // cospi 4, 12, 20, 28
93 int16x8_t a0 = load_tran_low_to_s16q(input);
94 int16x8_t a1 = load_tran_low_to_s16q(input + 8);
95 int16x8_t a2 = load_tran_low_to_s16q(input + 16);
96 int16x8_t a3 = load_tran_low_to_s16q(input + 24);
97 int16x8_t a4 = load_tran_low_to_s16q(input + 32);
98 int16x8_t a5 = load_tran_low_to_s16q(input + 40);
99 int16x8_t a6 = load_tran_low_to_s16q(input + 48);
100 int16x8_t a7 = load_tran_low_to_s16q(input + 56);
101
102 idct8x8_64_1d_bd8(cospis0, cospis1, &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
103 idct8x8_64_1d_bd8(cospis0, cospis1, &a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
104 add8x8(a0, a1, a2, a3, a4, a5, a6, a7, dest, stride);
105 }
106
vpx_idct8x8_12_add_neon(const tran_low_t * input,uint8_t * dest,int stride)107 void vpx_idct8x8_12_add_neon(const tran_low_t *input, uint8_t *dest,
108 int stride) {
109 const int16x8_t cospis = vld1q_s16(kCospi);
110 const int16x8_t cospisd = vaddq_s16(cospis, cospis);
111 const int16x4_t cospis0 = vget_low_s16(cospis); // cospi 0, 8, 16, 24
112 const int16x4_t cospisd0 = vget_low_s16(cospisd); // doubled 0, 8, 16, 24
113 const int16x4_t cospisd1 = vget_high_s16(cospisd); // doubled 4, 12, 20, 28
114 int16x4_t a0, a1, a2, a3, a4, a5, a6, a7;
115 int16x8_t b0, b1, b2, b3, b4, b5, b6, b7;
116
117 a0 = load_tran_low_to_s16d(input);
118 a1 = load_tran_low_to_s16d(input + 8);
119 a2 = load_tran_low_to_s16d(input + 16);
120 a3 = load_tran_low_to_s16d(input + 24);
121
122 idct8x8_12_pass1_bd8(cospis0, cospisd0, cospisd1, &a0, &a1, &a2, &a3, &a4,
123 &a5, &a6, &a7);
124 idct8x8_12_pass2_bd8(cospis0, cospisd0, cospisd1, a0, a1, a2, a3, a4, a5, a6,
125 a7, &b0, &b1, &b2, &b3, &b4, &b5, &b6, &b7);
126 add8x8(b0, b1, b2, b3, b4, b5, b6, b7, dest, stride);
127 }
128