]> git.sesse.net Git - ffmpeg/blob - libavcodec/avcodec.h
avcodec: add decoder for Simon & Schuster Interactive's ADPCM variant
[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  * @ingroup libavc
27  * Libavcodec external API header
28  */
29
30 #include <errno.h>
31 #include "libavutil/samplefmt.h"
32 #include "libavutil/attributes.h"
33 #include "libavutil/avutil.h"
34 #include "libavutil/buffer.h"
35 #include "libavutil/cpu.h"
36 #include "libavutil/channel_layout.h"
37 #include "libavutil/dict.h"
38 #include "libavutil/frame.h"
39 #include "libavutil/hwcontext.h"
40 #include "libavutil/log.h"
41 #include "libavutil/pixfmt.h"
42 #include "libavutil/rational.h"
43
44 #include "version.h"
45
46 /**
47  * @defgroup libavc libavcodec
48  * Encoding/Decoding Library
49  *
50  * @{
51  *
52  * @defgroup lavc_decoding Decoding
53  * @{
54  * @}
55  *
56  * @defgroup lavc_encoding Encoding
57  * @{
58  * @}
59  *
60  * @defgroup lavc_codec Codecs
61  * @{
62  * @defgroup lavc_codec_native Native Codecs
63  * @{
64  * @}
65  * @defgroup lavc_codec_wrappers External library wrappers
66  * @{
67  * @}
68  * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
69  * @{
70  * @}
71  * @}
72  * @defgroup lavc_internal Internal
73  * @{
74  * @}
75  * @}
76  */
77
78 /**
79  * @ingroup libavc
80  * @defgroup lavc_encdec send/receive encoding and decoding API overview
81  * @{
82  *
83  * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/
84  * avcodec_receive_packet() functions provide an encode/decode API, which
85  * decouples input and output.
86  *
87  * The API is very similar for encoding/decoding and audio/video, and works as
88  * follows:
89  * - Set up and open the AVCodecContext as usual.
90  * - Send valid input:
91  *   - For decoding, call avcodec_send_packet() to give the decoder raw
92  *     compressed data in an AVPacket.
93  *   - For encoding, call avcodec_send_frame() to give the encoder an AVFrame
94  *     containing uncompressed audio or video.
95  *   In both cases, it is recommended that AVPackets and AVFrames are
96  *   refcounted, or libavcodec might have to copy the input data. (libavformat
97  *   always returns refcounted AVPackets, and av_frame_get_buffer() allocates
98  *   refcounted AVFrames.)
99  * - Receive output in a loop. Periodically call one of the avcodec_receive_*()
100  *   functions and process their output:
101  *   - For decoding, call avcodec_receive_frame(). On success, it will return
102  *     an AVFrame containing uncompressed audio or video data.
103  *   - For encoding, call avcodec_receive_packet(). On success, it will return
104  *     an AVPacket with a compressed frame.
105  *   Repeat this call until it returns AVERROR(EAGAIN) or an error. The
106  *   AVERROR(EAGAIN) return value means that new input data is required to
107  *   return new output. In this case, continue with sending input. For each
108  *   input frame/packet, the codec will typically return 1 output frame/packet,
109  *   but it can also be 0 or more than 1.
110  *
111  * At the beginning of decoding or encoding, the codec might accept multiple
112  * input frames/packets without returning a frame, until its internal buffers
113  * are filled. This situation is handled transparently if you follow the steps
114  * outlined above.
115  *
116  * In theory, sending input can result in EAGAIN - this should happen only if
117  * not all output was received. You can use this to structure alternative decode
118  * or encode loops other than the one suggested above. For example, you could
119  * try sending new input on each iteration, and try to receive output if that
120  * returns EAGAIN.
121  *
122  * End of stream situations. These require "flushing" (aka draining) the codec,
123  * as the codec might buffer multiple frames or packets internally for
124  * performance or out of necessity (consider B-frames).
125  * This is handled as follows:
126  * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)
127  *   or avcodec_send_frame() (encoding) functions. This will enter draining
128  *   mode.
129  * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()
130  *   (encoding) in a loop until AVERROR_EOF is returned. The functions will
131  *   not return AVERROR(EAGAIN), unless you forgot to enter draining mode.
132  * - Before decoding can be resumed again, the codec has to be reset with
133  *   avcodec_flush_buffers().
134  *
135  * Using the API as outlined above is highly recommended. But it is also
136  * possible to call functions outside of this rigid schema. For example, you can
137  * call avcodec_send_packet() repeatedly without calling
138  * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed
139  * until the codec's internal buffer has been filled up (which is typically of
140  * size 1 per output frame, after initial input), and then reject input with
141  * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to
142  * read at least some output.
143  *
144  * Not all codecs will follow a rigid and predictable dataflow; the only
145  * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on
146  * one end implies that a receive/send call on the other end will succeed, or
147  * at least will not fail with AVERROR(EAGAIN). In general, no codec will
148  * permit unlimited buffering of input or output.
149  *
150  * This API replaces the following legacy functions:
151  * - avcodec_decode_video2() and avcodec_decode_audio4():
152  *   Use avcodec_send_packet() to feed input to the decoder, then use
153  *   avcodec_receive_frame() to receive decoded frames after each packet.
154  *   Unlike with the old video decoding API, multiple frames might result from
155  *   a packet. For audio, splitting the input packet into frames by partially
156  *   decoding packets becomes transparent to the API user. You never need to
157  *   feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then
158  *   no data was read from the packet).
159  *   Additionally, sending a flush/draining packet is required only once.
160  * - avcodec_encode_video2()/avcodec_encode_audio2():
161  *   Use avcodec_send_frame() to feed input to the encoder, then use
162  *   avcodec_receive_packet() to receive encoded packets.
163  *   Providing user-allocated buffers for avcodec_receive_packet() is not
164  *   possible.
165  * - The new API does not handle subtitles yet.
166  *
167  * Mixing new and old function calls on the same AVCodecContext is not allowed,
168  * and will result in undefined behavior.
169  *
170  * Some codecs might require using the new API; using the old API will return
171  * an error when calling it. All codecs support the new API.
172  *
173  * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This
174  * would be an invalid state, which could put the codec user into an endless
175  * loop. The API has no concept of time either: it cannot happen that trying to
176  * do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second
177  * later accepts the packet (with no other receive/flush API calls involved).
178  * The API is a strict state machine, and the passage of time is not supposed
179  * to influence it. Some timing-dependent behavior might still be deemed
180  * acceptable in certain cases. But it must never result in both send/receive
181  * returning EAGAIN at the same time at any point. It must also absolutely be
182  * avoided that the current state is "unstable" and can "flip-flop" between
183  * the send/receive APIs allowing progress. For example, it's not allowed that
184  * the codec randomly decides that it actually wants to consume a packet now
185  * instead of returning a frame, after it just returned AVERROR(EAGAIN) on an
186  * avcodec_send_packet() call.
187  * @}
188  */
189
190 /**
191  * @defgroup lavc_core Core functions/structures.
192  * @ingroup libavc
193  *
194  * Basic definitions, functions for querying libavcodec capabilities,
195  * allocating core structures, etc.
196  * @{
197  */
198
199
200 /**
201  * Identify the syntax and semantics of the bitstream.
202  * The principle is roughly:
203  * Two decoders with the same ID can decode the same streams.
204  * Two encoders with the same ID can encode compatible streams.
205  * There may be slight deviations from the principle due to implementation
206  * details.
207  *
208  * If you add a codec ID to this list, add it so that
209  * 1. no value of an existing codec ID changes (that would break ABI),
210  * 2. it is as close as possible to similar codecs
211  *
212  * After adding new codec IDs, do not forget to add an entry to the codec
213  * descriptor list and bump libavcodec minor version.
214  */
215 enum AVCodecID {
216     AV_CODEC_ID_NONE,
217
218     /* video codecs */
219     AV_CODEC_ID_MPEG1VIDEO,
220     AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
221     AV_CODEC_ID_H261,
222     AV_CODEC_ID_H263,
223     AV_CODEC_ID_RV10,
224     AV_CODEC_ID_RV20,
225     AV_CODEC_ID_MJPEG,
226     AV_CODEC_ID_MJPEGB,
227     AV_CODEC_ID_LJPEG,
228     AV_CODEC_ID_SP5X,
229     AV_CODEC_ID_JPEGLS,
230     AV_CODEC_ID_MPEG4,
231     AV_CODEC_ID_RAWVIDEO,
232     AV_CODEC_ID_MSMPEG4V1,
233     AV_CODEC_ID_MSMPEG4V2,
234     AV_CODEC_ID_MSMPEG4V3,
235     AV_CODEC_ID_WMV1,
236     AV_CODEC_ID_WMV2,
237     AV_CODEC_ID_H263P,
238     AV_CODEC_ID_H263I,
239     AV_CODEC_ID_FLV1,
240     AV_CODEC_ID_SVQ1,
241     AV_CODEC_ID_SVQ3,
242     AV_CODEC_ID_DVVIDEO,
243     AV_CODEC_ID_HUFFYUV,
244     AV_CODEC_ID_CYUV,
245     AV_CODEC_ID_H264,
246     AV_CODEC_ID_INDEO3,
247     AV_CODEC_ID_VP3,
248     AV_CODEC_ID_THEORA,
249     AV_CODEC_ID_ASV1,
250     AV_CODEC_ID_ASV2,
251     AV_CODEC_ID_FFV1,
252     AV_CODEC_ID_4XM,
253     AV_CODEC_ID_VCR1,
254     AV_CODEC_ID_CLJR,
255     AV_CODEC_ID_MDEC,
256     AV_CODEC_ID_ROQ,
257     AV_CODEC_ID_INTERPLAY_VIDEO,
258     AV_CODEC_ID_XAN_WC3,
259     AV_CODEC_ID_XAN_WC4,
260     AV_CODEC_ID_RPZA,
261     AV_CODEC_ID_CINEPAK,
262     AV_CODEC_ID_WS_VQA,
263     AV_CODEC_ID_MSRLE,
264     AV_CODEC_ID_MSVIDEO1,
265     AV_CODEC_ID_IDCIN,
266     AV_CODEC_ID_8BPS,
267     AV_CODEC_ID_SMC,
268     AV_CODEC_ID_FLIC,
269     AV_CODEC_ID_TRUEMOTION1,
270     AV_CODEC_ID_VMDVIDEO,
271     AV_CODEC_ID_MSZH,
272     AV_CODEC_ID_ZLIB,
273     AV_CODEC_ID_QTRLE,
274     AV_CODEC_ID_TSCC,
275     AV_CODEC_ID_ULTI,
276     AV_CODEC_ID_QDRAW,
277     AV_CODEC_ID_VIXL,
278     AV_CODEC_ID_QPEG,
279     AV_CODEC_ID_PNG,
280     AV_CODEC_ID_PPM,
281     AV_CODEC_ID_PBM,
282     AV_CODEC_ID_PGM,
283     AV_CODEC_ID_PGMYUV,
284     AV_CODEC_ID_PAM,
285     AV_CODEC_ID_FFVHUFF,
286     AV_CODEC_ID_RV30,
287     AV_CODEC_ID_RV40,
288     AV_CODEC_ID_VC1,
289     AV_CODEC_ID_WMV3,
290     AV_CODEC_ID_LOCO,
291     AV_CODEC_ID_WNV1,
292     AV_CODEC_ID_AASC,
293     AV_CODEC_ID_INDEO2,
294     AV_CODEC_ID_FRAPS,
295     AV_CODEC_ID_TRUEMOTION2,
296     AV_CODEC_ID_BMP,
297     AV_CODEC_ID_CSCD,
298     AV_CODEC_ID_MMVIDEO,
299     AV_CODEC_ID_ZMBV,
300     AV_CODEC_ID_AVS,
301     AV_CODEC_ID_SMACKVIDEO,
302     AV_CODEC_ID_NUV,
303     AV_CODEC_ID_KMVC,
304     AV_CODEC_ID_FLASHSV,
305     AV_CODEC_ID_CAVS,
306     AV_CODEC_ID_JPEG2000,
307     AV_CODEC_ID_VMNC,
308     AV_CODEC_ID_VP5,
309     AV_CODEC_ID_VP6,
310     AV_CODEC_ID_VP6F,
311     AV_CODEC_ID_TARGA,
312     AV_CODEC_ID_DSICINVIDEO,
313     AV_CODEC_ID_TIERTEXSEQVIDEO,
314     AV_CODEC_ID_TIFF,
315     AV_CODEC_ID_GIF,
316     AV_CODEC_ID_DXA,
317     AV_CODEC_ID_DNXHD,
318     AV_CODEC_ID_THP,
319     AV_CODEC_ID_SGI,
320     AV_CODEC_ID_C93,
321     AV_CODEC_ID_BETHSOFTVID,
322     AV_CODEC_ID_PTX,
323     AV_CODEC_ID_TXD,
324     AV_CODEC_ID_VP6A,
325     AV_CODEC_ID_AMV,
326     AV_CODEC_ID_VB,
327     AV_CODEC_ID_PCX,
328     AV_CODEC_ID_SUNRAST,
329     AV_CODEC_ID_INDEO4,
330     AV_CODEC_ID_INDEO5,
331     AV_CODEC_ID_MIMIC,
332     AV_CODEC_ID_RL2,
333     AV_CODEC_ID_ESCAPE124,
334     AV_CODEC_ID_DIRAC,
335     AV_CODEC_ID_BFI,
336     AV_CODEC_ID_CMV,
337     AV_CODEC_ID_MOTIONPIXELS,
338     AV_CODEC_ID_TGV,
339     AV_CODEC_ID_TGQ,
340     AV_CODEC_ID_TQI,
341     AV_CODEC_ID_AURA,
342     AV_CODEC_ID_AURA2,
343     AV_CODEC_ID_V210X,
344     AV_CODEC_ID_TMV,
345     AV_CODEC_ID_V210,
346     AV_CODEC_ID_DPX,
347     AV_CODEC_ID_MAD,
348     AV_CODEC_ID_FRWU,
349     AV_CODEC_ID_FLASHSV2,
350     AV_CODEC_ID_CDGRAPHICS,
351     AV_CODEC_ID_R210,
352     AV_CODEC_ID_ANM,
353     AV_CODEC_ID_BINKVIDEO,
354     AV_CODEC_ID_IFF_ILBM,
355 #define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM
356     AV_CODEC_ID_KGV1,
357     AV_CODEC_ID_YOP,
358     AV_CODEC_ID_VP8,
359     AV_CODEC_ID_PICTOR,
360     AV_CODEC_ID_ANSI,
361     AV_CODEC_ID_A64_MULTI,
362     AV_CODEC_ID_A64_MULTI5,
363     AV_CODEC_ID_R10K,
364     AV_CODEC_ID_MXPEG,
365     AV_CODEC_ID_LAGARITH,
366     AV_CODEC_ID_PRORES,
367     AV_CODEC_ID_JV,
368     AV_CODEC_ID_DFA,
369     AV_CODEC_ID_WMV3IMAGE,
370     AV_CODEC_ID_VC1IMAGE,
371     AV_CODEC_ID_UTVIDEO,
372     AV_CODEC_ID_BMV_VIDEO,
373     AV_CODEC_ID_VBLE,
374     AV_CODEC_ID_DXTORY,
375     AV_CODEC_ID_V410,
376     AV_CODEC_ID_XWD,
377     AV_CODEC_ID_CDXL,
378     AV_CODEC_ID_XBM,
379     AV_CODEC_ID_ZEROCODEC,
380     AV_CODEC_ID_MSS1,
381     AV_CODEC_ID_MSA1,
382     AV_CODEC_ID_TSCC2,
383     AV_CODEC_ID_MTS2,
384     AV_CODEC_ID_CLLC,
385     AV_CODEC_ID_MSS2,
386     AV_CODEC_ID_VP9,
387     AV_CODEC_ID_AIC,
388     AV_CODEC_ID_ESCAPE130,
389     AV_CODEC_ID_G2M,
390     AV_CODEC_ID_WEBP,
391     AV_CODEC_ID_HNM4_VIDEO,
392     AV_CODEC_ID_HEVC,
393 #define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC
394     AV_CODEC_ID_FIC,
395     AV_CODEC_ID_ALIAS_PIX,
396     AV_CODEC_ID_BRENDER_PIX,
397     AV_CODEC_ID_PAF_VIDEO,
398     AV_CODEC_ID_EXR,
399     AV_CODEC_ID_VP7,
400     AV_CODEC_ID_SANM,
401     AV_CODEC_ID_SGIRLE,
402     AV_CODEC_ID_MVC1,
403     AV_CODEC_ID_MVC2,
404     AV_CODEC_ID_HQX,
405     AV_CODEC_ID_TDSC,
406     AV_CODEC_ID_HQ_HQA,
407     AV_CODEC_ID_HAP,
408     AV_CODEC_ID_DDS,
409     AV_CODEC_ID_DXV,
410     AV_CODEC_ID_SCREENPRESSO,
411     AV_CODEC_ID_RSCC,
412     AV_CODEC_ID_AVS2,
413
414     AV_CODEC_ID_Y41P = 0x8000,
415     AV_CODEC_ID_AVRP,
416     AV_CODEC_ID_012V,
417     AV_CODEC_ID_AVUI,
418     AV_CODEC_ID_AYUV,
419     AV_CODEC_ID_TARGA_Y216,
420     AV_CODEC_ID_V308,
421     AV_CODEC_ID_V408,
422     AV_CODEC_ID_YUV4,
423     AV_CODEC_ID_AVRN,
424     AV_CODEC_ID_CPIA,
425     AV_CODEC_ID_XFACE,
426     AV_CODEC_ID_SNOW,
427     AV_CODEC_ID_SMVJPEG,
428     AV_CODEC_ID_APNG,
429     AV_CODEC_ID_DAALA,
430     AV_CODEC_ID_CFHD,
431     AV_CODEC_ID_TRUEMOTION2RT,
432     AV_CODEC_ID_M101,
433     AV_CODEC_ID_MAGICYUV,
434     AV_CODEC_ID_SHEERVIDEO,
435     AV_CODEC_ID_YLC,
436     AV_CODEC_ID_PSD,
437     AV_CODEC_ID_PIXLET,
438     AV_CODEC_ID_SPEEDHQ,
439     AV_CODEC_ID_FMVC,
440     AV_CODEC_ID_SCPR,
441     AV_CODEC_ID_CLEARVIDEO,
442     AV_CODEC_ID_XPM,
443     AV_CODEC_ID_AV1,
444     AV_CODEC_ID_BITPACKED,
445     AV_CODEC_ID_MSCC,
446     AV_CODEC_ID_SRGC,
447     AV_CODEC_ID_SVG,
448     AV_CODEC_ID_GDV,
449     AV_CODEC_ID_FITS,
450     AV_CODEC_ID_IMM4,
451     AV_CODEC_ID_PROSUMER,
452     AV_CODEC_ID_MWSC,
453     AV_CODEC_ID_WCMV,
454     AV_CODEC_ID_RASC,
455     AV_CODEC_ID_HYMT,
456     AV_CODEC_ID_ARBC,
457     AV_CODEC_ID_AGM,
458     AV_CODEC_ID_LSCR,
459     AV_CODEC_ID_VP4,
460     AV_CODEC_ID_IMM5,
461     AV_CODEC_ID_MVDV,
462     AV_CODEC_ID_MVHA,
463
464     /* various PCM "codecs" */
465     AV_CODEC_ID_FIRST_AUDIO = 0x10000,     ///< A dummy id pointing at the start of audio codecs
466     AV_CODEC_ID_PCM_S16LE = 0x10000,
467     AV_CODEC_ID_PCM_S16BE,
468     AV_CODEC_ID_PCM_U16LE,
469     AV_CODEC_ID_PCM_U16BE,
470     AV_CODEC_ID_PCM_S8,
471     AV_CODEC_ID_PCM_U8,
472     AV_CODEC_ID_PCM_MULAW,
473     AV_CODEC_ID_PCM_ALAW,
474     AV_CODEC_ID_PCM_S32LE,
475     AV_CODEC_ID_PCM_S32BE,
476     AV_CODEC_ID_PCM_U32LE,
477     AV_CODEC_ID_PCM_U32BE,
478     AV_CODEC_ID_PCM_S24LE,
479     AV_CODEC_ID_PCM_S24BE,
480     AV_CODEC_ID_PCM_U24LE,
481     AV_CODEC_ID_PCM_U24BE,
482     AV_CODEC_ID_PCM_S24DAUD,
483     AV_CODEC_ID_PCM_ZORK,
484     AV_CODEC_ID_PCM_S16LE_PLANAR,
485     AV_CODEC_ID_PCM_DVD,
486     AV_CODEC_ID_PCM_F32BE,
487     AV_CODEC_ID_PCM_F32LE,
488     AV_CODEC_ID_PCM_F64BE,
489     AV_CODEC_ID_PCM_F64LE,
490     AV_CODEC_ID_PCM_BLURAY,
491     AV_CODEC_ID_PCM_LXF,
492     AV_CODEC_ID_S302M,
493     AV_CODEC_ID_PCM_S8_PLANAR,
494     AV_CODEC_ID_PCM_S24LE_PLANAR,
495     AV_CODEC_ID_PCM_S32LE_PLANAR,
496     AV_CODEC_ID_PCM_S16BE_PLANAR,
497
498     AV_CODEC_ID_PCM_S64LE = 0x10800,
499     AV_CODEC_ID_PCM_S64BE,
500     AV_CODEC_ID_PCM_F16LE,
501     AV_CODEC_ID_PCM_F24LE,
502     AV_CODEC_ID_PCM_VIDC,
503
504     /* various ADPCM codecs */
505     AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
506     AV_CODEC_ID_ADPCM_IMA_WAV,
507     AV_CODEC_ID_ADPCM_IMA_DK3,
508     AV_CODEC_ID_ADPCM_IMA_DK4,
509     AV_CODEC_ID_ADPCM_IMA_WS,
510     AV_CODEC_ID_ADPCM_IMA_SMJPEG,
511     AV_CODEC_ID_ADPCM_MS,
512     AV_CODEC_ID_ADPCM_4XM,
513     AV_CODEC_ID_ADPCM_XA,
514     AV_CODEC_ID_ADPCM_ADX,
515     AV_CODEC_ID_ADPCM_EA,
516     AV_CODEC_ID_ADPCM_G726,
517     AV_CODEC_ID_ADPCM_CT,
518     AV_CODEC_ID_ADPCM_SWF,
519     AV_CODEC_ID_ADPCM_YAMAHA,
520     AV_CODEC_ID_ADPCM_SBPRO_4,
521     AV_CODEC_ID_ADPCM_SBPRO_3,
522     AV_CODEC_ID_ADPCM_SBPRO_2,
523     AV_CODEC_ID_ADPCM_THP,
524     AV_CODEC_ID_ADPCM_IMA_AMV,
525     AV_CODEC_ID_ADPCM_EA_R1,
526     AV_CODEC_ID_ADPCM_EA_R3,
527     AV_CODEC_ID_ADPCM_EA_R2,
528     AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
529     AV_CODEC_ID_ADPCM_IMA_EA_EACS,
530     AV_CODEC_ID_ADPCM_EA_XAS,
531     AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
532     AV_CODEC_ID_ADPCM_IMA_ISS,
533     AV_CODEC_ID_ADPCM_G722,
534     AV_CODEC_ID_ADPCM_IMA_APC,
535     AV_CODEC_ID_ADPCM_VIMA,
536
537     AV_CODEC_ID_ADPCM_AFC = 0x11800,
538     AV_CODEC_ID_ADPCM_IMA_OKI,
539     AV_CODEC_ID_ADPCM_DTK,
540     AV_CODEC_ID_ADPCM_IMA_RAD,
541     AV_CODEC_ID_ADPCM_G726LE,
542     AV_CODEC_ID_ADPCM_THP_LE,
543     AV_CODEC_ID_ADPCM_PSX,
544     AV_CODEC_ID_ADPCM_AICA,
545     AV_CODEC_ID_ADPCM_IMA_DAT4,
546     AV_CODEC_ID_ADPCM_MTAF,
547     AV_CODEC_ID_ADPCM_AGM,
548     AV_CODEC_ID_ADPCM_ARGO,
549     AV_CODEC_ID_ADPCM_IMA_SSI,
550
551     /* AMR */
552     AV_CODEC_ID_AMR_NB = 0x12000,
553     AV_CODEC_ID_AMR_WB,
554
555     /* RealAudio codecs*/
556     AV_CODEC_ID_RA_144 = 0x13000,
557     AV_CODEC_ID_RA_288,
558
559     /* various DPCM codecs */
560     AV_CODEC_ID_ROQ_DPCM = 0x14000,
561     AV_CODEC_ID_INTERPLAY_DPCM,
562     AV_CODEC_ID_XAN_DPCM,
563     AV_CODEC_ID_SOL_DPCM,
564
565     AV_CODEC_ID_SDX2_DPCM = 0x14800,
566     AV_CODEC_ID_GREMLIN_DPCM,
567
568     /* audio codecs */
569     AV_CODEC_ID_MP2 = 0x15000,
570     AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
571     AV_CODEC_ID_AAC,
572     AV_CODEC_ID_AC3,
573     AV_CODEC_ID_DTS,
574     AV_CODEC_ID_VORBIS,
575     AV_CODEC_ID_DVAUDIO,
576     AV_CODEC_ID_WMAV1,
577     AV_CODEC_ID_WMAV2,
578     AV_CODEC_ID_MACE3,
579     AV_CODEC_ID_MACE6,
580     AV_CODEC_ID_VMDAUDIO,
581     AV_CODEC_ID_FLAC,
582     AV_CODEC_ID_MP3ADU,
583     AV_CODEC_ID_MP3ON4,
584     AV_CODEC_ID_SHORTEN,
585     AV_CODEC_ID_ALAC,
586     AV_CODEC_ID_WESTWOOD_SND1,
587     AV_CODEC_ID_GSM, ///< as in Berlin toast format
588     AV_CODEC_ID_QDM2,
589     AV_CODEC_ID_COOK,
590     AV_CODEC_ID_TRUESPEECH,
591     AV_CODEC_ID_TTA,
592     AV_CODEC_ID_SMACKAUDIO,
593     AV_CODEC_ID_QCELP,
594     AV_CODEC_ID_WAVPACK,
595     AV_CODEC_ID_DSICINAUDIO,
596     AV_CODEC_ID_IMC,
597     AV_CODEC_ID_MUSEPACK7,
598     AV_CODEC_ID_MLP,
599     AV_CODEC_ID_GSM_MS, /* as found in WAV */
600     AV_CODEC_ID_ATRAC3,
601     AV_CODEC_ID_APE,
602     AV_CODEC_ID_NELLYMOSER,
603     AV_CODEC_ID_MUSEPACK8,
604     AV_CODEC_ID_SPEEX,
605     AV_CODEC_ID_WMAVOICE,
606     AV_CODEC_ID_WMAPRO,
607     AV_CODEC_ID_WMALOSSLESS,
608     AV_CODEC_ID_ATRAC3P,
609     AV_CODEC_ID_EAC3,
610     AV_CODEC_ID_SIPR,
611     AV_CODEC_ID_MP1,
612     AV_CODEC_ID_TWINVQ,
613     AV_CODEC_ID_TRUEHD,
614     AV_CODEC_ID_MP4ALS,
615     AV_CODEC_ID_ATRAC1,
616     AV_CODEC_ID_BINKAUDIO_RDFT,
617     AV_CODEC_ID_BINKAUDIO_DCT,
618     AV_CODEC_ID_AAC_LATM,
619     AV_CODEC_ID_QDMC,
620     AV_CODEC_ID_CELT,
621     AV_CODEC_ID_G723_1,
622     AV_CODEC_ID_G729,
623     AV_CODEC_ID_8SVX_EXP,
624     AV_CODEC_ID_8SVX_FIB,
625     AV_CODEC_ID_BMV_AUDIO,
626     AV_CODEC_ID_RALF,
627     AV_CODEC_ID_IAC,
628     AV_CODEC_ID_ILBC,
629     AV_CODEC_ID_OPUS,
630     AV_CODEC_ID_COMFORT_NOISE,
631     AV_CODEC_ID_TAK,
632     AV_CODEC_ID_METASOUND,
633     AV_CODEC_ID_PAF_AUDIO,
634     AV_CODEC_ID_ON2AVC,
635     AV_CODEC_ID_DSS_SP,
636     AV_CODEC_ID_CODEC2,
637
638     AV_CODEC_ID_FFWAVESYNTH = 0x15800,
639     AV_CODEC_ID_SONIC,
640     AV_CODEC_ID_SONIC_LS,
641     AV_CODEC_ID_EVRC,
642     AV_CODEC_ID_SMV,
643     AV_CODEC_ID_DSD_LSBF,
644     AV_CODEC_ID_DSD_MSBF,
645     AV_CODEC_ID_DSD_LSBF_PLANAR,
646     AV_CODEC_ID_DSD_MSBF_PLANAR,
647     AV_CODEC_ID_4GV,
648     AV_CODEC_ID_INTERPLAY_ACM,
649     AV_CODEC_ID_XMA1,
650     AV_CODEC_ID_XMA2,
651     AV_CODEC_ID_DST,
652     AV_CODEC_ID_ATRAC3AL,
653     AV_CODEC_ID_ATRAC3PAL,
654     AV_CODEC_ID_DOLBY_E,
655     AV_CODEC_ID_APTX,
656     AV_CODEC_ID_APTX_HD,
657     AV_CODEC_ID_SBC,
658     AV_CODEC_ID_ATRAC9,
659     AV_CODEC_ID_HCOM,
660     AV_CODEC_ID_ACELP_KELVIN,
661     AV_CODEC_ID_MPEGH_3D_AUDIO,
662
663     /* subtitle codecs */
664     AV_CODEC_ID_FIRST_SUBTITLE = 0x17000,          ///< A dummy ID pointing at the start of subtitle codecs.
665     AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
666     AV_CODEC_ID_DVB_SUBTITLE,
667     AV_CODEC_ID_TEXT,  ///< raw UTF-8 text
668     AV_CODEC_ID_XSUB,
669     AV_CODEC_ID_SSA,
670     AV_CODEC_ID_MOV_TEXT,
671     AV_CODEC_ID_HDMV_PGS_SUBTITLE,
672     AV_CODEC_ID_DVB_TELETEXT,
673     AV_CODEC_ID_SRT,
674
675     AV_CODEC_ID_MICRODVD   = 0x17800,
676     AV_CODEC_ID_EIA_608,
677     AV_CODEC_ID_JACOSUB,
678     AV_CODEC_ID_SAMI,
679     AV_CODEC_ID_REALTEXT,
680     AV_CODEC_ID_STL,
681     AV_CODEC_ID_SUBVIEWER1,
682     AV_CODEC_ID_SUBVIEWER,
683     AV_CODEC_ID_SUBRIP,
684     AV_CODEC_ID_WEBVTT,
685     AV_CODEC_ID_MPL2,
686     AV_CODEC_ID_VPLAYER,
687     AV_CODEC_ID_PJS,
688     AV_CODEC_ID_ASS,
689     AV_CODEC_ID_HDMV_TEXT_SUBTITLE,
690     AV_CODEC_ID_TTML,
691     AV_CODEC_ID_ARIB_CAPTION,
692
693     /* other specific kind of codecs (generally used for attachments) */
694     AV_CODEC_ID_FIRST_UNKNOWN = 0x18000,           ///< A dummy ID pointing at the start of various fake codecs.
695     AV_CODEC_ID_TTF = 0x18000,
696
697     AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream.
698     AV_CODEC_ID_EPG,
699     AV_CODEC_ID_BINTEXT    = 0x18800,
700     AV_CODEC_ID_XBIN,
701     AV_CODEC_ID_IDF,
702     AV_CODEC_ID_OTF,
703     AV_CODEC_ID_SMPTE_KLV,
704     AV_CODEC_ID_DVD_NAV,
705     AV_CODEC_ID_TIMED_ID3,
706     AV_CODEC_ID_BIN_DATA,
707
708
709     AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
710
711     AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
712                                 * stream (only used by libavformat) */
713     AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
714                                 * stream (only used by libavformat) */
715     AV_CODEC_ID_FFMETADATA = 0x21000,   ///< Dummy codec for streams containing only metadata information.
716     AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
717 };
718
719 /**
720  * This struct describes the properties of a single codec described by an
721  * AVCodecID.
722  * @see avcodec_descriptor_get()
723  */
724 typedef struct AVCodecDescriptor {
725     enum AVCodecID     id;
726     enum AVMediaType type;
727     /**
728      * Name of the codec described by this descriptor. It is non-empty and
729      * unique for each codec descriptor. It should contain alphanumeric
730      * characters and '_' only.
731      */
732     const char      *name;
733     /**
734      * A more descriptive name for this codec. May be NULL.
735      */
736     const char *long_name;
737     /**
738      * Codec properties, a combination of AV_CODEC_PROP_* flags.
739      */
740     int             props;
741     /**
742      * MIME type(s) associated with the codec.
743      * May be NULL; if not, a NULL-terminated array of MIME types.
744      * The first item is always non-NULL and is the preferred MIME type.
745      */
746     const char *const *mime_types;
747     /**
748      * If non-NULL, an array of profiles recognized for this codec.
749      * Terminated with FF_PROFILE_UNKNOWN.
750      */
751     const struct AVProfile *profiles;
752 } AVCodecDescriptor;
753
754 /**
755  * Codec uses only intra compression.
756  * Video and audio codecs only.
757  */
758 #define AV_CODEC_PROP_INTRA_ONLY    (1 << 0)
759 /**
760  * Codec supports lossy compression. Audio and video codecs only.
761  * @note a codec may support both lossy and lossless
762  * compression modes
763  */
764 #define AV_CODEC_PROP_LOSSY         (1 << 1)
765 /**
766  * Codec supports lossless compression. Audio and video codecs only.
767  */
768 #define AV_CODEC_PROP_LOSSLESS      (1 << 2)
769 /**
770  * Codec supports frame reordering. That is, the coded order (the order in which
771  * the encoded packets are output by the encoders / stored / input to the
772  * decoders) may be different from the presentation order of the corresponding
773  * frames.
774  *
775  * For codecs that do not have this property set, PTS and DTS should always be
776  * equal.
777  */
778 #define AV_CODEC_PROP_REORDER       (1 << 3)
779 /**
780  * Subtitle codec is bitmap based
781  * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field.
782  */
783 #define AV_CODEC_PROP_BITMAP_SUB    (1 << 16)
784 /**
785  * Subtitle codec is text based.
786  * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field.
787  */
788 #define AV_CODEC_PROP_TEXT_SUB      (1 << 17)
789
790 /**
791  * @ingroup lavc_decoding
792  * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
793  * This is mainly needed because some optimized bitstream readers read
794  * 32 or 64 bit at once and could read over the end.<br>
795  * Note: If the first 23 bits of the additional bytes are not 0, then damaged
796  * MPEG bitstreams could cause overread and segfault.
797  */
798 #define AV_INPUT_BUFFER_PADDING_SIZE 64
799
800 /**
801  * @ingroup lavc_encoding
802  * minimum encoding buffer size
803  * Used to avoid some checks during header writing.
804  */
805 #define AV_INPUT_BUFFER_MIN_SIZE 16384
806
807 /**
808  * @ingroup lavc_decoding
809  */
810 enum AVDiscard{
811     /* We leave some space between them for extensions (drop some
812      * keyframes for intra-only or drop just some bidir frames). */
813     AVDISCARD_NONE    =-16, ///< discard nothing
814     AVDISCARD_DEFAULT =  0, ///< discard useless packets like 0 size packets in avi
815     AVDISCARD_NONREF  =  8, ///< discard all non reference
816     AVDISCARD_BIDIR   = 16, ///< discard all bidirectional frames
817     AVDISCARD_NONINTRA= 24, ///< discard all non intra frames
818     AVDISCARD_NONKEY  = 32, ///< discard all frames except keyframes
819     AVDISCARD_ALL     = 48, ///< discard all
820 };
821
822 enum AVAudioServiceType {
823     AV_AUDIO_SERVICE_TYPE_MAIN              = 0,
824     AV_AUDIO_SERVICE_TYPE_EFFECTS           = 1,
825     AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
826     AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED  = 3,
827     AV_AUDIO_SERVICE_TYPE_DIALOGUE          = 4,
828     AV_AUDIO_SERVICE_TYPE_COMMENTARY        = 5,
829     AV_AUDIO_SERVICE_TYPE_EMERGENCY         = 6,
830     AV_AUDIO_SERVICE_TYPE_VOICE_OVER        = 7,
831     AV_AUDIO_SERVICE_TYPE_KARAOKE           = 8,
832     AV_AUDIO_SERVICE_TYPE_NB                   , ///< Not part of ABI
833 };
834
835 /**
836  * @ingroup lavc_encoding
837  */
838 typedef struct RcOverride{
839     int start_frame;
840     int end_frame;
841     int qscale; // If this is 0 then quality_factor will be used instead.
842     float quality_factor;
843 } RcOverride;
844
845 /* encoding support
846    These flags can be passed in AVCodecContext.flags before initialization.
847    Note: Not everything is supported yet.
848 */
849
850 /**
851  * Allow decoders to produce frames with data planes that are not aligned
852  * to CPU requirements (e.g. due to cropping).
853  */
854 #define AV_CODEC_FLAG_UNALIGNED       (1 <<  0)
855 /**
856  * Use fixed qscale.
857  */
858 #define AV_CODEC_FLAG_QSCALE          (1 <<  1)
859 /**
860  * 4 MV per MB allowed / advanced prediction for H.263.
861  */
862 #define AV_CODEC_FLAG_4MV             (1 <<  2)
863 /**
864  * Output even those frames that might be corrupted.
865  */
866 #define AV_CODEC_FLAG_OUTPUT_CORRUPT  (1 <<  3)
867 /**
868  * Use qpel MC.
869  */
870 #define AV_CODEC_FLAG_QPEL            (1 <<  4)
871 /**
872  * Don't output frames whose parameters differ from first
873  * decoded frame in stream.
874  */
875 #define AV_CODEC_FLAG_DROPCHANGED     (1 <<  5)
876 /**
877  * Use internal 2pass ratecontrol in first pass mode.
878  */
879 #define AV_CODEC_FLAG_PASS1           (1 <<  9)
880 /**
881  * Use internal 2pass ratecontrol in second pass mode.
882  */
883 #define AV_CODEC_FLAG_PASS2           (1 << 10)
884 /**
885  * loop filter.
886  */
887 #define AV_CODEC_FLAG_LOOP_FILTER     (1 << 11)
888 /**
889  * Only decode/encode grayscale.
890  */
891 #define AV_CODEC_FLAG_GRAY            (1 << 13)
892 /**
893  * error[?] variables will be set during encoding.
894  */
895 #define AV_CODEC_FLAG_PSNR            (1 << 15)
896 /**
897  * Input bitstream might be truncated at a random location
898  * instead of only at frame boundaries.
899  */
900 #define AV_CODEC_FLAG_TRUNCATED       (1 << 16)
901 /**
902  * Use interlaced DCT.
903  */
904 #define AV_CODEC_FLAG_INTERLACED_DCT  (1 << 18)
905 /**
906  * Force low delay.
907  */
908 #define AV_CODEC_FLAG_LOW_DELAY       (1 << 19)
909 /**
910  * Place global headers in extradata instead of every keyframe.
911  */
912 #define AV_CODEC_FLAG_GLOBAL_HEADER   (1 << 22)
913 /**
914  * Use only bitexact stuff (except (I)DCT).
915  */
916 #define AV_CODEC_FLAG_BITEXACT        (1 << 23)
917 /* Fx : Flag for H.263+ extra options */
918 /**
919  * H.263 advanced intra coding / MPEG-4 AC prediction
920  */
921 #define AV_CODEC_FLAG_AC_PRED         (1 << 24)
922 /**
923  * interlaced motion estimation
924  */
925 #define AV_CODEC_FLAG_INTERLACED_ME   (1 << 29)
926 #define AV_CODEC_FLAG_CLOSED_GOP      (1U << 31)
927
928 /**
929  * Allow non spec compliant speedup tricks.
930  */
931 #define AV_CODEC_FLAG2_FAST           (1 <<  0)
932 /**
933  * Skip bitstream encoding.
934  */
935 #define AV_CODEC_FLAG2_NO_OUTPUT      (1 <<  2)
936 /**
937  * Place global headers at every keyframe instead of in extradata.
938  */
939 #define AV_CODEC_FLAG2_LOCAL_HEADER   (1 <<  3)
940
941 /**
942  * timecode is in drop frame format. DEPRECATED!!!!
943  */
944 #define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13)
945
946 /**
947  * Input bitstream might be truncated at a packet boundaries
948  * instead of only at frame boundaries.
949  */
950 #define AV_CODEC_FLAG2_CHUNKS         (1 << 15)
951 /**
952  * Discard cropping information from SPS.
953  */
954 #define AV_CODEC_FLAG2_IGNORE_CROP    (1 << 16)
955
956 /**
957  * Show all frames before the first keyframe
958  */
959 #define AV_CODEC_FLAG2_SHOW_ALL       (1 << 22)
960 /**
961  * Export motion vectors through frame side data
962  */
963 #define AV_CODEC_FLAG2_EXPORT_MVS     (1 << 28)
964 /**
965  * Do not skip samples and export skip information as frame side data
966  */
967 #define AV_CODEC_FLAG2_SKIP_MANUAL    (1 << 29)
968 /**
969  * Do not reset ASS ReadOrder field on flush (subtitles decoding)
970  */
971 #define AV_CODEC_FLAG2_RO_FLUSH_NOOP  (1 << 30)
972
973 /* Unsupported options :
974  *              Syntax Arithmetic coding (SAC)
975  *              Reference Picture Selection
976  *              Independent Segment Decoding */
977 /* /Fx */
978 /* codec capabilities */
979
980 /**
981  * Decoder can use draw_horiz_band callback.
982  */
983 #define AV_CODEC_CAP_DRAW_HORIZ_BAND     (1 <<  0)
984 /**
985  * Codec uses get_buffer() for allocating buffers and supports custom allocators.
986  * If not set, it might not use get_buffer() at all or use operations that
987  * assume the buffer was allocated by avcodec_default_get_buffer.
988  */
989 #define AV_CODEC_CAP_DR1                 (1 <<  1)
990 #define AV_CODEC_CAP_TRUNCATED           (1 <<  3)
991 /**
992  * Encoder or decoder requires flushing with NULL input at the end in order to
993  * give the complete and correct output.
994  *
995  * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
996  *       with NULL data. The user can still send NULL data to the public encode
997  *       or decode function, but libavcodec will not pass it along to the codec
998  *       unless this flag is set.
999  *
1000  * Decoders:
1001  * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
1002  * avpkt->size=0 at the end to get the delayed data until the decoder no longer
1003  * returns frames.
1004  *
1005  * Encoders:
1006  * The encoder needs to be fed with NULL data at the end of encoding until the
1007  * encoder no longer returns data.
1008  *
1009  * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
1010  *       flag also means that the encoder must set the pts and duration for
1011  *       each output packet. If this flag is not set, the pts and duration will
1012  *       be determined by libavcodec from the input frame.
1013  */
1014 #define AV_CODEC_CAP_DELAY               (1 <<  5)
1015 /**
1016  * Codec can be fed a final frame with a smaller size.
1017  * This can be used to prevent truncation of the last audio samples.
1018  */
1019 #define AV_CODEC_CAP_SMALL_LAST_FRAME    (1 <<  6)
1020
1021 /**
1022  * Codec can output multiple frames per AVPacket
1023  * Normally demuxers return one frame at a time, demuxers which do not do
1024  * are connected to a parser to split what they return into proper frames.
1025  * This flag is reserved to the very rare category of codecs which have a
1026  * bitstream that cannot be split into frames without timeconsuming
1027  * operations like full decoding. Demuxers carrying such bitstreams thus
1028  * may return multiple frames in a packet. This has many disadvantages like
1029  * prohibiting stream copy in many cases thus it should only be considered
1030  * as a last resort.
1031  */
1032 #define AV_CODEC_CAP_SUBFRAMES           (1 <<  8)
1033 /**
1034  * Codec is experimental and is thus avoided in favor of non experimental
1035  * encoders
1036  */
1037 #define AV_CODEC_CAP_EXPERIMENTAL        (1 <<  9)
1038 /**
1039  * Codec should fill in channel configuration and samplerate instead of container
1040  */
1041 #define AV_CODEC_CAP_CHANNEL_CONF        (1 << 10)
1042 /**
1043  * Codec supports frame-level multithreading.
1044  */
1045 #define AV_CODEC_CAP_FRAME_THREADS       (1 << 12)
1046 /**
1047  * Codec supports slice-based (or partition-based) multithreading.
1048  */
1049 #define AV_CODEC_CAP_SLICE_THREADS       (1 << 13)
1050 /**
1051  * Codec supports changed parameters at any point.
1052  */
1053 #define AV_CODEC_CAP_PARAM_CHANGE        (1 << 14)
1054 /**
1055  * Codec supports avctx->thread_count == 0 (auto).
1056  */
1057 #define AV_CODEC_CAP_AUTO_THREADS        (1 << 15)
1058 /**
1059  * Audio encoder supports receiving a different number of samples in each call.
1060  */
1061 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
1062 /**
1063  * Decoder is not a preferred choice for probing.
1064  * This indicates that the decoder is not a good choice for probing.
1065  * It could for example be an expensive to spin up hardware decoder,
1066  * or it could simply not provide a lot of useful information about
1067  * the stream.
1068  * A decoder marked with this flag should only be used as last resort
1069  * choice for probing.
1070  */
1071 #define AV_CODEC_CAP_AVOID_PROBING       (1 << 17)
1072 /**
1073  * Codec is intra only.
1074  */
1075 #define AV_CODEC_CAP_INTRA_ONLY       0x40000000
1076 /**
1077  * Codec is lossless.
1078  */
1079 #define AV_CODEC_CAP_LOSSLESS         0x80000000
1080
1081 /**
1082  * Codec is backed by a hardware implementation. Typically used to
1083  * identify a non-hwaccel hardware decoder. For information about hwaccels, use
1084  * avcodec_get_hw_config() instead.
1085  */
1086 #define AV_CODEC_CAP_HARDWARE            (1 << 18)
1087
1088 /**
1089  * Codec is potentially backed by a hardware implementation, but not
1090  * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the
1091  * implementation provides some sort of internal fallback.
1092  */
1093 #define AV_CODEC_CAP_HYBRID              (1 << 19)
1094
1095 /**
1096  * This codec takes the reordered_opaque field from input AVFrames
1097  * and returns it in the corresponding field in AVCodecContext after
1098  * encoding.
1099  */
1100 #define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
1101
1102 /**
1103  * Pan Scan area.
1104  * This specifies the area which should be displayed.
1105  * Note there may be multiple such areas for one frame.
1106  */
1107 typedef struct AVPanScan {
1108     /**
1109      * id
1110      * - encoding: Set by user.
1111      * - decoding: Set by libavcodec.
1112      */
1113     int id;
1114
1115     /**
1116      * width and height in 1/16 pel
1117      * - encoding: Set by user.
1118      * - decoding: Set by libavcodec.
1119      */
1120     int width;
1121     int height;
1122
1123     /**
1124      * position of the top left corner in 1/16 pel for up to 3 fields/frames
1125      * - encoding: Set by user.
1126      * - decoding: Set by libavcodec.
1127      */
1128     int16_t position[3][2];
1129 } AVPanScan;
1130
1131 /**
1132  * This structure describes the bitrate properties of an encoded bitstream. It
1133  * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
1134  * parameters for H.264/HEVC.
1135  */
1136 typedef struct AVCPBProperties {
1137     /**
1138      * Maximum bitrate of the stream, in bits per second.
1139      * Zero if unknown or unspecified.
1140      */
1141 #if FF_API_UNSANITIZED_BITRATES
1142     int max_bitrate;
1143 #else
1144     int64_t max_bitrate;
1145 #endif
1146     /**
1147      * Minimum bitrate of the stream, in bits per second.
1148      * Zero if unknown or unspecified.
1149      */
1150 #if FF_API_UNSANITIZED_BITRATES
1151     int min_bitrate;
1152 #else
1153     int64_t min_bitrate;
1154 #endif
1155     /**
1156      * Average bitrate of the stream, in bits per second.
1157      * Zero if unknown or unspecified.
1158      */
1159 #if FF_API_UNSANITIZED_BITRATES
1160     int avg_bitrate;
1161 #else
1162     int64_t avg_bitrate;
1163 #endif
1164
1165     /**
1166      * The size of the buffer to which the ratecontrol is applied, in bits.
1167      * Zero if unknown or unspecified.
1168      */
1169     int buffer_size;
1170
1171     /**
1172      * The delay between the time the packet this structure is associated with
1173      * is received and the time when it should be decoded, in periods of a 27MHz
1174      * clock.
1175      *
1176      * UINT64_MAX when unknown or unspecified.
1177      */
1178     uint64_t vbv_delay;
1179 } AVCPBProperties;
1180
1181 typedef struct AVProducerReferenceTime {
1182     int64_t wallclock;
1183     int flags;
1184 } AVProducerReferenceTime;
1185
1186 /**
1187  * The decoder will keep a reference to the frame and may reuse it later.
1188  */
1189 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
1190
1191 /**
1192  * @defgroup lavc_packet AVPacket
1193  *
1194  * Types and functions for working with AVPacket.
1195  * @{
1196  */
1197 enum AVPacketSideDataType {
1198     /**
1199      * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE
1200      * bytes worth of palette. This side data signals that a new palette is
1201      * present.
1202      */
1203     AV_PKT_DATA_PALETTE,
1204
1205     /**
1206      * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
1207      * that the extradata buffer was changed and the receiving side should
1208      * act upon it appropriately. The new extradata is embedded in the side
1209      * data buffer and should be immediately used for processing the current
1210      * frame or packet.
1211      */
1212     AV_PKT_DATA_NEW_EXTRADATA,
1213
1214     /**
1215      * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
1216      * @code
1217      * u32le param_flags
1218      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
1219      *     s32le channel_count
1220      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
1221      *     u64le channel_layout
1222      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
1223      *     s32le sample_rate
1224      * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
1225      *     s32le width
1226      *     s32le height
1227      * @endcode
1228      */
1229     AV_PKT_DATA_PARAM_CHANGE,
1230
1231     /**
1232      * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
1233      * structures with info about macroblocks relevant to splitting the
1234      * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
1235      * That is, it does not necessarily contain info about all macroblocks,
1236      * as long as the distance between macroblocks in the info is smaller
1237      * than the target payload size.
1238      * Each MB info structure is 12 bytes, and is laid out as follows:
1239      * @code
1240      * u32le bit offset from the start of the packet
1241      * u8    current quantizer at the start of the macroblock
1242      * u8    GOB number
1243      * u16le macroblock address within the GOB
1244      * u8    horizontal MV predictor
1245      * u8    vertical MV predictor
1246      * u8    horizontal MV predictor for block number 3
1247      * u8    vertical MV predictor for block number 3
1248      * @endcode
1249      */
1250     AV_PKT_DATA_H263_MB_INFO,
1251
1252     /**
1253      * This side data should be associated with an audio stream and contains
1254      * ReplayGain information in form of the AVReplayGain struct.
1255      */
1256     AV_PKT_DATA_REPLAYGAIN,
1257
1258     /**
1259      * This side data contains a 3x3 transformation matrix describing an affine
1260      * transformation that needs to be applied to the decoded video frames for
1261      * correct presentation.
1262      *
1263      * See libavutil/display.h for a detailed description of the data.
1264      */
1265     AV_PKT_DATA_DISPLAYMATRIX,
1266
1267     /**
1268      * This side data should be associated with a video stream and contains
1269      * Stereoscopic 3D information in form of the AVStereo3D struct.
1270      */
1271     AV_PKT_DATA_STEREO3D,
1272
1273     /**
1274      * This side data should be associated with an audio stream and corresponds
1275      * to enum AVAudioServiceType.
1276      */
1277     AV_PKT_DATA_AUDIO_SERVICE_TYPE,
1278
1279     /**
1280      * This side data contains quality related information from the encoder.
1281      * @code
1282      * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad).
1283      * u8    picture type
1284      * u8    error count
1285      * u16   reserved
1286      * u64le[error count] sum of squared differences between encoder in and output
1287      * @endcode
1288      */
1289     AV_PKT_DATA_QUALITY_STATS,
1290
1291     /**
1292      * This side data contains an integer value representing the stream index
1293      * of a "fallback" track.  A fallback track indicates an alternate
1294      * track to use when the current track can not be decoded for some reason.
1295      * e.g. no decoder available for codec.
1296      */
1297     AV_PKT_DATA_FALLBACK_TRACK,
1298
1299     /**
1300      * This side data corresponds to the AVCPBProperties struct.
1301      */
1302     AV_PKT_DATA_CPB_PROPERTIES,
1303
1304     /**
1305      * Recommmends skipping the specified number of samples
1306      * @code
1307      * u32le number of samples to skip from start of this packet
1308      * u32le number of samples to skip from end of this packet
1309      * u8    reason for start skip
1310      * u8    reason for end   skip (0=padding silence, 1=convergence)
1311      * @endcode
1312      */
1313     AV_PKT_DATA_SKIP_SAMPLES,
1314
1315     /**
1316      * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that
1317      * the packet may contain "dual mono" audio specific to Japanese DTV
1318      * and if it is true, recommends only the selected channel to be used.
1319      * @code
1320      * u8    selected channels (0=mail/left, 1=sub/right, 2=both)
1321      * @endcode
1322      */
1323     AV_PKT_DATA_JP_DUALMONO,
1324
1325     /**
1326      * A list of zero terminated key/value strings. There is no end marker for
1327      * the list, so it is required to rely on the side data size to stop.
1328      */
1329     AV_PKT_DATA_STRINGS_METADATA,
1330
1331     /**
1332      * Subtitle event position
1333      * @code
1334      * u32le x1
1335      * u32le y1
1336      * u32le x2
1337      * u32le y2
1338      * @endcode
1339      */
1340     AV_PKT_DATA_SUBTITLE_POSITION,
1341
1342     /**
1343      * Data found in BlockAdditional element of matroska container. There is
1344      * no end marker for the data, so it is required to rely on the side data
1345      * size to recognize the end. 8 byte id (as found in BlockAddId) followed
1346      * by data.
1347      */
1348     AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL,
1349
1350     /**
1351      * The optional first identifier line of a WebVTT cue.
1352      */
1353     AV_PKT_DATA_WEBVTT_IDENTIFIER,
1354
1355     /**
1356      * The optional settings (rendering instructions) that immediately
1357      * follow the timestamp specifier of a WebVTT cue.
1358      */
1359     AV_PKT_DATA_WEBVTT_SETTINGS,
1360
1361     /**
1362      * A list of zero terminated key/value strings. There is no end marker for
1363      * the list, so it is required to rely on the side data size to stop. This
1364      * side data includes updated metadata which appeared in the stream.
1365      */
1366     AV_PKT_DATA_METADATA_UPDATE,
1367
1368     /**
1369      * MPEGTS stream ID as uint8_t, this is required to pass the stream ID
1370      * information from the demuxer to the corresponding muxer.
1371      */
1372     AV_PKT_DATA_MPEGTS_STREAM_ID,
1373
1374     /**
1375      * Mastering display metadata (based on SMPTE-2086:2014). This metadata
1376      * should be associated with a video stream and contains data in the form
1377      * of the AVMasteringDisplayMetadata struct.
1378      */
1379     AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
1380
1381     /**
1382      * This side data should be associated with a video stream and corresponds
1383      * to the AVSphericalMapping structure.
1384      */
1385     AV_PKT_DATA_SPHERICAL,
1386
1387     /**
1388      * Content light level (based on CTA-861.3). This metadata should be
1389      * associated with a video stream and contains data in the form of the
1390      * AVContentLightMetadata struct.
1391      */
1392     AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
1393
1394     /**
1395      * ATSC A53 Part 4 Closed Captions. This metadata should be associated with
1396      * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data.
1397      * The number of bytes of CC data is AVPacketSideData.size.
1398      */
1399     AV_PKT_DATA_A53_CC,
1400
1401     /**
1402      * This side data is encryption initialization data.
1403      * The format is not part of ABI, use av_encryption_init_info_* methods to
1404      * access.
1405      */
1406     AV_PKT_DATA_ENCRYPTION_INIT_INFO,
1407
1408     /**
1409      * This side data contains encryption info for how to decrypt the packet.
1410      * The format is not part of ABI, use av_encryption_info_* methods to access.
1411      */
1412     AV_PKT_DATA_ENCRYPTION_INFO,
1413
1414     /**
1415      * Active Format Description data consisting of a single byte as specified
1416      * in ETSI TS 101 154 using AVActiveFormatDescription enum.
1417      */
1418     AV_PKT_DATA_AFD,
1419
1420     /**
1421      * Producer Reference Time data corresponding to the AVProducerReferenceTime struct.
1422      */
1423     AV_PKT_DATA_PRFT,
1424
1425     /**
1426      * The number of side data types.
1427      * This is not part of the public API/ABI in the sense that it may
1428      * change when new side data types are added.
1429      * This must stay the last enum value.
1430      * If its value becomes huge, some code using it
1431      * needs to be updated as it assumes it to be smaller than other limits.
1432      */
1433     AV_PKT_DATA_NB
1434 };
1435
1436 #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
1437
1438 typedef struct AVPacketSideData {
1439     uint8_t *data;
1440     int      size;
1441     enum AVPacketSideDataType type;
1442 } AVPacketSideData;
1443
1444 /**
1445  * This structure stores compressed data. It is typically exported by demuxers
1446  * and then passed as input to decoders, or received as output from encoders and
1447  * then passed to muxers.
1448  *
1449  * For video, it should typically contain one compressed frame. For audio it may
1450  * contain several compressed frames. Encoders are allowed to output empty
1451  * packets, with no compressed data, containing only side data
1452  * (e.g. to update some stream parameters at the end of encoding).
1453  *
1454  * AVPacket is one of the few structs in FFmpeg, whose size is a part of public
1455  * ABI. Thus it may be allocated on stack and no new fields can be added to it
1456  * without libavcodec and libavformat major bump.
1457  *
1458  * The semantics of data ownership depends on the buf field.
1459  * If it is set, the packet data is dynamically allocated and is
1460  * valid indefinitely until a call to av_packet_unref() reduces the
1461  * reference count to 0.
1462  *
1463  * If the buf field is not set av_packet_ref() would make a copy instead
1464  * of increasing the reference count.
1465  *
1466  * The side data is always allocated with av_malloc(), copied by
1467  * av_packet_ref() and freed by av_packet_unref().
1468  *
1469  * @see av_packet_ref
1470  * @see av_packet_unref
1471  */
1472 typedef struct AVPacket {
1473     /**
1474      * A reference to the reference-counted buffer where the packet data is
1475      * stored.
1476      * May be NULL, then the packet data is not reference-counted.
1477      */
1478     AVBufferRef *buf;
1479     /**
1480      * Presentation timestamp in AVStream->time_base units; the time at which
1481      * the decompressed packet will be presented to the user.
1482      * Can be AV_NOPTS_VALUE if it is not stored in the file.
1483      * pts MUST be larger or equal to dts as presentation cannot happen before
1484      * decompression, unless one wants to view hex dumps. Some formats misuse
1485      * the terms dts and pts/cts to mean something different. Such timestamps
1486      * must be converted to true pts/dts before they are stored in AVPacket.
1487      */
1488     int64_t pts;
1489     /**
1490      * Decompression timestamp in AVStream->time_base units; the time at which
1491      * the packet is decompressed.
1492      * Can be AV_NOPTS_VALUE if it is not stored in the file.
1493      */
1494     int64_t dts;
1495     uint8_t *data;
1496     int   size;
1497     int   stream_index;
1498     /**
1499      * A combination of AV_PKT_FLAG values
1500      */
1501     int   flags;
1502     /**
1503      * Additional packet data that can be provided by the container.
1504      * Packet can contain several types of side information.
1505      */
1506     AVPacketSideData *side_data;
1507     int side_data_elems;
1508
1509     /**
1510      * Duration of this packet in AVStream->time_base units, 0 if unknown.
1511      * Equals next_pts - this_pts in presentation order.
1512      */
1513     int64_t duration;
1514
1515     int64_t pos;                            ///< byte position in stream, -1 if unknown
1516
1517 #if FF_API_CONVERGENCE_DURATION
1518     /**
1519      * @deprecated Same as the duration field, but as int64_t. This was required
1520      * for Matroska subtitles, whose duration values could overflow when the
1521      * duration field was still an int.
1522      */
1523     attribute_deprecated
1524     int64_t convergence_duration;
1525 #endif
1526 } AVPacket;
1527 #define AV_PKT_FLAG_KEY     0x0001 ///< The packet contains a keyframe
1528 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
1529 /**
1530  * Flag is used to discard packets which are required to maintain valid
1531  * decoder state but are not required for output and should be dropped
1532  * after decoding.
1533  **/
1534 #define AV_PKT_FLAG_DISCARD   0x0004
1535 /**
1536  * The packet comes from a trusted source.
1537  *
1538  * Otherwise-unsafe constructs such as arbitrary pointers to data
1539  * outside the packet may be followed.
1540  */
1541 #define AV_PKT_FLAG_TRUSTED   0x0008
1542 /**
1543  * Flag is used to indicate packets that contain frames that can
1544  * be discarded by the decoder.  I.e. Non-reference frames.
1545  */
1546 #define AV_PKT_FLAG_DISPOSABLE 0x0010
1547
1548
1549 enum AVSideDataParamChangeFlags {
1550     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
1551     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
1552     AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE    = 0x0004,
1553     AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS     = 0x0008,
1554 };
1555 /**
1556  * @}
1557  */
1558
1559 struct AVCodecInternal;
1560
1561 enum AVFieldOrder {
1562     AV_FIELD_UNKNOWN,
1563     AV_FIELD_PROGRESSIVE,
1564     AV_FIELD_TT,          //< Top coded_first, top displayed first
1565     AV_FIELD_BB,          //< Bottom coded first, bottom displayed first
1566     AV_FIELD_TB,          //< Top coded first, bottom displayed first
1567     AV_FIELD_BT,          //< Bottom coded first, top displayed first
1568 };
1569
1570 /**
1571  * main external API structure.
1572  * New fields can be added to the end with minor version bumps.
1573  * Removal, reordering and changes to existing fields require a major
1574  * version bump.
1575  * You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user
1576  * applications.
1577  * The name string for AVOptions options matches the associated command line
1578  * parameter name and can be found in libavcodec/options_table.h
1579  * The AVOption/command line parameter names differ in some cases from the C
1580  * structure field names for historic reasons or brevity.
1581  * sizeof(AVCodecContext) must not be used outside libav*.
1582  */
1583 typedef struct AVCodecContext {
1584     /**
1585      * information on struct for av_log
1586      * - set by avcodec_alloc_context3
1587      */
1588     const AVClass *av_class;
1589     int log_level_offset;
1590
1591     enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1592     const struct AVCodec  *codec;
1593     enum AVCodecID     codec_id; /* see AV_CODEC_ID_xxx */
1594
1595     /**
1596      * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1597      * This is used to work around some encoder bugs.
1598      * A demuxer should set this to what is stored in the field used to identify the codec.
1599      * If there are multiple such fields in a container then the demuxer should choose the one
1600      * which maximizes the information about the used codec.
1601      * If the codec tag field in a container is larger than 32 bits then the demuxer should
1602      * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1603      * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1604      * first.
1605      * - encoding: Set by user, if not then the default based on codec_id will be used.
1606      * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1607      */
1608     unsigned int codec_tag;
1609
1610     void *priv_data;
1611
1612     /**
1613      * Private context used for internal data.
1614      *
1615      * Unlike priv_data, this is not codec-specific. It is used in general
1616      * libavcodec functions.
1617      */
1618     struct AVCodecInternal *internal;
1619
1620     /**
1621      * Private data of the user, can be used to carry app specific stuff.
1622      * - encoding: Set by user.
1623      * - decoding: Set by user.
1624      */
1625     void *opaque;
1626
1627     /**
1628      * the average bitrate
1629      * - encoding: Set by user; unused for constant quantizer encoding.
1630      * - decoding: Set by user, may be overwritten by libavcodec
1631      *             if this info is available in the stream
1632      */
1633     int64_t bit_rate;
1634
1635     /**
1636      * number of bits the bitstream is allowed to diverge from the reference.
1637      *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
1638      * - encoding: Set by user; unused for constant quantizer encoding.
1639      * - decoding: unused
1640      */
1641     int bit_rate_tolerance;
1642
1643     /**
1644      * Global quality for codecs which cannot change it per frame.
1645      * This should be proportional to MPEG-1/2/4 qscale.
1646      * - encoding: Set by user.
1647      * - decoding: unused
1648      */
1649     int global_quality;
1650
1651     /**
1652      * - encoding: Set by user.
1653      * - decoding: unused
1654      */
1655     int compression_level;
1656 #define FF_COMPRESSION_DEFAULT -1
1657
1658     /**
1659      * AV_CODEC_FLAG_*.
1660      * - encoding: Set by user.
1661      * - decoding: Set by user.
1662      */
1663     int flags;
1664
1665     /**
1666      * AV_CODEC_FLAG2_*
1667      * - encoding: Set by user.
1668      * - decoding: Set by user.
1669      */
1670     int flags2;
1671
1672     /**
1673      * some codecs need / can use extradata like Huffman tables.
1674      * MJPEG: Huffman tables
1675      * rv10: additional flags
1676      * MPEG-4: global headers (they can be in the bitstream or here)
1677      * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
1678      * than extradata_size to avoid problems if it is read with the bitstream reader.
1679      * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1680      * Must be allocated with the av_malloc() family of functions.
1681      * - encoding: Set/allocated/freed by libavcodec.
1682      * - decoding: Set/allocated/freed by user.
1683      */
1684     uint8_t *extradata;
1685     int extradata_size;
1686
1687     /**
1688      * This is the fundamental unit of time (in seconds) in terms
1689      * of which frame timestamps are represented. For fixed-fps content,
1690      * timebase should be 1/framerate and timestamp increments should be
1691      * identically 1.
1692      * This often, but not always is the inverse of the frame rate or field rate
1693      * for video. 1/time_base is not the average frame rate if the frame rate is not
1694      * constant.
1695      *
1696      * Like containers, elementary streams also can store timestamps, 1/time_base
1697      * is the unit in which these timestamps are specified.
1698      * As example of such codec time base see ISO/IEC 14496-2:2001(E)
1699      * vop_time_increment_resolution and fixed_vop_rate
1700      * (fixed_vop_rate == 0 implies that it is different from the framerate)
1701      *
1702      * - encoding: MUST be set by user.
1703      * - decoding: the use of this field for decoding is deprecated.
1704      *             Use framerate instead.
1705      */
1706     AVRational time_base;
1707
1708     /**
1709      * For some codecs, the time base is closer to the field rate than the frame rate.
1710      * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1711      * if no telecine is used ...
1712      *
1713      * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1714      */
1715     int ticks_per_frame;
1716
1717     /**
1718      * Codec delay.
1719      *
1720      * Encoding: Number of frames delay there will be from the encoder input to
1721      *           the decoder output. (we assume the decoder matches the spec)
1722      * Decoding: Number of frames delay in addition to what a standard decoder
1723      *           as specified in the spec would produce.
1724      *
1725      * Video:
1726      *   Number of frames the decoded output will be delayed relative to the
1727      *   encoded input.
1728      *
1729      * Audio:
1730      *   For encoding, this field is unused (see initial_padding).
1731      *
1732      *   For decoding, this is the number of samples the decoder needs to
1733      *   output before the decoder's output is valid. When seeking, you should
1734      *   start decoding this many samples prior to your desired seek point.
1735      *
1736      * - encoding: Set by libavcodec.
1737      * - decoding: Set by libavcodec.
1738      */
1739     int delay;
1740
1741
1742     /* video only */
1743     /**
1744      * picture width / height.
1745      *
1746      * @note Those fields may not match the values of the last
1747      * AVFrame output by avcodec_decode_video2 due frame
1748      * reordering.
1749      *
1750      * - encoding: MUST be set by user.
1751      * - decoding: May be set by the user before opening the decoder if known e.g.
1752      *             from the container. Some decoders will require the dimensions
1753      *             to be set by the caller. During decoding, the decoder may
1754      *             overwrite those values as required while parsing the data.
1755      */
1756     int width, height;
1757
1758     /**
1759      * Bitstream width / height, may be different from width/height e.g. when
1760      * the decoded frame is cropped before being output or lowres is enabled.
1761      *
1762      * @note Those field may not match the value of the last
1763      * AVFrame output by avcodec_receive_frame() due frame
1764      * reordering.
1765      *
1766      * - encoding: unused
1767      * - decoding: May be set by the user before opening the decoder if known
1768      *             e.g. from the container. During decoding, the decoder may
1769      *             overwrite those values as required while parsing the data.
1770      */
1771     int coded_width, coded_height;
1772
1773     /**
1774      * the number of pictures in a group of pictures, or 0 for intra_only
1775      * - encoding: Set by user.
1776      * - decoding: unused
1777      */
1778     int gop_size;
1779
1780     /**
1781      * Pixel format, see AV_PIX_FMT_xxx.
1782      * May be set by the demuxer if known from headers.
1783      * May be overridden by the decoder if it knows better.
1784      *
1785      * @note This field may not match the value of the last
1786      * AVFrame output by avcodec_receive_frame() due frame
1787      * reordering.
1788      *
1789      * - encoding: Set by user.
1790      * - decoding: Set by user if known, overridden by libavcodec while
1791      *             parsing the data.
1792      */
1793     enum AVPixelFormat pix_fmt;
1794
1795     /**
1796      * If non NULL, 'draw_horiz_band' is called by the libavcodec
1797      * decoder to draw a horizontal band. It improves cache usage. Not
1798      * all codecs can do that. You must check the codec capabilities
1799      * beforehand.
1800      * When multithreading is used, it may be called from multiple threads
1801      * at the same time; threads might draw different parts of the same AVFrame,
1802      * or multiple AVFrames, and there is no guarantee that slices will be drawn
1803      * in order.
1804      * The function is also used by hardware acceleration APIs.
1805      * It is called at least once during frame decoding to pass
1806      * the data needed for hardware render.
1807      * In that mode instead of pixel data, AVFrame points to
1808      * a structure specific to the acceleration API. The application
1809      * reads the structure and can change some fields to indicate progress
1810      * or mark state.
1811      * - encoding: unused
1812      * - decoding: Set by user.
1813      * @param height the height of the slice
1814      * @param y the y position of the slice
1815      * @param type 1->top field, 2->bottom field, 3->frame
1816      * @param offset offset into the AVFrame.data from which the slice should be read
1817      */
1818     void (*draw_horiz_band)(struct AVCodecContext *s,
1819                             const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1820                             int y, int type, int height);
1821
1822     /**
1823      * callback to negotiate the pixelFormat
1824      * @param fmt is the list of formats which are supported by the codec,
1825      * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1826      * The first is always the native one.
1827      * @note The callback may be called again immediately if initialization for
1828      * the selected (hardware-accelerated) pixel format failed.
1829      * @warning Behavior is undefined if the callback returns a value not
1830      * in the fmt list of formats.
1831      * @return the chosen format
1832      * - encoding: unused
1833      * - decoding: Set by user, if not set the native format will be chosen.
1834      */
1835     enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1836
1837     /**
1838      * maximum number of B-frames between non-B-frames
1839      * Note: The output will be delayed by max_b_frames+1 relative to the input.
1840      * - encoding: Set by user.
1841      * - decoding: unused
1842      */
1843     int max_b_frames;
1844
1845     /**
1846      * qscale factor between IP and B-frames
1847      * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1848      * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1849      * - encoding: Set by user.
1850      * - decoding: unused
1851      */
1852     float b_quant_factor;
1853
1854 #if FF_API_PRIVATE_OPT
1855     /** @deprecated use encoder private options instead */
1856     attribute_deprecated
1857     int b_frame_strategy;
1858 #endif
1859
1860     /**
1861      * qscale offset between IP and B-frames
1862      * - encoding: Set by user.
1863      * - decoding: unused
1864      */
1865     float b_quant_offset;
1866
1867     /**
1868      * Size of the frame reordering buffer in the decoder.
1869      * For MPEG-2 it is 1 IPB or 0 low delay IP.
1870      * - encoding: Set by libavcodec.
1871      * - decoding: Set by libavcodec.
1872      */
1873     int has_b_frames;
1874
1875 #if FF_API_PRIVATE_OPT
1876     /** @deprecated use encoder private options instead */
1877     attribute_deprecated
1878     int mpeg_quant;
1879 #endif
1880
1881     /**
1882      * qscale factor between P- and I-frames
1883      * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
1884      * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1885      * - encoding: Set by user.
1886      * - decoding: unused
1887      */
1888     float i_quant_factor;
1889
1890     /**
1891      * qscale offset between P and I-frames
1892      * - encoding: Set by user.
1893      * - decoding: unused
1894      */
1895     float i_quant_offset;
1896
1897     /**
1898      * luminance masking (0-> disabled)
1899      * - encoding: Set by user.
1900      * - decoding: unused
1901      */
1902     float lumi_masking;
1903
1904     /**
1905      * temporary complexity masking (0-> disabled)
1906      * - encoding: Set by user.
1907      * - decoding: unused
1908      */
1909     float temporal_cplx_masking;
1910
1911     /**
1912      * spatial complexity masking (0-> disabled)
1913      * - encoding: Set by user.
1914      * - decoding: unused
1915      */
1916     float spatial_cplx_masking;
1917
1918     /**
1919      * p block masking (0-> disabled)
1920      * - encoding: Set by user.
1921      * - decoding: unused
1922      */
1923     float p_masking;
1924
1925     /**
1926      * darkness masking (0-> disabled)
1927      * - encoding: Set by user.
1928      * - decoding: unused
1929      */
1930     float dark_masking;
1931
1932     /**
1933      * slice count
1934      * - encoding: Set by libavcodec.
1935      * - decoding: Set by user (or 0).
1936      */
1937     int slice_count;
1938
1939 #if FF_API_PRIVATE_OPT
1940     /** @deprecated use encoder private options instead */
1941     attribute_deprecated
1942      int prediction_method;
1943 #define FF_PRED_LEFT   0
1944 #define FF_PRED_PLANE  1
1945 #define FF_PRED_MEDIAN 2
1946 #endif
1947
1948     /**
1949      * slice offsets in the frame in bytes
1950      * - encoding: Set/allocated by libavcodec.
1951      * - decoding: Set/allocated by user (or NULL).
1952      */
1953     int *slice_offset;
1954
1955     /**
1956      * sample aspect ratio (0 if unknown)
1957      * That is the width of a pixel divided by the height of the pixel.
1958      * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1959      * - encoding: Set by user.
1960      * - decoding: Set by libavcodec.
1961      */
1962     AVRational sample_aspect_ratio;
1963
1964     /**
1965      * motion estimation comparison function
1966      * - encoding: Set by user.
1967      * - decoding: unused
1968      */
1969     int me_cmp;
1970     /**
1971      * subpixel motion estimation comparison function
1972      * - encoding: Set by user.
1973      * - decoding: unused
1974      */
1975     int me_sub_cmp;
1976     /**
1977      * macroblock comparison function (not supported yet)
1978      * - encoding: Set by user.
1979      * - decoding: unused
1980      */
1981     int mb_cmp;
1982     /**
1983      * interlaced DCT comparison function
1984      * - encoding: Set by user.
1985      * - decoding: unused
1986      */
1987     int ildct_cmp;
1988 #define FF_CMP_SAD          0
1989 #define FF_CMP_SSE          1
1990 #define FF_CMP_SATD         2
1991 #define FF_CMP_DCT          3
1992 #define FF_CMP_PSNR         4
1993 #define FF_CMP_BIT          5
1994 #define FF_CMP_RD           6
1995 #define FF_CMP_ZERO         7
1996 #define FF_CMP_VSAD         8
1997 #define FF_CMP_VSSE         9
1998 #define FF_CMP_NSSE         10
1999 #define FF_CMP_W53          11
2000 #define FF_CMP_W97          12
2001 #define FF_CMP_DCTMAX       13
2002 #define FF_CMP_DCT264       14
2003 #define FF_CMP_MEDIAN_SAD   15
2004 #define FF_CMP_CHROMA       256
2005
2006     /**
2007      * ME diamond size & shape
2008      * - encoding: Set by user.
2009      * - decoding: unused
2010      */
2011     int dia_size;
2012
2013     /**
2014      * amount of previous MV predictors (2a+1 x 2a+1 square)
2015      * - encoding: Set by user.
2016      * - decoding: unused
2017      */
2018     int last_predictor_count;
2019
2020 #if FF_API_PRIVATE_OPT
2021     /** @deprecated use encoder private options instead */
2022     attribute_deprecated
2023     int pre_me;
2024 #endif
2025
2026     /**
2027      * motion estimation prepass comparison function
2028      * - encoding: Set by user.
2029      * - decoding: unused
2030      */
2031     int me_pre_cmp;
2032
2033     /**
2034      * ME prepass diamond size & shape
2035      * - encoding: Set by user.
2036      * - decoding: unused
2037      */
2038     int pre_dia_size;
2039
2040     /**
2041      * subpel ME quality
2042      * - encoding: Set by user.
2043      * - decoding: unused
2044      */
2045     int me_subpel_quality;
2046
2047     /**
2048      * maximum motion estimation search range in subpel units
2049      * If 0 then no limit.
2050      *
2051      * - encoding: Set by user.
2052      * - decoding: unused
2053      */
2054     int me_range;
2055
2056     /**
2057      * slice flags
2058      * - encoding: unused
2059      * - decoding: Set by user.
2060      */
2061     int slice_flags;
2062 #define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
2063 #define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
2064 #define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
2065
2066     /**
2067      * macroblock decision mode
2068      * - encoding: Set by user.
2069      * - decoding: unused
2070      */
2071     int mb_decision;
2072 #define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
2073 #define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
2074 #define FF_MB_DECISION_RD     2        ///< rate distortion
2075
2076     /**
2077      * custom intra quantization matrix
2078      * Must be allocated with the av_malloc() family of functions, and will be freed in
2079      * avcodec_free_context().
2080      * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.
2081      * - decoding: Set/allocated/freed by libavcodec.
2082      */
2083     uint16_t *intra_matrix;
2084
2085     /**
2086      * custom inter quantization matrix
2087      * Must be allocated with the av_malloc() family of functions, and will be freed in
2088      * avcodec_free_context().
2089      * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL.
2090      * - decoding: Set/allocated/freed by libavcodec.
2091      */
2092     uint16_t *inter_matrix;
2093
2094 #if FF_API_PRIVATE_OPT
2095     /** @deprecated use encoder private options instead */
2096     attribute_deprecated
2097     int scenechange_threshold;
2098
2099     /** @deprecated use encoder private options instead */
2100     attribute_deprecated
2101     int noise_reduction;
2102 #endif
2103
2104     /**
2105      * precision of the intra DC coefficient - 8
2106      * - encoding: Set by user.
2107      * - decoding: Set by libavcodec
2108      */
2109     int intra_dc_precision;
2110
2111     /**
2112      * Number of macroblock rows at the top which are skipped.
2113      * - encoding: unused
2114      * - decoding: Set by user.
2115      */
2116     int skip_top;
2117
2118     /**
2119      * Number of macroblock rows at the bottom which are skipped.
2120      * - encoding: unused
2121      * - decoding: Set by user.
2122      */
2123     int skip_bottom;
2124
2125     /**
2126      * minimum MB Lagrange multiplier
2127      * - encoding: Set by user.
2128      * - decoding: unused
2129      */
2130     int mb_lmin;
2131
2132     /**
2133      * maximum MB Lagrange multiplier
2134      * - encoding: Set by user.
2135      * - decoding: unused
2136      */
2137     int mb_lmax;
2138
2139 #if FF_API_PRIVATE_OPT
2140     /**
2141      * @deprecated use encoder private options instead
2142      */
2143     attribute_deprecated
2144     int me_penalty_compensation;
2145 #endif
2146
2147     /**
2148      * - encoding: Set by user.
2149      * - decoding: unused
2150      */
2151     int bidir_refine;
2152
2153 #if FF_API_PRIVATE_OPT
2154     /** @deprecated use encoder private options instead */
2155     attribute_deprecated
2156     int brd_scale;
2157 #endif
2158
2159     /**
2160      * minimum GOP size
2161      * - encoding: Set by user.
2162      * - decoding: unused
2163      */
2164     int keyint_min;
2165
2166     /**
2167      * number of reference frames
2168      * - encoding: Set by user.
2169      * - decoding: Set by lavc.
2170      */
2171     int refs;
2172
2173 #if FF_API_PRIVATE_OPT
2174     /** @deprecated use encoder private options instead */
2175     attribute_deprecated
2176     int chromaoffset;
2177 #endif
2178
2179     /**
2180      * Note: Value depends upon the compare function used for fullpel ME.
2181      * - encoding: Set by user.
2182      * - decoding: unused
2183      */
2184     int mv0_threshold;
2185
2186 #if FF_API_PRIVATE_OPT
2187     /** @deprecated use encoder private options instead */
2188     attribute_deprecated
2189     int b_sensitivity;
2190 #endif
2191
2192     /**
2193      * Chromaticity coordinates of the source primaries.
2194      * - encoding: Set by user
2195      * - decoding: Set by libavcodec
2196      */
2197     enum AVColorPrimaries color_primaries;
2198
2199     /**
2200      * Color Transfer Characteristic.
2201      * - encoding: Set by user
2202      * - decoding: Set by libavcodec
2203      */
2204     enum AVColorTransferCharacteristic color_trc;
2205
2206     /**
2207      * YUV colorspace type.
2208      * - encoding: Set by user
2209      * - decoding: Set by libavcodec
2210      */
2211     enum AVColorSpace colorspace;
2212
2213     /**
2214      * MPEG vs JPEG YUV range.
2215      * - encoding: Set by user
2216      * - decoding: Set by libavcodec
2217      */
2218     enum AVColorRange color_range;
2219
2220     /**
2221      * This defines the location of chroma samples.
2222      * - encoding: Set by user
2223      * - decoding: Set by libavcodec
2224      */
2225     enum AVChromaLocation chroma_sample_location;
2226
2227     /**
2228      * Number of slices.
2229      * Indicates number of picture subdivisions. Used for parallelized
2230      * decoding.
2231      * - encoding: Set by user
2232      * - decoding: unused
2233      */
2234     int slices;
2235
2236     /** Field order
2237      * - encoding: set by libavcodec
2238      * - decoding: Set by user.
2239      */
2240     enum AVFieldOrder field_order;
2241
2242     /* audio only */
2243     int sample_rate; ///< samples per second
2244     int channels;    ///< number of audio channels
2245
2246     /**
2247      * audio sample format
2248      * - encoding: Set by user.
2249      * - decoding: Set by libavcodec.
2250      */
2251     enum AVSampleFormat sample_fmt;  ///< sample format
2252
2253     /* The following data should not be initialized. */
2254     /**
2255      * Number of samples per channel in an audio frame.
2256      *
2257      * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
2258      *   except the last must contain exactly frame_size samples per channel.
2259      *   May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
2260      *   frame size is not restricted.
2261      * - decoding: may be set by some decoders to indicate constant frame size
2262      */
2263     int frame_size;
2264
2265     /**
2266      * Frame counter, set by libavcodec.
2267      *
2268      * - decoding: total number of frames returned from the decoder so far.
2269      * - encoding: total number of frames passed to the encoder so far.
2270      *
2271      *   @note the counter is not incremented if encoding/decoding resulted in
2272      *   an error.
2273      */
2274     int frame_number;
2275
2276     /**
2277      * number of bytes per packet if constant and known or 0
2278      * Used by some WAV based audio codecs.
2279      */
2280     int block_align;
2281
2282     /**
2283      * Audio cutoff bandwidth (0 means "automatic")
2284      * - encoding: Set by user.
2285      * - decoding: unused
2286      */
2287     int cutoff;
2288
2289     /**
2290      * Audio channel layout.
2291      * - encoding: set by user.
2292      * - decoding: set by user, may be overwritten by libavcodec.
2293      */
2294     uint64_t channel_layout;
2295
2296     /**
2297      * Request decoder to use this channel layout if it can (0 for default)
2298      * - encoding: unused
2299      * - decoding: Set by user.
2300      */
2301     uint64_t request_channel_layout;
2302
2303     /**
2304      * Type of service that the audio stream conveys.
2305      * - encoding: Set by user.
2306      * - decoding: Set by libavcodec.
2307      */
2308     enum AVAudioServiceType audio_service_type;
2309
2310     /**
2311      * desired sample format
2312      * - encoding: Not used.
2313      * - decoding: Set by user.
2314      * Decoder will decode to this format if it can.
2315      */
2316     enum AVSampleFormat request_sample_fmt;
2317
2318     /**
2319      * This callback is called at the beginning of each frame to get data
2320      * buffer(s) for it. There may be one contiguous buffer for all the data or
2321      * there may be a buffer per each data plane or anything in between. What
2322      * this means is, you may set however many entries in buf[] you feel necessary.
2323      * Each buffer must be reference-counted using the AVBuffer API (see description
2324      * of buf[] below).
2325      *
2326      * The following fields will be set in the frame before this callback is
2327      * called:
2328      * - format
2329      * - width, height (video only)
2330      * - sample_rate, channel_layout, nb_samples (audio only)
2331      * Their values may differ from the corresponding values in
2332      * AVCodecContext. This callback must use the frame values, not the codec
2333      * context values, to calculate the required buffer size.
2334      *
2335      * This callback must fill the following fields in the frame:
2336      * - data[]
2337      * - linesize[]
2338      * - extended_data:
2339      *   * if the data is planar audio with more than 8 channels, then this
2340      *     callback must allocate and fill extended_data to contain all pointers
2341      *     to all data planes. data[] must hold as many pointers as it can.
2342      *     extended_data must be allocated with av_malloc() and will be freed in
2343      *     av_frame_unref().
2344      *   * otherwise extended_data must point to data
2345      * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
2346      *   the frame's data and extended_data pointers must be contained in these. That
2347      *   is, one AVBufferRef for each allocated chunk of memory, not necessarily one
2348      *   AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
2349      *   and av_buffer_ref().
2350      * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
2351      *   this callback and filled with the extra buffers if there are more
2352      *   buffers than buf[] can hold. extended_buf will be freed in
2353      *   av_frame_unref().
2354      *
2355      * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
2356      * avcodec_default_get_buffer2() instead of providing buffers allocated by
2357      * some other means.
2358      *
2359      * Each data plane must be aligned to the maximum required by the target
2360      * CPU.
2361      *
2362      * @see avcodec_default_get_buffer2()
2363      *
2364      * Video:
2365      *
2366      * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
2367      * (read and/or written to if it is writable) later by libavcodec.
2368      *
2369      * avcodec_align_dimensions2() should be used to find the required width and
2370      * height, as they normally need to be rounded up to the next multiple of 16.
2371      *
2372      * Some decoders do not support linesizes changing between frames.
2373      *
2374      * If frame multithreading is used and thread_safe_callbacks is set,
2375      * this callback may be called from a different thread, but not from more
2376      * than one at once. Does not need to be reentrant.
2377      *
2378      * @see avcodec_align_dimensions2()
2379      *
2380      * Audio:
2381      *
2382      * Decoders request a buffer of a particular size by setting
2383      * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
2384      * however, utilize only part of the buffer by setting AVFrame.nb_samples
2385      * to a smaller value in the output frame.
2386      *
2387      * As a convenience, av_samples_get_buffer_size() and
2388      * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
2389      * functions to find the required data size and to fill data pointers and
2390      * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2391      * since all planes must be the same size.
2392      *
2393      * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2394      *
2395      * - encoding: unused
2396      * - decoding: Set by libavcodec, user can override.
2397      */
2398     int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
2399
2400     /**
2401      * If non-zero, the decoded audio and video frames returned from
2402      * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
2403      * and are valid indefinitely. The caller must free them with
2404      * av_frame_unref() when they are not needed anymore.
2405      * Otherwise, the decoded frames must not be freed by the caller and are
2406      * only valid until the next decode call.
2407      *
2408      * This is always automatically enabled if avcodec_receive_frame() is used.
2409      *
2410      * - encoding: unused
2411      * - decoding: set by the caller before avcodec_open2().
2412      */
2413     attribute_deprecated
2414     int refcounted_frames;
2415
2416     /* - encoding parameters */
2417     float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2418     float qblur;      ///< amount of qscale smoothing over time (0.0-1.0)
2419
2420     /**
2421      * minimum quantizer
2422      * - encoding: Set by user.
2423      * - decoding: unused
2424      */
2425     int qmin;
2426
2427     /**
2428      * maximum quantizer
2429      * - encoding: Set by user.
2430      * - decoding: unused
2431      */
2432     int qmax;
2433
2434     /**
2435      * maximum quantizer difference between frames
2436      * - encoding: Set by user.
2437      * - decoding: unused
2438      */
2439     int max_qdiff;
2440
2441     /**
2442      * decoder bitstream buffer size
2443      * - encoding: Set by user.
2444      * - decoding: unused
2445      */
2446     int rc_buffer_size;
2447
2448     /**
2449      * ratecontrol override, see RcOverride
2450      * - encoding: Allocated/set/freed by user.
2451      * - decoding: unused
2452      */
2453     int rc_override_count;
2454     RcOverride *rc_override;
2455
2456     /**
2457      * maximum bitrate
2458      * - encoding: Set by user.
2459      * - decoding: Set by user, may be overwritten by libavcodec.
2460      */
2461     int64_t rc_max_rate;
2462
2463     /**
2464      * minimum bitrate
2465      * - encoding: Set by user.
2466      * - decoding: unused
2467      */
2468     int64_t rc_min_rate;
2469
2470     /**
2471      * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2472      * - encoding: Set by user.
2473      * - decoding: unused.
2474      */
2475     float rc_max_available_vbv_use;
2476
2477     /**
2478      * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2479      * - encoding: Set by user.
2480      * - decoding: unused.
2481      */
2482     float rc_min_vbv_overflow_use;
2483
2484     /**
2485      * Number of bits which should be loaded into the rc buffer before decoding starts.
2486      * - encoding: Set by user.
2487      * - decoding: unused
2488      */
2489     int rc_initial_buffer_occupancy;
2490
2491 #if FF_API_CODER_TYPE
2492 #define FF_CODER_TYPE_VLC       0
2493 #define FF_CODER_TYPE_AC        1
2494 #define FF_CODER_TYPE_RAW       2
2495 #define FF_CODER_TYPE_RLE       3
2496     /**
2497      * @deprecated use encoder private options instead
2498      */
2499     attribute_deprecated
2500     int coder_type;
2501 #endif /* FF_API_CODER_TYPE */
2502
2503 #if FF_API_PRIVATE_OPT
2504     /** @deprecated use encoder private options instead */
2505     attribute_deprecated
2506     int context_model;
2507 #endif
2508
2509 #if FF_API_PRIVATE_OPT
2510     /** @deprecated use encoder private options instead */
2511     attribute_deprecated
2512     int frame_skip_threshold;
2513
2514     /** @deprecated use encoder private options instead */
2515     attribute_deprecated
2516     int frame_skip_factor;
2517
2518     /** @deprecated use encoder private options instead */
2519     attribute_deprecated
2520     int frame_skip_exp;
2521
2522     /** @deprecated use encoder private options instead */
2523     attribute_deprecated
2524     int frame_skip_cmp;
2525 #endif /* FF_API_PRIVATE_OPT */
2526
2527     /**
2528      * trellis RD quantization
2529      * - encoding: Set by user.
2530      * - decoding: unused
2531      */
2532     int trellis;
2533
2534 #if FF_API_PRIVATE_OPT
2535     /** @deprecated use encoder private options instead */
2536     attribute_deprecated
2537     int min_prediction_order;
2538
2539     /** @deprecated use encoder private options instead */
2540     attribute_deprecated
2541     int max_prediction_order;
2542
2543     /** @deprecated use encoder private options instead */
2544     attribute_deprecated
2545     int64_t timecode_frame_start;
2546 #endif
2547
2548 #if FF_API_RTP_CALLBACK
2549     /**
2550      * @deprecated unused
2551      */
2552     /* The RTP callback: This function is called    */
2553     /* every time the encoder has a packet to send. */
2554     /* It depends on the encoder if the data starts */
2555     /* with a Start Code (it should). H.263 does.   */
2556     /* mb_nb contains the number of macroblocks     */
2557     /* encoded in the RTP payload.                  */
2558     attribute_deprecated
2559     void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2560 #endif
2561
2562 #if FF_API_PRIVATE_OPT
2563     /** @deprecated use encoder private options instead */
2564     attribute_deprecated
2565     int rtp_payload_size;   /* The size of the RTP payload: the coder will  */
2566                             /* do its best to deliver a chunk with size     */
2567                             /* below rtp_payload_size, the chunk will start */
2568                             /* with a start code on some codecs like H.263. */
2569                             /* This doesn't take account of any particular  */
2570                             /* headers inside the transmitted RTP payload.  */
2571 #endif
2572
2573 #if FF_API_STAT_BITS
2574     /* statistics, used for 2-pass encoding */
2575     attribute_deprecated
2576     int mv_bits;
2577     attribute_deprecated
2578     int header_bits;
2579     attribute_deprecated
2580     int i_tex_bits;
2581     attribute_deprecated
2582     int p_tex_bits;
2583     attribute_deprecated
2584     int i_count;
2585     attribute_deprecated
2586     int p_count;
2587     attribute_deprecated
2588     int skip_count;
2589     attribute_deprecated
2590     int misc_bits;
2591
2592     /** @deprecated this field is unused */
2593     attribute_deprecated
2594     int frame_bits;
2595 #endif
2596
2597     /**
2598      * pass1 encoding statistics output buffer
2599      * - encoding: Set by libavcodec.
2600      * - decoding: unused
2601      */
2602     char *stats_out;
2603
2604     /**
2605      * pass2 encoding statistics input buffer
2606      * Concatenated stuff from stats_out of pass1 should be placed here.
2607      * - encoding: Allocated/set/freed by user.
2608      * - decoding: unused
2609      */
2610     char *stats_in;
2611
2612     /**
2613      * Work around bugs in encoders which sometimes cannot be detected automatically.
2614      * - encoding: Set by user
2615      * - decoding: Set by user
2616      */
2617     int workaround_bugs;
2618 #define FF_BUG_AUTODETECT       1  ///< autodetection
2619 #define FF_BUG_XVID_ILACE       4
2620 #define FF_BUG_UMP4             8
2621 #define FF_BUG_NO_PADDING       16
2622 #define FF_BUG_AMV              32
2623 #define FF_BUG_QPEL_CHROMA      64
2624 #define FF_BUG_STD_QPEL         128
2625 #define FF_BUG_QPEL_CHROMA2     256
2626 #define FF_BUG_DIRECT_BLOCKSIZE 512
2627 #define FF_BUG_EDGE             1024
2628 #define FF_BUG_HPEL_CHROMA      2048
2629 #define FF_BUG_DC_CLIP          4096
2630 #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders.
2631 #define FF_BUG_TRUNCATED       16384
2632 #define FF_BUG_IEDGE           32768
2633
2634     /**
2635      * strictly follow the standard (MPEG-4, ...).
2636      * - encoding: Set by user.
2637      * - decoding: Set by user.
2638      * Setting this to STRICT or higher means the encoder and decoder will
2639      * generally do stupid things, whereas setting it to unofficial or lower
2640      * will mean the encoder might produce output that is not supported by all
2641      * spec-compliant decoders. Decoders don't differentiate between normal,
2642      * unofficial and experimental (that is, they always try to decode things
2643      * when they can) unless they are explicitly asked to behave stupidly
2644      * (=strictly conform to the specs)
2645      */
2646     int strict_std_compliance;
2647 #define FF_COMPLIANCE_VERY_STRICT   2 ///< Strictly conform to an older more strict version of the spec or reference software.
2648 #define FF_COMPLIANCE_STRICT        1 ///< Strictly conform to all the things in the spec no matter what consequences.
2649 #define FF_COMPLIANCE_NORMAL        0
2650 #define FF_COMPLIANCE_UNOFFICIAL   -1 ///< Allow unofficial extensions
2651 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2652
2653     /**
2654      * error concealment flags
2655      * - encoding: unused
2656      * - decoding: Set by user.
2657      */
2658     int error_concealment;
2659 #define FF_EC_GUESS_MVS   1
2660 #define FF_EC_DEBLOCK     2
2661 #define FF_EC_FAVOR_INTER 256
2662
2663     /**
2664      * debug
2665      * - encoding: Set by user.
2666      * - decoding: Set by user.
2667      */
2668     int debug;
2669 #define FF_DEBUG_PICT_INFO   1
2670 #define FF_DEBUG_RC          2
2671 #define FF_DEBUG_BITSTREAM   4
2672 #define FF_DEBUG_MB_TYPE     8
2673 #define FF_DEBUG_QP          16
2674 #if FF_API_DEBUG_MV
2675 /**
2676  * @deprecated this option does nothing
2677  */
2678 #define FF_DEBUG_MV          32
2679 #endif
2680 #define FF_DEBUG_DCT_COEFF   0x00000040
2681 #define FF_DEBUG_SKIP        0x00000080
2682 #define FF_DEBUG_STARTCODE   0x00000100
2683 #define FF_DEBUG_ER          0x00000400
2684 #define FF_DEBUG_MMCO        0x00000800
2685 #define FF_DEBUG_BUGS        0x00001000
2686 #if FF_API_DEBUG_MV
2687 #define FF_DEBUG_VIS_QP      0x00002000
2688 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2689 #endif
2690 #define FF_DEBUG_BUFFERS     0x00008000
2691 #define FF_DEBUG_THREADS     0x00010000
2692 #define FF_DEBUG_GREEN_MD    0x00800000
2693 #define FF_DEBUG_NOMC        0x01000000
2694
2695 #if FF_API_DEBUG_MV
2696     /**
2697      * debug
2698      * - encoding: Set by user.
2699      * - decoding: Set by user.
2700      */
2701     int debug_mv;
2702 #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 // visualize forward predicted MVs of P-frames
2703 #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 // visualize forward predicted MVs of B-frames
2704 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
2705 #endif
2706
2707     /**
2708      * Error recognition; may misdetect some more or less valid parts as errors.
2709      * - encoding: unused
2710      * - decoding: Set by user.
2711      */
2712     int err_recognition;
2713
2714 /**
2715  * Verify checksums embedded in the bitstream (could be of either encoded or
2716  * decoded data, depending on the codec) and print an error message on mismatch.
2717  * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
2718  * decoder returning an error.
2719  */
2720 #define AV_EF_CRCCHECK  (1<<0)
2721 #define AV_EF_BITSTREAM (1<<1)          ///< detect bitstream specification deviations
2722 #define AV_EF_BUFFER    (1<<2)          ///< detect improper bitstream length
2723 #define AV_EF_EXPLODE   (1<<3)          ///< abort decoding on minor error detection
2724
2725 #define AV_EF_IGNORE_ERR (1<<15)        ///< ignore errors and continue
2726 #define AV_EF_CAREFUL    (1<<16)        ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors
2727 #define AV_EF_COMPLIANT  (1<<17)        ///< consider all spec non compliances as errors
2728 #define AV_EF_AGGRESSIVE (1<<18)        ///< consider things that a sane encoder should not do as an error
2729
2730
2731     /**
2732      * opaque 64-bit number (generally a PTS) that will be reordered and
2733      * output in AVFrame.reordered_opaque
2734      * - encoding: Set by libavcodec to the reordered_opaque of the input
2735      *             frame corresponding to the last returned packet. Only
2736      *             supported by encoders with the
2737      *             AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability.
2738      * - decoding: Set by user.
2739      */
2740     int64_t reordered_opaque;
2741
2742     /**
2743      * Hardware accelerator in use
2744      * - encoding: unused.
2745      * - decoding: Set by libavcodec
2746      */
2747     const struct AVHWAccel *hwaccel;
2748
2749     /**
2750      * Hardware accelerator context.
2751      * For some hardware accelerators, a global context needs to be
2752      * provided by the user. In that case, this holds display-dependent
2753      * data FFmpeg cannot instantiate itself. Please refer to the
2754      * FFmpeg HW accelerator documentation to know how to fill this
2755      * is. e.g. for VA API, this is a struct vaapi_context.
2756      * - encoding: unused
2757      * - decoding: Set by user
2758      */
2759     void *hwaccel_context;
2760
2761     /**
2762      * error
2763      * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
2764      * - decoding: unused
2765      */
2766     uint64_t error[AV_NUM_DATA_POINTERS];
2767
2768     /**
2769      * DCT algorithm, see FF_DCT_* below
2770      * - encoding: Set by user.
2771      * - decoding: unused
2772      */
2773     int dct_algo;
2774 #define FF_DCT_AUTO    0
2775 #define FF_DCT_FASTINT 1
2776 #define FF_DCT_INT     2
2777 #define FF_DCT_MMX     3
2778 #define FF_DCT_ALTIVEC 5
2779 #define FF_DCT_FAAN    6
2780
2781     /**
2782      * IDCT algorithm, see FF_IDCT_* below.
2783      * - encoding: Set by user.
2784      * - decoding: Set by user.
2785      */
2786     int idct_algo;
2787 #define FF_IDCT_AUTO          0
2788 #define FF_IDCT_INT           1
2789 #define FF_IDCT_SIMPLE        2
2790 #define FF_IDCT_SIMPLEMMX     3
2791 #define FF_IDCT_ARM           7
2792 #define FF_IDCT_ALTIVEC       8
2793 #define FF_IDCT_SIMPLEARM     10
2794 #define FF_IDCT_XVID          14
2795 #define FF_IDCT_SIMPLEARMV5TE 16
2796 #define FF_IDCT_SIMPLEARMV6   17
2797 #define FF_IDCT_FAAN          20
2798 #define FF_IDCT_SIMPLENEON    22
2799 #define FF_IDCT_NONE          24 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */
2800 #define FF_IDCT_SIMPLEAUTO    128
2801
2802     /**
2803      * bits per sample/pixel from the demuxer (needed for huffyuv).
2804      * - encoding: Set by libavcodec.
2805      * - decoding: Set by user.
2806      */
2807      int bits_per_coded_sample;
2808
2809     /**
2810      * Bits per sample/pixel of internal libavcodec pixel/sample format.
2811      * - encoding: set by user.
2812      * - decoding: set by libavcodec.
2813      */
2814     int bits_per_raw_sample;
2815
2816 #if FF_API_LOWRES
2817     /**
2818      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2819      * - encoding: unused
2820      * - decoding: Set by user.
2821      */
2822      int lowres;
2823 #endif
2824
2825 #if FF_API_CODED_FRAME
2826     /**
2827      * the picture in the bitstream
2828      * - encoding: Set by libavcodec.
2829      * - decoding: unused
2830      *
2831      * @deprecated use the quality factor packet side data instead
2832      */
2833     attribute_deprecated AVFrame *coded_frame;
2834 #endif
2835
2836     /**
2837      * thread count
2838      * is used to decide how many independent tasks should be passed to execute()
2839      * - encoding: Set by user.
2840      * - decoding: Set by user.
2841      */
2842     int thread_count;
2843
2844     /**
2845      * Which multithreading methods to use.
2846      * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2847      * so clients which cannot provide future frames should not use it.
2848      *
2849      * - encoding: Set by user, otherwise the default is used.
2850      * - decoding: Set by user, otherwise the default is used.
2851      */
2852     int thread_type;
2853 #define FF_THREAD_FRAME   1 ///< Decode more than one frame at once
2854 #define FF_THREAD_SLICE   2 ///< Decode more than one part of a single frame at once
2855
2856     /**
2857      * Which multithreading methods are in use by the codec.
2858      * - encoding: Set by libavcodec.
2859      * - decoding: Set by libavcodec.
2860      */
2861     int active_thread_type;
2862
2863     /**
2864      * Set by the client if its custom get_buffer() callback can be called
2865      * synchronously from another thread, which allows faster multithreaded decoding.
2866      * draw_horiz_band() will be called from other threads regardless of this setting.
2867      * Ignored if the default get_buffer() is used.
2868      * - encoding: Set by user.
2869      * - decoding: Set by user.
2870      */
2871     int thread_safe_callbacks;
2872
2873     /**
2874      * The codec may call this to execute several independent things.
2875      * It will return only after finishing all tasks.
2876      * The user may replace this with some multithreaded implementation,
2877      * the default implementation will execute the parts serially.
2878      * @param count the number of things to execute
2879      * - encoding: Set by libavcodec, user can override.
2880      * - decoding: Set by libavcodec, user can override.
2881      */
2882     int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2883
2884     /**
2885      * The codec may call this to execute several independent things.
2886      * It will return only after finishing all tasks.
2887      * The user may replace this with some multithreaded implementation,
2888      * the default implementation will execute the parts serially.
2889      * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2890      * @param c context passed also to func
2891      * @param count the number of things to execute
2892      * @param arg2 argument passed unchanged to func
2893      * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2894      * @param func function that will be called count times, with jobnr from 0 to count-1.
2895      *             threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2896      *             two instances of func executing at the same time will have the same threadnr.
2897      * @return always 0 currently, but code should handle a future improvement where when any call to func
2898      *         returns < 0 no further calls to func may be done and < 0 is returned.
2899      * - encoding: Set by libavcodec, user can override.
2900      * - decoding: Set by libavcodec, user can override.
2901      */
2902     int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2903
2904     /**
2905      * noise vs. sse weight for the nsse comparison function
2906      * - encoding: Set by user.
2907      * - decoding: unused
2908      */
2909      int nsse_weight;
2910
2911     /**
2912      * profile
2913      * - encoding: Set by user.
2914      * - decoding: Set by libavcodec.
2915      */
2916      int profile;
2917 #define FF_PROFILE_UNKNOWN -99
2918 #define FF_PROFILE_RESERVED -100
2919
2920 #define FF_PROFILE_AAC_MAIN 0
2921 #define FF_PROFILE_AAC_LOW  1
2922 #define FF_PROFILE_AAC_SSR  2
2923 #define FF_PROFILE_AAC_LTP  3
2924 #define FF_PROFILE_AAC_HE   4
2925 #define FF_PROFILE_AAC_HE_V2 28
2926 #define FF_PROFILE_AAC_LD   22
2927 #define FF_PROFILE_AAC_ELD  38
2928 #define FF_PROFILE_MPEG2_AAC_LOW 128
2929 #define FF_PROFILE_MPEG2_AAC_HE  131
2930
2931 #define FF_PROFILE_DNXHD         0
2932 #define FF_PROFILE_DNXHR_LB      1
2933 #define FF_PROFILE_DNXHR_SQ      2
2934 #define FF_PROFILE_DNXHR_HQ      3
2935 #define FF_PROFILE_DNXHR_HQX     4
2936 #define FF_PROFILE_DNXHR_444     5
2937
2938 #define FF_PROFILE_DTS         20
2939 #define FF_PROFILE_DTS_ES      30
2940 #define FF_PROFILE_DTS_96_24   40
2941 #define FF_PROFILE_DTS_HD_HRA  50
2942 #define FF_PROFILE_DTS_HD_MA   60
2943 #define FF_PROFILE_DTS_EXPRESS 70
2944
2945 #define FF_PROFILE_MPEG2_422    0
2946 #define FF_PROFILE_MPEG2_HIGH   1
2947 #define FF_PROFILE_MPEG2_SS     2
2948 #define FF_PROFILE_MPEG2_SNR_SCALABLE  3
2949 #define FF_PROFILE_MPEG2_MAIN   4
2950 #define FF_PROFILE_MPEG2_SIMPLE 5
2951
2952 #define FF_PROFILE_H264_CONSTRAINED  (1<<9)  // 8+1; constraint_set1_flag
2953 #define FF_PROFILE_H264_INTRA        (1<<11) // 8+3; constraint_set3_flag
2954
2955 #define FF_PROFILE_H264_BASELINE             66
2956 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2957 #define FF_PROFILE_H264_MAIN                 77
2958 #define FF_PROFILE_H264_EXTENDED             88
2959 #define FF_PROFILE_H264_HIGH                 100
2960 #define FF_PROFILE_H264_HIGH_10              110
2961 #define FF_PROFILE_H264_HIGH_10_INTRA        (110|FF_PROFILE_H264_INTRA)
2962 #define FF_PROFILE_H264_MULTIVIEW_HIGH       118
2963 #define FF_PROFILE_H264_HIGH_422             122
2964 #define FF_PROFILE_H264_HIGH_422_INTRA       (122|FF_PROFILE_H264_INTRA)
2965 #define FF_PROFILE_H264_STEREO_HIGH          128
2966 #define FF_PROFILE_H264_HIGH_444             144
2967 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE  244
2968 #define FF_PROFILE_H264_HIGH_444_INTRA       (244|FF_PROFILE_H264_INTRA)
2969 #define FF_PROFILE_H264_CAVLC_444            44
2970
2971 #define FF_PROFILE_VC1_SIMPLE   0
2972 #define FF_PROFILE_VC1_MAIN     1
2973 #define FF_PROFILE_VC1_COMPLEX  2
2974 #define FF_PROFILE_VC1_ADVANCED 3
2975
2976 #define FF_PROFILE_MPEG4_SIMPLE                     0
2977 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE            1
2978 #define FF_PROFILE_MPEG4_CORE                       2
2979 #define FF_PROFILE_MPEG4_MAIN                       3
2980 #define FF_PROFILE_MPEG4_N_BIT                      4
2981 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE           5
2982 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION      6
2983 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE     7
2984 #define FF_PROFILE_MPEG4_HYBRID                     8
2985 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME         9
2986 #define FF_PROFILE_MPEG4_CORE_SCALABLE             10
2987 #define FF_PROFILE_MPEG4_ADVANCED_CODING           11
2988 #define FF_PROFILE_MPEG4_ADVANCED_CORE             12
2989 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2990 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO             14
2991 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE           15
2992
2993 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0   1
2994 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1   2
2995 #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION  32768
2996 #define FF_PROFILE_JPEG2000_DCINEMA_2K              3
2997 #define FF_PROFILE_JPEG2000_DCINEMA_4K              4
2998
2999 #define FF_PROFILE_VP9_0                            0
3000 #define FF_PROFILE_VP9_1                            1
3001 #define FF_PROFILE_VP9_2                            2
3002 #define FF_PROFILE_VP9_3                            3
3003
3004 #define FF_PROFILE_HEVC_MAIN                        1
3005 #define FF_PROFILE_HEVC_MAIN_10                     2
3006 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE          3
3007 #define FF_PROFILE_HEVC_REXT                        4
3008
3009 #define FF_PROFILE_AV1_MAIN                         0
3010 #define FF_PROFILE_AV1_HIGH                         1
3011 #define FF_PROFILE_AV1_PROFESSIONAL                 2
3012
3013 #define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT            0xc0
3014 #define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1
3015 #define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT         0xc2
3016 #define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS                0xc3
3017 #define FF_PROFILE_MJPEG_JPEG_LS                         0xf7
3018
3019 #define FF_PROFILE_SBC_MSBC                         1
3020
3021 #define FF_PROFILE_PRORES_PROXY     0
3022 #define FF_PROFILE_PRORES_LT        1
3023 #define FF_PROFILE_PRORES_STANDARD  2
3024 #define FF_PROFILE_PRORES_HQ        3
3025 #define FF_PROFILE_PRORES_4444      4
3026 #define FF_PROFILE_PRORES_XQ        5
3027
3028 #define FF_PROFILE_ARIB_PROFILE_A 0
3029 #define FF_PROFILE_ARIB_PROFILE_C 1
3030
3031     /**
3032      * level
3033      * - encoding: Set by user.
3034      * - decoding: Set by libavcodec.
3035      */
3036      int level;
3037 #define FF_LEVEL_UNKNOWN -99
3038
3039     /**
3040      * Skip loop filtering for selected frames.
3041      * - encoding: unused
3042      * - decoding: Set by user.
3043      */
3044     enum AVDiscard skip_loop_filter;
3045
3046     /**
3047      * Skip IDCT/dequantization for selected frames.
3048      * - encoding: unused
3049      * - decoding: Set by user.
3050      */
3051     enum AVDiscard skip_idct;
3052
3053     /**
3054      * Skip decoding for selected frames.
3055      * - encoding: unused
3056      * - decoding: Set by user.
3057      */
3058     enum AVDiscard skip_frame;
3059
3060     /**
3061      * Header containing style information for text subtitles.
3062      * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3063      * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3064      * the Format line following. It shouldn't include any Dialogue line.
3065      * - encoding: Set/allocated/freed by user (before avcodec_open2())
3066      * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3067      */
3068     uint8_t *subtitle_header;
3069     int subtitle_header_size;
3070
3071 #if FF_API_VBV_DELAY
3072     /**
3073      * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3074      * Used for compliant TS muxing.
3075      * - encoding: Set by libavcodec.
3076      * - decoding: unused.
3077      * @deprecated this value is now exported as a part of
3078      * AV_PKT_DATA_CPB_PROPERTIES packet side data
3079      */
3080     attribute_deprecated
3081     uint64_t vbv_delay;
3082 #endif
3083
3084 #if FF_API_SIDEDATA_ONLY_PKT
3085     /**
3086      * Encoding only and set by default. Allow encoders to output packets
3087      * that do not contain any encoded data, only side data.
3088      *
3089      * Some encoders need to output such packets, e.g. to update some stream
3090      * parameters at the end of encoding.
3091      *
3092      * @deprecated this field disables the default behaviour and
3093      *             it is kept only for compatibility.
3094      */
3095     attribute_deprecated
3096     int side_data_only_packets;
3097 #endif
3098
3099     /**
3100      * Audio only. The number of "priming" samples (padding) inserted by the
3101      * encoder at the beginning of the audio. I.e. this number of leading
3102      * decoded samples must be discarded by the caller to get the original audio
3103      * without leading padding.
3104      *
3105      * - decoding: unused
3106      * - encoding: Set by libavcodec. The timestamps on the output packets are
3107      *             adjusted by the encoder so that they always refer to the
3108      *             first sample of the data actually contained in the packet,
3109      *             including any added padding.  E.g. if the timebase is
3110      *             1/samplerate and the timestamp of the first input sample is
3111      *             0, the timestamp of the first output packet will be
3112      *             -initial_padding.
3113      */
3114     int initial_padding;
3115
3116     /**
3117      * - decoding: For codecs that store a framerate value in the compressed
3118      *             bitstream, the decoder may export it here. { 0, 1} when
3119      *             unknown.
3120      * - encoding: May be used to signal the framerate of CFR content to an
3121      *             encoder.
3122      */
3123     AVRational framerate;
3124
3125     /**
3126      * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
3127      * - encoding: unused.
3128      * - decoding: Set by libavcodec before calling get_format()
3129      */
3130     enum AVPixelFormat sw_pix_fmt;
3131
3132     /**
3133      * Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
3134      * - encoding unused.
3135      * - decoding set by user.
3136      */
3137     AVRational pkt_timebase;
3138
3139     /**
3140      * AVCodecDescriptor
3141      * - encoding: unused.
3142      * - decoding: set by libavcodec.
3143      */
3144     const AVCodecDescriptor *codec_descriptor;
3145
3146 #if !FF_API_LOWRES
3147     /**
3148      * low resolution decoding, 1-> 1/2 size, 2->1/4 size
3149      * - encoding: unused
3150      * - decoding: Set by user.
3151      */
3152      int lowres;
3153 #endif
3154
3155     /**
3156      * Current statistics for PTS correction.
3157      * - decoding: maintained and used by libavcodec, not intended to be used by user apps
3158      * - encoding: unused
3159      */
3160     int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far
3161     int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
3162     int64_t pts_correction_last_pts;       /// PTS of the last frame
3163     int64_t pts_correction_last_dts;       /// DTS of the last frame
3164
3165     /**
3166      * Character encoding of the input subtitles file.
3167      * - decoding: set by user
3168      * - encoding: unused
3169      */
3170     char *sub_charenc;
3171
3172     /**
3173      * Subtitles character encoding mode. Formats or codecs might be adjusting
3174      * this setting (if they are doing the conversion themselves for instance).
3175      * - decoding: set by libavcodec
3176      * - encoding: unused
3177      */
3178     int sub_charenc_mode;
3179 #define FF_SUB_CHARENC_MODE_DO_NOTHING  -1  ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance)
3180 #define FF_SUB_CHARENC_MODE_AUTOMATIC    0  ///< libavcodec will select the mode itself
3181 #define FF_SUB_CHARENC_MODE_PRE_DECODER  1  ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv
3182 #define FF_SUB_CHARENC_MODE_IGNORE       2  ///< neither convert the subtitles, nor check them for valid UTF-8
3183
3184     /**
3185      * Skip processing alpha if supported by codec.
3186      * Note that if the format uses pre-multiplied alpha (common with VP6,
3187      * and recommended due to better video quality/compression)
3188      * the image will look as if alpha-blended onto a black background.
3189      * However for formats that do not use pre-multiplied alpha
3190      * there might be serious artefacts (though e.g. libswscale currently
3191      * assumes pre-multiplied alpha anyway).
3192      *
3193      * - decoding: set by user
3194      * - encoding: unused
3195      */
3196     int skip_alpha;
3197
3198     /**
3199      * Number of samples to skip after a discontinuity
3200      * - decoding: unused
3201      * - encoding: set by libavcodec
3202      */
3203     int seek_preroll;
3204
3205 #if !FF_API_DEBUG_MV
3206     /**
3207      * debug motion vectors
3208      * - encoding: Set by user.
3209      * - decoding: Set by user.
3210      */
3211     int debug_mv;
3212 #define FF_DEBUG_VIS_MV_P_FOR  0x00000001 //visualize forward predicted MVs of P frames
3213 #define FF_DEBUG_VIS_MV_B_FOR  0x00000002 //visualize forward predicted MVs of B frames
3214 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
3215 #endif
3216
3217     /**
3218      * custom intra quantization matrix
3219      * - encoding: Set by user, can be NULL.
3220      * - decoding: unused.
3221      */
3222     uint16_t *chroma_intra_matrix;
3223
3224     /**
3225      * dump format separator.
3226      * can be ", " or "\n      " or anything else
3227      * - encoding: Set by user.
3228      * - decoding: Set by user.
3229      */
3230     uint8_t *dump_separator;
3231
3232     /**
3233      * ',' separated list of allowed decoders.
3234      * If NULL then all are allowed
3235      * - encoding: unused
3236      * - decoding: set by user
3237      */
3238     char *codec_whitelist;
3239
3240     /**
3241      * Properties of the stream that gets decoded
3242      * - encoding: unused
3243      * - decoding: set by libavcodec
3244      */
3245     unsigned properties;
3246 #define FF_CODEC_PROPERTY_LOSSLESS        0x00000001
3247 #define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002
3248
3249     /**
3250      * Additional data associated with the entire coded stream.
3251      *
3252      * - decoding: unused
3253      * - encoding: may be set by libavcodec after avcodec_open2().
3254      */
3255     AVPacketSideData *coded_side_data;
3256     int            nb_coded_side_data;
3257
3258     /**
3259      * A reference to the AVHWFramesContext describing the input (for encoding)
3260      * or output (decoding) frames. The reference is set by the caller and
3261      * afterwards owned (and freed) by libavcodec - it should never be read by
3262      * the caller after being set.
3263      *
3264      * - decoding: This field should be set by the caller from the get_format()
3265      *             callback. The previous reference (if any) will always be
3266      *             unreffed by libavcodec before the get_format() call.
3267      *
3268      *             If the default get_buffer2() is used with a hwaccel pixel
3269      *             format, then this AVHWFramesContext will be used for
3270      *             allocating the frame buffers.
3271      *
3272      * - encoding: For hardware encoders configured to use a hwaccel pixel
3273      *             format, this field should be set by the caller to a reference
3274      *             to the AVHWFramesContext describing input frames.
3275      *             AVHWFramesContext.format must be equal to
3276      *             AVCodecContext.pix_fmt.
3277      *
3278      *             This field should be set before avcodec_open2() is called.
3279      */
3280     AVBufferRef *hw_frames_ctx;
3281
3282     /**
3283      * Control the form of AVSubtitle.rects[N]->ass
3284      * - decoding: set by user
3285      * - encoding: unused
3286      */
3287     int sub_text_format;
3288 #define FF_SUB_TEXT_FMT_ASS              0
3289 #if FF_API_ASS_TIMING
3290 #define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1
3291 #endif
3292
3293     /**
3294      * Audio only. The amount of padding (in samples) appended by the encoder to
3295      * the end of the audio. I.e. this number of decoded samples must be
3296      * discarded by the caller from the end of the stream to get the original
3297      * audio without any trailing padding.
3298      *
3299      * - decoding: unused
3300      * - encoding: unused
3301      */
3302     int trailing_padding;
3303
3304     /**
3305      * The number of pixels per image to maximally accept.
3306      *
3307      * - decoding: set by user
3308      * - encoding: set by user
3309      */
3310     int64_t max_pixels;
3311
3312     /**
3313      * A reference to the AVHWDeviceContext describing the device which will
3314      * be used by a hardware encoder/decoder.  The reference is set by the
3315      * caller and afterwards owned (and freed) by libavcodec.
3316      *
3317      * This should be used if either the codec device does not require
3318      * hardware frames or any that are used are to be allocated internally by
3319      * libavcodec.  If the user wishes to supply any of the frames used as
3320      * encoder input or decoder output then hw_frames_ctx should be used
3321      * instead.  When hw_frames_ctx is set in get_format() for a decoder, this
3322      * field will be ignored while decoding the associated stream segment, but
3323      * may again be used on a following one after another get_format() call.
3324      *
3325      * For both encoders and decoders this field should be set before
3326      * avcodec_open2() is called and must not be written to thereafter.
3327      *
3328      * Note that some decoders may require this field to be set initially in
3329      * order to support hw_frames_ctx at all - in that case, all frames
3330      * contexts used must be created on the same device.
3331      */
3332     AVBufferRef *hw_device_ctx;
3333
3334     /**
3335      * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated
3336      * decoding (if active).
3337      * - encoding: unused
3338      * - decoding: Set by user (either before avcodec_open2(), or in the
3339      *             AVCodecContext.get_format callback)
3340      */
3341     int hwaccel_flags;
3342
3343     /**
3344      * Video decoding only. Certain video codecs support cropping, meaning that
3345      * only a sub-rectangle of the decoded frame is intended for display.  This
3346      * option controls how cropping is handled by libavcodec.
3347      *
3348      * When set to 1 (the default), libavcodec will apply cropping internally.
3349      * I.e. it will modify the output frame width/height fields and offset the
3350      * data pointers (only by as much as possible while preserving alignment, or
3351      * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
3352      * the frames output by the decoder refer only to the cropped area. The
3353      * crop_* fields of the output frames will be zero.
3354      *
3355      * When set to 0, the width/height fields of the output frames will be set
3356      * to the coded dimensions and the crop_* fields will describe the cropping
3357      * rectangle. Applying the cropping is left to the caller.
3358      *
3359      * @warning When hardware acceleration with opaque output frames is used,
3360      * libavcodec is unable to apply cropping from the top/left border.
3361      *
3362      * @note when this option is set to zero, the width/height fields of the
3363      * AVCodecContext and output AVFrames have different meanings. The codec
3364      * context fields store display dimensions (with the coded dimensions in
3365      * coded_width/height), while the frame fields store the coded dimensions
3366      * (with the display dimensions being determined by the crop_* fields).
3367      */
3368     int apply_cropping;
3369
3370     /*
3371      * Video decoding only.  Sets the number of extra hardware frames which
3372      * the decoder will allocate for use by the caller.  This must be set
3373      * before avcodec_open2() is called.
3374      *
3375      * Some hardware decoders require all frames that they will use for
3376      * output to be defined in advance before decoding starts.  For such
3377      * decoders, the hardware frame pool must therefore be of a fixed size.
3378      * The extra frames set here are on top of any number that the decoder
3379      * needs internally in order to operate normally (for example, frames
3380      * used as reference pictures).
3381      */
3382     int extra_hw_frames;
3383
3384     /**
3385      * The percentage of damaged samples to discard a frame.
3386      *
3387      * - decoding: set by user
3388      * - encoding: unused
3389      */
3390     int discard_damaged_percentage;
3391
3392     /**
3393      * The number of samples per frame to maximally accept.
3394      *
3395      * - decoding: set by user
3396      * - encoding: set by user
3397      */
3398     int64_t max_samples;
3399 } AVCodecContext;
3400
3401 #if FF_API_CODEC_GET_SET
3402 /**
3403  * Accessors for some AVCodecContext fields. These used to be provided for ABI
3404  * compatibility, and do not need to be used anymore.
3405  */
3406 attribute_deprecated
3407 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
3408 attribute_deprecated
3409 void       av_codec_set_pkt_timebase         (AVCodecContext *avctx, AVRational val);
3410
3411 attribute_deprecated
3412 const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx);
3413 attribute_deprecated
3414 void                     av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc);
3415
3416 attribute_deprecated
3417 unsigned av_codec_get_codec_properties(const AVCodecContext *avctx);
3418
3419 #if FF_API_LOWRES
3420 attribute_deprecated
3421 int  av_codec_get_lowres(const AVCodecContext *avctx);
3422 attribute_deprecated
3423 void av_codec_set_lowres(AVCodecContext *avctx, int val);
3424 #endif
3425
3426 attribute_deprecated
3427 int  av_codec_get_seek_preroll(const AVCodecContext *avctx);
3428 attribute_deprecated
3429 void av_codec_set_seek_preroll(AVCodecContext *avctx, int val);
3430
3431 attribute_deprecated
3432 uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx);
3433 attribute_deprecated
3434 void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val);
3435 #endif
3436
3437 /**
3438  * AVProfile.
3439  */
3440 typedef struct AVProfile {
3441     int profile;
3442     const char *name; ///< short name for the profile
3443 } AVProfile;
3444
3445 enum {
3446     /**
3447      * The codec supports this format via the hw_device_ctx interface.
3448      *
3449      * When selecting this format, AVCodecContext.hw_device_ctx should
3450      * have been set to a device of the specified type before calling
3451      * avcodec_open2().
3452      */
3453     AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
3454     /**
3455      * The codec supports this format via the hw_frames_ctx interface.
3456      *
3457      * When selecting this format for a decoder,
3458      * AVCodecContext.hw_frames_ctx should be set to a suitable frames
3459      * context inside the get_format() callback.  The frames context
3460      * must have been created on a device of the specified type.
3461      */
3462     AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
3463     /**
3464      * The codec supports this format by some internal method.
3465      *
3466      * This format can be selected without any additional configuration -
3467      * no device or frames context is required.
3468      */
3469     AV_CODEC_HW_CONFIG_METHOD_INTERNAL      = 0x04,
3470     /**
3471      * The codec supports this format by some ad-hoc method.
3472      *
3473      * Additional settings and/or function calls are required.  See the
3474      * codec-specific documentation for details.  (Methods requiring
3475      * this sort of configuration are deprecated and others should be
3476      * used in preference.)
3477      */
3478     AV_CODEC_HW_CONFIG_METHOD_AD_HOC        = 0x08,
3479 };
3480
3481 typedef struct AVCodecHWConfig {
3482     /**
3483      * A hardware pixel format which the codec can use.
3484      */
3485     enum AVPixelFormat pix_fmt;
3486     /**
3487      * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
3488      * setup methods which can be used with this configuration.
3489      */
3490     int methods;
3491     /**
3492      * The device type associated with the configuration.
3493      *
3494      * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
3495      * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
3496      */
3497     enum AVHWDeviceType device_type;
3498 } AVCodecHWConfig;
3499
3500 typedef struct AVCodecDefault AVCodecDefault;
3501
3502 struct AVSubtitle;
3503
3504 /**
3505  * AVCodec.
3506  */
3507 typedef struct AVCodec {
3508     /**
3509      * Name of the codec implementation.
3510      * The name is globally unique among encoders and among decoders (but an
3511      * encoder and a decoder can share the same name).
3512      * This is the primary way to find a codec from the user perspective.
3513      */
3514     const char *name;
3515     /**
3516      * Descriptive name for the codec, meant to be more human readable than name.
3517      * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3518      */
3519     const char *long_name;
3520     enum AVMediaType type;
3521     enum AVCodecID id;
3522     /**
3523      * Codec capabilities.
3524      * see AV_CODEC_CAP_*
3525      */
3526     int capabilities;
3527     const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3528     const enum AVPixelFormat *pix_fmts;     ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3529     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3530     const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3531     const uint64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3532     uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
3533     const AVClass *priv_class;              ///< AVClass for the private context
3534     const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3535
3536     /**
3537      * Group name of the codec implementation.
3538      * This is a short symbolic name of the wrapper backing this codec. A
3539      * wrapper uses some kind of external implementation for the codec, such
3540      * as an external library, or a codec implementation provided by the OS or
3541      * the hardware.
3542      * If this field is NULL, this is a builtin, libavcodec native codec.
3543      * If non-NULL, this will be the suffix in AVCodec.name in most cases
3544      * (usually AVCodec.name will be of the form "<codec_name>_<wrapper_name>").
3545      */
3546     const char *wrapper_name;
3547
3548     /*****************************************************************
3549      * No fields below this line are part of the public API. They
3550      * may not be used outside of libavcodec and can be changed and
3551      * removed at will.
3552      * New public fields should be added right above.
3553      *****************************************************************
3554      */
3555     int priv_data_size;
3556     struct AVCodec *next;
3557     /**
3558      * @name Frame-level threading support functions
3559      * @{
3560      */
3561     /**
3562      * If defined, called on thread contexts when they are created.
3563      * If the codec allocates writable tables in init(), re-allocate them here.
3564      * priv_data will be set to a copy of the original.
3565      */
3566     int (*init_thread_copy)(AVCodecContext *);
3567     /**
3568      * Copy necessary context variables from a previous thread context to the current one.
3569      * If not defined, the next thread will start automatically; otherwise, the codec
3570      * must call ff_thread_finish_setup().
3571      *
3572      * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3573      */
3574     int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
3575     /** @} */
3576
3577     /**
3578      * Private codec-specific defaults.
3579      */
3580     const AVCodecDefault *defaults;
3581
3582     /**
3583      * Initialize codec static data, called from avcodec_register().
3584      *
3585      * This is not intended for time consuming operations as it is
3586      * run for every codec regardless of that codec being used.
3587      */
3588     void (*init_static_data)(struct AVCodec *codec);
3589
3590     int (*init)(AVCodecContext *);
3591     int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
3592                       const struct AVSubtitle *sub);
3593     /**
3594      * Encode data to an AVPacket.
3595      *
3596      * @param      avctx          codec context
3597      * @param      avpkt          output AVPacket (may contain a user-provided buffer)
3598      * @param[in]  frame          AVFrame containing the raw data to be encoded
3599      * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3600      *                            non-empty packet was returned in avpkt.
3601      * @return 0 on success, negative error code on failure
3602      */
3603     int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3604                    int *got_packet_ptr);
3605     int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3606     int (*close)(AVCodecContext *);
3607     /**
3608      * Encode API with decoupled packet/frame dataflow. The API is the
3609      * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except
3610      * that:
3611      * - never called if the codec is closed or the wrong type,
3612      * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent,
3613      * - only one drain frame is ever passed down,
3614      */
3615     int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame);
3616     int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt);
3617
3618     /**
3619      * Decode API with decoupled packet/frame dataflow. This function is called
3620      * to get one output frame. It should call ff_decode_get_packet() to obtain
3621      * input data.
3622      */
3623     int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame);
3624     /**
3625      * Flush buffers.
3626      * Will be called when seeking
3627      */
3628     void (*flush)(AVCodecContext *);
3629     /**
3630      * Internal codec capabilities.
3631      * See FF_CODEC_CAP_* in internal.h
3632      */
3633     int caps_internal;
3634
3635     /**
3636      * Decoding only, a comma-separated list of bitstream filters to apply to
3637      * packets before decoding.
3638      */
3639     const char *bsfs;
3640
3641     /**
3642      * Array of pointers to hardware configurations supported by the codec,
3643      * or NULL if no hardware supported.  The array is terminated by a NULL
3644      * pointer.
3645      *
3646      * The user can only access this field via avcodec_get_hw_config().
3647      */
3648     const struct AVCodecHWConfigInternal **hw_configs;
3649
3650     /**
3651      * List of supported codec_tags, terminated by FF_CODEC_TAGS_END.
3652      */
3653     const uint32_t *codec_tags;
3654 } AVCodec;
3655
3656 #if FF_API_CODEC_GET_SET
3657 attribute_deprecated
3658 int av_codec_get_max_lowres(const AVCodec *codec);
3659 #endif
3660
3661 struct MpegEncContext;
3662
3663 /**
3664  * Retrieve supported hardware configurations for a codec.
3665  *
3666  * Values of index from zero to some maximum return the indexed configuration
3667  * descriptor; all other values return NULL.  If the codec does not support
3668  * any hardware configurations then it will always return NULL.
3669  */
3670 const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index);
3671
3672 /**
3673  * @defgroup lavc_hwaccel AVHWAccel
3674  *
3675  * @note  Nothing in this structure should be accessed by the user.  At some
3676  *        point in future it will not be externally visible at all.
3677  *
3678  * @{
3679  */
3680 typedef struct AVHWAccel {
3681     /**
3682      * Name of the hardware accelerated codec.
3683      * The name is globally unique among encoders and among decoders (but an
3684      * encoder and a decoder can share the same name).
3685      */
3686     const char *name;
3687
3688     /**
3689      * Type of codec implemented by the hardware accelerator.
3690      *
3691      * See AVMEDIA_TYPE_xxx
3692      */
3693     enum AVMediaType type;
3694
3695     /**
3696      * Codec implemented by the hardware accelerator.
3697      *
3698      * See AV_CODEC_ID_xxx
3699      */
3700     enum AVCodecID id;
3701
3702     /**
3703      * Supported pixel format.
3704      *
3705      * Only hardware accelerated formats are supported here.
3706      */
3707     enum AVPixelFormat pix_fmt;
3708
3709     /**
3710      * Hardware accelerated codec capabilities.
3711      * see AV_HWACCEL_CODEC_CAP_*
3712      */
3713     int capabilities;
3714
3715     /*****************************************************************
3716      * No fields below this line are part of the public API. They
3717      * may not be used outside of libavcodec and can be changed and
3718      * removed at will.
3719      * New public fields should be added right above.
3720      *****************************************************************
3721      */
3722
3723     /**
3724      * Allocate a custom buffer
3725      */
3726     int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
3727
3728     /**
3729      * Called at the beginning of each frame or field picture.
3730      *
3731      * Meaningful frame information (codec specific) is guaranteed to
3732      * be parsed at this point. This function is mandatory.
3733      *
3734      * Note that buf can be NULL along with buf_size set to 0.
3735      * Otherwise, this means the whole frame is available at this point.
3736      *
3737      * @param avctx the codec context
3738      * @param buf the frame data buffer base
3739      * @param buf_size the size of the frame in bytes
3740      * @return zero if successful, a negative value otherwise
3741      */
3742     int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3743
3744     /**
3745      * Callback for parameter data (SPS/PPS/VPS etc).
3746      *
3747      * Useful for hardware decoders which keep persistent state about the
3748      * video parameters, and need to receive any changes to update that state.
3749      *
3750      * @param avctx the codec context
3751      * @param type the nal unit type
3752      * @param buf the nal unit data buffer
3753      * @param buf_size the size of the nal unit in bytes
3754      * @return zero if successful, a negative value otherwise
3755      */
3756     int (*decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size);
3757
3758     /**
3759      * Callback for each slice.
3760      *
3761      * Meaningful slice information (codec specific) is guaranteed to
3762      * be parsed at this point. This function is mandatory.
3763      * The only exception is XvMC, that works on MB level.
3764      *
3765      * @param avctx the codec context
3766      * @param buf the slice data buffer base
3767      * @param buf_size the size of the slice in bytes
3768      * @return zero if successful, a negative value otherwise
3769      */
3770     int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3771
3772     /**
3773      * Called at the end of each frame or field picture.
3774      *
3775      * The whole picture is parsed at this point and can now be sent
3776      * to the hardware accelerator. This function is mandatory.
3777      *
3778      * @param avctx the codec context
3779      * @return zero if successful, a negative value otherwise
3780      */
3781     int (*end_frame)(AVCodecContext *avctx);
3782
3783     /**
3784      * Size of per-frame hardware accelerator private data.
3785      *
3786      * Private data is allocated with av_mallocz() before
3787      * AVCodecContext.get_buffer() and deallocated after
3788      * AVCodecContext.release_buffer().
3789      */
3790     int frame_priv_data_size;
3791
3792     /**
3793      * Called for every Macroblock in a slice.
3794      *
3795      * XvMC uses it to replace the ff_mpv_reconstruct_mb().
3796      * Instead of decoding to raw picture, MB parameters are
3797      * stored in an array provided by the video driver.
3798      *
3799      * @param s the mpeg context
3800      */
3801     void (*decode_mb)(struct MpegEncContext *s);
3802
3803     /**
3804      * Initialize the hwaccel private data.
3805      *
3806      * This will be called from ff_get_format(), after hwaccel and
3807      * hwaccel_context are set and the hwaccel private data in AVCodecInternal
3808      * is allocated.
3809      */
3810     int (*init)(AVCodecContext *avctx);
3811
3812     /**
3813      * Uninitialize the hwaccel private data.
3814      *
3815      * This will be called from get_format() or avcodec_close(), after hwaccel
3816      * and hwaccel_context are already uninitialized.
3817      */
3818     int (*uninit)(AVCodecContext *avctx);
3819
3820     /**
3821      * Size of the private data to allocate in
3822      * AVCodecInternal.hwaccel_priv_data.
3823      */
3824     int priv_data_size;
3825
3826     /**
3827      * Internal hwaccel capabilities.
3828      */
3829     int caps_internal;
3830
3831     /**
3832      * Fill the given hw_frames context with current codec parameters. Called
3833      * from get_format. Refer to avcodec_get_hw_frames_parameters() for
3834      * details.
3835      *
3836      * This CAN be called before AVHWAccel.init is called, and you must assume
3837      * that avctx->hwaccel_priv_data is invalid.
3838      */
3839     int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx);
3840 } AVHWAccel;
3841
3842 /**
3843  * HWAccel is experimental and is thus avoided in favor of non experimental
3844  * codecs
3845  */
3846 #define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL 0x0200
3847
3848 /**
3849  * Hardware acceleration should be used for decoding even if the codec level
3850  * used is unknown or higher than the maximum supported level reported by the
3851  * hardware driver.
3852  *
3853  * It's generally a good idea to pass this flag unless you have a specific
3854  * reason not to, as hardware tends to under-report supported levels.
3855  */
3856 #define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)
3857
3858 /**
3859  * Hardware acceleration can output YUV pixel formats with a different chroma
3860  * sampling than 4:2:0 and/or other than 8 bits per component.
3861  */
3862 #define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)
3863
3864 /**
3865  * Hardware acceleration should still be attempted for decoding when the
3866  * codec profile does not match the reported capabilities of the hardware.
3867  *
3868  * For example, this can be used to try to decode baseline profile H.264
3869  * streams in hardware - it will often succeed, because many streams marked
3870  * as baseline profile actually conform to constrained baseline profile.
3871  *
3872  * @warning If the stream is actually not supported then the behaviour is
3873  *          undefined, and may include returning entirely incorrect output
3874  *          while indicating success.
3875  */
3876 #define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2)
3877
3878 /**
3879  * @}
3880  */
3881
3882 #if FF_API_AVPICTURE
3883 /**
3884  * @defgroup lavc_picture AVPicture
3885  *
3886  * Functions for working with AVPicture
3887  * @{
3888  */
3889
3890 /**
3891  * Picture data structure.
3892  *
3893  * Up to four components can be stored into it, the last component is
3894  * alpha.
3895  * @deprecated use AVFrame or imgutils functions instead
3896  */
3897 typedef struct AVPicture {
3898     attribute_deprecated
3899     uint8_t *data[AV_NUM_DATA_POINTERS];    ///< pointers to the image data planes
3900     attribute_deprecated
3901     int linesize[AV_NUM_DATA_POINTERS];     ///< number of bytes per line
3902 } AVPicture;
3903
3904 /**
3905  * @}
3906  */
3907 #endif
3908
3909 enum AVSubtitleType {
3910     SUBTITLE_NONE,
3911
3912     SUBTITLE_BITMAP,                ///< A bitmap, pict will be set
3913
3914     /**
3915      * Plain text, the text field must be set by the decoder and is
3916      * authoritative. ass and pict fields may contain approximations.
3917      */
3918     SUBTITLE_TEXT,
3919
3920     /**
3921      * Formatted text, the ass field must be set by the decoder and is
3922      * authoritative. pict and text fields may contain approximations.
3923      */
3924     SUBTITLE_ASS,
3925 };
3926
3927 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
3928
3929 typedef struct AVSubtitleRect {
3930     int x;         ///< top left corner  of pict, undefined when pict is not set
3931     int y;         ///< top left corner  of pict, undefined when pict is not set
3932     int w;         ///< width            of pict, undefined when pict is not set
3933     int h;         ///< height           of pict, undefined when pict is not set
3934     int nb_colors; ///< number of colors in pict, undefined when pict is not set
3935
3936 #if FF_API_AVPICTURE
3937     /**
3938      * @deprecated unused
3939      */
3940     attribute_deprecated
3941     AVPicture pict;
3942 #endif
3943     /**
3944      * data+linesize for the bitmap of this subtitle.
3945      * Can be set for text/ass as well once they are rendered.
3946      */
3947     uint8_t *data[4];
3948     int linesize[4];
3949
3950     enum AVSubtitleType type;
3951
3952     char *text;                     ///< 0 terminated plain UTF-8 text
3953
3954     /**
3955      * 0 terminated ASS/SSA compatible event line.
3956      * The presentation of this is unaffected by the other values in this
3957      * struct.
3958      */
3959     char *ass;
3960
3961     int flags;
3962 } AVSubtitleRect;
3963
3964 typedef struct AVSubtitle {
3965     uint16_t format; /* 0 = graphics */
3966     uint32_t start_display_time; /* relative to packet pts, in ms */
3967     uint32_t end_display_time; /* relative to packet pts, in ms */
3968     unsigned num_rects;
3969     AVSubtitleRect **rects;
3970     int64_t pts;    ///< Same as packet pts, in AV_TIME_BASE
3971 } AVSubtitle;
3972
3973 /**
3974  * This struct describes the properties of an encoded stream.
3975  *
3976  * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
3977  * be allocated with avcodec_parameters_alloc() and freed with
3978  * avcodec_parameters_free().
3979  */
3980 typedef struct AVCodecParameters {
3981     /**
3982      * General type of the encoded data.
3983      */
3984     enum AVMediaType codec_type;
3985     /**
3986      * Specific type of the encoded data (the codec used).
3987      */
3988     enum AVCodecID   codec_id;
3989     /**
3990      * Additional information about the codec (corresponds to the AVI FOURCC).
3991      */
3992     uint32_t         codec_tag;
3993
3994     /**
3995      * Extra binary data needed for initializing the decoder, codec-dependent.
3996      *
3997      * Must be allocated with av_malloc() and will be freed by
3998      * avcodec_parameters_free(). The allocated size of extradata must be at
3999      * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
4000      * bytes zeroed.
4001      */
4002     uint8_t *extradata;
4003     /**
4004      * Size of the extradata content in bytes.
4005      */
4006     int      extradata_size;
4007
4008     /**
4009      * - video: the pixel format, the value corresponds to enum AVPixelFormat.
4010      * - audio: the sample format, the value corresponds to enum AVSampleFormat.
4011      */
4012     int format;
4013
4014     /**
4015      * The average bitrate of the encoded data (in bits per second).
4016      */
4017     int64_t bit_rate;
4018
4019     /**
4020      * The number of bits per sample in the codedwords.
4021      *
4022      * This is basically the bitrate per sample. It is mandatory for a bunch of
4023      * formats to actually decode them. It's the number of bits for one sample in
4024      * the actual coded bitstream.
4025      *
4026      * This could be for example 4 for ADPCM
4027      * For PCM formats this matches bits_per_raw_sample
4028      * Can be 0
4029      */
4030     int bits_per_coded_sample;
4031
4032     /**
4033      * This is the number of valid bits in each output sample. If the
4034      * sample format has more bits, the least significant bits are additional
4035      * padding bits, which are always 0. Use right shifts to reduce the sample
4036      * to its actual size. For example, audio formats with 24 bit samples will
4037      * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32.
4038      * To get the original sample use "(int32_t)sample >> 8"."
4039      *
4040      * For ADPCM this might be 12 or 16 or similar
4041      * Can be 0
4042      */
4043     int bits_per_raw_sample;
4044
4045     /**
4046      * Codec-specific bitstream restrictions that the stream conforms to.
4047      */
4048     int profile;
4049     int level;
4050
4051     /**
4052      * Video only. The dimensions of the video frame in pixels.
4053      */
4054     int width;
4055     int height;
4056
4057     /**
4058      * Video only. The aspect ratio (width / height) which a single pixel
4059      * should have when displayed.
4060      *
4061      * When the aspect ratio is unknown / undefined, the numerator should be
4062      * set to 0 (the denominator may have any value).
4063      */
4064     AVRational sample_aspect_ratio;
4065
4066     /**
4067      * Video only. The order of the fields in interlaced video.
4068      */
4069     enum AVFieldOrder                  field_order;
4070
4071     /**
4072      * Video only. Additional colorspace characteristics.
4073      */
4074     enum AVColorRange                  color_range;
4075     enum AVColorPrimaries              color_primaries;
4076     enum AVColorTransferCharacteristic color_trc;
4077     enum AVColorSpace                  color_space;
4078     enum AVChromaLocation              chroma_location;
4079
4080     /**
4081      * Video only. Number of delayed frames.
4082      */
4083     int video_delay;
4084
4085     /**
4086      * Audio only. The channel layout bitmask. May be 0 if the channel layout is
4087      * unknown or unspecified, otherwise the number of bits set must be equal to
4088      * the channels field.
4089      */
4090     uint64_t channel_layout;
4091     /**
4092      * Audio only. The number of audio channels.
4093      */
4094     int      channels;
4095     /**
4096      * Audio only. The number of audio samples per second.
4097      */
4098     int      sample_rate;
4099     /**
4100      * Audio only. The number of bytes per coded audio frame, required by some
4101      * formats.
4102      *
4103      * Corresponds to nBlockAlign in WAVEFORMATEX.
4104      */
4105     int      block_align;
4106     /**
4107      * Audio only. Audio frame size, if known. Required by some formats to be static.
4108      */
4109     int      frame_size;
4110
4111     /**
4112      * Audio only. The amount of padding (in samples) inserted by the encoder at
4113      * the beginning of the audio. I.e. this number of leading decoded samples
4114      * must be discarded by the caller to get the original audio without leading
4115      * padding.
4116      */
4117     int initial_padding;
4118     /**
4119      * Audio only. The amount of padding (in samples) appended by the encoder to
4120      * the end of the audio. I.e. this number of decoded samples must be
4121      * discarded by the caller from the end of the stream to get the original
4122      * audio without any trailing padding.
4123      */
4124     int trailing_padding;
4125     /**
4126      * Audio only. Number of samples to skip after a discontinuity.
4127      */
4128     int seek_preroll;
4129 } AVCodecParameters;
4130
4131 /**
4132  * Iterate over all registered codecs.
4133  *
4134  * @param opaque a pointer where libavcodec will store the iteration state. Must
4135  *               point to NULL to start the iteration.
4136  *
4137  * @return the next registered codec or NULL when the iteration is
4138  *         finished
4139  */
4140 const AVCodec *av_codec_iterate(void **opaque);
4141
4142 #if FF_API_NEXT
4143 /**
4144  * If c is NULL, returns the first registered codec,
4145  * if c is non-NULL, returns the next registered codec after c,
4146  * or NULL if c is the last one.
4147  */
4148 attribute_deprecated
4149 AVCodec *av_codec_next(const AVCodec *c);
4150 #endif
4151
4152 /**
4153  * Return the LIBAVCODEC_VERSION_INT constant.
4154  */
4155 unsigned avcodec_version(void);
4156
4157 /**
4158  * Return the libavcodec build-time configuration.
4159  */
4160 const char *avcodec_configuration(void);
4161
4162 /**
4163  * Return the libavcodec license.
4164  */
4165 const char *avcodec_license(void);
4166
4167 #if FF_API_NEXT
4168 /**
4169  * Register the codec codec and initialize libavcodec.
4170  *
4171  * @warning either this function or avcodec_register_all() must be called
4172  * before any other libavcodec functions.
4173  *
4174  * @see avcodec_register_all()
4175  */
4176 attribute_deprecated
4177 void avcodec_register(AVCodec *codec);
4178
4179 /**
4180  * Register all the codecs, parsers and bitstream filters which were enabled at
4181  * configuration time. If you do not call this function you can select exactly
4182  * which formats you want to support, by using the individual registration
4183  * functions.
4184  *
4185  * @see avcodec_register
4186  * @see av_register_codec_parser
4187  * @see av_register_bitstream_filter
4188  */
4189 attribute_deprecated
4190 void avcodec_register_all(void);
4191 #endif
4192
4193 /**
4194  * Allocate an AVCodecContext and set its fields to default values. The
4195  * resulting struct should be freed with avcodec_free_context().
4196  *
4197  * @param codec if non-NULL, allocate private data and initialize defaults
4198  *              for the given codec. It is illegal to then call avcodec_open2()
4199  *              with a different codec.
4200  *              If NULL, then the codec-specific defaults won't be initialized,
4201  *              which may result in suboptimal default settings (this is
4202  *              important mainly for encoders, e.g. libx264).
4203  *
4204  * @return An AVCodecContext filled with default values or NULL on failure.
4205  */
4206 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
4207
4208 /**
4209  * Free the codec context and everything associated with it and write NULL to
4210  * the provided pointer.
4211  */
4212 void avcodec_free_context(AVCodecContext **avctx);
4213
4214 #if FF_API_GET_CONTEXT_DEFAULTS
4215 /**
4216  * @deprecated This function should not be used, as closing and opening a codec
4217  * context multiple time is not supported. A new codec context should be
4218  * allocated for each new use.
4219  */
4220 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
4221 #endif
4222
4223 /**
4224  * Get the AVClass for AVCodecContext. It can be used in combination with
4225  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
4226  *
4227  * @see av_opt_find().
4228  */
4229 const AVClass *avcodec_get_class(void);
4230
4231 #if FF_API_COPY_CONTEXT
4232 /**
4233  * Get the AVClass for AVFrame. It can be used in combination with
4234  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
4235  *
4236  * @see av_opt_find().
4237  */
4238 const AVClass *avcodec_get_frame_class(void);
4239
4240 /**
4241  * Get the AVClass for AVSubtitleRect. It can be used in combination with
4242  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
4243  *
4244  * @see av_opt_find().
4245  */
4246 const AVClass *avcodec_get_subtitle_rect_class(void);
4247
4248 /**
4249  * Copy the settings of the source AVCodecContext into the destination
4250  * AVCodecContext. The resulting destination codec context will be
4251  * unopened, i.e. you are required to call avcodec_open2() before you
4252  * can use this AVCodecContext to decode/encode video/audio data.
4253  *
4254  * @param dest target codec context, should be initialized with
4255  *             avcodec_alloc_context3(NULL), but otherwise uninitialized
4256  * @param src source codec context
4257  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
4258  *
4259  * @deprecated The semantics of this function are ill-defined and it should not
4260  * be used. If you need to transfer the stream parameters from one codec context
4261  * to another, use an intermediate AVCodecParameters instance and the
4262  * avcodec_parameters_from_context() / avcodec_parameters_to_context()
4263  * functions.
4264  */
4265 attribute_deprecated
4266 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
4267 #endif
4268
4269 /**
4270  * Allocate a new AVCodecParameters and set its fields to default values
4271  * (unknown/invalid/0). The returned struct must be freed with
4272  * avcodec_parameters_free().
4273  */
4274 AVCodecParameters *avcodec_parameters_alloc(void);
4275
4276 /**
4277  * Free an AVCodecParameters instance and everything associated with it and
4278  * write NULL to the supplied pointer.
4279  */
4280 void avcodec_parameters_free(AVCodecParameters **par);
4281
4282 /**
4283  * Copy the contents of src to dst. Any allocated fields in dst are freed and
4284  * replaced with newly allocated duplicates of the corresponding fields in src.
4285  *
4286  * @return >= 0 on success, a negative AVERROR code on failure.
4287  */
4288 int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
4289
4290 /**
4291  * Fill the parameters struct based on the values from the supplied codec
4292  * context. Any allocated fields in par are freed and replaced with duplicates
4293  * of the corresponding fields in codec.
4294  *
4295  * @return >= 0 on success, a negative AVERROR code on failure
4296  */
4297 int avcodec_parameters_from_context(AVCodecParameters *par,
4298                                     const AVCodecContext *codec);
4299
4300 /**
4301  * Fill the codec context based on the values from the supplied codec
4302  * parameters. Any allocated fields in codec that have a corresponding field in
4303  * par are freed and replaced with duplicates of the corresponding field in par.
4304  * Fields in codec that do not have a counterpart in par are not touched.
4305  *
4306  * @return >= 0 on success, a negative AVERROR code on failure.
4307  */
4308 int avcodec_parameters_to_context(AVCodecContext *codec,
4309                                   const AVCodecParameters *par);
4310
4311 /**
4312  * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
4313  * function the context has to be allocated with avcodec_alloc_context3().
4314  *
4315  * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
4316  * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
4317  * retrieving a codec.
4318  *
4319  * @warning This function is not thread safe!
4320  *
4321  * @note Always call this function before using decoding routines (such as
4322  * @ref avcodec_receive_frame()).
4323  *
4324  * @code
4325  * avcodec_register_all();
4326  * av_dict_set(&opts, "b", "2.5M", 0);
4327  * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
4328  * if (!codec)
4329  *     exit(1);
4330  *
4331  * context = avcodec_alloc_context3(codec);
4332  *
4333  * if (avcodec_open2(context, codec, opts) < 0)
4334  *     exit(1);
4335  * @endcode
4336  *
4337  * @param avctx The context to initialize.
4338  * @param codec The codec to open this context for. If a non-NULL codec has been
4339  *              previously passed to avcodec_alloc_context3() or
4340  *              for this context, then this parameter MUST be either NULL or
4341  *              equal to the previously passed codec.
4342  * @param options A dictionary filled with AVCodecContext and codec-private options.
4343  *                On return this object will be filled with options that were not found.
4344  *
4345  * @return zero on success, a negative value on error
4346  * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
4347  *      av_dict_set(), av_opt_find().
4348  */
4349 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
4350
4351 /**
4352  * Close a given AVCodecContext and free all the data associated with it
4353  * (but not the AVCodecContext itself).
4354  *
4355  * Calling this function on an AVCodecContext that hasn't been opened will free
4356  * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
4357  * codec. Subsequent calls will do nothing.
4358  *
4359  * @note Do not use this function. Use avcodec_free_context() to destroy a
4360  * codec context (either open or closed). Opening and closing a codec context
4361  * multiple times is not supported anymore -- use multiple codec contexts
4362  * instead.
4363  */
4364 int avcodec_close(AVCodecContext *avctx);
4365
4366 /**
4367  * Free all allocated data in the given subtitle struct.
4368  *
4369  * @param sub AVSubtitle to free.
4370  */
4371 void avsubtitle_free(AVSubtitle *sub);
4372
4373 /**
4374  * @}
4375  */
4376
4377 /**
4378  * @addtogroup lavc_packet
4379  * @{
4380  */
4381
4382 /**
4383  * Allocate an AVPacket and set its fields to default values.  The resulting
4384  * struct must be freed using av_packet_free().
4385  *
4386  * @return An AVPacket filled with default values or NULL on failure.
4387  *
4388  * @note this only allocates the AVPacket itself, not the data buffers. Those
4389  * must be allocated through other means such as av_new_packet.
4390  *
4391  * @see av_new_packet
4392  */
4393 AVPacket *av_packet_alloc(void);
4394
4395 /**
4396  * Create a new packet that references the same data as src.
4397  *
4398  * This is a shortcut for av_packet_alloc()+av_packet_ref().
4399  *
4400  * @return newly created AVPacket on success, NULL on error.
4401  *
4402  * @see av_packet_alloc
4403  * @see av_packet_ref
4404  */
4405 AVPacket *av_packet_clone(const AVPacket *src);
4406
4407 /**
4408  * Free the packet, if the packet is reference counted, it will be
4409  * unreferenced first.
4410  *
4411  * @param pkt packet to be freed. The pointer will be set to NULL.
4412  * @note passing NULL is a no-op.
4413  */
4414 void av_packet_free(AVPacket **pkt);
4415
4416 /**
4417  * Initialize optional fields of a packet with default values.
4418  *
4419  * Note, this does not touch the data and size members, which have to be
4420  * initialized separately.
4421  *
4422  * @param pkt packet
4423  */
4424 void av_init_packet(AVPacket *pkt);
4425
4426 /**
4427  * Allocate the payload of a packet and initialize its fields with
4428  * default values.
4429  *
4430  * @param pkt packet
4431  * @param size wanted payload size
4432  * @return 0 if OK, AVERROR_xxx otherwise
4433  */
4434 int av_new_packet(AVPacket *pkt, int size);
4435
4436 /**
4437  * Reduce packet size, correctly zeroing padding
4438  *
4439  * @param pkt packet
4440  * @param size new size
4441  */
4442 void av_shrink_packet(AVPacket *pkt, int size);
4443
4444 /**
4445  * Increase packet size, correctly zeroing padding
4446  *
4447  * @param pkt packet
4448  * @param grow_by number of bytes by which to increase the size of the packet
4449  */
4450 int av_grow_packet(AVPacket *pkt, int grow_by);
4451
4452 /**
4453  * Initialize a reference-counted packet from av_malloc()ed data.
4454  *
4455  * @param pkt packet to be initialized. This function will set the data, size,
4456  *        and buf fields, all others are left untouched.
4457  * @param data Data allocated by av_malloc() to be used as packet data. If this
4458  *        function returns successfully, the data is owned by the underlying AVBuffer.
4459  *        The caller may not access the data through other means.
4460  * @param size size of data in bytes, without the padding. I.e. the full buffer
4461  *        size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.
4462  *
4463  * @return 0 on success, a negative AVERROR on error
4464  */
4465 int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
4466
4467 #if FF_API_AVPACKET_OLD_API
4468 /**
4469  * @warning This is a hack - the packet memory allocation stuff is broken. The
4470  * packet is allocated if it was not really allocated.
4471  *
4472  * @deprecated Use av_packet_ref or av_packet_make_refcounted
4473  */
4474 attribute_deprecated
4475 int av_dup_packet(AVPacket *pkt);
4476 /**
4477  * Copy packet, including contents
4478  *
4479  * @return 0 on success, negative AVERROR on fail
4480  *
4481  * @deprecated Use av_packet_ref
4482  */
4483 attribute_deprecated
4484 int av_copy_packet(AVPacket *dst, const AVPacket *src);
4485
4486 /**
4487  * Copy packet side data
4488  *
4489  * @return 0 on success, negative AVERROR on fail
4490  *
4491  * @deprecated Use av_packet_copy_props
4492  */
4493 attribute_deprecated
4494 int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
4495
4496 /**
4497  * Free a packet.
4498  *
4499  * @deprecated Use av_packet_unref
4500  *
4501  * @param pkt packet to free
4502  */
4503 attribute_deprecated
4504 void av_free_packet(AVPacket *pkt);
4505 #endif
4506 /**
4507  * Allocate new information of a packet.
4508  *
4509  * @param pkt packet
4510  * @param type side information type
4511  * @param size side information size
4512  * @return pointer to fresh allocated data or NULL otherwise
4513  */
4514 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4515                                  int size);
4516
4517 /**
4518  * Wrap an existing array as a packet side data.
4519  *
4520  * @param pkt packet
4521  * @param type side information type
4522  * @param data the side data array. It must be allocated with the av_malloc()
4523  *             family of functions. The ownership of the data is transferred to
4524  *             pkt.
4525  * @param size side information size
4526  * @return a non-negative number on success, a negative AVERROR code on
4527  *         failure. On failure, the packet is unchanged and the data remains
4528  *         owned by the caller.
4529  */
4530 int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4531                             uint8_t *data, size_t size);
4532
4533 /**
4534  * Shrink the already allocated side data buffer
4535  *
4536  * @param pkt packet
4537  * @param type side information type
4538  * @param size new side information size
4539  * @return 0 on success, < 0 on failure
4540  */
4541 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4542                                int size);
4543
4544 /**
4545  * Get side information from packet.
4546  *
4547  * @param pkt packet
4548  * @param type desired side information type
4549  * @param size pointer for side information size to store (optional)
4550  * @return pointer to data if present or NULL otherwise
4551  */
4552 uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type,
4553                                  int *size);
4554
4555 #if FF_API_MERGE_SD_API
4556 attribute_deprecated
4557 int av_packet_merge_side_data(AVPacket *pkt);
4558
4559 attribute_deprecated
4560 int av_packet_split_side_data(AVPacket *pkt);
4561 #endif
4562
4563 const char *av_packet_side_data_name(enum AVPacketSideDataType type);
4564
4565 /**
4566  * Pack a dictionary for use in side_data.
4567  *
4568  * @param dict The dictionary to pack.
4569  * @param size pointer to store the size of the returned data
4570  * @return pointer to data if successful, NULL otherwise
4571  */
4572 uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size);
4573 /**
4574  * Unpack a dictionary from side_data.
4575  *
4576  * @param data data from side_data
4577  * @param size size of the data
4578  * @param dict the metadata storage dictionary
4579  * @return 0 on success, < 0 on failure
4580  */
4581 int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict);
4582
4583
4584 /**
4585  * Convenience function to free all the side data stored.
4586  * All the other fields stay untouched.
4587  *
4588  * @param pkt packet
4589  */
4590 void av_packet_free_side_data(AVPacket *pkt);
4591
4592 /**
4593  * Setup a new reference to the data described by a given packet
4594  *
4595  * If src is reference-counted, setup dst as a new reference to the
4596  * buffer in src. Otherwise allocate a new buffer in dst and copy the
4597  * data from src into it.
4598  *
4599  * All the other fields are copied from src.
4600  *
4601  * @see av_packet_unref
4602  *
4603  * @param dst Destination packet
4604  * @param src Source packet
4605  *
4606  * @return 0 on success, a negative AVERROR on error.
4607  */
4608 int av_packet_ref(AVPacket *dst, const AVPacket *src);
4609
4610 /**
4611  * Wipe the packet.
4612  *
4613  * Unreference the buffer referenced by the packet and reset the
4614  * remaining packet fields to their default values.
4615  *
4616  * @param pkt The packet to be unreferenced.
4617  */
4618 void av_packet_unref(AVPacket *pkt);
4619
4620 /**
4621  * Move every field in src to dst and reset src.
4622  *
4623  * @see av_packet_unref
4624  *
4625  * @param src Source packet, will be reset
4626  * @param dst Destination packet
4627  */
4628 void av_packet_move_ref(AVPacket *dst, AVPacket *src);
4629
4630 /**
4631  * Copy only "properties" fields from src to dst.
4632  *
4633  * Properties for the purpose of this function are all the fields
4634  * beside those related to the packet data (buf, data, size)
4635  *
4636  * @param dst Destination packet
4637  * @param src Source packet
4638  *
4639  * @return 0 on success AVERROR on failure.
4640  */
4641 int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
4642
4643 /**
4644  * Ensure the data described by a given packet is reference counted.
4645  *
4646  * @note This function does not ensure that the reference will be writable.
4647  *       Use av_packet_make_writable instead for that purpose.
4648  *
4649  * @see av_packet_ref
4650  * @see av_packet_make_writable
4651  *
4652  * @param pkt packet whose data should be made reference counted.
4653  *
4654  * @return 0 on success, a negative AVERROR on error. On failure, the
4655  *         packet is unchanged.
4656  */
4657 int av_packet_make_refcounted(AVPacket *pkt);
4658
4659 /**
4660  * Create a writable reference for the data described by a given packet,
4661  * avoiding data copy if possible.
4662  *
4663  * @param pkt Packet whose data should be made writable.
4664  *
4665  * @return 0 on success, a negative AVERROR on failure. On failure, the
4666  *         packet is unchanged.
4667  */
4668 int av_packet_make_writable(AVPacket *pkt);
4669
4670 /**
4671  * Convert valid timing fields (timestamps / durations) in a packet from one
4672  * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
4673  * ignored.
4674  *
4675  * @param pkt packet on which the conversion will be performed
4676  * @param tb_src source timebase, in which the timing fields in pkt are
4677  *               expressed
4678  * @param tb_dst destination timebase, to which the timing fields will be
4679  *               converted
4680  */
4681 void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
4682
4683 /**
4684  * @}
4685  */
4686
4687 /**
4688  * @addtogroup lavc_decoding
4689  * @{
4690  */
4691
4692 /**
4693  * Find a registered decoder with a matching codec ID.
4694  *
4695  * @param id AVCodecID of the requested decoder
4696  * @return A decoder if one was found, NULL otherwise.
4697  */
4698 AVCodec *avcodec_find_decoder(enum AVCodecID id);
4699
4700 /**
4701  * Find a registered decoder with the specified name.
4702  *
4703  * @param name name of the requested decoder
4704  * @return A decoder if one was found, NULL otherwise.
4705  */
4706 AVCodec *avcodec_find_decoder_by_name(const char *name);
4707
4708 /**
4709  * The default callback for AVCodecContext.get_buffer2(). It is made public so
4710  * it can be called by custom get_buffer2() implementations for decoders without
4711  * AV_CODEC_CAP_DR1 set.
4712  */
4713 int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
4714
4715 /**
4716  * Modify width and height values so that they will result in a memory
4717  * buffer that is acceptable for the codec if you do not use any horizontal
4718  * padding.
4719  *
4720  * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
4721  */
4722 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
4723
4724 /**
4725  * Modify width and height values so that they will result in a memory
4726  * buffer that is acceptable for the codec if you also ensure that all
4727  * line sizes are a multiple of the respective linesize_align[i].
4728  *
4729  * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
4730  */
4731 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
4732                                int linesize_align[AV_NUM_DATA_POINTERS]);
4733
4734 /**
4735  * Converts AVChromaLocation to swscale x/y chroma position.
4736  *
4737  * The positions represent the chroma (0,0) position in a coordinates system
4738  * with luma (0,0) representing the origin and luma(1,1) representing 256,256
4739  *
4740  * @param xpos  horizontal chroma sample position
4741  * @param ypos  vertical   chroma sample position
4742  */
4743 int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos);
4744
4745 /**
4746  * Converts swscale x/y chroma position to AVChromaLocation.
4747  *
4748  * The positions represent the chroma (0,0) position in a coordinates system
4749  * with luma (0,0) representing the origin and luma(1,1) representing 256,256
4750  *
4751  * @param xpos  horizontal chroma sample position
4752  * @param ypos  vertical   chroma sample position
4753  */
4754 enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos);
4755
4756 /**
4757  * Decode the audio frame of size avpkt->size from avpkt->data into frame.
4758  *
4759  * Some decoders may support multiple frames in a single AVPacket. Such
4760  * decoders would then just decode the first frame and the return value would be
4761  * less than the packet size. In this case, avcodec_decode_audio4 has to be
4762  * called again with an AVPacket containing the remaining data in order to
4763  * decode the second frame, etc...  Even if no frames are returned, the packet
4764  * needs to be fed to the decoder with remaining data until it is completely
4765  * consumed or an error occurs.
4766  *
4767  * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
4768  * and output. This means that for some packets they will not immediately
4769  * produce decoded output and need to be flushed at the end of decoding to get
4770  * all the decoded data. Flushing is done by calling this function with packets
4771  * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
4772  * returning samples. It is safe to flush even those decoders that are not
4773  * marked with AV_CODEC_CAP_DELAY, then no samples will be returned.
4774  *
4775  * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
4776  *          larger than the actual read bytes because some optimized bitstream
4777  *          readers read 32 or 64 bits at once and could read over the end.
4778  *
4779  * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4780  * before packets may be fed to the decoder.
4781  *
4782  * @param      avctx the codec context
4783  * @param[out] frame The AVFrame in which to store decoded audio samples.
4784  *                   The decoder will allocate a buffer for the decoded frame by
4785  *                   calling the AVCodecContext.get_buffer2() callback.
4786  *                   When AVCodecContext.refcounted_frames is set to 1, the frame is
4787  *                   reference counted and the returned reference belongs to the
4788  *                   caller. The caller must release the frame using av_frame_unref()
4789  *                   when the frame is no longer needed. The caller may safely write
4790  *                   to the frame if av_frame_is_writable() returns 1.
4791  *                   When AVCodecContext.refcounted_frames is set to 0, the returned
4792  *                   reference belongs to the decoder and is valid only until the
4793  *                   next call to this function or until closing or flushing the
4794  *                   decoder. The caller may not write to it.
4795  * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
4796  *                           non-zero. Note that this field being set to zero
4797  *                           does not mean that an error has occurred. For
4798  *                           decoders with AV_CODEC_CAP_DELAY set, no given decode
4799  *                           call is guaranteed to produce a frame.
4800  * @param[in]  avpkt The input AVPacket containing the input buffer.
4801  *                   At least avpkt->data and avpkt->size should be set. Some
4802  *                   decoders might also require additional fields to be set.
4803  * @return A negative error code is returned if an error occurred during
4804  *         decoding, otherwise the number of bytes consumed from the input
4805  *         AVPacket is returned.
4806  *
4807 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
4808  */
4809 attribute_deprecated
4810 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
4811                           int *got_frame_ptr, const AVPacket *avpkt);
4812
4813 /**
4814  * Decode the video frame of size avpkt->size from avpkt->data into picture.
4815  * Some decoders may support multiple frames in a single AVPacket, such
4816  * decoders would then just decode the first frame.
4817  *
4818  * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than
4819  * the actual read bytes because some optimized bitstream readers read 32 or 64
4820  * bits at once and could read over the end.
4821  *
4822  * @warning The end of the input buffer buf should be set to 0 to ensure that
4823  * no overreading happens for damaged MPEG streams.
4824  *
4825  * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
4826  * between input and output, these need to be fed with avpkt->data=NULL,
4827  * avpkt->size=0 at the end to return the remaining frames.
4828  *
4829  * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4830  * before packets may be fed to the decoder.
4831  *
4832  * @param avctx the codec context
4833  * @param[out] picture The AVFrame in which the decoded video frame will be stored.
4834  *             Use av_frame_alloc() to get an AVFrame. The codec will
4835  *             allocate memory for the actual bitmap by calling the
4836  *             AVCodecContext.get_buffer2() callback.
4837  *             When AVCodecContext.refcounted_frames is set to 1, the frame is
4838  *             reference counted and the returned reference belongs to the
4839  *             caller. The caller must release the frame using av_frame_unref()
4840  *             when the frame is no longer needed. The caller may safely write
4841  *             to the frame if av_frame_is_writable() returns 1.
4842  *             When AVCodecContext.refcounted_frames is set to 0, the returned
4843  *             reference belongs to the decoder and is valid only until the
4844  *             next call to this function or until closing or flushing the
4845  *             decoder. The caller may not write to it.
4846  *
4847  * @param[in] avpkt The input AVPacket containing the input buffer.
4848  *            You can create such packet with av_init_packet() and by then setting
4849  *            data and size, some decoders might in addition need other fields like
4850  *            flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
4851  *            fields possible.
4852  * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
4853  * @return On error a negative value is returned, otherwise the number of bytes
4854  * used or zero if no frame could be decompressed.
4855  *
4856  * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
4857  */
4858 attribute_deprecated
4859 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
4860                          int *got_picture_ptr,
4861                          const AVPacket *avpkt);
4862
4863 /**
4864  * Decode a subtitle message.
4865  * Return a negative value on error, otherwise return the number of bytes used.
4866  * If no subtitle could be decompressed, got_sub_ptr is zero.
4867  * Otherwise, the subtitle is stored in *sub.
4868  * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for
4869  * simplicity, because the performance difference is expect to be negligible
4870  * and reusing a get_buffer written for video codecs would probably perform badly
4871  * due to a potentially very different allocation pattern.
4872  *
4873  * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
4874  * and output. This means that for some packets they will not immediately
4875  * produce decoded output and need to be flushed at the end of decoding to get
4876  * all the decoded data. Flushing is done by calling this function with packets
4877  * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
4878  * returning subtitles. It is safe to flush even those decoders that are not
4879  * marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned.
4880  *
4881  * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4882  * before packets may be fed to the decoder.
4883  *
4884  * @param avctx the codec context
4885  * @param[out] sub The Preallocated AVSubtitle in which the decoded subtitle will be stored,
4886  *                 must be freed with avsubtitle_free if *got_sub_ptr is set.
4887  * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
4888  * @param[in] avpkt The input AVPacket containing the input buffer.
4889  */
4890 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
4891                             int *got_sub_ptr,
4892                             AVPacket *avpkt);
4893
4894 /**
4895  * Supply raw packet data as input to a decoder.
4896  *
4897  * Internally, this call will copy relevant AVCodecContext fields, which can
4898  * influence decoding per-packet, and apply them when the packet is actually
4899  * decoded. (For example AVCodecContext.skip_frame, which might direct the
4900  * decoder to drop the frame contained by the packet sent with this function.)
4901  *
4902  * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
4903  *          larger than the actual read bytes because some optimized bitstream
4904  *          readers read 32 or 64 bits at once and could read over the end.
4905  *
4906  * @warning Do not mix this API with the legacy API (like avcodec_decode_video2())
4907  *          on the same AVCodecContext. It will return unexpected results now
4908  *          or in future libavcodec versions.
4909  *
4910  * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4911  *       before packets may be fed to the decoder.
4912  *
4913  * @param avctx codec context
4914  * @param[in] avpkt The input AVPacket. Usually, this will be a single video
4915  *                  frame, or several complete audio frames.
4916  *                  Ownership of the packet remains with the caller, and the
4917  *                  decoder will not write to the packet. The decoder may create
4918  *                  a reference to the packet data (or copy it if the packet is
4919  *                  not reference-counted).
4920  *                  Unlike with older APIs, the packet is always fully consumed,
4921  *                  and if it contains multiple frames (e.g. some audio codecs),
4922  *                  will require you to call avcodec_receive_frame() multiple
4923  *                  times afterwards before you can send a new packet.
4924  *                  It can be NULL (or an AVPacket with data set to NULL and
4925  *                  size set to 0); in this case, it is considered a flush
4926  *                  packet, which signals the end of the stream. Sending the
4927  *                  first flush packet will return success. Subsequent ones are
4928  *                  unnecessary and will return AVERROR_EOF. If the decoder
4929  *                  still has frames buffered, it will return them after sending
4930  *                  a flush packet.
4931  *
4932  * @return 0 on success, otherwise negative error code:
4933  *      AVERROR(EAGAIN):   input is not accepted in the current state - user
4934  *                         must read output with avcodec_receive_frame() (once
4935  *                         all output is read, the packet should be resent, and
4936  *                         the call will not fail with EAGAIN).
4937  *      AVERROR_EOF:       the decoder has been flushed, and no new packets can
4938  *                         be sent to it (also returned if more than 1 flush
4939  *                         packet is sent)
4940  *      AVERROR(EINVAL):   codec not opened, it is an encoder, or requires flush
4941  *      AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
4942  *      other errors: legitimate decoding errors
4943  */
4944 int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
4945
4946 /**
4947  * Return decoded output data from a decoder.
4948  *
4949  * @param avctx codec context
4950  * @param frame This will be set to a reference-counted video or audio
4951  *              frame (depending on the decoder type) allocated by the
4952  *              decoder. Note that the function will always call
4953  *              av_frame_unref(frame) before doing anything else.
4954  *
4955  * @return
4956  *      0:                 success, a frame was returned
4957  *      AVERROR(EAGAIN):   output is not available in this state - user must try
4958  *                         to send new input
4959  *      AVERROR_EOF:       the decoder has been fully flushed, and there will be
4960  *                         no more output frames
4961  *      AVERROR(EINVAL):   codec not opened, or it is an encoder
4962  *      AVERROR_INPUT_CHANGED:   current decoded frame has changed parameters
4963  *                               with respect to first decoded frame. Applicable
4964  *                               when flag AV_CODEC_FLAG_DROPCHANGED is set.
4965  *      other negative values: legitimate decoding errors
4966  */
4967 int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
4968
4969 /**
4970  * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()
4971  * to retrieve buffered output packets.
4972  *
4973  * @param avctx     codec context
4974  * @param[in] frame AVFrame containing the raw audio or video frame to be encoded.
4975  *                  Ownership of the frame remains with the caller, and the
4976  *                  encoder will not write to the frame. The encoder may create
4977  *                  a reference to the frame data (or copy it if the frame is
4978  *                  not reference-counted).
4979  *                  It can be NULL, in which case it is considered a flush
4980  *                  packet.  This signals the end of the stream. If the encoder
4981  *                  still has packets buffered, it will return them after this
4982  *                  call. Once flushing mode has been entered, additional flush
4983  *                  packets are ignored, and sending frames will return
4984  *                  AVERROR_EOF.
4985  *
4986  *                  For audio:
4987  *                  If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
4988  *                  can have any number of samples.
4989  *                  If it is not set, frame->nb_samples must be equal to
4990  *                  avctx->frame_size for all frames except the last.
4991  *                  The final frame may be smaller than avctx->frame_size.
4992  * @return 0 on success, otherwise negative error code:
4993  *      AVERROR(EAGAIN):   input is not accepted in the current state - user
4994  *                         must read output with avcodec_receive_packet() (once
4995  *                         all output is read, the packet should be resent, and
4996  *                         the call will not fail with EAGAIN).
4997  *      AVERROR_EOF:       the encoder has been flushed, and no new frames can
4998  *                         be sent to it
4999  *      AVERROR(EINVAL):   codec not opened, refcounted_frames not set, it is a
5000  *                         decoder, or requires flush
5001  *      AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
5002  *      other errors: legitimate decoding errors
5003  */
5004 int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);
5005
5006 /**
5007  * Read encoded data from the encoder.
5008  *
5009  * @param avctx codec context
5010  * @param avpkt This will be set to a reference-counted packet allocated by the
5011  *              encoder. Note that the function will always call
5012  *              av_frame_unref(frame) before doing anything else.
5013  * @return 0 on success, otherwise negative error code:
5014  *      AVERROR(EAGAIN):   output is not available in the current state - user
5015  *                         must try to send input
5016  *      AVERROR_EOF:       the encoder has been fully flushed, and there will be
5017  *                         no more output packets
5018  *      AVERROR(EINVAL):   codec not opened, or it is an encoder
5019  *      other errors: legitimate decoding errors
5020  */
5021 int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
5022
5023 /**
5024  * Create and return a AVHWFramesContext with values adequate for hardware
5025  * decoding. This is meant to get called from the get_format callback, and is
5026  * a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx.
5027  * This API is for decoding with certain hardware acceleration modes/APIs only.
5028  *
5029  * The returned AVHWFramesContext is not initialized. The caller must do this
5030  * with av_hwframe_ctx_init().
5031  *
5032  * Calling this function is not a requirement, but makes it simpler to avoid
5033  * codec or hardware API specific details when manually allocating frames.
5034  *
5035  * Alternatively to this, an API user can set AVCodecContext.hw_device_ctx,
5036  * which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes
5037  * it unnecessary to call this function or having to care about
5038  * AVHWFramesContext initialization at all.
5039  *
5040  * There are a number of requirements for calling this function:
5041  *
5042  * - It must be called from get_format with the same avctx parameter that was
5043  *   passed to get_format. Calling it outside of get_format is not allowed, and
5044  *   can trigger undefined behavior.
5045  * - The function is not always supported (see description of return values).
5046  *   Even if this function returns successfully, hwaccel initialization could
5047  *   fail later. (The degree to which implementations check whether the stream
5048  *   is actually supported varies. Some do this check only after the user's
5049  *   get_format callback returns.)
5050  * - The hw_pix_fmt must be one of the choices suggested by get_format. If the
5051  *   user decides to use a AVHWFramesContext prepared with this API function,
5052  *   the user must return the same hw_pix_fmt from get_format.
5053  * - The device_ref passed to this function must support the given hw_pix_fmt.
5054  * - After calling this API function, it is the user's responsibility to
5055  *   initialize the AVHWFramesContext (returned by the out_frames_ref parameter),
5056  *   and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done
5057  *   before returning from get_format (this is implied by the normal
5058  *   AVCodecContext.hw_frames_ctx API rules).
5059  * - The AVHWFramesContext parameters may change every time time get_format is
5060  *   called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So
5061  *   you are inherently required to go through this process again on every
5062  *   get_format call.
5063  * - It is perfectly possible to call this function without actually using
5064  *   the resulting AVHWFramesContext. One use-case might be trying to reuse a
5065  *   previously initialized AVHWFramesContext, and calling this API function
5066  *   only to test whether the required frame parameters have changed.
5067  * - Fields that use dynamically allocated values of any kind must not be set
5068  *   by the user unless setting them is explicitly allowed by the documentation.
5069  *   If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque,
5070  *   the new free callback must call the potentially set previous free callback.
5071  *   This API call may set any dynamically allocated fields, including the free
5072  *   callback.
5073  *
5074  * The function will set at least the following fields on AVHWFramesContext
5075  * (potentially more, depending on hwaccel API):
5076  *
5077  * - All fields set by av_hwframe_ctx_alloc().
5078  * - Set the format field to hw_pix_fmt.
5079  * - Set the sw_format field to the most suited and most versatile format. (An
5080  *   implication is that this will prefer generic formats over opaque formats
5081  *   with arbitrary restrictions, if possible.)
5082  * - Set the width/height fields to the coded frame size, rounded up to the
5083  *   API-specific minimum alignment.
5084  * - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size
5085  *   field to the number of maximum reference surfaces possible with the codec,
5086  *   plus 1 surface for the user to work (meaning the user can safely reference
5087  *   at most 1 decoded surface at a time), plus additional buffering introduced
5088  *   by frame threading. If the hwaccel does not require pre-allocation, the
5089  *   field is left to 0, and the decoder will allocate new surfaces on demand
5090  *   during decoding.
5091  * - Possibly AVHWFramesContext.hwctx fields, depending on the underlying
5092  *   hardware API.
5093  *
5094  * Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but
5095  * with basic frame parameters set.
5096  *
5097  * The function is stateless, and does not change the AVCodecContext or the
5098  * device_ref AVHWDeviceContext.
5099  *
5100  * @param avctx The context which is currently calling get_format, and which
5101  *              implicitly contains all state needed for filling the returned
5102  *              AVHWFramesContext properly.
5103  * @param device_ref A reference to the AVHWDeviceContext describing the device
5104  *                   which will be used by the hardware decoder.
5105  * @param hw_pix_fmt The hwaccel format you are going to return from get_format.
5106  * @param out_frames_ref On success, set to a reference to an _uninitialized_
5107  *                       AVHWFramesContext, created from the given device_ref.
5108  *                       Fields will be set to values required for decoding.
5109  *                       Not changed if an error is returned.
5110  * @return zero on success, a negative value on error. The following error codes
5111  *         have special semantics:
5112  *      AVERROR(ENOENT): the decoder does not support this functionality. Setup
5113  *                       is always manual, or it is a decoder which does not
5114  *                       support setting AVCodecContext.hw_frames_ctx at all,
5115  *                       or it is a software format.
5116  *      AVERROR(EINVAL): it is known that hardware decoding is not supported for
5117  *                       this configuration, or the device_ref is not supported
5118  *                       for the hwaccel referenced by hw_pix_fmt.
5119  */
5120 int avcodec_get_hw_frames_parameters(AVCodecContext *avctx,
5121                                      AVBufferRef *device_ref,
5122                                      enum AVPixelFormat hw_pix_fmt,
5123                                      AVBufferRef **out_frames_ref);
5124
5125
5126
5127 /**
5128  * @defgroup lavc_parsing Frame parsing
5129  * @{
5130  */
5131
5132 enum AVPictureStructure {
5133     AV_PICTURE_STRUCTURE_UNKNOWN,      //< unknown
5134     AV_PICTURE_STRUCTURE_TOP_FIELD,    //< coded as top field
5135     AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
5136     AV_PICTURE_STRUCTURE_FRAME,        //< coded as frame
5137 };
5138
5139 typedef struct AVCodecParserContext {
5140     void *priv_data;
5141     struct AVCodecParser *parser;
5142     int64_t frame_offset; /* offset of the current frame */
5143     int64_t cur_offset; /* current offset
5144                            (incremented by each av_parser_parse()) */
5145     int64_t next_frame_offset; /* offset of the next frame */
5146     /* video info */
5147     int pict_type; /* XXX: Put it back in AVCodecContext. */
5148     /**
5149      * This field is used for proper frame duration computation in lavf.
5150      * It signals, how much longer the frame duration of the current frame
5151      * is compared to normal frame duration.
5152      *
5153      * frame_duration = (1 + repeat_pict) * time_base
5154      *
5155      * It is used by codecs like H.264 to display telecined material.
5156      */
5157     int repeat_pict; /* XXX: Put it back in AVCodecContext. */
5158     int64_t pts;     /* pts of the current frame */
5159     int64_t dts;     /* dts of the current frame */
5160
5161     /* private data */
5162     int64_t last_pts;
5163     int64_t last_dts;
5164     int fetch_timestamp;
5165
5166 #define AV_PARSER_PTS_NB 4
5167     int cur_frame_start_index;
5168     int64_t cur_frame_offset[AV_PARSER_PTS_NB];
5169     int64_t cur_frame_pts[AV_PARSER_PTS_NB];
5170     int64_t cur_frame_dts[AV_PARSER_PTS_NB];
5171
5172     int flags;
5173 #define PARSER_FLAG_COMPLETE_FRAMES           0x0001
5174 #define PARSER_FLAG_ONCE                      0x0002
5175 /// Set if the parser has a valid file offset
5176 #define PARSER_FLAG_FETCHED_OFFSET            0x0004
5177 #define PARSER_FLAG_USE_CODEC_TS              0x1000
5178
5179     int64_t offset;      ///< byte offset from starting packet start
5180     int64_t cur_frame_end[AV_PARSER_PTS_NB];
5181
5182     /**
5183      * Set by parser to 1 for key frames and 0 for non-key frames.
5184      * It is initialized to -1, so if the parser doesn't set this flag,
5185      * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
5186      * will be used.
5187      */
5188     int key_frame;
5189
5190 #if FF_API_CONVERGENCE_DURATION
5191     /**
5192      * @deprecated unused
5193      */
5194     attribute_deprecated
5195     int64_t convergence_duration;
5196 #endif
5197
5198     // Timestamp generation support:
5199     /**
5200      * Synchronization point for start of timestamp generation.
5201      *
5202      * Set to >0 for sync point, 0 for no sync point and <0 for undefined
5203      * (default).
5204      *
5205      * For example, this corresponds to presence of H.264 buffering period
5206      * SEI message.
5207      */
5208     int dts_sync_point;
5209
5210     /**
5211      * Offset of the current timestamp against last timestamp sync point in
5212      * units of AVCodecContext.time_base.
5213      *
5214      * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
5215      * contain a valid timestamp offset.
5216      *
5217      * Note that the timestamp of sync point has usually a nonzero
5218      * dts_ref_dts_delta, which refers to the previous sync point. Offset of
5219      * the next frame after timestamp sync point will be usually 1.
5220      *
5221      * For example, this corresponds to H.264 cpb_removal_delay.
5222      */
5223     int dts_ref_dts_delta;
5224
5225     /**
5226      * Presentation delay of current frame in units of AVCodecContext.time_base.
5227      *
5228      * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
5229      * contain valid non-negative timestamp delta (presentation time of a frame
5230      * must not lie in the past).
5231      *
5232      * This delay represents the difference between decoding and presentation
5233      * time of the frame.
5234      *
5235      * For example, this corresponds to H.264 dpb_output_delay.
5236      */
5237     int pts_dts_delta;
5238
5239     /**
5240      * Position of the packet in file.
5241      *
5242      * Analogous to cur_frame_pts/dts
5243      */
5244     int64_t cur_frame_pos[AV_PARSER_PTS_NB];
5245
5246     /**
5247      * Byte position of currently parsed frame in stream.
5248      */
5249     int64_t pos;
5250
5251     /**
5252      * Previous frame byte position.
5253      */
5254     int64_t last_pos;
5255
5256     /**
5257      * Duration of the current frame.
5258      * For audio, this is in units of 1 / AVCodecContext.sample_rate.
5259      * For all other types, this is in units of AVCodecContext.time_base.
5260      */
5261     int duration;
5262
5263     enum AVFieldOrder field_order;
5264
5265     /**
5266      * Indicate whether a picture is coded as a frame, top field or bottom field.
5267      *
5268      * For example, H.264 field_pic_flag equal to 0 corresponds to
5269      * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag
5270      * equal to 1 and bottom_field_flag equal to 0 corresponds to
5271      * AV_PICTURE_STRUCTURE_TOP_FIELD.
5272      */
5273     enum AVPictureStructure picture_structure;
5274
5275     /**
5276      * Picture number incremented in presentation or output order.
5277      * This field may be reinitialized at the first picture of a new sequence.
5278      *
5279      * For example, this corresponds to H.264 PicOrderCnt.
5280      */
5281     int output_picture_number;
5282
5283     /**
5284      * Dimensions of the decoded video intended for presentation.
5285      */
5286     int width;
5287     int height;
5288
5289     /**
5290      * Dimensions of the coded video.
5291      */
5292     int coded_width;
5293     int coded_height;
5294
5295     /**
5296      * The format of the coded data, corresponds to enum AVPixelFormat for video
5297      * and for enum AVSampleFormat for audio.
5298      *
5299      * Note that a decoder can have considerable freedom in how exactly it
5300      * decodes the data, so the format reported here might be different from the
5301      * one returned by a decoder.
5302      */
5303     int format;
5304 } AVCodecParserContext;
5305
5306 typedef struct AVCodecParser {
5307     int codec_ids[5]; /* several codec IDs are permitted */
5308     int priv_data_size;
5309     int (*parser_init)(AVCodecParserContext *s);
5310     /* This callback never returns an error, a negative value means that
5311      * the frame start was in a previous packet. */
5312     int (*parser_parse)(AVCodecParserContext *s,
5313                         AVCodecContext *avctx,
5314                         const uint8_t **poutbuf, int *poutbuf_size,
5315                         const uint8_t *buf, int buf_size);
5316     void (*parser_close)(AVCodecParserContext *s);
5317     int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
5318     struct AVCodecParser *next;
5319 } AVCodecParser;
5320
5321 /**
5322  * Iterate over all registered codec parsers.
5323  *
5324  * @param opaque a pointer where libavcodec will store the iteration state. Must
5325  *               point to NULL to start the iteration.
5326  *
5327  * @return the next registered codec parser or NULL when the iteration is
5328  *         finished
5329  */
5330 const AVCodecParser *av_parser_iterate(void **opaque);
5331
5332 attribute_deprecated
5333 AVCodecParser *av_parser_next(const AVCodecParser *c);
5334
5335 attribute_deprecated
5336 void av_register_codec_parser(AVCodecParser *parser);
5337 AVCodecParserContext *av_parser_init(int codec_id);
5338
5339 /**
5340  * Parse a packet.
5341  *
5342  * @param s             parser context.
5343  * @param avctx         codec context.
5344  * @param poutbuf       set to pointer to parsed buffer or NULL if not yet finished.
5345  * @param poutbuf_size  set to size of parsed buffer or zero if not yet finished.
5346  * @param buf           input buffer.
5347  * @param buf_size      buffer size in bytes without the padding. I.e. the full buffer
5348                         size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE.
5349                         To signal EOF, this should be 0 (so that the last frame
5350                         can be output).
5351  * @param pts           input presentation timestamp.
5352  * @param dts           input decoding timestamp.
5353  * @param pos           input byte position in stream.
5354  * @return the number of bytes of the input bitstream used.
5355  *
5356  * Example:
5357  * @code
5358  *   while(in_len){
5359  *       len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
5360  *                                        in_data, in_len,
5361  *                                        pts, dts, pos);
5362  *       in_data += len;
5363  *       in_len  -= len;
5364  *
5365  *       if(size)
5366  *          decode_frame(data, size);
5367  *   }
5368  * @endcode
5369  */
5370 int av_parser_parse2(AVCodecParserContext *s,
5371                      AVCodecContext *avctx,
5372                      uint8_t **poutbuf, int *poutbuf_size,
5373                      const uint8_t *buf, int buf_size,
5374                      int64_t pts, int64_t dts,
5375                      int64_t pos);
5376
5377 /**
5378  * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
5379  * @deprecated use AVBitStreamFilter
5380  */
5381 int av_parser_change(AVCodecParserContext *s,
5382                      AVCodecContext *avctx,
5383                      uint8_t **poutbuf, int *poutbuf_size,
5384                      const uint8_t *buf, int buf_size, int keyframe);
5385 void av_parser_close(AVCodecParserContext *s);
5386
5387 /**
5388  * @}
5389  * @}
5390  */
5391
5392 /**
5393  * @addtogroup lavc_encoding
5394  * @{
5395  */
5396
5397 /**
5398  * Find a registered encoder with a matching codec ID.
5399  *
5400  * @param id AVCodecID of the requested encoder
5401  * @return An encoder if one was found, NULL otherwise.
5402  */
5403 AVCodec *avcodec_find_encoder(enum AVCodecID id);
5404
5405 /**
5406  * Find a registered encoder with the specified name.
5407  *
5408  * @param name name of the requested encoder
5409  * @return An encoder if one was found, NULL otherwise.
5410  */
5411 AVCodec *avcodec_find_encoder_by_name(const char *name);
5412
5413 /**
5414  * Encode a frame of audio.
5415  *
5416  * Takes input samples from frame and writes the next output packet, if
5417  * available, to avpkt. The output packet does not necessarily contain data for
5418  * the most recent frame, as encoders can delay, split, and combine input frames
5419  * internally as needed.
5420  *
5421  * @param avctx     codec context
5422  * @param avpkt     output AVPacket.
5423  *                  The user can supply an output buffer by setting
5424  *                  avpkt->data and avpkt->size prior to calling the
5425  *                  function, but if the size of the user-provided data is not
5426  *                  large enough, encoding will fail. If avpkt->data and
5427  *                  avpkt->size are set, avpkt->destruct must also be set. All
5428  *                  other AVPacket fields will be reset by the encoder using
5429  *                  av_init_packet(). If avpkt->data is NULL, the encoder will
5430  *                  allocate it. The encoder will set avpkt->size to the size
5431  *                  of the output packet.
5432  *
5433  *                  If this function fails or produces no output, avpkt will be
5434  *                  freed using av_packet_unref().
5435  * @param[in] frame AVFrame containing the raw audio data to be encoded.
5436  *                  May be NULL when flushing an encoder that has the
5437  *                  AV_CODEC_CAP_DELAY capability set.
5438  *                  If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
5439  *                  can have any number of samples.
5440  *                  If it is not set, frame->nb_samples must be equal to
5441  *                  avctx->frame_size for all frames except the last.
5442  *                  The final frame may be smaller than avctx->frame_size.
5443  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
5444  *                            output packet is non-empty, and to 0 if it is
5445  *                            empty. If the function returns an error, the
5446  *                            packet can be assumed to be invalid, and the
5447  *                            value of got_packet_ptr is undefined and should
5448  *                            not be used.
5449  * @return          0 on success, negative error code on failure
5450  *
5451  * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead
5452  */
5453 attribute_deprecated
5454 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
5455                           const AVFrame *frame, int *got_packet_ptr);
5456
5457 /**
5458  * Encode a frame of video.
5459  *
5460  * Takes input raw video data from frame and writes the next output packet, if
5461  * available, to avpkt. The output packet does not necessarily contain data for
5462  * the most recent frame, as encoders can delay and reorder input frames
5463  * internally as needed.
5464  *
5465  * @param avctx     codec context
5466  * @param avpkt     output AVPacket.
5467  *                  The user can supply an output buffer by setting
5468  *                  avpkt->data and avpkt->size prior to calling the
5469  *                  function, but if the size of the user-provided data is not
5470  *                  large enough, encoding will fail. All other AVPacket fields
5471  *                  will be reset by the encoder using av_init_packet(). If
5472  *                  avpkt->data is NULL, the encoder will allocate it.
5473  *                  The encoder will set avpkt->size to the size of the
5474  *                  output packet. The returned data (if any) belongs to the
5475  *                  caller, he is responsible for freeing it.
5476  *
5477  *                  If this function fails or produces no output, avpkt will be
5478  *                  freed using av_packet_unref().
5479  * @param[in] frame AVFrame containing the raw video data to be encoded.
5480  *                  May be NULL when flushing an encoder that has the
5481  *                  AV_CODEC_CAP_DELAY capability set.
5482  * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
5483  *                            output packet is non-empty, and to 0 if it is
5484  *                            empty. If the function returns an error, the
5485  *                            packet can be assumed to be invalid, and the
5486  *                            value of got_packet_ptr is undefined and should
5487  *                            not be used.
5488  * @return          0 on success, negative error code on failure
5489  *
5490  * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead
5491  */
5492 attribute_deprecated
5493 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
5494                           const AVFrame *frame, int *got_packet_ptr);
5495
5496 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
5497                             const AVSubtitle *sub);
5498
5499
5500 /**
5501  * @}
5502  */
5503
5504 #if FF_API_AVPICTURE
5505 /**
5506  * @addtogroup lavc_picture
5507  * @{
5508  */
5509
5510 /**
5511  * @deprecated unused
5512  */
5513 attribute_deprecated
5514 int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
5515
5516 /**
5517  * @deprecated unused
5518  */
5519 attribute_deprecated
5520 void avpicture_free(AVPicture *picture);
5521
5522 /**
5523  * @deprecated use av_image_fill_arrays() instead.
5524  */
5525 attribute_deprecated
5526 int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
5527                    enum AVPixelFormat pix_fmt, int width, int height);
5528
5529 /**
5530  * @deprecated use av_image_copy_to_buffer() instead.
5531  */
5532 attribute_deprecated
5533 int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt,
5534                      int width, int height,
5535                      unsigned char *dest, int dest_size);
5536
5537 /**
5538  * @deprecated use av_image_get_buffer_size() instead.
5539  */
5540 attribute_deprecated
5541 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
5542
5543 /**
5544  * @deprecated av_image_copy() instead.
5545  */
5546 attribute_deprecated
5547 void av_picture_copy(AVPicture *dst, const AVPicture *src,
5548                      enum AVPixelFormat pix_fmt, int width, int height);
5549
5550 /**
5551  * @deprecated unused
5552  */
5553 attribute_deprecated
5554 int av_picture_crop(AVPicture *dst, const AVPicture *src,
5555                     enum AVPixelFormat pix_fmt, int top_band, int left_band);
5556
5557 /**
5558  * @deprecated unused
5559  */
5560 attribute_deprecated
5561 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt,
5562             int padtop, int padbottom, int padleft, int padright, int *color);
5563
5564 /**
5565  * @}
5566  */
5567 #endif
5568
5569 /**
5570  * @defgroup lavc_misc Utility functions
5571  * @ingroup libavc
5572  *
5573  * Miscellaneous utility functions related to both encoding and decoding
5574  * (or neither).
5575  * @{
5576  */
5577
5578 /**
5579  * @defgroup lavc_misc_pixfmt Pixel formats
5580  *
5581  * Functions for working with pixel formats.
5582  * @{
5583  */
5584
5585 #if FF_API_GETCHROMA
5586 /**
5587  * @deprecated Use av_pix_fmt_get_chroma_sub_sample
5588  */
5589
5590 attribute_deprecated
5591 void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
5592 #endif
5593
5594 /**
5595  * Return a value representing the fourCC code associated to the
5596  * pixel format pix_fmt, or 0 if no associated fourCC code can be
5597  * found.
5598  */
5599 unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt);
5600
5601 /**
5602  * @deprecated see av_get_pix_fmt_loss()
5603  */
5604 int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt,
5605                              int has_alpha);
5606
5607 /**
5608  * Find the best pixel format to convert to given a certain source pixel
5609  * format.  When converting from one pixel format to another, information loss
5610  * may occur.  For example, when converting from RGB24 to GRAY, the color
5611  * information will be lost. Similarly, other losses occur when converting from
5612  * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of
5613  * the given pixel formats should be used to suffer the least amount of loss.
5614  * The pixel formats from which it chooses one, are determined by the
5615  * pix_fmt_list parameter.
5616  *
5617  *
5618  * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from
5619  * @param[in] src_pix_fmt source pixel format
5620  * @param[in] has_alpha Whether the source pixel format alpha channel is used.
5621  * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
5622  * @return The best pixel format to convert to or -1 if none was found.
5623  */
5624 enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,
5625                                             enum AVPixelFormat src_pix_fmt,
5626                                             int has_alpha, int *loss_ptr);
5627
5628 /**
5629  * @deprecated see av_find_best_pix_fmt_of_2()
5630  */
5631 enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
5632                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
5633
5634 attribute_deprecated
5635 enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
5636                                             enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
5637
5638 enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
5639
5640 /**
5641  * @}
5642  */
5643
5644 #if FF_API_TAG_STRING
5645 /**
5646  * Put a string representing the codec tag codec_tag in buf.
5647  *
5648  * @param buf       buffer to place codec tag in
5649  * @param buf_size size in bytes of buf
5650  * @param codec_tag codec tag to assign
5651  * @return the length of the string that would have been generated if
5652  * enough space had been available, excluding the trailing null
5653  *
5654  * @deprecated see av_fourcc_make_string() and av_fourcc2str().
5655  */
5656 attribute_deprecated
5657 size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag);
5658 #endif
5659
5660 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
5661
5662 /**
5663  * Return a name for the specified profile, if available.
5664  *
5665  * @param codec the codec that is searched for the given profile
5666  * @param profile the profile value for which a name is requested
5667  * @return A name for the profile if found, NULL otherwise.
5668  */
5669 const char *av_get_profile_name(const AVCodec *codec, int profile);
5670
5671 /**
5672  * Return a name for the specified profile, if available.
5673  *
5674  * @param codec_id the ID of the codec to which the requested profile belongs
5675  * @param profile the profile value for which a name is requested
5676  * @return A name for the profile if found, NULL otherwise.
5677  *
5678  * @note unlike av_get_profile_name(), which searches a list of profiles
5679  *       supported by a specific decoder or encoder implementation, this
5680  *       function searches the list of profiles from the AVCodecDescriptor
5681  */
5682 const char *avcodec_profile_name(enum AVCodecID codec_id, int profile);
5683
5684 int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size);
5685 int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count);
5686 //FIXME func typedef
5687
5688 /**
5689  * Fill AVFrame audio data and linesize pointers.
5690  *
5691  * The buffer buf must be a preallocated buffer with a size big enough
5692  * to contain the specified samples amount. The filled AVFrame data
5693  * pointers will point to this buffer.
5694  *
5695  * AVFrame extended_data channel pointers are allocated if necessary for
5696  * planar audio.
5697  *
5698  * @param frame       the AVFrame
5699  *                    frame->nb_samples must be set prior to calling the
5700  *                    function. This function fills in frame->data,
5701  *                    frame->extended_data, frame->linesize[0].
5702  * @param nb_channels channel count
5703  * @param sample_fmt  sample format
5704  * @param buf         buffer to use for frame data
5705  * @param buf_size    size of buffer
5706  * @param align       plane size sample alignment (0 = default)
5707  * @return            >=0 on success, negative error code on failure
5708  * @todo return the size in bytes required to store the samples in
5709  * case of success, at the next libavutil bump
5710  */
5711 int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
5712                              enum AVSampleFormat sample_fmt, const uint8_t *buf,
5713                              int buf_size, int align);
5714
5715 /**
5716  * Reset the internal decoder state / flush internal buffers. Should be called
5717  * e.g. when seeking or when switching to a different stream.
5718  *
5719  * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0),
5720  * this invalidates the frames previously returned from the decoder. When
5721  * refcounted frames are used, the decoder just releases any references it might
5722  * keep internally, but the caller's reference remains valid.
5723  */
5724 void avcodec_flush_buffers(AVCodecContext *avctx);
5725
5726 /**
5727  * Return codec bits per sample.
5728  *
5729  * @param[in] codec_id the codec
5730  * @return Number of bits per sample or zero if unknown for the given codec.
5731  */
5732 int av_get_bits_per_sample(enum AVCodecID codec_id);
5733
5734 /**
5735  * Return the PCM codec associated with a sample format.
5736  * @param be  endianness, 0 for little, 1 for big,
5737  *            -1 (or anything else) for native
5738  * @return  AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE
5739  */
5740 enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be);
5741
5742 /**
5743  * Return codec bits per sample.
5744  * Only return non-zero if the bits per sample is exactly correct, not an
5745  * approximation.
5746  *
5747  * @param[in] codec_id the codec
5748  * @return Number of bits per sample or zero if unknown for the given codec.
5749  */
5750 int av_get_exact_bits_per_sample(enum AVCodecID codec_id);
5751
5752 /**
5753  * Return audio frame duration.
5754  *
5755  * @param avctx        codec context
5756  * @param frame_bytes  size of the frame, or 0 if unknown
5757  * @return             frame duration, in samples, if known. 0 if not able to
5758  *                     determine.
5759  */
5760 int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes);
5761
5762 /**
5763  * This function is the same as av_get_audio_frame_duration(), except it works
5764  * with AVCodecParameters instead of an AVCodecContext.
5765  */
5766 int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes);
5767
5768 #if FF_API_OLD_BSF
5769 typedef struct AVBitStreamFilterContext {
5770     void *priv_data;
5771     const struct AVBitStreamFilter *filter;
5772     AVCodecParserContext *parser;
5773     struct AVBitStreamFilterContext *next;
5774     /**
5775      * Internal default arguments, used if NULL is passed to av_bitstream_filter_filter().
5776      * Not for access by library users.
5777      */
5778     char *args;
5779 } AVBitStreamFilterContext;
5780 #endif
5781
5782 typedef struct AVBSFInternal AVBSFInternal;
5783
5784 /**
5785  * The bitstream filter state.
5786  *
5787  * This struct must be allocated with av_bsf_alloc() and freed with
5788  * av_bsf_free().
5789  *
5790  * The fields in the struct will only be changed (by the caller or by the
5791  * filter) as described in their documentation, and are to be considered
5792  * immutable otherwise.
5793  */
5794 typedef struct AVBSFContext {
5795     /**
5796      * A class for logging and AVOptions
5797      */
5798     const AVClass *av_class;
5799
5800     /**
5801      * The bitstream filter this context is an instance of.
5802      */
5803     const struct AVBitStreamFilter *filter;
5804
5805     /**
5806      * Opaque libavcodec internal data. Must not be touched by the caller in any
5807      * way.
5808      */
5809     AVBSFInternal *internal;
5810
5811     /**
5812      * Opaque filter-specific private data. If filter->priv_class is non-NULL,
5813      * this is an AVOptions-enabled struct.
5814      */
5815     void *priv_data;
5816
5817     /**
5818      * Parameters of the input stream. This field is allocated in
5819      * av_bsf_alloc(), it needs to be filled by the caller before
5820      * av_bsf_init().
5821      */
5822     AVCodecParameters *par_in;
5823
5824     /**
5825      * Parameters of the output stream. This field is allocated in
5826      * av_bsf_alloc(), it is set by the filter in av_bsf_init().
5827      */
5828     AVCodecParameters *par_out;
5829
5830     /**
5831      * The timebase used for the timestamps of the input packets. Set by the
5832      * caller before av_bsf_init().
5833      */
5834     AVRational time_base_in;
5835
5836     /**
5837      * The timebase used for the timestamps of the output packets. Set by the
5838      * filter in av_bsf_init().
5839      */
5840     AVRational time_base_out;
5841 } AVBSFContext;
5842
5843 typedef struct AVBitStreamFilter {
5844     const char *name;
5845
5846     /**
5847      * A list of codec ids supported by the filter, terminated by
5848      * AV_CODEC_ID_NONE.
5849      * May be NULL, in that case the bitstream filter works with any codec id.
5850      */
5851     const enum AVCodecID *codec_ids;
5852
5853     /**
5854      * A class for the private data, used to declare bitstream filter private
5855      * AVOptions. This field is NULL for bitstream filters that do not declare
5856      * any options.
5857      *
5858      * If this field is non-NULL, the first member of the filter private data
5859      * must be a pointer to AVClass, which will be set by libavcodec generic
5860      * code to this class.
5861      */
5862     const AVClass *priv_class;
5863
5864     /*****************************************************************
5865      * No fields below this line are part of the public API. They
5866      * may not be used outside of libavcodec and can be changed and
5867      * removed at will.
5868      * New public fields should be added right above.
5869      *****************************************************************
5870      */
5871
5872     int priv_data_size;
5873     int (*init)(AVBSFContext *ctx);
5874     int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
5875     void (*close)(AVBSFContext *ctx);
5876     void (*flush)(AVBSFContext *ctx);
5877 } AVBitStreamFilter;
5878
5879 #if FF_API_OLD_BSF
5880 /**
5881  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
5882  * is deprecated. Use the new bitstream filtering API (using AVBSFContext).
5883  */
5884 attribute_deprecated
5885 void av_register_bitstream_filter(AVBitStreamFilter *bsf);
5886 /**
5887  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
5888  * is deprecated. Use av_bsf_get_by_name(), av_bsf_alloc(), and av_bsf_init()
5889  * from the new bitstream filtering API (using AVBSFContext).
5890  */
5891 attribute_deprecated
5892 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
5893 /**
5894  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
5895  * is deprecated. Use av_bsf_send_packet() and av_bsf_receive_packet() from the
5896  * new bitstream filtering API (using AVBSFContext).
5897  */
5898 attribute_deprecated
5899 int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
5900                                AVCodecContext *avctx, const char *args,
5901                                uint8_t **poutbuf, int *poutbuf_size,
5902                                const uint8_t *buf, int buf_size, int keyframe);
5903 /**
5904  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
5905  * is deprecated. Use av_bsf_free() from the new bitstream filtering API (using
5906  * AVBSFContext).
5907  */
5908 attribute_deprecated
5909 void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
5910 /**
5911  * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext)
5912  * is deprecated. Use av_bsf_iterate() from the new bitstream filtering API (using
5913  * AVBSFContext).
5914  */
5915 attribute_deprecated
5916 const AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f);
5917 #endif
5918
5919 /**
5920  * @return a bitstream filter with the specified name or NULL if no such
5921  *         bitstream filter exists.
5922  */
5923 const AVBitStreamFilter *av_bsf_get_by_name(const char *name);
5924
5925 /**
5926  * Iterate over all registered bitstream filters.
5927  *
5928  * @param opaque a pointer where libavcodec will store the iteration state. Must
5929  *               point to NULL to start the iteration.
5930  *
5931  * @return the next registered bitstream filter or NULL when the iteration is
5932  *         finished
5933  */
5934 const AVBitStreamFilter *av_bsf_iterate(void **opaque);
5935 #if FF_API_NEXT
5936 attribute_deprecated
5937 const AVBitStreamFilter *av_bsf_next(void **opaque);
5938 #endif
5939
5940 /**
5941  * Allocate a context for a given bitstream filter. The caller must fill in the
5942  * context parameters as described in the documentation and then call
5943  * av_bsf_init() before sending any data to the filter.
5944  *
5945  * @param filter the filter for which to allocate an instance.
5946  * @param ctx a pointer into which the pointer to the newly-allocated context
5947  *            will be written. It must be freed with av_bsf_free() after the
5948  *            filtering is done.
5949  *
5950  * @return 0 on success, a negative AVERROR code on failure
5951  */
5952 int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx);
5953
5954 /**
5955  * Prepare the filter for use, after all the parameters and options have been
5956  * set.
5957  */
5958 int av_bsf_init(AVBSFContext *ctx);
5959
5960 /**
5961  * Submit a packet for filtering.
5962  *
5963  * After sending each packet, the filter must be completely drained by calling
5964  * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or
5965  * AVERROR_EOF.
5966  *
5967  * @param pkt the packet to filter. The bitstream filter will take ownership of
5968  * the packet and reset the contents of pkt. pkt is not touched if an error occurs.
5969  * If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero),
5970  * it signals the end of the stream (i.e. no more non-empty packets will be sent;
5971  * sending more empty packets does nothing) and will cause the filter to output
5972  * any packets it may have buffered internally.
5973  *
5974  * @return 0 on success, a negative AVERROR on error. This function never fails if
5975  * pkt is empty.
5976  */
5977 int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
5978
5979 /**
5980  * Retrieve a filtered packet.
5981  *
5982  * @param[out] pkt this struct will be filled with the contents of the filtered
5983  *                 packet. It is owned by the caller and must be freed using
5984  *                 av_packet_unref() when it is no longer needed.
5985  *                 This parameter should be "clean" (i.e. freshly allocated
5986  *                 with av_packet_alloc() or unreffed with av_packet_unref())
5987  *                 when this function is called. If this function returns
5988  *                 successfully, the contents of pkt will be completely
5989  *                 overwritten by the returned data. On failure, pkt is not
5990  *                 touched.
5991  *
5992  * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the
5993  * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there
5994  * will be no further output from the filter. Another negative AVERROR value if
5995  * an error occurs.
5996  *
5997  * @note one input packet may result in several output packets, so after sending
5998  * a packet with av_bsf_send_packet(), this function needs to be called
5999  * repeatedly until it stops returning 0. It is also possible for a filter to
6000  * output fewer packets than were sent to it, so this function may return
6001  * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call.
6002  */
6003 int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);
6004
6005 /**
6006  * Reset the internal bitstream filter state / flush internal buffers.
6007  */
6008 void av_bsf_flush(AVBSFContext *ctx);
6009
6010 /**
6011  * Free a bitstream filter context and everything associated with it; write NULL
6012  * into the supplied pointer.
6013  */
6014 void av_bsf_free(AVBSFContext **ctx);
6015
6016 /**
6017  * Get the AVClass for AVBSFContext. It can be used in combination with
6018  * AV_OPT_SEARCH_FAKE_OBJ for examining options.
6019  *
6020  * @see av_opt_find().
6021  */
6022 const AVClass *av_bsf_get_class(void);
6023
6024 /**
6025  * Structure for chain/list of bitstream filters.
6026  * Empty list can be allocated by av_bsf_list_alloc().
6027  */
6028 typedef struct AVBSFList AVBSFList;
6029
6030 /**
6031  * Allocate empty list of bitstream filters.
6032  * The list must be later freed by av_bsf_list_free()
6033  * or finalized by av_bsf_list_finalize().
6034  *
6035  * @return Pointer to @ref AVBSFList on success, NULL in case of failure
6036  */
6037 AVBSFList *av_bsf_list_alloc(void);
6038
6039 /**
6040  * Free list of bitstream filters.
6041  *
6042  * @param lst Pointer to pointer returned by av_bsf_list_alloc()
6043  */
6044 void av_bsf_list_free(AVBSFList **lst);
6045
6046 /**
6047  * Append bitstream filter to the list of bitstream filters.
6048  *
6049  * @param lst List to append to
6050  * @param bsf Filter context to be appended
6051  *
6052  * @return >=0 on success, negative AVERROR in case of failure
6053  */
6054 int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf);
6055
6056 /**
6057  * Construct new bitstream filter context given it's name and options
6058  * and append it to the list of bitstream filters.
6059  *
6060  * @param lst      List to append to
6061  * @param bsf_name Name of the bitstream filter
6062  * @param options  Options for the bitstream filter, can be set to NULL
6063  *
6064  * @return >=0 on success, negative AVERROR in case of failure
6065  */
6066 int av_bsf_list_append2(AVBSFList *lst, const char * bsf_name, AVDictionary **options);
6067 /**
6068  * Finalize list of bitstream filters.
6069  *
6070  * This function will transform @ref AVBSFList to single @ref AVBSFContext,
6071  * so the whole chain of bitstream filters can be treated as single filter
6072  * freshly allocated by av_bsf_alloc().
6073  * If the call is successful, @ref AVBSFList structure is freed and lst
6074  * will be set to NULL. In case of failure, caller is responsible for
6075  * freeing the structure by av_bsf_list_free()
6076  *
6077  * @param      lst Filter list structure to be transformed
6078  * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure
6079  *                 representing the chain of bitstream filters
6080  *
6081  * @return >=0 on success, negative AVERROR in case of failure
6082  */
6083 int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf);
6084
6085 /**
6086  * Parse string describing list of bitstream filters and create single
6087  * @ref AVBSFContext describing the whole chain of bitstream filters.
6088  * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly
6089  * allocated by av_bsf_alloc().
6090  *
6091  * @param      str String describing chain of bitstream filters in format
6092  *                 `bsf1[=opt1=val1:opt2=val2][,bsf2]`
6093  * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure
6094  *                 representing the chain of bitstream filters
6095  *
6096  * @return >=0 on success, negative AVERROR in case of failure
6097  */
6098 int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf);
6099
6100 /**
6101  * Get null/pass-through bitstream filter.
6102  *
6103  * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter
6104  *
6105  * @return
6106  */
6107 int av_bsf_get_null_filter(AVBSFContext **bsf);
6108
6109 /* memory */
6110
6111 /**
6112  * Same behaviour av_fast_malloc but the buffer has additional
6113  * AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.
6114  *
6115  * In addition the whole buffer will initially and after resizes
6116  * be 0-initialized so that no uninitialized data will ever appear.
6117  */
6118 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
6119
6120 /**
6121  * Same behaviour av_fast_padded_malloc except that buffer will always
6122  * be 0-initialized after call.
6123  */
6124 void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size);
6125
6126 /**
6127  * Encode extradata length to a buffer. Used by xiph codecs.
6128  *
6129  * @param s buffer to write to; must be at least (v/255+1) bytes long
6130  * @param v size of extradata in bytes
6131  * @return number of bytes written to the buffer.
6132  */
6133 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
6134
6135 #if FF_API_USER_VISIBLE_AVHWACCEL
6136 /**
6137  * Register the hardware accelerator hwaccel.
6138  *
6139  * @deprecated  This function doesn't do anything.
6140  */
6141 attribute_deprecated
6142 void av_register_hwaccel(AVHWAccel *hwaccel);
6143
6144 /**
6145  * If hwaccel is NULL, returns the first registered hardware accelerator,
6146  * if hwaccel is non-NULL, returns the next registered hardware accelerator
6147  * after hwaccel, or NULL if hwaccel is the last one.
6148  *
6149  * @deprecated  AVHWaccel structures contain no user-serviceable parts, so
6150  *              this function should not be used.
6151  */
6152 attribute_deprecated
6153 AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel);
6154 #endif
6155
6156 #if FF_API_LOCKMGR
6157 /**
6158  * Lock operation used by lockmgr
6159  *
6160  * @deprecated Deprecated together with av_lockmgr_register().
6161  */
6162 enum AVLockOp {
6163   AV_LOCK_CREATE,  ///< Create a mutex
6164   AV_LOCK_OBTAIN,  ///< Lock the mutex
6165   AV_LOCK_RELEASE, ///< Unlock the mutex
6166   AV_LOCK_DESTROY, ///< Free mutex resources
6167 };
6168
6169 /**
6170  * Register a user provided lock manager supporting the operations
6171  * specified by AVLockOp. The "mutex" argument to the function points
6172  * to a (void *) where the lockmgr should store/get a pointer to a user
6173  * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the
6174  * value left by the last call for all other ops. If the lock manager is
6175  * unable to perform the op then it should leave the mutex in the same
6176  * state as when it was called and return a non-zero value. However,
6177  * when called with AV_LOCK_DESTROY the mutex will always be assumed to
6178  * have been successfully destroyed. If av_lockmgr_register succeeds
6179  * it will return a non-negative value, if it fails it will return a
6180  * negative value and destroy all mutex and unregister all callbacks.
6181  * av_lockmgr_register is not thread-safe, it must be called from a
6182  * single thread before any calls which make use of locking are used.
6183  *
6184  * @param cb User defined callback. av_lockmgr_register invokes calls
6185  *           to this callback and the previously registered callback.
6186  *           The callback will be used to create more than one mutex
6187  *           each of which must be backed by its own underlying locking
6188  *           mechanism (i.e. do not use a single static object to
6189  *           implement your lock manager). If cb is set to NULL the
6190  *           lockmgr will be unregistered.
6191  *
6192  * @deprecated This function does nothing, and always returns 0. Be sure to
6193  *             build with thread support to get basic thread safety.
6194  */
6195 attribute_deprecated
6196 int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
6197 #endif
6198
6199 /**
6200  * Get the type of the given codec.
6201  */
6202 enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
6203
6204 /**
6205  * Get the name of a codec.
6206  * @return  a static string identifying the codec; never NULL
6207  */
6208 const char *avcodec_get_name(enum AVCodecID id);
6209
6210 /**
6211  * @return a positive value if s is open (i.e. avcodec_open2() was called on it
6212  * with no corresponding avcodec_close()), 0 otherwise.
6213  */
6214 int avcodec_is_open(AVCodecContext *s);
6215
6216 /**
6217  * @return a non-zero number if codec is an encoder, zero otherwise
6218  */
6219 int av_codec_is_encoder(const AVCodec *codec);
6220
6221 /**
6222  * @return a non-zero number if codec is a decoder, zero otherwise
6223  */
6224 int av_codec_is_decoder(const AVCodec *codec);
6225
6226 /**
6227  * @return descriptor for given codec ID or NULL if no descriptor exists.
6228  */
6229 const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id);
6230
6231 /**
6232  * Iterate over all codec descriptors known to libavcodec.
6233  *
6234  * @param prev previous descriptor. NULL to get the first descriptor.
6235  *
6236  * @return next descriptor or NULL after the last descriptor
6237  */
6238 const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev);
6239
6240 /**
6241  * @return codec descriptor with the given name or NULL if no such descriptor
6242  *         exists.
6243  */
6244 const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name);
6245
6246 /**
6247  * Allocate a CPB properties structure and initialize its fields to default
6248  * values.
6249  *
6250  * @param size if non-NULL, the size of the allocated struct will be written
6251  *             here. This is useful for embedding it in side data.
6252  *
6253  * @return the newly allocated struct or NULL on failure
6254  */
6255 AVCPBProperties *av_cpb_properties_alloc(size_t *size);
6256
6257 /**
6258  * @}
6259  */
6260
6261 #endif /* AVCODEC_AVCODEC_H */