Line 0
Link Here
|
|
|
1 |
#ifndef __ffmpeg_compat_h_included__ |
2 |
#define __ffmpeg_compat_h_included__ 1 |
3 |
|
4 |
/* |
5 |
* $Id: ffmpeg_compat.h 39749 2011-08-28 14:46:03Z schlaile $ |
6 |
* |
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 |
10 |
* seperately. |
11 |
* |
12 |
* Copyright (c) 2011 Peter Schlaile |
13 |
* |
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. |
18 |
* |
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. |
23 |
* |
24 |
*/ |
25 |
|
26 |
|
27 |
#include <libavformat/avformat.h> |
28 |
#include <libavcodec/avcodec.h> |
29 |
#include <libavutil/rational.h> |
30 |
|
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> |
34 |
#endif |
35 |
|
36 |
#include <libswscale/swscale.h> |
37 |
#include <libavcodec/opt.h> |
38 |
|
39 |
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105)) |
40 |
#define FFMPEG_HAVE_AVIO 1 |
41 |
#endif |
42 |
|
43 |
#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)) |
44 |
#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 |
45 |
#endif |
46 |
|
47 |
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) |
48 |
#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 |
49 |
#endif |
50 |
|
51 |
#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 45)) |
52 |
#define FFMPEG_HAVE_AV_GUESS_FORMAT 1 |
53 |
#endif |
54 |
|
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 |
58 |
#endif |
59 |
|
60 |
#if (LIBAVCODEC_VERSION_MAJOR > 52) || ((LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 64)) |
61 |
#define FFMPEG_HAVE_AVMEDIA_TYPES 1 |
62 |
#endif |
63 |
|
64 |
#if ((LIBAVCODEC_VERSION_MAJOR > 52) || (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29)) && \ |
65 |
((LIBSWSCALE_VERSION_MAJOR > 0) || (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10)) |
66 |
#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT |
67 |
#endif |
68 |
|
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 |
74 |
#define avio_size url_fsize |
75 |
#endif |
76 |
|
77 |
/* there are some version inbetween, which have avio_... functions but no |
78 |
AVIO_FLAG_... */ |
79 |
#ifndef AVIO_FLAG_WRITE |
80 |
#define AVIO_FLAG_WRITE URL_WRONLY |
81 |
#endif |
82 |
|
83 |
#ifndef AV_PKT_FLAG_KEY |
84 |
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY |
85 |
#endif |
86 |
|
87 |
#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT |
88 |
#define av_dump_format dump_format |
89 |
#endif |
90 |
|
91 |
#ifndef FFMPEG_HAVE_AV_GUESS_FORMAT |
92 |
#define av_guess_format guess_format |
93 |
#endif |
94 |
|
95 |
#ifndef FFMPEG_HAVE_PARSE_UTILS |
96 |
#define av_parse_video_rate av_parse_video_frame_rate |
97 |
#endif |
98 |
|
99 |
#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION |
100 |
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val.i64 |
101 |
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val.dbl |
102 |
#else |
103 |
#define FFMPEG_DEF_OPT_VAL_INT(OPT) OPT->default_val |
104 |
#define FFMPEG_DEF_OPT_VAL_DOUBLE(OPT) OPT->default_val |
105 |
#endif |
106 |
|
107 |
#ifndef FFMPEG_HAVE_AVMEDIA_TYPES |
108 |
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO |
109 |
#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO |
110 |
#endif |
111 |
|
112 |
#ifndef FFMPEG_HAVE_DECODE_AUDIO3 |
113 |
static inline |
114 |
int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, |
115 |
int *frame_size_ptr, AVPacket *avpkt) |
116 |
{ |
117 |
return avcodec_decode_audio2(avctx, samples, |
118 |
frame_size_ptr, avpkt->data, |
119 |
avpkt->size); |
120 |
} |
121 |
#endif |
122 |
|
123 |
#ifndef FFMPEG_HAVE_DECODE_VIDEO2 |
124 |
static inline |
125 |
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, |
126 |
int *got_picture_ptr, |
127 |
AVPacket *avpkt) |
128 |
{ |
129 |
return avcodec_decode_video(avctx, picture, got_picture_ptr, |
130 |
avpkt->data, avpkt->size); |
131 |
} |
132 |
#endif |
133 |
|
134 |
static inline |
135 |
int64_t av_get_pts_from_frame(AVFormatContext *avctx, AVFrame * picture) |
136 |
{ |
137 |
int64_t pts = picture->pkt_pts; |
138 |
|
139 |
if (pts == AV_NOPTS_VALUE) { |
140 |
pts = picture->pkt_dts; |
141 |
} |
142 |
if (pts == AV_NOPTS_VALUE) { |
143 |
pts = 0; |
144 |
} |
145 |
|
146 |
return pts; |
147 |
} |
148 |
|
149 |
#endif |