Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ b82cdc72

History | View | Annotate | Download (41.4 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       4666
19
#define LIBAVCODEC_BUILD_STR   "4666"
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

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

    
69
    /* various adpcm codecs */
70
    CODEC_ID_ADPCM_IMA_QT,
71
    CODEC_ID_ADPCM_IMA_WAV,
72
    CODEC_ID_ADPCM_MS,
73

    
74
        /* AMR */
75
    CODEC_ID_AMR_NB,
76
};
77

    
78
enum CodecType {
79
    CODEC_TYPE_UNKNOWN = -1,
80
    CODEC_TYPE_VIDEO,
81
    CODEC_TYPE_AUDIO,
82
};
83

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

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

    
114
/* in bytes */
115
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
116

    
117
/**
118
 * Required number of zero bytes at the end of the input bitstream for decoding.
119
 * to avoid overreading (and possibly segfaulting)
120
 */
121
#define FF_INPUT_BUFFER_PADDING_SIZE 8
122

    
123
/* motion estimation type, EPZS by default */
124
enum Motion_Est_ID {
125
    ME_ZERO = 1,
126
    ME_FULL,
127
    ME_LOG,
128
    ME_PHODS,
129
    ME_EPZS,
130
    ME_X1
131
};
132

    
133
typedef struct RcOverride{
134
    int start_frame;
135
    int end_frame;
136
    int qscale; // if this is 0 then quality_factor will be used instead
137
    float quality_factor;
138
} RcOverride;
139

    
140
/* only for ME compatiblity with old apps */
141
extern int motion_estimation_method;
142

    
143
/* ME algos sorted by quality */
144
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
145
                                       ME_X1, ME_EPZS, ME_FULL };
146

    
147

    
148
#define FF_MAX_B_FRAMES 8
149

    
150
/* encoding support
151
   these flags can be passed in AVCodecContext.flags before initing 
152
   Note: note not everything is supported yet 
153
*/
154

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

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

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

    
334
#define FF_QSCALE_TYPE_MPEG1        0
335
#define FF_QSCALE_TYPE_MPEG2        1
336

    
337
#define FF_BUFFER_TYPE_INTERNAL 1
338
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers
339
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc
340

    
341

    
342
#define FF_I_TYPE 1 // Intra
343
#define FF_P_TYPE 2 // Predicted
344
#define FF_B_TYPE 3 // Bi-dir predicted
345
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
346
#define FF_SI_TYPE 5
347
#define FF_SP_TYPE 6
348

    
349
/**
350
 * Audio Video Frame.
351
 */
352
typedef struct AVFrame {
353
    FF_COMMON_FRAME
354
} AVFrame;
355

    
356
#define DEFAULT_FRAME_RATE_BASE 1001000
357

    
358
/**
359
 * main external api structure.
360
 */
361
typedef struct AVCodecContext {
362
    /**
363
     * the average bitrate.
364
     * - encoding: set by user. unused for constant quantizer encoding
365
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
366
     */
367
    int bit_rate;
368

    
369
    /**
370
     * number of bits the bitstream is allowed to diverge from the reference.
371
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
372
     * - encoding: set by user. unused for constant quantizer encoding
373
     * - decoding: unused
374
     */
375
    int bit_rate_tolerance; 
376

    
377
    /**
378
     * CODEC_FLAG_*.
379
     * - encoding: set by user.
380
     * - decoding: set by user.
381
     */
382
    int flags;
383

    
384
    /**
385
     * some codecs needs additionnal format info. It is stored here
386
     * - encoding: set by user. 
387
     * - decoding: set by lavc. (FIXME is this ok?)
388
     */
389
    int sub_id;
390

    
391
    /**
392
     * motion estimation algorithm used for video coding.
393
     * - encoding: MUST be set by user.
394
     * - decoding: unused
395
     */
396
    int me_method;
397

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

    
433
    /**
434
     * the number of pictures in a group of pitures, or 0 for intra_only.
435
     * - encoding: set by user.
436
     * - decoding: unused
437
     */
438
    int gop_size;
439

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

    
467
    /* audio only */
468
    int sample_rate; ///< samples per sec 
469
    int channels;
470
    int sample_fmt;  ///< sample format, currenly unused 
471

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

    
496
    /**
497
     * maximum quantizer.
498
     * - encoding: set by user.
499
     * - decoding: unused
500
     */
501
    int qmax;
502

    
503
    /**
504
     * maximum quantizer difference etween frames.
505
     * - encoding: set by user.
506
     * - decoding: unused
507
     */
508
    int max_qdiff;
509

    
510
    /**
511
     * maximum number of b frames between non b frames.
512
     * note: the output will be delayed by max_b_frames+1 relative to the input
513
     * - encoding: set by user.
514
     * - decoding: unused
515
     */
516
    int max_b_frames;
517

    
518
    /**
519
     * qscale factor between ip and b frames.
520
     * - encoding: set by user.
521
     * - decoding: unused
522
     */
523
    float b_quant_factor;
524
    
525
    /** obsolete FIXME remove */
526
    int rc_strategy;
527
    int b_frame_strategy;
528

    
529
    /**
530
     * hurry up amount.
531
     * - encoding: unused
532
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
533
     */
534
    int hurry_up;
535
    
536
    struct AVCodec *codec;
537
    
538
    void *priv_data;
539

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

    
553
    
554
    /* The RTP callcack: This function is called  */
555
    /* every time the encoder as a packet to send */
556
    /* Depends on the encoder if the data starts  */
557
    /* with a Start Code (it should) H.263 does   */
558
    void (*rtp_callback)(void *data, int size, int packet_number); 
559

    
560
    /* statistics, used for 2-pass encoding */
561
    int mv_bits;
562
    int header_bits;
563
    int i_tex_bits;
564
    int p_tex_bits;
565
    int i_count;
566
    int p_count;
567
    int skip_count;
568
    int misc_bits;
569
    
570
    /**
571
     * number of bits used for the previously encoded frame.
572
     * - encoding: set by lavc
573
     * - decoding: unused
574
     */
575
    int frame_bits;
576

    
577
    /**
578
     * private data of the user, can be used to carry app specific stuff.
579
     * - encoding: set by user
580
     * - decoding: set by user
581
     */
582
    void *opaque;
583

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

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

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

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

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

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

    
849
    /**
850
     * slice count.
851
     * - encoding: set by lavc
852
     * - decoding: set by user (or 0)
853
     */
854
    int slice_count;
855
    /**
856
     * slice offsets in the frame in bytes.
857
     * - encoding: set/allocated by lavc
858
     * - decoding: set/allocated by user (or NULL)
859
     */
860
    int *slice_offset;
861

    
862
    /**
863
     * error concealment flags.
864
     * - encoding: unused
865
     * - decoding: set by user
866
     */
867
    int error_concealment;
868
#define FF_EC_GUESS_MVS   1
869
#define FF_EC_DEBLOCK     2
870

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

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

    
914
    /**
915
     * the picture in the bitstream.
916
     * - encoding: set by lavc
917
     * - decoding: set by lavc
918
     */
919
    AVFrame *coded_frame;
920

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

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

    
996
    /**
997
     * amount of previous MV predictors (2a+1 x 2a+1 square).
998
     * - encoding: set by user.
999
     * - decoding: unused
1000
     */
1001
    int last_predictor_count;
1002

    
1003
    /**
1004
     * pre pass for motion estimation.
1005
     * - encoding: set by user.
1006
     * - decoding: unused
1007
     */
1008
    int pre_me;
1009

    
1010
    /**
1011
     * motion estimation pre pass compare function.
1012
     * - encoding: set by user.
1013
     * - decoding: unused
1014
     */
1015
    int me_pre_cmp;
1016

    
1017
    /**
1018
     * ME pre pass diamond size & shape.
1019
     * - encoding: set by user.
1020
     * - decoding: unused
1021
     */
1022
    int pre_dia_size;
1023

    
1024
    /**
1025
     * subpel ME quality.
1026
     * - encoding: set by user.
1027
     * - decoding: unused
1028
     */
1029
    int me_subpel_quality;
1030

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

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

    
1059
    /**
1060
     * Maximum motion estimation search range in subpel units.
1061
     * if 0 then no limit
1062
     * 
1063
     * - encoding: set by user.
1064
     * - decoding: unused.
1065
     */
1066
    int me_range;
1067

    
1068
    /**
1069
     * frame_rate_base.
1070
     * for variable fps this is 1
1071
     * - encoding: set by user.
1072
     * - decoding: set by lavc.
1073
     * @todo move this after frame_rate
1074
     */
1075

    
1076
    int frame_rate_base;
1077
    /**
1078
     * intra quantizer bias.
1079
     * - encoding: set by user.
1080
     * - decoding: unused
1081
     */
1082
    int intra_quant_bias;
1083
#define FF_DEFAULT_QUANT_BIAS 999999
1084
    
1085
    /**
1086
     * inter quantizer bias.
1087
     * - encoding: set by user.
1088
     * - decoding: unused
1089
     */
1090
    int inter_quant_bias;
1091

    
1092
    /**
1093
     * color table ID.
1094
     * - encoding: unused.
1095
     * - decoding: which clrtable should be used for 8bit RGB images
1096
     *             table have to be stored somewhere FIXME
1097
     */
1098
    int color_table_id;
1099
    
1100
    /**
1101
     * internal_buffer count. 
1102
     * Dont touch, used by lavc default_get_buffer()
1103
     */
1104
    int internal_buffer_count;
1105
    
1106
    /**
1107
     * internal_buffers. 
1108
     * Dont touch, used by lavc default_get_buffer()
1109
     */
1110
    void *internal_buffer;
1111
} AVCodecContext;
1112

    
1113

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

    
1149
/**
1150
 * Parse option(s) and sets fields in passed structure
1151
 * @param strct        structure where the parsed results will be written
1152
 * @param list  list with AVOptions
1153
 * @param opts        string with options for parsing
1154
 */
1155
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1156

    
1157

    
1158
/**
1159
 * AVCodec.
1160
 */
1161
typedef struct AVCodec {
1162
    const char *name;
1163
    enum CodecType type;
1164
    int id;
1165
    int priv_data_size;
1166
    int (*init)(AVCodecContext *);
1167
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1168
    int (*close)(AVCodecContext *);
1169
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1170
                  uint8_t *buf, int buf_size);
1171
    int capabilities;
1172
    const AVOption *options;
1173
    struct AVCodec *next;
1174
} AVCodec;
1175

    
1176
/**
1177
 * four components are given, that's all.
1178
 * the last component is alpha
1179
 */
1180
typedef struct AVPicture {
1181
    uint8_t *data[4];
1182
    int linesize[4];
1183
} AVPicture;
1184

    
1185
extern AVCodec ac3_encoder;
1186
extern AVCodec mp2_encoder;
1187
extern AVCodec mp3lame_encoder;
1188
extern AVCodec oggvorbis_encoder;
1189
extern AVCodec mpeg1video_encoder;
1190
extern AVCodec h263_encoder;
1191
extern AVCodec h263p_encoder;
1192
extern AVCodec rv10_encoder;
1193
extern AVCodec mjpeg_encoder;
1194
extern AVCodec mpeg4_encoder;
1195
extern AVCodec msmpeg4v1_encoder;
1196
extern AVCodec msmpeg4v2_encoder;
1197
extern AVCodec msmpeg4v3_encoder;
1198
extern AVCodec wmv1_encoder;
1199
extern AVCodec wmv2_encoder;
1200
extern AVCodec huffyuv_encoder;
1201
extern AVCodec h264_encoder;
1202

    
1203
extern AVCodec h263_decoder;
1204
extern AVCodec mpeg4_decoder;
1205
extern AVCodec msmpeg4v1_decoder;
1206
extern AVCodec msmpeg4v2_decoder;
1207
extern AVCodec msmpeg4v3_decoder;
1208
extern AVCodec wmv1_decoder;
1209
extern AVCodec wmv2_decoder;
1210
extern AVCodec mpeg_decoder;
1211
extern AVCodec h263i_decoder;
1212
extern AVCodec rv10_decoder;
1213
extern AVCodec svq1_decoder;
1214
extern AVCodec svq3_decoder;
1215
extern AVCodec dvvideo_decoder;
1216
extern AVCodec dvaudio_decoder;
1217
extern AVCodec wmav1_decoder;
1218
extern AVCodec wmav2_decoder;
1219
extern AVCodec mjpeg_decoder;
1220
extern AVCodec mjpegb_decoder;
1221
extern AVCodec mp2_decoder;
1222
extern AVCodec mp3_decoder;
1223
extern AVCodec mace3_decoder;
1224
extern AVCodec mace6_decoder;
1225
extern AVCodec huffyuv_decoder;
1226
extern AVCodec oggvorbis_decoder;
1227
extern AVCodec cyuv_decoder;
1228
extern AVCodec h264_decoder;
1229
extern AVCodec indeo3_decoder;
1230
extern AVCodec vp3_decoder;
1231
extern AVCodec amr_nb_decoder;
1232
extern AVCodec aac_decoder;
1233
extern AVCodec mpeg4aac_decoder;
1234

    
1235
/* pcm codecs */
1236
#define PCM_CODEC(id, name) \
1237
extern AVCodec name ## _decoder; \
1238
extern AVCodec name ## _encoder
1239

    
1240
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1241
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1242
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1243
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1244
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1245
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1246
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1247
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1248

    
1249
/* adpcm codecs */
1250

    
1251
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1252
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1253
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1254

    
1255
#undef PCM_CODEC
1256

    
1257
/* dummy raw video codec */
1258
extern AVCodec rawvideo_encoder;
1259
extern AVCodec rawvideo_decoder;
1260

    
1261
/* the following codecs use external GPL libs */
1262
extern AVCodec ac3_decoder;
1263

    
1264
/* resample.c */
1265

    
1266
struct ReSampleContext;
1267

    
1268
typedef struct ReSampleContext ReSampleContext;
1269

    
1270
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1271
                                     int output_rate, int input_rate);
1272
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1273
void audio_resample_close(ReSampleContext *s);
1274

    
1275
/* YUV420 format is assumed ! */
1276

    
1277
struct ImgReSampleContext;
1278

    
1279
typedef struct ImgReSampleContext ImgReSampleContext;
1280

    
1281
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1282
                                      int input_width, int input_height);
1283

    
1284
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1285
                                      int iwidth, int iheight,
1286
                                      int topBand, int bottomBand,
1287
                                      int leftBand, int rightBand);
1288

    
1289
void img_resample(ImgReSampleContext *s, 
1290
                  AVPicture *output, AVPicture *input);
1291

    
1292
void img_resample_close(ImgReSampleContext *s);
1293

    
1294
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1295
                   int pix_fmt, int width, int height);
1296
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1297
                     unsigned char *dest, int dest_size);
1298
int avpicture_get_size(int pix_fmt, int width, int height);
1299
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1300
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1301
enum PixelFormat avcodec_get_pix_fmt(const char* name);
1302

    
1303
#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
1304
#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
1305
#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
1306
#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
1307
#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
1308
#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1309

    
1310
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1311
                             int has_alpha);
1312
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1313
                              int has_alpha, int *loss_ptr);
1314

    
1315
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1316
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1317
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1318

    
1319
/* convert among pixel formats */
1320
int img_convert(AVPicture *dst, int dst_pix_fmt,
1321
                AVPicture *src, int pix_fmt, 
1322
                int width, int height);
1323

    
1324
/* deinterlace a picture */
1325
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1326
                          int pix_fmt, int width, int height);
1327

    
1328
/* external high level API */
1329

    
1330
extern AVCodec *first_avcodec;
1331

    
1332
/* returns LIBAVCODEC_VERSION_INT constant */
1333
unsigned avcodec_version(void);
1334
/* returns LIBAVCODEC_BUILD constant */
1335
unsigned avcodec_build(void);
1336
void avcodec_init(void);
1337

    
1338
void register_avcodec(AVCodec *format);
1339
AVCodec *avcodec_find_encoder(enum CodecID id);
1340
AVCodec *avcodec_find_encoder_by_name(const char *name);
1341
AVCodec *avcodec_find_decoder(enum CodecID id);
1342
AVCodec *avcodec_find_decoder_by_name(const char *name);
1343
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1344

    
1345
void avcodec_get_context_defaults(AVCodecContext *s);
1346
AVCodecContext *avcodec_alloc_context(void);
1347
AVFrame *avcodec_alloc_frame(void);
1348

    
1349
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1350
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1351
void avcodec_default_free_buffers(AVCodecContext *s);
1352

    
1353
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1354
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1355
                         int *frame_size_ptr,
1356
                         uint8_t *buf, int buf_size);
1357
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1358
                         int *got_picture_ptr,
1359
                         uint8_t *buf, int buf_size);
1360
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1361
                        int *data_size_ptr,
1362
                        uint8_t *buf, int buf_size);
1363
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1364
                         const short *samples);
1365
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1366
                         const AVFrame *pict);
1367

    
1368
int avcodec_close(AVCodecContext *avctx);
1369

    
1370
void avcodec_register_all(void);
1371

    
1372
void avcodec_flush_buffers(AVCodecContext *avctx);
1373

    
1374
/* misc usefull functions */
1375
/**
1376
 * reduce a fraction.
1377
 * this is usefull for framerate calculations
1378
 * @param max the maximum allowed for dst_nom & dst_den
1379
 * @return 1 if exact, 0 otherwise
1380
 */
1381
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1382

    
1383
/**
1384
 * rescale a 64bit integer.
1385
 * a simple a*b/c isnt possible as it can overflow
1386
 */
1387
int64_t av_rescale(int64_t a, int b, int c);
1388

    
1389

    
1390
/**
1391
 * Interface for 0.5.0 version
1392
 *
1393
 * do not even think about it's usage for this moment
1394
 */
1395

    
1396
typedef struct {
1397
    /// compressed size used from given memory buffer
1398
    int size;
1399
    /// I/P/B frame type
1400
    int frame_type;
1401
} avc_enc_result_t;
1402

    
1403
/**
1404
 * Commands
1405
 * order can't be changed - once it was defined
1406
 */
1407
typedef enum {
1408
    // general commands
1409
    AVC_OPEN_BY_NAME = 0xACA000,
1410
    AVC_OPEN_BY_CODEC_ID,
1411
    AVC_OPEN_BY_FOURCC,
1412
    AVC_CLOSE,
1413

    
1414
    AVC_FLUSH,
1415
    // pin - struct { uint8_t* src, uint_t src_size }
1416
    // pout - struct { AVPicture* img, consumed_bytes,
1417
    AVC_DECODE,
1418
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1419
    // pout - uint_t used_from_dest_size
1420
    AVC_ENCODE, 
1421

    
1422
    // query/get video commands
1423
    AVC_GET_VERSION = 0xACB000,
1424
    AVC_GET_WIDTH,
1425
    AVC_GET_HEIGHT,
1426
    AVC_GET_DELAY,
1427
    AVC_GET_QUANT_TABLE,
1428
    // ...
1429

    
1430
    // query/get audio commands
1431
    AVC_GET_FRAME_SIZE = 0xABC000,
1432

    
1433
    // maybe define some simple structure which
1434
    // might be passed to the user - but they can't
1435
    // contain any codec specific parts and these
1436
    // calls are usualy necessary only few times
1437

    
1438
    // set video commands
1439
    AVC_SET_WIDTH = 0xACD000,
1440
    AVC_SET_HEIGHT,
1441

    
1442
    // set video encoding commands
1443
    AVC_SET_FRAME_RATE = 0xACD800,
1444
    AVC_SET_QUALITY,
1445
    AVC_SET_HURRY_UP,
1446

    
1447
    // set audio commands
1448
    AVC_SET_SAMPLE_RATE = 0xACE000,
1449
    AVC_SET_CHANNELS,
1450

    
1451
} avc_cmd_t;
1452

    
1453
/**
1454
 * \param handle  allocated private structure by libavcodec
1455
 *                for initialization pass NULL - will be returned pout
1456
 *                user is supposed to know nothing about its structure
1457
 * \param cmd     type of operation to be performed
1458
 * \param pint    input parameter
1459
 * \param pout    output parameter
1460
 *
1461
 * \returns  command status - eventually for query command it might return
1462
 * integer resulting value
1463
 */
1464
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1465

    
1466
/* memory */
1467
void *av_malloc(unsigned int size);
1468
void *av_mallocz(unsigned int size);
1469
void *av_realloc(void *ptr, unsigned int size);
1470
void av_free(void *ptr);
1471
char *av_strdup(const char *s);
1472
void __av_freep(void **ptr);
1473
#define av_freep(p) __av_freep((void **)(p))
1474
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1475
/* for static data only */
1476
/* call av_free_static to release all staticaly allocated tables */
1477
void av_free_static(void);
1478
void *__av_mallocz_static(void** location, unsigned int size);
1479
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1480

    
1481
#ifdef __cplusplus
1482
}
1483
#endif
1484

    
1485
#endif /* AVCODEC_H */