16#include <libavutil/avutil.h>
17#include <libavutil/parseutils.h>
18#include <libavutil/mathematics.h>
19#include <libavutil/opt.h>
20#include <libavutil/pixdesc.h>
21#include <libavutil/bswap.h>
22#include <libswscale/swscale.h>
23#include <libswresample/swresample.h>
85 void _log(
int level,
const char *fmt)
const
87 av_log(
m_raw, level, fmt);
97 template<
typename... Args>
98 void _log(
int level,
const char* fmt,
const Args&... args)
const
100 av_log(
m_raw, level, fmt, args...);
114#define RAW_GET(field, def) (m_raw ? m_raw->field : (def))
121#define RAW_SET(field, val) if(m_raw) m_raw->field = (val)
130#define RAW_GET2(cond, field, def) (m_raw && (cond) ? m_raw->field : def)
138#define RAW_SET2(cond, field, val) if(m_raw && (cond)) m_raw->field = (val)
147#define IF_GET(ptr, field, def) ((ptr) ? ptr->field : def)
155#define IF_SET(ptr, field, val) (if(ptr) ptr->field = (val))
165#define IF_GET2(cond, ptr, field, def) (ptr && (cond) ? ptr->field : def)
174#define IF_SET2(cond, ptr, field, val) (if(ptr && (cond)) ptr->field = (val))
176#if !DEPRECATED_INIT_PACKET
226 static const T empty = T();
227 auto res = memcmp(&
m_raw, &empty,
sizeof(empty));
237 void _log(
int level,
const char *fmt)
const
239 av_log(&
m_raw, level, fmt);
249 template<
typename... Args>
250 void _log(
int level,
const char* fmt,
const Args&... args)
const
252 av_log(&
m_raw, level, fmt, args...);
272template<typename WrapperClass, typename T, T NoneValue = static_cast<T>(-1)>
292 operator T() const noexcept
315 operator T&()
noexcept
352 friend std::ostream&
operator<<(std::ostream& ost, WrapperClass fmt)
FFmpeg version and API compatibility switches.
void reset(T *raw=nullptr)
Replace the stored pointer.
Definition ffmpeg.h:71
T * raw()
Write access to the wrapped object.
Definition ffmpeg.h:62
void _log(int level, const char *fmt, const Args &... args) const
Log through the FFmpeg log system with arguments.
Definition ffmpeg.h:98
void _log(int level, const char *fmt) const
Log through the FFmpeg log system, using this wrapper as the context.
Definition ffmpeg.h:85
AVCodecContext * m_raw
Definition ffmpeg.h:105
FFWrapperPtr()=default
Create an empty wrapper; isNull() is true.
const AVCodecContext * raw() const
Definition ffmpeg.h:56
bool isNull() const
Whether the wrapper is empty.
Definition ffmpeg.h:77
FFWrapperPtr(T *raw)
Wrap an existing object.
Definition ffmpeg.h:48
bool isNull() const
Whether the stored value equals a default-constructed one.
Definition ffmpeg.h:225
T * raw()
Write access to the stored structure.
Definition ffmpeg.h:213
void _log(int level, const char *fmt, const Args &... args) const
Log through the FFmpeg log system with arguments.
Definition ffmpeg.h:250
T m_raw
The stored value.
Definition ffmpeg.h:257
void reset(const T &raw=T())
Replace the stored value.
Definition ffmpeg.h:219
void _log(int level, const char *fmt) const
Log through the FFmpeg log system, using this wrapper as the context.
Definition ffmpeg.h:237
FFWrapperRef()=default
Create a value-initialised holder.
const T * raw() const
Read access to the stored structure.
Definition ffmpeg.h:207
FFWrapperRef(const T &raw)
Copy a structure into the wrapper.
Definition ffmpeg.h:199
AVPixelFormat m_fmt
Definition ffmpeg.h:360
T get() const noexcept
The stored enum value.
Definition ffmpeg.h:302
constexpr PixSampleFmtWrapper()=default
Create a wrapper holding NoneValue.
constexpr PixSampleFmtWrapper(T fmt) noexcept
Wrap a raw enum value.
Definition ffmpeg.h:284
friend std::ostream & operator<<(std::ostream &ost, WrapperClass fmt)
Print the format name.
Definition ffmpeg.h:352
WrapperClass & operator=(T fmt) noexcept
Assign a raw enum value.
Definition ffmpeg.h:327
void set(T fmt) noexcept
Assign a raw enum value.
Definition ffmpeg.h:338