lavc doxy: add avcodec.h to the libavcodec group.
[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/avutil.h"
33 #include "libavutil/buffer.h"
34 #include "libavutil/cpu.h"
35 #include "libavutil/dict.h"
36 #include "libavutil/frame.h"
37 #include "libavutil/log.h"
38 #include "libavutil/pixfmt.h"
39 #include "libavutil/rational.h"
40
41 #include "libavcodec/version.h"
42 /**
43 * @defgroup libavc Encoding/Decoding Library
44 * @{
45 *
46 * @defgroup lavc_decoding Decoding
47 * @{
48 * @}
49 *
50 * @defgroup lavc_encoding Encoding
51 * @{
52 * @}
53 *
54 * @defgroup lavc_codec Codecs
55 * @{
56 * @defgroup lavc_codec_native Native Codecs
57 * @{
58 * @}
59 * @defgroup lavc_codec_wrappers External library wrappers
60 * @{
61 * @}
62 * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
63 * @{
64 * @}
65 * @}
66 * @defgroup lavc_internal Internal
67 * @{
68 * @}
69 * @}
70 *
71 */
72
73 /**
74 * @defgroup lavc_core Core functions/structures.
75 * @ingroup libavc
76 *
77 * Basic definitions, functions for querying libavcodec capabilities,
78 * allocating core structures, etc.
79 * @{
80 */
81
82
83 /**
84 * Identify the syntax and semantics of the bitstream.
85 * The principle is roughly:
86 * Two decoders with the same ID can decode the same streams.
87 * Two encoders with the same ID can encode compatible streams.
88 * There may be slight deviations from the principle due to implementation
89 * details.
90 *
91 * If you add a codec ID to this list, add it so that
92 * 1. no value of a existing codec ID changes (that would break ABI),
93 * 2. it is as close as possible to similar codecs.
94 *
95 * After adding new codec IDs, do not forget to add an entry to the codec
96 * descriptor list and bump libavcodec minor version.
97 */
98 enum AVCodecID {
99 AV_CODEC_ID_NONE,
100
101 /* video codecs */
102 AV_CODEC_ID_MPEG1VIDEO,
103 AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
104 AV_CODEC_ID_MPEG2VIDEO_XVMC,
105 AV_CODEC_ID_H261,
106 AV_CODEC_ID_H263,
107 AV_CODEC_ID_RV10,
108 AV_CODEC_ID_RV20,
109 AV_CODEC_ID_MJPEG,
110 AV_CODEC_ID_MJPEGB,
111 AV_CODEC_ID_LJPEG,
112 AV_CODEC_ID_SP5X,
113 AV_CODEC_ID_JPEGLS,
114 AV_CODEC_ID_MPEG4,
115 AV_CODEC_ID_RAWVIDEO,
116 AV_CODEC_ID_MSMPEG4V1,
117 AV_CODEC_ID_MSMPEG4V2,
118 AV_CODEC_ID_MSMPEG4V3,
119 AV_CODEC_ID_WMV1,
120 AV_CODEC_ID_WMV2,
121 AV_CODEC_ID_H263P,
122 AV_CODEC_ID_H263I,
123 AV_CODEC_ID_FLV1,
124 AV_CODEC_ID_SVQ1,
125 AV_CODEC_ID_SVQ3,
126 AV_CODEC_ID_DVVIDEO,
127 AV_CODEC_ID_HUFFYUV,
128 AV_CODEC_ID_CYUV,
129 AV_CODEC_ID_H264,
130 AV_CODEC_ID_INDEO3,
131 AV_CODEC_ID_VP3,
132 AV_CODEC_ID_THEORA,
133 AV_CODEC_ID_ASV1,
134 AV_CODEC_ID_ASV2,
135 AV_CODEC_ID_FFV1,
136 AV_CODEC_ID_4XM,
137 AV_CODEC_ID_VCR1,
138 AV_CODEC_ID_CLJR,
139 AV_CODEC_ID_MDEC,
140 AV_CODEC_ID_ROQ,
141 AV_CODEC_ID_INTERPLAY_VIDEO,
142 AV_CODEC_ID_XAN_WC3,
143 AV_CODEC_ID_XAN_WC4,
144 AV_CODEC_ID_RPZA,
145 AV_CODEC_ID_CINEPAK,
146 AV_CODEC_ID_WS_VQA,
147 AV_CODEC_ID_MSRLE,
148 AV_CODEC_ID_MSVIDEO1,
149 AV_CODEC_ID_IDCIN,
150 AV_CODEC_ID_8BPS,
151 AV_CODEC_ID_SMC,
152 AV_CODEC_ID_FLIC,
153 AV_CODEC_ID_TRUEMOTION1,
154 AV_CODEC_ID_VMDVIDEO,
155 AV_CODEC_ID_MSZH,
156 AV_CODEC_ID_ZLIB,
157 AV_CODEC_ID_QTRLE,
158 AV_CODEC_ID_TSCC,
159 AV_CODEC_ID_ULTI,
160 AV_CODEC_ID_QDRAW,
161 AV_CODEC_ID_VIXL,
162 AV_CODEC_ID_QPEG,
163 AV_CODEC_ID_PNG,
164 AV_CODEC_ID_PPM,
165 AV_CODEC_ID_PBM,
166 AV_CODEC_ID_PGM,
167 AV_CODEC_ID_PGMYUV,
168 AV_CODEC_ID_PAM,
169 AV_CODEC_ID_FFVHUFF,
170 AV_CODEC_ID_RV30,
171 AV_CODEC_ID_RV40,
172 AV_CODEC_ID_VC1,
173 AV_CODEC_ID_WMV3,
174 AV_CODEC_ID_LOCO,
175 AV_CODEC_ID_WNV1,
176 AV_CODEC_ID_AASC,
177 AV_CODEC_ID_INDEO2,
178 AV_CODEC_ID_FRAPS,
179 AV_CODEC_ID_TRUEMOTION2,
180 AV_CODEC_ID_BMP,
181 AV_CODEC_ID_CSCD,
182 AV_CODEC_ID_MMVIDEO,
183 AV_CODEC_ID_ZMBV,
184 AV_CODEC_ID_AVS,
185 AV_CODEC_ID_SMACKVIDEO,
186 AV_CODEC_ID_NUV,
187 AV_CODEC_ID_KMVC,
188 AV_CODEC_ID_FLASHSV,
189 AV_CODEC_ID_CAVS,
190 AV_CODEC_ID_JPEG2000,
191 AV_CODEC_ID_VMNC,
192 AV_CODEC_ID_VP5,
193 AV_CODEC_ID_VP6,
194 AV_CODEC_ID_VP6F,
195 AV_CODEC_ID_TARGA,
196 AV_CODEC_ID_DSICINVIDEO,
197 AV_CODEC_ID_TIERTEXSEQVIDEO,
198 AV_CODEC_ID_TIFF,
199 AV_CODEC_ID_GIF,
200 AV_CODEC_ID_DXA,
201 AV_CODEC_ID_DNXHD,
202 AV_CODEC_ID_THP,
203 AV_CODEC_ID_SGI,
204 AV_CODEC_ID_C93,
205 AV_CODEC_ID_BETHSOFTVID,
206 AV_CODEC_ID_PTX,
207 AV_CODEC_ID_TXD,
208 AV_CODEC_ID_VP6A,
209 AV_CODEC_ID_AMV,
210 AV_CODEC_ID_VB,
211 AV_CODEC_ID_PCX,
212 AV_CODEC_ID_SUNRAST,
213 AV_CODEC_ID_INDEO4,
214 AV_CODEC_ID_INDEO5,
215 AV_CODEC_ID_MIMIC,
216 AV_CODEC_ID_RL2,
217 AV_CODEC_ID_ESCAPE124,
218 AV_CODEC_ID_DIRAC,
219 AV_CODEC_ID_BFI,
220 AV_CODEC_ID_CMV,
221 AV_CODEC_ID_MOTIONPIXELS,
222 AV_CODEC_ID_TGV,
223 AV_CODEC_ID_TGQ,
224 AV_CODEC_ID_TQI,
225 AV_CODEC_ID_AURA,
226 AV_CODEC_ID_AURA2,
227 AV_CODEC_ID_V210X,
228 AV_CODEC_ID_TMV,
229 AV_CODEC_ID_V210,
230 AV_CODEC_ID_DPX,
231 AV_CODEC_ID_MAD,
232 AV_CODEC_ID_FRWU,
233 AV_CODEC_ID_FLASHSV2,
234 AV_CODEC_ID_CDGRAPHICS,
235 AV_CODEC_ID_R210,
236 AV_CODEC_ID_ANM,
237 AV_CODEC_ID_BINKVIDEO,
238 AV_CODEC_ID_IFF_ILBM,
239 AV_CODEC_ID_IFF_BYTERUN1,
240 AV_CODEC_ID_KGV1,
241 AV_CODEC_ID_YOP,
242 AV_CODEC_ID_VP8,
243 AV_CODEC_ID_PICTOR,
244 AV_CODEC_ID_ANSI,
245 AV_CODEC_ID_A64_MULTI,
246 AV_CODEC_ID_A64_MULTI5,
247 AV_CODEC_ID_R10K,
248 AV_CODEC_ID_MXPEG,
249 AV_CODEC_ID_LAGARITH,
250 AV_CODEC_ID_PRORES,
251 AV_CODEC_ID_JV,
252 AV_CODEC_ID_DFA,
253 AV_CODEC_ID_WMV3IMAGE,
254 AV_CODEC_ID_VC1IMAGE,
255 AV_CODEC_ID_UTVIDEO,
256 AV_CODEC_ID_BMV_VIDEO,
257 AV_CODEC_ID_VBLE,
258 AV_CODEC_ID_DXTORY,
259 AV_CODEC_ID_V410,
260 AV_CODEC_ID_XWD,
261 AV_CODEC_ID_CDXL,
262 AV_CODEC_ID_XBM,
263 AV_CODEC_ID_ZEROCODEC,
264 AV_CODEC_ID_MSS1,
265 AV_CODEC_ID_MSA1,
266 AV_CODEC_ID_TSCC2,
267 AV_CODEC_ID_MTS2,
268 AV_CODEC_ID_CLLC,
269 AV_CODEC_ID_MSS2,
270 AV_CODEC_ID_VP9,
271 AV_CODEC_ID_AIC,
272
273 /* various PCM "codecs" */
274 AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
275 AV_CODEC_ID_PCM_S16LE = 0x10000,
276 AV_CODEC_ID_PCM_S16BE,
277 AV_CODEC_ID_PCM_U16LE,
278 AV_CODEC_ID_PCM_U16BE,
279 AV_CODEC_ID_PCM_S8,
280 AV_CODEC_ID_PCM_U8,
281 AV_CODEC_ID_PCM_MULAW,
282 AV_CODEC_ID_PCM_ALAW,
283 AV_CODEC_ID_PCM_S32LE,
284 AV_CODEC_ID_PCM_S32BE,
285 AV_CODEC_ID_PCM_U32LE,
286 AV_CODEC_ID_PCM_U32BE,
287 AV_CODEC_ID_PCM_S24LE,
288 AV_CODEC_ID_PCM_S24BE,
289 AV_CODEC_ID_PCM_U24LE,
290 AV_CODEC_ID_PCM_U24BE,
291 AV_CODEC_ID_PCM_S24DAUD,
292 AV_CODEC_ID_PCM_ZORK,
293 AV_CODEC_ID_PCM_S16LE_PLANAR,
294 AV_CODEC_ID_PCM_DVD,
295 AV_CODEC_ID_PCM_F32BE,
296 AV_CODEC_ID_PCM_F32LE,
297 AV_CODEC_ID_PCM_F64BE,
298 AV_CODEC_ID_PCM_F64LE,
299 AV_CODEC_ID_PCM_BLURAY,
300 AV_CODEC_ID_PCM_LXF,
301 AV_CODEC_ID_S302M,
302 AV_CODEC_ID_PCM_S8_PLANAR,
303
304 /* various ADPCM codecs */
305 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
306 AV_CODEC_ID_ADPCM_IMA_WAV,
307 AV_CODEC_ID_ADPCM_IMA_DK3,
308 AV_CODEC_ID_ADPCM_IMA_DK4,
309 AV_CODEC_ID_ADPCM_IMA_WS,
310 AV_CODEC_ID_ADPCM_IMA_SMJPEG,
311 AV_CODEC_ID_ADPCM_MS,
312 AV_CODEC_ID_ADPCM_4XM,
313 AV_CODEC_ID_ADPCM_XA,
314 AV_CODEC_ID_ADPCM_ADX,
315 AV_CODEC_ID_ADPCM_EA,
316 AV_CODEC_ID_ADPCM_G726,
317 AV_CODEC_ID_ADPCM_CT,
318 AV_CODEC_ID_ADPCM_SWF,
319 AV_CODEC_ID_ADPCM_YAMAHA,
320 AV_CODEC_ID_ADPCM_SBPRO_4,
321 AV_CODEC_ID_ADPCM_SBPRO_3,
322 AV_CODEC_ID_ADPCM_SBPRO_2,
323 AV_CODEC_ID_ADPCM_THP,
324 AV_CODEC_ID_ADPCM_IMA_AMV,
325 AV_CODEC_ID_ADPCM_EA_R1,
326 AV_CODEC_ID_ADPCM_EA_R3,
327 AV_CODEC_ID_ADPCM_EA_R2,
328 AV_CODEC_ID_ADPCM_IMA_EA_SEAD,
329 AV_CODEC_ID_ADPCM_IMA_EA_EACS,
330 AV_CODEC_ID_ADPCM_EA_XAS,
331 AV_CODEC_ID_ADPCM_EA_MAXIS_XA,
332 AV_CODEC_ID_ADPCM_IMA_ISS,
333 AV_CODEC_ID_ADPCM_G722,
334 AV_CODEC_ID_ADPCM_IMA_APC,
335
336 /* AMR */
337 AV_CODEC_ID_AMR_NB = 0x12000,
338 AV_CODEC_ID_AMR_WB,
339
340 /* RealAudio codecs*/
341 AV_CODEC_ID_RA_144 = 0x13000,
342 AV_CODEC_ID_RA_288,
343
344 /* various DPCM codecs */
345 AV_CODEC_ID_ROQ_DPCM = 0x14000,
346 AV_CODEC_ID_INTERPLAY_DPCM,
347 AV_CODEC_ID_XAN_DPCM,
348 AV_CODEC_ID_SOL_DPCM,
349
350 /* audio codecs */
351 AV_CODEC_ID_MP2 = 0x15000,
352 AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
353 AV_CODEC_ID_AAC,
354 AV_CODEC_ID_AC3,
355 AV_CODEC_ID_DTS,
356 AV_CODEC_ID_VORBIS,
357 AV_CODEC_ID_DVAUDIO,
358 AV_CODEC_ID_WMAV1,
359 AV_CODEC_ID_WMAV2,
360 AV_CODEC_ID_MACE3,
361 AV_CODEC_ID_MACE6,
362 AV_CODEC_ID_VMDAUDIO,
363 AV_CODEC_ID_FLAC,
364 AV_CODEC_ID_MP3ADU,
365 AV_CODEC_ID_MP3ON4,
366 AV_CODEC_ID_SHORTEN,
367 AV_CODEC_ID_ALAC,
368 AV_CODEC_ID_WESTWOOD_SND1,
369 AV_CODEC_ID_GSM, ///< as in Berlin toast format
370 AV_CODEC_ID_QDM2,
371 AV_CODEC_ID_COOK,
372 AV_CODEC_ID_TRUESPEECH,
373 AV_CODEC_ID_TTA,
374 AV_CODEC_ID_SMACKAUDIO,
375 AV_CODEC_ID_QCELP,
376 AV_CODEC_ID_WAVPACK,
377 AV_CODEC_ID_DSICINAUDIO,
378 AV_CODEC_ID_IMC,
379 AV_CODEC_ID_MUSEPACK7,
380 AV_CODEC_ID_MLP,
381 AV_CODEC_ID_GSM_MS, /* as found in WAV */
382 AV_CODEC_ID_ATRAC3,
383 AV_CODEC_ID_VOXWARE,
384 AV_CODEC_ID_APE,
385 AV_CODEC_ID_NELLYMOSER,
386 AV_CODEC_ID_MUSEPACK8,
387 AV_CODEC_ID_SPEEX,
388 AV_CODEC_ID_WMAVOICE,
389 AV_CODEC_ID_WMAPRO,
390 AV_CODEC_ID_WMALOSSLESS,
391 AV_CODEC_ID_ATRAC3P,
392 AV_CODEC_ID_EAC3,
393 AV_CODEC_ID_SIPR,
394 AV_CODEC_ID_MP1,
395 AV_CODEC_ID_TWINVQ,
396 AV_CODEC_ID_TRUEHD,
397 AV_CODEC_ID_MP4ALS,
398 AV_CODEC_ID_ATRAC1,
399 AV_CODEC_ID_BINKAUDIO_RDFT,
400 AV_CODEC_ID_BINKAUDIO_DCT,
401 AV_CODEC_ID_AAC_LATM,
402 AV_CODEC_ID_QDMC,
403 AV_CODEC_ID_CELT,
404 AV_CODEC_ID_G723_1,
405 AV_CODEC_ID_G729,
406 AV_CODEC_ID_8SVX_EXP,
407 AV_CODEC_ID_8SVX_FIB,
408 AV_CODEC_ID_BMV_AUDIO,
409 AV_CODEC_ID_RALF,
410 AV_CODEC_ID_IAC,
411 AV_CODEC_ID_ILBC,
412 AV_CODEC_ID_OPUS,
413 AV_CODEC_ID_COMFORT_NOISE,
414 AV_CODEC_ID_TAK,
415
416 /* subtitle codecs */
417 AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
418 AV_CODEC_ID_DVD_SUBTITLE = 0x17000,
419 AV_CODEC_ID_DVB_SUBTITLE,
420 AV_CODEC_ID_TEXT, ///< raw UTF-8 text
421 AV_CODEC_ID_XSUB,
422 AV_CODEC_ID_SSA,
423 AV_CODEC_ID_MOV_TEXT,
424 AV_CODEC_ID_HDMV_PGS_SUBTITLE,
425 AV_CODEC_ID_DVB_TELETEXT,
426 AV_CODEC_ID_SRT,
427
428 /* other specific kind of codecs (generally used for attachments) */
429 AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
430 AV_CODEC_ID_TTF = 0x18000,
431
432 AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
433
434 AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
435 * stream (only used by libavformat) */
436 AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
437 * stream (only used by libavformat) */
438 AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
439 };
440
441 /**
442 * This struct describes the properties of a single codec described by an
443 * AVCodecID.
444 * @see avcodec_get_descriptor()
445 */
446 typedef struct AVCodecDescriptor {
447 enum AVCodecID id;
448 enum AVMediaType type;
449 /**
450 * Name of the codec described by this descriptor. It is non-empty and
451 * unique for each codec descriptor. It should contain alphanumeric
452 * characters and '_' only.
453 */
454 const char *name;
455 /**
456 * A more descriptive name for this codec. May be NULL.
457 */
458 const char *long_name;
459 /**
460 * Codec properties, a combination of AV_CODEC_PROP_* flags.
461 */
462 int props;
463 } AVCodecDescriptor;
464
465 /**
466 * Codec uses only intra compression.
467 * Video codecs only.
468 */
469 #define AV_CODEC_PROP_INTRA_ONLY (1 << 0)
470 /**
471 * Codec supports lossy compression. Audio and video codecs only.
472 * @note a codec may support both lossy and lossless
473 * compression modes
474 */
475 #define AV_CODEC_PROP_LOSSY (1 << 1)
476 /**
477 * Codec supports lossless compression. Audio and video codecs only.
478 */
479 #define AV_CODEC_PROP_LOSSLESS (1 << 2)
480
481 /**
482 * @ingroup lavc_decoding
483 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
484 * This is mainly needed because some optimized bitstream readers read
485 * 32 or 64 bit at once and could read over the end.<br>
486 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
487 * MPEG bitstreams could cause overread and segfault.
488 */
489 #define FF_INPUT_BUFFER_PADDING_SIZE 8
490
491 /**
492 * @ingroup lavc_encoding
493 * minimum encoding buffer size
494 * Used to avoid some checks during header writing.
495 */
496 #define FF_MIN_BUFFER_SIZE 16384
497
498
499 /**
500 * @ingroup lavc_encoding
501 * motion estimation type.
502 */
503 enum Motion_Est_ID {
504 ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
505 ME_FULL,
506 ME_LOG,
507 ME_PHODS,
508 ME_EPZS, ///< enhanced predictive zonal search
509 ME_X1, ///< reserved for experiments
510 ME_HEX, ///< hexagon based search
511 ME_UMH, ///< uneven multi-hexagon search
512 ME_TESA, ///< transformed exhaustive search algorithm
513 };
514
515 /**
516 * @ingroup lavc_decoding
517 */
518 enum AVDiscard{
519 /* We leave some space between them for extensions (drop some
520 * keyframes for intra-only or drop just some bidir frames). */
521 AVDISCARD_NONE =-16, ///< discard nothing
522 AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi
523 AVDISCARD_NONREF = 8, ///< discard all non reference
524 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
525 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
526 AVDISCARD_ALL = 48, ///< discard all
527 };
528
529 enum AVColorPrimaries{
530 AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
531 AVCOL_PRI_UNSPECIFIED = 2,
532 AVCOL_PRI_BT470M = 4,
533 AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
534 AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
535 AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
536 AVCOL_PRI_FILM = 8,
537 AVCOL_PRI_NB , ///< Not part of ABI
538 };
539
540 enum AVColorTransferCharacteristic{
541 AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
542 AVCOL_TRC_UNSPECIFIED = 2,
543 AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
544 AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
545 AVCOL_TRC_SMPTE240M = 7,
546 AVCOL_TRC_NB , ///< Not part of ABI
547 };
548
549 enum AVColorSpace{
550 AVCOL_SPC_RGB = 0,
551 AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
552 AVCOL_SPC_UNSPECIFIED = 2,
553 AVCOL_SPC_FCC = 4,
554 AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
555 AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
556 AVCOL_SPC_SMPTE240M = 7,
557 AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
558 AVCOL_SPC_NB , ///< Not part of ABI
559 };
560
561 enum AVColorRange{
562 AVCOL_RANGE_UNSPECIFIED = 0,
563 AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
564 AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
565 AVCOL_RANGE_NB , ///< Not part of ABI
566 };
567
568 /**
569 * X X 3 4 X X are luma samples,
570 * 1 2 1-6 are possible chroma positions
571 * X X 5 6 X 0 is undefined/unknown position
572 */
573 enum AVChromaLocation{
574 AVCHROMA_LOC_UNSPECIFIED = 0,
575 AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default
576 AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263
577 AVCHROMA_LOC_TOPLEFT = 3, ///< DV
578 AVCHROMA_LOC_TOP = 4,
579 AVCHROMA_LOC_BOTTOMLEFT = 5,
580 AVCHROMA_LOC_BOTTOM = 6,
581 AVCHROMA_LOC_NB , ///< Not part of ABI
582 };
583
584 enum AVAudioServiceType {
585 AV_AUDIO_SERVICE_TYPE_MAIN = 0,
586 AV_AUDIO_SERVICE_TYPE_EFFECTS = 1,
587 AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2,
588 AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3,
589 AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4,
590 AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5,
591 AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6,
592 AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7,
593 AV_AUDIO_SERVICE_TYPE_KARAOKE = 8,
594 AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI
595 };
596
597 /**
598 * @ingroup lavc_encoding
599 */
600 typedef struct RcOverride{
601 int start_frame;
602 int end_frame;
603 int qscale; // If this is 0 then quality_factor will be used instead.
604 float quality_factor;
605 } RcOverride;
606
607 #define FF_MAX_B_FRAMES 16
608
609 /* encoding support
610 These flags can be passed in AVCodecContext.flags before initialization.
611 Note: Not everything is supported yet.
612 */
613
614 /**
615 * Allow decoders to produce frames with data planes that are not aligned
616 * to CPU requirements (e.g. due to cropping).
617 */
618 #define CODEC_FLAG_UNALIGNED 0x0001
619 #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale.
620 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263.
621 #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC.
622 #define CODEC_FLAG_GMC 0x0020 ///< Use GMC.
623 #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>.
624 /**
625 * The parent program guarantees that the input for B-frames containing
626 * streams is not written to for at least s->max_b_frames+1 frames, if
627 * this is not set the input will be copied.
628 */
629 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
630 #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode.
631 #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode.
632 #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale.
633 #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges.
634 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding.
635 #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random
636 location instead of only at frame boundaries. */
637 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization.
638 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT.
639 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay.
640 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe.
641 #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT).
642 /* Fx : Flag for h263+ extra options */
643 #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction
644 #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
645 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
646 #define CODEC_FLAG_CLOSED_GOP 0x80000000
647 #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks.
648 #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding.
649 #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata.
650 #define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS.
651
652 #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
653
654 /* Unsupported options :
655 * Syntax Arithmetic coding (SAC)
656 * Reference Picture Selection
657 * Independent Segment Decoding */
658 /* /Fx */
659 /* codec capabilities */
660
661 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback.
662 /**
663 * Codec uses get_buffer() for allocating buffers and supports custom allocators.
664 * If not set, it might not use get_buffer() at all or use operations that
665 * assume the buffer was allocated by avcodec_default_get_buffer.
666 */
667 #define CODEC_CAP_DR1 0x0002
668 #define CODEC_CAP_TRUNCATED 0x0008
669 /* Codec can export data for HW decoding (XvMC). */
670 #define CODEC_CAP_HWACCEL 0x0010
671 /**
672 * Encoder or decoder requires flushing with NULL input at the end in order to
673 * give the complete and correct output.
674 *
675 * NOTE: If this flag is not set, the codec is guaranteed to never be fed with
676 * with NULL data. The user can still send NULL data to the public encode
677 * or decode function, but libavcodec will not pass it along to the codec
678 * unless this flag is set.
679 *
680 * Decoders:
681 * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
682 * avpkt->size=0 at the end to get the delayed data until the decoder no longer
683 * returns frames.
684 *
685 * Encoders:
686 * The encoder needs to be fed with NULL data at the end of encoding until the
687 * encoder no longer returns data.
688 *
689 * NOTE: For encoders implementing the AVCodec.encode2() function, setting this
690 * flag also means that the encoder must set the pts and duration for
691 * each output packet. If this flag is not set, the pts and duration will
692 * be determined by libavcodec from the input frame.
693 */
694 #define CODEC_CAP_DELAY 0x0020
695 /**
696 * Codec can be fed a final frame with a smaller size.
697 * This can be used to prevent truncation of the last audio samples.
698 */
699 #define CODEC_CAP_SMALL_LAST_FRAME 0x0040
700 /**
701 * Codec can export data for HW decoding (VDPAU).
702 */
703 #define CODEC_CAP_HWACCEL_VDPAU 0x0080
704 /**
705 * Codec can output multiple frames per AVPacket
706 * Normally demuxers return one frame at a time, demuxers which do not do
707 * are connected to a parser to split what they return into proper frames.
708 * This flag is reserved to the very rare category of codecs which have a
709 * bitstream that cannot be split into frames without timeconsuming
710 * operations like full decoding. Demuxers carring such bitstreams thus
711 * may return multiple frames in a packet. This has many disadvantages like
712 * prohibiting stream copy in many cases thus it should only be considered
713 * as a last resort.
714 */
715 #define CODEC_CAP_SUBFRAMES 0x0100
716 /**
717 * Codec is experimental and is thus avoided in favor of non experimental
718 * encoders
719 */
720 #define CODEC_CAP_EXPERIMENTAL 0x0200
721 /**
722 * Codec should fill in channel configuration and samplerate instead of container
723 */
724 #define CODEC_CAP_CHANNEL_CONF 0x0400
725 /**
726 * Codec is able to deal with negative linesizes
727 */
728 #define CODEC_CAP_NEG_LINESIZES 0x0800
729 /**
730 * Codec supports frame-level multithreading.
731 */
732 #define CODEC_CAP_FRAME_THREADS 0x1000
733 /**
734 * Codec supports slice-based (or partition-based) multithreading.
735 */
736 #define CODEC_CAP_SLICE_THREADS 0x2000
737 /**
738 * Codec supports changed parameters at any point.
739 */
740 #define CODEC_CAP_PARAM_CHANGE 0x4000
741 /**
742 * Codec supports avctx->thread_count == 0 (auto).
743 */
744 #define CODEC_CAP_AUTO_THREADS 0x8000
745 /**
746 * Audio encoder supports receiving a different number of samples in each call.
747 */
748 #define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000
749
750 //The following defines may change, don't expect compatibility if you use them.
751 #define MB_TYPE_INTRA4x4 0x0001
752 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
753 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
754 #define MB_TYPE_16x16 0x0008
755 #define MB_TYPE_16x8 0x0010
756 #define MB_TYPE_8x16 0x0020
757 #define MB_TYPE_8x8 0x0040
758 #define MB_TYPE_INTERLACED 0x0080
759 #define MB_TYPE_DIRECT2 0x0100 //FIXME
760 #define MB_TYPE_ACPRED 0x0200
761 #define MB_TYPE_GMC 0x0400
762 #define MB_TYPE_SKIP 0x0800
763 #define MB_TYPE_P0L0 0x1000
764 #define MB_TYPE_P1L0 0x2000
765 #define MB_TYPE_P0L1 0x4000
766 #define MB_TYPE_P1L1 0x8000
767 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
768 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
769 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
770 #define MB_TYPE_QUANT 0x00010000
771 #define MB_TYPE_CBP 0x00020000
772 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
773
774 /**
775 * Pan Scan area.
776 * This specifies the area which should be displayed.
777 * Note there may be multiple such areas for one frame.
778 */
779 typedef struct AVPanScan{
780 /**
781 * id
782 * - encoding: Set by user.
783 * - decoding: Set by libavcodec.
784 */
785 int id;
786
787 /**
788 * width and height in 1/16 pel
789 * - encoding: Set by user.
790 * - decoding: Set by libavcodec.
791 */
792 int width;
793 int height;
794
795 /**
796 * position of the top left corner in 1/16 pel for up to 3 fields/frames
797 * - encoding: Set by user.
798 * - decoding: Set by libavcodec.
799 */
800 int16_t position[3][2];
801 }AVPanScan;
802
803 #define FF_QSCALE_TYPE_MPEG1 0
804 #define FF_QSCALE_TYPE_MPEG2 1
805 #define FF_QSCALE_TYPE_H264 2
806 #define FF_QSCALE_TYPE_VP56 3
807
808 #if FF_API_GET_BUFFER
809 #define FF_BUFFER_TYPE_INTERNAL 1
810 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
811 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
812 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
813
814 #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore).
815 #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer.
816 #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
817 #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
818 #endif
819
820 /**
821 * The decoder will keep a reference to the frame and may reuse it later.
822 */
823 #define AV_GET_BUFFER_FLAG_REF (1 << 0)
824
825 /**
826 * @defgroup lavc_packet AVPacket
827 *
828 * Types and functions for working with AVPacket.
829 * @{
830 */
831 enum AVPacketSideDataType {
832 AV_PKT_DATA_PALETTE,
833 AV_PKT_DATA_NEW_EXTRADATA,
834
835 /**
836 * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
837 * @code
838 * u32le param_flags
839 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
840 * s32le channel_count
841 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
842 * u64le channel_layout
843 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
844 * s32le sample_rate
845 * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
846 * s32le width
847 * s32le height
848 * @endcode
849 */
850 AV_PKT_DATA_PARAM_CHANGE,
851
852 /**
853 * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of
854 * structures with info about macroblocks relevant to splitting the
855 * packet into smaller packets on macroblock edges (e.g. as for RFC 2190).
856 * That is, it does not necessarily contain info about all macroblocks,
857 * as long as the distance between macroblocks in the info is smaller
858 * than the target payload size.
859 * Each MB info structure is 12 bytes, and is laid out as follows:
860 * @code
861 * u32le bit offset from the start of the packet
862 * u8 current quantizer at the start of the macroblock
863 * u8 GOB number
864 * u16le macroblock address within the GOB
865 * u8 horizontal MV predictor
866 * u8 vertical MV predictor
867 * u8 horizontal MV predictor for block number 3
868 * u8 vertical MV predictor for block number 3
869 * @endcode
870 */
871 AV_PKT_DATA_H263_MB_INFO,
872 };
873
874 /**
875 * This structure stores compressed data. It is typically exported by demuxers
876 * and then passed as input to decoders, or received as output from encoders and
877 * then passed to muxers.
878 *
879 * For video, it should typically contain one compressed frame. For audio it may
880 * contain several compressed frames.
881 *
882 * AVPacket is one of the few structs in Libav, whose size is a part of public
883 * ABI. Thus it may be allocated on stack and no new fields can be added to it
884 * without libavcodec and libavformat major bump.
885 *
886 * The semantics of data ownership depends on the buf or destruct (deprecated)
887 * fields. If either is set, the packet data is dynamically allocated and is
888 * valid indefinitely until av_free_packet() is called (which in turn calls
889 * av_buffer_unref()/the destruct callback to free the data). If neither is set,
890 * the packet data is typically backed by some static buffer somewhere and is
891 * only valid for a limited time (e.g. until the next read call when demuxing).
892 *
893 * The side data is always allocated with av_malloc() and is freed in
894 * av_free_packet().
895 */
896 typedef struct AVPacket {
897 /**
898 * A reference to the reference-counted buffer where the packet data is
899 * stored.
900 * May be NULL, then the packet data is not reference-counted.
901 */
902 AVBufferRef *buf;
903 /**
904 * Presentation timestamp in AVStream->time_base units; the time at which
905 * the decompressed packet will be presented to the user.
906 * Can be AV_NOPTS_VALUE if it is not stored in the file.
907 * pts MUST be larger or equal to dts as presentation cannot happen before
908 * decompression, unless one wants to view hex dumps. Some formats misuse
909 * the terms dts and pts/cts to mean something different. Such timestamps
910 * must be converted to true pts/dts before they are stored in AVPacket.
911 */
912 int64_t pts;
913 /**
914 * Decompression timestamp in AVStream->time_base units; the time at which
915 * the packet is decompressed.
916 * Can be AV_NOPTS_VALUE if it is not stored in the file.
917 */
918 int64_t dts;
919 uint8_t *data;
920 int size;
921 int stream_index;
922 /**
923 * A combination of AV_PKT_FLAG values
924 */
925 int flags;
926 /**
927 * Additional packet data that can be provided by the container.
928 * Packet can contain several types of side information.
929 */
930 struct {
931 uint8_t *data;
932 int size;
933 enum AVPacketSideDataType type;
934 } *side_data;
935 int side_data_elems;
936
937 /**
938 * Duration of this packet in AVStream->time_base units, 0 if unknown.
939 * Equals next_pts - this_pts in presentation order.
940 */
941 int duration;
942 #if FF_API_DESTRUCT_PACKET
943 attribute_deprecated
944 void (*destruct)(struct AVPacket *);
945 attribute_deprecated
946 void *priv;
947 #endif
948 int64_t pos; ///< byte position in stream, -1 if unknown
949
950 /**
951 * Time difference in AVStream->time_base units from the pts of this
952 * packet to the point at which the output from the decoder has converged
953 * independent from the availability of previous frames. That is, the
954 * frames are virtually identical no matter if decoding started from
955 * the very first frame or from this keyframe.
956 * Is AV_NOPTS_VALUE if unknown.
957 * This field is not the display duration of the current packet.
958 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
959 * set.
960 *
961 * The purpose of this field is to allow seeking in streams that have no
962 * keyframes in the conventional sense. It corresponds to the
963 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
964 * essential for some types of subtitle streams to ensure that all
965 * subtitles are correctly displayed after seeking.
966 */
967 int64_t convergence_duration;
968 } AVPacket;
969 #define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
970 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
971
972 enum AVSideDataParamChangeFlags {
973 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
974 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
975 AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004,
976 AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008,
977 };
978 /**
979 * @}
980 */
981
982 struct AVCodecInternal;
983
984 enum AVFieldOrder {
985 AV_FIELD_UNKNOWN,
986 AV_FIELD_PROGRESSIVE,
987 AV_FIELD_TT, //< Top coded_first, top displayed first
988 AV_FIELD_BB, //< Bottom coded first, bottom displayed first
989 AV_FIELD_TB, //< Top coded first, bottom displayed first
990 AV_FIELD_BT, //< Bottom coded first, top displayed first
991 };
992
993 /**
994 * main external API structure.
995 * New fields can be added to the end with minor version bumps.
996 * Removal, reordering and changes to existing fields require a major
997 * version bump.
998 * sizeof(AVCodecContext) must not be used outside libav*.
999 */
1000 typedef struct AVCodecContext {
1001 /**
1002 * information on struct for av_log
1003 * - set by avcodec_alloc_context3
1004 */
1005 const AVClass *av_class;
1006 int log_level_offset;
1007
1008 enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */
1009 const struct AVCodec *codec;
1010 char codec_name[32];
1011 enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
1012
1013 /**
1014 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1015 * This is used to work around some encoder bugs.
1016 * A demuxer should set this to what is stored in the field used to identify the codec.
1017 * If there are multiple such fields in a container then the demuxer should choose the one
1018 * which maximizes the information about the used codec.
1019 * If the codec tag field in a container is larger than 32 bits then the demuxer should
1020 * remap the longer ID to 32 bits with a table or other structure. Alternatively a new
1021 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
1022 * first.
1023 * - encoding: Set by user, if not then the default based on codec_id will be used.
1024 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1025 */
1026 unsigned int codec_tag;
1027
1028 /**
1029 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1030 * This is used to work around some encoder bugs.
1031 * - encoding: unused
1032 * - decoding: Set by user, will be converted to uppercase by libavcodec during init.
1033 */
1034 unsigned int stream_codec_tag;
1035
1036 void *priv_data;
1037
1038 /**
1039 * Private context used for internal data.
1040 *
1041 * Unlike priv_data, this is not codec-specific. It is used in general
1042 * libavcodec functions.
1043 */
1044 struct AVCodecInternal *internal;
1045
1046 /**
1047 * Private data of the user, can be used to carry app specific stuff.
1048 * - encoding: Set by user.
1049 * - decoding: Set by user.
1050 */
1051 void *opaque;
1052
1053 /**
1054 * the average bitrate
1055 * - encoding: Set by user; unused for constant quantizer encoding.
1056 * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream.
1057 */
1058 int bit_rate;
1059
1060 /**
1061 * number of bits the bitstream is allowed to diverge from the reference.
1062 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
1063 * - encoding: Set by user; unused for constant quantizer encoding.
1064 * - decoding: unused
1065 */
1066 int bit_rate_tolerance;
1067
1068 /**
1069 * Global quality for codecs which cannot change it per frame.
1070 * This should be proportional to MPEG-1/2/4 qscale.
1071 * - encoding: Set by user.
1072 * - decoding: unused
1073 */
1074 int global_quality;
1075
1076 /**
1077 * - encoding: Set by user.
1078 * - decoding: unused
1079 */
1080 int compression_level;
1081 #define FF_COMPRESSION_DEFAULT -1
1082
1083 /**
1084 * CODEC_FLAG_*.
1085 * - encoding: Set by user.
1086 * - decoding: Set by user.
1087 */
1088 int flags;
1089
1090 /**
1091 * CODEC_FLAG2_*
1092 * - encoding: Set by user.
1093 * - decoding: Set by user.
1094 */
1095 int flags2;
1096
1097 /**
1098 * some codecs need / can use extradata like Huffman tables.
1099 * mjpeg: Huffman tables
1100 * rv10: additional flags
1101 * mpeg4: global headers (they can be in the bitstream or here)
1102 * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
1103 * than extradata_size to avoid prolems if it is read with the bitstream reader.
1104 * The bytewise contents of extradata must not depend on the architecture or CPU endianness.
1105 * - encoding: Set/allocated/freed by libavcodec.
1106 * - decoding: Set/allocated/freed by user.
1107 */
1108 uint8_t *extradata;
1109 int extradata_size;
1110
1111 /**
1112 * This is the fundamental unit of time (in seconds) in terms
1113 * of which frame timestamps are represented. For fixed-fps content,
1114 * timebase should be 1/framerate and timestamp increments should be
1115 * identically 1.
1116 * - encoding: MUST be set by user.
1117 * - decoding: Set by libavcodec.
1118 */
1119 AVRational time_base;
1120
1121 /**
1122 * For some codecs, the time base is closer to the field rate than the frame rate.
1123 * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration
1124 * if no telecine is used ...
1125 *
1126 * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2.
1127 */
1128 int ticks_per_frame;
1129
1130 /**
1131 * Codec delay.
1132 *
1133 * Video:
1134 * Number of frames the decoded output will be delayed relative to the
1135 * encoded input.
1136 *
1137 * Audio:
1138 * For encoding, this is the number of "priming" samples added to the
1139 * beginning of the stream. The decoded output will be delayed by this
1140 * many samples relative to the input to the encoder. Note that this
1141 * field is purely informational and does not directly affect the pts
1142 * output by the encoder, which should always be based on the actual
1143 * presentation time, including any delay.
1144 * For decoding, this is the number of samples the decoder needs to
1145 * output before the decoder's output is valid. When seeking, you should
1146 * start decoding this many samples prior to your desired seek point.
1147 *
1148 * - encoding: Set by libavcodec.
1149 * - decoding: Set by libavcodec.
1150 */
1151 int delay;
1152
1153
1154 /* video only */
1155 /**
1156 * picture width / height.
1157 * - encoding: MUST be set by user.
1158 * - decoding: May be set by the user before opening the decoder if known e.g.
1159 * from the container. Some decoders will require the dimensions
1160 * to be set by the caller. During decoding, the decoder may
1161 * overwrite those values as required.
1162 */
1163 int width, height;
1164
1165 /**
1166 * Bitstream width / height, may be different from width/height e.g. when
1167 * the decoded frame is cropped before being output.
1168 * - encoding: unused
1169 * - decoding: May be set by the user before opening the decoder if known
1170 * e.g. from the container. During decoding, the decoder may
1171 * overwrite those values as required.
1172 */
1173 int coded_width, coded_height;
1174
1175 #define FF_ASPECT_EXTENDED 15
1176
1177 /**
1178 * the number of pictures in a group of pictures, or 0 for intra_only
1179 * - encoding: Set by user.
1180 * - decoding: unused
1181 */
1182 int gop_size;
1183
1184 /**
1185 * Pixel format, see AV_PIX_FMT_xxx.
1186 * May be set by the demuxer if known from headers.
1187 * May be overriden by the decoder if it knows better.
1188 * - encoding: Set by user.
1189 * - decoding: Set by user if known, overridden by libavcodec if known
1190 */
1191 enum AVPixelFormat pix_fmt;
1192
1193 /**
1194 * Motion estimation algorithm used for video coding.
1195 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
1196 * 8 (umh), 10 (tesa) [7, 8, 10 are x264 specific]
1197 * - encoding: MUST be set by user.
1198 * - decoding: unused
1199 */
1200 int me_method;
1201
1202 /**
1203 * If non NULL, 'draw_horiz_band' is called by the libavcodec
1204 * decoder to draw a horizontal band. It improves cache usage. Not
1205 * all codecs can do that. You must check the codec capabilities
1206 * beforehand.
1207 * When multithreading is used, it may be called from multiple threads
1208 * at the same time; threads might draw different parts of the same AVFrame,
1209 * or multiple AVFrames, and there is no guarantee that slices will be drawn
1210 * in order.
1211 * The function is also used by hardware acceleration APIs.
1212 * It is called at least once during frame decoding to pass
1213 * the data needed for hardware render.
1214 * In that mode instead of pixel data, AVFrame points to
1215 * a structure specific to the acceleration API. The application
1216 * reads the structure and can change some fields to indicate progress
1217 * or mark state.
1218 * - encoding: unused
1219 * - decoding: Set by user.
1220 * @param height the height of the slice
1221 * @param y the y position of the slice
1222 * @param type 1->top field, 2->bottom field, 3->frame
1223 * @param offset offset into the AVFrame.data from which the slice should be read
1224 */
1225 void (*draw_horiz_band)(struct AVCodecContext *s,
1226 const AVFrame *src, int offset[AV_NUM_DATA_POINTERS],
1227 int y, int type, int height);
1228
1229 /**
1230 * callback to negotiate the pixelFormat
1231 * @param fmt is the list of formats which are supported by the codec,
1232 * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality.
1233 * The first is always the native one.
1234 * @return the chosen format
1235 * - encoding: unused
1236 * - decoding: Set by user, if not set the native format will be chosen.
1237 */
1238 enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt);
1239
1240 /**
1241 * maximum number of B-frames between non-B-frames
1242 * Note: The output will be delayed by max_b_frames+1 relative to the input.
1243 * - encoding: Set by user.
1244 * - decoding: unused
1245 */
1246 int max_b_frames;
1247
1248 /**
1249 * qscale factor between IP and B-frames
1250 * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset).
1251 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1252 * - encoding: Set by user.
1253 * - decoding: unused
1254 */
1255 float b_quant_factor;
1256
1257 /** obsolete FIXME remove */
1258 int rc_strategy;
1259 #define FF_RC_STRATEGY_XVID 1
1260
1261 int b_frame_strategy;
1262
1263 /**
1264 * qscale offset between IP and B-frames
1265 * - encoding: Set by user.
1266 * - decoding: unused
1267 */
1268 float b_quant_offset;
1269
1270 /**
1271 * Size of the frame reordering buffer in the decoder.
1272 * For MPEG-2 it is 1 IPB or 0 low delay IP.
1273 * - encoding: Set by libavcodec.
1274 * - decoding: Set by libavcodec.
1275 */
1276 int has_b_frames;
1277
1278 /**
1279 * 0-> h263 quant 1-> mpeg quant
1280 * - encoding: Set by user.
1281 * - decoding: unused
1282 */
1283 int mpeg_quant;
1284
1285 /**
1286 * qscale factor between P and I-frames
1287 * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset).
1288 * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset).
1289 * - encoding: Set by user.
1290 * - decoding: unused
1291 */
1292 float i_quant_factor;
1293
1294 /**
1295 * qscale offset between P and I-frames
1296 * - encoding: Set by user.
1297 * - decoding: unused
1298 */
1299 float i_quant_offset;
1300
1301 /**
1302 * luminance masking (0-> disabled)
1303 * - encoding: Set by user.
1304 * - decoding: unused
1305 */
1306 float lumi_masking;
1307
1308 /**
1309 * temporary complexity masking (0-> disabled)
1310 * - encoding: Set by user.
1311 * - decoding: unused
1312 */
1313 float temporal_cplx_masking;
1314
1315 /**
1316 * spatial complexity masking (0-> disabled)
1317 * - encoding: Set by user.
1318 * - decoding: unused
1319 */
1320 float spatial_cplx_masking;
1321
1322 /**
1323 * p block masking (0-> disabled)
1324 * - encoding: Set by user.
1325 * - decoding: unused
1326 */
1327 float p_masking;
1328
1329 /**
1330 * darkness masking (0-> disabled)
1331 * - encoding: Set by user.
1332 * - decoding: unused
1333 */
1334 float dark_masking;
1335
1336 /**
1337 * slice count
1338 * - encoding: Set by libavcodec.
1339 * - decoding: Set by user (or 0).
1340 */
1341 int slice_count;
1342 /**
1343 * prediction method (needed for huffyuv)
1344 * - encoding: Set by user.
1345 * - decoding: unused
1346 */
1347 int prediction_method;
1348 #define FF_PRED_LEFT 0
1349 #define FF_PRED_PLANE 1
1350 #define FF_PRED_MEDIAN 2
1351
1352 /**
1353 * slice offsets in the frame in bytes
1354 * - encoding: Set/allocated by libavcodec.
1355 * - decoding: Set/allocated by user (or NULL).
1356 */
1357 int *slice_offset;
1358
1359 /**
1360 * sample aspect ratio (0 if unknown)
1361 * That is the width of a pixel divided by the height of the pixel.
1362 * Numerator and denominator must be relatively prime and smaller than 256 for some video standards.
1363 * - encoding: Set by user.
1364 * - decoding: Set by libavcodec.
1365 */
1366 AVRational sample_aspect_ratio;
1367
1368 /**
1369 * motion estimation comparison function
1370 * - encoding: Set by user.
1371 * - decoding: unused
1372 */
1373 int me_cmp;
1374 /**
1375 * subpixel motion estimation comparison function
1376 * - encoding: Set by user.
1377 * - decoding: unused
1378 */
1379 int me_sub_cmp;
1380 /**
1381 * macroblock comparison function (not supported yet)
1382 * - encoding: Set by user.
1383 * - decoding: unused
1384 */
1385 int mb_cmp;
1386 /**
1387 * interlaced DCT comparison function
1388 * - encoding: Set by user.
1389 * - decoding: unused
1390 */
1391 int ildct_cmp;
1392 #define FF_CMP_SAD 0
1393 #define FF_CMP_SSE 1
1394 #define FF_CMP_SATD 2
1395 #define FF_CMP_DCT 3
1396 #define FF_CMP_PSNR 4
1397 #define FF_CMP_BIT 5
1398 #define FF_CMP_RD 6
1399 #define FF_CMP_ZERO 7
1400 #define FF_CMP_VSAD 8
1401 #define FF_CMP_VSSE 9
1402 #define FF_CMP_NSSE 10
1403 #define FF_CMP_DCTMAX 13
1404 #define FF_CMP_DCT264 14
1405 #define FF_CMP_CHROMA 256
1406
1407 /**
1408 * ME diamond size & shape
1409 * - encoding: Set by user.
1410 * - decoding: unused
1411 */
1412 int dia_size;
1413
1414 /**
1415 * amount of previous MV predictors (2a+1 x 2a+1 square)
1416 * - encoding: Set by user.
1417 * - decoding: unused
1418 */
1419 int last_predictor_count;
1420
1421 /**
1422 * prepass for motion estimation
1423 * - encoding: Set by user.
1424 * - decoding: unused
1425 */
1426 int pre_me;
1427
1428 /**
1429 * motion estimation prepass comparison function
1430 * - encoding: Set by user.
1431 * - decoding: unused
1432 */
1433 int me_pre_cmp;
1434
1435 /**
1436 * ME prepass diamond size & shape
1437 * - encoding: Set by user.
1438 * - decoding: unused
1439 */
1440 int pre_dia_size;
1441
1442 /**
1443 * subpel ME quality
1444 * - encoding: Set by user.
1445 * - decoding: unused
1446 */
1447 int me_subpel_quality;
1448
1449 /**
1450 * DTG active format information (additional aspect ratio
1451 * information only used in DVB MPEG-2 transport streams)
1452 * 0 if not set.
1453 *
1454 * - encoding: unused
1455 * - decoding: Set by decoder.
1456 */
1457 int dtg_active_format;
1458 #define FF_DTG_AFD_SAME 8
1459 #define FF_DTG_AFD_4_3 9
1460 #define FF_DTG_AFD_16_9 10
1461 #define FF_DTG_AFD_14_9 11
1462 #define FF_DTG_AFD_4_3_SP_14_9 13
1463 #define FF_DTG_AFD_16_9_SP_14_9 14
1464 #define FF_DTG_AFD_SP_4_3 15
1465
1466 /**
1467 * maximum motion estimation search range in subpel units
1468 * If 0 then no limit.
1469 *
1470 * - encoding: Set by user.
1471 * - decoding: unused
1472 */
1473 int me_range;
1474
1475 /**
1476 * intra quantizer bias
1477 * - encoding: Set by user.
1478 * - decoding: unused
1479 */
1480 int intra_quant_bias;
1481 #define FF_DEFAULT_QUANT_BIAS 999999
1482
1483 /**
1484 * inter quantizer bias
1485 * - encoding: Set by user.
1486 * - decoding: unused
1487 */
1488 int inter_quant_bias;
1489
1490 /**
1491 * slice flags
1492 * - encoding: unused
1493 * - decoding: Set by user.
1494 */
1495 int slice_flags;
1496 #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1497 #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1498 #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1499
1500 /**
1501 * XVideo Motion Acceleration
1502 * - encoding: forbidden
1503 * - decoding: set by decoder
1504 */
1505 int xvmc_acceleration;
1506
1507 /**
1508 * macroblock decision mode
1509 * - encoding: Set by user.
1510 * - decoding: unused
1511 */
1512 int mb_decision;
1513 #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1514 #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1515 #define FF_MB_DECISION_RD 2 ///< rate distortion
1516
1517 /**
1518 * custom intra quantization matrix
1519 * - encoding: Set by user, can be NULL.
1520 * - decoding: Set by libavcodec.
1521 */
1522 uint16_t *intra_matrix;
1523
1524 /**
1525 * custom inter quantization matrix
1526 * - encoding: Set by user, can be NULL.
1527 * - decoding: Set by libavcodec.
1528 */
1529 uint16_t *inter_matrix;
1530
1531 /**
1532 * scene change detection threshold
1533 * 0 is default, larger means fewer detected scene changes.
1534 * - encoding: Set by user.
1535 * - decoding: unused
1536 */
1537 int scenechange_threshold;
1538
1539 /**
1540 * noise reduction strength
1541 * - encoding: Set by user.
1542 * - decoding: unused
1543 */
1544 int noise_reduction;
1545
1546 /**
1547 * Motion estimation threshold below which no motion estimation is
1548 * performed, but instead the user specified motion vectors are used.
1549 *
1550 * - encoding: Set by user.
1551 * - decoding: unused
1552 */
1553 int me_threshold;
1554
1555 /**
1556 * Macroblock threshold below which the user specified macroblock types will be used.
1557 * - encoding: Set by user.
1558 * - decoding: unused
1559 */
1560 int mb_threshold;
1561
1562 /**
1563 * precision of the intra DC coefficient - 8
1564 * - encoding: Set by user.
1565 * - decoding: unused
1566 */
1567 int intra_dc_precision;
1568
1569 /**
1570 * Number of macroblock rows at the top which are skipped.
1571 * - encoding: unused
1572 * - decoding: Set by user.
1573 */
1574 int skip_top;
1575
1576 /**
1577 * Number of macroblock rows at the bottom which are skipped.
1578 * - encoding: unused
1579 * - decoding: Set by user.
1580 */
1581 int skip_bottom;
1582
1583 /**
1584 * Border processing masking, raises the quantizer for mbs on the borders
1585 * of the picture.
1586 * - encoding: Set by user.
1587 * - decoding: unused
1588 */
1589 float border_masking;
1590
1591 /**
1592 * minimum MB lagrange multipler
1593 * - encoding: Set by user.
1594 * - decoding: unused
1595 */
1596 int mb_lmin;
1597
1598 /**
1599 * maximum MB lagrange multipler
1600 * - encoding: Set by user.
1601 * - decoding: unused
1602 */
1603 int mb_lmax;
1604
1605 /**
1606 *
1607 * - encoding: Set by user.
1608 * - decoding: unused
1609 */
1610 int me_penalty_compensation;
1611
1612 /**
1613 *
1614 * - encoding: Set by user.
1615 * - decoding: unused
1616 */
1617 int bidir_refine;
1618
1619 /**
1620 *
1621 * - encoding: Set by user.
1622 * - decoding: unused
1623 */
1624 int brd_scale;
1625
1626 /**
1627 * minimum GOP size
1628 * - encoding: Set by user.
1629 * - decoding: unused
1630 */
1631 int keyint_min;
1632
1633 /**
1634 * number of reference frames
1635 * - encoding: Set by user.
1636 * - decoding: Set by lavc.
1637 */
1638 int refs;
1639
1640 /**
1641 * chroma qp offset from luma
1642 * - encoding: Set by user.
1643 * - decoding: unused
1644 */
1645 int chromaoffset;
1646
1647 /**
1648 * Multiplied by qscale for each frame and added to scene_change_score.
1649 * - encoding: Set by user.
1650 * - decoding: unused
1651 */
1652 int scenechange_factor;
1653
1654 /**
1655 *
1656 * Note: Value depends upon the compare function used for fullpel ME.
1657 * - encoding: Set by user.
1658 * - decoding: unused
1659 */
1660 int mv0_threshold;
1661
1662 /**
1663 * Adjust sensitivity of b_frame_strategy 1.
1664 * - encoding: Set by user.
1665 * - decoding: unused
1666 */
1667 int b_sensitivity;
1668
1669 /**
1670 * Chromaticity coordinates of the source primaries.
1671 * - encoding: Set by user
1672 * - decoding: Set by libavcodec
1673 */
1674 enum AVColorPrimaries color_primaries;
1675
1676 /**
1677 * Color Transfer Characteristic.
1678 * - encoding: Set by user
1679 * - decoding: Set by libavcodec
1680 */
1681 enum AVColorTransferCharacteristic color_trc;
1682
1683 /**
1684 * YUV colorspace type.
1685 * - encoding: Set by user
1686 * - decoding: Set by libavcodec
1687 */
1688 enum AVColorSpace colorspace;
1689
1690 /**
1691 * MPEG vs JPEG YUV range.
1692 * - encoding: Set by user
1693 * - decoding: Set by libavcodec
1694 */
1695 enum AVColorRange color_range;
1696
1697 /**
1698 * This defines the location of chroma samples.
1699 * - encoding: Set by user
1700 * - decoding: Set by libavcodec
1701 */
1702 enum AVChromaLocation chroma_sample_location;
1703
1704 /**
1705 * Number of slices.
1706 * Indicates number of picture subdivisions. Used for parallelized
1707 * decoding.
1708 * - encoding: Set by user
1709 * - decoding: unused
1710 */
1711 int slices;
1712
1713 /** Field order
1714 * - encoding: set by libavcodec
1715 * - decoding: Set by libavcodec
1716 */
1717 enum AVFieldOrder field_order;
1718
1719 /* audio only */
1720 int sample_rate; ///< samples per second
1721 int channels; ///< number of audio channels
1722
1723 /**
1724 * audio sample format
1725 * - encoding: Set by user.
1726 * - decoding: Set by libavcodec.
1727 */
1728 enum AVSampleFormat sample_fmt; ///< sample format
1729
1730 /* The following data should not be initialized. */
1731 /**
1732 * Number of samples per channel in an audio frame.
1733 *
1734 * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
1735 * except the last must contain exactly frame_size samples per channel.
1736 * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
1737 * frame size is not restricted.
1738 * - decoding: may be set by some decoders to indicate constant frame size
1739 */
1740 int frame_size;
1741
1742 /**
1743 * Frame counter, set by libavcodec.
1744 *
1745 * - decoding: total number of frames returned from the decoder so far.
1746 * - encoding: total number of frames passed to the encoder so far.
1747 *
1748 * @note the counter is not incremented if encoding/decoding resulted in
1749 * an error.
1750 */
1751 int frame_number;
1752
1753 /**
1754 * number of bytes per packet if constant and known or 0
1755 * Used by some WAV based audio codecs.
1756 */
1757 int block_align;
1758
1759 /**
1760 * Audio cutoff bandwidth (0 means "automatic")
1761 * - encoding: Set by user.
1762 * - decoding: unused
1763 */
1764 int cutoff;
1765
1766 #if FF_API_REQUEST_CHANNELS
1767 /**
1768 * Decoder should decode to this many channels if it can (0 for default)
1769 * - encoding: unused
1770 * - decoding: Set by user.
1771 * @deprecated Deprecated in favor of request_channel_layout.
1772 */
1773 int request_channels;
1774 #endif
1775
1776 /**
1777 * Audio channel layout.
1778 * - encoding: set by user.
1779 * - decoding: set by libavcodec.
1780 */
1781 uint64_t channel_layout;
1782
1783 /**
1784 * Request decoder to use this channel layout if it can (0 for default)
1785 * - encoding: unused
1786 * - decoding: Set by user.
1787 */
1788 uint64_t request_channel_layout;
1789
1790 /**
1791 * Type of service that the audio stream conveys.
1792 * - encoding: Set by user.
1793 * - decoding: Set by libavcodec.
1794 */
1795 enum AVAudioServiceType audio_service_type;
1796
1797 /**
1798 * Used to request a sample format from the decoder.
1799 * - encoding: unused.
1800 * - decoding: Set by user.
1801 */
1802 enum AVSampleFormat request_sample_fmt;
1803
1804 #if FF_API_GET_BUFFER
1805 /**
1806 * Called at the beginning of each frame to get a buffer for it.
1807 *
1808 * The function will set AVFrame.data[], AVFrame.linesize[].
1809 * AVFrame.extended_data[] must also be set, but it should be the same as
1810 * AVFrame.data[] except for planar audio with more channels than can fit
1811 * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as
1812 * many data pointers as it can hold.
1813 *
1814 * if CODEC_CAP_DR1 is not set then get_buffer() must call
1815 * avcodec_default_get_buffer() instead of providing buffers allocated by
1816 * some other means.
1817 *
1818 * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't
1819 * need it. avcodec_default_get_buffer() aligns the output buffer properly,
1820 * but if get_buffer() is overridden then alignment considerations should
1821 * be taken into account.
1822 *
1823 * @see avcodec_default_get_buffer()
1824 *
1825 * Video:
1826 *
1827 * If pic.reference is set then the frame will be read later by libavcodec.
1828 * avcodec_align_dimensions2() should be used to find the required width and
1829 * height, as they normally need to be rounded up to the next multiple of 16.
1830 *
1831 * If frame multithreading is used and thread_safe_callbacks is set,
1832 * it may be called from a different thread, but not from more than one at
1833 * once. Does not need to be reentrant.
1834 *
1835 * @see release_buffer(), reget_buffer()
1836 * @see avcodec_align_dimensions2()
1837 *
1838 * Audio:
1839 *
1840 * Decoders request a buffer of a particular size by setting
1841 * AVFrame.nb_samples prior to calling get_buffer(). The decoder may,
1842 * however, utilize only part of the buffer by setting AVFrame.nb_samples
1843 * to a smaller value in the output frame.
1844 *
1845 * Decoders cannot use the buffer after returning from
1846 * avcodec_decode_audio4(), so they will not call release_buffer(), as it
1847 * is assumed to be released immediately upon return. In some rare cases,
1848 * a decoder may need to call get_buffer() more than once in a single
1849 * call to avcodec_decode_audio4(). In that case, when get_buffer() is
1850 * called again after it has already been called once, the previously
1851 * acquired buffer is assumed to be released at that time and may not be
1852 * reused by the decoder.
1853 *
1854 * As a convenience, av_samples_get_buffer_size() and
1855 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer()
1856 * functions to find the required data size and to fill data pointers and
1857 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
1858 * since all planes must be the same size.
1859 *
1860 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
1861 *
1862 * - encoding: unused
1863 * - decoding: Set by libavcodec, user can override.
1864 *
1865 * @deprecated use get_buffer2()
1866 */
1867 attribute_deprecated
1868 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
1869
1870 /**
1871 * Called to release buffers which were allocated with get_buffer.
1872 * A released buffer can be reused in get_buffer().
1873 * pic.data[*] must be set to NULL.
1874 * May be called from a different thread if frame multithreading is used,
1875 * but not by more than one thread at once, so does not need to be reentrant.
1876 * - encoding: unused
1877 * - decoding: Set by libavcodec, user can override.
1878 *
1879 * @deprecated custom freeing callbacks should be set from get_buffer2()
1880 */
1881 attribute_deprecated
1882 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
1883
1884 /**
1885 * Called at the beginning of a frame to get cr buffer for it.
1886 * Buffer type (size, hints) must be the same. libavcodec won't check it.
1887 * libavcodec will pass previous buffer in pic, function should return
1888 * same buffer or new buffer with old frame "painted" into it.
1889 * If pic.data[0] == NULL must behave like get_buffer().
1890 * if CODEC_CAP_DR1 is not set then reget_buffer() must call
1891 * avcodec_default_reget_buffer() instead of providing buffers allocated by
1892 * some other means.
1893 * - encoding: unused
1894 * - decoding: Set by libavcodec, user can override.
1895 */
1896 attribute_deprecated
1897 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
1898 #endif
1899
1900 /**
1901 * This callback is called at the beginning of each frame to get data
1902 * buffer(s) for it. There may be one contiguous buffer for all the data or
1903 * there may be a buffer per each data plane or anything in between. What
1904 * this means is, you may set however many entries in buf[] you feel necessary.
1905 * Each buffer must be reference-counted using the AVBuffer API (see description
1906 * of buf[] below).
1907 *
1908 * The following fields will be set in the frame before this callback is
1909 * called:
1910 * - format
1911 * - width, height (video only)
1912 * - sample_rate, channel_layout, nb_samples (audio only)
1913 * Their values may differ from the corresponding values in
1914 * AVCodecContext. This callback must use the frame values, not the codec
1915 * context values, to calculate the required buffer size.
1916 *
1917 * This callback must fill the following fields in the frame:
1918 * - data[]
1919 * - linesize[]
1920 * - extended_data:
1921 * * if the data is planar audio with more than 8 channels, then this
1922 * callback must allocate and fill extended_data to contain all pointers
1923 * to all data planes. data[] must hold as many pointers as it can.
1924 * extended_data must be allocated with av_malloc() and will be freed in
1925 * av_frame_unref().
1926 * * otherwise exended_data must point to data
1927 * - buf[] must contain one or more pointers to AVBufferRef structures. Each of
1928 * the frame's data and extended_data pointers must be contained in these. That
1929 * is, one AVBufferRef for each allocated chunk of memory, not necessarily one
1930 * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
1931 * and av_buffer_ref().
1932 * - extended_buf and nb_extended_buf must be allocated with av_malloc() by
1933 * this callback and filled with the extra buffers if there are more
1934 * buffers than buf[] can hold. extended_buf will be freed in
1935 * av_frame_unref().
1936 *
1937 * If CODEC_CAP_DR1 is not set then get_buffer2() must call
1938 * avcodec_default_get_buffer2() instead of providing buffers allocated by
1939 * some other means.
1940 *
1941 * Each data plane must be aligned to the maximum required by the target
1942 * CPU.
1943 *
1944 * @see avcodec_default_get_buffer2()
1945 *
1946 * Video:
1947 *
1948 * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
1949 * (read and/or written to if it is writable) later by libavcodec.
1950 *
1951 * If CODEC_FLAG_EMU_EDGE is not set in s->flags, the buffer must contain an
1952 * edge of the size returned by avcodec_get_edge_width() on all sides.
1953 *
1954 * avcodec_align_dimensions2() should be used to find the required width and
1955 * height, as they normally need to be rounded up to the next multiple of 16.
1956 *
1957 * If frame multithreading is used and thread_safe_callbacks is set,
1958 * this callback may be called from a different thread, but not from more
1959 * than one at once. Does not need to be reentrant.
1960 *
1961 * @see avcodec_align_dimensions2()
1962 *
1963 * Audio:
1964 *
1965 * Decoders request a buffer of a particular size by setting
1966 * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
1967 * however, utilize only part of the buffer by setting AVFrame.nb_samples
1968 * to a smaller value in the output frame.
1969 *
1970 * As a convenience, av_samples_get_buffer_size() and
1971 * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
1972 * functions to find the required data size and to fill data pointers and
1973 * linesize. In AVFrame.linesize, only linesize[0] may be set for audio
1974 * since all planes must be the same size.
1975 *
1976 * @see av_samples_get_buffer_size(), av_samples_fill_arrays()
1977 *
1978 * - encoding: unused
1979 * - decoding: Set by libavcodec, user can override.
1980 */
1981 int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags);
1982
1983 /**
1984 * If non-zero, the decoded audio and video frames returned from
1985 * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted
1986 * and are valid indefinitely. The caller must free them with
1987 * av_frame_unref() when they are not needed anymore.
1988 * Otherwise, the decoded frames must not be freed by the caller and are
1989 * only valid until the next decode call.
1990 *
1991 * - encoding: unused
1992 * - decoding: set by the caller before avcodec_open2().
1993 */
1994 int refcounted_frames;
1995
1996 /* - encoding parameters */
1997 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
1998 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
1999
2000 /**
2001 * minimum quantizer
2002 * - encoding: Set by user.
2003 * - decoding: unused
2004 */
2005 int qmin;
2006
2007 /**
2008 * maximum quantizer
2009 * - encoding: Set by user.
2010 * - decoding: unused
2011 */
2012 int qmax;
2013
2014 /**
2015 * maximum quantizer difference between frames
2016 * - encoding: Set by user.
2017 * - decoding: unused
2018 */
2019 int max_qdiff;
2020
2021 /**
2022 * ratecontrol qmin qmax limiting method
2023 * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax.
2024 * - encoding: Set by user.
2025 * - decoding: unused
2026 */
2027 float rc_qsquish;
2028
2029 float rc_qmod_amp;
2030 int rc_qmod_freq;
2031
2032 /**
2033 * decoder bitstream buffer size
2034 * - encoding: Set by user.
2035 * - decoding: unused
2036 */
2037 int rc_buffer_size;
2038
2039 /**
2040 * ratecontrol override, see RcOverride
2041 * - encoding: Allocated/set/freed by user.
2042 * - decoding: unused
2043 */
2044 int rc_override_count;
2045 RcOverride *rc_override;
2046
2047 /**
2048 * rate control equation
2049 * - encoding: Set by user
2050 * - decoding: unused
2051 */
2052 const char *rc_eq;
2053
2054 /**
2055 * maximum bitrate
2056 * - encoding: Set by user.
2057 * - decoding: unused
2058 */
2059 int rc_max_rate;
2060
2061 /**
2062 * minimum bitrate
2063 * - encoding: Set by user.
2064 * - decoding: unused
2065 */
2066 int rc_min_rate;
2067
2068 float rc_buffer_aggressivity;
2069
2070 /**
2071 * initial complexity for pass1 ratecontrol
2072 * - encoding: Set by user.
2073 * - decoding: unused
2074 */
2075 float rc_initial_cplx;
2076
2077 /**
2078 * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
2079 * - encoding: Set by user.
2080 * - decoding: unused.
2081 */
2082 float rc_max_available_vbv_use;
2083
2084 /**
2085 * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow.
2086 * - encoding: Set by user.
2087 * - decoding: unused.
2088 */
2089 float rc_min_vbv_overflow_use;
2090
2091 /**
2092 * Number of bits which should be loaded into the rc buffer before decoding starts.
2093 * - encoding: Set by user.
2094 * - decoding: unused
2095 */
2096 int rc_initial_buffer_occupancy;
2097
2098 #define FF_CODER_TYPE_VLC 0
2099 #define FF_CODER_TYPE_AC 1
2100 #define FF_CODER_TYPE_RAW 2
2101 #define FF_CODER_TYPE_RLE 3
2102 #define FF_CODER_TYPE_DEFLATE 4
2103 /**
2104 * coder type
2105 * - encoding: Set by user.
2106 * - decoding: unused
2107 */
2108 int coder_type;
2109
2110 /**
2111 * context model
2112 * - encoding: Set by user.
2113 * - decoding: unused
2114 */
2115 int context_model;
2116
2117 /**
2118 * minimum Lagrange multipler
2119 * - encoding: Set by user.
2120 * - decoding: unused
2121 */
2122 int lmin;
2123
2124 /**
2125 * maximum Lagrange multipler
2126 * - encoding: Set by user.
2127 * - decoding: unused
2128 */
2129 int lmax;
2130
2131 /**
2132 * frame skip threshold
2133 * - encoding: Set by user.
2134 * - decoding: unused
2135 */
2136 int frame_skip_threshold;
2137
2138 /**
2139 * frame skip factor
2140 * - encoding: Set by user.
2141 * - decoding: unused
2142 */
2143 int frame_skip_factor;
2144
2145 /**
2146 * frame skip exponent
2147 * - encoding: Set by user.
2148 * - decoding: unused
2149 */
2150 int frame_skip_exp;
2151
2152 /**
2153 * frame skip comparison function
2154 * - encoding: Set by user.
2155 * - decoding: unused
2156 */
2157 int frame_skip_cmp;
2158
2159 /**
2160 * trellis RD quantization
2161 * - encoding: Set by user.
2162 * - decoding: unused
2163 */
2164 int trellis;
2165
2166 /**
2167 * - encoding: Set by user.
2168 * - decoding: unused
2169 */
2170 int min_prediction_order;
2171
2172 /**
2173 * - encoding: Set by user.
2174 * - decoding: unused
2175 */
2176 int max_prediction_order;
2177
2178 /**
2179 * GOP timecode frame start number, in non drop frame format
2180 * - encoding: Set by user.
2181 * - decoding: unused
2182 */
2183 int64_t timecode_frame_start;
2184
2185 /* The RTP callback: This function is called */
2186 /* every time the encoder has a packet to send. */
2187 /* It depends on the encoder if the data starts */
2188 /* with a Start Code (it should). H.263 does. */
2189 /* mb_nb contains the number of macroblocks */
2190 /* encoded in the RTP payload. */
2191 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
2192
2193 int rtp_payload_size; /* The size of the RTP payload: the coder will */
2194 /* do its best to deliver a chunk with size */
2195 /* below rtp_payload_size, the chunk will start */
2196 /* with a start code on some codecs like H.263. */
2197 /* This doesn't take account of any particular */
2198 /* headers inside the transmitted RTP payload. */
2199
2200 /* statistics, used for 2-pass encoding */
2201 int mv_bits;
2202 int header_bits;
2203 int i_tex_bits;
2204 int p_tex_bits;
2205 int i_count;
2206 int p_count;
2207 int skip_count;
2208 int misc_bits;
2209
2210 /**
2211 * number of bits used for the previously encoded frame
2212 * - encoding: Set by libavcodec.
2213 * - decoding: unused
2214 */
2215 int frame_bits;
2216
2217 /**
2218 * pass1 encoding statistics output buffer
2219 * - encoding: Set by libavcodec.
2220 * - decoding: unused
2221 */
2222 char *stats_out;
2223
2224 /**
2225 * pass2 encoding statistics input buffer
2226 * Concatenated stuff from stats_out of pass1 should be placed here.
2227 * - encoding: Allocated/set/freed by user.
2228 * - decoding: unused
2229 */
2230 char *stats_in;
2231
2232 /**
2233 * Work around bugs in encoders which sometimes cannot be detected automatically.
2234 * - encoding: Set by user
2235 * - decoding: Set by user
2236 */
2237 int workaround_bugs;
2238 #define FF_BUG_AUTODETECT 1 ///< autodetection
2239 #define FF_BUG_OLD_MSMPEG4 2
2240 #define FF_BUG_XVID_ILACE 4
2241 #define FF_BUG_UMP4 8
2242 #define FF_BUG_NO_PADDING 16
2243 #define FF_BUG_AMV 32
2244 #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default.
2245 #define FF_BUG_QPEL_CHROMA 64
2246 #define FF_BUG_STD_QPEL 128
2247 #define FF_BUG_QPEL_CHROMA2 256
2248 #define FF_BUG_DIRECT_BLOCKSIZE 512
2249 #define FF_BUG_EDGE 1024
2250 #define FF_BUG_HPEL_CHROMA 2048
2251 #define FF_BUG_DC_CLIP 4096
2252 #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders.
2253 #define FF_BUG_TRUNCATED 16384
2254
2255 /**
2256 * strictly follow the standard (MPEG4, ...).
2257 * - encoding: Set by user.
2258 * - decoding: Set by user.
2259 * Setting this to STRICT or higher means the encoder and decoder will
2260 * generally do stupid things, whereas setting it to unofficial or lower
2261 * will mean the encoder might produce output that is not supported by all
2262 * spec-compliant decoders. Decoders don't differentiate between normal,
2263 * unofficial and experimental (that is, they always try to decode things
2264 * when they can) unless they are explicitly asked to behave stupidly
2265 * (=strictly conform to the specs)
2266 */
2267 int strict_std_compliance;
2268 #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software.
2269 #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences.
2270 #define FF_COMPLIANCE_NORMAL 0
2271 #define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions
2272 #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things.
2273
2274 /**
2275 * error concealment flags
2276 * - encoding: unused
2277 * - decoding: Set by user.
2278 */
2279 int error_concealment;
2280 #define FF_EC_GUESS_MVS 1
2281 #define FF_EC_DEBLOCK 2
2282
2283 /**
2284 * debug
2285 * - encoding: Set by user.
2286 * - decoding: Set by user.
2287 */
2288 int debug;
2289 #define FF_DEBUG_PICT_INFO 1
2290 #define FF_DEBUG_RC 2
2291 #define FF_DEBUG_BITSTREAM 4
2292 #define FF_DEBUG_MB_TYPE 8
2293 #define FF_DEBUG_QP 16
2294 #define FF_DEBUG_MV 32
2295 #define FF_DEBUG_DCT_COEFF 0x00000040
2296 #define FF_DEBUG_SKIP 0x00000080
2297 #define FF_DEBUG_STARTCODE 0x00000100
2298 #define FF_DEBUG_PTS 0x00000200
2299 #define FF_DEBUG_ER 0x00000400
2300 #define FF_DEBUG_MMCO 0x00000800
2301 #define FF_DEBUG_BUGS 0x00001000
2302 #define FF_DEBUG_VIS_QP 0x00002000
2303 #define FF_DEBUG_VIS_MB_TYPE 0x00004000
2304 #define FF_DEBUG_BUFFERS 0x00008000
2305 #define FF_DEBUG_THREADS 0x00010000
2306
2307 /**
2308 * debug
2309 * - encoding: Set by user.
2310 * - decoding: Set by user.
2311 */
2312 int debug_mv;
2313 #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
2314 #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
2315 #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
2316
2317 /**
2318 * Error recognition; may misdetect some more or less valid parts as errors.
2319 * - encoding: unused
2320 * - decoding: Set by user.
2321 */
2322 int err_recognition;
2323 #define AV_EF_CRCCHECK (1<<0)
2324 #define AV_EF_BITSTREAM (1<<1)
2325 #define AV_EF_BUFFER (1<<2)
2326 #define AV_EF_EXPLODE (1<<3)
2327
2328 /**
2329 * opaque 64bit number (generally a PTS) that will be reordered and
2330 * output in AVFrame.reordered_opaque
2331 * @deprecated in favor of pkt_pts
2332 * - encoding: unused
2333 * - decoding: Set by user.
2334 */
2335 int64_t reordered_opaque;
2336
2337 /**
2338 * Hardware accelerator in use
2339 * - encoding: unused.
2340 * - decoding: Set by libavcodec
2341 */
2342 struct AVHWAccel *hwaccel;
2343
2344 /**
2345 * Hardware accelerator context.
2346 * For some hardware accelerators, a global context needs to be
2347 * provided by the user. In that case, this holds display-dependent
2348 * data Libav cannot instantiate itself. Please refer to the
2349 * Libav HW accelerator documentation to know how to fill this
2350 * is. e.g. for VA API, this is a struct vaapi_context.
2351 * - encoding: unused
2352 * - decoding: Set by user
2353 */
2354 void *hwaccel_context;
2355
2356 /**
2357 * error
2358 * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR.
2359 * - decoding: unused
2360 */
2361 uint64_t error[AV_NUM_DATA_POINTERS];
2362
2363 /**
2364 * DCT algorithm, see FF_DCT_* below
2365 * - encoding: Set by user.
2366 * - decoding: unused
2367 */
2368 int dct_algo;
2369 #define FF_DCT_AUTO 0
2370 #define FF_DCT_FASTINT 1
2371 #define FF_DCT_INT 2
2372 #define FF_DCT_MMX 3
2373 #define FF_DCT_ALTIVEC 5
2374 #define FF_DCT_FAAN 6
2375
2376 /**
2377 * IDCT algorithm, see FF_IDCT_* below.
2378 * - encoding: Set by user.
2379 * - decoding: Set by user.
2380 */
2381 int idct_algo;
2382 #define FF_IDCT_AUTO 0
2383 #define FF_IDCT_INT 1
2384 #define FF_IDCT_SIMPLE 2
2385 #define FF_IDCT_SIMPLEMMX 3
2386 #define FF_IDCT_ARM 7
2387 #define FF_IDCT_ALTIVEC 8
2388 #define FF_IDCT_SH4 9
2389 #define FF_IDCT_SIMPLEARM 10
2390 #define FF_IDCT_IPP 13
2391 #define FF_IDCT_XVIDMMX 14
2392 #define FF_IDCT_SIMPLEARMV5TE 16
2393 #define FF_IDCT_SIMPLEARMV6 17
2394 #define FF_IDCT_SIMPLEVIS 18
2395 #define FF_IDCT_FAAN 20
2396 #define FF_IDCT_SIMPLENEON 22
2397 #define FF_IDCT_SIMPLEALPHA 23
2398
2399 /**
2400 * bits per sample/pixel from the demuxer (needed for huffyuv).
2401 * - encoding: Set by libavcodec.
2402 * - decoding: Set by user.
2403 */
2404 int bits_per_coded_sample;
2405
2406 /**
2407 * Bits per sample/pixel of internal libavcodec pixel/sample format.
2408 * - encoding: set by user.
2409 * - decoding: set by libavcodec.
2410 */
2411 int bits_per_raw_sample;
2412
2413 #if FF_API_LOWRES
2414 /**
2415 * low resolution decoding, 1-> 1/2 size, 2->1/4 size
2416 * - encoding: unused
2417 * - decoding: Set by user.
2418 *
2419 * @deprecated use decoder private options instead
2420 */
2421 attribute_deprecated int lowres;
2422 #endif
2423
2424 /**
2425 * the picture in the bitstream
2426 * - encoding: Set by libavcodec.
2427 * - decoding: Set by libavcodec.
2428 */
2429 AVFrame *coded_frame;
2430
2431 /**
2432 * thread count
2433 * is used to decide how many independent tasks should be passed to execute()
2434 * - encoding: Set by user.
2435 * - decoding: Set by user.
2436 */
2437 int thread_count;
2438
2439 /**
2440 * Which multithreading methods to use.
2441 * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread,
2442 * so clients which cannot provide future frames should not use it.
2443 *
2444 * - encoding: Set by user, otherwise the default is used.
2445 * - decoding: Set by user, otherwise the default is used.
2446 */
2447 int thread_type;
2448 #define FF_THREAD_FRAME 1 ///< Decode more than one frame at once
2449 #define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once
2450
2451 /**
2452 * Which multithreading methods are in use by the codec.
2453 * - encoding: Set by libavcodec.
2454 * - decoding: Set by libavcodec.
2455 */
2456 int active_thread_type;
2457
2458 /**
2459 * Set by the client if its custom get_buffer() callback can be called
2460 * synchronously from another thread, which allows faster multithreaded decoding.
2461 * draw_horiz_band() will be called from other threads regardless of this setting.
2462 * Ignored if the default get_buffer() is used.
2463 * - encoding: Set by user.
2464 * - decoding: Set by user.
2465 */
2466 int thread_safe_callbacks;
2467
2468 /**
2469 * The codec may call this to execute several independent things.
2470 * It will return only after finishing all tasks.
2471 * The user may replace this with some multithreaded implementation,
2472 * the default implementation will execute the parts serially.
2473 * @param count the number of things to execute
2474 * - encoding: Set by libavcodec, user can override.
2475 * - decoding: Set by libavcodec, user can override.
2476 */
2477 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size);
2478
2479 /**
2480 * The codec may call this to execute several independent things.
2481 * It will return only after finishing all tasks.
2482 * The user may replace this with some multithreaded implementation,
2483 * the default implementation will execute the parts serially.
2484 * Also see avcodec_thread_init and e.g. the --enable-pthread configure option.
2485 * @param c context passed also to func
2486 * @param count the number of things to execute
2487 * @param arg2 argument passed unchanged to func
2488 * @param ret return values of executed functions, must have space for "count" values. May be NULL.
2489 * @param func function that will be called count times, with jobnr from 0 to count-1.
2490 * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no
2491 * two instances of func executing at the same time will have the same threadnr.
2492 * @return always 0 currently, but code should handle a future improvement where when any call to func
2493 * returns < 0 no further calls to func may be done and < 0 is returned.
2494 * - encoding: Set by libavcodec, user can override.
2495 * - decoding: Set by libavcodec, user can override.
2496 */
2497 int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count);
2498
2499 /**
2500 * thread opaque
2501 * Can be used by execute() to store some per AVCodecContext stuff.
2502 * - encoding: set by execute()
2503 * - decoding: set by execute()
2504 */
2505 void *thread_opaque;
2506
2507 /**
2508 * noise vs. sse weight for the nsse comparsion function
2509 * - encoding: Set by user.
2510 * - decoding: unused
2511 */
2512 int nsse_weight;
2513
2514 /**
2515 * profile
2516 * - encoding: Set by user.
2517 * - decoding: Set by libavcodec.
2518 */
2519 int profile;
2520 #define FF_PROFILE_UNKNOWN -99
2521 #define FF_PROFILE_RESERVED -100
2522
2523 #define FF_PROFILE_AAC_MAIN 0
2524 #define FF_PROFILE_AAC_LOW 1
2525 #define FF_PROFILE_AAC_SSR 2
2526 #define FF_PROFILE_AAC_LTP 3
2527 #define FF_PROFILE_AAC_HE 4
2528 #define FF_PROFILE_AAC_HE_V2 28
2529 #define FF_PROFILE_AAC_LD 22
2530 #define FF_PROFILE_AAC_ELD 38
2531
2532 #define FF_PROFILE_DTS 20
2533 #define FF_PROFILE_DTS_ES 30
2534 #define FF_PROFILE_DTS_96_24 40
2535 #define FF_PROFILE_DTS_HD_HRA 50
2536 #define FF_PROFILE_DTS_HD_MA 60
2537
2538 #define FF_PROFILE_MPEG2_422 0
2539 #define FF_PROFILE_MPEG2_HIGH 1
2540 #define FF_PROFILE_MPEG2_SS 2
2541 #define FF_PROFILE_MPEG2_SNR_SCALABLE 3
2542 #define FF_PROFILE_MPEG2_MAIN 4
2543 #define FF_PROFILE_MPEG2_SIMPLE 5
2544
2545 #define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag
2546 #define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag
2547
2548 #define FF_PROFILE_H264_BASELINE 66
2549 #define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED)
2550 #define FF_PROFILE_H264_MAIN 77
2551 #define FF_PROFILE_H264_EXTENDED 88
2552 #define FF_PROFILE_H264_HIGH 100
2553 #define FF_PROFILE_H264_HIGH_10 110
2554 #define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA)
2555 #define FF_PROFILE_H264_HIGH_422 122
2556 #define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA)
2557 #define FF_PROFILE_H264_HIGH_444 144
2558 #define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244
2559 #define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA)
2560 #define FF_PROFILE_H264_CAVLC_444 44
2561
2562 #define FF_PROFILE_VC1_SIMPLE 0
2563 #define FF_PROFILE_VC1_MAIN 1
2564 #define FF_PROFILE_VC1_COMPLEX 2
2565 #define FF_PROFILE_VC1_ADVANCED 3
2566
2567 #define FF_PROFILE_MPEG4_SIMPLE 0
2568 #define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1
2569 #define FF_PROFILE_MPEG4_CORE 2
2570 #define FF_PROFILE_MPEG4_MAIN 3
2571 #define FF_PROFILE_MPEG4_N_BIT 4
2572 #define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5
2573 #define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6
2574 #define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7
2575 #define FF_PROFILE_MPEG4_HYBRID 8
2576 #define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9
2577 #define FF_PROFILE_MPEG4_CORE_SCALABLE 10
2578 #define FF_PROFILE_MPEG4_ADVANCED_CODING 11
2579 #define FF_PROFILE_MPEG4_ADVANCED_CORE 12
2580 #define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13
2581 #define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14
2582 #define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15
2583
2584 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0
2585 #define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1
2586 #define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2
2587 #define FF_PROFILE_JPEG2000_DCINEMA_2K 3
2588 #define FF_PROFILE_JPEG2000_DCINEMA_4K 4
2589
2590 /**
2591 * level
2592 * - encoding: Set by user.
2593 * - decoding: Set by libavcodec.
2594 */
2595 int level;
2596 #define FF_LEVEL_UNKNOWN -99
2597
2598 /**
2599 *
2600 * - encoding: unused
2601 * - decoding: Set by user.
2602 */
2603 enum AVDiscard skip_loop_filter;
2604
2605 /**
2606 *
2607 * - encoding: unused
2608 * - decoding: Set by user.
2609 */
2610 enum AVDiscard skip_idct;
2611
2612 /**
2613 *
2614 * - encoding: unused
2615 * - decoding: Set by user.
2616 */
2617 enum AVDiscard skip_frame;
2618
2619 /**
2620 * Header containing style information for text subtitles.
2621 * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
2622 * [Script Info] and [V4+ Styles] section, plus the [Events] line and
2623 * the Format line following. It shouldn't include any Dialogue line.
2624 * - encoding: Set/allocated/freed by user (before avcodec_open2())
2625 * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2())
2626 */
2627 uint8_t *subtitle_header;
2628 int subtitle_header_size;
2629
2630 /**
2631 * Simulates errors in the bitstream to test error concealment.
2632 * - encoding: Set by user.
2633 * - decoding: unused
2634 */
2635 int error_rate;
2636
2637 /**
2638 * Current packet as passed into the decoder, to avoid having
2639 * to pass the packet into every function. Currently only valid
2640 * inside lavc and get/release_buffer callbacks.
2641 * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
2642 * - encoding: unused
2643 */
2644 AVPacket *pkt;
2645
2646 /**
2647 * VBV delay coded in the last frame (in periods of a 27 MHz clock).
2648 * Used for compliant TS muxing.
2649 * - encoding: Set by libavcodec.
2650 * - decoding: unused.
2651 */
2652 uint64_t vbv_delay;
2653 } AVCodecContext;
2654
2655 /**
2656 * AVProfile.
2657 */
2658 typedef struct AVProfile {
2659 int profile;
2660 const char *name; ///< short name for the profile
2661 } AVProfile;
2662
2663 typedef struct AVCodecDefault AVCodecDefault;
2664
2665 struct AVSubtitle;
2666
2667 /**
2668 * AVCodec.
2669 */
2670 typedef struct AVCodec {
2671 /**
2672 * Name of the codec implementation.
2673 * The name is globally unique among encoders and among decoders (but an
2674 * encoder and a decoder can share the same name).
2675 * This is the primary way to find a codec from the user perspective.
2676 */
2677 const char *name;
2678 /**
2679 * Descriptive name for the codec, meant to be more human readable than name.
2680 * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
2681 */
2682 const char *long_name;
2683 enum AVMediaType type;
2684 enum AVCodecID id;
2685 /**
2686 * Codec capabilities.
2687 * see CODEC_CAP_*
2688 */
2689 int capabilities;
2690 const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0}
2691 const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1
2692 const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
2693 const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
2694 const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
2695 attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder
2696 const AVClass *priv_class; ///< AVClass for the private context
2697 const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
2698
2699 /*****************************************************************
2700 * No fields below this line are part of the public API. They
2701 * may not be used outside of libavcodec and can be changed and
2702 * removed at will.
2703 * New public fields should be added right above.
2704 *****************************************************************
2705 */
2706 int priv_data_size;
2707 struct AVCodec *next;
2708 /**
2709 * @name Frame-level threading support functions
2710 * @{
2711 */
2712 /**
2713 * If defined, called on thread contexts when they are created.
2714 * If the codec allocates writable tables in init(), re-allocate them here.
2715 * priv_data will be set to a copy of the original.
2716 */
2717 int (*init_thread_copy)(AVCodecContext *);
2718 /**
2719 * Copy necessary context variables from a previous thread context to the current one.
2720 * If not defined, the next thread will start automatically; otherwise, the codec
2721 * must call ff_thread_finish_setup().
2722 *
2723 * dst and src will (rarely) point to the same context, in which case memcpy should be skipped.
2724 */
2725 int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
2726 /** @} */
2727
2728 /**
2729 * Private codec-specific defaults.
2730 */
2731 const AVCodecDefault *defaults;
2732
2733 /**
2734 * Initialize codec static data, called from avcodec_register().
2735 */
2736 void (*init_static_data)(struct AVCodec *codec);
2737
2738 int (*init)(AVCodecContext *);
2739 int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size,
2740 const struct AVSubtitle *sub);
2741 /**
2742 * Encode data to an AVPacket.
2743 *
2744 * @param avctx codec context
2745 * @param avpkt output AVPacket (may contain a user-provided buffer)
2746 * @param[in] frame AVFrame containing the raw data to be encoded
2747 * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a
2748 * non-empty packet was returned in avpkt.
2749 * @return 0 on success, negative error code on failure
2750 */
2751 int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame,
2752 int *got_packet_ptr);
2753 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt);
2754 int (*close)(AVCodecContext *);
2755 /**
2756 * Flush buffers.
2757 * Will be called when seeking
2758 */
2759 void (*flush)(AVCodecContext *);
2760 } AVCodec;
2761
2762 /**
2763 * AVHWAccel.
2764 */
2765 typedef struct AVHWAccel {
2766 /**
2767 * Name of the hardware accelerated codec.
2768 * The name is globally unique among encoders and among decoders (but an
2769 * encoder and a decoder can share the same name).
2770 */
2771 const char *name;
2772
2773 /**
2774 * Type of codec implemented by the hardware accelerator.
2775 *
2776 * See AVMEDIA_TYPE_xxx
2777 */
2778 enum AVMediaType type;
2779
2780 /**
2781 * Codec implemented by the hardware accelerator.
2782 *
2783 * See AV_CODEC_ID_xxx
2784 */
2785 enum AVCodecID id;
2786
2787 /**
2788 * Supported pixel format.
2789 *
2790 * Only hardware accelerated formats are supported here.
2791 */
2792 enum AVPixelFormat pix_fmt;
2793
2794 /**
2795 * Hardware accelerated codec capabilities.
2796 * see FF_HWACCEL_CODEC_CAP_*
2797 */
2798 int capabilities;
2799
2800 struct AVHWAccel *next;
2801
2802 /**
2803 * Called at the beginning of each frame or field picture.
2804 *
2805 * Meaningful frame information (codec specific) is guaranteed to
2806 * be parsed at this point. This function is mandatory.
2807 *
2808 * Note that buf can be NULL along with buf_size set to 0.
2809 * Otherwise, this means the whole frame is available at this point.
2810 *
2811 * @param avctx the codec context
2812 * @param buf the frame data buffer base
2813 * @param buf_size the size of the frame in bytes
2814 * @return zero if successful, a negative value otherwise
2815 */
2816 int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2817
2818 /**
2819 * Callback for each slice.
2820 *
2821 * Meaningful slice information (codec specific) is guaranteed to
2822 * be parsed at this point. This function is mandatory.
2823 *
2824 * @param avctx the codec context
2825 * @param buf the slice data buffer base
2826 * @param buf_size the size of the slice in bytes
2827 * @return zero if successful, a negative value otherwise
2828 */
2829 int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size);
2830
2831 /**
2832 * Called at the end of each frame or field picture.
2833 *
2834 * The whole picture is parsed at this point and can now be sent
2835 * to the hardware accelerator. This function is mandatory.
2836 *
2837 * @param avctx the codec context
2838 * @return zero if successful, a negative value otherwise
2839 */
2840 int (*end_frame)(AVCodecContext *avctx);
2841
2842 /**
2843 * Size of HW accelerator private data.
2844 *
2845 * Private data is allocated with av_mallocz() before
2846 * AVCodecContext.get_buffer() and deallocated after
2847 * AVCodecContext.release_buffer().
2848 */
2849 int priv_data_size;
2850 } AVHWAccel;
2851
2852 /**
2853 * @defgroup lavc_picture AVPicture
2854 *
2855 * Functions for working with AVPicture
2856 * @{
2857 */
2858
2859 /**
2860 * four components are given, that's all.
2861 * the last component is alpha
2862 */
2863 typedef struct AVPicture {
2864 uint8_t *data[AV_NUM_DATA_POINTERS];
2865 int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line
2866 } AVPicture;
2867
2868 /**
2869 * @}
2870 */
2871
2872 #define AVPALETTE_SIZE 1024
2873 #define AVPALETTE_COUNT 256
2874
2875 enum AVSubtitleType {
2876 SUBTITLE_NONE,
2877
2878 SUBTITLE_BITMAP, ///< A bitmap, pict will be set
2879
2880 /**
2881 * Plain text, the text field must be set by the decoder and is
2882 * authoritative. ass and pict fields may contain approximations.
2883 */
2884 SUBTITLE_TEXT,
2885
2886 /**
2887 * Formatted text, the ass field must be set by the decoder and is
2888 * authoritative. pict and text fields may contain approximations.
2889 */
2890 SUBTITLE_ASS,
2891 };
2892
2893 #define AV_SUBTITLE_FLAG_FORCED 0x00000001
2894
2895 typedef struct AVSubtitleRect {
2896 int x; ///< top left corner of pict, undefined when pict is not set
2897 int y; ///< top left corner of pict, undefined when pict is not set
2898 int w; ///< width of pict, undefined when pict is not set
2899 int h; ///< height of pict, undefined when pict is not set
2900 int nb_colors; ///< number of colors in pict, undefined when pict is not set
2901
2902 /**
2903 * data+linesize for the bitmap of this subtitle.
2904 * can be set for text/ass as well once they where rendered
2905 */
2906 AVPicture pict;
2907 enum AVSubtitleType type;
2908
2909 char *text; ///< 0 terminated plain UTF-8 text
2910
2911 /**
2912 * 0 terminated ASS/SSA compatible event line.
2913 * The pressentation of this is unaffected by the other values in this
2914 * struct.
2915 */
2916 char *ass;
2917 int flags;
2918 } AVSubtitleRect;
2919
2920 typedef struct AVSubtitle {
2921 uint16_t format; /* 0 = graphics */
2922 uint32_t start_display_time; /* relative to packet pts, in ms */
2923 uint32_t end_display_time; /* relative to packet pts, in ms */
2924 unsigned num_rects;
2925 AVSubtitleRect **rects;
2926 int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
2927 } AVSubtitle;
2928
2929 /**
2930 * If c is NULL, returns the first registered codec,
2931 * if c is non-NULL, returns the next registered codec after c,
2932 * or NULL if c is the last one.
2933 */
2934 AVCodec *av_codec_next(const AVCodec *c);
2935
2936 /**
2937 * Return the LIBAVCODEC_VERSION_INT constant.
2938 */
2939 unsigned avcodec_version(void);
2940
2941 /**
2942 * Return the libavcodec build-time configuration.
2943 */
2944 const char *avcodec_configuration(void);
2945
2946 /**
2947 * Return the libavcodec license.
2948 */
2949 const char *avcodec_license(void);
2950
2951 /**
2952 * Register the codec codec and initialize libavcodec.
2953 *
2954 * @warning either this function or avcodec_register_all() must be called
2955 * before any other libavcodec functions.
2956 *
2957 * @see avcodec_register_all()
2958 */
2959 void avcodec_register(AVCodec *codec);
2960
2961 /**
2962 * Register all the codecs, parsers and bitstream filters which were enabled at
2963 * configuration time. If you do not call this function you can select exactly
2964 * which formats you want to support, by using the individual registration
2965 * functions.
2966 *
2967 * @see avcodec_register
2968 * @see av_register_codec_parser
2969 * @see av_register_bitstream_filter
2970 */
2971 void avcodec_register_all(void);
2972
2973 /**
2974 * Allocate an AVCodecContext and set its fields to default values. The
2975 * resulting struct can be deallocated by calling avcodec_close() on it followed
2976 * by av_free().
2977 *
2978 * @param codec if non-NULL, allocate private data and initialize defaults
2979 * for the given codec. It is illegal to then call avcodec_open2()
2980 * with a different codec.
2981 * If NULL, then the codec-specific defaults won't be initialized,
2982 * which may result in suboptimal default settings (this is
2983 * important mainly for encoders, e.g. libx264).
2984 *
2985 * @return An AVCodecContext filled with default values or NULL on failure.
2986 * @see avcodec_get_context_defaults
2987 */
2988 AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
2989
2990 /**
2991 * Set the fields of the given AVCodecContext to default values corresponding
2992 * to the given codec (defaults may be codec-dependent).
2993 *
2994 * Do not call this function if a non-NULL codec has been passed
2995 * to avcodec_alloc_context3() that allocated this AVCodecContext.
2996 * If codec is non-NULL, it is illegal to call avcodec_open2() with a
2997 * different codec on this AVCodecContext.
2998 */
2999 int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
3000
3001 /**
3002 * Get the AVClass for AVCodecContext. It can be used in combination with
3003 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
3004 *
3005 * @see av_opt_find().
3006 */
3007 const AVClass *avcodec_get_class(void);
3008
3009 /**
3010 * Copy the settings of the source AVCodecContext into the destination
3011 * AVCodecContext. The resulting destination codec context will be
3012 * unopened, i.e. you are required to call avcodec_open2() before you
3013 * can use this AVCodecContext to decode/encode video/audio data.
3014 *
3015 * @param dest target codec context, should be initialized with
3016 * avcodec_alloc_context3(), but otherwise uninitialized
3017 * @param src source codec context
3018 * @return AVERROR() on error (e.g. memory allocation error), 0 on success
3019 */
3020 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
3021
3022 /**
3023 * Allocate an AVFrame and set its fields to default values. The resulting
3024 * struct must be freed using avcodec_free_frame().
3025 *
3026 * @return An AVFrame filled with default values or NULL on failure.
3027 * @see avcodec_get_frame_defaults
3028 */
3029 AVFrame *avcodec_alloc_frame(void);
3030
3031 /**
3032 * Set the fields of the given AVFrame to default values.
3033 *
3034 * @param frame The AVFrame of which the fields should be set to default values.
3035 */
3036 void avcodec_get_frame_defaults(AVFrame *frame);
3037
3038 /**
3039 * Free the frame and any dynamically allocated objects in it,
3040 * e.g. extended_data.
3041 *
3042 * @param frame frame to be freed. The pointer will be set to NULL.
3043 *
3044 * @warning this function does NOT free the data buffers themselves
3045 * (it does not know how, since they might have been allocated with
3046 * a custom get_buffer()).
3047 */
3048 void avcodec_free_frame(AVFrame **frame);
3049
3050 /**
3051 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
3052 * function the context has to be allocated with avcodec_alloc_context3().
3053 *
3054 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
3055 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
3056 * retrieving a codec.
3057 *
3058 * @warning This function is not thread safe!
3059 *
3060 * @code
3061 * avcodec_register_all();
3062 * av_dict_set(&opts, "b", "2.5M", 0);
3063 * codec = avcodec_find_decoder(AV_CODEC_ID_H264);
3064 * if (!codec)
3065 * exit(1);
3066 *
3067 * context = avcodec_alloc_context3(codec);
3068 *
3069 * if (avcodec_open2(context, codec, opts) < 0)
3070 * exit(1);
3071 * @endcode
3072 *
3073 * @param avctx The context to initialize.
3074 * @param codec The codec to open this context for. If a non-NULL codec has been
3075 * previously passed to avcodec_alloc_context3() or
3076 * avcodec_get_context_defaults3() for this context, then this
3077 * parameter MUST be either NULL or equal to the previously passed
3078 * codec.
3079 * @param options A dictionary filled with AVCodecContext and codec-private options.
3080 * On return this object will be filled with options that were not found.
3081 *
3082 * @return zero on success, a negative value on error
3083 * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
3084 * av_dict_set(), av_opt_find().
3085 */
3086 int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
3087
3088 /**
3089 * Close a given AVCodecContext and free all the data associated with it
3090 * (but not the AVCodecContext itself).
3091 *
3092 * Calling this function on an AVCodecContext that hasn't been opened will free
3093 * the codec-specific data allocated in avcodec_alloc_context3() /
3094 * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
3095 * do nothing.
3096 */
3097 int avcodec_close(AVCodecContext *avctx);
3098
3099 /**
3100 * Free all allocated data in the given subtitle struct.
3101 *
3102 * @param sub AVSubtitle to free.
3103 */
3104 void avsubtitle_free(AVSubtitle *sub);
3105
3106 /**
3107 * @}
3108 */
3109
3110 /**
3111 * @addtogroup lavc_packet
3112 * @{
3113 */
3114
3115 #if FF_API_DESTRUCT_PACKET
3116 /**
3117 * Default packet destructor.
3118 * @deprecated use the AVBuffer API instead
3119 */
3120 attribute_deprecated
3121 void av_destruct_packet(AVPacket *pkt);
3122 #endif
3123
3124 /**
3125 * Initialize optional fields of a packet with default values.
3126 *
3127 * Note, this does not touch the data and size members, which have to be
3128 * initialized separately.
3129 *
3130 * @param pkt packet
3131 */
3132 void av_init_packet(AVPacket *pkt);
3133
3134 /**
3135 * Allocate the payload of a packet and initialize its fields with
3136 * default values.
3137 *
3138 * @param pkt packet
3139 * @param size wanted payload size
3140 * @return 0 if OK, AVERROR_xxx otherwise
3141 */
3142 int av_new_packet(AVPacket *pkt, int size);
3143
3144 /**
3145 * Reduce packet size, correctly zeroing padding
3146 *
3147 * @param pkt packet
3148 * @param size new size
3149 */
3150 void av_shrink_packet(AVPacket *pkt, int size);
3151
3152 /**
3153 * Increase packet size, correctly zeroing padding
3154 *
3155 * @param pkt packet
3156 * @param grow_by number of bytes by which to increase the size of the packet
3157 */
3158 int av_grow_packet(AVPacket *pkt, int grow_by);
3159
3160 /**
3161 * Initialize a reference-counted packet from av_malloc()ed data.
3162 *
3163 * @param pkt packet to be initialized. This function will set the data, size,
3164 * buf and destruct fields, all others are left untouched.
3165 * @param data Data allocated by av_malloc() to be used as packet data. If this
3166 * function returns successfully, the data is owned by the underlying AVBuffer.
3167 * The caller may not access the data through other means.
3168 * @param size size of data in bytes, without the padding. I.e. the full buffer
3169 * size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE.
3170 *
3171 * @return 0 on success, a negative AVERROR on error
3172 */
3173 int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
3174
3175 /**
3176 * @warning This is a hack - the packet memory allocation stuff is broken. The
3177 * packet is allocated if it was not really allocated.
3178 */
3179 int av_dup_packet(AVPacket *pkt);
3180
3181 /**
3182 * Free a packet.
3183 *
3184 * @param pkt packet to free
3185 */
3186 void av_free_packet(AVPacket *pkt);
3187
3188 /**
3189 * Allocate new information of a packet.
3190 *
3191 * @param pkt packet
3192 * @param type side information type
3193 * @param size side information size
3194 * @return pointer to fresh allocated data or NULL otherwise
3195 */
3196 uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3197 int size);
3198
3199 /**
3200 * Shrink the already allocated side data buffer
3201 *
3202 * @param pkt packet
3203 * @param type side information type
3204 * @param size new side information size
3205 * @return 0 on success, < 0 on failure
3206 */
3207 int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3208 int size);
3209
3210 /**
3211 * Get side information from packet.
3212 *
3213 * @param pkt packet
3214 * @param type desired side information type
3215 * @param size pointer for side information size to store (optional)
3216 * @return pointer to data if present or NULL otherwise
3217 */
3218 uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
3219 int *size);
3220
3221 /**
3222 * @}
3223 */
3224
3225 /**
3226 * @addtogroup lavc_decoding
3227 * @{
3228 */
3229
3230 /**
3231 * Find a registered decoder with a matching codec ID.
3232 *
3233 * @param id AVCodecID of the requested decoder
3234 * @return A decoder if one was found, NULL otherwise.
3235 */
3236 AVCodec *avcodec_find_decoder(enum AVCodecID id);
3237
3238 /**
3239 * Find a registered decoder with the specified name.
3240 *
3241 * @param name name of the requested decoder
3242 * @return A decoder if one was found, NULL otherwise.
3243 */
3244 AVCodec *avcodec_find_decoder_by_name(const char *name);
3245
3246 #if FF_API_GET_BUFFER
3247 attribute_deprecated int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
3248 attribute_deprecated void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3249 attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
3250 #endif
3251
3252 /**
3253 * The default callback for AVCodecContext.get_buffer2(). It is made public so
3254 * it can be called by custom get_buffer2() implementations for decoders without
3255 * CODEC_CAP_DR1 set.
3256 */
3257 int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags);
3258
3259 /**
3260 * Return the amount of padding in pixels which the get_buffer callback must
3261 * provide around the edge of the image for codecs which do not have the
3262 * CODEC_FLAG_EMU_EDGE flag.
3263 *
3264 * @return Required padding in pixels.
3265 */
3266 unsigned avcodec_get_edge_width(void);
3267
3268 /**
3269 * Modify width and height values so that they will result in a memory
3270 * buffer that is acceptable for the codec if you do not use any horizontal
3271 * padding.
3272 *
3273 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3274 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3275 * according to avcodec_get_edge_width() before.
3276 */
3277 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
3278
3279 /**
3280 * Modify width and height values so that they will result in a memory
3281 * buffer that is acceptable for the codec if you also ensure that all
3282 * line sizes are a multiple of the respective linesize_align[i].
3283 *
3284 * May only be used if a codec with CODEC_CAP_DR1 has been opened.
3285 * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased
3286 * according to avcodec_get_edge_width() before.
3287 */
3288 void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
3289 int linesize_align[AV_NUM_DATA_POINTERS]);
3290
3291 /**
3292 * Decode the audio frame of size avpkt->size from avpkt->data into frame.
3293 *
3294 * Some decoders may support multiple frames in a single AVPacket. Such
3295 * decoders would then just decode the first frame. In this case,
3296 * avcodec_decode_audio4 has to be called again with an AVPacket containing
3297 * the remaining data in order to decode the second frame, etc...
3298 * Even if no frames are returned, the packet needs to be fed to the decoder
3299 * with remaining data until it is completely consumed or an error occurs.
3300 *
3301 * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE
3302 * larger than the actual read bytes because some optimized bitstream
3303 * readers read 32 or 64 bits at once and could read over the end.
3304 *
3305 * @note You might have to align the input buffer. The alignment requirements
3306 * depend on the CPU and the decoder.
3307 *
3308 * @param avctx the codec context
3309 * @param[out] frame The AVFrame in which to store decoded audio samples.
3310 * The decoder will allocate a buffer for the decoded frame by
3311 * calling the AVCodecContext.get_buffer2() callback.
3312 * When AVCodecContext.refcounted_frames is set to 1, the frame is
3313 * reference counted and the returned reference belongs to the
3314 * caller. The caller must release the frame using av_frame_unref()
3315 * when the frame is no longer needed. The caller may safely write
3316 * to the frame if av_frame_is_writable() returns 1.
3317 * When AVCodecContext.refcounted_frames is set to 0, the returned
3318 * reference belongs to the decoder and is valid only until the
3319 * next call to this function or until closing the decoder.
3320 * The caller may not write to it.
3321 * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is
3322 * non-zero.
3323 * @param[in] avpkt The input AVPacket containing the input buffer.
3324 * At least avpkt->data and avpkt->size should be set. Some
3325 * decoders might also require additional fields to be set.
3326 * @return A negative error code is returned if an error occurred during
3327 * decoding, otherwise the number of bytes consumed from the input
3328 * AVPacket is returned.
3329 */
3330 int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
3331 int *got_frame_ptr, AVPacket *avpkt);
3332
3333 /**
3334 * Decode the video frame of size avpkt->size from avpkt->data into picture.
3335 * Some decoders may support multiple frames in a single AVPacket, such
3336 * decoders would then just decode the first frame.
3337 *
3338 * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than
3339 * the actual read bytes because some optimized bitstream readers read 32 or 64
3340 * bits at once and could read over the end.
3341 *
3342 * @warning The end of the input buffer buf should be set to 0 to ensure that
3343 * no overreading happens for damaged MPEG streams.
3344 *
3345 * @note You might have to align the input buffer avpkt->data.
3346 * The alignment requirements depend on the CPU: on some CPUs it isn't
3347 * necessary at all, on others it won't work at all if not aligned and on others
3348 * it will work but it will have an impact on performance.
3349 *
3350 * In practice, avpkt->data should have 4 byte alignment at minimum.
3351 *
3352 * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay
3353 * between input and output, these need to be fed with avpkt->data=NULL,
3354 * avpkt->size=0 at the end to return the remaining frames.
3355 *
3356 * @param avctx the codec context
3357 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
3358 * Use av_frame_alloc() to get an AVFrame. The codec will
3359 * allocate memory for the actual bitmap by calling the
3360 * AVCodecContext.get_buffer2() callback.
3361 * When AVCodecContext.refcounted_frames is set to 1, the frame is
3362 * reference counted and the returned reference belongs to the
3363 * caller. The caller must release the frame using av_frame_unref()
3364 * when the frame is no longer needed. The caller may safely write
3365 * to the frame if av_frame_is_writable() returns 1.
3366 * When AVCodecContext.refcounted_frames is set to 0, the returned
3367 * reference belongs to the decoder and is valid only until the
3368 * next call to this function or until closing the decoder. The
3369 * caller may not write to it.
3370 *
3371 * @param[in] avpkt The input AVpacket containing the input buffer.
3372 * You can create such packet with av_init_packet() and by then setting
3373 * data and size, some decoders might in addition need other fields like
3374 * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least
3375 * fields possible.
3376 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero.
3377 * @return On error a negative value is returned, otherwise the number of bytes
3378 * used or zero if no frame could be decompressed.
3379 */
3380 int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
3381 int *got_picture_ptr,
3382 AVPacket *avpkt);
3383
3384 /**
3385 * Decode a subtitle message.
3386 * Return a negative value on error, otherwise return the number of bytes used.
3387 * If no subtitle could be decompressed, got_sub_ptr is zero.
3388 * Otherwise, the subtitle is stored in *sub.
3389 * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for
3390 * simplicity, because the performance difference is expect to be negligible
3391 * and reusing a get_buffer written for video codecs would probably perform badly
3392 * due to a potentially very different allocation pattern.
3393 *
3394 * @param avctx the codec context
3395 * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be
3396 freed with avsubtitle_free if *got_sub_ptr is set.
3397 * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero.
3398 * @param[in] avpkt The input AVPacket containing the input buffer.
3399 */
3400 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
3401 int *got_sub_ptr,
3402 AVPacket *avpkt);
3403
3404 /**
3405 * @defgroup lavc_parsing Frame parsing
3406 * @{
3407 */
3408
3409 typedef struct AVCodecParserContext {
3410 void *priv_data;
3411 struct AVCodecParser *parser;
3412 int64_t frame_offset; /* offset of the current frame */
3413 int64_t cur_offset; /* current offset
3414 (incremented by each av_parser_parse()) */
3415 int64_t next_frame_offset; /* offset of the next frame */
3416 /* video info */
3417 int pict_type; /* XXX: Put it back in AVCodecContext. */
3418 /**
3419 * This field is used for proper frame duration computation in lavf.
3420 * It signals, how much longer the frame duration of the current frame
3421 * is compared to normal frame duration.
3422 *
3423 * frame_duration = (1 + repeat_pict) * time_base
3424 *
3425 * It is used by codecs like H.264 to display telecined material.
3426 */
3427 int repeat_pict; /* XXX: Put it back in AVCodecContext. */
3428 int64_t pts; /* pts of the current frame */
3429 int64_t dts; /* dts of the current frame */
3430
3431 /* private data */
3432 int64_t last_pts;
3433 int64_t last_dts;
3434 int fetch_timestamp;
3435
3436 #define AV_PARSER_PTS_NB 4
3437 int cur_frame_start_index;
3438 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
3439 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
3440 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
3441
3442 int flags;
3443 #define PARSER_FLAG_COMPLETE_FRAMES 0x0001
3444 #define PARSER_FLAG_ONCE 0x0002
3445 /// Set if the parser has a valid file offset
3446 #define PARSER_FLAG_FETCHED_OFFSET 0x0004
3447
3448 int64_t offset; ///< byte offset from starting packet start
3449 int64_t cur_frame_end[AV_PARSER_PTS_NB];
3450
3451 /**
3452 * Set by parser to 1 for key frames and 0 for non-key frames.
3453 * It is initialized to -1, so if the parser doesn't set this flag,
3454 * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
3455 * will be used.
3456 */
3457 int key_frame;
3458
3459 /**
3460 * Time difference in stream time base units from the pts of this
3461 * packet to the point at which the output from the decoder has converged
3462 * independent from the availability of previous frames. That is, the
3463 * frames are virtually identical no matter if decoding started from
3464 * the very first frame or from this keyframe.
3465 * Is AV_NOPTS_VALUE if unknown.
3466 * This field is not the display duration of the current frame.
3467 * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
3468 * set.
3469 *
3470 * The purpose of this field is to allow seeking in streams that have no
3471 * keyframes in the conventional sense. It corresponds to the
3472 * recovery point SEI in H.264 and match_time_delta in NUT. It is also
3473 * essential for some types of subtitle streams to ensure that all
3474 * subtitles are correctly displayed after seeking.
3475 */
3476 int64_t convergence_duration;
3477
3478 // Timestamp generation support:
3479 /**
3480 * Synchronization point for start of timestamp generation.
3481 *
3482 * Set to >0 for sync point, 0 for no sync point and <0 for undefined
3483 * (default).
3484 *
3485 * For example, this corresponds to presence of H.264 buffering period
3486 * SEI message.
3487 */
3488 int dts_sync_point;
3489
3490 /**
3491 * Offset of the current timestamp against last timestamp sync point in
3492 * units of AVCodecContext.time_base.
3493 *
3494 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3495 * contain a valid timestamp offset.
3496 *
3497 * Note that the timestamp of sync point has usually a nonzero
3498 * dts_ref_dts_delta, which refers to the previous sync point. Offset of
3499 * the next frame after timestamp sync point will be usually 1.
3500 *
3501 * For example, this corresponds to H.264 cpb_removal_delay.
3502 */
3503 int dts_ref_dts_delta;
3504
3505 /**
3506 * Presentation delay of current frame in units of AVCodecContext.time_base.
3507 *
3508 * Set to INT_MIN when dts_sync_point unused. Otherwise, it must
3509 * contain valid non-negative timestamp delta (presentation time of a frame
3510 * must not lie in the past).
3511 *
3512 * This delay represents the difference between decoding and presentation
3513 * time of the frame.
3514 *
3515 * For example, this corresponds to H.264 dpb_output_delay.
3516 */
3517 int pts_dts_delta;
3518
3519 /**
3520 * Position of the packet in file.
3521 *
3522 * Analogous to cur_frame_pts/dts
3523 */
3524 int64_t cur_frame_pos[AV_PARSER_PTS_NB];
3525
3526 /**
3527 * Byte position of currently parsed frame in stream.
3528 */
3529 int64_t pos;
3530
3531 /**
3532 * Previous frame byte position.
3533 */
3534 int64_t last_pos;
3535
3536 /**
3537 * Duration of the current frame.
3538 * For audio, this is in units of 1 / AVCodecContext.sample_rate.
3539 * For all other types, this is in units of AVCodecContext.time_base.
3540 */
3541 int duration;
3542
3543 enum AVFieldOrder field_order;
3544 } AVCodecParserContext;
3545
3546 typedef struct AVCodecParser {
3547 int codec_ids[5]; /* several codec IDs are permitted */
3548 int priv_data_size;
3549 int (*parser_init)(AVCodecParserContext *s);
3550 int (*parser_parse)(AVCodecParserContext *s,
3551 AVCodecContext *avctx,
3552 const uint8_t **poutbuf, int *poutbuf_size,
3553 const uint8_t *buf, int buf_size);
3554 void (*parser_close)(AVCodecParserContext *s);
3555 int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
3556 struct AVCodecParser *next;
3557 } AVCodecParser;
3558
3559 AVCodecParser *av_parser_next(AVCodecParser *c);
3560
3561 void av_register_codec_parser(AVCodecParser *parser);
3562 AVCodecParserContext *av_parser_init(int codec_id);
3563
3564 /**
3565 * Parse a packet.
3566 *
3567 * @param s parser context.
3568 * @param avctx codec context.
3569 * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished.
3570 * @param poutbuf_size set to size of parsed buffer or zero if not yet finished.
3571 * @param buf input buffer.
3572 * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output).
3573 * @param pts input presentation timestamp.
3574 * @param dts input decoding timestamp.
3575 * @param pos input byte position in stream.
3576 * @return the number of bytes of the input bitstream used.
3577 *
3578 * Example:
3579 * @code
3580 * while(in_len){
3581 * len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
3582 * in_data, in_len,
3583 * pts, dts, pos);
3584 * in_data += len;
3585 * in_len -= len;
3586 *
3587 * if(size)
3588 * decode_frame(data, size);
3589 * }
3590 * @endcode
3591 */
3592 int av_parser_parse2(AVCodecParserContext *s,
3593 AVCodecContext *avctx,
3594 uint8_t **poutbuf, int *poutbuf_size,
3595 const uint8_t *buf, int buf_size,
3596 int64_t pts, int64_t dts,
3597 int64_t pos);
3598
3599 /**
3600 * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed
3601 * @deprecated use AVBitstreamFilter
3602 */
3603 int av_parser_change(AVCodecParserContext *s,
3604 AVCodecContext *avctx,
3605 uint8_t **poutbuf, int *poutbuf_size,
3606 const uint8_t *buf, int buf_size, int keyframe);
3607 void av_parser_close(AVCodecParserContext *s);
3608
3609 /**
3610 * @}
3611 * @}
3612 */
3613
3614 /**
3615 * @addtogroup lavc_encoding
3616 * @{
3617 */
3618
3619 /**
3620 * Find a registered encoder with a matching codec ID.
3621 *
3622 * @param id AVCodecID of the requested encoder
3623 * @return An encoder if one was found, NULL otherwise.
3624 */
3625 AVCodec *avcodec_find_encoder(enum AVCodecID id);
3626
3627 /**
3628 * Find a registered encoder with the specified name.
3629 *
3630 * @param name name of the requested encoder
3631 * @return An encoder if one was found, NULL otherwise.
3632 */
3633 AVCodec *avcodec_find_encoder_by_name(const char *name);
3634
3635 /**
3636 * Encode a frame of audio.
3637 *
3638 * Takes input samples from frame and writes the next output packet, if
3639 * available, to avpkt. The output packet does not necessarily contain data for
3640 * the most recent frame, as encoders can delay, split, and combine input frames
3641 * internally as needed.
3642 *
3643 * @param avctx codec context
3644 * @param avpkt output AVPacket.
3645 * The user can supply an output buffer by setting
3646 * avpkt->data and avpkt->size prior to calling the
3647 * function, but if the size of the user-provided data is not
3648 * large enough, encoding will fail. All other AVPacket fields
3649 * will be reset by the encoder using av_init_packet(). If
3650 * avpkt->data is NULL, the encoder will allocate it.
3651 * The encoder will set avpkt->size to the size of the
3652 * output packet.
3653 *
3654 * If this function fails or produces no output, avpkt will be
3655 * freed using av_free_packet() (i.e. avpkt->destruct will be
3656 * called to free the user supplied buffer).
3657 * @param[in] frame AVFrame containing the raw audio data to be encoded.
3658 * May be NULL when flushing an encoder that has the
3659 * CODEC_CAP_DELAY capability set.
3660 * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame
3661 * can have any number of samples.
3662 * If it is not set, frame->nb_samples must be equal to
3663 * avctx->frame_size for all frames except the last.
3664 * The final frame may be smaller than avctx->frame_size.
3665 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
3666 * output packet is non-empty, and to 0 if it is
3667 * empty. If the function returns an error, the
3668 * packet can be assumed to be invalid, and the
3669 * value of got_packet_ptr is undefined and should
3670 * not be used.
3671 * @return 0 on success, negative error code on failure
3672 */
3673 int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
3674 const AVFrame *frame, int *got_packet_ptr);
3675
3676 /**
3677 * Encode a frame of video.
3678 *
3679 * Takes input raw video data from frame and writes the next output packet, if
3680 * available, to avpkt. The output packet does not necessarily contain data for
3681 * the most recent frame, as encoders can delay and reorder input frames
3682 * internally as needed.
3683 *
3684 * @param avctx codec context
3685 * @param avpkt output AVPacket.
3686 * The user can supply an output buffer by setting
3687 * avpkt->data and avpkt->size prior to calling the
3688 * function, but if the size of the user-provided data is not
3689 * large enough, encoding will fail. All other AVPacket fields
3690 * will be reset by the encoder using av_init_packet(). If
3691 * avpkt->data is NULL, the encoder will allocate it.
3692 * The encoder will set avpkt->size to the size of the
3693 * output packet. The returned data (if any) belongs to the
3694 * caller, he is responsible for freeing it.
3695 *
3696 * If this function fails or produces no output, avpkt will be
3697 * freed using av_free_packet() (i.e. avpkt->destruct will be
3698 * called to free the user supplied buffer).
3699 * @param[in] frame AVFrame containing the raw video data to be encoded.
3700 * May be NULL when flushing an encoder that has the
3701 * CODEC_CAP_DELAY capability set.
3702 * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the
3703 * output packet is non-empty, and to 0 if it is
3704 * empty. If the function returns an error, the
3705 * packet can be assumed to be invalid, and the
3706 * value of got_packet_ptr is undefined and should
3707 * not be used.
3708 * @return 0 on success, negative error code on failure
3709 */
3710 int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
3711 const AVFrame *frame, int *got_packet_ptr);
3712
3713 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
3714 const AVSubtitle *sub);
3715
3716
3717 /**
3718 * @}
3719 */
3720
3721 /**
3722 * @addtogroup lavc_picture
3723 * @{
3724 */
3725
3726 /**
3727 * Allocate memory for a picture. Call avpicture_free() to free it.
3728 *
3729 * @see avpicture_fill()
3730 *
3731 * @param picture the picture to be filled in
3732 * @param pix_fmt the format of the picture
3733 * @param width the width of the picture
3734 * @param height the height of the picture
3735 * @return zero if successful, a negative value if not
3736 */
3737 int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height);
3738
3739 /**
3740 * Free a picture previously allocated by avpicture_alloc().
3741 * The data buffer used by the AVPicture is freed, but the AVPicture structure
3742 * itself is not.
3743 *
3744 * @param picture the AVPicture to be freed
3745 */
3746 void avpicture_free(AVPicture *picture);
3747
3748 /**
3749 * Fill in the AVPicture fields.
3750 * The fields of the given AVPicture are filled in by using the 'ptr' address
3751 * which points to the image data buffer. Depending on the specified picture
3752 * format, one or multiple image data pointers and line sizes will be set.
3753 * If a planar format is specified, several pointers will be set pointing to
3754 * the different picture planes and the line sizes of the different planes
3755 * will be stored in the lines_sizes array.
3756 * Call with ptr == NULL to get the required size for the ptr buffer.
3757 *
3758 * To allocate the buffer and fill in the AVPicture fields in one call,
3759 * use avpicture_alloc().
3760 *
3761 * @param picture AVPicture whose fields are to be filled in
3762 * @param ptr Buffer which will contain or contains the actual image data
3763 * @param pix_fmt The format in which the picture data is stored.
3764 * @param width the width of the image in pixels
3765 * @param height the height of the image in pixels
3766 * @return size of the image data in bytes
3767 */
3768 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
3769 enum AVPixelFormat pix_fmt, int width, int height);
3770
3771 /**
3772 * Copy pixel data from an AVPicture into a buffer.
3773 * The data is stored compactly, without any gaps for alignment or padding
3774 * which may be applied by avpicture_fill().
3775 *
3776 * @see avpicture_get_size()
3777 *
3778 * @param[in] src AVPicture containing image data
3779 * @param[in] pix_fmt The format in which the picture data is stored.
3780 * @param[in] width the width of the image in pixels.
3781 * @param[in] height the height of the image in pixels.
3782 * @param[out] dest A buffer into which picture data will be copied.
3783 * @param[in] dest_size The size of 'dest'.
3784 * @return The number of bytes written to dest, or a negative value (error code) on error.
3785 */
3786 int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt,
3787 int width, int height,
3788 unsigned char *dest, int dest_size);
3789
3790 /**
3791 * Calculate the size in bytes that a picture of the given width and height
3792 * would occupy if stored in the given picture format.
3793 * Note that this returns the size of a compact representation as generated
3794 * by avpicture_layout(), which can be smaller than the size required for e.g.
3795 * avpicture_fill().
3796 *
3797 * @param pix_fmt the given picture format
3798 * @param width the width of the image
3799 * @param height the height of the image
3800 * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
3801 */
3802 int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
3803
3804 #if FF_API_DEINTERLACE
3805 /**
3806 * deinterlace - if not supported return -1
3807 *
3808 * @deprecated - use yadif (in libavfilter) instead
3809 */
3810 attribute_deprecated
3811 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
3812 enum AVPixelFormat pix_fmt, int width, int height);
3813 #endif
3814 /**