Statistics
| Branch: | Revision:

ffmpeg / libavcodec / avcodec.h @ 628d601b

History | View | Annotate | Download (33.7 KB)

1
#ifndef AVCODEC_H
2
#define AVCODEC_H
3

    
4
#include "common.h"
5

    
6
#define LIBAVCODEC_VERSION_INT 0x000406
7
#define LIBAVCODEC_VERSION     "0.4.6"
8
#define LIBAVCODEC_BUILD       4652
9
#define LIBAVCODEC_BUILD_STR   "4652"
10

    
11
enum CodecID {
12
    CODEC_ID_NONE, 
13
    CODEC_ID_MPEG1VIDEO,
14
    CODEC_ID_H263,
15
    CODEC_ID_RV10,
16
    CODEC_ID_MP2,
17
    CODEC_ID_MP3LAME,
18
    CODEC_ID_VORBIS,
19
    CODEC_ID_AC3,
20
    CODEC_ID_MJPEG,
21
    CODEC_ID_MJPEGB,
22
    CODEC_ID_MPEG4,
23
    CODEC_ID_RAWVIDEO,
24
    CODEC_ID_MSMPEG4V1,
25
    CODEC_ID_MSMPEG4V2,
26
    CODEC_ID_MSMPEG4V3,
27
    CODEC_ID_WMV1,
28
    CODEC_ID_WMV2,
29
    CODEC_ID_H263P,
30
    CODEC_ID_H263I,
31
    CODEC_ID_SVQ1,
32
    CODEC_ID_DVVIDEO,
33
    CODEC_ID_DVAUDIO,
34
    CODEC_ID_WMAV1,
35
    CODEC_ID_WMAV2,
36
    CODEC_ID_MACE3,
37
    CODEC_ID_MACE6,
38
    CODEC_ID_HUFFYUV,
39

    
40
    /* various pcm "codecs" */
41
    CODEC_ID_PCM_S16LE,
42
    CODEC_ID_PCM_S16BE,
43
    CODEC_ID_PCM_U16LE,
44
    CODEC_ID_PCM_U16BE,
45
    CODEC_ID_PCM_S8,
46
    CODEC_ID_PCM_U8,
47
    CODEC_ID_PCM_MULAW,
48
    CODEC_ID_PCM_ALAW,
49

    
50
    /* various adpcm codecs */
51
    CODEC_ID_ADPCM_IMA_QT,
52
    CODEC_ID_ADPCM_IMA_WAV,
53
    CODEC_ID_ADPCM_MS,
54
};
55

    
56
enum CodecType {
57
    CODEC_TYPE_UNKNOWN = -1,
58
    CODEC_TYPE_VIDEO,
59
    CODEC_TYPE_AUDIO,
60
};
61

    
62
enum PixelFormat {
63
    PIX_FMT_YUV420P,
64
    PIX_FMT_YUV422,
65
    PIX_FMT_RGB24,
66
    PIX_FMT_BGR24,
67
    PIX_FMT_YUV422P,
68
    PIX_FMT_YUV444P,
69
    PIX_FMT_RGBA32,
70
    PIX_FMT_BGRA32,
71
    PIX_FMT_YUV410P,
72
    PIX_FMT_YUV411P,
73
    PIX_FMT_RGB565,
74
    PIX_FMT_RGB555,
75
//    PIX_FMT_RGB5551,
76
    PIX_FMT_BGR565,
77
    PIX_FMT_BGR555,
78
//    PIX_FMT_GBR565,
79
//    PIX_FMT_GBR555
80
};
81

    
82
/* currently unused, may be used if 24/32 bits samples ever supported */
83
enum SampleFormat {
84
    SAMPLE_FMT_S16 = 0,         /* signed 16 bits */
85
};
86

    
87
/* in bytes */
88
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
89

    
90
/**
91
 * Required number of zero bytes at the end of the input bitstream for decoding.
92
 * to avoid overreading (and possibly segfaulting)
93
 */
94
#define FF_INPUT_BUFFER_PADDING_SIZE 8
95

    
96
/* motion estimation type, EPZS by default */
97
enum Motion_Est_ID {
98
    ME_ZERO = 1,
99
    ME_FULL,
100
    ME_LOG,
101
    ME_PHODS,
102
    ME_EPZS,
103
    ME_X1
104
};
105

    
106
typedef struct RcOverride{
107
    int start_frame;
108
    int end_frame;
109
    int qscale; // if this is 0 then quality_factor will be used instead
110
    float quality_factor;
111
} RcOverride;
112

    
113
/* only for ME compatiblity with old apps */
114
extern int motion_estimation_method;
115

    
116
/* ME algos sorted by quality */
117
static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG, 
118
                                       ME_X1, ME_EPZS, ME_FULL };
119

    
120

    
121
#define FF_MAX_B_FRAMES 8
122

    
123
/* encoding support
124
   these flags can be passed in AVCodecContext.flags before initing 
125
   Note: note not everything is supported yet 
126
*/
127

    
128
#define CODEC_FLAG_HQ     0x0001  /* brute force MB-type decission mode (slow) */
129
#define CODEC_FLAG_QSCALE 0x0002  /* use fixed qscale */
130
#define CODEC_FLAG_4MV    0x0004  /* 4 MV per MB allowed */
131
#define CODEC_FLAG_QPEL   0x0010  /* use qpel MC */
132
#define CODEC_FLAG_GMC    0x0020  /* use GMC */
133
#define CODEC_FLAG_PART   0x0080  /* use data partitioning */
134
/* parent program gurantees that the input for b-frame containing streams is not written to 
135
   for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
136
#define CODEC_FLAG_INPUT_PRESERVED 0x0100
137
#define CODEC_FLAG_PASS1 0x0200   /* use internal 2pass ratecontrol in first  pass mode */
138
#define CODEC_FLAG_PASS2 0x0400   /* use internal 2pass ratecontrol in second pass mode */
139
#define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */
140
#define CODEC_FLAG_GRAY  0x2000   /* only decode/encode grayscale */
141
#define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */
142
#define CODEC_FLAG_PSNR           0x8000 /* error[?] variables will be set during encoding */
143
#define CODEC_FLAG_TRUNCATED  0x00010000 /* input bitstream might be truncated at a random location instead 
144
                                            of only at frame boundaries */
145
#define CODEC_FLAG_NORMALIZE_AQP  0x00020000 /* normalize adaptive quantization */
146
#define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */
147
#define CODEC_FLAG_LOW_DELAY      0x00080000 /* force low delay / will fail on b frames */
148
#define CODEC_FLAG_ALT_SCAN       0x00100000 /* use alternate scan */
149
#define CODEC_FLAG_TRELLIS_QUANT  0x00200000 /* use trellis quantization */
150
#define CODEC_FLAG_GLOBAL_HEADER  0x00400000 /* place global headers in extradata instead of every keyframe */
151

    
152
/* codec capabilities */
153

    
154
#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 /* decoder can use draw_horiz_band callback */
155
#define CODEC_CAP_DR1             0x0002 /* direct rendering method 1 */
156
/* if 'parse_only' field is true, then avcodec_parse_frame() can be
157
   used */
158
#define CODEC_CAP_PARSE_ONLY      0x0004
159
#define CODEC_CAP_TRUNCATED       0x0008
160

    
161
#define FRAME_RATE_BASE 10000
162

    
163
#define FF_COMMON_FRAME \
164
    uint8_t *data[4];\
165
    int linesize[4];\
166
    /**\
167
     * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
168
     * this isnt used by lavc unless the default get/release_buffer() is used\
169
     * encoding: \
170
     * decoding: \
171
     */\
172
    uint8_t *base[4];\
173
    /**\
174
     * 1 -> keyframe, 0-> not\
175
     * encoding: set by lavc\
176
     * decoding: set by lavc\
177
     */\
178
    int key_frame;\
179
\
180
    /**\
181
     * picture type of the frame, see ?_TYPE below\
182
     * encoding: set by lavc for coded_picture (and set by user for input)\
183
     * decoding: set by lavc\
184
     */\
185
    int pict_type;\
186
\
187
    /**\
188
     * presentation timestamp in micro seconds (time when frame should be shown to user)\
189
     * if 0 then the frame_rate will be used as reference\
190
     * encoding: MUST be set by user\
191
     * decoding: set by lavc\
192
     */\
193
    long long int pts;\
194
\
195
    /**\
196
     * picture number in bitstream order.\
197
     * encoding: set by\
198
     * decoding: set by lavc\
199
     */\
200
    int coded_picture_number;\
201
    /**\
202
     * encoding: set by\
203
     * decoding: set by lavc\
204
     * picture number in display order.\
205
     */\
206
    int display_picture_number;\
207
\
208
    /**\
209
     * quality (between 1 (good) and 31 (bad)) \
210
     * encoding: set by lavc for coded_picture (and set by user for input)\
211
     * decoding: set by lavc\
212
     */\
213
    float quality; \
214
\
215
    /**\
216
     * buffer age (1->was last buffer and dint change, 2->..., ...).\
217
     * set to something large if the buffer has not been used yet \
218
     * encoding: unused\
219
     * decoding: MUST be set by get_buffer()\
220
     */\
221
    int age;\
222
\
223
    /**\
224
     * is this picture used as reference\
225
     * encoding: unused\
226
     * decoding: set by lavc (before get_buffer() call))\
227
     */\
228
    int reference;\
229
\
230
    /**\
231
     * QP table\
232
     * encoding: unused\
233
     * decoding: set by lavc\
234
     */\
235
    int8_t *qscale_table;\
236
    /**\
237
     * QP store stride\
238
     * encoding: unused\
239
     * decoding: set by lavc\
240
     */\
241
    int qstride;\
242
\
243
    /**\
244
     * mbskip_table[mb]>=1 if MB didnt change\
245
     * stride= mb_width = (width+15)>>4\
246
     * encoding: unused\
247
     * decoding: set by lavc\
248
     */\
249
    uint8_t *mbskip_table;\
250
\
251
    /**\
252
     * for some private data of the user\
253
     * encoding: unused\
254
     * decoding: set by user\
255
     */\
256
    void *opaque;\
257
\
258
    /**\
259
     * error\
260
     * encoding: set by lavc if flags&CODEC_FLAG_PSNR\
261
     * decoding: unused\
262
     */\
263
    uint64_t error[4];\
264
\
265
    /**\
266
     * type of the buffer (to keep track of who has to dealloc data[*])\
267
     * encoding: set by the one who allocs it\
268
     * decoding: set by the one who allocs it\
269
     * Note: user allocated (direct rendering) & internal buffers can not coexist currently\ 
270
     */\
271
    int type;\
272

    
273
#define FF_BUFFER_TYPE_INTERNAL 1
274
#define FF_BUFFER_TYPE_USER     2 // Direct rendering buffers
275
#define FF_BUFFER_TYPE_SHARED   4 // input frame for encoding(wont be dealloced)
276

    
277

    
278
#define FF_I_TYPE 1 // Intra
279
#define FF_P_TYPE 2 // Predicted
280
#define FF_B_TYPE 3 // Bi-dir predicted
281
#define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
282

    
283
typedef struct AVFrame {
284
    FF_COMMON_FRAME
285
} AVFrame;
286

    
287
typedef struct AVCodecContext {
288
    /**
289
     * the average bitrate
290
     * encoding: set by user. unused for constant quantizer encoding
291
     * decoding: set by lavc. 0 or some bitrate if this info is available in the stream 
292
     */
293
    int bit_rate;
294

    
295
    /**
296
     * number of bits the bitstream is allowed to diverge from the reference
297
     *           the reference can be CBR (for CBR pass1) or VBR (for pass2)
298
     * encoding: set by user. unused for constant quantizer encoding
299
     * decoding: unused
300
     */
301
    int bit_rate_tolerance; 
302

    
303
    /**
304
     * CODEC_FLAG_*
305
     * encoding: set by user.
306
     * decoding: set by user.
307
     */
308
    int flags;
309

    
310
    /**
311
     * some codecs needs additionnal format info. It is stored here
312
     * encoding: set by user. 
313
     * decoding: set by lavc. (FIXME is this ok?)
314
     */
315
    int sub_id;
316

    
317
    /**
318
     * motion estimation algorithm used for video coding
319
     * encoding: MUST be set by user.
320
     * decoding: unused
321
     */
322
    int me_method;
323

    
324
    /**
325
     * some codecs need / can use extra-data like huffman tables
326
     * mjpeg: huffman tables
327
     * rv10: additional flags
328
     * mpeg4: global headers (they can be in the bitstream or here)
329
     * encoding: set/allocated/freed by lavc.
330
     * decoding: set/allocated/freed by user.
331
     */
332
    void *extradata;
333
    int extradata_size;
334
    
335
    /* video only */
336
    /**
337
     * frames per sec multiplied by FRAME_RATE_BASE
338
     * for variable fps this is the precission, so if the timestamps 
339
     * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
340
     * encoding: MUST be set by user
341
     * decoding: set by lavc. 0 or the frame_rate if available
342
     */
343
    int frame_rate;
344

    
345
    /**
346
     * encoding: MUST be set by user. 
347
     * decoding: set by user, some codecs might override / change it during playback
348
     */
349
    int width, height;
350
    
351
#define FF_ASPECT_SQUARE 1
352
#define FF_ASPECT_4_3_625 2
353
#define FF_ASPECT_4_3_525 3
354
#define FF_ASPECT_16_9_625 4
355
#define FF_ASPECT_16_9_525 5
356
#define FF_ASPECT_EXTENDED 15
357

    
358
    /**
359
     * the number of pictures in a group of pitures, or 0 for intra_only
360
     * encoding: set by user.
361
     * decoding: unused
362
     */
363
    int gop_size;
364

    
365
    /**
366
     * pixel format, see PIX_FMT_xxx
367
     * encoding: unused
368
     * decoding: set by lavc.
369
     */
370
    enum PixelFormat pix_fmt;
371
    
372
    int repeat_pict; /* when decoding, this signal how much the picture */
373
                     /* must be delayed.                                */
374
                     /* extra_delay = (repeat_pict / 2) * (1/fps)       */
375
    
376
    /**
377
     * if non NULL, 'draw_horiz_band' is called by the libavcodec
378
     * decoder to draw an horizontal band. It improve cache usage. Not
379
     * all codecs can do that. You must check the codec capabilities
380
     * before
381
     * encoding: unused
382
     * decoding: set by user.
383
     */
384
    void (*draw_horiz_band)(struct AVCodecContext *s,
385
                            UINT8 **src_ptr, int linesize,
386
                            int y, int width, int height);
387

    
388
    /* audio only */
389
    int sample_rate; /* samples per sec */
390
    int channels;
391
    int sample_fmt;  /* sample format, currenly unused */
392

    
393
    /* the following data should not be initialized */
394
    int frame_size;     /* in samples, initialized when calling 'init' */
395
    int frame_number;   /* audio or video frame number */
396
    int real_pict_num;  /* returns the real picture number of
397
                           previous encoded frame */
398
    
399
    /**
400
     * number of frames the decoded output will be delayed relative to 
401
     * the encoded input
402
     * encoding: set by lavc.
403
     * decoding: unused
404
     */
405
    int delay;
406
    
407
    /* encoding parameters */
408
    float qcompress;  /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
409
    float qblur;      /* amount of qscale smoothing over time (0.0-1.0) */
410
    
411
    /**
412
     * minimum quantizer
413
     * encoding: set by user.
414
     * decoding: unused
415
     */
416
    int qmin;
417

    
418
    /**
419
     * maximum quantizer
420
     * encoding: set by user.
421
     * decoding: unused
422
     */
423
    int qmax;
424

    
425
    /**
426
     * maximum quantizer difference etween frames
427
     * encoding: set by user.
428
     * decoding: unused
429
     */
430
    int max_qdiff;
431

    
432
    /**
433
     * maximum number of b frames between non b frames
434
     * note: the output will be delayed by max_b_frames+1 relative to the input
435
     * encoding: set by user.
436
     * decoding: unused
437
     */
438
    int max_b_frames;
439

    
440
    /**
441
     * qscale factor between ip and b frames
442
     * encoding: set by user.
443
     * decoding: unused
444
     */
445
    float b_quant_factor;
446
    
447
    /** obsolete FIXME remove */
448
    int rc_strategy;
449
    int b_frame_strategy;
450

    
451
    /**
452
     * encoding: unused
453
     * decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
454
     */
455
    int hurry_up;
456
    
457
    struct AVCodec *codec;
458
    
459
    void *priv_data;
460

    
461
    /* The following data is for RTP friendly coding */
462
    /* By now only H.263/H.263+/MPEG4 coder honours this   */
463
    int rtp_mode;   /* 1 for activate RTP friendly-mode           */
464
                    /* highers numbers represent more error-prone */
465
                    /* enviroments, by now just "1" exist         */
466
    
467
    int rtp_payload_size;   /* The size of the RTP payload, the coder will  */
468
                            /* do it's best to deliver a chunk with size    */
469
                            /* below rtp_payload_size, the chunk will start */
470
                            /* with a start code on some codecs like H.263  */
471
                            /* This doesn't take account of any particular  */
472
                            /* headers inside the transmited RTP payload    */
473

    
474
    
475
    /* The RTP callcack: This function is called  */
476
    /* every time the encoder as a packet to send */
477
    /* Depends on the encoder if the data starts  */
478
    /* with a Start Code (it should) H.263 does   */
479
    void (*rtp_callback)(void *data, int size, int packet_number); 
480

    
481
    /* statistics, used for 2-pass encoding */
482
    int mv_bits;
483
    int header_bits;
484
    int i_tex_bits;
485
    int p_tex_bits;
486
    int i_count;
487
    int p_count;
488
    int skip_count;
489
    int misc_bits;
490
    
491
    /**
492
     * number of bits used for the previously encoded frame
493
     * encoding: set by lavc
494
     * decoding: - for audio - bits_per_sample
495
     */
496
    int frame_bits;
497
                 
498
    /**
499
     * private data of the user, can be used to carry app specific stuff
500
     * encoding: set by user
501
     * decoding: set by user
502
     */
503
    void *opaque;
504

    
505
    char codec_name[32];
506
    enum CodecType codec_type; /* see CODEC_TYPE_xxx */
507
    enum CodecID codec_id; /* see CODEC_ID_xxx */
508
    unsigned int codec_tag;  /* codec tag, only used if unknown codec */
509
    
510
    /**
511
     * workaround bugs in encoders which sometimes cannot be detected automatically
512
     * encoding: unused
513
     * decoding: set by user
514
     */
515
    int workaround_bugs;
516
#define FF_BUG_AUTODETECT       1  //autodetection
517
#define FF_BUG_OLD_MSMPEG4      2
518
#define FF_BUG_XVID_ILACE       4
519
#define FF_BUG_UMP4             8
520
#define FF_BUG_NO_PADDING       16
521
#define FF_BUG_AC_VLC           32
522
#define FF_BUG_QPEL_CHROMA      64
523
//#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
524
        
525
    /**
526
     * encoding: set by user
527
     * decoding: unused
528
     */
529
    int luma_elim_threshold;
530
    
531
    /**
532
     * encoding: set by user
533
     * decoding: unused
534
     */
535
    int chroma_elim_threshold;
536
    
537
    /**
538
     * strictly follow the std (MPEG4, ...)
539
     * encoding: set by user
540
     * decoding: unused
541
     */
542
    int strict_std_compliance;
543
    
544
    /**
545
     * qscale offset between ip and b frames
546
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
547
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
548
     * encoding: set by user.
549
     * decoding: unused
550
     */
551
    float b_quant_offset;
552
    
553
    /**
554
     * error resilience higher values will detect more errors but may missdetect
555
     * some more or less valid parts as errors
556
     * encoding: unused
557
     * decoding: set by user
558
     */
559
    int error_resilience;
560
#define FF_ER_CAREFULL        1
561
#define FF_ER_COMPLIANT       2
562
#define FF_ER_AGGRESSIVE      3
563
#define FF_ER_VERY_AGGRESSIVE 4
564
    
565
    /**
566
     * called at the beginning of each frame to get a buffer for it.
567
     * if pic.reference is set then the frame will be read later by lavc
568
     * encoding: unused
569
     * decoding: set by lavc, user can override
570
     */
571
    int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
572
    
573
    /**
574
     * called to release buffers which where allocated with get_buffer.
575
     * a released buffer can be reused in get_buffer()
576
     * pic.data[*] must be set to NULL
577
     * encoding: unused
578
     * decoding: set by lavc, user can override
579
     */
580
    void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
581

    
582
    /**
583
     * is 1 if the decoded stream contains b frames, 0 otherwise
584
     * encoding: unused
585
     * decoding: set by lavc
586
     */
587
    int has_b_frames;
588
    
589
    int block_align; /* used by some WAV based audio codecs */
590
    
591
    int parse_only; /* decoding only: if true, only parsing is done
592
                       (function avcodec_parse_frame()). The frame
593
                       data is returned. Only MPEG codecs support this now. */
594
    
595
    /**
596
     * 0-> h263 quant 1-> mpeg quant
597
     * encoding: set by user.
598
     * decoding: unused
599
     */
600
    int mpeg_quant;
601
    
602
    /**
603
     * pass1 encoding statistics output buffer
604
     * encoding: set by lavc
605
     * decoding: unused
606
     */
607
    char *stats_out; /* encoding statistics output buffer */
608
    
609
    /**
610
     * pass2 encoding statistics input buffer.
611
     * concatenated stuff from stats_out of pass1 should be placed here
612
     * encoding: allocated/set/freed by user
613
     * decoding: unused
614
     */
615
    char *stats_in;
616
    
617
    /**
618
     * ratecontrol qmin qmax limiting method
619
     * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
620
     * encoding: set by user.
621
     * decoding: unused
622
     */
623
    float rc_qsquish;
624

    
625
    float rc_qmod_amp;
626
    int rc_qmod_freq;
627
    
628
    /**
629
     * ratecontrol override, see RcOverride
630
     * encoding: allocated/set/freed by user.
631
     * decoding: unused
632
     */
633
    RcOverride *rc_override;
634
    int rc_override_count;
635
    
636
    /**
637
     * rate control equation
638
     * encoding: set by user
639
     * decoding: unused
640
     */
641
    char *rc_eq;
642
    
643
    /**
644
     * maximum bitrate
645
     * encoding: set by user.
646
     * decoding: unused
647
     */
648
    int rc_max_rate;
649
    
650
    /**
651
     * minimum bitrate
652
     * encoding: set by user.
653
     * decoding: unused
654
     */
655
    int rc_min_rate;
656
    
657
    /**
658
     * decoder bitstream buffer size
659
     * encoding: set by user.
660
     * decoding: unused
661
     */
662
    int rc_buffer_size;
663
    float rc_buffer_aggressivity;
664

    
665
    /**
666
     * qscale factor between p and i frames
667
     * encoding: set by user.
668
     * decoding: unused
669
     */
670
    float i_quant_factor;
671
    
672
    /**
673
     * qscale offset between p and i frames
674
     * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
675
     * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
676
     * encoding: set by user.
677
     * decoding: unused
678
     */
679
    float i_quant_offset;
680
    
681
    /**
682
     * initial complexity for pass1 ratecontrol
683
     * encoding: set by user.
684
     * decoding: unused
685
     */
686
    float rc_initial_cplx;
687

    
688
    /**
689
     * dct algorithm, see FF_DCT_* below
690
     * encoding: set by user
691
     * decoding: unused
692
     */
693
    int dct_algo;
694
#define FF_DCT_AUTO    0
695
#define FF_DCT_FASTINT 1
696
#define FF_DCT_INT     2
697
#define FF_DCT_MMX     3
698
#define FF_DCT_MLIB    4
699
#define FF_DCT_ALTIVEC 5
700
    
701
    /**
702
     * luminance masking (0-> disabled)
703
     * encoding: set by user
704
     * decoding: unused
705
     */
706
    float lumi_masking;
707
    
708
    /**
709
     * temporary complexity masking (0-> disabled)
710
     * encoding: set by user
711
     * decoding: unused
712
     */
713
    float temporal_cplx_masking;
714
    
715
    /**
716
     * spatial complexity masking (0-> disabled)
717
     * encoding: set by user
718
     * decoding: unused
719
     */
720
    float spatial_cplx_masking;
721
    
722
    /**
723
     * p block masking (0-> disabled)
724
     * encoding: set by user
725
     * decoding: unused
726
     */
727
    float p_masking;
728

    
729
    /**
730
     * darkness masking (0-> disabled)
731
     * encoding: set by user
732
     * decoding: unused
733
     */
734
    float dark_masking;
735
    
736
    /**
737
     * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A')
738
     * this is used to workaround some encoder bugs
739
     * encoding: unused
740
     * decoding: set by user, will be converted to upper case by lavc during init
741
     */
742
    int fourcc;
743

    
744
    /**
745
     * idct algorithm, see FF_IDCT_* below
746
     * encoding: set by user
747
     * decoding: set by user
748
     */
749
    int idct_algo;
750
#define FF_IDCT_AUTO         0
751
#define FF_IDCT_INT          1
752
#define FF_IDCT_SIMPLE       2
753
#define FF_IDCT_SIMPLEMMX    3
754
#define FF_IDCT_LIBMPEG2MMX  4
755
#define FF_IDCT_PS2          5
756
#define FF_IDCT_MLIB         6
757
#define FF_IDCT_ARM          7
758
#define FF_IDCT_ALTIVEC      8
759

    
760
    /**
761
     * slice count
762
     * encoding: set by lavc
763
     * decoding: set by user (or 0)
764
     */
765
    int slice_count;
766
    /**
767
     * slice offsets in the frame in bytes
768
     * encoding: set/allocated by lavc
769
     * decoding: set/allocated by user (or NULL)
770
     */
771
    int *slice_offset;
772

    
773
    /**
774
     * error concealment flags
775
     * encoding: unused
776
     * decoding: set by user
777
     */
778
    int error_concealment;
779
#define FF_EC_GUESS_MVS   1
780
#define FF_EC_DEBLOCK     2
781

    
782
    /**
783
     * dsp_mask could be used to disable unwanted
784
     * CPU features (i.e. MMX, SSE. ...)
785
     */
786
     unsigned dsp_mask;
787

    
788
    /**
789
     * bits per sample/pixel from the demuxer (needed for huffyuv)
790
     * encoding: set by lavc
791
     * decoding: set by user
792
     */
793
     int bits_per_sample;
794
    
795
    /**
796
     * prediction method (needed for huffyuv)
797
     * encoding: set by user
798
     * decoding: unused
799
     */
800
     int prediction_method;
801
#define FF_PRED_LEFT   0
802
#define FF_PRED_PLANE  1
803
#define FF_PRED_MEDIAN 2
804
    
805
    /**
806
     * aspect ratio. (0 if unknown)
807
     * encoding: set by user.
808
     * decoding: set by lavc.
809
     */
810
    float aspect_ratio;
811

    
812
    /**
813
     * the picture in the bitstream
814
     * encoding: set by lavc
815
     * decoding: set by lavc
816
     */
817
    AVFrame *coded_frame;
818

    
819
    /**
820
     * debug 
821
     * encoding: set by user.
822
     * decoding: set by user.
823
     */
824
    int debug;
825
#define FF_DEBUG_PICT_INFO 1
826
#define FF_DEBUG_RC        2
827
#define FF_DEBUG_BITSTREAM 4
828
#define FF_DEBUG_MB_TYPE   8
829
#define FF_DEBUG_QP        16
830
#define FF_DEBUG_MV        32
831
#define FF_DEBUG_VIS_MV    0x00000040
832
#define FF_DEBUG_SKIP      0x00000080
833
#define FF_DEBUG_STARTCODE 0x00000100
834
#define FF_DEBUG_PTS       0x00000200
835
    
836
    /**
837
     * error
838
     * encoding: set by lavc if flags&CODEC_FLAG_PSNR
839
     * decoding: unused
840
     */
841
    uint64_t error[4];
842
    
843
    /**
844
     * minimum MB quantizer
845
     * encoding: set by user.
846
     * decoding: unused
847
     */
848
    int mb_qmin;
849

    
850
    /**
851
     * maximum MB quantizer
852
     * encoding: set by user.
853
     * decoding: unused
854
     */
855
    int mb_qmax;
856
    
857
    /**
858
     * motion estimation compare function
859
     * encoding: set by user.
860
     * decoding: unused
861
     */
862
    int me_cmp;
863
    /**
864
     * subpixel motion estimation compare function
865
     * encoding: set by user.
866
     * decoding: unused
867
     */
868
    int me_sub_cmp;
869
    /**
870
     * macroblock compare function (not supported yet)
871
     * encoding: set by user.
872
     * decoding: unused
873
     */
874
    int mb_cmp;
875
#define FF_CMP_SAD  0
876
#define FF_CMP_SSE  1
877
#define FF_CMP_SATD 2
878
#define FF_CMP_DCT  3
879
#define FF_CMP_PSNR 4
880
#define FF_CMP_BIT  5
881
#define FF_CMP_RD   6
882
#define FF_CMP_ZERO 7
883
#define FF_CMP_CHROMA 256
884
    
885
    /**
886
     * ME diamond size & shape
887
     * encoding: set by user.
888
     * decoding: unused
889
     */
890
    int dia_size;
891

    
892
    /**
893
     * amount of previous MV predictors (2a+1 x 2a+1 square)
894
     * encoding: set by user.
895
     * decoding: unused
896
     */
897
    int last_predictor_count;
898

    
899
    /**
900
     * pre pass for motion estimation
901
     * encoding: set by user.
902
     * decoding: unused
903
     */
904
    int pre_me;
905

    
906
    /**
907
     * motion estimation pre pass compare function
908
     * encoding: set by user.
909
     * decoding: unused
910
     */
911
    int me_pre_cmp;
912

    
913
    /**
914
     * ME pre pass diamond size & shape
915
     * encoding: set by user.
916
     * decoding: unused
917
     */
918
    int pre_dia_size;
919

    
920
    /**
921
     * subpel ME quality
922
     * encoding: set by user.
923
     * decoding: unused
924
     */
925
    int me_subpel_quality;
926

    
927
} AVCodecContext;
928

    
929
typedef struct AVCodec {
930
    const char *name;
931
    int type;
932
    int id;
933
    int priv_data_size;
934
    int (*init)(AVCodecContext *);
935
    int (*encode)(AVCodecContext *, UINT8 *buf, int buf_size, void *data);
936
    int (*close)(AVCodecContext *);
937
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
938
                  UINT8 *buf, int buf_size);
939
    int capabilities;
940
    struct AVCodec *next;
941
} AVCodec;
942

    
943
/** 
944
 * four components are given, that's all.
945
 * the last component is alpha
946
 */
947
typedef struct AVPicture {
948
    UINT8 *data[4];
949
    int linesize[4];
950
} AVPicture;
951

    
952
extern AVCodec ac3_encoder;
953
extern AVCodec mp2_encoder;
954
extern AVCodec mp3lame_encoder;
955
extern AVCodec oggvorbis_encoder;
956
extern AVCodec mpeg1video_encoder;
957
extern AVCodec h263_encoder;
958
extern AVCodec h263p_encoder;
959
extern AVCodec rv10_encoder;
960
extern AVCodec mjpeg_encoder;
961
extern AVCodec mpeg4_encoder;
962
extern AVCodec msmpeg4v1_encoder;
963
extern AVCodec msmpeg4v2_encoder;
964
extern AVCodec msmpeg4v3_encoder;
965
extern AVCodec wmv1_encoder;
966
extern AVCodec wmv2_encoder;
967
extern AVCodec huffyuv_encoder;
968

    
969
extern AVCodec h263_decoder;
970
extern AVCodec mpeg4_decoder;
971
extern AVCodec msmpeg4v1_decoder;
972
extern AVCodec msmpeg4v2_decoder;
973
extern AVCodec msmpeg4v3_decoder;
974
extern AVCodec wmv1_decoder;
975
extern AVCodec wmv2_decoder;
976
extern AVCodec mpeg_decoder;
977
extern AVCodec h263i_decoder;
978
extern AVCodec rv10_decoder;
979
extern AVCodec svq1_decoder;
980
extern AVCodec dvvideo_decoder;
981
extern AVCodec dvaudio_decoder;
982
extern AVCodec wmav1_decoder;
983
extern AVCodec wmav2_decoder;
984
extern AVCodec mjpeg_decoder;
985
extern AVCodec mjpegb_decoder;
986
extern AVCodec mp2_decoder;
987
extern AVCodec mp3_decoder;
988
extern AVCodec mace3_decoder;
989
extern AVCodec mace6_decoder;
990
extern AVCodec huffyuv_decoder;
991
extern AVCodec oggvorbis_decoder;
992

    
993
/* pcm codecs */
994
#define PCM_CODEC(id, name) \
995
extern AVCodec name ## _decoder; \
996
extern AVCodec name ## _encoder
997

    
998
PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
999
PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1000
PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1001
PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1002
PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1003
PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1004
PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1005
PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1006

    
1007
/* adpcm codecs */
1008

    
1009
PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1010
PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1011
PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1012

    
1013
#undef PCM_CODEC
1014

    
1015
/* dummy raw video codec */
1016
extern AVCodec rawvideo_codec;
1017

    
1018
/* the following codecs use external GPL libs */
1019
extern AVCodec ac3_decoder;
1020

    
1021
/* resample.c */
1022

    
1023
struct ReSampleContext;
1024

    
1025
typedef struct ReSampleContext ReSampleContext;
1026

    
1027
ReSampleContext *audio_resample_init(int output_channels, int input_channels, 
1028
                                     int output_rate, int input_rate);
1029
int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1030
void audio_resample_close(ReSampleContext *s);
1031

    
1032
/* YUV420 format is assumed ! */
1033

    
1034
struct ImgReSampleContext;
1035

    
1036
typedef struct ImgReSampleContext ImgReSampleContext;
1037

    
1038
ImgReSampleContext *img_resample_init(int output_width, int output_height,
1039
                                      int input_width, int input_height);
1040

    
1041
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1042
                                      int iwidth, int iheight,
1043
                                      int topBand, int bottomBand,
1044
                                      int leftBand, int rightBand);
1045

    
1046
void img_resample(ImgReSampleContext *s, 
1047
                  AVPicture *output, AVPicture *input);
1048

    
1049
void img_resample_close(ImgReSampleContext *s);
1050

    
1051
void avpicture_fill(AVPicture *picture, UINT8 *ptr,
1052
                    int pix_fmt, int width, int height);
1053
int avpicture_get_size(int pix_fmt, int width, int height);
1054
void avcodec_get_chroma_sub_sample(int fmt, int *h_shift, int *v_shift);
1055

    
1056
/* convert among pixel formats */
1057
int img_convert(AVPicture *dst, int dst_pix_fmt,
1058
                AVPicture *src, int pix_fmt, 
1059
                int width, int height);
1060

    
1061
/* deinterlace a picture */
1062
int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1063
                          int pix_fmt, int width, int height);
1064

    
1065
/* external high level API */
1066

    
1067
extern AVCodec *first_avcodec;
1068

    
1069
/* returns LIBAVCODEC_VERSION_INT constant */
1070
unsigned avcodec_version(void);
1071
/* returns LIBAVCODEC_BUILD constant */
1072
unsigned avcodec_build(void);
1073
void avcodec_init(void);
1074

    
1075
void avcodec_set_bit_exact(void);
1076

    
1077
void register_avcodec(AVCodec *format);
1078
AVCodec *avcodec_find_encoder(enum CodecID id);
1079
AVCodec *avcodec_find_encoder_by_name(const char *name);
1080
AVCodec *avcodec_find_decoder(enum CodecID id);
1081
AVCodec *avcodec_find_decoder_by_name(const char *name);
1082
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1083

    
1084
void avcodec_get_context_defaults(AVCodecContext *s);
1085
AVCodecContext *avcodec_alloc_context(void);
1086
AVFrame *avcodec_alloc_frame(void);
1087

    
1088
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1089
void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1090

    
1091
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1092
int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, 
1093
                         int *frame_size_ptr,
1094
                         UINT8 *buf, int buf_size);
1095
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, 
1096
                         int *got_picture_ptr,
1097
                         UINT8 *buf, int buf_size);
1098
int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata, 
1099
                        int *data_size_ptr,
1100
                        UINT8 *buf, int buf_size);
1101
int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, 
1102
                         const short *samples);
1103
int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, 
1104
                         const AVFrame *pict);
1105

    
1106
int avcodec_close(AVCodecContext *avctx);
1107

    
1108
void avcodec_register_all(void);
1109

    
1110
void avcodec_flush_buffers(AVCodecContext *avctx);
1111

    
1112
typedef struct {
1113
    /** options' name with default value*/
1114
    const char* name;
1115
    /** English text help */
1116
    const char* help;
1117
    /** type of variable */
1118
    int type;
1119
#define FF_CONF_TYPE_BOOL 1     // boolean - true,1,on  (or simply presence)
1120
#define FF_CONF_TYPE_DOUBLE 2   // double
1121
#define FF_CONF_TYPE_INT 3      // integer
1122
#define FF_CONF_TYPE_STRING 4   // string (finished with \0)
1123
#define FF_CONF_TYPE_MASK 0x1f        // mask for types - upper bits are various flags
1124
#define FF_CONF_TYPE_EXPERT 0x20 // flag for expert option
1125
#define FF_CONF_TYPE_FLAG (FF_CONF_TYPE_BOOL | 0x40)
1126
#define FF_CONF_TYPE_RCOVERIDE (FF_CONF_TYPE_STRING | 0x80)
1127
    /** where the parsed value should be stored */
1128
    void* val;
1129
    /** min value  (min == max   ->  no limits) */
1130
    double min;
1131
    /** maximum value for double/int */
1132
    double max;
1133
    /** default boo [0,1]l/double/int value */
1134
    double defval;
1135
    /**
1136
     * default string value (with optional semicolon delimited extra option-list
1137
     * i.e.   option1;option2;option3
1138
     * defval might select other then first argument as default
1139
     */
1140
    const char* defstr;
1141
    /** char* list of supported codecs (i.e. ",msmpeg4,h263," NULL - everything */
1142
    const char* supported;
1143
} avc_config_t;
1144

    
1145
void avcodec_getopt(AVCodecContext* avctx, char* str, avc_config_t** config);
1146

    
1147
/**
1148
 * Interface for 0.5.0 version
1149
 *
1150
 * do not even think about it's usage for this moment
1151
 */
1152

    
1153
typedef struct {
1154
    // compressed size used from given memory buffer
1155
    int size;
1156
    /// I/P/B frame type
1157
    int frame_type;
1158
} avc_enc_result_t;
1159

    
1160
/**
1161
 * Commands
1162
 * order can't be changed - once it was defined
1163
 */
1164
typedef enum {
1165
    // general commands
1166
    AVC_OPEN_BY_NAME = 0xACA000,
1167
    AVC_OPEN_BY_CODEC_ID,
1168
    AVC_OPEN_BY_FOURCC,
1169
    AVC_CLOSE,
1170

    
1171
    AVC_FLUSH,
1172
    // pin - struct { uint8_t* src, uint_t src_size }
1173
    // pout - struct { AVPicture* img, consumed_bytes,
1174
    AVC_DECODE,
1175
    // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1176
    // pout - uint_t used_from_dest_size
1177
    AVC_ENCODE, 
1178

    
1179
    // query/get video commands
1180
    AVC_GET_VERSION = 0xACB000,
1181
    AVC_GET_WIDTH,
1182
    AVC_GET_HEIGHT,
1183
    AVC_GET_DELAY,
1184
    AVC_GET_QUANT_TABLE,
1185
    // ...
1186

    
1187
    // query/get audio commands
1188
    AVC_GET_FRAME_SIZE = 0xABC000,
1189

    
1190
    // maybe define some simple structure which
1191
    // might be passed to the user - but they can't
1192
    // contain any codec specific parts and these
1193
    // calls are usualy necessary only few times
1194

    
1195
    // set video commands
1196
    AVC_SET_WIDTH = 0xACD000,
1197
    AVC_SET_HEIGHT,
1198

    
1199
    // set video encoding commands
1200
    AVC_SET_FRAME_RATE = 0xACD800,
1201
    AVC_SET_QUALITY,
1202
    AVC_SET_HURRY_UP,
1203

    
1204
    // set audio commands
1205
    AVC_SET_SAMPLE_RATE = 0xACE000,
1206
    AVC_SET_CHANNELS,
1207

    
1208
} avc_cmd_t;
1209

    
1210
/**
1211
 * \param handle  allocated private structure by libavcodec
1212
 *                for initialization pass NULL - will be returned pout
1213
 *                user is supposed to know nothing about its structure
1214
 * \param cmd     type of operation to be performed
1215
 * \param pint    input parameter
1216
 * \param pout    output parameter
1217
 *
1218
 * \returns  command status - eventually for query command it might return
1219
 * integer resulting value
1220
 */
1221
int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1222

    
1223
/* memory */
1224
void *av_malloc(unsigned int size);
1225
void *av_mallocz(unsigned int size);
1226
void av_free(void *ptr);
1227
void __av_freep(void **ptr);
1228
#define av_freep(p) __av_freep((void **)(p))
1229
/* for static data only */
1230
/* call av_free_static to release all staticaly allocated tables */
1231
void av_free_static(void);
1232
void *__av_mallocz_static(void** location, unsigned int size);
1233
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1234

    
1235
#endif /* AVCODEC_H */