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