6#include <private/qtmultimediaglobal_p.h>
11#include <libavformat/avformat.h>
12#include <libavcodec/avcodec.h>
13#include <libswresample/swresample.h>
14#include <libavutil/avutil.h>
15#include <libswscale/swscale.h>
18#define QT_FFMPEG_OLD_CHANNEL_LAYOUT (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100))
19#define QT_FFMPEG_HAS_VULKAN \
20 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 91, 100))
21#define QT_FFMPEG_HAS_FRAME_TIME_BASE \
22 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 18, 100))
23#define QT_FFMPEG_HAS_FRAME_DURATION \
24 (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 3, 100))
33 return b.den != 0 ? (
a *
b.num +
b.den / 2) /
b.den : std::optional<qint64>{};
38 return b.den != 0 ?
a *
qreal(
b.num) /
qreal(
b.den) : std::optional<qreal>{};
48 return mul(1'000'000 * ts,
base);
51inline std::optional<float>
toFloat(AVRational
r)
53 return r.den != 0 ? float(
r.num) / float(
r.den) : std::optional<float>{};
58 char buffer[AV_ERROR_MAX_STRING_SIZE + 1] = {};
59 av_make_error_string(
buffer, AV_ERROR_MAX_STRING_SIZE, errnum);
66#if QT_FFMPEG_HAS_FRAME_TIME_BASE
67 frame.time_base = timeBase;
76#if QT_FFMPEG_HAS_FRAME_TIME_BASE
77 timeBase =
frame.time_base;
85#if QT_FFMPEG_HAS_FRAME_DURATION
86 return frame.duration;
95 AVDictionary *
opts =
nullptr;
97 operator AVDictionary **() {
return &
opts; }
106template<
typename FunctionType, FunctionType F>
125 std::unique_ptr<AVPacket,
AVDeleter<
decltype(&av_packet_free), &av_packet_free>>;
128 std::unique_ptr<AVCodecContext,
129 AVDeleter<
decltype(&avcodec_free_context), &avcodec_free_context>>;
132 std::unique_ptr<AVBufferRef,
AVDeleter<
decltype(&av_buffer_unref), &av_buffer_unref>>;
135 AVHWFramesConstraints,
136 AVDeleter<
decltype(&av_hwframe_constraints_free), &av_hwframe_constraints_free>>;
146 const std::optional<AVHWDeviceType> &
deviceType = {},
147 const std::optional<PixelOrSampleFormat> &
format = {});
150 const std::optional<AVHWDeviceType> &
deviceType = {},
151 const std::optional<PixelOrSampleFormat> &
format = {});
154 const std::function<
AVScore(
const AVCodec *)> &scoresGetter);
158template<
typename Format>
164template<
typename Format,
typename Predicate>
173template<
typename Format,
typename CalculateScore>
175 const CalculateScore &calculateScore)
180 const auto score = calculateScore(*fmts);
181 if (score >
result.second)
182 result = std::pair(*fmts, score);
199bool isCVFormatSupported(uint32_t
format);
201std::string cvFormatToString(uint32_t
format);
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
AVFrameUPtr makeAVFrame()
constexpr AVScore BestAVScore
void getAVFrameTime(const AVFrame &frame, int64_t &pts, AVRational &timeBase)
const AVCodec * findAVEncoder(AVCodecID codecId, const std::optional< AVHWDeviceType > &deviceType, const std::optional< PixelOrSampleFormat > &format)
std::pair< Format, AVScore > findBestAVFormat(const Format *fmts, const CalculateScore &calculateScore)
std::unique_ptr< AVHWFramesConstraints, AVDeleter< decltype(&av_hwframe_constraints_free), &av_hwframe_constraints_free > > AVHWFramesConstraintsUPtr
int64_t getAVFrameDuration(const AVFrame &frame)
std::unique_ptr< AVCodecContext, AVDeleter< decltype(&avcodec_free_context), &avcodec_free_context > > AVCodecContextUPtr
bool isHwPixelFormat(AVPixelFormat format)
std::unique_ptr< AVBufferRef, AVDeleter< decltype(&av_buffer_unref), &av_buffer_unref > > AVBufferUPtr
QString err2str(int errnum)
bool isAVFormatSupported(const AVCodec *codec, PixelOrSampleFormat format)
const AVCodec * findAVDecoder(AVCodecID codecId, const std::optional< AVHWDeviceType > &deviceType, const std::optional< PixelOrSampleFormat > &format)
void setAVFrameTime(AVFrame &frame, int64_t pts, const AVRational &timeBase)
std::unique_ptr< AVPacket, AVDeleter< decltype(&av_packet_free), &av_packet_free > > AVPacketUPtr
bool isSwPixelFormat(AVPixelFormat format)
constexpr AVScore DefaultAVScore
bool hasAVFormat(const Format *fmts, Format format)
Format findAVFormat(const Format *fmts, const Predicate &predicate)
constexpr AVScore NotSuitableAVScore
std::optional< qint64 > timeStampMs(qint64 ts, AVRational base)
AVPixelFormat pixelFormatForHwDevice(AVHWDeviceType deviceType)
std::optional< qint64 > timeStampUs(qint64 ts, AVRational base)
std::optional< float > toFloat(AVRational r)
constexpr AVScore MinAVScore
std::unique_ptr< AVFrame, AVDeleter< decltype(&av_frame_free), &av_frame_free > > AVFrameUPtr
std::optional< qint64 > mul(qint64 a, AVRational b)
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum format
QVideoFrameFormat::PixelFormat fmt
static QInputDevice::DeviceType deviceType(const UINT cursorType)
void operator()(T *object) const