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