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