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-2024 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
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(51,68,0) && LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(60,0,0)
58
# define XFF_AVCODEC_REORDERED_OPAQUE
59
#else
60
# undef XFF_AVCODEC_REORDERED_OPAQUE
61
#endif
62
63
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(58,33,100)
64
# define XFF_AVCODEC_FRAME_PTS
65
#else
66
# undef XFF_AVCODEC_FRAME_PTS
67
#endif
68
69
/* colorspace and color_range were added before 52.29.0 */
70
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,29,0)
71
# define XFF_AVCODEC_COLORSPACE
72
#endif
73
74
/* "unused" as of v54 */
75
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,0,0)
76
# define XFF_AVCODEC_SUB_ID
77
#endif
78
79
/* not 100% sure about this (between 55.19 and 56.56) */
80
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(56,0,0)
81
# define XFF_AVCODEC_STREAM_CODEC_TAG
82
#endif
83
84
/* avcodec_thread_init() */
85
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,112,0)
86
# define DEPRECATED_AVCODEC_THREAD_INIT 1
87
#endif
88
89
/* av_parser_parse() */
90
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,94,0)
91
# define XFF_PARSE 2
92
#else
93
# define XFF_PARSE 1
94
#endif
95
96
/* avcodec_decode_video* (), avcodec_send_packet (), avcodec_receive_frame () */
97
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
98
# define XFF_VIDEO 3
99
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,32,0)
100
# define XFF_VIDEO 2
101
#else
102
# define XFF_VIDEO 1
103
#endif
104
105
/* avcodec_decode_audio* (), avcodec_send_packet (), avcodec_receive_frame () */
106
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
107
# define XFF_AUDIO 5
108
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(54,0,0)
109
# define XFF_AUDIO 4
110
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(52,32,0)
111
# define XFF_AUDIO 3
112
#else
113
# define XFF_AUDIO 2
114
#endif
115
116
/* avcodec_encode_video(), av_packet_unref, avcodec_send_frame (), avcodec_receive_packet () */
117
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(57,106,102)
118
# define XFF_ENCVIDEO 3
119
#elif LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(55,25,100)
120
# define XFF_ENCVIDEO 2
121
#else
122
# define XFF_ENCVIDEO 1
123
#endif
124
125
/* AVFrame.age not sure about this - original condition was broken */
126
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(53,28,1) && LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,0,0)
127
# define XFF_FRAME_AGE 1
128
#endif
129
130
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,0,0)
131
/* release 0.7.x (libavcodec 52) has deprecated AVCodecContext.palctrl but for backwards compatibility no
132
working alternative. */
133
# define XFF_PALETTE 1
134
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,92,100)
135
/* pass palette as AVPacket side data, free with av_destruct_packet () after NULLing main data pointer */
136
# define XFF_PALETTE 2
137
#else
138
/* dito, free with av_free_packet () after NULLing main data pointer */
139
# define XFF_PALETTE 3
140
#endif
141
142
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,42,100)
143
/* AVCodecContext.slice_{offset,count} */
144
# define XFF_AVCODEC_SLICE_TABLE 1
145
#else
146
/* inline offset table before the frame. */
147
# define XFF_AVCODEC_SLICE_TABLE 2
148
#endif
149
150
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
151
# define XFF_VAAPI 1
152
#else
153
# define XFF_VAAPI 2
154
#endif
155
156
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(54,25,0)
157
/* dxr3/ffmpeg_encoder */
158
# define CODEC_ID_MPEG1VIDEO AV_CODEC_ID_MPEG1VIDEO
159
/* video_out/video_out_vaapi */
160
# define CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO
161
# define CODEC_ID_MPEG4 AV_CODEC_ID_MPEG4
162
# define CODEC_ID_H263 AV_CODEC_ID_H263
163
# define CODEC_ID_H264 AV_CODEC_ID_H264
164
# define CODEC_ID_WMV3 AV_CODEC_ID_WMV3
165
/* video_out/video_out_vaapi, ff_video_decoder */
166
# define CODEC_ID_VC1 AV_CODEC_ID_VC1
167
/* ff_video_decoder */
168
# define CODEC_ID_SVQ3 AV_CODEC_ID_SVQ3
169
# define CODEC_ID_MSMPEG4V1 AV_CODEC_ID_MSMPEG4V1
170
# define CODEC_ID_MSMPEG4V2 AV_CODEC_ID_MSMPEG4V2
171
# define CODEC_ID_MSMPEG4V3 AV_CODEC_ID_MSMPEG4V3
172
# define CODEC_ID_WMV1 AV_CODEC_ID_WMV1
173
# define CODEC_ID_WMV2 AV_CODEC_ID_WMV2
174
/* demux_avformat */
175
# define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE
176
# define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE
177
# define CODEC_ID_MP2 AV_CODEC_ID_MP2
178
# define CODEC_ID_AC3 AV_CODEC_ID_AC3
179
/* ff_*_decoder mapping is already handled by mkcodeclists.pl */
180
#endif
181
182
#if LIBAVCODEC_VERSION_INT >= XFF_INT_VERSION(55,0,100)
183
# define XFF_AV_BUFFER 1
184
#endif
185
186
/* 0 (no), 1 (yes), 2 (deprecated but still needed to make direct rendering work) */
187
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,0,100)
188
# define XFF_THREAD_SAFE_CB 0
189
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
190
# define XFF_THREAD_SAFE_CB 1
191
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(60,0,0)
192
# define XFF_THREAD_SAFE_CB 2
193
#else
194
/* now callbacks shall always be thread safe. */
195
# define XFF_THREAD_SAFE_CB 0
196
#endif
197
198
/* function aliases */
199
200
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(52,66,0)
201
# define XFF_EDGE_WIDTH() (16)
202
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,48,102)
203
# define XFF_EDGE_WIDTH() avcodec_get_edge_width()
204
#else
205
/* edges not needed anymore supposedly */
206
# define XFF_EDGE_WIDTH() (0)
207
#endif
208
209
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,8,0)
210
# define XFF_AVCODEC_INIT() avcodec_init()
211
#else
212
# define XFF_AVCODEC_INIT() do {} while(0)
213
#endif
214
215
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,6,0)
216
# define XFF_ALLOC_CONTEXT() avcodec_alloc_context()
217
#else
218
# define XFF_ALLOC_CONTEXT() avcodec_alloc_context3(NULL)
219
#endif
220
221
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(53,6,0)
222
# define XFF_AVCODEC_OPEN(ctx,codec) avcodec_open(ctx,codec)
223
#else
224
# define XFF_AVCODEC_OPEN(ctx,codec) avcodec_open2(ctx, codec, NULL)
225
#endif
226
227
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,63,100)
228
# define XFF_FREE_CONTEXT(pp) do {if (pp) avcodec_close (pp); av_free (pp); pp = NULL;} while (0)
229
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(58,33,100)
230
# define XFF_FREE_CONTEXT(pp) do {if (pp) avcodec_close (pp); avcodec_free_context (&(pp));} while (0)
231
#else
232
# define XFF_FREE_CONTEXT(pp) avcodec_free_context (&(pp))
233
#endif
234
235
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(54,59,100)
236
# define XFF_ALLOC_FRAME() avcodec_alloc_frame()
237
# define XFF_FREE_FRAME(pp) do {av_free(pp); pp = NULL;} while (0)
238
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(55,45,101)
239
# define XFF_ALLOC_FRAME() avcodec_alloc_frame()
240
# define XFF_FREE_FRAME(pp) avcodec_free_frame(&(pp))
241
#else
242
# define XFF_ALLOC_FRAME() av_frame_alloc()
243
# define XFF_FREE_FRAME(pp) av_frame_free(&(pp))
244
#endif
245
246
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(57,12,100)
247
# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
248
# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
249
# define XFF_PACKET_UNREF(_p) av_free_packet (_p)
250
#elif LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
251
# define XFF_PACKET_DECL(_p) AVPacket _p##_stat, *_p
252
# define XFF_PACKET_NEW(_p) _p = &_p##_stat, av_init_packet (_p)
253
# define XFF_PACKET_UNREF(_p) av_packet_unref (_p)
254
#else
255
# define XFF_PACKET_DECL(_p) AVPacket *_p
256
# define XFF_PACKET_NEW(_p) _p = av_packet_alloc ()
257
# define XFF_PACKET_UNREF(_p) av_packet_free (&(_p))
258
#endif
259
260
#ifndef AV_INPUT_BUFFER_PADDING_SIZE
261
# define AV_INPUT_BUFFER_PADDING_SIZE FF_INPUT_BUFFER_PADDING_SIZE
262
#endif
263
#ifndef AV_CODEC_CAP_DR1
264
# define AV_CODEC_CAP_DR1 CODEC_CAP_DR1
265
#endif
266
#ifndef AV_CODEC_FLAG2_FAST
267
# define AV_CODEC_FLAG2_FAST CODEC_FLAG2_FAST
268
#endif
269
270
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(58,10,100)
271
# define XFF_AVCODEC_REGISTER_ALL() avcodec_register_all()
272
#else
273
# define XFF_AVCODEC_REGISTER_ALL() do {} while(0)
274
#endif
275
276
#if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,24,100)
277
# define XFF_AUDIO_CHANNEL_LAYOUT 1
/* AVCodecContext.channels, .channel_leyout */
278
#else
279
# define XFF_AUDIO_CHANNEL_LAYOUT 2
/* AVCodecContext.ch_layout.nb_channels, .ch_layout.u.mask */
280
#endif
281
282
#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
283
# define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
284
#endif
285
286
#if LIBAVUTIL_VERSION_INT >= XFF_INT_VERSION(52,0,0)
287
# define PIX_FMT_NONE AV_PIX_FMT_NONE
288
# define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
289
# define PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P
290
# define PIX_FMT_YUV444P AV_PIX_FMT_YUV444P
291
# define PIX_FMT_YUVJ444P AV_PIX_FMT_YUVJ444P
292
# define PIX_FMT_YUV410P AV_PIX_FMT_YUV410P
293
# define PIX_FMT_YUV411P AV_PIX_FMT_YUV411P
294
# define PIX_FMT_ARGB AV_PIX_FMT_ARGB
295
# define PIX_FMT_BGRA AV_PIX_FMT_BGRA
296
# define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
297
# define PIX_FMT_BGR24 AV_PIX_FMT_BGR24
298
# define PIX_FMT_RGB555BE AV_PIX_FMT_RGB555BE
299
# define PIX_FMT_RGB555LE AV_PIX_FMT_RGB555LE
300
# define PIX_FMT_RGB565BE AV_PIX_FMT_RGB565BE
301
# define PIX_FMT_RGB565LE AV_PIX_FMT_RGB565LE
302
# define PIX_FMT_PAL8 AV_PIX_FMT_PAL8
303
# define PixelFormat AVPixelFormat
304
/* video_out/video_out_vaapi */
305
# if LIBAVCODEC_VERSION_INT < XFF_INT_VERSION(59,0,100)
306
# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI_VLD
307
# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI_IDCT
308
# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI_MOCO
309
# else
310
# define PIX_FMT_VAAPI_VLD AV_PIX_FMT_VAAPI
311
# define PIX_FMT_VAAPI_IDCT AV_PIX_FMT_VAAPI
312
# define PIX_FMT_VAAPI_MOCO AV_PIX_FMT_VAAPI
313
# endif
314
315
# define CODEC_FLAG_BITEXACT AV_CODEC_FLAG_BITEXACT
316
#endif
317
318
#else
/* defined(LIBAVCODEC_VERSION_INT) */
319
# error avcodec.h must be included first !
320
#endif
/* defined(LIBAVCODEC_VERSION_INT) */
321
322
#endif
/* XINE_AVCODEC_COMPAT_H */
Generated by
1.11.0