28 #define QTAV_USE_FFMPEG(MODULE) (MODULE##_VERSION_MICRO >= 100) 29 #define QTAV_USE_LIBAV(MODULE) !QTAV_USE_FFMPEG(MODULE) 30 #define FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) \ 31 (QTAV_USE_FFMPEG(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO)) 32 #define LIBAV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) \ 33 (QTAV_USE_LIBAV(MODULE) && MODULE##_VERSION_INT >= AV_VERSION_INT(MAJOR, MINOR, MICRO)) 34 #define AV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO, MINOR2, MICRO2) \ 35 (LIBAV_MODULE_CHECK(MODULE, MAJOR, MINOR, MICRO) || FFMPEG_MODULE_CHECK(MODULE, MAJOR, MINOR2, MICRO2)) 36 #define AV_ENSURE_OK(FUNC, ...) AV_RUN_CHECK(FUNC, return, __VA_ARGS__) 38 #define AV_ENSURE(FUNC, ...) AV_RUN_CHECK(FUNC, return, __VA_ARGS__) 39 #define AV_WARN(FUNC) AV_RUN_CHECK(FUNC, void) 63 #if !FFMPEG_MODULE_CHECK(LIBAVUTIL, 51, 73, 101) 69 #if QTAV_HAVE(SWRESAMPLE) 71 #ifndef LIBSWRESAMPLE_VERSION_INT //ffmpeg 0.9, swr 0.5 72 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, LIBSWRESAMPLE_VERSION_MINOR, LIBSWRESAMPLE_VERSION_MICRO) 73 #endif //LIBSWRESAMPLE_VERSION_INT 75 #define HAVE_SWR_GET_DELAY (LIBSWRESAMPLE_VERSION_INT > AV_VERSION_INT(0, 6, 100)) 76 #endif //QTAV_HAVE(SWRESAMPLE) 77 #if QTAV_HAVE(AVRESAMPLE) 78 #include <libavresample/avresample.h> 79 #endif //QTAV_HAVE(AVRESAMPLE) 81 #if QTAV_HAVE(AVFILTER) 86 #endif //QTAV_HAVE(AVFILTER) 88 #if QTAV_HAVE(AVDEVICE) 121 #ifndef AV_VERSION_INT 122 #define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) 127 #if !FFMPEG_MODULE_CHECK(LIBAVFORMAT, 56, 4, 101) 130 #if QTAV_USE_LIBAV(LIBAVFORMAT) 135 #if defined(__GNUC__) && !(defined(__ARMCC__) || defined(__CC_ARM)) 136 #define GCC_VERSION_AT_LEAST(major, minor, patch) \ 137 (__GNUC__ > major || (__GNUC__ == major && (__GNUC_MINOR__ > minor \ 138 || (__GNUC_MINOR__ == minor && __GNUC_PATCHLEVEL__ >= patch)))) 141 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 145 #define QTAV_HAVE_AVBUFREF AV_MODULE_CHECK(LIBAVUTIL, 52, 8, 0, 19, 100) 147 #if defined(_MSC_VER) || !defined(av_err2str) || (GCC_VERSION_AT_LEAST(4, 7, 0) && __cplusplus) 162 static av_always_inline char *av_make_error_string(
char *errbuf,
size_t errbuf_size,
int errnum)
169 #define AV_ERROR_MAX_STRING_SIZE 64 171 #include <QtCore/QSharedPointer> 172 #define av_err2str(e) av_err2str_qsp(e).data() 183 memset(str, 0,
sizeof(str));
189 #if (LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52,23,0)) 190 #define avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt) \ 191 avcodec_decode_audio2(avctx, samples, frame_size_ptr, (*avpkt).data, (*avpkt).size); 195 #if (LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52,101,0)) 196 #define av_dump_format(...) dump_format(__VA_ARGS__) 199 #if QTAV_HAVE(SWRESAMPLE) && (LIBSWRESAMPLE_VERSION_INT <= AV_VERSION_INT(0, 5, 0)) 200 #define swresample_version() LIBSWRESAMPLE_VERSION_INT //we can not know the runtime version, so just use build time version 201 #define swresample_configuration() "Not available." 202 #define swresample_license() "Not available." 205 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 32, 0) 212 #if (QTAV_HAVE(SWR_AVR_MAP) || !QTAV_HAVE(SWRESAMPLE)) && QTAV_HAVE(AVRESAMPLE) 214 #ifdef AVRESAMPLE_MAX_CHANNELS 215 #define SWR_CH_MAX AVRESAMPLE_MAX_CHANNELS 217 #define SWR_CH_MAX 64 218 #endif //AVRESAMPLE_MAX_CHANNELS 220 #define SwrContext AVAudioResampleContext 221 #define swr_init(ctx) avresample_open(ctx) 223 #define swr_free(ctx) \ 225 avresample_close(*ctx); \ 228 #define swr_get_class() avresample_get_class() 229 #define swr_alloc() avresample_alloc_context() 231 #define swr_set_compensation() avresample_set_compensation() 232 #define swr_set_channel_mapping(ctx, map) avresample_set_channel_mapping(ctx, map) 233 #define swr_set_matrix(ctx, matrix, stride) avresample_set_matrix(ctx, matrix, stride) 236 #define swr_get_delay(ctx, ...) avresample_get_delay(ctx) 237 #if LIBAVRESAMPLE_VERSION_INT >= AV_VERSION_INT(1, 0, 0) //ffmpeg >= 1.1 238 #define swr_convert(ctx, out, out_count, in, in_count) \ 239 avresample_convert(ctx, out, 0, out_count, const_cast<uint8_t**>(in), 0, in_count) 241 #define swr_convert(ctx, out, out_count, in, in_count) \ 242 avresample_convert(ctx, (void**)out, 0, out_count, (void**)in, 0, in_count) 243 #define HAVE_SWR_GET_DELAY 1 244 #define swr_get_delay(ctx, ...) avresample_get_delay(ctx) 247 #define swresample_version() avresample_version() 248 #define swresample_configuration() avresample_configuration() 249 #define swresample_license() avresample_license() 259 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 13, 100) //(51, 42, 0) 261 #define QTAV_PIX_FMT_C(X) PIX_FMT_##X 262 #else //FFmpeg >= 2.0 264 #define QTAV_PIX_FMT_C(X) AV_PIX_FMT_##X 265 #endif //AV_VERSION_INT(51, 42, 0) 273 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 2, 1) //git cbe5a60c9d495df0fb4775b064f06719b70b9952 274 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 22, 1) //git 38d553322891c8e47182f05199d19888422167dc 275 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 19, 0) //git 6b0768e2021b90215a2ab55ed427bce91d148148 276 #define PIX_FMT_PLANAR 16 277 #define PIX_FMT_RGB 32 278 #endif //AV_VERSION_INT(51, 19, 0) 279 #define PIX_FMT_PSEUDOPAL 64 //why not defined in FFmpeg 0.9 lavu51.32.0 but git log says 51.22.1 defined it? 280 #endif //AV_VERSION_INT(51, 22, 1) 281 #define PIX_FMT_ALPHA 128 282 #endif //AV_VERSION_INT(52, 2, 1) 284 #ifndef PIX_FMT_PLANAR 285 #define PIX_FMT_PLANAR 16 286 #endif //PIX_FMT_PLANAR 288 #define PIX_FMT_RGB 32 290 #ifndef PIX_FMT_PSEUDOPAL 291 #define PIX_FMT_PSEUDOPAL 64 292 #endif //PIX_FMT_PSEUDOPAL 293 #ifndef PIX_FMT_ALPHA 294 #define PIX_FMT_ALPHA 128 295 #endif //PIX_FMT_ALPHA 301 #ifndef AV_PIX_FMT_FLAG_BE 302 #define AV_PIX_FMT_FLAG_BE PIX_FMT_BE 303 #define AV_PIX_FMT_FLAG_PAL PIX_FMT_PAL 304 #define AV_PIX_FMT_FLAG_BITSTREAM PIX_FMT_BITSTREAM 305 #define AV_PIX_FMT_FLAG_HWACCEL PIX_FMT_HWACCEL 308 #define AV_PIX_FMT_FLAG_PLANAR PIX_FMT_PLANAR 309 #define AV_PIX_FMT_FLAG_RGB PIX_FMT_RGB 312 #define AV_PIX_FMT_FLAG_PSEUDOPAL PIX_FMT_PSEUDOPAL 314 #define AV_PIX_FMT_FLAG_ALPHA PIX_FMT_ALPHA 315 #endif //AV_PIX_FMT_FLAG_BE 319 #if !AV_MODULE_CHECK(LIBAVUTIL, 52, 3, 0, 13, 100) 323 #endif // !AV_MODULE_CHECK(LIBAVUTIL, 52, 3, 0, 13, 100) 324 #if !FFMPEG_MODULE_CHECK(LIBAVUTIL, 52, 48, 101) // since ffmpeg2.1, libavutil53.16.0 (FF_API_AVFRAME_COLORSPACE), git 8c02adc 332 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52, 38, 100) 334 #endif //AV_VERSION_INT(52, 38, 100) 337 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 73, 101) 349 int av_samples_copy(uint8_t **dst, uint8_t *
const *src,
int dst_offset,
350 int src_offset,
int nb_samples,
int nb_channels,
352 #endif //AV_VERSION_INT(51, 73, 101) 356 #if AV_MODULE_CHECK(LIBAVCODEC, 54, 25, 0, 51, 100) 357 #define QTAV_CODEC_ID(X) AV_CODEC_ID_##X 360 #define QTAV_CODEC_ID(X) CODEC_ID_##X 368 #if !AV_MODULE_CHECK(LIBAVCODEC, 55, 34, 0, 18, 100) 369 #define av_frame_alloc() avcodec_alloc_frame() 370 #if QTAV_USE_LIBAV(LIBAVCODEC) || FFMPEG_MODULE_CHECK(LIBAVCODEC, 54, 59, 100) 371 #define av_frame_free(f) avcodec_free_frame(f) 373 #define av_frame_free(f) av_free(f) 377 #if QTAV_USE_LIBAV(LIBAVCODEC) 380 #if !AV_MODULE_CHECK(LIBAVCODEC, 55, 55, 0, 68, 100) 384 #if !LIBAV_MODULE_CHECK(LIBAVCODEC, 56, 1, 0) && !FFMPEG_MODULE_CHECK(LIBAVCODEC, 55, 39, 100) 388 #if !LIBAV_MODULE_CHECK(LIBAVCODEC, 55, 34, 1) && !FFMPEG_MODULE_CHECK(LIBAVCODEC, 55, 39, 100) 392 #if !AV_MODULE_CHECK(LIBAVCODEC, 55, 34, 1, 39, 101) 394 #define av_packet_unref(pkt) av_free_packet(pkt) 397 #if !AV_MODULE_CHECK(LIBAVCODEC, 55, 52, 0, 63, 100) 401 #if QTAV_HAVE(AVFILTER) 403 #if QTAV_USE_LIBAV(LIBAVFILTER) 404 #define avfilter_graph_parse_ptr(pGraph, pFilters, ppInputs, ppOutputs, pLog) avfilter_graph_parse(pGraph, pFilters, *ppInputs, *ppOutputs, pLog) 405 #elif !FFMPEG_MODULE_CHECK(LIBAVFILTER, 3, 78, 100) 406 #define avfilter_graph_parse_ptr(pGraph, pFilters, ppInputs, ppOutputs, pLog) avfilter_graph_parse(pGraph, pFilters, ppInputs, ppOutputs, pLog) 407 #endif //QTAV_USE_LIBAV(LIBAVFILTER) 410 #if !AV_MODULE_CHECK(LIBAVFILTER, 2, 22, 0, 79, 100) //FF_API_AVFILTERPAD_PUBLIC 414 #if QTAV_USE_FFMPEG(LIBAVFILTER) 419 struct AVFilterBufferRef;
420 int avfilter_copy_buf_props(
AVFrame *dst,
const AVFilterBufferRef *src);
425 #endif //QTAV_HAVE(AVFILTER) 431 #ifndef FF_PROFILE_HEVC_MAIN //libav does not define it 432 #define AV_CODEC_ID_HEVC ((AVCodecID)0) //QTAV_CODEC_ID(NONE) 433 #define CODEC_ID_HEVC ((AVCodecID)0) //QTAV_CODEC_ID(NONE) 434 #define FF_PROFILE_HEVC_MAIN -1 435 #define FF_PROFILE_HEVC_MAIN_10 -1 437 #if !FFMPEG_MODULE_CHECK(LIBAVCODEC, 54, 92, 100) && !LIBAV_MODULE_CHECK(LIBAVCODEC, 55, 34, 1) //ffmpeg1.2 libav10 438 #define AV_CODEC_ID_VP9 ((AVCodecID)0) //QTAV_CODEC_ID(NONE) 439 #define CODEC_ID_VP9 ((AVCodecID)0) //QTAV_CODEC_ID(NONE) 441 #ifndef FF_PROFILE_VP9_0 442 #define FF_PROFILE_VP9_0 0 443 #define FF_PROFILE_VP9_1 1 444 #define FF_PROFILE_VP9_2 2 445 #define FF_PROFILE_VP9_3 3 448 #define AV_RUN_CHECK(FUNC, RETURN, ...) do { \ 451 char str[AV_ERROR_MAX_STRING_SIZE]; \ 452 memset(str, 0, sizeof(str)); \ 453 av_strerror(ret, str, sizeof(str)); \ 454 av_log(NULL, AV_LOG_WARNING, "Error " #FUNC " @%d " __FILE__ ": (%#x) %s\n", __LINE__, ret, str); \ 455 RETURN __VA_ARGS__; \ 458 #endif //QTAV_COMPAT_H
int av_samples_copy(uint8_t **dst, uint8_t *const *src, int dst_offset, int src_offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
enum PixelFormat AVPixelFormat
Definition: AVCompat.h:260
int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat, const char *format, const char *filename)
const AVPixFmtDescriptor * av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev)
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
void av_packet_free_side_data(AVPacket *pkt)
enum CodecID AVCodecID
Definition: AVCompat.h:359
void avcodec_free_context(AVCodecContext **avctx)
AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
AVColorSpace
Definition: pixfmt.h:436
void ffmpeg_version_print()
int av_packet_ref(AVPacket *dst, const AVPacket *src)
AVColorRange
Definition: pixfmt.h:457
AVCodecID
Definition: avcodec.h:191
Definition: avcodec.h:1578
const char * get_codec_long_name(AVCodecID id)
struct SwrContext SwrContext
Definition: swresample.h:186
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
struct SwrContext * swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
const char * avcodec_get_name(enum AVCodecID id)
int avio_feof(AVIOContext *s)
AVSampleFormat
Definition: samplefmt.h:58
Definition: avcodec.h:1676
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame)
av_always_inline char * av_err2str(int errnum)
Definition: AVCompat.h:180
AVMediaType
Definition: avutil.h:193
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Definition: rational.h:58
Definition: avformat.h:1338
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
int av_pix_fmt_count_planes(AVPixelFormat pix_fmt)
int64_t av_get_default_channel_layout(int nb_channels)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(AVPixelFormat pix_fmt)
struct AVFilterPad AVFilterPad
Definition: avfilter.h:69
#define AV_ERROR_MAX_STRING_SIZE
Definition: AVCompat.h:169
#define av_always_inline
Definition: attributes.h:43
enum AVColorRange av_frame_get_color_range(const AVFrame *frame)
AVPixelFormat
Definition: pixfmt.h:60