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) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qimagescale_p.h"-
35#include "qimage.h"-
36#include <private/qsimd_p.h>-
37-
38#if defined(QT_COMPILER_SUPPORTS_SSE4_1)-
39-
40QT_BEGIN_NAMESPACE-
41-
42using namespace QImageScale;-
43-
44inline static __m128i qt_qimageScaleAARGBA_helper(const unsigned int *pix, int xyap, int Cxy, int step, const __m128i vxyap, const __m128i vCxy)-
45{-
46 __m128i vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
47 __m128i vx = _mm_mullo_epi32(vpix, vxyap);-
48 int i;-
49 for (i = (1 << 14) - xyap; i > Cxy; i -= Cxy) {
i > CxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
50 pix += step;-
51 vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
52 vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, vCxy));-
53 }
never executed: end of block
0
54 pix += step;-
55 vpix = _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*pix));-
56 vx = _mm_add_epi32(vx, _mm_mullo_epi32(vpix, _mm_set1_epi32(i)));-
57 return vx;
never executed: return vx;
0
58}-
59-
60template<bool RGB>-
61void qt_qimageScaleAARGBA_up_x_down_y_sse4(QImageScaleInfo *isi, unsigned int *dest,-
62 int dw, int dh, int dow, int sow)-
63{-
64 const unsigned int **ypoints = isi->ypoints;-
65 int *xpoints = isi->xpoints;-
66 int *xapoints = isi->xapoints;-
67 int *yapoints = isi->yapoints;-
68-
69 const __m128i v256 = _mm_set1_epi32(256);-
70-
71 /* go through every scanline in the output buffer */-
72 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
73 int Cy = yapoints[y] >> 16;-
74 int yap = yapoints[y] & 0xffff;-
75 const __m128i vCy = _mm_set1_epi32(Cy);-
76 const __m128i vyap = _mm_set1_epi32(yap);-
77-
78 unsigned int *dptr = dest + (y * dow);-
79 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
80 const unsigned int *sptr = ypoints[y] + xpoints[x];-
81 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, yap, Cy, sow, vyap, vCy);-
82-
83 int xap = xapoints[x];-
84 if (xap > 0) {
xap > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
85 const __m128i vxap = _mm_set1_epi32(xap);-
86 const __m128i vinvxap = _mm_sub_epi32(v256, vxap);-
87 __m128i vr = qt_qimageScaleAARGBA_helper(sptr + 1, yap, Cy, sow, vyap, vCy);-
88-
89 vx = _mm_mullo_epi32(vx, vinvxap);-
90 vr = _mm_mullo_epi32(vr, vxap);-
91 vx = _mm_add_epi32(vx, vr);-
92 vx = _mm_srli_epi32(vx, 8);-
93 }
never executed: end of block
0
94 vx = _mm_srli_epi32(vx, 14);-
95 vx = _mm_packus_epi32(vx, _mm_setzero_si128());-
96 vx = _mm_packus_epi16(vx, _mm_setzero_si128());-
97 *dptr = _mm_cvtsi128_si32(vx);-
98 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
99 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
100 dptr++;-
101 }
never executed: end of block
0
102 }
never executed: end of block
0
103}
never executed: end of block
0
104-
105template<bool RGB>-
106void qt_qimageScaleAARGBA_down_x_up_y_sse4(QImageScaleInfo *isi, unsigned int *dest,-
107 int dw, int dh, int dow, int sow)-
108{-
109 const unsigned int **ypoints = isi->ypoints;-
110 int *xpoints = isi->xpoints;-
111 int *xapoints = isi->xapoints;-
112 int *yapoints = isi->yapoints;-
113-
114 const __m128i v256 = _mm_set1_epi32(256);-
115-
116 /* go through every scanline in the output buffer */-
117 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
118 unsigned int *dptr = dest + (y * dow);-
119 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
120 int Cx = xapoints[x] >> 16;-
121 int xap = xapoints[x] & 0xffff;-
122 const __m128i vCx = _mm_set1_epi32(Cx);-
123 const __m128i vxap = _mm_set1_epi32(xap);-
124-
125 const unsigned int *sptr = ypoints[y] + xpoints[x];-
126 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
127-
128 int yap = yapoints[y];-
129 if (yap > 0) {
yap > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
130 const __m128i vyap = _mm_set1_epi32(yap);-
131 const __m128i vinvyap = _mm_sub_epi32(v256, vyap);-
132 __m128i vr = qt_qimageScaleAARGBA_helper(sptr + sow, xap, Cx, 1, vxap, vCx);-
133-
134 vx = _mm_mullo_epi32(vx, vinvyap);-
135 vr = _mm_mullo_epi32(vr, vyap);-
136 vx = _mm_add_epi32(vx, vr);-
137 vx = _mm_srli_epi32(vx, 8);-
138 }
never executed: end of block
0
139 vx = _mm_srli_epi32(vx, 14);-
140 vx = _mm_packus_epi32(vx, _mm_setzero_si128());-
141 vx = _mm_packus_epi16(vx, _mm_setzero_si128());-
142 *dptr = _mm_cvtsi128_si32(vx);-
143 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
144 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
145 dptr++;-
146 }
never executed: end of block
0
147 }
never executed: end of block
0
148}
never executed: end of block
0
149-
150template<bool RGB>-
151void qt_qimageScaleAARGBA_down_xy_sse4(QImageScaleInfo *isi, unsigned int *dest,-
152 int dw, int dh, int dow, int sow)-
153{-
154 const unsigned int **ypoints = isi->ypoints;-
155 int *xpoints = isi->xpoints;-
156 int *xapoints = isi->xapoints;-
157 int *yapoints = isi->yapoints;-
158-
159 for (int y = 0; y < dh; y++) {
y < dhDescription
TRUEnever evaluated
FALSEnever evaluated
0
160 int Cy = yapoints[y] >> 16;-
161 int yap = yapoints[y] & 0xffff;-
162 const __m128i vCy = _mm_set1_epi32(Cy);-
163 const __m128i vyap = _mm_set1_epi32(yap);-
164-
165 unsigned int *dptr = dest + (y * dow);-
166 for (int x = 0; x < dw; x++) {
x < dwDescription
TRUEnever evaluated
FALSEnever evaluated
0
167 const int Cx = xapoints[x] >> 16;-
168 const int xap = xapoints[x] & 0xffff;-
169 const __m128i vCx = _mm_set1_epi32(Cx);-
170 const __m128i vxap = _mm_set1_epi32(xap);-
171-
172 const unsigned int *sptr = ypoints[y] + xpoints[x];-
173 __m128i vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
174 __m128i vr = _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vyap);-
175-
176 int j;-
177 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
j > CyDescription
TRUEnever evaluated
FALSEnever evaluated
0
178 sptr += sow;-
179 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
180 vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), vCy));-
181 }
never executed: end of block
0
182 sptr += sow;-
183 vx = qt_qimageScaleAARGBA_helper(sptr, xap, Cx, 1, vxap, vCx);-
184 vr = _mm_add_epi32(vr, _mm_mullo_epi32(_mm_srli_epi32(vx, 4), _mm_set1_epi32(j)));-
185-
186 vr = _mm_srli_epi32(vr, 24);-
187 vr = _mm_packus_epi32(vr, _mm_setzero_si128());-
188 vr = _mm_packus_epi16(vr, _mm_setzero_si128());-
189 *dptr = _mm_cvtsi128_si32(vr);-
190 if (RGB)
RGBDescription
TRUEnever evaluated
FALSEnever evaluated
0
191 *dptr |= 0xff000000;
never executed: *dptr |= 0xff000000;
0
192 dptr++;-
193 }
never executed: end of block
0
194 }
never executed: end of block
0
195}
never executed: end of block
0
196-
197template void qt_qimageScaleAARGBA_up_x_down_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
198 int dw, int dh, int dow, int sow);-
199-
200template void qt_qimageScaleAARGBA_up_x_down_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
201 int dw, int dh, int dow, int sow);-
202-
203template void qt_qimageScaleAARGBA_down_x_up_y_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
204 int dw, int dh, int dow, int sow);-
205-
206template void qt_qimageScaleAARGBA_down_x_up_y_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
207 int dw, int dh, int dow, int sow);-
208-
209template void qt_qimageScaleAARGBA_down_xy_sse4<false>(QImageScaleInfo *isi, unsigned int *dest,-
210 int dw, int dh, int dow, int sow);-
211-
212template void qt_qimageScaleAARGBA_down_xy_sse4<true>(QImageScaleInfo *isi, unsigned int *dest,-
213 int dw, int dh, int dow, int sow);-
214-
215QT_END_NAMESPACE-
216-
217#endif-
Source codeSwitch to Preprocessed file

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