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
qvideoframeformat.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qvideoframeformat.h"
6
7#include <qdebug.h>
8#include <qlist.h>
9#include <qmetatype.h>
10#include <qpair.h>
11#include <qvariant.h>
12#include <qmatrix4x4.h>
13
14static void initResource() {
15 Q_INIT_RESOURCE(qtmultimedia_shaders);
16}
17
19
66
68
355
364
369
386
397
404{
405 return d->pixelFormat != Format_Invalid && d->frameSize.isValid();
406}
407
412{
413 return d == other.d || *d == *other.d;
414}
415
420{
421 return d != other.d && !(*d == *other.d);
422}
423
428{
429 d.detach();
430}
431
439
446{
447 return d->frameSize;
448}
449
456{
457 return d->frameSize.width();
458}
459
464{
465 return d->frameSize.height();
466}
467
478
485{
486 detach();
487 d->frameSize = size;
488 d->viewport = QRect(QPoint(0, 0), size);
489}
490
499{
500 detach();
502 d->viewport = QRect(0, 0, width, height);
503}
504
513{
514 return d->viewport;
515}
516
521{
522 detach();
523 d->viewport = viewport;
524}
525
533
542
543#if QT_DEPRECATED_SINCE(6, 8)
547qreal QVideoFrameFormat::frameRate() const
548{
549 return streamFrameRate();
550}
551
555void QVideoFrameFormat::setFrameRate(qreal rate)
556{
558}
559#endif
560
565{
566 return d->frameRate;
567}
568
577
578#if QT_DEPRECATED_SINCE(6, 4)
584QVideoFrameFormat::YCbCrColorSpace QVideoFrameFormat::yCbCrColorSpace() const
585{
586 return YCbCrColorSpace(d->colorSpace);
587}
588
595void QVideoFrameFormat::setYCbCrColorSpace(QVideoFrameFormat::YCbCrColorSpace space)
596{
597 detach();
598 d->colorSpace = ColorSpace(space);
599}
600#endif // QT_DEPRECATED_SINCE(6, 4)
601
609
614{
615 detach();
617}
618
627
637
646
656
667{
668 return d->mirrored;
669}
670
682{
683 detach();
684 d->mirrored = mirrored;
685}
686
694
703
711
719
727
735{
736 if (d->maxLuminance <= 0) {
738 return 10000.; // ST2084 can encode up to 10000 nits
740 return 1500.; // SRD_B67 can encode up to 1200 nits, use a bit more for some headroom
741 return 100; // SDR
742 }
743 return d->maxLuminance;
744}
749{
750 detach();
751 d->maxLuminance = lum;
752}
753
754
796
805{
806 switch (format) {
807#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
818#else
829#endif
861 }
863}
864
869{
870 switch (pixelFormat) {
872 return QStringLiteral("Invalid");
874 return QStringLiteral("ARGB8888");
876 return QStringLiteral("ARGB8888 Premultiplied");
878 return QStringLiteral("XRGB8888");
880 return QStringLiteral("BGRA8888");
882 return QStringLiteral("BGRX8888");
884 return QStringLiteral("BGRA8888 Premultiplied");
886 return QStringLiteral("RGBA8888");
888 return QStringLiteral("RGBX8888");
890 return QStringLiteral("ABGR8888");
892 return QStringLiteral("XBGR8888");
894 return QStringLiteral("AYUV");
896 return QStringLiteral("AYUV Premultiplied");
898 return QStringLiteral("YUV420P");
900 return QStringLiteral("YUV420P10");
902 return QStringLiteral("YUV422P");
904 return QStringLiteral("YV12");
906 return QStringLiteral("UYVY");
908 return QStringLiteral("YUYV");
910 return QStringLiteral("NV12");
912 return QStringLiteral("NV21");
914 return QStringLiteral("IMC1");
916 return QStringLiteral("IMC2");
918 return QStringLiteral("IMC3");
920 return QStringLiteral("IMC4");
922 return QStringLiteral("Y8");
924 return QStringLiteral("Y16");
926 return QStringLiteral("P010");
928 return QStringLiteral("P016");
930 return QStringLiteral("SamplerExternalOES");
932 return QStringLiteral("Jpeg");
934 return QStringLiteral("SamplerRect");
935 }
936
937 return QStringLiteral("");
938}
939
940#ifndef QT_NO_DEBUG_STREAM
941# if QT_DEPRECATED_SINCE(6, 4)
942QDebug operator<<(QDebug dbg, QVideoFrameFormat::YCbCrColorSpace cs)
943{
944 QDebugStateSaver saver(dbg);
945 dbg.nospace();
946 switch (cs) {
947 case QVideoFrameFormat::YCbCr_BT601:
948 dbg << "YCbCr_BT601";
949 break;
950 case QVideoFrameFormat::YCbCr_BT709:
951 dbg << "YCbCr_BT709";
952 break;
953 case QVideoFrameFormat::YCbCr_JPEG:
954 dbg << "YCbCr_JPEG";
955 break;
956 case QVideoFrameFormat::YCbCr_xvYCC601:
957 dbg << "YCbCr_xvYCC601";
958 break;
959 case QVideoFrameFormat::YCbCr_xvYCC709:
960 dbg << "YCbCr_xvYCC709";
961 break;
962 case QVideoFrameFormat::YCbCr_BT2020:
963 dbg << "YCbCr_BT2020";
964 break;
965 default:
966 dbg << "YCbCr_Undefined";
967 break;
968 }
969 return dbg;
970}
971# endif // QT_DEPRECATED_SINCE(6, 4)
972
974{
975 QDebugStateSaver saver(dbg);
976 dbg.nospace();
977 switch (cs) {
979 dbg << "ColorSpace_BT601";
980 break;
982 dbg << "ColorSpace_BT709";
983 break;
985 dbg << "ColorSpace_AdobeRgb";
986 break;
988 dbg << "ColorSpace_BT2020";
989 break;
990 default:
991 dbg << "ColorSpace_Undefined";
992 break;
993 }
994 return dbg;
995}
996
998{
999 QDebugStateSaver saver(dbg);
1000 dbg.nospace();
1001 switch (dir) {
1003 dbg << "BottomToTop";
1004 break;
1006 dbg << "TopToBottom";
1007 break;
1008 }
1009 return dbg;
1010}
1011
1013{
1014 QDebugStateSaver saver(dbg);
1015 dbg.nospace();
1016 dbg << "QVideoFrameFormat(" << f.pixelFormat() << ", " << f.frameSize()
1017 << ", viewport=" << f.viewport()
1018 << ", colorSpace=" << f.colorSpace()
1019 << ')'
1020 << "\n pixel format=" << f.pixelFormat()
1021 << "\n frame size=" << f.frameSize()
1022 << "\n viewport=" << f.viewport()
1023 << "\n colorSpace=" << f.colorSpace()
1024 << "\n frameRate=" << f.streamFrameRate()
1025 << "\n mirrored=" << f.isMirrored();
1026
1027 return dbg;
1028}
1029
1031{
1032 QDebugStateSaver saver(dbg);
1033 dbg.nospace();
1034
1036 if (format.isEmpty())
1037 return dbg;
1038
1039 dbg.noquote() << QStringLiteral("Format_") << format;
1040 return dbg;
1041}
1042#endif
1043
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_Grayscale16
Definition qimage.h:70
@ Format_RGBA8888
Definition qimage.h:59
@ Format_RGB32
Definition qimage.h:46
@ Format_Invalid
Definition qimage.h:42
@ Format_RGBA8888_Premultiplied
Definition qimage.h:60
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_ARGB32
Definition qimage.h:47
@ Format_RGBX8888
Definition qimage.h:58
@ Format_Grayscale8
Definition qimage.h:66
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
Definition qmatrix4x4.h:25
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qshareddata.h:19
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
Definition qsize.h:127
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QVideoFrameFormatPrivate(const QSize &size, QVideoFrameFormat::PixelFormat format)
QVideoFrameFormat::ColorSpace colorSpace
QVideoFrameFormat::Direction scanLineDirection
QVideoFrameFormat::PixelFormat pixelFormat
QVideoFrameFormat::ColorRange colorRange
static bool frameRatesEqual(qreal r1, qreal r2)
bool operator==(const QVideoFrameFormatPrivate &other) const
QVideoFrameFormatPrivate()=default
QVideoFrameFormat::ColorTransfer colorTransfer
The QVideoFrameFormat class specifies the stream format of a video presentation surface.
ColorRange colorRange() const
Returns the color range that should be used to render the video stream.
void setViewport(const QRect &viewport)
Sets the viewport of a video stream to viewport.
bool isValid() const
Identifies if a video surface format has a valid pixel format and frame size.
bool isMirrored() const
Returns true if the surface is mirrored around its vertical axis.
ColorSpace
Enumerates the color space of video frames.
void setMaxLuminance(float lum)
Sets the maximum luminance to the given value, lum.
void setColorRange(ColorRange range)
Sets the color transfer range that should be used to render the video stream to range.
ColorTransfer
\value ColorTransfer_Unknown The color transfer function is unknown.
void setStreamFrameRate(qreal rate)
Sets the frame rate of a video stream in frames per second.
PixelFormat
Enumerates video data types.
void setScanLineDirection(Direction direction)
Sets the direction of scan lines.
bool operator!=(const QVideoFrameFormat &format) const
Returns true if other is different to this video format, and false if they are the same.
void setFrameSize(const QSize &size)
Sets the size of frames in a video stream to size.
void setColorSpace(ColorSpace colorSpace)
Sets the colorSpace of a video stream.
QRect viewport() const
Returns the viewport of a video stream.
Direction scanLineDirection() const
Returns the direction of scan lines.
int planeCount() const
Returns the number of planes used.
void setColorTransfer(ColorTransfer colorTransfer)
Sets the color transfer function that should be used to render the video stream to colorTransfer.
qreal streamFrameRate() const
Returns the frame rate of a video stream in frames per second.
static QString pixelFormatToString(QVideoFrameFormat::PixelFormat pixelFormat)
Returns a string representation of the given pixelFormat.
bool operator==(const QVideoFrameFormat &format) const
Returns true if other is the same as this video format, and false if they are different.
QVideoFrameFormat::PixelFormat pixelFormat() const
Returns the pixel format of frames in a video stream.
static QImage::Format imageFormatFromPixelFormat(PixelFormat format)
Returns an image format equivalent to a video frame pixel format.
int frameWidth() const
Returns the width of frames in a video stream.
Direction
Enumerates the layout direction of video scan lines.
ColorTransfer colorTransfer() const
Returns the color transfer function that should be used to render the video stream.
void updateUniformData(QByteArray *dst, const QVideoFrame &frame, const QMatrix4x4 &transform, float opacity) const
QVideoFrameFormat & operator=(const QVideoFrameFormat &format)
Assigns the values of other to this object.
~QVideoFrameFormat()
Destroys a video stream description.
void setRotation(QtVideo::Rotation rotation)
Sets the rotation angle the matching video frame should be rotated clockwise before displaying.
int frameHeight() const
Returns the height of frame in a video stream.
void setMirrored(bool mirrored)
Sets if the surface is mirrored around its vertical axis.
QtVideo::Rotation rotation() const
Returns the rotation angle the matching video frame should be rotated clockwise before displaying.
QVideoFrameFormat()
Constructs a null video stream format.
QSize frameSize() const
Returns the dimensions of frames in a video stream.
QString fragmentShaderFileName() const
static PixelFormat pixelFormatFromImageFormat(QImage::Format format)
Returns a video pixel format equivalent to an image format.
ColorRange
Describes the color range used by the video data.
ColorSpace colorSpace() const
Returns the color space of a video stream.
QString vertexShaderFileName() const
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:27
direction
Combined button and popup list for selecting options.
QString vertexShaderFileName(const QVideoFrameFormat &format)
QString fragmentShaderFileName(const QVideoFrameFormat &format, QRhiSwapChain::Format surfaceFormat)
const TextureDescription * textureDescription(QVideoFrameFormat::PixelFormat format)
void updateUniformData(QByteArray *dst, const QVideoFrameFormat &format, const QVideoFrame &frame, const QMatrix4x4 &transform, float opacity, float maxNits)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat f
GLsizei range
GLint GLsizei width
GLenum GLenum dst
GLint GLsizei GLsizei GLenum format
GLuint GLenum GLenum transform
GLuint GLenum * rate
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
#define QStringLiteral(str)
#define Q_INIT_RESOURCE(name)
Definition qtresource.h:14
double qreal
Definition qtypes.h:187
QDebug operator<<(QDebug dbg, QVideoFrameFormat::ColorSpace cs)
static void initResource()
QRect r1(100, 200, 11, 16)
[0]
QRect r2(QPoint(100, 200), QSize(11, 16))
QSharedPointer< T > other(t)
[5]
QString dir
[11]
view viewport() -> scroll(dx, dy, deviceRect)
QFrame frame
[0]