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