Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qvideoframeconverter.cpp File Reference

(721cd63b7d8600b2f2801a32e047f6ce24b47e51)

#include "qvideoframeconverter_p.h"
#include "qvideoframeconversionhelper_p.h"
#include "qvideoframeformat.h"
#include "qvideoframe_p.h"
#include "qmultimediautils_p.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, QtVideo::Rotation 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, QtVideo::Rotation rotation, bool mirrorX, bool mirrorY)
 
static QImage convertCPU (const QVideoFrame &frame, QtVideo::Rotation rotation, bool mirrorX, bool mirrorY)
 
QImage qImageFromVideoFrame (const QVideoFrame &frame, QtVideo::Rotation rotation, bool mirrorX, bool mirrorY)
 
QImage videoFramePlaneAsImage (QVideoFrame &frame, int plane, QImage::Format targetFormat, QSize targetSize)
 Maps the video frame and returns an image having a shared ownership for the video frame and referencing to its mapped data.
 

Variables

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

Function Documentation

◆ convertCPU()

static QImage convertCPU ( const QVideoFrame & frame,
QtVideo::Rotation rotation,
bool mirrorX,
bool mirrorY )
static

Definition at line 268 of file qvideoframeconverter.cpp.

References convert(), QImage::Format_ARGB32_Premultiplied, QImage::Format_RGB32, frame, pixelFormatHasAlpha(), Q_FUNC_INFO, qCDebug, qConverterForFormat(), rasterTransform(), and QVideoFrame::ReadOnly.

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,
QtVideo::Rotation rotation,
bool mirrorX,
bool mirrorY )
static

Definition at line 254 of file qvideoframeconverter.cpp.

References frame, Q_FUNC_INFO, qCDebug, rasterTransform(), and QVideoFrame::ReadOnly.

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 133 of file qvideoframeconverter.cpp.

References imageData, and info.

◆ initializeRHI()

static QRhi * initializeRHI ( QRhi * videoFrameRhi)
static

Definition at line 139 of file qvideoframeconverter.cpp.

References Qt::AA_ForceRasterWidgets, QGuiApplication::applicationStateChanged(), Qt::ApplicationSuspended, QObject::connect(), context, QRhi::create(), QRhi::D3D11, g_state, QRhi::Metal, QRhi::Null, QPlatformIntegration::OpenGL, QRhi::OpenGLES2, QGuiApplicationPrivate::platformIntegration(), Q_FUNC_INFO, qApp, qWarning, QPlatformIntegration::RasterGLSurface, QPlatformIntegration::RhiBasedRendering, state, 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 29 of file qvideoframeconverter.cpp.

◆ qImageFromVideoFrame()

QImage qImageFromVideoFrame ( const QVideoFrame & frame,
QtVideo::Rotation rotation,
bool mirrorX,
bool mirrorY )

◆ rasterTransform()

static void rasterTransform ( QImage & image,
QtVideo::Rotation rotation,
bool mirrorX,
bool mirrorY )
static

Definition at line 119 of file qvideoframeconverter.cpp.

References QtVideo::None, QTransform::rotate(), and QTransform::scale().

Referenced by convertCPU(), and convertJPEG().

+ Here is the call graph for this function:
+ 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 103 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:

◆ videoFramePlaneAsImage()

QImage videoFramePlaneAsImage ( QVideoFrame & frame,
int plane,
QImage::Format targetFormat,
QSize targetSize )

Maps the video frame and returns an image having a shared ownership for the video frame and referencing to its mapped data.

Definition at line 425 of file qvideoframeconverter.cpp.

References frame, QVideoFramePrivate::handle(), QSize::height(), Q_ASSERT, qMin(), qWarning, QVideoFrame::ReadOnly, and QSize::width().

+ Here is the call 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 63 of file qvideoframeconverter.cpp.

Referenced by qImageFromVideoFrame().

◆ g_shaderCache

QHash<QString, QShader> g_shaderCache
static

Definition at line 61 of file qvideoframeconverter.cpp.

Referenced by vfcGetShader().

◆ g_state

QThreadStorage<State> g_state
static

Definition at line 60 of file qvideoframeconverter.cpp.

Referenced by initializeRHI(), and qImageFromVideoFrame().