overdue format updates
[libav.git] / libavcodec / avcodec.h
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 4668
19 #define LIBAVCODEC_BUILD_STR "4668"
20
21 #define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
22
23 enum CodecID {
24 CODEC_ID_NONE,
25 CODEC_ID_MPEG1VIDEO,
26 CODEC_ID_H263,
27 CODEC_ID_RV10,
28 CODEC_ID_MP2,
29 CODEC_ID_MP3LAME,
30 CODEC_ID_VORBIS,
31 CODEC_ID_AC3,
32 CODEC_ID_MJPEG,
33 CODEC_ID_MJPEGB,
34 CODEC_ID_MPEG4,
35 CODEC_ID_RAWVIDEO,
36 CODEC_ID_MSMPEG4V1,
37 CODEC_ID_MSMPEG4V2,
38 CODEC_ID_MSMPEG4V3,
39 CODEC_ID_WMV1,
40 CODEC_ID_WMV2,
41 CODEC_ID_H263P,
42 CODEC_ID_H263I,
43 CODEC_ID_SVQ1,
44 CODEC_ID_SVQ3,
45 CODEC_ID_DVVIDEO,
46 CODEC_ID_DVAUDIO,
47 CODEC_ID_WMAV1,
48 CODEC_ID_WMAV2,
49 CODEC_ID_MACE3,
50 CODEC_ID_MACE6,
51 CODEC_ID_HUFFYUV,
52 CODEC_ID_CYUV,
53 CODEC_ID_H264,
54 CODEC_ID_INDEO3,
55 CODEC_ID_VP3,
56 CODEC_ID_AAC,
57 CODEC_ID_MPEG4AAC,
58 CODEC_ID_ASV1,
59 CODEC_ID_4XM,
60
61 /* various pcm "codecs" */
62 CODEC_ID_PCM_S16LE,
63 CODEC_ID_PCM_S16BE,
64 CODEC_ID_PCM_U16LE,
65 CODEC_ID_PCM_U16BE,
66 CODEC_ID_PCM_S8,
67 CODEC_ID_PCM_U8,
68 CODEC_ID_PCM_MULAW,
69 CODEC_ID_PCM_ALAW,
70
71 /* various adpcm codecs */
72 CODEC_ID_ADPCM_IMA_QT,
73 CODEC_ID_ADPCM_IMA_WAV,
74 CODEC_ID_ADPCM_MS,
75 CODEC_ID_ADPCM_4XM,
76
77 /* AMR */
78 CODEC_ID_AMR_NB,
79 };
80
81 enum CodecType {
82 CODEC_TYPE_UNKNOWN = -1,
83 CODEC_TYPE_VIDEO,
84 CODEC_TYPE_AUDIO,
85 };
86
87 /**
88 * Pixel format.
89 */
90 enum PixelFormat {
91 PIX_FMT_YUV420P,
92 PIX_FMT_YUV422,
93 PIX_FMT_RGB24, ///< 3 bytes, R is first
94 PIX_FMT_BGR24, ///< 3 bytes, B is first
95 PIX_FMT_YUV422P,
96 PIX_FMT_YUV444P,
97 PIX_FMT_RGBA32, ///< always stored in cpu endianness
98 PIX_FMT_YUV410P,
99 PIX_FMT_YUV411P,
100 PIX_FMT_RGB565, ///< always stored in cpu endianness
101 PIX_FMT_RGB555, ///< always stored in cpu endianness, most significant bit to 1
102 PIX_FMT_GRAY8,
103 PIX_FMT_MONOWHITE, ///< 0 is white
104 PIX_FMT_MONOBLACK, ///< 0 is black
105 PIX_FMT_PAL8, ///< 8 bit with RGBA palette
106 PIX_FMT_YUVJ420P, ///< YUV full scale (jpeg)
107 PIX_FMT_YUVJ422P, ///< YUV full scale (jpeg)
108 PIX_FMT_YUVJ444P, ///< YUV full scale (jpeg)
109 PIX_FMT_NB,
110 };
111
112 /* currently unused, may be used if 24/32 bits samples ever supported */
113 enum SampleFormat {
114 SAMPLE_FMT_S16 = 0, ///< signed 16 bits
115 };
116
117 /* in bytes */
118 #define AVCODEC_MAX_AUDIO_FRAME_SIZE 131072
119
120 /**
121 * Required number of zero bytes at the end of the input bitstream for decoding.
122 * to avoid overreading (and possibly segfaulting)
123 */
124 #define FF_INPUT_BUFFER_PADDING_SIZE 8
125
126 /* motion estimation type, EPZS by default */
127 enum Motion_Est_ID {
128 ME_ZERO = 1,
129 ME_FULL,
130 ME_LOG,
131 ME_PHODS,
132 ME_EPZS,
133 ME_X1
134 };
135
136 typedef struct RcOverride{
137 int start_frame;
138 int end_frame;
139 int qscale; // if this is 0 then quality_factor will be used instead
140 float quality_factor;
141 } RcOverride;
142
143 /* only for ME compatiblity with old apps */
144 extern int motion_estimation_method;
145
146 /* ME algos sorted by quality */
147 static const int Motion_Est_QTab[] = { ME_ZERO, ME_PHODS, ME_LOG,
148 ME_X1, ME_EPZS, ME_FULL };
149
150
151 #define FF_MAX_B_FRAMES 8
152
153 /* encoding support
154 these flags can be passed in AVCodecContext.flags before initing
155 Note: note not everything is supported yet
156 */
157
158 #define CODEC_FLAG_HQ 0x0001 ///< brute force MB-type decission mode (slow)
159 #define CODEC_FLAG_QSCALE 0x0002 ///< use fixed qscale
160 #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed
161 #define CODEC_FLAG_QPEL 0x0010 ///< use qpel MC
162 #define CODEC_FLAG_GMC 0x0020 ///< use GMC
163 #define CODEC_FLAG_PART 0x0080 ///< use data partitioning
164 /* parent program gurantees that the input for b-frame containing streams is not written to
165 for at least s->max_b_frames+1 frames, if this is not set than the input will be copied */
166 #define CODEC_FLAG_INPUT_PRESERVED 0x0100
167 #define CODEC_FLAG_PASS1 0x0200 ///< use internal 2pass ratecontrol in first pass mode
168 #define CODEC_FLAG_PASS2 0x0400 ///< use internal 2pass ratecontrol in second pass mode
169 #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< use external huffman table (for mjpeg)
170 #define CODEC_FLAG_GRAY 0x2000 ///< only decode/encode grayscale
171 #define CODEC_FLAG_EMU_EDGE 0x4000///< dont draw edges
172 #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding
173 #define CODEC_FLAG_TRUNCATED 0x00010000 /** input bitstream might be truncated at a random location instead
174 of only at frame boundaries */
175 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< normalize adaptive quantization
176 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< use interlaced dct
177 #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< force low delay / will fail on b frames
178 #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< use alternate scan
179 #define CODEC_FLAG_TRELLIS_QUANT 0x00200000 ///< use trellis quantization
180 #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< place global headers in extradata instead of every keyframe
181 #define CODEC_FLAG_BITEXACT 0x00800000 ///< use only bitexact stuff (except (i)dct)
182 /* Fx : Flag for h263+ extra options */
183 #define CODEC_FLAG_H263P_AIC 0x01000000 ///< Advanced intra coding
184 #define CODEC_FLAG_H263P_UMV 0x02000000 ///< Unlimited motion vector
185 /* For advanced prediction mode, we reuse the 4MV flag */
186 /* Unsupported options :
187 * Syntax Arithmetic coding (SAC)
188 * Deblocking filter internal loop
189 * Slice structured
190 * Reference Picture Selection
191 * Independant Segment Decoding
192 * Alternative Inter * VLC
193 * Modified Quantization */
194 /* /Fx */
195 /* codec capabilities */
196
197 #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< decoder can use draw_horiz_band callback
198 /**
199 * Codec uses get_buffer() for allocating buffers.
200 * direct rendering method 1
201 */
202 #define CODEC_CAP_DR1 0x0002
203 /* if 'parse_only' field is true, then avcodec_parse_frame() can be
204 used */
205 #define CODEC_CAP_PARSE_ONLY 0x0004
206 #define CODEC_CAP_TRUNCATED 0x0008
207
208 #define FF_COMMON_FRAME \
209 /**\
210 * pointer to the picture planes.\
211 * this might be different from the first allocated byte\
212 * - encoding: \
213 * - decoding: \
214 */\
215 uint8_t *data[4];\
216 int linesize[4];\
217 /**\
218 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer\
219 * this isnt used by lavc unless the default get/release_buffer() is used\
220 * - encoding: \
221 * - decoding: \
222 */\
223 uint8_t *base[4];\
224 /**\
225 * 1 -> keyframe, 0-> not\
226 * - encoding: set by lavc\
227 * - decoding: set by lavc\
228 */\
229 int key_frame;\
230 \
231 /**\
232 * picture type of the frame, see ?_TYPE below.\
233 * - encoding: set by lavc for coded_picture (and set by user for input)\
234 * - decoding: set by lavc\
235 */\
236 int pict_type;\
237 \
238 /**\
239 * presentation timestamp in micro seconds (time when frame should be shown to user)\
240 * if 0 then the frame_rate will be used as reference\
241 * - encoding: MUST be set by user\
242 * - decoding: set by lavc\
243 */\
244 int64_t pts;\
245 \
246 /**\
247 * picture number in bitstream order.\
248 * - encoding: set by\
249 * - decoding: set by lavc\
250 */\
251 int coded_picture_number;\
252 /**\
253 * picture number in display order.\
254 * - encoding: set by\
255 * - decoding: set by lavc\
256 */\
257 int display_picture_number;\
258 \
259 /**\
260 * quality (between 1 (good) and 31 (bad)) \
261 * - encoding: set by lavc for coded_picture (and set by user for input)\
262 * - decoding: set by lavc\
263 */\
264 float quality; \
265 \
266 /**\
267 * buffer age (1->was last buffer and dint change, 2->..., ...).\
268 * set to something large if the buffer has not been used yet \
269 * - encoding: unused\
270 * - decoding: MUST be set by get_buffer()\
271 */\
272 int age;\
273 \
274 /**\
275 * is this picture used as reference\
276 * - encoding: unused\
277 * - decoding: set by lavc (before get_buffer() call))\
278 */\
279 int reference;\
280 \
281 /**\
282 * QP table\
283 * - encoding: unused\
284 * - decoding: set by lavc\
285 */\
286 int8_t *qscale_table;\
287 /**\
288 * QP store stride\
289 * - encoding: unused\
290 * - decoding: set by lavc\
291 */\
292 int qstride;\
293 \
294 /**\
295 * mbskip_table[mb]>=1 if MB didnt change\
296 * stride= mb_width = (width+15)>>4\
297 * - encoding: unused\
298 * - decoding: set by lavc\
299 */\
300 uint8_t *mbskip_table;\
301 \
302 /**\
303 * for some private data of the user\
304 * - encoding: unused\
305 * - decoding: set by user\
306 */\
307 void *opaque;\
308 \
309 /**\
310 * error\
311 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR\
312 * - decoding: unused\
313 */\
314 uint64_t error[4];\
315 \
316 /**\
317 * type of the buffer (to keep track of who has to dealloc data[*])\
318 * - encoding: set by the one who allocs it\
319 * - decoding: set by the one who allocs it\
320 * Note: user allocated (direct rendering) & internal buffers can not coexist currently\
321 */\
322 int type;\
323 \
324 /**\
325 * when decoding, this signal how much the picture must be delayed.\
326 * extra_delay = repeat_pict / (2*fps)\
327 * - encoding: unused\
328 * - decoding: set by lavc\
329 */\
330 int repeat_pict;\
331 \
332 /**\
333 * \
334 */\
335 int qscale_type;\
336
337 #define FF_QSCALE_TYPE_MPEG1 0
338 #define FF_QSCALE_TYPE_MPEG2 1
339
340 #define FF_BUFFER_TYPE_INTERNAL 1
341 #define FF_BUFFER_TYPE_USER 2 ///< Direct rendering buffers
342 #define FF_BUFFER_TYPE_SHARED 4 ///< buffer from somewher else, dont dealloc
343
344
345 #define FF_I_TYPE 1 // Intra
346 #define FF_P_TYPE 2 // Predicted
347 #define FF_B_TYPE 3 // Bi-dir predicted
348 #define FF_S_TYPE 4 // S(GMC)-VOP MPEG4
349 #define FF_SI_TYPE 5
350 #define FF_SP_TYPE 6
351
352 /**
353 * Audio Video Frame.
354 */
355 typedef struct AVFrame {
356 FF_COMMON_FRAME
357 } AVFrame;
358
359 #define DEFAULT_FRAME_RATE_BASE 1001000
360
361 /**
362 * main external api structure.
363 */
364 typedef struct AVCodecContext {
365 /**
366 * the average bitrate.
367 * - encoding: set by user. unused for constant quantizer encoding
368 * - decoding: set by lavc. 0 or some bitrate if this info is available in the stream
369 */
370 int bit_rate;
371
372 /**
373 * number of bits the bitstream is allowed to diverge from the reference.
374 * the reference can be CBR (for CBR pass1) or VBR (for pass2)
375 * - encoding: set by user. unused for constant quantizer encoding
376 * - decoding: unused
377 */
378 int bit_rate_tolerance;
379
380 /**
381 * CODEC_FLAG_*.
382 * - encoding: set by user.
383 * - decoding: set by user.
384 */
385 int flags;
386
387 /**
388 * some codecs needs additionnal format info. It is stored here
389 * - encoding: set by user.
390 * - decoding: set by lavc. (FIXME is this ok?)
391 */
392 int sub_id;
393
394 /**
395 * motion estimation algorithm used for video coding.
396 * - encoding: MUST be set by user.
397 * - decoding: unused
398 */
399 int me_method;
400
401 /**
402 * some codecs need / can use extra-data like huffman tables.
403 * mjpeg: huffman tables
404 * rv10: additional flags
405 * mpeg4: global headers (they can be in the bitstream or here)
406 * - encoding: set/allocated/freed by lavc.
407 * - decoding: set/allocated/freed by user.
408 */
409 void *extradata;
410 int extradata_size;
411
412 /* video only */
413 /**
414 * frames per sec multiplied by frame_rate_base.
415 * for variable fps this is the precission, so if the timestamps
416 * can be specified in msec precssion then this is 1000*frame_rate_base
417 * - encoding: MUST be set by user
418 * - decoding: set by lavc. 0 or the frame_rate if available
419 */
420 int frame_rate;
421
422 /**
423 * width / height.
424 * - encoding: MUST be set by user.
425 * - decoding: set by user, some codecs might override / change it during playback
426 */
427 int width, height;
428
429 #define FF_ASPECT_SQUARE 1
430 #define FF_ASPECT_4_3_625 2
431 #define FF_ASPECT_4_3_525 3
432 #define FF_ASPECT_16_9_625 4
433 #define FF_ASPECT_16_9_525 5
434 #define FF_ASPECT_EXTENDED 15
435
436 /**
437 * the number of pictures in a group of pitures, or 0 for intra_only.
438 * - encoding: set by user.
439 * - decoding: unused
440 */
441 int gop_size;
442
443 /**
444 * pixel format, see PIX_FMT_xxx.
445 * - encoding: unused
446 * - decoding: set by lavc.
447 */
448 enum PixelFormat pix_fmt;
449
450 /**
451 * Frame rate emulation. If not zero lower layer (i.e. format handler)
452 * has to read frames at native frame rate.
453 * - encoding: set by user.
454 * - decoding: unused.
455 */
456 int rate_emu;
457
458 /**
459 * if non NULL, 'draw_horiz_band' is called by the libavcodec
460 * decoder to draw an horizontal band. It improve cache usage. Not
461 * all codecs can do that. You must check the codec capabilities
462 * before
463 * - encoding: unused
464 * - decoding: set by user.
465 */
466 void (*draw_horiz_band)(struct AVCodecContext *s,
467 uint8_t **src_ptr, int linesize,
468 int y, int width, int height);
469
470 /* audio only */
471 int sample_rate; ///< samples per sec
472 int channels;
473 int sample_fmt; ///< sample format, currenly unused
474
475 /* the following data should not be initialized */
476 int frame_size; ///< in samples, initialized when calling 'init'
477 int frame_number; ///< audio or video frame number
478 int real_pict_num; ///< returns the real picture number of previous encoded frame
479
480 /**
481 * number of frames the decoded output will be delayed relative to
482 * the encoded input.
483 * - encoding: set by lavc.
484 * - decoding: unused
485 */
486 int delay;
487
488 /* - encoding parameters */
489 float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0)
490 float qblur; ///< amount of qscale smoothing over time (0.0-1.0)
491
492 /**
493 * minimum quantizer.
494 * - encoding: set by user.
495 * - decoding: unused
496 */
497 int qmin;
498
499 /**
500 * maximum quantizer.
501 * - encoding: set by user.
502 * - decoding: unused
503 */
504 int qmax;
505
506 /**
507 * maximum quantizer difference etween frames.
508 * - encoding: set by user.
509 * - decoding: unused
510 */
511 int max_qdiff;
512
513 /**
514 * maximum number of b frames between non b frames.
515 * note: the output will be delayed by max_b_frames+1 relative to the input
516 * - encoding: set by user.
517 * - decoding: unused
518 */
519 int max_b_frames;
520
521 /**
522 * qscale factor between ip and b frames.
523 * - encoding: set by user.
524 * - decoding: unused
525 */
526 float b_quant_factor;
527
528 /** obsolete FIXME remove */
529 int rc_strategy;
530 int b_frame_strategy;
531
532 /**
533 * hurry up amount.
534 * - encoding: unused
535 * - decoding: set by user. 1-> skip b frames, 2-> skip idct/dequant too, 5-> skip everything except header
536 */
537 int hurry_up;
538
539 struct AVCodec *codec;
540
541 void *priv_data;
542
543 /* The following data is for RTP friendly coding */
544 /* By now only H.263/H.263+/MPEG4 coder honours this */
545 int rtp_mode; /* 1 for activate RTP friendly-mode */
546 /* highers numbers represent more error-prone */
547 /* enviroments, by now just "1" exist */
548
549 int rtp_payload_size; /* The size of the RTP payload, the coder will */
550 /* do it's best to deliver a chunk with size */
551 /* below rtp_payload_size, the chunk will start */
552 /* with a start code on some codecs like H.263 */
553 /* This doesn't take account of any particular */
554 /* headers inside the transmited RTP payload */
555
556
557 /* The RTP callcack: This function is called */
558 /* every time the encoder as a packet to send */
559 /* Depends on the encoder if the data starts */
560 /* with a Start Code (it should) H.263 does */
561 void (*rtp_callback)(void *data, int size, int packet_number);
562
563 /* statistics, used for 2-pass encoding */
564 int mv_bits;
565 int header_bits;
566 int i_tex_bits;
567 int p_tex_bits;
568 int i_count;
569 int p_count;
570 int skip_count;
571 int misc_bits;
572
573 /**
574 * number of bits used for the previously encoded frame.
575 * - encoding: set by lavc
576 * - decoding: unused
577 */
578 int frame_bits;
579
580 /**
581 * private data of the user, can be used to carry app specific stuff.
582 * - encoding: set by user
583 * - decoding: set by user
584 */
585 void *opaque;
586
587 char codec_name[32];
588 enum CodecType codec_type; /* see CODEC_TYPE_xxx */
589 enum CodecID codec_id; /* see CODEC_ID_xxx */
590
591 /**
592 * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
593 * this is used to workaround some encoder bugs
594 * - encoding: unused
595 * - decoding: set by user, will be converted to upper case by lavc during init
596 */
597 unsigned int codec_tag;
598
599 /**
600 * workaround bugs in encoders which sometimes cannot be detected automatically.
601 * - encoding: unused
602 * - decoding: set by user
603 */
604 int workaround_bugs;
605 #define FF_BUG_AUTODETECT 1 ///< autodetection
606 #define FF_BUG_OLD_MSMPEG4 2
607 #define FF_BUG_XVID_ILACE 4
608 #define FF_BUG_UMP4 8
609 #define FF_BUG_NO_PADDING 16
610 #define FF_BUG_AC_VLC 32
611 #define FF_BUG_QPEL_CHROMA 64
612 #define FF_BUG_STD_QPEL 128
613 #define FF_BUG_QPEL_CHROMA2 256
614 #define FF_BUG_DIRECT_BLOCKSIZE 512
615 #define FF_BUG_EDGE 1024
616 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
617
618 /**
619 * luma single coeff elimination threshold.
620 * - encoding: set by user
621 * - decoding: unused
622 */
623 int luma_elim_threshold;
624
625 /**
626 * chroma single coeff elimination threshold.
627 * - encoding: set by user
628 * - decoding: unused
629 */
630 int chroma_elim_threshold;
631
632 /**
633 * strictly follow the std (MPEG4, ...).
634 * - encoding: set by user
635 * - decoding: unused
636 */
637 int strict_std_compliance;
638
639 /**
640 * qscale offset between ip and b frames.
641 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
642 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
643 * - encoding: set by user.
644 * - decoding: unused
645 */
646 float b_quant_offset;
647
648 /**
649 * error resilience higher values will detect more errors but may missdetect
650 * some more or less valid parts as errors.
651 * - encoding: unused
652 * - decoding: set by user
653 */
654 int error_resilience;
655 #define FF_ER_CAREFULL 1
656 #define FF_ER_COMPLIANT 2
657 #define FF_ER_AGGRESSIVE 3
658 #define FF_ER_VERY_AGGRESSIVE 4
659
660 /**
661 * called at the beginning of each frame to get a buffer for it.
662 * if pic.reference is set then the frame will be read later by lavc
663 * - encoding: unused
664 * - decoding: set by lavc, user can override
665 */
666 int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic);
667
668 /**
669 * called to release buffers which where allocated with get_buffer.
670 * a released buffer can be reused in get_buffer()
671 * pic.data[*] must be set to NULL
672 * - encoding: unused
673 * - decoding: set by lavc, user can override
674 */
675 void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic);
676
677 /**
678 * is 1 if the decoded stream contains b frames, 0 otherwise.
679 * - encoding: unused
680 * - decoding: set by lavc
681 */
682 int has_b_frames;
683
684 int block_align; ///< used by some WAV based audio codecs
685
686 int parse_only; /* - decoding only: if true, only parsing is done
687 (function avcodec_parse_frame()). The frame
688 data is returned. Only MPEG codecs support this now. */
689
690 /**
691 * 0-> h263 quant 1-> mpeg quant.
692 * - encoding: set by user.
693 * - decoding: unused
694 */
695 int mpeg_quant;
696
697 /**
698 * pass1 encoding statistics output buffer.
699 * - encoding: set by lavc
700 * - decoding: unused
701 */
702 char *stats_out;
703
704 /**
705 * pass2 encoding statistics input buffer.
706 * concatenated stuff from stats_out of pass1 should be placed here
707 * - encoding: allocated/set/freed by user
708 * - decoding: unused
709 */
710 char *stats_in;
711
712 /**
713 * ratecontrol qmin qmax limiting method.
714 * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax
715 * - encoding: set by user.
716 * - decoding: unused
717 */
718 float rc_qsquish;
719
720 float rc_qmod_amp;
721 int rc_qmod_freq;
722
723 /**
724 * ratecontrol override, see RcOverride.
725 * - encoding: allocated/set/freed by user.
726 * - decoding: unused
727 */
728 RcOverride *rc_override;
729 int rc_override_count;
730
731 /**
732 * rate control equation.
733 * - encoding: set by user
734 * - decoding: unused
735 */
736 char *rc_eq;
737
738 /**
739 * maximum bitrate.
740 * - encoding: set by user.
741 * - decoding: unused
742 */
743 int rc_max_rate;
744
745 /**
746 * minimum bitrate.
747 * - encoding: set by user.
748 * - decoding: unused
749 */
750 int rc_min_rate;
751
752 /**
753 * decoder bitstream buffer size.
754 * - encoding: set by user.
755 * - decoding: unused
756 */
757 int rc_buffer_size;
758 float rc_buffer_aggressivity;
759
760 /**
761 * qscale factor between p and i frames.
762 * - encoding: set by user.
763 * - decoding: unused
764 */
765 float i_quant_factor;
766
767 /**
768 * qscale offset between p and i frames.
769 * if > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset)
770 * if < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset)
771 * - encoding: set by user.
772 * - decoding: unused
773 */
774 float i_quant_offset;
775
776 /**
777 * initial complexity for pass1 ratecontrol.
778 * - encoding: set by user.
779 * - decoding: unused
780 */
781 float rc_initial_cplx;
782
783 /**
784 * dct algorithm, see FF_DCT_* below.
785 * - encoding: set by user
786 * - decoding: unused
787 */
788 int dct_algo;
789 #define FF_DCT_AUTO 0
790 #define FF_DCT_FASTINT 1
791 #define FF_DCT_INT 2
792 #define FF_DCT_MMX 3
793 #define FF_DCT_MLIB 4
794 #define FF_DCT_ALTIVEC 5
795
796 /**
797 * luminance masking (0-> disabled).
798 * - encoding: set by user
799 * - decoding: unused
800 */
801 float lumi_masking;
802
803 /**
804 * temporary complexity masking (0-> disabled).
805 * - encoding: set by user
806 * - decoding: unused
807 */
808 float temporal_cplx_masking;
809
810 /**
811 * spatial complexity masking (0-> disabled).
812 * - encoding: set by user
813 * - decoding: unused
814 */
815 float spatial_cplx_masking;
816
817 /**
818 * p block masking (0-> disabled).
819 * - encoding: set by user
820 * - decoding: unused
821 */
822 float p_masking;
823
824 /**
825 * darkness masking (0-> disabled).
826 * - encoding: set by user
827 * - decoding: unused
828 */
829 float dark_masking;
830
831
832 /* for binary compatibility */
833 int unused;
834
835 /**
836 * idct algorithm, see FF_IDCT_* below.
837 * - encoding: set by user
838 * - decoding: set by user
839 */
840 int idct_algo;
841 #define FF_IDCT_AUTO 0
842 #define FF_IDCT_INT 1
843 #define FF_IDCT_SIMPLE 2
844 #define FF_IDCT_SIMPLEMMX 3
845 #define FF_IDCT_LIBMPEG2MMX 4
846 #define FF_IDCT_PS2 5
847 #define FF_IDCT_MLIB 6
848 #define FF_IDCT_ARM 7
849 #define FF_IDCT_ALTIVEC 8
850 #define FF_IDCT_SH4 9
851
852 /**
853 * slice count.
854 * - encoding: set by lavc
855 * - decoding: set by user (or 0)
856 */
857 int slice_count;
858 /**
859 * slice offsets in the frame in bytes.
860 * - encoding: set/allocated by lavc
861 * - decoding: set/allocated by user (or NULL)
862 */
863 int *slice_offset;
864
865 /**
866 * error concealment flags.
867 * - encoding: unused
868 * - decoding: set by user
869 */
870 int error_concealment;
871 #define FF_EC_GUESS_MVS 1
872 #define FF_EC_DEBLOCK 2
873
874 /**
875 * dsp_mask could be add used to disable unwanted CPU features
876 * CPU features (i.e. MMX, SSE. ...)
877 *
878 * with FORCE flag you may instead enable given CPU features
879 * (Dangerous: usable in case of misdetection, improper usage however will
880 * result into program crash)
881 */
882 unsigned dsp_mask;
883 #define FF_MM_FORCE 0x80000000 /* force usage of selected flags (OR) */
884 /* lower 16 bits - CPU features */
885 #ifdef HAVE_MMX
886 #define FF_MM_MMX 0x0001 /* standard MMX */
887 #define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */
888 #define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */
889 #define FF_MM_SSE 0x0008 /* SSE functions */
890 #define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */
891 #endif /* HAVE_MMX */
892
893 /**
894 * bits per sample/pixel from the demuxer (needed for huffyuv).
895 * - encoding: set by lavc
896 * - decoding: set by user
897 */
898 int bits_per_sample;
899
900 /**
901 * prediction method (needed for huffyuv).
902 * - encoding: set by user
903 * - decoding: unused
904 */
905 int prediction_method;
906 #define FF_PRED_LEFT 0
907 #define FF_PRED_PLANE 1
908 #define FF_PRED_MEDIAN 2
909
910 /**
911 * aspect ratio (0 if unknown).
912 * - encoding: set by user.
913 * - decoding: set by lavc.
914 */
915 float aspect_ratio;
916
917 /**
918 * the picture in the bitstream.
919 * - encoding: set by lavc
920 * - decoding: set by lavc
921 */
922 AVFrame *coded_frame;
923
924 /**
925 * debug.
926 * - encoding: set by user.
927 * - decoding: set by user.
928 */
929 int debug;
930 #define FF_DEBUG_PICT_INFO 1
931 #define FF_DEBUG_RC 2
932 #define FF_DEBUG_BITSTREAM 4
933 #define FF_DEBUG_MB_TYPE 8
934 #define FF_DEBUG_QP 16
935 #define FF_DEBUG_MV 32
936 #define FF_DEBUG_VIS_MV 0x00000040
937 #define FF_DEBUG_SKIP 0x00000080
938 #define FF_DEBUG_STARTCODE 0x00000100
939 #define FF_DEBUG_PTS 0x00000200
940 #define FF_DEBUG_ER 0x00000400
941 #define FF_DEBUG_MMCO 0x00000800
942
943 /**
944 * error.
945 * - encoding: set by lavc if flags&CODEC_FLAG_PSNR
946 * - decoding: unused
947 */
948 uint64_t error[4];
949
950 /**
951 * minimum MB quantizer.
952 * - encoding: set by user.
953 * - decoding: unused
954 */
955 int mb_qmin;
956
957 /**
958 * maximum MB quantizer.
959 * - encoding: set by user.
960 * - decoding: unused
961 */
962 int mb_qmax;
963
964 /**
965 * motion estimation compare function.
966 * - encoding: set by user.
967 * - decoding: unused
968 */
969 int me_cmp;
970 /**
971 * subpixel motion estimation compare function.
972 * - encoding: set by user.
973 * - decoding: unused
974 */
975 int me_sub_cmp;
976 /**
977 * macroblock compare function (not supported yet).
978 * - encoding: set by user.
979 * - decoding: unused
980 */
981 int mb_cmp;
982 #define FF_CMP_SAD 0
983 #define FF_CMP_SSE 1
984 #define FF_CMP_SATD 2
985 #define FF_CMP_DCT 3
986 #define FF_CMP_PSNR 4
987 #define FF_CMP_BIT 5
988 #define FF_CMP_RD 6
989 #define FF_CMP_ZERO 7
990 #define FF_CMP_CHROMA 256
991
992 /**
993 * ME diamond size & shape.
994 * - encoding: set by user.
995 * - decoding: unused
996 */
997 int dia_size;
998
999 /**
1000 * amount of previous MV predictors (2a+1 x 2a+1 square).
1001 * - encoding: set by user.
1002 * - decoding: unused
1003 */
1004 int last_predictor_count;
1005
1006 /**
1007 * pre pass for motion estimation.
1008 * - encoding: set by user.
1009 * - decoding: unused
1010 */
1011 int pre_me;
1012
1013 /**
1014 * motion estimation pre pass compare function.
1015 * - encoding: set by user.
1016 * - decoding: unused
1017 */
1018 int me_pre_cmp;
1019
1020 /**
1021 * ME pre pass diamond size & shape.
1022 * - encoding: set by user.
1023 * - decoding: unused
1024 */
1025 int pre_dia_size;
1026
1027 /**
1028 * subpel ME quality.
1029 * - encoding: set by user.
1030 * - decoding: unused
1031 */
1032 int me_subpel_quality;
1033
1034 /**
1035 * callback to negotiate the pixelFormat.
1036 * @param fmt is the list of formats which are supported by the codec,
1037 * its terminated by -1 as 0 is a valid format, the formats are ordered by quality
1038 * the first is allways the native one
1039 * @return the choosen format
1040 * - encoding: unused
1041 * - decoding: set by user, if not set then the native format will always be choosen
1042 */
1043 enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt);
1044
1045 /**
1046 * DTG active format information (additionnal aspect ratio
1047 * information only used in DVB MPEG2 transport streams). 0 if
1048 * not set.
1049 *
1050 * - encoding: unused.
1051 * - decoding: set by decoder
1052 */
1053 int dtg_active_format;
1054 #define FF_DTG_AFD_SAME 8
1055 #define FF_DTG_AFD_4_3 9
1056 #define FF_DTG_AFD_16_9 10
1057 #define FF_DTG_AFD_14_9 11
1058 #define FF_DTG_AFD_4_3_SP_14_9 13
1059 #define FF_DTG_AFD_16_9_SP_14_9 14
1060 #define FF_DTG_AFD_SP_4_3 15
1061
1062 /**
1063 * Maximum motion estimation search range in subpel units.
1064 * if 0 then no limit
1065 *
1066 * - encoding: set by user.
1067 * - decoding: unused.
1068 */
1069 int me_range;
1070
1071 /**
1072 * frame_rate_base.
1073 * for variable fps this is 1
1074 * - encoding: set by user.
1075 * - decoding: set by lavc.
1076 * @todo move this after frame_rate
1077 */
1078
1079 int frame_rate_base;
1080 /**
1081 * intra quantizer bias.
1082 * - encoding: set by user.
1083 * - decoding: unused
1084 */
1085 int intra_quant_bias;
1086 #define FF_DEFAULT_QUANT_BIAS 999999
1087
1088 /**
1089 * inter quantizer bias.
1090 * - encoding: set by user.
1091 * - decoding: unused
1092 */
1093 int inter_quant_bias;
1094
1095 /**
1096 * color table ID.
1097 * - encoding: unused.
1098 * - decoding: which clrtable should be used for 8bit RGB images
1099 * table have to be stored somewhere FIXME
1100 */
1101 int color_table_id;
1102
1103 /**
1104 * internal_buffer count.
1105 * Dont touch, used by lavc default_get_buffer()
1106 */
1107 int internal_buffer_count;
1108
1109 /**
1110 * internal_buffers.
1111 * Dont touch, used by lavc default_get_buffer()
1112 */
1113 void *internal_buffer;
1114
1115 #define FF_QUALITY_SCALE 256
1116 /**
1117 * global quality for codecs which cannot change it per frame.
1118 * this should be proportional to MPEG1/2/4 qscale.
1119 * - encoding: set by user.
1120 * - decoding: unused
1121 */
1122 int global_quality;
1123 } AVCodecContext;
1124
1125
1126 /**
1127 * AVOption.
1128 */
1129 typedef struct AVOption {
1130 /** options' name */
1131 const char *name; /* if name is NULL, it indicates a link to next */
1132 /** short English text help or const struct AVOption* subpointer */
1133 const char *help; // const struct AVOption* sub;
1134 /** offset to context structure where the parsed value should be stored */
1135 int offset;
1136 /** options' type */
1137 int type;
1138 #define FF_OPT_TYPE_BOOL 1 ///< boolean - true,1,on (or simply presence)
1139 #define FF_OPT_TYPE_DOUBLE 2 ///< double
1140 #define FF_OPT_TYPE_INT 3 ///< integer
1141 #define FF_OPT_TYPE_STRING 4 ///< string (finished with \0)
1142 #define FF_OPT_TYPE_MASK 0x1f ///< mask for types - upper bits are various flags
1143 //#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
1144 #define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
1145 #define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
1146 /** min value (min == max -> no limits) */
1147 double min;
1148 /** maximum value for double/int */
1149 double max;
1150 /** default boo [0,1]l/double/int value */
1151 double defval;
1152 /**
1153 * default string value (with optional semicolon delimited extra option-list
1154 * i.e. option1;option2;option3
1155 * defval might select other then first argument as default
1156 */
1157 const char *defstr;
1158 #define FF_OPT_MAX_DEPTH 10
1159 } AVOption;
1160
1161 /**
1162 * Parse option(s) and sets fields in passed structure
1163 * @param strct structure where the parsed results will be written
1164 * @param list list with AVOptions
1165 * @param opts string with options for parsing
1166 */
1167 int avoption_parse(void* strct, const AVOption* list, const char* opts);
1168
1169
1170 /**
1171 * AVCodec.
1172 */
1173 typedef struct AVCodec {
1174 const char *name;
1175 enum CodecType type;
1176 int id;
1177 int priv_data_size;
1178 int (*init)(AVCodecContext *);
1179 int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data);
1180 int (*close)(AVCodecContext *);
1181 int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1182 uint8_t *buf, int buf_size);
1183 int capabilities;
1184 const AVOption *options;
1185 struct AVCodec *next;
1186 } AVCodec;
1187
1188 /**
1189 * four components are given, that's all.
1190 * the last component is alpha
1191 */
1192 typedef struct AVPicture {
1193 uint8_t *data[4];
1194 int linesize[4];
1195 } AVPicture;
1196
1197 extern AVCodec ac3_encoder;
1198 extern AVCodec mp2_encoder;
1199 extern AVCodec mp3lame_encoder;
1200 extern AVCodec oggvorbis_encoder;
1201 extern AVCodec mpeg1video_encoder;
1202 extern AVCodec h263_encoder;
1203 extern AVCodec h263p_encoder;
1204 extern AVCodec rv10_encoder;
1205 extern AVCodec mjpeg_encoder;
1206 extern AVCodec mpeg4_encoder;
1207 extern AVCodec msmpeg4v1_encoder;
1208 extern AVCodec msmpeg4v2_encoder;
1209 extern AVCodec msmpeg4v3_encoder;
1210 extern AVCodec wmv1_encoder;
1211 extern AVCodec wmv2_encoder;
1212 extern AVCodec huffyuv_encoder;
1213 extern AVCodec h264_encoder;
1214 extern AVCodec asv1_encoder;
1215
1216 extern AVCodec h263_decoder;
1217 extern AVCodec mpeg4_decoder;
1218 extern AVCodec msmpeg4v1_decoder;
1219 extern AVCodec msmpeg4v2_decoder;
1220 extern AVCodec msmpeg4v3_decoder;
1221 extern AVCodec wmv1_decoder;
1222 extern AVCodec wmv2_decoder;
1223 extern AVCodec mpeg_decoder;
1224 extern AVCodec h263i_decoder;
1225 extern AVCodec rv10_decoder;
1226 extern AVCodec svq1_decoder;
1227 extern AVCodec svq3_decoder;
1228 extern AVCodec dvvideo_decoder;
1229 extern AVCodec dvaudio_decoder;
1230 extern AVCodec wmav1_decoder;
1231 extern AVCodec wmav2_decoder;
1232 extern AVCodec mjpeg_decoder;
1233 extern AVCodec mjpegb_decoder;
1234 extern AVCodec mp2_decoder;
1235 extern AVCodec mp3_decoder;
1236 extern AVCodec mace3_decoder;
1237 extern AVCodec mace6_decoder;
1238 extern AVCodec huffyuv_decoder;
1239 extern AVCodec oggvorbis_decoder;
1240 extern AVCodec cyuv_decoder;
1241 extern AVCodec h264_decoder;
1242 extern AVCodec indeo3_decoder;
1243 extern AVCodec vp3_decoder;
1244 extern AVCodec amr_nb_decoder;
1245 extern AVCodec aac_decoder;
1246 extern AVCodec mpeg4aac_decoder;
1247 extern AVCodec asv1_decoder;
1248
1249 /* pcm codecs */
1250 #define PCM_CODEC(id, name) \
1251 extern AVCodec name ## _decoder; \
1252 extern AVCodec name ## _encoder
1253
1254 PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
1255 PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
1256 PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
1257 PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
1258 PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
1259 PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
1260 PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
1261 PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
1262
1263 /* adpcm codecs */
1264
1265 PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
1266 PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
1267 PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
1268
1269 #undef PCM_CODEC
1270
1271 /* dummy raw video codec */
1272 extern AVCodec rawvideo_encoder;
1273 extern AVCodec rawvideo_decoder;
1274
1275 /* the following codecs use external GPL libs */
1276 extern AVCodec ac3_decoder;
1277
1278 /* resample.c */
1279
1280 struct ReSampleContext;
1281
1282 typedef struct ReSampleContext ReSampleContext;
1283
1284 ReSampleContext *audio_resample_init(int output_channels, int input_channels,
1285 int output_rate, int input_rate);
1286 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples);
1287 void audio_resample_close(ReSampleContext *s);
1288
1289 /* YUV420 format is assumed ! */
1290
1291 struct ImgReSampleContext;
1292
1293 typedef struct ImgReSampleContext ImgReSampleContext;
1294
1295 ImgReSampleContext *img_resample_init(int output_width, int output_height,
1296 int input_width, int input_height);
1297
1298 ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
1299 int iwidth, int iheight,
1300 int topBand, int bottomBand,
1301 int leftBand, int rightBand);
1302
1303 void img_resample(ImgReSampleContext *s,
1304 AVPicture *output, AVPicture *input);
1305
1306 void img_resample_close(ImgReSampleContext *s);
1307
1308 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
1309 int pix_fmt, int width, int height);
1310 int avpicture_layout(AVPicture* src, int pix_fmt, int width, int height,
1311 unsigned char *dest, int dest_size);
1312 int avpicture_get_size(int pix_fmt, int width, int height);
1313 void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
1314 const char *avcodec_get_pix_fmt_name(int pix_fmt);
1315 enum PixelFormat avcodec_get_pix_fmt(const char* name);
1316
1317 #define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
1318 #define FF_LOSS_DEPTH 0x0002 /* loss due to color depth change */
1319 #define FF_LOSS_COLORSPACE 0x0004 /* loss due to color space conversion */
1320 #define FF_LOSS_ALPHA 0x0008 /* loss of alpha bits */
1321 #define FF_LOSS_COLORQUANT 0x0010 /* loss due to color quantization */
1322 #define FF_LOSS_CHROMA 0x0020 /* loss of chroma (e.g. rgb to gray conversion) */
1323
1324 int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
1325 int has_alpha);
1326 int avcodec_find_best_pix_fmt(int pix_fmt_mask, int src_pix_fmt,
1327 int has_alpha, int *loss_ptr);
1328
1329 #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */
1330 #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */
1331 int img_get_alpha_info(AVPicture *src, int pix_fmt, int width, int height);
1332
1333 /* convert among pixel formats */
1334 int img_convert(AVPicture *dst, int dst_pix_fmt,
1335 AVPicture *src, int pix_fmt,
1336 int width, int height);
1337
1338 /* deinterlace a picture */
1339 int avpicture_deinterlace(AVPicture *dst, AVPicture *src,
1340 int pix_fmt, int width, int height);
1341
1342 /* external high level API */
1343
1344 extern AVCodec *first_avcodec;
1345
1346 /* returns LIBAVCODEC_VERSION_INT constant */
1347 unsigned avcodec_version(void);
1348 /* returns LIBAVCODEC_BUILD constant */
1349 unsigned avcodec_build(void);
1350 void avcodec_init(void);
1351
1352 void register_avcodec(AVCodec *format);
1353 AVCodec *avcodec_find_encoder(enum CodecID id);
1354 AVCodec *avcodec_find_encoder_by_name(const char *name);
1355 AVCodec *avcodec_find_decoder(enum CodecID id);
1356 AVCodec *avcodec_find_decoder_by_name(const char *name);
1357 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
1358
1359 void avcodec_get_context_defaults(AVCodecContext *s);
1360 AVCodecContext *avcodec_alloc_context(void);
1361 AVFrame *avcodec_alloc_frame(void);
1362
1363 int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic);
1364 void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic);
1365 void avcodec_default_free_buffers(AVCodecContext *s);
1366
1367 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
1368 int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
1369 int *frame_size_ptr,
1370 uint8_t *buf, int buf_size);
1371 int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
1372 int *got_picture_ptr,
1373 uint8_t *buf, int buf_size);
1374 int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata,
1375 int *data_size_ptr,
1376 uint8_t *buf, int buf_size);
1377 int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1378 const short *samples);
1379 int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1380 const AVFrame *pict);
1381
1382 int avcodec_close(AVCodecContext *avctx);
1383
1384 void avcodec_register_all(void);
1385
1386 void avcodec_flush_buffers(AVCodecContext *avctx);
1387
1388 /* misc usefull functions */
1389
1390 /**
1391 * returns a single letter to describe the picture type
1392 */
1393 char av_get_pict_type_char(int pict_type);
1394
1395 /**
1396 * reduce a fraction.
1397 * this is usefull for framerate calculations
1398 * @param max the maximum allowed for dst_nom & dst_den
1399 * @return 1 if exact, 0 otherwise
1400 */
1401 int av_reduce(int *dst_nom, int *dst_den, int64_t nom, int64_t den, int64_t max);
1402
1403 /**
1404 * rescale a 64bit integer.
1405 * a simple a*b/c isnt possible as it can overflow
1406 */
1407 int64_t av_rescale(int64_t a, int b, int c);
1408
1409
1410 /**
1411 * Interface for 0.5.0 version
1412 *
1413 * do not even think about it's usage for this moment
1414 */
1415
1416 typedef struct {
1417 /// compressed size used from given memory buffer
1418 int size;
1419 /// I/P/B frame type
1420 int frame_type;
1421 } avc_enc_result_t;
1422
1423 /**
1424 * Commands
1425 * order can't be changed - once it was defined
1426 */
1427 typedef enum {
1428 // general commands
1429 AVC_OPEN_BY_NAME = 0xACA000,
1430 AVC_OPEN_BY_CODEC_ID,
1431 AVC_OPEN_BY_FOURCC,
1432 AVC_CLOSE,
1433
1434 AVC_FLUSH,
1435 // pin - struct { uint8_t* src, uint_t src_size }
1436 // pout - struct { AVPicture* img, consumed_bytes,
1437 AVC_DECODE,
1438 // pin - struct { AVPicture* img, uint8_t* dest, uint_t dest_size }
1439 // pout - uint_t used_from_dest_size
1440 AVC_ENCODE,
1441
1442 // query/get video commands
1443 AVC_GET_VERSION = 0xACB000,
1444 AVC_GET_WIDTH,
1445 AVC_GET_HEIGHT,
1446 AVC_GET_DELAY,
1447 AVC_GET_QUANT_TABLE,
1448 // ...
1449
1450 // query/get audio commands
1451 AVC_GET_FRAME_SIZE = 0xABC000,
1452
1453 // maybe define some simple structure which
1454 // might be passed to the user - but they can't
1455 // contain any codec specific parts and these
1456 // calls are usualy necessary only few times
1457
1458 // set video commands
1459 AVC_SET_WIDTH = 0xACD000,
1460 AVC_SET_HEIGHT,
1461
1462 // set video encoding commands
1463 AVC_SET_FRAME_RATE = 0xACD800,
1464 AVC_SET_QUALITY,
1465 AVC_SET_HURRY_UP,
1466
1467 // set audio commands
1468 AVC_SET_SAMPLE_RATE = 0xACE000,
1469 AVC_SET_CHANNELS,
1470
1471 } avc_cmd_t;
1472
1473 /**
1474 * \param handle allocated private structure by libavcodec
1475 * for initialization pass NULL - will be returned pout
1476 * user is supposed to know nothing about its structure
1477 * \param cmd type of operation to be performed
1478 * \param pint input parameter
1479 * \param pout output parameter
1480 *
1481 * \returns command status - eventually for query command it might return
1482 * integer resulting value
1483 */
1484 int avcodec(void* handle, avc_cmd_t cmd, void* pin, void* pout);
1485
1486 /* memory */
1487 void *av_malloc(unsigned int size);
1488 void *av_mallocz(unsigned int size);
1489 void *av_realloc(void *ptr, unsigned int size);
1490 void av_free(void *ptr);
1491 char *av_strdup(const char *s);
1492 void __av_freep(void **ptr);
1493 #define av_freep(p) __av_freep((void **)(p))
1494 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
1495 /* for static data only */
1496 /* call av_free_static to release all staticaly allocated tables */
1497 void av_free_static(void);
1498 void *__av_mallocz_static(void** location, unsigned int size);
1499 #define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1500
1501 #ifdef __cplusplus
1502 }
1503 #endif
1504
1505 #endif /* AVCODEC_H */