1 #ifndef __ffmpeg_compat_h_included__
2 #define __ffmpeg_compat_h_included__ 1
7 * compatibility macros to make every ffmpeg installation appear
8 * like the most current installation (wrapping some functionality sometimes)
9 * it also includes all ffmpeg header files at once, no need to do it
12 * Copyright (c) 2011 Peter Schlaile
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
27 #include <libavformat/avformat.h>
28 #include <libavcodec/avcodec.h>
29 #include <libavutil/rational.h>
31 #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
32 #define FFMPEG_HAVE_PARSE_UTILS 1
33 #include <libavutil/parseutils.h>
36 #include <libswscale/swscale.h>
37 #include <libavcodec/opt.h>
39 #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105))
40 #define FFMPEG_HAVE_AVIO 1
43 #if (LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 1))
44 #define FFMPEG_HAVE_DEFAULT_VAL_UNION 1
47 #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
48 #define FFMPEG_HAVE_AV_DUMP_FORMAT 1
51 #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 45))
52 #define FFMPEG_HAVE_AV_GUESS_FORMAT 1
55 #if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 23))
56 #define FFMPEG_HAVE_DECODE_AUDIO3 1
57 #define FFMPEG_HAVE_DECODE_VIDEO2 1
60 #if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 64))
61 #define FFMPEG_HAVE_AVMEDIA_TYPES 1
64 #if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29) && \
65 (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10)
66 #define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT
69 #ifndef FFMPEG_HAVE_AVIO
70 #define AVIO_FLAG_WRITE URL_WRONLY
71 #define avio_open url_fopen
72 #define avio_tell url_ftell
73 #define avio_close url_fclose
76 /* there are some version inbetween, which have avio_... functions but no
78 #ifndef AVIO_FLAG_WRITE
79 #define AVIO_FLAG_WRITE URL_WRONLY
82 #ifndef AV_PKT_FLAG_KEY
83 #define AV_PKT_FLAG_KEY PKT_FLAG_KEY
86 #ifndef FFMPEG_HAVE_AV_DUMP_FORMAT
87 #define av_dump_format dump_format
90 #ifndef FFMPEG_HAVE_AV_GUESS_FORMAT
91 #define av_guess_format guess_format
94 #ifndef FFMPEG_HAVE_PARSE_UTILS
95 #define av_parse_video_rate av_parse_video_frame_rate
98 #ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION
99 #define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val.i64
100 #define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val.dbl
102 #define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val
103 #define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val
106 #ifndef FFMPEG_HAVE_AVMEDIA_TYPES
107 #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
108 #define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
111 #ifndef FFMPEG_HAVE_DECODE_AUDIO3
113 int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
114 int *frame_size_ptr, AVPacket *avpkt)
116 return avcodec_decode_audio2(avctx, samples,
117 frame_size_ptr, avpkt->data,
122 #ifndef FFMPEG_HAVE_DECODE_VIDEO2
124 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
125 int *got_picture_ptr,
128 return avcodec_decode_video(avctx, picture, got_picture_ptr,
129 avpkt->data, avpkt->size);