Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qimagescale_p.h"
41#include "qimage.h"
42#include <private/qsimd_p.h>
43
44#if defined(__ARM_NEON__)
45
46QT_BEGIN_NAMESPACE
47
48using namespace QImageScale;
49
50inline static uint32x4_t qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step)
51{
52 uint32x2_t vpix32 = vmov_n_u32(*pix);
53 uint16x4_t vpix16 = vget_low_u16(vmovl_u8(vreinterpret_u8_u32(vpix32)));
54 uint32x4_t vx = vmull_n_u16(vpix16, xyap);
55 int i;
56 for (i = (1 << 14) - xyap; i > Cxy; i -= Cxy) {
57 pix += step;
58 vpix32 = vmov_n_u32(*pix);
59 vpix16 = vget_low_u16(vmovl_u8(vreinterpret_u8_u32(vpix32)));
60 vx = vaddq_u32(vx, vmull_n_u16(vpix16, Cxy));
61 }
62 pix += step;
63 vpix32 = vmov_n_u32(*pix);
64 vpix16 = vget_low_u16(vmovl_u8(vreinterpret_u8_u32(vpix32)));
65 vx = vaddq_u32(vx, vmull_n_u16(vpix16, i));
66 return vx;
67}
68
69template<bool RGB>
70void qt_qimageScaleAARGBA_up_x_down_y_neon(QImageScaleInfo *isi, unsigned int *dest,
71 int dw, int dh, int dow, int sow)
72{
73 const unsigned int **ypoints = isi->ypoints;
74 int *xpoints = isi->xpoints;
75 int *xapoints = isi->xapoints;
76 int *yapoints = isi->yapoints;
77
78 /* go through every scanline in the output buffer */
79 for (int y = 0; y < dh; y++) {
80 int Cy = yapoints[y] >> 16;
81 int yap = yapoints[y] & 0xffff;
82
83 unsigned int *dptr = dest + (y * dow);
84 for (int x = 0; x < dw; x++) {
85 const unsigned int *sptr = ypoints[y] + xpoints[x];
86 uint32x4_t vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow);
87
88 int xap = xapoints[x];
89 if (xap > 0) {
90 uint32x4_t vr = qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow);
91
92 vx = vmulq_n_u32(vx, 256 - xap);
93 vr = vmulq_n_u32(vr, xap);
94 vx = vaddq_u32(vx, vr);
95 vx = vshrq_n_u32(vx, 8);
96 }
97 vx = vshrq_n_u32(vx, 14);
98 const uint16x4_t vx16 = vmovn_u32(vx);
99 const uint8x8_t vx8 = vmovn_u16(vcombine_u16(vx16, vx16));
100 *dptr = vget_lane_u32(vreinterpret_u32_u8(vx8), 0);
101 if (RGB)
102 *dptr |= 0xff000000;
103 dptr++;
104 }
105 }
106}
107
108template<bool RGB>
109void qt_qimageScaleAARGBA_down_x_up_y_neon(QImageScaleInfo *isi, unsigned int *dest,
110 int dw, int dh, int dow, int sow)
111{
112 const unsigned int **ypoints = isi->ypoints;
113 int *xpoints = isi->xpoints;
114 int *xapoints = isi->xapoints;
115 int *yapoints = isi->yapoints;
116
117 /* go through every scanline in the output buffer */
118 for (int y = 0; y < dh; y++) {
119 unsigned int *dptr = dest + (y * dow);
120 for (int x = 0; x < dw; x++) {
121 int Cx = xapoints[x] >> 16;
122 int xap = xapoints[x] & 0xffff;
123
124 const unsigned int *sptr = ypoints[y] + xpoints[x];
125 uint32x4_t vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1);
126
127 int yap = yapoints[y];
128 if (yap > 0) {
129 uint32x4_t vr = qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1);
130
131 vx = vmulq_n_u32(vx, 256 - yap);
132 vr = vmulq_n_u32(vr, yap);
133 vx = vaddq_u32(vx, vr);
134 vx = vshrq_n_u32(vx, 8);
135 }
136 vx = vshrq_n_u32(vx, 14);
137 const uint16x4_t vx16 = vmovn_u32(vx);
138 const uint8x8_t vx8 = vmovn_u16(vcombine_u16(vx16, vx16));
139 *dptr = vget_lane_u32(vreinterpret_u32_u8(vx8), 0);
140 if (RGB)
141 *dptr |= 0xff000000;
142 dptr++;
143 }
144 }
145}
146
147template<bool RGB>
148void qt_qimageScaleAARGBA_down_xy_neon(QImageScaleInfo *isi, unsigned int *dest,
149 int dw, int dh, int dow, int sow)
150{
151 const unsigned int **ypoints = isi->ypoints;
152 int *xpoints = isi->xpoints;
153 int *xapoints = isi->xapoints;
154 int *yapoints = isi->yapoints;
155
156 for (int y = 0; y < dh; y++) {
157 int Cy = yapoints[y] >> 16;
158 int yap = yapoints[y] & 0xffff;
159
160 unsigned int *dptr = dest + (y * dow);
161 for (int x = 0; x < dw; x++) {
162 const int Cx = xapoints[x] >> 16;
163 const int xap = xapoints[x] & 0xffff;
164
165 const unsigned int *sptr = ypoints[y] + xpoints[x];
166 uint32x4_t vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1);
167 vx = vshrq_n_u32(vx, 4);
168 uint32x4_t vr = vmulq_n_u32(vx, yap);
169
170 int j;
171 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
172 sptr += sow;
173 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1);
174 vx = vshrq_n_u32(vx, 4);
175 vx = vmulq_n_u32(vx, Cy);
176 vr = vaddq_u32(vr, vx);
177 }
178 sptr += sow;
179 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1);
180 vx = vshrq_n_u32(vx, 4);
181 vx = vmulq_n_u32(vx, j);
182 vr = vaddq_u32(vr, vx);
183
184 vx = vshrq_n_u32(vr, 24);
185 const uint16x4_t vx16 = vmovn_u32(vx);
186 const uint8x8_t vx8 = vmovn_u16(vcombine_u16(vx16, vx16));
187 *dptr = vget_lane_u32(vreinterpret_u32_u8(vx8), 0);
188 if (RGB)
189 *dptr |= 0xff000000;
190 dptr++;
191 }
192 }
193}
194
195template void qt_qimageScaleAARGBA_up_x_down_y_neon<false>(QImageScaleInfo *isi, unsigned int *dest,
196 int dw, int dh, int dow, int sow);
197
198template void qt_qimageScaleAARGBA_up_x_down_y_neon<true>(QImageScaleInfo *isi, unsigned int *dest,
199 int dw, int dh, int dow, int sow);
200
201template void qt_qimageScaleAARGBA_down_x_up_y_neon<false>(QImageScaleInfo *isi, unsigned int *dest,
202 int dw, int dh, int dow, int sow);
203
204template void qt_qimageScaleAARGBA_down_x_up_y_neon<true>(QImageScaleInfo *isi, unsigned int *dest,
205 int dw, int dh, int dow, int sow);
206
207template void qt_qimageScaleAARGBA_down_xy_neon<false>(QImageScaleInfo *isi, unsigned int *dest,
208 int dw, int dh, int dow, int sow);
209
210template void qt_qimageScaleAARGBA_down_xy_neon<true>(QImageScaleInfo *isi, unsigned int *dest,
211 int dw, int dh, int dow, int sow);
212
213QT_END_NAMESPACE
214
215#endif
216

Warning: That file was not part of the compilation database. It may have many parsing errors.