00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVFILTER_AVFILTER_H
00023 #define AVFILTER_AVFILTER_H
00024
00025 #include "libavutil/avutil.h"
00026 #include "libavutil/samplefmt.h"
00027
00028 #define LIBAVFILTER_VERSION_MAJOR 2
00029 #define LIBAVFILTER_VERSION_MINOR 23
00030 #define LIBAVFILTER_VERSION_MICRO 0
00031
00032 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
00033 LIBAVFILTER_VERSION_MINOR, \
00034 LIBAVFILTER_VERSION_MICRO)
00035 #define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
00036 LIBAVFILTER_VERSION_MINOR, \
00037 LIBAVFILTER_VERSION_MICRO)
00038 #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
00039
00040 #include <stddef.h>
00041
00045 unsigned avfilter_version(void);
00046
00050 const char *avfilter_configuration(void);
00051
00055 const char *avfilter_license(void);
00056
00057
00058 typedef struct AVFilterContext AVFilterContext;
00059 typedef struct AVFilterLink AVFilterLink;
00060 typedef struct AVFilterPad AVFilterPad;
00061
00067 typedef struct AVFilterBuffer {
00068 uint8_t *data[8];
00069 int linesize[8];
00070
00071 unsigned refcount;
00072
00074 void *priv;
00081 void (*free)(struct AVFilterBuffer *buf);
00082
00083 int format;
00084 int w, h;
00085 } AVFilterBuffer;
00086
00087 #define AV_PERM_READ 0x01
00088 #define AV_PERM_WRITE 0x02
00089 #define AV_PERM_PRESERVE 0x04
00090 #define AV_PERM_REUSE 0x08
00091 #define AV_PERM_REUSE2 0x10
00092 #define AV_PERM_NEG_LINESIZES 0x20
00093
00094
00099 typedef struct AVFilterBufferRefAudioProps {
00100 int64_t channel_layout;
00101 int nb_samples;
00102 uint32_t sample_rate;
00103 int planar;
00104 } AVFilterBufferRefAudioProps;
00105
00111 typedef struct AVFilterBufferRefVideoProps {
00112 int w;
00113 int h;
00114 AVRational sample_aspect_ratio;
00115 int interlaced;
00116 int top_field_first;
00117 enum AVPictureType pict_type;
00118 int key_frame;
00119 } AVFilterBufferRefVideoProps;
00120
00129 typedef struct AVFilterBufferRef {
00130 AVFilterBuffer *buf;
00131 uint8_t *data[8];
00132 int linesize[8];
00133 int format;
00134
00140 int64_t pts;
00141 int64_t pos;
00142
00143 int perms;
00144
00145 enum AVMediaType type;
00146 AVFilterBufferRefVideoProps *video;
00147 AVFilterBufferRefAudioProps *audio;
00148 } AVFilterBufferRef;
00149
00153 static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
00154 {
00155
00156 dst->pts = src->pts;
00157 dst->pos = src->pos;
00158
00159 switch (src->type) {
00160 case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
00161 case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
00162 }
00163 }
00164
00174 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
00175
00182 void avfilter_unref_buffer(AVFilterBufferRef *ref);
00183
00224 typedef struct AVFilterFormats {
00225 unsigned format_count;
00226 int64_t *formats;
00227
00228 unsigned refcount;
00229 struct AVFilterFormats ***refs;
00230 } AVFilterFormats;
00231
00240 AVFilterFormats *avfilter_make_format_list(const int *fmts);
00241 AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts);
00242
00251 int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
00252
00256 AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
00257
00261 AVFilterFormats *avfilter_all_channel_layouts(void);
00262
00271 AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
00272
00285 void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
00286
00302 void avfilter_formats_unref(AVFilterFormats **ref);
00303
00317 void avfilter_formats_changeref(AVFilterFormats **oldref,
00318 AVFilterFormats **newref);
00319
00323 struct AVFilterPad {
00329 const char *name;
00330
00335 enum AVMediaType type;
00336
00344 int min_perms;
00345
00355 int rej_perms;
00356
00364 void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
00365
00372 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
00373
00380 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
00381 enum AVSampleFormat sample_fmt, int nb_samples,
00382 int64_t channel_layout, int planar);
00383
00391 void (*end_frame)(AVFilterLink *link);
00392
00399 void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
00400
00407 void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
00408
00418 int (*poll_frame)(AVFilterLink *link);
00419
00427 int (*request_frame)(AVFilterLink *link);
00428
00443 int (*config_props)(AVFilterLink *link);
00444 };
00445
00447 void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00448
00450 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00451
00453 void avfilter_default_end_frame(AVFilterLink *link);
00454
00456 void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00457
00459 int avfilter_default_config_output_link(AVFilterLink *link);
00460
00462 int avfilter_default_config_input_link (AVFilterLink *link);
00463
00465 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
00466 int perms, int w, int h);
00467
00469 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
00470 enum AVSampleFormat sample_fmt, int nb_samples,
00471 int64_t channel_layout, int planar);
00472
00478 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00479 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00480 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
00481
00483 int avfilter_default_query_formats(AVFilterContext *ctx);
00484
00486 void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00487
00489 void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00490
00492 void avfilter_null_end_frame(AVFilterLink *link);
00493
00495 void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00496
00498 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
00499 int perms, int w, int h);
00500
00502 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
00503 enum AVSampleFormat sample_fmt, int size,
00504 int64_t channel_layout, int planar);
00505
00510 typedef struct AVFilter {
00511 const char *name;
00512
00513 int priv_size;
00514
00521 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
00522
00528 void (*uninit)(AVFilterContext *ctx);
00529
00538 int (*query_formats)(AVFilterContext *);
00539
00540 const AVFilterPad *inputs;
00541 const AVFilterPad *outputs;
00542
00547 const char *description;
00548 } AVFilter;
00549
00551 struct AVFilterContext {
00552 const AVClass *av_class;
00553
00554 AVFilter *filter;
00555
00556 char *name;
00557
00558 unsigned input_count;
00559 AVFilterPad *input_pads;
00560 AVFilterLink **inputs;
00561
00562 unsigned output_count;
00563 AVFilterPad *output_pads;
00564 AVFilterLink **outputs;
00565
00566 void *priv;
00567 };
00568
00576 struct AVFilterLink {
00577 AVFilterContext *src;
00578 AVFilterPad *srcpad;
00579
00580 AVFilterContext *dst;
00581 AVFilterPad *dstpad;
00582
00584 enum {
00585 AVLINK_UNINIT = 0,
00586 AVLINK_STARTINIT,
00587 AVLINK_INIT
00588 } init_state;
00589
00590 enum AVMediaType type;
00591
00592
00593 int w;
00594 int h;
00595 AVRational sample_aspect_ratio;
00596
00597 int64_t channel_layout;
00598 int64_t sample_rate;
00599
00600 int format;
00601
00609 AVFilterFormats *in_formats;
00610 AVFilterFormats *out_formats;
00611
00612 AVFilterFormats *in_chlayouts;
00613 AVFilterFormats *out_chlayouts;
00614
00622 AVFilterBufferRef *src_buf;
00623
00624 AVFilterBufferRef *cur_buf;
00625 AVFilterBufferRef *out_buf;
00626
00634 AVRational time_base;
00635
00636 struct AVFilterPool *pool;
00637 };
00638
00648 int avfilter_link(AVFilterContext *src, unsigned srcpad,
00649 AVFilterContext *dst, unsigned dstpad);
00650
00654 void avfilter_link_free(AVFilterLink **link);
00655
00662 int avfilter_config_links(AVFilterContext *filter);
00663
00675 AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
00676 int w, int h);
00677
00689 AVFilterBufferRef *
00690 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
00691 int w, int h, enum PixelFormat format);
00692
00706 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
00707 enum AVSampleFormat sample_fmt, int nb_samples,
00708 int64_t channel_layout, int planar);
00709
00722 AVFilterBufferRef *
00723 avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
00724 int nb_samples, enum AVSampleFormat sample_fmt,
00725 int64_t channel_layout, int planar);
00726
00733 int avfilter_request_frame(AVFilterLink *link);
00734
00742 int avfilter_poll_frame(AVFilterLink *link);
00743
00753 void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00754
00760 void avfilter_end_frame(AVFilterLink *link);
00761
00777 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00778
00787 void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00788
00790 void avfilter_register_all(void);
00791
00793 void avfilter_uninit(void);
00794
00805 int avfilter_register(AVFilter *filter);
00806
00814 AVFilter *avfilter_get_by_name(const char *name);
00815
00822 AVFilter **av_filter_next(AVFilter **filter);
00823
00833 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
00834
00845 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
00846
00852 void avfilter_free(AVFilterContext *filter);
00853
00863 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
00864 unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
00865
00879 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
00880 AVFilterPad **pads, AVFilterLink ***links,
00881 AVFilterPad *newpad);
00882
00884 static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
00885 AVFilterPad *p)
00886 {
00887 avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
00888 &f->input_pads, &f->inputs, p);
00889 }
00890
00892 static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
00893 AVFilterPad *p)
00894 {
00895 avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
00896 &f->output_pads, &f->outputs, p);
00897 }
00898
00899 #endif