19#include <QtMultimedia/qvideoframeformat.h>
24inline bool operator==(
const AVRational &lhs,
const AVRational &rhs)
26 return lhs.num == rhs.num && lhs.den == rhs.den;
29inline bool operator!=(
const AVRational &lhs,
const AVRational &rhs)
41 return b.den != 0 ? (
a *
b.num +
b.den / 2) /
b.den : std::optional<qint64>{};
46 return b.den != 0 ?
a *
qreal(
b.num) /
qreal(
b.den) : std::optional<qreal>{};
56 return mul(1'000'000 * ts,
base);
59inline std::optional<float>
toFloat(AVRational
r)
61 return r.den != 0 ? float(
r.num) / float(
r.den) : std::optional<float>{};
66 char buffer[AV_ERROR_MAX_STRING_SIZE + 1] = {};
67 av_make_error_string(
buffer, AV_ERROR_MAX_STRING_SIZE, errnum);
74#if QT_FFMPEG_HAS_FRAME_TIME_BASE
75 frame.time_base = timeBase;
84#if QT_FFMPEG_HAS_FRAME_TIME_BASE
85 timeBase =
frame.time_base;
93#if QT_FFMPEG_HAS_FRAME_DURATION
94 return frame.duration;
105 operator AVDictionary **() {
return &
opts; }
123template<
typename FunctionType, FunctionType F>
142 std::unique_ptr<AVPacket,
AVDeleter<
decltype(&av_packet_free), &av_packet_free>>;
145 std::unique_ptr<AVCodecContext,
146 AVDeleter<
decltype(&avcodec_free_context), &avcodec_free_context>>;
149 std::unique_ptr<AVBufferRef,
AVDeleter<
decltype(&av_buffer_unref), &av_buffer_unref>>;
152 AVHWFramesConstraints,
153 AVDeleter<
decltype(&av_hwframe_constraints_free), &av_hwframe_constraints_free>>;
165 const std::optional<AVHWDeviceType> &
deviceType = {},
166 const std::optional<PixelOrSampleFormat> &
format = {});
169 const std::optional<AVHWDeviceType> &
deviceType = {},
170 const std::optional<PixelOrSampleFormat> &
format = {});
173 const std::function<
AVScore(
const AVCodec *)> &scoresGetter);
177template<
typename Format>
183template<
typename Format,
typename Predicate>
192template <
typename Value,
typename CalculateScore>
194 Value invalidValue = {})
196 using Limits = std::numeric_limits<
decltype(calculateScore(*
values))>;
197 std::pair
result(invalidValue, Limits::min());
200 const auto score = calculateScore(*
values);
201 if (score >
result.second)
209template <
typename Format,
typename CalculateScore>
211 const CalculateScore &calculateScore)
213 static_assert(std::is_same_v<Format, AVSampleFormat> || std::is_same_v<Format, AVPixelFormat>,
214 "The input value is not AV format, use findBestAVValue instead.");
236 const AVAudioFormat &outputFormat);
241bool isCVFormatSupported(uint32_t
format);
243std::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...
std::unique_ptr< AVHWFramesConstraints, AVDeleter< decltype(&av_hwframe_constraints_free), &av_hwframe_constraints_free > > AVHWFramesConstraintsUPtr
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)
int64_t getAVFrameDuration(const AVFrame &frame)
bool isHwPixelFormat(AVPixelFormat format)
bool isAVCodecExperimental(const AVCodec *codec)
AVPacketSideData * addStreamSideData(AVStream *stream, AVPacketSideData sideData)
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)
bool isSwPixelFormat(AVPixelFormat format)
constexpr AVScore DefaultAVScore
std::unique_ptr< AVCodecContext, AVDeleter< decltype(&avcodec_free_context), &avcodec_free_context > > AVCodecContextUPtr
bool hasAVFormat(const Format *fmts, Format format)
std::unique_ptr< AVFrame, AVDeleter< decltype(&av_frame_free), &av_frame_free > > AVFrameUPtr
std::unique_ptr< AVBufferRef, AVDeleter< decltype(&av_buffer_unref), &av_buffer_unref > > AVBufferUPtr
Format findAVFormat(const Format *fmts, const Predicate &predicate)
QVideoFrameFormat::ColorTransfer fromAvColorTransfer(AVColorTransferCharacteristic colorTrc)
void applyExperimentalCodecOptions(const AVCodec *codec, AVDictionary **opts)
constexpr AVScore NotSuitableAVScore
std::optional< qint64 > timeStampMs(qint64 ts, AVRational base)
SwrContextUPtr createResampleContext(const AVAudioFormat &inputFormat, const AVAudioFormat &outputFormat)
AVPixelFormat pixelFormatForHwDevice(AVHWDeviceType deviceType)
std::optional< qint64 > timeStampUs(qint64 ts, AVRational base)
std::unique_ptr< SwrContext, AVDeleter< decltype(&swr_free), &swr_free > > SwrContextUPtr
const AVPacketSideData * streamSideData(const AVStream *stream, AVPacketSideDataType type)
std::unique_ptr< AVPacket, AVDeleter< decltype(&av_packet_free), &av_packet_free > > AVPacketUPtr
std::optional< float > toFloat(AVRational r)
constexpr AVScore MinAVScore
std::optional< qint64 > mul(qint64 a, AVRational b)
auto findBestAVValue(const Value *values, const CalculateScore &calculateScore, Value invalidValue={})
Combined button and popup list for selecting options.
bool operator==(const AVRational &lhs, const AVRational &rhs)
QDebug operator<<(QDebug, const AVRational &)
bool operator!=(const AVRational &lhs, const AVRational &rhs)
GLenum GLsizei GLsizei GLint * values
[15]
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
AVDictionaryHolder()=default