Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ 7458ccbb

History | View | Annotate | Download (48.5 KB)

1 a96b68b7 Fabrice Bellard
#ifndef AVCODEC_H
2
#define AVCODEC_H
3
4 36df8805 Michael Niedermayer
/**
5
 * @file avcodec.h
6 d33c949c Michael Niedermayer
 * external api header.
7 36df8805 Michael Niedermayer
 */
8
9
10 02d697aa Zdenek Kabelac
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
14 de6d9b64 Fabrice Bellard
#include "common.h"
15
16 7b7d86f1 Fabrice Bellard
#define FFMPEG_VERSION_INT     0x000408
17
#define FFMPEG_VERSION         "0.4.8"
18 05fbd0a2 Michael Niedermayer
#define LIBAVCODEC_BUILD       4680
19 4b1f4f23 Juanjo
20 7b7d86f1 Fabrice Bellard
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
21
#define LIBAVCODEC_VERSION     FFMPEG_VERSION
22
23
#define AV_STRINGIFY(s)        AV_TOSTRING(s)
24
#define AV_TOSTRING(s) #s
25
#define LIBAVCODEC_IDENT        "FFmpeg" LIBAVCODEC_VERSION "b" AV_STRINGIFY(LIBAVCODEC_BUILD)
26 ce2749d2 Alex Beregszaszi
27 de6d9b64 Fabrice Bellard
enum CodecID {
28
    CODEC_ID_NONE, 
29
    CODEC_ID_MPEG1VIDEO,
30 dcedf586 Fabrice Bellard
    CODEC_ID_MPEG2VIDEO, /* prefered ID for MPEG Video 1 or 2 decoding */
31 fb364ada Ivan Kalvachev
    CODEC_ID_MPEG2VIDEO_XVMC,
32 de6d9b64 Fabrice Bellard
    CODEC_ID_H263,
33
    CODEC_ID_RV10,
34
    CODEC_ID_MP2,
35 dcedf586 Fabrice Bellard
    CODEC_ID_MP3, /* prefered ID for MPEG Audio layer 1, 2 or3 decoding */
36 81e0d0b4 Mark Hills
    CODEC_ID_VORBIS,
37 de6d9b64 Fabrice Bellard
    CODEC_ID_AC3,
38
    CODEC_ID_MJPEG,
39 b135d9fb Alex Beregszaszi
    CODEC_ID_MJPEGB,
40 b1e6b355 Michael Niedermayer
    CODEC_ID_LJPEG,
41 bf89e6b1 Fabrice Bellard
    CODEC_ID_MPEG4,
42 de6d9b64 Fabrice Bellard
    CODEC_ID_RAWVIDEO,
43 84afee34 Michael Niedermayer
    CODEC_ID_MSMPEG4V1,
44
    CODEC_ID_MSMPEG4V2,
45
    CODEC_ID_MSMPEG4V3,
46 e1a9dbff Michael Niedermayer
    CODEC_ID_WMV1,
47 b50eef3a Michael Niedermayer
    CODEC_ID_WMV2,
48 de6d9b64 Fabrice Bellard
    CODEC_ID_H263P,
49
    CODEC_ID_H263I,
50 d4f5d74a Garrick Meeker
    CODEC_ID_FLV1,
51 be8ffec9 Nick Kurshev
    CODEC_ID_SVQ1,
52 8b82a956 Michael Niedermayer
    CODEC_ID_SVQ3,
53 020fcc94 Fabrice Bellard
    CODEC_ID_DVVIDEO,
54
    CODEC_ID_DVAUDIO,
55 bc8d1857 Fabrice Bellard
    CODEC_ID_WMAV1,
56
    CODEC_ID_WMAV2,
57 3f95e843 François Revol
    CODEC_ID_MACE3,
58
    CODEC_ID_MACE6,
59 11f18faf Michael Niedermayer
    CODEC_ID_HUFFYUV,
60 f70f7c6d Michael Niedermayer
    CODEC_ID_CYUV,
61 0da71265 Michael Niedermayer
    CODEC_ID_H264,
62 deabd4fd Mike Melanson
    CODEC_ID_INDEO3,
63 d86053a4 Mike Melanson
    CODEC_ID_VP3,
64 280bd7b7 Zdenek Kabelac
    CODEC_ID_AAC,
65
    CODEC_ID_MPEG4AAC,
66 3d2e8cce Michael Niedermayer
    CODEC_ID_ASV1,
67 9b56edf5 Michael Niedermayer
    CODEC_ID_ASV2,
68 5e20f836 Michael Niedermayer
    CODEC_ID_FFV1,
69 e2a7bb28 Mike Melanson
    CODEC_ID_4XM,
70 be3564ed Michael Niedermayer
    CODEC_ID_VCR1,
71 3aff069b Alex Beregszaszi
    CODEC_ID_CLJR,
72 c3bf0288 Michael Niedermayer
    CODEC_ID_MDEC,
73 3ef8be2b Mike Melanson
    CODEC_ID_ROQ,
74
    CODEC_ID_INTERPLAY_VIDEO,
75 9937e686 Mike Melanson
    CODEC_ID_XAN_WC3,
76
    CODEC_ID_XAN_WC4,
77 a96b68b7 Fabrice Bellard
78
    /* various pcm "codecs" */
79
    CODEC_ID_PCM_S16LE,
80
    CODEC_ID_PCM_S16BE,
81
    CODEC_ID_PCM_U16LE,
82
    CODEC_ID_PCM_U16BE,
83
    CODEC_ID_PCM_S8,
84
    CODEC_ID_PCM_U8,
85
    CODEC_ID_PCM_MULAW,
86
    CODEC_ID_PCM_ALAW,
87 0147f198 François Revol
88
    /* various adpcm codecs */
89
    CODEC_ID_ADPCM_IMA_QT,
90
    CODEC_ID_ADPCM_IMA_WAV,
91 9937e686 Mike Melanson
    CODEC_ID_ADPCM_IMA_DK3,
92
    CODEC_ID_ADPCM_IMA_DK4,
93 0147f198 François Revol
    CODEC_ID_ADPCM_MS,
94 e2a7bb28 Mike Melanson
    CODEC_ID_ADPCM_4XM,
95 891f64b3 joca@rixmail.se
96
        /* AMR */
97
    CODEC_ID_AMR_NB,
98 d663a1fd Michael Niedermayer
    CODEC_ID_AMR_WB,
99
100 b8414bbd Nick Kurshev
    /* RealAudio codecs*/
101
    CODEC_ID_RA_144,
102
    CODEC_ID_RA_288,
103 3ef8be2b Mike Melanson
104
    /* various DPCM codecs */
105
    CODEC_ID_ROQ_DPCM,
106
    CODEC_ID_INTERPLAY_DPCM,
107 9937e686 Mike Melanson
    CODEC_ID_XAN_DPCM,
108 de6d9b64 Fabrice Bellard
};
109 dcedf586 Fabrice Bellard
110
/* CODEC_ID_MP3LAME is absolete */
111
#define CODEC_ID_MP3LAME CODEC_ID_MP3
112 de6d9b64 Fabrice Bellard
113
enum CodecType {
114 4a663d80 Philip Gladstone
    CODEC_TYPE_UNKNOWN = -1,
115 de6d9b64 Fabrice Bellard
    CODEC_TYPE_VIDEO,
116
    CODEC_TYPE_AUDIO,
117
};
118
119 64863965 Michael Niedermayer
/**
120 0f371e3e Mike Melanson
 * Pixel format. Notes: 
121
 *
122
 * PIX_FMT_RGBA32 is handled in an endian-specific manner. A RGBA
123
 * color is put together as:
124
 *  (A << 24) | (R << 16) | (G << 8) | B
125
 * This is stored as BGRA on little endian CPU architectures and ARGB on
126
 * big endian CPUs.
127
 *
128
 * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
129
 * image data is stored in AVFrame.data[0]. The palette is transported in
130
 * AVFrame.data[1] and, is 1024 bytes long (256 4-byte entries) and is
131
 * formatted the same as in PIX_FMT_RGBA32 described above (i.e., it is
132
 * also endian-specific).
133 64863965 Michael Niedermayer
 */
134 de6d9b64 Fabrice Bellard
enum PixelFormat {
135 cd394651 Michael Niedermayer
    PIX_FMT_YUV420P,   ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
136
    PIX_FMT_YUV422,    
137
    PIX_FMT_RGB24,     ///< Packed pixel, 3 bytes per pixel, RGBRGB...
138
    PIX_FMT_BGR24,     ///< Packed pixel, 3 bytes per pixel, BGRBGR...
139
    PIX_FMT_YUV422P,   ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
140
    PIX_FMT_YUV444P,   ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
141 0f371e3e Mike Melanson
    PIX_FMT_RGBA32,    ///< Packed pixel, 4 bytes per pixel, BGRABGRA..., stored in cpu endianness
142 cd394651 Michael Niedermayer
    PIX_FMT_YUV410P,   ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
143
    PIX_FMT_YUV411P,   ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
144 64863965 Michael Niedermayer
    PIX_FMT_RGB565,    ///< always stored in cpu endianness 
145
    PIX_FMT_RGB555,    ///< always stored in cpu endianness, most significant bit to 1 
146 dab64ebc Fabrice Bellard
    PIX_FMT_GRAY8,
147 64863965 Michael Niedermayer
    PIX_FMT_MONOWHITE, ///< 0 is white 
148
    PIX_FMT_MONOBLACK, ///< 0 is black 
149
    PIX_FMT_PAL8,      ///< 8 bit with RGBA palette 
150 cd394651 Michael Niedermayer
    PIX_FMT_YUVJ420P,  ///< Planar YUV 4:2:0 full scale (jpeg)
151
    PIX_FMT_YUVJ422P,  ///< Planar YUV 4:2:2 full scale (jpeg)
152
    PIX_FMT_YUVJ444P,  ///< Planar YUV 4:4:4 full scale (jpeg)
153 fb364ada Ivan Kalvachev
    PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
154
    PIX_FMT_XVMC_MPEG2_IDCT,
155 dab64ebc Fabrice Bellard
    PIX_FMT_NB,
156 de6d9b64 Fabrice Bellard
};
157
158 a96b68b7 Fabrice Bellard
/* currently unused, may be used if 24/32 bits samples ever supported */
159
enum SampleFormat {
160 64863965 Michael Niedermayer
    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
161 a96b68b7 Fabrice Bellard
};
162
163 de6d9b64 Fabrice Bellard
/* in bytes */
164 bc8d1857 Fabrice Bellard
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
165 de6d9b64 Fabrice Bellard
166 d7425f59 Michael Niedermayer
/**
167 cf713bb8 Michael Niedermayer
 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
168
 * this is mainly needed because some optimized bitstream readers read 
169
 * 32 or 64 bit at once and could read over the end<br>
170
 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
171
 * MPEG bitstreams could cause overread and segfault
172 d7425f59 Michael Niedermayer
 */
173
#define FF_INPUT_BUFFER_PADDING_SIZE 8
174
175 e4986da9 Juanjo
/* motion estimation type, EPZS by default */
176
enum Motion_Est_ID {
177 101bea5f Juanjo
    ME_ZERO = 1,
178 e4986da9 Juanjo
    ME_FULL,
179
    ME_LOG,
180
    ME_PHODS,
181
    ME_EPZS,
182
    ME_X1
183
};
184
185 ce980a95 Michael Niedermayer
typedef struct RcOverride{
186
    int start_frame;
187
    int end_frame;
188
    int qscale; // if this is 0 then quality_factor will be used instead
189
    float quality_factor;
190
} RcOverride;
191
192 101bea5f Juanjo
/* only for ME compatiblity with old apps */
193
extern int motion_estimation_method;
194
195 e4986da9 Juanjo
/* ME algos sorted by quality */
196 bc6caae2 Juanjo
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
197
                                       ME_X1, ME_EPZS, ME_FULL };
198 de6d9b64 Fabrice Bellard
199 28db7fce Michael Niedermayer
200 4e00e76b Michael Niedermayer
#define FF_MAX_B_FRAMES 8
201 9dbcbd92 Michael Niedermayer
202 a949d72e Michael Niedermayer
/* encoding support
203
   these flags can be passed in AVCodecContext.flags before initing 
204
   Note: note not everything is supported yet 
205
*/
206 de6d9b64 Fabrice Bellard
207 64863965 Michael Niedermayer
#define CODEC_FLAG_QSCALE 0x0002  ///< use fixed qscale 
208
#define CODEC_FLAG_4MV    0x0004  ///< 4 MV per MB allowed 
209
#define CODEC_FLAG_QPEL   0x0010  ///< use qpel MC 
210
#define CODEC_FLAG_GMC    0x0020  ///< use GMC 
211
#define CODEC_FLAG_PART   0x0080  ///< use data partitioning 
212 9dbcbd92 Michael Niedermayer
/* parent program gurantees that the input for b-frame containing streams is not written to 
213
   for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
214 8b4c7dbc Michael Niedermayer
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
215 64863965 Michael Niedermayer
#define CODEC_FLAG_PASS1 0x0200   ///< use internal 2pass ratecontrol in first  pass mode 
216
#define CODEC_FLAG_PASS2 0x0400   ///< use internal 2pass ratecontrol in second pass mode 
217
#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg) 
218
#define CODEC_FLAG_GRAY  0x2000   ///< only decode/encode grayscale 
219
#define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges 
220
#define CODEC_FLAG_PSNR           0x8000 ///< error[?] variables will be set during encoding 
221
#define CODEC_FLAG_TRUNCATED  0x00010000 /** input bitstream might be truncated at a random location instead 
222 d7425f59 Michael Niedermayer
                                            of only at frame boundaries */
223 64863965 Michael Niedermayer
#define CODEC_FLAG_NORMALIZE_AQP  0x00020000 ///< normalize adaptive quantization 
224
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct 
225 3bb07d61 Michael Niedermayer
#define CODEC_FLAG_LOW_DELAY      0x00080000 ///< force low delay
226 64863965 Michael Niedermayer
#define CODEC_FLAG_ALT_SCAN       0x00100000 ///< use alternate scan 
227
#define CODEC_FLAG_TRELLIS_QUANT  0x00200000 ///< use trellis quantization 
228
#define CODEC_FLAG_GLOBAL_HEADER  0x00400000 ///< place global headers in extradata instead of every keyframe 
229
#define CODEC_FLAG_BITEXACT       0x00800000 ///< use only bitexact stuff (except (i)dct) 
230 21e59552 Michael Niedermayer
/* Fx : Flag for h263+ extra options */
231 64863965 Michael Niedermayer
#define CODEC_FLAG_H263P_AIC      0x01000000 ///< Advanced intra coding 
232
#define CODEC_FLAG_H263P_UMV      0x02000000 ///< Unlimited motion vector  
233 21e59552 Michael Niedermayer
/* For advanced prediction mode, we reuse the 4MV flag */
234
/* Unsupported options :
235
 *                 Syntax Arithmetic coding (SAC)
236
 *                 Deblocking filter internal loop
237
 *                 Slice structured
238
 *                 Reference Picture Selection
239
 *                 Independant Segment Decoding
240
 *                 Alternative Inter *                 VLC
241
 *                 Modified Quantization */
242
/* /Fx */
243 bf89e6b1 Fabrice Bellard
/* codec capabilities */
244
245 64863965 Michael Niedermayer
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback 
246 6814a25c Michael Niedermayer
/**
247
 * Codec uses get_buffer() for allocating buffers.
248
 * direct rendering method 1
249
 */
250
#define CODEC_CAP_DR1             0x0002
251 917e06c8 Fabrice Bellard
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
252
   used */
253
#define CODEC_CAP_PARSE_ONLY      0x0004
254 d7425f59 Michael Niedermayer
#define CODEC_CAP_TRUNCATED       0x0008
255 bf89e6b1 Fabrice Bellard
256 492cd3a9 Michael Niedermayer
#define FF_COMMON_FRAME \
257 b536d0aa Michael Niedermayer
    /**\
258
     * pointer to the picture planes.\
259
     * this might be different from the first allocated byte\
260
     * - encoding: \
261
     * - decoding: \
262
     */\
263 1e491e29 Michael Niedermayer
    uint8_t *data[4];\
264
    int linesize[4];\
265
    /**\
266 32db2b1d Michael Niedermayer
     * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
267 1e491e29 Michael Niedermayer
     * this isnt used by lavc unless the default get/release_buffer() is used\
268 64863965 Michael Niedermayer
     * - encoding: \
269
     * - decoding: \
270 1e491e29 Michael Niedermayer
     */\
271
    uint8_t *base[4];\
272
    /**\
273
     * 1 -> keyframe, 0-> not\
274 64863965 Michael Niedermayer
     * - encoding: set by lavc\
275
     * - decoding: set by lavc\
276 1e491e29 Michael Niedermayer
     */\
277
    int key_frame;\
278
\
279
    /**\
280 0da71265 Michael Niedermayer
     * picture type of the frame, see ?_TYPE below.\
281 64863965 Michael Niedermayer
     * - encoding: set by lavc for coded_picture (and set by user for input)\
282
     * - decoding: set by lavc\
283 1e491e29 Michael Niedermayer
     */\
284
    int pict_type;\
285
\
286
    /**\
287
     * presentation timestamp in micro seconds (time when frame should be shown to user)\
288
     * if 0 then the frame_rate will be used as reference\
289 64863965 Michael Niedermayer
     * - encoding: MUST be set by user\
290
     * - decoding: set by lavc\
291 1e491e29 Michael Niedermayer
     */\
292 be6784dc Richard Hodges
    int64_t pts;\
293 1e491e29 Michael Niedermayer
\
294
    /**\
295
     * picture number in bitstream order.\
296 64863965 Michael Niedermayer
     * - encoding: set by\
297
     * - decoding: set by lavc\
298 1e491e29 Michael Niedermayer
     */\
299
    int coded_picture_number;\
300
    /**\
301
     * picture number in display order.\
302 64863965 Michael Niedermayer
     * - encoding: set by\
303
     * - decoding: set by lavc\
304 1e491e29 Michael Niedermayer
     */\
305
    int display_picture_number;\
306
\
307
    /**\
308
     * quality (between 1 (good) and 31 (bad)) \
309 64863965 Michael Niedermayer
     * - encoding: set by lavc for coded_picture (and set by user for input)\
310
     * - decoding: set by lavc\
311 1e491e29 Michael Niedermayer
     */\
312
    float quality; \
313
\
314
    /**\
315
     * buffer age (1->was last buffer and dint change, 2->..., ...).\
316
     * set to something large if the buffer has not been used yet \
317 64863965 Michael Niedermayer
     * - encoding: unused\
318
     * - decoding: MUST be set by get_buffer()\
319 1e491e29 Michael Niedermayer
     */\
320
    int age;\
321
\
322
    /**\
323
     * is this picture used as reference\
324 64863965 Michael Niedermayer
     * - encoding: unused\
325
     * - decoding: set by lavc (before get_buffer() call))\
326 1e491e29 Michael Niedermayer
     */\
327
    int reference;\
328
\
329
    /**\
330
     * QP table\
331 64863965 Michael Niedermayer
     * - encoding: unused\
332
     * - decoding: set by lavc\
333 1e491e29 Michael Niedermayer
     */\
334
    int8_t *qscale_table;\
335
    /**\
336
     * QP store stride\
337 64863965 Michael Niedermayer
     * - encoding: unused\
338
     * - decoding: set by lavc\
339 1e491e29 Michael Niedermayer
     */\
340
    int qstride;\
341
\
342
    /**\
343
     * mbskip_table[mb]>=1 if MB didnt change\
344
     * stride= mb_width = (width+15)>>4\
345 64863965 Michael Niedermayer
     * - encoding: unused\
346
     * - decoding: set by lavc\
347 1e491e29 Michael Niedermayer
     */\
348
    uint8_t *mbskip_table;\
349
\
350
    /**\
351
     * for some private data of the user\
352 64863965 Michael Niedermayer
     * - encoding: unused\
353
     * - decoding: set by user\
354 1e491e29 Michael Niedermayer
     */\
355
    void *opaque;\
356 140cb663 Michael Niedermayer
\
357
    /**\
358
     * error\
359 64863965 Michael Niedermayer
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
360
     * - decoding: unused\
361 140cb663 Michael Niedermayer
     */\
362
    uint64_t error[4];\
363 4e00e76b Michael Niedermayer
\
364
    /**\
365
     * type of the buffer (to keep track of who has to dealloc data[*])\
366 64863965 Michael Niedermayer
     * - encoding: set by the one who allocs it\
367
     * - decoding: set by the one who allocs it\
368 3db320ea Falk Hüffner
     * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
369 4e00e76b Michael Niedermayer
     */\
370
    int type;\
371 2ec23b6d Michael Niedermayer
    \
372
    /**\
373
     * when decoding, this signal how much the picture must be delayed.\
374
     * extra_delay = repeat_pict / (2*fps)\
375 64863965 Michael Niedermayer
     * - encoding: unused\
376
     * - decoding: set by lavc\
377 2ec23b6d Michael Niedermayer
     */\
378 0426af31 Michael Niedermayer
    int repeat_pict;\
379
    \
380
    /**\
381
     * \
382
     */\
383
    int qscale_type;\
384 2ec23b6d Michael Niedermayer
385 0426af31 Michael Niedermayer
#define FF_QSCALE_TYPE_MPEG1        0
386
#define FF_QSCALE_TYPE_MPEG2        1
387 4e00e76b Michael Niedermayer
388
#define FF_BUFFER_TYPE_INTERNAL 1
389 9b56edf5 Michael Niedermayer
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers (image is (de)allocated by user)
390
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc image (data/base)
391
#define FF_BUFFER_TYPE_COPY     8 ///< just a (modified) copy of some other buffer, dont dealloc anything
392 4e00e76b Michael Niedermayer
393 1e491e29 Michael Niedermayer
394 140cb663 Michael Niedermayer
#define FF_I_TYPE 1 // Intra
395
#define FF_P_TYPE 2 // Predicted
396
#define FF_B_TYPE 3 // Bi-dir predicted
397
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
398 0da71265 Michael Niedermayer
#define FF_SI_TYPE 5
399
#define FF_SP_TYPE 6
400 1e491e29 Michael Niedermayer
401 0da71265 Michael Niedermayer
/**
402
 * Audio Video Frame.
403
 */
404 492cd3a9 Michael Niedermayer
typedef struct AVFrame {
405
    FF_COMMON_FRAME
406
} AVFrame;
407 1e491e29 Michael Niedermayer
408 14bea432 Michael Niedermayer
#define DEFAULT_FRAME_RATE_BASE 1001000
409 d33c949c Michael Niedermayer
410
/**
411
 * main external api structure.
412
 */
413 de6d9b64 Fabrice Bellard
typedef struct AVCodecContext {
414 b71901e6 Michael Niedermayer
    /**
415 64863965 Michael Niedermayer
     * the average bitrate.
416
     * - encoding: set by user. unused for constant quantizer encoding
417
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
418 b71901e6 Michael Niedermayer
     */
419 de6d9b64 Fabrice Bellard
    int bit_rate;
420 b71901e6 Michael Niedermayer
421
    /**
422 64863965 Michael Niedermayer
     * number of bits the bitstream is allowed to diverge from the reference.
423 b71901e6 Michael Niedermayer
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
424 64863965 Michael Niedermayer
     * - encoding: set by user. unused for constant quantizer encoding
425
     * - decoding: unused
426 b71901e6 Michael Niedermayer
     */
427
    int bit_rate_tolerance; 
428
429
    /**
430 64863965 Michael Niedermayer
     * CODEC_FLAG_*.
431
     * - encoding: set by user.
432
     * - decoding: set by user.
433 b71901e6 Michael Niedermayer
     */
434 de6d9b64 Fabrice Bellard
    int flags;
435 b71901e6 Michael Niedermayer
436
    /**
437
     * some codecs needs additionnal format info. It is stored here
438 64863965 Michael Niedermayer
     * - encoding: set by user. 
439
     * - decoding: set by lavc. (FIXME is this ok?)
440 b71901e6 Michael Niedermayer
     */
441
    int sub_id;
442
443
    /**
444 64863965 Michael Niedermayer
     * motion estimation algorithm used for video coding.
445
     * - encoding: MUST be set by user.
446
     * - decoding: unused
447 b71901e6 Michael Niedermayer
     */
448
    int me_method;
449
450
    /**
451 64863965 Michael Niedermayer
     * some codecs need / can use extra-data like huffman tables.
452 b71901e6 Michael Niedermayer
     * mjpeg: huffman tables
453
     * rv10: additional flags
454 b704e742 Michael Niedermayer
     * mpeg4: global headers (they can be in the bitstream or here)
455 64863965 Michael Niedermayer
     * - encoding: set/allocated/freed by lavc.
456
     * - decoding: set/allocated/freed by user.
457 b71901e6 Michael Niedermayer
     */
458 e84c31dc Arpi
    void *extradata;
459
    int extradata_size;
460
    
461 de6d9b64 Fabrice Bellard
    /* video only */
462 b71901e6 Michael Niedermayer
    /**
463 14bea432 Michael Niedermayer
     * frames per sec multiplied by frame_rate_base.
464 b71901e6 Michael Niedermayer
     * for variable fps this is the precission, so if the timestamps 
465 14bea432 Michael Niedermayer
     * can be specified in msec precssion then this is 1000*frame_rate_base
466 64863965 Michael Niedermayer
     * - encoding: MUST be set by user
467
     * - decoding: set by lavc. 0 or the frame_rate if available
468 b71901e6 Michael Niedermayer
     */
469
    int frame_rate;
470 14bea432 Michael Niedermayer
    
471
    /**
472 64863965 Michael Niedermayer
     * width / height.
473
     * - encoding: MUST be set by user. 
474
     * - decoding: set by user, some codecs might override / change it during playback
475 b71901e6 Michael Niedermayer
     */
476 de6d9b64 Fabrice Bellard
    int width, height;
477 b71901e6 Michael Niedermayer
    
478 2efe097a Michael Niedermayer
#define FF_ASPECT_SQUARE 1
479
#define FF_ASPECT_4_3_625 2
480
#define FF_ASPECT_4_3_525 3
481
#define FF_ASPECT_16_9_625 4
482
#define FF_ASPECT_16_9_525 5
483 e769f053 Alex Beregszaszi
#define FF_ASPECT_EXTENDED 15
484 b71901e6 Michael Niedermayer
485
    /**
486 64863965 Michael Niedermayer
     * the number of pictures in a group of pitures, or 0 for intra_only.
487
     * - encoding: set by user.
488
     * - decoding: unused
489 b71901e6 Michael Niedermayer
     */
490
    int gop_size;
491
492
    /**
493 64863965 Michael Niedermayer
     * pixel format, see PIX_FMT_xxx.
494 36b58e85 Roman Shaposhnik
     * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
495
     *                    conversion is in order. This only works for
496
     *                    codecs with one supported pix_fmt, we should
497
     *                    do something for a generic case as well.
498 64863965 Michael Niedermayer
     * - decoding: set by lavc.
499 b71901e6 Michael Niedermayer
     */
500 e4eadb4b Michael Niedermayer
    enum PixelFormat pix_fmt;
501 bdfcbbed Max Krasnyansky
 
502
    /**
503
     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
504
     * has to read frames at native frame rate.
505
     * - encoding: set by user.
506
     * - decoding: unused.
507
     */
508
    int rate_emu;
509
       
510 b71901e6 Michael Niedermayer
    /**
511
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
512
     * decoder to draw an horizontal band. It improve cache usage. Not
513
     * all codecs can do that. You must check the codec capabilities
514
     * before
515 64863965 Michael Niedermayer
     * - encoding: unused
516
     * - decoding: set by user.
517 3bb07d61 Michael Niedermayer
     * @param height the height of the slice
518
     * @param y the y position of the slice
519
     * @param type 1->top field, 2->bottom field, 3->frame
520
     * @param offset offset into the AVFrame.data from which the slice should be read
521 b71901e6 Michael Niedermayer
     */
522 bf89e6b1 Fabrice Bellard
    void (*draw_horiz_band)(struct AVCodecContext *s,
523 da64ecc3 Drew Hess
                            const AVFrame *src, int offset[4],
524 3bb07d61 Michael Niedermayer
                            int y, int type, int height);
525 bf89e6b1 Fabrice Bellard
526 de6d9b64 Fabrice Bellard
    /* audio only */
527 64863965 Michael Niedermayer
    int sample_rate; ///< samples per sec 
528 de6d9b64 Fabrice Bellard
    int channels;
529 64863965 Michael Niedermayer
    int sample_fmt;  ///< sample format, currenly unused 
530 de6d9b64 Fabrice Bellard
531
    /* the following data should not be initialized */
532 64863965 Michael Niedermayer
    int frame_size;     ///< in samples, initialized when calling 'init' 
533
    int frame_number;   ///< audio or video frame number 
534
    int real_pict_num;  ///< returns the real picture number of previous encoded frame 
535 1e491e29 Michael Niedermayer
    
536 b71901e6 Michael Niedermayer
    /**
537
     * number of frames the decoded output will be delayed relative to 
538 64863965 Michael Niedermayer
     * the encoded input.
539
     * - encoding: set by lavc.
540
     * - decoding: unused
541 b71901e6 Michael Niedermayer
     */
542
    int delay;
543 1ff662cc Michael Niedermayer
    
544 64863965 Michael Niedermayer
    /* - encoding parameters */
545
    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
546
    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
547 b71901e6 Michael Niedermayer
    
548
    /**
549 64863965 Michael Niedermayer
     * minimum quantizer.
550
     * - encoding: set by user.
551
     * - decoding: unused
552 b71901e6 Michael Niedermayer
     */
553
    int qmin;
554
555
    /**
556 64863965 Michael Niedermayer
     * maximum quantizer.
557
     * - encoding: set by user.
558
     * - decoding: unused
559 b71901e6 Michael Niedermayer
     */
560
    int qmax;
561
562
    /**
563 64863965 Michael Niedermayer
     * maximum quantizer difference etween frames.
564
     * - encoding: set by user.
565
     * - decoding: unused
566 b71901e6 Michael Niedermayer
     */
567
    int max_qdiff;
568
569
    /**
570 64863965 Michael Niedermayer
     * maximum number of b frames between non b frames.
571 b71901e6 Michael Niedermayer
     * note: the output will be delayed by max_b_frames+1 relative to the input
572 64863965 Michael Niedermayer
     * - encoding: set by user.
573
     * - decoding: unused
574 b71901e6 Michael Niedermayer
     */
575
    int max_b_frames;
576
577
    /**
578 64863965 Michael Niedermayer
     * qscale factor between ip and b frames.
579
     * - encoding: set by user.
580
     * - decoding: unused
581 b71901e6 Michael Niedermayer
     */
582
    float b_quant_factor;
583
    
584
    /** obsolete FIXME remove */
585
    int rc_strategy;
586 8b4c7dbc Michael Niedermayer
    int b_frame_strategy;
587 9dbcbd92 Michael Niedermayer
588 b71901e6 Michael Niedermayer
    /**
589 64863965 Michael Niedermayer
     * hurry up amount.
590
     * - encoding: unused
591
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
592 b71901e6 Michael Niedermayer
     */
593
    int hurry_up;
594 2417652e Michael Niedermayer
    
595 de6d9b64 Fabrice Bellard
    struct AVCodec *codec;
596 b71901e6 Michael Niedermayer
    
597 de6d9b64 Fabrice Bellard
    void *priv_data;
598
599 644d98a4 Juanjo
    /* The following data is for RTP friendly coding */
600 1f6b6e50 Michael Niedermayer
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
601 644d98a4 Juanjo
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
602
                    /* highers numbers represent more error-prone */
603
                    /* enviroments, by now just "1" exist         */
604
    
605
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
606
                            /* do it's best to deliver a chunk with size    */
607
                            /* below rtp_payload_size, the chunk will start */
608
                            /* with a start code on some codecs like H.263  */
609
                            /* This doesn't take account of any particular  */
610
                            /* headers inside the transmited RTP payload    */
611 81401c1f Juanjo
612
    
613
    /* The RTP callcack: This function is called  */
614
    /* every time the encoder as a packet to send */
615
    /* Depends on the encoder if the data starts  */
616
    /* with a Start Code (it should) H.263 does   */
617
    void (*rtp_callback)(void *data, int size, int packet_number); 
618
619 098eefe1 Michael Niedermayer
    /* statistics, used for 2-pass encoding */
620
    int mv_bits;
621
    int header_bits;
622
    int i_tex_bits;
623
    int p_tex_bits;
624
    int i_count;
625
    int p_count;
626
    int skip_count;
627 b71901e6 Michael Niedermayer
    int misc_bits;
628
    
629
    /**
630 64863965 Michael Niedermayer
     * number of bits used for the previously encoded frame.
631
     * - encoding: set by lavc
632 7004ffb3 Michael Niedermayer
     * - decoding: unused
633 b71901e6 Michael Niedermayer
     */
634 098eefe1 Michael Niedermayer
    int frame_bits;
635 7004ffb3 Michael Niedermayer
636 b71901e6 Michael Niedermayer
    /**
637 64863965 Michael Niedermayer
     * private data of the user, can be used to carry app specific stuff.
638
     * - encoding: set by user
639
     * - decoding: set by user
640 b71901e6 Michael Niedermayer
     */
641
    void *opaque;
642
643 de6d9b64 Fabrice Bellard
    char codec_name[32];
644 4a663d80 Philip Gladstone
    enum CodecType codec_type; /* see CODEC_TYPE_xxx */
645
    enum CodecID codec_id; /* see CODEC_ID_xxx */
646 7004ffb3 Michael Niedermayer
    
647
    /**
648
     * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
649
     * this is used to workaround some encoder bugs
650 bd5a6020 Michael Niedermayer
     * - encoding: set by user, if not then the default based on codec_id will be used
651 7004ffb3 Michael Niedermayer
     * - decoding: set by user, will be converted to upper case by lavc during init
652
     */
653
    unsigned int codec_tag;
654 92ba5ffb Michael Niedermayer
    
655 b71901e6 Michael Niedermayer
    /**
656 64863965 Michael Niedermayer
     * workaround bugs in encoders which sometimes cannot be detected automatically.
657
     * - encoding: unused
658
     * - decoding: set by user
659 b71901e6 Michael Niedermayer
     */
660
    int workaround_bugs;
661 64863965 Michael Niedermayer
#define FF_BUG_AUTODETECT       1  ///< autodetection
662 4d2858de Michael Niedermayer
#define FF_BUG_OLD_MSMPEG4      2
663
#define FF_BUG_XVID_ILACE       4
664
#define FF_BUG_UMP4             8
665
#define FF_BUG_NO_PADDING       16
666
#define FF_BUG_AC_VLC           32
667 03e93d35 Michael Niedermayer
#define FF_BUG_QPEL_CHROMA      64
668 db794953 Michael Niedermayer
#define FF_BUG_STD_QPEL         128
669 36df8805 Michael Niedermayer
#define FF_BUG_QPEL_CHROMA2     256
670 c40c3482 Michael Niedermayer
#define FF_BUG_DIRECT_BLOCKSIZE 512
671 1c6dcb0f Michael Niedermayer
#define FF_BUG_EDGE             1024
672 4d2858de Michael Niedermayer
//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
673
        
674 b71901e6 Michael Niedermayer
    /**
675 64863965 Michael Niedermayer
     * luma single coeff elimination threshold.
676
     * - encoding: set by user
677
     * - decoding: unused
678 b71901e6 Michael Niedermayer
     */
679 1f6b6e50 Michael Niedermayer
    int luma_elim_threshold;
680 b71901e6 Michael Niedermayer
    
681
    /**
682 64863965 Michael Niedermayer
     * chroma single coeff elimination threshold.
683
     * - encoding: set by user
684
     * - decoding: unused
685 b71901e6 Michael Niedermayer
     */
686 1f6b6e50 Michael Niedermayer
    int chroma_elim_threshold;
687 b71901e6 Michael Niedermayer
    
688
    /**
689 64863965 Michael Niedermayer
     * strictly follow the std (MPEG4, ...).
690
     * - encoding: set by user
691
     * - decoding: unused
692 b71901e6 Michael Niedermayer
     */
693
    int strict_std_compliance;
694
    
695
    /**
696 64863965 Michael Niedermayer
     * qscale offset between ip and b frames.
697 b3a391e8 Michael Niedermayer
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
698
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
699 64863965 Michael Niedermayer
     * - encoding: set by user.
700
     * - decoding: unused
701 b71901e6 Michael Niedermayer
     */
702
    float b_quant_offset;
703
    
704
    /**
705 ce3bcaed Michael Niedermayer
     * error resilience higher values will detect more errors but may missdetect
706 64863965 Michael Niedermayer
     * some more or less valid parts as errors.
707
     * - encoding: unused
708
     * - decoding: set by user
709 b71901e6 Michael Niedermayer
     */
710 1f6b6e50 Michael Niedermayer
    int error_resilience;
711 ce3bcaed Michael Niedermayer
#define FF_ER_CAREFULL        1
712
#define FF_ER_COMPLIANT       2
713
#define FF_ER_AGGRESSIVE      3
714
#define FF_ER_VERY_AGGRESSIVE 4
715 ae72cda6 Nick Kurshev
    
716 6b72ac63 Michael Niedermayer
    /**
717 1e491e29 Michael Niedermayer
     * called at the beginning of each frame to get a buffer for it.
718
     * if pic.reference is set then the frame will be read later by lavc
719 3bb07d61 Michael Niedermayer
     * width and height should be rounded up to the next multiple of 16
720 64863965 Michael Niedermayer
     * - encoding: unused
721
     * - decoding: set by lavc, user can override
722 b71901e6 Michael Niedermayer
     */
723 492cd3a9 Michael Niedermayer
    int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
724 b71901e6 Michael Niedermayer
    
725
    /**
726 1e491e29 Michael Niedermayer
     * called to release buffers which where allocated with get_buffer.
727
     * a released buffer can be reused in get_buffer()
728
     * pic.data[*] must be set to NULL
729 64863965 Michael Niedermayer
     * - encoding: unused
730
     * - decoding: set by lavc, user can override
731 b71901e6 Michael Niedermayer
     */
732 492cd3a9 Michael Niedermayer
    void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
733 0fd90455 Michael Niedermayer
734 b71901e6 Michael Niedermayer
    /**
735 64863965 Michael Niedermayer
     * is 1 if the decoded stream contains b frames, 0 otherwise.
736
     * - encoding: unused
737
     * - decoding: set by lavc
738 b71901e6 Michael Niedermayer
     */
739
    int has_b_frames;
740
    
741 64863965 Michael Niedermayer
    int block_align; ///< used by some WAV based audio codecs
742 ce980a95 Michael Niedermayer
    
743 64863965 Michael Niedermayer
    int parse_only; /* - decoding only: if true, only parsing is done
744 917e06c8 Fabrice Bellard
                       (function avcodec_parse_frame()). The frame
745
                       data is returned. Only MPEG codecs support this now. */
746 ce980a95 Michael Niedermayer
    
747 b71901e6 Michael Niedermayer
    /**
748 e4eadb4b Michael Niedermayer
     * 0-> h263 quant 1-> mpeg quant.
749 64863965 Michael Niedermayer
     * - encoding: set by user.
750
     * - decoding: unused
751 b71901e6 Michael Niedermayer
     */
752
    int mpeg_quant;
753 ce980a95 Michael Niedermayer
    
754 b71901e6 Michael Niedermayer
    /**
755 64863965 Michael Niedermayer
     * pass1 encoding statistics output buffer.
756
     * - encoding: set by lavc
757
     * - decoding: unused
758 b71901e6 Michael Niedermayer
     */
759 64863965 Michael Niedermayer
    char *stats_out;
760 b71901e6 Michael Niedermayer
    
761
    /**
762
     * pass2 encoding statistics input buffer.
763
     * concatenated stuff from stats_out of pass1 should be placed here
764 64863965 Michael Niedermayer
     * - encoding: allocated/set/freed by user
765
     * - decoding: unused
766 b71901e6 Michael Niedermayer
     */
767
    char *stats_in;
768
    
769
    /**
770 64863965 Michael Niedermayer
     * ratecontrol qmin qmax limiting method.
771 b71901e6 Michael Niedermayer
     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
772 64863965 Michael Niedermayer
     * - encoding: set by user.
773
     * - decoding: unused
774 b71901e6 Michael Niedermayer
     */
775 ce980a95 Michael Niedermayer
    float rc_qsquish;
776 b71901e6 Michael Niedermayer
777 ce980a95 Michael Niedermayer
    float rc_qmod_amp;
778
    int rc_qmod_freq;
779 b71901e6 Michael Niedermayer
    
780
    /**
781 64863965 Michael Niedermayer
     * ratecontrol override, see RcOverride.
782
     * - encoding: allocated/set/freed by user.
783
     * - decoding: unused
784 b71901e6 Michael Niedermayer
     */
785 ce980a95 Michael Niedermayer
    RcOverride *rc_override;
786
    int rc_override_count;
787 b71901e6 Michael Niedermayer
    
788
    /**
789 64863965 Michael Niedermayer
     * rate control equation.
790
     * - encoding: set by user
791
     * - decoding: unused
792 b71901e6 Michael Niedermayer
     */
793 ce980a95 Michael Niedermayer
    char *rc_eq;
794 b71901e6 Michael Niedermayer
    
795
    /**
796 64863965 Michael Niedermayer
     * maximum bitrate.
797
     * - encoding: set by user.
798
     * - decoding: unused
799 b71901e6 Michael Niedermayer
     */
800 ce980a95 Michael Niedermayer
    int rc_max_rate;
801 b71901e6 Michael Niedermayer
    
802
    /**
803 64863965 Michael Niedermayer
     * minimum bitrate.
804
     * - encoding: set by user.
805
     * - decoding: unused
806 b71901e6 Michael Niedermayer
     */
807 ce980a95 Michael Niedermayer
    int rc_min_rate;
808 b71901e6 Michael Niedermayer
    
809
    /**
810 64863965 Michael Niedermayer
     * decoder bitstream buffer size.
811
     * - encoding: set by user.
812
     * - decoding: unused
813 b71901e6 Michael Niedermayer
     */
814 ce980a95 Michael Niedermayer
    int rc_buffer_size;
815
    float rc_buffer_aggressivity;
816 b71901e6 Michael Niedermayer
817
    /**
818 64863965 Michael Niedermayer
     * qscale factor between p and i frames.
819
     * - encoding: set by user.
820
     * - decoding: unused
821 b71901e6 Michael Niedermayer
     */
822
    float i_quant_factor;
823
    
824
    /**
825 64863965 Michael Niedermayer
     * qscale offset between p and i frames.
826 b3a391e8 Michael Niedermayer
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
827
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
828 64863965 Michael Niedermayer
     * - encoding: set by user.
829
     * - decoding: unused
830 b71901e6 Michael Niedermayer
     */
831
    float i_quant_offset;
832
    
833
    /**
834 64863965 Michael Niedermayer
     * initial complexity for pass1 ratecontrol.
835
     * - encoding: set by user.
836
     * - decoding: unused
837 b71901e6 Michael Niedermayer
     */
838 ce980a95 Michael Niedermayer
    float rc_initial_cplx;
839 917e06c8 Fabrice Bellard
840 b71901e6 Michael Niedermayer
    /**
841 64863965 Michael Niedermayer
     * dct algorithm, see FF_DCT_* below.
842
     * - encoding: set by user
843
     * - decoding: unused
844 b71901e6 Michael Niedermayer
     */
845 28db7fce Michael Niedermayer
    int dct_algo;
846 c7e07931 Martin Olschewski
#define FF_DCT_AUTO    0
847 28db7fce Michael Niedermayer
#define FF_DCT_FASTINT 1
848 c7e07931 Martin Olschewski
#define FF_DCT_INT     2
849
#define FF_DCT_MMX     3
850
#define FF_DCT_MLIB    4
851 05c4072b Michael Niedermayer
#define FF_DCT_ALTIVEC 5
852 c5d309f2 Michael Niedermayer
    
853
    /**
854 64863965 Michael Niedermayer
     * luminance masking (0-> disabled).
855
     * - encoding: set by user
856
     * - decoding: unused
857 c5d309f2 Michael Niedermayer
     */
858
    float lumi_masking;
859
    
860
    /**
861 64863965 Michael Niedermayer
     * temporary complexity masking (0-> disabled).
862
     * - encoding: set by user
863
     * - decoding: unused
864 c5d309f2 Michael Niedermayer
     */
865
    float temporal_cplx_masking;
866
    
867
    /**
868 64863965 Michael Niedermayer
     * spatial complexity masking (0-> disabled).
869
     * - encoding: set by user
870
     * - decoding: unused
871 c5d309f2 Michael Niedermayer
     */
872
    float spatial_cplx_masking;
873
    
874
    /**
875 64863965 Michael Niedermayer
     * p block masking (0-> disabled).
876
     * - encoding: set by user
877
     * - decoding: unused
878 c5d309f2 Michael Niedermayer
     */
879
    float p_masking;
880 15415af4 Michael Niedermayer
881 5e746b99 Michael Niedermayer
    /**
882 64863965 Michael Niedermayer
     * darkness masking (0-> disabled).
883
     * - encoding: set by user
884
     * - decoding: unused
885 5e746b99 Michael Niedermayer
     */
886
    float dark_masking;
887 0c2dd16e Michael Niedermayer
    
888 3a694b04 Nick Kurshev
    
889
    /* for binary compatibility */
890
    int unused;
891
    
892 0c2dd16e Michael Niedermayer
    /**
893 64863965 Michael Niedermayer
     * idct algorithm, see FF_IDCT_* below.
894
     * - encoding: set by user
895
     * - decoding: set by user
896 2ad1516a Michael Niedermayer
     */
897
    int idct_algo;
898
#define FF_IDCT_AUTO         0
899
#define FF_IDCT_INT          1
900
#define FF_IDCT_SIMPLE       2
901
#define FF_IDCT_SIMPLEMMX    3
902
#define FF_IDCT_LIBMPEG2MMX  4
903
#define FF_IDCT_PS2          5
904
#define FF_IDCT_MLIB         6
905
#define FF_IDCT_ARM          7
906 05c4072b Michael Niedermayer
#define FF_IDCT_ALTIVEC      8
907 b82cdc72 Michael Niedermayer
#define FF_IDCT_SH4          9
908 bd7d1ea7 Alex Beregszaszi
#define FF_IDCT_SIMPLEARM    10
909 2ad1516a Michael Niedermayer
910 144f0625 Michael Niedermayer
    /**
911 64863965 Michael Niedermayer
     * slice count.
912
     * - encoding: set by lavc
913
     * - decoding: set by user (or 0)
914 144f0625 Michael Niedermayer
     */
915
    int slice_count;
916
    /**
917 64863965 Michael Niedermayer
     * slice offsets in the frame in bytes.
918
     * - encoding: set/allocated by lavc
919
     * - decoding: set/allocated by user (or NULL)
920 144f0625 Michael Niedermayer
     */
921
    int *slice_offset;
922
923 4d2858de Michael Niedermayer
    /**
924 64863965 Michael Niedermayer
     * error concealment flags.
925
     * - encoding: unused
926
     * - decoding: set by user
927 4d2858de Michael Niedermayer
     */
928
    int error_concealment;
929
#define FF_EC_GUESS_MVS   1
930
#define FF_EC_DEBLOCK     2
931
932 6b72ac63 Michael Niedermayer
    /**
933 bec89a84 Zdenek Kabelac
     * dsp_mask could be add used to disable unwanted CPU features
934 8350df97 Zdenek Kabelac
     * CPU features (i.e. MMX, SSE. ...)
935 bec89a84 Zdenek Kabelac
     *
936
     * with FORCE flag you may instead enable given CPU features
937
     * (Dangerous: usable in case of misdetection, improper usage however will
938
     * result into program crash)
939
     */
940
    unsigned dsp_mask;
941
#define FF_MM_FORCE        0x80000000 /* force usage of selected flags (OR) */
942
    /* lower 16 bits - CPU features */
943
#ifdef HAVE_MMX
944
#define FF_MM_MMX        0x0001 /* standard MMX */
945
#define FF_MM_3DNOW        0x0004 /* AMD 3DNOW */
946
#define FF_MM_MMXEXT        0x0002 /* SSE integer functions or AMD MMX ext */
947
#define FF_MM_SSE        0x0008 /* SSE functions */
948
#define FF_MM_SSE2        0x0010 /* PIV SSE2 functions */
949
#endif /* HAVE_MMX */
950 11f18faf Michael Niedermayer
951
    /**
952 64863965 Michael Niedermayer
     * bits per sample/pixel from the demuxer (needed for huffyuv).
953
     * - encoding: set by lavc
954
     * - decoding: set by user
955 11f18faf Michael Niedermayer
     */
956
     int bits_per_sample;
957
    
958
    /**
959 64863965 Michael Niedermayer
     * prediction method (needed for huffyuv).
960
     * - encoding: set by user
961
     * - decoding: unused
962 11f18faf Michael Niedermayer
     */
963
     int prediction_method;
964
#define FF_PRED_LEFT   0
965
#define FF_PRED_PLANE  1
966
#define FF_PRED_MEDIAN 2
967 5d3cea3a Michael Niedermayer
    
968
    /**
969 64863965 Michael Niedermayer
     * aspect ratio (0 if unknown).
970
     * - encoding: set by user.
971
     * - decoding: set by lavc.
972 5d3cea3a Michael Niedermayer
     */
973
    float aspect_ratio;
974 1e491e29 Michael Niedermayer
975
    /**
976 64863965 Michael Niedermayer
     * the picture in the bitstream.
977
     * - encoding: set by lavc
978
     * - decoding: set by lavc
979 1e491e29 Michael Niedermayer
     */
980 492cd3a9 Michael Niedermayer
    AVFrame *coded_frame;
981 c8c437bc Michael Niedermayer
982
    /**
983 64863965 Michael Niedermayer
     * debug.
984
     * - encoding: set by user.
985
     * - decoding: set by user.
986 c8c437bc Michael Niedermayer
     */
987
    int debug;
988
#define FF_DEBUG_PICT_INFO 1
989
#define FF_DEBUG_RC        2
990
#define FF_DEBUG_BITSTREAM 4
991
#define FF_DEBUG_MB_TYPE   8
992
#define FF_DEBUG_QP        16
993
#define FF_DEBUG_MV        32
994 41773b73 Michael Niedermayer
#define FF_DEBUG_VIS_MV    0x00000040
995
#define FF_DEBUG_SKIP      0x00000080
996
#define FF_DEBUG_STARTCODE 0x00000100
997
#define FF_DEBUG_PTS       0x00000200
998 46b4feec Michael Niedermayer
#define FF_DEBUG_ER        0x00000400
999 0da71265 Michael Niedermayer
#define FF_DEBUG_MMCO      0x00000800
1000 8fc6c2b5 Michael Niedermayer
#define FF_DEBUG_BUGS      0x00001000
1001 140cb663 Michael Niedermayer
    
1002
    /**
1003 64863965 Michael Niedermayer
     * error.
1004
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
1005
     * - decoding: unused
1006 140cb663 Michael Niedermayer
     */
1007
    uint64_t error[4];
1008 17a70fde Michael Niedermayer
    
1009
    /**
1010 64863965 Michael Niedermayer
     * minimum MB quantizer.
1011
     * - encoding: set by user.
1012
     * - decoding: unused
1013 17a70fde Michael Niedermayer
     */
1014
    int mb_qmin;
1015
1016
    /**
1017 64863965 Michael Niedermayer
     * maximum MB quantizer.
1018
     * - encoding: set by user.
1019
     * - decoding: unused
1020 17a70fde Michael Niedermayer
     */
1021
    int mb_qmax;
1022 1457ab52 Michael Niedermayer
    
1023
    /**
1024 64863965 Michael Niedermayer
     * motion estimation compare function.
1025
     * - encoding: set by user.
1026
     * - decoding: unused
1027 1457ab52 Michael Niedermayer
     */
1028
    int me_cmp;
1029
    /**
1030 64863965 Michael Niedermayer
     * subpixel motion estimation compare function.
1031
     * - encoding: set by user.
1032
     * - decoding: unused
1033 1457ab52 Michael Niedermayer
     */
1034
    int me_sub_cmp;
1035
    /**
1036 64863965 Michael Niedermayer
     * macroblock compare function (not supported yet).
1037
     * - encoding: set by user.
1038
     * - decoding: unused
1039 1457ab52 Michael Niedermayer
     */
1040
    int mb_cmp;
1041
#define FF_CMP_SAD  0
1042
#define FF_CMP_SSE  1
1043
#define FF_CMP_SATD 2
1044
#define FF_CMP_DCT  3
1045
#define FF_CMP_PSNR 4
1046
#define FF_CMP_BIT  5
1047
#define FF_CMP_RD   6
1048
#define FF_CMP_ZERO 7
1049
#define FF_CMP_CHROMA 256
1050
    
1051
    /**
1052 64863965 Michael Niedermayer
     * ME diamond size & shape.
1053
     * - encoding: set by user.
1054
     * - decoding: unused
1055 1457ab52 Michael Niedermayer
     */
1056
    int dia_size;
1057 b07a5980 Michael Niedermayer
1058
    /**
1059 64863965 Michael Niedermayer
     * amount of previous MV predictors (2a+1 x 2a+1 square).
1060
     * - encoding: set by user.
1061
     * - decoding: unused
1062 b07a5980 Michael Niedermayer
     */
1063
    int last_predictor_count;
1064 70ac76c0 Michael Niedermayer
1065 f5fb6b34 Michael Niedermayer
    /**
1066 64863965 Michael Niedermayer
     * pre pass for motion estimation.
1067
     * - encoding: set by user.
1068
     * - decoding: unused
1069 f5fb6b34 Michael Niedermayer
     */
1070
    int pre_me;
1071 b07a5980 Michael Niedermayer
1072 70ac76c0 Michael Niedermayer
    /**
1073 64863965 Michael Niedermayer
     * motion estimation pre pass compare function.
1074
     * - encoding: set by user.
1075
     * - decoding: unused
1076 70ac76c0 Michael Niedermayer
     */
1077
    int me_pre_cmp;
1078 826f429a Michael Niedermayer
1079 70ac76c0 Michael Niedermayer
    /**
1080 64863965 Michael Niedermayer
     * ME pre pass diamond size & shape.
1081
     * - encoding: set by user.
1082
     * - decoding: unused
1083 70ac76c0 Michael Niedermayer
     */
1084
    int pre_dia_size;
1085
1086 826f429a Michael Niedermayer
    /**
1087 64863965 Michael Niedermayer
     * subpel ME quality.
1088
     * - encoding: set by user.
1089
     * - decoding: unused
1090 826f429a Michael Niedermayer
     */
1091
    int me_subpel_quality;
1092
1093 a33c7159 Michael Niedermayer
    /**
1094 64863965 Michael Niedermayer
     * callback to negotiate the pixelFormat.
1095 a33c7159 Michael Niedermayer
     * @param fmt is the list of formats which are supported by the codec,
1096
     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1097
     * the first is allways the native one
1098
     * @return the choosen format
1099 64863965 Michael Niedermayer
     * - encoding: unused
1100
     * - decoding: set by user, if not set then the native format will always be choosen
1101 a33c7159 Michael Niedermayer
     */
1102
    enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1103 e2f9490e Fabrice Bellard
1104
    /**
1105
     * DTG active format information (additionnal aspect ratio
1106
     * information only used in DVB MPEG2 transport streams). 0 if
1107
     * not set.
1108
     * 
1109 64863965 Michael Niedermayer
     * - encoding: unused.
1110
     * - decoding: set by decoder 
1111 e2f9490e Fabrice Bellard
     */
1112
    int dtg_active_format;
1113
#define FF_DTG_AFD_SAME         8
1114
#define FF_DTG_AFD_4_3          9
1115
#define FF_DTG_AFD_16_9         10
1116
#define FF_DTG_AFD_14_9         11
1117
#define FF_DTG_AFD_4_3_SP_14_9  13
1118
#define FF_DTG_AFD_16_9_SP_14_9 14
1119
#define FF_DTG_AFD_SP_4_3       15
1120
1121 ebbcdc9a Michael Niedermayer
    /**
1122
     * Maximum motion estimation search range in subpel units.
1123
     * if 0 then no limit
1124
     * 
1125 64863965 Michael Niedermayer
     * - encoding: set by user.
1126
     * - decoding: unused.
1127 ebbcdc9a Michael Niedermayer
     */
1128 59e0ac8e Zdenek Kabelac
    int me_range;
1129 ebbcdc9a Michael Niedermayer
1130 65f7062d Michael Niedermayer
    /**
1131
     * frame_rate_base.
1132
     * for variable fps this is 1
1133
     * - encoding: set by user.
1134
     * - decoding: set by lavc.
1135
     * @todo move this after frame_rate
1136
     */
1137
1138 1984f635 Michael Niedermayer
    int frame_rate_base;
1139
    /**
1140
     * intra quantizer bias.
1141
     * - encoding: set by user.
1142
     * - decoding: unused
1143
     */
1144
    int intra_quant_bias;
1145
#define FF_DEFAULT_QUANT_BIAS 999999
1146
    
1147
    /**
1148
     * inter quantizer bias.
1149
     * - encoding: set by user.
1150
     * - decoding: unused
1151
     */
1152
    int inter_quant_bias;
1153 5cd62665 Zdenek Kabelac
1154
    /**
1155
     * color table ID.
1156
     * - encoding: unused.
1157
     * - decoding: which clrtable should be used for 8bit RGB images
1158
     *             table have to be stored somewhere FIXME
1159
     */
1160
    int color_table_id;
1161 1984f635 Michael Niedermayer
    
1162 d90cf87b Michael Niedermayer
    /**
1163
     * internal_buffer count. 
1164
     * Dont touch, used by lavc default_get_buffer()
1165
     */
1166
    int internal_buffer_count;
1167
    
1168
    /**
1169
     * internal_buffers. 
1170
     * Dont touch, used by lavc default_get_buffer()
1171
     */
1172
    void *internal_buffer;
1173 3d2e8cce Michael Niedermayer
    
1174
#define FF_QUALITY_SCALE 256
1175
    /**
1176
     * global quality for codecs which cannot change it per frame.
1177
     * this should be proportional to MPEG1/2/4 qscale.
1178
     * - encoding: set by user.
1179
     * - decoding: unused
1180
     */
1181
    int global_quality;
1182 11e659c2 Michael Niedermayer
    
1183
#define FF_CODER_TYPE_VLC   0
1184
#define FF_CODER_TYPE_AC    1
1185
    /**
1186
     * coder type
1187
     * - encoding: set by user.
1188
     * - decoding: unused
1189
     */
1190
    int coder_type;
1191
1192
    /**
1193
     * context model
1194
     * - encoding: set by user.
1195
     * - decoding: unused
1196
     */
1197
    int context_model;
1198 3bb07d61 Michael Niedermayer
    
1199
    /**
1200
     * slice flags
1201
     * - encoding: unused
1202
     * - decoding: set by user.
1203
     */
1204
    int slice_flags;
1205
#define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
1206
#define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1207
#define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1208
1209 fb364ada Ivan Kalvachev
    /**
1210
     * XVideo Motion Acceleration
1211
     * - encoding: forbidden
1212
     * - decoding: set by decoder
1213
     */
1214
    int xvmc_acceleration;
1215 7d1c3fc1 Michael Niedermayer
    
1216
    /**
1217
     * macroblock decision mode
1218
     * - encoding: set by user.
1219
     * - decoding: unused
1220
     */
1221
    int mb_decision;
1222
#define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
1223
#define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
1224
#define FF_MB_DECISION_RD     2        ///< rate distoration
1225 d6eb3c50 Michael Niedermayer
1226
    /**
1227
     * custom intra quantization matrix
1228
     * - encoding: set by user, can be NULL
1229
     * - decoding: set by lavc
1230
     */
1231
    uint16_t *intra_matrix;
1232
1233
    /**
1234
     * custom inter quantization matrix
1235
     * - encoding: set by user, can be NULL
1236
     * - decoding: set by lavc
1237
     */
1238
    uint16_t *inter_matrix;
1239 7d1c3fc1 Michael Niedermayer
    
1240 541ae140 Michael Niedermayer
    /**
1241
     * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
1242
     * this is used to workaround some encoder bugs
1243
     * - encoding: unused
1244
     * - decoding: set by user, will be converted to upper case by lavc during init
1245
     */
1246
    unsigned int stream_codec_tag;
1247 05fbd0a2 Michael Niedermayer
1248
    /**
1249
     * scene change detection threshold.
1250
     * 0 is default, larger means fewer detected scene changes
1251
     * - encoding: set by user.
1252
     * - decoding: unused
1253
     */
1254
    int scenechange_threshold;
1255 de6d9b64 Fabrice Bellard
} AVCodecContext;
1256
1257 97d96aaa Zdenek Kabelac
1258 64863965 Michael Niedermayer
/**
1259
 * AVOption.
1260
 */
1261 97d96aaa Zdenek Kabelac
typedef struct AVOption {
1262
    /** options' name */
1263
    const char *name; /* if name is NULL, it indicates a link to next */
1264 bec89a84 Zdenek Kabelac
    /** short English text help or const struct AVOption* subpointer */
1265
    const char *help; //        const struct AVOption* sub;
1266 97d96aaa Zdenek Kabelac
    /** offset to context structure where the parsed value should be stored */
1267
    int offset;
1268
    /** options' type */
1269
    int type;
1270 64863965 Michael Niedermayer
#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
1271
#define FF_OPT_TYPE_DOUBLE 2    ///< double
1272
#define FF_OPT_TYPE_INT 3       ///< integer
1273
#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
1274
#define FF_OPT_TYPE_MASK 0x1f        ///< mask for types - upper bits are various flags
1275 97d96aaa Zdenek Kabelac
//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1276
#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1277
#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1278
    /** min value  (min == max   ->  no limits) */
1279
    double min;
1280
    /** maximum value for double/int */
1281
    double max;
1282
    /** default boo [0,1]l/double/int value */
1283
    double defval;
1284
    /**
1285
     * default string value (with optional semicolon delimited extra option-list
1286
     * i.e.   option1;option2;option3
1287
     * defval might select other then first argument as default
1288
     */
1289
    const char *defstr;
1290
#define FF_OPT_MAX_DEPTH 10
1291
} AVOption;
1292
1293 64863965 Michael Niedermayer
/**
1294 bec89a84 Zdenek Kabelac
 * Parse option(s) and sets fields in passed structure
1295
 * @param strct        structure where the parsed results will be written
1296
 * @param list  list with AVOptions
1297
 * @param opts        string with options for parsing
1298
 */
1299
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1300
1301
1302
/**
1303 64863965 Michael Niedermayer
 * AVCodec.
1304
 */
1305 de6d9b64 Fabrice Bellard
typedef struct AVCodec {
1306 18f77016 Zdenek Kabelac
    const char *name;
1307 5d234974 Zdenek Kabelac
    enum CodecType type;
1308 de6d9b64 Fabrice Bellard
    int id;
1309
    int priv_data_size;
1310
    int (*init)(AVCodecContext *);
1311 0c1a9eda Zdenek Kabelac
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1312 de6d9b64 Fabrice Bellard
    int (*close)(AVCodecContext *);
1313 0fd90455 Michael Niedermayer
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1314 0c1a9eda Zdenek Kabelac
                  uint8_t *buf, int buf_size);
1315 bf89e6b1 Fabrice Bellard
    int capabilities;
1316 97d96aaa Zdenek Kabelac
    const AVOption *options;
1317 de6d9b64 Fabrice Bellard
    struct AVCodec *next;
1318 7a06ff14 Michael Niedermayer
    void (*flush)(AVCodecContext *);
1319 de6d9b64 Fabrice Bellard
} AVCodec;
1320
1321 97d96aaa Zdenek Kabelac
/**
1322 d7425f59 Michael Niedermayer
 * four components are given, that's all.
1323
 * the last component is alpha
1324
 */
1325 de6d9b64 Fabrice Bellard
typedef struct AVPicture {
1326 0c1a9eda Zdenek Kabelac
    uint8_t *data[4];
1327 cd394651 Michael Niedermayer
    int linesize[4];       ///< number of bytes per line
1328 de6d9b64 Fabrice Bellard
} AVPicture;
1329
1330 ba118447 Mike Melanson
/**
1331
 * AVPaletteControl
1332
 * This structure defines a method for communicating palette changes
1333
 * between and demuxer and a decoder.
1334
 */
1335
typedef struct AVPaletteControl {
1336
1337
    /* demuxer sets this to 1 to indicate the palette has changed;
1338
     * decoder resets to 0 */
1339
    int palette_changed;
1340
1341
    /* 256 3-byte RGB palette entries; the components should be
1342
     * formatted in the buffer as "RGBRGB..." and should be scaled to
1343
     * 8 bits if they originally represented 6-bit VGA palette
1344
     * components */
1345
    unsigned char palette[256 * 3];
1346
1347
} AVPaletteControl;
1348
1349 de6d9b64 Fabrice Bellard
extern AVCodec ac3_encoder;
1350
extern AVCodec mp2_encoder;
1351 9d36bdc9 Juanjo
extern AVCodec mp3lame_encoder;
1352 81e0d0b4 Mark Hills
extern AVCodec oggvorbis_encoder;
1353 de6d9b64 Fabrice Bellard
extern AVCodec mpeg1video_encoder;
1354 029911d1 Michael Niedermayer
extern AVCodec mpeg2video_encoder;
1355 de6d9b64 Fabrice Bellard
extern AVCodec h263_encoder;
1356
extern AVCodec h263p_encoder;
1357 d4f5d74a Garrick Meeker
extern AVCodec flv_encoder;
1358 de6d9b64 Fabrice Bellard
extern AVCodec rv10_encoder;
1359
extern AVCodec mjpeg_encoder;
1360 b1e6b355 Michael Niedermayer
extern AVCodec ljpeg_encoder;
1361 bf89e6b1 Fabrice Bellard
extern AVCodec mpeg4_encoder;
1362 84afee34 Michael Niedermayer
extern AVCodec msmpeg4v1_encoder;
1363
extern AVCodec msmpeg4v2_encoder;
1364
extern AVCodec msmpeg4v3_encoder;
1365 0151a6f5 Michael Niedermayer
extern AVCodec wmv1_encoder;
1366
extern AVCodec wmv2_encoder;
1367 11f18faf Michael Niedermayer
extern AVCodec huffyuv_encoder;
1368 0da71265 Michael Niedermayer
extern AVCodec h264_encoder;
1369 3d2e8cce Michael Niedermayer
extern AVCodec asv1_encoder;
1370 9b56edf5 Michael Niedermayer
extern AVCodec asv2_encoder;
1371 be3564ed Michael Niedermayer
extern AVCodec vcr1_encoder;
1372 5e20f836 Michael Niedermayer
extern AVCodec ffv1_encoder;
1373 c3bf0288 Michael Niedermayer
extern AVCodec mdec_encoder;
1374 de6d9b64 Fabrice Bellard
1375
extern AVCodec h263_decoder;
1376 bf89e6b1 Fabrice Bellard
extern AVCodec mpeg4_decoder;
1377 84afee34 Michael Niedermayer
extern AVCodec msmpeg4v1_decoder;
1378
extern AVCodec msmpeg4v2_decoder;
1379
extern AVCodec msmpeg4v3_decoder;
1380 e1a9dbff Michael Niedermayer
extern AVCodec wmv1_decoder;
1381 0151a6f5 Michael Niedermayer
extern AVCodec wmv2_decoder;
1382 922bc38d Michael Niedermayer
extern AVCodec mpeg1video_decoder;
1383
extern AVCodec mpeg2video_decoder;
1384 fb364ada Ivan Kalvachev
extern AVCodec mpeg_xvmc_decoder;
1385 de6d9b64 Fabrice Bellard
extern AVCodec h263i_decoder;
1386 d4f5d74a Garrick Meeker
extern AVCodec flv_decoder;
1387 de6d9b64 Fabrice Bellard
extern AVCodec rv10_decoder;
1388 be8ffec9 Nick Kurshev
extern AVCodec svq1_decoder;
1389 8b82a956 Michael Niedermayer
extern AVCodec svq3_decoder;
1390 020fcc94 Fabrice Bellard
extern AVCodec dvvideo_decoder;
1391 bc8d1857 Fabrice Bellard
extern AVCodec wmav1_decoder;
1392
extern AVCodec wmav2_decoder;
1393 4e66ab3b Fabrice Bellard
extern AVCodec mjpeg_decoder;
1394 b135d9fb Alex Beregszaszi
extern AVCodec mjpegb_decoder;
1395 4b1f4f23 Juanjo
extern AVCodec mp2_decoder;
1396 a96b68b7 Fabrice Bellard
extern AVCodec mp3_decoder;
1397 3f95e843 François Revol
extern AVCodec mace3_decoder;
1398
extern AVCodec mace6_decoder;
1399 11f18faf Michael Niedermayer
extern AVCodec huffyuv_decoder;
1400 3aca208a Mark Hills
extern AVCodec oggvorbis_decoder;
1401 f70f7c6d Michael Niedermayer
extern AVCodec cyuv_decoder;
1402 0da71265 Michael Niedermayer
extern AVCodec h264_decoder;
1403 deabd4fd Mike Melanson
extern AVCodec indeo3_decoder;
1404 d86053a4 Mike Melanson
extern AVCodec vp3_decoder;
1405 891f64b3 joca@rixmail.se
extern AVCodec amr_nb_decoder;
1406 bc634f6f Zdenek Kabelac
extern AVCodec amr_nb_encoder;
1407 d663a1fd Michael Niedermayer
extern AVCodec amr_wb_encoder;
1408
extern AVCodec amr_wb_decoder;
1409 280bd7b7 Zdenek Kabelac
extern AVCodec aac_decoder;
1410
extern AVCodec mpeg4aac_decoder;
1411 3d2e8cce Michael Niedermayer
extern AVCodec asv1_decoder;
1412 9b56edf5 Michael Niedermayer
extern AVCodec asv2_decoder;
1413 be3564ed Michael Niedermayer
extern AVCodec vcr1_decoder;
1414 3aff069b Alex Beregszaszi
extern AVCodec cljr_decoder;
1415 5e20f836 Michael Niedermayer
extern AVCodec ffv1_decoder;
1416 8809cfee Michael Niedermayer
extern AVCodec fourxm_decoder;
1417 c3bf0288 Michael Niedermayer
extern AVCodec mdec_decoder;
1418 3ef8be2b Mike Melanson
extern AVCodec roq_decoder;
1419
extern AVCodec interplay_video_decoder;
1420 9937e686 Mike Melanson
extern AVCodec xan_wc3_decoder;
1421 b8414bbd Nick Kurshev
extern AVCodec ra_144_decoder;
1422
extern AVCodec ra_288_decoder;
1423 3ef8be2b Mike Melanson
extern AVCodec roq_dpcm_decoder;
1424
extern AVCodec interplay_dpcm_decoder;
1425 9937e686 Mike Melanson
extern AVCodec xan_dpcm_decoder;
1426 de6d9b64 Fabrice Bellard
1427 a96b68b7 Fabrice Bellard
/* pcm codecs */
1428
#define PCM_CODEC(id, name) \
1429
extern AVCodec name ## _decoder; \
1430 f11d3f23 Michael Niedermayer
extern AVCodec name ## _encoder
1431 a96b68b7 Fabrice Bellard
1432
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1433
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1434
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1435
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1436
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1437
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1438
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1439
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1440
1441 0147f198 François Revol
/* adpcm codecs */
1442
1443
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1444
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1445 9937e686 Mike Melanson
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
1446
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
1447 0147f198 François Revol
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1448 4b465299 Michael Niedermayer
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1449 0147f198 François Revol
1450 a96b68b7 Fabrice Bellard
#undef PCM_CODEC
1451
1452
/* dummy raw video codec */
1453 63167088 Roman Shaposhnik
extern AVCodec rawvideo_encoder;
1454
extern AVCodec rawvideo_decoder;
1455 de6d9b64 Fabrice Bellard
1456
/* the following codecs use external GPL libs */
1457
extern AVCodec ac3_decoder;
1458
1459
/* resample.c */
1460
1461
struct ReSampleContext;
1462
1463
typedef struct ReSampleContext ReSampleContext;
1464
1465
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1466
                                     int output_rate, int input_rate);
1467
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1468
void audio_resample_close(ReSampleContext *s);
1469
1470
/* YUV420 format is assumed ! */
1471
1472
struct ImgReSampleContext;
1473
1474
typedef struct ImgReSampleContext ImgReSampleContext;
1475
1476
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1477
                                      int input_width, int input_height);
1478 ab6d194a Michael Niedermayer
1479
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1480
                                      int iwidth, int iheight,
1481
                                      int topBand, int bottomBand,
1482
                                      int leftBand, int rightBand);
1483
1484 de6d9b64 Fabrice Bellard
void img_resample(ImgReSampleContext *s, 
1485 da64ecc3 Drew Hess
                  AVPicture *output, const AVPicture *input);
1486 de6d9b64 Fabrice Bellard
1487
void img_resample_close(ImgReSampleContext *s);
1488
1489 0c1a9eda Zdenek Kabelac
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1490 2d1a4094 Fabrice Bellard
                   int pix_fmt, int width, int height);
1491 da64ecc3 Drew Hess
int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
1492 63167088 Roman Shaposhnik
                     unsigned char *dest, int dest_size);
1493 219b06c6 Fabrice Bellard
int avpicture_get_size(int pix_fmt, int width, int height);
1494 dab64ebc Fabrice Bellard
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1495
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1496 63167088 Roman Shaposhnik
enum PixelFormat avcodec_get_pix_fmt(const char* name);
1497 219b06c6 Fabrice Bellard
1498 fab21997 Fabrice Bellard
#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
1499
#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
1500
#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
1501
#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
1502
#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
1503
#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1504
1505
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1506
                             int has_alpha);
1507
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1508
                              int has_alpha, int *loss_ptr);
1509
1510 0469baf1 Fabrice Bellard
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1511
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1512 da64ecc3 Drew Hess
int img_get_alpha_info(const AVPicture *src,
1513
                       int pix_fmt, int width, int height);
1514 0469baf1 Fabrice Bellard
1515 219b06c6 Fabrice Bellard
/* convert among pixel formats */
1516
int img_convert(AVPicture *dst, int dst_pix_fmt,
1517 da64ecc3 Drew Hess
                const AVPicture *src, int pix_fmt, 
1518 219b06c6 Fabrice Bellard
                int width, int height);
1519
1520
/* deinterlace a picture */
1521 da64ecc3 Drew Hess
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
1522 de6d9b64 Fabrice Bellard
                          int pix_fmt, int width, int height);
1523
1524
/* external high level API */
1525
1526
extern AVCodec *first_avcodec;
1527
1528 156e5023 Nick Kurshev
/* returns LIBAVCODEC_VERSION_INT constant */
1529 51a49663 Fabrice Bellard
unsigned avcodec_version(void);
1530 8bceb6af Nick Kurshev
/* returns LIBAVCODEC_BUILD constant */
1531 51a49663 Fabrice Bellard
unsigned avcodec_build(void);
1532 de6d9b64 Fabrice Bellard
void avcodec_init(void);
1533
1534
void register_avcodec(AVCodec *format);
1535
AVCodec *avcodec_find_encoder(enum CodecID id);
1536 98f3b098 Arpi
AVCodec *avcodec_find_encoder_by_name(const char *name);
1537 de6d9b64 Fabrice Bellard
AVCodec *avcodec_find_decoder(enum CodecID id);
1538
AVCodec *avcodec_find_decoder_by_name(const char *name);
1539
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1540
1541 1e491e29 Michael Niedermayer
void avcodec_get_context_defaults(AVCodecContext *s);
1542 7ffbb60e Falk Hüffner
AVCodecContext *avcodec_alloc_context(void);
1543 492cd3a9 Michael Niedermayer
AVFrame *avcodec_alloc_frame(void);
1544 1e491e29 Michael Niedermayer
1545 492cd3a9 Michael Niedermayer
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1546
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1547 d90cf87b Michael Niedermayer
void avcodec_default_free_buffers(AVCodecContext *s);
1548 1e491e29 Michael Niedermayer
1549 7a06ff14 Michael Niedermayer
/**
1550
 * opens / inits the AVCodecContext.
1551
 * not thread save!
1552
 */
1553 de6d9b64 Fabrice Bellard
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1554 7a06ff14 Michael Niedermayer
1555 0c1a9eda Zdenek Kabelac
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1556 de6d9b64 Fabrice Bellard
                         int *frame_size_ptr,
1557 0c1a9eda Zdenek Kabelac
                         uint8_t *buf, int buf_size);
1558 492cd3a9 Michael Niedermayer
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1559 de6d9b64 Fabrice Bellard
                         int *got_picture_ptr,
1560 0c1a9eda Zdenek Kabelac
                         uint8_t *buf, int buf_size);
1561
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1562 917e06c8 Fabrice Bellard
                        int *data_size_ptr,
1563 0c1a9eda Zdenek Kabelac
                        uint8_t *buf, int buf_size);
1564
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1565 de6d9b64 Fabrice Bellard
                         const short *samples);
1566 0c1a9eda Zdenek Kabelac
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1567 492cd3a9 Michael Niedermayer
                         const AVFrame *pict);
1568 de6d9b64 Fabrice Bellard
1569
int avcodec_close(AVCodecContext *avctx);
1570
1571
void avcodec_register_all(void);
1572 a96b68b7 Fabrice Bellard
1573 1c2a8c7f Michael Niedermayer
void avcodec_flush_buffers(AVCodecContext *avctx);
1574
1575 14bea432 Michael Niedermayer
/* misc usefull functions */
1576 d8085ea7 Michael Niedermayer
1577
/**
1578
 * returns a single letter to describe the picture type
1579
 */
1580
char av_get_pict_type_char(int pict_type);
1581
1582 14bea432 Michael Niedermayer
/**
1583
 * reduce a fraction.
1584
 * this is usefull for framerate calculations
1585
 * @param max the maximum allowed for dst_nom & dst_den
1586
 * @return 1 if exact, 0 otherwise
1587
 */
1588
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1589
1590
/**
1591
 * rescale a 64bit integer.
1592
 * a simple a*b/c isnt possible as it can overflow
1593
 */
1594
int64_t av_rescale(int64_t a, int b, int c);
1595 628d601b Zdenek Kabelac
1596
1597 e8f14793 Zdenek Kabelac
/**
1598
 * Interface for 0.5.0 version
1599
 *
1600
 * do not even think about it's usage for this moment
1601
 */
1602
1603
typedef struct {
1604 64863965 Michael Niedermayer
    /// compressed size used from given memory buffer
1605 e8f14793 Zdenek Kabelac
    int size;
1606
    /// I/P/B frame type
1607
    int frame_type;
1608
} avc_enc_result_t;
1609
1610
/**
1611
 * Commands
1612
 * order can't be changed - once it was defined
1613
 */
1614
typedef enum {
1615
    // general commands
1616
    AVC_OPEN_BY_NAME = 0xACA000,
1617
    AVC_OPEN_BY_CODEC_ID,
1618
    AVC_OPEN_BY_FOURCC,
1619
    AVC_CLOSE,
1620
1621
    AVC_FLUSH,
1622
    // pin - struct { uint8_t* src, uint_t src_size }
1623
    // pout - struct { AVPicture* img, consumed_bytes,
1624
    AVC_DECODE,
1625
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1626
    // pout - uint_t used_from_dest_size
1627
    AVC_ENCODE, 
1628
1629
    // query/get video commands
1630
    AVC_GET_VERSION = 0xACB000,
1631
    AVC_GET_WIDTH,
1632
    AVC_GET_HEIGHT,
1633
    AVC_GET_DELAY,
1634
    AVC_GET_QUANT_TABLE,
1635
    // ...
1636
1637
    // query/get audio commands
1638
    AVC_GET_FRAME_SIZE = 0xABC000,
1639
1640
    // maybe define some simple structure which
1641
    // might be passed to the user - but they can't
1642
    // contain any codec specific parts and these
1643
    // calls are usualy necessary only few times
1644
1645
    // set video commands
1646
    AVC_SET_WIDTH = 0xACD000,
1647
    AVC_SET_HEIGHT,
1648
1649
    // set video encoding commands
1650
    AVC_SET_FRAME_RATE = 0xACD800,
1651
    AVC_SET_QUALITY,
1652
    AVC_SET_HURRY_UP,
1653
1654
    // set audio commands
1655
    AVC_SET_SAMPLE_RATE = 0xACE000,
1656
    AVC_SET_CHANNELS,
1657
1658
} avc_cmd_t;
1659
1660
/**
1661
 * \param handle  allocated private structure by libavcodec
1662
 *                for initialization pass NULL - will be returned pout
1663
 *                user is supposed to know nothing about its structure
1664
 * \param cmd     type of operation to be performed
1665
 * \param pint    input parameter
1666
 * \param pout    output parameter
1667
 *
1668
 * \returns  command status - eventually for query command it might return
1669
 * integer resulting value
1670
 */
1671
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1672
1673 544eb99c Fabrice Bellard
/* memory */
1674 e4eadb4b Michael Niedermayer
void *av_malloc(unsigned int size);
1675 18f77016 Zdenek Kabelac
void *av_mallocz(unsigned int size);
1676 8e1e6f31 Fabrice Bellard
void *av_realloc(void *ptr, unsigned int size);
1677 544eb99c Fabrice Bellard
void av_free(void *ptr);
1678 8e1e6f31 Fabrice Bellard
char *av_strdup(const char *s);
1679 544eb99c Fabrice Bellard
void __av_freep(void **ptr);
1680
#define av_freep(p) __av_freep((void **)(p))
1681 97d96aaa Zdenek Kabelac
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1682 855ea723 Zdenek Kabelac
/* for static data only */
1683
/* call av_free_static to release all staticaly allocated tables */
1684 628d601b Zdenek Kabelac
void av_free_static(void);
1685 855ea723 Zdenek Kabelac
void *__av_mallocz_static(void** location, unsigned int size);
1686
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1687 544eb99c Fabrice Bellard
1688 02d697aa Zdenek Kabelac
#ifdef __cplusplus
1689
}
1690
#endif
1691
1692 a96b68b7 Fabrice Bellard
#endif /* AVCODEC_H */