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
qvideoframeconversionhelper_ssse3.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
5
6#ifdef QT_COMPILER_SUPPORTS_SSSE3
7
9
10namespace {
11
12template<int a, int r, int g, int b>
13void convert_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
14{
17 quint32 *argb = reinterpret_cast<quint32*>(output);
18
19#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
20 __m128i shuffleMask = _mm_set_epi8(12 + a, 12 + r, 12 + g, 12 + b,
21 8 + a, 8 + r, 8 + g, 8 + b,
22 4 + a, 4 + r, 4 + g, 4 + b,
23 0 + a, 0 + r, 0 + g, 0 + b);
24#else
25 __m128i shuffleMask = _mm_set_epi8(15 - a, 15 - r, 15 - g, 15 - b,
26 11 - a, 11 - r, 11 - g, 11 - b,
27 7 - a, 7 - r, 7 - g, 7 - b,
28 3 - a, 3 - r, 3 - g, 3 - b);
29#endif
30
31 using Pixel = const ArgbPixel<a, r, g, b>;
32
33 for (int y = 0; y < height; ++y) {
34 const auto *pixel = reinterpret_cast<const Pixel *>(src);
35
36 int x = 0;
37 QT_MEDIA_ALIGN(16, argb, x, width) {
38 *argb = pixel->convert();
39 ++pixel;
40 ++argb;
41 }
42
43 for (; x < width - 7; x += 8) {
44 __m128i pixelData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pixel));
45 __m128i pixelData2 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pixel + 4));
46 pixel += 8;
47 pixelData = _mm_shuffle_epi8(pixelData, shuffleMask);
48 pixelData2 = _mm_shuffle_epi8(pixelData2, shuffleMask);
49 _mm_store_si128(reinterpret_cast<__m128i*>(argb), pixelData);
50 _mm_store_si128(reinterpret_cast<__m128i*>(argb + 4), pixelData2);
51 argb += 8;
52 }
53
54 // leftovers
55 for (; x < width; ++x) {
56 *argb = pixel->convert();
57 ++pixel;
58 ++argb;
59 }
60
61 src += stride;
62 }
63}
64
65}
66
67void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
68{
69 convert_to_ARGB32_ssse3<0, 1, 2, 3>(frame, output);
70}
71
72void QT_FASTCALL qt_convert_ABGR8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
73{
74 convert_to_ARGB32_ssse3<0, 3, 2, 1>(frame, output);
75}
76
77void QT_FASTCALL qt_convert_RGBA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
78{
79 convert_to_ARGB32_ssse3<3, 0, 1, 2>(frame, output);
80}
81
82void QT_FASTCALL qt_convert_BGRA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
83{
84 convert_to_ARGB32_ssse3<3, 2, 1, 0>(frame, output);
85}
86
88
89#endif
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
Combined button and popup list for selecting options.
#define QT_FASTCALL
GLboolean GLboolean GLboolean b
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean GLboolean a
[7]
GLboolean r
[2]
GLenum src
const void GLsizei GLsizei stride
GLint GLsizei width
GLboolean GLboolean g
GLint y
unsigned int quint32
Definition qtypes.h:50
unsigned char uchar
Definition qtypes.h:32
#define MERGE_LOOPS(width, height, stride, bpp)
#define FETCH_INFO_PACKED(frame)
QT_BEGIN_NAMESPACE typedef uchar * output
#define QT_MEDIA_ALIGN(boundary, ptr, x, length)
QFrame frame
[0]