Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ cf713bb8

History | View | Annotate | Download (42.1 KB)

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       4668
19
#define LIBAVCODEC_BUILD_STR   "4668"
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_MPEG4,
35
    CODEC_ID_RAWVIDEO,
36
    CODEC_ID_MSMPEG4V1,
37
    CODEC_ID_MSMPEG4V2,
38
    CODEC_ID_MSMPEG4V3,
39
    CODEC_ID_WMV1,
40
    CODEC_ID_WMV2,
41
    CODEC_ID_H263P,
42
    CODEC_ID_H263I,
43
    CODEC_ID_SVQ1,
44
    CODEC_ID_SVQ3,
45
    CODEC_ID_DVVIDEO,
46
    CODEC_ID_DVAUDIO,
47
    CODEC_ID_WMAV1,
48
    CODEC_ID_WMAV2,
49
    CODEC_ID_MACE3,
50
    CODEC_ID_MACE6,
51
    CODEC_ID_HUFFYUV,
52
    CODEC_ID_CYUV,
53
    CODEC_ID_H264,
54
    CODEC_ID_INDEO3,
55
    CODEC_ID_VP3,
56
    CODEC_ID_AAC,
57
    CODEC_ID_MPEG4AAC,
58
    CODEC_ID_ASV1,
59
    CODEC_ID_4XM,
60

    
61
    /* various pcm "codecs" */
62
    CODEC_ID_PCM_S16LE,
63
    CODEC_ID_PCM_S16BE,
64
    CODEC_ID_PCM_U16LE,
65
    CODEC_ID_PCM_U16BE,
66
    CODEC_ID_PCM_S8,
67
    CODEC_ID_PCM_U8,
68
    CODEC_ID_PCM_MULAW,
69
    CODEC_ID_PCM_ALAW,
70

    
71
    /* various adpcm codecs */
72
    CODEC_ID_ADPCM_IMA_QT,
73
    CODEC_ID_ADPCM_IMA_WAV,
74
    CODEC_ID_ADPCM_MS,
75
    CODEC_ID_ADPCM_4XM,
76

    
77
        /* AMR */
78
    CODEC_ID_AMR_NB,
79
};
80

    
81
enum CodecType {
82
    CODEC_TYPE_UNKNOWN = -1,
83
    CODEC_TYPE_VIDEO,
84
    CODEC_TYPE_AUDIO,
85
};
86

    
87
/**
88
 * Pixel format.
89
 */
90
enum PixelFormat {
91
    PIX_FMT_YUV420P,
92
    PIX_FMT_YUV422,
93
    PIX_FMT_RGB24,     ///< 3 bytes, R is first 
94
    PIX_FMT_BGR24,     ///< 3 bytes, B is first 
95
    PIX_FMT_YUV422P,
96
    PIX_FMT_YUV444P,
97
    PIX_FMT_RGBA32,    ///< always stored in cpu endianness 
98
    PIX_FMT_YUV410P,
99
    PIX_FMT_YUV411P,
100
    PIX_FMT_RGB565,    ///< always stored in cpu endianness 
101
    PIX_FMT_RGB555,    ///< always stored in cpu endianness, most significant bit to 1 
102
    PIX_FMT_GRAY8,
103
    PIX_FMT_MONOWHITE, ///< 0 is white 
104
    PIX_FMT_MONOBLACK, ///< 0 is black 
105
    PIX_FMT_PAL8,      ///< 8 bit with RGBA palette 
106
    PIX_FMT_YUVJ420P,  ///< YUV full scale (jpeg)
107
    PIX_FMT_YUVJ422P,  ///< YUV full scale (jpeg)
108
    PIX_FMT_YUVJ444P,  ///< YUV full scale (jpeg)
109
    PIX_FMT_NB,
110
};
111

    
112
/* currently unused, may be used if 24/32 bits samples ever supported */
113
enum SampleFormat {
114
    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
115
};
116

    
117
/* in bytes */
118
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
119

    
120
/**
121
 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
122
 * this is mainly needed because some optimized bitstream readers read 
123
 * 32 or 64 bit at once and could read over the end<br>
124
 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
125
 * MPEG bitstreams could cause overread and segfault
126
 */
127
#define FF_INPUT_BUFFER_PADDING_SIZE 8
128

    
129
/* motion estimation type, EPZS by default */
130
enum Motion_Est_ID {
131
    ME_ZERO = 1,
132
    ME_FULL,
133
    ME_LOG,
134
    ME_PHODS,
135
    ME_EPZS,
136
    ME_X1
137
};
138

    
139
typedef struct RcOverride{
140
    int start_frame;
141
    int end_frame;
142
    int qscale; // if this is 0 then quality_factor will be used instead
143
    float quality_factor;
144
} RcOverride;
145

    
146
/* only for ME compatiblity with old apps */
147
extern int motion_estimation_method;
148

    
149
/* ME algos sorted by quality */
150
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
151
                                       ME_X1, ME_EPZS, ME_FULL };
152

    
153

    
154
#define FF_MAX_B_FRAMES 8
155

    
156
/* encoding support
157
   these flags can be passed in AVCodecContext.flags before initing 
158
   Note: note not everything is supported yet 
159
*/
160

    
161
#define CODEC_FLAG_HQ     0x0001  ///< brute force MB-type decission mode (slow) 
162
#define CODEC_FLAG_QSCALE 0x0002  ///< use fixed qscale 
163
#define CODEC_FLAG_4MV    0x0004  ///< 4 MV per MB allowed 
164
#define CODEC_FLAG_QPEL   0x0010  ///< use qpel MC 
165
#define CODEC_FLAG_GMC    0x0020  ///< use GMC 
166
#define CODEC_FLAG_PART   0x0080  ///< use data partitioning 
167
/* parent program gurantees that the input for b-frame containing streams is not written to 
168
   for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
169
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
170
#define CODEC_FLAG_PASS1 0x0200   ///< use internal 2pass ratecontrol in first  pass mode 
171
#define CODEC_FLAG_PASS2 0x0400   ///< use internal 2pass ratecontrol in second pass mode 
172
#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg) 
173
#define CODEC_FLAG_GRAY  0x2000   ///< only decode/encode grayscale 
174
#define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges 
175
#define CODEC_FLAG_PSNR           0x8000 ///< error[?] variables will be set during encoding 
176
#define CODEC_FLAG_TRUNCATED  0x00010000 /** input bitstream might be truncated at a random location instead 
177
                                            of only at frame boundaries */
178
#define CODEC_FLAG_NORMALIZE_AQP  0x00020000 ///< normalize adaptive quantization 
179
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct 
180
#define CODEC_FLAG_LOW_DELAY      0x00080000 ///< force low delay / will fail on b frames 
181
#define CODEC_FLAG_ALT_SCAN       0x00100000 ///< use alternate scan 
182
#define CODEC_FLAG_TRELLIS_QUANT  0x00200000 ///< use trellis quantization 
183
#define CODEC_FLAG_GLOBAL_HEADER  0x00400000 ///< place global headers in extradata instead of every keyframe 
184
#define CODEC_FLAG_BITEXACT       0x00800000 ///< use only bitexact stuff (except (i)dct) 
185
/* Fx : Flag for h263+ extra options */
186
#define CODEC_FLAG_H263P_AIC      0x01000000 ///< Advanced intra coding 
187
#define CODEC_FLAG_H263P_UMV      0x02000000 ///< Unlimited motion vector  
188
/* For advanced prediction mode, we reuse the 4MV flag */
189
/* Unsupported options :
190
 *                 Syntax Arithmetic coding (SAC)
191
 *                 Deblocking filter internal loop
192
 *                 Slice structured
193
 *                 Reference Picture Selection
194
 *                 Independant Segment Decoding
195
 *                 Alternative Inter *                 VLC
196
 *                 Modified Quantization */
197
/* /Fx */
198
/* codec capabilities */
199

    
200
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback 
201
/**
202
 * Codec uses get_buffer() for allocating buffers.
203
 * direct rendering method 1
204
 */
205
#define CODEC_CAP_DR1             0x0002
206
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
207
   used */
208
#define CODEC_CAP_PARSE_ONLY      0x0004
209
#define CODEC_CAP_TRUNCATED       0x0008
210

    
211
#define FF_COMMON_FRAME \
212
    /**\
213
     * pointer to the picture planes.\
214
     * this might be different from the first allocated byte\
215
     * - encoding: \
216
     * - decoding: \
217
     */\
218
    uint8_t *data[4];\
219
    int linesize[4];\
220
    /**\
221
     * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
222
     * this isnt used by lavc unless the default get/release_buffer() is used\
223
     * - encoding: \
224
     * - decoding: \
225
     */\
226
    uint8_t *base[4];\
227
    /**\
228
     * 1 -> keyframe, 0-> not\
229
     * - encoding: set by lavc\
230
     * - decoding: set by lavc\
231
     */\
232
    int key_frame;\
233
\
234
    /**\
235
     * picture type of the frame, see ?_TYPE below.\
236
     * - encoding: set by lavc for coded_picture (and set by user for input)\
237
     * - decoding: set by lavc\
238
     */\
239
    int pict_type;\
240
\
241
    /**\
242
     * presentation timestamp in micro seconds (time when frame should be shown to user)\
243
     * if 0 then the frame_rate will be used as reference\
244
     * - encoding: MUST be set by user\
245
     * - decoding: set by lavc\
246
     */\
247
    int64_t pts;\
248
\
249
    /**\
250
     * picture number in bitstream order.\
251
     * - encoding: set by\
252
     * - decoding: set by lavc\
253
     */\
254
    int coded_picture_number;\
255
    /**\
256
     * picture number in display order.\
257
     * - encoding: set by\
258
     * - decoding: set by lavc\
259
     */\
260
    int display_picture_number;\
261
\
262
    /**\
263
     * quality (between 1 (good) and 31 (bad)) \
264
     * - encoding: set by lavc for coded_picture (and set by user for input)\
265
     * - decoding: set by lavc\
266
     */\
267
    float quality; \
268
\
269
    /**\
270
     * buffer age (1->was last buffer and dint change, 2->..., ...).\
271
     * set to something large if the buffer has not been used yet \
272
     * - encoding: unused\
273
     * - decoding: MUST be set by get_buffer()\
274
     */\
275
    int age;\
276
\
277
    /**\
278
     * is this picture used as reference\
279
     * - encoding: unused\
280
     * - decoding: set by lavc (before get_buffer() call))\
281
     */\
282
    int reference;\
283
\
284
    /**\
285
     * QP table\
286
     * - encoding: unused\
287
     * - decoding: set by lavc\
288
     */\
289
    int8_t *qscale_table;\
290
    /**\
291
     * QP store stride\
292
     * - encoding: unused\
293
     * - decoding: set by lavc\
294
     */\
295
    int qstride;\
296
\
297
    /**\
298
     * mbskip_table[mb]>=1 if MB didnt change\
299
     * stride= mb_width = (width+15)>>4\
300
     * - encoding: unused\
301
     * - decoding: set by lavc\
302
     */\
303
    uint8_t *mbskip_table;\
304
\
305
    /**\
306
     * for some private data of the user\
307
     * - encoding: unused\
308
     * - decoding: set by user\
309
     */\
310
    void *opaque;\
311
\
312
    /**\
313
     * error\
314
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
315
     * - decoding: unused\
316
     */\
317
    uint64_t error[4];\
318
\
319
    /**\
320
     * type of the buffer (to keep track of who has to dealloc data[*])\
321
     * - encoding: set by the one who allocs it\
322
     * - decoding: set by the one who allocs it\
323
     * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
324
     */\
325
    int type;\
326
    \
327
    /**\
328
     * when decoding, this signal how much the picture must be delayed.\
329
     * extra_delay = repeat_pict / (2*fps)\
330
     * - encoding: unused\
331
     * - decoding: set by lavc\
332
     */\
333
    int repeat_pict;\
334
    \
335
    /**\
336
     * \
337
     */\
338
    int qscale_type;\
339

    
340
#define FF_QSCALE_TYPE_MPEG1        0
341
#define FF_QSCALE_TYPE_MPEG2        1
342

    
343
#define FF_BUFFER_TYPE_INTERNAL 1
344
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers
345
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc
346

    
347

    
348
#define FF_I_TYPE 1 // Intra
349
#define FF_P_TYPE 2 // Predicted
350
#define FF_B_TYPE 3 // Bi-dir predicted
351
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
352
#define FF_SI_TYPE 5
353
#define FF_SP_TYPE 6
354

    
355
/**
356
 * Audio Video Frame.
357
 */
358
typedef struct AVFrame {
359
    FF_COMMON_FRAME
360
} AVFrame;
361

    
362
#define DEFAULT_FRAME_RATE_BASE 1001000
363

    
364
/**
365
 * main external api structure.
366
 */
367
typedef struct AVCodecContext {
368
    /**
369
     * the average bitrate.
370
     * - encoding: set by user. unused for constant quantizer encoding
371
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
372
     */
373
    int bit_rate;
374

    
375
    /**
376
     * number of bits the bitstream is allowed to diverge from the reference.
377
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
378
     * - encoding: set by user. unused for constant quantizer encoding
379
     * - decoding: unused
380
     */
381
    int bit_rate_tolerance; 
382

    
383
    /**
384
     * CODEC_FLAG_*.
385
     * - encoding: set by user.
386
     * - decoding: set by user.
387
     */
388
    int flags;
389

    
390
    /**
391
     * some codecs needs additionnal format info. It is stored here
392
     * - encoding: set by user. 
393
     * - decoding: set by lavc. (FIXME is this ok?)
394
     */
395
    int sub_id;
396

    
397
    /**
398
     * motion estimation algorithm used for video coding.
399
     * - encoding: MUST be set by user.
400
     * - decoding: unused
401
     */
402
    int me_method;
403

    
404
    /**
405
     * some codecs need / can use extra-data like huffman tables.
406
     * mjpeg: huffman tables
407
     * rv10: additional flags
408
     * mpeg4: global headers (they can be in the bitstream or here)
409
     * - encoding: set/allocated/freed by lavc.
410
     * - decoding: set/allocated/freed by user.
411
     */
412
    void *extradata;
413
    int extradata_size;
414
    
415
    /* video only */
416
    /**
417
     * frames per sec multiplied by frame_rate_base.
418
     * for variable fps this is the precission, so if the timestamps 
419
     * can be specified in msec precssion then this is 1000*frame_rate_base
420
     * - encoding: MUST be set by user
421
     * - decoding: set by lavc. 0 or the frame_rate if available
422
     */
423
    int frame_rate;
424
    
425
    /**
426
     * width / height.
427
     * - encoding: MUST be set by user. 
428
     * - decoding: set by user, some codecs might override / change it during playback
429
     */
430
    int width, height;
431
    
432
#define FF_ASPECT_SQUARE 1
433
#define FF_ASPECT_4_3_625 2
434
#define FF_ASPECT_4_3_525 3
435
#define FF_ASPECT_16_9_625 4
436
#define FF_ASPECT_16_9_525 5
437
#define FF_ASPECT_EXTENDED 15
438

    
439
    /**
440
     * the number of pictures in a group of pitures, or 0 for intra_only.
441
     * - encoding: set by user.
442
     * - decoding: unused
443
     */
444
    int gop_size;
445

    
446
    /**
447
     * pixel format, see PIX_FMT_xxx.
448
     * - encoding: unused
449
     * - decoding: set by lavc.
450
     */
451
    enum PixelFormat pix_fmt;
452
 
453
    /**
454
     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
455
     * has to read frames at native frame rate.
456
     * - encoding: set by user.
457
     * - decoding: unused.
458
     */
459
    int rate_emu;
460
       
461
    /**
462
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
463
     * decoder to draw an horizontal band. It improve cache usage. Not
464
     * all codecs can do that. You must check the codec capabilities
465
     * before
466
     * - encoding: unused
467
     * - decoding: set by user.
468
     */
469
    void (*draw_horiz_band)(struct AVCodecContext *s,
470
                            uint8_t **src_ptr, int linesize,
471
                            int y, int width, int height);
472

    
473
    /* audio only */
474
    int sample_rate; ///< samples per sec 
475
    int channels;
476
    int sample_fmt;  ///< sample format, currenly unused 
477

    
478
    /* the following data should not be initialized */
479
    int frame_size;     ///< in samples, initialized when calling 'init' 
480
    int frame_number;   ///< audio or video frame number 
481
    int real_pict_num;  ///< returns the real picture number of previous encoded frame 
482
    
483
    /**
484
     * number of frames the decoded output will be delayed relative to 
485
     * the encoded input.
486
     * - encoding: set by lavc.
487
     * - decoding: unused
488
     */
489
    int delay;
490
    
491
    /* - encoding parameters */
492
    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
493
    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
494
    
495
    /**
496
     * minimum quantizer.
497
     * - encoding: set by user.
498
     * - decoding: unused
499
     */
500
    int qmin;
501

    
502
    /**
503
     * maximum quantizer.
504
     * - encoding: set by user.
505
     * - decoding: unused
506
     */
507
    int qmax;
508

    
509
    /**
510
     * maximum quantizer difference etween frames.
511
     * - encoding: set by user.
512
     * - decoding: unused
513
     */
514
    int max_qdiff;
515

    
516
    /**
517
     * maximum number of b frames between non b frames.
518
     * note: the output will be delayed by max_b_frames+1 relative to the input
519
     * - encoding: set by user.
520
     * - decoding: unused
521
     */
522
    int max_b_frames;
523

    
524
    /**
525
     * qscale factor between ip and b frames.
526
     * - encoding: set by user.
527
     * - decoding: unused
528
     */
529
    float b_quant_factor;
530
    
531
    /** obsolete FIXME remove */
532
    int rc_strategy;
533
    int b_frame_strategy;
534

    
535
    /**
536
     * hurry up amount.
537
     * - encoding: unused
538
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
539
     */
540
    int hurry_up;
541
    
542
    struct AVCodec *codec;
543
    
544
    void *priv_data;
545

    
546
    /* The following data is for RTP friendly coding */
547
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
548
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
549
                    /* highers numbers represent more error-prone */
550
                    /* enviroments, by now just "1" exist         */
551
    
552
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
553
                            /* do it's best to deliver a chunk with size    */
554
                            /* below rtp_payload_size, the chunk will start */
555
                            /* with a start code on some codecs like H.263  */
556
                            /* This doesn't take account of any particular  */
557
                            /* headers inside the transmited RTP payload    */
558

    
559
    
560
    /* The RTP callcack: This function is called  */
561
    /* every time the encoder as a packet to send */
562
    /* Depends on the encoder if the data starts  */
563
    /* with a Start Code (it should) H.263 does   */
564
    void (*rtp_callback)(void *data, int size, int packet_number); 
565

    
566
    /* statistics, used for 2-pass encoding */
567
    int mv_bits;
568
    int header_bits;
569
    int i_tex_bits;
570
    int p_tex_bits;
571
    int i_count;
572
    int p_count;
573
    int skip_count;
574
    int misc_bits;
575
    
576
    /**
577
     * number of bits used for the previously encoded frame.
578
     * - encoding: set by lavc
579
     * - decoding: unused
580
     */
581
    int frame_bits;
582

    
583
    /**
584
     * private data of the user, can be used to carry app specific stuff.
585
     * - encoding: set by user
586
     * - decoding: set by user
587
     */
588
    void *opaque;
589

    
590
    char codec_name[32];
591
    enum CodecType codec_type; /* see CODEC_TYPE_xxx */
592
    enum CodecID codec_id; /* see CODEC_ID_xxx */
593
    
594
    /**
595
     * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
596
     * this is used to workaround some encoder bugs
597
     * - encoding: unused
598
     * - decoding: set by user, will be converted to upper case by lavc during init
599
     */
600
    unsigned int codec_tag;
601
    
602
    /**
603
     * workaround bugs in encoders which sometimes cannot be detected automatically.
604
     * - encoding: unused
605
     * - decoding: set by user
606
     */
607
    int workaround_bugs;
608
#define FF_BUG_AUTODETECT       1  ///< autodetection
609
#define FF_BUG_OLD_MSMPEG4      2
610
#define FF_BUG_XVID_ILACE       4
611
#define FF_BUG_UMP4             8
612
#define FF_BUG_NO_PADDING       16
613
#define FF_BUG_AC_VLC           32
614
#define FF_BUG_QPEL_CHROMA      64
615
#define FF_BUG_STD_QPEL         128
616
#define FF_BUG_QPEL_CHROMA2     256
617
#define FF_BUG_DIRECT_BLOCKSIZE 512
618
#define FF_BUG_EDGE             1024
619
//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
620
        
621
    /**
622
     * luma single coeff elimination threshold.
623
     * - encoding: set by user
624
     * - decoding: unused
625
     */
626
    int luma_elim_threshold;
627
    
628
    /**
629
     * chroma single coeff elimination threshold.
630
     * - encoding: set by user
631
     * - decoding: unused
632
     */
633
    int chroma_elim_threshold;
634
    
635
    /**
636
     * strictly follow the std (MPEG4, ...).
637
     * - encoding: set by user
638
     * - decoding: unused
639
     */
640
    int strict_std_compliance;
641
    
642
    /**
643
     * qscale offset between ip and b frames.
644
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
645
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
646
     * - encoding: set by user.
647
     * - decoding: unused
648
     */
649
    float b_quant_offset;
650
    
651
    /**
652
     * error resilience higher values will detect more errors but may missdetect
653
     * some more or less valid parts as errors.
654
     * - encoding: unused
655
     * - decoding: set by user
656
     */
657
    int error_resilience;
658
#define FF_ER_CAREFULL        1
659
#define FF_ER_COMPLIANT       2
660
#define FF_ER_AGGRESSIVE      3
661
#define FF_ER_VERY_AGGRESSIVE 4
662
    
663
    /**
664
     * called at the beginning of each frame to get a buffer for it.
665
     * if pic.reference is set then the frame will be read later by lavc
666
     * - encoding: unused
667
     * - decoding: set by lavc, user can override
668
     */
669
    int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
670
    
671
    /**
672
     * called to release buffers which where allocated with get_buffer.
673
     * a released buffer can be reused in get_buffer()
674
     * pic.data[*] must be set to NULL
675
     * - encoding: unused
676
     * - decoding: set by lavc, user can override
677
     */
678
    void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
679

    
680
    /**
681
     * is 1 if the decoded stream contains b frames, 0 otherwise.
682
     * - encoding: unused
683
     * - decoding: set by lavc
684
     */
685
    int has_b_frames;
686
    
687
    int block_align; ///< used by some WAV based audio codecs
688
    
689
    int parse_only; /* - decoding only: if true, only parsing is done
690
                       (function avcodec_parse_frame()). The frame
691
                       data is returned. Only MPEG codecs support this now. */
692
    
693
    /**
694
     * 0-> h263 quant 1-> mpeg quant.
695
     * - encoding: set by user.
696
     * - decoding: unused
697
     */
698
    int mpeg_quant;
699
    
700
    /**
701
     * pass1 encoding statistics output buffer.
702
     * - encoding: set by lavc
703
     * - decoding: unused
704
     */
705
    char *stats_out;
706
    
707
    /**
708
     * pass2 encoding statistics input buffer.
709
     * concatenated stuff from stats_out of pass1 should be placed here
710
     * - encoding: allocated/set/freed by user
711
     * - decoding: unused
712
     */
713
    char *stats_in;
714
    
715
    /**
716
     * ratecontrol qmin qmax limiting method.
717
     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
718
     * - encoding: set by user.
719
     * - decoding: unused
720
     */
721
    float rc_qsquish;
722

    
723
    float rc_qmod_amp;
724
    int rc_qmod_freq;
725
    
726
    /**
727
     * ratecontrol override, see RcOverride.
728
     * - encoding: allocated/set/freed by user.
729
     * - decoding: unused
730
     */
731
    RcOverride *rc_override;
732
    int rc_override_count;
733
    
734
    /**
735
     * rate control equation.
736
     * - encoding: set by user
737
     * - decoding: unused
738
     */
739
    char *rc_eq;
740
    
741
    /**
742
     * maximum bitrate.
743
     * - encoding: set by user.
744
     * - decoding: unused
745
     */
746
    int rc_max_rate;
747
    
748
    /**
749
     * minimum bitrate.
750
     * - encoding: set by user.
751
     * - decoding: unused
752
     */
753
    int rc_min_rate;
754
    
755
    /**
756
     * decoder bitstream buffer size.
757
     * - encoding: set by user.
758
     * - decoding: unused
759
     */
760
    int rc_buffer_size;
761
    float rc_buffer_aggressivity;
762

    
763
    /**
764
     * qscale factor between p and i frames.
765
     * - encoding: set by user.
766
     * - decoding: unused
767
     */
768
    float i_quant_factor;
769
    
770
    /**
771
     * qscale offset between p and i frames.
772
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
773
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
774
     * - encoding: set by user.
775
     * - decoding: unused
776
     */
777
    float i_quant_offset;
778
    
779
    /**
780
     * initial complexity for pass1 ratecontrol.
781
     * - encoding: set by user.
782
     * - decoding: unused
783
     */
784
    float rc_initial_cplx;
785

    
786
    /**
787
     * dct algorithm, see FF_DCT_* below.
788
     * - encoding: set by user
789
     * - decoding: unused
790
     */
791
    int dct_algo;
792
#define FF_DCT_AUTO    0
793
#define FF_DCT_FASTINT 1
794
#define FF_DCT_INT     2
795
#define FF_DCT_MMX     3
796
#define FF_DCT_MLIB    4
797
#define FF_DCT_ALTIVEC 5
798
    
799
    /**
800
     * luminance masking (0-> disabled).
801
     * - encoding: set by user
802
     * - decoding: unused
803
     */
804
    float lumi_masking;
805
    
806
    /**
807
     * temporary complexity masking (0-> disabled).
808
     * - encoding: set by user
809
     * - decoding: unused
810
     */
811
    float temporal_cplx_masking;
812
    
813
    /**
814
     * spatial complexity masking (0-> disabled).
815
     * - encoding: set by user
816
     * - decoding: unused
817
     */
818
    float spatial_cplx_masking;
819
    
820
    /**
821
     * p block masking (0-> disabled).
822
     * - encoding: set by user
823
     * - decoding: unused
824
     */
825
    float p_masking;
826

    
827
    /**
828
     * darkness masking (0-> disabled).
829
     * - encoding: set by user
830
     * - decoding: unused
831
     */
832
    float dark_masking;
833
    
834
    
835
    /* for binary compatibility */
836
    int unused;
837
    
838
    /**
839
     * idct algorithm, see FF_IDCT_* below.
840
     * - encoding: set by user
841
     * - decoding: set by user
842
     */
843
    int idct_algo;
844
#define FF_IDCT_AUTO         0
845
#define FF_IDCT_INT          1
846
#define FF_IDCT_SIMPLE       2
847
#define FF_IDCT_SIMPLEMMX    3
848
#define FF_IDCT_LIBMPEG2MMX  4
849
#define FF_IDCT_PS2          5
850
#define FF_IDCT_MLIB         6
851
#define FF_IDCT_ARM          7
852
#define FF_IDCT_ALTIVEC      8
853
#define FF_IDCT_SH4          9
854

    
855
    /**
856
     * slice count.
857
     * - encoding: set by lavc
858
     * - decoding: set by user (or 0)
859
     */
860
    int slice_count;
861
    /**
862
     * slice offsets in the frame in bytes.
863
     * - encoding: set/allocated by lavc
864
     * - decoding: set/allocated by user (or NULL)
865
     */
866
    int *slice_offset;
867

    
868
    /**
869
     * error concealment flags.
870
     * - encoding: unused
871
     * - decoding: set by user
872
     */
873
    int error_concealment;
874
#define FF_EC_GUESS_MVS   1
875
#define FF_EC_DEBLOCK     2
876

    
877
    /**
878
     * dsp_mask could be add used to disable unwanted CPU features
879
     * CPU features (i.e. MMX, SSE. ...)
880
     *
881
     * with FORCE flag you may instead enable given CPU features
882
     * (Dangerous: usable in case of misdetection, improper usage however will
883
     * result into program crash)
884
     */
885
    unsigned dsp_mask;
886
#define FF_MM_FORCE        0x80000000 /* force usage of selected flags (OR) */
887
    /* lower 16 bits - CPU features */
888
#ifdef HAVE_MMX
889
#define FF_MM_MMX        0x0001 /* standard MMX */
890
#define FF_MM_3DNOW        0x0004 /* AMD 3DNOW */
891
#define FF_MM_MMXEXT        0x0002 /* SSE integer functions or AMD MMX ext */
892
#define FF_MM_SSE        0x0008 /* SSE functions */
893
#define FF_MM_SSE2        0x0010 /* PIV SSE2 functions */
894
#endif /* HAVE_MMX */
895

    
896
    /**
897
     * bits per sample/pixel from the demuxer (needed for huffyuv).
898
     * - encoding: set by lavc
899
     * - decoding: set by user
900
     */
901
     int bits_per_sample;
902
    
903
    /**
904
     * prediction method (needed for huffyuv).
905
     * - encoding: set by user
906
     * - decoding: unused
907
     */
908
     int prediction_method;
909
#define FF_PRED_LEFT   0
910
#define FF_PRED_PLANE  1
911
#define FF_PRED_MEDIAN 2
912
    
913
    /**
914
     * aspect ratio (0 if unknown).
915
     * - encoding: set by user.
916
     * - decoding: set by lavc.
917
     */
918
    float aspect_ratio;
919

    
920
    /**
921
     * the picture in the bitstream.
922
     * - encoding: set by lavc
923
     * - decoding: set by lavc
924
     */
925
    AVFrame *coded_frame;
926

    
927
    /**
928
     * debug.
929
     * - encoding: set by user.
930
     * - decoding: set by user.
931
     */
932
    int debug;
933
#define FF_DEBUG_PICT_INFO 1
934
#define FF_DEBUG_RC        2
935
#define FF_DEBUG_BITSTREAM 4
936
#define FF_DEBUG_MB_TYPE   8
937
#define FF_DEBUG_QP        16
938
#define FF_DEBUG_MV        32
939
#define FF_DEBUG_VIS_MV    0x00000040
940
#define FF_DEBUG_SKIP      0x00000080
941
#define FF_DEBUG_STARTCODE 0x00000100
942
#define FF_DEBUG_PTS       0x00000200
943
#define FF_DEBUG_ER        0x00000400
944
#define FF_DEBUG_MMCO      0x00000800
945
    
946
    /**
947
     * error.
948
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
949
     * - decoding: unused
950
     */
951
    uint64_t error[4];
952
    
953
    /**
954
     * minimum MB quantizer.
955
     * - encoding: set by user.
956
     * - decoding: unused
957
     */
958
    int mb_qmin;
959

    
960
    /**
961
     * maximum MB quantizer.
962
     * - encoding: set by user.
963
     * - decoding: unused
964
     */
965
    int mb_qmax;
966
    
967
    /**
968
     * motion estimation compare function.
969
     * - encoding: set by user.
970
     * - decoding: unused
971
     */
972
    int me_cmp;
973
    /**
974
     * subpixel motion estimation compare function.
975
     * - encoding: set by user.
976
     * - decoding: unused
977
     */
978
    int me_sub_cmp;
979
    /**
980
     * macroblock compare function (not supported yet).
981
     * - encoding: set by user.
982
     * - decoding: unused
983
     */
984
    int mb_cmp;
985
#define FF_CMP_SAD  0
986
#define FF_CMP_SSE  1
987
#define FF_CMP_SATD 2
988
#define FF_CMP_DCT  3
989
#define FF_CMP_PSNR 4
990
#define FF_CMP_BIT  5
991
#define FF_CMP_RD   6
992
#define FF_CMP_ZERO 7
993
#define FF_CMP_CHROMA 256
994
    
995
    /**
996
     * ME diamond size & shape.
997
     * - encoding: set by user.
998
     * - decoding: unused
999
     */
1000
    int dia_size;
1001

    
1002
    /**
1003
     * amount of previous MV predictors (2a+1 x 2a+1 square).
1004
     * - encoding: set by user.
1005
     * - decoding: unused
1006
     */
1007
    int last_predictor_count;
1008

    
1009
    /**
1010
     * pre pass for motion estimation.
1011
     * - encoding: set by user.
1012
     * - decoding: unused
1013
     */
1014
    int pre_me;
1015

    
1016
    /**
1017
     * motion estimation pre pass compare function.
1018
     * - encoding: set by user.
1019
     * - decoding: unused
1020
     */
1021
    int me_pre_cmp;
1022

    
1023
    /**
1024
     * ME pre pass diamond size & shape.
1025
     * - encoding: set by user.
1026
     * - decoding: unused
1027
     */
1028
    int pre_dia_size;
1029

    
1030
    /**
1031
     * subpel ME quality.
1032
     * - encoding: set by user.
1033
     * - decoding: unused
1034
     */
1035
    int me_subpel_quality;
1036

    
1037
    /**
1038
     * callback to negotiate the pixelFormat.
1039
     * @param fmt is the list of formats which are supported by the codec,
1040
     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1041
     * the first is allways the native one
1042
     * @return the choosen format
1043
     * - encoding: unused
1044
     * - decoding: set by user, if not set then the native format will always be choosen
1045
     */
1046
    enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1047

    
1048
    /**
1049
     * DTG active format information (additionnal aspect ratio
1050
     * information only used in DVB MPEG2 transport streams). 0 if
1051
     * not set.
1052
     * 
1053
     * - encoding: unused.
1054
     * - decoding: set by decoder 
1055
     */
1056
    int dtg_active_format;
1057
#define FF_DTG_AFD_SAME         8
1058
#define FF_DTG_AFD_4_3          9
1059
#define FF_DTG_AFD_16_9         10
1060
#define FF_DTG_AFD_14_9         11
1061
#define FF_DTG_AFD_4_3_SP_14_9  13
1062
#define FF_DTG_AFD_16_9_SP_14_9 14
1063
#define FF_DTG_AFD_SP_4_3       15
1064

    
1065
    /**
1066
     * Maximum motion estimation search range in subpel units.
1067
     * if 0 then no limit
1068
     * 
1069
     * - encoding: set by user.
1070
     * - decoding: unused.
1071
     */
1072
    int me_range;
1073

    
1074
    /**
1075
     * frame_rate_base.
1076
     * for variable fps this is 1
1077
     * - encoding: set by user.
1078
     * - decoding: set by lavc.
1079
     * @todo move this after frame_rate
1080
     */
1081

    
1082
    int frame_rate_base;
1083
    /**
1084
     * intra quantizer bias.
1085
     * - encoding: set by user.
1086
     * - decoding: unused
1087
     */
1088
    int intra_quant_bias;
1089
#define FF_DEFAULT_QUANT_BIAS 999999
1090
    
1091
    /**
1092
     * inter quantizer bias.
1093
     * - encoding: set by user.
1094
     * - decoding: unused
1095
     */
1096
    int inter_quant_bias;
1097

    
1098
    /**
1099
     * color table ID.
1100
     * - encoding: unused.
1101
     * - decoding: which clrtable should be used for 8bit RGB images
1102
     *             table have to be stored somewhere FIXME
1103
     */
1104
    int color_table_id;
1105
    
1106
    /**
1107
     * internal_buffer count. 
1108
     * Dont touch, used by lavc default_get_buffer()
1109
     */
1110
    int internal_buffer_count;
1111
    
1112
    /**
1113
     * internal_buffers. 
1114
     * Dont touch, used by lavc default_get_buffer()
1115
     */
1116
    void *internal_buffer;
1117
    
1118
#define FF_QUALITY_SCALE 256
1119
    /**
1120
     * global quality for codecs which cannot change it per frame.
1121
     * this should be proportional to MPEG1/2/4 qscale.
1122
     * - encoding: set by user.
1123
     * - decoding: unused
1124
     */
1125
    int global_quality;
1126
} AVCodecContext;
1127

    
1128

    
1129
/**
1130
 * AVOption.
1131
 */
1132
typedef struct AVOption {
1133
    /** options' name */
1134
    const char *name; /* if name is NULL, it indicates a link to next */
1135
    /** short English text help or const struct AVOption* subpointer */
1136
    const char *help; //        const struct AVOption* sub;
1137
    /** offset to context structure where the parsed value should be stored */
1138
    int offset;
1139
    /** options' type */
1140
    int type;
1141
#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
1142
#define FF_OPT_TYPE_DOUBLE 2    ///< double
1143
#define FF_OPT_TYPE_INT 3       ///< integer
1144
#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
1145
#define FF_OPT_TYPE_MASK 0x1f        ///< mask for types - upper bits are various flags
1146
//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1147
#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1148
#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1149
    /** min value  (min == max   ->  no limits) */
1150
    double min;
1151
    /** maximum value for double/int */
1152
    double max;
1153
    /** default boo [0,1]l/double/int value */
1154
    double defval;
1155
    /**
1156
     * default string value (with optional semicolon delimited extra option-list
1157
     * i.e.   option1;option2;option3
1158
     * defval might select other then first argument as default
1159
     */
1160
    const char *defstr;
1161
#define FF_OPT_MAX_DEPTH 10
1162
} AVOption;
1163

    
1164
/**
1165
 * Parse option(s) and sets fields in passed structure
1166
 * @param strct        structure where the parsed results will be written
1167
 * @param list  list with AVOptions
1168
 * @param opts        string with options for parsing
1169
 */
1170
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1171

    
1172

    
1173
/**
1174
 * AVCodec.
1175
 */
1176
typedef struct AVCodec {
1177
    const char *name;
1178
    enum CodecType type;
1179
    int id;
1180
    int priv_data_size;
1181
    int (*init)(AVCodecContext *);
1182
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1183
    int (*close)(AVCodecContext *);
1184
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1185
                  uint8_t *buf, int buf_size);
1186
    int capabilities;
1187
    const AVOption *options;
1188
    struct AVCodec *next;
1189
} AVCodec;
1190

    
1191
/**
1192
 * four components are given, that's all.
1193
 * the last component is alpha
1194
 */
1195
typedef struct AVPicture {
1196
    uint8_t *data[4];
1197
    int linesize[4];
1198
} AVPicture;
1199

    
1200
extern AVCodec ac3_encoder;
1201
extern AVCodec mp2_encoder;
1202
extern AVCodec mp3lame_encoder;
1203
extern AVCodec oggvorbis_encoder;
1204
extern AVCodec mpeg1video_encoder;
1205
extern AVCodec h263_encoder;
1206
extern AVCodec h263p_encoder;
1207
extern AVCodec rv10_encoder;
1208
extern AVCodec mjpeg_encoder;
1209
extern AVCodec mpeg4_encoder;
1210
extern AVCodec msmpeg4v1_encoder;
1211
extern AVCodec msmpeg4v2_encoder;
1212
extern AVCodec msmpeg4v3_encoder;
1213
extern AVCodec wmv1_encoder;
1214
extern AVCodec wmv2_encoder;
1215
extern AVCodec huffyuv_encoder;
1216
extern AVCodec h264_encoder;
1217
extern AVCodec asv1_encoder;
1218

    
1219
extern AVCodec h263_decoder;
1220
extern AVCodec mpeg4_decoder;
1221
extern AVCodec msmpeg4v1_decoder;
1222
extern AVCodec msmpeg4v2_decoder;
1223
extern AVCodec msmpeg4v3_decoder;
1224
extern AVCodec wmv1_decoder;
1225
extern AVCodec wmv2_decoder;
1226
extern AVCodec mpeg_decoder;
1227
extern AVCodec h263i_decoder;
1228
extern AVCodec rv10_decoder;
1229
extern AVCodec svq1_decoder;
1230
extern AVCodec svq3_decoder;
1231
extern AVCodec dvvideo_decoder;
1232
extern AVCodec dvaudio_decoder;
1233
extern AVCodec wmav1_decoder;
1234
extern AVCodec wmav2_decoder;
1235
extern AVCodec mjpeg_decoder;
1236
extern AVCodec mjpegb_decoder;
1237
extern AVCodec mp2_decoder;
1238
extern AVCodec mp3_decoder;
1239
extern AVCodec mace3_decoder;
1240
extern AVCodec mace6_decoder;
1241
extern AVCodec huffyuv_decoder;
1242
extern AVCodec oggvorbis_decoder;
1243
extern AVCodec cyuv_decoder;
1244
extern AVCodec h264_decoder;
1245
extern AVCodec indeo3_decoder;
1246
extern AVCodec vp3_decoder;
1247
extern AVCodec amr_nb_decoder;
1248
extern AVCodec aac_decoder;
1249
extern AVCodec mpeg4aac_decoder;
1250
extern AVCodec asv1_decoder;
1251

    
1252
/* pcm codecs */
1253
#define PCM_CODEC(id, name) \
1254
extern AVCodec name ## _decoder; \
1255
extern AVCodec name ## _encoder
1256

    
1257
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1258
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1259
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1260
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1261
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1262
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1263
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1264
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1265

    
1266
/* adpcm codecs */
1267

    
1268
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1269
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1270
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1271

    
1272
#undef PCM_CODEC
1273

    
1274
/* dummy raw video codec */
1275
extern AVCodec rawvideo_encoder;
1276
extern AVCodec rawvideo_decoder;
1277

    
1278
/* the following codecs use external GPL libs */
1279
extern AVCodec ac3_decoder;
1280

    
1281
/* resample.c */
1282

    
1283
struct ReSampleContext;
1284

    
1285
typedef struct ReSampleContext ReSampleContext;
1286

    
1287
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1288
                                     int output_rate, int input_rate);
1289
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1290
void audio_resample_close(ReSampleContext *s);
1291

    
1292
/* YUV420 format is assumed ! */
1293

    
1294
struct ImgReSampleContext;
1295

    
1296
typedef struct ImgReSampleContext ImgReSampleContext;
1297

    
1298
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1299
                                      int input_width, int input_height);
1300

    
1301
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1302
                                      int iwidth, int iheight,
1303
                                      int topBand, int bottomBand,
1304
                                      int leftBand, int rightBand);
1305

    
1306
void img_resample(ImgReSampleContext *s, 
1307
                  AVPicture *output, AVPicture *input);
1308

    
1309
void img_resample_close(ImgReSampleContext *s);
1310

    
1311
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1312
                   int pix_fmt, int width, int height);
1313
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1314
                     unsigned char *dest, int dest_size);
1315
int avpicture_get_size(int pix_fmt, int width, int height);
1316
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1317
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1318
enum PixelFormat avcodec_get_pix_fmt(const char* name);
1319

    
1320
#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
1321
#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
1322
#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
1323
#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
1324
#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
1325
#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1326

    
1327
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1328
                             int has_alpha);
1329
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1330
                              int has_alpha, int *loss_ptr);
1331

    
1332
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1333
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1334
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1335

    
1336
/* convert among pixel formats */
1337
int img_convert(AVPicture *dst, int dst_pix_fmt,
1338
                AVPicture *src, int pix_fmt, 
1339
                int width, int height);
1340

    
1341
/* deinterlace a picture */
1342
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1343
                          int pix_fmt, int width, int height);
1344

    
1345
/* external high level API */
1346

    
1347
extern AVCodec *first_avcodec;
1348

    
1349
/* returns LIBAVCODEC_VERSION_INT constant */
1350
unsigned avcodec_version(void);
1351
/* returns LIBAVCODEC_BUILD constant */
1352
unsigned avcodec_build(void);
1353
void avcodec_init(void);
1354

    
1355
void register_avcodec(AVCodec *format);
1356
AVCodec *avcodec_find_encoder(enum CodecID id);
1357
AVCodec *avcodec_find_encoder_by_name(const char *name);
1358
AVCodec *avcodec_find_decoder(enum CodecID id);
1359
AVCodec *avcodec_find_decoder_by_name(const char *name);
1360
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1361

    
1362
void avcodec_get_context_defaults(AVCodecContext *s);
1363
AVCodecContext *avcodec_alloc_context(void);
1364
AVFrame *avcodec_alloc_frame(void);
1365

    
1366
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1367
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1368
void avcodec_default_free_buffers(AVCodecContext *s);
1369

    
1370
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1371
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1372
                         int *frame_size_ptr,
1373
                         uint8_t *buf, int buf_size);
1374
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1375
                         int *got_picture_ptr,
1376
                         uint8_t *buf, int buf_size);
1377
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1378
                        int *data_size_ptr,
1379
                        uint8_t *buf, int buf_size);
1380
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1381
                         const short *samples);
1382
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1383
                         const AVFrame *pict);
1384

    
1385
int avcodec_close(AVCodecContext *avctx);
1386

    
1387
void avcodec_register_all(void);
1388

    
1389
void avcodec_flush_buffers(AVCodecContext *avctx);
1390

    
1391
/* misc usefull functions */
1392

    
1393
/**
1394
 * returns a single letter to describe the picture type
1395
 */
1396
char av_get_pict_type_char(int pict_type);
1397

    
1398
/**
1399
 * reduce a fraction.
1400
 * this is usefull for framerate calculations
1401
 * @param max the maximum allowed for dst_nom & dst_den
1402
 * @return 1 if exact, 0 otherwise
1403
 */
1404
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1405

    
1406
/**
1407
 * rescale a 64bit integer.
1408
 * a simple a*b/c isnt possible as it can overflow
1409
 */
1410
int64_t av_rescale(int64_t a, int b, int c);
1411

    
1412

    
1413
/**
1414
 * Interface for 0.5.0 version
1415
 *
1416
 * do not even think about it's usage for this moment
1417
 */
1418

    
1419
typedef struct {
1420
    /// compressed size used from given memory buffer
1421
    int size;
1422
    /// I/P/B frame type
1423
    int frame_type;
1424
} avc_enc_result_t;
1425

    
1426
/**
1427
 * Commands
1428
 * order can't be changed - once it was defined
1429
 */
1430
typedef enum {
1431
    // general commands
1432
    AVC_OPEN_BY_NAME = 0xACA000,
1433
    AVC_OPEN_BY_CODEC_ID,
1434
    AVC_OPEN_BY_FOURCC,
1435
    AVC_CLOSE,
1436

    
1437
    AVC_FLUSH,
1438
    // pin - struct { uint8_t* src, uint_t src_size }
1439
    // pout - struct { AVPicture* img, consumed_bytes,
1440
    AVC_DECODE,
1441
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1442
    // pout - uint_t used_from_dest_size
1443
    AVC_ENCODE, 
1444

    
1445
    // query/get video commands
1446
    AVC_GET_VERSION = 0xACB000,
1447
    AVC_GET_WIDTH,
1448
    AVC_GET_HEIGHT,
1449
    AVC_GET_DELAY,
1450
    AVC_GET_QUANT_TABLE,
1451
    // ...
1452

    
1453
    // query/get audio commands
1454
    AVC_GET_FRAME_SIZE = 0xABC000,
1455

    
1456
    // maybe define some simple structure which
1457
    // might be passed to the user - but they can't
1458
    // contain any codec specific parts and these
1459
    // calls are usualy necessary only few times
1460

    
1461
    // set video commands
1462
    AVC_SET_WIDTH = 0xACD000,
1463
    AVC_SET_HEIGHT,
1464

    
1465
    // set video encoding commands
1466
    AVC_SET_FRAME_RATE = 0xACD800,
1467
    AVC_SET_QUALITY,
1468
    AVC_SET_HURRY_UP,
1469

    
1470
    // set audio commands
1471
    AVC_SET_SAMPLE_RATE = 0xACE000,
1472
    AVC_SET_CHANNELS,
1473

    
1474
} avc_cmd_t;
1475

    
1476
/**
1477
 * \param handle  allocated private structure by libavcodec
1478
 *                for initialization pass NULL - will be returned pout
1479
 *                user is supposed to know nothing about its structure
1480
 * \param cmd     type of operation to be performed
1481
 * \param pint    input parameter
1482
 * \param pout    output parameter
1483
 *
1484
 * \returns  command status - eventually for query command it might return
1485
 * integer resulting value
1486
 */
1487
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1488

    
1489
/* memory */
1490
void *av_malloc(unsigned int size);
1491
void *av_mallocz(unsigned int size);
1492
void *av_realloc(void *ptr, unsigned int size);
1493
void av_free(void *ptr);
1494
char *av_strdup(const char *s);
1495
void __av_freep(void **ptr);
1496
#define av_freep(p) __av_freep((void **)(p))
1497
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1498
/* for static data only */
1499
/* call av_free_static to release all staticaly allocated tables */
1500
void av_free_static(void);
1501
void *__av_mallocz_static(void** location, unsigned int size);
1502
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1503

    
1504
#ifdef __cplusplus
1505
}
1506
#endif
1507

    
1508
#endif /* AVCODEC_H */