Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ deabd4fd

History | View | Annotate | Download (39.2 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       4663
19
#define LIBAVCODEC_BUILD_STR   "4663"
20

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

    
23
enum CodecID {
24
    CODEC_ID_NONE, 
25
    CODEC_ID_MPEG1VIDEO,
26
    CODEC_ID_H263,
27
    CODEC_ID_RV10,
28
    CODEC_ID_MP2,
29
    CODEC_ID_MP3LAME,
30
    CODEC_ID_VORBIS,
31
    CODEC_ID_AC3,
32
    CODEC_ID_MJPEG,
33
    CODEC_ID_MJPEGB,
34
    CODEC_ID_MPEG4,
35
    CODEC_ID_RAWVIDEO,
36
    CODEC_ID_MSMPEG4V1,
37
    CODEC_ID_MSMPEG4V2,
38
    CODEC_ID_MSMPEG4V3,
39
    CODEC_ID_WMV1,
40
    CODEC_ID_WMV2,
41
    CODEC_ID_H263P,
42
    CODEC_ID_H263I,
43
    CODEC_ID_SVQ1,
44
    CODEC_ID_DVVIDEO,
45
    CODEC_ID_DVAUDIO,
46
    CODEC_ID_WMAV1,
47
    CODEC_ID_WMAV2,
48
    CODEC_ID_MACE3,
49
    CODEC_ID_MACE6,
50
    CODEC_ID_HUFFYUV,
51
    CODEC_ID_CYUV,
52
    CODEC_ID_H264,
53
    CODEC_ID_INDEO3,
54

    
55
    /* various pcm "codecs" */
56
    CODEC_ID_PCM_S16LE,
57
    CODEC_ID_PCM_S16BE,
58
    CODEC_ID_PCM_U16LE,
59
    CODEC_ID_PCM_U16BE,
60
    CODEC_ID_PCM_S8,
61
    CODEC_ID_PCM_U8,
62
    CODEC_ID_PCM_MULAW,
63
    CODEC_ID_PCM_ALAW,
64

    
65
    /* various adpcm codecs */
66
    CODEC_ID_ADPCM_IMA_QT,
67
    CODEC_ID_ADPCM_IMA_WAV,
68
    CODEC_ID_ADPCM_MS,
69
};
70

    
71
enum CodecType {
72
    CODEC_TYPE_UNKNOWN = -1,
73
    CODEC_TYPE_VIDEO,
74
    CODEC_TYPE_AUDIO,
75
};
76

    
77
/**
78
 * Pixel format.
79
 */
80
enum PixelFormat {
81
    PIX_FMT_YUV420P,
82
    PIX_FMT_YUV422,
83
    PIX_FMT_RGB24,     ///< 3 bytes, R is first 
84
    PIX_FMT_BGR24,     ///< 3 bytes, B is first 
85
    PIX_FMT_YUV422P,
86
    PIX_FMT_YUV444P,
87
    PIX_FMT_RGBA32,    ///< always stored in cpu endianness 
88
    PIX_FMT_YUV410P,
89
    PIX_FMT_YUV411P,
90
    PIX_FMT_RGB565,    ///< always stored in cpu endianness 
91
    PIX_FMT_RGB555,    ///< always stored in cpu endianness, most significant bit to 1 
92
    PIX_FMT_GRAY8,
93
    PIX_FMT_MONOWHITE, ///< 0 is white 
94
    PIX_FMT_MONOBLACK, ///< 0 is black 
95
    PIX_FMT_PAL8,      ///< 8 bit with RGBA palette 
96
    PIX_FMT_NB,
97
};
98

    
99
/* currently unused, may be used if 24/32 bits samples ever supported */
100
enum SampleFormat {
101
    SAMPLE_FMT_S16 = 0,         ///< signed 16 bits 
102
};
103

    
104
/* in bytes */
105
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
106

    
107
/**
108
 * Required number of zero bytes at the end of the input bitstream for decoding.
109
 * to avoid overreading (and possibly segfaulting)
110
 */
111
#define FF_INPUT_BUFFER_PADDING_SIZE 8
112

    
113
/* motion estimation type, EPZS by default */
114
enum Motion_Est_ID {
115
    ME_ZERO = 1,
116
    ME_FULL,
117
    ME_LOG,
118
    ME_PHODS,
119
    ME_EPZS,
120
    ME_X1
121
};
122

    
123
typedef struct RcOverride{
124
    int start_frame;
125
    int end_frame;
126
    int qscale; // if this is 0 then quality_factor will be used instead
127
    float quality_factor;
128
} RcOverride;
129

    
130
/* only for ME compatiblity with old apps */
131
extern int motion_estimation_method;
132

    
133
/* ME algos sorted by quality */
134
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
135
                                       ME_X1, ME_EPZS, ME_FULL };
136

    
137

    
138
#define FF_MAX_B_FRAMES 8
139

    
140
/* encoding support
141
   these flags can be passed in AVCodecContext.flags before initing 
142
   Note: note not everything is supported yet 
143
*/
144

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

    
184
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback 
185
#define CODEC_CAP_DR1             0x0002 ///< direct rendering method 1 
186
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
187
   used */
188
#define CODEC_CAP_PARSE_ONLY      0x0004
189
#define CODEC_CAP_TRUNCATED       0x0008
190

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

    
315

    
316
#define FF_BUFFER_TYPE_INTERNAL 1
317
#define FF_BUFFER_TYPE_USER     2 ///< Direct rendering buffers
318
#define FF_BUFFER_TYPE_SHARED   4 ///< buffer from somewher else, dont dealloc
319

    
320

    
321
#define FF_I_TYPE 1 // Intra
322
#define FF_P_TYPE 2 // Predicted
323
#define FF_B_TYPE 3 // Bi-dir predicted
324
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
325
#define FF_SI_TYPE 5
326
#define FF_SP_TYPE 6
327

    
328
/**
329
 * Audio Video Frame.
330
 */
331
typedef struct AVFrame {
332
    FF_COMMON_FRAME
333
} AVFrame;
334

    
335
#define DEFAULT_FRAME_RATE_BASE 1001000
336

    
337
/**
338
 * main external api structure.
339
 */
340
typedef struct AVCodecContext {
341
    /**
342
     * the average bitrate.
343
     * - encoding: set by user. unused for constant quantizer encoding
344
     * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
345
     */
346
    int bit_rate;
347

    
348
    /**
349
     * number of bits the bitstream is allowed to diverge from the reference.
350
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
351
     * - encoding: set by user. unused for constant quantizer encoding
352
     * - decoding: unused
353
     */
354
    int bit_rate_tolerance; 
355

    
356
    /**
357
     * CODEC_FLAG_*.
358
     * - encoding: set by user.
359
     * - decoding: set by user.
360
     */
361
    int flags;
362

    
363
    /**
364
     * some codecs needs additionnal format info. It is stored here
365
     * - encoding: set by user. 
366
     * - decoding: set by lavc. (FIXME is this ok?)
367
     */
368
    int sub_id;
369

    
370
    /**
371
     * motion estimation algorithm used for video coding.
372
     * - encoding: MUST be set by user.
373
     * - decoding: unused
374
     */
375
    int me_method;
376

    
377
    /**
378
     * some codecs need / can use extra-data like huffman tables.
379
     * mjpeg: huffman tables
380
     * rv10: additional flags
381
     * mpeg4: global headers (they can be in the bitstream or here)
382
     * - encoding: set/allocated/freed by lavc.
383
     * - decoding: set/allocated/freed by user.
384
     */
385
    void *extradata;
386
    int extradata_size;
387
    
388
    /* video only */
389
    /**
390
     * frames per sec multiplied by frame_rate_base.
391
     * for variable fps this is the precission, so if the timestamps 
392
     * can be specified in msec precssion then this is 1000*frame_rate_base
393
     * - encoding: MUST be set by user
394
     * - decoding: set by lavc. 0 or the frame_rate if available
395
     */
396
    int frame_rate;
397
    
398
    /**
399
     * width / height.
400
     * - encoding: MUST be set by user. 
401
     * - decoding: set by user, some codecs might override / change it during playback
402
     */
403
    int width, height;
404
    
405
#define FF_ASPECT_SQUARE 1
406
#define FF_ASPECT_4_3_625 2
407
#define FF_ASPECT_4_3_525 3
408
#define FF_ASPECT_16_9_625 4
409
#define FF_ASPECT_16_9_525 5
410
#define FF_ASPECT_EXTENDED 15
411

    
412
    /**
413
     * the number of pictures in a group of pitures, or 0 for intra_only.
414
     * - encoding: set by user.
415
     * - decoding: unused
416
     */
417
    int gop_size;
418

    
419
    /**
420
     * pixel format, see PIX_FMT_xxx.
421
     * - encoding: unused
422
     * - decoding: set by lavc.
423
     */
424
    enum PixelFormat pix_fmt;
425
 
426
    /**
427
     * Frame rate emulation. If not zero lower layer (i.e. format handler) 
428
     * has to read frames at native frame rate.
429
     * - encoding: set by user.
430
     * - decoding: unused.
431
     */
432
    int rate_emu;
433
       
434
    /**
435
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
436
     * decoder to draw an horizontal band. It improve cache usage. Not
437
     * all codecs can do that. You must check the codec capabilities
438
     * before
439
     * - encoding: unused
440
     * - decoding: set by user.
441
     */
442
    void (*draw_horiz_band)(struct AVCodecContext *s,
443
                            uint8_t **src_ptr, int linesize,
444
                            int y, int width, int height);
445

    
446
    /* audio only */
447
    int sample_rate; ///< samples per sec 
448
    int channels;
449
    int sample_fmt;  ///< sample format, currenly unused 
450

    
451
    /* the following data should not be initialized */
452
    int frame_size;     ///< in samples, initialized when calling 'init' 
453
    int frame_number;   ///< audio or video frame number 
454
    int real_pict_num;  ///< returns the real picture number of previous encoded frame 
455
    
456
    /**
457
     * number of frames the decoded output will be delayed relative to 
458
     * the encoded input.
459
     * - encoding: set by lavc.
460
     * - decoding: unused
461
     */
462
    int delay;
463
    
464
    /* - encoding parameters */
465
    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0)
466
    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
467
    
468
    /**
469
     * minimum quantizer.
470
     * - encoding: set by user.
471
     * - decoding: unused
472
     */
473
    int qmin;
474

    
475
    /**
476
     * maximum quantizer.
477
     * - encoding: set by user.
478
     * - decoding: unused
479
     */
480
    int qmax;
481

    
482
    /**
483
     * maximum quantizer difference etween frames.
484
     * - encoding: set by user.
485
     * - decoding: unused
486
     */
487
    int max_qdiff;
488

    
489
    /**
490
     * maximum number of b frames between non b frames.
491
     * note: the output will be delayed by max_b_frames+1 relative to the input
492
     * - encoding: set by user.
493
     * - decoding: unused
494
     */
495
    int max_b_frames;
496

    
497
    /**
498
     * qscale factor between ip and b frames.
499
     * - encoding: set by user.
500
     * - decoding: unused
501
     */
502
    float b_quant_factor;
503
    
504
    /** obsolete FIXME remove */
505
    int rc_strategy;
506
    int b_frame_strategy;
507

    
508
    /**
509
     * hurry up amount.
510
     * - encoding: unused
511
     * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
512
     */
513
    int hurry_up;
514
    
515
    struct AVCodec *codec;
516
    
517
    void *priv_data;
518

    
519
    /* The following data is for RTP friendly coding */
520
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
521
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
522
                    /* highers numbers represent more error-prone */
523
                    /* enviroments, by now just "1" exist         */
524
    
525
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
526
                            /* do it's best to deliver a chunk with size    */
527
                            /* below rtp_payload_size, the chunk will start */
528
                            /* with a start code on some codecs like H.263  */
529
                            /* This doesn't take account of any particular  */
530
                            /* headers inside the transmited RTP payload    */
531

    
532
    
533
    /* The RTP callcack: This function is called  */
534
    /* every time the encoder as a packet to send */
535
    /* Depends on the encoder if the data starts  */
536
    /* with a Start Code (it should) H.263 does   */
537
    void (*rtp_callback)(void *data, int size, int packet_number); 
538

    
539
    /* statistics, used for 2-pass encoding */
540
    int mv_bits;
541
    int header_bits;
542
    int i_tex_bits;
543
    int p_tex_bits;
544
    int i_count;
545
    int p_count;
546
    int skip_count;
547
    int misc_bits;
548
    
549
    /**
550
     * number of bits used for the previously encoded frame.
551
     * - encoding: set by lavc
552
     * - decoding: unused
553
     */
554
    int frame_bits;
555

    
556
    /**
557
     * private data of the user, can be used to carry app specific stuff.
558
     * - encoding: set by user
559
     * - decoding: set by user
560
     */
561
    void *opaque;
562

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

    
653
    /**
654
     * is 1 if the decoded stream contains b frames, 0 otherwise.
655
     * - encoding: unused
656
     * - decoding: set by lavc
657
     */
658
    int has_b_frames;
659
    
660
    int block_align; ///< used by some WAV based audio codecs
661
    
662
    int parse_only; /* - decoding only: if true, only parsing is done
663
                       (function avcodec_parse_frame()). The frame
664
                       data is returned. Only MPEG codecs support this now. */
665
    
666
    /**
667
     * 0-> h263 quant 1-> mpeg quant.
668
     * - encoding: set by user.
669
     * - decoding: unused
670
     */
671
    int mpeg_quant;
672
    
673
    /**
674
     * pass1 encoding statistics output buffer.
675
     * - encoding: set by lavc
676
     * - decoding: unused
677
     */
678
    char *stats_out;
679
    
680
    /**
681
     * pass2 encoding statistics input buffer.
682
     * concatenated stuff from stats_out of pass1 should be placed here
683
     * - encoding: allocated/set/freed by user
684
     * - decoding: unused
685
     */
686
    char *stats_in;
687
    
688
    /**
689
     * ratecontrol qmin qmax limiting method.
690
     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
691
     * - encoding: set by user.
692
     * - decoding: unused
693
     */
694
    float rc_qsquish;
695

    
696
    float rc_qmod_amp;
697
    int rc_qmod_freq;
698
    
699
    /**
700
     * ratecontrol override, see RcOverride.
701
     * - encoding: allocated/set/freed by user.
702
     * - decoding: unused
703
     */
704
    RcOverride *rc_override;
705
    int rc_override_count;
706
    
707
    /**
708
     * rate control equation.
709
     * - encoding: set by user
710
     * - decoding: unused
711
     */
712
    char *rc_eq;
713
    
714
    /**
715
     * maximum bitrate.
716
     * - encoding: set by user.
717
     * - decoding: unused
718
     */
719
    int rc_max_rate;
720
    
721
    /**
722
     * minimum bitrate.
723
     * - encoding: set by user.
724
     * - decoding: unused
725
     */
726
    int rc_min_rate;
727
    
728
    /**
729
     * decoder bitstream buffer size.
730
     * - encoding: set by user.
731
     * - decoding: unused
732
     */
733
    int rc_buffer_size;
734
    float rc_buffer_aggressivity;
735

    
736
    /**
737
     * qscale factor between p and i frames.
738
     * - encoding: set by user.
739
     * - decoding: unused
740
     */
741
    float i_quant_factor;
742
    
743
    /**
744
     * qscale offset between p and i frames.
745
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
746
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
747
     * - encoding: set by user.
748
     * - decoding: unused
749
     */
750
    float i_quant_offset;
751
    
752
    /**
753
     * initial complexity for pass1 ratecontrol.
754
     * - encoding: set by user.
755
     * - decoding: unused
756
     */
757
    float rc_initial_cplx;
758

    
759
    /**
760
     * dct algorithm, see FF_DCT_* below.
761
     * - encoding: set by user
762
     * - decoding: unused
763
     */
764
    int dct_algo;
765
#define FF_DCT_AUTO    0
766
#define FF_DCT_FASTINT 1
767
#define FF_DCT_INT     2
768
#define FF_DCT_MMX     3
769
#define FF_DCT_MLIB    4
770
#define FF_DCT_ALTIVEC 5
771
    
772
    /**
773
     * luminance masking (0-> disabled).
774
     * - encoding: set by user
775
     * - decoding: unused
776
     */
777
    float lumi_masking;
778
    
779
    /**
780
     * temporary complexity masking (0-> disabled).
781
     * - encoding: set by user
782
     * - decoding: unused
783
     */
784
    float temporal_cplx_masking;
785
    
786
    /**
787
     * spatial complexity masking (0-> disabled).
788
     * - encoding: set by user
789
     * - decoding: unused
790
     */
791
    float spatial_cplx_masking;
792
    
793
    /**
794
     * p block masking (0-> disabled).
795
     * - encoding: set by user
796
     * - decoding: unused
797
     */
798
    float p_masking;
799

    
800
    /**
801
     * darkness masking (0-> disabled).
802
     * - encoding: set by user
803
     * - decoding: unused
804
     */
805
    float dark_masking;
806
    
807
    
808
    /* for binary compatibility */
809
    int unused;
810
    
811
    /**
812
     * idct algorithm, see FF_IDCT_* below.
813
     * - encoding: set by user
814
     * - decoding: set by user
815
     */
816
    int idct_algo;
817
#define FF_IDCT_AUTO         0
818
#define FF_IDCT_INT          1
819
#define FF_IDCT_SIMPLE       2
820
#define FF_IDCT_SIMPLEMMX    3
821
#define FF_IDCT_LIBMPEG2MMX  4
822
#define FF_IDCT_PS2          5
823
#define FF_IDCT_MLIB         6
824
#define FF_IDCT_ARM          7
825
#define FF_IDCT_ALTIVEC      8
826

    
827
    /**
828
     * slice count.
829
     * - encoding: set by lavc
830
     * - decoding: set by user (or 0)
831
     */
832
    int slice_count;
833
    /**
834
     * slice offsets in the frame in bytes.
835
     * - encoding: set/allocated by lavc
836
     * - decoding: set/allocated by user (or NULL)
837
     */
838
    int *slice_offset;
839

    
840
    /**
841
     * error concealment flags.
842
     * - encoding: unused
843
     * - decoding: set by user
844
     */
845
    int error_concealment;
846
#define FF_EC_GUESS_MVS   1
847
#define FF_EC_DEBLOCK     2
848

    
849
    /**
850
     * dsp_mask could be add used to disable unwanted CPU features
851
     * CPU features (i.e. MMX, SSE. ...)
852
     *
853
     * with FORCE flag you may instead enable given CPU features
854
     * (Dangerous: usable in case of misdetection, improper usage however will
855
     * result into program crash)
856
     */
857
    unsigned dsp_mask;
858
#define FF_MM_FORCE        0x80000000 /* force usage of selected flags (OR) */
859
    /* lower 16 bits - CPU features */
860
#ifdef HAVE_MMX
861
#define FF_MM_MMX        0x0001 /* standard MMX */
862
#define FF_MM_3DNOW        0x0004 /* AMD 3DNOW */
863
#define FF_MM_MMXEXT        0x0002 /* SSE integer functions or AMD MMX ext */
864
#define FF_MM_SSE        0x0008 /* SSE functions */
865
#define FF_MM_SSE2        0x0010 /* PIV SSE2 functions */
866
#endif /* HAVE_MMX */
867

    
868
    /**
869
     * bits per sample/pixel from the demuxer (needed for huffyuv).
870
     * - encoding: set by lavc
871
     * - decoding: set by user
872
     */
873
     int bits_per_sample;
874
    
875
    /**
876
     * prediction method (needed for huffyuv).
877
     * - encoding: set by user
878
     * - decoding: unused
879
     */
880
     int prediction_method;
881
#define FF_PRED_LEFT   0
882
#define FF_PRED_PLANE  1
883
#define FF_PRED_MEDIAN 2
884
    
885
    /**
886
     * aspect ratio (0 if unknown).
887
     * - encoding: set by user.
888
     * - decoding: set by lavc.
889
     */
890
    float aspect_ratio;
891

    
892
    /**
893
     * the picture in the bitstream.
894
     * - encoding: set by lavc
895
     * - decoding: set by lavc
896
     */
897
    AVFrame *coded_frame;
898

    
899
    /**
900
     * debug.
901
     * - encoding: set by user.
902
     * - decoding: set by user.
903
     */
904
    int debug;
905
#define FF_DEBUG_PICT_INFO 1
906
#define FF_DEBUG_RC        2
907
#define FF_DEBUG_BITSTREAM 4
908
#define FF_DEBUG_MB_TYPE   8
909
#define FF_DEBUG_QP        16
910
#define FF_DEBUG_MV        32
911
#define FF_DEBUG_VIS_MV    0x00000040
912
#define FF_DEBUG_SKIP      0x00000080
913
#define FF_DEBUG_STARTCODE 0x00000100
914
#define FF_DEBUG_PTS       0x00000200
915
#define FF_DEBUG_ER        0x00000400
916
#define FF_DEBUG_MMCO      0x00000800
917
    
918
    /**
919
     * error.
920
     * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
921
     * - decoding: unused
922
     */
923
    uint64_t error[4];
924
    
925
    /**
926
     * minimum MB quantizer.
927
     * - encoding: set by user.
928
     * - decoding: unused
929
     */
930
    int mb_qmin;
931

    
932
    /**
933
     * maximum MB quantizer.
934
     * - encoding: set by user.
935
     * - decoding: unused
936
     */
937
    int mb_qmax;
938
    
939
    /**
940
     * motion estimation compare function.
941
     * - encoding: set by user.
942
     * - decoding: unused
943
     */
944
    int me_cmp;
945
    /**
946
     * subpixel motion estimation compare function.
947
     * - encoding: set by user.
948
     * - decoding: unused
949
     */
950
    int me_sub_cmp;
951
    /**
952
     * macroblock compare function (not supported yet).
953
     * - encoding: set by user.
954
     * - decoding: unused
955
     */
956
    int mb_cmp;
957
#define FF_CMP_SAD  0
958
#define FF_CMP_SSE  1
959
#define FF_CMP_SATD 2
960
#define FF_CMP_DCT  3
961
#define FF_CMP_PSNR 4
962
#define FF_CMP_BIT  5
963
#define FF_CMP_RD   6
964
#define FF_CMP_ZERO 7
965
#define FF_CMP_CHROMA 256
966
    
967
    /**
968
     * ME diamond size & shape.
969
     * - encoding: set by user.
970
     * - decoding: unused
971
     */
972
    int dia_size;
973

    
974
    /**
975
     * amount of previous MV predictors (2a+1 x 2a+1 square).
976
     * - encoding: set by user.
977
     * - decoding: unused
978
     */
979
    int last_predictor_count;
980

    
981
    /**
982
     * pre pass for motion estimation.
983
     * - encoding: set by user.
984
     * - decoding: unused
985
     */
986
    int pre_me;
987

    
988
    /**
989
     * motion estimation pre pass compare function.
990
     * - encoding: set by user.
991
     * - decoding: unused
992
     */
993
    int me_pre_cmp;
994

    
995
    /**
996
     * ME pre pass diamond size & shape.
997
     * - encoding: set by user.
998
     * - decoding: unused
999
     */
1000
    int pre_dia_size;
1001

    
1002
    /**
1003
     * subpel ME quality.
1004
     * - encoding: set by user.
1005
     * - decoding: unused
1006
     */
1007
    int me_subpel_quality;
1008

    
1009
    /**
1010
     * callback to negotiate the pixelFormat.
1011
     * @param fmt is the list of formats which are supported by the codec,
1012
     * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1013
     * the first is allways the native one
1014
     * @return the choosen format
1015
     * - encoding: unused
1016
     * - decoding: set by user, if not set then the native format will always be choosen
1017
     */
1018
    enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1019

    
1020
    /**
1021
     * DTG active format information (additionnal aspect ratio
1022
     * information only used in DVB MPEG2 transport streams). 0 if
1023
     * not set.
1024
     * 
1025
     * - encoding: unused.
1026
     * - decoding: set by decoder 
1027
     */
1028
    int dtg_active_format;
1029
#define FF_DTG_AFD_SAME         8
1030
#define FF_DTG_AFD_4_3          9
1031
#define FF_DTG_AFD_16_9         10
1032
#define FF_DTG_AFD_14_9         11
1033
#define FF_DTG_AFD_4_3_SP_14_9  13
1034
#define FF_DTG_AFD_16_9_SP_14_9 14
1035
#define FF_DTG_AFD_SP_4_3       15
1036

    
1037
    /**
1038
     * Maximum motion estimation search range in subpel units.
1039
     * if 0 then no limit
1040
     * 
1041
     * - encoding: set by user.
1042
     * - decoding: unused.
1043
     */
1044
    int me_range;
1045

    
1046
    /**
1047
     * frame_rate_base.
1048
     * for variable fps this is 1
1049
     * - encoding: set by user.
1050
     * - decoding: set by lavc.
1051
     * @todo move this after frame_rate
1052
     */
1053

    
1054
    int frame_rate_base;
1055
    /**
1056
     * intra quantizer bias.
1057
     * - encoding: set by user.
1058
     * - decoding: unused
1059
     */
1060
    int intra_quant_bias;
1061
#define FF_DEFAULT_QUANT_BIAS 999999
1062
    
1063
    /**
1064
     * inter quantizer bias.
1065
     * - encoding: set by user.
1066
     * - decoding: unused
1067
     */
1068
    int inter_quant_bias;
1069
    
1070
} AVCodecContext;
1071

    
1072

    
1073
/**
1074
 * AVOption.
1075
 */
1076
typedef struct AVOption {
1077
    /** options' name */
1078
    const char *name; /* if name is NULL, it indicates a link to next */
1079
    /** short English text help or const struct AVOption* subpointer */
1080
    const char *help; //        const struct AVOption* sub;
1081
    /** offset to context structure where the parsed value should be stored */
1082
    int offset;
1083
    /** options' type */
1084
    int type;
1085
#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
1086
#define FF_OPT_TYPE_DOUBLE 2    ///< double
1087
#define FF_OPT_TYPE_INT 3       ///< integer
1088
#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
1089
#define FF_OPT_TYPE_MASK 0x1f        ///< mask for types - upper bits are various flags
1090
//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1091
#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1092
#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1093
    /** min value  (min == max   ->  no limits) */
1094
    double min;
1095
    /** maximum value for double/int */
1096
    double max;
1097
    /** default boo [0,1]l/double/int value */
1098
    double defval;
1099
    /**
1100
     * default string value (with optional semicolon delimited extra option-list
1101
     * i.e.   option1;option2;option3
1102
     * defval might select other then first argument as default
1103
     */
1104
    const char *defstr;
1105
#define FF_OPT_MAX_DEPTH 10
1106
} AVOption;
1107

    
1108
/**
1109
 * Parse option(s) and sets fields in passed structure
1110
 * @param strct        structure where the parsed results will be written
1111
 * @param list  list with AVOptions
1112
 * @param opts        string with options for parsing
1113
 */
1114
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1115

    
1116

    
1117
/**
1118
 * AVCodec.
1119
 */
1120
typedef struct AVCodec {
1121
    const char *name;
1122
    int type;
1123
    int id;
1124
    int priv_data_size;
1125
    int (*init)(AVCodecContext *);
1126
    int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1127
    int (*close)(AVCodecContext *);
1128
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1129
                  uint8_t *buf, int buf_size);
1130
    int capabilities;
1131
    const AVOption *options;
1132
    struct AVCodec *next;
1133
} AVCodec;
1134

    
1135
/**
1136
 * four components are given, that's all.
1137
 * the last component is alpha
1138
 */
1139
typedef struct AVPicture {
1140
    uint8_t *data[4];
1141
    int linesize[4];
1142
} AVPicture;
1143

    
1144
extern AVCodec ac3_encoder;
1145
extern AVCodec mp2_encoder;
1146
extern AVCodec mp3lame_encoder;
1147
extern AVCodec oggvorbis_encoder;
1148
extern AVCodec mpeg1video_encoder;
1149
extern AVCodec h263_encoder;
1150
extern AVCodec h263p_encoder;
1151
extern AVCodec rv10_encoder;
1152
extern AVCodec mjpeg_encoder;
1153
extern AVCodec mpeg4_encoder;
1154
extern AVCodec msmpeg4v1_encoder;
1155
extern AVCodec msmpeg4v2_encoder;
1156
extern AVCodec msmpeg4v3_encoder;
1157
extern AVCodec wmv1_encoder;
1158
extern AVCodec wmv2_encoder;
1159
extern AVCodec huffyuv_encoder;
1160
extern AVCodec h264_encoder;
1161

    
1162
extern AVCodec h263_decoder;
1163
extern AVCodec mpeg4_decoder;
1164
extern AVCodec msmpeg4v1_decoder;
1165
extern AVCodec msmpeg4v2_decoder;
1166
extern AVCodec msmpeg4v3_decoder;
1167
extern AVCodec wmv1_decoder;
1168
extern AVCodec wmv2_decoder;
1169
extern AVCodec mpeg_decoder;
1170
extern AVCodec h263i_decoder;
1171
extern AVCodec rv10_decoder;
1172
extern AVCodec svq1_decoder;
1173
extern AVCodec dvvideo_decoder;
1174
extern AVCodec dvaudio_decoder;
1175
extern AVCodec wmav1_decoder;
1176
extern AVCodec wmav2_decoder;
1177
extern AVCodec mjpeg_decoder;
1178
extern AVCodec mjpegb_decoder;
1179
extern AVCodec mp2_decoder;
1180
extern AVCodec mp3_decoder;
1181
extern AVCodec mace3_decoder;
1182
extern AVCodec mace6_decoder;
1183
extern AVCodec huffyuv_decoder;
1184
extern AVCodec oggvorbis_decoder;
1185
extern AVCodec cyuv_decoder;
1186
extern AVCodec h264_decoder;
1187
extern AVCodec indeo3_decoder;
1188

    
1189
/* pcm codecs */
1190
#define PCM_CODEC(id, name) \
1191
extern AVCodec name ## _decoder; \
1192
extern AVCodec name ## _encoder
1193

    
1194
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1195
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1196
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1197
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1198
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1199
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1200
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1201
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1202

    
1203
/* adpcm codecs */
1204

    
1205
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1206
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1207
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1208

    
1209
#undef PCM_CODEC
1210

    
1211
/* dummy raw video codec */
1212
extern AVCodec rawvideo_codec;
1213

    
1214
/* the following codecs use external GPL libs */
1215
extern AVCodec ac3_decoder;
1216

    
1217
/* resample.c */
1218

    
1219
struct ReSampleContext;
1220

    
1221
typedef struct ReSampleContext ReSampleContext;
1222

    
1223
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1224
                                     int output_rate, int input_rate);
1225
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1226
void audio_resample_close(ReSampleContext *s);
1227

    
1228
/* YUV420 format is assumed ! */
1229

    
1230
struct ImgReSampleContext;
1231

    
1232
typedef struct ImgReSampleContext ImgReSampleContext;
1233

    
1234
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1235
                                      int input_width, int input_height);
1236

    
1237
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1238
                                      int iwidth, int iheight,
1239
                                      int topBand, int bottomBand,
1240
                                      int leftBand, int rightBand);
1241

    
1242
void img_resample(ImgReSampleContext *s, 
1243
                  AVPicture *output, AVPicture *input);
1244

    
1245
void img_resample_close(ImgReSampleContext *s);
1246

    
1247
int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1248
                   int pix_fmt, int width, int height);
1249
int avpicture_get_size(int pix_fmt, int width, int height);
1250
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1251
const char *avcodec_get_pix_fmt_name(int pix_fmt);
1252

    
1253
/* convert among pixel formats */
1254
int img_convert(AVPicture *dst, int dst_pix_fmt,
1255
                AVPicture *src, int pix_fmt, 
1256
                int width, int height);
1257

    
1258
/* deinterlace a picture */
1259
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1260
                          int pix_fmt, int width, int height);
1261

    
1262
/* external high level API */
1263

    
1264
extern AVCodec *first_avcodec;
1265

    
1266
/* returns LIBAVCODEC_VERSION_INT constant */
1267
unsigned avcodec_version(void);
1268
/* returns LIBAVCODEC_BUILD constant */
1269
unsigned avcodec_build(void);
1270
void avcodec_init(void);
1271

    
1272
void register_avcodec(AVCodec *format);
1273
AVCodec *avcodec_find_encoder(enum CodecID id);
1274
AVCodec *avcodec_find_encoder_by_name(const char *name);
1275
AVCodec *avcodec_find_decoder(enum CodecID id);
1276
AVCodec *avcodec_find_decoder_by_name(const char *name);
1277
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1278

    
1279
void avcodec_get_context_defaults(AVCodecContext *s);
1280
AVCodecContext *avcodec_alloc_context(void);
1281
AVFrame *avcodec_alloc_frame(void);
1282

    
1283
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1284
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1285

    
1286
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1287
int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, 
1288
                         int *frame_size_ptr,
1289
                         uint8_t *buf, int buf_size);
1290
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1291
                         int *got_picture_ptr,
1292
                         uint8_t *buf, int buf_size);
1293
int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, 
1294
                        int *data_size_ptr,
1295
                        uint8_t *buf, int buf_size);
1296
int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1297
                         const short *samples);
1298
int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, 
1299
                         const AVFrame *pict);
1300

    
1301
int avcodec_close(AVCodecContext *avctx);
1302

    
1303
void avcodec_register_all(void);
1304

    
1305
void avcodec_flush_buffers(AVCodecContext *avctx);
1306

    
1307
/* misc usefull functions */
1308
/**
1309
 * reduce a fraction.
1310
 * this is usefull for framerate calculations
1311
 * @param max the maximum allowed for dst_nom & dst_den
1312
 * @return 1 if exact, 0 otherwise
1313
 */
1314
int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1315

    
1316
/**
1317
 * rescale a 64bit integer.
1318
 * a simple a*b/c isnt possible as it can overflow
1319
 */
1320
int64_t av_rescale(int64_t a, int b, int c);
1321

    
1322

    
1323
/**
1324
 * Interface for 0.5.0 version
1325
 *
1326
 * do not even think about it's usage for this moment
1327
 */
1328

    
1329
typedef struct {
1330
    /// compressed size used from given memory buffer
1331
    int size;
1332
    /// I/P/B frame type
1333
    int frame_type;
1334
} avc_enc_result_t;
1335

    
1336
/**
1337
 * Commands
1338
 * order can't be changed - once it was defined
1339
 */
1340
typedef enum {
1341
    // general commands
1342
    AVC_OPEN_BY_NAME = 0xACA000,
1343
    AVC_OPEN_BY_CODEC_ID,
1344
    AVC_OPEN_BY_FOURCC,
1345
    AVC_CLOSE,
1346

    
1347
    AVC_FLUSH,
1348
    // pin - struct { uint8_t* src, uint_t src_size }
1349
    // pout - struct { AVPicture* img, consumed_bytes,
1350
    AVC_DECODE,
1351
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1352
    // pout - uint_t used_from_dest_size
1353
    AVC_ENCODE, 
1354

    
1355
    // query/get video commands
1356
    AVC_GET_VERSION = 0xACB000,
1357
    AVC_GET_WIDTH,
1358
    AVC_GET_HEIGHT,
1359
    AVC_GET_DELAY,
1360
    AVC_GET_QUANT_TABLE,
1361
    // ...
1362

    
1363
    // query/get audio commands
1364
    AVC_GET_FRAME_SIZE = 0xABC000,
1365

    
1366
    // maybe define some simple structure which
1367
    // might be passed to the user - but they can't
1368
    // contain any codec specific parts and these
1369
    // calls are usualy necessary only few times
1370

    
1371
    // set video commands
1372
    AVC_SET_WIDTH = 0xACD000,
1373
    AVC_SET_HEIGHT,
1374

    
1375
    // set video encoding commands
1376
    AVC_SET_FRAME_RATE = 0xACD800,
1377
    AVC_SET_QUALITY,
1378
    AVC_SET_HURRY_UP,
1379

    
1380
    // set audio commands
1381
    AVC_SET_SAMPLE_RATE = 0xACE000,
1382
    AVC_SET_CHANNELS,
1383

    
1384
} avc_cmd_t;
1385

    
1386
/**
1387
 * \param handle  allocated private structure by libavcodec
1388
 *                for initialization pass NULL - will be returned pout
1389
 *                user is supposed to know nothing about its structure
1390
 * \param cmd     type of operation to be performed
1391
 * \param pint    input parameter
1392
 * \param pout    output parameter
1393
 *
1394
 * \returns  command status - eventually for query command it might return
1395
 * integer resulting value
1396
 */
1397
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1398

    
1399
/* memory */
1400
void *av_malloc(unsigned int size);
1401
void *av_mallocz(unsigned int size);
1402
void *av_realloc(void *ptr, unsigned int size);
1403
void av_free(void *ptr);
1404
char *av_strdup(const char *s);
1405
void __av_freep(void **ptr);
1406
#define av_freep(p) __av_freep((void **)(p))
1407
void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1408
/* for static data only */
1409
/* call av_free_static to release all staticaly allocated tables */
1410
void av_free_static(void);
1411
void *__av_mallocz_static(void** location, unsigned int size);
1412
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1413

    
1414
#ifdef __cplusplus
1415
}
1416
#endif
1417

    
1418
#endif /* AVCODEC_H */