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