Qt 4.8
qimage_neon.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <qimage.h>
43 #include <private/qimage_p.h>
44 #include <private/qsimd_p.h>
45 
46 #ifdef QT_HAVE_NEON
47 
49 
50 Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len)
51 {
52  if (!len)
53  return;
54 
55  const quint32 *const end = dst + len;
56 
57  // align dst on 64 bits
58  const int offsetToAlignOn8Bytes = (reinterpret_cast<quintptr>(dst) >> 2) & 0x1;
59  for (int i = 0; i < offsetToAlignOn8Bytes; ++i) {
60  *dst++ = qRgb(src[0], src[1], src[2]);
61  src += 3;
62  }
63 
64  if ((len - offsetToAlignOn8Bytes) >= 8) {
65  const quint32 *const simdEnd = end - 7;
66  register uint8x8_t fullVector asm ("d3") = vdup_n_u8(0xff);
67  do {
68 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
69  asm volatile (
70  "vld3.8 { d4, d5, d6 }, [%[SRC]] !\n\t"
71  "vst4.8 { d3, d4, d5, d6 }, [%[DST],:64] !\n\t"
72  : [DST]"+r" (dst), [SRC]"+r" (src)
73  : "w"(fullVector)
74  : "memory", "d4", "d5", "d6"
75  );
76 #else
77  asm volatile (
78  "vld3.8 { d0, d1, d2 }, [%[SRC]] !\n\t"
79  "vswp d0, d2\n\t"
80  "vst4.8 { d0, d1, d2, d3 }, [%[DST],:64] !\n\t"
81  : [DST]"+r" (dst), [SRC]"+r" (src)
82  : "w"(fullVector)
83  : "memory", "d0", "d1", "d2"
84  );
85 #endif
86  } while (dst < simdEnd);
87  }
88 
89  while (dst != end) {
90  *dst++ = qRgb(src[0], src[1], src[2]);
91  src += 3;
92  }
93 }
94 
95 void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
96 {
99  Q_ASSERT(src->width == dest->width);
100  Q_ASSERT(src->height == dest->height);
101 
102  const uchar *src_data = (uchar *) src->data;
103  quint32 *dest_data = (quint32 *) dest->data;
104 
105  for (int i = 0; i < src->height; ++i) {
106  qt_convert_rgb888_to_rgb32_neon(dest_data, src_data, src->width);
107  src_data += src->bytes_per_line;
108  dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line);
109  }
110 }
111 
113 
114 #endif // QT_HAVE_NEON
int width
Definition: qimage_p.h:76
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define QT_FASTCALL
Definition: qglobal.h:1161
unsigned char uchar
Definition: qglobal.h:994
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int height
Definition: qimage_p.h:77
int bytes_per_line
Definition: qimage_p.h:86
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69
QImage::Format format
Definition: qimage_p.h:85
unsigned int quint32
Definition: qglobal.h:938
uchar * data
Definition: qimage_p.h:81
static const KeyPair *const end