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