Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qimage_neon.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <qimage.h>
5#include <private/qimage_p.h>
6#include <private/qsimd_p.h>
7
8#if defined(__ARM_NEON__)
9
11
12Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len)
13{
14 if (!len)
15 return;
16
17 const quint32 *const end = dst + len;
18
19 // align dst on 128 bits
20 const int offsetToAlignOn16Bytes = (reinterpret_cast<quintptr>(dst) >> 2) & 0x3;
21 for (int i = 0; i < qMin(len, offsetToAlignOn16Bytes); ++i) {
22 *dst++ = qRgb(src[0], src[1], src[2]);
23 src += 3;
24 }
25
26 if ((len - offsetToAlignOn16Bytes) >= 16) {
27 const quint32 *const simdEnd = end - 15;
28 uint8x16x4_t dstVector;
29#if Q_BYTE_ORDER == Q_BIG_ENDIAN
30 dstVector.val[0] = vdupq_n_u8(0xff);
31#else
32 dstVector.val[3] = vdupq_n_u8(0xff);
33#endif
34 do {
35 uint8x16x3_t srcVector = vld3q_u8(src);
36 src += 3 * 16;
37#if Q_BYTE_ORDER == Q_BIG_ENDIAN
38 dstVector.val[1] = srcVector.val[0];
39 dstVector.val[2] = srcVector.val[1];
40 dstVector.val[3] = srcVector.val[2];
41#else
42 dstVector.val[0] = srcVector.val[2];
43 dstVector.val[1] = srcVector.val[1];
44 dstVector.val[2] = srcVector.val[0];
45#endif
46 vst4q_u8(reinterpret_cast<uint8_t*>(dst), dstVector);
47 dst += 16;
48 } while (dst < simdEnd);
49 }
50
51 int i = 0;
52 int length = end - dst;
53 SIMD_EPILOGUE(i, length, 15) {
54 *dst++ = qRgb(src[0], src[1], src[2]);
55 src += 3;
56 }
57}
58
59void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
60{
63 Q_ASSERT(src->width == dest->width);
64 Q_ASSERT(src->height == dest->height);
65
66 const uchar *src_data = (uchar *) src->data;
67 quint32 *dest_data = (quint32 *) dest->data;
68
69 for (int i = 0; i < src->height; ++i) {
70 qt_convert_rgb888_to_rgb32_neon(dest_data, src_data, src->width);
71 src_data += src->bytes_per_line;
72 dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line);
73 }
74}
75
77
78#endif // defined(__ARM_NEON__)
@ Format_RGB888
Definition qimage.h:55
@ Format_RGB32
Definition qimage.h:46
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_ARGB32
Definition qimage.h:47
Combined button and popup list for selecting options.
#define QT_FASTCALL
Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLenum src
GLenum GLenum dst
GLenum GLsizei len
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
constexpr QRgb qRgb(int r, int g, int b)
Definition qrgb.h:30
#define SIMD_EPILOGUE(i, length, max)
Definition qsimd_p.h:33
unsigned int quint32
Definition qtypes.h:50
unsigned char uchar
Definition qtypes.h:32
size_t quintptr
Definition qtypes.h:167
int height
Definition qimage_p.h:43
int width
Definition qimage_p.h:42
QImage::Format format
Definition qimage_p.h:49