xine-lib: xine-lib-1.2.12/src/combined/ffmpeg/ffmpeg_compat.h Source File

xine-lib 1.2.12

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