xine-lib
1.2.13-20230125hg15249
xine-lib-1.2.13
src
combined
ffmpeg
ffmpeg_compat.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2000-2022 the xine project
3
*
4
* This file is part of xine, a unix video player.
5
*
6
* xine is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* xine is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19
*
20
* Compability macros for various ffmpeg versions
21
*/
22
23
#ifndef XINE_AVCODEC_COMPAT_H
24
#define XINE_AVCODEC_COMPAT_H
25
26
#define XFF_INT_VERSION(major,minor,micro) ((major<<16)|(minor<<8)|micro)
27
33
#if !defined(LIBAVUTIL_VERSION_INT) && defined(LIBAVUTIL_VERSION_MAJOR) && defined(LIBAVUTIL_VERSION_MINOR)
34
# define LIBAVUTIL_VERSION_INT XFF_INT_VERSION(LIBAVUTIL_VERSION_MAJOR,LIBAVUTIL_VERSION_MINOR,0)
35
#endif
36
#if !defined(LIBAVUTIL_VERSION_INT)
37
# error avutil.h must be included first !
38
#endif
39
40
#if !defined(LIBAVCODEC_VERSION_INT) && defined(LIBAVCODEC_VERSION_MAJOR) && defined(LIBAVCODEC_VERSION_MINOR)
41
# define LIBAVCODEC_VERSION_INT XFF_INT_VERSION(LIBAVCODEC_VERSION_MAJOR,LIBAVCODEC_VERSION_MINOR,0)
42
#endif
43
44
#if defined(LIBAVCODEC_VERSION_INT)
45
46
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,0,0)
47
# define bits_per_sample bits_per_coded_sample
48
#endif
49
50
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,32,0)
51
#else
52
# define pp_context pp_context_t
53
# define pp_mode pp_mode_t
54
#endif
55
56
/* reordered_opaque appeared in libavcodec 51.68.0 */
57
#define XFF_AVCODEC_REORDERED_OPAQUE
58
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(51,68,0)
59
# undef XFF_AVCODEC_REORDERED_OPAQUE
60
#endif
61
62
/* colorspace and color_range were added before 52.29.0 */
63
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,29,0)
64
# define XFF_AVCODEC_COLORSPACE
65
#endif
66
67
/* "unused" as of v54 */
68
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,0,0)
69
# define XFF_AVCODEC_SUB_ID
70
#endif
71
72
/* not 100% sure about this (between 55.19 and 56.56) */
73
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(56,0,0)
74
# define XFF_AVCODEC_STREAM_CODEC_TAG
75
#endif
76
77
/* avcodec_thread_init() */
78
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,112,0)
79
# define DEPRECATED_AVCODEC_THREAD_INIT 1
80
#endif
81
82
/* av_parser_parse() */
83
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,94,0)
84
# define XFF_PARSE 2
85
#else
86
# define XFF_PARSE 1
87
#endif
88
89
/* avcodec_decode_video* (), avcodec_send_packet (), avcodec_receive_frame () */
90
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
91
# define XFF_VIDEO 3
92
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,32,0)
93
# define XFF_VIDEO 2
94
#else
95
# define XFF_VIDEO 1
96
#endif
97
98
/* avcodec_decode_audio* (), avcodec_send_packet (), avcodec_receive_frame () */
99
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
100
# define XFF_AUDIO 5
101
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(54,0,0)
102
# define XFF_AUDIO 4
103
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,32,0)
104
# define XFF_AUDIO 3
105
#else
106
# define XFF_AUDIO 2
107
#endif
108
109
/* avcodec_encode_video(), av_packet_unref, avcodec_send_frame (), avcodec_receive_packet () */
110
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
111
# define XFF_ENCVIDEO 3
112
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(55,25,100)
113
# define XFF_ENCVIDEO 2
114
#else
115
# define XFF_ENCVIDEO 1
116
#endif
117
118
/* AVFrame.age not sure about this - original condition was broken */
119
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(53,28,1) && LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,0,0)
120
# define XFF_FRAME_AGE 1
121
#endif
122
123
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,0,0)
124
/* release 0.7.x (libavcodec 52) has deprecated AVCodecContext.palctrl but for backwards compatibility no
125
working alternative. */
126
# define XFF_PALETTE 1
127
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,92,100)
128
/* pass palette as AVPacket side data, free with av_destruct_packet () after NULLing main data pointer */
129
# define XFF_PALETTE 2
130
#else
131
/* dito, free with av_free_packet () after NULLing main data pointer */
132
# define XFF_PALETTE 3
133
#endif
134
135
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
136
# define XFF_VAAPI 1
137
#else
138
# define XFF_VAAPI 2
139
#endif
140
141
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(54,25,0)
142
/* dxr3/ffmpeg_encoder */
143
# define CODEC_ID_MPEG1VIDEO AV_CODEC_ID_MPEG1VIDEO
144
/* video_out/video_out_vaapi */
145
# define CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO
146
# define CODEC_ID_MPEG4 AV_CODEC_ID_MPEG4
147
# define CODEC_ID_H263 AV_CODEC_ID_H263
148
# define CODEC_ID_H264 AV_CODEC_ID_H264
149
# define CODEC_ID_WMV3 AV_CODEC_ID_WMV3
150
/* video_out/video_out_vaapi, ff_video_decoder */
151
# define CODEC_ID_VC1 AV_CODEC_ID_VC1
152
/* ff_video_decoder */
153
# define CODEC_ID_SVQ3 AV_CODEC_ID_SVQ3
154
# define CODEC_ID_MSMPEG4V1 AV_CODEC_ID_MSMPEG4V1
155
# define CODEC_ID_MSMPEG4V2 AV_CODEC_ID_MSMPEG4V2
156
# define CODEC_ID_MSMPEG4V3 AV_CODEC_ID_MSMPEG4V3
157
# define CODEC_ID_WMV1 AV_CODEC_ID_WMV1
158
# define CODEC_ID_WMV2 AV_CODEC_ID_WMV2
159
/* demux_avformat */
160
# define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
161
# define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
162
# define CODEC_ID_MP2 AV_CODEC_ID_MP2
163
# define CODEC_ID_AC3 AV_CODEC_ID_AC3
164
/* ff_*_decoder mapping is already handled by mkcodeclists.pl */
165
#endif
166
167
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(55,0,100)
168
# define XFF_AV_BUFFER 1
169
#endif
170
171
/* 0 (no), 1 (yes), 2 (deprecated but still needed to make direct rendering work) */
172
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,0,100)
173
# define XFF_THREAD_SAFE_CB 0
174
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
175
# define XFF_THREAD_SAFE_CB 1
176
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(60,0,0)
177
# define XFF_THREAD_SAFE_CB 2
178
#else
179
/* now callbacks shall always be thread safe. */
180
# define XFF_THREAD_SAFE_CB 0
181
#endif
182
183
/* function aliases */
184
185
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(52,66,0)
186
# define XFF_EDGE_WIDTH() (16)
187
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,48,102)
188
# define XFF_EDGE_WIDTH() avcodec_get_edge_width()
189
#else
190
/* edges not needed anymore supposedly */
191
# define XFF_EDGE_WIDTH() (0)
192
#endif
193
194
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,8,0)
195
# define XFF_AVCODEC_INIT() avcodec_init()
196
#else
197
# define XFF_AVCODEC_INIT() do {} while(0)
198
#endif
199
200
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,6,0)
201
# define XFF_ALLOC_CONTEXT() avcodec_alloc_context()
202
#else
203
# define XFF_ALLOC_CONTEXT() avcodec_alloc_context3(NULL)
204
#endif
205
206
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,6,0)
207
# define XFF_AVCODEC_OPEN(ctx,codec) avcodec_open(ctx,codec)
208
#else
209
# define XFF_AVCODEC_OPEN(ctx,codec) avcodec_open2(ctx, codec, NULL)
210
#endif
211
212
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,63,100)
213
# define XFF_FREE_CONTEXT(pp) do {av_free(pp); pp = NULL;} while (0)
214
#else
215
# define XFF_FREE_CONTEXT(pp) avcodec_free_context(&(pp))
216
#endif
217
218
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,59,100)
219
# define XFF_ALLOC_FRAME() avcodec_alloc_frame()
220
# define XFF_FREE_FRAME(pp) do {av_free(pp); pp = NULL;} while (0)
221
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,45,101)
222
# define XFF_ALLOC_FRAME() avcodec_alloc_frame()
223
# define XFF_FREE_FRAME(pp) avcodec_free_frame(&(pp))
224
#else
225
# define XFF_ALLOC_FRAME() av_frame_alloc()
226
# define XFF_FREE_FRAME(pp) av_frame_free(&(pp))
227
#endif
228
229
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(57,12,100)
230
# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
231
# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
232
# define XFF_PACKET_UNREF(_p) av_free_packet (_p)
233
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
234
# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
235
# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
236
# define XFF_PACKET_UNREF(_p) av_packet_unref (_p)
237
#else
238
# define XFF_PACKET_DECL(_p) AVPacket *_p
239
# define XFF_PACKET_NEW(_p) _p = av_packet_alloc ()
240
# define XFF_PACKET_UNREF(_p) av_packet_free (&(_p))
241
#endif
242
243
#ifndef AV_INPUT_BUFFER_PADDING_SIZE
244
# define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
245
#endif
246
#ifndef AV_CODEC_CAP_DR1
247
# define AV_CODEC_CAP_DR1 CODEC_CAP_DR1
248
#endif
249
#ifndef AV_CODEC_FLAG2_FAST
250
# define AV_CODEC_FLAG2_FAST CODEC_FLAG2_FAST
251
#endif
252
253
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(58,10,100)
254
# define XFF_AVCODEC_REGISTER_ALL() avcodec_register_all()
255
#else
256
# define XFF_AVCODEC_REGISTER_ALL() do {} while(0)
257
#endif
258
259
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,24,100)
260
# define XFF_AUDIO_CHANNEL_LAYOUT 1
/* AVCodecContext.channels, .channel_leyout */
261
#else
262
# define XFF_AUDIO_CHANNEL_LAYOUT 2
/* AVCodecContext.ch_layout.nb_channels, .ch_layout.u.mask */
263
#endif
264
265
#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
266
# define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
267
#endif
268
269
#if LIBAVUTIL_VERSION_INT >= XFF_INT_VERSION(52,0,0)
270
# define PIX_FMT_NONE AV_PIX_FMT_NONE
271
# define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
272
# define PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P
273
# define PIX_FMT_YUV444P AV_PIX_FMT_YUV444P
274
# define PIX_FMT_YUVJ444P AV_PIX_FMT_YUVJ444P
275
# define PIX_FMT_YUV410P AV_PIX_FMT_YUV410P
276
# define PIX_FMT_YUV411P AV_PIX_FMT_YUV411P
277
# define PIX_FMT_ARGB AV_PIX_FMT_ARGB
278
# define PIX_FMT_BGRA AV_PIX_FMT_BGRA
279
# define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
280
# define PIX_FMT_BGR24 AV_PIX_FMT_BGR24
281
# define PIX_FMT_RGB555BE AV_PIX_FMT_RGB555BE
282
# define PIX_FMT_RGB555LE AV_PIX_FMT_RGB555LE
283
# define PIX_FMT_RGB565BE AV_PIX_FMT_RGB565BE
284
# define PIX_FMT_RGB565LE AV_PIX_FMT_RGB565LE
285
# define PIX_FMT_PAL8 AV_PIX_FMT_PAL8
286
# define PixelFormat AVPixelFormat
287
/* video_out/video_out_vaapi */
288
# if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
289
# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI_VLD
290
# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI_IDCT
291
# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI_MOCO
292
# else
293
# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI
294
# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI
295
# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI
296
# endif
297
298
# define CODEC_FLAG_BITEXACT AV_CODEC_FLAG_BITEXACT
299
#endif
300
301
#else
/* defined(LIBAVCODEC_VERSION_INT) */
302
# error avcodec.h must be included first !
303
#endif
/* defined(LIBAVCODEC_VERSION_INT) */
304
305
#endif
/* XINE_AVCODEC_COMPAT_H */
306
Generated by
1.10.0