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_p.h
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#ifndef QVIDEOFRAMECONVERSIONHELPER_P_H
5#define QVIDEOFRAMECONVERSIONHELPER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qvideoframe.h>
19#include <private/qsimd_p.h>
20
22
23// Converts to RGB32 or ARGB32_Premultiplied
24typedef void (QT_FASTCALL *VideoFrameConvertFunc)(const QVideoFrame &frame, uchar *output);
25typedef void(QT_FASTCALL *PixelsCopyFunc)(uint32_t *dst, const uint32_t *src, size_t size, uint32_t mask);
26
28
29void Q_MULTIMEDIA_EXPORT qCopyPixelsWithAlphaMask(uint32_t *dst,
30 const uint32_t *src,
31 size_t size,
33 bool srcAlphaVaries);
34
35void Q_MULTIMEDIA_EXPORT qCopyPixelsWithMask(uint32_t *dst, const uint32_t *src, size_t size, uint32_t mask);
36
37uint32_t Q_MULTIMEDIA_EXPORT qAlphaMask(QVideoFrameFormat::PixelFormat format);
38
39template<int a, int r, int g, int b>
41{
43 inline quint32 convert() const
44 {
45#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
46 return (((data >> (8*a)) & 0xff) << 24)
47 | (((data >> (8*r)) & 0xff) << 16)
48 | (((data >> (8*g)) & 0xff) << 8)
49 | ((data >> (8*b)) & 0xff);
50#else
51 return (((data >> (32-8*a)) & 0xff) << 24)
52 | (((data >> (32-8*r)) & 0xff) << 16)
53 | (((data >> (32-8*g)) & 0xff) << 8)
54 | ((data >> (32-8*b)) & 0xff);
55#endif
56 }
57};
58
59template<int r, int g, int b>
61{
63 inline quint32 convert() const
64 {
65#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
66 return 0xff000000
67 | (((data >> (8*r)) & 0xff) << 16)
68 | (((data >> (8*g)) & 0xff) << 8)
69 | ((data >> (8*b)) & 0xff);
70#else
71 return 0xff000000
72 | (((data >> (32-8*r)) & 0xff) << 16)
73 | (((data >> (32-8*g)) & 0xff) << 8)
74 | ((data >> (32-8*b)) & 0xff);
75#endif
76 }
77};
78
79template<typename Y>
80struct YPixel
81{
83 static constexpr uint shift = (sizeof(Y) - 1)*8;
84 inline quint32 convert() const
85 {
86 uint y = (data >> shift) & 0xff;
87 return (0xff000000)
88 | (y << 16)
89 | (y << 8)
90 | (y);
91 }
92
93};
94
95
96using ARGB8888 = ArgbPixel<0, 1, 2, 3>;
97using ABGR8888 = ArgbPixel<0, 3, 2, 1>;
98using RGBA8888 = ArgbPixel<3, 0, 1, 2>;
99using BGRA8888 = ArgbPixel<3, 2, 1, 0>;
100using XRGB8888 = RgbPixel<1, 2, 3>;
101using XBGR8888 = RgbPixel<3, 2, 1>;
102using RGBX8888 = RgbPixel<0, 1, 2>;
103using BGRX8888 = RgbPixel<2, 1, 0>;
104
105#define FETCH_INFO_PACKED(frame) \
106 const uchar *src = frame.bits(0); \
107 int stride = frame.bytesPerLine(0); \
108 int width = frame.width(); \
109 int height = frame.height();
110
111#define FETCH_INFO_BIPLANAR(frame) \
112 const uchar *plane1 = frame.bits(0); \
113 const uchar *plane2 = frame.bits(1); \
114 int plane1Stride = frame.bytesPerLine(0); \
115 int plane2Stride = frame.bytesPerLine(1); \
116 int width = frame.width(); \
117 int height = frame.height();
118
119#define FETCH_INFO_TRIPLANAR(frame) \
120 const uchar *plane1 = frame.bits(0); \
121 const uchar *plane2 = frame.bits(1); \
122 const uchar *plane3 = frame.bits(2); \
123 int plane1Stride = frame.bytesPerLine(0); \
124 int plane2Stride = frame.bytesPerLine(1); \
125 int plane3Stride = frame.bytesPerLine(2); \
126 int width = frame.width(); \
127 int height = frame.height(); \
128
129#define MERGE_LOOPS(width, height, stride, bpp) \
130 if (stride == width * bpp) { \
131 width *= height; \
132 height = 1; \
133 stride = 0; \
134 }
135
136#define QT_MEDIA_ALIGN(boundary, ptr, x, length) \
137 for (; ((reinterpret_cast<qintptr>(ptr) & (boundary - 1)) != 0) && x < length; ++x)
138
140
141#endif // QVIDEOFRAMECONVERSIONHELPER_P_H
142
PixelFormat
Enumerates video data types.
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
Combined button and popup list for selecting options.
#define QT_FASTCALL
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum src
GLenum GLenum dst
GLboolean GLboolean g
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLint y
unsigned int quint32
Definition qtypes.h:50
unsigned char uchar
Definition qtypes.h:32
unsigned int uint
Definition qtypes.h:34
ArgbPixel< 3, 0, 1, 2 > RGBA8888
ArgbPixel< 0, 1, 2, 3 > ARGB8888
VideoFrameConvertFunc qConverterForFormat(QVideoFrameFormat::PixelFormat format)
RgbPixel< 1, 2, 3 > XRGB8888
ArgbPixel< 3, 2, 1, 0 > BGRA8888
void Q_MULTIMEDIA_EXPORT qCopyPixelsWithMask(uint32_t *dst, const uint32_t *src, size_t size, uint32_t mask)
void Q_MULTIMEDIA_EXPORT qCopyPixelsWithAlphaMask(uint32_t *dst, const uint32_t *src, size_t size, QVideoFrameFormat::PixelFormat format, bool srcAlphaVaries)
RgbPixel< 0, 1, 2 > RGBX8888
RgbPixel< 3, 2, 1 > XBGR8888
ArgbPixel< 0, 3, 2, 1 > ABGR8888
QT_BEGIN_NAMESPACE typedef uchar * output
void(QT_FASTCALL * PixelsCopyFunc)(uint32_t *dst, const uint32_t *src, size_t size, uint32_t mask)
RgbPixel< 2, 1, 0 > BGRX8888
uint32_t Q_MULTIMEDIA_EXPORT qAlphaMask(QVideoFrameFormat::PixelFormat format)
QFrame frame
[0]
quint32 convert() const
quint32 convert() const
static constexpr uint shift