summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-08-05 21:11:18 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-08-09 14:30:11 +0200
commit6e479464a37ddc6abbc46fbd5a3a1065091da480 (patch)
treee5c95bcfccbd97fe90d730b5c49ec5b48b648613
parente49d7b66d9f48a9b0c4e5535f6feb9e82638669d (diff)
Larger rework of the RGB pixel formats
Until now, pixel formats where not declared in an endian independent way. Format_ARGB32 meant that we casted the data to an array of integers and interpreted the highest 8 bits as alpha. This is unfortunate, as this adds endianness into the picture and complicates things. Change this towards endian independent ordering of the A, R, G and B components. New names of those formats are in line with the endian independent formats in QImage, where RGBA8888 indicates that the first byte is R and the last byte A. Add a couple of missing RGB formats, so that we have a symmetrical set and extend our conversion handling and other places to cover those as well. Refactor all our code to use the new formats and adjust our built-in converters to QImage to handle them correctly. Also refactor the SSE/AVX optimized code paths to handle all RGB based pixel formats. Adjust our shaders to work correctly with the new definitions. Finally enable all RGB pixel formats for GL accelerated rendering on gstreamer, as the byte order issues are now solved. Change-Id: I8927dc01d569233e9868e54b890f0f7c34705a2b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/multimedia/CMakeLists.txt1
-rw-r--r--src/multimedia/doc/snippets/multimedia-snippets/video.cpp2
-rw-r--r--src/multimedia/platform/android/common/qandroidvideooutput.cpp2
-rw-r--r--src/multimedia/platform/darwin/avfvideobuffer.mm20
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstutils.cpp22
-rw-r--r--src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp50
-rw-r--r--src/multimedia/platform/windows/common/qwindowsmultimediautils.cpp14
-rw-r--r--src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp4
-rw-r--r--src/multimedia/platform/windows/evr/evrhelpers.cpp16
-rw-r--r--src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp17
-rw-r--r--src/multimedia/shaders/abgr.frag2
-rw-r--r--src/multimedia/shaders/argb.frag2
-rw-r--r--src/multimedia/shaders/ayuv.frag5
-rw-r--r--src/multimedia/shaders/bgra.frag2
-rw-r--r--src/multimedia/shaders/rgba.frag18
-rw-r--r--src/multimedia/shaders/uyvy.frag2
-rw-r--r--src/multimedia/shaders/yuyv.frag2
-rw-r--r--src/multimedia/video/qvideoframe.cpp43
-rw-r--r--src/multimedia/video/qvideoframeconversionhelper.cpp188
-rw-r--r--src/multimedia/video/qvideoframeconversionhelper_avx2.cpp67
-rw-r--r--src/multimedia/video/qvideoframeconversionhelper_p.h51
-rw-r--r--src/multimedia/video/qvideoframeconversionhelper_sse2.cpp58
-rw-r--r--src/multimedia/video/qvideoframeconversionhelper_ssse3.cpp57
-rw-r--r--src/multimedia/video/qvideoframeformat.cpp136
-rw-r--r--src/multimedia/video/qvideoframeformat.h23
-rw-r--r--src/multimedia/video/qvideotexturehelper.cpp156
-rw-r--r--tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp4
-rw-r--r--tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp96
-rw-r--r--tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp46
-rw-r--r--tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp6
-rw-r--r--tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp2
31 files changed, 682 insertions, 432 deletions
diff --git a/src/multimedia/CMakeLists.txt b/src/multimedia/CMakeLists.txt
index a8b350539..40687a823 100644
--- a/src/multimedia/CMakeLists.txt
+++ b/src/multimedia/CMakeLists.txt
@@ -477,6 +477,7 @@ qt_internal_add_shaders(Multimedia "shaders"
"shaders/abgr.frag"
"shaders/argb.frag"
"shaders/bgra.frag"
+ "shaders/rgba.frag"
"shaders/y.frag"
"shaders/nv12.frag"
"shaders/nv21.frag"
diff --git a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
index a04363248..4e29269d8 100644
--- a/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
+++ b/src/multimedia/doc/snippets/multimedia-snippets/video.cpp
@@ -128,7 +128,7 @@ void VideoExample::VideoSurface()
{
//! [Widget Surface]
QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
- QVideoFrameFormat format(img.size(), QVideoFrameFormat::Format_ARGB32);
+ QVideoFrameFormat format(img.size(), QVideoFrameFormat::Format_ARGB8888);
videoWidget = new QVideoWidget;
videoWidget->videoSurface()->start(format);
videoWidget->videoSurface()->present(img);
diff --git a/src/multimedia/platform/android/common/qandroidvideooutput.cpp b/src/multimedia/platform/android/common/qandroidvideooutput.cpp
index 2cfdd3fbc..57c6cfda5 100644
--- a/src/multimedia/platform/android/common/qandroidvideooutput.cpp
+++ b/src/multimedia/platform/android/common/qandroidvideooutput.cpp
@@ -247,7 +247,7 @@ void QAndroidTextureVideoOutput::onFrameAvailable()
QRhi *rhi = m_sink ? m_sink->rhi() : nullptr;
auto *buffer = new AndroidTextureVideoBuffer(rhi, this, m_nativeSize);
const QVideoFrameFormat::PixelFormat format = rhi ? QVideoFrameFormat::Format_SamplerExternalOES
- : QVideoFrameFormat::Format_ARGB32_Premultiplied;
+ : QVideoFrameFormat::Format_RGBA8888;
QVideoFrame frame(buffer, QVideoFrameFormat(m_nativeSize, format));
m_sink->newVideoFrame(frame);
}
diff --git a/src/multimedia/platform/darwin/avfvideobuffer.mm b/src/multimedia/platform/darwin/avfvideobuffer.mm
index 5a3ea4d5d..68764fcd1 100644
--- a/src/multimedia/platform/darwin/avfvideobuffer.mm
+++ b/src/multimedia/platform/darwin/avfvideobuffer.mm
@@ -163,7 +163,7 @@ quint64 AVFVideoBuffer::textureHandle(int plane) const
cvMetalTextureCache,
m_buffer, nil,
// ### This needs proper handling when enabling other pixel formats than BRGA8
- MTLPixelFormatBGRA8Unorm,
+ MTLPixelFormatRGBA8Unorm,
width, height,
plane,
&cvMetalTexture[plane]);
@@ -241,14 +241,11 @@ quint64 AVFVideoBuffer::textureHandle(int plane) const
QVideoFrameFormat::PixelFormat AVFVideoBuffer::fromCVPixelFormat(unsigned avPixelFormat)
{
- // BGRA <-> ARGB "swap" is intentional:
- // to work correctly with GL_RGBA, color swap shaders
- // (in QSG node renderer etc.).
switch (avPixelFormat) {
case kCVPixelFormatType_32ARGB:
- return QVideoFrameFormat::Format_BGRA32;
+ return QVideoFrameFormat::Format_ARGB8888;
case kCVPixelFormatType_32BGRA:
- return QVideoFrameFormat::Format_ARGB32;
+ return QVideoFrameFormat::Format_BGRA8888;
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
return QVideoFrameFormat::Format_NV12;
@@ -269,16 +266,13 @@ QVideoFrameFormat::PixelFormat AVFVideoBuffer::fromCVPixelFormat(unsigned avPixe
bool AVFVideoBuffer::toCVPixelFormat(QVideoFrameFormat::PixelFormat qtFormat, unsigned &conv)
{
- // BGRA <-> ARGB "swap" is intentional:
- // to work correctly with GL_RGBA, color swap shaders
- // (in QSG node renderer etc.).
switch (qtFormat) {
- case QVideoFrameFormat::Format_ARGB32:
- conv = kCVPixelFormatType_32BGRA;
- break;
- case QVideoFrameFormat::Format_BGRA32:
+ case QVideoFrameFormat::Format_ARGB8888:
conv = kCVPixelFormatType_32ARGB;
break;
+ case QVideoFrameFormat::Format_BGRA8888:
+ conv = kCVPixelFormatType_32BGRA;
+ break;
case QVideoFrameFormat::Format_NV12:
conv = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;
break;
diff --git a/src/multimedia/platform/gstreamer/common/qgstutils.cpp b/src/multimedia/platform/gstreamer/common/qgstutils.cpp
index 2b88124d0..434dcd143 100644
--- a/src/multimedia/platform/gstreamer/common/qgstutils.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstutils.cpp
@@ -182,22 +182,20 @@ static const VideoFormat qt_videoFormatLookup[] =
{ QVideoFrameFormat::Format_YUYV , GST_VIDEO_FORMAT_YUY2 },
{ QVideoFrameFormat::Format_NV12 , GST_VIDEO_FORMAT_NV12 },
{ QVideoFrameFormat::Format_NV21 , GST_VIDEO_FORMAT_NV21 },
- { QVideoFrameFormat::Format_AYUV444, GST_VIDEO_FORMAT_AYUV },
- { QVideoFrameFormat::Format_Y8 , GST_VIDEO_FORMAT_GRAY8 },
+ { QVideoFrameFormat::Format_AYUV , GST_VIDEO_FORMAT_AYUV },
+ { QVideoFrameFormat::Format_Y8 , GST_VIDEO_FORMAT_GRAY8 },
+ { QVideoFrameFormat::Format_XRGB8888 , GST_VIDEO_FORMAT_xRGB },
+ { QVideoFrameFormat::Format_XBGR8888 , GST_VIDEO_FORMAT_xBGR },
+ { QVideoFrameFormat::Format_RGBX8888 , GST_VIDEO_FORMAT_RGBx },
+ { QVideoFrameFormat::Format_BGRX8888 , GST_VIDEO_FORMAT_BGRx },
+ { QVideoFrameFormat::Format_ARGB8888, GST_VIDEO_FORMAT_ARGB },
+ { QVideoFrameFormat::Format_ABGR8888, GST_VIDEO_FORMAT_ABGR },
+ { QVideoFrameFormat::Format_RGBA8888, GST_VIDEO_FORMAT_RGBA },
+ { QVideoFrameFormat::Format_BGRA8888, GST_VIDEO_FORMAT_BGRA },
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- { QVideoFrameFormat::Format_RGB32 , GST_VIDEO_FORMAT_BGRx },
- { QVideoFrameFormat::Format_BGR32 , GST_VIDEO_FORMAT_RGBx },
- { QVideoFrameFormat::Format_ARGB32, GST_VIDEO_FORMAT_BGRA },
- { QVideoFrameFormat::Format_ABGR32, GST_VIDEO_FORMAT_RGBA },
- { QVideoFrameFormat::Format_BGRA32, GST_VIDEO_FORMAT_ARGB },
{ QVideoFrameFormat::Format_Y16 , GST_VIDEO_FORMAT_GRAY16_LE },
{ QVideoFrameFormat::Format_P010 , GST_VIDEO_FORMAT_P010_10LE },
#else
- { QVideoFrameFormat::Format_RGB32 , GST_VIDEO_FORMAT_xRGB },
- { QVideoFrameFormat::Format_BGR32 , GST_VIDEO_FORMAT_xBGR },
- { QVideoFrameFormat::Format_ARGB32, GST_VIDEO_FORMAT_ARGB },
- { QVideoFrameFormat::Format_ABGR32, GST_VIDEO_FORMAT_ABGR },
- { QVideoFrameFormat::Format_BGRA32, GST_VIDEO_FORMAT_BGRA },
{ QVideoFrameFormat::Format_Y16 , GST_VIDEO_FORMAT_GRAY16_BE },
{ QVideoFrameFormat::Format_P010 , GST_VIDEO_FORMAT_P010_10BE },
#endif
diff --git a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp
index ab351c897..cd6d251ae 100644
--- a/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp
+++ b/src/multimedia/platform/gstreamer/common/qgstvideorenderersink.cpp
@@ -84,34 +84,6 @@ void QGstVideoRenderer::createSurfaceCaps()
caps.create();
// All the formats that both we and gstreamer support
-#if QT_CONFIG(gstreamer_gl)
- if (rhi && rhi->backend() == QRhi::OpenGLES2) {
- auto formats = QList<QVideoFrameFormat::PixelFormat>()
- << QVideoFrameFormat::Format_YUV420P
- << QVideoFrameFormat::Format_YUV422P
- << QVideoFrameFormat::Format_YV12
- << QVideoFrameFormat::Format_UYVY
- << QVideoFrameFormat::Format_YUYV
- << QVideoFrameFormat::Format_NV12
- << QVideoFrameFormat::Format_NV21
- << QVideoFrameFormat::Format_AYUV444
- << QVideoFrameFormat::Format_P010
- // ### Gstreamer uses opposite endianness from what we assume in our shaders for RGB formats
-// << QVideoFrameFormat::Format_RGB32
-// << QVideoFrameFormat::Format_BGR32
-// << QVideoFrameFormat::Format_ARGB32
-// << QVideoFrameFormat::Format_ABGR32
-// << QVideoFrameFormat::Format_BGRA32
- << QVideoFrameFormat::Format_Y8
- << QVideoFrameFormat::Format_Y16
- ;
- // Even if the surface does not support gl textures,
- // glupload will be added to the pipeline and GLMemory will be requested.
- // This will lead to upload data to gl textures
- // and download it when the buffer will be used within rendering.
- caps.addPixelFormats(formats, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
- }
-#endif
auto formats = QList<QVideoFrameFormat::PixelFormat>()
<< QVideoFrameFormat::Format_YUV420P
<< QVideoFrameFormat::Format_YUV422P
@@ -120,18 +92,24 @@ void QGstVideoRenderer::createSurfaceCaps()
<< QVideoFrameFormat::Format_YUYV
<< QVideoFrameFormat::Format_NV12
<< QVideoFrameFormat::Format_NV21
- << QVideoFrameFormat::Format_AYUV444
-#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
+ << QVideoFrameFormat::Format_AYUV
<< QVideoFrameFormat::Format_P010
-#endif
- << QVideoFrameFormat::Format_RGB32
- << QVideoFrameFormat::Format_BGR32
- << QVideoFrameFormat::Format_ARGB32
- << QVideoFrameFormat::Format_ABGR32
- << QVideoFrameFormat::Format_BGRA32
+ << QVideoFrameFormat::Format_XRGB8888
+ << QVideoFrameFormat::Format_XBGR8888
+ << QVideoFrameFormat::Format_RGBX8888
+ << QVideoFrameFormat::Format_BGRX8888
+ << QVideoFrameFormat::Format_ARGB8888
+ << QVideoFrameFormat::Format_ABGR8888
+ << QVideoFrameFormat::Format_RGBA8888
+ << QVideoFrameFormat::Format_BGRA8888
<< QVideoFrameFormat::Format_Y8
<< QVideoFrameFormat::Format_Y16
;
+#if QT_CONFIG(gstreamer_gl)
+ if (rhi && rhi->backend() == QRhi::OpenGLES2) {
+ caps.addPixelFormats(formats, GST_CAPS_FEATURE_MEMORY_GL_MEMORY);
+ }
+#endif
caps.addPixelFormats(formats);
m_surfaceCaps = caps;
diff --git a/src/multimedia/platform/windows/common/qwindowsmultimediautils.cpp b/src/multimedia/platform/windows/common/qwindowsmultimediautils.cpp
index a9f8c1dfd..ad6a234eb 100644
--- a/src/multimedia/platform/windows/common/qwindowsmultimediautils.cpp
+++ b/src/multimedia/platform/windows/common/qwindowsmultimediautils.cpp
@@ -47,11 +47,19 @@ QT_BEGIN_NAMESPACE
QVideoFrameFormat::PixelFormat QWindowsMultimediaUtils::pixelFormatFromMediaSubtype(const GUID &subtype)
{
if (subtype == MFVideoFormat_ARGB32)
- return QVideoFrameFormat::Format_ARGB32;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ return QVideoFrameFormat::Format_BGRA8888;
+#else
+ return QVideoFrameFormat::Format_ARGB8888;
+#endif
if (subtype == MFVideoFormat_RGB32)
- return QVideoFrameFormat::Format_RGB32;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ return QVideoFrameFormat::Format_BGRX8888;
+#else
+ return QVideoFrameFormat::Format_XRGB8888;
+#endif
if (subtype == MFVideoFormat_AYUV)
- return QVideoFrameFormat::Format_AYUV444;
+ return QVideoFrameFormat::Format_AYUV;
if (subtype == MFVideoFormat_I420)
return QVideoFrameFormat::Format_YUV420P;
if (subtype == MFVideoFormat_UYVY)
diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
index b1e477675..77265875f 100644
--- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
+++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp
@@ -360,8 +360,8 @@ HRESULT D3DPresentEngine::createVideoSamples(IMFMediaType *format, QList<IMFSamp
done:
if (SUCCEEDED(hr)) {
m_surfaceFormat = QVideoFrameFormat(QSize(width, height),
- m_useTextureRendering ? QVideoFrameFormat::Format_RGB32
- : qt_evr_pixelFormatFromD3DFormat(d3dFormat));
+ m_useTextureRendering ? QVideoFrameFormat::Format_BGRX8888
+ : qt_evr_pixelFormatFromD3DFormat(d3dFormat));
} else {
releaseResources();
}
diff --git a/src/multimedia/platform/windows/evr/evrhelpers.cpp b/src/multimedia/platform/windows/evr/evrhelpers.cpp
index 868189e2a..3f2059585 100644
--- a/src/multimedia/platform/windows/evr/evrhelpers.cpp
+++ b/src/multimedia/platform/windows/evr/evrhelpers.cpp
@@ -121,15 +121,15 @@ QVideoFrameFormat::PixelFormat qt_evr_pixelFormatFromD3DFormat(DWORD format)
{
switch (format) {
case D3DFMT_A8R8G8B8:
- return QVideoFrameFormat::Format_ARGB32;
+ return QVideoFrameFormat::Format_BGRA8888;
case D3DFMT_X8R8G8B8:
- return QVideoFrameFormat::Format_RGB32;
+ return QVideoFrameFormat::Format_BGRX8888;
case D3DFMT_A8:
return QVideoFrameFormat::Format_Y8;
case D3DFMT_A8B8G8R8:
- return QVideoFrameFormat::Format_BGRA32;
+ return QVideoFrameFormat::Format_RGBA8888;
case D3DFMT_X8B8G8R8:
- return QVideoFrameFormat::Format_BGR32;
+ return QVideoFrameFormat::Format_RGBX8888;
case D3DFMT_UYVY:
return QVideoFrameFormat::Format_UYVY;
case D3DFMT_YUY2:
@@ -147,15 +147,15 @@ QVideoFrameFormat::PixelFormat qt_evr_pixelFormatFromD3DFormat(DWORD format)
D3DFORMAT qt_evr_D3DFormatFromPixelFormat(QVideoFrameFormat::PixelFormat format)
{
switch (format) {
- case QVideoFrameFormat::Format_ARGB32:
+ case QVideoFrameFormat::Format_BGRA8888:
return D3DFMT_A8R8G8B8;
- case QVideoFrameFormat::Format_RGB32:
+ case QVideoFrameFormat::Format_BGRX8888:
return D3DFMT_X8R8G8B8;
case QVideoFrameFormat::Format_Y8:
return D3DFMT_A8;
- case QVideoFrameFormat::Format_BGRA32:
+ case QVideoFrameFormat::Format_RGBA8888:
return D3DFMT_A8B8G8R8;
- case QVideoFrameFormat::Format_BGR32:
+ case QVideoFrameFormat::Format_RGBX8888:
return D3DFMT_X8B8G8R8;
case QVideoFrameFormat::Format_UYVY:
return D3DFMT_UYVY;
diff --git a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp
index fb64d5ae2..1ea2c6aee 100644
--- a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp
+++ b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp
@@ -804,15 +804,15 @@ namespace
mediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
mediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
switch (format) {
- case QVideoFrameFormat::Format_ARGB32:
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
mediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_ARGB32);
break;
- case QVideoFrameFormat::Format_RGB32:
+ case QVideoFrameFormat::Format_BGRX8888:
mediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_RGB32);
break;
- case QVideoFrameFormat::Format_AYUV444:
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
+ case QVideoFrameFormat::Format_AYUV:
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
mediaType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_AYUV);
break;
case QVideoFrameFormat::Format_YUV420P:
@@ -1036,8 +1036,11 @@ namespace
{
switch (format.pixelFormat()) {
// 32 bpp packed formats.
- case QVideoFrameFormat::Format_RGB32:
- case QVideoFrameFormat::Format_AYUV444:
+ case QVideoFrameFormat::Format_XBGR8888:
+ case QVideoFrameFormat::Format_BGRX8888:
+ case QVideoFrameFormat::Format_XRGB8888:
+ case QVideoFrameFormat::Format_RGBX8888:
+ case QVideoFrameFormat::Format_AYUV:
return format.frameWidth() * 4;
// 16 bpp packed formats.
case QVideoFrameFormat::Format_YUYV:
diff --git a/src/multimedia/shaders/abgr.frag b/src/multimedia/shaders/abgr.frag
index 2b2812a33..a09defef3 100644
--- a/src/multimedia/shaders/abgr.frag
+++ b/src/multimedia/shaders/abgr.frag
@@ -14,5 +14,5 @@ layout(binding = 1) uniform sampler2D rgbTexture;
void main()
{
- fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).bgra * ubuf.opacity;
+ fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).abgr * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/argb.frag b/src/multimedia/shaders/argb.frag
index 6b9abade7..bfe7a97b2 100644
--- a/src/multimedia/shaders/argb.frag
+++ b/src/multimedia/shaders/argb.frag
@@ -14,5 +14,5 @@ layout(binding = 1) uniform sampler2D rgbTexture;
void main()
{
- fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord) * ubuf.opacity;
+ fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).gbar * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/ayuv.frag b/src/multimedia/shaders/ayuv.frag
index 51427eed0..4212325e6 100644
--- a/src/multimedia/shaders/ayuv.frag
+++ b/src/multimedia/shaders/ayuv.frag
@@ -14,6 +14,7 @@ layout(binding = 1) uniform sampler2D plane1Texture;
void main()
{
- vec3 YUV = texture(plane1Texture, texCoord).gra;
- fragColor = ubuf.colorMatrix * vec4(YUV, 1.0) * ubuf.opacity;
+ vec3 YUV = texture(plane1Texture, texCoord).gba;
+ float A = texture(plane1Texture, texCoord).r;
+ fragColor = ubuf.colorMatrix * vec4(YUV, 1.0) * A * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/bgra.frag b/src/multimedia/shaders/bgra.frag
index 938dfbd72..2b2812a33 100644
--- a/src/multimedia/shaders/bgra.frag
+++ b/src/multimedia/shaders/bgra.frag
@@ -14,5 +14,5 @@ layout(binding = 1) uniform sampler2D rgbTexture;
void main()
{
- fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).grab * ubuf.opacity;
+ fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).bgra * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/rgba.frag b/src/multimedia/shaders/rgba.frag
new file mode 100644
index 000000000..33c4a8669
--- /dev/null
+++ b/src/multimedia/shaders/rgba.frag
@@ -0,0 +1,18 @@
+#version 440
+
+layout(location = 0) in vec2 texCoord;
+layout(location = 0) out vec4 fragColor;
+
+layout(std140, binding = 0) uniform buf {
+ mat4 matrix;
+ mat4 colorMatrix;
+ float opacity;
+ float width;
+} ubuf;
+
+layout(binding = 1) uniform sampler2D rgbTexture;
+
+void main()
+{
+ fragColor = ubuf.colorMatrix * texture(rgbTexture, texCoord).rgba * ubuf.opacity;
+}
diff --git a/src/multimedia/shaders/uyvy.frag b/src/multimedia/shaders/uyvy.frag
index 059b8ee2f..5ab50e3b6 100644
--- a/src/multimedia/shaders/uyvy.frag
+++ b/src/multimedia/shaders/uyvy.frag
@@ -17,6 +17,6 @@ void main()
int x = int(floor(texCoord.x * ubuf.width));
bool rightSubPixel = (x/2*2 != x);
float Y = rightSubPixel ? texture(plane1Texture, texCoord).a : texture(plane1Texture, texCoord).g;
- vec2 UV = texture(plane1Texture, texCoord).br;
+ vec2 UV = texture(plane1Texture, texCoord).rb;
fragColor = ubuf.colorMatrix * vec4(Y, UV, 1.0) * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/yuyv.frag b/src/multimedia/shaders/yuyv.frag
index ab68b2bea..6fc3f35e9 100644
--- a/src/multimedia/shaders/yuyv.frag
+++ b/src/multimedia/shaders/yuyv.frag
@@ -16,7 +16,7 @@ void main()
{
int x = int(floor(texCoord.x * ubuf.width));
bool rightSubPixel = (x/2*2 != x);
- float Y = rightSubPixel ? texture(plane1Texture, texCoord).r : texture(plane1Texture, texCoord).b;
+ float Y = rightSubPixel ? texture(plane1Texture, texCoord).b : texture(plane1Texture, texCoord).r;
vec2 UV = texture(plane1Texture, texCoord).ga;
fragColor = ubuf.colorMatrix * vec4(Y, UV, 1.0) * ubuf.opacity;
}
diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp
index bbe3675a6..4e6a002cc 100644
--- a/src/multimedia/video/qvideoframe.cpp
+++ b/src/multimedia/video/qvideoframe.cpp
@@ -59,14 +59,17 @@ static bool pixelFormatHasAlpha[QVideoFrameFormat::NPixelFormats] =
false, //Format_Invalid,
true, //Format_ARGB32,
true, //Format_ARGB32_Premultiplied,
- false, //Format_RGB32,
+ false, //Format_XRGB32,
true, //Format_BGRA32,
true, //Format_BGRA32_Premultiplied,
+ false, //Format_BGRX32,
true, //Format_ABGR32,
- false, //Format_BGR32,
+ false, //Format_XBGR32,
+ true, //Format_RGBA32,
+ false, //Format_RGBX32,
- true, //Format_AYUV444,
- true, //Format_AYUV444_Premultiplied,
+ true, //Format_AYUV,
+ true, //Format_AYUV_Premultiplied,
false, //Format_YUV420P,
false, //Format_YUV422P,
false, //Format_YV12,
@@ -442,15 +445,18 @@ bool QVideoFrame::map(QVideoFrame::MapMode mode)
// If the plane count is 1 derive the additional planes for planar formats.
switch (pixelFmt) {
case QVideoFrameFormat::Format_Invalid:
- case QVideoFrameFormat::Format_ARGB32:
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
- case QVideoFrameFormat::Format_RGB32:
- case QVideoFrameFormat::Format_BGRA32:
- case QVideoFrameFormat::Format_BGRA32_Premultiplied:
- case QVideoFrameFormat::Format_ABGR32:
- case QVideoFrameFormat::Format_BGR32:
- case QVideoFrameFormat::Format_AYUV444:
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
+ case QVideoFrameFormat::Format_ARGB8888:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ case QVideoFrameFormat::Format_XRGB8888:
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ case QVideoFrameFormat::Format_BGRX8888:
+ case QVideoFrameFormat::Format_ABGR8888:
+ case QVideoFrameFormat::Format_XBGR8888:
+ case QVideoFrameFormat::Format_RGBA8888:
+ case QVideoFrameFormat::Format_RGBX8888:
+ case QVideoFrameFormat::Format_AYUV:
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
case QVideoFrameFormat::Format_UYVY:
case QVideoFrameFormat::Format_YUYV:
case QVideoFrameFormat::Format_Y8:
@@ -687,20 +693,15 @@ QImage QVideoFrame::toImage() const
if (!frame.isValid() || !frame.map(QVideoFrame::ReadOnly))
return result;
- // Formats supported by QImage don't need conversion
- QImage::Format imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat(frame.pixelFormat());
- if (imageFormat != QImage::Format_Invalid) {
- result = QImage(frame.bits(0), frame.width(), frame.height(), frame.bytesPerLine(0), imageFormat).copy();
- }
-
- // Load from JPG
- else if (frame.pixelFormat() == QVideoFrameFormat::Format_Jpeg) {
+ if (frame.pixelFormat() == QVideoFrameFormat::Format_Jpeg) {
+ // Load from JPG
result.loadFromData(frame.bits(0), frame.mappedBytes(0), "JPG");
}
// Need conversion
else {
VideoFrameConvertFunc convert = qConverterForFormat(frame.pixelFormat());
+ qDebug() << "using QVideoFrame conversion" << frame.pixelFormat();
if (!convert) {
qWarning() << Q_FUNC_INFO << ": unsupported pixel format" << frame.pixelFormat();
} else {
diff --git a/src/multimedia/video/qvideoframeconversionhelper.cpp b/src/multimedia/video/qvideoframeconversionhelper.cpp
index 68cfbccec..d4eb53f88 100644
--- a/src/multimedia/video/qvideoframeconversionhelper.cpp
+++ b/src/multimedia/video/qvideoframeconversionhelper.cpp
@@ -163,7 +163,7 @@ static void QT_FASTCALL qt_convert_YV12_to_ARGB32(const QVideoFrame &frame, ucha
width, height);
}
-static void QT_FASTCALL qt_convert_AYUV444_to_ARGB32(const QVideoFrame &frame, uchar *output)
+static void QT_FASTCALL qt_convert_AYUV_to_ARGB32(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
@@ -188,7 +188,7 @@ static void QT_FASTCALL qt_convert_AYUV444_to_ARGB32(const QVideoFrame &frame, u
}
}
-static void QT_FASTCALL qt_convert_AYUV444_Premultiplied_to_ARGB32(const QVideoFrame &frame, uchar *output)
+static void QT_FASTCALL qt_convert_AYUV_Premultiplied_to_ARGB32(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
@@ -342,7 +342,8 @@ static void QT_FASTCALL qt_convert_IMC4_to_ARGB32(const QVideoFrame &frame, ucha
}
-static void QT_FASTCALL qt_convert_BGRA32_to_ARGB32(const QVideoFrame &frame, uchar *output)
+template<typename Pixel>
+static void QT_FASTCALL qt_convert_to_ARGB32(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
@@ -350,51 +351,32 @@ static void QT_FASTCALL qt_convert_BGRA32_to_ARGB32(const QVideoFrame &frame, uc
quint32 *argb = reinterpret_cast<quint32*>(output);
for (int y = 0; y < height; ++y) {
- const quint32 *bgra = reinterpret_cast<const quint32*>(src);
+ const Pixel *data = reinterpret_cast<const Pixel *>(src);
int x = 0;
for (; x < width - 3; x += 4) {
- *argb++ = qPremultiply(qConvertBGRA32ToARGB32(*bgra++));
- *argb++ = qPremultiply(qConvertBGRA32ToARGB32(*bgra++));
- *argb++ = qPremultiply(qConvertBGRA32ToARGB32(*bgra++));
- *argb++ = qPremultiply(qConvertBGRA32ToARGB32(*bgra++));
+ *argb++ = qPremultiply(data->convert());
+ ++data;
+ *argb++ = qPremultiply(data->convert());
+ ++data;
+ *argb++ = qPremultiply(data->convert());
+ ++data;
+ *argb++ = qPremultiply(data->convert());
+ ++data;
}
// leftovers
- for (; x < width; ++x)
- *argb++ = qPremultiply(qConvertBGRA32ToARGB32(*bgra++));
-
- src += stride;
- }
-}
-
-static void QT_FASTCALL qt_convert_BGRA32_Premultiplied_to_ARGB32(const QVideoFrame &frame, uchar *output)
-{
- FETCH_INFO_PACKED(frame)
- MERGE_LOOPS(width, height, stride, 4)
-
- quint32 *argb = reinterpret_cast<quint32*>(output);
-
- for (int y = 0; y < height; ++y) {
- const quint32 *bgra = reinterpret_cast<const quint32*>(src);
-
- int x = 0;
- for (; x < width - 3; x += 4) {
- *argb++ = qConvertBGRA32ToARGB32(*bgra++);
- *argb++ = qConvertBGRA32ToARGB32(*bgra++);
- *argb++ = qConvertBGRA32ToARGB32(*bgra++);
- *argb++ = qConvertBGRA32ToARGB32(*bgra++);
+ for (; x < width; ++x) {
+ *argb++ = qPremultiply(data->convert());
+ ++data;
}
- // leftovers
- for (; x < width; ++x)
- *argb++ = qConvertBGRA32ToARGB32(*bgra++);
-
src += stride;
}
}
-static void QT_FASTCALL qt_convert_ABGR32_to_ARGB32(const QVideoFrame &frame, uchar *output)
+template<typename Pixel>
+static void QT_FASTCALL qt_convert_premultiplied_to_ARGB32(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
@@ -402,19 +384,25 @@ static void QT_FASTCALL qt_convert_ABGR32_to_ARGB32(const QVideoFrame &frame, uc
quint32 *argb = reinterpret_cast<quint32*>(output);
for (int y = 0; y < height; ++y) {
- const quint32 *abgr = reinterpret_cast<const quint32*>(src);
+ const Pixel *data = reinterpret_cast<const Pixel *>(src);
int x = 0;
for (; x < width - 3; x += 4) {
- *argb++ = qConvertABGR32ToARGB32(*abgr++);
- *argb++ = qConvertABGR32ToARGB32(*abgr++);
- *argb++ = qConvertABGR32ToARGB32(*abgr++);
- *argb++ = qConvertABGR32ToARGB32(*abgr++);
+ *argb++ = data->convert();
+ ++data;
+ *argb++ = data->convert();
+ ++data;
+ *argb++ = data->convert();
+ ++data;
+ *argb++ = data->convert();
+ ++data;
}
// leftovers
- for (; x < width; ++x)
- *argb++ = qConvertABGR32ToARGB32(*abgr++);
+ for (; x < width; ++x) {
+ *argb++ = data->convert();
+ ++data;
+ }
src += stride;
}
@@ -471,17 +459,55 @@ static void QT_FASTCALL qt_convert_P016_to_ARGB32(const QVideoFrame &frame, ucha
}
+template <typename Y>
+static void QT_FASTCALL qt_convert_Y_to_ARGB32(const QVideoFrame &frame, uchar *output)
+{
+ FETCH_INFO_PACKED(frame)
+ MERGE_LOOPS(width, height, stride, (int)sizeof(Y))
+ quint32 *argb = reinterpret_cast<quint32*>(output);
+
+ using Pixel = YPixel<Y>;
+
+ for (int y = 0; y < height; ++y) {
+ const Pixel *pixel = reinterpret_cast<const Pixel *>(src);
+
+ int x = 0;
+ for (; x < width - 3; x += 4) {
+ *argb++ = pixel->convert();
+ ++pixel;
+ *argb++ = pixel->convert();
+ ++pixel;
+ *argb++ = pixel->convert();
+ ++pixel;
+ *argb++ = pixel->convert();
+ ++pixel;
+ }
+
+ // leftovers
+ for (; x < width; ++x) {
+ *argb++ = pixel->convert();
+ ++pixel;
+ }
+
+ src += stride;
+ }
+ MERGE_LOOPS(width, height, stride, 1)
+}
+
static VideoFrameConvertFunc qConvertFuncs[QVideoFrameFormat::NPixelFormats] = {
/* Format_Invalid */ nullptr, // Not needed
- /* Format_ARGB32 */ nullptr, // Not needed
- /* Format_ARGB32_Premultiplied */ nullptr, // Not needed
- /* Format_RGB32 */ nullptr, // Not needed
- /* Format_BGRA32 */ qt_convert_BGRA32_to_ARGB32,
- /* Format_BGRA32_Premultiplied */ qt_convert_BGRA32_Premultiplied_to_ARGB32,
- /* Format_ABGR32 */ qt_convert_ABGR32_to_ARGB32,
- /* Format_BGR32 */ qt_convert_BGRA32_Premultiplied_to_ARGB32,
- /* Format_AYUV444 */ qt_convert_AYUV444_to_ARGB32,
- /* Format_AYUV444_Premultiplied */ qt_convert_AYUV444_Premultiplied_to_ARGB32,
+ /* Format_ARGB8888 */ qt_convert_to_ARGB32<ARGB8888>,
+ /* Format_ARGB8888_Premultiplied */ qt_convert_premultiplied_to_ARGB32<ARGB8888>,
+ /* Format_XRGB8888 */ qt_convert_premultiplied_to_ARGB32<XRGB8888>,
+ /* Format_BGRA8888 */ qt_convert_to_ARGB32<BGRA8888>,
+ /* Format_BGRA8888_Premultiplied */ qt_convert_premultiplied_to_ARGB32<BGRA8888>,
+ /* Format_BGRX8888 */ qt_convert_premultiplied_to_ARGB32<BGRX8888>,
+ /* Format_ABGR8888 */ qt_convert_to_ARGB32<ABGR8888>,
+ /* Format_XBGR8888 */ qt_convert_premultiplied_to_ARGB32<XBGR8888>,
+ /* Format_RGBA8888 */ qt_convert_to_ARGB32<RGBA8888>,
+ /* Format_RGBX8888 */ qt_convert_premultiplied_to_ARGB32<RGBX8888>,
+ /* Format_AYUV */ qt_convert_AYUV_to_ARGB32,
+ /* Format_AYUV_Premultiplied */ qt_convert_AYUV_Premultiplied_to_ARGB32,
/* Format_YUV420P */ qt_convert_YUV420P_to_ARGB32,
/* Format_YUV422P */ qt_convert_YUV422P_to_ARGB32,
/* Format_YV12 */ qt_convert_YV12_to_ARGB32,
@@ -493,8 +519,8 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrameFormat::NPixelFormats] = {
/* Format_IMC2 */ qt_convert_IMC2_to_ARGB32,
/* Format_IMC3 */ qt_convert_IMC3_to_ARGB32,
/* Format_IMC4 */ qt_convert_IMC4_to_ARGB32,
- /* Format_Y8 */ nullptr, // Not needed
- /* Format_Y16 */ nullptr, // Not needed
+ /* Format_Y8 */ qt_convert_Y_to_ARGB32<uchar>,
+ /* Format_Y16 */ qt_convert_Y_to_ARGB32<ushort>,
/* Format_P010 */ qt_convert_P016_to_ARGB32,
/* Format_P016 */ qt_convert_P016_to_ARGB32,
/* Format_Jpeg */ nullptr, // Not needed
@@ -503,27 +529,57 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrameFormat::NPixelFormats] = {
static void qInitConvertFuncsAsm()
{
#ifdef QT_COMPILER_SUPPORTS_SSE2
- extern void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_sse2(const QVideoFrame&, uchar*);
+ extern void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_ABGR8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_RGBA8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_BGRA8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output);
if (qCpuHasFeature(SSE2)){
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32] = qt_convert_BGRA32_to_ARGB32_sse2;
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32_Premultiplied] = qt_convert_BGRA32_to_ARGB32_sse2;
- qConvertFuncs[QVideoFrameFormat::Format_BGR32] = qt_convert_BGRA32_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888] = qt_convert_ARGB8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888_Premultiplied] = qt_convert_ARGB8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_XRGB8888] = qt_convert_ARGB8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888_Premultiplied] = qt_convert_BGRA8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_BGRA8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_ABGR8888] = qt_convert_ABGR8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_ABGR8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_sse2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_sse2;
}
#endif
#ifdef QT_COMPILER_SUPPORTS_SSSE3
- extern void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_ssse3(const QVideoFrame&, uchar*);
+ extern void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_ABGR8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_RGBA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_BGRA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output);
if (qCpuHasFeature(SSSE3)){
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32] = qt_convert_BGRA32_to_ARGB32_ssse3;
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32_Premultiplied] = qt_convert_BGRA32_to_ARGB32_ssse3;
- qConvertFuncs[QVideoFrameFormat::Format_BGR32] = qt_convert_BGRA32_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888] = qt_convert_ARGB8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888_Premultiplied] = qt_convert_ARGB8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_XRGB8888] = qt_convert_ARGB8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888_Premultiplied] = qt_convert_BGRA8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_BGRA8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_ABGR8888] = qt_convert_ABGR8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_ABGR8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_ssse3;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_ssse3;
}
#endif
#ifdef QT_COMPILER_SUPPORTS_AVX2
- extern void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_avx2(const QVideoFrame&, uchar*);
+ extern void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_ABGR8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_RGBA8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output);
+ extern void QT_FASTCALL qt_convert_BGRA8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output);
if (qCpuHasFeature(AVX2)){
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32] = qt_convert_BGRA32_to_ARGB32_avx2;
- qConvertFuncs[QVideoFrameFormat::Format_BGRA32_Premultiplied] = qt_convert_BGRA32_to_ARGB32_avx2;
- qConvertFuncs[QVideoFrameFormat::Format_BGR32] = qt_convert_BGRA32_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888] = qt_convert_ARGB8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_ARGB8888_Premultiplied] = qt_convert_ARGB8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_XRGB8888] = qt_convert_ARGB8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888_Premultiplied] = qt_convert_BGRA8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_BGRA8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_ABGR8888] = qt_convert_ABGR8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_XBGR8888] = qt_convert_ABGR8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_avx2;
+ qConvertFuncs[QVideoFrameFormat::Format_BGRA8888] = qt_convert_BGRA8888_to_ARGB32_avx2;
}
#endif
}
diff --git a/src/multimedia/video/qvideoframeconversionhelper_avx2.cpp b/src/multimedia/video/qvideoframeconversionhelper_avx2.cpp
index 4df08f162..c17f8a6a4 100644
--- a/src/multimedia/video/qvideoframeconversionhelper_avx2.cpp
+++ b/src/multimedia/video/qvideoframeconversionhelper_avx2.cpp
@@ -43,29 +43,51 @@
QT_BEGIN_NAMESPACE
-void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
+namespace {
+
+template<int a, int r, int g, int b>
+void convert_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
quint32 *argb = reinterpret_cast<quint32*>(output);
- const __m256i shuffleMask = _mm256_set_epi8(12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3,
- 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3);
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ __m256i shuffleMask = _mm256_set_epi8(12 + a, 12 + r, 12 + g, 12 + b,
+ 8 + a, 8 + r, 8 + g, 8 + b,
+ 4 + a, 4 + r, 4 + g, 4 + b,
+ 0 + a, 0 + r, 0 + g, 0 + b,
+ 12 + a, 12 + r, 12 + g, 12 + b,
+ 8 + a, 8 + r, 8 + g, 8 + b,
+ 4 + a, 4 + r, 4 + g, 4 + b,
+ 0 + a, 0 + r, 0 + g, 0 + b);
+#else
+ __m256i shuffleMask = _mm256_set_epi8(15 - a, 15 - r, 15 - g, 15 - b,
+ 11 - a, 11 - r, 11 - g, 11 - b,
+ 7 - a, 7 - r, 7 - g, 7 - b,
+ 3 - a, 3 - r, 3 - g, 3 - b,
+ 15 - a, 15 - r, 15 - g, 15 - b,
+ 11 - a, 11 - r, 11 - g, 11 - b,
+ 7 - a, 7 - r, 7 - g, 7 - b,
+ 3 - a, 3 - r, 3 - g, 3 - b);
+#endif
+
+ using Pixel = const RgbPixel<a, r, g, b>;
for (int y = 0; y < height; ++y) {
- const quint32 *bgra = reinterpret_cast<const quint32*>(src);
+ auto *pixel = reinterpret_cast<const Pixel *>(src);
int x = 0;
ALIGN(32, argb, x, width) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
for (; x < width - 15; x += 16) {
- __m256i pixelData = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(bgra));
- __m256i pixelData2 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(bgra + 8));
- bgra += 16;
+ __m256i pixelData = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(pixel));
+ __m256i pixelData2 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(pixel + 8));
+ pixel += 16;
pixelData = _mm256_shuffle_epi8(pixelData, shuffleMask);
pixelData2 = _mm256_shuffle_epi8(pixelData2, shuffleMask);
_mm256_store_si256(reinterpret_cast<__m256i*>(argb), pixelData);
@@ -75,8 +97,8 @@ void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_avx2(const QVideoFrame &frame, ucha
// leftovers
for (; x < width; ++x) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
@@ -84,6 +106,29 @@ void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_avx2(const QVideoFrame &frame, ucha
}
}
+}
+
+
+void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_avx2<0, 1, 2, 3>(frame, output);
+}
+
+void qt_convert_ABGR8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_avx2<0, 3, 2, 1>(frame, output);
+}
+
+void qt_convert_RGBA8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_avx2<3, 0, 1, 2>(frame, output);
+}
+
+void qt_convert_BGRA8888_to_ARGB32_avx2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_avx2<3, 2, 1, 0>(frame, output);
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/multimedia/video/qvideoframeconversionhelper_p.h b/src/multimedia/video/qvideoframeconversionhelper_p.h
index 855c29205..eeb11f833 100644
--- a/src/multimedia/video/qvideoframeconversionhelper_p.h
+++ b/src/multimedia/video/qvideoframeconversionhelper_p.h
@@ -61,26 +61,45 @@ typedef void (QT_FASTCALL *VideoFrameConvertFunc)(const QVideoFrame &frame, ucha
VideoFrameConvertFunc qConverterForFormat(QVideoFrameFormat::PixelFormat format);
-inline quint32 qConvertBGRA32ToARGB32(quint32 bgra)
+template<int a, int r, int g, int b>
+struct RgbPixel
{
- return (((bgra & 0xFF000000) >> 24)
- | ((bgra & 0x00FF0000) >> 8)
- | ((bgra & 0x0000FF00) << 8)
- | ((bgra & 0x000000FF) << 24));
-}
+ uchar data[4];
+ inline quint32 convert() const
+ {
+ return (a >= 0 ? (uint(data[a]) << 24) : 0xff000000)
+ | (uint(data[r]) << 16)
+ | (uint(data[g]) << 8)
+ | (uint(data[b]));
+ }
-inline quint32 qConvertABGR32ToARGB32(quint32 abgr)
-{
- return ((abgr & 0xFF000000)
- | ((abgr & 0x00FF0000) >> 16)
- | (abgr & 0x0000FF00)
- | ((abgr & 0x000000FF) << 16));
-}
+};
-inline quint32 qConvertBGR24ToARGB32(const uchar *bgr)
+template<typename Y>
+struct YPixel
{
- return 0xFF000000 | bgr[0] | bgr[1] << 8 | bgr[2] << 16;
-}
+ Y data;
+ static constexpr uint shift = (sizeof(Y) - 1)*8;
+ inline quint32 convert() const
+ {
+ uint y = (data >> shift) & 0xff;
+ return (0xff000000)
+ | (y << 16)
+ | (y << 8)
+ | (y);
+ }
+
+};
+
+
+using ARGB8888 = RgbPixel<0, 1, 2, 3>;
+using ABGR8888 = RgbPixel<0, 3, 2, 1>;
+using RGBA8888 = RgbPixel<3, 0, 1, 2>;
+using BGRA8888 = RgbPixel<3, 2, 1, 0>;
+using XRGB8888 = RgbPixel<-1, 1, 2, 3>;
+using XBGR8888 = RgbPixel<-1, 3, 2, 1>;
+using RGBX8888 = RgbPixel<-1, 0, 1, 2>;
+using BGRX8888 = RgbPixel<-1, 2, 1, 0>;
#define FETCH_INFO_PACKED(frame) \
const uchar *src = frame.bits(0); \
diff --git a/src/multimedia/video/qvideoframeconversionhelper_sse2.cpp b/src/multimedia/video/qvideoframeconversionhelper_sse2.cpp
index 50e12c07b..8c0092eb1 100644
--- a/src/multimedia/video/qvideoframeconversionhelper_sse2.cpp
+++ b/src/multimedia/video/qvideoframeconversionhelper_sse2.cpp
@@ -43,40 +43,50 @@
QT_BEGIN_NAMESPACE
-void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
+namespace {
+
+template<int a, int r, int b, int g>
+void convert_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
quint32 *argb = reinterpret_cast<quint32*>(output);
const __m128i zero = _mm_setzero_si128();
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ const uchar shuffle = _MM_SHUFFLE(a, r, b, g);
+#else
+ const uchar shuffle = _MM_SHUFFLE(3-a, 3-r, 3-b, 3-g);
+#endif
+
+ using Pixel = const RgbPixel<a, r, g, b>;
for (int y = 0; y < height; ++y) {
- const quint32 *bgra = reinterpret_cast<const quint32*>(src);
+ auto *pixel = reinterpret_cast<const Pixel *>(src);
int x = 0;
ALIGN(16, argb, x, width) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
for (; x < width - 3; x += 4) {
- __m128i pixelData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(bgra));
- bgra += 4;
- __m128i gaComponents = _mm_unpacklo_epi8(pixelData, zero);
- __m128i brComponents = _mm_unpackhi_epi8(pixelData, zero);
- gaComponents = _mm_shufflelo_epi16(_mm_shufflehi_epi16(gaComponents, _MM_SHUFFLE(0, 1, 2, 3)), _MM_SHUFFLE(0, 1, 2, 3)); // swap GA
- brComponents = _mm_shufflelo_epi16(_mm_shufflehi_epi16(brComponents, _MM_SHUFFLE(0, 1, 2, 3)), _MM_SHUFFLE(0, 1, 2, 3)); // swap BR
- pixelData = _mm_packus_epi16(gaComponents, brComponents);
+ __m128i pixelData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pixel));
+ pixel += 4;
+ __m128i lowPixels = _mm_unpacklo_epi8(pixelData, zero);
+ __m128i highPixels = _mm_unpackhi_epi8(pixelData, zero);
+ lowPixels = _mm_shufflelo_epi16(_mm_shufflehi_epi16(lowPixels, shuffle), shuffle);
+ highPixels = _mm_shufflelo_epi16(_mm_shufflehi_epi16(highPixels, shuffle), shuffle);
+ pixelData = _mm_packus_epi16(lowPixels, highPixels);
_mm_store_si128(reinterpret_cast<__m128i*>(argb), pixelData);
argb += 4;
}
// leftovers
for (; x < width; ++x) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
@@ -84,6 +94,28 @@ void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_sse2(const QVideoFrame &frame, ucha
}
}
+}
+
+void qt_convert_ARGB8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_sse2<0, 1, 2, 3>(frame, output);
+}
+
+void qt_convert_ABGR8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_sse2<0, 3, 2, 1>(frame, output);
+}
+
+void qt_convert_RGBA8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_sse2<3, 0, 1, 2>(frame, output);
+}
+
+void qt_convert_BGRA8888_to_ARGB32_sse2(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_sse2<3, 2, 1, 0>(frame, output);
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/multimedia/video/qvideoframeconversionhelper_ssse3.cpp b/src/multimedia/video/qvideoframeconversionhelper_ssse3.cpp
index 1e87c8e5c..c1acb9b08 100644
--- a/src/multimedia/video/qvideoframeconversionhelper_ssse3.cpp
+++ b/src/multimedia/video/qvideoframeconversionhelper_ssse3.cpp
@@ -43,28 +43,43 @@
QT_BEGIN_NAMESPACE
-void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
+namespace {
+
+template<int a, int r, int g, int b>
+void convert_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
{
FETCH_INFO_PACKED(frame)
MERGE_LOOPS(width, height, stride, 4)
quint32 *argb = reinterpret_cast<quint32*>(output);
- __m128i shuffleMask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3);
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ __m128i shuffleMask = _mm_set_epi8(12 + a, 12 + r, 12 + g, 12 + b,
+ 8 + a, 8 + r, 8 + g, 8 + b,
+ 4 + a, 4 + r, 4 + g, 4 + b,
+ 0 + a, 0 + r, 0 + g, 0 + b);
+#else
+ __m128i shuffleMask = _mm_set_epi8(15 - a, 15 - r, 15 - g, 15 - b,
+ 11 - a, 11 - r, 11 - g, 11 - b,
+ 7 - a, 7 - r, 7 - g, 7 - b,
+ 3 - a, 3 - r, 3 - g, 3 - b);
+#endif
+
+ using Pixel = const RgbPixel<a, r, g, b>;
for (int y = 0; y < height; ++y) {
- const quint32 *bgra = reinterpret_cast<const quint32*>(src);
+ const auto *pixel = reinterpret_cast<const Pixel *>(src);
int x = 0;
ALIGN(16, argb, x, width) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
for (; x < width - 7; x += 8) {
- __m128i pixelData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(bgra));
- __m128i pixelData2 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(bgra + 4));
- bgra += 8;
+ __m128i pixelData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pixel));
+ __m128i pixelData2 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(pixel + 4));
+ pixel += 8;
pixelData = _mm_shuffle_epi8(pixelData, shuffleMask);
pixelData2 = _mm_shuffle_epi8(pixelData2, shuffleMask);
_mm_store_si128(reinterpret_cast<__m128i*>(argb), pixelData);
@@ -74,8 +89,8 @@ void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_ssse3(const QVideoFrame &frame, uch
// leftovers
for (; x < width; ++x) {
- *argb = qConvertBGRA32ToARGB32(*bgra);
- ++bgra;
+ *argb = pixel->convert();
+ ++pixel;
++argb;
}
@@ -83,6 +98,28 @@ void QT_FASTCALL qt_convert_BGRA32_to_ARGB32_ssse3(const QVideoFrame &frame, uch
}
}
+}
+
+void QT_FASTCALL qt_convert_ARGB8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_ssse3<0, 1, 2, 3>(frame, output);
+}
+
+void qt_convert_ABGR8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_ssse3<0, 3, 2, 1>(frame, output);
+}
+
+void qt_convert_RGBA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_ssse3<3, 0, 1, 2>(frame, output);
+}
+
+void qt_convert_BGRA8888_to_ARGB32_ssse3(const QVideoFrame &frame, uchar *output)
+{
+ convert_to_ARGB32_ssse3<3, 2, 1, 0>(frame, output);
+}
+
QT_END_NAMESPACE
#endif
diff --git a/src/multimedia/video/qvideoframeformat.cpp b/src/multimedia/video/qvideoframeformat.cpp
index 940fdaf98..974858a44 100644
--- a/src/multimedia/video/qvideoframeformat.cpp
+++ b/src/multimedia/video/qvideoframeformat.cpp
@@ -128,34 +128,31 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFrameFormatPrivate);
\value Format_Invalid
The frame is invalid.
- \value Format_ARGB32
- The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent to
- QImage::Format_ARGB32.
+ \value Format_ARGB8888
+ The frame is stored using a ARGB format with 8 bits per component.
- \value Format_ARGB32_Premultiplied
- The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent
- to QImage::Format_ARGB32_Premultiplied.
+ \value Format_ARGB8888_Premultiplied
+ The frame stored using a premultiplied ARGB format with 8 bits per component.
- \value Format_RGB32
- The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent to
- QImage::Format_RGB32
+ \value Format_XRGB8888
+ The frame stored using a 32 bits per pixel RGB format (0xff, R, G, B).
- \value Format_BGRA32
+ \value Format_BGRA8888
The frame is stored using a 32-bit BGRA format (0xBBGGRRAA).
- \value Format_BGRA32_Premultiplied
+ \value Format_BGRA8888_Premultiplied
The frame is stored using a premultiplied 32bit BGRA format.
- \value Format_ABGR32
+ \value Format_ABGR8888
The frame is stored using a 32-bit ABGR format (0xAABBGGRR).
- \value Format_BGR32
- The frame is stored using a 32-bit BGR format (0xBBGGRRff).
+ \value Format_XBGR8888
+ The frame is stored using a 32-bit BGR format (0xffBBGGRR).
- \value Format_AYUV444
+ \value Format_AYUV
The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV).
- \value Format_AYUV444_Premultiplied
+ \value Format_AYUV_Premultiplied
The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV).
\value Format_YUV420P
@@ -564,15 +561,27 @@ void QVideoFrameFormat::updateUniformData(QByteArray *dst, const QVideoFrame &fr
QVideoFrameFormat::PixelFormat QVideoFrameFormat::pixelFormatFromImageFormat(QImage::Format format)
{
switch (format) {
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
case QImage::Format_RGB32:
- case QImage::Format_RGBX8888:
- return QVideoFrameFormat::Format_RGB32;
+ return QVideoFrameFormat::Format_BGRX8888;
case QImage::Format_ARGB32:
- case QImage::Format_RGBA8888:
- return QVideoFrameFormat::Format_ARGB32;
+ return QVideoFrameFormat::Format_BGRA8888;
+ case QImage::Format_ARGB32_Premultiplied:
+ return QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+#else
+ case QImage::Format_RGB32:
+ return QVideoFrameFormat::Format_XRGB8888;
+ case QImage::Format_ARGB32:
+ return QVideoFrameFormat::Format_ARGB8888;
case QImage::Format_ARGB32_Premultiplied:
+ return QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+#endif
+ case QImage::Format_RGBA8888:
+ return QVideoFrameFormat::Format_RGBA8888;
case QImage::Format_RGBA8888_Premultiplied:
- return QVideoFrameFormat::Format_ARGB32_Premultiplied;
+ return QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+ case QImage::Format_RGBX8888:
+ return QVideoFrameFormat::Format_RGBX8888;
case QImage::Format_Grayscale8:
return QVideoFrameFormat::Format_Y8;
case QImage::Format_Grayscale16:
@@ -592,22 +601,41 @@ QVideoFrameFormat::PixelFormat QVideoFrameFormat::pixelFormatFromImageFormat(QIm
QImage::Format QVideoFrameFormat::imageFormatFromPixelFormat(QVideoFrameFormat::PixelFormat format)
{
switch (format) {
- case QVideoFrameFormat::Format_ARGB32:
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ case QVideoFrameFormat::Format_BGRA8888:
+ return QImage::Format_ARGB32;
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ return QImage::Format_ARGB32_Premultiplied;
+ case QVideoFrameFormat::Format_BGRX8888:
+ return QImage::Format_RGB32;
+ case QVideoFrameFormat::Format_ARGB8888:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ case QVideoFrameFormat::Format_XRGB8888:
+ return QImage::Format_Invalid;
+#else
+ case QVideoFrameFormat::Format_ARGB8888:
return QImage::Format_ARGB32;
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
return QImage::Format_ARGB32_Premultiplied;
- case QVideoFrameFormat::Format_RGB32:
+ case QVideoFrameFormat::Format_XRGB8888:
return QImage::Format_RGB32;
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ case QVideoFrameFormat::Format_BGRX8888:
+ return QImage::Format_Invalid;
+#endif
+ case QVideoFrameFormat::Format_RGBA8888:
+ return QImage::Format_RGBA8888;
+ case QVideoFrameFormat::Format_RGBX8888:
+ return QImage::Format_RGBX8888;
case QVideoFrameFormat::Format_Y8:
return QImage::Format_Grayscale8;
case QVideoFrameFormat::Format_Y16:
return QImage::Format_Grayscale16;
- case QVideoFrameFormat::Format_ABGR32:
- case QVideoFrameFormat::Format_BGRA32:
- case QVideoFrameFormat::Format_BGRA32_Premultiplied:
- case QVideoFrameFormat::Format_BGR32:
- case QVideoFrameFormat::Format_AYUV444:
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
+ case QVideoFrameFormat::Format_ABGR8888:
+ case QVideoFrameFormat::Format_XBGR8888:
+ case QVideoFrameFormat::Format_AYUV:
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
case QVideoFrameFormat::Format_YUV420P:
case QVideoFrameFormat::Format_YUV422P:
case QVideoFrameFormat::Format_YV12:
@@ -697,24 +725,30 @@ QDebug operator<<(QDebug dbg, QVideoFrameFormat::PixelFormat pf)
switch (pf) {
case QVideoFrameFormat::Format_Invalid:
return dbg << "Format_Invalid";
- case QVideoFrameFormat::Format_ARGB32:
- return dbg << "Format_ARGB32";
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
- return dbg << "Format_ARGB32_Premultiplied";
- case QVideoFrameFormat::Format_RGB32:
- return dbg << "Format_RGB32";
- case QVideoFrameFormat::Format_BGRA32:
- return dbg << "Format_BGRA32";
- case QVideoFrameFormat::Format_BGRA32_Premultiplied:
- return dbg << "Format_BGRA32_Premultiplied";
- case QVideoFrameFormat::Format_ABGR32:
- return dbg << "Format_ABGR32";
- case QVideoFrameFormat::Format_BGR32:
- return dbg << "Format_BGR32";
- case QVideoFrameFormat::Format_AYUV444:
- return dbg << "Format_AYUV444";
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
- return dbg << "Format_AYUV444_Premultiplied";
+ case QVideoFrameFormat::Format_ARGB8888:
+ return dbg << "Format_ARGB8888";
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ return dbg << "Format_ARGB8888_Premultiplied";
+ case QVideoFrameFormat::Format_XRGB8888:
+ return dbg << "Format_XRGB8888";
+ case QVideoFrameFormat::Format_BGRA8888:
+ return dbg << "Format_BGRA8888";
+ case QVideoFrameFormat::Format_BGRX8888:
+ return dbg << "Format_BGRX8888";
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ return dbg << "Format_BGRA8888_Premultiplied";
+ case QVideoFrameFormat::Format_RGBA8888:
+ return dbg << "Format_RGBA8888";
+ case QVideoFrameFormat::Format_RGBX8888:
+ return dbg << "Format_RGBX8888";
+ case QVideoFrameFormat::Format_ABGR8888:
+ return dbg << "Format_ABGR8888";
+ case QVideoFrameFormat::Format_XBGR8888:
+ return dbg << "Format_XBGR8888";
+ case QVideoFrameFormat::Format_AYUV:
+ return dbg << "Format_AYUV";
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
+ return dbg << "Format_AYUV_Premultiplied";
case QVideoFrameFormat::Format_YUV420P:
return dbg << "Format_YUV420P";
case QVideoFrameFormat::Format_YUV422P:
@@ -745,12 +779,12 @@ QDebug operator<<(QDebug dbg, QVideoFrameFormat::PixelFormat pf)
return dbg << "Format_P010";
case QVideoFrameFormat::Format_P016:
return dbg << "Format_P016";
+ case QVideoFrameFormat::Format_SamplerExternalOES:
+ return dbg << "Format_SamplerExternalOES";
case QVideoFrameFormat::Format_Jpeg:
return dbg << "Format_Jpeg";
-
- default:
- return dbg << QString(QLatin1String("UserType(%1)" )).arg(int(pf)).toLatin1().constData();
}
+ return dbg;
}
#endif
diff --git a/src/multimedia/video/qvideoframeformat.h b/src/multimedia/video/qvideoframeformat.h
index bfab9ebb3..ddea655dd 100644
--- a/src/multimedia/video/qvideoframeformat.h
+++ b/src/multimedia/video/qvideoframeformat.h
@@ -65,16 +65,19 @@ public:
enum PixelFormat
{
Format_Invalid,
- Format_ARGB32,
- Format_ARGB32_Premultiplied,
- Format_RGB32,
- Format_BGRA32,
- Format_BGRA32_Premultiplied,
- Format_ABGR32,
- Format_BGR32,
-
- Format_AYUV444,
- Format_AYUV444_Premultiplied,
+ Format_ARGB8888,
+ Format_ARGB8888_Premultiplied,
+ Format_XRGB8888,
+ Format_BGRA8888,
+ Format_BGRA8888_Premultiplied,
+ Format_BGRX8888,
+ Format_ABGR8888,
+ Format_XBGR8888,
+ Format_RGBA8888,
+ Format_RGBX8888,
+
+ Format_AYUV,
+ Format_AYUV_Premultiplied,
Format_YUV420P,
Format_YUV422P,
Format_YV12,
diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp
index cca4720ae..2fd3edeef 100644
--- a/src/multimedia/video/qvideotexturehelper.cpp
+++ b/src/multimedia/video/qvideotexturehelper.cpp
@@ -54,61 +54,78 @@ static const TextureDescription descriptions[QVideoFrameFormat::NPixelFormats] =
{ QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat},
{ { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_ARGB32
+ // Format_ARGB8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_ARGB32_Premultiplied
+ // Format_ARGB8888_Premultiplied
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_RGB32
+ // Format_XRGB8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_BGRA32
+ // Format_BGRA8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_BGRA32_Premultiplied
+ // Format_BGRA8888_Premultiplied
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_ABGR32
+ // Format_BGRX8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_BGR32
+ // Format_ABGR8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
-
- // Format_AYUV444
+ // Format_XBGR8888
{ 1, 4,
- [](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ },
+ // Format_RGBA8888
+ { 1, 4,
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
- // Format_AYUV444_Premultiplied
+ // Format_RGBX8888
+ { 1, 4,
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ },
+ // Format_AYUV
{ 1, 4,
[](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
{ { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
+ // Format_AYUV_Premultiplied
+ { 1, 4,
+ [](int stride, int height) { return stride*height; },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { { 1, 1 }, { 1, 1 }, { 1, 1 } }
+ },
// Format_YUV420P
{ 3, 1,
[](int stride, int height) { return stride * ((height * 3 / 2 + 1) & ~1); },
@@ -130,13 +147,13 @@ static const TextureDescription descriptions[QVideoFrameFormat::NPixelFormats] =
// Format_UYVY
{ 1, 2,
[](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
{ { 2, 1 }, { 1, 1 }, { 1, 1 } }
},
// Format_YUYV
{ 1, 2,
[](int stride, int height) { return stride*height; },
- { QRhiTexture::BGRA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
+ { QRhiTexture::RGBA8, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
{ { 2, 1 }, { 1, 1 }, { 1, 1 } }
},
// Format_NV12
@@ -197,21 +214,6 @@ static const TextureDescription descriptions[QVideoFrameFormat::NPixelFormats] =
{ QRhiTexture::R16, QRhiTexture::UnknownFormat, QRhiTexture::UnknownFormat },
{ { 1, 1 }, { 1, 1 }, { 1, 1 } }
},
-#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
- // Rendering of those formats pre 6.2 will be wrong, as RHI doesn't yet support the correct texture formats
- // Format_P010
- { 2, 2,
- [](int stride, int height) { return stride * ((height * 3 / 2 + 1) & ~1); },
- { QRhiTexture::RG8, QRhiTexture::RGBA8, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 2, 2 }, { 1, 1 } }
- },
- // Format_P016
- { 2, 2,
- [](int stride, int height) { return stride * ((height * 3 / 2 + 1) & ~1); },
- { QRhiTexture::RG8, QRhiTexture::RGBA8, QRhiTexture::UnknownFormat },
- { { 1, 1 }, { 2, 2 }, { 1, 1 } }
- },
-#else
// Format_P010
{ 2, 2,
[](int stride, int height) { return stride * ((height * 3 / 2 + 1) & ~1); },
@@ -224,7 +226,6 @@ static const TextureDescription descriptions[QVideoFrameFormat::NPixelFormats] =
{ QRhiTexture::R16, QRhiTexture::RG16, QRhiTexture::UnknownFormat },
{ { 1, 1 }, { 2, 2 }, { 1, 1 } }
},
-#endif
// Format_SamplerExternalOES
{
1, 0,
@@ -250,7 +251,7 @@ QString vertexShaderFileName(QVideoFrameFormat::PixelFormat format)
{
Q_UNUSED(format);
-#ifdef Q_OS_ANDROID
+#if 1//def Q_OS_ANDROID
if (format == QVideoFrameFormat::Format_SamplerExternalOES)
return QStringLiteral(":/qt-project.org/multimedia/shaders/externalsampler.vert.qsb");
#endif
@@ -264,19 +265,23 @@ QString fragmentShaderFileName(QVideoFrameFormat::PixelFormat format)
case QVideoFrameFormat::Format_Y8:
case QVideoFrameFormat::Format_Y16:
return QStringLiteral(":/qt-project.org/multimedia/shaders/y.frag.qsb");
- case QVideoFrameFormat::Format_AYUV444:
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
+ case QVideoFrameFormat::Format_AYUV:
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
return QStringLiteral(":/qt-project.org/multimedia/shaders/ayuv.frag.qsb");
- case QVideoFrameFormat::Format_ARGB32:
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
- case QVideoFrameFormat::Format_RGB32:
+ case QVideoFrameFormat::Format_ARGB8888:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ case QVideoFrameFormat::Format_XRGB8888:
return QStringLiteral(":/qt-project.org/multimedia/shaders/argb.frag.qsb");
- case QVideoFrameFormat::Format_BGRA32:
- case QVideoFrameFormat::Format_BGRA32_Premultiplied:
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ case QVideoFrameFormat::Format_BGRX8888:
return QStringLiteral(":/qt-project.org/multimedia/shaders/bgra.frag.qsb");
- case QVideoFrameFormat::Format_ABGR32:
- case QVideoFrameFormat::Format_BGR32:
+ case QVideoFrameFormat::Format_ABGR8888:
+ case QVideoFrameFormat::Format_XBGR8888:
return QStringLiteral(":/qt-project.org/multimedia/shaders/abgr.frag.qsb");
+ case QVideoFrameFormat::Format_RGBA8888:
+ case QVideoFrameFormat::Format_RGBX8888:
+ return QStringLiteral(":/qt-project.org/multimedia/shaders/rgba.frag.qsb");
case QVideoFrameFormat::Format_YUV420P:
case QVideoFrameFormat::Format_YUV422P:
case QVideoFrameFormat::Format_IMC3:
@@ -300,10 +305,12 @@ QString fragmentShaderFileName(QVideoFrameFormat::PixelFormat format)
case QVideoFrameFormat::Format_NV21:
return QStringLiteral(":/qt-project.org/multimedia/shaders/nv21.frag.qsb");
case QVideoFrameFormat::Format_SamplerExternalOES:
-#ifdef Q_OS_ANDROID
+#if 1//def Q_OS_ANDROID
return QStringLiteral(":/qt-project.org/multimedia/shaders/externalsampler.frag.qsb");
#endif
// fallthrough
+ case QVideoFrameFormat::Format_Invalid:
+ case QVideoFrameFormat::Format_Jpeg:
default:
return QString();
}
@@ -379,13 +386,16 @@ void updateUniformData(QByteArray *dst, const QVideoFrameFormat &format, const Q
case QVideoFrameFormat::Format_Jpeg:
return;
- case QVideoFrameFormat::Format_ARGB32:
- case QVideoFrameFormat::Format_ARGB32_Premultiplied:
- case QVideoFrameFormat::Format_RGB32:
- case QVideoFrameFormat::Format_BGRA32:
- case QVideoFrameFormat::Format_BGRA32_Premultiplied:
- case QVideoFrameFormat::Format_ABGR32:
- case QVideoFrameFormat::Format_BGR32:
+ case QVideoFrameFormat::Format_ARGB8888:
+ case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
+ case QVideoFrameFormat::Format_XRGB8888:
+ case QVideoFrameFormat::Format_BGRA8888:
+ case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
+ case QVideoFrameFormat::Format_BGRX8888:
+ case QVideoFrameFormat::Format_ABGR8888:
+ case QVideoFrameFormat::Format_XBGR8888:
+ case QVideoFrameFormat::Format_RGBA8888:
+ case QVideoFrameFormat::Format_RGBX8888:
case QVideoFrameFormat::Format_Y8:
case QVideoFrameFormat::Format_Y16:
@@ -394,8 +404,8 @@ void updateUniformData(QByteArray *dst, const QVideoFrameFormat &format, const Q
case QVideoFrameFormat::Format_IMC2:
case QVideoFrameFormat::Format_IMC3:
case QVideoFrameFormat::Format_IMC4:
- case QVideoFrameFormat::Format_AYUV444:
- case QVideoFrameFormat::Format_AYUV444_Premultiplied:
+ case QVideoFrameFormat::Format_AYUV:
+ case QVideoFrameFormat::Format_AYUV_Premultiplied:
case QVideoFrameFormat::Format_YUV420P:
case QVideoFrameFormat::Format_YUV422P:
case QVideoFrameFormat::Format_YV12:
diff --git a/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp b/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp
index 9ec6bcee4..a0edac4f1 100644
--- a/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp
+++ b/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp
@@ -45,7 +45,7 @@
void presentDummyFrame(QVideoSink *sink, const QSize &size)
{
if (sink) {
- QVideoFrameFormat format(size, QVideoFrameFormat::Format_ARGB32_Premultiplied);
+ QVideoFrameFormat format(size, QVideoFrameFormat::Format_ARGB8888_Premultiplied);
QVideoFrame frame(format);
sink->newVideoFrame(frame);
@@ -309,7 +309,7 @@ void tst_QQuickVideoOutput::paintSurface()
QVERIFY(surface);
videoOutput->setSize(QSize(2, 2));
- QVideoFrame frame(QVideoFrameFormat(QSize(4, 4), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(QVideoFrameFormat(QSize(4, 4), QVideoFrameFormat::Format_ARGB8888));
frame.map(QVideoFrame::ReadWrite);
QCOMPARE(frame.mappedBytes(0), 64);
memcpy(frame.bits(0), rgb32ImageData, 64);
diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp
index 5ff6d0e11..c10400bf7 100644
--- a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp
+++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp
@@ -174,7 +174,7 @@ void tst_QVideoFrame::create_data()
QTest::newRow("64x64 ARGB32")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32;
+ << QVideoFrameFormat::Format_ARGB8888;
QTest::newRow("32x256 YUV420P")
<< QSize(32, 256)
<< QVideoFrameFormat::Format_YUV420P;
@@ -205,7 +205,7 @@ void tst_QVideoFrame::createInvalid_data()
QTest::newRow("0x64 ARGB32 0 size")
<< QSize(0, 64)
- << QVideoFrameFormat::Format_ARGB32;
+ << QVideoFrameFormat::Format_ARGB8888;
QTest::newRow("32x0 YUV420P 0 size")
<< QSize(32, 0)
<< QVideoFrameFormat::Format_YUV420P;
@@ -238,11 +238,11 @@ void tst_QVideoFrame::createFromBuffer_data()
QTest::newRow("64x64 ARGB32 no handle")
<< QVideoFrame::NoHandle
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32;
+ << QVideoFrameFormat::Format_ARGB8888;
QTest::newRow("64x64 ARGB32 gl handle")
<< QVideoFrame::RhiTextureHandle
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32;
+ << QVideoFrameFormat::Format_ARGB8888;
}
void tst_QVideoFrame::createFromBuffer()
@@ -272,11 +272,11 @@ void tst_QVideoFrame::createFromImage_data()
QTest::newRow("64x64 RGB32")
<< QSize(64, 64)
<< QImage::Format_RGB32
- << QVideoFrameFormat::Format_RGB32;
+ << QVideoFrameFormat::Format_XRGB8888;
QTest::newRow("19x46 ARGB32_Premultiplied")
<< QSize(19, 46)
<< QImage::Format_ARGB32_Premultiplied
- << QVideoFrameFormat::Format_ARGB32_Premultiplied;
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
}
void tst_QVideoFrame::createNull()
@@ -305,10 +305,10 @@ void tst_QVideoFrame::createNull()
// Null buffer (shouldn't crash)
{
- QVideoFrame frame(nullptr, QVideoFrameFormat(QSize(1024,768), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(nullptr, QVideoFrameFormat(QSize(1024,768), QVideoFrameFormat::Format_ARGB8888));
QVERIFY(!frame.isValid());
QCOMPARE(frame.handleType(), QVideoFrame::NoHandle);
- QCOMPARE(frame.pixelFormat(), QVideoFrameFormat::Format_ARGB32);
+ QCOMPARE(frame.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
QCOMPARE(frame.size(), QSize(1024, 768));
QCOMPARE(frame.width(), 1024);
QCOMPARE(frame.height(), 768);
@@ -330,7 +330,7 @@ void tst_QVideoFrame::destructor()
QPointer<QtTestDummyVideoBuffer> buffer = new QtTestDummyVideoBuffer;
{
- QVideoFrame frame(buffer, QVideoFrameFormat(QSize(4, 1), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(buffer, QVideoFrameFormat(QSize(4, 1), QVideoFrameFormat::Format_ARGB8888));
}
QVERIFY(buffer.isNull());
@@ -347,13 +347,13 @@ void tst_QVideoFrame::copy_data()
QTest::newRow("64x64 ARGB32")
<< QVideoFrame::RhiTextureHandle
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< qint64(63641740)
<< qint64(63641954);
QTest::newRow("64x64 ARGB32")
<< QVideoFrame::RhiTextureHandle
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< qint64(63641740)
<< qint64(63641954);
QTest::newRow("32x256 YUV420P")
@@ -365,7 +365,7 @@ void tst_QVideoFrame::copy_data()
QTest::newRow("1052x756 ARGB32")
<< QVideoFrame::NoHandle
<< QSize(1052, 756)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< qint64(12345)
<< qint64(12389);
QTest::newRow("32x256 YUV420P")
@@ -454,7 +454,7 @@ void tst_QVideoFrame::assign_data()
QTest::newRow("64x64 ARGB32")
<< QVideoFrame::RhiTextureHandle
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< qint64(63641740)
<< qint64(63641954);
QTest::newRow("32x256 YUV420P")
@@ -541,17 +541,17 @@ void tst_QVideoFrame::map_data()
QTest::newRow("read-only")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< QVideoFrame::ReadOnly;
QTest::newRow("write-only")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< QVideoFrame::WriteOnly;
QTest::newRow("read-write")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< QVideoFrame::ReadWrite;
}
@@ -658,7 +658,7 @@ void tst_QVideoFrame::mapPlanes_data()
<< (QList<int>() << 64 << 64 << 64)
<< (QList<int>() << 4096 << 6144);
QTest::newRow("Format_ARGB32")
- << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_ARGB32))
+ << QVideoFrame(QVideoFrameFormat(QSize(60, 64), QVideoFrameFormat::Format_ARGB8888))
<< (QList<int>() << 240)
<< (QList<int>());
}
@@ -699,15 +699,27 @@ void tst_QVideoFrame::formatConversion_data()
QTest::addColumn<QImage::Format>("imageFormat");
QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat");
- QTest::newRow("QImage::Format_RGB32 | QVideoFrameFormat::Format_RGB32")
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ QTest::newRow("QImage::Format_RGB32 | QVideoFrameFormat::Format_BGRX8888")
<< QImage::Format_RGB32
- << QVideoFrameFormat::Format_RGB32;
- QTest::newRow("QImage::Format_ARGB32 | QVideoFrameFormat::Format_ARGB32")
+ << QVideoFrameFormat::Format_BGRX8888;
+ QTest::newRow("QImage::Format_ARGB32 | QVideoFrameFormat::Format_BGRA8888")
<< QImage::Format_ARGB32
- << QVideoFrameFormat::Format_ARGB32;
- QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrameFormat::Format_ARGB32_Premultiplied")
+ << QVideoFrameFormat::Format_BGRA8888;
+ QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrameFormat::Format_BGRA8888_Premultiplied")
<< QImage::Format_ARGB32_Premultiplied
- << QVideoFrameFormat::Format_ARGB32_Premultiplied;
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
+#else
+ QTest::newRow("QImage::Format_RGB32 | QVideoFrameFormat::Format_XRGB8888")
+ << QImage::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888;
+ QTest::newRow("QImage::Format_ARGB32 | QVideoFrameFormat::Format_ARGB8888")
+ << QImage::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888;
+ QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrameFormat::Format_ARGB8888_Premultiplied")
+ << QImage::Format_ARGB32_Premultiplied
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied;
+#endif
QTest::newRow("QImage::Format_MonoLSB")
<< QImage::Format_MonoLSB
@@ -733,19 +745,19 @@ void tst_QVideoFrame::formatConversion_data()
QTest::newRow("QVideoFrameFormat::Format_BGRA32")
<< QImage::Format_Invalid
- << QVideoFrameFormat::Format_BGRA32;
+ << QVideoFrameFormat::Format_BGRA8888;
QTest::newRow("QVideoFrameFormat::Format_BGRA32_Premultiplied")
<< QImage::Format_Invalid
- << QVideoFrameFormat::Format_BGRA32_Premultiplied;
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied;
QTest::newRow("QVideoFrameFormat::Format_BGR32")
<< QImage::Format_Invalid
- << QVideoFrameFormat::Format_BGR32;
- QTest::newRow("QVideoFrameFormat::Format_AYUV444")
+ << QVideoFrameFormat::Format_XBGR8888;
+ QTest::newRow("QVideoFrameFormat::Format_AYUV")
<< QImage::Format_Invalid
- << QVideoFrameFormat::Format_AYUV444;
- QTest::newRow("QVideoFrameFormat::Format_AYUV444_Premultiplied")
+ << QVideoFrameFormat::Format_AYUV;
+ QTest::newRow("QVideoFrameFormat::Format_AYUV_Premultiplied")
<< QImage::Format_Invalid
- << QVideoFrameFormat::Format_AYUV444_Premultiplied;
+ << QVideoFrameFormat::Format_AYUV_Premultiplied;
QTest::newRow("QVideoFrameFormat::Format_YUV420P")
<< QImage::Format_Invalid
<< QVideoFrameFormat::Format_YUV420P;
@@ -819,7 +831,7 @@ do { \
void tst_QVideoFrame::isMapped()
{
- QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
const QVideoFrame& constFrame(frame);
TEST_UNMAPPED(frame);
@@ -849,7 +861,7 @@ void tst_QVideoFrame::isMapped()
void tst_QVideoFrame::isReadable()
{
- QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
QVERIFY(!frame.isMapped());
QVERIFY(!frame.isReadable());
@@ -872,7 +884,7 @@ void tst_QVideoFrame::isReadable()
void tst_QVideoFrame::isWritable()
{
- QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrame frame(QVideoFrameFormat(QSize(64, 64), QVideoFrameFormat::Format_ARGB8888));
QVERIFY(!frame.isMapped());
QVERIFY(!frame.isWritable());
@@ -901,37 +913,37 @@ void tst_QVideoFrame::image_data()
QTest::newRow("64x64 ARGB32")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32
+ << QVideoFrameFormat::Format_ARGB8888
<< QImage::Format_ARGB32;
QTest::newRow("64x64 ARGB32_Premultiplied")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_ARGB32_Premultiplied
+ << QVideoFrameFormat::Format_ARGB8888_Premultiplied
<< QImage::Format_ARGB32_Premultiplied;
QTest::newRow("64x64 RGB32")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888
<< QImage::Format_RGB32;
QTest::newRow("64x64 BGRA32")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_BGRA32
+ << QVideoFrameFormat::Format_BGRA8888
<< QImage::Format_ARGB32_Premultiplied;
QTest::newRow("64x64 BGRA32_Premultiplied")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_BGRA32_Premultiplied
+ << QVideoFrameFormat::Format_BGRA8888_Premultiplied
<< QImage::Format_ARGB32_Premultiplied;
QTest::newRow("64x64 BGR32")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_BGR32
+ << QVideoFrameFormat::Format_XBGR8888
<< QImage::Format_RGB32;
- QTest::newRow("64x64 AYUV444")
+ QTest::newRow("64x64 AYUV")
<< QSize(64, 64)
- << QVideoFrameFormat::Format_AYUV444
+ << QVideoFrameFormat::Format_AYUV
<< QImage::Format_ARGB32_Premultiplied;
QTest::newRow("64x64 YUV420P")
@@ -983,7 +995,7 @@ void tst_QVideoFrame::emptyData()
{
QByteArray data(nullptr, 0);
QVideoFrame f(new QMemoryVideoBuffer(data, 600),
- QVideoFrameFormat(QSize(800, 600), QVideoFrameFormat::Format_ARGB32));
+ QVideoFrameFormat(QSize(800, 600), QVideoFrameFormat::Format_ARGB8888));
QVERIFY(!f.map(QVideoFrame::ReadOnly));
}
diff --git a/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp
index 22b6b739a..4dcada327 100644
--- a/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp
+++ b/tests/auto/unit/multimedia/qvideoframeformat/tst_qvideoframeformat.cpp
@@ -121,7 +121,7 @@ void tst_QVideoFrameFormat::construct_data()
QTest::newRow("32x32 rgb32 no handle")
<< QSize(32, 32)
- << QVideoFrameFormat::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888
<< true;
QTest::newRow("32x32 invalid no handle")
@@ -131,12 +131,12 @@ void tst_QVideoFrameFormat::construct_data()
QTest::newRow("invalid size, rgb32 no handle")
<< QSize()
- << QVideoFrameFormat::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888
<< false;
QTest::newRow("0x0 rgb32 no handle")
<< QSize(0,0)
- << QVideoFrameFormat::Format_RGB32
+ << QVideoFrameFormat::Format_XRGB8888
<< true;
}
@@ -182,7 +182,7 @@ void tst_QVideoFrameFormat::frameSize()
QFETCH(QSize, initialSize);
QFETCH(QSize, newSize);
- QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_XRGB8888);
format.setFrameSize(newSize);
@@ -224,7 +224,7 @@ void tst_QVideoFrameFormat::viewport()
QRect initialViewport(QPoint(0, 0), initialSize);
- QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(initialSize, QVideoFrameFormat::Format_XRGB8888);
format.setViewport(viewport);
@@ -249,7 +249,7 @@ void tst_QVideoFrameFormat::scanLineDirection()
QFETCH(QVideoFrameFormat::Direction, direction);
QFETCH(QString, stringized);
- QVideoFrameFormat format(QSize(16, 16), QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
format.setScanLineDirection(direction);
@@ -278,7 +278,7 @@ void tst_QVideoFrameFormat::yCbCrColorSpaceEnum()
QFETCH(QVideoFrameFormat::YCbCrColorSpace, colorspace);
QFETCH(QString, stringized);
- QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_XRGB8888);
format.setYCbCrColorSpace(colorspace);
QCOMPARE(format.yCbCrColorSpace(), colorspace);
@@ -306,7 +306,7 @@ void tst_QVideoFrameFormat::frameRate()
{
QFETCH(qreal, frameRate);
- QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(QSize(64, 64), QVideoFrameFormat::Format_XRGB8888);
format.setFrameRate(frameRate);
@@ -316,13 +316,13 @@ void tst_QVideoFrameFormat::frameRate()
void tst_QVideoFrameFormat::compare()
{
QVideoFrameFormat format1(
- QSize(16, 16), QVideoFrameFormat::Format_RGB32);
+ QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
QVideoFrameFormat format2(
- QSize(16, 16), QVideoFrameFormat::Format_RGB32);
+ QSize(16, 16), QVideoFrameFormat::Format_XRGB8888);
QVideoFrameFormat format3(
- QSize(32, 32), QVideoFrameFormat::Format_AYUV444);
+ QSize(32, 32), QVideoFrameFormat::Format_AYUV);
QVideoFrameFormat format4(
- QSize(16, 16), QVideoFrameFormat::Format_BGR32);
+ QSize(16, 16), QVideoFrameFormat::Format_XBGR8888);
QCOMPARE(format1 == format2, true);
QCOMPARE(format1 != format2, false);
@@ -397,12 +397,12 @@ void tst_QVideoFrameFormat::compare()
void tst_QVideoFrameFormat::copy()
{
QVideoFrameFormat original(
- QSize(1024, 768), QVideoFrameFormat::Format_ARGB32);
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
QVideoFrameFormat copy(original);
- QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB32);
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
QCOMPARE(copy.frameSize(), QSize(1024, 768));
QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
@@ -422,15 +422,15 @@ void tst_QVideoFrameFormat::copy()
void tst_QVideoFrameFormat::assign()
{
QVideoFrameFormat copy(
- QSize(64, 64), QVideoFrameFormat::Format_AYUV444);
+ QSize(64, 64), QVideoFrameFormat::Format_AYUV);
QVideoFrameFormat original(
- QSize(1024, 768), QVideoFrameFormat::Format_ARGB32);
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
copy = original;
- QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB32);
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
QCOMPARE(copy.frameSize(), QSize(1024, 768));
QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
@@ -461,7 +461,7 @@ void tst_QVideoFrameFormat::isValid()
QVERIFY(!format.isValid());
/* When both the pixel format and framesize is valid. */
- QVideoFrameFormat format1(QSize(32, 32), QVideoFrameFormat::Format_AYUV444);
+ QVideoFrameFormat format1(QSize(32, 32), QVideoFrameFormat::Format_AYUV);
QVERIFY(format1.isValid());
/* When pixel format is valid and frame size is not valid */
@@ -475,7 +475,7 @@ void tst_QVideoFrameFormat::copyAllParameters()
{
/* Create the instance and set all the parameters. */
QVideoFrameFormat original(
- QSize(1024, 768), QVideoFrameFormat::Format_ARGB32);
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
original.setViewport(QRect(0, 0, 1024, 1024));
@@ -486,7 +486,7 @@ void tst_QVideoFrameFormat::copyAllParameters()
have the same parameters. */
QVideoFrameFormat copy(original);
- QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB32);
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
QCOMPARE(copy.frameSize(), QSize(1024, 768));
QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
@@ -503,7 +503,7 @@ void tst_QVideoFrameFormat::assignAllParameters()
{
/* Create the instance and set all the parameters. */
QVideoFrameFormat copy(
- QSize(64, 64), QVideoFrameFormat::Format_AYUV444);
+ QSize(64, 64), QVideoFrameFormat::Format_AYUV);
copy.setScanLineDirection(QVideoFrameFormat::TopToBottom);
copy.setViewport(QRect(0, 0, 640, 320));
copy.setFrameRate(qreal(7.5));
@@ -511,7 +511,7 @@ void tst_QVideoFrameFormat::assignAllParameters()
/* Create the instance and set all the parameters. */
QVideoFrameFormat original(
- QSize(1024, 768), QVideoFrameFormat::Format_ARGB32);
+ QSize(1024, 768), QVideoFrameFormat::Format_ARGB8888);
original.setScanLineDirection(QVideoFrameFormat::BottomToTop);
original.setViewport(QRect(0, 0, 1024, 1024));
original.setFrameRate(qreal(15.0));
@@ -521,7 +521,7 @@ void tst_QVideoFrameFormat::assignAllParameters()
have the same parameters. */
copy = original;
- QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB32);
+ QCOMPARE(copy.pixelFormat(), QVideoFrameFormat::Format_ARGB8888);
QCOMPARE(copy.frameSize(), QSize(1024, 768));
QCOMPARE(copy.scanLineDirection(), QVideoFrameFormat::BottomToTop);
QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024));
diff --git a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
index 003c131ae..b9cbfeb7c 100644
--- a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
+++ b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp
@@ -243,7 +243,7 @@ void tst_QGraphicsVideoItem::nativeSize()
QSignalSpy spy(&item, SIGNAL(nativeSizeChanged(QSizeF)));
- QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB32);
+ QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB8888);
format.setViewport(viewport);
QVideoFrame frame(format);
item.videoSink()->newVideoFrame(frame);
@@ -371,7 +371,7 @@ void tst_QGraphicsVideoItem::boundingRect()
item.setSize(size);
item.setAspectRatioMode(aspectRatioMode);
- QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB32);
+ QVideoFrameFormat format(frameSize, QVideoFrameFormat::Format_ARGB8888);
QVideoFrame frame(format);
item.videoSink()->newVideoFrame(frame);
@@ -400,7 +400,7 @@ void tst_QGraphicsVideoItem::paint()
auto *sink = item->videoSink();
Q_ASSERT(sink);
- QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_XRGB8888);
QVideoFrame frame(format);
frame.map(QVideoFrame::WriteOnly);
memcpy(frame.bits(0), rgb32ImageData, frame.mappedBytes(0));
diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp
index 75ec4c93c..c937e59b4 100644
--- a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp
+++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp
@@ -514,7 +514,7 @@ void tst_QVideoWidget::paint()
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_RGB32);
+ QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_XRGB8888);
QVideoFrame frame(format);
QVERIFY(frame.map(QVideoFrame::ReadWrite));
uchar *data = frame.bits(0);