comparison avcodec.h @ 903:22ee74da2cd3 libavcodec

cleanup adding AVVideoFrame moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame removing obsolete variables in AVCodecContext skiping of MBs in b frames correctly initalizing AVCodecContext picture buffer cleanup
author michaelni
date Wed, 04 Dec 2002 10:04:03 +0000
parents 6acc8394960d
children 2b93dc762f9a
comparison
equal deleted inserted replaced
902:6acc8394960d 903:22ee74da2cd3
3 3
4 #include "common.h" 4 #include "common.h"
5 5
6 #define LIBAVCODEC_VERSION_INT 0x000406 6 #define LIBAVCODEC_VERSION_INT 0x000406
7 #define LIBAVCODEC_VERSION "0.4.6" 7 #define LIBAVCODEC_VERSION "0.4.6"
8 #define LIBAVCODEC_BUILD 4640 8 #define LIBAVCODEC_BUILD 4641
9 #define LIBAVCODEC_BUILD_STR "4640" 9 #define LIBAVCODEC_BUILD_STR "4641"
10 10
11 enum CodecID { 11 enum CodecID {
12 CODEC_ID_NONE, 12 CODEC_ID_NONE,
13 CODEC_ID_MPEG1VIDEO, 13 CODEC_ID_MPEG1VIDEO,
14 CODEC_ID_H263, 14 CODEC_ID_H263,
138 #define CODEC_FLAG_PASS1 0x0200 /* use internal 2pass ratecontrol in first pass mode */ 138 #define CODEC_FLAG_PASS1 0x0200 /* use internal 2pass ratecontrol in first pass mode */
139 #define CODEC_FLAG_PASS2 0x0400 /* use internal 2pass ratecontrol in second pass mode */ 139 #define CODEC_FLAG_PASS2 0x0400 /* use internal 2pass ratecontrol in second pass mode */
140 #define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */ 140 #define CODEC_FLAG_EXTERN_HUFF 0x1000 /* use external huffman table (for mjpeg) */
141 #define CODEC_FLAG_GRAY 0x2000 /* only decode/encode grayscale */ 141 #define CODEC_FLAG_GRAY 0x2000 /* only decode/encode grayscale */
142 #define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */ 142 #define CODEC_FLAG_EMU_EDGE 0x4000/* dont draw edges */
143 #define CODEC_FLAG_DR1 0x8000 /* direct renderig type 1 (store internal frames in external buffers) */
144 #define CODEC_FLAG_TRUNCATED 0x00010000 /* input bitstream might be truncated at a random location instead 143 #define CODEC_FLAG_TRUNCATED 0x00010000 /* input bitstream might be truncated at a random location instead
145 of only at frame boundaries */ 144 of only at frame boundaries */
146 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 /* normalize adaptive quantization */ 145 #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 /* normalize adaptive quantization */
147 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */ 146 #define CODEC_FLAG_INTERLACED_DCT 0x00040000 /* use interlaced dct */
148 #define CODEC_FLAG_LOW_DELAY 0x00080000 /* force low delay / will fail on b frames */ 147 #define CODEC_FLAG_LOW_DELAY 0x00080000 /* force low delay / will fail on b frames */
157 #define CODEC_CAP_PARSE_ONLY 0x0004 156 #define CODEC_CAP_PARSE_ONLY 0x0004
158 #define CODEC_CAP_TRUNCATED 0x0008 157 #define CODEC_CAP_TRUNCATED 0x0008
159 158
160 #define FRAME_RATE_BASE 10000 159 #define FRAME_RATE_BASE 10000
161 160
161 #define FF_COMMON_PICTURE \
162 uint8_t *data[4];\
163 int linesize[4];\
164 /**\
165 * pointer to the first allocated byte of the picture. can be used in get_buffer/release_buffer
166 * this isnt used by lavc unless the default get/release_buffer() is used\
167 * encoding: \
168 * decoding: \
169 */\
170 uint8_t *base[4];\
171 /**\
172 * 1 -> keyframe, 0-> not\
173 * encoding: set by lavc\
174 * decoding: set by lavc\
175 */\
176 int key_frame;\
177 \
178 /**\
179 * picture type of the frame, see ?_TYPE below\
180 * encoding: set by lavc for coded_picture (and set by user for input)\
181 * decoding: set by lavc\
182 */\
183 int pict_type;\
184 \
185 /**\
186 * presentation timestamp in micro seconds (time when frame should be shown to user)\
187 * if 0 then the frame_rate will be used as reference\
188 * encoding: MUST be set by user\
189 * decoding: set by lavc\
190 */\
191 long long int pts;\
192 \
193 /**\
194 * picture number in bitstream order.\
195 * encoding: set by\
196 * decoding: set by lavc\
197 */\
198 int coded_picture_number;\
199 /**\
200 * encoding: set by\
201 * decoding: set by lavc\
202 * picture number in display order.\
203 */\
204 int display_picture_number;\
205 \
206 /**\
207 * quality (between 1 (good) and 31 (bad)) \
208 * encoding: set by lavc for coded_picture (and set by user for input)\
209 * decoding: set by lavc\
210 */\
211 float quality; \
212 \
213 /**\
214 * buffer age (1->was last buffer and dint change, 2->..., ...).\
215 * set to something large if the buffer has not been used yet \
216 * encoding: unused\
217 * decoding: MUST be set by get_buffer()\
218 */\
219 int age;\
220 \
221 /**\
222 * is this picture used as reference\
223 * encoding: unused\
224 * decoding: set by lavc (before get_buffer() call))\
225 */\
226 int reference;\
227 \
228 /**\
229 * QP table\
230 * encoding: unused\
231 * decoding: set by lavc\
232 */\
233 int8_t *qscale_table;\
234 /**\
235 * QP store stride\
236 * encoding: unused\
237 * decoding: set by lavc\
238 */\
239 int qstride;\
240 \
241 /**\
242 * mbskip_table[mb]>=1 if MB didnt change\
243 * stride= mb_width = (width+15)>>4\
244 * encoding: unused\
245 * decoding: set by lavc\
246 */\
247 uint8_t *mbskip_table;\
248 \
249 /**\
250 * for some private data of the user\
251 * encoding: unused\
252 * decoding: set by user\
253 */\
254 void *opaque;\
255
256 /* FIXME: these should have FF_ */
257 #define I_TYPE 1 // Intra
258 #define P_TYPE 2 // Predicted
259 #define B_TYPE 3 // Bi-dir predicted
260 #define S_TYPE 4 // S(GMC)-VOP MPEG4
261
262 typedef struct AVVideoFrame {
263 FF_COMMON_PICTURE
264 } AVVideoFrame;
265
162 typedef struct AVCodecContext { 266 typedef struct AVCodecContext {
163 /** 267 /**
164 * the average bitrate 268 * the average bitrate
165 * encoding: set by user. unused for constant quantizer encoding 269 * encoding: set by user. unused for constant quantizer encoding
166 * decoding: set by lavc. 0 or some bitrate if this info is available in the stream 270 * decoding: set by lavc. 0 or some bitrate if this info is available in the stream
189 */ 293 */
190 int sub_id; 294 int sub_id;
191 295
192 /** 296 /**
193 * motion estimation algorithm used for video coding 297 * motion estimation algorithm used for video coding
194 * encoding: set by user. 298 * encoding: MUST be set by user.
195 * decoding: unused 299 * decoding: unused
196 */ 300 */
197 int me_method; 301 int me_method;
198 302
199 /** 303 /**
210 /* video only */ 314 /* video only */
211 /** 315 /**
212 * frames per sec multiplied by FRAME_RATE_BASE 316 * frames per sec multiplied by FRAME_RATE_BASE
213 * for variable fps this is the precission, so if the timestamps 317 * for variable fps this is the precission, so if the timestamps
214 * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE 318 * can be specified in msec precssion then this is 1000*FRAME_RATE_BASE
215 * encoding: set by user 319 * encoding: MUST be set by user
216 * decoding: set by lavc. 0 or the frame_rate if available 320 * decoding: set by lavc. 0 or the frame_rate if available
217 */ 321 */
218 int frame_rate; 322 int frame_rate;
219 323
220 /** 324 /**
221 * encoding: set by user. 325 * encoding: MUST be set by user.
222 * decoding: set by user, some codecs might override / change it during playback 326 * decoding: set by user, some codecs might override / change it during playback
223 */ 327 */
224 int width, height; 328 int width, height;
225 329
226 /**
227 * Obsolete, will be removed
228 */
229 int aspect_ratio_info;
230 #define FF_ASPECT_SQUARE 1 330 #define FF_ASPECT_SQUARE 1
231 #define FF_ASPECT_4_3_625 2 331 #define FF_ASPECT_4_3_625 2
232 #define FF_ASPECT_4_3_525 3 332 #define FF_ASPECT_4_3_525 3
233 #define FF_ASPECT_16_9_625 4 333 #define FF_ASPECT_16_9_625 4
234 #define FF_ASPECT_16_9_525 5 334 #define FF_ASPECT_16_9_525 5
272 /* the following data should not be initialized */ 372 /* the following data should not be initialized */
273 int frame_size; /* in samples, initialized when calling 'init' */ 373 int frame_size; /* in samples, initialized when calling 'init' */
274 int frame_number; /* audio or video frame number */ 374 int frame_number; /* audio or video frame number */
275 int real_pict_num; /* returns the real picture number of 375 int real_pict_num; /* returns the real picture number of
276 previous encoded frame */ 376 previous encoded frame */
277 377
278 /** 378 /**
279 * 1 -> keyframe, 0-> not 379 * 1 -> keyframe, 0-> not (this if for audio only, for video, AVVideoFrame.key_frame should be used)
280 * encoding: set by lavc (for the outputed bitstream, not the input frame) 380 * encoding: set by lavc (for the outputed bitstream, not the input frame)
281 * decoding: set by lavc (for the decoded bitstream, not the displayed frame) 381 * decoding: set by lavc (for the decoded bitstream, not the displayed frame)
282 */ 382 */
283 int key_frame; 383 int key_frame;
284
285 /**
286 * picture type of the previous en/decoded frame, see ?_TYPE below
287 * encoding: set by lavc (for the outputed bitstream, not the input frame)
288 * decoding: set by lavc (for the decoded bitstream, not the displayed frame)
289 */
290 int pict_type;
291 /* FIXME: these should have FF_ */
292 #define I_TYPE 1 // Intra
293 #define P_TYPE 2 // Predicted
294 #define B_TYPE 3 // Bi-dir predicted
295 #define S_TYPE 4 // S(GMC)-VOP MPEG4
296 384
297 /** 385 /**
298 * number of frames the decoded output will be delayed relative to 386 * number of frames the decoded output will be delayed relative to
299 * the encoded input 387 * the encoded input
300 * encoding: set by lavc. 388 * encoding: set by lavc.
301 * decoding: unused 389 * decoding: unused
302 */ 390 */
303 int delay; 391 int delay;
304
305 /**
306 * mbskip_table[mb]=1 if MB didnt change, is only valid for I/P frames
307 * stride= mb_width = (width+15)>>4 (FIXME export stride?)
308 * encoding: unused
309 * decoding: set by lavc
310 */
311 uint8_t *mbskip_table;
312 392
313 /* encoding parameters */ 393 /* encoding parameters */
314 /**
315 * quality (between 1 (good) and 31 (bad))
316 * encoding: set by user if CODEC_FLAG_QSCALE is set otherwise set by lavc
317 * decoding: set by lavc
318 */
319 int quality; /* quality of the previous encoded frame
320
321 this is allso used to set the quality in vbr mode
322 and the per frame quality in CODEC_FLAG_TYPE (second pass mode) */
323 float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/ 394 float qcompress; /* amount of qscale change between easy & hard scenes (0.0-1.0)*/
324 float qblur; /* amount of qscale smoothing over time (0.0-1.0) */ 395 float qblur; /* amount of qscale smoothing over time (0.0-1.0) */
325 396
326 /** 397 /**
327 * minimum quantizer 398 * minimum quantizer
483 * decoding: set by user 554 * decoding: set by user
484 */ 555 */
485 int error_resilience; 556 int error_resilience;
486 557
487 /** 558 /**
488 * obsolete, just here to keep ABI compatible (should be removed perhaps, dunno) 559 * called at the beginning of each frame to get a buffer for it.
489 */ 560 * if pic.reference is set then the frame will be read later by lavc
490 int *quant_store;
491
492 /**
493 * QP store stride
494 * encoding: unused 561 * encoding: unused
495 * decoding: set by lavc 562 * decoding: set by lavc, user can override
496 */ 563 */
497 int qstride; 564 int (*get_buffer)(struct AVCodecContext *c, AVVideoFrame *pic);
498 565
499 /** 566 /**
500 * buffer, where the next picture should be decoded into 567 * called to release buffers which where allocated with get_buffer.
568 * a released buffer can be reused in get_buffer()
569 * pic.data[*] must be set to NULL
501 * encoding: unused 570 * encoding: unused
502 * decoding: set by user in get_buffer_callback to a buffer into which the next part 571 * decoding: set by lavc, user can override
503 * of the bitstream will be decoded, and set by lavc at end of frame to the 572 */
504 * next frame which needs to be displayed 573 void (*release_buffer)(struct AVCodecContext *c, AVVideoFrame *pic);
505 */
506 uint8_t *dr_buffer[3];
507
508 /**
509 * stride of the luminance part of the dr buffer
510 * encoding: unused
511 * decoding: set by user
512 */
513 int dr_stride;
514
515 /**
516 * same behavior as dr_buffer, just for some private data of the user
517 * encoding: unused
518 * decoding: set by user in get_buffer_callback, and set by lavc at end of frame
519 */
520 void *dr_opaque_frame;
521
522 /**
523 * called at the beginning of each frame to get a buffer for it
524 * encoding: unused
525 * decoding: set by user
526 */
527 int (*get_buffer_callback)(struct AVCodecContext *c, int width, int height, int pict_type);
528 574
529 /** 575 /**
530 * is 1 if the decoded stream contains b frames, 0 otherwise 576 * is 1 if the decoded stream contains b frames, 0 otherwise
531 * encoding: unused 577 * encoding: unused
532 * decoding: set by lavc 578 * decoding: set by lavc
533 */ 579 */
534 int has_b_frames; 580 int has_b_frames;
535
536 /**
537 * stride of the chrominance part of the dr buffer
538 * encoding: unused
539 * decoding: set by user
540 */
541 int dr_uvstride;
542
543 /**
544 * number of dr buffers
545 * encoding: unused
546 * decoding: set by user
547 */
548 int dr_ip_buffer_count;
549 581
550 int block_align; /* used by some WAV based audio codecs */ 582 int block_align; /* used by some WAV based audio codecs */
551 583
552 int parse_only; /* decoding only: if true, only parsing is done 584 int parse_only; /* decoding only: if true, only parsing is done
553 (function avcodec_parse_frame()). The frame 585 (function avcodec_parse_frame()). The frame
643 * initial complexity for pass1 ratecontrol 675 * initial complexity for pass1 ratecontrol
644 * encoding: set by user. 676 * encoding: set by user.
645 * decoding: unused 677 * decoding: unused
646 */ 678 */
647 float rc_initial_cplx; 679 float rc_initial_cplx;
648
649 /**
650 * Obsolete, will be removed
651 */
652 int aspected_width;
653 int aspected_height;
654 680
655 /** 681 /**
656 * dct algorithm, see FF_DCT_* below 682 * dct algorithm, see FF_DCT_* below
657 * encoding: set by user 683 * encoding: set by user
658 * decoding: unused 684 * decoding: unused
662 #define FF_DCT_FASTINT 1 688 #define FF_DCT_FASTINT 1
663 #define FF_DCT_INT 2 689 #define FF_DCT_INT 2
664 #define FF_DCT_MMX 3 690 #define FF_DCT_MMX 3
665 #define FF_DCT_MLIB 4 691 #define FF_DCT_MLIB 4
666 #define FF_DCT_ALTIVEC 5 692 #define FF_DCT_ALTIVEC 5
667
668 /**
669 * presentation timestamp in micro seconds (time when frame should be shown to user)
670 * if 0 then the frame_rate will be used as reference
671 * encoding: set by user
672 * decoding; set by lavc
673 */
674 long long int pts;
675 693
676 /** 694 /**
677 * luminance masking (0-> disabled) 695 * luminance masking (0-> disabled)
678 * encoding: set by user 696 * encoding: set by user
679 * decoding: unused 697 * decoding: unused
753 int error_concealment; 771 int error_concealment;
754 #define FF_EC_GUESS_MVS 1 772 #define FF_EC_GUESS_MVS 1
755 #define FF_EC_DEBLOCK 2 773 #define FF_EC_DEBLOCK 2
756 774
757 /** 775 /**
758 * QP table of the currently decoded frame
759 * encoding; unused
760 * decoding: set by lavc
761 */
762 int8_t *current_qscale_table;
763 /**
764 * QP table of the currently displayed frame
765 * encoding; unused
766 * decoding: set by lavc
767 */
768 int8_t *display_qscale_table;
769 /**
770 * force specific pict_type.
771 * encoding; set by user (I/P/B_TYPE)
772 * decoding: unused
773 */
774 int force_type;
775 /**
776 * dsp_mask could be used to disable unwanted 776 * dsp_mask could be used to disable unwanted
777 * CPU features (i.e. MMX, SSE. ...) 777 * CPU features (i.e. MMX, SSE. ...)
778 */ 778 */
779 unsigned dsp_mask; 779 unsigned dsp_mask;
780 780
781 /** 781 /**
782 * bits per sample/pixel from the demuxer (needed for huffyuv) 782 * bits per sample/pixel from the demuxer (needed for huffyuv)
783 * encoding; set by lavc 783 * encoding: set by lavc
784 * decoding: set by user 784 * decoding: set by user
785 */ 785 */
786 int bits_per_sample; 786 int bits_per_sample;
787 787
788 /** 788 /**
789 * prediction method (needed for huffyuv) 789 * prediction method (needed for huffyuv)
790 * encoding; set by user 790 * encoding: set by user
791 * decoding: unused 791 * decoding: unused
792 */ 792 */
793 int prediction_method; 793 int prediction_method;
794 #define FF_PRED_LEFT 0 794 #define FF_PRED_LEFT 0
795 #define FF_PRED_PLANE 1 795 #define FF_PRED_PLANE 1
799 * aspect ratio. (0 if unknown) 799 * aspect ratio. (0 if unknown)
800 * encoding: set by user. 800 * encoding: set by user.
801 * decoding: set by lavc. 801 * decoding: set by lavc.
802 */ 802 */
803 float aspect_ratio; 803 float aspect_ratio;
804
805 /**
806 * the picture in the bitstream
807 * encoding: set by lavc
808 * decoding: set by lavc
809 */
810 AVVideoFrame *coded_picture;
804 } AVCodecContext; 811 } AVCodecContext;
805 812
806 typedef struct AVCodec { 813 typedef struct AVCodec {
807 const char *name; 814 const char *name;
808 int type; 815 int type;
926 void img_resample_close(ImgReSampleContext *s); 933 void img_resample_close(ImgReSampleContext *s);
927 934
928 void avpicture_fill(AVPicture *picture, UINT8 *ptr, 935 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
929 int pix_fmt, int width, int height); 936 int pix_fmt, int width, int height);
930 int avpicture_get_size(int pix_fmt, int width, int height); 937 int avpicture_get_size(int pix_fmt, int width, int height);
938 void avcodec_get_chroma_sub_sample(int fmt, int *h_shift, int *v_shift);
931 939
932 /* convert among pixel formats */ 940 /* convert among pixel formats */
933 int img_convert(AVPicture *dst, int dst_pix_fmt, 941 int img_convert(AVPicture *dst, int dst_pix_fmt,
934 AVPicture *src, int pix_fmt, 942 AVPicture *src, int pix_fmt,
935 int width, int height); 943 int width, int height);
955 AVCodec *avcodec_find_encoder_by_name(const char *name); 963 AVCodec *avcodec_find_encoder_by_name(const char *name);
956 AVCodec *avcodec_find_decoder(enum CodecID id); 964 AVCodec *avcodec_find_decoder(enum CodecID id);
957 AVCodec *avcodec_find_decoder_by_name(const char *name); 965 AVCodec *avcodec_find_decoder_by_name(const char *name);
958 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); 966 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode);
959 967
968 void avcodec_get_context_defaults(AVCodecContext *s);
960 AVCodecContext *avcodec_alloc_context(void); 969 AVCodecContext *avcodec_alloc_context(void);
970 AVVideoFrame *avcodec_alloc_picture(void);
971
972 int avcodec_default_get_buffer(AVCodecContext *s, AVVideoFrame *pic);
973 void avcodec_default_release_buffer(AVCodecContext *s, AVVideoFrame *pic);
974
961 int avcodec_open(AVCodecContext *avctx, AVCodec *codec); 975 int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
962 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples, 976 int avcodec_decode_audio(AVCodecContext *avctx, INT16 *samples,
963 int *frame_size_ptr, 977 int *frame_size_ptr,
964 UINT8 *buf, int buf_size); 978 UINT8 *buf, int buf_size);
965 int avcodec_decode_video(AVCodecContext *avctx, AVPicture *picture, 979 int avcodec_decode_video(AVCodecContext *avctx, AVVideoFrame *picture,
966 int *got_picture_ptr, 980 int *got_picture_ptr,
967 UINT8 *buf, int buf_size); 981 UINT8 *buf, int buf_size);
968 int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata, 982 int avcodec_parse_frame(AVCodecContext *avctx, UINT8 **pdata,
969 int *data_size_ptr, 983 int *data_size_ptr,
970 UINT8 *buf, int buf_size); 984 UINT8 *buf, int buf_size);
971 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size, 985 int avcodec_encode_audio(AVCodecContext *avctx, UINT8 *buf, int buf_size,
972 const short *samples); 986 const short *samples);
973 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size, 987 int avcodec_encode_video(AVCodecContext *avctx, UINT8 *buf, int buf_size,
974 const AVPicture *pict); 988 const AVVideoFrame *pict);
975 989
976 int avcodec_close(AVCodecContext *avctx); 990 int avcodec_close(AVCodecContext *avctx);
977 991
978 void avcodec_register_all(void); 992 void avcodec_register_all(void);
979 993