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