2
* compatibility macros to make every ffmpeg installation appear
3
* like the most current installation (wrapping some functionality sometimes)
4
* it also includes all ffmpeg header files at once, no need to do it
7
* Copyright (c) 2011 Peter Schlaile
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
21
#ifndef __FFMPEG_COMPAT_H__
22
#define __FFMPEG_COMPAT_H__
24
#include <libavformat/avformat.h>
26
/* check our ffmpeg is new enough, avoids user complaints */
27
#if (LIBAVFORMAT_VERSION_MAJOR < 52) || ((LIBAVFORMAT_VERSION_MAJOR == 52) && (LIBAVFORMAT_VERSION_MINOR <= 64))
28
# error "FFmpeg 0.7 or newer is needed, Upgrade your FFmpeg or disable it"
30
/* end sanity check */
33
#include <libavcodec/avcodec.h>
34
#include <libavutil/rational.h>
35
#include <libavutil/opt.h>
37
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
38
#define FFMPEG_HAVE_PARSE_UTILS 1
39
#include <libavutil/parseutils.h>
42
#include <libswscale/swscale.h>
43
#include <libavcodec/opt.h>
45
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105))
46
#define FFMPEG_HAVE_AVIO 1
49
#if (LIBAVCODEC_VERSION_MAJOR > 53) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR > 1)) || ((LIBAVCODEC_VERSION_MAJOR == 53) && (LIBAVCODEC_VERSION_MINOR == 1) && (LIBAVCODEC_VERSION_MICRO >= 1)) || ((LIBAVCODEC_VERSION_MAJOR == 52) && (LIBAVCODEC_VERSION_MINOR >= 121))
50
#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1
53
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101))
54
#define FFMPEG_HAVE_AV_DUMP_FORMAT 1
57
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 45))
58
#define FFMPEG_HAVE_AV_GUESS_FORMAT 1
61
#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 23))
62
#define FFMPEG_HAVE_DECODE_AUDIO3 1
63
#define FFMPEG_HAVE_DECODE_VIDEO2 1
66
#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 64))
67
#define FFMPEG_HAVE_AVMEDIA_TYPES 1
70
#if ((LIBAVCODEC_VERSION_MAJOR > 52) || (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29)) && \
71
((LIBSWSCALE_VERSION_MAJOR > 0) || (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10))
72
#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT
75
#if ((LIBAVUTIL_VERSION_MAJOR > 51) || (LIBAVUTIL_VERSION_MAJOR == 51) && (LIBAVUTIL_VERSION_MINOR >= 32))
76
#define FFMPEG_FFV1_ALPHA_SUPPORTED
79
#ifndef FFMPEG_HAVE_AVIO
80
#define AVIO_FLAG_WRITE URL_WRONLY
81
#define avio_open url_fopen
82
#define avio_tell url_ftell
83
#define avio_close url_fclose
84
#define avio_size url_fsize
87
/* there are some version inbetween, which have avio_... functions but no
89
#ifndef AVIO_FLAG_WRITE
90
#define AVIO_FLAG_WRITE URL_WRONLY
93
#ifndef AV_PKT_FLAG_KEY
94
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY
97
#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT
98
#define av_dump_format dump_format
101
#ifndef FFMPEG_HAVE_AV_GUESS_FORMAT
102
#define av_guess_format guess_format
105
#ifndef FFMPEG_HAVE_PARSE_UTILS
106
#define av_parse_video_rate av_parse_video_frame_rate
109
#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION
110
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val.i64
111
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val.dbl
113
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val
114
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val
117
#ifndef FFMPEG_HAVE_AVMEDIA_TYPES
118
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
119
#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
122
#ifndef FFMPEG_HAVE_DECODE_AUDIO3
124
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
125
int *frame_size_ptr, AVPacket *avpkt)
127
return avcodec_decode_audio2(avctx, samples,
128
frame_size_ptr, avpkt->data,
133
#ifndef FFMPEG_HAVE_DECODE_VIDEO2
135
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
136
int *got_picture_ptr,
139
return avcodec_decode_video(avctx, picture, got_picture_ptr,
140
avpkt->data, avpkt->size);
145
int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame * picture)
147
int64_t pts = picture->pkt_pts;
149
if (pts == AV_NOPTS_VALUE) {
150
pts = picture->pkt_dts;
152
if (pts == AV_NOPTS_VALUE) {