Add Apple Pixlet decoder
[libav.git] / libavcodec / avcodec.h
1 /*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of Libav.
5 *
6 * Libav 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 * Libav 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 Libav; 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/dict.h"
37 #include "libavutil/frame.h"
38 #include "libavutil/log.h"
39 #include "libavutil/pixfmt.h"
40 #include "libavutil/rational.h"
41
42 #include "version.h"
43
44 #if FF_API_FAST_MALLOC
45 // to provide fast_*alloc
46 #include "libavutil/mem.h"
47 #endif
48
49 /**
50 * @defgroup libavc Encoding/Decoding Library
51 * @{
52 *
53 * @defgroup lavc_decoding Decoding
54 * @{
55 * @}
56 *
57 * @defgroup lavc_encoding Encoding
58 * @{
59 * @}
60 *
61 * @defgroup lavc_codec Codecs
62 * @{
63 * @defgroup lavc_codec_native Native Codecs
64 * @{
65 * @}
66 * @defgroup lavc_codec_wrappers External library wrappers
67 * @{
68 * @}
69 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
70 * @{
71 * @}
72 * @}
73 * @defgroup lavc_internal Internal
74 * @{
75 * @}
76 * @}
77 */
78
79 /**
80 * @ingroup libavc
81 * @defgroup lavc_encdec send/receive encoding and decoding API overview
82 * @{
83 *
84 * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/
85 * avcodec_receive_packet() functions provide an encode/decode API, which
86 * decouples input and output.
87 *
88 * The API is very similar for encoding/decoding and audio/video, and works as
89 * follows:
90 * - Set up and open the AVCodecContext as usual.
91 * - Send valid input:
92 * - For decoding, call avcodec_send_packet() to give the decoder raw
93 * compressed data in an AVPacket.
94 * - For encoding, call avcodec_send_frame() to give the decoder an AVFrame
95 * containing uncompressed audio or video.
96 * In both cases, it is recommended that AVPackets and AVFrames are
97 * refcounted, or libavcodec might have to copy the input data. (libavformat
98 * always returns refcounted AVPackets, and av_frame_get_buffer() allocates
99 * refcounted AVFrames.)
100 * - Receive output in a loop. Periodically call one of the avcodec_receive_*()
101 * functions and process their output:
102 * - For decoding, call avcodec_receive_frame(). On success, it will return
103 * an AVFrame containing uncompressed audio or video data.
104 * - For encoding, call avcodec_receive_packet(). On success, it will return
105 * an AVPacket with a compressed frame.
106 * Repeat this call until it returns AVERROR(EAGAIN) or an error. The
107 * AVERROR(EAGAIN) return value means that new input data is required to
108 * return new output. In this case, continue with sending input. For each
109 * input frame/packet, the codec will typically return 1 output frame/packet,
110 * but it can also be 0 or more than 1.
111 *
112 * At the beginning of decoding or encoding, the codec might accept multiple
113 * input frames/packets without returning a frame, until its internal buffers
114 * are filled. This situation is handled transparently if you follow the steps
115 * outlined above.
116 *
117 * End of stream situations. These require "flushing" (aka draining) the codec,
118 * as the codec might buffer multiple frames or packets internally for
119 * performance or out of necessity (consider B-frames).
120 * This is handled as follows:
121 * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding)
122 * or avcodec_send_frame() (encoding) functions. This will enter draining
123 * mode.
124 * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet()
125 * (encoding) in a loop until AVERROR_EOF is returned. The functions will
126 * not return AVERROR(EAGAIN), unless you forgot to enter draining mode.
127 * - Before decoding can be resumed again, the codec has to be reset with
128 * avcodec_flush_buffers().
129 *
130 * Using the API as outlined above is highly recommended. But it is also
131 * possible to call functions outside of this rigid schema. For example, you can
132 * call avcodec_send_packet() repeatedly without calling
133 * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed
134 * until the codec's internal buffer has been filled up (which is typically of
135 * size 1 per output frame, after initial input), and then reject input with
136 * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to
137 * read at least some output.
138 *
139 * Not all codecs will follow a rigid and predictable dataflow; the only
140 * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on
141 * one end implies that a receive/send call on the other end will succeed. In
142 * general, no codec will permit unlimited buffering of input or output.
143 *
144 * This API replaces the following legacy functions:
145 * - avcodec_decode_video2() and avcodec_decode_audio4():
146 * Use avcodec_send_packet() to feed input to the decoder, then use
147 * avcodec_receive_frame() to receive decoded frames after each packet.
148 * Unlike with the old video decoding API, multiple frames might result from
149 * a packet. For audio, splitting the input packet into frames by partially
150 * decoding packets becomes transparent to the API user. You never need to
151 * feed an AVPacket to the API twice.
152 * Additionally, sending a flush/draining packet is required only once.
153 * - avcodec_encode_video2()/avcodec_encode_audio2():
154 * Use avcodec_send_frame() to feed input to the encoder, then use
155 * avcodec_receive_packet() to receive encoded packets.
156 * Providing user-allocated buffers for avcodec_receive_packet() is not
157 * possible.
158 * - The new API does not handle subtitles yet.
159 *
160 * Mixing new and old function calls on the same AVCodecContext is not allowed,
161 * and will result in arbitrary behavior.
162 *
163 * Some codecs might require using the new API; using the old API will return
164 * an error when calling it.
165 * @}
166 */
167
168 /**
169 * @defgroup lavc_core Core functions/structures.
170 * @ingroup libavc
171 *
172 * Basic definitions, functions for querying libavcodec capabilities,
173 * allocating core structures, etc.
174 * @{
175 */
176
177
178 /**
179 * Identify the syntax and semantics of the bitstream.
180 * The principle is roughly:
181 * Two decoders with the same ID can decode the same streams.
182 * Two encoders with the same ID can encode compatible streams.
183 * There may be slight deviations from the principle due to implementation
184 * details.
185 *
186 * If you add a codec ID to this list, add it so that
187 * 1. no value of a existing codec ID changes (that would break ABI),
188 * 2. it is as close as possible to similar codecs.
189 *
190 * After adding new codec IDs, do not forget to add an entry to the codec
191 * descriptor list and bump libavcodec minor version.
192 */
193 enum AVCodecID {
194 AV_CODEC_ID_NONE,
195
196 /* video codecs */
197 AV_CODEC_ID_MPEG1VIDEO,
198 AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
199 #if FF_API_XVMC
200 AV_CODEC_ID_MPEG2VIDEO_XVMC,
201 #endif /* FF_API_XVMC */
202 AV_CODEC_ID_H261,
203 AV_CODEC_ID_H263,
204 AV_CODEC_ID_RV10,
205 AV_CODEC_ID_RV20,
206 AV_CODEC_ID_MJPEG,
207 AV_CODEC_ID_MJPEGB,
208 AV_CODEC_ID_LJPEG,
209 AV_CODEC_ID_SP5X,
210 AV_CODEC_ID_JPEGLS,
211 AV_CODEC_ID_MPEG4,
212 AV_CODEC_ID_RAWVIDEO,
213 AV_CODEC_ID_MSMPEG4V1,
214 AV_CODEC_ID_MSMPEG4V2,
215 AV_CODEC_ID_MSMPEG4V3,
216 AV_CODEC_ID_WMV1,
217 AV_CODEC_ID_WMV2,
218 AV_CODEC_ID_H263P,
219 AV_CODEC_ID_H263I,
220 AV_CODEC_ID_FLV1,
221 AV_CODEC_ID_SVQ1,
222 AV_CODEC_ID_SVQ3,
223 AV_CODEC_ID_DVVIDEO,
224 AV_CODEC_ID_HUFFYUV,
225 AV_CODEC_ID_CYUV,
226 AV_CODEC_ID_H264,
227 AV_CODEC_ID_INDEO3,
228 AV_CODEC_ID_VP3,
229 AV_CODEC_ID_THEORA,
230 AV_CODEC_ID_ASV1,
231 AV_CODEC_ID_ASV2,
232 AV_CODEC_ID_FFV1,
233 AV_CODEC_ID_4XM,
234 AV_CODEC_ID_VCR1,
235 AV_CODEC_ID_CLJR,
236 AV_CODEC_ID_MDEC,
237 AV_CODEC_ID_ROQ,
238 AV_CODEC_ID_INTERPLAY_VIDEO,
239 AV_CODEC_ID_XAN_WC3,
240 AV_CODEC_ID_XAN_WC4,
241 AV_CODEC_ID_RPZA,
242 AV_CODEC_ID_CINEPAK,
243 AV_CODEC_ID_WS_VQA,
244 AV_CODEC_ID_MSRLE,
245 AV_CODEC_ID_MSVIDEO1,
246 AV_CODEC_ID_IDCIN,
247 AV_CODEC_ID_8BPS,
248 AV_CODEC_ID_SMC,
249 AV_CODEC_ID_FLIC,
250 AV_CODEC_ID_TRUEMOTION1,
251 AV_CODEC_ID_VMDVIDEO,
252 AV_CODEC_ID_MSZH,
253 AV_CODEC_ID_ZLIB,
254 AV_CODEC_ID_QTRLE,
255 AV_CODEC_ID_TSCC,
256 AV_CODEC_ID_ULTI,
257 AV_CODEC_ID_QDRAW,
258 AV_CODEC_ID_VIXL,
259 AV_CODEC_ID_QPEG,
260 AV_CODEC_ID_PNG,
261 AV_CODEC_ID_PPM,
262 AV_CODEC_ID_PBM,
263 AV_CODEC_ID_PGM,
264 AV_CODEC_ID_PGMYUV,
265 AV_CODEC_ID_PAM,
266 AV_CODEC_ID_FFVHUFF,
267 AV_CODEC_ID_RV30,
268 AV_CODEC_ID_RV40,
269 AV_CODEC_ID_VC1,
270 AV_CODEC_ID_WMV3,
271 AV_CODEC_ID_LOCO,
272 AV_CODEC_ID_WNV1,
273 AV_CODEC_ID_AASC,
274 AV_CODEC_ID_INDEO2,
275 AV_CODEC_ID_FRAPS,
276 AV_CODEC_ID_TRUEMOTION2,
277 AV_CODEC_ID_BMP,
278 AV_CODEC_ID_CSCD,
279 AV_CODEC_ID_MMVIDEO,
280 AV_CODEC_ID_ZMBV,
281 AV_CODEC_ID_AVS,
282 AV_CODEC_ID_SMACKVIDEO,
283 AV_CODEC_ID_NUV,
284 AV_CODEC_ID_KMVC,
285 AV_CODEC_ID_FLASHSV,
286 AV_CODEC_ID_CAVS,
287 AV_CODEC_ID_JPEG2000,
288 AV_CODEC_ID_VMNC,
289 AV_CODEC_ID_VP5,
290 AV_CODEC_ID_VP6,
291 AV_CODEC_ID_VP6F,
292 AV_CODEC_ID_TARGA,
293 AV_CODEC_ID_DSICINVIDEO,
294 AV_CODEC_ID_TIERTEXSEQVIDEO,
295 AV_CODEC_ID_TIFF,
296 AV_CODEC_ID_GIF,
297 AV_CODEC_ID_DXA,
298 AV_CODEC_ID_DNXHD,
299 AV_CODEC_ID_THP,
300 AV_CODEC_ID_SGI,
301 AV_CODEC_ID_C93,
302 AV_CODEC_ID_BETHSOFTVID,
303 AV_CODEC_ID_PTX,
304 AV_CODEC_ID_TXD,
305 AV_CODEC_ID_VP6A,
306 AV_CODEC_ID_AMV,
307 AV_CODEC_ID_VB,
308 AV_CODEC_ID_PCX,
309 AV_CODEC_ID_SUNRAST,
310 AV_CODEC_ID_INDEO4,
311 AV_CODEC_ID_INDEO5,
312 AV_CODEC_ID_MIMIC,
313 AV_CODEC_ID_RL2,
314 AV_CODEC_ID_ESCAPE124,
315 AV_CODEC_ID_DIRAC,
316 AV_CODEC_ID_BFI,
317 AV_CODEC_ID_CMV,
318 AV_CODEC_ID_MOTIONPIXELS,
319 AV_CODEC_ID_TGV,
320 AV_CODEC_ID_TGQ,
321 AV_CODEC_ID_TQI,
322 AV_CODEC_ID_AURA,
323 AV_CODEC_ID_AURA2,
324 AV_CODEC_ID_V210X,
325 AV_CODEC_ID_TMV,
326 AV_CODEC_ID_V210,
327 AV_CODEC_ID_DPX,
328 AV_CODEC_ID_MAD,
329 AV_CODEC_ID_FRWU,
330 AV_CODEC_ID_FLASHSV2,
331 AV_CODEC_ID_CDGRAPHICS,
332 AV_CODEC_ID_R210,
333 AV_CODEC_ID_ANM,
334 AV_CODEC_ID_BINKVIDEO,
335 AV_CODEC_ID_IFF_ILBM,
336 AV_CODEC_ID_IFF_BYTERUN1,
337 AV_CODEC_ID_KGV1,
338 AV_CODEC_ID_YOP,
339 AV_CODEC_ID_VP8,
340 AV_CODEC_ID_PICTOR,
341 AV_CODEC_ID_ANSI,
342 AV_CODEC_ID_A64_MULTI,
343 AV_CODEC_ID_A64_MULTI5,
344 AV_CODEC_ID_R10K,
345 AV_CODEC_ID_MXPEG,
346 AV_CODEC_ID_LAGARITH,
347 AV_CODEC_ID_PRORES,
348 AV_CODEC_ID_JV,
349 AV_CODEC_ID_DFA,
350 AV_CODEC_ID_WMV3IMAGE,
351 AV_CODEC_ID_VC1IMAGE,
352 AV_CODEC_ID_UTVIDEO,
353 AV_CODEC_ID_BMV_VIDEO,
354 AV_CODEC_ID_VBLE,
355 AV_CODEC_ID_DXTORY,
356 AV_CODEC_ID_V410,
357 AV_CODEC_ID_XWD,
358 AV_CODEC_ID_CDXL,
359 AV_CODEC_ID_XBM,
360 AV_CODEC_ID_ZEROCODEC,
361 AV_CODEC_ID_MSS1,
362 AV_CODEC_ID_MSA1,
363 AV_CODEC_ID_TSCC2,
364 AV_CODEC_ID_MTS2,
365 AV_CODEC_ID_CLLC,
366 AV_CODEC_ID_MSS2,
367 AV_CODEC_ID_VP9,
368 AV_CODEC_ID_AIC,
369 AV_CODEC_ID_ESCAPE130,
370 AV_CODEC_ID_G2M,
371 AV_CODEC_ID_WEBP,
372 AV_CODEC_ID_HNM4_VIDEO,
373 AV_CODEC_ID_HEVC,
374 AV_CODEC_ID_FIC,
375 AV_CODEC_ID_ALIAS_PIX,
376 AV_CODEC_ID_BRENDER_PIX,
377 AV_CODEC_ID_PAF_VIDEO,
378 AV_CODEC_ID_EXR,
379 AV_CODEC_ID_VP7,
380 AV_CODEC_ID_SANM,
381 AV_CODEC_ID_SGIRLE,
382 AV_CODEC_ID_MVC1,
383 AV_CODEC_ID_MVC2,
384 AV_CODEC_ID_HQX,
385 AV_CODEC_ID_TDSC,
386 AV_CODEC_ID_HQ_HQA,
387 AV_CODEC_ID_HAP,
388 AV_CODEC_ID_DDS,
389 AV_CODEC_ID_DXV,
390 AV_CODEC_ID_SCREENPRESSO,
391 AV_CODEC_ID_RSCC,
392 AV_CODEC_ID_MAGICYUV,
393 AV_CODEC_ID_TRUEMOTION2RT,
394 AV_CODEC_ID_AV1,
395 AV_CODEC_ID_PIXLET,
396
397 /* various PCM "codecs" */
398 AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
399 AV_CODEC_ID_PCM_S16LE = 0x10000,
400 AV_CODEC_ID_PCM_S16BE,
401 AV_CODEC_ID_PCM_U16LE,
402 AV_CODEC_ID_PCM_U16BE,
403 AV_CODEC_ID_PCM_S8,
404 AV_CODEC_ID_PCM_U8,
405 AV_CODEC_ID_PCM_MULAW,
406 AV_CODEC_ID_PCM_ALAW,
407 AV_CODEC_ID_PCM_S32LE,
408 AV_CODEC_ID_PCM_S32BE,
409 AV_CODEC_ID_PCM_U32LE,
410 AV_CODEC_ID_PCM_U32BE,
411 AV_CODEC_ID_PCM_S24LE,
412 AV_CODEC_ID_PCM_S24BE,
413 AV_CODEC_ID_PCM_U24LE,
414 AV_CODEC_ID_PCM_U24BE,
415 AV_CODEC_ID_PCM_S24DAUD,
416 AV_CODEC_ID_PCM_ZORK,
417 AV_CODEC_ID_PCM_S16LE_PLANAR,
418 AV_CODEC_ID_PCM_DVD,
419 AV_CODEC_ID_PCM_F32BE,
420 AV_CODEC_ID_PCM_F32LE,
421 AV_CODEC_ID_PCM_F64BE,
422 AV_CODEC_ID_PCM_F64LE,
423 AV_CODEC_ID_PCM_BLURAY,
424 AV_CODEC_ID_PCM_LXF,
425 AV_CODEC_ID_S302M,
426 AV_CODEC_ID_PCM_S8_PLANAR,
427 AV_CODEC_ID_PCM_S24LE_PLANAR,
428 AV_CODEC_ID_PCM_S32LE_PLANAR,
429 AV_CODEC_ID_PCM_S16BE_PLANAR,
430
431 /* various ADPCM codecs */
432 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
433 AV_CODEC_ID_ADPCM_IMA_WAV,
434 AV_CODEC_ID_ADPCM_IMA_DK3,
435 AV_CODEC_ID_ADPCM_IMA_DK4,
436 AV_CODEC_ID_ADPCM_IMA_WS,
437 AV_CODEC_ID_ADPCM_IMA_SMJPEG,
438 AV_CODEC_ID_ADPCM_MS,
439 AV_CODEC_ID_ADPCM_4XM,
440 AV_CODEC_ID_ADPCM_XA,
441 AV_CODEC_ID_ADPCM_ADX,
442 AV_CODEC_ID_ADPCM_EA,
443 AV_CODEC_ID_ADPCM_G726,
444 AV_CODEC_ID_ADPCM_CT,
445 AV_CODEC_ID_ADPCM_SWF,
446 AV_CODEC_ID_ADPCM_YAMAHA,
447 AV_CODEC_ID_ADPCM_SBPRO_4,
448 AV_CODEC_ID_ADPCM_SBPRO_3,
449 AV_CODEC_ID_ADPCM_SBPRO_2,
450 AV_CODEC_ID_ADPCM_THP,
451 AV_CODEC_ID_ADPCM_IMA_AMV,
452 AV_CODEC_ID_ADPCM_EA_R1,
453 AV_CODEC_ID_ADPCM_EA_R3,
454 AV_CODEC_ID_ADPCM_EA_R2,
455 AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
456 AV_CODEC_ID_ADPCM_IMA_EA_EACS,
457 AV_CODEC_ID_ADPCM_EA_XAS,
458 AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
459 AV_CODEC_ID_ADPCM_IMA_ISS,
460 AV_CODEC_ID_ADPCM_G722,
461 AV_CODEC_ID_ADPCM_IMA_APC,
462 AV_CODEC_ID_ADPCM_VIMA,
463
464 /* AMR */
465 AV_CODEC_ID_AMR_NB = 0x12000,
466 AV_CODEC_ID_AMR_WB,
467
468 /* RealAudio codecs*/
469 AV_CODEC_ID_RA_144 = 0x13000,
470 AV_CODEC_ID_RA_288,
471
472 /* various DPCM codecs */
473 AV_CODEC_ID_ROQ_DPCM = 0x14000,
474 AV_CODEC_ID_INTERPLAY_DPCM,
475 AV_CODEC_ID_XAN_DPCM,
476 AV_CODEC_ID_SOL_DPCM,
477
478 /* audio codecs */
479 AV_CODEC_ID_MP2 = 0x15000,
480 AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
481 AV_CODEC_ID_AAC,
482 AV_CODEC_ID_AC3,
483 AV_CODEC_ID_DTS,
484 AV_CODEC_ID_VORBIS,
485 AV_CODEC_ID_DVAUDIO,
486 AV_CODEC_ID_WMAV1,
487 AV_CODEC_ID_WMAV2,
488 AV_CODEC_ID_MACE3,
489 AV_CODEC_ID_MACE6,
490 AV_CODEC_ID_VMDAUDIO,
491 AV_CODEC_ID_FLAC,
492 AV_CODEC_ID_MP3ADU,
493 AV_CODEC_ID_MP3ON4,
494 AV_CODEC_ID_SHORTEN,
495 AV_CODEC_ID_ALAC,
496 AV_CODEC_ID_WESTWOOD_SND1,
497 AV_CODEC_ID_GSM, ///< as in Berlin toast format
498 AV_CODEC_ID_QDM2,
499 AV_CODEC_ID_COOK,
500 AV_CODEC_ID_TRUESPEECH,
501 AV_CODEC_ID_TTA,
502 AV_CODEC_ID_SMACKAUDIO,
503 AV_CODEC_ID_QCELP,
504 AV_CODEC_ID_WAVPACK,
505 AV_CODEC_ID_DSICINAUDIO,
506 AV_CODEC_ID_IMC,
507 AV_CODEC_ID_MUSEPACK7,
508 AV_CODEC_ID_MLP,
509 AV_CODEC_ID_GSM_MS, /* as found in WAV */
510 AV_CODEC_ID_ATRAC3,
511 #if FF_API_VOXWARE
512 AV_CODEC_ID_VOXWARE,
513 #endif
514 AV_CODEC_ID_APE,
515 AV_CODEC_ID_NELLYMOSER,
516 AV_CODEC_ID_MUSEPACK8,
517 AV_CODEC_ID_SPEEX,
518 AV_CODEC_ID_WMAVOICE,
519 AV_CODEC_ID_WMAPRO,
520 AV_CODEC_ID_WMALOSSLESS,
521 AV_CODEC_ID_ATRAC3P,
522 AV_CODEC_ID_EAC3,
523 AV_CODEC_ID_SIPR,
524 AV_CODEC_ID_MP1,
525 AV_CODEC_ID_TWINVQ,
526 AV_CODEC_ID_TRUEHD,
527 AV_CODEC_ID_MP4ALS,
528 AV_CODEC_ID_ATRAC1,
529 AV_CODEC_ID_BINKAUDIO_RDFT,
530 AV_CODEC_ID_BINKAUDIO_DCT,
531 AV_CODEC_ID_AAC_LATM,
532 AV_CODEC_ID_QDMC,
533 AV_CODEC_ID_CELT,
534 AV_CODEC_ID_G723_1,
535 AV_CODEC_ID_G729,
536 AV_CODEC_ID_8SVX_EXP,
537 AV_CODEC_ID_8SVX_FIB,
538 AV_CODEC_ID_BMV_AUDIO,
539 AV_CODEC_ID_RALF,
540 AV_CODEC_ID_IAC,
541 AV_CODEC_ID_ILBC,
542 AV_CODEC_ID_OPUS,
543 AV_CODEC_ID_COMFORT_NOISE,
544 AV_CODEC_ID_TAK,
545 AV_CODEC_ID_METASOUND,
546 AV_CODEC_ID_PAF_AUDIO,
547 AV_CODEC_ID_ON2AVC,
548 AV_CODEC_ID_DSS_SP,
549
550 /* subtitle codecs */
551 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
552 AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
553 AV_CODEC_ID_DVB_SUBTITLE,
554 AV_CODEC_ID_TEXT, ///< raw UTF-8 text
555 AV_CODEC_ID_XSUB,
556 AV_CODEC_ID_SSA,
557 AV_CODEC_ID_MOV_TEXT,
558 AV_CODEC_ID_HDMV_PGS_SUBTITLE,
559 AV_CODEC_ID_DVB_TELETEXT,
560 AV_CODEC_ID_SRT,
561
562 /* other specific kind of codecs (generally used for attachments) */
563 AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
564 AV_CODEC_ID_TTF = 0x18000,
565
566 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
567
568 AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
569 * stream (only used by libavformat) */
570 AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
571 * stream (only used by libavformat) */
572 AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
573 AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
574 };
575
576 /**
577 * This struct describes the properties of a single codec described by an
578 * AVCodecID.
579 * @see avcodec_descriptor_get()
580 */
581 typedef struct AVCodecDescriptor {
582 enum AVCodecID id;
583 enum AVMediaType type;
584 /**
585 * Name of the codec described by this descriptor. It is non-empty and
586 * unique for each codec descriptor. It should contain alphanumeric
587 * characters and '_' only.
588 */
589 const char *name;
590 /**
591 * A more descriptive name for this codec. May be NULL.
592 */
593 const char *long_name;
594 /**
595 * Codec properties, a combination of AV_CODEC_PROP_* flags.
596 */
597 int props;
598 /**
599 * If non-NULL, an array of profiles recognized for this codec.
600 * Terminated with FF_PROFILE_UNKNOWN.
601 */
602 const struct AVProfile *profiles;
603 } AVCodecDescriptor;
604
605 /**
606 * Codec uses only intra compression.
607 * Video codecs only.
608 */
609 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
610 /**
611 * Codec supports lossy compression. Audio and video codecs only.
612 * @note a codec may support both lossy and lossless
613 * compression modes
614 */
615 #define AV_CODEC_PROP_LOSSY (1 << 1)
616 /**
617 * Codec supports lossless compression. Audio and video codecs only.
618 */
619 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
620 /**
621 * Codec supports frame reordering. That is, the coded order (the order in which
622 * the encoded packets are output by the encoders / stored / input to the
623 * decoders) may be different from the presentation order of the corresponding
624 * frames.
625 *
626 * For codecs that do not have this property set, PTS and DTS should always be
627 * equal.
628 */
629 #define AV_CODEC_PROP_REORDER (1 << 3)
630
631 /**
632 * @ingroup lavc_decoding
633 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
634 * This is mainly needed because some optimized bitstream readers read
635 * 32 or 64 bit at once and could read over the end.<br>
636 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
637 * MPEG bitstreams could cause overread and segfault.
638 */
639 #define AV_INPUT_BUFFER_PADDING_SIZE 8
640
641 /**
642 * @ingroup lavc_encoding
643 * minimum encoding buffer size
644 * Used to avoid some checks during header writing.
645 */
646 #define AV_INPUT_BUFFER_MIN_SIZE 16384
647
648 #if FF_API_WITHOUT_PREFIX
649 /**
650 * @deprecated use AV_INPUT_BUFFER_PADDING_SIZE instead
651 */
652 #define FF_INPUT_BUFFER_PADDING_SIZE 8
653
654 /**
655 * @deprecated use AV_INPUT_BUFFER_MIN_SIZE instead
656 */
657 #define FF_MIN_BUFFER_SIZE 16384
658 #endif /* FF_API_WITHOUT_PREFIX */
659
660 /**
661 * @ingroup lavc_encoding
662 * motion estimation type.
663 * @deprecated use codec private option instead
664 */
665 #if FF_API_MOTION_EST
666 enum Motion_Est_ID {
667 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
668 ME_FULL,
669 ME_LOG,
670 ME_PHODS,
671 ME_EPZS, ///< enhanced predictive zonal search
672 ME_X1, ///< reserved for experiments
673 ME_HEX, ///< hexagon based search
674 ME_UMH, ///< uneven multi-hexagon search
675 ME_TESA, ///< transformed exhaustive search algorithm
676 };
677 #endif
678
679 /**
680 * @ingroup lavc_decoding
681 */
682 enum AVDiscard{
683 /* We leave some space between them for extensions (drop some
684 * keyframes for intra-only or drop just some bidir frames). */
685 AVDISCARD_NONE =-16, ///< discard nothing
686 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
687 AVDISCARD_NONREF = 8, ///< discard all non reference
688 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
689 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
690 AVDISCARD_ALL = 48, ///< discard all
691 };
692
693 enum AVAudioServiceType {
694 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
695 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
696 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
697 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
698 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
699 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
700 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
701 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
702 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
703 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
704 };
705
706 /**
707 * @ingroup lavc_encoding
708 */
709 typedef struct RcOverride{
710 int start_frame;
711 int end_frame;
712 int qscale; // If this is 0 then quality_factor will be used instead.
713 float quality_factor;
714 } RcOverride;
715
716 #if FF_API_MAX_BFRAMES
717 /**
718 * @deprecated there is no libavcodec-wide limit on the number of B-frames
719 */
720 #define FF_MAX_B_FRAMES 16
721 #endif
722
723 /* encoding support
724 These flags can be passed in AVCodecContext.flags before initialization.
725 Note: Not everything is supported yet.
726 */
727
728 /**
729 * Allow decoders to produce frames with data planes that are not aligned
730 * to CPU requirements (e.g. due to cropping).
731 */
732 #define AV_CODEC_FLAG_UNALIGNED (1 << 0)
733 /**
734 * Use fixed qscale.
735 */
736 #define AV_CODEC_FLAG_QSCALE (1 << 1)
737 /**
738 * 4 MV per MB allowed / advanced prediction for H.263.
739 */
740 #define AV_CODEC_FLAG_4MV (1 << 2)
741 /**
742 * Output even those frames that might be corrupted.
743 */
744 #define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)
745 /**
746 * Use qpel MC.
747 */
748 #define AV_CODEC_FLAG_QPEL (1 << 4)
749 /**
750 * Use internal 2pass ratecontrol in first pass mode.
751 */
752 #define AV_CODEC_FLAG_PASS1 (1 << 9)
753 /**
754 * Use internal 2pass ratecontrol in second pass mode.
755 */
756 #define AV_CODEC_FLAG_PASS2 (1 << 10)
757 /**
758 * loop filter.
759 */
760 #define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
761 /**
762 * Only decode/encode grayscale.
763 */
764 #define AV_CODEC_FLAG_GRAY (1 << 13)
765 /**
766 * error[?] variables will be set during encoding.
767 */
768 #define AV_CODEC_FLAG_PSNR (1 << 15)
769 /**
770 * Input bitstream might be truncated at a random location
771 * instead of only at frame boundaries.
772 */
773 #define AV_CODEC_FLAG_TRUNCATED (1 << 16)
774 /**
775 * Use interlaced DCT.
776 */
777 #define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18)
778 /**
779 * Force low delay.
780 */
781 #define AV_CODEC_FLAG_LOW_DELAY (1 << 19)
782 /**
783 * Place global headers in extradata instead of every keyframe.
784 */
785 #define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
786 /**
787 * Use only bitexact stuff (except (I)DCT).
788 */
789 #define AV_CODEC_FLAG_BITEXACT (1 << 23)
790 /* Fx : Flag for H.263+ extra options */
791 /**
792 * H.263 advanced intra coding / MPEG-4 AC prediction
793 */
794 #define AV_CODEC_FLAG_AC_PRED (1 << 24)
795 /**
796 * interlaced motion estimation
797 */
798 #define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)
799 #define AV_CODEC_FLAG_CLOSED_GOP (1 << 31)
800
801 /**
802 * Allow non spec compliant speedup tricks.
803 */
804 #define AV_CODEC_FLAG2_FAST (1 << 0)
805 /**
806 * Skip bitstream encoding.
807 */
808 #define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)
809 /**
810 * Place global headers at every keyframe instead of in extradata.
811 */
812 #define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)
813 /**
814 * Input bitstream might be truncated at a packet boundaries
815 * instead of only at frame boundaries.
816 */
817 #define AV_CODEC_FLAG2_CHUNKS (1 << 15)
818 /**
819 * Discard cropping information from SPS.
820 */
821 #define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)
822
823 /* Unsupported options :
824 * Syntax Arithmetic coding (SAC)
825 * Reference Picture Selection
826 * Independent Segment Decoding */
827 /* /Fx */
828 /* codec capabilities */
829
830 /**
831 * Decoder can use draw_horiz_band callback.
832 */
833 #define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0)
834 /**
835 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
836 * If not set, it might not use get_buffer() at all or use operations that
837 * assume the buffer was allocated by avcodec_default_get_buffer.
838 */
839 #define AV_CODEC_CAP_DR1 (1 << 1)
840 #define AV_CODEC_CAP_TRUNCATED (1 << 3)
841 /**
842 * Encoder or decoder requires flushing with NULL input at the end in order to
843 * give the complete and correct output.
844 *
845 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
846 * with NULL data. The user can still send NULL data to the public encode
847 * or decode function, but libavcodec will not pass it along to the codec
848 * unless this flag is set.
849 *
850 * Decoders:
851 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
852 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
853 * returns frames.
854 *
855 * Encoders:
856 * The encoder needs to be fed with NULL data at the end of encoding until the
857 * encoder no longer returns data.
858 *
859 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
860 * flag also means that the encoder must set the pts and duration for
861 * each output packet. If this flag is not set, the pts and duration will
862 * be determined by libavcodec from the input frame.
863 */
864 #define AV_CODEC_CAP_DELAY (1 << 5)
865 /**
866 * Codec can be fed a final frame with a smaller size.
867 * This can be used to prevent truncation of the last audio samples.
868 */
869 #define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)
870 /**
871 * Codec can output multiple frames per AVPacket
872 * Normally demuxers return one frame at a time, demuxers which do not do
873 * are connected to a parser to split what they return into proper frames.
874 * This flag is reserved to the very rare category of codecs which have a
875 * bitstream that cannot be split into frames without timeconsuming
876 * operations like full decoding. Demuxers carrying such bitstreams thus
877 * may return multiple frames in a packet. This has many disadvantages like
878 * prohibiting stream copy in many cases thus it should only be considered
879 * as a last resort.
880 */
881 #define AV_CODEC_CAP_SUBFRAMES (1 << 8)
882 /**
883 * Codec is experimental and is thus avoided in favor of non experimental
884 * encoders
885 */
886 #define AV_CODEC_CAP_EXPERIMENTAL (1 << 9)
887 /**
888 * Codec should fill in channel configuration and samplerate instead of container
889 */
890 #define AV_CODEC_CAP_CHANNEL_CONF (1 << 10)
891 /**
892 * Codec supports frame-level multithreading.
893 */
894 #define AV_CODEC_CAP_FRAME_THREADS (1 << 12)
895 /**
896 * Codec supports slice-based (or partition-based) multithreading.
897 */
898 #define AV_CODEC_CAP_SLICE_THREADS (1 << 13)
899 /**
900 * Codec supports changed parameters at any point.
901 */
902 #define AV_CODEC_CAP_PARAM_CHANGE (1 << 14)
903 /**
904 * Codec supports avctx->thread_count == 0 (auto).
905 */
906 #define AV_CODEC_CAP_AUTO_THREADS (1 << 15)
907 /**
908 * Audio encoder supports receiving a different number of samples in each call.
909 */
910 #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16)
911
912 #if FF_API_WITHOUT_PREFIX
913 /**
914 * Allow decoders to produce frames with data planes that are not aligned
915 * to CPU requirements (e.g. due to cropping).
916 */
917 #define CODEC_FLAG_UNALIGNED 0x0001
918 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
919 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
920 #define CODEC_FLAG_OUTPUT_CORRUPT 0x0008 ///< Output even those frames that might be corrupted
921 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
922 #if FF_API_GMC
923 /**
924 * @deprecated use the "gmc" private option of the libxvid encoder
925 */
926 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
927 #endif
928 #if FF_API_MV0
929 /**
930 * @deprecated use the flag "mv0" in the "mpv_flags" private option of the
931 * mpegvideo encoders
932 */
933 #define CODEC_FLAG_MV0 0x0040
934 #endif
935 #if FF_API_INPUT_PRESERVED
936 /**
937 * @deprecated passing reference-counted frames to the encoders replaces this
938 * flag
939 */
940 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
941 #endif
942 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
943 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
944 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
945 #if FF_API_EMU_EDGE
946 /**
947 * @deprecated edges are not used/required anymore. I.e. this flag is now always
948 * set.
949 */
950 #define CODEC_FLAG_EMU_EDGE 0x4000
951 #endif
952 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
953 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
954 location instead of only at frame boundaries. */
955 #if FF_API_NORMALIZE_AQP
956 /**
957 * @deprecated use the flag "naq" in the "mpv_flags" private option of the
958 * mpegvideo encoders
959 */
960 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000
961 #endif
962 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
963 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
964 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
965 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
966 /* Fx : Flag for H.263+ extra options */
967 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
968 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
969 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
970 #define CODEC_FLAG_CLOSED_GOP 0x80000000
971 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
972 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
973 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
974 #define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS.
975
976 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
977
978 /* Unsupported options :
979 * Syntax Arithmetic coding (SAC)
980 * Reference Picture Selection
981 * Independent Segment Decoding */
982 /* /Fx */
983 /* codec capabilities */
984
985 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
986 /**
987 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
988 * If not set, it might not use get_buffer() at all or use operations that
989 * assume the buffer was allocated by avcodec_default_get_buffer.
990 */
991 #define CODEC_CAP_DR1 0x0002
992 #define CODEC_CAP_TRUNCATED 0x0008
993 #if FF_API_XVMC
994 /* Codec can export data for HW decoding (XvMC). */
995 #define CODEC_CAP_HWACCEL 0x0010
996 #endif /* FF_API_XVMC */
997 /**
998 * Encoder or decoder requires flushing with NULL input at the end in order to
999 * give the complete and correct output.
1000 *
1001 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
1002 * with NULL data. The user can still send NULL data to the public encode
1003 * or decode function, but libavcodec will not pass it along to the codec
1004 * unless this flag is set.
1005 *
1006 * Decoders:
1007 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
1008 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
1009 * returns frames.
1010 *
1011 * Encoders:
1012 * The encoder needs to be fed with NULL data at the end of encoding until the
1013 * encoder no longer returns data.
1014 *
1015 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
1016 * flag also means that the encoder must set the pts and duration for
1017 * each output packet. If this flag is not set, the pts and duration will
1018 * be determined by libavcodec from the input frame.
1019 */
1020 #define CODEC_CAP_DELAY 0x0020
1021 /**
1022 * Codec can be fed a final frame with a smaller size.
1023 * This can be used to prevent truncation of the last audio samples.
1024 */
1025 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
1026 #if FF_API_CAP_VDPAU
1027 /**
1028 * Codec can export data for HW decoding (VDPAU).
1029 */
1030 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
1031 #endif
1032 /**
1033 * Codec can output multiple frames per AVPacket
1034 * Normally demuxers return one frame at a time, demuxers which do not do
1035 * are connected to a parser to split what they return into proper frames.
1036 * This flag is reserved to the very rare category of codecs which have a
1037 * bitstream that cannot be split into frames without timeconsuming
1038 * operations like full decoding. Demuxers carrying such bitstreams thus
1039 * may return multiple frames in a packet. This has many disadvantages like
1040 * prohibiting stream copy in many cases thus it should only be considered
1041 * as a last resort.
1042 */
1043 #define CODEC_CAP_SUBFRAMES 0x0100
1044 /**
1045 * Codec is experimental and is thus avoided in favor of non experimental
1046 * encoders
1047 */
1048 #define CODEC_CAP_EXPERIMENTAL 0x0200
1049 /**
1050 * Codec should fill in channel configuration and samplerate instead of container
1051 */
1052 #define CODEC_CAP_CHANNEL_CONF 0x0400
1053 #if FF_API_NEG_LINESIZES
1054 /**
1055 * @deprecated no codecs use this capability
1056 */
1057 #define CODEC_CAP_NEG_LINESIZES 0x0800
1058 #endif
1059 /**
1060 * Codec supports frame-level multithreading.
1061 */
1062 #define CODEC_CAP_FRAME_THREADS 0x1000
1063 /**
1064 * Codec supports slice-based (or partition-based) multithreading.
1065 */
1066 #define CODEC_CAP_SLICE_THREADS 0x2000
1067 /**
1068 * Codec supports changed parameters at any point.
1069 */
1070 #define CODEC_CAP_PARAM_CHANGE 0x4000
1071 /**
1072 * Codec supports avctx->thread_count == 0 (auto).
1073 */
1074 #define CODEC_CAP_AUTO_THREADS 0x8000
1075 /**
1076 * Audio encoder supports receiving a different number of samples in each call.
1077 */
1078 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
1079 #endif /* FF_API_WITHOUT_PREFIX */
1080
1081 #if FF_API_MB_TYPE
1082 //The following defines may change, don't expect compatibility if you use them.
1083 #define MB_TYPE_INTRA4x4 0x0001
1084 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
1085 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
1086 #define MB_TYPE_16x16 0x0008
1087 #define MB_TYPE_16x8 0x0010
1088 #define MB_TYPE_8x16 0x0020
1089 #define MB_TYPE_8x8 0x0040
1090 #define MB_TYPE_INTERLACED 0x0080
1091 #define MB_TYPE_DIRECT2 0x0100 //FIXME
1092 #define MB_TYPE_ACPRED 0x0200
1093 #define MB_TYPE_GMC 0x0400
1094 #define MB_TYPE_SKIP 0x0800
1095 #define MB_TYPE_P0L0 0x1000
1096 #define MB_TYPE_P1L0 0x2000
1097 #define MB_TYPE_P0L1 0x4000
1098 #define MB_TYPE_P1L1 0x8000
1099 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
1100 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
1101 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
1102 #define MB_TYPE_QUANT 0x00010000
1103 #define MB_TYPE_CBP 0x00020000
1104 // Note bits 24-31 are reserved for codec specific use (H.264 ref0, MPEG-1 0mv, ...)
1105 #endif
1106
1107 /**
1108 * Pan Scan area.
1109 * This specifies the area which should be displayed.
1110 * Note there may be multiple such areas for one frame.
1111 */
1112 typedef struct AVPanScan{
1113 /**
1114 * id
1115 * - encoding: Set by user.
1116 * - decoding: Set by libavcodec.
1117 */
1118 int id;
1119
1120 /**
1121 * width and height in 1/16 pel
1122 * - encoding: Set by user.
1123 * - decoding: Set by libavcodec.
1124 */
1125 int width;
1126 int height;
1127
1128 /**
1129 * position of the top left corner in 1/16 pel for up to 3 fields/frames
1130 * - encoding: Set by user.
1131 * - decoding: Set by libavcodec.
1132 */
1133 int16_t position[3][2];
1134 }AVPanScan;
1135
1136 /**
1137 * This structure describes the bitrate properties of an encoded bitstream. It
1138 * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD
1139 * parameters for H.264/HEVC.
1140 */
1141 typedef struct AVCPBProperties {
1142 /**
1143 * Maximum bitrate of the stream, in bits per second.
1144 * Zero if unknown or unspecified.
1145 */
1146 int max_bitrate;
1147 /**
1148 * Minimum bitrate of the stream, in bits per second.
1149 * Zero if unknown or unspecified.
1150 */
1151 int min_bitrate;
1152 /**
1153 * Average bitrate of the stream, in bits per second.
1154 * Zero if unknown or unspecified.
1155 */
1156 int avg_bitrate;
1157
1158 /**
1159 * The size of the buffer to which the ratecontrol is applied, in bits.
1160 * Zero if unknown or unspecified.
1161 */
1162 int buffer_size;
1163
1164 /**
1165 * The delay between the time the packet this structure is associated with
1166 * is received and the time when it should be decoded, in periods of a 27MHz
1167 * clock.
1168 *
1169 * UINT64_MAX when unknown or unspecified.
1170 */
1171 uint64_t vbv_delay;
1172 } AVCPBProperties;
1173
1174 #if FF_API_QSCALE_TYPE
1175 #define FF_QSCALE_TYPE_MPEG1 0
1176 #define FF_QSCALE_TYPE_MPEG2 1
1177 #define FF_QSCALE_TYPE_H264 2
1178 #define FF_QSCALE_TYPE_VP56 3
1179 #endif
1180
1181 /**
1182 * The decoder will keep a reference to the frame and may reuse it later.
1183 */
1184 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
1185
1186 /**
1187 * @defgroup lavc_packet AVPacket
1188 *
1189 * Types and functions for working with AVPacket.
1190 * @{
1191 */
1192 enum AVPacketSideDataType {
1193 /**
1194 * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE
1195 * bytes worth of palette. This side data signals that a new palette is
1196 * present.
1197 */
1198 AV_PKT_DATA_PALETTE,
1199
1200 /**
1201 * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format
1202 * that the extradata buffer was changed and the receiving side should
1203 * act upon it appropriately. The new extradata is embedded in the side
1204 * data buffer and should be immediately used for processing the current
1205 * frame or packet.
1206 */
1207 AV_PKT_DATA_NEW_EXTRADATA,
1208
1209 /**
1210 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
1211 * @code
1212 * u32le param_flags
1213 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
1214 * s32le channel_count
1215 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
1216 * u64le channel_layout
1217 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
1218 * s32le sample_rate
1219 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
1220 * s32le width
1221 * s32le height
1222 * @endcode
1223 */
1224 AV_PKT_DATA_PARAM_CHANGE,
1225
1226 /**
1227 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
1228 * structures with info about macroblocks relevant to splitting the
1229 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
1230 * That is, it does not necessarily contain info about all macroblocks,
1231 * as long as the distance between macroblocks in the info is smaller
1232 * than the target payload size.
1233 * Each MB info structure is 12 bytes, and is laid out as follows:
1234 * @code
1235 * u32le bit offset from the start of the packet
1236 * u8 current quantizer at the start of the macroblock
1237 * u8 GOB number
1238 * u16le macroblock address within the GOB
1239 * u8 horizontal MV predictor
1240 * u8 vertical MV predictor
1241 * u8 horizontal MV predictor for block number 3
1242 * u8 vertical MV predictor for block number 3
1243 * @endcode
1244 */
1245 AV_PKT_DATA_H263_MB_INFO,
1246
1247 /**
1248 * This side data should be associated with an audio stream and contains
1249 * ReplayGain information in form of the AVReplayGain struct.
1250 */
1251 AV_PKT_DATA_REPLAYGAIN,
1252
1253 /**
1254 * This side data contains a 3x3 transformation matrix describing an affine
1255 * transformation that needs to be applied to the decoded video frames for
1256 * correct presentation.
1257 *
1258 * See libavutil/display.h for a detailed description of the data.
1259 */
1260 AV_PKT_DATA_DISPLAYMATRIX,
1261
1262 /**
1263 * This side data should be associated with a video stream and contains
1264 * Stereoscopic 3D information in form of the AVStereo3D struct.
1265 */
1266 AV_PKT_DATA_STEREO3D,
1267
1268 /**
1269 * This side data should be associated with an audio stream and corresponds
1270 * to enum AVAudioServiceType.
1271 */
1272 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
1273
1274 /**
1275 * This side data contains an integer value representing the quality
1276 * factor of the compressed frame. Allowed range is between 1 (good)
1277 * and FF_LAMBDA_MAX (bad).
1278 */
1279 AV_PKT_DATA_QUALITY_FACTOR,
1280
1281 /**
1282 * This side data contains an integer value representing the stream index
1283 * of a "fallback" track. A fallback track indicates an alternate
1284 * track to use when the current track can not be decoded for some reason.
1285 * e.g. no decoder available for codec.
1286 */
1287 AV_PKT_DATA_FALLBACK_TRACK,
1288
1289 /**
1290 * This side data corresponds to the AVCPBProperties struct.
1291 */
1292 AV_PKT_DATA_CPB_PROPERTIES,
1293
1294 /**
1295 * This side data should be associated with a video stream and corresponds
1296 * to the AVSphericalMapping structure.
1297 */
1298 AV_PKT_DATA_SPHERICAL,
1299 };
1300
1301 typedef struct AVPacketSideData {
1302 uint8_t *data;
1303 int size;
1304 enum AVPacketSideDataType type;
1305 } AVPacketSideData;
1306
1307 /**
1308 * This structure stores compressed data. It is typically exported by demuxers
1309 * and then passed as input to decoders, or received as output from encoders and
1310 * then passed to muxers.
1311 *
1312 * For video, it should typically contain one compressed frame. For audio it may
1313 * contain several compressed frames. Encoders are allowed to output empty
1314 * packets, with no compressed data, containing only side data
1315 * (e.g. to update some stream parameters at the end of encoding).
1316 *
1317 * AVPacket is one of the few structs in Libav, whose size is a part of public
1318 * ABI. Thus it may be allocated on stack and no new fields can be added to it
1319 * without libavcodec and libavformat major bump.
1320 *
1321 * The semantics of data ownership depends on the buf field.
1322 * If it is set, the packet data is dynamically allocated and is
1323 * valid indefinitely until a call to av_packet_unref() reduces the
1324 * reference count to 0.
1325 *
1326 * If the buf field is not set av_packet_ref() would make a copy instead
1327 * of increasing the reference count.
1328 *
1329 * The side data is always allocated with av_malloc(), copied by
1330 * av_packet_ref() and freed by av_packet_unref().
1331 *
1332 * @see av_packet_ref
1333 * @see av_packet_unref
1334 */
1335 typedef struct AVPacket {
1336 /**
1337 * A reference to the reference-counted buffer where the packet data is
1338 * stored.
1339 * May be NULL, then the packet data is not reference-counted.
1340 */
1341 AVBufferRef *buf;
1342 /**
1343 * Presentation timestamp in AVStream->time_base units; the time at which
1344 * the decompressed packet will be presented to the user.
1345 * Can be AV_NOPTS_VALUE if it is not stored in the file.
1346 * pts MUST be larger or equal to dts as presentation cannot happen before
1347 * decompression, unless one wants to view hex dumps. Some formats misuse
1348 * the terms dts and pts/cts to mean something different. Such timestamps
1349 * must be converted to true pts/dts before they are stored in AVPacket.
1350 */
1351 int64_t pts;
1352 /**
1353 * Decompression timestamp in AVStream->time_base units; the time at which
1354 * the packet is decompressed.
1355 * Can be AV_NOPTS_VALUE if it is not stored in the file.
1356 */
1357 int64_t dts;
1358 uint8_t *data;
1359 int size;
1360 int stream_index;
1361 /**
1362 * A combination of AV_PKT_FLAG values
1363 */
1364 int flags;
1365 /**
1366 * Additional packet data that can be provided by the container.
1367 * Packet can contain several types of side information.
1368 */
1369 AVPacketSideData *side_data;
1370 int side_data_elems;
1371
1372 /**
1373 * Duration of this packet in AVStream->time_base units, 0 if unknown.
1374 * Equals next_pts - this_pts in presentation order.
1375 */
1376 int64_t duration;
1377
1378 int64_t pos; ///< byte position in stream, -1 if unknown
1379
1380 #if FF_API_CONVERGENCE_DURATION
1381 /**
1382 * @deprecated Same as the duration field, but as int64_t. This was required
1383 * for Matroska subtitles, whose duration values could overflow when the
1384 * duration field was still an int.
1385 */
1386 attribute_deprecated
1387 int64_t convergence_duration;
1388 #endif
1389 } AVPacket;
1390 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
1391 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
1392
1393 enum AVSideDataParamChangeFlags {
1394 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
1395 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
1396 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
1397 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
1398 };
1399 /**
1400 * @}
1401 */
1402
1403 struct AVCodecInternal;
1404
1405 enum AVFieldOrder {
1406 AV_FIELD_UNKNOWN,
1407 AV_FIELD_PROGRESSIVE,
1408 AV_FIELD_TT, //< Top coded_first, top displayed first
1409 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
1410 AV_FIELD_TB, //< Top coded first, bottom displayed first
1411 AV_FIELD_BT, //< Bottom coded first, top displayed first
1412 };
1413
1414 /**
1415 * main external API structure.
1416 * New fields can be added to the end with minor version bumps.
1417 * Removal, reordering and changes to existing fields require a major
1418 * version bump.
1419 * sizeof(AVCodecContext) must not be used outside libav*.
1420 */
1421 typedef struct AVCodecContext {
1422 /**
1423 * information on struct for av_log
1424 * - set by avcodec_alloc_context3
1425 */
1426 const AVClass *av_class;
1427 int log_level_offset;
1428
1429 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1430 const struct AVCodec *codec;
1431 #if FF_API_CODEC_NAME
1432 /**
1433 * @deprecated this field is not used for anything in libavcodec
1434 */
1435 attribute_deprecated
1436 char codec_name[32];
1437 #endif
1438 enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
1439
1440 /**
1441 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1442 * This is used to work around some encoder bugs.
1443 * A demuxer should set this to what is stored in the field used to identify the codec.
1444 * If there are multiple such fields in a container then the demuxer should choose the one
1445 * which maximizes the information about the used codec.
1446 * If the codec tag field in a container is larger than 32 bits then the demuxer should
1447 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1448 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1449 * first.
1450 * - encoding: Set by user, if not then the default based on codec_id will be used.
1451 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1452 */
1453 unsigned int codec_tag;
1454
1455 #if FF_API_STREAM_CODEC_TAG
1456 /**
1457 * @deprecated this field is unused
1458 */
1459 attribute_deprecated
1460 unsigned int stream_codec_tag;
1461 #endif
1462
1463 void *priv_data;
1464
1465 /**
1466 * Private context used for internal data.
1467 *
1468 * Unlike priv_data, this is not codec-specific. It is used in general
1469 * libavcodec functions.
1470 */
1471 struct AVCodecInternal *internal;
1472
1473 /**
1474 * Private data of the user, can be used to carry app specific stuff.
1475 * - encoding: Set by user.
1476 * - decoding: Set by user.
1477 */
1478 void *opaque;
1479
1480 /**
1481 * the average bitrate
1482 * - encoding: Set by user; unused for constant quantizer encoding.
1483 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1484 */
1485 int bit_rate;
1486
1487 /**
1488 * number of bits the bitstream is allowed to diverge from the reference.
1489 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1490 * - encoding: Set by user; unused for constant quantizer encoding.
1491 * - decoding: unused
1492 */
1493 int bit_rate_tolerance;
1494
1495 /**
1496 * Global quality for codecs which cannot change it per frame.
1497 * This should be proportional to MPEG-1/2/4 qscale.
1498 * - encoding: Set by user.
1499 * - decoding: unused
1500 */
1501 int global_quality;
1502
1503 /**
1504 * - encoding: Set by user.
1505 * - decoding: unused
1506 */
1507 int compression_level;
1508 #define FF_COMPRESSION_DEFAULT -1
1509
1510 /**
1511 * AV_CODEC_FLAG_*.
1512 * - encoding: Set by user.
1513 * - decoding: Set by user.
1514 */
1515 int flags;
1516
1517 /**
1518 * AV_CODEC_FLAG2_*
1519 * - encoding: Set by user.
1520 * - decoding: Set by user.
1521 */
1522 int flags2;
1523
1524 /**
1525 * some codecs need / can use extradata like Huffman tables.
1526 * MJPEG: Huffman tables
1527 * rv10: additional flags
1528 * MPEG-4: global headers (they can be in the bitstream or here)
1529 * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
1530 * than extradata_size to avoid problems if it is read with the bitstream reader.
1531 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1532 * - encoding: Set/allocated/freed by libavcodec.
1533 * - decoding: Set/allocated/freed by user.
1534 */
1535 uint8_t *extradata;
1536 int extradata_size;
1537
1538 /**
1539 * This is the fundamental unit of time (in seconds) in terms
1540 * of which frame timestamps are represented. For fixed-fps content,
1541 * timebase should be 1/framerate and timestamp increments should be
1542 * identically 1.
1543 * - encoding: MUST be set by user.
1544 * - decoding: the use of this field for decoding is deprecated.
1545 * Use framerate instead.
1546 */
1547 AVRational time_base;
1548
1549 /**
1550 * For some codecs, the time base is closer to the field rate than the frame rate.
1551 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1552 * if no telecine is used ...
1553 *
1554 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1555 */
1556 int ticks_per_frame;
1557
1558 /**
1559 * Codec delay.
1560 *
1561 * Video:
1562 * Number of frames the decoded output will be delayed relative to the
1563 * encoded input.
1564 *
1565 * Audio:
1566 * For encoding, this field is unused (see initial_padding).
1567 *
1568 * For decoding, this is the number of samples the decoder needs to
1569 * output before the decoder's output is valid. When seeking, you should
1570 * start decoding this many samples prior to your desired seek point.
1571 *
1572 * - encoding: Set by libavcodec.
1573 * - decoding: Set by libavcodec.
1574 */
1575 int delay;
1576
1577
1578 /* video only */
1579 /**
1580 * picture width / height.
1581 *
1582 * @note Those fields may not match the values of the last
1583 * AVFrame output by avcodec_decode_video2 due frame
1584 * reordering.
1585 *
1586 * - encoding: MUST be set by user.
1587 * - decoding: May be set by the user before opening the decoder if known e.g.
1588 * from the container. Some decoders will require the dimensions
1589 * to be set by the caller. During decoding, the decoder may
1590 * overwrite those values as required while parsing the data.
1591 */
1592 int width, height;
1593
1594 /**
1595 * Bitstream width / height, may be different from width/height e.g. when
1596 * the decoded frame is cropped before being output.
1597 *
1598 * @note Those field may not match the value of the last
1599 * AVFrame output by avcodec_receive_frame() due frame
1600 * reordering.
1601 *
1602 * - encoding: unused
1603 * - decoding: May be set by the user before opening the decoder if known
1604 * e.g. from the container. During decoding, the decoder may
1605 * overwrite those values as required while parsing the data.
1606 */
1607 int coded_width, coded_height;
1608
1609 #if FF_API_ASPECT_EXTENDED
1610 #define FF_ASPECT_EXTENDED 15
1611 #endif
1612
1613 /**
1614 * the number of pictures in a group of pictures, or 0 for intra_only
1615 * - encoding: Set by user.
1616 * - decoding: unused
1617 */
1618 int gop_size;
1619
1620 /**
1621 * Pixel format, see AV_PIX_FMT_xxx.
1622 * May be set by the demuxer if known from headers.
1623 * May be overridden by the decoder if it knows better.
1624 *
1625 * @note This field may not match the value of the last
1626 * AVFrame output by avcodec_receive_frame() due frame
1627 * reordering.
1628 *
1629 * - encoding: Set by user.
1630 * - decoding: Set by user if known, overridden by libavcodec while
1631 * parsing the data.
1632 */
1633 enum AVPixelFormat pix_fmt;
1634
1635 #if FF_API_MOTION_EST
1636 /**
1637 * This option does nothing
1638 * @deprecated use codec private options instead
1639 */
1640 attribute_deprecated int me_method;
1641 #endif
1642
1643 /**
1644 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1645 * decoder to draw a horizontal band. It improves cache usage. Not
1646 * all codecs can do that. You must check the codec capabilities
1647 * beforehand.
1648 * When multithreading is used, it may be called from multiple threads
1649 * at the same time; threads might draw different parts of the same AVFrame,
1650 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1651 * in order.
1652 * The function is also used by hardware acceleration APIs.
1653 * It is called at least once during frame decoding to pass
1654 * the data needed for hardware render.
1655 * In that mode instead of pixel data, AVFrame points to
1656 * a structure specific to the acceleration API. The application
1657 * reads the structure and can change some fields to indicate progress
1658 * or mark state.
1659 * - encoding: unused
1660 * - decoding: Set by user.
1661 * @param height the height of the slice
1662 * @param y the y position of the slice
1663 * @param type 1->top field, 2->bottom field, 3->frame
1664 * @param offset offset into the AVFrame.data from which the slice should be read
1665 */
1666 void (*draw_horiz_band)(struct AVCodecContext *s,
1667 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1668 int y, int type, int height);
1669
1670 /**
1671 * callback to negotiate the pixelFormat
1672 * @param fmt is the list of formats which are supported by the codec,
1673 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1674 * The first is always the native one.
1675 * @note The callback may be called again immediately if initialization for
1676 * the selected (hardware-accelerated) pixel format failed.
1677 * @warning Behavior is undefined if the callback returns a value not
1678 * in the fmt list of formats.
1679 * @return the chosen format
1680 * - encoding: unused
1681 * - decoding: Set by user, if not set the native format will be chosen.
1682 */
1683 enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1684
1685 /**
1686 * maximum number of B-frames between non-B-frames
1687 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1688 * - encoding: Set by user.
1689 * - decoding: unused
1690 */
1691 int max_b_frames;
1692
1693 /**
1694 * qscale factor between IP and B-frames
1695 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1696 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1697 * - encoding: Set by user.
1698 * - decoding: unused
1699 */
1700 float b_quant_factor;
1701
1702 #if FF_API_RC_STRATEGY
1703 /** @deprecated use codec private option instead */
1704 attribute_deprecated int rc_strategy;
1705 #define FF_RC_STRATEGY_XVID 1
1706 #endif
1707
1708 #if FF_API_PRIVATE_OPT
1709 /** @deprecated use encoder private options instead */
1710 attribute_deprecated
1711 int b_frame_strategy;
1712 #endif
1713
1714 /**
1715 * qscale offset between IP and B-frames
1716 * - encoding: Set by user.
1717 * - decoding: unused
1718 */
1719 float b_quant_offset;
1720
1721 /**
1722 * Size of the frame reordering buffer in the decoder.
1723 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1724 * - encoding: Set by libavcodec.
1725 * - decoding: Set by libavcodec.
1726 */
1727 int has_b_frames;
1728
1729 #if FF_API_PRIVATE_OPT
1730 /** @deprecated use encoder private options instead */
1731 attribute_deprecated
1732 int mpeg_quant;
1733 #endif
1734
1735 /**
1736 * qscale factor between P- and I-frames
1737 * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset).
1738 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1739 * - encoding: Set by user.
1740 * - decoding: unused
1741 */
1742 float i_quant_factor;
1743
1744 /**
1745 * qscale offset between P and I-frames
1746 * - encoding: Set by user.
1747 * - decoding: unused
1748 */
1749 float i_quant_offset;
1750
1751 /**
1752 * luminance masking (0-> disabled)
1753 * - encoding: Set by user.
1754 * - decoding: unused
1755 */
1756 float lumi_masking;
1757
1758 /**
1759 * temporary complexity masking (0-> disabled)
1760 * - encoding: Set by user.
1761 * - decoding: unused
1762 */
1763 float temporal_cplx_masking;
1764
1765 /**
1766 * spatial complexity masking (0-> disabled)
1767 * - encoding: Set by user.
1768 * - decoding: unused
1769 */
1770 float spatial_cplx_masking;
1771
1772 /**
1773 * p block masking (0-> disabled)
1774 * - encoding: Set by user.
1775 * - decoding: unused
1776 */
1777 float p_masking;
1778
1779 /**
1780 * darkness masking (0-> disabled)
1781 * - encoding: Set by user.
1782 * - decoding: unused
1783 */
1784 float dark_masking;
1785
1786 /**
1787 * slice count
1788 * - encoding: Set by libavcodec.
1789 * - decoding: Set by user (or 0).
1790 */
1791 int slice_count;
1792
1793 #if FF_API_PRIVATE_OPT
1794 /** @deprecated use encoder private options instead */
1795 attribute_deprecated
1796 int prediction_method;
1797 #define FF_PRED_LEFT 0
1798 #define FF_PRED_PLANE 1
1799 #define FF_PRED_MEDIAN 2
1800 #endif
1801
1802 /**
1803 * slice offsets in the frame in bytes
1804 * - encoding: Set/allocated by libavcodec.
1805 * - decoding: Set/allocated by user (or NULL).
1806 */
1807 int *slice_offset;
1808
1809 /**
1810 * sample aspect ratio (0 if unknown)
1811 * That is the width of a pixel divided by the height of the pixel.
1812 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1813 * - encoding: Set by user.
1814 * - decoding: Set by libavcodec.
1815 */
1816 AVRational sample_aspect_ratio;
1817
1818 /**
1819 * motion estimation comparison function
1820 * - encoding: Set by user.
1821 * - decoding: unused
1822 */
1823 int me_cmp;
1824 /**
1825 * subpixel motion estimation comparison function
1826 * - encoding: Set by user.
1827 * - decoding: unused
1828 */
1829 int me_sub_cmp;
1830 /**
1831 * macroblock comparison function (not supported yet)
1832 * - encoding: Set by user.
1833 * - decoding: unused
1834 */
1835 int mb_cmp;
1836 /**
1837 * interlaced DCT comparison function
1838 * - encoding: Set by user.
1839 * - decoding: unused
1840 */
1841 int ildct_cmp;
1842 #define FF_CMP_SAD 0
1843 #define FF_CMP_SSE 1
1844 #define FF_CMP_SATD 2
1845 #define FF_CMP_DCT 3
1846 #define FF_CMP_PSNR 4
1847 #define FF_CMP_BIT 5
1848 #define FF_CMP_RD 6
1849 #define FF_CMP_ZERO 7
1850 #define FF_CMP_VSAD 8
1851 #define FF_CMP_VSSE 9
1852 #define FF_CMP_NSSE 10
1853 #define FF_CMP_DCTMAX 13
1854 #define FF_CMP_DCT264 14
1855 #define FF_CMP_CHROMA 256
1856
1857 /**
1858 * ME diamond size & shape
1859 * - encoding: Set by user.
1860 * - decoding: unused
1861 */
1862 int dia_size;
1863
1864 /**
1865 * amount of previous MV predictors (2a+1 x 2a+1 square)
1866 * - encoding: Set by user.
1867 * - decoding: unused
1868 */
1869 int last_predictor_count;
1870
1871 #if FF_API_PRIVATE_OPT
1872 /** @deprecated use encoder private options instead */
1873 attribute_deprecated
1874 int pre_me;
1875 #endif
1876
1877 /**
1878 * motion estimation prepass comparison function
1879 * - encoding: Set by user.
1880 * - decoding: unused
1881 */
1882 int me_pre_cmp;
1883
1884 /**
1885 * ME prepass diamond size & shape
1886 * - encoding: Set by user.
1887 * - decoding: unused
1888 */
1889 int pre_dia_size;
1890
1891 /**
1892 * subpel ME quality
1893 * - encoding: Set by user.
1894 * - decoding: unused
1895 */
1896 int me_subpel_quality;
1897
1898 #if FF_API_AFD
1899 /**
1900 * DTG active format information (additional aspect ratio
1901 * information only used in DVB MPEG-2 transport streams)
1902 * 0 if not set.
1903 *
1904 * - encoding: unused
1905 * - decoding: Set by decoder.
1906 * @deprecated Deprecated in favor of AVSideData
1907 */
1908 attribute_deprecated int dtg_active_format;
1909 #define FF_DTG_AFD_SAME 8
1910 #define FF_DTG_AFD_4_3 9
1911 #define FF_DTG_AFD_16_9 10
1912 #define FF_DTG_AFD_14_9 11
1913 #define FF_DTG_AFD_4_3_SP_14_9 13
1914 #define FF_DTG_AFD_16_9_SP_14_9 14
1915 #define FF_DTG_AFD_SP_4_3 15
1916 #endif /* FF_API_AFD */
1917
1918 /**
1919 * maximum motion estimation search range in subpel units
1920 * If 0 then no limit.
1921 *
1922 * - encoding: Set by user.
1923 * - decoding: unused
1924 */
1925 int me_range;
1926
1927 #if FF_API_QUANT_BIAS
1928 /**
1929 * @deprecated use encoder private option instead
1930 */
1931 attribute_deprecated int intra_quant_bias;
1932 #define FF_DEFAULT_QUANT_BIAS 999999
1933
1934 /**
1935 * @deprecated use encoder private option instead
1936 */
1937 attribute_deprecated int inter_quant_bias;
1938 #endif
1939
1940 /**
1941 * slice flags
1942 * - encoding: unused
1943 * - decoding: Set by user.
1944 */
1945 int slice_flags;
1946 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1947 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics)
1948 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1949
1950 #if FF_API_XVMC
1951 /**
1952 * XVideo Motion Acceleration
1953 * - encoding: forbidden
1954 * - decoding: set by decoder
1955 * @deprecated XvMC support is slated for removal.
1956 */
1957 attribute_deprecated int xvmc_acceleration;
1958 #endif /* FF_API_XVMC */
1959
1960 /**
1961 * macroblock decision mode
1962 * - encoding: Set by user.
1963 * - decoding: unused
1964 */
1965 int mb_decision;
1966 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1967 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1968 #define FF_MB_DECISION_RD 2 ///< rate distortion
1969
1970 /**
1971 * custom intra quantization matrix
1972 * - encoding: Set by user, can be NULL.
1973 * - decoding: Set by libavcodec.
1974 */
1975 uint16_t *intra_matrix;
1976
1977 /**
1978 * custom inter quantization matrix
1979 * - encoding: Set by user, can be NULL.
1980 * - decoding: Set by libavcodec.
1981 */
1982 uint16_t *inter_matrix;
1983
1984 #if FF_API_PRIVATE_OPT
1985 /** @deprecated use encoder private options instead */
1986 attribute_deprecated
1987 int scenechange_threshold;
1988
1989 /** @deprecated use encoder private options instead */
1990 attribute_deprecated
1991 int noise_reduction;
1992 #endif
1993
1994 #if FF_API_MPV_OPT
1995 /**
1996 * @deprecated this field is unused
1997 */
1998 attribute_deprecated
1999 int me_threshold;
2000
2001 /**
2002 * @deprecated this field is unused
2003 */
2004 attribute_deprecated
2005 int mb_threshold;
2006 #endif
2007
2008 /**
2009 * precision of the intra DC coefficient - 8
2010 * - encoding: Set by user.
2011 * - decoding: unused
2012 */
2013 int intra_dc_precision;
2014
2015 /**
2016 * Number of macroblock rows at the top which are skipped.
2017 * - encoding: unused
2018 * - decoding: Set by user.
2019 */
2020 int skip_top;
2021
2022 /**
2023 * Number of macroblock rows at the bottom which are skipped.
2024 * - encoding: unused
2025 * - decoding: Set by user.
2026 */
2027 int skip_bottom;
2028
2029 #if FF_API_MPV_OPT
2030 /**
2031 * @deprecated use encoder private options instead
2032 */
2033 attribute_deprecated
2034 float border_masking;
2035 #endif
2036
2037 /**
2038 * minimum MB Lagrange multiplier
2039 * - encoding: Set by user.
2040 * - decoding: unused
2041 */
2042 int mb_lmin;
2043
2044 /**
2045 * maximum MB Lagrange multiplier
2046 * - encoding: Set by user.
2047 * - decoding: unused
2048 */
2049 int mb_lmax;
2050
2051 #if FF_API_PRIVATE_OPT
2052 /**
2053 * @deprecated use encoder private options instead
2054 */
2055 attribute_deprecated
2056 int me_penalty_compensation;
2057 #endif
2058
2059 /**
2060 * - encoding: Set by user.
2061 * - decoding: unused
2062 */
2063 int bidir_refine;
2064
2065 #if FF_API_PRIVATE_OPT
2066 /** @deprecated use encoder private options instead */
2067 attribute_deprecated
2068 int brd_scale;
2069 #endif
2070
2071 /**
2072 * minimum GOP size
2073 * - encoding: Set by user.
2074 * - decoding: unused
2075 */
2076 int keyint_min;
2077
2078 /**
2079 * number of reference frames
2080 * - encoding: Set by user.
2081 * - decoding: Set by lavc.
2082 */
2083 int refs;
2084
2085 #if FF_API_PRIVATE_OPT
2086 /** @deprecated use encoder private options instead */
2087 attribute_deprecated
2088 int chromaoffset;
2089 #endif
2090
2091 #if FF_API_UNUSED_MEMBERS
2092 /**
2093 * Multiplied by qscale for each frame and added to scene_change_score.
2094 * - encoding: Set by user.
2095 * - decoding: unused
2096 */
2097 attribute_deprecated int scenechange_factor;
2098 #endif
2099
2100 /**
2101 * Note: Value depends upon the compare function used for fullpel ME.
2102 * - encoding: Set by user.
2103 * - decoding: unused
2104 */
2105 int mv0_threshold;
2106
2107 #if FF_API_PRIVATE_OPT
2108 /** @deprecated use encoder private options instead */
2109 attribute_deprecated
2110 int b_sensitivity;
2111 #endif
2112
2113 /**
2114 * Chromaticity coordinates of the source primaries.
2115 * - encoding: Set by user
2116 * - decoding: Set by libavcodec
2117 */
2118 enum AVColorPrimaries color_primaries;
2119
2120 /**
2121 * Color Transfer Characteristic.
2122 * - encoding: Set by user
2123 * - decoding: Set by libavcodec
2124 */
2125 enum AVColorTransferCharacteristic color_trc;
2126
2127 /**
2128 * YUV colorspace type.
2129 * - encoding: Set by user
2130 * - decoding: Set by libavcodec
2131 */
2132 enum AVColorSpace colorspace;
2133
2134 /**
2135 * MPEG vs JPEG YUV range.
2136 * - encoding: Set by user
2137 * - decoding: Set by libavcodec
2138 */
2139 enum AVColorRange color_range;
2140
2141 /**
2142 * This defines the location of chroma samples.
2143 * - encoding: Set by user
2144 * - decoding: Set by libavcodec
2145 */
2146 enum AVChromaLocation chroma_sample_location;
2147
2148 /**
2149 * Number of slices.
2150 * Indicates number of picture subdivisions. Used for parallelized
2151 * decoding.
2152 * - encoding: Set by user
2153 * - decoding: unused
2154 */
2155 int slices;
2156
2157 /** Field order
2158 * - encoding: set by libavcodec
2159 * - decoding: Set by libavcodec
2160 */
2161 enum AVFieldOrder field_order;
2162
2163 /* audio only */
2164 int sample_rate; ///< samples per second
2165 int channels; ///< number of audio channels
2166
2167 /**
2168 * audio sample format
2169 * - encoding: Set by user.
2170 * - decoding: Set by libavcodec.
2171 */
2172 enum AVSampleFormat sample_fmt; ///< sample format
2173
2174 /* The following data should not be initialized. */
2175 /**
2176 * Number of samples per channel in an audio frame.
2177 *
2178 * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
2179 * except the last must contain exactly frame_size samples per channel.
2180 * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
2181 * frame size is not restricted.
2182 * - decoding: may be set by some decoders to indicate constant frame size
2183 */
2184 int frame_size;
2185
2186 /**
2187 * Frame counter, set by libavcodec.
2188 *
2189 * - decoding: total number of frames returned from the decoder so far.
2190 * - encoding: total number of frames passed to the encoder so far.
2191 *
2192 * @note the counter is not incremented if encoding/decoding resulted in
2193 * an error.
2194 */
2195 int frame_number;
2196
2197 /**
2198 * number of bytes per packet if constant and known or 0
2199 * Used by some WAV based audio codecs.
2200 */
2201 int block_align;
2202
2203 /**
2204 * Audio cutoff bandwidth (0 means "automatic")
2205 * - encoding: Set by user.
2206 * - decoding: unused
2207 */
2208 int cutoff;
2209
2210 /**
2211 * Audio channel layout.
2212 * - encoding: set by user.
2213 * - decoding: set by libavcodec.
2214 */
2215 uint64_t channel_layout;
2216
2217 /**
2218 * Request decoder to use this channel layout if it can (0 for default)
2219 * - encoding: unused
2220 * - decoding: Set by user.
2221 */
2222 uint64_t request_channel_layout;
2223
2224 /**
2225 * Type of service that the audio stream conveys.
2226 * - encoding: Set by user.
2227 * - decoding: Set by libavcodec.
2228 */
2229 enum AVAudioServiceType audio_service_type;
2230
2231 /**
2232 * Used to request a sample format from the decoder.
2233 * - encoding: unused.
2234 * - decoding: Set by user.
2235 */
2236 enum AVSampleFormat request_sample_fmt;
2237
2238 /**
2239 * This callback is called at the beginning of each frame to get data
2240 * buffer(s) for it. There may be one contiguous buffer for all the data or
2241 * there may be a buffer per each data plane or anything in between. What
2242 * this means is, you may set however many entries in buf[] you feel necessary.
2243 * Each buffer must be reference-counted using the AVBuffer API (see description
2244 * of buf[] below).
2245 *
2246 * The following fields will be set in the frame before this callback is
2247 * called:
2248 * - format
2249 * - width, height (video only)
2250 * - sample_rate, channel_layout, nb_samples (audio only)
2251 * Their values may differ from the corresponding values in
2252 * AVCodecContext. This callback must use the frame values, not the codec
2253 * context values, to calculate the required buffer size.
2254 *
2255 * This callback must fill the following fields in the frame:
2256 * - data[]
2257 * - linesize[]
2258 * - extended_data:
2259 * * if the data is planar audio with more than 8 channels, then this
2260 * callback must allocate and fill extended_data to contain all pointers
2261 * to all data planes. data[] must hold as many pointers as it can.
2262 * extended_data must be allocated with av_malloc() and will be freed in
2263 * av_frame_unref().
2264 * * otherwise extended_data must point to data
2265 * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
2266 * the frame's data and extended_data pointers must be contained in these. That
2267 * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
2268 * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
2269 * and av_buffer_ref().
2270 * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
2271 * this callback and filled with the extra buffers if there are more
2272 * buffers than buf[] can hold. extended_buf will be freed in
2273 * av_frame_unref().
2274 *
2275 * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call
2276 * avcodec_default_get_buffer2() instead of providing buffers allocated by
2277 * some other means.
2278 *
2279 * Each data plane must be aligned to the maximum required by the target
2280 * CPU.
2281 *
2282 * @see avcodec_default_get_buffer2()
2283 *
2284 * Video:
2285 *
2286 * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
2287 * (read and/or written to if it is writable) later by libavcodec.
2288 *
2289 * avcodec_align_dimensions2() should be used to find the required width and
2290 * height, as they normally need to be rounded up to the next multiple of 16.
2291 *
2292 * If frame multithreading is used and thread_safe_callbacks is set,
2293 * this callback may be called from a different thread, but not from more
2294 * than one at once. Does not need to be reentrant.
2295 *
2296 * @see avcodec_align_dimensions2()
2297 *
2298 * Audio:
2299 *
2300 * Decoders request a buffer of a particular size by setting
2301 * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
2302 * however, utilize only part of the buffer by setting AVFrame.nb_samples
2303 * to a smaller value in the output frame.
2304 *
2305 * As a convenience, av_samples_get_buffer_size() and
2306 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
2307 * functions to find the required data size and to fill data pointers and
2308 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
2309 * since all planes must be the same size.
2310 *
2311 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
2312 *
2313 * - encoding: unused
2314 * - decoding: Set by libavcodec, user can override.
2315 */
2316 int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
2317
2318 /**
2319 * If non-zero, the decoded audio and video frames returned from
2320 * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
2321 * and are valid indefinitely. The caller must free them with
2322 * av_frame_unref() when they are not needed anymore.
2323 * Otherwise, the decoded frames must not be freed by the caller and are
2324 * only valid until the next decode call.
2325 *
2326 * This is always automatically enabled if avcodec_receive_frame() is used.
2327 *
2328 * - encoding: unused
2329 * - decoding: set by the caller before avcodec_open2().
2330 */
2331 attribute_deprecated int refcounted_frames;
2332
2333 /* - encoding parameters */
2334 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
2335 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
2336
2337 /**
2338 * minimum quantizer
2339 * - encoding: Set by user.
2340 * - decoding: unused
2341 */
2342 int qmin;
2343
2344 /**
2345 * maximum quantizer
2346 * - encoding: Set by user.
2347 * - decoding: unused
2348 */
2349 int qmax;
2350
2351 /**
2352 * maximum quantizer difference between frames
2353 * - encoding: Set by user.
2354 * - decoding: unused
2355 */
2356 int max_qdiff;
2357
2358 #if FF_API_MPV_OPT
2359 /**
2360 * @deprecated use encoder private options instead
2361 */
2362 attribute_deprecated
2363 float rc_qsquish;
2364
2365 attribute_deprecated
2366 float rc_qmod_amp;
2367 attribute_deprecated
2368 int rc_qmod_freq;
2369 #endif
2370
2371 /**
2372 * decoder bitstream buffer size
2373 * - encoding: Set by user.
2374 * - decoding: unused
2375 */
2376 int rc_buffer_size;
2377
2378 /**
2379 * ratecontrol override, see RcOverride
2380 * - encoding: Allocated/set/freed by user.
2381 * - decoding: unused
2382 */
2383 int rc_override_count;
2384 RcOverride *rc_override;
2385
2386 #if FF_API_MPV_OPT
2387 /**
2388 * @deprecated use encoder private options instead
2389 */
2390 attribute_deprecated
2391 const char *rc_eq;
2392 #endif
2393
2394 /**
2395 * maximum bitrate
2396 * - encoding: Set by user.
2397 * - decoding: unused
2398 */
2399 int rc_max_rate;
2400
2401 /**
2402 * minimum bitrate
2403 * - encoding: Set by user.
2404 * - decoding: unused
2405 */
2406 int rc_min_rate;
2407
2408 #if FF_API_MPV_OPT
2409 /**
2410 * @deprecated use encoder private options instead
2411 */
2412 attribute_deprecated
2413 float rc_buffer_aggressivity;
2414
2415 attribute_deprecated
2416 float rc_initial_cplx;
2417 #endif
2418
2419 /**
2420 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2421 * - encoding: Set by user.
2422 * - decoding: unused.
2423 */
2424 float rc_max_available_vbv_use;
2425
2426 /**
2427 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2428 * - encoding: Set by user.
2429 * - decoding: unused.
2430 */
2431 float rc_min_vbv_overflow_use;
2432
2433 /**
2434 * Number of bits which should be loaded into the rc buffer before decoding starts.
2435 * - encoding: Set by user.
2436 * - decoding: unused
2437 */
2438 int rc_initial_buffer_occupancy;
2439
2440 #if FF_API_CODER_TYPE
2441 #define FF_CODER_TYPE_VLC 0
2442 #define FF_CODER_TYPE_AC 1
2443 #define FF_CODER_TYPE_RAW 2
2444 #define FF_CODER_TYPE_RLE 3
2445 #if FF_API_UNUSED_MEMBERS
2446 #define FF_CODER_TYPE_DEFLATE 4
2447 #endif /* FF_API_UNUSED_MEMBERS */
2448 /**
2449 * @deprecated use encoder private options instead
2450 */
2451 attribute_deprecated
2452 int coder_type;
2453 #endif /* FF_API_CODER_TYPE */
2454
2455 #if FF_API_PRIVATE_OPT
2456 /** @deprecated use encoder private options instead */
2457 attribute_deprecated
2458 int context_model;
2459 #endif
2460
2461 #if FF_API_MPV_OPT
2462 /**
2463 * @deprecated use encoder private options instead
2464 */
2465 attribute_deprecated
2466 int lmin;
2467
2468 /**
2469 * @deprecated use encoder private options instead
2470 */
2471 attribute_deprecated
2472 int lmax;
2473 #endif
2474
2475 #if FF_API_PRIVATE_OPT
2476 /** @deprecated use encoder private options instead */
2477 attribute_deprecated
2478 int frame_skip_threshold;
2479
2480 /** @deprecated use encoder private options instead */
2481 attribute_deprecated
2482 int frame_skip_factor;
2483
2484 /** @deprecated use encoder private options instead */
2485 attribute_deprecated
2486 int frame_skip_exp;
2487
2488 /** @deprecated use encoder private options instead */
2489 attribute_deprecated
2490 int frame_skip_cmp;
2491 #endif /* FF_API_PRIVATE_OPT */
2492
2493 /**
2494 * trellis RD quantization
2495 * - encoding: Set by user.
2496 * - decoding: unused
2497 */
2498 int trellis;
2499
2500 #if FF_API_PRIVATE_OPT
2501 /** @deprecated use encoder private options instead */
2502 attribute_deprecated
2503 int min_prediction_order;
2504
2505 /** @deprecated use encoder private options instead */
2506 attribute_deprecated
2507 int max_prediction_order;
2508
2509 /** @deprecated use encoder private options instead */
2510 attribute_deprecated
2511 int64_t timecode_frame_start;
2512 #endif
2513
2514 #if FF_API_RTP_CALLBACK
2515 /**
2516 * @deprecated unused
2517 */
2518 /* The RTP callback: This function is called */
2519 /* every time the encoder has a packet to send. */
2520 /* It depends on the encoder if the data starts */
2521 /* with a Start Code (it should). H.263 does. */
2522 /* mb_nb contains the number of macroblocks */
2523 /* encoded in the RTP payload. */
2524 attribute_deprecated
2525 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2526 #endif
2527
2528 #if FF_API_PRIVATE_OPT
2529 /** @deprecated use encoder private options instead */
2530 attribute_deprecated
2531 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2532 /* do its best to deliver a chunk with size */
2533 /* below rtp_payload_size, the chunk will start */
2534 /* with a start code on some codecs like H.263. */
2535 /* This doesn't take account of any particular */
2536 /* headers inside the transmitted RTP payload. */
2537 #endif
2538
2539 #if FF_API_STAT_BITS
2540 /* statistics, used for 2-pass encoding */
2541 attribute_deprecated
2542 int mv_bits;
2543 attribute_deprecated
2544 int header_bits;
2545 attribute_deprecated
2546 int i_tex_bits;
2547 attribute_deprecated
2548 int p_tex_bits;
2549 attribute_deprecated
2550 int i_count;
2551 attribute_deprecated
2552 int p_count;
2553 attribute_deprecated
2554 int skip_count;
2555 attribute_deprecated
2556 int misc_bits;
2557
2558 /** @deprecated this field is unused */
2559 attribute_deprecated
2560 int frame_bits;
2561 #endif
2562
2563 /**
2564 * pass1 encoding statistics output buffer
2565 * - encoding: Set by libavcodec.
2566 * - decoding: unused
2567 */
2568 char *stats_out;
2569
2570 /**
2571 * pass2 encoding statistics input buffer
2572 * Concatenated stuff from stats_out of pass1 should be placed here.
2573 * - encoding: Allocated/set/freed by user.
2574 * - decoding: unused
2575 */
2576 char *stats_in;
2577
2578 /**
2579 * Work around bugs in encoders which sometimes cannot be detected automatically.
2580 * - encoding: Set by user
2581 * - decoding: Set by user
2582 */
2583 int workaround_bugs;
2584 #define FF_BUG_AUTODETECT 1 ///< autodetection
2585 #if FF_API_OLD_MSMPEG4
2586 #define FF_BUG_OLD_MSMPEG4 2
2587 #endif
2588 #define FF_BUG_XVID_ILACE 4
2589 #define FF_BUG_UMP4 8
2590 #define FF_BUG_NO_PADDING 16
2591 #define FF_BUG_AMV 32
2592 #if FF_API_AC_VLC
2593 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2594 #endif
2595 #define FF_BUG_QPEL_CHROMA 64
2596 #define FF_BUG_STD_QPEL 128
2597 #define FF_BUG_QPEL_CHROMA2 256
2598 #define FF_BUG_DIRECT_BLOCKSIZE 512
2599 #define FF_BUG_EDGE 1024
2600 #define FF_BUG_HPEL_CHROMA 2048
2601 #define FF_BUG_DC_CLIP 4096
2602 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2603 #define FF_BUG_TRUNCATED 16384
2604
2605 /**
2606 * strictly follow the standard (MPEG-4, ...).
2607 * - encoding: Set by user.
2608 * - decoding: Set by user.
2609 * Setting this to STRICT or higher means the encoder and decoder will
2610 * generally do stupid things, whereas setting it to unofficial or lower
2611 * will mean the encoder might produce output that is not supported by all
2612 * spec-compliant decoders. Decoders don't differentiate between normal,
2613 * unofficial and experimental (that is, they always try to decode things
2614 * when they can) unless they are explicitly asked to behave stupidly
2615 * (=strictly conform to the specs)
2616 */
2617 int strict_std_compliance;
2618 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2619 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2620 #define FF_COMPLIANCE_NORMAL 0
2621 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2622 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2623
2624 /**
2625 * error concealment flags
2626 * - encoding: unused
2627 * - decoding: Set by user.
2628 */
2629 int error_concealment;
2630 #define FF_EC_GUESS_MVS 1
2631 #define FF_EC_DEBLOCK 2
2632
2633 /**
2634 * debug
2635 * - encoding: Set by user.
2636 * - decoding: Set by user.
2637 */
2638 int debug;
2639 #define FF_DEBUG_PICT_INFO 1
2640 #define FF_DEBUG_RC 2
2641 #define FF_DEBUG_BITSTREAM 4
2642 #define FF_DEBUG_MB_TYPE 8
2643 #define FF_DEBUG_QP 16
2644 #if FF_API_DEBUG_MV
2645 /**
2646 * @deprecated this option does nothing
2647 */
2648 #define FF_DEBUG_MV 32
2649 #endif
2650 #define FF_DEBUG_DCT_COEFF 0x00000040
2651 #define FF_DEBUG_SKIP 0x00000080
2652 #define FF_DEBUG_STARTCODE 0x00000100
2653 #if FF_API_UNUSED_MEMBERS
2654 #define FF_DEBUG_PTS 0x00000200
2655 #endif /* FF_API_UNUSED_MEMBERS */
2656 #define FF_DEBUG_ER 0x00000400
2657 #define FF_DEBUG_MMCO 0x00000800
2658 #define FF_DEBUG_BUGS 0x00001000
2659 #if FF_API_DEBUG_MV
2660 #define FF_DEBUG_VIS_QP 0x00002000
2661 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2662 #endif
2663 #define FF_DEBUG_BUFFERS 0x00008000
2664 #define FF_DEBUG_THREADS 0x00010000
2665
2666 #if FF_API_DEBUG_MV
2667 /**
2668 * @deprecated this option does not have any effect
2669 */
2670 attribute_deprecated
2671 int debug_mv;
2672 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames
2673 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames
2674 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames
2675 #endif
2676
2677 /**
2678 * Error recognition; may misdetect some more or less valid parts as errors.
2679 * - encoding: unused
2680 * - decoding: Set by user.
2681 */
2682 int err_recognition;
2683
2684 /**
2685 * Verify checksums embedded in the bitstream (could be of either encoded or
2686 * decoded data, depending on the codec) and print an error message on mismatch.
2687 * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the
2688 * decoder returning an error.
2689 */
2690 #define AV_EF_CRCCHECK (1<<0)
2691 #define AV_EF_BITSTREAM (1<<1)
2692 #define AV_EF_BUFFER (1<<2)
2693 #define AV_EF_EXPLODE (1<<3)
2694
2695 /**
2696 * opaque 64-bit number (generally a PTS) that will be reordered and
2697 * output in AVFrame.reordered_opaque
2698 * - encoding: unused
2699 * - decoding: Set by user.
2700 */
2701 int64_t reordered_opaque;
2702
2703 /**
2704 * Hardware accelerator in use
2705 * - encoding: unused.
2706 * - decoding: Set by libavcodec
2707 */
2708 struct AVHWAccel *hwaccel;
2709
2710 /**
2711 * Hardware accelerator context.
2712 * For some hardware accelerators, a global context needs to be
2713 * provided by the user. In that case, this holds display-dependent
2714 * data Libav cannot instantiate itself. Please refer to the
2715 * Libav HW accelerator documentation to know how to fill this
2716 * is. e.g. for VA API, this is a struct vaapi_context.
2717 * - encoding: unused
2718 * - decoding: Set by user
2719 */
2720 void *hwaccel_context;
2721
2722 /**
2723 * error
2724 * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR.
2725 * - decoding: unused
2726 */
2727 uint64_t error[AV_NUM_DATA_POINTERS];
2728
2729 /**
2730 * DCT algorithm, see FF_DCT_* below
2731 * - encoding: Set by user.
2732 * - decoding: unused
2733 */
2734 int dct_algo;
2735 #define FF_DCT_AUTO 0
2736 #define FF_DCT_FASTINT 1
2737 #define FF_DCT_INT 2
2738 #define FF_DCT_MMX 3
2739 #define FF_DCT_ALTIVEC 5
2740 #define FF_DCT_FAAN 6
2741
2742 /**
2743 * IDCT algorithm, see FF_IDCT_* below.
2744 * - encoding: Set by user.
2745 * - decoding: Set by user.
2746 */
2747 int idct_algo;
2748 #define FF_IDCT_AUTO 0
2749 #define FF_IDCT_INT 1
2750 #define FF_IDCT_SIMPLE 2
2751 #define FF_IDCT_SIMPLEMMX 3
2752 #define FF_IDCT_ARM 7
2753 #define FF_IDCT_ALTIVEC 8
2754 #if FF_API_ARCH_SH4
2755 #define FF_IDCT_SH4 9
2756 #endif
2757 #define FF_IDCT_SIMPLEARM 10
2758 #if FF_API_UNUSED_MEMBERS
2759 #define FF_IDCT_IPP 13
2760 #endif /* FF_API_UNUSED_MEMBERS */
2761 #define FF_IDCT_XVID 14
2762 #if FF_API_IDCT_XVIDMMX
2763 #define FF_IDCT_XVIDMMX 14
2764 #endif /* FF_API_IDCT_XVIDMMX */
2765 #define FF_IDCT_SIMPLEARMV5TE 16
2766 #define FF_IDCT_SIMPLEARMV6 17
2767 #if FF_API_ARCH_SPARC
2768 #define FF_IDCT_SIMPLEVIS 18
2769 #endif
2770 #define FF_IDCT_FAAN 20
2771 #define FF_IDCT_SIMPLENEON 22
2772 #if FF_API_ARCH_ALPHA
2773 #define FF_IDCT_SIMPLEALPHA 23
2774 #endif
2775
2776 /**
2777 * bits per sample/pixel from the demuxer (needed for huffyuv).
2778 * - encoding: Set by libavcodec.
2779 * - decoding: Set by user.
2780 */
2781 int bits_per_coded_sample;
2782
2783 /**
2784 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2785 * - encoding: set by user.
2786 * - decoding: set by libavcodec.
2787 */
2788 int bits_per_raw_sample;
2789
2790 #if FF_API_LOWRES
2791 /**
2792 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2793 * - encoding: unused
2794 * - decoding: Set by user.
2795 *
2796 * @deprecated use decoder private options instead
2797 */
2798 attribute_deprecated int lowres;
2799 #endif
2800
2801 #if FF_API_CODED_FRAME
2802 /**
2803 * the picture in the bitstream
2804 * - encoding: Set by libavcodec.
2805 * - decoding: unused
2806 *
2807 * @deprecated use the quality factor packet side data instead
2808 */
2809 attribute_deprecated AVFrame *coded_frame;
2810 #endif
2811
2812 /**
2813 * thread count
2814 * is used to decide how many independent tasks should be passed to execute()
2815 * - encoding: Set by user.
2816 * - decoding: Set by user.
2817 */
2818 int thread_count;
2819
2820 /**
2821 * Which multithreading methods to use.
2822 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2823 * so clients which cannot provide future frames should not use it.
2824 *
2825 * - encoding: Set by user, otherwise the default is used.
2826 * - decoding: Set by user, otherwise the default is used.
2827 */
2828 int thread_type;
2829 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2830 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2831
2832 /**
2833 * Which multithreading methods are in use by the codec.
2834 * - encoding: Set by libavcodec.
2835 * - decoding: Set by libavcodec.
2836 */
2837 int active_thread_type;
2838
2839 /**
2840 * Set by the client if its custom get_buffer() callback can be called
2841 * synchronously from another thread, which allows faster multithreaded decoding.
2842 * draw_horiz_band() will be called from other threads regardless of this setting.
2843 * Ignored if the default get_buffer() is used.
2844 * - encoding: Set by user.
2845 * - decoding: Set by user.
2846 */
2847 int thread_safe_callbacks;
2848
2849 /**
2850 * The codec may call this to execute several independent things.
2851 * It will return only after finishing all tasks.
2852 * The user may replace this with some multithreaded implementation,
2853 * the default implementation will execute the parts serially.
2854 * @param count the number of things to execute
2855 * - encoding: Set by libavcodec, user can override.
2856 * - decoding: Set by libavcodec, user can override.
2857 */
2858 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2859
2860 /**
2861 * The codec may call this to execute several independent things.
2862 * It will return only after finishing all tasks.
2863 * The user may replace this with some multithreaded implementation,
2864 * the default implementation will execute the parts serially.
2865 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2866 * @param c context passed also to func
2867 * @param count the number of things to execute
2868 * @param arg2 argument passed unchanged to func
2869 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2870 * @param func function that will be called count times, with jobnr from 0 to count-1.
2871 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2872 * two instances of func executing at the same time will have the same threadnr.
2873 * @return always 0 currently, but code should handle a future improvement where when any call to func
2874 * returns < 0 no further calls to func may be done and < 0 is returned.
2875 * - encoding: Set by libavcodec, user can override.
2876 * - decoding: Set by libavcodec, user can override.
2877 */
2878 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2879
2880 /**
2881 * noise vs. sse weight for the nsse comparison function
2882 * - encoding: Set by user.
2883 * - decoding: unused
2884 */
2885 int nsse_weight;
2886
2887 /**
2888 * profile
2889 * - encoding: Set by user.
2890 * - decoding: Set by libavcodec.
2891 */
2892 int profile;
2893 #define FF_PROFILE_UNKNOWN -99
2894 #define FF_PROFILE_RESERVED -100
2895
2896 #define FF_PROFILE_AAC_MAIN 0
2897 #define FF_PROFILE_AAC_LOW 1
2898 #define FF_PROFILE_AAC_SSR 2
2899 #define FF_PROFILE_AAC_LTP 3
2900 #define FF_PROFILE_AAC_HE 4
2901 #define FF_PROFILE_AAC_HE_V2 28
2902 #define FF_PROFILE_AAC_LD 22
2903 #define FF_PROFILE_AAC_ELD 38
2904 #define FF_PROFILE_MPEG2_AAC_LOW 128
2905 #define FF_PROFILE_MPEG2_AAC_HE 131
2906
2907 #define FF_PROFILE_DTS 20
2908 #define FF_PROFILE_DTS_ES 30
2909 #define FF_PROFILE_DTS_96_24 40
2910 #define FF_PROFILE_DTS_HD_HRA 50
2911 #define FF_PROFILE_DTS_HD_MA 60
2912 #define FF_PROFILE_DTS_EXPRESS 70
2913
2914 #define FF_PROFILE_MPEG2_422 0
2915 #define FF_PROFILE_MPEG2_HIGH 1
2916 #define FF_PROFILE_MPEG2_SS 2
2917 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2918 #define FF_PROFILE_MPEG2_MAIN 4
2919 #define FF_PROFILE_MPEG2_SIMPLE 5
2920
2921 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2922 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2923
2924 #define FF_PROFILE_H264_BASELINE 66
2925 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2926 #define FF_PROFILE_H264_MAIN 77
2927 #define FF_PROFILE_H264_EXTENDED 88
2928 #define FF_PROFILE_H264_HIGH 100
2929 #define FF_PROFILE_H264_HIGH_10 110
2930 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2931 #define FF_PROFILE_H264_MULTIVIEW_HIGH 118
2932 #define FF_PROFILE_H264_HIGH_422 122
2933 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2934 #define FF_PROFILE_H264_STEREO_HIGH 128
2935 #define FF_PROFILE_H264_HIGH_444 144
2936 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2937 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2938 #define FF_PROFILE_H264_CAVLC_444 44
2939
2940 #define FF_PROFILE_VC1_SIMPLE 0
2941 #define FF_PROFILE_VC1_MAIN 1
2942 #define FF_PROFILE_VC1_COMPLEX 2
2943 #define FF_PROFILE_VC1_ADVANCED 3
2944
2945 #define FF_PROFILE_MPEG4_SIMPLE 0
2946 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2947 #define FF_PROFILE_MPEG4_CORE 2
2948 #define FF_PROFILE_MPEG4_MAIN 3
2949 #define FF_PROFILE_MPEG4_N_BIT 4
2950 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2951 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2952 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2953 #define FF_PROFILE_MPEG4_HYBRID 8
2954 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2955 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2956 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2957 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2958 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2959 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2960 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2961
2962 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1
2963 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2
2964 #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768
2965 #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
2966 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
2967
2968 #define FF_PROFILE_VP9_0 0
2969 #define FF_PROFILE_VP9_1 1
2970 #define FF_PROFILE_VP9_2 2
2971 #define FF_PROFILE_VP9_3 3
2972
2973 #define FF_PROFILE_HEVC_MAIN 1
2974 #define FF_PROFILE_HEVC_MAIN_10 2
2975 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3
2976 #define FF_PROFILE_HEVC_REXT 4
2977
2978 /**
2979 * level
2980 * - encoding: Set by user.
2981 * - decoding: Set by libavcodec.
2982 */
2983 int level;
2984 #define FF_LEVEL_UNKNOWN -99
2985
2986 /**
2987 * - encoding: unused
2988 * - decoding: Set by user.
2989 */
2990 enum AVDiscard skip_loop_filter;
2991
2992 /**
2993 * - encoding: unused
2994 * - decoding: Set by user.
2995 */
2996 enum AVDiscard skip_idct;
2997
2998 /**
2999 * - encoding: unused
3000 * - decoding: Set by user.
3001 */
3002 enum AVDiscard skip_frame;
3003
3004 /**
3005 * Header containing style information for text subtitles.
3006 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
3007 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
3008 * the Format line following. It shouldn't include any Dialogue line.
3009 * - encoding: Set/allocated/freed by user (before avcodec_open2())
3010 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
3011 */
3012 uint8_t *subtitle_header;
3013 int subtitle_header_size;
3014
3015 #if FF_API_ERROR_RATE
3016 /**
3017 * @deprecated use the 'error_rate' private AVOption of the mpegvideo
3018 * encoders
3019 */
3020 attribute_deprecated
3021 int error_rate;
3022 #endif
3023
3024 #if FF_API_VBV_DELAY
3025 /**
3026 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
3027 * Used for compliant TS muxing.
3028 * - encoding: Set by libavcodec.
3029 * - decoding: unused.
3030 * @deprecated this value is now exported as a part of
3031 * AV_PKT_DATA_CPB_PROPERTIES packet side data
3032 */
3033 attribute_deprecated
3034 uint64_t vbv_delay;
3035 #endif
3036
3037 #if FF_API_SIDEDATA_ONLY_PKT
3038 /**
3039 * Encoding only and set by default. Allow encoders to output packets
3040 * that do not contain any encoded data, only side data.
3041 *
3042 * Some encoders need to output such packets, e.g. to update some stream
3043 * parameters at the end of encoding.
3044 *
3045 * @deprecated this field disables the default behaviour and
3046 * it is kept only for compatibility.
3047 */
3048 attribute_deprecated
3049 int side_data_only_packets;
3050 #endif
3051
3052 /**
3053 * Audio only. The number of "priming" samples (padding) inserted by the
3054 * encoder at the beginning of the audio. I.e. this number of leading
3055 * decoded samples must be discarded by the caller to get the original audio
3056 * without leading padding.
3057 *
3058 * - decoding: unused
3059 * - encoding: Set by libavcodec. The timestamps on the output packets are
3060 * adjusted by the encoder so that they always refer to the
3061 * first sample of the data actually contained in the packet,
3062 * including any added padding. E.g. if the timebase is
3063 * 1/samplerate and the timestamp of the first input sample is
3064 * 0, the timestamp of the first output packet will be
3065 * -initial_padding.
3066 */
3067 int initial_padding;
3068
3069 /*
3070 * - decoding: For codecs that store a framerate value in the compressed
3071 * bitstream, the decoder may export it here. { 0, 1} when
3072 * unknown.
3073 * - encoding: May be used to signal the framerate of CFR content to an
3074 * encoder.
3075 */
3076 AVRational framerate;
3077
3078 /**
3079 * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
3080 * - encoding: unused.
3081 * - decoding: Set by libavcodec before calling get_format()
3082 */
3083 enum AVPixelFormat sw_pix_fmt;
3084
3085 /**
3086 * Additional data associated with the entire coded stream.
3087 *
3088 * - decoding: unused
3089 * - encoding: may be set by libavcodec after avcodec_open2().
3090 */
3091 AVPacketSideData *coded_side_data;
3092 int nb_coded_side_data;
3093
3094 /**
3095 * A reference to the AVHWFramesContext describing the input (for encoding)
3096 * or output (decoding) frames. The reference is set by the caller and
3097 * afterwards owned (and freed) by libavcodec - it should never be read by
3098 * the caller after being set.
3099 *
3100 * - decoding: This field should be set by the caller from the get_format()
3101 * callback. The previous reference (if any) will always be
3102 * unreffed by libavcodec before the get_format() call.
3103 *
3104 * If the default get_buffer2() is used with a hwaccel pixel
3105 * format, then this AVHWFramesContext will be used for
3106 * allocating the frame buffers.
3107 *
3108 * - encoding: For hardware encoders configured to use a hwaccel pixel
3109 * format, this field should be set by the caller to a reference
3110 * to the AVHWFramesContext describing input frames.
3111 * AVHWFramesContext.format must be equal to
3112 * AVCodecContext.pix_fmt.
3113 *
3114 * This field should be set before avcodec_open2() is called.
3115 */
3116 AVBufferRef *hw_frames_ctx;
3117
3118 /**
3119 * Video decoding only. Certain video codecs support cropping, meaning that
3120 * only a sub-rectangle of the decoded frame is intended for display. This
3121 * option controls how cropping is handled by libavcodec.
3122 *
3123 * When set to 1 (the default), libavcodec will apply cropping internally.
3124 * I.e. it will modify the output frame width/height fields and offset the
3125 * data pointers (only by as much as possible while preserving alignment, or
3126 * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that
3127 * the frames output by the decoder refer only to the cropped area. The
3128 * crop_* fields of the output frames will be zero.
3129 *
3130 * When set to 0, the width/height fields of the output frames will be set
3131 * to the coded dimensions and the crop_* fields will describe the cropping
3132 * rectangle. Applying the cropping is left to the caller.
3133 *
3134 * @warning When hardware acceleration with opaque output frames is used,
3135 * libavcodec is unable to apply cropping from the top/left border.
3136 *
3137 * @note when this option is set to zero, the width/height fields of the
3138 * AVCodecContext and output AVFrames have different meanings. The codec
3139 * context fields store display dimensions (with the coded dimensions in
3140 * coded_width/height), while the frame fields store the coded dimensions
3141 * (with the display dimensions being determined by the crop_* fields).
3142 */
3143 int apply_cropping;
3144
3145 /**
3146 * A reference to the AVHWDeviceContext describing the device which will
3147 * be used by a hardware encoder/decoder. The reference is set by the
3148 * caller and afterwards owned (and freed) by libavcodec.
3149 *
3150 * This should be used if either the codec device does not require
3151 * hardware frames or any that are used are to be allocated internally by
3152 * libavcodec. If the user wishes to supply any of the frames used as
3153 * encoder input or decoder output then hw_frames_ctx should be used
3154 * instead. When hw_frames_ctx is set in get_format() for a decoder, this
3155 * field will be ignored while decoding the associated stream segment, but
3156 * may again be used on a following one after another get_format() call.
3157 *
3158 * For both encoders and decoders this field should be set before
3159 * avcodec_open2() is called and must not be written to thereafter.
3160 *
3161 * Note that some decoders may require this field to be set initially in
3162 * order to support hw_frames_ctx at all - in that case, all frames
3163 * contexts used must be created on the same device.
3164 */
3165 AVBufferRef *hw_device_ctx;
3166 } AVCodecContext;
3167
3168 /**
3169 * AVProfile.
3170 */
3171 typedef struct AVProfile {
3172 int profile;
3173 const char *name; ///< short name for the profile
3174 } AVProfile;
3175
3176 typedef struct AVCodecDefault AVCodecDefault;
3177
3178 struct AVSubtitle;
3179
3180 /**
3181 * AVCodec.
3182 */
3183 typedef struct AVCodec {
3184 /**
3185 * Name of the codec implementation.
3186 * The name is globally unique among encoders and among decoders (but an
3187 * encoder and a decoder can share the same name).
3188 * This is the primary way to find a codec from the user perspective.
3189 */
3190 const char *name;
3191 /**
3192 * Descriptive name for the codec, meant to be more human readable than name.
3193 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
3194 */
3195 const char *long_name;
3196 enum AVMediaType type;
3197 enum AVCodecID id;
3198 /**
3199 * Codec capabilities.
3200 * see AV_CODEC_CAP_*
3201 */
3202 int capabilities;
3203 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
3204 const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
3205 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3206 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3207 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3208 #if FF_API_LOWRES
3209 attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
3210 #endif
3211 const AVClass *priv_class; ///< AVClass for the private context
3212 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
3213
3214 /*****************************************************************
3215 * No fields below this line are part of the public API. They
3216 * may not be used outside of libavcodec and can be changed and
3217 * removed at will.
3218 * New public fields should be added right above.
3219 *****************************************************************
3220 */
3221 int priv_data_size;
3222 struct AVCodec *next;
3223 /**
3224 * @name Frame-level threading support functions
3225 * @{
3226 */
3227 /**
3228 * If defined, called on thread contexts when they are created.
3229 * If the codec allocates writable tables in init(), re-allocate them here.
3230 * priv_data will be set to a copy of the original.
3231 */
3232 int (*init_thread_copy)(AVCodecContext *);
3233 /**
3234 * Copy necessary context variables from a previous thread context to the current one.
3235 * If not defined, the next thread will start automatically; otherwise, the codec
3236 * must call ff_thread_finish_setup().
3237 *
3238 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
3239 */
3240 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
3241 /** @} */
3242
3243 /**
3244 * Private codec-specific defaults.
3245 */
3246 const AVCodecDefault *defaults;
3247
3248 /**
3249 * Initialize codec static data, called from avcodec_register().
3250 */
3251 void (*init_static_data)(struct AVCodec *codec);
3252
3253 int (*init)(AVCodecContext *);
3254 int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
3255 const struct AVSubtitle *sub);
3256 /**
3257 * Encode data to an AVPacket.
3258 *
3259 * @param avctx codec context
3260 * @param avpkt output AVPacket (may contain a user-provided buffer)
3261 * @param[in] frame AVFrame containing the raw data to be encoded
3262 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
3263 * non-empty packet was returned in avpkt.
3264 * @return 0 on success, negative error code on failure
3265 */
3266 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
3267 int *got_packet_ptr);
3268 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
3269 int (*close)(AVCodecContext *);
3270 /**
3271 * Encode API with decoupled packet/frame dataflow. The API is the
3272 * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except
3273 * that:
3274 * - never called if the codec is closed or the wrong type,
3275 * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent,
3276 * - only one drain frame is ever passed down,
3277 */
3278 int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame);
3279 int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt);
3280
3281 /**
3282 * Decode API with decoupled packet/frame dataflow. This function is called
3283 * to get one output frame. It should call ff_decode_get_packet() to obtain
3284 * input data.
3285 */
3286 int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame);
3287 /**
3288 * Flush buffers.
3289 * Will be called when seeking
3290 */
3291 void (*flush)(AVCodecContext *);
3292 /**
3293 * Internal codec capabilities.
3294 * See FF_CODEC_CAP_* in internal.h
3295 */
3296 int caps_internal;
3297
3298 /**
3299 * Decoding only, a comma-separated list of bitstream filters to apply to
3300 * packets before decoding.
3301 */
3302 const char *bsfs;
3303 } AVCodec;
3304
3305 /**
3306 * @defgroup lavc_hwaccel AVHWAccel
3307 * @{
3308 */
3309 typedef struct AVHWAccel {
3310 /**
3311 * Name of the hardware accelerated codec.
3312 * The name is globally unique among encoders and among decoders (but an
3313 * encoder and a decoder can share the same name).
3314 */
3315 const char *name;
3316
3317 /**
3318 * Type of codec implemented by the hardware accelerator.
3319 *
3320 * See AVMEDIA_TYPE_xxx
3321 */
3322 enum AVMediaType type;
3323
3324 /**
3325 * Codec implemented by the hardware accelerator.
3326 *
3327 * See AV_CODEC_ID_xxx
3328 */
3329 enum AVCodecID id;
3330
3331 /**
3332 * Supported pixel format.
3333 *
3334 * Only hardware accelerated formats are supported here.
3335 */
3336 enum AVPixelFormat pix_fmt;
3337
3338 /**
3339 * Hardware accelerated codec capabilities.
3340 * see FF_HWACCEL_CODEC_CAP_*
3341 */
3342 int capabilities;
3343
3344 /*****************************************************************
3345 * No fields below this line are part of the public API. They
3346 * may not be used outside of libavcodec and can be changed and
3347 * removed at will.
3348 * New public fields should be added right above.
3349 *****************************************************************
3350 */
3351 struct AVHWAccel *next;
3352
3353 /**
3354 * Allocate a custom buffer
3355 */
3356 int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame);
3357
3358 /**
3359 * Called at the beginning of each frame or field picture.
3360 *
3361 * Meaningful frame information (codec specific) is guaranteed to
3362 * be parsed at this point. This function is mandatory.
3363 *
3364 * Note that buf can be NULL along with buf_size set to 0.
3365 * Otherwise, this means the whole frame is available at this point.
3366 *
3367 * @param avctx the codec context
3368 * @param buf the frame data buffer base
3369 * @param buf_size the size of the frame in bytes
3370 * @return zero if successful, a negative value otherwise
3371 */
3372 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3373
3374 /**
3375 * Callback for each slice.
3376 *
3377 * Meaningful slice information (codec specific) is guaranteed to
3378 * be parsed at this point. This function is mandatory.
3379 *
3380 * @param avctx the codec context
3381 * @param buf the slice data buffer base
3382 * @param buf_size the size of the slice in bytes
3383 * @return zero if successful, a negative value otherwise
3384 */
3385 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
3386
3387 /**
3388 * Called at the end of each frame or field picture.
3389 *
3390 * The whole picture is parsed at this point and can now be sent
3391 * to the hardware accelerator. This function is mandatory.
3392 *
3393 * @param avctx the codec context
3394 * @return zero if successful, a negative value otherwise
3395 */
3396 int (*end_frame)(AVCodecContext *avctx);
3397
3398 /**
3399 * Size of per-frame hardware accelerator private data.
3400 *
3401 * Private data is allocated with av_mallocz() before
3402 * AVCodecContext.get_buffer() and deallocated after
3403 * AVCodecContext.release_buffer().
3404 */
3405 int frame_priv_data_size;
3406
3407 /**
3408 * Initialize the hwaccel private data.
3409 *
3410 * This will be called from ff_get_format(), after hwaccel and
3411 * hwaccel_context are set and the hwaccel private data in AVCodecInternal
3412 * is allocated.
3413 */
3414 int (*init)(AVCodecContext *avctx);
3415
3416 /**
3417 * Uninitialize the hwaccel private data.
3418 *
3419 * This will be called from get_format() or avcodec_close(), after hwaccel
3420 * and hwaccel_context are already uninitialized.
3421 */
3422 int (*uninit)(AVCodecContext *avctx);
3423
3424 /**
3425 * Size of the private data to allocate in
3426 * AVCodecInternal.hwaccel_priv_data.
3427 */
3428 int priv_data_size;
3429
3430 /**
3431 * Internal hwaccel capabilities.
3432 */
3433 int caps_internal;
3434 } AVHWAccel;
3435
3436 /**
3437 * Hardware acceleration should be used for decoding even if the codec level
3438 * used is unknown or higher than the maximum supported level reported by the
3439 * hardware driver.
3440 */
3441 #define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0)
3442
3443 /**
3444 * Hardware acceleration can output YUV pixel formats with a different chroma
3445 * sampling than 4:2:0 and/or other than 8 bits per component.
3446 */
3447 #define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1)
3448
3449 /**
3450 * @}
3451 */
3452
3453 #if FF_API_AVPICTURE
3454 /**
3455 * @defgroup lavc_picture AVPicture
3456 *
3457 * Functions for working with AVPicture
3458 * @{
3459 */
3460
3461 /**
3462 * four components are given, that's all.
3463 * the last component is alpha
3464 * @deprecated Use the imgutils functions
3465 */
3466 typedef struct AVPicture {
3467 attribute_deprecated
3468 uint8_t *data[AV_NUM_DATA_POINTERS];
3469 attribute_deprecated
3470 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
3471 } AVPicture;
3472
3473 /**
3474 * @}
3475 */
3476 #endif
3477
3478 #define AVPALETTE_SIZE 1024
3479 #define AVPALETTE_COUNT 256
3480
3481 enum AVSubtitleType {
3482 SUBTITLE_NONE,
3483
3484 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
3485
3486 /**
3487 * Plain text, the text field must be set by the decoder and is
3488 * authoritative. ass and pict fields may contain approximations.
3489 */
3490 SUBTITLE_TEXT,
3491
3492 /**
3493 * Formatted text, the ass field must be set by the decoder and is
3494 * authoritative. pict and text fields may contain approximations.
3495 */
3496 SUBTITLE_ASS,
3497 };
3498
3499 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
3500
3501 typedef struct AVSubtitleRect {
3502 int x; ///< top left corner of pict, undefined when pict is not set
3503 int y; ///< top left corner of pict, undefined when pict is not set
3504 int w; ///< width of pict, undefined when pict is not set
3505 int h; ///< height of pict, undefined when pict is not set
3506 int nb_colors; ///< number of colors in pict, undefined when pict is not set
3507
3508 #if FF_API_AVPICTURE
3509 /**
3510 * @deprecated unused
3511 */
3512 attribute_deprecated
3513 AVPicture pict;
3514 #endif
3515 /**
3516 * data+linesize for the bitmap of this subtitle.
3517 * Can be set for text/ass as well once they are rendered.
3518 */
3519 uint8_t *data[4];
3520 int linesize[4];
3521
3522 enum AVSubtitleType type;
3523
3524 char *text; ///< 0 terminated plain UTF-8 text
3525
3526 /**
3527 * 0 terminated ASS/SSA compatible event line.
3528 * The presentation of this is unaffected by the other values in this
3529 * struct.
3530 */
3531 char *ass;
3532 int flags;
3533 } AVSubtitleRect;
3534
3535 typedef struct AVSubtitle {
3536 uint16_t format; /* 0 = graphics */
3537 uint32_t start_display_time; /* relative to packet pts, in ms */
3538 uint32_t end_display_time; /* relative to packet pts, in ms */
3539 unsigned num_rects;
3540 AVSubtitleRect **rects;
3541 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
3542 } AVSubtitle;
3543
3544 /**
3545 * This struct describes the properties of an encoded stream.
3546 *
3547 * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must
3548 * be allocated with avcodec_parameters_alloc() and freed with
3549 * avcodec_parameters_free().
3550 */
3551 typedef struct AVCodecParameters {
3552 /**
3553 * General type of the encoded data.
3554 */
3555 enum AVMediaType codec_type;
3556 /**
3557 * Specific type of the encoded data (the codec used).
3558 */
3559 enum AVCodecID codec_id;
3560 /**
3561 * Additional information about the codec (corresponds to the AVI FOURCC).
3562 */
3563 uint32_t codec_tag;
3564
3565 /**
3566 * Extra binary data needed for initializing the decoder, codec-dependent.
3567 *
3568 * Must be allocated with av_malloc() and will be freed by
3569 * avcodec_parameters_free(). The allocated size of extradata must be at
3570 * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding
3571 * bytes zeroed.
3572 */
3573 uint8_t *extradata;
3574 /**
3575 * Size of the extradata content in bytes.
3576 */
3577 int extradata_size;
3578
3579 /**
3580 * - video: the pixel format, the value corresponds to enum AVPixelFormat.
3581 * - audio: the sample format, the value corresponds to enum AVSampleFormat.
3582 */
3583 int format;
3584
3585 /**
3586 * The average bitrate of the encoded data (in bits per second).
3587 */
3588 int bit_rate;
3589
3590 int bits_per_coded_sample;
3591
3592 /**
3593 * Codec-specific bitstream restrictions that the stream conforms to.
3594 */
3595 int profile;
3596 int level;
3597
3598 /**
3599 * Video only. The dimensions of the video frame in pixels.
3600 */
3601 int width;
3602 int height;
3603
3604 /**
3605 * Video only. The aspect ratio (width / height) which a single pixel
3606 * should have when displayed.
3607 *
3608 * When the aspect ratio is unknown / undefined, the numerator should be
3609 * set to 0 (the denominator may have any value).
3610 */
3611 AVRational sample_aspect_ratio;
3612
3613 /**
3614 * Video only. The order of the fields in interlaced video.
3615 */
3616 enum AVFieldOrder field_order;
3617
3618 /**
3619 * Video only. Additional colorspace characteristics.
3620 */
3621 enum AVColorRange color_range;
3622 enum AVColorPrimaries color_primaries;
3623 enum AVColorTransferCharacteristic color_trc;
3624 enum AVColorSpace color_space;
3625 enum AVChromaLocation chroma_location;
3626
3627 /**
3628 * Audio only. The channel layout bitmask. May be 0 if the channel layout is
3629 * unknown or unspecified, otherwise the number of bits set must be equal to
3630 * the channels field.
3631 */
3632 uint64_t channel_layout;
3633 /**
3634 * Audio only. The number of audio channels.
3635 */
3636 int channels;
3637 /**
3638 * Audio only. The number of audio samples per second.
3639 */
3640 int sample_rate;
3641 /**
3642 * Audio only. The number of bytes per coded audio frame, required by some
3643 * formats.
3644 *
3645 * Corresponds to nBlockAlign in WAVEFORMATEX.
3646 */
3647 int block_align;
3648
3649 /**
3650 * Audio only. The amount of padding (in samples) inserted by the encoder at
3651 * the beginning of the audio. I.e. this number of leading decoded samples
3652 * must be discarded by the caller to get the original audio without leading
3653 * padding.
3654 */
3655 int initial_padding;
3656 /**
3657 * Audio only. The amount of padding (in samples) appended by the encoder to
3658 * the end of the audio. I.e. this number of decoded samples must be
3659 * discarded by the caller from the end of the stream to get the original
3660 * audio without any trailing padding.
3661 */
3662 int trailing_padding;
3663 } AVCodecParameters;
3664
3665 /**
3666 * If c is NULL, returns the first registered codec,
3667 * if c is non-NULL, returns the next registered codec after c,
3668 * or NULL if c is the last one.
3669 */
3670 AVCodec *av_codec_next(const AVCodec *c);
3671
3672 /**
3673 * Return the LIBAVCODEC_VERSION_INT constant.
3674 */
3675 unsigned avcodec_version(void);
3676
3677 /**
3678 * Return the libavcodec build-time configuration.
3679 */
3680 const char *avcodec_configuration(void);
3681
3682 /**
3683 * Return the libavcodec license.
3684 */
3685 const char *avcodec_license(void);
3686
3687 /**
3688 * Register the codec codec and initialize libavcodec.
3689 *
3690 * @warning either this function or avcodec_register_all() must be called
3691 * before any other libavcodec functions.
3692 *
3693 * @see avcodec_register_all()
3694 */
3695 void avcodec_register(AVCodec *codec);
3696
3697 /**
3698 * Register all the codecs, parsers and bitstream filters which were enabled at
3699 * configuration time. If you do not call this function you can select exactly
3700 * which formats you want to support, by using the individual registration
3701 * functions.
3702 *
3703 * @see avcodec_register
3704 * @see av_register_codec_parser
3705 * @see av_register_bitstream_filter
3706 */
3707 void avcodec_register_all(void);
3708
3709 /**
3710 * Allocate an AVCodecContext and set its fields to default values. The
3711 * resulting struct should be freed with avcodec_free_context().
3712 *
3713 * @param codec if non-NULL, allocate private data and initialize defaults
3714 * for the given codec. It is illegal to then call avcodec_open2()
3715 * with a different codec.
3716 * If NULL, then the codec-specific defaults won't be initialized,
3717 * which may result in suboptimal default settings (this is
3718 * important mainly for encoders, e.g. libx264).
3719 *
3720 * @return An AVCodecContext filled with default values or NULL on failure.
3721 */
3722 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
3723
3724 /**
3725 * Free the codec context and everything associated with it and write NULL to
3726 * the provided pointer.
3727 */
3728 void avcodec_free_context(AVCodecContext **avctx);
3729
3730 #if FF_API_GET_CONTEXT_DEFAULTS
3731 /**
3732 * @deprecated This function should not be used, as closing and opening a codec
3733 * context multiple time is not supported. A new codec context should be
3734 * allocated for each new use.
3735 */
3736 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
3737 #endif
3738
3739 /**
3740 * Get the AVClass for AVCodecContext. It can be used in combination with
3741 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3742 *
3743 * @see av_opt_find().
3744 */
3745 const AVClass *avcodec_get_class(void);
3746
3747 #if FF_API_COPY_CONTEXT
3748 /**
3749 * Copy the settings of the source AVCodecContext into the destination
3750 * AVCodecContext. The resulting destination codec context will be
3751 * unopened, i.e. you are required to call avcodec_open2() before you
3752 * can use this AVCodecContext to decode/encode video/audio data.
3753 *
3754 * @param dest target codec context, should be initialized with
3755 * avcodec_alloc_context3(), but otherwise uninitialized
3756 * @param src source codec context
3757 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3758 *
3759 * @deprecated The semantics of this function are ill-defined and it should not
3760 * be used. If you need to transfer the stream parameters from one codec context
3761 * to another, use an intermediate AVCodecParameters instance and the
3762 * avcodec_parameters_from_context() / avcodec_parameters_to_context()
3763 * functions.
3764 */
3765 attribute_deprecated
3766 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3767 #endif
3768
3769 /**
3770 * Allocate a new AVCodecParameters and set its fields to default values
3771 * (unknown/invalid/0). The returned struct must be freed with
3772 * avcodec_parameters_free().
3773 */
3774 AVCodecParameters *avcodec_parameters_alloc(void);
3775
3776 /**
3777 * Free an AVCodecParameters instance and everything associated with it and
3778 * write NULL to the supplied pointer.
3779 */
3780 void avcodec_parameters_free(AVCodecParameters **par);
3781
3782 /**
3783 * Copy the contents of src to dst. Any allocated fields in dst are freed and
3784 * replaced with newly allocated duplicates of the corresponding fields in src.
3785 *
3786 * @return >= 0 on success, a negative AVERROR code on failure.
3787 */
3788 int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src);
3789
3790 /**
3791 * Fill the parameters struct based on the values from the supplied codec
3792 * context. Any allocated fields in par are freed and replaced with duplicates
3793 * of the corresponding fields in codec.
3794 *
3795 * @return >= 0 on success, a negative AVERROR code on failure
3796 */
3797 int avcodec_parameters_from_context(AVCodecParameters *par,
3798 const AVCodecContext *codec);
3799
3800 /**
3801 * Fill the codec context based on the values from the supplied codec
3802 * parameters. Any allocated fields in codec that have a corresponding field in
3803 * par are freed and replaced with duplicates of the corresponding field in par.
3804 * Fields in codec that do not have a counterpart in par are not touched.
3805 *
3806 * @return >= 0 on success, a negative AVERROR code on failure.
3807 */
3808 int avcodec_parameters_to_context(AVCodecContext *codec,
3809 const AVCodecParameters *par);
3810
3811 /**
3812 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3813 * function the context has to be allocated with avcodec_alloc_context3().
3814 *
3815 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3816 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3817 * retrieving a codec.
3818 *
3819 * @warning This function is not thread safe!
3820 *
3821 * @note Always call this function before using decoding routines (such as
3822 * @ref avcodec_receive_frame()).
3823 *
3824 * @code
3825 * avcodec_register_all();
3826 * av_dict_set(&opts, "b", "2.5M", 0);
3827 * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3828 * if (!codec)
3829 * exit(1);
3830 *
3831 * context = avcodec_alloc_context3(codec);
3832 *
3833 * if (avcodec_open2(context, codec, opts) < 0)
3834 * exit(1);
3835 * @endcode
3836 *
3837 * @param avctx The context to initialize.
3838 * @param codec The codec to open this context for. If a non-NULL codec has been
3839 * previously passed to avcodec_alloc_context3() or
3840 * for this context, then this parameter MUST be either NULL or
3841 * equal to the previously passed codec.
3842 * @param options A dictionary filled with AVCodecContext and codec-private options.
3843 * On return this object will be filled with options that were not found.
3844 *
3845 * @return zero on success, a negative value on error
3846 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3847 * av_dict_set(), av_opt_find().
3848 */
3849 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3850
3851 /**
3852 * Close a given AVCodecContext and free all the data associated with it
3853 * (but not the AVCodecContext itself).
3854 *
3855 * Calling this function on an AVCodecContext that hasn't been opened will free
3856 * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL
3857 * codec. Subsequent calls will do nothing.
3858 *
3859 * @note Do not use this function. Use avcodec_free_context() to destroy a
3860 * codec context (either open or closed). Opening and closing a codec context
3861 * multiple times is not supported anymore -- use multiple codec contexts
3862 * instead.
3863 */
3864 int avcodec_close(AVCodecContext *avctx);
3865
3866 /**
3867 * Free all allocated data in the given subtitle struct.
3868 *
3869 * @param sub AVSubtitle to free.
3870 */
3871 void avsubtitle_free(AVSubtitle *sub);
3872
3873 /**
3874 * @}
3875 */
3876
3877 /**
3878 * @addtogroup lavc_packet
3879 * @{
3880 */
3881
3882 /**
3883 * Allocate an AVPacket and set its fields to default values. The resulting
3884 * struct must be freed using av_packet_free().
3885 *
3886 * @return An AVPacket filled with default values or NULL on failure.
3887 *
3888 * @note this only allocates the AVPacket itself, not the data buffers. Those
3889 * must be allocated through other means such as av_new_packet.
3890 *
3891 * @see av_new_packet
3892 */
3893 AVPacket *av_packet_alloc(void);
3894
3895 /**
3896 * Create a new packet that references the same data as src.
3897 *
3898 * This is a shortcut for av_packet_alloc()+av_packet_ref().
3899 *
3900 * @return newly created AVPacket on success, NULL on error.
3901 *
3902 * @see av_packet_alloc
3903 * @see av_packet_ref
3904 */
3905 AVPacket *av_packet_clone(const AVPacket *src);
3906
3907 /**
3908 * Free the packet, if the packet is reference counted, it will be
3909 * unreferenced first.
3910 *
3911 * @param pkt packet to be freed. The pointer will be set to NULL.
3912 * @note passing NULL is a no-op.
3913 */
3914 void av_packet_free(AVPacket **pkt);
3915
3916 /**
3917 * Initialize optional fields of a packet with default values.
3918 *
3919 * Note, this does not touch the data and size members, which have to be
3920 * initialized separately.
3921 *
3922 * @param pkt packet
3923 */
3924 void av_init_packet(AVPacket *pkt);
3925
3926 /**
3927 * Allocate the payload of a packet and initialize its fields with
3928 * default values.
3929 *
3930 * @param pkt packet
3931 * @param size wanted payload size
3932 * @return 0 if OK, AVERROR_xxx otherwise
3933 */
3934 int av_new_packet(AVPacket *pkt, int size);
3935
3936 /**
3937 * Reduce packet size, correctly zeroing padding
3938 *
3939 * @param pkt packet
3940 * @param size new size
3941 */
3942 void av_shrink_packet(AVPacket *pkt, int size);
3943
3944 /**
3945 * Increase packet size, correctly zeroing padding
3946 *
3947 * @param pkt packet
3948 * @param grow_by number of bytes by which to increase the size of the packet
3949 */
3950 int av_grow_packet(AVPacket *pkt, int grow_by);
3951
3952 /**
3953 * Initialize a reference-counted packet from av_malloc()ed data.
3954 *
3955 * @param pkt packet to be initialized. This function will set the data, size,
3956 * buf and destruct fields, all others are left untouched.
3957 * @param data Data allocated by av_malloc() to be used as packet data. If this
3958 * function returns successfully, the data is owned by the underlying AVBuffer.
3959 * The caller may not access the data through other means.
3960 * @param size size of data in bytes, without the padding. I.e. the full buffer
3961 * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE.
3962 *
3963 * @return 0 on success, a negative AVERROR on error
3964 */
3965 int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
3966
3967 #if FF_API_AVPACKET_OLD_API
3968 /**
3969 * @warning This is a hack - the packet memory allocation stuff is broken. The
3970 * packet is allocated if it was not really allocated.
3971 *
3972 * @deprecated Use av_packet_ref
3973 */
3974 attribute_deprecated
3975 int av_dup_packet(AVPacket *pkt);
3976 /**
3977 * Free a packet.
3978 *
3979 * @deprecated Use av_packet_unref
3980 *
3981 * @param pkt packet to free
3982 */
3983 attribute_deprecated
3984 void av_free_packet(AVPacket *pkt);
3985 #endif
3986 /**
3987 * Allocate new information of a packet.
3988 *
3989 * @param pkt packet
3990 * @param type side information type
3991 * @param size side information size
3992 * @return pointer to fresh allocated data or NULL otherwise
3993 */
3994 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3995 int size);
3996
3997 /**
3998 * Wrap an existing array as a packet side data.
3999 *
4000 * @param pkt packet
4001 * @param type side information type
4002 * @param data the side data array. It must be allocated with the av_malloc()
4003 * family of functions. The ownership of the data is transferred to
4004 * pkt.
4005 * @param size side information size
4006 * @return a non-negative number on success, a negative AVERROR code on
4007 * failure. On failure, the packet is unchanged and the data remains
4008 * owned by the caller.
4009 */
4010 int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4011 uint8_t *data, size_t size);
4012
4013 /**
4014 * Shrink the already allocated side data buffer
4015 *
4016 * @param pkt packet
4017 * @param type side information type
4018 * @param size new side information size
4019 * @return 0 on success, < 0 on failure
4020 */
4021 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4022 int size);
4023
4024 /**
4025 * Get side information from packet.
4026 *
4027 * @param pkt packet
4028 * @param type desired side information type
4029 * @param size pointer for side information size to store (optional)
4030 * @return pointer to data if present or NULL otherwise
4031 */
4032 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
4033 int *size);
4034
4035 /**
4036 * Convenience function to free all the side data stored.
4037 * All the other fields stay untouched.
4038 *
4039 * @param pkt packet
4040 */
4041 void av_packet_free_side_data(AVPacket *pkt);
4042
4043 /**
4044 * Setup a new reference to the data described by a given packet
4045 *
4046 * If src is reference-counted, setup dst as a new reference to the
4047 * buffer in src. Otherwise allocate a new buffer in dst and copy the
4048 * data from src into it.
4049 *
4050 * All the other fields are copied from src.
4051 *
4052 * @see av_packet_unref
4053 *
4054 * @param dst Destination packet
4055 * @param src Source packet
4056 *
4057 * @return 0 on success, a negative AVERROR on error.
4058 */
4059 int av_packet_ref(AVPacket *dst, const AVPacket *src);
4060
4061 /**
4062 * Wipe the packet.
4063 *
4064 * Unreference the buffer referenced by the packet and reset the
4065 * remaining packet fields to their default values.
4066 *
4067 * @param pkt The packet to be unreferenced.
4068 */
4069 void av_packet_unref(AVPacket *pkt);
4070
4071 /**
4072 * Move every field in src to dst and reset src.
4073 *
4074 * @see av_packet_unref
4075 *
4076 * @param src Source packet, will be reset
4077 * @param dst Destination packet
4078 */
4079 void av_packet_move_ref(AVPacket *dst, AVPacket *src);
4080
4081 /**
4082 * Copy only "properties" fields from src to dst.
4083 *
4084 * Properties for the purpose of this function are all the fields
4085 * beside those related to the packet data (buf, data, size)
4086 *
4087 * @param dst Destination packet
4088 * @param src Source packet
4089 *
4090 * @return 0 on success AVERROR on failure.
4091 */
4092 int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
4093
4094 /**
4095 * Convert valid timing fields (timestamps / durations) in a packet from one
4096 * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be
4097 * ignored.
4098 *
4099 * @param pkt packet on which the conversion will be performed
4100 * @param tb_src source timebase, in which the timing fields in pkt are
4101 * expressed
4102 * @param tb_dst destination timebase, to which the timing fields will be
4103 * converted
4104 */
4105 void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
4106
4107 /**
4108 * @}
4109 */
4110
4111 /**
4112 * @addtogroup lavc_decoding
4113 * @{
4114 */
4115
4116 /**
4117 * Find a registered decoder with a matching codec ID.
4118 *
4119 * @param id AVCodecID of the requested decoder
4120 * @return A decoder if one was found, NULL otherwise.
4121 */
4122 AVCodec *avcodec_find_decoder(enum AVCodecID id);
4123
4124 /**
4125 * Find a registered decoder with the specified name.
4126 *
4127 * @param name name of the requested decoder
4128 * @return A decoder if one was found, NULL otherwise.
4129 */
4130 AVCodec *avcodec_find_decoder_by_name(const char *name);
4131
4132 /**
4133 * The default callback for AVCodecContext.get_buffer2(). It is made public so
4134 * it can be called by custom get_buffer2() implementations for decoders without
4135 * AV_CODEC_CAP_DR1 set.
4136 */
4137 int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
4138
4139 #if FF_API_EMU_EDGE
4140 /**
4141 * Return the amount of padding in pixels which the get_buffer callback must
4142 * provide around the edge of the image for codecs which do not have the
4143 * CODEC_FLAG_EMU_EDGE flag.
4144 *
4145 * @return Required padding in pixels.
4146 *
4147 * @deprecated CODEC_FLAG_EMU_EDGE is deprecated, so this function is no longer
4148 * needed
4149 */
4150 attribute_deprecated
4151 unsigned avcodec_get_edge_width(void);
4152 #endif
4153
4154 /**
4155 * Modify width and height values so that they will result in a memory
4156 * buffer that is acceptable for the codec if you do not use any horizontal
4157 * padding.
4158 *
4159 * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
4160 */
4161 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
4162
4163 /**
4164 * Modify width and height values so that they will result in a memory
4165 * buffer that is acceptable for the codec if you also ensure that all
4166 * line sizes are a multiple of the respective linesize_align[i].
4167 *
4168 * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened.
4169 */
4170 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
4171 int linesize_align[AV_NUM_DATA_POINTERS]);
4172
4173 /**
4174 * Decode the audio frame of size avpkt->size from avpkt->data into frame.
4175 *
4176 * Some decoders may support multiple frames in a single AVPacket. Such
4177 * decoders would then just decode the first frame and the return value would be
4178 * less than the packet size. In this case, avcodec_decode_audio4 has to be
4179 * called again with an AVPacket containing the remaining data in order to
4180 * decode the second frame, etc... Even if no frames are returned, the packet
4181 * needs to be fed to the decoder with remaining data until it is completely
4182 * consumed or an error occurs.
4183 *
4184 * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input
4185 * and output. This means that for some packets they will not immediately
4186 * produce decoded output and need to be flushed at the end of decoding to get
4187 * all the decoded data. Flushing is done by calling this function with packets
4188 * with avpkt->data set to NULL and avpkt->size set to 0 until it stops
4189 * returning samples. It is safe to flush even those decoders that are not
4190 * marked with AV_CODEC_CAP_DELAY, then no samples will be returned.
4191 *
4192 * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
4193 * larger than the actual read bytes because some optimized bitstream
4194 * readers read 32 or 64 bits at once and could read over the end.
4195 *
4196 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4197 * before packets may be fed to the decoder.
4198 *
4199 * @param avctx the codec context
4200 * @param[out] frame The AVFrame in which to store decoded audio samples.
4201 * The decoder will allocate a buffer for the decoded frame by
4202 * calling the AVCodecContext.get_buffer2() callback.
4203 * When AVCodecContext.refcounted_frames is set to 1, the frame is
4204 * reference counted and the returned reference belongs to the
4205 * caller. The caller must release the frame using av_frame_unref()
4206 * when the frame is no longer needed. The caller may safely write
4207 * to the frame if av_frame_is_writable() returns 1.
4208 * When AVCodecContext.refcounted_frames is set to 0, the returned
4209 * reference belongs to the decoder and is valid only until the
4210 * next call to this function or until closing or flushing the
4211 * decoder. The caller may not write to it.
4212 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
4213 * non-zero. Note that this field being set to zero
4214 * does not mean that an error has occurred. For
4215 * decoders with AV_CODEC_CAP_DELAY set, no given decode
4216 * call is guaranteed to produce a frame.
4217 * @param[in] avpkt The input AVPacket containing the input buffer.
4218 * At least avpkt->data and avpkt->size should be set. Some
4219 * decoders might also require additional fields to be set.
4220 * @return A negative error code is returned if an error occurred during
4221 * decoding, otherwise the number of bytes consumed from the input
4222 * AVPacket is returned.
4223 *
4224 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
4225 */
4226 attribute_deprecated
4227 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
4228 int *got_frame_ptr, AVPacket *avpkt);
4229
4230 /**
4231 * Decode the video frame of size avpkt->size from avpkt->data into picture.
4232 * Some decoders may support multiple frames in a single AVPacket, such
4233 * decoders would then just decode the first frame.
4234 *
4235 * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than
4236 * the actual read bytes because some optimized bitstream readers read 32 or 64
4237 * bits at once and could read over the end.
4238 *
4239 * @warning The end of the input buffer buf should be set to 0 to ensure that
4240 * no overreading happens for damaged MPEG streams.
4241 *
4242 * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay
4243 * between input and output, these need to be fed with avpkt->data=NULL,
4244 * avpkt->size=0 at the end to return the remaining frames.
4245 *
4246 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4247 * before packets may be fed to the decoder.
4248 *
4249 * @param avctx the codec context
4250 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
4251 * Use av_frame_alloc() to get an AVFrame. The codec will
4252 * allocate memory for the actual bitmap by calling the
4253 * AVCodecContext.get_buffer2() callback.
4254 * When AVCodecContext.refcounted_frames is set to 1, the frame is
4255 * reference counted and the returned reference belongs to the
4256 * caller. The caller must release the frame using av_frame_unref()
4257 * when the frame is no longer needed. The caller may safely write
4258 * to the frame if av_frame_is_writable() returns 1.
4259 * When AVCodecContext.refcounted_frames is set to 0, the returned
4260 * reference belongs to the decoder and is valid only until the
4261 * next call to this function or until closing or flushing the
4262 * decoder. The caller may not write to it.
4263 *
4264 * @param[in] avpkt The input AVPacket containing the input buffer.
4265 * You can create such packet with av_init_packet() and by then setting
4266 * data and size, some decoders might in addition need other fields like
4267 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
4268 * fields possible.
4269 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
4270 * @return On error a negative value is returned, otherwise the number of bytes
4271 * used or zero if no frame could be decompressed.
4272 *
4273 * @deprecated Use avcodec_send_packet() and avcodec_receive_frame().
4274 */
4275 attribute_deprecated
4276 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
4277 int *got_picture_ptr,
4278 AVPacket *avpkt);
4279
4280 /**
4281 * Decode a subtitle message.
4282 * Return a negative value on error, otherwise return the number of bytes used.
4283 * If no subtitle could be decompressed, got_sub_ptr is zero.
4284 * Otherwise, the subtitle is stored in *sub.
4285 * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for
4286 * simplicity, because the performance difference is expect to be negligible
4287 * and reusing a get_buffer written for video codecs would probably perform badly
4288 * due to a potentially very different allocation pattern.
4289 *
4290 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4291 * before packets may be fed to the decoder.
4292 *
4293 * @param avctx the codec context
4294 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
4295 freed with avsubtitle_free if *got_sub_ptr is set.
4296 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
4297 * @param[in] avpkt The input AVPacket containing the input buffer.
4298 */
4299 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
4300 int *got_sub_ptr,
4301 AVPacket *avpkt);
4302
4303 /**
4304 * Supply raw packet data as input to a decoder.
4305 *
4306 * Internally, this call will copy relevant AVCodecContext fields, which can
4307 * influence decoding per-packet, and apply them when the packet is actually
4308 * decoded. (For example AVCodecContext.skip_frame, which might direct the
4309 * decoder to drop the frame contained by the packet sent with this function.)
4310 *
4311 * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE
4312 * larger than the actual read bytes because some optimized bitstream
4313 * readers read 32 or 64 bits at once and could read over the end.
4314 *
4315 * @warning Do not mix this API with the legacy API (like avcodec_decode_video2())
4316 * on the same AVCodecContext. It will return unexpected results now
4317 * or in future libavcodec versions.
4318 *
4319 * @note The AVCodecContext MUST have been opened with @ref avcodec_open2()
4320 * before packets may be fed to the decoder.
4321 *
4322 * @param avctx codec context
4323 * @param[in] avpkt The input AVPacket. Usually, this will be a single video
4324 * frame, or several complete audio frames.
4325 * Ownership of the packet remains with the caller, and the
4326 * decoder will not write to the packet. The decoder may create
4327 * a reference to the packet data (or copy it if the packet is
4328 * not reference-counted).
4329 * Unlike with older APIs, the packet is always fully consumed,
4330 * and if it contains multiple frames (e.g. some audio codecs),
4331 * will require you to call avcodec_receive_frame() multiple
4332 * times afterwards before you can send a new packet.
4333 * It can be NULL (or an AVPacket with data set to NULL and
4334 * size set to 0); in this case, it is considered a flush
4335 * packet, which signals the end of the stream. Sending the
4336 * first flush packet will return success. Subsequent ones are
4337 * unnecessary and will return AVERROR_EOF. If the decoder
4338 * still has frames buffered, it will return them after sending
4339 * a flush packet.
4340 *
4341 * @return 0 on success, otherwise negative error code:
4342 * AVERROR(EAGAIN): input is not accepted right now - the packet must be
4343 * resent after trying to read output
4344 * AVERROR_EOF: the decoder has been flushed, and no new packets can
4345 * be sent to it (also returned if more than 1 flush
4346 * packet is sent)
4347 * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush
4348 * AVERROR(ENOMEM): failed to add packet to internal queue, or similar
4349 * other errors: legitimate decoding errors
4350 */
4351 int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);
4352
4353 /**
4354 * Return decoded output data from a decoder.
4355 *
4356 * @param avctx codec context
4357 * @param frame This will be set to a reference-counted video or audio
4358 * frame (depending on the decoder type) allocated by the
4359 * decoder. Note that the function will always call
4360 * av_frame_unref(frame) before doing anything else.
4361 *
4362 * @return
4363 * 0: success, a frame was returned
4364 * AVERROR(EAGAIN): output is not available right now - user must try
4365 * to send new input
4366 * AVERROR_EOF: the decoder has been fully flushed, and there will be
4367 * no more output frames
4368 * AVERROR(EINVAL): codec not opened, or it is an encoder
4369 * other negative values: legitimate decoding errors
4370 */
4371 int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);
4372
4373 /**
4374 * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet()
4375 * to retrieve buffered output packets.
4376 *
4377 * @param avctx codec context
4378 * @param[in] frame AVFrame containing the raw audio or video frame to be encoded.
4379 * Ownership of the frame remains with the caller, and the
4380 * encoder will not write to the frame. The encoder may create
4381 * a reference to the frame data (or copy it if the frame is
4382 * not reference-counted).
4383 * It can be NULL, in which case it is considered a flush
4384 * packet. This signals the end of the stream. If the encoder
4385 * still has packets buffered, it will return them after this
4386 * call. Once flushing mode has been entered, additional flush
4387 * packets are ignored, and sending frames will return
4388 * AVERROR_EOF.
4389 *
4390 * For audio:
4391 * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
4392 * can have any number of samples.
4393 * If it is not set, frame->nb_samples must be equal to
4394 * avctx->frame_size for all frames except the last.
4395 * The final frame may be smaller than avctx->frame_size.
4396 * @return 0 on success, otherwise negative error code:
4397 * AVERROR(EAGAIN): input is not accepted right now - the frame must be
4398 * resent after trying to read output packets
4399 * AVERROR_EOF: the encoder has been flushed, and no new frames can
4400 * be sent to it
4401 * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a
4402 * decoder, or requires flush
4403 * AVERROR(ENOMEM): failed to add packet to internal queue, or similar
4404 * other errors: legitimate decoding errors
4405 */
4406 int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame);
4407
4408 /**
4409 * Read encoded data from the encoder.
4410 *
4411 * @param avctx codec context
4412 * @param avpkt This will be set to a reference-counted packet allocated by the
4413 * encoder. Note that the function will always call
4414 * av_frame_unref(frame) before doing anything else.
4415 * @return 0 on success, otherwise negative error code:
4416 * AVERROR(EAGAIN): output is not available right now - user must try
4417 * to send input
4418 * AVERROR_EOF: the encoder has been fully flushed, and there will be
4419 * no more output packets
4420 * AVERROR(EINVAL): codec not opened, or it is an encoder
4421 * other errors: legitimate decoding errors
4422 */
4423 int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt);
4424
4425
4426 /**
4427 * @defgroup lavc_parsing Frame parsing
4428 * @{
4429 */
4430
4431 enum AVPictureStructure {
4432 AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown
4433 AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field
4434 AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field
4435 AV_PICTURE_STRUCTURE_FRAME, //< coded as frame
4436 };
4437
4438 typedef struct AVCodecParserContext {
4439 void *priv_data;
4440 struct AVCodecParser *parser;
4441 int64_t frame_offset; /* offset of the current frame */
4442 int64_t cur_offset; /* current offset
4443 (incremented by each av_parser_parse()) */
4444 int64_t next_frame_offset; /* offset of the next frame */
4445 /* video info */
4446 int pict_type; /* XXX: Put it back in AVCodecContext. */
4447 /**
4448 * This field is used for proper frame duration computation in lavf.
4449 * It signals, how much longer the frame duration of the current frame
4450 * is compared to normal frame duration.
4451 *
4452 * frame_duration = (1 + repeat_pict) * time_base
4453 *
4454 * It is used by codecs like H.264 to display telecined material.
4455 */
4456 int repeat_pict; /* XXX: Put it back in AVCodecContext. */
4457 int64_t pts; /* pts of the current frame */
4458 int64_t dts; /* dts of the current frame */
4459
4460 /* private data */
4461 int64_t last_pts;
4462 int64_t last_dts;
4463 int fetch_timestamp;
4464
4465 #define AV_PARSER_PTS_NB 4
4466 int cur_frame_start_index;
4467 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
4468 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
4469 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
4470
4471 int flags;
4472 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
4473 #define PARSER_FLAG_ONCE 0x0002
4474 /// Set if the parser has a valid file offset
4475 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
4476
4477 int64_t offset; ///< byte offset from starting packet start
4478 int64_t cur_frame_end[AV_PARSER_PTS_NB];
4479
4480 /**
4481 * Set by parser to 1 for key frames and 0 for non-key frames.
4482 * It is initialized to -1, so if the parser doesn't set this flag,
4483 * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
4484 * will be used.
4485 */
4486 int key_frame;
4487
4488 #if FF_API_CONVERGENCE_DURATION
4489 /**
4490 * @deprecated unused
4491 */
4492 attribute_deprecated
4493 int64_t convergence_duration;
4494 #endif
4495
4496 // Timestamp generation support:
4497 /**
4498 * Synchronization point for start of timestamp generation.
4499 *
4500 * Set to >0 for sync point, 0 for no sync point and <0 for undefined
4501 * (default).
4502 *
4503 * For example, this corresponds to presence of H.264 buffering period
4504 * SEI message.
4505 */
4506 int dts_sync_point;
4507
4508 /**
4509 * Offset of the current timestamp against last timestamp sync point in
4510 * units of AVCodecContext.time_base.
4511 *
4512 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4513 * contain a valid timestamp offset.
4514 *
4515 * Note that the timestamp of sync point has usually a nonzero
4516 * dts_ref_dts_delta, which refers to the previous sync point. Offset of
4517 * the next frame after timestamp sync point will be usually 1.
4518 *
4519 * For example, this corresponds to H.264 cpb_removal_delay.
4520 */
4521 int dts_ref_dts_delta;
4522
4523 /**
4524 * Presentation delay of current frame in units of AVCodecContext.time_base.
4525 *
4526 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
4527 * contain valid non-negative timestamp delta (presentation time of a frame
4528 * must not lie in the past).
4529 *
4530 * This delay represents the difference between decoding and presentation
4531 * time of the frame.
4532 *
4533 * For example, this corresponds to H.264 dpb_output_delay.
4534 */
4535 int pts_dts_delta;
4536
4537 /**
4538 * Position of the packet in file.
4539 *
4540 * Analogous to cur_frame_pts/dts
4541 */
4542 int64_t cur_frame_pos[AV_PARSER_PTS_NB];
4543
4544 /**
4545 * Byte position of currently parsed frame in stream.
4546 */
4547 int64_t pos;
4548
4549 /**
4550 * Previous frame byte position.
4551 */
4552 int64_t last_pos;
4553
4554 /**
4555 * Duration of the current frame.
4556 * For audio, this is in units of 1 / AVCodecContext.sample_rate.
4557 * For all other types, this is in units of AVCodecContext.time_base.
4558 */
4559 int duration;
4560
4561 enum AVFieldOrder field_order;
4562
4563 /**
4564 * Indicate whether a picture is coded as a frame, top field or bottom field.
4565 *
4566 * For example, H.264 field_pic_flag equal to 0 corresponds to
4567 * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag
4568 * equal to 1 and bottom_field_flag equal to 0 corresponds to
4569 * AV_PICTURE_STRUCTURE_TOP_FIELD.
4570 */
4571 enum AVPictureStructure picture_structure;
4572
4573 /**
4574 * Picture number incremented in presentation or output order.
4575 * This field may be reinitialized at the first picture of a new sequence.
4576 *
4577 * For example, this corresponds to H.264 PicOrderCnt.
4578 */
4579 int output_picture_number;
4580