avcpp
2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
|
Go to the documentation of this file.
7 #include <libavutil/avutil.h>
8 #include <libavutil/parseutils.h>
9 #include <libavutil/mathematics.h>
10 #include <libavutil/opt.h>
11 #include <libavutil/pixdesc.h>
12 #include <libavdevice/avdevice.h>
13 #include <libswscale/swscale.h>
14 #include <libswresample/swresample.h>
15 #include <libavformat/version.h>
19 #include <libavfilter/avfilter.h>
20 #if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(7,0,0)
21 # include <libavfilter/avfiltergraph.h>
23 #include <libavfilter/buffersink.h>
24 #include <libavfilter/buffersrc.h>
25 #if LIBAVFILTER_VERSION_INT <= AV_VERSION_INT(2,77,100) // 0.11.1
26 # include <libavfilter/vsrc_buffer.h>
28 #if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(6,31,100) // 3.0
29 #include <libavfilter/avcodec.h>
36 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,59,100) // 1.0
37 inline void avcodec_free_frame(AVFrame **frame)
44 #if LIBAVFILTER_VERSION_INT < AV_VERSION_INT(3,17,100) // 1.0
45 inline const char *avfilter_pad_get_name(AVFilterPad *pads,
int pad_idx)
47 return pads[pad_idx].name;
50 inline AVMediaType avfilter_pad_get_type(AVFilterPad *pads,
int pad_idx)
52 return pads[pad_idx].type;
58 #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(6,31,100) // < 3.0
59 #define avpacket_unref(p) av_free_packet(p)
61 #define avpacket_unref(p) av_packet_unref(p)
64 #define NO_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR >= 60)
65 #define DEPRECATED_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR >= 58)
79 void _log(
int level,
const char *fmt)
const
81 av_log(
m_raw, level, fmt);
84 template<
typename... Args>
85 void _log(
int level,
const char* fmt,
const Args&... args)
const
87 av_log(
m_raw, level, fmt, args...);
94 #define RAW_GET(field, def) (m_raw ? m_raw->field : (def))
95 #define RAW_SET(field, val) if(m_raw) m_raw->field = (val)
97 #define RAW_GET2(cond, field, def) (m_raw && (cond) ? m_raw->field : def)
98 #define RAW_SET2(cond, field, val) if(m_raw && (cond)) m_raw->field = (val)
100 #define IF_GET(ptr, field, def) ((ptr) ? ptr->field : def)
101 #define IF_SET(ptr, field, val) (if(ptr) ptr->field = (val))
103 #define IF_GET2(cond, ptr, field, def) (ptr && (cond) ? ptr->field : def)
104 #define IF_SET2(cond, ptr, field, val) (if(ptr && (cond)) ptr->field = (val))
106 #if !DEPRECATED_INIT_PACKET
118 static const T empty = T();
119 auto res = memcmp(&
m_raw, &empty,
sizeof(empty));
123 void _log(
int level,
const char *fmt)
const
125 av_log(&
m_raw, level, fmt);
128 template<
typename... Args>
129 void _log(
int level,
const char* fmt,
const Args&... args)
const
131 av_log(&
m_raw, level, fmt, args...);
139 template<typename WrapperClass, typename T, T NoneValue = static_cast<T>(-1)>
146 operator T() const noexcept
156 operator T&() noexcept
173 friend std::ostream&
operator<<(std::ostream& ost, WrapperClass fmt)
184 #if AV_GCC_VERSION_AT_LEAST(3,1)
185 # define attribute_deprecated2(x) __attribute__((deprecated(x)))
186 #elif defined(_MSC_VER)
187 # define attribute_deprecated2(x) __declspec(deprecated(x))
189 # define attribute_deprecated2(x)
void set(T fmt) noexcept
Definition: ffmpeg.h:167
const T * raw() const
Definition: ffmpeg.h:114
bool isNull() const
Definition: ffmpeg.h:77
FFWrapperPtr(T *raw)
Definition: ffmpeg.h:71
void _log(int level, const char *fmt, const Args &... args) const
Definition: ffmpeg.h:129
bool isNull() const
Definition: ffmpeg.h:117
T m_raw
Definition: ffmpeg.h:135
constexpr PixSampleFmtWrapper(T fmt) noexcept
Definition: ffmpeg.h:143
void _log(int level, const char *fmt) const
Definition: ffmpeg.h:79
void reset(const T &raw=T())
Definition: ffmpeg.h:116
T m_fmt
Definition: ffmpeg.h:180
friend std::ostream & operator<<(std::ostream &ost, WrapperClass fmt)
Definition: ffmpeg.h:173
const T * raw() const
Definition: ffmpeg.h:74
T * raw()
Definition: ffmpeg.h:75
constexpr PixSampleFmtWrapper()=default
T * m_raw
Definition: ffmpeg.h:91
T * raw()
Definition: ffmpeg.h:115
void reset(T *raw=nullptr)
Definition: ffmpeg.h:76
void _log(int level, const char *fmt, const Args &... args) const
Definition: ffmpeg.h:85
WrapperClass & operator=(T fmt) noexcept
Definition: ffmpeg.h:161
T get() const noexcept
Definition: ffmpeg.h:151
FFWrapperRef(const T &raw)
Definition: ffmpeg.h:111
void _log(int level, const char *fmt) const
Definition: ffmpeg.h:123