Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ 3bb07d61

History | View | Annotate | Download (44.1 KB)

1
#ifndef AVCODEC_H
2
#define AVCODEC_H
3

    
4
/**
5
 * @file avcodec.h
6
 * external api header.
7
 */
8

    
9

    
10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13

    
14
#include "common.h"
15

    
16
#define LIBAVCODEC_VERSION_INT 0x000406
17
#define LIBAVCODEC_VERSION     "0.4.6"
18
#define LIBAVCODEC_BUILD       4671
19
#define LIBAVCODEC_BUILD_STR   "4671"
20

    
21
#define LIBAVCODEC_IDENT        "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
22

    
23
enum CodecID {
24
    CODEC_ID_NONE, 
25
    CODEC_ID_MPEG1VIDEO,
26
    CODEC_ID_H263,
27
    CODEC_ID_RV10,
28
    CODEC_ID_MP2,
29
    CODEC_ID_MP3LAME,
30
    CODEC_ID_VORBIS,
31
    CODEC_ID_AC3,
32
    CODEC_ID_MJPEG,
33
    CODEC_ID_MJPEGB,
34
    CODEC_ID_LJPEG,
35
    CODEC_ID_MPEG4,
36
    CODEC_ID_RAWVIDEO,
37
    CODEC_ID_MSMPEG4V1,
38
    CODEC_ID_MSMPEG4V2,
39
    CODEC_ID_MSMPEG4V3,
40
    CODEC_ID_WMV1,
41
    CODEC_ID_WMV2,
42
    CODEC_ID_H263P,
43
    CODEC_ID_H263I,
44
    CODEC_ID_FLV1,
45
    CODEC_ID_SVQ1,
46
    CODEC_ID_SVQ3,
47
    CODEC_ID_DVVIDEO,
48
    CODEC_ID_DVAUDIO,
49
    CODEC_ID_WMAV1,
50
    CODEC_ID_WMAV2,
51
    CODEC_ID_MACE3,
52
    CODEC_ID_MACE6,
53
    CODEC_ID_HUFFYUV,
54
    CODEC_ID_CYUV,
55
    CODEC_ID_H264,
56
    CODEC_ID_INDEO3,
57
    CODEC_ID_VP3,
58
    CODEC_ID_AAC,
59
    CODEC_ID_MPEG4AAC,
60
    CODEC_ID_ASV1,
61
    CODEC_ID_FFV1,
62
    CODEC_ID_4XM,
63

    
64
    /* various pcm "codecs" */
65
    CODEC_ID_PCM_S16LE,
66
    CODEC_ID_PCM_S16BE,
67
    CODEC_ID_PCM_U16LE,
68
    CODEC_ID_PCM_U16BE,
69
    CODEC_ID_PCM_S8,
70
    CODEC_ID_PCM_U8,
71
    CODEC_ID_PCM_MULAW,
72
    CODEC_ID_PCM_ALAW,
73

    
74
    /* various adpcm codecs */
75
    CODEC_ID_ADPCM_IMA_QT,
76
    CODEC_ID_ADPCM_IMA_WAV,
77
    CODEC_ID_ADPCM_MS,
78
    CODEC_ID_ADPCM_4XM,
79

    
80
        /* AMR */
81
    CODEC_ID_AMR_NB,
82
    /* RealAudio codecs*/
83
    CODEC_ID_RA_144,
84
    CODEC_ID_RA_288,
85
};
86

    
87
enum CodecType {
88
    CODEC_TYPE_UNKNOWN = -1,
89
    CODEC_TYPE_VIDEO,
90
    CODEC_TYPE_AUDIO,
91
};
92

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

    
118
/* currently unused, may be used if 24/32 bits samples ever supported */
119
enum SampleFormat {
120
    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
121
};
122

    
123
/* in bytes */
124
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
125

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

    
135
/* motion estimation type, EPZS by default */
136
enum Motion_Est_ID {
137
    ME_ZERO = 1,
138
    ME_FULL,
139
    ME_LOG,
140
    ME_PHODS,
141
    ME_EPZS,
142
    ME_X1
143
};
144

    
145
typedef struct RcOverride{
146
    int start_frame;
147
    int end_frame;
148
    int qscale; // if this is 0 then quality_factor will be used instead
149
    float quality_factor;
150
} RcOverride;
151

    
152
/* only for ME compatiblity with old apps */
153
extern int motion_estimation_method;
154

    
155
/* ME algos sorted by quality */
156
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
157
                                       ME_X1, ME_EPZS, ME_FULL };
158

    
159

    
160
#define FF_MAX_B_FRAMES 8
161

    
162
/* encoding support
163
   these flags can be passed in AVCodecContext.flags before initing 
164
   Note: note not everything is supported yet 
165
*/
166

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

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

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

    
346
#define FF_QSCALE_TYPE_MPEG1        0
347
#define FF_QSCALE_TYPE_MPEG2        1
348

    
349
#define FF_BUFFER_TYPE_INTERNAL 1
350
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers
351
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc
352

    
353

    
354
#define FF_I_TYPE 1 // Intra
355
#define FF_P_TYPE 2 // Predicted
356
#define FF_B_TYPE 3 // Bi-dir predicted
357
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
358
#define FF_SI_TYPE 5
359
#define FF_SP_TYPE 6
360

    
361
/**
362
 * Audio Video Frame.
363
 */
364
typedef struct AVFrame {
365
    FF_COMMON_FRAME
366
} AVFrame;
367

    
368
#define DEFAULT_FRAME_RATE_BASE 1001000
369

    
370
/**
371
 * main external api structure.
372
 */
373
typedef struct AVCodecContext {
374
    /**
375
     * the average bitrate.
376
     * - encoding: set by user. unused for constant quantizer encoding
377
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
378
     */
379
    int bit_rate;
380

    
381
    /**
382
     * number of bits the bitstream is allowed to diverge from the reference.
383
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
384
     * - encoding: set by user. unused for constant quantizer encoding
385
     * - decoding: unused
386
     */
387
    int bit_rate_tolerance; 
388

    
389
    /**
390
     * CODEC_FLAG_*.
391
     * - encoding: set by user.
392
     * - decoding: set by user.
393
     */
394
    int flags;
395

    
396
    /**
397
     * some codecs needs additionnal format info. It is stored here
398
     * - encoding: set by user. 
399
     * - decoding: set by lavc. (FIXME is this ok?)
400
     */
401
    int sub_id;
402

    
403
    /**
404
     * motion estimation algorithm used for video coding.
405
     * - encoding: MUST be set by user.
406
     * - decoding: unused
407
     */
408
    int me_method;
409

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

    
445
    /**
446
     * the number of pictures in a group of pitures, or 0 for intra_only.
447
     * - encoding: set by user.
448
     * - decoding: unused
449
     */
450
    int gop_size;
451

    
452
    /**
453
     * pixel format, see PIX_FMT_xxx.
454
     * - encoding: unused
455
     * - decoding: set by lavc.
456
     */
457
    enum PixelFormat pix_fmt;
458
 
459
    /**
460
     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
461
     * has to read frames at native frame rate.
462
     * - encoding: set by user.
463
     * - decoding: unused.
464
     */
465
    int rate_emu;
466
       
467
    /**
468
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
469
     * decoder to draw an horizontal band. It improve cache usage. Not
470
     * all codecs can do that. You must check the codec capabilities
471
     * before
472
     * - encoding: unused
473
     * - decoding: set by user.
474
     * @param height the height of the slice
475
     * @param y the y position of the slice
476
     * @param type 1->top field, 2->bottom field, 3->frame
477
     * @param offset offset into the AVFrame.data from which the slice should be read
478
     */
479
    void (*draw_horiz_band)(struct AVCodecContext *s,
480
                            AVFrame *src, int offset[4],
481
                            int y, int type, int height);
482

    
483
    /* audio only */
484
    int sample_rate; ///< samples per sec 
485
    int channels;
486
    int sample_fmt;  ///< sample format, currenly unused 
487

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

    
512
    /**
513
     * maximum quantizer.
514
     * - encoding: set by user.
515
     * - decoding: unused
516
     */
517
    int qmax;
518

    
519
    /**
520
     * maximum quantizer difference etween frames.
521
     * - encoding: set by user.
522
     * - decoding: unused
523
     */
524
    int max_qdiff;
525

    
526
    /**
527
     * maximum number of b frames between non b frames.
528
     * note: the output will be delayed by max_b_frames+1 relative to the input
529
     * - encoding: set by user.
530
     * - decoding: unused
531
     */
532
    int max_b_frames;
533

    
534
    /**
535
     * qscale factor between ip and b frames.
536
     * - encoding: set by user.
537
     * - decoding: unused
538
     */
539
    float b_quant_factor;
540
    
541
    /** obsolete FIXME remove */
542
    int rc_strategy;
543
    int b_frame_strategy;
544

    
545
    /**
546
     * hurry up amount.
547
     * - encoding: unused
548
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
549
     */
550
    int hurry_up;
551
    
552
    struct AVCodec *codec;
553
    
554
    void *priv_data;
555

    
556
    /* The following data is for RTP friendly coding */
557
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
558
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
559
                    /* highers numbers represent more error-prone */
560
                    /* enviroments, by now just "1" exist         */
561
    
562
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
563
                            /* do it's best to deliver a chunk with size    */
564
                            /* below rtp_payload_size, the chunk will start */
565
                            /* with a start code on some codecs like H.263  */
566
                            /* This doesn't take account of any particular  */
567
                            /* headers inside the transmited RTP payload    */
568

    
569
    
570
    /* The RTP callcack: This function is called  */
571
    /* every time the encoder as a packet to send */
572
    /* Depends on the encoder if the data starts  */
573
    /* with a Start Code (it should) H.263 does   */
574
    void (*rtp_callback)(void *data, int size, int packet_number); 
575

    
576
    /* statistics, used for 2-pass encoding */
577
    int mv_bits;
578
    int header_bits;
579
    int i_tex_bits;
580
    int p_tex_bits;
581
    int i_count;
582
    int p_count;
583
    int skip_count;
584
    int misc_bits;
585
    
586
    /**
587
     * number of bits used for the previously encoded frame.
588
     * - encoding: set by lavc
589
     * - decoding: unused
590
     */
591
    int frame_bits;
592

    
593
    /**
594
     * private data of the user, can be used to carry app specific stuff.
595
     * - encoding: set by user
596
     * - decoding: set by user
597
     */
598
    void *opaque;
599

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

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

    
734
    float rc_qmod_amp;
735
    int rc_qmod_freq;
736
    
737
    /**
738
     * ratecontrol override, see RcOverride.
739
     * - encoding: allocated/set/freed by user.
740
     * - decoding: unused
741
     */
742
    RcOverride *rc_override;
743
    int rc_override_count;
744
    
745
    /**
746
     * rate control equation.
747
     * - encoding: set by user
748
     * - decoding: unused
749
     */
750
    char *rc_eq;
751
    
752
    /**
753
     * maximum bitrate.
754
     * - encoding: set by user.
755
     * - decoding: unused
756
     */
757
    int rc_max_rate;
758
    
759
    /**
760
     * minimum bitrate.
761
     * - encoding: set by user.
762
     * - decoding: unused
763
     */
764
    int rc_min_rate;
765
    
766
    /**
767
     * decoder bitstream buffer size.
768
     * - encoding: set by user.
769
     * - decoding: unused
770
     */
771
    int rc_buffer_size;
772
    float rc_buffer_aggressivity;
773

    
774
    /**
775
     * qscale factor between p and i frames.
776
     * - encoding: set by user.
777
     * - decoding: unused
778
     */
779
    float i_quant_factor;
780
    
781
    /**
782
     * qscale offset between p and i frames.
783
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
784
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
785
     * - encoding: set by user.
786
     * - decoding: unused
787
     */
788
    float i_quant_offset;
789
    
790
    /**
791
     * initial complexity for pass1 ratecontrol.
792
     * - encoding: set by user.
793
     * - decoding: unused
794
     */
795
    float rc_initial_cplx;
796

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

    
838
    /**
839
     * darkness masking (0-> disabled).
840
     * - encoding: set by user
841
     * - decoding: unused
842
     */
843
    float dark_masking;
844
    
845
    
846
    /* for binary compatibility */
847
    int unused;
848
    
849
    /**
850
     * idct algorithm, see FF_IDCT_* below.
851
     * - encoding: set by user
852
     * - decoding: set by user
853
     */
854
    int idct_algo;
855
#define FF_IDCT_AUTO         0
856
#define FF_IDCT_INT          1
857
#define FF_IDCT_SIMPLE       2
858
#define FF_IDCT_SIMPLEMMX    3
859
#define FF_IDCT_LIBMPEG2MMX  4
860
#define FF_IDCT_PS2          5
861
#define FF_IDCT_MLIB         6
862
#define FF_IDCT_ARM          7
863
#define FF_IDCT_ALTIVEC      8
864
#define FF_IDCT_SH4          9
865
#define FF_IDCT_SIMPLEARM    10
866

    
867
    /**
868
     * slice count.
869
     * - encoding: set by lavc
870
     * - decoding: set by user (or 0)
871
     */
872
    int slice_count;
873
    /**
874
     * slice offsets in the frame in bytes.
875
     * - encoding: set/allocated by lavc
876
     * - decoding: set/allocated by user (or NULL)
877
     */
878
    int *slice_offset;
879

    
880
    /**
881
     * error concealment flags.
882
     * - encoding: unused
883
     * - decoding: set by user
884
     */
885
    int error_concealment;
886
#define FF_EC_GUESS_MVS   1
887
#define FF_EC_DEBLOCK     2
888

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

    
908
    /**
909
     * bits per sample/pixel from the demuxer (needed for huffyuv).
910
     * - encoding: set by lavc
911
     * - decoding: set by user
912
     */
913
     int bits_per_sample;
914
    
915
    /**
916
     * prediction method (needed for huffyuv).
917
     * - encoding: set by user
918
     * - decoding: unused
919
     */
920
     int prediction_method;
921
#define FF_PRED_LEFT   0
922
#define FF_PRED_PLANE  1
923
#define FF_PRED_MEDIAN 2
924
    
925
    /**
926
     * aspect ratio (0 if unknown).
927
     * - encoding: set by user.
928
     * - decoding: set by lavc.
929
     */
930
    float aspect_ratio;
931

    
932
    /**
933
     * the picture in the bitstream.
934
     * - encoding: set by lavc
935
     * - decoding: set by lavc
936
     */
937
    AVFrame *coded_frame;
938

    
939
    /**
940
     * debug.
941
     * - encoding: set by user.
942
     * - decoding: set by user.
943
     */
944
    int debug;
945
#define FF_DEBUG_PICT_INFO 1
946
#define FF_DEBUG_RC        2
947
#define FF_DEBUG_BITSTREAM 4
948
#define FF_DEBUG_MB_TYPE   8
949
#define FF_DEBUG_QP        16
950
#define FF_DEBUG_MV        32
951
#define FF_DEBUG_VIS_MV    0x00000040
952
#define FF_DEBUG_SKIP      0x00000080
953
#define FF_DEBUG_STARTCODE 0x00000100
954
#define FF_DEBUG_PTS       0x00000200
955
#define FF_DEBUG_ER        0x00000400
956
#define FF_DEBUG_MMCO      0x00000800
957
    
958
    /**
959
     * error.
960
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
961
     * - decoding: unused
962
     */
963
    uint64_t error[4];
964
    
965
    /**
966
     * minimum MB quantizer.
967
     * - encoding: set by user.
968
     * - decoding: unused
969
     */
970
    int mb_qmin;
971

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

    
1014
    /**
1015
     * amount of previous MV predictors (2a+1 x 2a+1 square).
1016
     * - encoding: set by user.
1017
     * - decoding: unused
1018
     */
1019
    int last_predictor_count;
1020

    
1021
    /**
1022
     * pre pass for motion estimation.
1023
     * - encoding: set by user.
1024
     * - decoding: unused
1025
     */
1026
    int pre_me;
1027

    
1028
    /**
1029
     * motion estimation pre pass compare function.
1030
     * - encoding: set by user.
1031
     * - decoding: unused
1032
     */
1033
    int me_pre_cmp;
1034

    
1035
    /**
1036
     * ME pre pass diamond size & shape.
1037
     * - encoding: set by user.
1038
     * - decoding: unused
1039
     */
1040
    int pre_dia_size;
1041

    
1042
    /**
1043
     * subpel ME quality.
1044
     * - encoding: set by user.
1045
     * - decoding: unused
1046
     */
1047
    int me_subpel_quality;
1048

    
1049
    /**
1050
     * callback to negotiate the pixelFormat.
1051
     * @param fmt is the list of formats which are supported by the codec,
1052
     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1053
     * the first is allways the native one
1054
     * @return the choosen format
1055
     * - encoding: unused
1056
     * - decoding: set by user, if not set then the native format will always be choosen
1057
     */
1058
    enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1059

    
1060
    /**
1061
     * DTG active format information (additionnal aspect ratio
1062
     * information only used in DVB MPEG2 transport streams). 0 if
1063
     * not set.
1064
     * 
1065
     * - encoding: unused.
1066
     * - decoding: set by decoder 
1067
     */
1068
    int dtg_active_format;
1069
#define FF_DTG_AFD_SAME         8
1070
#define FF_DTG_AFD_4_3          9
1071
#define FF_DTG_AFD_16_9         10
1072
#define FF_DTG_AFD_14_9         11
1073
#define FF_DTG_AFD_4_3_SP_14_9  13
1074
#define FF_DTG_AFD_16_9_SP_14_9 14
1075
#define FF_DTG_AFD_SP_4_3       15
1076

    
1077
    /**
1078
     * Maximum motion estimation search range in subpel units.
1079
     * if 0 then no limit
1080
     * 
1081
     * - encoding: set by user.
1082
     * - decoding: unused.
1083
     */
1084
    int me_range;
1085

    
1086
    /**
1087
     * frame_rate_base.
1088
     * for variable fps this is 1
1089
     * - encoding: set by user.
1090
     * - decoding: set by lavc.
1091
     * @todo move this after frame_rate
1092
     */
1093

    
1094
    int frame_rate_base;
1095
    /**
1096
     * intra quantizer bias.
1097
     * - encoding: set by user.
1098
     * - decoding: unused
1099
     */
1100
    int intra_quant_bias;
1101
#define FF_DEFAULT_QUANT_BIAS 999999
1102
    
1103
    /**
1104
     * inter quantizer bias.
1105
     * - encoding: set by user.
1106
     * - decoding: unused
1107
     */
1108
    int inter_quant_bias;
1109

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

    
1148
    /**
1149
     * context model
1150
     * - encoding: set by user.
1151
     * - decoding: unused
1152
     */
1153
    int context_model;
1154
    
1155
    /**
1156
     * slice flags
1157
     * - encoding: unused
1158
     * - decoding: set by user.
1159
     */
1160
    int slice_flags;
1161
#define SLICE_FLAG_CODED_ORDER    0x0001 ///< draw_horiz_band() is called in coded order instead of display
1162
#define SLICE_FLAG_ALLOW_FIELD    0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics)
1163
#define SLICE_FLAG_ALLOW_PLANE    0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1)
1164

    
1165
} AVCodecContext;
1166

    
1167

    
1168
/**
1169
 * AVOption.
1170
 */
1171
typedef struct AVOption {
1172
    /** options' name */
1173
    const char *name; /* if name is NULL, it indicates a link to next */
1174
    /** short English text help or const struct AVOption* subpointer */
1175
    const char *help; //        const struct AVOption* sub;
1176
    /** offset to context structure where the parsed value should be stored */
1177
    int offset;
1178
    /** options' type */
1179
    int type;
1180
#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
1181
#define FF_OPT_TYPE_DOUBLE 2    ///< double
1182
#define FF_OPT_TYPE_INT 3       ///< integer
1183
#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
1184
#define FF_OPT_TYPE_MASK 0x1f        ///< mask for types - upper bits are various flags
1185
//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1186
#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1187
#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1188
    /** min value  (min == max   ->  no limits) */
1189
    double min;
1190
    /** maximum value for double/int */
1191
    double max;
1192
    /** default boo [0,1]l/double/int value */
1193
    double defval;
1194
    /**
1195
     * default string value (with optional semicolon delimited extra option-list
1196
     * i.e.   option1;option2;option3
1197
     * defval might select other then first argument as default
1198
     */
1199
    const char *defstr;
1200
#define FF_OPT_MAX_DEPTH 10
1201
} AVOption;
1202

    
1203
/**
1204
 * Parse option(s) and sets fields in passed structure
1205
 * @param strct        structure where the parsed results will be written
1206
 * @param list  list with AVOptions
1207
 * @param opts        string with options for parsing
1208
 */
1209
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1210

    
1211

    
1212
/**
1213
 * AVCodec.
1214
 */
1215
typedef struct AVCodec {
1216
    const char *name;
1217
    enum CodecType type;
1218
    int id;
1219
    int priv_data_size;
1220
    int (*init)(AVCodecContext *);
1221
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1222
    int (*close)(AVCodecContext *);
1223
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1224
                  uint8_t *buf, int buf_size);
1225
    int capabilities;
1226
    const AVOption *options;
1227
    struct AVCodec *next;
1228
    void (*flush)(AVCodecContext *);
1229
} AVCodec;
1230

    
1231
/**
1232
 * four components are given, that's all.
1233
 * the last component is alpha
1234
 */
1235
typedef struct AVPicture {
1236
    uint8_t *data[4];
1237
    int linesize[4];       ///< number of bytes per line
1238
} AVPicture;
1239

    
1240
extern AVCodec ac3_encoder;
1241
extern AVCodec mp2_encoder;
1242
extern AVCodec mp3lame_encoder;
1243
extern AVCodec oggvorbis_encoder;
1244
extern AVCodec mpeg1video_encoder;
1245
extern AVCodec h263_encoder;
1246
extern AVCodec h263p_encoder;
1247
extern AVCodec flv_encoder;
1248
extern AVCodec rv10_encoder;
1249
extern AVCodec mjpeg_encoder;
1250
extern AVCodec ljpeg_encoder;
1251
extern AVCodec mpeg4_encoder;
1252
extern AVCodec msmpeg4v1_encoder;
1253
extern AVCodec msmpeg4v2_encoder;
1254
extern AVCodec msmpeg4v3_encoder;
1255
extern AVCodec wmv1_encoder;
1256
extern AVCodec wmv2_encoder;
1257
extern AVCodec huffyuv_encoder;
1258
extern AVCodec h264_encoder;
1259
extern AVCodec asv1_encoder;
1260
extern AVCodec ffv1_encoder;
1261

    
1262
extern AVCodec h263_decoder;
1263
extern AVCodec mpeg4_decoder;
1264
extern AVCodec msmpeg4v1_decoder;
1265
extern AVCodec msmpeg4v2_decoder;
1266
extern AVCodec msmpeg4v3_decoder;
1267
extern AVCodec wmv1_decoder;
1268
extern AVCodec wmv2_decoder;
1269
extern AVCodec mpeg_decoder;
1270
extern AVCodec h263i_decoder;
1271
extern AVCodec flv_decoder;
1272
extern AVCodec rv10_decoder;
1273
extern AVCodec svq1_decoder;
1274
extern AVCodec svq3_decoder;
1275
extern AVCodec dvvideo_decoder;
1276
extern AVCodec dvaudio_decoder;
1277
extern AVCodec wmav1_decoder;
1278
extern AVCodec wmav2_decoder;
1279
extern AVCodec mjpeg_decoder;
1280
extern AVCodec mjpegb_decoder;
1281
extern AVCodec mp2_decoder;
1282
extern AVCodec mp3_decoder;
1283
extern AVCodec mace3_decoder;
1284
extern AVCodec mace6_decoder;
1285
extern AVCodec huffyuv_decoder;
1286
extern AVCodec oggvorbis_decoder;
1287
extern AVCodec cyuv_decoder;
1288
extern AVCodec h264_decoder;
1289
extern AVCodec indeo3_decoder;
1290
extern AVCodec vp3_decoder;
1291
extern AVCodec amr_nb_decoder;
1292
extern AVCodec amr_nb_encoder;
1293
extern AVCodec aac_decoder;
1294
extern AVCodec mpeg4aac_decoder;
1295
extern AVCodec asv1_decoder;
1296
extern AVCodec ffv1_decoder;
1297
extern AVCodec fourxm_decoder;
1298
extern AVCodec ra_144_decoder;
1299
extern AVCodec ra_288_decoder;
1300

    
1301
/* pcm codecs */
1302
#define PCM_CODEC(id, name) \
1303
extern AVCodec name ## _decoder; \
1304
extern AVCodec name ## _encoder
1305

    
1306
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1307
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1308
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1309
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1310
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1311
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1312
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1313
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1314

    
1315
/* adpcm codecs */
1316

    
1317
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1318
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1319
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1320
PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
1321

    
1322
#undef PCM_CODEC
1323

    
1324
/* dummy raw video codec */
1325
extern AVCodec rawvideo_encoder;
1326
extern AVCodec rawvideo_decoder;
1327

    
1328
/* the following codecs use external GPL libs */
1329
extern AVCodec ac3_decoder;
1330

    
1331
/* resample.c */
1332

    
1333
struct ReSampleContext;
1334

    
1335
typedef struct ReSampleContext ReSampleContext;
1336

    
1337
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1338
                                     int output_rate, int input_rate);
1339
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1340
void audio_resample_close(ReSampleContext *s);
1341

    
1342
/* YUV420 format is assumed ! */
1343

    
1344
struct ImgReSampleContext;
1345

    
1346
typedef struct ImgReSampleContext ImgReSampleContext;
1347

    
1348
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1349
                                      int input_width, int input_height);
1350

    
1351
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1352
                                      int iwidth, int iheight,
1353
                                      int topBand, int bottomBand,
1354
                                      int leftBand, int rightBand);
1355

    
1356
void img_resample(ImgReSampleContext *s, 
1357
                  AVPicture *output, AVPicture *input);
1358

    
1359
void img_resample_close(ImgReSampleContext *s);
1360

    
1361
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1362
                   int pix_fmt, int width, int height);
1363
int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1364
                     unsigned char *dest, int dest_size);
1365
int avpicture_get_size(int pix_fmt, int width, int height);
1366
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1367
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1368
enum PixelFormat avcodec_get_pix_fmt(const char* name);
1369

    
1370
#define FF_LOSS_RESOLUTION  0x0001 /* loss due to resolution change */
1371
#define FF_LOSS_DEPTH       0x0002 /* loss due to color depth change */
1372
#define FF_LOSS_COLORSPACE  0x0004 /* loss due to color space conversion */
1373
#define FF_LOSS_ALPHA       0x0008 /* loss of alpha bits */
1374
#define FF_LOSS_COLORQUANT  0x0010 /* loss due to color quantization */
1375
#define FF_LOSS_CHROMA      0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1376

    
1377
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1378
                             int has_alpha);
1379
int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1380
                              int has_alpha, int *loss_ptr);
1381

    
1382
#define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
1383
#define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
1384
int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1385

    
1386
/* convert among pixel formats */
1387
int img_convert(AVPicture *dst, int dst_pix_fmt,
1388
                AVPicture *src, int pix_fmt, 
1389
                int width, int height);
1390

    
1391
/* deinterlace a picture */
1392
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1393
                          int pix_fmt, int width, int height);
1394

    
1395
/* external high level API */
1396

    
1397
extern AVCodec *first_avcodec;
1398

    
1399
/* returns LIBAVCODEC_VERSION_INT constant */
1400
unsigned avcodec_version(void);
1401
/* returns LIBAVCODEC_BUILD constant */
1402
unsigned avcodec_build(void);
1403
void avcodec_init(void);
1404

    
1405
void register_avcodec(AVCodec *format);
1406
AVCodec *avcodec_find_encoder(enum CodecID id);
1407
AVCodec *avcodec_find_encoder_by_name(const char *name);
1408
AVCodec *avcodec_find_decoder(enum CodecID id);
1409
AVCodec *avcodec_find_decoder_by_name(const char *name);
1410
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1411

    
1412
void avcodec_get_context_defaults(AVCodecContext *s);
1413
AVCodecContext *avcodec_alloc_context(void);
1414
AVFrame *avcodec_alloc_frame(void);
1415

    
1416
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1417
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1418
void avcodec_default_free_buffers(AVCodecContext *s);
1419

    
1420
/**
1421
 * opens / inits the AVCodecContext.
1422
 * not thread save!
1423
 */
1424
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1425

    
1426
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1427
                         int *frame_size_ptr,
1428
                         uint8_t *buf, int buf_size);
1429
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1430
                         int *got_picture_ptr,
1431
                         uint8_t *buf, int buf_size);
1432
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1433
                        int *data_size_ptr,
1434
                        uint8_t *buf, int buf_size);
1435
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1436
                         const short *samples);
1437
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1438
                         const AVFrame *pict);
1439

    
1440
int avcodec_close(AVCodecContext *avctx);
1441

    
1442
void avcodec_register_all(void);
1443

    
1444
void avcodec_flush_buffers(AVCodecContext *avctx);
1445

    
1446
/* misc usefull functions */
1447

    
1448
/**
1449
 * returns a single letter to describe the picture type
1450
 */
1451
char av_get_pict_type_char(int pict_type);
1452

    
1453
/**
1454
 * reduce a fraction.
1455
 * this is usefull for framerate calculations
1456
 * @param max the maximum allowed for dst_nom & dst_den
1457
 * @return 1 if exact, 0 otherwise
1458
 */
1459
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1460

    
1461
/**
1462
 * rescale a 64bit integer.
1463
 * a simple a*b/c isnt possible as it can overflow
1464
 */
1465
int64_t av_rescale(int64_t a, int b, int c);
1466

    
1467

    
1468
/**
1469
 * Interface for 0.5.0 version
1470
 *
1471
 * do not even think about it's usage for this moment
1472
 */
1473

    
1474
typedef struct {
1475
    /// compressed size used from given memory buffer
1476
    int size;
1477
    /// I/P/B frame type
1478
    int frame_type;
1479
} avc_enc_result_t;
1480

    
1481
/**
1482
 * Commands
1483
 * order can't be changed - once it was defined
1484
 */
1485
typedef enum {
1486
    // general commands
1487
    AVC_OPEN_BY_NAME = 0xACA000,
1488
    AVC_OPEN_BY_CODEC_ID,
1489
    AVC_OPEN_BY_FOURCC,
1490
    AVC_CLOSE,
1491

    
1492
    AVC_FLUSH,
1493
    // pin - struct { uint8_t* src, uint_t src_size }
1494
    // pout - struct { AVPicture* img, consumed_bytes,
1495
    AVC_DECODE,
1496
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1497
    // pout - uint_t used_from_dest_size
1498
    AVC_ENCODE, 
1499

    
1500
    // query/get video commands
1501
    AVC_GET_VERSION = 0xACB000,
1502
    AVC_GET_WIDTH,
1503
    AVC_GET_HEIGHT,
1504
    AVC_GET_DELAY,
1505
    AVC_GET_QUANT_TABLE,
1506
    // ...
1507

    
1508
    // query/get audio commands
1509
    AVC_GET_FRAME_SIZE = 0xABC000,
1510

    
1511
    // maybe define some simple structure which
1512
    // might be passed to the user - but they can't
1513
    // contain any codec specific parts and these
1514
    // calls are usualy necessary only few times
1515

    
1516
    // set video commands
1517
    AVC_SET_WIDTH = 0xACD000,
1518
    AVC_SET_HEIGHT,
1519

    
1520
    // set video encoding commands
1521
    AVC_SET_FRAME_RATE = 0xACD800,
1522
    AVC_SET_QUALITY,
1523
    AVC_SET_HURRY_UP,
1524

    
1525
    // set audio commands
1526
    AVC_SET_SAMPLE_RATE = 0xACE000,
1527
    AVC_SET_CHANNELS,
1528

    
1529
} avc_cmd_t;
1530

    
1531
/**
1532
 * \param handle  allocated private structure by libavcodec
1533
 *                for initialization pass NULL - will be returned pout
1534
 *                user is supposed to know nothing about its structure
1535
 * \param cmd     type of operation to be performed
1536
 * \param pint    input parameter
1537
 * \param pout    output parameter
1538
 *
1539
 * \returns  command status - eventually for query command it might return
1540
 * integer resulting value
1541
 */
1542
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1543

    
1544
/* memory */
1545
void *av_malloc(unsigned int size);
1546
void *av_mallocz(unsigned int size);
1547
void *av_realloc(void *ptr, unsigned int size);
1548
void av_free(void *ptr);
1549
char *av_strdup(const char *s);
1550
void __av_freep(void **ptr);
1551
#define av_freep(p) __av_freep((void **)(p))
1552
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1553
/* for static data only */
1554
/* call av_free_static to release all staticaly allocated tables */
1555
void av_free_static(void);
1556
void *__av_mallocz_static(void** location, unsigned int size);
1557
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1558

    
1559
#ifdef __cplusplus
1560
}
1561
#endif
1562

    
1563
#endif /* AVCODEC_H */