]> git.sesse.net Git - ffmpeg/blob - libavcodec/avcodec.h
Merge commit '44e065d56c87d6a9d0effccec5f31517f72924ec'
[ffmpeg] / libavcodec / avcodec.h
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_AVCODEC_H
22 #define AVCODEC_AVCODEC_H
23
24 /**
25  * @file
26  * external API header
27  */
28
29 #include <errno.h>
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avutil.h"
32 #include "libavutil/cpu.h"
33 #include "libavutil/channel_layout.h"
34 #include "libavutil/dict.h"
35 #include "libavutil/log.h"
36 #include "libavutil/pixfmt.h"
37 #include "libavutil/rational.h"
38
39 #include "libavcodec/version.h"
40 /**
41  * @defgroup libavc Encoding/Decoding Library
42  * @{
43  *
44  * @defgroup lavc_decoding Decoding
45  * @{
46  * @}
47  *
48  * @defgroup lavc_encoding Encoding
49  * @{
50  * @}
51  *
52  * @defgroup lavc_codec Codecs
53  * @{
54  * @defgroup lavc_codec_native Native Codecs
55  * @{
56  * @}
57  * @defgroup lavc_codec_wrappers External library wrappers
58  * @{
59  * @}
60  * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
61  * @{
62  * @}
63  * @}
64  * @defgroup lavc_internal Internal
65  * @{
66  * @}
67  * @}
68  *
69  */
70
71 /**
72  * @defgroup lavc_core Core functions/structures.
73  * @ingroup libavc
74  *
75  * Basic definitions, functions for querying libavcodec capabilities,
76  * allocating core structures, etc.
77  * @{
78  */
79
80
81 /**
82  * Identify the syntax and semantics of the bitstream.
83  * The principle is roughly:
84  * Two decoders with the same ID can decode the same streams.
85  * Two encoders with the same ID can encode compatible streams.
86  * There may be slight deviations from the principle due to implementation
87  * details.
88  *
89  * If you add a codec ID to this list, add it so that
90  * 1. no value of a existing codec ID changes (that would break ABI),
91  * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec.
92  *    This ensures that 2 forks can independently add AVCodecIDs without producing conflicts.
93  *
94  * After adding new codec IDs, do not forget to add an entry to the codec
95  * descriptor list and bump libavcodec minor version.
96  */
97 enum AVCodecID {
98     AV_CODEC_ID_NONE,
99
100     /* video codecs */
101     AV_CODEC_ID_MPEG1VIDEO,
102     AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
103     AV_CODEC_ID_MPEG2VIDEO_XVMC,
104     AV_CODEC_ID_H261,
105     AV_CODEC_ID_H263,
106     AV_CODEC_ID_RV10,
107     AV_CODEC_ID_RV20,
108     AV_CODEC_ID_MJPEG,
109     AV_CODEC_ID_MJPEGB,
110     AV_CODEC_ID_LJPEG,
111     AV_CODEC_ID_SP5X,
112     AV_CODEC_ID_JPEGLS,
113     AV_CODEC_ID_MPEG4,
114     AV_CODEC_ID_RAWVIDEO,
115     AV_CODEC_ID_MSMPEG4V1,
116     AV_CODEC_ID_MSMPEG4V2,
117     AV_CODEC_ID_MSMPEG4V3,
118     AV_CODEC_ID_WMV1,
119     AV_CODEC_ID_WMV2,
120     AV_CODEC_ID_H263P,
121     AV_CODEC_ID_H263I,
122     AV_CODEC_ID_FLV1,
123     AV_CODEC_ID_SVQ1,
124     AV_CODEC_ID_SVQ3,
125     AV_CODEC_ID_DVVIDEO,
126     AV_CODEC_ID_HUFFYUV,
127     AV_CODEC_ID_CYUV,
128     AV_CODEC_ID_H264,
129     AV_CODEC_ID_INDEO3,
130     AV_CODEC_ID_VP3,
131     AV_CODEC_ID_THEORA,
132     AV_CODEC_ID_ASV1,
133     AV_CODEC_ID_ASV2,
134     AV_CODEC_ID_FFV1,
135     AV_CODEC_ID_4XM,
136     AV_CODEC_ID_VCR1,
137     AV_CODEC_ID_CLJR,
138     AV_CODEC_ID_MDEC,
139     AV_CODEC_ID_ROQ,
140     AV_CODEC_ID_INTERPLAY_VIDEO,
141     AV_CODEC_ID_XAN_WC3,
142     AV_CODEC_ID_XAN_WC4,
143     AV_CODEC_ID_RPZA,
144     AV_CODEC_ID_CINEPAK,
145     AV_CODEC_ID_WS_VQA,
146     AV_CODEC_ID_MSRLE,
147     AV_CODEC_ID_MSVIDEO1,
148     AV_CODEC_ID_IDCIN,
149     AV_CODEC_ID_8BPS,
150     AV_CODEC_ID_SMC,
151     AV_CODEC_ID_FLIC,
152     AV_CODEC_ID_TRUEMOTION1,
153     AV_CODEC_ID_VMDVIDEO,
154     AV_CODEC_ID_MSZH,
155     AV_CODEC_ID_ZLIB,
156     AV_CODEC_ID_QTRLE,
157     AV_CODEC_ID_SNOW,
158     AV_CODEC_ID_TSCC,
159     AV_CODEC_ID_ULTI,
160     AV_CODEC_ID_QDRAW,
161     AV_CODEC_ID_VIXL,
162     AV_CODEC_ID_QPEG,
163     AV_CODEC_ID_PNG,
164     AV_CODEC_ID_PPM,
165     AV_CODEC_ID_PBM,
166     AV_CODEC_ID_PGM,
167     AV_CODEC_ID_PGMYUV,
168     AV_CODEC_ID_PAM,
169     AV_CODEC_ID_FFVHUFF,
170     AV_CODEC_ID_RV30,
171     AV_CODEC_ID_RV40,
172     AV_CODEC_ID_VC1,
173     AV_CODEC_ID_WMV3,
174     AV_CODEC_ID_LOCO,
175     AV_CODEC_ID_WNV1,
176     AV_CODEC_ID_AASC,
177     AV_CODEC_ID_INDEO2,
178     AV_CODEC_ID_FRAPS,
179     AV_CODEC_ID_TRUEMOTION2,
180     AV_CODEC_ID_BMP,
181     AV_CODEC_ID_CSCD,
182     AV_CODEC_ID_MMVIDEO,
183     AV_CODEC_ID_ZMBV,
184     AV_CODEC_ID_AVS,
185     AV_CODEC_ID_SMACKVIDEO,
186     AV_CODEC_ID_NUV,
187     AV_CODEC_ID_KMVC,
188     AV_CODEC_ID_FLASHSV,
189     AV_CODEC_ID_CAVS,
190     AV_CODEC_ID_JPEG2000,
191     AV_CODEC_ID_VMNC,
192     AV_CODEC_ID_VP5,
193     AV_CODEC_ID_VP6,
194     AV_CODEC_ID_VP6F,
195     AV_CODEC_ID_TARGA,
196     AV_CODEC_ID_DSICINVIDEO,
197     AV_CODEC_ID_TIERTEXSEQVIDEO,
198     AV_CODEC_ID_TIFF,
199     AV_CODEC_ID_GIF,
200     AV_CODEC_ID_DXA,
201     AV_CODEC_ID_DNXHD,
202     AV_CODEC_ID_THP,
203     AV_CODEC_ID_SGI,
204     AV_CODEC_ID_C93,
205     AV_CODEC_ID_BETHSOFTVID,
206     AV_CODEC_ID_PTX,
207     AV_CODEC_ID_TXD,
208     AV_CODEC_ID_VP6A,
209     AV_CODEC_ID_AMV,
210     AV_CODEC_ID_VB,
211     AV_CODEC_ID_PCX,
212     AV_CODEC_ID_SUNRAST,
213     AV_CODEC_ID_INDEO4,
214     AV_CODEC_ID_INDEO5,
215     AV_CODEC_ID_MIMIC,
216     AV_CODEC_ID_RL2,
217     AV_CODEC_ID_ESCAPE124,
218     AV_CODEC_ID_DIRAC,
219     AV_CODEC_ID_BFI,
220     AV_CODEC_ID_CMV,
221     AV_CODEC_ID_MOTIONPIXELS,
222     AV_CODEC_ID_TGV,
223     AV_CODEC_ID_TGQ,
224     AV_CODEC_ID_TQI,
225     AV_CODEC_ID_AURA,
226     AV_CODEC_ID_AURA2,
227     AV_CODEC_ID_V210X,
228     AV_CODEC_ID_TMV,
229     AV_CODEC_ID_V210,
230     AV_CODEC_ID_DPX,
231     AV_CODEC_ID_MAD,
232     AV_CODEC_ID_FRWU,
233     AV_CODEC_ID_FLASHSV2,
234     AV_CODEC_ID_CDGRAPHICS,
235     AV_CODEC_ID_R210,
236     AV_CODEC_ID_ANM,
237     AV_CODEC_ID_BINKVIDEO,
238     AV_CODEC_ID_IFF_ILBM,
239     AV_CODEC_ID_IFF_BYTERUN1,
240     AV_CODEC_ID_KGV1,
241     AV_CODEC_ID_YOP,
242     AV_CODEC_ID_VP8,
243     AV_CODEC_ID_PICTOR,
244     AV_CODEC_ID_ANSI,
245     AV_CODEC_ID_A64_MULTI,
246     AV_CODEC_ID_A64_MULTI5,
247     AV_CODEC_ID_R10K,
248     AV_CODEC_ID_MXPEG,
249     AV_CODEC_ID_LAGARITH,
250     AV_CODEC_ID_PRORES,
251     AV_CODEC_ID_JV,
252     AV_CODEC_ID_DFA,
253     AV_CODEC_ID_WMV3IMAGE,
254     AV_CODEC_ID_VC1IMAGE,
255     AV_CODEC_ID_UTVIDEO,
256     AV_CODEC_ID_BMV_VIDEO,
257     AV_CODEC_ID_VBLE,
258     AV_CODEC_ID_DXTORY,
259     AV_CODEC_ID_V410,
260     AV_CODEC_ID_XWD,
261     AV_CODEC_ID_CDXL,
262     AV_CODEC_ID_XBM,
263     AV_CODEC_ID_ZEROCODEC,
264     AV_CODEC_ID_MSS1,
265     AV_CODEC_ID_MSA1,
266     AV_CODEC_ID_TSCC2,
267     AV_CODEC_ID_MTS2,
268     AV_CODEC_ID_CLLC,
269     AV_CODEC_ID_MSS2,
270     AV_CODEC_ID_BRENDER_PIX= MKBETAG('B','P','I','X'),
271     AV_CODEC_ID_Y41P       = MKBETAG('Y','4','1','P'),
272     AV_CODEC_ID_ESCAPE130  = MKBETAG('E','1','3','0'),
273     AV_CODEC_ID_EXR        = MKBETAG('0','E','X','R'),
274     AV_CODEC_ID_AVRP       = MKBETAG('A','V','R','P'),
275
276     AV_CODEC_ID_012V       = MKBETAG('0','1','2','V'),
277     AV_CODEC_ID_G2M        = MKBETAG( 0 ,'G','2','M'),
278     AV_CODEC_ID_AVUI       = MKBETAG('A','V','U','I'),
279     AV_CODEC_ID_AYUV       = MKBETAG('A','Y','U','V'),
280     AV_CODEC_ID_TARGA_Y216 = MKBETAG('T','2','1','6'),
281     AV_CODEC_ID_V308       = MKBETAG('V','3','0','8'),
282     AV_CODEC_ID_V408       = MKBETAG('V','4','0','8'),
283     AV_CODEC_ID_YUV4       = MKBETAG('Y','U','V','4'),
284     AV_CODEC_ID_SANM       = MKBETAG('S','A','N','M'),
285     AV_CODEC_ID_PAF_VIDEO  = MKBETAG('P','A','F','V'),
286     AV_CODEC_ID_AVRN       = MKBETAG('A','V','R','n'),
287     AV_CODEC_ID_CPIA       = MKBETAG('C','P','I','A'),
288     AV_CODEC_ID_XFACE      = MKBETAG('X','F','A','C'),
289     AV_CODEC_ID_SGIRLE     = MKBETAG('S','G','I','R'),
290     AV_CODEC_ID_MVC1       = MKBETAG('M','V','C','1'),
291     AV_CODEC_ID_MVC2       = MKBETAG('M','V','C','2'),
292
293     /* various PCM "codecs" */
294     AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
295     AV_CODEC_ID_PCM_S16LE = 0x10000,
296     AV_CODEC_ID_PCM_S16BE,
297     AV_CODEC_ID_PCM_U16LE,
298     AV_CODEC_ID_PCM_U16BE,
299     AV_CODEC_ID_PCM_S8,
300     AV_CODEC_ID_PCM_U8,
301     AV_CODEC_ID_PCM_MULAW,
302     AV_CODEC_ID_PCM_ALAW,
303     AV_CODEC_ID_PCM_S32LE,
304     AV_CODEC_ID_PCM_S32BE,
305     AV_CODEC_ID_PCM_U32LE,
306     AV_CODEC_ID_PCM_U32BE,
307     AV_CODEC_ID_PCM_S24LE,
308     AV_CODEC_ID_PCM_S24BE,
309     AV_CODEC_ID_PCM_U24LE,
310     AV_CODEC_ID_PCM_U24BE,
311     AV_CODEC_ID_PCM_S24DAUD,
312     AV_CODEC_ID_PCM_ZORK,
313     AV_CODEC_ID_PCM_S16LE_PLANAR,
314     AV_CODEC_ID_PCM_DVD,
315     AV_CODEC_ID_PCM_F32BE,
316     AV_CODEC_ID_PCM_F32LE,
317     AV_CODEC_ID_PCM_F64BE,
318     AV_CODEC_ID_PCM_F64LE,
319     AV_CODEC_ID_PCM_BLURAY,
320     AV_CODEC_ID_PCM_LXF,
321     AV_CODEC_ID_S302M,
322     AV_CODEC_ID_PCM_S8_PLANAR,
323     AV_CODEC_ID_PCM_S24LE_PLANAR = MKBETAG(24,'P','S','P'),
324     AV_CODEC_ID_PCM_S32LE_PLANAR = MKBETAG(32,'P','S','P'),
325     AV_CODEC_ID_PCM_S16BE_PLANAR = MKBETAG('P','S','P',16),
326
327     /* various ADPCM codecs */
328     AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
329     AV_CODEC_ID_ADPCM_IMA_WAV,
330     AV_CODEC_ID_ADPCM_IMA_DK3,
331     AV_CODEC_ID_ADPCM_IMA_DK4,
332     AV_CODEC_ID_ADPCM_IMA_WS,
333     AV_CODEC_ID_ADPCM_IMA_SMJPEG,
334     AV_CODEC_ID_ADPCM_MS,
335     AV_CODEC_ID_ADPCM_4XM,
336     AV_CODEC_ID_ADPCM_XA,
337     AV_CODEC_ID_ADPCM_ADX,
338     AV_CODEC_ID_ADPCM_EA,
339     AV_CODEC_ID_ADPCM_G726,
340     AV_CODEC_ID_ADPCM_CT,
341     AV_CODEC_ID_ADPCM_SWF,
342     AV_CODEC_ID_ADPCM_YAMAHA,
343     AV_CODEC_ID_ADPCM_SBPRO_4,
344     AV_CODEC_ID_ADPCM_SBPRO_3,
345     AV_CODEC_ID_ADPCM_SBPRO_2,
346     AV_CODEC_ID_ADPCM_THP,
347     AV_CODEC_ID_ADPCM_IMA_AMV,
348     AV_CODEC_ID_ADPCM_EA_R1,
349     AV_CODEC_ID_ADPCM_EA_R3,
350     AV_CODEC_ID_ADPCM_EA_R2,
351     AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
352     AV_CODEC_ID_ADPCM_IMA_EA_EACS,
353     AV_CODEC_ID_ADPCM_EA_XAS,
354     AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
355     AV_CODEC_ID_ADPCM_IMA_ISS,
356     AV_CODEC_ID_ADPCM_G722,
357     AV_CODEC_ID_ADPCM_IMA_APC,
358     AV_CODEC_ID_VIMA       = MKBETAG('V','I','M','A'),
359     AV_CODEC_ID_ADPCM_AFC  = MKBETAG('A','F','C',' '),
360     AV_CODEC_ID_ADPCM_IMA_OKI = MKBETAG('O','K','I',' '),
361
362     /* AMR */
363     AV_CODEC_ID_AMR_NB = 0x12000,
364     AV_CODEC_ID_AMR_WB,
365
366     /* RealAudio codecs*/
367     AV_CODEC_ID_RA_144 = 0x13000,
368     AV_CODEC_ID_RA_288,
369
370     /* various DPCM codecs */
371     AV_CODEC_ID_ROQ_DPCM = 0x14000,
372     AV_CODEC_ID_INTERPLAY_DPCM,
373     AV_CODEC_ID_XAN_DPCM,
374     AV_CODEC_ID_SOL_DPCM,
375
376     /* audio codecs */
377     AV_CODEC_ID_MP2 = 0x15000,
378     AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
379     AV_CODEC_ID_AAC,
380     AV_CODEC_ID_AC3,
381     AV_CODEC_ID_DTS,
382     AV_CODEC_ID_VORBIS,
383     AV_CODEC_ID_DVAUDIO,
384     AV_CODEC_ID_WMAV1,
385     AV_CODEC_ID_WMAV2,
386     AV_CODEC_ID_MACE3,
387     AV_CODEC_ID_MACE6,
388     AV_CODEC_ID_VMDAUDIO,
389     AV_CODEC_ID_FLAC,
390     AV_CODEC_ID_MP3ADU,
391     AV_CODEC_ID_MP3ON4,
392     AV_CODEC_ID_SHORTEN,
393     AV_CODEC_ID_ALAC,
394     AV_CODEC_ID_WESTWOOD_SND1,
395     AV_CODEC_ID_GSM, ///< as in Berlin toast format
396     AV_CODEC_ID_QDM2,
397     AV_CODEC_ID_COOK,
398     AV_CODEC_ID_TRUESPEECH,
399     AV_CODEC_ID_TTA,
400     AV_CODEC_ID_SMACKAUDIO,
401     AV_CODEC_ID_QCELP,
402     AV_CODEC_ID_WAVPACK,
403     AV_CODEC_ID_DSICINAUDIO,
404     AV_CODEC_ID_IMC,
405     AV_CODEC_ID_MUSEPACK7,
406     AV_CODEC_ID_MLP,
407     AV_CODEC_ID_GSM_MS, /* as found in WAV */
408     AV_CODEC_ID_ATRAC3,
409     AV_CODEC_ID_VOXWARE,
410     AV_CODEC_ID_APE,
411     AV_CODEC_ID_NELLYMOSER,
412     AV_CODEC_ID_MUSEPACK8,
413     AV_CODEC_ID_SPEEX,
414     AV_CODEC_ID_WMAVOICE,
415     AV_CODEC_ID_WMAPRO,
416     AV_CODEC_ID_WMALOSSLESS,
417     AV_CODEC_ID_ATRAC3P,
418     AV_CODEC_ID_EAC3,
419     AV_CODEC_ID_SIPR,
420     AV_CODEC_ID_MP1,
421     AV_CODEC_ID_TWINVQ,
422     AV_CODEC_ID_TRUEHD,
423     AV_CODEC_ID_MP4ALS,
424     AV_CODEC_ID_ATRAC1,
425     AV_CODEC_ID_BINKAUDIO_RDFT,
426     AV_CODEC_ID_BINKAUDIO_DCT,
427     AV_CODEC_ID_AAC_LATM,
428     AV_CODEC_ID_QDMC,
429     AV_CODEC_ID_CELT,
430     AV_CODEC_ID_G723_1,
431     AV_CODEC_ID_G729,
432     AV_CODEC_ID_8SVX_EXP,
433     AV_CODEC_ID_8SVX_FIB,
434     AV_CODEC_ID_BMV_AUDIO,
435     AV_CODEC_ID_RALF,
436     AV_CODEC_ID_IAC,
437     AV_CODEC_ID_ILBC,
438     AV_CODEC_ID_OPUS_DEPRECATED,
439     AV_CODEC_ID_COMFORT_NOISE,
440     AV_CODEC_ID_TAK_DEPRECATED,
441     AV_CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
442 #if LIBAVCODEC_VERSION_MAJOR <= 54
443     AV_CODEC_ID_8SVX_RAW    = MKBETAG('8','S','V','X'),
444 #endif
445     AV_CODEC_ID_SONIC       = MKBETAG('S','O','N','C'),
446     AV_CODEC_ID_SONIC_LS    = MKBETAG('S','O','N','L'),
447     AV_CODEC_ID_PAF_AUDIO   = MKBETAG('P','A','F','A'),
448     AV_CODEC_ID_OPUS        = MKBETAG('O','P','U','S'),
449     AV_CODEC_ID_TAK         = MKBETAG('t','B','a','K'),
450     AV_CODEC_ID_EVRC        = MKBETAG('s','e','v','c'),
451     AV_CODEC_ID_SMV         = MKBETAG('s','s','m','v'),
452
453     /* subtitle codecs */
454     AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
455     AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
456     AV_CODEC_ID_DVB_SUBTITLE,
457     AV_CODEC_ID_TEXT,  ///< raw UTF-8 text
458     AV_CODEC_ID_XSUB,
459     AV_CODEC_ID_SSA,
460     AV_CODEC_ID_MOV_TEXT,
461     AV_CODEC_ID_HDMV_PGS_SUBTITLE,
462     AV_CODEC_ID_DVB_TELETEXT,
463     AV_CODEC_ID_SRT,
464     AV_CODEC_ID_MICRODVD   = MKBETAG('m','D','V','D'),
465     AV_CODEC_ID_EIA_608    = MKBETAG('c','6','0','8'),
466     AV_CODEC_ID_JACOSUB    = MKBETAG('J','S','U','B'),
467     AV_CODEC_ID_SAMI       = MKBETAG('S','A','M','I'),
468     AV_CODEC_ID_REALTEXT   = MKBETAG('R','T','X','T'),
469     AV_CODEC_ID_SUBVIEWER1 = MKBETAG('S','b','V','1'),
470     AV_CODEC_ID_SUBVIEWER  = MKBETAG('S','u','b','V'),
471     AV_CODEC_ID_SUBRIP     = MKBETAG('S','R','i','p'),
472     AV_CODEC_ID_WEBVTT     = MKBETAG('W','V','T','T'),
473     AV_CODEC_ID_MPL2       = MKBETAG('M','P','L','2'),
474     AV_CODEC_ID_VPLAYER    = MKBETAG('V','P','l','r'),
475     AV_CODEC_ID_PJS        = MKBETAG('P','h','J','S'),
476
477     /* other specific kind of codecs (generally used for attachments) */
478     AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
479     AV_CODEC_ID_TTF = 0x18000,
480     AV_CODEC_ID_BINTEXT    = MKBETAG('B','T','X','T'),
481     AV_CODEC_ID_XBIN       = MKBETAG('X','B','I','N'),
482     AV_CODEC_ID_IDF        = MKBETAG( 0 ,'I','D','F'),
483     AV_CODEC_ID_OTF        = MKBETAG( 0 ,'O','T','F'),
484     AV_CODEC_ID_SMPTE_KLV  = MKBETAG('K','L','V','A'),
485
486     AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
487
488     AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
489                                 * stream (only used by libavformat) */
490     AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
491                                 * stream (only used by libavformat) */
492     AV_CODEC_ID_FFMETADATA = 0x21000,   ///< Dummy codec for streams containing only metadata information.
493
494 #if FF_API_CODEC_ID
495 #include "old_codec_ids.h"
496 #endif
497 };
498
499 #if FF_API_CODEC_ID
500 #define CodecID AVCodecID
501 #endif
502
503 /**
504  * This struct describes the properties of a single codec described by an
505  * AVCodecID.
506  * @see avcodec_get_descriptor()
507  */
508 typedef struct AVCodecDescriptor {
509     enum AVCodecID     id;
510     enum AVMediaType type;
511     /**
512      * Name of the codec described by this descriptor. It is non-empty and
513      * unique for each codec descriptor. It should contain alphanumeric
514      * characters and '_' only.
515      */
516     const char      *name;
517     /**
518      * A more descriptive name for this codec. May be NULL.
519      */
520     const char *long_name;
521     /**
522      * Codec properties, a combination of AV_CODEC_PROP_* flags.
523      */
524     int             props;
525 } AVCodecDescriptor;
526
527 /**
528  * Codec uses only intra compression.
529  * Video codecs only.
530  */
531 #define AV_CODEC_PROP_INTRA_ONLY    (1 << 0)
532 /**
533  * Codec supports lossy compression. Audio and video codecs only.
534  * @note a codec may support both lossy and lossless
535  * compression modes
536  */
537 #define AV_CODEC_PROP_LOSSY         (1 << 1)
538 /**
539  * Codec supports lossless compression. Audio and video codecs only.
540  */
541 #define AV_CODEC_PROP_LOSSLESS      (1 << 2)
542
543 #if FF_API_OLD_DECODE_AUDIO
544 /* in bytes */
545 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
546 #endif
547
548 /**
549  * @ingroup lavc_decoding
550  * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
551  * This is mainly needed because some optimized bitstream readers read
552  * 32 or 64 bit at once and could read over the end.<br>
553  * Note: If the first 23 bits of the additional bytes are not 0, then damaged
554  * MPEG bitstreams could cause overread and segfault.
555  */
556 #define FF_INPUT_BUFFER_PADDING_SIZE 16
557
558 /**
559  * @ingroup lavc_encoding
560  * minimum encoding buffer size
561  * Used to avoid some checks during header writing.
562  */
563 #define FF_MIN_BUFFER_SIZE 16384
564
565
566 /**
567  * @ingroup lavc_encoding
568  * motion estimation type.
569  */
570 enum Motion_Est_ID {
571     ME_ZERO = 1,    ///< no search, that is use 0,0 vector whenever one is needed
572     ME_FULL,
573     ME_LOG,
574     ME_PHODS,
575     ME_EPZS,        ///< enhanced predictive zonal search
576     ME_X1,          ///< reserved for experiments
577     ME_HEX,         ///< hexagon based search
578     ME_UMH,         ///< uneven multi-hexagon search
579     ME_ITER,        ///< iterative search
580     ME_TESA,        ///< transformed exhaustive search algorithm
581 };
582
583 /**
584  * @ingroup lavc_decoding
585  */
586 enum AVDiscard{
587     /* We leave some space between them for extensions (drop some
588      * keyframes for intra-only or drop just some bidir frames). */
589     AVDISCARD_NONE    =-16, ///< discard nothing
590     AVDISCARD_DEFAULT =  0, ///< discard useless packets like 0 size packets in avi
591     AVDISCARD_NONREF  =  8, ///< discard all non reference
592     AVDISCARD_BIDIR   = 16, ///< discard all bidirectional frames
593     AVDISCARD_NONKEY  = 32, ///< discard all frames except keyframes
594     AVDISCARD_ALL     = 48, ///< discard all
595 };
596
597 enum AVColorPrimaries{
598     AVCOL_PRI_BT709       = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
599     AVCOL_PRI_UNSPECIFIED = 2,
600     AVCOL_PRI_BT470M      = 4,
601     AVCOL_PRI_BT470BG     = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
602     AVCOL_PRI_SMPTE170M   = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
603     AVCOL_PRI_SMPTE240M   = 7, ///< functionally identical to above
604     AVCOL_PRI_FILM        = 8,
605     AVCOL_PRI_NB             , ///< Not part of ABI
606 };
607
608 enum AVColorTransferCharacteristic{
609     AVCOL_TRC_BT709       = 1, ///< also ITU-R BT1361
610     AVCOL_TRC_UNSPECIFIED = 2,
611     AVCOL_TRC_GAMMA22     = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
612     AVCOL_TRC_GAMMA28     = 5, ///< also ITU-R BT470BG
613     AVCOL_TRC_SMPTE240M   = 7,
614     AVCOL_TRC_NB             , ///< Not part of ABI
615 };
616
617 enum AVColorSpace{
618     AVCOL_SPC_RGB         = 0,
619     AVCOL_SPC_BT709       = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
620     AVCOL_SPC_UNSPECIFIED = 2,
621     AVCOL_SPC_FCC         = 4,
622     AVCOL_SPC_BT470BG     = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
623     AVCOL_SPC_SMPTE170M   = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
624     AVCOL_SPC_SMPTE240M   = 7,
625     AVCOL_SPC_YCOCG       = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
626     AVCOL_SPC_NB             , ///< Not part of ABI
627 };
628 #define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
629
630 enum AVColorRange{
631     AVCOL_RANGE_UNSPECIFIED = 0,
632     AVCOL_RANGE_MPEG        = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
633     AVCOL_RANGE_JPEG        = 2, ///< the normal     2^n-1   "JPEG" YUV ranges
634     AVCOL_RANGE_NB             , ///< Not part of ABI
635 };
636
637 /**
638  *  X   X      3 4 X      X are luma samples,
639  *             1 2        1-6 are possible chroma positions
640  *  X   X      5 6 X      0 is undefined/unknown position
641  */
642 enum AVChromaLocation{
643     AVCHROMA_LOC_UNSPECIFIED = 0,
644     AVCHROMA_LOC_LEFT        = 1, ///< mpeg2/4, h264 default
645     AVCHROMA_LOC_CENTER      = 2, ///< mpeg1, jpeg, h263
646     AVCHROMA_LOC_TOPLEFT     = 3, ///< DV
647     AVCHROMA_LOC_TOP         = 4,
648     AVCHROMA_LOC_BOTTOMLEFT  = 5,
649     AVCHROMA_LOC_BOTTOM      = 6,
650     AVCHROMA_LOC_NB             , ///< Not part of ABI
651 };
652
653 enum AVAudioServiceType {
654     AV_AUDIO_SERVICE_TYPE_MAIN              = 0,
655     AV_AUDIO_SERVICE_TYPE_EFFECTS           = 1,
656     AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
657     AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED  = 3,
658     AV_AUDIO_SERVICE_TYPE_DIALOGUE          = 4,
659     AV_AUDIO_SERVICE_TYPE_COMMENTARY        = 5,
660     AV_AUDIO_SERVICE_TYPE_EMERGENCY         = 6,
661     AV_AUDIO_SERVICE_TYPE_VOICE_OVER        = 7,
662     AV_AUDIO_SERVICE_TYPE_KARAOKE           = 8,
663     AV_AUDIO_SERVICE_TYPE_NB                   , ///< Not part of ABI
664 };
665
666 /**
667  * @ingroup lavc_encoding
668  */
669 typedef struct RcOverride{
670     int start_frame;
671     int end_frame;
672     int qscale; // If this is 0 then quality_factor will be used instead.
673     float quality_factor;
674 } RcOverride;
675
676 #define FF_MAX_B_FRAMES 16
677
678 /* encoding support
679    These flags can be passed in AVCodecContext.flags before initialization.
680    Note: Not everything is supported yet.
681 */
682
683 #define CODEC_FLAG_QSCALE 0x0002  ///< Use fixed qscale.
684 #define CODEC_FLAG_4MV    0x0004  ///< 4 MV per MB allowed / advanced prediction for H.263.
685 #define CODEC_FLAG_QPEL   0x0010  ///< Use qpel MC.
686 #define CODEC_FLAG_GMC    0x0020  ///< Use GMC.
687 #define CODEC_FLAG_MV0    0x0040  ///< Always try a MB with MV=<0,0>.
688 /**
689  * The parent program guarantees that the input for B-frames containing
690  * streams is not written to for at least s->max_b_frames+1 frames, if
691  * this is not set the input will be copied.
692  */
693 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
694 #define CODEC_FLAG_PASS1           0x0200   ///< Use internal 2pass ratecontrol in first pass mode.
695 #define CODEC_FLAG_PASS2           0x0400   ///< Use internal 2pass ratecontrol in second pass mode.
696 #define CODEC_FLAG_GRAY            0x2000   ///< Only decode/encode grayscale.
697 #define CODEC_FLAG_EMU_EDGE        0x4000   ///< Don't draw edges.
698 #define CODEC_FLAG_PSNR            0x8000   ///< error[?] variables will be set during encoding.
699 #define CODEC_FLAG_TRUNCATED       0x00010000 /** Input bitstream might be truncated at a random
700                                                   location instead of only at frame boundaries. */
701 #define CODEC_FLAG_NORMALIZE_AQP  0x00020000 ///< Normalize adaptive quantization.
702 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
703 #define CODEC_FLAG_LOW_DELAY      0x00080000 ///< Force low delay.
704 #define CODEC_FLAG_GLOBAL_HEADER  0x00400000 ///< Place global headers in extradata instead of every keyframe.
705 #define CODEC_FLAG_BITEXACT       0x00800000 ///< Use only bitexact stuff (except (I)DCT).
706 /* Fx : Flag for h263+ extra options */
707 #define CODEC_FLAG_AC_PRED        0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
708 #define CODEC_FLAG_LOOP_FILTER    0x00000800 ///< loop filter
709 #define CODEC_FLAG_INTERLACED_ME  0x20000000 ///< interlaced motion estimation
710 #define CODEC_FLAG_CLOSED_GOP     0x80000000
711 #define CODEC_FLAG2_FAST          0x00000001 ///< Allow non spec compliant speedup tricks.
712 #define CODEC_FLAG2_NO_OUTPUT     0x00000004 ///< Skip bitstream encoding.
713 #define CODEC_FLAG2_LOCAL_HEADER  0x00000008 ///< Place global headers at every keyframe instead of in extradata.
714 #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. DEPRECATED!!!!
715 #if FF_API_MPV_GLOBAL_OPTS
716 #define CODEC_FLAG_CBP_RD         0x04000000 ///< Use rate distortion optimization for cbp.
717 #define CODEC_FLAG_QP_RD          0x08000000 ///< Use rate distortion optimization for qp selectioon.
718 #define CODEC_FLAG2_STRICT_GOP    0x00000002 ///< Strictly enforce GOP size.
719 #define CODEC_FLAG2_SKIP_RD       0x00004000 ///< RD optimal MB level residual skipping
720 #endif
721 #define CODEC_FLAG2_CHUNKS        0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
722 #define CODEC_FLAG2_SHOW_ALL      0x00400000 ///< Show all frames before the first keyframe
723
724 /* Unsupported options :
725  *              Syntax Arithmetic coding (SAC)
726  *              Reference Picture Selection
727  *              Independent Segment Decoding */
728 /* /Fx */
729 /* codec capabilities */
730
731 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
732 /**
733  * Codec uses get_buffer() for allocating buffers and supports custom allocators.
734  * If not set, it might not use get_buffer() at all or use operations that
735  * assume the buffer was allocated by avcodec_default_get_buffer.
736  */
737 #define CODEC_CAP_DR1             0x0002
738 #define CODEC_CAP_TRUNCATED       0x0008
739 /* Codec can export data for HW decoding (XvMC). */
740 #define CODEC_CAP_HWACCEL         0x0010
741 /**
742  * Encoder or decoder requires flushing with NULL input at the end in order to
743  * give the complete and correct output.
744  *
745  * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
746  *       with NULL data. The user can still send NULL data to the public encode
747  *       or decode function, but libavcodec will not pass it along to the codec
748  *       unless this flag is set.
749  *
750  * Decoders:
751  * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
752  * avpkt->size=0 at the end to get the delayed data until the decoder no longer
753  * returns frames.
754  *
755  * Encoders:
756  * The encoder needs to be fed with NULL data at the end of encoding until the
757  * encoder no longer returns data.
758  *
759  * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
760  *       flag also means that the encoder must set the pts and duration for
761  *       each output packet. If this flag is not set, the pts and duration will
762  *       be determined by libavcodec from the input frame.
763  */
764 #define CODEC_CAP_DELAY           0x0020
765 /**
766  * Codec can be fed a final frame with a smaller size.
767  * This can be used to prevent truncation of the last audio samples.
768  */
769 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
770 /**
771  * Codec can export data for HW decoding (VDPAU).
772  */
773 #define CODEC_CAP_HWACCEL_VDPAU    0x0080
774 /**
775  * Codec can output multiple frames per AVPacket
776  * Normally demuxers return one frame at a time, demuxers which do not do
777  * are connected to a parser to split what they return into proper frames.
778  * This flag is reserved to the very rare category of codecs which have a
779  * bitstream that cannot be split into frames without timeconsuming
780  * operations like full decoding. Demuxers carring such bitstreams thus
781  * may return multiple frames in a packet. This has many disadvantages like
782  * prohibiting stream copy in many cases thus it should only be considered
783  * as a last resort.
784  */
785 #define CODEC_CAP_SUBFRAMES        0x0100
786 /**
787  * Codec is experimental and is thus avoided in favor of non experimental
788  * encoders
789  */
790 #define CODEC_CAP_EXPERIMENTAL     0x0200
791 /**
792  * Codec should fill in channel configuration and samplerate instead of container
793  */
794 #define CODEC_CAP_CHANNEL_CONF     0x0400
795
796 /**
797  * Codec is able to deal with negative linesizes
798  */
799 #define CODEC_CAP_NEG_LINESIZES    0x0800
800
801 /**
802  * Codec supports frame-level multithreading.
803  */
804 #define CODEC_CAP_FRAME_THREADS    0x1000
805 /**
806  * Codec supports slice-based (or partition-based) multithreading.
807  */
808 #define CODEC_CAP_SLICE_THREADS    0x2000
809 /**
810  * Codec supports changed parameters at any point.
811  */
812 #define CODEC_CAP_PARAM_CHANGE     0x4000
813 /**
814  * Codec supports avctx->thread_count == 0 (auto).
815  */
816 #define CODEC_CAP_AUTO_THREADS     0x8000
817 /**
818  * Audio encoder supports receiving a different number of samples in each call.
819  */
820 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
821 /**
822  * Codec is intra only.
823  */
824 #define CODEC_CAP_INTRA_ONLY       0x40000000
825 /**
826  * Codec is lossless.
827  */
828 #define CODEC_CAP_LOSSLESS         0x80000000
829
830 //The following defines may change, don't expect compatibility if you use them.
831 #define MB_TYPE_INTRA4x4   0x0001
832 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
833 #define MB_TYPE_INTRA_PCM  0x0004 //FIXME H.264-specific
834 #define MB_TYPE_16x16      0x0008
835 #define MB_TYPE_16x8       0x0010
836 #define MB_TYPE_8x16       0x0020
837 #define MB_TYPE_8x8        0x0040
838 #define MB_TYPE_INTERLACED 0x0080
839 #define MB_TYPE_DIRECT2    0x0100 //FIXME
840 #define MB_TYPE_ACPRED     0x0200
841 #define MB_TYPE_GMC        0x0400
842 #define MB_TYPE_SKIP       0x0800
843 #define MB_TYPE_P0L0       0x1000
844 #define MB_TYPE_P1L0       0x2000
845 #define MB_TYPE_P0L1       0x4000
846 #define MB_TYPE_P1L1       0x8000
847 #define MB_TYPE_L0         (MB_TYPE_P0L0 | MB_TYPE_P1L0)
848 #define MB_TYPE_L1         (MB_TYPE_P0L1 | MB_TYPE_P1L1)
849 #define MB_TYPE_L0L1       (MB_TYPE_L0   | MB_TYPE_L1)
850 #define MB_TYPE_QUANT      0x00010000
851 #define MB_TYPE_CBP        0x00020000
852 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
853
854 /**
855  * Pan Scan area.
856  * This specifies the area which should be displayed.
857  * Note there may be multiple such areas for one frame.
858  */
859 typedef struct AVPanScan{
860     /**
861      * id
862      * - encoding: Set by user.
863      * - decoding: Set by libavcodec.
864      */
865     int id;
866
867     /**
868      * width and height in 1/16 pel
869      * - encoding: Set by user.
870      * - decoding: Set by libavcodec.
871      */
872     int width;
873     int height;
874
875     /**
876      * position of the top left corner in 1/16 pel for up to 3 fields/frames
877      * - encoding: Set by user.
878      * - decoding: Set by libavcodec.
879      */
880     int16_t position[3][2];
881 }AVPanScan;
882
883 #define FF_QSCALE_TYPE_MPEG1 0
884 #define FF_QSCALE_TYPE_MPEG2 1
885 #define FF_QSCALE_TYPE_H264  2
886 #define FF_QSCALE_TYPE_VP56  3
887
888 #define FF_BUFFER_TYPE_INTERNAL 1
889 #define FF_BUFFER_TYPE_USER     2 ///< direct rendering buffers (image is (de)allocated by user)
890 #define FF_BUFFER_TYPE_SHARED   4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
891 #define FF_BUFFER_TYPE_COPY     8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
892
893 #define FF_BUFFER_HINTS_VALID    0x01 // Buffer hints value is meaningful (if 0 ignore).
894 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
895 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
896 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
897
898 /**
899  * @defgroup lavc_packet AVPacket
900  *
901  * Types and functions for working with AVPacket.
902  * @{
903  */
904 enum AVPacketSideDataType {
905     AV_PKT_DATA_PALETTE,
906     AV_PKT_DATA_NEW_EXTRADATA,
907
908     /**
909      * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
910      * @code
911      * u32le param_flags
912      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
913      *     s32le channel_count
914      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
915      *     u64le channel_layout
916      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
917      *     s32le sample_rate
918      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
919      *     s32le width
920      *     s32le height
921      * @endcode
922      */
923     AV_PKT_DATA_PARAM_CHANGE,
924
925     /**
926      * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
927      * structures with info about macroblocks relevant to splitting the
928      * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
929      * That is, it does not necessarily contain info about all macroblocks,
930      * as long as the distance between macroblocks in the info is smaller
931      * than the target payload size.
932      * Each MB info structure is 12 bytes, and is laid out as follows:
933      * @code
934      * u32le bit offset from the start of the packet
935      * u8    current quantizer at the start of the macroblock
936      * u8    GOB number
937      * u16le macroblock address within the GOB
938      * u8    horizontal MV predictor
939      * u8    vertical MV predictor
940      * u8    horizontal MV predictor for block number 3
941      * u8    vertical MV predictor for block number 3
942      * @endcode
943      */
944     AV_PKT_DATA_H263_MB_INFO,
945
946     /**
947      * Recommmends skipping the specified number of samples
948      * @code
949      * u32le number of samples to skip from start of this packet
950      * u32le number of samples to skip from end of this packet
951      * u8    reason for start skip
952      * u8    reason for end   skip (0=padding silence, 1=convergence)
953      * @endcode
954      */
955     AV_PKT_DATA_SKIP_SAMPLES=70,
956
957     /**
958      * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
959      * the packet may contain "dual mono" audio specific to Japanese DTV
960      * and if it is true, recommends only the selected channel to be used.
961      * @code
962      * u8    selected channels (0=mail/left, 1=sub/right, 2=both)
963      * @endcode
964      */
965     AV_PKT_DATA_JP_DUALMONO,
966
967     /**
968      * A list of zero terminated key/value strings. There is no end marker for
969      * the list, so it is required to rely on the side data size to stop.
970      */
971     AV_PKT_DATA_STRINGS_METADATA,
972
973     /**
974      * Subtitle event position
975      * @code
976      * u32le x1
977      * u32le y1
978      * u32le x2
979      * u32le y2
980      * @endcode
981      */
982     AV_PKT_DATA_SUBTITLE_POSITION,
983 };
984
985 /**
986  * This structure stores compressed data. It is typically exported by demuxers
987  * and then passed as input to decoders, or received as output from encoders and
988  * then passed to muxers.
989  *
990  * For video, it should typically contain one compressed frame. For audio it may
991  * contain several compressed frames.
992  *
993  * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
994  * ABI. Thus it may be allocated on stack and no new fields can be added to it
995  * without libavcodec and libavformat major bump.
996  *
997  * The semantics of data ownership depends on the destruct field.
998  * If it is set, the packet data is dynamically allocated and is valid
999  * indefinitely until av_free_packet() is called (which in turn calls the
1000  * destruct callback to free the data). If destruct is not set, the packet data
1001  * is typically backed by some static buffer somewhere and is only valid for a
1002  * limited time (e.g. until the next read call when demuxing).
1003  *
1004  * The side data is always allocated with av_malloc() and is freed in
1005  * av_free_packet().
1006  */
1007 typedef struct AVPacket {
1008     /**
1009      * Presentation timestamp in AVStream->time_base units; the time at which
1010      * the decompressed packet will be presented to the user.
1011      * Can be AV_NOPTS_VALUE if it is not stored in the file.
1012      * pts MUST be larger or equal to dts as presentation cannot happen before
1013      * decompression, unless one wants to view hex dumps. Some formats misuse
1014      * the terms dts and pts/cts to mean something different. Such timestamps
1015      * must be converted to true pts/dts before they are stored in AVPacket.
1016      */
1017     int64_t pts;
1018     /**
1019      * Decompression timestamp in AVStream->time_base units; the time at which
1020      * the packet is decompressed.
1021      * Can be AV_NOPTS_VALUE if it is not stored in the file.
1022      */
1023     int64_t dts;
1024     uint8_t *data;
1025     int   size;
1026     int   stream_index;
1027     /**
1028      * A combination of AV_PKT_FLAG values
1029      */
1030     int   flags;
1031     /**
1032      * Additional packet data that can be provided by the container.
1033      * Packet can contain several types of side information.
1034      */
1035     struct {
1036         uint8_t *data;
1037         int      size;
1038         enum AVPacketSideDataType type;
1039     } *side_data;
1040     int side_data_elems;
1041
1042     /**
1043      * Duration of this packet in AVStream->time_base units, 0 if unknown.
1044      * Equals next_pts - this_pts in presentation order.
1045      */
1046     int   duration;
1047     void  (*destruct)(struct AVPacket *);
1048     void  *priv;
1049     int64_t pos;                            ///< byte position in stream, -1 if unknown
1050
1051     /**
1052      * Time difference in AVStream->time_base units from the pts of this
1053      * packet to the point at which the output from the decoder has converged
1054      * independent from the availability of previous frames. That is, the
1055      * frames are virtually identical no matter if decoding started from
1056      * the very first frame or from this keyframe.
1057      * Is AV_NOPTS_VALUE if unknown.
1058      * This field is not the display duration of the current packet.
1059      * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
1060      * set.
1061      *
1062      * The purpose of this field is to allow seeking in streams that have no
1063      * keyframes in the conventional sense. It corresponds to the
1064      * recovery point SEI in H.264 and match_time_delta in NUT. It is also
1065      * essential for some types of subtitle streams to ensure that all
1066      * subtitles are correctly displayed after seeking.
1067      */
1068     int64_t convergence_duration;
1069 } AVPacket;
1070 #define AV_PKT_FLAG_KEY     0x0001 ///< The packet contains a keyframe
1071 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
1072
1073 enum AVSideDataParamChangeFlags {
1074     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
1075     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
1076     AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE    = 0x0004,
1077     AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS     = 0x0008,
1078 };
1079 /**
1080  * @}
1081  */
1082
1083 /**
1084  * This structure describes decoded (raw) audio or video data.
1085  *
1086  * AVFrame must be allocated using avcodec_alloc_frame() and freed with
1087  * avcodec_free_frame(). Note that this allocates only the AVFrame itself. The
1088  * buffers for the data must be managed through other means.
1089  *
1090  * AVFrame is typically allocated once and then reused multiple times to hold
1091  * different data (e.g. a single AVFrame to hold frames received from a
1092  * decoder). In such a case, avcodec_get_frame_defaults() should be used to
1093  * reset the frame to its original clean state before it is reused again.
1094  *
1095  * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
1096  * to the end with a minor bump.
1097  * Similarly fields that are marked as to be only accessed by
1098  * av_opt_ptr() can be reordered. This allows 2 forks to add fields
1099  * without breaking compatibility with each other.
1100  */
1101 typedef struct AVFrame {
1102 #define AV_NUM_DATA_POINTERS 8
1103     /**
1104      * pointer to the picture/channel planes.
1105      * This might be different from the first allocated byte
1106      * - encoding: Set by user
1107      * - decoding: set by AVCodecContext.get_buffer()
1108      */
1109     uint8_t *data[AV_NUM_DATA_POINTERS];
1110
1111     /**
1112      * Size, in bytes, of the data for each picture/channel plane.
1113      *
1114      * For audio, only linesize[0] may be set. For planar audio, each channel
1115      * plane must be the same size.
1116      *
1117      * - encoding: Set by user
1118      * - decoding: set by AVCodecContext.get_buffer()
1119      */
1120     int linesize[AV_NUM_DATA_POINTERS];
1121
1122     /**
1123      * pointers to the data planes/channels.
1124      *
1125      * For video, this should simply point to data[].
1126      *
1127      * For planar audio, each channel has a separate data pointer, and
1128      * linesize[0] contains the size of each channel buffer.
1129      * For packed audio, there is just one data pointer, and linesize[0]
1130      * contains the total size of the buffer for all channels.
1131      *
1132      * Note: Both data and extended_data will always be set by get_buffer(),
1133      * but for planar audio with more channels that can fit in data,
1134      * extended_data must be used by the decoder in order to access all
1135      * channels.
1136      *
1137      * encoding: set by user
1138      * decoding: set by AVCodecContext.get_buffer()
1139      */
1140     uint8_t **extended_data;
1141
1142     /**
1143      * width and height of the video frame
1144      * - encoding: unused
1145      * - decoding: Read by user.
1146      */
1147     int width, height;
1148
1149     /**
1150      * number of audio samples (per channel) described by this frame
1151      * - encoding: Set by user
1152      * - decoding: Set by libavcodec
1153      */
1154     int nb_samples;
1155
1156     /**
1157      * format of the frame, -1 if unknown or unset
1158      * Values correspond to enum AVPixelFormat for video frames,
1159      * enum AVSampleFormat for audio)
1160      * - encoding: unused
1161      * - decoding: Read by user.
1162      */
1163     int format;
1164
1165     /**
1166      * 1 -> keyframe, 0-> not
1167      * - encoding: Set by libavcodec.
1168      * - decoding: Set by libavcodec.
1169      */
1170     int key_frame;
1171
1172     /**
1173      * Picture type of the frame, see ?_TYPE below.
1174      * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1175      * - decoding: Set by libavcodec.
1176      */
1177     enum AVPictureType pict_type;
1178
1179     /**
1180      * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.
1181      * This isn't used by libavcodec unless the default get/release_buffer() is used.
1182      * - encoding:
1183      * - decoding:
1184      */
1185     uint8_t *base[AV_NUM_DATA_POINTERS];
1186
1187     /**
1188      * sample aspect ratio for the video frame, 0/1 if unknown/unspecified
1189      * - encoding: unused
1190      * - decoding: Read by user.
1191      */
1192     AVRational sample_aspect_ratio;
1193
1194     /**
1195      * presentation timestamp in time_base units (time when frame should be shown to user)
1196      * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.
1197      * - encoding: MUST be set by user.
1198      * - decoding: Set by libavcodec.
1199      */
1200     int64_t pts;
1201
1202     /**
1203      * pts copied from the AVPacket that was decoded to produce this frame
1204      * - encoding: unused
1205      * - decoding: Read by user.
1206      */
1207     int64_t pkt_pts;
1208
1209     /**
1210      * dts copied from the AVPacket that triggered returning this frame
1211      * - encoding: unused
1212      * - decoding: Read by user.
1213      */
1214     int64_t pkt_dts;
1215
1216     /**
1217      * picture number in bitstream order
1218      * - encoding: set by
1219      * - decoding: Set by libavcodec.
1220      */
1221     int coded_picture_number;
1222     /**
1223      * picture number in display order
1224      * - encoding: set by
1225      * - decoding: Set by libavcodec.
1226      */
1227     int display_picture_number;
1228
1229     /**
1230      * quality (between 1 (good) and FF_LAMBDA_MAX (bad))
1231      * - encoding: Set by libavcodec. for coded_picture (and set by user for input).
1232      * - decoding: Set by libavcodec.
1233      */
1234     int quality;
1235
1236     /**
1237      * is this picture used as reference
1238      * The values for this are the same as the MpegEncContext.picture_structure
1239      * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
1240      * Set to 4 for delayed, non-reference frames.
1241      * - encoding: unused
1242      * - decoding: Set by libavcodec. (before get_buffer() call)).
1243      */
1244     int reference;
1245
1246     /**
1247      * QP table
1248      * - encoding: unused
1249      * - decoding: Set by libavcodec.
1250      */
1251     int8_t *qscale_table;
1252     /**
1253      * QP store stride
1254      * - encoding: unused
1255      * - decoding: Set by libavcodec.
1256      */
1257     int qstride;
1258
1259     /**
1260      *
1261      */
1262     int qscale_type;
1263
1264     /**
1265      * mbskip_table[mb]>=1 if MB didn't change
1266      * stride= mb_width = (width+15)>>4
1267      * - encoding: unused
1268      * - decoding: Set by libavcodec.
1269      */
1270     uint8_t *mbskip_table;
1271
1272     /**
1273      * motion vector table
1274      * @code
1275      * example:
1276      * int mv_sample_log2= 4 - motion_subsample_log2;
1277      * int mb_width= (width+15)>>4;
1278      * int mv_stride= (mb_width << mv_sample_log2) + 1;
1279      * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];
1280      * @endcode
1281      * - encoding: Set by user.
1282      * - decoding: Set by libavcodec.
1283      */
1284     int16_t (*motion_val[2])[2];
1285
1286     /**
1287      * macroblock type table
1288      * mb_type_base + mb_width + 2
1289      * - encoding: Set by user.
1290      * - decoding: Set by libavcodec.
1291      */
1292     uint32_t *mb_type;
1293
1294     /**
1295      * DCT coefficients
1296      * - encoding: unused
1297      * - decoding: Set by libavcodec.
1298      */
1299     short *dct_coeff;
1300
1301     /**
1302      * motion reference frame index
1303      * the order in which these are stored can depend on the codec.
1304      * - encoding: Set by user.
1305      * - decoding: Set by libavcodec.
1306      */
1307     int8_t *ref_index[2];
1308
1309     /**
1310      * for some private data of the user
1311      * - encoding: unused
1312      * - decoding: Set by user.
1313      */
1314     void *opaque;
1315
1316     /**
1317      * error
1318      * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.
1319      * - decoding: unused
1320      */
1321     uint64_t error[AV_NUM_DATA_POINTERS];
1322
1323     /**
1324      * type of the buffer (to keep track of who has to deallocate data[*])
1325      * - encoding: Set by the one who allocates it.
1326      * - decoding: Set by the one who allocates it.
1327      * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.
1328      */
1329     int type;
1330
1331     /**
1332      * When decoding, this signals how much the picture must be delayed.
1333      * extra_delay = repeat_pict / (2*fps)
1334      * - encoding: unused
1335      * - decoding: Set by libavcodec.
1336      */
1337     int repeat_pict;
1338
1339     /**
1340      * The content of the picture is interlaced.
1341      * - encoding: Set by user.
1342      * - decoding: Set by libavcodec. (default 0)
1343      */
1344     int interlaced_frame;
1345
1346     /**
1347      * If the content is interlaced, is top field displayed first.
1348      * - encoding: Set by user.
1349      * - decoding: Set by libavcodec.
1350      */
1351     int top_field_first;
1352
1353     /**
1354      * Tell user application that palette has changed from previous frame.
1355      * - encoding: ??? (no palette-enabled encoder yet)
1356      * - decoding: Set by libavcodec. (default 0).
1357      */
1358     int palette_has_changed;
1359
1360     /**
1361      * codec suggestion on buffer type if != 0
1362      * - encoding: unused
1363      * - decoding: Set by libavcodec. (before get_buffer() call)).
1364      */
1365     int buffer_hints;
1366
1367     /**
1368      * Pan scan.
1369      * - encoding: Set by user.
1370      * - decoding: Set by libavcodec.
1371      */
1372     AVPanScan *pan_scan;
1373
1374     /**
1375      * reordered opaque 64bit (generally an integer or a double precision float
1376      * PTS but can be anything).
1377      * The user sets AVCodecContext.reordered_opaque to represent the input at
1378      * that time,
1379      * the decoder reorders values as needed and sets AVFrame.reordered_opaque
1380      * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
1381      * @deprecated in favor of pkt_pts
1382      * - encoding: unused
1383      * - decoding: Read by user.
1384      */
1385     int64_t reordered_opaque;
1386
1387     /**
1388      * hardware accelerator private data (FFmpeg-allocated)
1389      * - encoding: unused
1390      * - decoding: Set by libavcodec
1391      */
1392     void *hwaccel_picture_private;
1393
1394     /**
1395      * the AVCodecContext which ff_thread_get_buffer() was last called on
1396      * - encoding: Set by libavcodec.
1397      * - decoding: Set by libavcodec.
1398      */
1399     struct AVCodecContext *owner;
1400
1401     /**
1402      * used by multithreading to store frame-specific info
1403      * - encoding: Set by libavcodec.
1404      * - decoding: Set by libavcodec.
1405      */
1406     void *thread_opaque;
1407
1408     /**
1409      * log2 of the size of the block which a single vector in motion_val represents:
1410      * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)
1411      * - encoding: unused
1412      * - decoding: Set by libavcodec.
1413      */
1414     uint8_t motion_subsample_log2;
1415
1416     /**
1417      * Sample rate of the audio data.
1418      *
1419      * - encoding: unused
1420      * - decoding: read by user
1421      */
1422     int sample_rate;
1423
1424     /**
1425      * Channel layout of the audio data.
1426      *
1427      * - encoding: unused
1428      * - decoding: read by user.
1429      */
1430     uint64_t channel_layout;
1431
1432     /**
1433      * frame timestamp estimated using various heuristics, in stream time base
1434      * Code outside libavcodec should access this field using:
1435      * av_frame_get_best_effort_timestamp(frame)
1436      * - encoding: unused
1437      * - decoding: set by libavcodec, read by user.
1438      */
1439     int64_t best_effort_timestamp;
1440
1441     /**
1442      * reordered pos from the last AVPacket that has been input into the decoder
1443      * Code outside libavcodec should access this field using:
1444      * av_frame_get_pkt_pos(frame)
1445      * - encoding: unused
1446      * - decoding: Read by user.
1447      */
1448     int64_t pkt_pos;
1449
1450     /**
1451      * duration of the corresponding packet, expressed in
1452      * AVStream->time_base units, 0 if unknown.
1453      * Code outside libavcodec should access this field using:
1454      * av_frame_get_pkt_duration(frame)
1455      * - encoding: unused
1456      * - decoding: Read by user.
1457      */
1458     int64_t pkt_duration;
1459
1460     /**
1461      * metadata.
1462      * Code outside libavcodec should access this field using:
1463      * av_frame_get_metadata(frame)
1464      * - encoding: Set by user.
1465      * - decoding: Set by libavcodec.
1466      */
1467     AVDictionary *metadata;
1468
1469     /**
1470      * decode error flags of the frame, set to a combination of
1471      * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
1472      * were errors during the decoding.
1473      * Code outside libavcodec should access this field using:
1474      * av_frame_get_decode_error_flags(frame)
1475      * - encoding: unused
1476      * - decoding: set by libavcodec, read by user.
1477      */
1478     int decode_error_flags;
1479 #define FF_DECODE_ERROR_INVALID_BITSTREAM   1
1480 #define FF_DECODE_ERROR_MISSING_REFERENCE   2
1481
1482     /**
1483      * number of audio channels, only used for audio.
1484      * Code outside libavcodec should access this field using:
1485      * av_frame_get_channels(frame)
1486      * - encoding: unused
1487      * - decoding: Read by user.
1488      */
1489     int64_t channels;
1490
1491     /**
1492      * size of the corresponding packet containing the compressed
1493      * frame. It must be accessed using av_frame_get_pkt_size() and
1494      * av_frame_set_pkt_size().
1495      * It is set to a negative value if unknown.
1496      * - encoding: unused
1497      * - decoding: set by libavcodec, read by user.
1498      */
1499     int pkt_size;
1500 } AVFrame;
1501
1502 /**
1503  * Accessors for some AVFrame fields.
1504  * The position of these field in the structure is not part of the ABI,
1505  * they should not be accessed directly outside libavcodec.
1506  */
1507 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
1508 void    av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
1509 int64_t av_frame_get_pkt_duration         (const AVFrame *frame);
1510 void    av_frame_set_pkt_duration         (AVFrame *frame, int64_t val);
1511 int64_t av_frame_get_pkt_pos              (const AVFrame *frame);
1512 void    av_frame_set_pkt_pos              (AVFrame *frame, int64_t val);
1513 int64_t av_frame_get_channel_layout       (const AVFrame *frame);
1514 void    av_frame_set_channel_layout       (AVFrame *frame, int64_t val);
1515 int     av_frame_get_channels             (const AVFrame *frame);
1516 void    av_frame_set_channels             (AVFrame *frame, int     val);
1517 int     av_frame_get_sample_rate          (const AVFrame *frame);
1518 void    av_frame_set_sample_rate          (AVFrame *frame, int     val);
1519 AVDictionary *av_frame_get_metadata       (const AVFrame *frame);
1520 void          av_frame_set_metadata       (AVFrame *frame, AVDictionary *val);
1521 int     av_frame_get_decode_error_flags   (const AVFrame *frame);
1522 void    av_frame_set_decode_error_flags   (AVFrame *frame, int     val);
1523 int     av_frame_get_pkt_size(const AVFrame *frame);
1524 void    av_frame_set_pkt_size(AVFrame *frame, int val);
1525
1526 struct AVCodecInternal;
1527
1528 enum AVFieldOrder {
1529     AV_FIELD_UNKNOWN,
1530     AV_FIELD_PROGRESSIVE,
1531     AV_FIELD_TT,          //< Top coded_first, top displayed first
1532     AV_FIELD_BB,          //< Bottom coded first, bottom displayed first
1533     AV_FIELD_TB,          //< Top coded first, bottom displayed first
1534     AV_FIELD_BT,          //< Bottom coded first, top displayed first
1535 };
1536
1537 /**
1538  * main external API structure.
1539  * New fields can be added to the end with minor version bumps.
1540  * Removal, reordering and changes to existing fields require a major
1541  * version bump.
1542  * Please use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1543  * applications.
1544  * sizeof(AVCodecContext) must not be used outside libav*.
1545  */
1546 typedef struct AVCodecContext {
1547     /**
1548      * information on struct for av_log
1549      * - set by avcodec_alloc_context3
1550      */
1551     const AVClass *av_class;
1552     int log_level_offset;
1553
1554     enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1555     const struct AVCodec  *codec;
1556     char             codec_name[32];
1557     enum AVCodecID     codec_id; /* see AV_CODEC_ID_xxx */
1558
1559     /**
1560      * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1561      * This is used to work around some encoder bugs.
1562      * A demuxer should set this to what is stored in the field used to identify the codec.
1563      * If there are multiple such fields in a container then the demuxer should choose the one
1564      * which maximizes the information about the used codec.
1565      * If the codec tag field in a container is larger than 32 bits then the demuxer should
1566      * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1567      * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1568      * first.
1569      * - encoding: Set by user, if not then the default based on codec_id will be used.
1570      * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1571      */
1572     unsigned int codec_tag;
1573
1574     /**
1575      * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1576      * This is used to work around some encoder bugs.
1577      * - encoding: unused
1578      * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1579      */
1580     unsigned int stream_codec_tag;
1581
1582 #if FF_API_SUB_ID
1583     /**
1584      * @deprecated this field is unused
1585      */
1586     attribute_deprecated int sub_id;
1587 #endif
1588
1589     void *priv_data;
1590
1591     /**
1592      * Private context used for internal data.
1593      *
1594      * Unlike priv_data, this is not codec-specific. It is used in general
1595      * libavcodec functions.
1596      */
1597     struct AVCodecInternal *internal;
1598
1599     /**
1600      * Private data of the user, can be used to carry app specific stuff.
1601      * - encoding: Set by user.
1602      * - decoding: Set by user.
1603      */
1604     void *opaque;
1605
1606     /**
1607      * the average bitrate
1608      * - encoding: Set by user; unused for constant quantizer encoding.
1609      * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1610      */
1611     int bit_rate;
1612
1613     /**
1614      * number of bits the bitstream is allowed to diverge from the reference.
1615      *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
1616      * - encoding: Set by user; unused for constant quantizer encoding.
1617      * - decoding: unused
1618      */
1619     int bit_rate_tolerance;
1620
1621     /**
1622      * Global quality for codecs which cannot change it per frame.
1623      * This should be proportional to MPEG-1/2/4 qscale.
1624      * - encoding: Set by user.
1625      * - decoding: unused
1626      */
1627     int global_quality;
1628
1629     /**
1630      * - encoding: Set by user.
1631      * - decoding: unused
1632      */
1633     int compression_level;
1634 #define FF_COMPRESSION_DEFAULT -1
1635
1636     /**
1637      * CODEC_FLAG_*.
1638      * - encoding: Set by user.
1639      * - decoding: Set by user.
1640      */
1641     int flags;
1642
1643     /**
1644      * CODEC_FLAG2_*
1645      * - encoding: Set by user.
1646      * - decoding: Set by user.
1647      */
1648     int flags2;
1649
1650     /**
1651      * some codecs need / can use extradata like Huffman tables.
1652      * mjpeg: Huffman tables
1653      * rv10: additional flags
1654      * mpeg4: global headers (they can be in the bitstream or here)
1655      * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1656      * than extradata_size to avoid prolems if it is read with the bitstream reader.
1657      * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1658      * - encoding: Set/allocated/freed by libavcodec.
1659      * - decoding: Set/allocated/freed by user.
1660      */
1661     uint8_t *extradata;
1662     int extradata_size;
1663
1664     /**
1665      * This is the fundamental unit of time (in seconds) in terms
1666      * of which frame timestamps are represented. For fixed-fps content,
1667      * timebase should be 1/framerate and timestamp increments should be
1668      * identically 1.
1669      * - encoding: MUST be set by user.
1670      * - decoding: Set by libavcodec.
1671      */
1672     AVRational time_base;
1673
1674     /**
1675      * For some codecs, the time base is closer to the field rate than the frame rate.
1676      * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1677      * if no telecine is used ...
1678      *
1679      * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1680      */
1681     int ticks_per_frame;
1682
1683     /**
1684      * Codec delay.
1685      *
1686      * Encoding: Number of frames delay there will be from the encoder input to
1687      *           the decoder output. (we assume the decoder matches the spec)
1688      * Decoding: Number of frames delay in addition to what a standard decoder
1689      *           as specified in the spec would produce.
1690      *
1691      * Video:
1692      *   Number of frames the decoded output will be delayed relative to the
1693      *   encoded input.
1694      *
1695      * Audio:
1696      *   For encoding, this is the number of "priming" samples added to the
1697      *   beginning of the stream. The decoded output will be delayed by this
1698      *   many samples relative to the input to the encoder. Note that this
1699      *   field is purely informational and does not directly affect the pts
1700      *   output by the encoder, which should always be based on the actual
1701      *   presentation time, including any delay.
1702      *   For decoding, this is the number of samples the decoder needs to
1703      *   output before the decoder's output is valid. When seeking, you should
1704      *   start decoding this many samples prior to your desired seek point.
1705      *
1706      * - encoding: Set by libavcodec.
1707      * - decoding: Set by libavcodec.
1708      */
1709     int delay;
1710
1711
1712     /* video only */
1713     /**
1714      * picture width / height.
1715      * - encoding: MUST be set by user.
1716      * - decoding: Set by libavcodec.
1717      * Note: For compatibility it is possible to set this instead of
1718      * coded_width/height before decoding.
1719      */
1720     int width, height;
1721
1722     /**
1723      * Bitstream width / height, may be different from width/height if lowres enabled.
1724      * - encoding: unused
1725      * - decoding: Set by user before init if known. Codec should override / dynamically change if needed.
1726      */
1727     int coded_width, coded_height;
1728
1729 #define FF_ASPECT_EXTENDED 15
1730
1731     /**
1732      * the number of pictures in a group of pictures, or 0 for intra_only
1733      * - encoding: Set by user.
1734      * - decoding: unused
1735      */
1736     int gop_size;
1737
1738     /**
1739      * Pixel format, see AV_PIX_FMT_xxx.
1740      * May be set by the demuxer if known from headers.
1741      * May be overridden by the decoder if it knows better.
1742      * - encoding: Set by user.
1743      * - decoding: Set by user if known, overridden by libavcodec if known
1744      */
1745     enum AVPixelFormat pix_fmt;
1746
1747     /**
1748      * Motion estimation algorithm used for video coding.
1749      * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1750      * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific]
1751      * - encoding: MUST be set by user.
1752      * - decoding: unused
1753      */
1754     int me_method;
1755
1756     /**
1757      * If non NULL, 'draw_horiz_band' is called by the libavcodec
1758      * decoder to draw a horizontal band. It improves cache usage. Not
1759      * all codecs can do that. You must check the codec capabilities
1760      * beforehand.
1761      * When multithreading is used, it may be called from multiple threads
1762      * at the same time; threads might draw different parts of the same AVFrame,
1763      * or multiple AVFrames, and there is no guarantee that slices will be drawn
1764      * in order.
1765      * The function is also used by hardware acceleration APIs.
1766      * It is called at least once during frame decoding to pass
1767      * the data needed for hardware render.
1768      * In that mode instead of pixel data, AVFrame points to
1769      * a structure specific to the acceleration API. The application
1770      * reads the structure and can change some fields to indicate progress
1771      * or mark state.
1772      * - encoding: unused
1773      * - decoding: Set by user.
1774      * @param height the height of the slice
1775      * @param y the y position of the slice
1776      * @param type 1->top field, 2->bottom field, 3->frame
1777      * @param offset offset into the AVFrame.data from which the slice should be read
1778      */
1779     void (*draw_horiz_band)(struct AVCodecContext *s,
1780                             const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1781                             int y, int type, int height);
1782
1783     /**
1784      * callback to negotiate the pixelFormat
1785      * @param fmt is the list of formats which are supported by the codec,
1786      * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1787      * The first is always the native one.
1788      * @return the chosen format
1789      * - encoding: unused
1790      * - decoding: Set by user, if not set the native format will be chosen.
1791      */
1792     enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1793
1794     /**
1795      * maximum number of B-frames between non-B-frames
1796      * Note: The output will be delayed by max_b_frames+1 relative to the input.
1797      * - encoding: Set by user.
1798      * - decoding: unused
1799      */
1800     int max_b_frames;
1801
1802     /**
1803      * qscale factor between IP and B-frames
1804      * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1805      * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1806      * - encoding: Set by user.
1807      * - decoding: unused
1808      */
1809     float b_quant_factor;
1810
1811     /** obsolete FIXME remove */
1812     int rc_strategy;
1813 #define FF_RC_STRATEGY_XVID 1
1814
1815     int b_frame_strategy;
1816
1817 #if FF_API_MPV_GLOBAL_OPTS
1818     /**
1819      * luma single coefficient elimination threshold
1820      * - encoding: Set by user.
1821      * - decoding: unused
1822      */
1823     attribute_deprecated int luma_elim_threshold;
1824
1825     /**
1826      * chroma single coeff elimination threshold
1827      * - encoding: Set by user.
1828      * - decoding: unused
1829      */
1830     attribute_deprecated int chroma_elim_threshold;
1831 #endif
1832
1833     /**
1834      * qscale offset between IP and B-frames
1835      * - encoding: Set by user.
1836      * - decoding: unused
1837      */
1838     float b_quant_offset;
1839
1840     /**
1841      * Size of the frame reordering buffer in the decoder.
1842      * For MPEG-2 it is 1 IPB or 0 low delay IP.
1843      * - encoding: Set by libavcodec.
1844      * - decoding: Set by libavcodec.
1845      */
1846     int has_b_frames;
1847
1848     /**
1849      * 0-> h263 quant 1-> mpeg quant
1850      * - encoding: Set by user.
1851      * - decoding: unused
1852      */
1853     int mpeg_quant;
1854
1855     /**
1856      * qscale factor between P and I-frames
1857      * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1858      * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1859      * - encoding: Set by user.
1860      * - decoding: unused
1861      */
1862     float i_quant_factor;
1863
1864     /**
1865      * qscale offset between P and I-frames
1866      * - encoding: Set by user.
1867      * - decoding: unused
1868      */
1869     float i_quant_offset;
1870
1871     /**
1872      * luminance masking (0-> disabled)
1873      * - encoding: Set by user.
1874      * - decoding: unused
1875      */
1876     float lumi_masking;
1877
1878     /**
1879      * temporary complexity masking (0-> disabled)
1880      * - encoding: Set by user.
1881      * - decoding: unused
1882      */
1883     float temporal_cplx_masking;
1884
1885     /**
1886      * spatial complexity masking (0-> disabled)
1887      * - encoding: Set by user.
1888      * - decoding: unused
1889      */
1890     float spatial_cplx_masking;
1891
1892     /**
1893      * p block masking (0-> disabled)
1894      * - encoding: Set by user.
1895      * - decoding: unused
1896      */
1897     float p_masking;
1898
1899     /**
1900      * darkness masking (0-> disabled)
1901      * - encoding: Set by user.
1902      * - decoding: unused
1903      */
1904     float dark_masking;
1905
1906     /**
1907      * slice count
1908      * - encoding: Set by libavcodec.
1909      * - decoding: Set by user (or 0).
1910      */
1911     int slice_count;
1912     /**
1913      * prediction method (needed for huffyuv)
1914      * - encoding: Set by user.
1915      * - decoding: unused
1916      */
1917      int prediction_method;
1918 #define FF_PRED_LEFT   0
1919 #define FF_PRED_PLANE  1
1920 #define FF_PRED_MEDIAN 2
1921
1922     /**
1923      * slice offsets in the frame in bytes
1924      * - encoding: Set/allocated by libavcodec.
1925      * - decoding: Set/allocated by user (or NULL).
1926      */
1927     int *slice_offset;
1928
1929     /**
1930      * sample aspect ratio (0 if unknown)
1931      * That is the width of a pixel divided by the height of the pixel.
1932      * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1933      * - encoding: Set by user.
1934      * - decoding: Set by libavcodec.
1935      */
1936     AVRational sample_aspect_ratio;
1937
1938     /**
1939      * motion estimation comparison function
1940      * - encoding: Set by user.
1941      * - decoding: unused
1942      */
1943     int me_cmp;
1944     /**
1945      * subpixel motion estimation comparison function
1946      * - encoding: Set by user.
1947      * - decoding: unused
1948      */
1949     int me_sub_cmp;
1950     /**
1951      * macroblock comparison function (not supported yet)
1952      * - encoding: Set by user.
1953      * - decoding: unused
1954      */
1955     int mb_cmp;
1956     /**
1957      * interlaced DCT comparison function
1958      * - encoding: Set by user.
1959      * - decoding: unused
1960      */
1961     int ildct_cmp;
1962 #define FF_CMP_SAD    0
1963 #define FF_CMP_SSE    1
1964 #define FF_CMP_SATD   2
1965 #define FF_CMP_DCT    3
1966 #define FF_CMP_PSNR   4
1967 #define FF_CMP_BIT    5
1968 #define FF_CMP_RD     6
1969 #define FF_CMP_ZERO   7
1970 #define FF_CMP_VSAD   8
1971 #define FF_CMP_VSSE   9
1972 #define FF_CMP_NSSE   10
1973 #define FF_CMP_W53    11
1974 #define FF_CMP_W97    12
1975 #define FF_CMP_DCTMAX 13
1976 #define FF_CMP_DCT264 14
1977 #define FF_CMP_CHROMA 256
1978
1979     /**
1980      * ME diamond size & shape
1981      * - encoding: Set by user.
1982      * - decoding: unused
1983      */
1984     int dia_size;
1985
1986     /**
1987      * amount of previous MV predictors (2a+1 x 2a+1 square)
1988      * - encoding: Set by user.
1989      * - decoding: unused
1990      */
1991     int last_predictor_count;
1992
1993     /**
1994      * prepass for motion estimation
1995      * - encoding: Set by user.
1996      * - decoding: unused
1997      */
1998     int pre_me;
1999
2000     /**
2001      * motion estimation prepass comparison function
2002      * - encoding: Set by user.
2003      * - decoding: unused
2004      */
2005     int me_pre_cmp;
2006
2007     /**
2008      * ME prepass diamond size & shape
2009      * - encoding: Set by user.
2010      * - decoding: unused
2011      */
2012     int pre_dia_size;
2013
2014     /**
2015      * subpel ME quality
2016      * - encoding: Set by user.
2017      * - decoding: unused
2018      */
2019     int me_subpel_quality;
2020
2021     /**
2022      * DTG active format information (additional aspect ratio
2023      * information only used in DVB MPEG-2 transport streams)
2024      * 0 if not set.
2025      *
2026      * - encoding: unused
2027      * - decoding: Set by decoder.
2028      */
2029     int dtg_active_format;
2030 #define FF_DTG_AFD_SAME         8
2031 #define FF_DTG_AFD_4_3          9
2032 #define FF_DTG_AFD_16_9         10
2033 #define FF_DTG_AFD_14_9         11
2034 #define FF_DTG_AFD_4_3_SP_14_9  13
2035 #define FF_DTG_AFD_16_9_SP_14_9 14
2036 #define FF_DTG_AFD_SP_4_3       15
2037
2038     /**
2039      * maximum motion estimation search range in subpel units
2040      * If 0 then no limit.
2041      *
2042      * - encoding: Set by user.
2043      * - decoding: unused
2044      */
2045     int me_range;
2046
2047     /**
2048      * intra quantizer bias
2049      * - encoding: Set by user.
2050      * - decoding: unused
2051      */
2052     int intra_quant_bias;
2053 #define FF_DEFAULT_QUANT_BIAS 999999
2054
2055     /**
2056      * inter quantizer bias
2057      * - encoding: Set by user.
2058      * - decoding: unused
2059      */
2060     int inter_quant_bias;
2061
2062 #if FF_API_COLOR_TABLE_ID
2063     /**
2064      * color table ID
2065      * - encoding: unused
2066      * - decoding: Which clrtable should be used for 8bit RGB images.
2067      *             Tables have to be stored somewhere. FIXME
2068      */
2069     attribute_deprecated int color_table_id;
2070 #endif
2071
2072     /**
2073      * slice flags
2074      * - encoding: unused
2075      * - decoding: Set by user.
2076      */
2077     int slice_flags;
2078 #define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
2079 #define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
2080 #define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
2081
2082     /**
2083      * XVideo Motion Acceleration
2084      * - encoding: forbidden
2085      * - decoding: set by decoder
2086      */
2087     int xvmc_acceleration;
2088
2089     /**
2090      * macroblock decision mode
2091      * - encoding: Set by user.
2092      * - decoding: unused
2093      */
2094     int mb_decision;
2095 #define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
2096 #define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
2097 #define FF_MB_DECISION_RD     2        ///< rate distortion
2098
2099     /**
2100      * custom intra quantization matrix
2101      * - encoding: Set by user, can be NULL.
2102      * - decoding: Set by libavcodec.
2103      */
2104     uint16_t *intra_matrix;
2105
2106     /**
2107      * custom inter quantization matrix
2108      * - encoding: Set by user, can be NULL.
2109      * - decoding: Set by libavcodec.
2110      */
2111     uint16_t *inter_matrix;
2112
2113     /**
2114      * scene change detection threshold
2115      * 0 is default, larger means fewer detected scene changes.
2116      * - encoding: Set by user.
2117      * - decoding: unused
2118      */
2119     int scenechange_threshold;
2120
2121     /**
2122      * noise reduction strength
2123      * - encoding: Set by user.
2124      * - decoding: unused
2125      */
2126     int noise_reduction;
2127
2128 #if FF_API_INTER_THRESHOLD
2129     /**
2130      * @deprecated this field is unused
2131      */
2132     attribute_deprecated int inter_threshold;
2133 #endif
2134
2135 #if FF_API_MPV_GLOBAL_OPTS
2136     /**
2137      * @deprecated use mpegvideo private options instead
2138      */
2139     attribute_deprecated int quantizer_noise_shaping;
2140 #endif
2141
2142     /**
2143      * Motion estimation threshold below which no motion estimation is
2144      * performed, but instead the user specified motion vectors are used.
2145      *
2146      * - encoding: Set by user.
2147      * - decoding: unused
2148      */
2149     int me_threshold;
2150
2151     /**
2152      * Macroblock threshold below which the user specified macroblock types will be used.
2153      * - encoding: Set by user.
2154      * - decoding: unused
2155      */
2156     int mb_threshold;
2157
2158     /**
2159      * precision of the intra DC coefficient - 8
2160      * - encoding: Set by user.
2161      * - decoding: unused
2162      */
2163     int intra_dc_precision;
2164
2165     /**
2166      * Number of macroblock rows at the top which are skipped.
2167      * - encoding: unused
2168      * - decoding: Set by user.
2169      */
2170     int skip_top;
2171
2172     /**
2173      * Number of macroblock rows at the bottom which are skipped.
2174      * - encoding: unused
2175      * - decoding: Set by user.
2176      */
2177     int skip_bottom;
2178
2179     /**
2180      * Border processing masking, raises the quantizer for mbs on the borders
2181      * of the picture.
2182      * - encoding: Set by user.
2183      * - decoding: unused
2184      */
2185     float border_masking;
2186
2187     /**
2188      * minimum MB lagrange multipler
2189      * - encoding: Set by user.
2190      * - decoding: unused
2191      */
2192     int mb_lmin;
2193
2194     /**
2195      * maximum MB lagrange multipler
2196      * - encoding: Set by user.
2197      * - decoding: unused
2198      */
2199     int mb_lmax;
2200
2201     /**
2202      *
2203      * - encoding: Set by user.
2204      * - decoding: unused
2205      */
2206     int me_penalty_compensation;
2207
2208     /**
2209      *
2210      * - encoding: Set by user.
2211      * - decoding: unused
2212      */
2213     int bidir_refine;
2214
2215     /**
2216      *
2217      * - encoding: Set by user.
2218      * - decoding: unused
2219      */
2220     int brd_scale;
2221
2222     /**
2223      * minimum GOP size
2224      * - encoding: Set by user.
2225      * - decoding: unused
2226      */
2227     int keyint_min;
2228
2229     /**
2230      * number of reference frames
2231      * - encoding: Set by user.
2232      * - decoding: Set by lavc.
2233      */
2234     int refs;
2235
2236     /**
2237      * chroma qp offset from luma
2238      * - encoding: Set by user.
2239      * - decoding: unused
2240      */
2241     int chromaoffset;
2242
2243     /**
2244      * Multiplied by qscale for each frame and added to scene_change_score.
2245      * - encoding: Set by user.
2246      * - decoding: unused
2247      */
2248     int scenechange_factor;
2249
2250     /**
2251      *
2252      * Note: Value depends upon the compare function used for fullpel ME.
2253      * - encoding: Set by user.
2254      * - decoding: unused
2255      */
2256     int mv0_threshold;
2257
2258     /**
2259      * Adjust sensitivity of b_frame_strategy 1.
2260      * - encoding: Set by user.
2261      * - decoding: unused
2262      */
2263     int b_sensitivity;
2264
2265     /**
2266      * Chromaticity coordinates of the source primaries.
2267      * - encoding: Set by user
2268      * - decoding: Set by libavcodec
2269      */
2270     enum AVColorPrimaries color_primaries;
2271
2272     /**
2273      * Color Transfer Characteristic.
2274      * - encoding: Set by user
2275      * - decoding: Set by libavcodec
2276      */
2277     enum AVColorTransferCharacteristic color_trc;
2278
2279     /**
2280      * YUV colorspace type.
2281      * - encoding: Set by user
2282      * - decoding: Set by libavcodec
2283      */
2284     enum AVColorSpace colorspace;
2285
2286     /**
2287      * MPEG vs JPEG YUV range.
2288      * - encoding: Set by user
2289      * - decoding: Set by libavcodec
2290      */
2291     enum AVColorRange color_range;
2292
2293     /**
2294      * This defines the location of chroma samples.
2295      * - encoding: Set by user
2296      * - decoding: Set by libavcodec
2297      */
2298     enum AVChromaLocation chroma_sample_location;
2299
2300     /**
2301      * Number of slices.
2302      * Indicates number of picture subdivisions. Used for parallelized
2303      * decoding.
2304      * - encoding: Set by user
2305      * - decoding: unused
2306      */
2307     int slices;
2308
2309     /** Field order
2310      * - encoding: set by libavcodec
2311      * - decoding: Set by user.
2312      */
2313     enum AVFieldOrder field_order;
2314
2315     /* audio only */
2316     int sample_rate; ///< samples per second
2317     int channels;    ///< number of audio channels
2318
2319     /**
2320      * audio sample format
2321      * - encoding: Set by user.
2322      * - decoding: Set by libavcodec.
2323      */
2324     enum AVSampleFormat sample_fmt;  ///< sample format
2325
2326     /* The following data should not be initialized. */
2327     /**
2328      * Number of samples per channel in an audio frame.
2329      *
2330      * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
2331      *   except the last must contain exactly frame_size samples per channel.
2332      *   May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
2333      *   frame size is not restricted.
2334      * - decoding: may be set by some decoders to indicate constant frame size
2335      */
2336     int frame_size;
2337
2338     /**
2339      * Frame counter, set by libavcodec.
2340      *
2341      * - decoding: total number of frames returned from the decoder so far.
2342      * - encoding: total number of frames passed to the encoder so far.
2343      *
2344      *   @note the counter is not incremented if encoding/decoding resulted in
2345      *   an error.
2346      */
2347     int frame_number;
2348
2349     /**
2350      * number of bytes per packet if constant and known or 0
2351      * Used by some WAV based audio codecs.
2352      */
2353     int block_align;
2354
2355     /**
2356      * Audio cutoff bandwidth (0 means "automatic")
2357      * - encoding: Set by user.
2358      * - decoding: unused
2359      */
2360     int cutoff;
2361
2362 #if FF_API_REQUEST_CHANNELS
2363     /**
2364      * Decoder should decode to this many channels if it can (0 for default)
2365      * - encoding: unused
2366      * - decoding: Set by user.
2367      * @deprecated Deprecated in favor of request_channel_layout.
2368      */
2369     int request_channels;
2370 #endif
2371
2372     /**
2373      * Audio channel layout.
2374      * - encoding: set by user.
2375      * - decoding: set by user, may be overwritten by libavcodec.
2376      */
2377     uint64_t channel_layout;
2378
2379     /**
2380      * Request decoder to use this channel layout if it can (0 for default)
2381      * - encoding: unused
2382      * - decoding: Set by user.
2383      */
2384     uint64_t request_channel_layout;
2385
2386     /**
2387      * Type of service that the audio stream conveys.
2388      * - encoding: Set by user.
2389      * - decoding: Set by libavcodec.
2390      */
2391     enum AVAudioServiceType audio_service_type;
2392
2393     /**
2394      * desired sample format
2395      * - encoding: Not used.
2396      * - decoding: Set by user.
2397      * Decoder will decode to this format if it can.
2398      */
2399     enum AVSampleFormat request_sample_fmt;
2400
2401     /**
2402      * Called at the beginning of each frame to get a buffer for it.
2403      *
2404      * The function will set AVFrame.data[], AVFrame.linesize[].
2405      * AVFrame.extended_data[] must also be set, but it should be the same as
2406      * AVFrame.data[] except for planar audio with more channels than can fit
2407      * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
2408      * many data pointers as it can hold.
2409      *
2410      * if CODEC_CAP_DR1 is not set then get_buffer() must call
2411      * avcodec_default_get_buffer() instead of providing buffers allocated by
2412      * some other means.
2413      *
2414      * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
2415      * need it. avcodec_default_get_buffer() aligns the output buffer properly,
2416      * but if get_buffer() is overridden then alignment considerations should
2417      * be taken into account.
2418      *
2419      * @see avcodec_default_get_buffer()
2420      *
2421      * Video:
2422      *
2423      * If pic.reference is set then the frame will be read later by libavcodec.
2424      * avcodec_align_dimensions2() should be used to find the required width and
2425      * height, as they normally need to be rounded up to the next multiple of 16.
2426      *
2427      * If frame multithreading is used and thread_safe_callbacks is set,
2428      * it may be called from a different thread, but not from more than one at
2429      * once. Does not need to be reentrant.
2430      *
2431      * @see release_buffer(), reget_buffer()
2432      * @see avcodec_align_dimensions2()
2433      *
2434      * Audio:
2435      *
2436      * Decoders request a buffer of a particular size by setting
2437      * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
2438      * however, utilize only part of the buffer by setting AVFrame.nb_samples
2439      * to a smaller value in the output frame.
2440      *
2441      * Decoders cannot use the buffer after returning from
2442      * avcodec_decode_audio4(), so they will not call release_buffer(), as it
2443      * is assumed to be released immediately upon return. In some rare cases,
2444      * a decoder may need to call get_buffer() more than once in a single
2445      * call to avcodec_decode_audio4(). In that case, when get_buffer() is
2446      * called again after it has already been called once, the previously
2447      * acquired buffer is assumed to be released at that time and may not be
2448      * reused by the decoder.
2449      *
2450      * As a convenience, av_samples_get_buffer_size() and
2451      * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
2452      * functions to find the required data size and to fill data pointers and
2453      * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2454      * since all planes must be the same size.
2455      *
2456      * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2457      *
2458      * - encoding: unused
2459      * - decoding: Set by libavcodec, user can override.
2460      */
2461     int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
2462
2463     /**
2464      * Called to release buffers which were allocated with get_buffer.
2465      * A released buffer can be reused in get_buffer().
2466      * pic.data[*] must be set to NULL.
2467      * May be called from a different thread if frame multithreading is used,
2468      * but not by more than one thread at once, so does not need to be reentrant.
2469      * - encoding: unused
2470      * - decoding: Set by libavcodec, user can override.
2471      */
2472     void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
2473
2474     /**
2475      * Called at the beginning of a frame to get cr buffer for it.
2476      * Buffer type (size, hints) must be the same. libavcodec won't check it.
2477      * libavcodec will pass previous buffer in pic, function should return
2478      * same buffer or new buffer with old frame "painted" into it.
2479      * If pic.data[0] == NULL must behave like get_buffer().
2480      * if CODEC_CAP_DR1 is not set then reget_buffer() must call
2481      * avcodec_default_reget_buffer() instead of providing buffers allocated by
2482      * some other means.
2483      * - encoding: unused
2484      * - decoding: Set by libavcodec, user can override.
2485      */
2486     int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
2487
2488
2489     /* - encoding parameters */
2490     float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2491     float qblur;      ///< amount of qscale smoothing over time (0.0-1.0)
2492
2493     /**
2494      * minimum quantizer
2495      * - encoding: Set by user.
2496      * - decoding: unused
2497      */
2498     int qmin;
2499
2500     /**
2501      * maximum quantizer
2502      * - encoding: Set by user.
2503      * - decoding: unused
2504      */
2505     int qmax;
2506
2507     /**
2508      * maximum quantizer difference between frames
2509      * - encoding: Set by user.
2510      * - decoding: unused
2511      */
2512     int max_qdiff;
2513
2514     /**
2515      * ratecontrol qmin qmax limiting method
2516      * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
2517      * - encoding: Set by user.
2518      * - decoding: unused
2519      */
2520     float rc_qsquish;
2521
2522     float rc_qmod_amp;
2523     int rc_qmod_freq;
2524
2525     /**
2526      * decoder bitstream buffer size
2527      * - encoding: Set by user.
2528      * - decoding: unused
2529      */
2530     int rc_buffer_size;
2531
2532     /**
2533      * ratecontrol override, see RcOverride
2534      * - encoding: Allocated/set/freed by user.
2535      * - decoding: unused
2536      */
2537     int rc_override_count;
2538     RcOverride *rc_override;
2539
2540     /**
2541      * rate control equation
2542      * - encoding: Set by user
2543      * - decoding: unused
2544      */
2545     const char *rc_eq;
2546
2547     /**
2548      * maximum bitrate
2549      * - encoding: Set by user.
2550      * - decoding: unused
2551      */
2552     int rc_max_rate;
2553
2554     /**
2555      * minimum bitrate
2556      * - encoding: Set by user.
2557      * - decoding: unused
2558      */
2559     int rc_min_rate;
2560
2561     float rc_buffer_aggressivity;
2562
2563     /**
2564      * initial complexity for pass1 ratecontrol
2565      * - encoding: Set by user.
2566      * - decoding: unused
2567      */
2568     float rc_initial_cplx;
2569
2570     /**
2571      * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2572      * - encoding: Set by user.
2573      * - decoding: unused.
2574      */
2575     float rc_max_available_vbv_use;
2576
2577     /**
2578      * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2579      * - encoding: Set by user.
2580      * - decoding: unused.
2581      */
2582     float rc_min_vbv_overflow_use;
2583
2584     /**
2585      * Number of bits which should be loaded into the rc buffer before decoding starts.
2586      * - encoding: Set by user.
2587      * - decoding: unused
2588      */
2589     int rc_initial_buffer_occupancy;
2590
2591 #define FF_CODER_TYPE_VLC       0
2592 #define FF_CODER_TYPE_AC        1
2593 #define FF_CODER_TYPE_RAW       2
2594 #define FF_CODER_TYPE_RLE       3
2595 #define FF_CODER_TYPE_DEFLATE   4
2596     /**
2597      * coder type
2598      * - encoding: Set by user.
2599      * - decoding: unused
2600      */
2601     int coder_type;
2602
2603     /**
2604      * context model
2605      * - encoding: Set by user.
2606      * - decoding: unused
2607      */
2608     int context_model;
2609
2610     /**
2611      * minimum Lagrange multipler
2612      * - encoding: Set by user.
2613      * - decoding: unused
2614      */
2615     int lmin;
2616
2617     /**
2618      * maximum Lagrange multipler
2619      * - encoding: Set by user.
2620      * - decoding: unused
2621      */
2622     int lmax;
2623
2624     /**
2625      * frame skip threshold
2626      * - encoding: Set by user.
2627      * - decoding: unused
2628      */
2629     int frame_skip_threshold;
2630
2631     /**
2632      * frame skip factor
2633      * - encoding: Set by user.
2634      * - decoding: unused
2635      */
2636     int frame_skip_factor;
2637
2638     /**
2639      * frame skip exponent
2640      * - encoding: Set by user.
2641      * - decoding: unused
2642      */
2643     int frame_skip_exp;
2644
2645     /**
2646      * frame skip comparison function
2647      * - encoding: Set by user.
2648      * - decoding: unused
2649      */
2650     int frame_skip_cmp;
2651
2652     /**
2653      * trellis RD quantization
2654      * - encoding: Set by user.
2655      * - decoding: unused
2656      */
2657     int trellis;
2658
2659     /**
2660      * - encoding: Set by user.
2661      * - decoding: unused
2662      */
2663     int min_prediction_order;
2664
2665     /**
2666      * - encoding: Set by user.
2667      * - decoding: unused
2668      */
2669     int max_prediction_order;
2670
2671     /**
2672      * GOP timecode frame start number
2673      * - encoding: Set by user, in non drop frame format
2674      * - decoding: Set by libavcodec (timecode in the 25 bits format, -1 if unset)
2675      */
2676     int64_t timecode_frame_start;
2677
2678     /* The RTP callback: This function is called    */
2679     /* every time the encoder has a packet to send. */
2680     /* It depends on the encoder if the data starts */
2681     /* with a Start Code (it should). H.263 does.   */
2682     /* mb_nb contains the number of macroblocks     */
2683     /* encoded in the RTP payload.                  */
2684     void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2685
2686     int rtp_payload_size;   /* The size of the RTP payload: the coder will  */
2687                             /* do its best to deliver a chunk with size     */
2688                             /* below rtp_payload_size, the chunk will start */
2689                             /* with a start code on some codecs like H.263. */
2690                             /* This doesn't take account of any particular  */
2691                             /* headers inside the transmitted RTP payload.  */
2692
2693     /* statistics, used for 2-pass encoding */
2694     int mv_bits;
2695     int header_bits;
2696     int i_tex_bits;
2697     int p_tex_bits;
2698     int i_count;
2699     int p_count;
2700     int skip_count;
2701     int misc_bits;
2702
2703     /**
2704      * number of bits used for the previously encoded frame
2705      * - encoding: Set by libavcodec.
2706      * - decoding: unused
2707      */
2708     int frame_bits;
2709
2710     /**
2711      * pass1 encoding statistics output buffer
2712      * - encoding: Set by libavcodec.
2713      * - decoding: unused
2714      */
2715     char *stats_out;
2716
2717     /**
2718      * pass2 encoding statistics input buffer
2719      * Concatenated stuff from stats_out of pass1 should be placed here.
2720      * - encoding: Allocated/set/freed by user.
2721      * - decoding: unused
2722      */
2723     char *stats_in;
2724
2725     /**
2726      * Work around bugs in encoders which sometimes cannot be detected automatically.
2727      * - encoding: Set by user
2728      * - decoding: Set by user
2729      */
2730     int workaround_bugs;
2731 #define FF_BUG_AUTODETECT       1  ///< autodetection
2732 #define FF_BUG_OLD_MSMPEG4      2
2733 #define FF_BUG_XVID_ILACE       4
2734 #define FF_BUG_UMP4             8
2735 #define FF_BUG_NO_PADDING       16
2736 #define FF_BUG_AMV              32
2737 #define FF_BUG_AC_VLC           0  ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2738 #define FF_BUG_QPEL_CHROMA      64
2739 #define FF_BUG_STD_QPEL         128
2740 #define FF_BUG_QPEL_CHROMA2     256
2741 #define FF_BUG_DIRECT_BLOCKSIZE 512
2742 #define FF_BUG_EDGE             1024
2743 #define FF_BUG_HPEL_CHROMA      2048
2744 #define FF_BUG_DC_CLIP          4096
2745 #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders.
2746 #define FF_BUG_TRUNCATED       16384
2747
2748     /**
2749      * strictly follow the standard (MPEG4, ...).
2750      * - encoding: Set by user.
2751      * - decoding: Set by user.
2752      * Setting this to STRICT or higher means the encoder and decoder will
2753      * generally do stupid things, whereas setting it to unofficial or lower
2754      * will mean the encoder might produce output that is not supported by all
2755      * spec-compliant decoders. Decoders don't differentiate between normal,
2756      * unofficial and experimental (that is, they always try to decode things
2757      * when they can) unless they are explicitly asked to behave stupidly
2758      * (=strictly conform to the specs)
2759      */
2760     int strict_std_compliance;
2761 #define FF_COMPLIANCE_VERY_STRICT   2 ///< Strictly conform to an older more strict version of the spec or reference software.
2762 #define FF_COMPLIANCE_STRICT        1 ///< Strictly conform to all the things in the spec no matter what consequences.
2763 #define FF_COMPLIANCE_NORMAL        0
2764 #define FF_COMPLIANCE_UNOFFICIAL   -1 ///< Allow unofficial extensions
2765 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2766
2767     /**
2768      * error concealment flags
2769      * - encoding: unused
2770      * - decoding: Set by user.
2771      */
2772     int error_concealment;
2773 #define FF_EC_GUESS_MVS   1
2774 #define FF_EC_DEBLOCK     2
2775
2776     /**
2777      * debug
2778      * - encoding: Set by user.
2779      * - decoding: Set by user.
2780      */
2781     int debug;
2782 #define FF_DEBUG_PICT_INFO   1
2783 #define FF_DEBUG_RC          2
2784 #define FF_DEBUG_BITSTREAM   4
2785 #define FF_DEBUG_MB_TYPE     8
2786 #define FF_DEBUG_QP          16
2787 #define FF_DEBUG_MV          32
2788 #define FF_DEBUG_DCT_COEFF   0x00000040
2789 #define FF_DEBUG_SKIP        0x00000080
2790 #define FF_DEBUG_STARTCODE   0x00000100
2791 #define FF_DEBUG_PTS         0x00000200
2792 #define FF_DEBUG_ER          0x00000400
2793 #define FF_DEBUG_MMCO        0x00000800
2794 #define FF_DEBUG_BUGS        0x00001000
2795 #define FF_DEBUG_VIS_QP      0x00002000
2796 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2797 #define FF_DEBUG_BUFFERS     0x00008000
2798 #define FF_DEBUG_THREADS     0x00010000
2799
2800     /**
2801      * debug
2802      * - encoding: Set by user.
2803      * - decoding: Set by user.
2804      */
2805     int debug_mv;
2806 #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 //visualize forward predicted MVs of P frames
2807 #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames
2808 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2809
2810     /**
2811      * Error recognition; may misdetect some more or less valid parts as errors.
2812      * - encoding: unused
2813      * - decoding: Set by user.
2814      */
2815     int err_recognition;
2816 #define AV_EF_CRCCHECK  (1<<0)
2817 #define AV_EF_BITSTREAM (1<<1)
2818 #define AV_EF_BUFFER    (1<<2)
2819 #define AV_EF_EXPLODE   (1<<3)
2820
2821 #define AV_EF_CAREFUL    (1<<16)
2822 #define AV_EF_COMPLIANT  (1<<17)
2823 #define AV_EF_AGGRESSIVE (1<<18)
2824
2825
2826     /**
2827      * opaque 64bit number (generally a PTS) that will be reordered and
2828      * output in AVFrame.reordered_opaque
2829      * @deprecated in favor of pkt_pts
2830      * - encoding: unused
2831      * - decoding: Set by user.
2832      */
2833     int64_t reordered_opaque;
2834
2835     /**
2836      * Hardware accelerator in use
2837      * - encoding: unused.
2838      * - decoding: Set by libavcodec
2839      */
2840     struct AVHWAccel *hwaccel;
2841
2842     /**
2843      * Hardware accelerator context.
2844      * For some hardware accelerators, a global context needs to be
2845      * provided by the user. In that case, this holds display-dependent
2846      * data FFmpeg cannot instantiate itself. Please refer to the
2847      * FFmpeg HW accelerator documentation to know how to fill this
2848      * is. e.g. for VA API, this is a struct vaapi_context.
2849      * - encoding: unused
2850      * - decoding: Set by user
2851      */
2852     void *hwaccel_context;
2853
2854     /**
2855      * error
2856      * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2857      * - decoding: unused
2858      */
2859     uint64_t error[AV_NUM_DATA_POINTERS];
2860
2861     /**
2862      * DCT algorithm, see FF_DCT_* below
2863      * - encoding: Set by user.
2864      * - decoding: unused
2865      */
2866     int dct_algo;
2867 #define FF_DCT_AUTO    0
2868 #define FF_DCT_FASTINT 1
2869 #define FF_DCT_INT     2
2870 #define FF_DCT_MMX     3
2871 #define FF_DCT_ALTIVEC 5
2872 #define FF_DCT_FAAN    6
2873
2874     /**
2875      * IDCT algorithm, see FF_IDCT_* below.
2876      * - encoding: Set by user.
2877      * - decoding: Set by user.
2878      */
2879     int idct_algo;
2880 #define FF_IDCT_AUTO          0
2881 #define FF_IDCT_INT           1
2882 #define FF_IDCT_SIMPLE        2
2883 #define FF_IDCT_SIMPLEMMX     3
2884 #define FF_IDCT_LIBMPEG2MMX   4
2885 #if FF_API_MMI
2886 #define FF_IDCT_MMI           5
2887 #endif
2888 #define FF_IDCT_ARM           7
2889 #define FF_IDCT_ALTIVEC       8
2890 #define FF_IDCT_SH4           9
2891 #define FF_IDCT_SIMPLEARM     10
2892 #define FF_IDCT_H264          11
2893 #define FF_IDCT_VP3           12
2894 #define FF_IDCT_IPP           13
2895 #define FF_IDCT_XVIDMMX       14
2896 #define FF_IDCT_CAVS          15
2897 #define FF_IDCT_SIMPLEARMV5TE 16
2898 #define FF_IDCT_SIMPLEARMV6   17
2899 #define FF_IDCT_SIMPLEVIS     18
2900 #define FF_IDCT_WMV2          19
2901 #define FF_IDCT_FAAN          20
2902 #define FF_IDCT_EA            21
2903 #define FF_IDCT_SIMPLENEON    22
2904 #define FF_IDCT_SIMPLEALPHA   23
2905 #define FF_IDCT_BINK          24
2906
2907 #if FF_API_DSP_MASK
2908     /**
2909      * Unused.
2910      * @deprecated use av_set_cpu_flags_mask() instead.
2911      */
2912     attribute_deprecated unsigned dsp_mask;
2913 #endif
2914
2915     /**
2916      * bits per sample/pixel from the demuxer (needed for huffyuv).
2917      * - encoding: Set by libavcodec.
2918      * - decoding: Set by user.
2919      */
2920      int bits_per_coded_sample;
2921
2922     /**
2923      * Bits per sample/pixel of internal libavcodec pixel/sample format.
2924      * - encoding: set by user.
2925      * - decoding: set by libavcodec.
2926      */
2927     int bits_per_raw_sample;
2928
2929     /**
2930      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2931      * - encoding: unused
2932      * - decoding: Set by user.
2933      */
2934      int lowres;
2935
2936     /**
2937      * the picture in the bitstream
2938      * - encoding: Set by libavcodec.
2939      * - decoding: Set by libavcodec.
2940      */
2941     AVFrame *coded_frame;
2942
2943     /**
2944      * thread count
2945      * is used to decide how many independent tasks should be passed to execute()
2946      * - encoding: Set by user.
2947      * - decoding: Set by user.
2948      */
2949     int thread_count;
2950
2951     /**
2952      * Which multithreading methods to use.
2953      * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2954      * so clients which cannot provide future frames should not use it.
2955      *
2956      * - encoding: Set by user, otherwise the default is used.
2957      * - decoding: Set by user, otherwise the default is used.
2958      */
2959     int thread_type;
2960 #define FF_THREAD_FRAME   1 ///< Decode more than one frame at once
2961 #define FF_THREAD_SLICE   2 ///< Decode more than one part of a single frame at once
2962
2963     /**
2964      * Which multithreading methods are in use by the codec.
2965      * - encoding: Set by libavcodec.
2966      * - decoding: Set by libavcodec.
2967      */
2968     int active_thread_type;
2969
2970     /**
2971      * Set by the client if its custom get_buffer() callback can be called
2972      * synchronously from another thread, which allows faster multithreaded decoding.
2973      * draw_horiz_band() will be called from other threads regardless of this setting.
2974      * Ignored if the default get_buffer() is used.
2975      * - encoding: Set by user.
2976      * - decoding: Set by user.
2977      */
2978     int thread_safe_callbacks;
2979
2980     /**
2981      * The codec may call this to execute several independent things.
2982      * It will return only after finishing all tasks.
2983      * The user may replace this with some multithreaded implementation,
2984      * the default implementation will execute the parts serially.
2985      * @param count the number of things to execute
2986      * - encoding: Set by libavcodec, user can override.
2987      * - decoding: Set by libavcodec, user can override.
2988      */
2989     int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2990
2991     /**
2992      * The codec may call this to execute several independent things.
2993      * It will return only after finishing all tasks.
2994      * The user may replace this with some multithreaded implementation,
2995      * the default implementation will execute the parts serially.
2996      * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2997      * @param c context passed also to func
2998      * @param count the number of things to execute
2999      * @param arg2 argument passed unchanged to func
3000      * @param ret return values of executed functions, must have space for "count" values. May be NULL.
3001      * @param func function that will be called count times, with jobnr from 0 to count-1.
3002      *             threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
3003      *             two instances of func executing at the same time will have the same threadnr.
3004      * @return always 0 currently, but code should handle a future improvement where when any call to func
3005      *         returns < 0 no further calls to func may be done and < 0 is returned.
3006      * - encoding: Set by libavcodec, user can override.
3007      * - decoding: Set by libavcodec, user can override.
3008      */
3009     int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
3010
3011     /**
3012      * thread opaque
3013      * Can be used by execute() to store some per AVCodecContext stuff.
3014      * - encoding: set by execute()
3015      * - decoding: set by execute()
3016      */
3017     void *thread_opaque;
3018
3019     /**
3020      * noise vs. sse weight for the nsse comparsion function
3021      * - encoding: Set by user.
3022      * - decoding: unused
3023      */
3024      int nsse_weight;
3025
3026     /**
3027      * profile
3028      * - encoding: Set by user.
3029      * - decoding: Set by libavcodec.
3030      */
3031      int profile;
3032 #define FF_PROFILE_UNKNOWN -99
3033 #define FF_PROFILE_RESERVED -100
3034
3035 #define FF_PROFILE_AAC_MAIN 0
3036 #define FF_PROFILE_AAC_LOW  1
3037 #define FF_PROFILE_AAC_SSR  2
3038 #define FF_PROFILE_AAC_LTP  3
3039 #define FF_PROFILE_AAC_HE   4
3040 #define FF_PROFILE_AAC_HE_V2 28
3041 #define FF_PROFILE_AAC_LD   22
3042 #define FF_PROFILE_AAC_ELD  38
3043
3044 #define FF_PROFILE_DTS         20
3045 #define FF_PROFILE_DTS_ES      30
3046 #define FF_PROFILE_DTS_96_24   40
3047 #define FF_PROFILE_DTS_HD_HRA  50
3048 #define FF_PROFILE_DTS_HD_MA   60
3049
3050 #define FF_PROFILE_MPEG2_422    0
3051 #define FF_PROFILE_MPEG2_HIGH   1
3052 #define FF_PROFILE_MPEG2_SS     2
3053 #define FF_PROFILE_MPEG2_SNR_SCALABLE  3
3054 #define FF_PROFILE_MPEG2_MAIN   4
3055 #define FF_PROFILE_MPEG2_SIMPLE 5
3056
3057 #define FF_PROFILE_H264_CONSTRAINED  (1<<9)  // 8+1; constraint_set1_flag
3058 #define FF_PROFILE_H264_INTRA        (1<<11) // 8+3; constraint_set3_flag
3059
3060 #define FF_PROFILE_H264_BASELINE             66
3061 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
3062 #define FF_PROFILE_H264_MAIN                 77
3063 #define FF_PROFILE_H264_EXTENDED             88
3064 #define FF_PROFILE_H264_HIGH                 100
3065 #define FF_PROFILE_H264_HIGH_10              110
3066 #define FF_PROFILE_H264_HIGH_10_INTRA        (110|FF_PROFILE_H264_INTRA)
3067 #define FF_PROFILE_H264_HIGH_422             122
3068 #define FF_PROFILE_H264_HIGH_422_INTRA       (122|FF_PROFILE_H264_INTRA)
3069 #define FF_PROFILE_H264_HIGH_444             144
3070 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE  244
3071 #define FF_PROFILE_H264_HIGH_444_INTRA       (244|FF_PROFILE_H264_INTRA)
3072 #define FF_PROFILE_H264_CAVLC_444            44
3073
3074 #define FF_PROFILE_VC1_SIMPLE   0
3075 #define FF_PROFILE_VC1_MAIN     1
3076 #define FF_PROFILE_VC1_COMPLEX  2
3077 #define FF_PROFILE_VC1_ADVANCED 3
3078
3079 #define FF_PROFILE_MPEG4_SIMPLE                     0
3080 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE            1
3081 #define FF_PROFILE_MPEG4_CORE                       2
3082 #define FF_PROFILE_MPEG4_MAIN                       3
3083 #define FF_PROFILE_MPEG4_N_BIT                      4
3084 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE           5
3085 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION      6
3086 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE     7
3087 #define FF_PROFILE_MPEG4_HYBRID                     8
3088 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME         9
3089 #define FF_PROFILE_MPEG4_CORE_SCALABLE             10
3090 #define FF_PROFILE_MPEG4_ADVANCED_CODING           11
3091 #define FF_PROFILE_MPEG4_ADVANCED_CORE             12
3092 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
3093 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO             14
3094 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE           15
3095
3096     /**
3097      * level
3098      * - encoding: Set by user.
3099      * - decoding: Set by libavcodec.
3100      */
3101      int level;
3102 #define FF_LEVEL_UNKNOWN -99
3103
3104     /**
3105      *
3106      * - encoding: unused
3107      * - decoding: Set by user.
3108      */
3109     enum AVDiscard skip_loop_filter;
3110
3111     /**
3112      *
3113      * - encoding: unused
3114      * - decoding: Set by user.
3115      */
3116     enum AVDiscard skip_idct;
3117
3118     /**
3119      *
3120      * - encoding: unused
3121      * - decoding: Set by user.
3122      */
3123     enum AVDiscard skip_frame;
3124
3125     /**
3126      * Header containing style information for text subtitles.
3127      * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3128      * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3129      * the Format line following. It shouldn't include any Dialogue line.
3130      * - encoding: Set/allocated/freed by user (before avcodec_open2())
3131      * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3132      */
3133     uint8_t *subtitle_header;
3134     int subtitle_header_size;
3135
3136     /**
3137      * Simulates errors in the bitstream to test error concealment.
3138      * - encoding: Set by user.
3139      * - decoding: unused
3140      */
3141     int error_rate;
3142
3143     /**
3144      * Current packet as passed into the decoder, to avoid having
3145      * to pass the packet into every function. Currently only valid
3146      * inside lavc and get/release_buffer callbacks.
3147      * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
3148      * - encoding: unused
3149      */
3150     AVPacket *pkt;
3151
3152     /**
3153      * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3154      * Used for compliant TS muxing.
3155      * - encoding: Set by libavcodec.
3156      * - decoding: unused.
3157      */
3158     uint64_t vbv_delay;
3159
3160     /**
3161      * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
3162      * Code outside libavcodec should access this field using:
3163      * avcodec_set_pkt_timebase(avctx)
3164      * - encoding unused.
3165      * - decodimg set by user
3166      */
3167     AVRational pkt_timebase;
3168
3169     /**
3170      * AVCodecDescriptor
3171      * Code outside libavcodec should access this field using:
3172      * avcodec_get_codec_descriptior(avctx)
3173      * - encoding: unused.
3174      * - decoding: set by libavcodec.
3175      */
3176     const AVCodecDescriptor *codec_descriptor;
3177
3178     /**
3179      * Current statistics for PTS correction.
3180      * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3181      * - encoding: unused
3182      */
3183     int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
3184     int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
3185     int64_t pts_correction_last_pts;       /// PTS of the last frame
3186     int64_t pts_correction_last_dts;       /// DTS of the last frame
3187
3188     /**
3189      * Current frame metadata.
3190      * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3191      * - encoding: unused
3192      */
3193     AVDictionary *metadata;
3194 } AVCodecContext;
3195
3196 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
3197 void       av_codec_set_pkt_timebase         (AVCodecContext *avctx, AVRational val);
3198
3199 const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
3200 void                     av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
3201
3202 /**
3203  * AVProfile.
3204  */
3205 typedef struct AVProfile {
3206     int profile;
3207     const char *name; ///< short name for the profile
3208 } AVProfile;
3209
3210 typedef struct AVCodecDefault AVCodecDefault;
3211
3212 struct AVSubtitle;
3213
3214 /**
3215  * AVCodec.
3216  */
3217 typedef struct AVCodec {
3218     /**
3219      * Name of the codec implementation.
3220      * The name is globally unique among encoders and among decoders (but an
3221      * encoder and a decoder can share the same name).
3222      * This is the primary way to find a codec from the user perspective.
3223      */
3224     const char *name;
3225     /**
3226      * Descriptive name for the codec, meant to be more human readable than name.
3227      * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3228      */
3229     const char *long_name;
3230     enum AVMediaType type;
3231     enum AVCodecID id;
3232     /**
3233      * Codec capabilities.
3234      * see CODEC_CAP_*
3235      */
3236     int capabilities;
3237     const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3238     const enum AVPixelFormat *pix_fmts;     ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3239     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3240     const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3241     const uint64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3242     uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
3243     const AVClass *priv_class;              ///< AVClass for the private context
3244     const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3245
3246     /*****************************************************************
3247      * No fields below this line are part of the public API. They
3248      * may not be used outside of libavcodec and can be changed and
3249      * removed at will.
3250      * New public fields should be added right above.
3251      *****************************************************************
3252      */
3253     int priv_data_size;
3254     struct AVCodec *next;
3255     /**
3256      * @name Frame-level threading support functions
3257      * @{
3258      */
3259     /**
3260      * If defined, called on thread contexts when they are created.
3261      * If the codec allocates writable tables in init(), re-allocate them here.
3262      * priv_data will be set to a copy of the original.
3263      */
3264     int (*init_thread_copy)(AVCodecContext *);
3265     /**
3266      * Copy necessary context variables from a previous thread context to the current one.
3267      * If not defined, the next thread will start automatically; otherwise, the codec
3268      * must call ff_thread_finish_setup().
3269      *
3270      * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3271      */
3272     int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
3273     /** @} */
3274
3275     /**
3276      * Private codec-specific defaults.
3277      */
3278     const AVCodecDefault *defaults;
3279
3280     /**
3281      * Initialize codec static data, called from avcodec_register().
3282      */
3283     void (*init_static_data)(struct AVCodec *codec);
3284
3285     int (*init)(AVCodecContext *);
3286     int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
3287                       const struct AVSubtitle *sub);
3288     /**
3289      * Encode data to an AVPacket.
3290      *
3291      * @param      avctx          codec context
3292      * @param      avpkt          output AVPacket (may contain a user-provided buffer)
3293      * @param[in]  frame          AVFrame containing the raw data to be encoded
3294      * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3295      *                            non-empty packet was returned in avpkt.
3296      * @return 0 on success, negative error code on failure
3297      */
3298     int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3299                    int *got_packet_ptr);
3300     int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3301     int (*close)(AVCodecContext *);
3302     /**
3303      * Flush buffers.
3304      * Will be called when seeking
3305      */
3306     void (*flush)(AVCodecContext *);
3307 } AVCodec;
3308
3309 /**
3310  * AVHWAccel.
3311  */
3312 typedef struct AVHWAccel {
3313     /**
3314      * Name of the hardware accelerated codec.
3315      * The name is globally unique among encoders and among decoders (but an
3316      * encoder and a decoder can share the same name).
3317      */
3318     const char *name;
3319
3320     /**
3321      * Type of codec implemented by the hardware accelerator.
3322      *
3323      * See AVMEDIA_TYPE_xxx
3324      */
3325     enum AVMediaType type;
3326
3327     /**
3328      * Codec implemented by the hardware accelerator.
3329      *
3330      * See AV_CODEC_ID_xxx
3331      */
3332     enum AVCodecID id;
3333
3334     /**
3335      * Supported pixel format.
3336      *
3337      * Only hardware accelerated formats are supported here.
3338      */
3339     enum AVPixelFormat pix_fmt;
3340
3341     /**
3342      * Hardware accelerated codec capabilities.
3343      * see FF_HWACCEL_CODEC_CAP_*
3344      */
3345     int capabilities;
3346
3347     struct AVHWAccel *next;
3348
3349     /**
3350      * Called at the beginning of each frame or field picture.
3351      *
3352      * Meaningful frame information (codec specific) is guaranteed to
3353      * be parsed at this point. This function is mandatory.
3354      *
3355      * Note that buf can be NULL along with buf_size set to 0.
3356      * Otherwise, this means the whole frame is available at this point.
3357      *
3358      * @param avctx the codec context
3359      * @param buf the frame data buffer base
3360      * @param buf_size the size of the frame in bytes
3361      * @return zero if successful, a negative value otherwise
3362      */
3363     int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3364
3365     /**
3366      * Callback for each slice.
3367      *
3368      * Meaningful slice information (codec specific) is guaranteed to
3369      * be parsed at this point. This function is mandatory.
3370      *
3371      * @param avctx the codec context
3372      * @param buf the slice data buffer base
3373      * @param buf_size the size of the slice in bytes
3374      * @return zero if successful, a negative value otherwise
3375      */
3376     int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3377
3378     /**
3379      * Called at the end of each frame or field picture.
3380      *
3381      * The whole picture is parsed at this point and can now be sent
3382      * to the hardware accelerator. This function is mandatory.
3383      *
3384      * @param avctx the codec context
3385      * @return zero if successful, a negative value otherwise
3386      */
3387     int (*end_frame)(AVCodecContext *avctx);
3388
3389     /**
3390      * Size of HW accelerator private data.
3391      *
3392      * Private data is allocated with av_mallocz() before
3393      * AVCodecContext.get_buffer() and deallocated after
3394      * AVCodecContext.release_buffer().
3395      */
3396     int priv_data_size;
3397 } AVHWAccel;
3398
3399 /**
3400  * @defgroup lavc_picture AVPicture
3401  *
3402  * Functions for working with AVPicture
3403  * @{
3404  */
3405
3406 /**
3407  * four components are given, that's all.
3408  * the last component is alpha
3409  */
3410 typedef struct AVPicture {
3411     uint8_t *data[AV_NUM_DATA_POINTERS];
3412     int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
3413 } AVPicture;
3414
3415 /**
3416  * @}
3417  */
3418
3419 enum AVSubtitleType {
3420     SUBTITLE_NONE,
3421
3422     SUBTITLE_BITMAP,                ///< A bitmap, pict will be set
3423
3424     /**
3425      * Plain text, the text field must be set by the decoder and is
3426      * authoritative. ass and pict fields may contain approximations.
3427      */
3428     SUBTITLE_TEXT,
3429
3430     /**
3431      * Formatted text, the ass field must be set by the decoder and is
3432      * authoritative. pict and text fields may contain approximations.
3433      */
3434     SUBTITLE_ASS,
3435 };
3436
3437 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
3438
3439 typedef struct AVSubtitleRect {
3440     int x;         ///< top left corner  of pict, undefined when pict is not set
3441     int y;         ///< top left corner  of pict, undefined when pict is not set
3442     int w;         ///< width            of pict, undefined when pict is not set
3443     int h;         ///< height           of pict, undefined when pict is not set
3444     int nb_colors; ///< number of colors in pict, undefined when pict is not set
3445
3446     /**
3447      * data+linesize for the bitmap of this subtitle.
3448      * can be set for text/ass as well once they where rendered
3449      */
3450     AVPicture pict;
3451     enum AVSubtitleType type;
3452
3453     char *text;                     ///< 0 terminated plain UTF-8 text
3454
3455     /**
3456      * 0 terminated ASS/SSA compatible event line.
3457      * The presentation of this is unaffected by the other values in this
3458      * struct.
3459      */
3460     char *ass;
3461
3462     int flags;
3463 } AVSubtitleRect;
3464
3465 typedef struct AVSubtitle {
3466     uint16_t format; /* 0 = graphics */
3467     uint32_t start_display_time; /* relative to packet pts, in ms */
3468     uint32_t end_display_time; /* relative to packet pts, in ms */
3469     unsigned num_rects;
3470     AVSubtitleRect **rects;
3471     int64_t pts;    ///< Same as packet pts, in AV_TIME_BASE
3472 } AVSubtitle;
3473
3474 /**
3475  * If c is NULL, returns the first registered codec,
3476  * if c is non-NULL, returns the next registered codec after c,
3477  * or NULL if c is the last one.
3478  */
3479 AVCodec *av_codec_next(const AVCodec *c);
3480
3481 /**
3482  * Return the LIBAVCODEC_VERSION_INT constant.
3483  */
3484 unsigned avcodec_version(void);
3485
3486 /**
3487  * Return the libavcodec build-time configuration.
3488  */
3489 const char *avcodec_configuration(void);
3490
3491 /**
3492  * Return the libavcodec license.
3493  */
3494 const char *avcodec_license(void);
3495
3496 /**
3497  * Register the codec codec and initialize libavcodec.
3498  *
3499  * @warning either this function or avcodec_register_all() must be called
3500  * before any other libavcodec functions.
3501  *
3502  * @see avcodec_register_all()
3503  */
3504 void avcodec_register(AVCodec *codec);
3505
3506 /**
3507  * Register all the codecs, parsers and bitstream filters which were enabled at
3508  * configuration time. If you do not call this function you can select exactly
3509  * which formats you want to support, by using the individual registration
3510  * functions.
3511  *
3512  * @see avcodec_register
3513  * @see av_register_codec_parser
3514  * @see av_register_bitstream_filter
3515  */
3516 void avcodec_register_all(void);
3517
3518
3519 #if FF_API_ALLOC_CONTEXT
3520 /**
3521  * Allocate an AVCodecContext and set its fields to default values.  The
3522  * resulting struct can be deallocated by simply calling av_free().
3523  *
3524  * @return An AVCodecContext filled with default values or NULL on failure.
3525  * @see avcodec_get_context_defaults
3526  *
3527  * @deprecated use avcodec_alloc_context3()
3528  */
3529 attribute_deprecated
3530 AVCodecContext *avcodec_alloc_context(void);
3531
3532 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3533  *  we WILL change its arguments and name a few times! */
3534 attribute_deprecated
3535 AVCodecContext *avcodec_alloc_context2(enum AVMediaType);
3536
3537 /**
3538  * Set the fields of the given AVCodecContext to default values.
3539  *
3540  * @param s The AVCodecContext of which the fields should be set to default values.
3541  * @deprecated use avcodec_get_context_defaults3
3542  */
3543 attribute_deprecated
3544 void avcodec_get_context_defaults(AVCodecContext *s);
3545
3546 /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
3547  *  we WILL change its arguments and name a few times! */
3548 attribute_deprecated
3549 void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType);
3550 #endif
3551
3552 /**
3553  * Allocate an AVCodecContext and set its fields to default values.  The
3554  * resulting struct can be deallocated by calling avcodec_close() on it followed
3555  * by av_free().
3556  *
3557  * @param codec if non-NULL, allocate private data and initialize defaults
3558  *              for the given codec. It is illegal to then call avcodec_open2()
3559  *              with a different codec.
3560  *              If NULL, then the codec-specific defaults won't be initialized,
3561  *              which may result in suboptimal default settings (this is
3562  *              important mainly for encoders, e.g. libx264).
3563  *
3564  * @return An AVCodecContext filled with default values or NULL on failure.
3565  * @see avcodec_get_context_defaults
3566  */
3567 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
3568
3569 /**
3570  * Set the fields of the given AVCodecContext to default values corresponding
3571  * to the given codec (defaults may be codec-dependent).
3572  *
3573  * Do not call this function if a non-NULL codec has been passed
3574  * to avcodec_alloc_context3() that allocated this AVCodecContext.
3575  * If codec is non-NULL, it is illegal to call avcodec_open2() with a
3576  * different codec on this AVCodecContext.
3577  */
3578 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
3579
3580 /**
3581  * Get the AVClass for AVCodecContext. It can be used in combination with
3582  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3583  *
3584  * @see av_opt_find().
3585  */
3586 const AVClass *avcodec_get_class(void);
3587
3588 /**
3589  * Get the AVClass for AVFrame. It can be used in combination with
3590  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3591  *
3592  * @see av_opt_find().
3593  */
3594 const AVClass *avcodec_get_frame_class(void);
3595
3596 /**
3597  * Get the AVClass for AVSubtitleRect. It can be used in combination with
3598  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3599  *
3600  * @see av_opt_find().
3601  */
3602 const AVClass *avcodec_get_subtitle_rect_class(void);
3603
3604 /**
3605  * Copy the settings of the source AVCodecContext into the destination
3606  * AVCodecContext. The resulting destination codec context will be
3607  * unopened, i.e. you are required to call avcodec_open2() before you
3608  * can use this AVCodecContext to decode/encode video/audio data.
3609  *
3610  * @param dest target codec context, should be initialized with
3611  *             avcodec_alloc_context3(), but otherwise uninitialized
3612  * @param src source codec context
3613  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3614  */
3615 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3616
3617 /**
3618  * Allocate an AVFrame and set its fields to default values.  The resulting
3619  * struct must be freed using avcodec_free_frame().
3620  *
3621  * @return An AVFrame filled with default values or NULL on failure.
3622  * @see avcodec_get_frame_defaults
3623  */
3624 AVFrame *avcodec_alloc_frame(void);
3625
3626 /**
3627  * Set the fields of the given AVFrame to default values.
3628  *
3629  * @param frame The AVFrame of which the fields should be set to default values.
3630  */
3631 void avcodec_get_frame_defaults(AVFrame *frame);
3632
3633 /**
3634  * Free the frame and any dynamically allocated objects in it,
3635  * e.g. extended_data.
3636  *
3637  * @param frame frame to be freed. The pointer will be set to NULL.
3638  *
3639  * @warning this function does NOT free the data buffers themselves
3640  * (it does not know how, since they might have been allocated with
3641  *  a custom get_buffer()).
3642  */
3643 void avcodec_free_frame(AVFrame **frame);
3644
3645 #if FF_API_AVCODEC_OPEN
3646 /**
3647  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3648  * function the context has to be allocated.
3649  *
3650  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3651  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3652  * retrieving a codec.
3653  *
3654  * @warning This function is not thread safe!
3655  *
3656  * @code
3657  * avcodec_register_all();
3658  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3659  * if (!codec)
3660  *     exit(1);
3661  *
3662  * context = avcodec_alloc_context3(codec);
3663  *
3664  * if (avcodec_open(context, codec) < 0)
3665  *     exit(1);
3666  * @endcode
3667  *
3668  * @param avctx The context which will be set up to use the given codec.
3669  * @param codec The codec to use within the context.
3670  * @return zero on success, a negative value on error
3671  * @see avcodec_alloc_context3, avcodec_find_decoder, avcodec_find_encoder, avcodec_close
3672  *
3673  * @deprecated use avcodec_open2
3674  */
3675 attribute_deprecated
3676 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
3677 #endif
3678
3679 /**
3680  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3681  * function the context has to be allocated with avcodec_alloc_context3().
3682  *
3683  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3684  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3685  * retrieving a codec.
3686  *
3687  * @warning This function is not thread safe!
3688  *
3689  * @code
3690  * avcodec_register_all();
3691  * av_dict_set(&opts, "b", "2.5M", 0);
3692  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3693  * if (!codec)
3694  *     exit(1);
3695  *
3696  * context = avcodec_alloc_context3(codec);
3697  *
3698  * if (avcodec_open2(context, codec, opts) < 0)
3699  *     exit(1);
3700  * @endcode
3701  *
3702  * @param avctx The context to initialize.
3703  * @param codec The codec to open this context for. If a non-NULL codec has been
3704  *              previously passed to avcodec_alloc_context3() or
3705  *              avcodec_get_context_defaults3() for this context, then this
3706  *              parameter MUST be either NULL or equal to the previously passed
3707  *              codec.
3708  * @param options A dictionary filled with AVCodecContext and codec-private options.
3709  *                On return this object will be filled with options that were not found.
3710  *
3711  * @return zero on success, a negative value on error
3712  * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3713  *      av_dict_set(), av_opt_find().
3714  */
3715 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3716
3717 /**
3718  * Close a given AVCodecContext and free all the data associated with it
3719  * (but not the AVCodecContext itself).
3720  *
3721  * Calling this function on an AVCodecContext that hasn't been opened will free
3722  * the codec-specific data allocated in avcodec_alloc_context3() /
3723  * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
3724  * do nothing.
3725  */
3726 int avcodec_close(AVCodecContext *avctx);
3727
3728 /**
3729  * Free all allocated data in the given subtitle struct.
3730  *
3731  * @param sub AVSubtitle to free.
3732  */
3733 void avsubtitle_free(AVSubtitle *sub);
3734
3735 /**
3736  * @}
3737  */
3738
3739 /**
3740  * @addtogroup lavc_packet
3741  * @{
3742  */
3743
3744 /**
3745  * Default packet destructor.
3746  */
3747 void av_destruct_packet(AVPacket *pkt);
3748
3749 /**
3750  * Initialize optional fields of a packet with default values.
3751  *
3752  * Note, this does not touch the data and size members, which have to be
3753  * initialized separately.
3754  *
3755  * @param pkt packet
3756  */
3757 void av_init_packet(AVPacket *pkt);
3758
3759 /**
3760  * Allocate the payload of a packet and initialize its fields with
3761  * default values.
3762  *
3763  * @param pkt packet
3764  * @param size wanted payload size
3765  * @return 0 if OK, AVERROR_xxx otherwise
3766  */
3767 int av_new_packet(AVPacket *pkt, int size);
3768
3769 /**
3770  * Reduce packet size, correctly zeroing padding
3771  *
3772  * @param pkt packet
3773  * @param size new size
3774  */
3775 void av_shrink_packet(AVPacket *pkt, int size);
3776
3777 /**
3778  * Increase packet size, correctly zeroing padding
3779  *
3780  * @param pkt packet
3781  * @param grow_by number of bytes by which to increase the size of the packet
3782  */
3783 int av_grow_packet(AVPacket *pkt, int grow_by);
3784
3785 /**
3786  * @warning This is a hack - the packet memory allocation stuff is broken. The
3787  * packet is allocated if it was not really allocated.
3788  */
3789 int av_dup_packet(AVPacket *pkt);
3790
3791 /**
3792  * Copy packet, including contents
3793  *
3794  * @return 0 on success, negative AVERROR on fail
3795  */
3796 int av_copy_packet(AVPacket *dst, AVPacket *src);
3797
3798 /**
3799  * Free a packet.
3800  *
3801  * @param pkt packet to free
3802  */
3803 void av_free_packet(AVPacket *pkt);
3804
3805 /**
3806  * Allocate new information of a packet.
3807  *
3808  * @param pkt packet
3809  * @param type side information type
3810  * @param size side information size
3811  * @return pointer to fresh allocated data or NULL otherwise
3812  */
3813 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3814                                  int size);
3815
3816 /**
3817  * Shrink the already allocated side data buffer
3818  *
3819  * @param pkt packet
3820  * @param type side information type
3821  * @param size new side information size
3822  * @return 0 on success, < 0 on failure
3823  */
3824 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3825                                int size);
3826
3827 /**
3828  * Get side information from packet.
3829  *
3830  * @param pkt packet
3831  * @param type desired side information type
3832  * @param size pointer for side information size to store (optional)
3833  * @return pointer to data if present or NULL otherwise
3834  */
3835 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3836                                  int *size);
3837
3838 int av_packet_merge_side_data(AVPacket *pkt);
3839
3840 int av_packet_split_side_data(AVPacket *pkt);
3841
3842
3843 /**
3844  * @}
3845  */
3846
3847 /**
3848  * @addtogroup lavc_decoding
3849  * @{
3850  */
3851
3852 /**
3853  * Find a registered decoder with a matching codec ID.
3854  *
3855  * @param id AVCodecID of the requested decoder
3856  * @return A decoder if one was found, NULL otherwise.
3857  */
3858 AVCodec *avcodec_find_decoder(enum AVCodecID id);
3859
3860 /**
3861  * Find a registered decoder with the specified name.
3862  *
3863  * @param name name of the requested decoder
3864  * @return A decoder if one was found, NULL otherwise.
3865  */
3866 AVCodec *avcodec_find_decoder_by_name(const char *name);
3867
3868 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3869 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3870 int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3871
3872 /**
3873  * Return the amount of padding in pixels which the get_buffer callback must
3874  * provide around the edge of the image for codecs which do not have the
3875  * CODEC_FLAG_EMU_EDGE flag.
3876  *
3877  * @return Required padding in pixels.
3878  */
3879 unsigned avcodec_get_edge_width(void);
3880
3881 /**
3882  * Modify width and height values so that they will result in a memory
3883  * buffer that is acceptable for the codec if you do not use any horizontal
3884  * padding.
3885  *
3886  * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3887  * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3888  * according to avcodec_get_edge_width() before.
3889  */
3890 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3891
3892 /**
3893  * Modify width and height values so that they will result in a memory
3894  * buffer that is acceptable for the codec if you also ensure that all
3895  * line sizes are a multiple of the respective linesize_align[i].
3896  *
3897  * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3898  * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3899  * according to avcodec_get_edge_width() before.
3900  */
3901 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3902                                int linesize_align[AV_NUM_DATA_POINTERS]);
3903
3904 #if FF_API_OLD_DECODE_AUDIO
3905 /**
3906  * Wrapper function which calls avcodec_decode_audio4.
3907  *
3908  * @deprecated Use avcodec_decode_audio4 instead.
3909  *
3910  * Decode the audio frame of size avpkt->size from avpkt->data into samples.
3911  * Some decoders may support multiple frames in a single AVPacket, such
3912  * decoders would then just decode the first frame. In this case,
3913  * avcodec_decode_audio3 has to be called again with an AVPacket that contains
3914  * the remaining data in order to decode the second frame etc.
3915  * If no frame
3916  * could be outputted, frame_size_ptr is zero. Otherwise, it is the
3917  * decompressed frame size in bytes.
3918  *
3919  * @warning You must set frame_size_ptr to the allocated size of the
3920  * output buffer before calling avcodec_decode_audio3().
3921  *
3922  * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3923  * the actual read bytes because some optimized bitstream readers read 32 or 64
3924  * bits at once and could read over the end.
3925  *
3926  * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that
3927  * no overreading happens for damaged MPEG streams.
3928  *
3929  * @warning You must not provide a custom get_buffer() when using
3930  * avcodec_decode_audio3().  Doing so will override it with
3931  * avcodec_default_get_buffer.  Use avcodec_decode_audio4() instead,
3932  * which does allow the application to provide a custom get_buffer().
3933  *
3934  * @note You might have to align the input buffer avpkt->data and output buffer
3935  * samples. The alignment requirements depend on the CPU: On some CPUs it isn't
3936  * necessary at all, on others it won't work at all if not aligned and on others
3937  * it will work but it will have an impact on performance.
3938  *
3939  * In practice, avpkt->data should have 4 byte alignment at minimum and
3940  * samples should be 16 byte aligned unless the CPU doesn't need it
3941  * (AltiVec and SSE do).
3942  *
3943  * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3944  * between input and output, these need to be fed with avpkt->data=NULL,
3945  * avpkt->size=0 at the end to return the remaining frames.
3946  *
3947  * @param avctx the codec context
3948  * @param[out] samples the output buffer, sample type in avctx->sample_fmt
3949  *                     If the sample format is planar, each channel plane will
3950  *                     be the same size, with no padding between channels.
3951  * @param[in,out] frame_size_ptr the output buffer size in bytes
3952  * @param[in] avpkt The input AVPacket containing the input buffer.
3953  *            You can create such packet with av_init_packet() and by then setting
3954  *            data and size, some decoders might in addition need other fields.
3955  *            All decoders are designed to use the least fields possible though.
3956  * @return On error a negative value is returned, otherwise the number of bytes
3957  * used or zero if no frame data was decompressed (used) from the input AVPacket.
3958  */
3959 attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
3960                          int *frame_size_ptr,
3961                          AVPacket *avpkt);
3962 #endif
3963
3964 /**
3965  * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3966  *
3967  * Some decoders may support multiple frames in a single AVPacket. Such
3968  * decoders would then just decode the first frame. In this case,
3969  * avcodec_decode_audio4 has to be called again with an AVPacket containing
3970  * the remaining data in order to decode the second frame, etc...
3971  * Even if no frames are returned, the packet needs to be fed to the decoder
3972  * with remaining data until it is completely consumed or an error occurs.
3973  *
3974  * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3975  *          larger than the actual read bytes because some optimized bitstream
3976  *          readers read 32 or 64 bits at once and could read over the end.
3977  *
3978  * @note You might have to align the input buffer. The alignment requirements
3979  *       depend on the CPU and the decoder.
3980  *
3981  * @param      avctx the codec context
3982  * @param[out] frame The AVFrame in which to store decoded audio samples.
3983  *                   Decoders request a buffer of a particular size by setting
3984  *                   AVFrame.nb_samples prior to calling get_buffer(). The
3985  *                   decoder may, however, only utilize part of the buffer by
3986  *                   setting AVFrame.nb_samples to a smaller value in the
3987  *                   output frame.
3988  * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3989  *                           non-zero.
3990  * @param[in]  avpkt The input AVPacket containing the input buffer.
3991  *                   At least avpkt->data and avpkt->size should be set. Some
3992  *                   decoders might also require additional fields to be set.
3993  * @return A negative error code is returned if an error occurred during
3994  *         decoding, otherwise the number of bytes consumed from the input
3995  *         AVPacket is returned.
3996  */
3997 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3998                           int *got_frame_ptr, const AVPacket *avpkt);
3999
4000 /**
4001  * Decode the video frame of size avpkt->size from avpkt->data into picture.
4002  * Some decoders may support multiple frames in a single AVPacket, such
4003  * decoders would then just decode the first frame.
4004  *
4005  * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
4006  * the actual read bytes because some optimized bitstream readers read 32 or 64
4007  * bits at once and could read over the end.
4008  *
4009  * @warning The end of the input buffer buf should be set to 0 to ensure that
4010  * no overreading happens for damaged MPEG streams.
4011  *
4012  * @note You might have to align the input buffer avpkt->data.
4013  * The alignment requirements depend on the CPU: on some CPUs it isn't
4014  * necessary at all, on others it won't work at all if not aligned and on others
4015  * it will work but it will have an impact on performance.
4016  *
4017  * In practice, avpkt->data should have 4 byte alignment at minimum.
4018  *
4019  * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
4020  * between input and output, these need to be fed with avpkt->data=NULL,
4021  * avpkt->size=0 at the end to return the remaining frames.
4022  *
4023  * @param avctx the codec context
4024  * @param[out] picture The AVFrame in which the decoded video frame will be stored.
4025  *             Use avcodec_alloc_frame to get an AVFrame, the codec will
4026  *             allocate memory for the actual bitmap.
4027  *             with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit.
4028  *             with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder
4029  *                   decodes and the decoder tells the user once it does not need the data anymore,
4030  *                   the user app can at this point free/reuse/keep the memory as it sees fit.
4031  *
4032  * @param[in] avpkt The input AVpacket containing the input buffer.
4033  *            You can create such packet with av_init_packet() and by then setting
4034  *            data and size, some decoders might in addition need other fields like
4035  *            flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
4036  *            fields possible.
4037  * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
4038  * @return On error a negative value is returned, otherwise the number of bytes
4039  * used or zero if no frame could be decompressed.
4040  */
4041 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
4042                          int *got_picture_ptr,
4043                          const AVPacket *avpkt);
4044
4045 /**
4046  * Decode a subtitle message.
4047  * Return a negative value on error, otherwise return the number of bytes used.
4048  * If no subtitle could be decompressed, got_sub_ptr is zero.
4049  * Otherwise, the subtitle is stored in *sub.
4050  * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
4051  * simplicity, because the performance difference is expect to be negligible
4052  * and reusing a get_buffer written for video codecs would probably perform badly
4053  * due to a potentially very different allocation pattern.
4054  *
4055  * @param avctx the codec context
4056  * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
4057                    freed with avsubtitle_free if *got_sub_ptr is set.
4058  * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
4059  * @param[in] avpkt The input AVPacket containing the input buffer.
4060  */
4061 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
4062                             int *got_sub_ptr,
4063                             AVPacket *avpkt);
4064
4065 /**
4066  * @defgroup lavc_parsing Frame parsing
4067  * @{
4068  */
4069
4070 typedef struct AVCodecParserContext {
4071     void *priv_data;
4072     struct AVCodecParser *parser;
4073     int64_t frame_offset; /* offset of the current frame */
4074     int64_t cur_offset; /* current offset
4075                            (incremented by each av_parser_parse()) */
4076     int64_t next_frame_offset; /* offset of the next frame */
4077     /* video info */
4078     int pict_type; /* XXX: Put it back in AVCodecContext. */
4079     /**
4080      * This field is used for proper frame duration computation in lavf.
4081      * It signals, how much longer the frame duration of the current frame
4082      * is compared to normal frame duration.
4083      *
4084      * frame_duration = (1 + repeat_pict) * time_base
4085      *
4086      * It is used by codecs like H.264 to display telecined material.
4087      */
4088     int repeat_pict; /* XXX: Put it back in AVCodecContext. */
4089     int64_t pts;     /* pts of the current frame */
4090     int64_t dts;     /* dts of the current frame */
4091
4092     /* private data */
4093     int64_t last_pts;
4094     int64_t last_dts;
4095     int fetch_timestamp;
4096
4097 #define AV_PARSER_PTS_NB 4
4098     int cur_frame_start_index;
4099     int64_t cur_frame_offset[AV_PARSER_PTS_NB];
4100     int64_t cur_frame_pts[AV_PARSER_PTS_NB];
4101     int64_t cur_frame_dts[AV_PARSER_PTS_NB];
4102
4103     int flags;
4104 #define PARSER_FLAG_COMPLETE_FRAMES           0x0001
4105 #define PARSER_FLAG_ONCE                      0x0002
4106 /// Set if the parser has a valid file offset
4107 #define PARSER_FLAG_FETCHED_OFFSET            0x0004
4108 #define PARSER_FLAG_USE_CODEC_TS              0x1000
4109
4110     int64_t offset;      ///< byte offset from starting packet start
4111     int64_t cur_frame_end[AV_PARSER_PTS_NB];
4112
4113     /**
4114      * Set by parser to 1 for key frames and 0 for non-key frames.
4115      * It is initialized to -1, so if the parser doesn't set this flag,
4116      * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
4117      * will be used.
4118      */
4119     int key_frame;
4120
4121     /**
4122      * Time difference in stream time base units from the pts of this
4123      * packet to the point at which the output from the decoder has converged
4124      * independent from the availability of previous frames. That is, the
4125      * frames are virtually identical no matter if decoding started from
4126      * the very first frame or from this keyframe.
4127      * Is AV_NOPTS_VALUE if unknown.
4128      * This field is not the display duration of the current frame.
4129      * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
4130      * set.
4131      *
4132      * The purpose of this field is to allow seeking in streams that have no
4133      * keyframes in the conventional sense. It corresponds to the
4134      * recovery point SEI in H.264 and match_time_delta in NUT. It is also
4135      * essential for some types of subtitle streams to ensure that all
4136      * subtitles are correctly displayed after seeking.
4137      */
4138     int64_t convergence_duration;
4139
4140     // Timestamp generation support:
4141     /**
4142      * Synchronization point for start of timestamp generation.
4143      *
4144      * Set to >0 for sync point, 0 for no sync point and <0 for undefined
4145      * (default).
4146      *
4147      * For example, this corresponds to presence of H.264 buffering period
4148      * SEI message.
4149      */
4150     int dts_sync_point;
4151
4152     /**
4153      * Offset of the current timestamp against last timestamp sync point in
4154      * units of AVCodecContext.time_base.
4155      *
4156      * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4157      * contain a valid timestamp offset.
4158      *
4159      * Note that the timestamp of sync point has usually a nonzero
4160      * dts_ref_dts_delta, which refers to the previous sync point. Offset of
4161      * the next frame after timestamp sync point will be usually 1.
4162      *
4163      * For example, this corresponds to H.264 cpb_removal_delay.
4164      */
4165     int dts_ref_dts_delta;
4166
4167     /**
4168      * Presentation delay of current frame in units of AVCodecContext.time_base.
4169      *
4170      * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4171      * contain valid non-negative timestamp delta (presentation time of a frame
4172      * must not lie in the past).
4173      *
4174      * This delay represents the difference between decoding and presentation
4175      * time of the frame.
4176      *
4177      * For example, this corresponds to H.264 dpb_output_delay.
4178      */
4179     int pts_dts_delta;
4180
4181     /**
4182      * Position of the packet in file.
4183      *
4184      * Analogous to cur_frame_pts/dts
4185      */
4186     int64_t cur_frame_pos[AV_PARSER_PTS_NB];
4187
4188     /**
4189      * Byte position of currently parsed frame in stream.
4190      */
4191     int64_t pos;
4192
4193     /**
4194      * Previous frame byte position.
4195      */
4196     int64_t last_pos;
4197
4198     /**
4199      * Duration of the current frame.
4200      * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4201      * For all other types, this is in units of AVCodecContext.time_base.
4202      */
4203     int duration;
4204 } AVCodecParserContext;
4205
4206 typedef struct AVCodecParser {
4207     int codec_ids[5]; /* several codec IDs are permitted */
4208     int priv_data_size;
4209     int (*parser_init)(AVCodecParserContext *s);
4210     int (*parser_parse)(AVCodecParserContext *s,
4211                         AVCodecContext *avctx,
4212                         const uint8_t **poutbuf, int *poutbuf_size,
4213                         const uint8_t *buf, int buf_size);
4214     void (*parser_close)(AVCodecParserContext *s);
4215     int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
4216     struct AVCodecParser *next;
4217 } AVCodecParser;
4218
4219 AVCodecParser *av_parser_next(AVCodecParser *c);
4220
4221 void av_register_codec_parser(AVCodecParser *parser);
4222 AVCodecParserContext *av_parser_init(int codec_id);
4223
4224 /**
4225  * Parse a packet.
4226  *
4227  * @param s             parser context.
4228  * @param avctx         codec context.
4229  * @param poutbuf       set to pointer to parsed buffer or NULL if not yet finished.
4230  * @param poutbuf_size  set to size of parsed buffer or zero if not yet finished.
4231  * @param buf           input buffer.
4232  * @param buf_size      input length, to signal EOF, this should be 0 (so that the last frame can be output).
4233  * @param pts           input presentation timestamp.
4234  * @param dts           input decoding timestamp.
4235  * @param pos           input byte position in stream.
4236  * @return the number of bytes of the input bitstream used.
4237  *
4238  * Example:
4239  * @code
4240  *   while(in_len){
4241  *       len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
4242  *                                        in_data, in_len,
4243  *                                        pts, dts, pos);
4244  *       in_data += len;
4245  *       in_len  -= len;
4246  *
4247  *       if(size)
4248  *          decode_frame(data, size);
4249  *   }
4250  * @endcode
4251  */
4252 int av_parser_parse2(AVCodecParserContext *s,
4253                      AVCodecContext *avctx,
4254                      uint8_t **poutbuf, int *poutbuf_size,
4255                      const uint8_t *buf, int buf_size,
4256                      int64_t pts, int64_t dts,
4257                      int64_t pos);
4258
4259 /**
4260  * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
4261  * @deprecated use AVBitstreamFilter
4262  */
4263 int av_parser_change(AVCodecParserContext *s,
4264                      AVCodecContext *avctx,
4265                      uint8_t **poutbuf, int *poutbuf_size,
4266                      const uint8_t *buf, int buf_size, int keyframe);
4267 void av_parser_close(AVCodecParserContext *s);
4268
4269 /**
4270  * @}
4271  * @}
4272  */
4273
4274 /**
4275  * @addtogroup lavc_encoding
4276  * @{
4277  */
4278
4279 /**
4280  * Find a registered encoder with a matching codec ID.
4281  *
4282  * @param id AVCodecID of the requested encoder
4283  * @return An encoder if one was found, NULL otherwise.
4284  */
4285 AVCodec *avcodec_find_encoder(enum AVCodecID id);
4286
4287 /**
4288  * Find a registered encoder with the specified name.
4289  *
4290  * @param name name of the requested encoder
4291  * @return An encoder if one was found, NULL otherwise.
4292  */
4293 AVCodec *avcodec_find_encoder_by_name(const char *name);
4294
4295 #if FF_API_OLD_ENCODE_AUDIO
4296 /**
4297  * Encode an audio frame from samples into buf.
4298  *
4299  * @deprecated Use avcodec_encode_audio2 instead.
4300  *
4301  * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large.
4302  * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user
4303  * will know how much space is needed because it depends on the value passed
4304  * in buf_size as described below. In that case a lower value can be used.
4305  *
4306  * @param avctx the codec context
4307  * @param[out] buf the output buffer
4308  * @param[in] buf_size the output buffer size
4309  * @param[in] samples the input buffer containing the samples
4310  * The number of samples read from this buffer is frame_size*channels,
4311  * both of which are defined in avctx.
4312  * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of
4313  * samples read from samples is equal to:
4314  * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id))
4315  * This also implies that av_get_bits_per_sample() must not return 0 for these
4316  * codecs.
4317  * @return On error a negative value is returned, on success zero or the number
4318  * of bytes used to encode the data read from the input buffer.
4319  */
4320 int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx,
4321                                               uint8_t *buf, int buf_size,
4322                                               const short *samples);
4323 #endif
4324
4325 /**
4326  * Encode a frame of audio.
4327  *
4328  * Takes input samples from frame and writes the next output packet, if
4329  * available, to avpkt. The output packet does not necessarily contain data for
4330  * the most recent frame, as encoders can delay, split, and combine input frames
4331  * internally as needed.
4332  *
4333  * @param avctx     codec context
4334  * @param avpkt     output AVPacket.
4335  *                  The user can supply an output buffer by setting
4336  *                  avpkt->data and avpkt->size prior to calling the
4337  *                  function, but if the size of the user-provided data is not
4338  *                  large enough, encoding will fail. If avpkt->data and
4339  *                  avpkt->size are set, avpkt->destruct must also be set. All
4340  *                  other AVPacket fields will be reset by the encoder using
4341  *                  av_init_packet(). If avpkt->data is NULL, the encoder will
4342  *                  allocate it. The encoder will set avpkt->size to the size
4343  *                  of the output packet.
4344  *
4345  *                  If this function fails or produces no output, avpkt will be
4346  *                  freed using av_free_packet() (i.e. avpkt->destruct will be
4347  *                  called to free the user supplied buffer).
4348  * @param[in] frame AVFrame containing the raw audio data to be encoded.
4349  *                  May be NULL when flushing an encoder that has the
4350  *                  CODEC_CAP_DELAY capability set.
4351  *                  If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
4352  *                  can have any number of samples.
4353  *                  If it is not set, frame->nb_samples must be equal to
4354  *                  avctx->frame_size for all frames except the last.
4355  *                  The final frame may be smaller than avctx->frame_size.
4356  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4357  *                            output packet is non-empty, and to 0 if it is
4358  *                            empty. If the function returns an error, the
4359  *                            packet can be assumed to be invalid, and the
4360  *                            value of got_packet_ptr is undefined and should
4361  *                            not be used.
4362  * @return          0 on success, negative error code on failure
4363  */
4364 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
4365                           const AVFrame *frame, int *got_packet_ptr);
4366
4367 #if FF_API_OLD_ENCODE_VIDEO
4368 /**
4369  * @deprecated use avcodec_encode_video2() instead.
4370  *
4371  * Encode a video frame from pict into buf.
4372  * The input picture should be
4373  * stored using a specific format, namely avctx.pix_fmt.
4374  *
4375  * @param avctx the codec context
4376  * @param[out] buf the output buffer for the bitstream of encoded frame
4377  * @param[in] buf_size the size of the output buffer in bytes
4378  * @param[in] pict the input picture to encode
4379  * @return On error a negative value is returned, on success zero or the number
4380  * of bytes used from the output buffer.
4381  */
4382 attribute_deprecated
4383 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4384                          const AVFrame *pict);
4385 #endif
4386
4387 /**
4388  * Encode a frame of video.
4389  *
4390  * Takes input raw video data from frame and writes the next output packet, if
4391  * available, to avpkt. The output packet does not necessarily contain data for
4392  * the most recent frame, as encoders can delay and reorder input frames
4393  * internally as needed.
4394  *
4395  * @param avctx     codec context
4396  * @param avpkt     output AVPacket.
4397  *                  The user can supply an output buffer by setting
4398  *                  avpkt->data and avpkt->size prior to calling the
4399  *                  function, but if the size of the user-provided data is not
4400  *                  large enough, encoding will fail. All other AVPacket fields
4401  *                  will be reset by the encoder using av_init_packet(). If
4402  *                  avpkt->data is NULL, the encoder will allocate it.
4403  *                  The encoder will set avpkt->size to the size of the
4404  *                  output packet. The returned data (if any) belongs to the
4405  *                  caller, he is responsible for freeing it.
4406  *
4407  *                  If this function fails or produces no output, avpkt will be
4408  *                  freed using av_free_packet() (i.e. avpkt->destruct will be
4409  *                  called to free the user supplied buffer).
4410  * @param[in] frame AVFrame containing the raw video data to be encoded.
4411  *                  May be NULL when flushing an encoder that has the
4412  *                  CODEC_CAP_DELAY capability set.
4413  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
4414  *                            output packet is non-empty, and to 0 if it is
4415  *                            empty. If the function returns an error, the
4416  *                            packet can be assumed to be invalid, and the
4417  *                            value of got_packet_ptr is undefined and should
4418  *                            not be used.
4419  * @return          0 on success, negative error code on failure
4420  */
4421 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
4422                           const AVFrame *frame, int *got_packet_ptr);
4423
4424 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
4425                             const AVSubtitle *sub);
4426
4427
4428 /**
4429  * @}
4430  */
4431
4432 #if FF_API_AVCODEC_RESAMPLE
4433 /**
4434  * @defgroup lavc_resample Audio resampling
4435  * @ingroup libavc
4436  * @deprecated use libswresample instead
4437  *
4438  * @{
4439  */
4440 struct ReSampleContext;
4441 struct AVResampleContext;
4442
4443 typedef struct ReSampleContext ReSampleContext;
4444
4445 /**
4446  *  Initialize audio resampling context.
4447  *
4448  * @param output_channels  number of output channels
4449  * @param input_channels   number of input channels
4450  * @param output_rate      output sample rate
4451  * @param input_rate       input sample rate
4452  * @param sample_fmt_out   requested output sample format
4453  * @param sample_fmt_in    input sample format
4454  * @param filter_length    length of each FIR filter in the filterbank relative to the cutoff frequency
4455  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4456  * @param linear           if 1 then the used FIR filter will be linearly interpolated
4457                            between the 2 closest, if 0 the closest will be used
4458  * @param cutoff           cutoff frequency, 1.0 corresponds to half the output sampling rate
4459  * @return allocated ReSampleContext, NULL if error occurred
4460  */
4461 attribute_deprecated
4462 ReSampleContext *av_audio_resample_init(int output_channels, int input_channels,
4463                                         int output_rate, int input_rate,
4464                                         enum AVSampleFormat sample_fmt_out,
4465                                         enum AVSampleFormat sample_fmt_in,
4466                                         int filter_length, int log2_phase_count,
4467                                         int linear, double cutoff);
4468
4469 attribute_deprecated
4470 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
4471
4472 /**
4473  * Free resample context.
4474  *
4475  * @param s a non-NULL pointer to a resample context previously
4476  *          created with av_audio_resample_init()
4477  */
4478 attribute_deprecated
4479 void audio_resample_close(ReSampleContext *s);
4480
4481
4482 /**
4483  * Initialize an audio resampler.
4484  * Note, if either rate is not an integer then simply scale both rates up so they are.
4485  * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq
4486  * @param log2_phase_count log2 of the number of entries in the polyphase filterbank
4487  * @param linear If 1 then the used FIR filter will be linearly interpolated
4488                  between the 2 closest, if 0 the closest will be used
4489  * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate
4490  */
4491 attribute_deprecated
4492 struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
4493
4494 /**
4495  * Resample an array of samples using a previously configured context.
4496  * @param src an array of unconsumed samples
4497  * @param consumed the number of samples of src which have been consumed are returned here
4498  * @param src_size the number of unconsumed samples available
4499  * @param dst_size the amount of space in samples available in dst
4500  * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context.
4501  * @return the number of samples written in dst or -1 if an error occurred
4502  */
4503 attribute_deprecated
4504 int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
4505
4506
4507 /**
4508  * Compensate samplerate/timestamp drift. The compensation is done by changing
4509  * the resampler parameters, so no audible clicks or similar distortions occur
4510  * @param compensation_distance distance in output samples over which the compensation should be performed
4511  * @param sample_delta number of output samples which should be output less
4512  *
4513  * example: av_resample_compensate(c, 10, 500)
4514  * here instead of 510 samples only 500 samples would be output
4515  *
4516  * note, due to rounding the actual compensation might be slightly different,
4517  * especially if the compensation_distance is large and the in_rate used during init is small
4518  */
4519 attribute_deprecated
4520 void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
4521 attribute_deprecated
4522 void av_resample_close(struct AVResampleContext *c);
4523
4524 /**
4525  * @}
4526  */
4527 #endif
4528
4529 /**
4530  * @addtogroup lavc_picture
4531  * @{
4532  */
4533
4534 /**
4535  * Allocate memory for a picture.  Call avpicture_free() to free it.
4536  *
4537  * @see avpicture_fill()
4538  *
4539  * @param picture the picture to be filled in
4540  * @param pix_fmt the format of the picture
4541  * @param width the width of the picture
4542  * @param height the height of the picture
4543  * @return zero if successful, a negative value if not
4544  */
4545 int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
4546
4547 /**
4548  * Free a picture previously allocated by avpicture_alloc().
4549  * The data buffer used by the AVPicture is freed, but the AVPicture structure
4550  * itself is not.
4551  *
4552  * @param picture the AVPicture to be freed
4553  */
4554 void avpicture_free(AVPicture *picture);
4555
4556 /**
4557  * Fill in the AVPicture fields, always assume a linesize alignment of
4558  * 1.
4559  *
4560  * @see av_image_fill_arrays()
4561  */
4562 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
4563                    enum AVPixelFormat pix_fmt, int width, int height);
4564
4565 /**
4566  * Copy pixel data from an AVPicture into a buffer, always assume a
4567  * linesize alignment of 1.
4568  *
4569  * @see av_image_copy_to_buffer()
4570  */
4571 int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
4572                      int width, int height,
4573                      unsigned char *dest, int dest_size);
4574
4575 /**
4576  * Calculate the size in bytes that a picture of the given width and height
4577  * would occupy if stored in the given picture format.
4578  * Always assume a linesize alignment of 1.
4579  *
4580  * @see av_image_get_buffer_size().
4581  */
4582 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
4583
4584 /**
4585  *  deinterlace - if not supported return -1
4586  */
4587 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
4588                           enum AVPixelFormat pix_fmt, int width, int height);
4589 /**
4590  * Copy image src to dst. Wraps av_image_copy().
4591  */
4592 void av_picture_copy(AVPicture *dst, const AVPicture *src,
4593                      enum AVPixelFormat pix_fmt, int width, int height);
4594
4595 /**
4596  * Crop image top and left side.
4597  */
4598 int av_picture_crop(AVPicture *dst, const AVPicture *src,
4599                     enum AVPixelFormat pix_fmt, int top_band, int left_band);
4600
4601 /**
4602  * Pad image.
4603  */
4604 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
4605             int padtop, int padbottom, int padleft, int padright, int *color);
4606
4607 /**
4608  * @}
4609  */
4610
4611 /**
4612  * @defgroup lavc_misc Utility functions
4613  * @ingroup libavc
4614  *
4615  * Miscellaneous utility functions related to both encoding and decoding
4616  * (or neither).
4617  * @{
4618  */
4619
4620 /**
4621  * @defgroup lavc_misc_pixfmt Pixel formats
4622  *
4623  * Functions for working with pixel formats.
4624  * @{
4625  */
4626
4627 /**
4628  * Utility function to access log2_chroma_w log2_chroma_h from
4629  * the pixel format AVPixFmtDescriptor.
4630  *
4631  * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
4632  * for one that returns a failure code and continues in case of invalid
4633  * pix_fmts.
4634  *
4635  * @param[in]  pix_fmt the pixel format
4636  * @param[out] h_shift store log2_chroma_h
4637  * @param[out] v_shift store log2_chroma_w
4638  *
4639  * @see av_pix_fmt_get_chroma_sub_sample
4640  */
4641
4642 void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
4643
4644 /**
4645  * Return a value representing the fourCC code associated to the
4646  * pixel format pix_fmt, or 0 if no associated fourCC code can be
4647  * found.
4648  */
4649 unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
4650
4651 #define FF_LOSS_RESOLUTION  0x0001 /**< loss due to resolution change */
4652 #define FF_LOSS_DEPTH       0x0002 /**< loss due to color depth change */
4653 #define FF_LOSS_COLORSPACE  0x0004 /**< loss due to color space conversion */
4654 #define FF_LOSS_ALPHA       0x0008 /**< loss of alpha bits */
4655 #define FF_LOSS_COLORQUANT  0x0010 /**< loss due to color quantization */
4656 #define FF_LOSS_CHROMA      0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
4657
4658 /**
4659  * Compute what kind of losses will occur when converting from one specific
4660  * pixel format to another.
4661  * When converting from one pixel format to another, information loss may occur.
4662  * For example, when converting from RGB24 to GRAY, the color information will
4663  * be lost. Similarly, other losses occur when converting from some formats to
4664  * other formats. These losses can involve loss of chroma, but also loss of
4665  * resolution, loss of color depth, loss due to the color space conversion, loss
4666  * of the alpha bits or loss due to color quantization.
4667  * avcodec_get_fix_fmt_loss() informs you about the various types of losses
4668  * which will occur when converting from one pixel format to another.
4669  *
4670  * @param[in] dst_pix_fmt destination pixel format
4671  * @param[in] src_pix_fmt source pixel format
4672  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4673  * @return Combination of flags informing you what kind of losses will occur
4674  * (maximum loss for an invalid dst_pix_fmt).
4675  */
4676 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
4677                              int has_alpha);
4678
4679 #if FF_API_FIND_BEST_PIX_FMT
4680 /**
4681  * @deprecated use avcodec_find_best_pix_fmt_of_2() instead.
4682  *
4683  * Find the best pixel format to convert to given a certain source pixel
4684  * format.  When converting from one pixel format to another, information loss
4685  * may occur.  For example, when converting from RGB24 to GRAY, the color
4686  * information will be lost. Similarly, other losses occur when converting from
4687  * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
4688  * the given pixel formats should be used to suffer the least amount of loss.
4689  * The pixel formats from which it chooses one, are determined by the
4690  * pix_fmt_mask parameter.
4691  *
4692  * Note, only the first 64 pixel formats will fit in pix_fmt_mask.
4693  *
4694  * @code
4695  * src_pix_fmt = AV_PIX_FMT_YUV420P;
4696  * pix_fmt_mask = (1 << AV_PIX_FMT_YUV422P) | (1 << AV_PIX_FMT_RGB24);
4697  * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
4698  * @endcode
4699  *
4700  * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from
4701  * @param[in] src_pix_fmt source pixel format
4702  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4703  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4704  * @return The best pixel format to convert to or -1 if none was found.
4705  */
4706 attribute_deprecated
4707 enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt,
4708                               int has_alpha, int *loss_ptr);
4709 #endif /* FF_API_FIND_BEST_PIX_FMT */
4710
4711 /**
4712  * Find the best pixel format to convert to given a certain source pixel
4713  * format.  When converting from one pixel format to another, information loss
4714  * may occur.  For example, when converting from RGB24 to GRAY, the color
4715  * information will be lost. Similarly, other losses occur when converting from
4716  * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
4717  * the given pixel formats should be used to suffer the least amount of loss.
4718  * The pixel formats from which it chooses one, are determined by the
4719  * pix_fmt_list parameter.
4720  *
4721  *
4722  * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from
4723  * @param[in] src_pix_fmt source pixel format
4724  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4725  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
4726  * @return The best pixel format to convert to or -1 if none was found.
4727  */
4728 enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(enum AVPixelFormat *pix_fmt_list,
4729                                             enum AVPixelFormat src_pix_fmt,
4730                                             int has_alpha, int *loss_ptr);
4731
4732 /**
4733  * Find the best pixel format to convert to given a certain source pixel
4734  * format and a selection of two destination pixel formats. When converting from
4735  * one pixel format to another, information loss may occur.  For example, when converting
4736  * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
4737  * converting from some formats to other formats. avcodec_find_best_pix_fmt_of_2() selects which of
4738  * the given pixel formats should be used to suffer the least amount of loss.
4739  *
4740  * If one of the destination formats is AV_PIX_FMT_NONE the other pixel format (if valid) will be
4741  * returned.
4742  *
4743  * @code
4744  * src_pix_fmt = AV_PIX_FMT_YUV420P;
4745  * dst_pix_fmt1= AV_PIX_FMT_RGB24;
4746  * dst_pix_fmt2= AV_PIX_FMT_GRAY8;
4747  * dst_pix_fmt3= AV_PIX_FMT_RGB8;
4748  * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
4749  * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
4750  * dst_pix_fmt = avcodec_find_best_pix_fmt_of_2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
4751  * @endcode
4752  *
4753  * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
4754  * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
4755  * @param[in] src_pix_fmt Source pixel format
4756  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
4757  * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
4758  *                               NULL or value of zero means we care about all losses. Out: the loss
4759  *                               that occurs when converting from src to selected dst pixel format.
4760  * @return The best pixel format to convert to or -1 if none was found.
4761  */
4762 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
4763                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4764
4765 attribute_deprecated
4766 #if AV_HAVE_INCOMPATIBLE_FORK_ABI
4767 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list,
4768                                               enum AVPixelFormat src_pix_fmt,
4769                                               int has_alpha, int *loss_ptr);
4770 #else
4771 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
4772                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
4773 #endif
4774
4775
4776 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
4777
4778 /**
4779  * @}
4780  */
4781
4782 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
4783
4784 /**
4785  * Put a string representing the codec tag codec_tag in buf.
4786  *
4787  * @param buf_size size in bytes of buf
4788  * @return the length of the string that would have been generated if
4789  * enough space had been available, excluding the trailing null
4790  */
4791 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
4792
4793 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
4794
4795 /**
4796  * Return a name for the specified profile, if available.
4797  *
4798  * @param codec the codec that is searched for the given profile
4799  * @param profile the profile value for which a name is requested
4800  * @return A name for the profile if found, NULL otherwise.
4801  */
4802 const char *av_get_profile_name(const AVCodec *codec, int profile);
4803
4804 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
4805 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
4806 //FIXME func typedef
4807
4808 /**
4809  * Fill AVFrame audio data and linesize pointers.
4810  *
4811  * The buffer buf must be a preallocated buffer with a size big enough
4812  * to contain the specified samples amount. The filled AVFrame data
4813  * pointers will point to this buffer.
4814  *
4815  * AVFrame extended_data channel pointers are allocated if necessary for
4816  * planar audio.
4817  *
4818  * @param frame       the AVFrame
4819  *                    frame->nb_samples must be set prior to calling the
4820  *                    function. This function fills in frame->data,
4821  *                    frame->extended_data, frame->linesize[0].
4822  * @param nb_channels channel count
4823  * @param sample_fmt  sample format
4824  * @param buf         buffer to use for frame data
4825  * @param buf_size    size of buffer
4826  * @param align       plane size sample alignment (0 = default)
4827  * @return            >=0 on success, negative error code on failure
4828  * @todo return the size in bytes required to store the samples in
4829  * case of success, at the next libavutil bump
4830  */
4831 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
4832                              enum AVSampleFormat sample_fmt, const uint8_t *buf,
4833                              int buf_size, int align);
4834
4835 /**
4836  * Flush buffers, should be called when seeking or when switching to a different stream.
4837  */
4838 void avcodec_flush_buffers(AVCodecContext *avctx);
4839
4840 void avcodec_default_free_buffers(AVCodecContext *s);
4841
4842 /**
4843  * Return codec bits per sample.
4844  *
4845  * @param[in] codec_id the codec
4846  * @return Number of bits per sample or zero if unknown for the given codec.
4847  */
4848 int av_get_bits_per_sample(enum AVCodecID codec_id);
4849
4850 /**
4851  * Return the PCM codec associated with a sample format.
4852  * @param be  endianness, 0 for little, 1 for big,
4853  *            -1 (or anything else) for native
4854  * @return  AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
4855  */
4856 enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
4857
4858 /**
4859  * Return codec bits per sample.
4860  * Only return non-zero if the bits per sample is exactly correct, not an
4861  * approximation.
4862  *
4863  * @param[in] codec_id the codec
4864  * @return Number of bits per sample or zero if unknown for the given codec.
4865  */
4866 int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
4867
4868 /**
4869  * Return audio frame duration.
4870  *
4871  * @param avctx        codec context
4872  * @param frame_bytes  size of the frame, or 0 if unknown
4873  * @return             frame duration, in samples, if known. 0 if not able to
4874  *                     determine.
4875  */
4876 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
4877
4878
4879 typedef struct AVBitStreamFilterContext {
4880     void *priv_data;
4881     struct AVBitStreamFilter *filter;
4882     AVCodecParserContext *parser;
4883     struct AVBitStreamFilterContext *next;
4884 } AVBitStreamFilterContext;
4885
4886
4887 typedef struct AVBitStreamFilter {
4888     const char *name;
4889     int priv_data_size;
4890     int (*filter)(AVBitStreamFilterContext *bsfc,
4891                   AVCodecContext *avctx, const char *args,
4892                   uint8_t **poutbuf, int *poutbuf_size,
4893                   const uint8_t *buf, int buf_size, int keyframe);
4894     void (*close)(AVBitStreamFilterContext *bsfc);
4895     struct AVBitStreamFilter *next;
4896 } AVBitStreamFilter;
4897
4898 void av_register_bitstream_filter(AVBitStreamFilter *bsf);
4899 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
4900 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
4901                                AVCodecContext *avctx, const char *args,
4902                                uint8_t **poutbuf, int *poutbuf_size,
4903                                const uint8_t *buf, int buf_size, int keyframe);
4904 void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
4905
4906 AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
4907
4908 /* memory */
4909
4910 /**
4911  * Reallocate the given block if it is not large enough, otherwise do nothing.
4912  *
4913  * @see av_realloc
4914  */
4915 void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
4916
4917 /**
4918  * Allocate a buffer, reusing the given one if large enough.
4919  *
4920  * Contrary to av_fast_realloc the current buffer contents might not be
4921  * preserved and on error the old buffer is freed, thus no special
4922  * handling to avoid memleaks is necessary.
4923  *
4924  * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
4925  * @param size size of the buffer *ptr points to
4926  * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
4927  *                 *size 0 if an error occurred.
4928  */
4929 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
4930
4931 /**
4932  * Same behaviour av_fast_malloc but the buffer has additional
4933  * FF_INPUT_BUFFER_PADDING_SIZE at the end which will will always be 0.
4934  *
4935  * In addition the whole buffer will initially and after resizes
4936  * be 0-initialized so that no uninitialized data will ever appear.
4937  */
4938 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
4939
4940 /**
4941  * Same behaviour av_fast_padded_malloc except that buffer will always
4942  * be 0-initialized after call.
4943  */
4944 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
4945
4946 /**
4947  * Encode extradata length to a buffer. Used by xiph codecs.
4948  *
4949  * @param s buffer to write to; must be at least (v/255+1) bytes long
4950  * @param v size of extradata in bytes
4951  * @return number of bytes written to the buffer.
4952  */
4953 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
4954
4955 /**
4956  * Log a generic warning message about a missing feature. This function is
4957  * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4958  * only, and would normally not be used by applications.
4959  * @param[in] avc a pointer to an arbitrary struct of which the first field is
4960  * a pointer to an AVClass struct
4961  * @param[in] feature string containing the name of the missing feature
4962  * @param[in] want_sample indicates if samples are wanted which exhibit this feature.
4963  * If want_sample is non-zero, additional verbage will be added to the log
4964  * message which tells the user how to report samples to the development
4965  * mailing list.
4966  */
4967 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
4968
4969 /**
4970  * Log a generic warning message asking for a sample. This function is
4971  * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.)
4972  * only, and would normally not be used by applications.
4973  * @param[in] avc a pointer to an arbitrary struct of which the first field is
4974  * a pointer to an AVClass struct
4975  * @param[in] msg string containing an optional message, or NULL if no message
4976  */
4977 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
4978
4979 /**
4980  * Register the hardware accelerator hwaccel.
4981  */
4982 void av_register_hwaccel(AVHWAccel *hwaccel);
4983
4984 /**
4985  * If hwaccel is NULL, returns the first registered hardware accelerator,
4986  * if hwaccel is non-NULL, returns the next registered hardware accelerator
4987  * after hwaccel, or NULL if hwaccel is the last one.
4988  */
4989 AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
4990
4991
4992 /**
4993  * Lock operation used by lockmgr
4994  */
4995 enum AVLockOp {
4996   AV_LOCK_CREATE,  ///< Create a mutex
4997   AV_LOCK_OBTAIN,  ///< Lock the mutex
4998   AV_LOCK_RELEASE, ///< Unlock the mutex
4999   AV_LOCK_DESTROY, ///< Free mutex resources
5000 };
5001
5002 /**
5003  * Register a user provided lock manager supporting the operations
5004  * specified by AVLockOp. mutex points to a (void *) where the
5005  * lockmgr should store/get a pointer to a user allocated mutex. It's
5006  * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
5007  *
5008  * @param cb User defined callback. Note: FFmpeg may invoke calls to this
5009  *           callback during the call to av_lockmgr_register().
5010  *           Thus, the application must be prepared to handle that.
5011  *           If cb is set to NULL the lockmgr will be unregistered.
5012  *           Also note that during unregistration the previously registered
5013  *           lockmgr callback may also be invoked.
5014  */
5015 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
5016
5017 /**
5018  * Get the type of the given codec.
5019  */
5020 enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
5021
5022 /**
5023  * Get the name of a codec.
5024  * @return  a static string identifying the codec; never NULL
5025  */
5026 const char *avcodec_get_name(enum AVCodecID id);
5027
5028 /**
5029  * @return a positive value if s is open (i.e. avcodec_open2() was called on it
5030  * with no corresponding avcodec_close()), 0 otherwise.
5031  */
5032 int avcodec_is_open(AVCodecContext *s);
5033
5034 /**
5035  * @return a non-zero number if codec is an encoder, zero otherwise
5036  */
5037 int av_codec_is_encoder(const AVCodec *codec);
5038
5039 /**
5040  * @return a non-zero number if codec is a decoder, zero otherwise
5041  */
5042 int av_codec_is_decoder(const AVCodec *codec);
5043
5044 /**
5045  * @return descriptor for given codec ID or NULL if no descriptor exists.
5046  */
5047 const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
5048
5049 /**
5050  * Iterate over all codec descriptors known to libavcodec.
5051  *
5052  * @param prev previous descriptor. NULL to get the first descriptor.
5053  *
5054  * @return next descriptor or NULL after the last descriptor
5055  */
5056 const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
5057
5058 /**
5059  * @return codec descriptor with the given name or NULL if no such descriptor
5060  *         exists.
5061  */
5062 const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
5063
5064 /**
5065  * @}
5066  */
5067
5068 #endif /* AVCODEC_AVCODEC_H */