Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ 029911d1

History | View | Annotate | Download (45.6 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       4676
19
#define LIBAVCODEC_BUILD_STR   "4676"
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_MPEG2VIDEO,
27
    CODEC_ID_MPEG2VIDEO_XVMC,
28
    CODEC_ID_H263,
29
    CODEC_ID_RV10,
30
    CODEC_ID_MP2,
31
    CODEC_ID_MP3LAME,
32
    CODEC_ID_VORBIS,
33
    CODEC_ID_AC3,
34
    CODEC_ID_MJPEG,
35
    CODEC_ID_MJPEGB,
36
    CODEC_ID_LJPEG,
37
    CODEC_ID_MPEG4,
38
    CODEC_ID_RAWVIDEO,
39
    CODEC_ID_MSMPEG4V1,
40
    CODEC_ID_MSMPEG4V2,
41
    CODEC_ID_MSMPEG4V3,
42
    CODEC_ID_WMV1,
43
    CODEC_ID_WMV2,
44
    CODEC_ID_H263P,
45
    CODEC_ID_H263I,
46
    CODEC_ID_FLV1,
47
    CODEC_ID_SVQ1,
48
    CODEC_ID_SVQ3,
49
    CODEC_ID_DVVIDEO,
50
    CODEC_ID_DVAUDIO,
51
    CODEC_ID_WMAV1,
52
    CODEC_ID_WMAV2,
53
    CODEC_ID_MACE3,
54
    CODEC_ID_MACE6,
55
    CODEC_ID_HUFFYUV,
56
    CODEC_ID_CYUV,
57
    CODEC_ID_H264,
58
    CODEC_ID_INDEO3,
59
    CODEC_ID_VP3,
60
    CODEC_ID_AAC,
61
    CODEC_ID_MPEG4AAC,
62
    CODEC_ID_ASV1,
63
    CODEC_ID_FFV1,
64
    CODEC_ID_4XM,
65
    CODEC_ID_VCR1,
66
    CODEC_ID_CLJR,
67
    CODEC_ID_MDEC,
68

    
69
    /* various pcm "codecs" */
70
    CODEC_ID_PCM_S16LE,
71
    CODEC_ID_PCM_S16BE,
72
    CODEC_ID_PCM_U16LE,
73
    CODEC_ID_PCM_U16BE,
74
    CODEC_ID_PCM_S8,
75
    CODEC_ID_PCM_U8,
76
    CODEC_ID_PCM_MULAW,
77
    CODEC_ID_PCM_ALAW,
78

    
79
    /* various adpcm codecs */
80
    CODEC_ID_ADPCM_IMA_QT,
81
    CODEC_ID_ADPCM_IMA_WAV,
82
    CODEC_ID_ADPCM_MS,
83
    CODEC_ID_ADPCM_4XM,
84

    
85
        /* AMR */
86
    CODEC_ID_AMR_NB,
87
    /* RealAudio codecs*/
88
    CODEC_ID_RA_144,
89
    CODEC_ID_RA_288,
90
};
91

    
92
enum CodecType {
93
    CODEC_TYPE_UNKNOWN = -1,
94
    CODEC_TYPE_VIDEO,
95
    CODEC_TYPE_AUDIO,
96
};
97

    
98
/**
99
 * Pixel format.
100
 */
101
enum PixelFormat {
102
    PIX_FMT_YUV420P,   ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples)
103
    PIX_FMT_YUV422,    
104
    PIX_FMT_RGB24,     ///< Packed pixel, 3 bytes per pixel, RGBRGB...
105
    PIX_FMT_BGR24,     ///< Packed pixel, 3 bytes per pixel, BGRBGR...
106
    PIX_FMT_YUV422P,   ///< Planar YUV 4:2:2 (1 Cr & Cb sample per 2x1 Y samples)
107
    PIX_FMT_YUV444P,   ///< Planar YUV 4:4:4 (1 Cr & Cb sample per 1x1 Y samples)
108
    PIX_FMT_RGBA32,    ///< Packed pixel, 4 bytes per pixel, BGRABGRA...
109
    PIX_FMT_YUV410P,   ///< Planar YUV 4:1:0 (1 Cr & Cb sample per 4x4 Y samples)
110
    PIX_FMT_YUV411P,   ///< Planar YUV 4:1:1 (1 Cr & Cb sample per 4x1 Y samples)
111
    PIX_FMT_RGB565,    ///< always stored in cpu endianness 
112
    PIX_FMT_RGB555,    ///< always stored in cpu endianness, most significant bit to 1 
113
    PIX_FMT_GRAY8,
114
    PIX_FMT_MONOWHITE, ///< 0 is white 
115
    PIX_FMT_MONOBLACK, ///< 0 is black 
116
    PIX_FMT_PAL8,      ///< 8 bit with RGBA palette 
117
    PIX_FMT_YUVJ420P,  ///< Planar YUV 4:2:0 full scale (jpeg)
118
    PIX_FMT_YUVJ422P,  ///< Planar YUV 4:2:2 full scale (jpeg)
119
    PIX_FMT_YUVJ444P,  ///< Planar YUV 4:4:4 full scale (jpeg)
120
    PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing(xvmc_render.h)
121
    PIX_FMT_XVMC_MPEG2_IDCT,
122
    PIX_FMT_NB,
123
};
124

    
125
/* currently unused, may be used if 24/32 bits samples ever supported */
126
enum SampleFormat {
127
    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
128
};
129

    
130
/* in bytes */
131
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
132

    
133
/**
134
 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
135
 * this is mainly needed because some optimized bitstream readers read 
136
 * 32 or 64 bit at once and could read over the end<br>
137
 * Note, if the first 23 bits of the additional bytes are not 0 then damaged
138
 * MPEG bitstreams could cause overread and segfault
139
 */
140
#define FF_INPUT_BUFFER_PADDING_SIZE 8
141

    
142
/* motion estimation type, EPZS by default */
143
enum Motion_Est_ID {
144
    ME_ZERO = 1,
145
    ME_FULL,
146
    ME_LOG,
147
    ME_PHODS,
148
    ME_EPZS,
149
    ME_X1
150
};
151

    
152
typedef struct RcOverride{
153
    int start_frame;
154
    int end_frame;
155
    int qscale; // if this is 0 then quality_factor will be used instead
156
    float quality_factor;
157
} RcOverride;
158

    
159
/* only for ME compatiblity with old apps */
160
extern int motion_estimation_method;
161

    
162
/* ME algos sorted by quality */
163
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
164
                                       ME_X1, ME_EPZS, ME_FULL };
165

    
166

    
167
#define FF_MAX_B_FRAMES 8
168

    
169
/* encoding support
170
   these flags can be passed in AVCodecContext.flags before initing 
171
   Note: note not everything is supported yet 
172
*/
173

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

    
212
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback 
213
/**
214
 * Codec uses get_buffer() for allocating buffers.
215
 * direct rendering method 1
216
 */
217
#define CODEC_CAP_DR1             0x0002
218
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
219
   used */
220
#define CODEC_CAP_PARSE_ONLY      0x0004
221
#define CODEC_CAP_TRUNCATED       0x0008
222

    
223

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

    
353
#define FF_QSCALE_TYPE_MPEG1        0
354
#define FF_QSCALE_TYPE_MPEG2        1
355

    
356
#define FF_BUFFER_TYPE_INTERNAL 1
357
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers
358
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc
359

    
360

    
361
#define FF_I_TYPE 1 // Intra
362
#define FF_P_TYPE 2 // Predicted
363
#define FF_B_TYPE 3 // Bi-dir predicted
364
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
365
#define FF_SI_TYPE 5
366
#define FF_SP_TYPE 6
367

    
368
/**
369
 * Audio Video Frame.
370
 */
371
typedef struct AVFrame {
372
    FF_COMMON_FRAME
373
} AVFrame;
374

    
375
#define DEFAULT_FRAME_RATE_BASE 1001000
376

    
377
/**
378
 * main external api structure.
379
 */
380
typedef struct AVCodecContext {
381
    /**
382
     * the average bitrate.
383
     * - encoding: set by user. unused for constant quantizer encoding
384
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
385
     */
386
    int bit_rate;
387

    
388
    /**
389
     * number of bits the bitstream is allowed to diverge from the reference.
390
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
391
     * - encoding: set by user. unused for constant quantizer encoding
392
     * - decoding: unused
393
     */
394
    int bit_rate_tolerance; 
395

    
396
    /**
397
     * CODEC_FLAG_*.
398
     * - encoding: set by user.
399
     * - decoding: set by user.
400
     */
401
    int flags;
402

    
403
    /**
404
     * some codecs needs additionnal format info. It is stored here
405
     * - encoding: set by user. 
406
     * - decoding: set by lavc. (FIXME is this ok?)
407
     */
408
    int sub_id;
409

    
410
    /**
411
     * motion estimation algorithm used for video coding.
412
     * - encoding: MUST be set by user.
413
     * - decoding: unused
414
     */
415
    int me_method;
416

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

    
452
    /**
453
     * the number of pictures in a group of pitures, or 0 for intra_only.
454
     * - encoding: set by user.
455
     * - decoding: unused
456
     */
457
    int gop_size;
458

    
459
    /**
460
     * pixel format, see PIX_FMT_xxx.
461
     * - encoding: FIXME: used by ffmpeg to decide whether an pix_fmt
462
     *                    conversion is in order. This only works for
463
     *                    codecs with one supported pix_fmt, we should
464
     *                    do something for a generic case as well.
465
     * - decoding: set by lavc.
466
     */
467
    enum PixelFormat pix_fmt; //FIXME move to AVFrme
468
 
469
    /**
470
     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
471
     * has to read frames at native frame rate.
472
     * - encoding: set by user.
473
     * - decoding: unused.
474
     */
475
    int rate_emu;
476
       
477
    /**
478
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
479
     * decoder to draw an horizontal band. It improve cache usage. Not
480
     * all codecs can do that. You must check the codec capabilities
481
     * before
482
     * - encoding: unused
483
     * - decoding: set by user.
484
     * @param height the height of the slice
485
     * @param y the y position of the slice
486
     * @param type 1->top field, 2->bottom field, 3->frame
487
     * @param offset offset into the AVFrame.data from which the slice should be read
488
     */
489
    void (*draw_horiz_band)(struct AVCodecContext *s,
490
                            AVFrame *src, int offset[4],
491
                            int y, int type, int height);
492

    
493
    /* audio only */
494
    int sample_rate; ///< samples per sec 
495
    int channels;
496
    int sample_fmt;  ///< sample format, currenly unused 
497

    
498
    /* the following data should not be initialized */
499
    int frame_size;     ///< in samples, initialized when calling 'init' 
500
    int frame_number;   ///< audio or video frame number 
501
    int real_pict_num;  ///< returns the real picture number of previous encoded frame 
502
    
503
    /**
504
     * number of frames the decoded output will be delayed relative to 
505
     * the encoded input.
506
     * - encoding: set by lavc.
507
     * - decoding: unused
508
     */
509
    int delay;
510
    
511
    /* - encoding parameters */
512
    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
513
    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
514
    
515
    /**
516
     * minimum quantizer.
517
     * - encoding: set by user.
518
     * - decoding: unused
519
     */
520
    int qmin;
521

    
522
    /**
523
     * maximum quantizer.
524
     * - encoding: set by user.
525
     * - decoding: unused
526
     */
527
    int qmax;
528

    
529
    /**
530
     * maximum quantizer difference etween frames.
531
     * - encoding: set by user.
532
     * - decoding: unused
533
     */
534
    int max_qdiff;
535

    
536
    /**
537
     * maximum number of b frames between non b frames.
538
     * note: the output will be delayed by max_b_frames+1 relative to the input
539
     * - encoding: set by user.
540
     * - decoding: unused
541
     */
542
    int max_b_frames;
543

    
544
    /**
545
     * qscale factor between ip and b frames.
546
     * - encoding: set by user.
547
     * - decoding: unused
548
     */
549
    float b_quant_factor;
550
    
551
    /** obsolete FIXME remove */
552
    int rc_strategy;
553
    int b_frame_strategy;
554

    
555
    /**
556
     * hurry up amount.
557
     * - encoding: unused
558
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
559
     */
560
    int hurry_up;
561
    
562
    struct AVCodec *codec;
563
    
564
    void *priv_data;
565

    
566
    /* The following data is for RTP friendly coding */
567
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
568
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
569
                    /* highers numbers represent more error-prone */
570
                    /* enviroments, by now just "1" exist         */
571
    
572
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
573
                            /* do it's best to deliver a chunk with size    */
574
                            /* below rtp_payload_size, the chunk will start */
575
                            /* with a start code on some codecs like H.263  */
576
                            /* This doesn't take account of any particular  */
577
                            /* headers inside the transmited RTP payload    */
578

    
579
    
580
    /* The RTP callcack: This function is called  */
581
    /* every time the encoder as a packet to send */
582
    /* Depends on the encoder if the data starts  */
583
    /* with a Start Code (it should) H.263 does   */
584
    void (*rtp_callback)(void *data, int size, int packet_number); 
585

    
586
    /* statistics, used for 2-pass encoding */
587
    int mv_bits;
588
    int header_bits;
589
    int i_tex_bits;
590
    int p_tex_bits;
591
    int i_count;
592
    int p_count;
593
    int skip_count;
594
    int misc_bits;
595
    
596
    /**
597
     * number of bits used for the previously encoded frame.
598
     * - encoding: set by lavc
599
     * - decoding: unused
600
     */
601
    int frame_bits;
602

    
603
    /**
604
     * private data of the user, can be used to carry app specific stuff.
605
     * - encoding: set by user
606
     * - decoding: set by user
607
     */
608
    void *opaque;
609

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

    
701
    /**
702
     * is 1 if the decoded stream contains b frames, 0 otherwise.
703
     * - encoding: unused
704
     * - decoding: set by lavc
705
     */
706
    int has_b_frames;
707
    
708
    int block_align; ///< used by some WAV based audio codecs
709
    
710
    int parse_only; /* - decoding only: if true, only parsing is done
711
                       (function avcodec_parse_frame()). The frame
712
                       data is returned. Only MPEG codecs support this now. */
713
    
714
    /**
715
     * 0-> default, 1-> mpeg quant.
716
     * - encoding: set by user.
717
     * - decoding: unused
718
     */
719
    int mpeg_quant;
720
    
721
    /**
722
     * pass1 encoding statistics output buffer.
723
     * - encoding: set by lavc
724
     * - decoding: unused
725
     */
726
    char *stats_out;
727
    
728
    /**
729
     * pass2 encoding statistics input buffer.
730
     * concatenated stuff from stats_out of pass1 should be placed here
731
     * - encoding: allocated/set/freed by user
732
     * - decoding: unused
733
     */
734
    char *stats_in;
735
    
736
    /**
737
     * ratecontrol qmin qmax limiting method.
738
     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
739
     * - encoding: set by user.
740
     * - decoding: unused
741
     */
742
    float rc_qsquish;
743

    
744
    float rc_qmod_amp;
745
    int rc_qmod_freq;
746
    
747
    /**
748
     * ratecontrol override, see RcOverride.
749
     * - encoding: allocated/set/freed by user.
750
     * - decoding: unused
751
     */
752
    RcOverride *rc_override;
753
    int rc_override_count;
754
    
755
    /**
756
     * rate control equation.
757
     * - encoding: set by user
758
     * - decoding: unused
759
     */
760
    char *rc_eq;
761
    
762
    /**
763
     * maximum bitrate.
764
     * - encoding: set by user.
765
     * - decoding: unused
766
     */
767
    int rc_max_rate;
768
    
769
    /**
770
     * minimum bitrate.
771
     * - encoding: set by user.
772
     * - decoding: unused
773
     */
774
    int rc_min_rate;
775
    
776
    /**
777
     * decoder bitstream buffer size.
778
     * - encoding: set by user.
779
     * - decoding: unused
780
     */
781
    int rc_buffer_size;
782
    float rc_buffer_aggressivity;
783

    
784
    /**
785
     * qscale factor between p and i frames.
786
     * - encoding: set by user.
787
     * - decoding: unused
788
     */
789
    float i_quant_factor;
790
    
791
    /**
792
     * qscale offset between p and i frames.
793
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
794
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
795
     * - encoding: set by user.
796
     * - decoding: unused
797
     */
798
    float i_quant_offset;
799
    
800
    /**
801
     * initial complexity for pass1 ratecontrol.
802
     * - encoding: set by user.
803
     * - decoding: unused
804
     */
805
    float rc_initial_cplx;
806

    
807
    /**
808
     * dct algorithm, see FF_DCT_* below.
809
     * - encoding: set by user
810
     * - decoding: unused
811
     */
812
    int dct_algo;
813
#define FF_DCT_AUTO    0
814
#define FF_DCT_FASTINT 1
815
#define FF_DCT_INT     2
816
#define FF_DCT_MMX     3
817
#define FF_DCT_MLIB    4
818
#define FF_DCT_ALTIVEC 5
819
    
820
    /**
821
     * luminance masking (0-> disabled).
822
     * - encoding: set by user
823
     * - decoding: unused
824
     */
825
    float lumi_masking;
826
    
827
    /**
828
     * temporary complexity masking (0-> disabled).
829
     * - encoding: set by user
830
     * - decoding: unused
831
     */
832
    float temporal_cplx_masking;
833
    
834
    /**
835
     * spatial complexity masking (0-> disabled).
836
     * - encoding: set by user
837
     * - decoding: unused
838
     */
839
    float spatial_cplx_masking;
840
    
841
    /**
842
     * p block masking (0-> disabled).
843
     * - encoding: set by user
844
     * - decoding: unused
845
     */
846
    float p_masking;
847

    
848
    /**
849
     * darkness masking (0-> disabled).
850
     * - encoding: set by user
851
     * - decoding: unused
852
     */
853
    float dark_masking;
854
    
855
    
856
    /* for binary compatibility */
857
    int unused;
858
    
859
    /**
860
     * idct algorithm, see FF_IDCT_* below.
861
     * - encoding: set by user
862
     * - decoding: set by user
863
     */
864
    int idct_algo;
865
#define FF_IDCT_AUTO         0
866
#define FF_IDCT_INT          1
867
#define FF_IDCT_SIMPLE       2
868
#define FF_IDCT_SIMPLEMMX    3
869
#define FF_IDCT_LIBMPEG2MMX  4
870
#define FF_IDCT_PS2          5
871
#define FF_IDCT_MLIB         6
872
#define FF_IDCT_ARM          7
873
#define FF_IDCT_ALTIVEC      8
874
#define FF_IDCT_SH4          9
875
#define FF_IDCT_SIMPLEARM    10
876

    
877
    /**
878
     * slice count.
879
     * - encoding: set by lavc
880
     * - decoding: set by user (or 0)
881
     */
882
    int slice_count;
883
    /**
884
     * slice offsets in the frame in bytes.
885
     * - encoding: set/allocated by lavc
886
     * - decoding: set/allocated by user (or NULL)
887
     */
888
    int *slice_offset;
889

    
890
    /**
891
     * error concealment flags.
892
     * - encoding: unused
893
     * - decoding: set by user
894
     */
895
    int error_concealment;
896
#define FF_EC_GUESS_MVS   1
897
#define FF_EC_DEBLOCK     2
898

    
899
    /**
900
     * dsp_mask could be add used to disable unwanted CPU features
901
     * CPU features (i.e. MMX, SSE. ...)
902
     *
903
     * with FORCE flag you may instead enable given CPU features
904
     * (Dangerous: usable in case of misdetection, improper usage however will
905
     * result into program crash)
906
     */
907
    unsigned dsp_mask;
908
#define FF_MM_FORCE        0x80000000 /* force usage of selected flags (OR) */
909
    /* lower 16 bits - CPU features */
910
#ifdef HAVE_MMX
911
#define FF_MM_MMX        0x0001 /* standard MMX */
912
#define FF_MM_3DNOW        0x0004 /* AMD 3DNOW */
913
#define FF_MM_MMXEXT        0x0002 /* SSE integer functions or AMD MMX ext */
914
#define FF_MM_SSE        0x0008 /* SSE functions */
915
#define FF_MM_SSE2        0x0010 /* PIV SSE2 functions */
916
#endif /* HAVE_MMX */
917

    
918
    /**
919
     * bits per sample/pixel from the demuxer (needed for huffyuv).
920
     * - encoding: set by lavc
921
     * - decoding: set by user
922
     */
923
     int bits_per_sample;
924
    
925
    /**
926
     * prediction method (needed for huffyuv).
927
     * - encoding: set by user
928
     * - decoding: unused
929
     */
930
     int prediction_method;
931
#define FF_PRED_LEFT   0
932
#define FF_PRED_PLANE  1
933
#define FF_PRED_MEDIAN 2
934
    
935
    /**
936
     * aspect ratio (0 if unknown).
937
     * - encoding: set by user.
938
     * - decoding: set by lavc.
939
     */
940
    float aspect_ratio;
941

    
942
    /**
943
     * the picture in the bitstream.
944
     * - encoding: set by lavc
945
     * - decoding: set by lavc
946
     */
947
    AVFrame *coded_frame;
948

    
949
    /**
950
     * debug.
951
     * - encoding: set by user.
952
     * - decoding: set by user.
953
     */
954
    int debug;
955
#define FF_DEBUG_PICT_INFO 1
956
#define FF_DEBUG_RC        2
957
#define FF_DEBUG_BITSTREAM 4
958
#define FF_DEBUG_MB_TYPE   8
959
#define FF_DEBUG_QP        16
960
#define FF_DEBUG_MV        32
961
#define FF_DEBUG_VIS_MV    0x00000040
962
#define FF_DEBUG_SKIP      0x00000080
963
#define FF_DEBUG_STARTCODE 0x00000100
964
#define FF_DEBUG_PTS       0x00000200
965
#define FF_DEBUG_ER        0x00000400
966
#define FF_DEBUG_MMCO      0x00000800
967
    
968
    /**
969
     * error.
970
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
971
     * - decoding: unused
972
     */
973
    uint64_t error[4];
974
    
975
    /**
976
     * minimum MB quantizer.
977
     * - encoding: set by user.
978
     * - decoding: unused
979
     */
980
    int mb_qmin;
981

    
982
    /**
983
     * maximum MB quantizer.
984
     * - encoding: set by user.
985
     * - decoding: unused
986
     */
987
    int mb_qmax;
988
    
989
    /**
990
     * motion estimation compare function.
991
     * - encoding: set by user.
992
     * - decoding: unused
993
     */
994
    int me_cmp;
995
    /**
996
     * subpixel motion estimation compare function.
997
     * - encoding: set by user.
998
     * - decoding: unused
999
     */
1000
    int me_sub_cmp;
1001
    /**
1002
     * macroblock compare function (not supported yet).
1003
     * - encoding: set by user.
1004
     * - decoding: unused
1005
     */
1006
    int mb_cmp;
1007
#define FF_CMP_SAD  0
1008
#define FF_CMP_SSE  1
1009
#define FF_CMP_SATD 2
1010
#define FF_CMP_DCT  3
1011
#define FF_CMP_PSNR 4
1012
#define FF_CMP_BIT  5
1013
#define FF_CMP_RD   6
1014
#define FF_CMP_ZERO 7
1015
#define FF_CMP_CHROMA 256
1016
    
1017
    /**
1018
     * ME diamond size & shape.
1019
     * - encoding: set by user.
1020
     * - decoding: unused
1021
     */
1022
    int dia_size;
1023

    
1024
    /**
1025
     * amount of previous MV predictors (2a+1 x 2a+1 square).
1026
     * - encoding: set by user.
1027
     * - decoding: unused
1028
     */
1029
    int last_predictor_count;
1030

    
1031
    /**
1032
     * pre pass for motion estimation.
1033
     * - encoding: set by user.
1034
     * - decoding: unused
1035
     */
1036
    int pre_me;
1037

    
1038
    /**
1039
     * motion estimation pre pass compare function.
1040
     * - encoding: set by user.
1041
     * - decoding: unused
1042
     */
1043
    int me_pre_cmp;
1044

    
1045
    /**
1046
     * ME pre pass diamond size & shape.
1047
     * - encoding: set by user.
1048
     * - decoding: unused
1049
     */
1050
    int pre_dia_size;
1051

    
1052
    /**
1053
     * subpel ME quality.
1054
     * - encoding: set by user.
1055
     * - decoding: unused
1056
     */
1057
    int me_subpel_quality;
1058

    
1059
    /**
1060
     * callback to negotiate the pixelFormat.
1061
     * @param fmt is the list of formats which are supported by the codec,
1062
     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1063
     * the first is allways the native one
1064
     * @return the choosen format
1065
     * - encoding: unused
1066
     * - decoding: set by user, if not set then the native format will always be choosen
1067
     */
1068
    enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1069

    
1070
    /**
1071
     * DTG active format information (additionnal aspect ratio
1072
     * information only used in DVB MPEG2 transport streams). 0 if
1073
     * not set.
1074
     * 
1075
     * - encoding: unused.
1076
     * - decoding: set by decoder 
1077
     */
1078
    int dtg_active_format;
1079
#define FF_DTG_AFD_SAME         8
1080
#define FF_DTG_AFD_4_3          9
1081
#define FF_DTG_AFD_16_9         10
1082
#define FF_DTG_AFD_14_9         11
1083
#define FF_DTG_AFD_4_3_SP_14_9  13
1084
#define FF_DTG_AFD_16_9_SP_14_9 14
1085
#define FF_DTG_AFD_SP_4_3       15
1086

    
1087
    /**
1088
     * Maximum motion estimation search range in subpel units.
1089
     * if 0 then no limit
1090
     * 
1091
     * - encoding: set by user.
1092
     * - decoding: unused.
1093
     */
1094
    int me_range;
1095

    
1096
    /**
1097
     * frame_rate_base.
1098
     * for variable fps this is 1
1099
     * - encoding: set by user.
1100
     * - decoding: set by lavc.
1101
     * @todo move this after frame_rate
1102
     */
1103

    
1104
    int frame_rate_base;
1105
    /**
1106
     * intra quantizer bias.
1107
     * - encoding: set by user.
1108
     * - decoding: unused
1109
     */
1110
    int intra_quant_bias;
1111
#define FF_DEFAULT_QUANT_BIAS 999999
1112
    
1113
    /**
1114
     * inter quantizer bias.
1115
     * - encoding: set by user.
1116
     * - decoding: unused
1117
     */
1118
    int inter_quant_bias;
1119

    
1120
    /**
1121
     * color table ID.
1122
     * - encoding: unused.
1123
     * - decoding: which clrtable should be used for 8bit RGB images
1124
     *             table have to be stored somewhere FIXME
1125
     */
1126
    int color_table_id;
1127
    
1128
    /**
1129
     * internal_buffer count. 
1130
     * Dont touch, used by lavc default_get_buffer()
1131
     */
1132
    int internal_buffer_count;
1133
    
1134
    /**
1135
     * internal_buffers. 
1136
     * Dont touch, used by lavc default_get_buffer()
1137
     */
1138
    void *internal_buffer;
1139
    
1140
#define FF_QUALITY_SCALE 256
1141
    /**
1142
     * global quality for codecs which cannot change it per frame.
1143
     * this should be proportional to MPEG1/2/4 qscale.
1144
     * - encoding: set by user.
1145
     * - decoding: unused
1146
     */
1147
    int global_quality;
1148
    
1149
#define FF_CODER_TYPE_VLC   0
1150
#define FF_CODER_TYPE_AC    1
1151
    /**
1152
     * coder type
1153
     * - encoding: set by user.
1154
     * - decoding: unused
1155
     */
1156
    int coder_type;
1157

    
1158
    /**
1159
     * context model
1160
     * - encoding: set by user.
1161
     * - decoding: unused
1162
     */
1163
    int context_model;
1164
    
1165
    /**
1166
     * slice flags
1167
     * - encoding: unused
1168
     * - decoding: set by user.
1169
     */
1170
    int slice_flags;
1171
#define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
1172
#define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1173
#define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1174

    
1175
    /**
1176
     * XVideo Motion Acceleration
1177
     * - encoding: forbidden
1178
     * - decoding: set by decoder
1179
     */
1180
    int xvmc_acceleration;
1181
    
1182
    /**
1183
     * macroblock decision mode
1184
     * - encoding: set by user.
1185
     * - decoding: unused
1186
     */
1187
    int mb_decision;
1188
#define FF_MB_DECISION_SIMPLE 0        ///< uses mb_cmp
1189
#define FF_MB_DECISION_BITS   1        ///< chooses the one which needs the fewest bits
1190
#define FF_MB_DECISION_RD     2        ///< rate distoration
1191

    
1192
    /**
1193
     * custom intra quantization matrix
1194
     * - encoding: set by user, can be NULL
1195
     * - decoding: set by lavc
1196
     */
1197
    uint16_t *intra_matrix;
1198

    
1199
    /**
1200
     * custom inter quantization matrix
1201
     * - encoding: set by user, can be NULL
1202
     * - decoding: set by lavc
1203
     */
1204
    uint16_t *inter_matrix;
1205
    
1206
} AVCodecContext;
1207

    
1208

    
1209
/**
1210
 * AVOption.
1211
 */
1212
typedef struct AVOption {
1213
    /** options' name */
1214
    const char *name; /* if name is NULL, it indicates a link to next */
1215
    /** short English text help or const struct AVOption* subpointer */
1216
    const char *help; //        const struct AVOption* sub;
1217
    /** offset to context structure where the parsed value should be stored */
1218
    int offset;
1219
    /** options' type */
1220
    int type;
1221
#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
1222
#define FF_OPT_TYPE_DOUBLE 2    ///< double
1223
#define FF_OPT_TYPE_INT 3       ///< integer
1224
#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
1225
#define FF_OPT_TYPE_MASK 0x1f        ///< mask for types - upper bits are various flags
1226
//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1227
#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1228
#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1229
    /** min value  (min == max   ->  no limits) */
1230
    double min;
1231
    /** maximum value for double/int */
1232
    double max;
1233
    /** default boo [0,1]l/double/int value */
1234
    double defval;
1235
    /**
1236
     * default string value (with optional semicolon delimited extra option-list
1237
     * i.e.   option1;option2;option3
1238
     * defval might select other then first argument as default
1239
     */
1240
    const char *defstr;
1241
#define FF_OPT_MAX_DEPTH 10
1242
} AVOption;
1243

    
1244
/**
1245
 * Parse option(s) and sets fields in passed structure
1246
 * @param strct        structure where the parsed results will be written
1247
 * @param list  list with AVOptions
1248
 * @param opts        string with options for parsing
1249
 */
1250
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1251

    
1252

    
1253
/**
1254
 * AVCodec.
1255
 */
1256
typedef struct AVCodec {
1257
    const char *name;
1258
    enum CodecType type;
1259
    int id;
1260
    int priv_data_size;
1261
    int (*init)(AVCodecContext *);
1262
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1263
    int (*close)(AVCodecContext *);
1264
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1265
                  uint8_t *buf, int buf_size);
1266
    int capabilities;
1267
    const AVOption *options;
1268
    struct AVCodec *next;
1269
    void (*flush)(AVCodecContext *);
1270
} AVCodec;
1271

    
1272
/**
1273
 * four components are given, that's all.
1274
 * the last component is alpha
1275
 */
1276
typedef struct AVPicture {
1277
    uint8_t *data[4];
1278
    int linesize[4];       ///< number of bytes per line
1279
} AVPicture;
1280

    
1281
extern AVCodec ac3_encoder;
1282
extern AVCodec mp2_encoder;
1283
extern AVCodec mp3lame_encoder;
1284
extern AVCodec oggvorbis_encoder;
1285
extern AVCodec mpeg1video_encoder;
1286
extern AVCodec mpeg2video_encoder;
1287
extern AVCodec h263_encoder;
1288
extern AVCodec h263p_encoder;
1289
extern AVCodec flv_encoder;
1290
extern AVCodec rv10_encoder;
1291
extern AVCodec mjpeg_encoder;
1292
extern AVCodec ljpeg_encoder;
1293
extern AVCodec mpeg4_encoder;
1294
extern AVCodec msmpeg4v1_encoder;
1295
extern AVCodec msmpeg4v2_encoder;
1296
extern AVCodec msmpeg4v3_encoder;
1297
extern AVCodec wmv1_encoder;
1298
extern AVCodec wmv2_encoder;
1299
extern AVCodec huffyuv_encoder;
1300
extern AVCodec h264_encoder;
1301
extern AVCodec asv1_encoder;
1302
extern AVCodec vcr1_encoder;
1303
extern AVCodec ffv1_encoder;
1304
extern AVCodec mdec_encoder;
1305

    
1306
extern AVCodec h263_decoder;
1307
extern AVCodec mpeg4_decoder;
1308
extern AVCodec msmpeg4v1_decoder;
1309
extern AVCodec msmpeg4v2_decoder;
1310
extern AVCodec msmpeg4v3_decoder;
1311
extern AVCodec wmv1_decoder;
1312
extern AVCodec wmv2_decoder;
1313
extern AVCodec mpeg_decoder;
1314
extern AVCodec mpeg_xvmc_decoder;
1315
extern AVCodec h263i_decoder;
1316
extern AVCodec flv_decoder;
1317
extern AVCodec rv10_decoder;
1318
extern AVCodec svq1_decoder;
1319
extern AVCodec svq3_decoder;
1320
extern AVCodec dvvideo_decoder;
1321
extern AVCodec dvaudio_decoder;
1322
extern AVCodec wmav1_decoder;
1323
extern AVCodec wmav2_decoder;
1324
extern AVCodec mjpeg_decoder;
1325
extern AVCodec mjpegb_decoder;
1326
extern AVCodec mp2_decoder;
1327
extern AVCodec mp3_decoder;
1328
extern AVCodec mace3_decoder;
1329
extern AVCodec mace6_decoder;
1330
extern AVCodec huffyuv_decoder;
1331
extern AVCodec oggvorbis_decoder;
1332
extern AVCodec cyuv_decoder;
1333
extern AVCodec h264_decoder;
1334
extern AVCodec indeo3_decoder;
1335
extern AVCodec vp3_decoder;
1336
extern AVCodec amr_nb_decoder;
1337
extern AVCodec amr_nb_encoder;
1338
extern AVCodec aac_decoder;
1339
extern AVCodec mpeg4aac_decoder;
1340
extern AVCodec asv1_decoder;
1341
extern AVCodec vcr1_decoder;
1342
extern AVCodec cljr_decoder;
1343
extern AVCodec ffv1_decoder;
1344
extern AVCodec fourxm_decoder;
1345
extern AVCodec mdec_decoder;
1346
extern AVCodec ra_144_decoder;
1347
extern AVCodec ra_288_decoder;
1348

    
1349
/* pcm codecs */
1350
#define PCM_CODEC(id, name) \
1351
extern AVCodec name ## _decoder; \
1352
extern AVCodec name ## _encoder
1353

    
1354
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1355
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1356
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1357
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1358
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1359
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1360
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1361
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1362

    
1363
/* adpcm codecs */
1364

    
1365
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1366
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1367
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1368
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1369

    
1370
#undef PCM_CODEC
1371

    
1372
/* dummy raw video codec */
1373
extern AVCodec rawvideo_encoder;
1374
extern AVCodec rawvideo_decoder;
1375

    
1376
/* the following codecs use external GPL libs */
1377
extern AVCodec ac3_decoder;
1378

    
1379
/* resample.c */
1380

    
1381
struct ReSampleContext;
1382

    
1383
typedef struct ReSampleContext ReSampleContext;
1384

    
1385
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1386
                                     int output_rate, int input_rate);
1387
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1388
void audio_resample_close(ReSampleContext *s);
1389

    
1390
/* YUV420 format is assumed ! */
1391

    
1392
struct ImgReSampleContext;
1393

    
1394
typedef struct ImgReSampleContext ImgReSampleContext;
1395

    
1396
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1397
                                      int input_width, int input_height);
1398

    
1399
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1400
                                      int iwidth, int iheight,
1401
                                      int topBand, int bottomBand,
1402
                                      int leftBand, int rightBand);
1403

    
1404
void img_resample(ImgReSampleContext *s, 
1405
                  AVPicture *output, AVPicture *input);
1406

    
1407
void img_resample_close(ImgReSampleContext *s);
1408

    
1409
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1410
                   int pix_fmt, int width, int height);
1411
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1412
                     unsigned char *dest, int dest_size);
1413
int avpicture_get_size(int pix_fmt, int width, int height);
1414
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1415
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1416
enum PixelFormat avcodec_get_pix_fmt(const char* name);
1417

    
1418
#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
1419
#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
1420
#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
1421
#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
1422
#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
1423
#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1424

    
1425
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1426
                             int has_alpha);
1427
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1428
                              int has_alpha, int *loss_ptr);
1429

    
1430
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1431
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1432
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1433

    
1434
/* convert among pixel formats */
1435
int img_convert(AVPicture *dst, int dst_pix_fmt,
1436
                AVPicture *src, int pix_fmt, 
1437
                int width, int height);
1438

    
1439
/* deinterlace a picture */
1440
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1441
                          int pix_fmt, int width, int height);
1442

    
1443
/* external high level API */
1444

    
1445
extern AVCodec *first_avcodec;
1446

    
1447
/* returns LIBAVCODEC_VERSION_INT constant */
1448
unsigned avcodec_version(void);
1449
/* returns LIBAVCODEC_BUILD constant */
1450
unsigned avcodec_build(void);
1451
void avcodec_init(void);
1452

    
1453
void register_avcodec(AVCodec *format);
1454
AVCodec *avcodec_find_encoder(enum CodecID id);
1455
AVCodec *avcodec_find_encoder_by_name(const char *name);
1456
AVCodec *avcodec_find_decoder(enum CodecID id);
1457
AVCodec *avcodec_find_decoder_by_name(const char *name);
1458
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1459

    
1460
void avcodec_get_context_defaults(AVCodecContext *s);
1461
AVCodecContext *avcodec_alloc_context(void);
1462
AVFrame *avcodec_alloc_frame(void);
1463

    
1464
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1465
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1466
void avcodec_default_free_buffers(AVCodecContext *s);
1467

    
1468
/**
1469
 * opens / inits the AVCodecContext.
1470
 * not thread save!
1471
 */
1472
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1473

    
1474
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1475
                         int *frame_size_ptr,
1476
                         uint8_t *buf, int buf_size);
1477
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1478
                         int *got_picture_ptr,
1479
                         uint8_t *buf, int buf_size);
1480
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1481
                        int *data_size_ptr,
1482
                        uint8_t *buf, int buf_size);
1483
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1484
                         const short *samples);
1485
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1486
                         const AVFrame *pict);
1487

    
1488
int avcodec_close(AVCodecContext *avctx);
1489

    
1490
void avcodec_register_all(void);
1491

    
1492
void avcodec_flush_buffers(AVCodecContext *avctx);
1493

    
1494
/* misc usefull functions */
1495

    
1496
/**
1497
 * returns a single letter to describe the picture type
1498
 */
1499
char av_get_pict_type_char(int pict_type);
1500

    
1501
/**
1502
 * reduce a fraction.
1503
 * this is usefull for framerate calculations
1504
 * @param max the maximum allowed for dst_nom & dst_den
1505
 * @return 1 if exact, 0 otherwise
1506
 */
1507
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1508

    
1509
/**
1510
 * rescale a 64bit integer.
1511
 * a simple a*b/c isnt possible as it can overflow
1512
 */
1513
int64_t av_rescale(int64_t a, int b, int c);
1514

    
1515

    
1516
/**
1517
 * Interface for 0.5.0 version
1518
 *
1519
 * do not even think about it's usage for this moment
1520
 */
1521

    
1522
typedef struct {
1523
    /// compressed size used from given memory buffer
1524
    int size;
1525
    /// I/P/B frame type
1526
    int frame_type;
1527
} avc_enc_result_t;
1528

    
1529
/**
1530
 * Commands
1531
 * order can't be changed - once it was defined
1532
 */
1533
typedef enum {
1534
    // general commands
1535
    AVC_OPEN_BY_NAME = 0xACA000,
1536
    AVC_OPEN_BY_CODEC_ID,
1537
    AVC_OPEN_BY_FOURCC,
1538
    AVC_CLOSE,
1539

    
1540
    AVC_FLUSH,
1541
    // pin - struct { uint8_t* src, uint_t src_size }
1542
    // pout - struct { AVPicture* img, consumed_bytes,
1543
    AVC_DECODE,
1544
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1545
    // pout - uint_t used_from_dest_size
1546
    AVC_ENCODE, 
1547

    
1548
    // query/get video commands
1549
    AVC_GET_VERSION = 0xACB000,
1550
    AVC_GET_WIDTH,
1551
    AVC_GET_HEIGHT,
1552
    AVC_GET_DELAY,
1553
    AVC_GET_QUANT_TABLE,
1554
    // ...
1555

    
1556
    // query/get audio commands
1557
    AVC_GET_FRAME_SIZE = 0xABC000,
1558

    
1559
    // maybe define some simple structure which
1560
    // might be passed to the user - but they can't
1561
    // contain any codec specific parts and these
1562
    // calls are usualy necessary only few times
1563

    
1564
    // set video commands
1565
    AVC_SET_WIDTH = 0xACD000,
1566
    AVC_SET_HEIGHT,
1567

    
1568
    // set video encoding commands
1569
    AVC_SET_FRAME_RATE = 0xACD800,
1570
    AVC_SET_QUALITY,
1571
    AVC_SET_HURRY_UP,
1572

    
1573
    // set audio commands
1574
    AVC_SET_SAMPLE_RATE = 0xACE000,
1575
    AVC_SET_CHANNELS,
1576

    
1577
} avc_cmd_t;
1578

    
1579
/**
1580
 * \param handle  allocated private structure by libavcodec
1581
 *                for initialization pass NULL - will be returned pout
1582
 *                user is supposed to know nothing about its structure
1583
 * \param cmd     type of operation to be performed
1584
 * \param pint    input parameter
1585
 * \param pout    output parameter
1586
 *
1587
 * \returns  command status - eventually for query command it might return
1588
 * integer resulting value
1589
 */
1590
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1591

    
1592
/* memory */
1593
void *av_malloc(unsigned int size); //FIXME unsigned could be bad, dunno, need thinking
1594
void *av_mallocz(unsigned int size);
1595
void *av_realloc(void *ptr, unsigned int size);
1596
void av_free(void *ptr);
1597
char *av_strdup(const char *s);
1598
void __av_freep(void **ptr);
1599
#define av_freep(p) __av_freep((void **)(p))
1600
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1601
/* for static data only */
1602
/* call av_free_static to release all staticaly allocated tables */
1603
void av_free_static(void);
1604
void *__av_mallocz_static(void** location, unsigned int size);
1605
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1606

    
1607
#ifdef __cplusplus
1608
}
1609
#endif
1610

    
1611
#endif /* AVCODEC_H */