qimagescale_sse4.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qimagescale_sse4.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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(QT_COMPILER_SUPPORTS_SSE4_1)-
45-
46QT_BEGIN_NAMESPACE-
47-
48using namespace QImageScale;-
49-
50inline static __m128i qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, const __m128i vxyap, const __m128i vCxy)-
51{-
52 __m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
53 __m128i vx = _mm_mullo_epi32(vpix, vxyap);-
54 int i;-
55 for (i = (1 << 14) - xyap; i > Cxy; i -= Cxy) {
i > CxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
56 pix += step;-
57 vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
58 vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCxy));-
59 }
never executed: end of block
0
60 pix += step;-
61 vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
62 vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));-
63 return vx;
never executed: return vx;
0
64}-
65-
66template<bool RGB>-
67void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest,-
68 int dw, int dh, int dow, int sow)-
69{-
70 const unsigned int **ypoints = isi->ypoints;-
71 int *xpoints = isi->xpoints;-
72 int *xapoints = isi->xapoints;-
73 int *yapoints = isi->yapoints;-
74-
75 const __m128i v256 = _mm_set1_epi32(256);-
76-
77 /* go through every scanline in the output buffer */-
78 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
79 int Cy = yapoints[y] >> 16;-
80 int yap = yapoints[y] & 0xffff;-
81 const __m128i vCy = _mm_set1_epi32(Cy);-
82 const __m128i vyap = _mm_set1_epi32(yap);-
83-
84 unsigned int *dptr = dest + (y * dow);-
85 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
86 const unsigned int *sptr = ypoints[y] + xpoints[x];-
87 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, vyap, vCy);-
88-
89 int xap = xapoints[x];-
90 if (xap > 0) {
xap > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
91 const __m128i vxap = _mm_set1_epi32(xap);-
92 const __m128i vinvxap = _mm_sub_epi32(v256, vxap);-
93 __m128i vr = qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, vyap, vCy);-
94-
95 vx = _mm_mullo_epi32(vx, vinvxap);-
96 vr = _mm_mullo_epi32(vr, vxap);-
97 vx = _mm_add_epi32(vx, vr);-
98 vx = _mm_srli_epi32(vx, 8);-
99 }
never executed: end of block
0
100 vx = _mm_srli_epi32(vx, 14);-
101 vx = _mm_packus_epi32(vx, _mm_setzero_si128());-
102 vx = _mm_packus_epi16(vx, _mm_setzero_si128());-
103 *dptr = _mm_cvtsi128_si32(vx);-
104 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
105 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
106 dptr++;-
107 }
never executed: end of block
0
108 }
never executed: end of block
0
109}
never executed: end of block
0
110-
111template<bool RGB>-
112void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *dest,-
113 int dw, int dh, int dow, int sow)-
114{-
115 const unsigned int **ypoints = isi->ypoints;-
116 int *xpoints = isi->xpoints;-
117 int *xapoints = isi->xapoints;-
118 int *yapoints = isi->yapoints;-
119-
120 const __m128i v256 = _mm_set1_epi32(256);-
121-
122 /* go through every scanline in the output buffer */-
123 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
124 unsigned int *dptr = dest + (y * dow);-
125 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
126 int Cx = xapoints[x] >> 16;-
127 int xap = xapoints[x] & 0xffff;-
128 const __m128i vCx = _mm_set1_epi32(Cx);-
129 const __m128i vxap = _mm_set1_epi32(xap);-
130-
131 const unsigned int *sptr = ypoints[y] + xpoints[x];-
132 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
133-
134 int yap = yapoints[y];-
135 if (yap > 0) {
yap > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
136 const __m128i vyap = _mm_set1_epi32(yap);-
137 const __m128i vinvyap = _mm_sub_epi32(v256, vyap);-
138 __m128i vr = qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, vxap, vCx);-
139-
140 vx = _mm_mullo_epi32(vx, vinvyap);-
141 vr = _mm_mullo_epi32(vr, vyap);-
142 vx = _mm_add_epi32(vx, vr);-
143 vx = _mm_srli_epi32(vx, 8);-
144 }
never executed: end of block
0
145 vx = _mm_srli_epi32(vx, 14);-
146 vx = _mm_packus_epi32(vx, _mm_setzero_si128());-
147 vx = _mm_packus_epi16(vx, _mm_setzero_si128());-
148 *dptr = _mm_cvtsi128_si32(vx);-
149 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
151 dptr++;-
152 }
never executed: end of block
0
153 }
never executed: end of block
0
154}
never executed: end of block
0
155-
156template<bool RGB>-
157void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,-
158 int dw, int dh, int dow, int sow)-
159{-
160 const unsigned int **ypoints = isi->ypoints;-
161 int *xpoints = isi->xpoints;-
162 int *xapoints = isi->xapoints;-
163 int *yapoints = isi->yapoints;-
164-
165 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
166 int Cy = yapoints[y] >> 16;-
167 int yap = yapoints[y] & 0xffff;-
168 const __m128i vCy = _mm_set1_epi32(Cy);-
169 const __m128i vyap = _mm_set1_epi32(yap);-
170-
171 unsigned int *dptr = dest + (y * dow);-
172 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
173 const int Cx = xapoints[x] >> 16;-
174 const int xap = xapoints[x] & 0xffff;-
175 const __m128i vCx = _mm_set1_epi32(Cx);-
176 const __m128i vxap = _mm_set1_epi32(xap);-
177-
178 const unsigned int *sptr = ypoints[y] + xpoints[x];-
179 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
180 __m128i vr = _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vyap);-
181-
182 int j;-
183 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
j > CyDescription
TRUEnever evaluated
FALSEnever evaluated
0
184 sptr += sow;-
185 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
186 vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vCy));-
187 }
never executed: end of block
0
188 sptr += sow;-
189 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
190 vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), _mm_set1_epi32(j)));-
191-
192 vr = _mm_srli_epi32(vr, 24);-
193 vr = _mm_packus_epi32(vr, _mm_setzero_si128());-
194 vr = _mm_packus_epi16(vr, _mm_setzero_si128());-
195 *dptr = _mm_cvtsi128_si32(vr);-
196 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
197 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
198 dptr++;-
199 }
never executed: end of block
0
200 }
never executed: end of block
0
201}
never executed: end of block
0
202-
203template void qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
204 int dw, int dh, int dow, int sow);-
205-
206template void qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
207 int dw, int dh, int dow, int sow);-
208-
209template void qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
210 int dw, int dh, int dow, int sow);-
211-
212template void qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
213 int dw, int dh, int dow, int sow);-
214-
215template void qt_qimageScaleAARGBA_down_xy_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
216 int dw, int dh, int dow, int sow);-
217-
218template void qt_qimageScaleAARGBA_down_xy_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
219 int dw, int dh, int dow, int sow);-
220-
221QT_END_NAMESPACE-
222-
223#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9