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