Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qvideoframeconverter.cpp File Reference
#include "qvideoframeconverter_p.h"
#include "qvideoframeconversionhelper_p.h"
#include "qvideoframeformat.h"
#include <QtCore/qcoreapplication.h>
#include <QtCore/qsize.h>
#include <QtCore/qhash.h>
#include <QtCore/qfile.h>
#include <QtCore/qthreadstorage.h>
#include <QtGui/qimage.h>
#include <QtGui/qoffscreensurface.h>
#include <qpa/qplatformintegration.h>
#include <private/qvideotexturehelper_p.h>
#include <private/qabstractvideobuffer_p.h>
#include <private/qguiapplication_p.h>
#include <rhi/qrhi.h>
+ Include dependency graph for qvideoframeconverter.cpp:

Go to the source code of this file.

Functions

static QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY (qLcVideoFrameConverter, "qt.multimedia.video.frameconverter") namespace
 
static bool pixelFormatHasAlpha (QVideoFrameFormat::PixelFormat format)
 
static QShader vfcGetShader (const QString &name)
 
static void rasterTransform (QImage &image, QVideoFrame::RotationAngle rotation, bool mirrorX, bool mirrorY)
 
static void imageCleanupHandler (void *info)
 
static QRhiinitializeRHI (QRhi *videoFrameRhi)
 
static bool updateTextures (QRhi *rhi, std::unique_ptr< QRhiBuffer > &uniformBuffer, std::unique_ptr< QRhiSampler > &textureSampler, std::unique_ptr< QRhiShaderResourceBindings > &shaderResourceBindings, std::unique_ptr< QRhiGraphicsPipeline > &graphicsPipeline, std::unique_ptr< QRhiRenderPassDescriptor > &renderPass, QVideoFrame &frame, const std::unique_ptr< QVideoFrameTextures > &videoFrameTextures)
 
static QImage convertJPEG (const QVideoFrame &frame, QVideoFrame::RotationAngle rotation, bool mirrorX, bool mirrorY)
 
static QImage convertCPU (const QVideoFrame &frame, QVideoFrame::RotationAngle rotation, bool mirrorX, bool mirrorY)
 
QImage qImageFromVideoFrame (const QVideoFrame &frame, QVideoFrame::RotationAngle rotation, bool mirrorX, bool mirrorY)
 

Variables

static QThreadStorage< Stateg_state
 
static QHash< QString, QShaderg_shaderCache
 
static const float g_quad []
 

Function Documentation

◆ convertCPU()

static QImage convertCPU ( const QVideoFrame frame,
QVideoFrame::RotationAngle  rotation,
bool  mirrorX,
bool  mirrorY 
)
static

Definition at line 246 of file qvideoframeconverter.cpp.

References convert(), QImage::Format_ARGB32_Premultiplied, QImage::Format_RGB32, frame, QVideoFrame::height(), QVideoFrame::map(), QVideoFrame::pixelFormat(), pixelFormatHasAlpha(), Q_FUNC_INFO, qCDebug, qConverterForFormat(), rasterTransform(), QVideoFrame::ReadOnly, QVideoFrame::unmap(), and QVideoFrame::width().

Referenced by qImageFromVideoFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convertJPEG()

static QImage convertJPEG ( const QVideoFrame frame,
QVideoFrame::RotationAngle  rotation,
bool  mirrorX,
bool  mirrorY 
)
static

Definition at line 232 of file qvideoframeconverter.cpp.

References QVideoFrame::bits(), frame, QVideoFrame::map(), QVideoFrame::mappedBytes(), Q_FUNC_INFO, qCDebug, rasterTransform(), QVideoFrame::ReadOnly, and QVideoFrame::unmap().

Referenced by qImageFromVideoFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imageCleanupHandler()

static void imageCleanupHandler ( void info)
static

Definition at line 121 of file qvideoframeconverter.cpp.

References imageData, and info.

◆ initializeRHI()

static QRhi * initializeRHI ( QRhi videoFrameRhi)
static

Definition at line 127 of file qvideoframeconverter.cpp.

References Qt::AA_ForceRasterWidgets, QRhi::backend(), context, QRhi::create(), QRhi::D3D11, g_state, QRhi::Metal, QRhi::nativeHandles(), QRhi::Null, QPlatformIntegration::OpenGL, QRhi::OpenGLES2, QGuiApplicationPrivate::platformIntegration(), Q_FUNC_INFO, qWarning, QPlatformIntegration::RasterGLSurface, QPlatformIntegration::RhiBasedRendering, and QCoreApplication::testAttribute().

Referenced by qImageFromVideoFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pixelFormatHasAlpha()

static bool pixelFormatHasAlpha ( QVideoFrameFormat::PixelFormat  format)
static

◆ Q_LOGGING_CATEGORY()

static QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY ( qLcVideoFrameConverter  ,
"qt.multimedia.video.frameconverter"   
)
static

Definition at line 27 of file qvideoframeconverter.cpp.

◆ qImageFromVideoFrame()

QImage qImageFromVideoFrame ( const QVideoFrame frame,
QVideoFrame::RotationAngle  rotation,
bool  mirrorX,
bool  mirrorY 
)

◆ rasterTransform()

static void rasterTransform ( QImage image,
QVideoFrame::RotationAngle  rotation,
bool  mirrorX,
bool  mirrorY 
)
static

Definition at line 107 of file qvideoframeconverter.cpp.

References QVideoFrame::Rotation0.

Referenced by convertCPU(), and convertJPEG().

+ Here is the caller graph for this function:

◆ updateTextures()

static bool updateTextures ( QRhi rhi,
std::unique_ptr< QRhiBuffer > &  uniformBuffer,
std::unique_ptr< QRhiSampler > &  textureSampler,
std::unique_ptr< QRhiShaderResourceBindings > &  shaderResourceBindings,
std::unique_ptr< QRhiGraphicsPipeline > &  graphicsPipeline,
std::unique_ptr< QRhiRenderPassDescriptor > &  renderPass,
QVideoFrame frame,
const std::unique_ptr< QVideoFrameTextures > &  videoFrameTextures 
)
static

◆ vfcGetShader()

static QShader vfcGetShader ( const QString name)
static

Definition at line 91 of file qvideoframeconverter.cpp.

References QShader::fromSerialized(), g_shaderCache, and QIODeviceBase::ReadOnly.

Referenced by updateTextures().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ g_quad

const float g_quad[]
static
Initial value:
= {
1.f, -1.f, 1.f, 1.f,
1.f, 1.f, 1.f, 0.f,
-1.f, -1.f, 0.f, 1.f,
-1.f, 1.f, 0.f, 0.f,
1.f, -1.f, 1.f, 0.f,
1.f, 1.f, 0.f, 0.f,
-1.f, -1.f, 1.f, 1.f,
-1.f, 1.f, 0.f, 1.f,
1.f, -1.f, 0.f, 0.f,
1.f, 1.f, 0.f, 1.f,
-1.f, -1.f, 1.f, 0.f,
-1.f, 1.f, 1.f, 1.f,
1.f, -1.f, 0.f, 1.f,
1.f, 1.f, 1.f, 1.f,
-1.f, -1.f, 0.f, 0.f,
-1.f, 1.f, 1.f, 0.f,
}

Definition at line 51 of file qvideoframeconverter.cpp.

Referenced by qImageFromVideoFrame().

◆ g_shaderCache

QHash<QString, QShader> g_shaderCache
static

Definition at line 49 of file qvideoframeconverter.cpp.

Referenced by vfcGetShader().

◆ g_state

QThreadStorage<State> g_state
static

Definition at line 48 of file qvideoframeconverter.cpp.

Referenced by initializeRHI(), and qImageFromVideoFrame().