Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmultimediautils_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMULTIMEDIAUTILS_P_H
5#define QMULTIMEDIAUTILS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/qtmultimediaglobal.h>
19#include <QtMultimedia/private/qvideotransformation_p.h>
20#include <QtCore/private/qexpected_p.h>
21#include <QtCore/qsize.h>
22#include <QtCore/qurl.h>
23#include <QtGui/rhi/qrhi.h>
24
25#include <memory>
26
27QT_BEGIN_NAMESPACE
28
29class QRhiSwapChain;
30class QFile;
31class QTemporaryFile;
32class QVideoFrame;
33class QVideoFrameFormat;
34
35struct Fraction {
38};
39
40Q_MULTIMEDIA_EXPORT Fraction qRealToFraction(qreal value);
41
42Q_MULTIMEDIA_EXPORT QSize qCalculateFrameSize(QSize resolution, Fraction pixelAspectRatio);
43
44// TODO: after adding pixel aspect ratio to QVideoFrameFormat, the function should
45// consider PAR as well as rotation
46Q_MULTIMEDIA_EXPORT QSize qRotatedFrameSize(QSize size, int rotation);
47
48inline QSize qRotatedFrameSize(QSize size, QtVideo::Rotation rotation)
49{
50 return qRotatedFrameSize(size, qToUnderlying(rotation));
51}
52
53Q_MULTIMEDIA_EXPORT QSize qRotatedFramePresentationSize(const QVideoFrame &frame);
54
55Q_MULTIMEDIA_EXPORT QUrl qMediaFromUserInput(const QUrl &fileName);
56
58
59Q_MULTIMEDIA_EXPORT QRhiSwapChain::Format
60qGetRequiredSwapChainFormat(const QVideoFrameFormat &format);
61
63qShouldUpdateSwapChainFormat(QRhiSwapChain *swapChain,
64 QRhiSwapChain::Format requiredSwapChainFormat);
65
66Q_MULTIMEDIA_EXPORT VideoTransformation
67qNormalizedSurfaceTransformation(const QVideoFrameFormat &format);
68
69Q_MULTIMEDIA_EXPORT VideoTransformation qNormalizedFrameTransformation(
70 const QVideoFrame &frame, VideoTransformation videoOutputTransformation = {});
71
72Q_MULTIMEDIA_EXPORT QtVideo::Rotation
73qVideoRotationFromDegrees(int clockwiseDegrees);
74
76 int videoOutputRotation)
77{
78 return qNormalizedFrameTransformation(
79 frame, VideoTransformation{ qVideoRotationFromDegrees(videoOutputRotation) });
80}
81
82/* The function get mirroring and rotation from the specified QTransform.
83 *
84 * Matrix translation is not taken into consideration.
85 * Matrix negative scaling is interpreted as mirroring.
86 * Absolute X and Y scale values are not taken into consideration as
87 * QVideoFrame and QVideoFrameFormat don't support scaling transformations.
88 *
89 * Sheared matrixes are not supported,
90 * as shearing can make the transformation ambiguous
91 * (the same matrix can be reached by different angle,scaleX,scaleY,shearV,shearH).
92 *
93 * If the given matrix is invalid, or the scale sign is ambiguous,
94 * the function returns an empty optional value.
95 */
96Q_MULTIMEDIA_EXPORT VideoTransformationOpt qVideoTransformationFromMatrix(const QTransform &matrix);
97
98namespace QtMultimediaPrivate {
99
100template <class... Ts>
101struct qOverloadedVisitor : Ts...
102{
103 using Ts::operator()...;
104 constexpr qOverloadedVisitor(Ts... args) : Ts(std::move(args))... {}
105};
106template <class... Ts>
108
110{
111 void operator()(QObject *ptr) const
112 {
113 if (ptr)
114 ptr->deleteLater();
115 }
116};
117
118template <typename T, typename... Args>
119std::shared_ptr<T> makeSharedDeleteLater(Args &&...args)
120{
121 return std::shared_ptr<T>(new T(std::forward<Args>(args)...), DeleteLaterDeleter());
122}
123
129
130q23::expected<QrcMedia, QString> qCopyQrcToTemporaryFile(QFile &, const QUrl &);
131
132} // namespace QtMultimediaPrivate
133
134QT_END_NAMESPACE
135
136#endif // QMULTIMEDIAUTILS_P_H
\inmodule QtCore
Definition qsize.h:27
\inmodule QtCore
Definition qurl.h:95
q23::expected< QrcMedia, QString > qCopyQrcToTemporaryFile(QFile &qrcFile, const QUrl &qrcUrl)
std::shared_ptr< T > makeSharedDeleteLater(Args &&...args)
qOverloadedVisitor(Ts...) -> qOverloadedVisitor< Ts... >
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
#define M_PI_2
Definition qmath.h:205
QRhiSwapChain::Format qGetRequiredSwapChainFormat(const QVideoFrameFormat &format)
QUrl qMediaFromUserInput(const QUrl &url)
QSize qRotatedFrameSize(QSize size, int rotation)
Fraction qRealToFraction(qreal value)
bool qIsAutoHdrEnabled()
QSize qRotatedFramePresentationSize(const QVideoFrame &frame)
QtVideo::Rotation qVideoRotationFromDegrees(int clockwiseDegrees)
VideoTransformationOpt qVideoTransformationFromMatrix(const QTransform &matrix)
VideoTransformation qNormalizedFrameTransformation(const QVideoFrame &frame, VideoTransformation videoOutputTransformation)
QSize qCalculateFrameSize(QSize resolution, Fraction par)
bool qShouldUpdateSwapChainFormat(QRhiSwapChain *swapChain, QRhiSwapChain::Format requiredSwapChainFormat)
std::optional< VideoTransformation > VideoTransformationOpt
std::unique_ptr< QTemporaryFile > file