Print a list of valid AMR bitrates if a wrong one is used.
[libav.git] / libavcodec / avcodec.h
CommitLineData
04d7f601
DB
1/*
2 * copyright (c) 2001 Fabrice Bellard
3 *
b78e7197
DB
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg 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 *
b78e7197 11 * FFmpeg 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
b78e7197 17 * License along with FFmpeg; if not, write to the Free Software
04d7f601
DB
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
a96b68b7
FB
21#ifndef AVCODEC_H
22#define AVCODEC_H
23
36df8805
MN
24/**
25 * @file avcodec.h
d33c949c 26 * external api header.
36df8805
MN
27 */
28
29
02d697aa
ZK
30#ifdef __cplusplus
31extern "C" {
32#endif
33
c11c2bc2 34#include "avutil.h"
4b813d5c 35#include <sys/types.h> /* size_t */
de6d9b64 36
bb270c08 37#define AV_STRINGIFY(s) AV_TOSTRING(s)
7b7d86f1 38#define AV_TOSTRING(s) #s
5aa083ee 39
d215d07a
IK
40#define LIBAVCODEC_VERSION_INT ((51<<16)+(40<<8)+2)
41#define LIBAVCODEC_VERSION 51.40.2
bb270c08 42#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
5aa083ee 43
bb270c08 44#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
ce2749d2 45
8da9266c 46#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
bb270c08
DB
47#define AV_TIME_BASE 1000000
48#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
9740beff 49
7ebf5927
MN
50/**
51 *
52 * if you add a codec id to this list add it so that
53 * 1. no value of a existing codec id changes (that would break ABI)
54 * 2. closest to similar codecs
55 */
de6d9b64 56enum CodecID {
115329f1 57 CODEC_ID_NONE,
de6d9b64 58 CODEC_ID_MPEG1VIDEO,
dcedf586 59 CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
fb364ada 60 CODEC_ID_MPEG2VIDEO_XVMC,
c6148de2 61 CODEC_ID_H261,
de6d9b64
FB
62 CODEC_ID_H263,
63 CODEC_ID_RV10,
68b94c35 64 CODEC_ID_RV20,
de6d9b64 65 CODEC_ID_MJPEG,
b135d9fb 66 CODEC_ID_MJPEGB,
b1e6b355 67 CODEC_ID_LJPEG,
5e83dec4 68 CODEC_ID_SP5X,
5639729b 69 CODEC_ID_JPEGLS,
bf89e6b1 70 CODEC_ID_MPEG4,
de6d9b64 71 CODEC_ID_RAWVIDEO,
84afee34
MN
72 CODEC_ID_MSMPEG4V1,
73 CODEC_ID_MSMPEG4V2,
74 CODEC_ID_MSMPEG4V3,
e1a9dbff 75 CODEC_ID_WMV1,
b50eef3a 76 CODEC_ID_WMV2,
de6d9b64
FB
77 CODEC_ID_H263P,
78 CODEC_ID_H263I,
d4f5d74a 79 CODEC_ID_FLV1,
be8ffec9 80 CODEC_ID_SVQ1,
8b82a956 81 CODEC_ID_SVQ3,
020fcc94 82 CODEC_ID_DVVIDEO,
11f18faf 83 CODEC_ID_HUFFYUV,
f70f7c6d 84 CODEC_ID_CYUV,
0da71265 85 CODEC_ID_H264,
deabd4fd 86 CODEC_ID_INDEO3,
d86053a4 87 CODEC_ID_VP3,
f44ee2c3 88 CODEC_ID_THEORA,
3d2e8cce 89 CODEC_ID_ASV1,
9b56edf5 90 CODEC_ID_ASV2,
5e20f836 91 CODEC_ID_FFV1,
e2a7bb28 92 CODEC_ID_4XM,
be3564ed 93 CODEC_ID_VCR1,
3aff069b 94 CODEC_ID_CLJR,
c3bf0288 95 CODEC_ID_MDEC,
3ef8be2b
MM
96 CODEC_ID_ROQ,
97 CODEC_ID_INTERPLAY_VIDEO,
9937e686
MM
98 CODEC_ID_XAN_WC3,
99 CODEC_ID_XAN_WC4,
2fdf638b
MM
100 CODEC_ID_RPZA,
101 CODEC_ID_CINEPAK,
102 CODEC_ID_WS_VQA,
103 CODEC_ID_MSRLE,
104 CODEC_ID_MSVIDEO1,
4120a53a 105 CODEC_ID_IDCIN,
1dc1ed99 106 CODEC_ID_8BPS,
11e29a41 107 CODEC_ID_SMC,
42cad81a 108 CODEC_ID_FLIC,
9a4117d5 109 CODEC_ID_TRUEMOTION1,
fafa0b75 110 CODEC_ID_VMDVIDEO,
a273bbfb
RT
111 CODEC_ID_MSZH,
112 CODEC_ID_ZLIB,
070ed1bc 113 CODEC_ID_QTRLE,
791e7b83 114 CODEC_ID_SNOW,
9d53d58e 115 CODEC_ID_TSCC,
d0a0bbd2 116 CODEC_ID_ULTI,
d08d7142 117 CODEC_ID_QDRAW,
ab711b3c 118 CODEC_ID_VIXL,
acfd8f0f 119 CODEC_ID_QPEG,
17179d2d
MN
120 CODEC_ID_XVID,
121 CODEC_ID_PNG,
122 CODEC_ID_PPM,
123 CODEC_ID_PBM,
124 CODEC_ID_PGM,
125 CODEC_ID_PGMYUV,
126 CODEC_ID_PAM,
f37b9768 127 CODEC_ID_FFVHUFF,
3f05305d
MN
128 CODEC_ID_RV30,
129 CODEC_ID_RV40,
10b9c374 130 CODEC_ID_VC1,
21aa398f 131 CODEC_ID_WMV3,
9c7fb608 132 CODEC_ID_LOCO,
a8a15e9d 133 CODEC_ID_WNV1,
589f8220 134 CODEC_ID_AASC,
856dbbff 135 CODEC_ID_INDEO2,
b81f8949 136 CODEC_ID_FRAPS,
64af6168 137 CODEC_ID_TRUEMOTION2,
9fa62f2a 138 CODEC_ID_BMP,
e0f80bd7 139 CODEC_ID_CSCD,
4e114829 140 CODEC_ID_MMVIDEO,
9c8d8e84 141 CODEC_ID_ZMBV,
26376701 142 CODEC_ID_AVS,
348efc18 143 CODEC_ID_SMACKVIDEO,
dfca23e3 144 CODEC_ID_NUV,
fd7b1991 145 CODEC_ID_KMVC,
0919e788 146 CODEC_ID_FLASHSV,
20ffddb9 147 CODEC_ID_CAVS,
f31065f6 148 CODEC_ID_JPEG2000,
eb57c889 149 CODEC_ID_VMNC,
5ce117c3
AJ
150 CODEC_ID_VP5,
151 CODEC_ID_VP6,
152 CODEC_ID_VP6F,
3689cf16 153 CODEC_ID_TARGA,
72450e50 154 CODEC_ID_DSICINVIDEO,
29f86228 155 CODEC_ID_TIERTEXSEQVIDEO,
a991b1fe 156 CODEC_ID_TIFF,
06d392a7 157 CODEC_ID_GIF,
3edeab82 158 CODEC_ID_FFH264,
33a0dd37 159 CODEC_ID_DXA,
52b6bad2 160 CODEC_ID_DNXHD,
efb0c399 161 CODEC_ID_THP,
2d99eed1 162 CODEC_ID_SGI,
a96b68b7
FB
163
164 /* various pcm "codecs" */
17179d2d 165 CODEC_ID_PCM_S16LE= 0x10000,
a96b68b7
FB
166 CODEC_ID_PCM_S16BE,
167 CODEC_ID_PCM_U16LE,
168 CODEC_ID_PCM_U16BE,
169 CODEC_ID_PCM_S8,
170 CODEC_ID_PCM_U8,
171 CODEC_ID_PCM_MULAW,
172 CODEC_ID_PCM_ALAW,
b461b3bc
RD
173 CODEC_ID_PCM_S32LE,
174 CODEC_ID_PCM_S32BE,
175 CODEC_ID_PCM_U32LE,
176 CODEC_ID_PCM_U32BE,
177 CODEC_ID_PCM_S24LE,
178 CODEC_ID_PCM_S24BE,
179 CODEC_ID_PCM_U24LE,
180 CODEC_ID_PCM_U24BE,
181 CODEC_ID_PCM_S24DAUD,
0147f198
FR
182
183 /* various adpcm codecs */
17179d2d 184 CODEC_ID_ADPCM_IMA_QT= 0x11000,
0147f198 185 CODEC_ID_ADPCM_IMA_WAV,
9937e686
MM
186 CODEC_ID_ADPCM_IMA_DK3,
187 CODEC_ID_ADPCM_IMA_DK4,
2fdf638b 188 CODEC_ID_ADPCM_IMA_WS,
7d8379f2 189 CODEC_ID_ADPCM_IMA_SMJPEG,
0147f198 190 CODEC_ID_ADPCM_MS,
e2a7bb28 191 CODEC_ID_ADPCM_4XM,
fc384777
MM
192 CODEC_ID_ADPCM_XA,
193 CODEC_ID_ADPCM_ADX,
7d8379f2 194 CODEC_ID_ADPCM_EA,
e5966052 195 CODEC_ID_ADPCM_G726,
b3bfb299 196 CODEC_ID_ADPCM_CT,
659c3692 197 CODEC_ID_ADPCM_SWF,
2ff4524e 198 CODEC_ID_ADPCM_YAMAHA,
2433f24f
AJ
199 CODEC_ID_ADPCM_SBPRO_4,
200 CODEC_ID_ADPCM_SBPRO_3,
201 CODEC_ID_ADPCM_SBPRO_2,
891f64b3 202
17179d2d
MN
203 /* AMR */
204 CODEC_ID_AMR_NB= 0x12000,
d663a1fd
MN
205 CODEC_ID_AMR_WB,
206
b8414bbd 207 /* RealAudio codecs*/
17179d2d 208 CODEC_ID_RA_144= 0x13000,
b8414bbd 209 CODEC_ID_RA_288,
3ef8be2b
MM
210
211 /* various DPCM codecs */
17179d2d 212 CODEC_ID_ROQ_DPCM= 0x14000,
3ef8be2b 213 CODEC_ID_INTERPLAY_DPCM,
9937e686 214 CODEC_ID_XAN_DPCM,
d08d7142 215 CODEC_ID_SOL_DPCM,
115329f1 216
17179d2d
MN
217 CODEC_ID_MP2= 0x15000,
218 CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
219 CODEC_ID_AAC,
cbee7a69 220#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
17179d2d 221 CODEC_ID_MPEG4AAC,
cbee7a69 222#endif
17179d2d
MN
223 CODEC_ID_AC3,
224 CODEC_ID_DTS,
225 CODEC_ID_VORBIS,
226 CODEC_ID_DVAUDIO,
227 CODEC_ID_WMAV1,
228 CODEC_ID_WMAV2,
229 CODEC_ID_MACE3,
230 CODEC_ID_MACE6,
231 CODEC_ID_VMDAUDIO,
232 CODEC_ID_SONIC,
233 CODEC_ID_SONIC_LS,
ac2570a8 234 CODEC_ID_FLAC,
1ede228a 235 CODEC_ID_MP3ADU,
d2a7718d 236 CODEC_ID_MP3ON4,
85ad5695 237 CODEC_ID_SHORTEN,
5df8a0c6 238 CODEC_ID_ALAC,
034eeaa1 239 CODEC_ID_WESTWOOD_SND1,
346a655d 240 CODEC_ID_GSM, /* As in Berlin toast format */
d9b1c197 241 CODEC_ID_QDM2,
e0f7e329 242 CODEC_ID_COOK,
bf3027c8 243 CODEC_ID_TRUESPEECH,
a24c4a2a 244 CODEC_ID_TTA,
348efc18 245 CODEC_ID_SMACKAUDIO,
6c496518 246 CODEC_ID_QCELP,
730581f3 247 CODEC_ID_WAVPACK,
72450e50 248 CODEC_ID_DSICINAUDIO,
84ed36da 249 CODEC_ID_IMC,
185c7b6b 250 CODEC_ID_MUSEPACK7,
aad512b4 251 CODEC_ID_MLP,
346a655d 252 CODEC_ID_GSM_MS, /* As found in WAV */
115329f1 253
240c1657 254 /* subtitle codecs */
115329f1
DB
255 CODEC_ID_DVD_SUBTITLE= 0x17000,
256 CODEC_ID_DVB_SUBTITLE,
257
17179d2d 258 CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG2 transport
985180a1 259 stream (only used by libavformat) */
de6d9b64 260};
dcedf586 261
abd6a4fc 262#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
dcedf586
FB
263/* CODEC_ID_MP3LAME is absolete */
264#define CODEC_ID_MP3LAME CODEC_ID_MP3
abd6a4fc
BC
265#define CODEC_ID_MPEG4AAC CODEC_ID_AAC
266#endif
de6d9b64
FB
267
268enum CodecType {
4a663d80 269 CODEC_TYPE_UNKNOWN = -1,
de6d9b64
FB
270 CODEC_TYPE_VIDEO,
271 CODEC_TYPE_AUDIO,
985180a1 272 CODEC_TYPE_DATA,
240c1657 273 CODEC_TYPE_SUBTITLE,
9ff77d17 274 CODEC_TYPE_NB
de6d9b64
FB
275};
276
a96b68b7 277/* currently unused, may be used if 24/32 bits samples ever supported */
1319a77b 278/* all in native endian */
a96b68b7 279enum SampleFormat {
9076fee4 280 SAMPLE_FMT_NONE = -1,
1319a77b
AB
281 SAMPLE_FMT_U8, ///< unsigned 8 bits
282 SAMPLE_FMT_S16, ///< signed 16 bits
283 SAMPLE_FMT_S24, ///< signed 24 bits
115329f1 284 SAMPLE_FMT_S32, ///< signed 32 bits
a3a5f4d6 285 SAMPLE_FMT_FLT, ///< float
a96b68b7
FB
286};
287
de6d9b64 288/* in bytes */
8170e5fb 289#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
de6d9b64 290
d7425f59 291/**
cf713bb8 292 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
115329f1 293 * this is mainly needed because some optimized bitstream readers read
cf713bb8
MN
294 * 32 or 64 bit at once and could read over the end<br>
295 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
296 * MPEG bitstreams could cause overread and segfault
d7425f59
MN
297 */
298#define FF_INPUT_BUFFER_PADDING_SIZE 8
299
0ecca7a4
MN
300/**
301 * minimum encoding buffer size.
302 * used to avoid some checks during header writing
303 */
304#define FF_MIN_BUFFER_SIZE 16384
305
e4986da9
J
306/* motion estimation type, EPZS by default */
307enum Motion_Est_ID {
101bea5f 308 ME_ZERO = 1,
e4986da9
J
309 ME_FULL,
310 ME_LOG,
311 ME_PHODS,
312 ME_EPZS,
51d6a3cf
MN
313 ME_X1,
314 ME_HEX,
315 ME_UMH,
316 ME_ITER,
e4986da9
J
317};
318
8c3eba7c
MN
319enum AVDiscard{
320//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
321 AVDISCARD_NONE =-16, ///< discard nothing
322 AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi
323 AVDISCARD_NONREF = 8, ///< discard all non reference
324 AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames
325 AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
326 AVDISCARD_ALL = 48, ///< discard all
327};
328
ce980a95
MN
329typedef struct RcOverride{
330 int start_frame;
331 int end_frame;
332 int qscale; // if this is 0 then quality_factor will be used instead
333 float quality_factor;
334} RcOverride;
335
b0ec9efd 336#define FF_MAX_B_FRAMES 16
9dbcbd92 337
a949d72e 338/* encoding support
115329f1 339 these flags can be passed in AVCodecContext.flags before initing
bb628dae 340 Note: not everything is supported yet.
a949d72e 341*/
de6d9b64 342
115329f1 343#define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
dba019da 344#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / Advanced prediction for H263
115329f1
DB
345#define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
346#define CODEC_FLAG_GMC 0x0020 ///< use GMC
347#define CODEC_FLAG_MV0 0x0040 ///< always try a MB with MV=<0,0>
348#define CODEC_FLAG_PART 0x0080 ///< use data partitioning
57177f64 349/* parent program guarantees that the input for b-frame containing streams is not written to
9dbcbd92 350 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
8b4c7dbc 351#define CODEC_FLAG_INPUT_PRESERVED 0x0100
115329f1
DB
352#define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
353#define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
354#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
355#define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
bb628dae 356#define CODEC_FLAG_EMU_EDGE 0x4000///< don't draw edges
115329f1
DB
357#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
358#define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
d7425f59 359 of only at frame boundaries */
115329f1
DB
360#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
361#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
3bb07d61 362#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay
115329f1
DB
363#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
364#define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
365#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
366#define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
21e59552 367/* Fx : Flag for h263+ extra options */
6b936ec6 368#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
8d8c0294 369#define CODEC_FLAG_H263P_AIC 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction (remove this)
6b936ec6 370#endif
8d8c0294 371#define CODEC_FLAG_AC_PRED 0x01000000 ///< H263 Advanced intra coding / MPEG4 AC prediction
115329f1 372#define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
f2f6134b 373#define CODEC_FLAG_CBP_RD 0x04000000 ///< use rate distortion optimization for cbp
1f26c6f3 374#define CODEC_FLAG_QP_RD 0x08000000 ///< use rate distortion optimization for qp selectioon
dba019da 375#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H263 Alternative inter vlc
332f9ac4
MN
376#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
377#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
bb198e19
MN
378#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
379#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
baaf3f46 380#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data
f2cf4a6b 381#define CODEC_FLAG_CLOSED_GOP ((int)0x80000000)
6fc5b059 382#define CODEC_FLAG2_FAST 0x00000001 ///< allow non spec compliant speedup tricks
03581772 383#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< strictly enforce GOP size
09b0499f 384#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< skip bitstream encoding
90ad92b3 385#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< place global headers at every keyframe instead of in extradata
58f7833e
RS
386#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow b-frames to be used as references
387#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for b-frames
d3075ed5 388#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock
58f7833e
RS
389#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform
390#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
391#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
392#define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization
307eb248 393#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
086bfd25 394#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< only do ME/MC (I frames -> ref, P frame -> ME+MC)
80d617f5 395#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format
c52f5d66 396#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skiping
66a4b2c1 397#define CODEC_FLAG2_CHUNKS 0x00008000 ///< input bitstream might be truncated at a packet boundaries instead of only at frame boundaries
5a6b9443 398#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< use MPEG-2 non linear quantizer
6fc5b059 399
21e59552 400/* Unsupported options :
bb270c08
DB
401 * Syntax Arithmetic coding (SAC)
402 * Reference Picture Selection
eafcac6a 403 * Independent Segment Decoding */
21e59552 404/* /Fx */
bf89e6b1
FB
405/* codec capabilities */
406
115329f1 407#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
6814a25c
MN
408/**
409 * Codec uses get_buffer() for allocating buffers.
410 * direct rendering method 1
411 */
412#define CODEC_CAP_DR1 0x0002
917e06c8
FB
413/* if 'parse_only' field is true, then avcodec_parse_frame() can be
414 used */
415#define CODEC_CAP_PARSE_ONLY 0x0004
d7425f59 416#define CODEC_CAP_TRUNCATED 0x0008
5e5c247a
IK
417/* codec can export data for HW decoding (XvMC) */
418#define CODEC_CAP_HWACCEL 0x0010
115329f1 419/**
934982c4 420 * codec has a non zero delay and needs to be feeded with NULL at the end to get the delayed data.
57177f64 421 * if this is not set, the codec is guaranteed to never be feeded with NULL data
934982c4 422 */
6f824977 423#define CODEC_CAP_DELAY 0x0020
cef7cc72
JR
424/**
425 * Codec can be fed a final frame with a smaller size.
426 * This can be used to prevent truncation of the last audio samples.
427 */
428#define CODEC_CAP_SMALL_LAST_FRAME 0x0040
bf89e6b1 429
bb628dae 430//the following defines may change, don't expect compatibility if you use them
8d7ec294
WH
431#define MB_TYPE_INTRA4x4 0x0001
432#define MB_TYPE_INTRA16x16 0x0002 //FIXME h264 specific
433#define MB_TYPE_INTRA_PCM 0x0004 //FIXME h264 specific
434#define MB_TYPE_16x16 0x0008
435#define MB_TYPE_16x8 0x0010
436#define MB_TYPE_8x16 0x0020
437#define MB_TYPE_8x8 0x0040
438#define MB_TYPE_INTERLACED 0x0080
439#define MB_TYPE_DIRECT2 0x0100 //FIXME
440#define MB_TYPE_ACPRED 0x0200
441#define MB_TYPE_GMC 0x0400
442#define MB_TYPE_SKIP 0x0800
443#define MB_TYPE_P0L0 0x1000
444#define MB_TYPE_P1L0 0x2000
445#define MB_TYPE_P0L1 0x4000
446#define MB_TYPE_P1L1 0x8000
447#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
448#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
449#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
450#define MB_TYPE_QUANT 0x00010000
451#define MB_TYPE_CBP 0x00020000
452//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
453
fa384dcc
MN
454/**
455 * Pan Scan area.
456 * this specifies the area which should be displayed. Note there may be multiple such areas for one frame
457 */
458typedef struct AVPanScan{
459 /**
460 * id.
461 * - encoding: set by user.
462 * - decoding: set by lavc
463 */
464 int id;
465
466 /**
467 * width and height in 1/16 pel
468 * - encoding: set by user.
469 * - decoding: set by lavc
470 */
471 int width;
472 int height;
473
474 /**
475 * position of the top left corner in 1/16 pel for up to 3 fields/frames.
476 * - encoding: set by user.
477 * - decoding: set by lavc
478 */
479 int16_t position[3][2];
480}AVPanScan;
481
492cd3a9 482#define FF_COMMON_FRAME \
b536d0aa
MN
483 /**\
484 * pointer to the picture planes.\
485 * this might be different from the first allocated byte\
486 * - encoding: \
487 * - decoding: \
488 */\
1e491e29
MN
489 uint8_t *data[4];\
490 int linesize[4];\
491 /**\
32db2b1d 492 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
bb628dae 493 * this isn't used by lavc unless the default get/release_buffer() is used\
64863965
MN
494 * - encoding: \
495 * - decoding: \
1e491e29
MN
496 */\
497 uint8_t *base[4];\
498 /**\
499 * 1 -> keyframe, 0-> not\
64863965
MN
500 * - encoding: set by lavc\
501 * - decoding: set by lavc\
1e491e29
MN
502 */\
503 int key_frame;\
504\
505 /**\
0da71265 506 * picture type of the frame, see ?_TYPE below.\
64863965
MN
507 * - encoding: set by lavc for coded_picture (and set by user for input)\
508 * - decoding: set by lavc\
1e491e29
MN
509 */\
510 int pict_type;\
511\
512 /**\
c0df9d75
MN
513 * presentation timestamp in time_base units (time when frame should be shown to user)\
514 * if AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed\
64863965
MN
515 * - encoding: MUST be set by user\
516 * - decoding: set by lavc\
1e491e29 517 */\
be6784dc 518 int64_t pts;\
1e491e29
MN
519\
520 /**\
521 * picture number in bitstream order.\
64863965
MN
522 * - encoding: set by\
523 * - decoding: set by lavc\
1e491e29
MN
524 */\
525 int coded_picture_number;\
526 /**\
1e491e29 527 * picture number in display order.\
64863965
MN
528 * - encoding: set by\
529 * - decoding: set by lavc\
1e491e29
MN
530 */\
531 int display_picture_number;\
532\
533 /**\
158c7f05 534 * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \
64863965
MN
535 * - encoding: set by lavc for coded_picture (and set by user for input)\
536 * - decoding: set by lavc\
1e491e29 537 */\
158c7f05 538 int quality; \
1e491e29
MN
539\
540 /**\
541 * buffer age (1->was last buffer and dint change, 2->..., ...).\
158c7f05 542 * set to INT_MAX if the buffer has not been used yet \
64863965
MN
543 * - encoding: unused\
544 * - decoding: MUST be set by get_buffer()\
1e491e29
MN
545 */\
546 int age;\
547\
548 /**\
549 * is this picture used as reference\
64863965
MN
550 * - encoding: unused\
551 * - decoding: set by lavc (before get_buffer() call))\
1e491e29
MN
552 */\
553 int reference;\
554\
555 /**\
556 * QP table\
64863965
MN
557 * - encoding: unused\
558 * - decoding: set by lavc\
1e491e29
MN
559 */\
560 int8_t *qscale_table;\
561 /**\
562 * QP store stride\
64863965
MN
563 * - encoding: unused\
564 * - decoding: set by lavc\
1e491e29
MN
565 */\
566 int qstride;\
567\
568 /**\
569 * mbskip_table[mb]>=1 if MB didnt change\
570 * stride= mb_width = (width+15)>>4\
64863965
MN
571 * - encoding: unused\
572 * - decoding: set by lavc\
1e491e29
MN
573 */\
574 uint8_t *mbskip_table;\
575\
576 /**\
61436073
MN
577 * Motion vector table.\
578 * @code\
579 * example:\
580 * int mv_sample_log2= 4 - motion_subsample_log2;\
581 * int mb_width= (width+15)>>4;\
582 * int mv_stride= (mb_width << mv_sample_log2) + 1;\
583 * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\
584 * @endcode\
a4d36c11 585 * - encoding: set by user\
8d7ec294
WH
586 * - decoding: set by lavc\
587 */\
588 int16_t (*motion_val[2])[2];\
589\
590 /**\
591 * Macroblock type table\
592 * mb_type_base + mb_width + 2\
a4d36c11 593 * - encoding: set by user\
8d7ec294
WH
594 * - decoding: set by lavc\
595 */\
596 uint32_t *mb_type;\
597\
598 /**\
f0b77c69
MN
599 * log2 of the size of the block which a single vector in motion_val represents: \
600 * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\
8d7ec294
WH
601 * - encoding: unused\
602 * - decoding: set by lavc\
603 */\
604 uint8_t motion_subsample_log2;\
605\
606 /**\
1e491e29 607 * for some private data of the user\
64863965
MN
608 * - encoding: unused\
609 * - decoding: set by user\
1e491e29
MN
610 */\
611 void *opaque;\
140cb663
MN
612\
613 /**\
614 * error\
64863965
MN
615 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
616 * - decoding: unused\
140cb663
MN
617 */\
618 uint64_t error[4];\
4e00e76b
MN
619\
620 /**\
621 * type of the buffer (to keep track of who has to dealloc data[*])\
64863965
MN
622 * - encoding: set by the one who allocs it\
623 * - decoding: set by the one who allocs it\
3db320ea 624 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
4e00e76b
MN
625 */\
626 int type;\
2ec23b6d
MN
627 \
628 /**\
629 * when decoding, this signal how much the picture must be delayed.\
630 * extra_delay = repeat_pict / (2*fps)\
64863965
MN
631 * - encoding: unused\
632 * - decoding: set by lavc\
2ec23b6d 633 */\
0426af31
MN
634 int repeat_pict;\
635 \
636 /**\
637 * \
638 */\
639 int qscale_type;\
2744ca9a
RS
640 \
641 /**\
642 * The content of the picture is interlaced.\
643 * - encoding: set by user\
644 * - decoding: set by lavc (default 0)\
645 */\
646 int interlaced_frame;\
647 \
648 /**\
9dad924e 649 * if the content is interlaced, is top field displayed first.\
2744ca9a 650 * - encoding: set by user\
9dad924e 651 * - decoding: set by lavc\
2744ca9a 652 */\
9dad924e 653 int top_field_first;\
fa384dcc
MN
654 \
655 /**\
656 * Pan scan.\
657 * - encoding: set by user\
658 * - decoding: set by lavc\
659 */\
660 AVPanScan *pan_scan;\
2a2bbcb0
MM
661 \
662 /**\
663 * tell user application that palette has changed from previous frame.\
664 * - encoding: ??? (no palette-enabled encoder yet)\
665 * - decoding: set by lavc (default 0)\
666 */\
667 int palette_has_changed;\
074c4ca7
RT
668 \
669 /**\
670 * Codec suggestion on buffer type if != 0\
671 * - encoding: unused\
672 * - decoding: set by lavc (before get_buffer() call))\
673 */\
674 int buffer_hints;\
8289c6fa
WH
675\
676 /**\
677 * DCT coeffitients\
678 * - encoding: unused\
679 * - decoding: set by lavc\
680 */\
681 short *dct_coeff;\
a4d36c11
MN
682\
683 /**\
684 * Motion referece frame index\
685 * - encoding: set by user\
686 * - decoding: set by lavc\
687 */\
688 int8_t *ref_index[2];
2ec23b6d 689
bb270c08
DB
690#define FF_QSCALE_TYPE_MPEG1 0
691#define FF_QSCALE_TYPE_MPEG2 1
692#define FF_QSCALE_TYPE_H264 2
4e00e76b
MN
693
694#define FF_BUFFER_TYPE_INTERNAL 1
9b56edf5 695#define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers (image is (de)allocated by user)
bb628dae
DB
696#define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewhere else, don't dealloc image (data/base), all other tables are not shared
697#define FF_BUFFER_TYPE_COPY 8 ///< just a (modified) copy of some other buffer, don't dealloc anything
4e00e76b 698
1e491e29 699
140cb663
MN
700#define FF_I_TYPE 1 // Intra
701#define FF_P_TYPE 2 // Predicted
702#define FF_B_TYPE 3 // Bi-dir predicted
703#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
0da71265
MN
704#define FF_SI_TYPE 5
705#define FF_SP_TYPE 6
1e491e29 706
074c4ca7
RT
707#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore)
708#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer
709#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content
710#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update)
711
0da71265
MN
712/**
713 * Audio Video Frame.
714 */
492cd3a9
MN
715typedef struct AVFrame {
716 FF_COMMON_FRAME
717} AVFrame;
1e491e29 718
14bea432 719#define DEFAULT_FRAME_RATE_BASE 1001000
d33c949c
MN
720
721/**
722 * main external api structure.
723 */
de6d9b64 724typedef struct AVCodecContext {
b71901e6 725 /**
bc874dae
MB
726 * Info on struct for av_log
727 * - set by avcodec_alloc_context
728 */
43465395 729 AVClass *av_class;
bc874dae 730 /**
64863965
MN
731 * the average bitrate.
732 * - encoding: set by user. unused for constant quantizer encoding
115329f1 733 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
b71901e6 734 */
de6d9b64 735 int bit_rate;
b71901e6
MN
736
737 /**
64863965 738 * number of bits the bitstream is allowed to diverge from the reference.
b71901e6 739 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
64863965
MN
740 * - encoding: set by user. unused for constant quantizer encoding
741 * - decoding: unused
b71901e6 742 */
115329f1 743 int bit_rate_tolerance;
b71901e6
MN
744
745 /**
64863965
MN
746 * CODEC_FLAG_*.
747 * - encoding: set by user.
748 * - decoding: set by user.
b71901e6 749 */
de6d9b64 750 int flags;
b71901e6
MN
751
752 /**
753 * some codecs needs additionnal format info. It is stored here
89cff671
MN
754 * if any muxer uses this then ALL demuxers/parsers AND encoders for the specific codec MUST set it correctly
755 * too otherwise stream copy breaks
756 * in general use of this field by muxers is not recommanded
757 * - encoding: set by lavc.
64863965 758 * - decoding: set by lavc. (FIXME is this ok?)
b71901e6
MN
759 */
760 int sub_id;
761
762 /**
64863965 763 * motion estimation algorithm used for video coding.
58f7833e
RS
764 * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex),
765 * 8 (umh), 9 (iter) [7, 8 are x264 specific, 9 is snow specific]
64863965
MN
766 * - encoding: MUST be set by user.
767 * - decoding: unused
b71901e6
MN
768 */
769 int me_method;
770
771 /**
64863965 772 * some codecs need / can use extra-data like huffman tables.
b71901e6
MN
773 * mjpeg: huffman tables
774 * rv10: additional flags
b704e742 775 * mpeg4: global headers (they can be in the bitstream or here)
dffcdbb5
MN
776 * the allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger
777 * then extradata_size to avoid prolems if its read with the bitstream reader
ed57bb79 778 * the bytewise contents of extradata must not depend on the architecture or cpu endianness
64863965
MN
779 * - encoding: set/allocated/freed by lavc.
780 * - decoding: set/allocated/freed by user.
b71901e6 781 */
58f2a4b0 782 uint8_t *extradata;
e84c31dc 783 int extradata_size;
115329f1 784
b71901e6 785 /**
5b28c8c3
MN
786 * this is the fundamental unit of time (in seconds) in terms
787 * of which frame timestamps are represented. for fixed-fps content,
788 * timebase should be 1/framerate and timestamp increments should be
789 * identically 1.
64863965 790 * - encoding: MUST be set by user
c0df9d75 791 * - decoding: set by lavc.
b71901e6 792 */
c0df9d75 793 AVRational time_base;
115329f1 794
5b28c8c3 795 /* video only */
14bea432 796 /**
21adafec 797 * picture width / height.
115329f1 798 * - encoding: MUST be set by user.
21adafec 799 * - decoding: set by lavc.
115329f1 800 * Note, for compatibility its possible to set this instead of
21adafec 801 * coded_width/height before decoding
b71901e6 802 */
de6d9b64 803 int width, height;
115329f1 804
e769f053 805#define FF_ASPECT_EXTENDED 15
b71901e6
MN
806
807 /**
64863965
MN
808 * the number of pictures in a group of pitures, or 0 for intra_only.
809 * - encoding: set by user.
810 * - decoding: unused
b71901e6
MN
811 */
812 int gop_size;
813
814 /**
64863965 815 * pixel format, see PIX_FMT_xxx.
a3a5f4d6 816 * - encoding: set by user.
64863965 817 * - decoding: set by lavc.
b71901e6 818 */
e4eadb4b 819 enum PixelFormat pix_fmt;
115329f1 820
bdfcbbed 821 /**
115329f1 822 * Frame rate emulation. If not zero lower layer (i.e. format handler)
bdfcbbed
MK
823 * has to read frames at native frame rate.
824 * - encoding: set by user.
825 * - decoding: unused.
826 */
827 int rate_emu;
115329f1 828
b71901e6
MN
829 /**
830 * if non NULL, 'draw_horiz_band' is called by the libavcodec
831 * decoder to draw an horizontal band. It improve cache usage. Not
832 * all codecs can do that. You must check the codec capabilities
833 * before
64863965
MN
834 * - encoding: unused
835 * - decoding: set by user.
3bb07d61
MN
836 * @param height the height of the slice
837 * @param y the y position of the slice
838 * @param type 1->top field, 2->bottom field, 3->frame
839 * @param offset offset into the AVFrame.data from which the slice should be read
b71901e6 840 */
bf89e6b1 841 void (*draw_horiz_band)(struct AVCodecContext *s,
da64ecc3 842 const AVFrame *src, int offset[4],
3bb07d61 843 int y, int type, int height);
bf89e6b1 844
de6d9b64 845 /* audio only */
115329f1 846 int sample_rate; ///< samples per sec
de6d9b64 847 int channels;
a3a5f4d6
MN
848
849 /**
850 * audio sample format.
851 * - encoding: set by user.
852 * - decoding: set by lavc.
853 */
115329f1 854 enum SampleFormat sample_fmt; ///< sample format, currenly unused
de6d9b64
FB
855
856 /* the following data should not be initialized */
718b27a7 857 /**
115329f1 858 * samples per packet. initialized when calling 'init'
718b27a7
MN
859 */
860 int frame_size;
115329f1
DB
861 int frame_number; ///< audio or video frame number
862 int real_pict_num; ///< returns the real picture number of previous encoded frame
863
b71901e6 864 /**
115329f1 865 * number of frames the decoded output will be delayed relative to
64863965
MN
866 * the encoded input.
867 * - encoding: set by lavc.
868 * - decoding: unused
b71901e6
MN
869 */
870 int delay;
115329f1 871
64863965
MN
872 /* - encoding parameters */
873 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
115329f1
DB
874 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
875
b71901e6 876 /**
64863965
MN
877 * minimum quantizer.
878 * - encoding: set by user.
879 * - decoding: unused
b71901e6
MN
880 */
881 int qmin;
882
883 /**
64863965
MN
884 * maximum quantizer.
885 * - encoding: set by user.
886 * - decoding: unused
b71901e6
MN
887 */
888 int qmax;
889
890 /**
de6c4b2d 891 * maximum quantizer difference between frames.
64863965
MN
892 * - encoding: set by user.
893 * - decoding: unused
b71901e6
MN
894 */
895 int max_qdiff;
896
897 /**
64863965 898 * maximum number of b frames between non b frames.
b71901e6 899 * note: the output will be delayed by max_b_frames+1 relative to the input
64863965
MN
900 * - encoding: set by user.
901 * - decoding: unused
b71901e6
MN
902 */
903 int max_b_frames;
904
905 /**
64863965
MN
906 * qscale factor between ip and b frames.
907 * - encoding: set by user.
908 * - decoding: unused
b71901e6
MN
909 */
910 float b_quant_factor;
115329f1 911
b71901e6
MN
912 /** obsolete FIXME remove */
913 int rc_strategy;
64b7c5b6
MN
914#define FF_RC_STRATEGY_XVID 1
915
8b4c7dbc 916 int b_frame_strategy;
9dbcbd92 917
b71901e6 918 /**
64863965
MN
919 * hurry up amount.
920 * - encoding: unused
921 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
f9ec0aa1 922 * @deprecated Deprecated in favor of skip_idct and skip_frame.
b71901e6
MN
923 */
924 int hurry_up;
115329f1 925
de6d9b64 926 struct AVCodec *codec;
115329f1 927
de6d9b64
FB
928 void *priv_data;
929
ccec0f4f 930#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
ba58dabc
MN
931 /* unused, FIXME remove*/
932 int rtp_mode;
ccec0f4f 933#endif
115329f1 934
bb628dae 935 int rtp_payload_size; /* The size of the RTP payload: the coder will */
644d98a4
J
936 /* do it's best to deliver a chunk with size */
937 /* below rtp_payload_size, the chunk will start */
938 /* with a start code on some codecs like H.263 */
939 /* This doesn't take account of any particular */
940 /* headers inside the transmited RTP payload */
81401c1f 941
115329f1 942
bb628dae
DB
943 /* The RTP callback: This function is called */
944 /* every time the encoder has a packet to send */
945 /* Depends on the encoder if the data starts */
946 /* with a Start Code (it should) H.263 does. */
947 /* mb_nb contains the number of macroblocks */
948 /* encoded in the RTP payload */
115329f1 949 void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb);
81401c1f 950
098eefe1
MN
951 /* statistics, used for 2-pass encoding */
952 int mv_bits;
953 int header_bits;
954 int i_tex_bits;
955 int p_tex_bits;
956 int i_count;
957 int p_count;
958 int skip_count;
b71901e6 959 int misc_bits;
115329f1 960
b71901e6 961 /**
64863965
MN
962 * number of bits used for the previously encoded frame.
963 * - encoding: set by lavc
7004ffb3 964 * - decoding: unused
b71901e6 965 */
098eefe1 966 int frame_bits;
7004ffb3 967
b71901e6 968 /**
64863965
MN
969 * private data of the user, can be used to carry app specific stuff.
970 * - encoding: set by user
971 * - decoding: set by user
b71901e6
MN
972 */
973 void *opaque;
974
de6d9b64 975 char codec_name[32];
4a663d80
PG
976 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
977 enum CodecID codec_id; /* see CODEC_ID_xxx */
115329f1 978
7004ffb3
MN
979 /**
980 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
981 * this is used to workaround some encoder bugs
47bbf8a7
MN
982 * a demuxer should set this to what is stored in the field used to identify the codec
983 * if there are mutiple such fields in a container then the demuxer should choose the one
984 * which maximizes the information about the used codec
985 * if the codec tag field in a container is larger then 32bit then the demxuer should
986 * remap the longer id to 32bit with a table or other structure alternatively a new
987 * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
988 * first
bd5a6020 989 * - encoding: set by user, if not then the default based on codec_id will be used
7004ffb3
MN
990 * - decoding: set by user, will be converted to upper case by lavc during init
991 */
992 unsigned int codec_tag;
115329f1 993
b71901e6 994 /**
64863965 995 * workaround bugs in encoders which sometimes cannot be detected automatically.
59fa3f96 996 * - encoding: set by user
64863965 997 * - decoding: set by user
b71901e6
MN
998 */
999 int workaround_bugs;
64863965 1000#define FF_BUG_AUTODETECT 1 ///< autodetection
4d2858de
MN
1001#define FF_BUG_OLD_MSMPEG4 2
1002#define FF_BUG_XVID_ILACE 4
1003#define FF_BUG_UMP4 8
1004#define FF_BUG_NO_PADDING 16
3116cb14 1005#define FF_BUG_AMV 32
ac0c6638 1006#define FF_BUG_AC_VLC 0 ///< will be removed, libavcodec can now handle these non compliant files by default
03e93d35 1007#define FF_BUG_QPEL_CHROMA 64
db794953 1008#define FF_BUG_STD_QPEL 128
36df8805 1009#define FF_BUG_QPEL_CHROMA2 256
c40c3482 1010#define FF_BUG_DIRECT_BLOCKSIZE 512
1c6dcb0f 1011#define FF_BUG_EDGE 1024
b44bdf7e 1012#define FF_BUG_HPEL_CHROMA 2048
4ccde216 1013#define FF_BUG_DC_CLIP 4096
59fa3f96 1014#define FF_BUG_MS 8192 ///< workaround various bugs in microsofts broken decoders
4d2858de 1015//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
115329f1 1016
b71901e6 1017 /**
64863965
MN
1018 * luma single coeff elimination threshold.
1019 * - encoding: set by user
1020 * - decoding: unused
b71901e6 1021 */
1f6b6e50 1022 int luma_elim_threshold;
115329f1 1023
b71901e6 1024 /**
64863965
MN
1025 * chroma single coeff elimination threshold.
1026 * - encoding: set by user
1027 * - decoding: unused
b71901e6 1028 */
1f6b6e50 1029 int chroma_elim_threshold;
115329f1 1030
b71901e6 1031 /**
64863965
MN
1032 * strictly follow the std (MPEG4, ...).
1033 * - encoding: set by user
1034 * - decoding: unused
b71901e6
MN
1035 */
1036 int strict_std_compliance;
9cd81798
MN
1037#define FF_COMPLIANCE_VERY_STRICT 2 ///< strictly conform to a older more strict version of the spec or reference software
1038#define FF_COMPLIANCE_STRICT 1 ///< strictly conform to all the things in the spec no matter what consequences
1039#define FF_COMPLIANCE_NORMAL 0
1040#define FF_COMPLIANCE_INOFFICIAL -1 ///< allow inofficial extensions
1041#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< allow non standarized experimental things
1042
b71901e6 1043 /**
64863965 1044 * qscale offset between ip and b frames.
b3a391e8
MN
1045 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
1046 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
64863965
MN
1047 * - encoding: set by user.
1048 * - decoding: unused
b71901e6
MN
1049 */
1050 float b_quant_offset;
115329f1 1051
b71901e6 1052 /**
ce3bcaed 1053 * error resilience higher values will detect more errors but may missdetect
64863965
MN
1054 * some more or less valid parts as errors.
1055 * - encoding: unused
1056 * - decoding: set by user
b71901e6 1057 */
1f6b6e50 1058 int error_resilience;
1471c6c2 1059#define FF_ER_CAREFUL 1
ce3bcaed
MN
1060#define FF_ER_COMPLIANT 2
1061#define FF_ER_AGGRESSIVE 3
1062#define FF_ER_VERY_AGGRESSIVE 4
115329f1 1063
6b72ac63 1064 /**
1e491e29
MN
1065 * called at the beginning of each frame to get a buffer for it.
1066 * if pic.reference is set then the frame will be read later by lavc
2b5296d2
MN
1067 * avcodec_align_dimensions() should be used to find the required width and
1068 * height, as they normally need to be rounded up to the next multiple of 16
64863965
MN
1069 * - encoding: unused
1070 * - decoding: set by lavc, user can override
b71901e6 1071 */
492cd3a9 1072 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
115329f1 1073
b71901e6 1074 /**
1e491e29
MN
1075 * called to release buffers which where allocated with get_buffer.
1076 * a released buffer can be reused in get_buffer()
1077 * pic.data[*] must be set to NULL
64863965
MN
1078 * - encoding: unused
1079 * - decoding: set by lavc, user can override
b71901e6 1080 */
492cd3a9 1081 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
0fd90455 1082
b71901e6 1083 /**
e6a2ac34
MN
1084 * if 1 the stream has a 1 frame delay during decoding.
1085 * - encoding: set by lavc
64863965 1086 * - decoding: set by lavc
b71901e6
MN
1087 */
1088 int has_b_frames;
718b27a7
MN
1089
1090 /**
1091 * number of bytes per packet if constant and known or 0
1092 * used by some WAV based audio codecs
1093 */
1094 int block_align;
115329f1 1095
64863965 1096 int parse_only; /* - decoding only: if true, only parsing is done
917e06c8
FB
1097 (function avcodec_parse_frame()). The frame
1098 data is returned. Only MPEG codecs support this now. */
115329f1 1099
b71901e6 1100 /**
e4eadb4b 1101 * 0-> h263 quant 1-> mpeg quant.
64863965
MN
1102 * - encoding: set by user.
1103 * - decoding: unused
b71901e6
MN
1104 */
1105 int mpeg_quant;
115329f1 1106
b71901e6 1107 /**
64863965
MN
1108 * pass1 encoding statistics output buffer.
1109 * - encoding: set by lavc
1110 * - decoding: unused
b71901e6 1111 */
64863965 1112 char *stats_out;
115329f1 1113
b71901e6
MN
1114 /**
1115 * pass2 encoding statistics input buffer.
1116 * concatenated stuff from stats_out of pass1 should be placed here
64863965
MN
1117 * - encoding: allocated/set/freed by user
1118 * - decoding: unused
b71901e6
MN
1119 */
1120 char *stats_in;
115329f1 1121
b71901e6 1122 /**
64863965 1123 * ratecontrol qmin qmax limiting method.
b71901e6 1124 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
64863965
MN
1125 * - encoding: set by user.
1126 * - decoding: unused
b71901e6 1127 */
ce980a95 1128 float rc_qsquish;
b71901e6 1129
ce980a95
MN
1130 float rc_qmod_amp;
1131 int rc_qmod_freq;
115329f1 1132
b71901e6 1133 /**
64863965
MN
1134 * ratecontrol override, see RcOverride.
1135 * - encoding: allocated/set/freed by user.
1136 * - decoding: unused
b71901e6 1137 */
ce980a95
MN
1138 RcOverride *rc_override;
1139 int rc_override_count;
115329f1 1140
b71901e6 1141 /**
64863965
MN
1142 * rate control equation.
1143 * - encoding: set by user
1144 * - decoding: unused
b71901e6 1145 */
ce980a95 1146 char *rc_eq;
115329f1 1147
b71901e6 1148 /**
64863965
MN
1149 * maximum bitrate.
1150 * - encoding: set by user.
1151 * - decoding: unused
b71901e6 1152 */
ce980a95 1153 int rc_max_rate;
115329f1 1154
b71901e6 1155 /**
64863965
MN
1156 * minimum bitrate.
1157 * - encoding: set by user.
1158 * - decoding: unused
b71901e6 1159 */
ce980a95 1160 int rc_min_rate;
115329f1 1161
b71901e6 1162 /**
64863965
MN
1163 * decoder bitstream buffer size.
1164 * - encoding: set by user.
1165 * - decoding: unused
b71901e6 1166 */
ce980a95
MN
1167 int rc_buffer_size;
1168 float rc_buffer_aggressivity;
b71901e6
MN
1169
1170 /**
64863965 1171 * qscale factor between p and i frames.
a1e257b2
MN
1172 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
1173 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
64863965
MN
1174 * - encoding: set by user.
1175 * - decoding: unused
b71901e6
MN
1176 */
1177 float i_quant_factor;
115329f1 1178
b71901e6 1179 /**
64863965 1180 * qscale offset between p and i frames.
64863965
MN
1181 * - encoding: set by user.
1182 * - decoding: unused
b71901e6
MN
1183 */
1184 float i_quant_offset;
115329f1 1185
b71901e6 1186 /**
64863965
MN
1187 * initial complexity for pass1 ratecontrol.
1188 * - encoding: set by user.
1189 * - decoding: unused
b71901e6 1190 */
ce980a95 1191 float rc_initial_cplx;
917e06c8 1192
b71901e6 1193 /**
64863965
MN
1194 * dct algorithm, see FF_DCT_* below.
1195 * - encoding: set by user
1196 * - decoding: unused
b71901e6 1197 */
28db7fce 1198 int dct_algo;
c7e07931 1199#define FF_DCT_AUTO 0
28db7fce 1200#define FF_DCT_FASTINT 1
c7e07931
MO
1201#define FF_DCT_INT 2
1202#define FF_DCT_MMX 3
1203#define FF_DCT_MLIB 4
05c4072b 1204#define FF_DCT_ALTIVEC 5
65e4c8c9 1205#define FF_DCT_FAAN 6
115329f1 1206
c5d309f2 1207 /**
64863965
MN
1208 * luminance masking (0-> disabled).
1209 * - encoding: set by user
1210 * - decoding: unused
c5d309f2
MN
1211 */
1212 float lumi_masking;
115329f1 1213
c5d309f2 1214 /**
64863965
MN
1215 * temporary complexity masking (0-> disabled).
1216 * - encoding: set by user
1217 * - decoding: unused
c5d309f2
MN
1218 */
1219 float temporal_cplx_masking;
115329f1 1220
c5d309f2 1221 /**
64863965
MN
1222 * spatial complexity masking (0-> disabled).
1223 * - encoding: set by user
1224 * - decoding: unused
c5d309f2
MN
1225 */
1226 float spatial_cplx_masking;
115329f1 1227
c5d309f2 1228 /**
64863965
MN
1229 * p block masking (0-> disabled).
1230 * - encoding: set by user
1231 * - decoding: unused
c5d309f2
MN
1232 */
1233 float p_masking;
15415af4 1234
5e746b99 1235 /**
64863965
MN
1236 * darkness masking (0-> disabled).
1237 * - encoding: set by user
1238 * - decoding: unused
5e746b99
MN
1239 */
1240 float dark_masking;
115329f1
DB
1241
1242
3a694b04
NK
1243 /* for binary compatibility */
1244 int unused;
115329f1 1245
0c2dd16e 1246 /**
64863965
MN
1247 * idct algorithm, see FF_IDCT_* below.
1248 * - encoding: set by user
1249 * - decoding: set by user
2ad1516a
MN
1250 */
1251 int idct_algo;
1252#define FF_IDCT_AUTO 0
1253#define FF_IDCT_INT 1
1254#define FF_IDCT_SIMPLE 2
1255#define FF_IDCT_SIMPLEMMX 3
1256#define FF_IDCT_LIBMPEG2MMX 4
1257#define FF_IDCT_PS2 5
1258#define FF_IDCT_MLIB 6
1259#define FF_IDCT_ARM 7
05c4072b 1260#define FF_IDCT_ALTIVEC 8
b82cdc72 1261#define FF_IDCT_SH4 9
bd7d1ea7 1262#define FF_IDCT_SIMPLEARM 10
0fa8158d 1263#define FF_IDCT_H264 11
8b6103da 1264#define FF_IDCT_VP3 12
eba9ae3c 1265#define FF_IDCT_IPP 13
84740d59 1266#define FF_IDCT_XVIDMMX 14
595e7bd9 1267#define FF_IDCT_CAVS 15
a0403006 1268#define FF_IDCT_SIMPLEARMV5TE 16
7d42886b 1269#define FF_IDCT_SIMPLEARMV6 17
2ad1516a 1270
144f0625 1271 /**
64863965
MN
1272 * slice count.
1273 * - encoding: set by lavc
1274 * - decoding: set by user (or 0)
144f0625
MN
1275 */
1276 int slice_count;
1277 /**
64863965
MN
1278 * slice offsets in the frame in bytes.
1279 * - encoding: set/allocated by lavc
1280 * - decoding: set/allocated by user (or NULL)
144f0625
MN
1281 */
1282 int *slice_offset;
1283
4d2858de 1284 /**
64863965
MN
1285 * error concealment flags.
1286 * - encoding: unused
1287 * - decoding: set by user
4d2858de
MN
1288 */
1289 int error_concealment;
1290#define FF_EC_GUESS_MVS 1
1291#define FF_EC_DEBLOCK 2
1292
6b72ac63 1293 /**
bec89a84 1294 * dsp_mask could be add used to disable unwanted CPU features
8350df97 1295 * CPU features (i.e. MMX, SSE. ...)
bec89a84
ZK
1296 *
1297 * with FORCE flag you may instead enable given CPU features
1298 * (Dangerous: usable in case of misdetection, improper usage however will
1299 * result into program crash)
1300 */
1301 unsigned dsp_mask;
bb270c08 1302#define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
bec89a84
ZK
1303 /* lower 16 bits - CPU features */
1304#ifdef HAVE_MMX
bb270c08
DB
1305#define FF_MM_MMX 0x0001 /* standard MMX */
1306#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
1307#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
1308#define FF_MM_SSE 0x0008 /* SSE functions */
1309#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
1310#define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */
bec89a84 1311#endif /* HAVE_MMX */
eba9ae3c 1312#ifdef HAVE_IWMMXT
bb270c08 1313#define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */
eba9ae3c 1314#endif /* HAVE_IWMMXT */
11f18faf
MN
1315
1316 /**
64863965
MN
1317 * bits per sample/pixel from the demuxer (needed for huffyuv).
1318 * - encoding: set by lavc
1319 * - decoding: set by user
11f18faf
MN
1320 */
1321 int bits_per_sample;
115329f1 1322
11f18faf 1323 /**
64863965
MN
1324 * prediction method (needed for huffyuv).
1325 * - encoding: set by user
1326 * - decoding: unused
11f18faf
MN
1327 */
1328 int prediction_method;
1329#define FF_PRED_LEFT 0
1330#define FF_PRED_PLANE 1
1331#define FF_PRED_MEDIAN 2
115329f1 1332
5d3cea3a 1333 /**
5ff85f1d 1334 * sample aspect ratio (0 if unknown).
1f26c6f3 1335 * numerator and denominator must be relative prime and smaller then 256 for some video standards
64863965
MN
1336 * - encoding: set by user.
1337 * - decoding: set by lavc.
5d3cea3a 1338 */
5ff85f1d 1339 AVRational sample_aspect_ratio;
1e491e29
MN
1340
1341 /**
64863965
MN
1342 * the picture in the bitstream.
1343 * - encoding: set by lavc
1344 * - decoding: set by lavc
1e491e29 1345 */
492cd3a9 1346 AVFrame *coded_frame;
c8c437bc
MN
1347
1348 /**
64863965
MN
1349 * debug.
1350 * - encoding: set by user.
1351 * - decoding: set by user.
c8c437bc
MN
1352 */
1353 int debug;
1354#define FF_DEBUG_PICT_INFO 1
1355#define FF_DEBUG_RC 2
1356#define FF_DEBUG_BITSTREAM 4
1357#define FF_DEBUG_MB_TYPE 8
1358#define FF_DEBUG_QP 16
1359#define FF_DEBUG_MV 32
8289c6fa 1360#define FF_DEBUG_DCT_COEFF 0x00000040
41773b73
MN
1361#define FF_DEBUG_SKIP 0x00000080
1362#define FF_DEBUG_STARTCODE 0x00000100
1363#define FF_DEBUG_PTS 0x00000200
46b4feec 1364#define FF_DEBUG_ER 0x00000400
0da71265 1365#define FF_DEBUG_MMCO 0x00000800
8fc6c2b5 1366#define FF_DEBUG_BUGS 0x00001000
864119b6
MN
1367#define FF_DEBUG_VIS_QP 0x00002000
1368#define FF_DEBUG_VIS_MB_TYPE 0x00004000
115329f1 1369
140cb663 1370 /**
0c9bbaec
WH
1371 * debug.
1372 * - encoding: set by user.
1373 * - decoding: set by user.
1374 */
1375 int debug_mv;
1376#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames
1377#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames
1378#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames
1379
1380 /**
64863965
MN
1381 * error.
1382 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
1383 * - decoding: unused
140cb663
MN
1384 */
1385 uint64_t error[4];
115329f1 1386
17a70fde 1387 /**
64863965 1388 * minimum MB quantizer.
6e0d8c06 1389 * - encoding: unused
64863965 1390 * - decoding: unused
17a70fde
MN
1391 */
1392 int mb_qmin;
1393
1394 /**
64863965 1395 * maximum MB quantizer.
6e0d8c06 1396 * - encoding: unused
64863965 1397 * - decoding: unused
17a70fde
MN
1398 */
1399 int mb_qmax;
115329f1 1400
1457ab52 1401 /**
64863965
MN
1402 * motion estimation compare function.
1403 * - encoding: set by user.
1404 * - decoding: unused
1457ab52
MN
1405 */
1406 int me_cmp;
1407 /**
64863965
MN
1408 * subpixel motion estimation compare function.
1409 * - encoding: set by user.
1410 * - decoding: unused
1457ab52
MN
1411 */
1412 int me_sub_cmp;
1413 /**
64863965
MN
1414 * macroblock compare function (not supported yet).
1415 * - encoding: set by user.
1416 * - decoding: unused
1457ab52
MN
1417 */
1418 int mb_cmp;
622348f9
MN
1419 /**
1420 * interlaced dct compare function
1421 * - encoding: set by user.
1422 * - decoding: unused
1423 */
1424 int ildct_cmp;
1457ab52
MN
1425#define FF_CMP_SAD 0
1426#define FF_CMP_SSE 1
1427#define FF_CMP_SATD 2
1428#define FF_CMP_DCT 3
1429#define FF_CMP_PSNR 4
1430#define FF_CMP_BIT 5
1431#define FF_CMP_RD 6
1432#define FF_CMP_ZERO 7
622348f9
MN
1433#define FF_CMP_VSAD 8
1434#define FF_CMP_VSSE 9
e6a2ac34 1435#define FF_CMP_NSSE 10
26efc54e
MN
1436#define FF_CMP_W53 11
1437#define FF_CMP_W97 12
0fd6aea1 1438#define FF_CMP_DCTMAX 13
27c61ac5 1439#define FF_CMP_DCT264 14
1457ab52 1440#define FF_CMP_CHROMA 256
115329f1 1441
1457ab52 1442 /**
64863965
MN
1443 * ME diamond size & shape.
1444 * - encoding: set by user.
1445 * - decoding: unused
1457ab52
MN
1446 */
1447 int dia_size;
b07a5980
MN
1448
1449 /**
64863965
MN
1450 * amount of previous MV predictors (2a+1 x 2a+1 square).
1451 * - encoding: set by user.
1452 * - decoding: unused
b07a5980
MN
1453 */
1454 int last_predictor_count;
70ac76c0 1455
f5fb6b34 1456 /**
64863965
MN
1457 * pre pass for motion estimation.
1458 * - encoding: set by user.
1459 * - decoding: unused
f5fb6b34
MN
1460 */
1461 int pre_me;
b07a5980 1462
70ac76c0 1463 /**
64863965
MN
1464 * motion estimation pre pass compare function.
1465 * - encoding: set by user.
1466 * - decoding: unused
70ac76c0
MN
1467 */
1468 int me_pre_cmp;
826f429a 1469
70ac76c0 1470 /**
64863965
MN
1471 * ME pre pass diamond size & shape.
1472 * - encoding: set by user.
1473 * - decoding: unused
70ac76c0
MN
1474 */
1475 int pre_dia_size;
1476
826f429a 1477 /**
64863965
MN
1478 * subpel ME quality.
1479 * - encoding: set by user.
1480 * - decoding: unused
826f429a
MN
1481 */
1482 int me_subpel_quality;
1483
a33c7159 1484 /**
64863965 1485 * callback to negotiate the pixelFormat.
a33c7159
MN
1486 * @param fmt is the list of formats which are supported by the codec,
1487 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1488 * the first is allways the native one
1489 * @return the choosen format
64863965
MN
1490 * - encoding: unused
1491 * - decoding: set by user, if not set then the native format will always be choosen
a33c7159 1492 */
494c56d3 1493 enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt);
e2f9490e
FB
1494
1495 /**
1496 * DTG active format information (additionnal aspect ratio
1497 * information only used in DVB MPEG2 transport streams). 0 if
1498 * not set.
115329f1 1499 *
64863965 1500 * - encoding: unused.
115329f1 1501 * - decoding: set by decoder
e2f9490e
FB
1502 */
1503 int dtg_active_format;
1504#define FF_DTG_AFD_SAME 8
1505#define FF_DTG_AFD_4_3 9
1506#define FF_DTG_AFD_16_9 10
1507#define FF_DTG_AFD_14_9 11
1508#define FF_DTG_AFD_4_3_SP_14_9 13
1509#define FF_DTG_AFD_16_9_SP_14_9 14
1510#define FF_DTG_AFD_SP_4_3 15
1511
ebbcdc9a
MN
1512 /**
1513 * Maximum motion estimation search range in subpel units.
1514 * if 0 then no limit
115329f1 1515 *
64863965
MN
1516 * - encoding: set by user.
1517 * - decoding: unused.
ebbcdc9a 1518 */
59e0ac8e 1519 int me_range;
ebbcdc9a 1520
65f7062d 1521 /**
1984f635
MN
1522 * intra quantizer bias.
1523 * - encoding: set by user.
1524 * - decoding: unused
1525 */
1526 int intra_quant_bias;
1527#define FF_DEFAULT_QUANT_BIAS 999999
115329f1 1528
1984f635
MN
1529 /**
1530 * inter quantizer bias.
1531 * - encoding: set by user.
1532 * - decoding: unused
1533 */
1534 int inter_quant_bias;
5cd62665
ZK
1535
1536 /**
1537 * color table ID.
1538 * - encoding: unused.
1539 * - decoding: which clrtable should be used for 8bit RGB images
1540 * table have to be stored somewhere FIXME
1541 */
1542 int color_table_id;
115329f1 1543
d90cf87b 1544 /**
115329f1 1545 * internal_buffer count.
bb628dae 1546 * Don't touch, used by lavc default_get_buffer()
d90cf87b
MN
1547 */
1548 int internal_buffer_count;
115329f1 1549
d90cf87b 1550 /**
115329f1 1551 * internal_buffers.
bb628dae 1552 * Don't touch, used by lavc default_get_buffer()
d90cf87b
MN
1553 */
1554 void *internal_buffer;
158c7f05
MN
1555
1556#define FF_LAMBDA_SHIFT 7
1557#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
1558#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
1559#define FF_LAMBDA_MAX (256*128-1)
1560
1561#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
3d2e8cce
MN
1562 /**
1563 * global quality for codecs which cannot change it per frame.
1564 * this should be proportional to MPEG1/2/4 qscale.
1565 * - encoding: set by user.
1566 * - decoding: unused
1567 */
1568 int global_quality;
115329f1 1569
bd446bb1
MN
1570#define FF_CODER_TYPE_VLC 0
1571#define FF_CODER_TYPE_AC 1
f87459e4
KN
1572#define FF_CODER_TYPE_RAW 2
1573#define FF_CODER_TYPE_RLE 3
1574#define FF_CODER_TYPE_DEFLATE 4
11e659c2
MN
1575 /**
1576 * coder type
1577 * - encoding: set by user.
1578 * - decoding: unused
1579 */
1580 int coder_type;
1581
1582 /**
1583 * context model
1584 * - encoding: set by user.
1585 * - decoding: unused
1586 */
1587 int context_model;
5639729b
MN
1588#if 0
1589 /**
1590 *
1591 * - encoding: unused
1592 * - decoding: set by user.
1593 */
1594 uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size);
1595#endif
115329f1 1596
3bb07d61
MN
1597 /**
1598 * slice flags
1599 * - encoding: unused
1600 * - decoding: set by user.
1601 */
1602 int slice_flags;
1603#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display
1604#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1605#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1606
fb364ada
IK
1607 /**
1608 * XVideo Motion Acceleration
1609 * - encoding: forbidden
1610 * - decoding: set by decoder
1611 */
1612 int xvmc_acceleration;
115329f1 1613
7d1c3fc1
MN
1614 /**
1615 * macroblock decision mode
1616 * - encoding: set by user.
1617 * - decoding: unused
1618 */
1619 int mb_decision;
1620#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp
1621#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits
1622#define FF_MB_DECISION_RD 2 ///< rate distoration
d6eb3c50
MN
1623
1624 /**
1625 * custom intra quantization matrix
1626 * - encoding: set by user, can be NULL
1627 * - decoding: set by lavc
1628 */
1629 uint16_t *intra_matrix;
1630
1631 /**
1632 * custom inter quantization matrix
1633 * - encoding: set by user, can be NULL
1634 * - decoding: set by lavc
1635 */
1636 uint16_t *inter_matrix;
115329f1 1637
541ae140
MN
1638 /**
1639 * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1640 * this is used to workaround some encoder bugs
1641 * - encoding: unused
1642 * - decoding: set by user, will be converted to upper case by lavc during init
1643 */
1644 unsigned int stream_codec_tag;
05fbd0a2
MN
1645
1646 /**
1647 * scene change detection threshold.
1648 * 0 is default, larger means fewer detected scene changes
1649 * - encoding: set by user.
1650 * - decoding: unused
1651 */
1652 int scenechange_threshold;
158c7f05
MN
1653
1654 /**
1655 * minimum lagrange multipler
1656 * - encoding: set by user.
1657 * - decoding: unused
1658 */
1659 int lmin;
1660
1661 /**
1662 * maximum lagrange multipler
1663 * - encoding: set by user.
1664 * - decoding: unused
1665 */
1666 int lmax;
2a2bbcb0
MM
1667
1668 /**
1669 * Palette control structure
1670 * - encoding: ??? (no palette-enabled encoder yet)
1671 * - decoding: set by user.
1672 */
1673 struct AVPaletteControl *palctrl;
821cb11f
MN
1674
1675 /**
1676 * noise reduction strength
1677 * - encoding: set by user.
1678 * - decoding: unused
1679 */
1680 int noise_reduction;
115329f1 1681
074c4ca7 1682 /**
e1c2a5a0
RT
1683 * called at the beginning of a frame to get cr buffer for it.
1684 * buffer type (size, hints) must be the same. lavc won't check it.
1685 * lavc will pass previous buffer in pic, function should return
1686 * same buffer or new buffer with old frame "painted" into it.
1687 * if pic.data[0] == NULL must behave like get_buffer().
074c4ca7 1688 * - encoding: unused
e1c2a5a0 1689 * - decoding: set by lavc, user can override
074c4ca7 1690 */
e1c2a5a0 1691 int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic);
ba58dabc
MN
1692
1693 /**
1694 * number of bits which should be loaded into the rc buffer before decoding starts
1695 * - encoding: set by user.
1696 * - decoding: unused
1697 */
1698 int rc_initial_buffer_occupancy;
1699
1700 /**
1701 *
1702 * - encoding: set by user.
1703 * - decoding: unused
1704 */
1705 int inter_threshold;
1706
1707 /**
1708 * CODEC_FLAG2_*.
1709 * - encoding: set by user.
1710 * - decoding: set by user.
1711 */
1712 int flags2;
7ebfc0ea
MN
1713
1714 /**
1715 * simulates errors in the bitstream to test error concealment.
1716 * - encoding: set by user.
1717 * - decoding: unused.
1718 */
1719 int error_rate;
115329f1 1720
a1e257b2
MN
1721 /**
1722 * MP3 antialias algorithm, see FF_AA_* below.
1723 * - encoding: unused
1724 * - decoding: set by user
1725 */
1726 int antialias_algo;
1727#define FF_AA_AUTO 0
1728#define FF_AA_FASTINT 1 //not implemented yet
1729#define FF_AA_INT 2
1730#define FF_AA_FLOAT 3
77ea0d4b
MN
1731 /**
1732 * Quantizer noise shaping.
1733 * - encoding: set by user
1734 * - decoding: unused
1735 */
1736 int quantizer_noise_shaping;
9c3d33d6
MN
1737
1738 /**
1739 * Thread count.
eafcac6a 1740 * is used to decide how many independent tasks should be passed to execute()
9c3d33d6
MN
1741 * - encoding: set by user
1742 * - decoding: set by user
1743 */
1744 int thread_count;
115329f1 1745
9c3d33d6 1746 /**
eafcac6a 1747 * the codec may call this to execute several independent things. it will return only after
9c3d33d6
MN
1748 * finishing all tasks, the user may replace this with some multithreaded implementation, the
1749 * default implementation will execute the parts serially
399cec2f 1750 * @param count the number of things to execute
9c3d33d6
MN
1751 * - encoding: set by lavc, user can override
1752 * - decoding: set by lavc, user can override
1753 */
1754 int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void **arg2, int *ret, int count);
115329f1 1755
9c3d33d6
MN
1756 /**
1757 * Thread opaque.
1758 * can be used by execute() to store some per AVCodecContext stuff.
1759 * - encoding: set by execute()
1760 * - decoding: set by execute()
1761 */
1762 void *thread_opaque;
a4d36c11
MN
1763
1764 /**
115329f1 1765 * Motion estimation threshold. under which no motion estimation is
f20f8a8b 1766 * performed, but instead the user specified motion vectors are used
115329f1 1767 *
a4d36c11 1768 * - encoding: set by user
f20f8a8b 1769 * - decoding: unused
a4d36c11 1770 */
2750b827 1771 int me_threshold;
f20f8a8b
MN
1772
1773 /**
1774 * Macroblock threshold. under which the user specified macroblock types will be used
1775 * - encoding: set by user
1776 * - decoding: unused
1777 */
1778 int mb_threshold;
bf266e19
MN
1779
1780 /**
d4c5d2ad 1781 * precision of the intra dc coefficient - 8.
bf266e19
MN
1782 * - encoding: set by user
1783 * - decoding: unused
1784 */
1785 int intra_dc_precision;
d4c5d2ad
MN
1786
1787 /**
1788 * noise vs. sse weight for the nsse comparsion function.
1789 * - encoding: set by user
1790 * - decoding: unused
1791 */
1792 int nsse_weight;
0dfd33c3
MN
1793
1794 /**
160d679c 1795 * number of macroblock rows at the top which are skipped.
0dfd33c3
MN
1796 * - encoding: unused
1797 * - decoding: set by user
1798 */
1799 int skip_top;
1800
1801 /**
160d679c 1802 * number of macroblock rows at the bottom which are skipped.
0dfd33c3
MN
1803 * - encoding: unused
1804 * - decoding: set by user
1805 */
1806 int skip_bottom;
baced9f5
MN
1807
1808 /**
1809 * profile
1810 * - encoding: set by user
1811 * - decoding: set by lavc
1812 */
1813 int profile;
1814#define FF_PROFILE_UNKNOWN -99
1815
1816 /**
1817 * level
1818 * - encoding: set by user
1819 * - decoding: set by lavc
1820 */
1821 int level;
1822#define FF_LEVEL_UNKNOWN -99
178fcca8
MN
1823
1824 /**
1825 * low resolution decoding. 1-> 1/2 size, 2->1/4 size
1826 * - encoding: unused
1827 * - decoding: set by user
1828 */
1829 int lowres;
21adafec
MN
1830
1831 /**
bbf18b21 1832 * bitsream width / height. may be different from width/height if lowres
21adafec
MN
1833 * or other things are used
1834 * - encoding: unused
1835 * - decoding: set by user before init if known, codec should override / dynamically change if needed
1836 */
1837 int coded_width, coded_height;
bbf18b21
MN
1838
1839 /**
1840 * frame skip threshold
1841 * - encoding: set by user
1842 * - decoding: unused
1843 */
1844 int frame_skip_threshold;
1845
1846 /**
1847 * frame skip factor
1848 * - encoding: set by user
1849 * - decoding: unused
1850 */
1851 int frame_skip_factor;
0fd6aea1
MN
1852
1853 /**
1854 * frame skip exponent
1855 * - encoding: set by user
1856 * - decoding: unused
1857 */
1858 int frame_skip_exp;
1859
1860 /**
1861 * frame skip comparission function
1862 * - encoding: set by user.
1863 * - decoding: unused
1864 */
1865 int frame_skip_cmp;
957c743a
CM
1866
1867 /**
1868 * border processing masking. raises the quantizer for mbs on the borders
1869 * of the picture.
1870 * - encoding: set by user
1871 * - decoding: unused
1872 */
1873 float border_masking;
6e0d8c06
MN
1874
1875 /**
1876 * minimum MB lagrange multipler.
1877 * - encoding: set by user.
1878 * - decoding: unused
1879 */
1880 int mb_lmin;
1881
1882 /**
1883 * maximum MB lagrange multipler.
1884 * - encoding: set by user.
1885 * - decoding: unused
1886 */
1887 int mb_lmax;
09c3e44e
MN
1888
1889 /**
115329f1 1890 *
09c3e44e
MN
1891 * - encoding: set by user.
1892 * - decoding: unused
1893 */
1894 int me_penalty_compensation;
8c3eba7c
MN
1895
1896 /**
115329f1 1897 *
8c3eba7c
MN
1898 * - encoding: unused
1899 * - decoding: set by user.
1900 */
1901 enum AVDiscard skip_loop_filter;
1902
1903 /**
115329f1 1904 *
8c3eba7c
MN
1905 * - encoding: unused
1906 * - decoding: set by user.
1907 */
1908 enum AVDiscard skip_idct;
1909
1910 /**
115329f1 1911 *
8c3eba7c
MN
1912 * - encoding: unused
1913 * - decoding: set by user.
1914 */
1915 enum AVDiscard skip_frame;
316a2ec8
MN
1916
1917 /**
1918 *
1919 * - encoding: set by user.
1920 * - decoding: unused
1921 */
1922 int bidir_refine;
e8501c93
MN
1923
1924 /**
1925 *
1926 * - encoding: set by user.
1927 * - decoding: unused
1928 */
1929 int brd_scale;
58f7833e
RS
1930
1931 /**
1932 * constant rate factor - quality-based VBR - values ~correspond to qps
1933 * - encoding: set by user.
1934 * - decoding: unused
1935 */
9f1c1c99 1936 float crf;
58f7833e
RS
1937
1938 /**
1939 * constant quantization parameter rate control method
1940 * - encoding: set by user.
1941 * - decoding: unused
1942 */
1943 int cqp;
1944
1945 /**
1946 * minimum gop size
1947 * - encoding: set by user.
1948 * - decoding: unused
1949 */
1950 int keyint_min;
1951
1952 /**
1953 * number of reference frames
1954 * - encoding: set by user.
1955 * - decoding: unused
1956 */
1957 int refs;
1958
1959 /**
1960 * chroma qp offset from luma
1961 * - encoding: set by user.
1962 * - decoding: unused
1963 */
1964 int chromaoffset;
1965
1966 /**
1967 * influences how often b-frames are used
1968 * - encoding: set by user.
1969 * - decoding: unused
1970 */
1971 int bframebias;
1972
1973 /**
1974 * trellis RD quantization
1975 * - encoding: set by user.
1976 * - decoding: unused
1977 */
1978 int trellis;
1979
1980 /**
1981 * reduce fluctuations in qp (before curve compression)
1982 * - encoding: set by user.
1983 * - decoding: unused
1984 */
1985 float complexityblur;
1986
1987 /**
1988 * in-loop deblocking filter alphac0 parameter
1989 * alpha is in the range -6...6
1990 * - encoding: set by user.
1991 * - decoding: unused
1992 */
1993 int deblockalpha;
1994
1995 /**
1996 * in-loop deblocking filter beta parameter
1997 * beta is in the range -6...6
1998 * - encoding: set by user.
1999 * - decoding: unused
2000 */
2001 int deblockbeta;
2002
2003 /**
2004 * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4
2005 * - encoding: set by user.
2006 * - decoding: unused
2007 */
2008 int partitions;
2009#define X264_PART_I4X4 0x001 /* Analyse i4x4 */
2010#define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */
2011#define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */
2012#define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */
2013#define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */
2014
2015 /**
2016 * direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal)
2017 * - encoding: set by user.
2018 * - decoding: unused
2019 */
2020 int directpred;
4f59b684 2021
14f0c8e2
LA
2022 /**
2023 * audio cutoff bandwidth (0 means "automatic") . Currently used only by FAAC
2024 * - encoding: set by user.
2025 * - decoding: unused
2026 */
2027 int cutoff;
39a64e30
CH
2028
2029 /**
2030 * multiplied by qscale for each frame and added to scene_change_score
2031 * - encoding: set by user.
2032 * - decoding: unused
2033 */
2034 int scenechange_factor;
1dd509b1
MN
2035
2036 /**
2037 *
2038 * note: value depends upon the compare functin used for fullpel ME
2039 * - encoding: set by user.
2040 * - decoding: unused
2041 */
2042 int mv0_threshold;
f9243d34
CH
2043
2044 /**
2045 * adjusts sensitivity of b_frame_strategy 1
2046 * - encoding: set by user.
2047 * - decoding: unused
2048 */
2049 int b_sensitivity;
a403fc03
JR
2050
2051 /**
2052 * - encoding: set by user.
2053 * - decoding: unused
2054 */
2055 int compression_level;
2056#define FF_COMPRESSION_DEFAULT -1
2057
2058 /**
2059 * sets whether to use LPC mode - used by FLAC encoder
2060 * - encoding: set by user.
2061 * - decoding: unused.
2062 */
2063 int use_lpc;
2064
2065 /**
2066 * LPC coefficient precision - used by FLAC encoder
2067 * - encoding: set by user.
2068 * - decoding: unused.
2069 */
2070 int lpc_coeff_precision;
2071
2072 /**
2073 * - encoding: set by user.
2074 * - decoding: unused.
2075 */
2076 int min_prediction_order;
2077
2078 /**
2079 * - encoding: set by user.
2080 * - decoding: unused.
2081 */
2082 int max_prediction_order;
2083
2084 /**
2085 * search method for selecting prediction order
2086 * - encoding: set by user.
2087 * - decoding: unused.
2088 */
2089 int prediction_order_method;
2090
2091 /**
2092 * - encoding: set by user.
2093 * - decoding: unused.
2094 */
2095 int min_partition_order;
2096
2097 /**
2098 * - encoding: set by user.
2099 * - decoding: unused.
2100 */
2101 int max_partition_order;
80d617f5
BC
2102
2103 /**
2104 * GOP timecode frame start number, in non drop frame format
2105 * - encoding: set by user.
2106 * - decoding: unused.
2107 */
2108 int64_t timecode_frame_start;
de6d9b64
FB
2109} AVCodecContext;
2110
64863965
MN
2111/**
2112 * AVCodec.
2113 */
de6d9b64 2114typedef struct AVCodec {
18f77016 2115 const char *name;
5d234974 2116 enum CodecType type;
9297ddd3 2117 enum CodecID id;
de6d9b64
FB
2118 int priv_data_size;
2119 int (*init)(AVCodecContext *);
0c1a9eda 2120 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
de6d9b64 2121 int (*close)(AVCodecContext *);
0fd90455 2122 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
0c1a9eda 2123 uint8_t *buf, int buf_size);
bf89e6b1 2124 int capabilities;
de6d9b64 2125 struct AVCodec *next;
7a06ff14 2126 void (*flush)(AVCodecContext *);
b0df362b 2127 const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
fcee0164 2128 const enum PixelFormat *pix_fmts; ///array of supported pixel formats, or NULL if unknown, array is terminanted by -1
de6d9b64
FB
2129} AVCodec;
2130
97d96aaa 2131/**
d7425f59
MN
2132 * four components are given, that's all.
2133 * the last component is alpha
2134 */
de6d9b64 2135typedef struct AVPicture {
0c1a9eda 2136 uint8_t *data[4];
cd394651 2137 int linesize[4]; ///< number of bytes per line
de6d9b64
FB
2138} AVPicture;
2139
ba118447
MM
2140/**
2141 * AVPaletteControl
2142 * This structure defines a method for communicating palette changes
2143 * between and demuxer and a decoder.
18239edf 2144 * this is totally broken, palette changes should be sent as AVPackets
ba118447 2145 */
2e99641b 2146#define AVPALETTE_SIZE 1024
432d84c3 2147#define AVPALETTE_COUNT 256
ba118447
MM
2148typedef struct AVPaletteControl {
2149
2150 /* demuxer sets this to 1 to indicate the palette has changed;
2151 * decoder resets to 0 */
2152 int palette_changed;
2153
2a2bbcb0
MM
2154 /* 4-byte ARGB palette entries, stored in native byte order; note that
2155 * the individual palette components should be on a 8-bit scale; if
2156 * the palette data comes from a IBM VGA native format, the component
2157 * data is probably 6 bits in size and needs to be scaled */
2e99641b 2158 unsigned int palette[AVPALETTE_COUNT];
ba118447 2159
18239edf 2160} AVPaletteControl attribute_deprecated;
ba118447 2161
c6ec28b1 2162typedef struct AVSubtitleRect {
240c1657
FB
2163 uint16_t x;
2164 uint16_t y;
2165 uint16_t w;
2166 uint16_t h;
2167 uint16_t nb_colors;
240c1657
FB
2168 int linesize;
2169 uint32_t *rgba_palette;
2170 uint8_t *bitmap;
c6ec28b1
MN
2171} AVSubtitleRect;
2172
2173typedef struct AVSubtitle {
2174 uint16_t format; /* 0 = graphics */
2175 uint32_t start_display_time; /* relative to packet pts, in ms */
2176 uint32_t end_display_time; /* relative to packet pts, in ms */
2177 uint32_t num_rects;
2178 AVSubtitleRect *rects;
240c1657
FB
2179} AVSubtitle;
2180
de6d9b64 2181extern AVCodec ac3_encoder;
7ce6a249
DB
2182extern AVCodec amr_nb_encoder;
2183extern AVCodec amr_wb_encoder;
2184extern AVCodec asv1_encoder;
2185extern AVCodec asv2_encoder;
52548eee 2186extern AVCodec bmp_encoder;
7ce6a249 2187extern AVCodec dvvideo_encoder;
29d48296 2188extern AVCodec faac_encoder;
7ce6a249
DB
2189extern AVCodec ffv1_encoder;
2190extern AVCodec ffvhuff_encoder;
9e96ab03 2191extern AVCodec flac_encoder;
7ce6a249
DB
2192extern AVCodec flashsv_encoder;
2193extern AVCodec flv_encoder;
93481fe5 2194extern AVCodec gif_encoder;
1c3990db 2195extern AVCodec h261_encoder;
de6d9b64
FB
2196extern AVCodec h263_encoder;
2197extern AVCodec h263p_encoder;
7ce6a249
DB
2198extern AVCodec h264_encoder;
2199extern AVCodec huffyuv_encoder;
5639729b 2200extern AVCodec jpegls_encoder;
7ce6a249 2201extern AVCodec libgsm_encoder;
346a655d 2202extern AVCodec libgsm_ms_encoder;
150d2772 2203extern AVCodec libtheora_encoder;
7ce6a249
DB
2204extern AVCodec ljpeg_encoder;
2205extern AVCodec mdec_encoder;
2206extern AVCodec mjpeg_encoder;
2207extern AVCodec mp2_encoder;
2208extern AVCodec mp3lame_encoder;
2209extern AVCodec mpeg1video_encoder;
2210extern AVCodec mpeg2video_encoder;
bf89e6b1 2211extern AVCodec mpeg4_encoder;
84afee34
MN
2212extern AVCodec msmpeg4v1_encoder;
2213extern AVCodec msmpeg4v2_encoder;
2214extern AVCodec msmpeg4v3_encoder;
7ce6a249
DB
2215extern AVCodec oggvorbis_encoder;
2216extern AVCodec pam_encoder;
2217extern AVCodec pbm_encoder;
2218extern AVCodec pgm_encoder;
2219extern AVCodec pgmyuv_encoder;
2220extern AVCodec png_encoder;
2221extern AVCodec ppm_encoder;
2222extern AVCodec rv10_encoder;
2223extern AVCodec rv20_encoder;
2d99eed1 2224extern AVCodec sgi_encoder;
791e7b83 2225extern AVCodec snow_encoder;
54f5fd22
AB
2226extern AVCodec sonic_encoder;
2227extern AVCodec sonic_ls_encoder;
3b64893d 2228extern AVCodec svq1_encoder;
2c0c00cb 2229extern AVCodec targa_encoder;
716222db 2230extern AVCodec tiff_encoder;
7ce6a249
DB
2231extern AVCodec vcr1_encoder;
2232extern AVCodec vorbis_encoder;
59686073
MN
2233extern AVCodec wmav1_encoder;
2234extern AVCodec wmav2_encoder;
7ce6a249
DB
2235extern AVCodec wmv1_encoder;
2236extern AVCodec wmv2_encoder;
6662ec29 2237extern AVCodec x264_encoder;
7ce6a249
DB
2238extern AVCodec xvid_encoder;
2239extern AVCodec zlib_encoder;
ec23a8cb 2240extern AVCodec zmbv_encoder;
de6d9b64 2241
7ce6a249
DB
2242extern AVCodec aac_decoder;
2243extern AVCodec aasc_decoder;
2244extern AVCodec alac_decoder;
2245extern AVCodec amr_nb_decoder;
2246extern AVCodec amr_wb_decoder;
2247extern AVCodec asv1_decoder;
2248extern AVCodec asv2_decoder;
2249extern AVCodec avs_decoder;
2250extern AVCodec bmp_decoder;
2251extern AVCodec cavs_decoder;
2252extern AVCodec cinepak_decoder;
2253extern AVCodec cljr_decoder;
2254extern AVCodec cook_decoder;
2255extern AVCodec cscd_decoder;
2256extern AVCodec cyuv_decoder;
01ca9ac3 2257extern AVCodec dca_decoder;
52b6bad2 2258extern AVCodec dnxhd_decoder;
7ce6a249
DB
2259extern AVCodec dsicinaudio_decoder;
2260extern AVCodec dsicinvideo_decoder;
2261extern AVCodec dvvideo_decoder;
33a0dd37 2262extern AVCodec dxa_decoder;
7ce6a249
DB
2263extern AVCodec eightbps_decoder;
2264extern AVCodec ffv1_decoder;
2265extern AVCodec ffvhuff_decoder;
2266extern AVCodec flac_decoder;
2267extern AVCodec flashsv_decoder;
2268extern AVCodec flic_decoder;
2269extern AVCodec flv_decoder;
2270extern AVCodec fourxm_decoder;
2271extern AVCodec fraps_decoder;
06d392a7 2272extern AVCodec gif_decoder;
c6148de2 2273extern AVCodec h261_decoder;
7ce6a249 2274extern AVCodec h263_decoder;
de6d9b64 2275extern AVCodec h263i_decoder;
7ce6a249
DB
2276extern AVCodec h264_decoder;
2277extern AVCodec huffyuv_decoder;
2278extern AVCodec idcin_decoder;
2279extern AVCodec imc_decoder;
2280extern AVCodec indeo2_decoder;
2281extern AVCodec indeo3_decoder;
2282extern AVCodec interplay_dpcm_decoder;
2283extern AVCodec interplay_video_decoder;
2284extern AVCodec kmvc_decoder;
2285extern AVCodec libgsm_decoder;
346a655d 2286extern AVCodec libgsm_ms_decoder;
7ce6a249
DB
2287extern AVCodec loco_decoder;
2288extern AVCodec mace3_decoder;
2289extern AVCodec mace6_decoder;
2290extern AVCodec mdec_decoder;
4e66ab3b 2291extern AVCodec mjpeg_decoder;
b135d9fb 2292extern AVCodec mjpegb_decoder;
7ce6a249 2293extern AVCodec mmvideo_decoder;
4b1f4f23 2294extern AVCodec mp2_decoder;
a96b68b7 2295extern AVCodec mp3_decoder;
1ede228a 2296extern AVCodec mp3adu_decoder;
d2a7718d 2297extern AVCodec mp3on4_decoder;
7ce6a249
DB
2298extern AVCodec mpc7_decoder;
2299extern AVCodec mpeg1video_decoder;
2300extern AVCodec mpeg2video_decoder;
2301extern AVCodec mpeg4_decoder;
280bd7b7 2302extern AVCodec mpeg4aac_decoder;
7ce6a249
DB
2303extern AVCodec mpeg_xvmc_decoder;
2304extern AVCodec mpegvideo_decoder;
2305extern AVCodec msmpeg4v1_decoder;
2306extern AVCodec msmpeg4v2_decoder;
2307extern AVCodec msmpeg4v3_decoder;
2fdf638b
MM
2308extern AVCodec msrle_decoder;
2309extern AVCodec msvideo1_decoder;
a273bbfb 2310extern AVCodec mszh_decoder;
7ce6a249
DB
2311extern AVCodec nuv_decoder;
2312extern AVCodec oggvorbis_decoder;
2313extern AVCodec png_decoder;
2314extern AVCodec qdm2_decoder;
2315extern AVCodec qdraw_decoder;
2316extern AVCodec qpeg_decoder;
2317extern AVCodec qtrle_decoder;
b8414bbd
NK
2318extern AVCodec ra_144_decoder;
2319extern AVCodec ra_288_decoder;
7ce6a249 2320extern AVCodec roq_decoder;
3ef8be2b 2321extern AVCodec roq_dpcm_decoder;
7ce6a249
DB
2322extern AVCodec rpza_decoder;
2323extern AVCodec rv10_decoder;
2324extern AVCodec rv20_decoder;
2325extern AVCodec rv30_decoder;
2326extern AVCodec rv40_decoder;
2d99eed1 2327extern AVCodec sgi_decoder;
7ce6a249
DB
2328extern AVCodec shorten_decoder;
2329extern AVCodec smackaud_decoder;
2330extern AVCodec smacker_decoder;
2331extern AVCodec smc_decoder;
2332extern AVCodec snow_decoder;
d08d7142 2333extern AVCodec sol_dpcm_decoder;
54f5fd22 2334extern AVCodec sonic_decoder;
7ce6a249
DB
2335extern AVCodec sp5x_decoder;
2336extern AVCodec svq1_decoder;
2337extern AVCodec svq3_decoder;
2338extern AVCodec targa_decoder;
2339extern AVCodec theora_decoder;
efb0c399 2340extern AVCodec thp_decoder;
7ce6a249
DB
2341extern AVCodec tiertexseqvideo_decoder;
2342extern AVCodec tiff_decoder;
2343extern AVCodec truemotion1_decoder;
2344extern AVCodec truemotion2_decoder;
2345extern AVCodec truespeech_decoder;
9d53d58e 2346extern AVCodec tscc_decoder;
7ce6a249 2347extern AVCodec tta_decoder;
d0a0bbd2 2348extern AVCodec ulti_decoder;
7ce6a249
DB
2349extern AVCodec vc1_decoder;
2350extern AVCodec vcr1_decoder;
2351extern AVCodec vmdaudio_decoder;
2352extern AVCodec vmdvideo_decoder;
2353extern AVCodec vmnc_decoder;
2354extern AVCodec vorbis_decoder;
2355extern AVCodec vp3_decoder;
2356extern AVCodec vp5_decoder;
2357extern AVCodec vp6_decoder;
2358extern AVCodec vp6f_decoder;
2359extern AVCodec vqa_decoder;
2360extern AVCodec wavpack_decoder;
2361extern AVCodec wmav1_decoder;
2362extern AVCodec wmav2_decoder;
2363extern AVCodec wmv1_decoder;
2364extern AVCodec wmv2_decoder;
2365extern AVCodec wmv3_decoder;
a8a15e9d 2366extern AVCodec wnv1_decoder;
034eeaa1 2367extern AVCodec ws_snd1_decoder;
7ce6a249
DB
2368extern AVCodec xan_dpcm_decoder;
2369extern AVCodec xan_wc3_decoder;
2370extern AVCodec xl_decoder;
2371extern AVCodec zlib_decoder;
9c8d8e84 2372extern AVCodec zmbv_decoder;
de6d9b64 2373
a96b68b7
FB
2374/* pcm codecs */
2375#define PCM_CODEC(id, name) \
2376extern AVCodec name ## _decoder; \
f11d3f23 2377extern AVCodec name ## _encoder
a96b68b7 2378
7ce6a249
DB
2379PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
2380PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
2381PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
2382PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
2383PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
2384PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
b461b3bc 2385PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
7ce6a249
DB
2386PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
2387PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
2388PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
2389PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
2390PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
2391PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
2392PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
2393PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
2394PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
2395PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
a96b68b7 2396
0147f198
FR
2397/* adpcm codecs */
2398
7ce6a249
DB
2399PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
2400PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
2401PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
2402PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
2403PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
9937e686
MM
2404PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
2405PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
7ce6a249
DB
2406PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
2407PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
2408PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
2409PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
2433f24f 2410PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
7ce6a249
DB
2411PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
2412PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
2413PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
2414PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
2415PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
2416PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
0147f198 2417
a96b68b7
FB
2418#undef PCM_CODEC
2419
2420/* dummy raw video codec */
63167088 2421extern AVCodec rawvideo_decoder;
7ce6a249 2422extern AVCodec rawvideo_encoder;
de6d9b64
FB
2423
2424/* the following codecs use external GPL libs */
23c99253 2425extern AVCodec dts_decoder;
f4ca5079 2426extern AVCodec liba52_decoder;
de6d9b64 2427
240c1657 2428/* subtitles */
c6ec28b1 2429extern AVCodec dvbsub_decoder;
7ce6a249
DB
2430extern AVCodec dvbsub_encoder;
2431extern AVCodec dvdsub_decoder;
2432extern AVCodec dvdsub_encoder;
240c1657 2433
de6d9b64
FB
2434/* resample.c */
2435
2436struct ReSampleContext;
aaaf1635 2437struct AVResampleContext;
de6d9b64
FB
2438
2439typedef struct ReSampleContext ReSampleContext;
2440
115329f1 2441ReSampleContext *audio_resample_init(int output_channels, int input_channels,
de6d9b64
FB
2442 int output_rate, int input_rate);
2443int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
2444void audio_resample_close(ReSampleContext *s);
2445
6e225de2 2446struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
aaaf1635 2447int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
2d48eddd 2448void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
d88443ae 2449void av_resample_close(struct AVResampleContext *c);
aaaf1635 2450
bc2ce35b 2451#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
de6d9b64
FB
2452/* YUV420 format is assumed ! */
2453
bc2ce35b 2454struct ImgReSampleContext attribute_deprecated;
de6d9b64 2455
bc2ce35b 2456typedef struct ImgReSampleContext ImgReSampleContext attribute_deprecated;
de6d9b64 2457
bc2ce35b 2458attribute_deprecated ImgReSampleContext *img_resample_init(int output_width, int output_height,
de6d9b64 2459 int input_width, int input_height);
ab6d194a 2460
bc2ce35b 2461attribute_deprecated ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
ab6d194a
MN
2462 int iwidth, int iheight,
2463 int topBand, int bottomBand,
1ff93ffc
TK
2464 int leftBand, int rightBand,
2465 int padtop, int padbottom,
2466 int padleft, int padright);
2467
ab6d194a 2468
bc2ce35b 2469attribute_deprecated void img_resample(ImgReSampleContext *s,
da64ecc3 2470 AVPicture *output, const AVPicture *input);
de6d9b64 2471
bc2ce35b
MN
2472attribute_deprecated void img_resample_close(ImgReSampleContext *s);
2473
2474#endif
de6d9b64 2475
75917b88
DH
2476/**
2477 * Allocate memory for a picture. Call avpicture_free to free it.
2478 *
2479 * @param picture the picture to be filled in.
2480 * @param pix_fmt the format of the picture.
2481 * @param width the width of the picture.
2482 * @param height the height of the picture.
f9ec0aa1 2483 * @return Zero if successful, a negative value if not.
75917b88
DH
2484 */
2485int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height);
2486
8fc3d25c
PI
2487/**
2488 * Free a picture previously allocated by avpicture_alloc().
2489 *
2490 * @param picture The AVPicture to be freed.
2491 */
75917b88
DH
2492void avpicture_free(AVPicture *picture);
2493
392cf77a
PI
2494/**
2495 * Fill in AVPicture's fields.
2496 * The fields of the given AVPicture are filled in by using the 'ptr' address
2497 * which points to the image data buffer. Depending on the specified picture
2498 * format, one or multiple image data pointers and line sizes will be set.
2499 * If a planar format is specified, several pointers will be set pointing to
2500 * the different picture planes and the line sizes of the different planes
2501 * will be stored in the lines_sizes array.
2502 *
2503 * @param picture AVPicture who's fields are to be filled in
2504 * @param ptr Buffer which will contain or contains the actual image data
2505 * @param pix_fmt The format in which the picture data is stored
2506 * @param width The width of the image in pixels
2507 * @param height The height of the image in pixels
2508 * @return Size of the image data in bytes.
2509 */
0c1a9eda 2510int avpicture_fill(AVPicture *picture, uint8_t *ptr,
2d1a4094 2511 int pix_fmt, int width, int height);
da64ecc3 2512int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
63167088 2513 unsigned char *dest, int dest_size);
392cf77a
PI
2514
2515/**
2516 * Calculate the size in bytes that a picture of the given width and height
2517 * would occupy if stored in the given picture format.
2518 *
2519 * @param pix_fmt The given picture format
2520 * @param width The width of the image
2521 * @param height The height of the image
2522 * @return Image data size in bytes
2523 */
219b06c6 2524int avpicture_get_size(int pix_fmt, int width, int height);
dab64ebc
FB
2525void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
2526const char *avcodec_get_pix_fmt_name(int pix_fmt);
21adafec 2527void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
63167088 2528enum PixelFormat avcodec_get_pix_fmt(const char* name);
d07730dd 2529unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
219b06c6 2530
81299d42
PI
2531#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
2532#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
2533#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
2534#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
2535#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
2536#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
fab21997 2537
392cf77a 2538/**
81299d42
PI
2539 * Computes what kind of losses will occur when converting from one specific
2540 * pixel format to another.
2541 * When converting from one pixel format to another, information loss may occur.
2542 * For example, when converting from RGB24 to GRAY, the color information will
2543 * be lost. Similarly, other losses occur when converting from some formats to
2544 * other formats. These losses can involve loss of chroma, but also loss of
2545 * resolution, loss of color depth, loss due to the color space conversion, loss
2546 * of the alpha bits or loss due to color quantization.
2547 * avcodec_get_fix_fmt_loss() informs you on the various types of losses which
2548 * will occur when converting from one pixel format to another.
2549 *
2550 * @param[in] dst_pix_fmt Destination pixel format.
2551 * @param[in] src_pix_fmt Source pixel format.
2552 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
2553 * @return Combination of flags informing you what kind of losses will occur.
392cf77a 2554 */
fab21997
FB
2555int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
2556 int has_alpha);
392cf77a
PI
2557
2558/**
81299d42
PI
2559 * Finds the best pixel format to convert to given a certain source pixel
2560 * format. When converting from one pixel format to another, information loss
2561 * may occur. For example, when converting from RGB24 to GRAY, the color
2562 * information will be lost. Similarly, other losses occur when converting from
2563 * some formats to other formats. avcodec_find_best_pix_fmt() searches which of
2564 * the given pixel formats should be used to undergo the least amount of losses.
2565 * The pixel formats from which it choses one, are determined by the
2566 * \p pix_fmt_mask parameter.
2567 *
2568 * @code
2569 * src_pix_fmt = PIX_FMT_YUV420P;
2570 * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24);
2571 * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss);
2572 * @endcode
2573 *
2574 * @param[in] pix_fmt_mask Bitmask determining which pixel format to choose from.
2575 * @param[in] src_pix_fmt Source pixel format.
2576 * @param[in] has_alpha Whether the source pixel format alpha channel is used.
2577 * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur.
2578 * @return The best pixel format to convert to or -1 if none was found.
392cf77a 2579 */
fab21997
FB
2580int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
2581 int has_alpha, int *loss_ptr);
2582
0469baf1
FB
2583#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
2584#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
392cf77a
PI
2585
2586/**
2587 * Tell if an image really has transparent alpha values.
2588 * @return ored mask of FF_ALPHA_xxx constants
2589 */
da64ecc3 2590int img_get_alpha_info(const AVPicture *src,
bb270c08 2591 int pix_fmt, int width, int height);
0469baf1 2592
bc2ce35b 2593#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
219b06c6 2594/* convert among pixel formats */
bc2ce35b 2595attribute_deprecated int img_convert(AVPicture *dst, int dst_pix_fmt,
115329f1 2596 const AVPicture *src, int pix_fmt,
219b06c6 2597 int width, int height);
bc2ce35b 2598#endif
219b06c6
FB
2599
2600/* deinterlace a picture */
392cf77a 2601/* deinterlace - if not supported return -1 */
da64ecc3 2602int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
de6d9b64
FB
2603 int pix_fmt, int width, int height);
2604
2605/* external high level API */
2606
2607extern AVCodec *first_avcodec;
2608
156e5023 2609/* returns LIBAVCODEC_VERSION_INT constant */
51a49663 2610unsigned avcodec_version(void);
8bceb6af 2611/* returns LIBAVCODEC_BUILD constant */
51a49663 2612unsigned avcodec_build(void);
f9ec0aa1
PI
2613
2614/**
2615 * Initializes libavcodec.
2616 *
2617 * @warning This function \e must be called before any other libavcodec
2618 * function.
2619 */
de6d9b64
FB
2620void avcodec_init(void);
2621
2622void register_avcodec(AVCodec *format);
f9ec0aa1
PI
2623
2624/**
2625 * Finds an encoder with a matching codec ID.
2626 *
2627 * @param id CodecID of the requested encoder.
2628 * @return An encoder if one was found, NULL otherwise.
2629 */
de6d9b64 2630AVCodec *avcodec_find_encoder(enum CodecID id);
f9ec0aa1
PI
2631
2632/**
2633 * Finds an encoder with the specified name.
2634 *
2635 * @param name Name of the requested encoder.
2636 * @return An encoder if one was found, NULL otherwise.
2637 */
98f3b098 2638AVCodec *avcodec_find_encoder_by_name(const char *name);
f9ec0aa1
PI
2639
2640/**
2641 * Finds a decoder with a matching codec ID.
2642 *
2643 * @param id CodecID of the requested decoder.
2644 * @return A decoder if one was found, NULL otherwise.
2645 */
de6d9b64 2646AVCodec *avcodec_find_decoder(enum CodecID id);
f9ec0aa1
PI
2647
2648/**
2649 * Finds an decoder with the specified name.
2650 *
2651 * @param name Name of the requested decoder.
2652 * @return A decoder if one was found, NULL otherwise.
2653 */
de6d9b64
FB
2654AVCodec *avcodec_find_decoder_by_name(const char *name);
2655void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
2656
f9ec0aa1
PI
2657/**
2658 * Sets the fields of the given AVCodecContext to default values.
2659 *
2660 * @param s The AVCodecContext of which the fields should be set to default values.
2661 */
1e491e29 2662void avcodec_get_context_defaults(AVCodecContext *s);
f9ec0aa1 2663
29301573
MN
2664/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
2665 * we WILL change its arguments and name a few times! */
2666void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType);
2667
f9ec0aa1
PI
2668/**
2669 * Allocates an AVCodecContext and sets its fields to default values. The
2670 * resulting struct can be deallocated by simply calling av_free().
2671 *
2672 * @return An AVCodecContext filled with default values or NULL on failure.
2673 * @see avcodec_get_context_defaults
2674 */
7ffbb60e 2675AVCodecContext *avcodec_alloc_context(void);
f9ec0aa1 2676
29301573
MN
2677/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API!
2678 * we WILL change its arguments and name a few times! */
2679AVCodecContext *avcodec_alloc_context2(enum CodecType);
2680
f9ec0aa1
PI
2681/**
2682 * Sets the fields of the given AVFrame to default values.
2683 *
2684 * @param pic The AVFrame of which the fields should be set to default values.
2685 */
7906085f 2686void avcodec_get_frame_defaults(AVFrame *pic);
f9ec0aa1
PI
2687
2688/**
2689 * Allocates an AVFrame and sets its fields to default values. The resulting
2690 * struct can be deallocated by simply calling av_free().
2691 *
2692 * @return An AVFrame filled with default values or NULL on failure.
2693 * @see avcodec_get_frame_defaults
2694 */
492cd3a9 2695AVFrame *avcodec_alloc_frame(void);
1e491e29 2696
492cd3a9
MN
2697int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
2698void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
3a569751
MN
2699int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic);
2700void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height);
f9ec0aa1
PI
2701
2702/**
2703 * Checks if the given dimension of a picture is valid, meaning that all
2704 * bytes of the picture can be addressed with a signed int.
2705 *
2706 * @param[in] w Width of the picture.
2707 * @param[in] h Height of the picture.
2708 * @return Zero if valid, a negative value if invalid.
2709 */
0ecca7a4 2710int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h);
3a569751 2711enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt);
1e491e29 2712
5a815088
MN
2713int avcodec_thread_init(AVCodecContext *s, int thread_count);
2714void avcodec_thread_free(AVCodecContext *s);
2715int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
3a569751 2716int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void **arg, int *ret, int count);
9c3d33d6
MN
2717//FIXME func typedef
2718
7a06ff14 2719/**
f9ec0aa1
PI
2720 * Initializes the AVCodecContext to use the given AVCodec. Prior to using this
2721 * function the context has to be allocated.
2722 *
2723 * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
2724 * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
2725 * retrieving a codec.
2726 *
2727 * @warning This function is not thread save!
2728 *
2729 * @code
2730 * codec = avcodec_find_decoder(CODEC_ID_H264);
2731 * if (!codec)
2732 * exit(1);
2733 *
2734 * context = avcodec_alloc_context();
2735 *
2736 * if (avcodec_open(context, codec) < 0)
2737 * exit(1);
2738 * @endcode
2739 *
2740 * @param avctx The context which will be setup to use the given codec.
2741 * @param codec The codec to use within the context.
2742 * @return Zero on success, a negative value on error.
2743 * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder
7a06ff14 2744 */
de6d9b64 2745int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
7a06ff14 2746
f9ec0aa1
PI
2747/**
2748 * @deprecated Use avcodec_decode_audio2() instead.
2749 */
ac66834c
MN
2750attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
2751 int *frame_size_ptr,
2752 uint8_t *buf, int buf_size);
f9ec0aa1 2753
98145875 2754/**
f9ec0aa1
PI
2755 * Decodes an audio frame from \p buf into \p samples.
2756 * The avcodec_decode_audio2() function decodes a frame of audio from the input
2757 * buffer \p buf of size \p buf_size. To decode it, it makes use of the
2758 * audiocodec which was coupled with \p avctx using avcodec_open(). The
2759 * resulting decoded frame is stored in output buffer \p samples. If no frame
2760 * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the
2761 * decompressed frame size in \e bytes.
2762 *
2763 * @warning You \e must set \p frame_size_ptr to the allocated size of the
2764 * output buffer before calling avcodec_decode_audio2().
2765 *
2766 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
2767 * the actual read bytes because some optimized bitstream readers read 32 or 64
2768 * bits at once and could read over the end.
2769 *
2770 * @warning The end of the input buffer \p buf should be set to 0 to ensure that
2771 * no overreading happens for damaged MPEG streams.
98145875 2772 *
f9ec0aa1
PI
2773 * @note You might have to align the input buffer \p buf and output buffer \p
2774 * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
2775 * necessary at all, on others it won't work at all if not aligned and on others
2776 * it will work but it will have an impact on performance. In practice, the
2777 * bitstream should have 4 byte alignment at minimum and all sample data should
2778 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
2779 * the linesize is not a multiple of 16 then there's no sense in aligning the
2780 * start of the buffer to 16.
2781 *
2782 * @param avctx The codec context.
2783 * @param[out] samples The output buffer.
2784 * @param[in,out] frame_size_ptr The output buffer size in bytes.
2785 * @param[in] buf The input buffer.
2786 * @param[in] buf_size The input buffer size in bytes.
2787 * @return On error a negative value is returned, otherwise the number of bytes
2788 * used or zero if no frame could be decompressed.
98145875 2789 */
ac66834c 2790int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
de6d9b64 2791 int *frame_size_ptr,
0c1a9eda 2792 uint8_t *buf, int buf_size);
f9ec0aa1
PI
2793
2794/**
2795 * Decodes a video frame from \p buf into \p picture.
2796 * The avcodec_decode_video() function decodes a frame of video from the input
2797 * buffer \p buf of size \p buf_size. To decode it, it makes use of the
2798 * videocodec which was coupled with \p avctx using avcodec_open(). The
2799 * resulting decoded frame is stored in \p picture.
2800 *
2801 * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than
2802 * the actual read bytes because some optimized bitstream readers read 32 or 64
2803 * bits at once and could read over the end.
2804 *
2805 * @warning The end of the input buffer \p buf should be set to 0 to ensure that
2806 * no overreading happens for damaged MPEG streams.
2807 *
2808 * @note You might have to align the input buffer \p buf and output buffer \p
2809 * samples. The alignment requirements depend on the CPU: on some CPUs it isn't
2810 * necessary at all, on others it won't work at all if not aligned and on others
2811 * it will work but it will have an impact on performance. In practice, the
2812 * bitstream should have 4 byte alignment at minimum and all sample data should
2813 * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If
2814 * the linesize is not a multiple of 16 then there's no sense in aligning the
2815 * start of the buffer to 16.
2816 *
2817 * @param avctx The codec context.
2818 * @param[out] picture The AVFrame in which the decoded video frame will be stored.
2819 * @param[in] buf The input buffer.
2820 * @param[in] buf_size The size of the input buffer in bytes.
2821 * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is non zero.
2822 * @return On error a negative value is returned, otherwise the number of bytes
2823 * used or zero if no frame could be decompressed.
2824 */
115329f1 2825int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
de6d9b64 2826 int *got_picture_ptr,
0c1a9eda 2827 uint8_t *buf, int buf_size);
8ab4861c
PI
2828
2829/* decode a subtitle message. return -1 if error, otherwise return the
2830 *number of bytes used. If no subtitle could be decompressed,
2831 *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
240c1657
FB
2832int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub,
2833 int *got_sub_ptr,
2834 const uint8_t *buf, int buf_size);
115329f1 2835int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
917e06c8 2836 int *data_size_ptr,
0c1a9eda 2837 uint8_t *buf, int buf_size);
f9ec0aa1
PI
2838
2839/**
2840 * Encodes an audio frame from \p samples into \p buf.
2841 * The avcodec_encode_audio() function encodes a frame of audio from the input
2842 * buffer \p samples. To encode it, it makes use of the audiocodec which was
2843 * coupled with \p avctx using avcodec_open(). The resulting encoded frame is
2844 * stored in output buffer \p buf.
2845 *
2846 * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large.
2847 *
2848 * @param avctx The codec context.
2849 * @param[out] buf The output buffer.
2850 * @param[in] buf_size The output buffer size.
2851 * @param[in] samples The input buffer containing the samples.
2852 * @return On error a negative value is returned, on succes zero or the number
2853 * of bytes used from the input buffer.
2854 */
115329f1 2855int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
de6d9b64 2856 const short *samples);
f9ec0aa1
PI
2857
2858/**
2859 * Encodes a video frame from \p pict into \p buf.
2860 * The avcodec_encode_video() function encodes a frame of video from the input
2861 * \p pict. To encode it, it makes use of the videocodec which was coupled with
2862 * \p avctx using avcodec_open(). The resulting encoded bytes representing the
2863 * frame are stored in the output buffer \p buf. The input picture should be
2864 * stored using a specific format, namely \c avctx.pix_fmt.
2865 *
2866 * @param avctx The codec context.
2867 * @param[out] buf The output buffer for the bitstream of encoded frame.
2868 * @param[in] buf_size The size of the outputbuffer in bytes.
2869 * @param[in] pict The input picture to encode.
2870 * @return On error a negative value is returned, on success zero or the number
2871 * of bytes used from the input buffer.
2872 */
115329f1 2873int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
492cd3a9 2874 const AVFrame *pict);
115329f1 2875int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
240c1657 2876 const AVSubtitle *sub);
de6d9b64
FB
2877
2878int avcodec_close(AVCodecContext *avctx);
2879
2880void avcodec_register_all(void);
a96b68b7 2881
8ab4861c
PI
2882/**
2883 * Flush buffers, should be called when seeking or when switching to a different stream.
2884 */
1c2a8c7f
MN
2885void avcodec_flush_buffers(AVCodecContext *avctx);
2886
88730be6
MR
2887void avcodec_default_free_buffers(AVCodecContext *s);
2888
85975aa9 2889/* misc useful functions */
d8085ea7
MN
2890
2891/**
8f6260af
PI
2892 * Returns a single letter to describe the given picture type \p pict_type.
2893 *
2894 * @param[in] pict_type The picture type.
2895 * @return A single character representing the picture type.
d8085ea7
MN
2896 */
2897char av_get_pict_type_char(int pict_type);
2898
ac3e1834 2899/**
2fa378a7
PI
2900 * Returns codec bits per sample.
2901 *
2902 * @param[in] codec_id The codec.
2903 * @return Number of bits per sample or zero if unknown for the given codec.
ac3e1834
BC
2904 */
2905int av_get_bits_per_sample(enum CodecID codec_id);
2e8f2c20 2906
8424cf50
FB
2907/* frame parsing */
2908typedef struct AVCodecParserContext {
2909 void *priv_data;
2910 struct AVCodecParser *parser;
2911 int64_t frame_offset; /* offset of the current frame */
115329f1 2912 int64_t cur_offset; /* current offset
8424cf50
FB
2913 (incremented by each av_parser_parse()) */
2914 int64_t last_frame_offset; /* offset of the last frame */
2915 /* video info */
2916 int pict_type; /* XXX: put it back in AVCodecContext */
2917 int repeat_pict; /* XXX: put it back in AVCodecContext */
b84f2a35
FB
2918 int64_t pts; /* pts of the current frame */
2919 int64_t dts; /* dts of the current frame */
2920
2921 /* private data */
2922 int64_t last_pts;
2923 int64_t last_dts;
a62aecce 2924 int fetch_timestamp;
b84f2a35
FB
2925
2926#define AV_PARSER_PTS_NB 4
2927 int cur_frame_start_index;
2928 int64_t cur_frame_offset[AV_PARSER_PTS_NB];
2929 int64_t cur_frame_pts[AV_PARSER_PTS_NB];
2930 int64_t cur_frame_dts[AV_PARSER_PTS_NB];
115329f1 2931
7cbaa7ba
MN
2932 int flags;
2933#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
8424cf50
FB
2934} AVCodecParserContext;
2935
2936typedef struct AVCodecParser {
99f06236 2937 int codec_ids[5]; /* several codec IDs are permitted */
8424cf50
FB
2938 int priv_data_size;
2939 int (*parser_init)(AVCodecParserContext *s);
115329f1 2940 int (*parser_parse)(AVCodecParserContext *s,
8424cf50 2941 AVCodecContext *avctx,
115329f1 2942 uint8_t **poutbuf, int *poutbuf_size,
8424cf50
FB
2943 const uint8_t *buf, int buf_size);
2944 void (*parser_close)(AVCodecParserContext *s);
90ad92b3 2945 int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size);
8424cf50
FB
2946 struct AVCodecParser *next;
2947} AVCodecParser;
2948
2949extern AVCodecParser *av_first_parser;
2950
2951void av_register_codec_parser(AVCodecParser *parser);
2952AVCodecParserContext *av_parser_init(int codec_id);
115329f1 2953int av_parser_parse(AVCodecParserContext *s,
8424cf50 2954 AVCodecContext *avctx,
115329f1 2955 uint8_t **poutbuf, int *poutbuf_size,
b84f2a35
FB
2956 const uint8_t *buf, int buf_size,
2957 int64_t pts, int64_t dts);
90ad92b3
MN
2958int av_parser_change(AVCodecParserContext *s,
2959 AVCodecContext *avctx,
115329f1 2960 uint8_t **poutbuf, int *poutbuf_size,
90ad92b3 2961 const uint8_t *buf, int buf_size, int keyframe);
8424cf50
FB
2962void av_parser_close(AVCodecParserContext *s);
2963
7ce6a249
DB
2964extern AVCodecParser aac_parser;
2965extern AVCodecParser ac3_parser;
20ffddb9 2966extern AVCodecParser cavsvideo_parser;
01ca9ac3 2967extern AVCodecParser dca_parser;
7ce6a249
DB
2968extern AVCodecParser dvbsub_parser;
2969extern AVCodecParser dvdsub_parser;
c6148de2 2970extern AVCodecParser h261_parser;
8424cf50
FB
2971extern AVCodecParser h263_parser;
2972extern AVCodecParser h264_parser;
8e6325b9 2973extern AVCodecParser mjpeg_parser;
7ce6a249 2974extern AVCodecParser mpeg4video_parser;
8424cf50 2975extern AVCodecParser mpegaudio_parser;
7ce6a249
DB
2976extern AVCodecParser mpegvideo_parser;
2977extern AVCodecParser pnm_parser;
35bffd7f 2978extern AVCodecParser vc1_parser;
8424cf50 2979
748c2fca
MN
2980
2981typedef struct AVBitStreamFilterContext {
514e0831 2982 void *priv_data;
748c2fca
MN
2983 struct AVBitStreamFilter *filter;
2984 AVCodecParserContext *parser;
2985 struct AVBitStreamFilterContext *next;
2986} AVBitStreamFilterContext;
2987
2988
2989typedef struct AVBitStreamFilter {
2990 const char *name;
514e0831 2991 int priv_data_size;
748c2fca
MN
2992 int (*filter)(AVBitStreamFilterContext *bsfc,
2993 AVCodecContext *avctx, const char *args,
2994 uint8_t **poutbuf, int *poutbuf_size,
2995 const uint8_t *buf, int buf_size, int keyframe);
2996 struct AVBitStreamFilter *next;
2997} AVBitStreamFilter;
2998
2999extern AVBitStreamFilter *av_first_bitstream_filter;
3000
3001void av_register_bitstream_filter(AVBitStreamFilter *bsf);
3002AVBitStreamFilterContext *av_bitstream_filter_init(const char *name);
3003int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc,
3004 AVCodecContext *avctx, const char *args,
3005 uint8_t **poutbuf, int *poutbuf_size,
3006 const uint8_t *buf, int buf_size, int keyframe);
3007void av_bitstream_filter_close(AVBitStreamFilterContext *bsf);
3008
3009extern AVBitStreamFilter dump_extradata_bsf;
3010extern AVBitStreamFilter remove_extradata_bsf;
514e0831 3011extern AVBitStreamFilter noise_bsf;
eacb41b2
MN
3012extern AVBitStreamFilter mp3_header_compress_bsf;
3013extern AVBitStreamFilter mp3_header_decompress_bsf;
1a1c5385 3014extern AVBitStreamFilter mjpega_dump_header_bsf;
92d6b7fd 3015extern AVBitStreamFilter imx_dump_header_bsf;
748c2fca
MN
3016
3017
544eb99c 3018/* memory */
8ab4861c
PI
3019
3020/**
4267e90d
PI
3021 * Reallocates the given block if it is not large enough, otherwise it
3022 * does nothing.
3023 *
3024 * @see av_realloc
8ab4861c 3025 */
97d96aaa 3026void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
8ab4861c 3027
855ea723 3028/* for static data only */
8ab4861c
PI
3029
3030/**
8079a686
PI
3031 * Frees all static arrays and reset their pointers to 0.
3032 * Call this function to release all statically allocated tables.
8ab4861c 3033 */
ca2a0c93 3034attribute_deprecated void av_free_static(void);
8ab4861c
PI
3035
3036/**
9c5cb112
PI
3037 * Allocation of static arrays.
3038 *
3039 * @warning Do not use for normal allocation.
3040 *
3041 * @param[in] size The amount of memory you need in bytes.
3042 * @return Block of memory of the requested size.
8ab4861c 3043 */
ca2a0c93 3044attribute_deprecated void *av_mallocz_static(unsigned int size);
8ab4861c 3045
392cf77a
PI
3046/**
3047 * Copy image 'src' to 'dst'.
3048 */
636d6a4a 3049void av_picture_copy(AVPicture *dst, const AVPicture *src,
e1c2a5a0
RT
3050 int pix_fmt, int width, int height);
3051
392cf77a
PI
3052/**
3053 * Crop image top and left side
3054 */
636d6a4a 3055int av_picture_crop(AVPicture *dst, const AVPicture *src,
f2651e7a
BC
3056 int pix_fmt, int top_band, int left_band);
3057
392cf77a
PI
3058/**
3059 * Pad image
3060 */
636d6a4a 3061int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
5341c209
LA
3062 int padtop, int padbottom, int padleft, int padright, int *color);
3063
636d6a4a
PI
3064#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
3065attribute_deprecated void img_copy(AVPicture *dst, const AVPicture *src,
3066 int pix_fmt, int width, int height);
3067
3068attribute_deprecated int img_crop(AVPicture *dst, const AVPicture *src,
3069 int pix_fmt, int top_band, int left_band);
3070
3071attribute_deprecated int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
3072 int padtop, int padbottom, int padleft, int padright, int *color);
3073#endif
3074
ad2b531d
MR
3075extern unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
3076
8fa36ae0
FR
3077/* error handling */
3078#if EINVAL > 0
3079#define AVERROR(e) (-(e)) /**< returns a negative error code from a POSIX error code, to return from library functions. */
3080#define AVUNERROR(e) (-(e)) /**< returns a POSIX error code from a library function error return value. */
3081#else
3082/* some platforms have E* and errno already negated. */
3083#define AVERROR(e) (e)
3084#define AVUNERROR(e) (e)
3085#endif
3086#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */
3087#define AVERROR_IO AVERROR(EIO) /**< i/o error */
3088#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< number syntax expected in filename */
3089#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */
3090#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */
3091#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */
3092#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< operation not supported */
3093
02d697aa
ZK
3094#ifdef __cplusplus
3095}
3096#endif
3097
a96b68b7 3098#endif /* AVCODEC_H */