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 #define LIBAVFILTER_VERSION_MAJOR 0
00026 #define LIBAVFILTER_VERSION_MINOR 4
00027 #define LIBAVFILTER_VERSION_MICRO 0
00028
00029 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
00030 LIBAVFILTER_VERSION_MINOR, \
00031 LIBAVFILTER_VERSION_MICRO)
00032 #define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
00033 LIBAVFILTER_VERSION_MINOR, \
00034 LIBAVFILTER_VERSION_MICRO)
00035 #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
00036
00037 #include <stddef.h>
00038 #include "libavcodec/avcodec.h"
00039
00043 unsigned avfilter_version(void);
00044
00045 typedef struct AVFilterContext AVFilterContext;
00046 typedef struct AVFilterLink AVFilterLink;
00047 typedef struct AVFilterPad AVFilterPad;
00048
00049
00050
00051
00057 typedef struct AVFilterPic
00058 {
00059 uint8_t *data[4];
00060 int linesize[4];
00061 enum PixelFormat format;
00062
00063 unsigned refcount;
00064
00066 void *priv;
00073 void (*free)(struct AVFilterPic *pic);
00074 } AVFilterPic;
00075
00084 typedef struct AVFilterPicRef
00085 {
00086 AVFilterPic *pic;
00087 uint8_t *data[4];
00088 int linesize[4];
00089 int w;
00090 int h;
00091
00092 int64_t pts;
00093
00094 AVRational pixel_aspect;
00095
00096 int perms;
00097 #define AV_PERM_READ 0x01
00098 #define AV_PERM_WRITE 0x02
00099 #define AV_PERM_PRESERVE 0x04
00100 #define AV_PERM_REUSE 0x08
00101 #define AV_PERM_REUSE2 0x10
00102 } AVFilterPicRef;
00103
00112 AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask);
00113
00119 void avfilter_unref_pic(AVFilterPicRef *ref);
00120
00161 typedef struct AVFilterFormats AVFilterFormats;
00162 struct AVFilterFormats
00163 {
00164 unsigned format_count;
00165 int *formats;
00166
00167 unsigned refcount;
00168 AVFilterFormats ***refs;
00169 };
00170
00178 AVFilterFormats *avfilter_make_format_list(int len, ...);
00179
00183 AVFilterFormats *avfilter_all_colorspaces(void);
00184
00193 AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
00194
00207 void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
00208
00223 void avfilter_formats_unref(AVFilterFormats **ref);
00224
00238 void avfilter_formats_changeref(AVFilterFormats **oldref,
00239 AVFilterFormats **newref);
00240
00244 struct AVFilterPad
00245 {
00251 const char *name;
00252
00257 enum CodecType type;
00258
00266 int min_perms;
00267
00277 int rej_perms;
00278
00286 void (*start_frame)(AVFilterLink *link, AVFilterPicRef *picref);
00287
00294 AVFilterPicRef *(*get_video_buffer)(AVFilterLink *link, int perms);
00295
00303 void (*end_frame)(AVFilterLink *link);
00304
00311 void (*draw_slice)(AVFilterLink *link, int y, int height);
00312
00322 int (*poll_frame)(AVFilterLink *link);
00323
00331 int (*request_frame)(AVFilterLink *link);
00332
00347 int (*config_props)(AVFilterLink *link);
00348 };
00349
00351 void avfilter_default_start_frame(AVFilterLink *link, AVFilterPicRef *picref);
00353 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h);
00355 void avfilter_default_end_frame(AVFilterLink *link);
00357 int avfilter_default_config_output_link(AVFilterLink *link);
00359 int avfilter_default_config_input_link (AVFilterLink *link);
00361 AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link,
00362 int perms);
00368 void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00370 int avfilter_default_query_formats(AVFilterContext *ctx);
00371
00376 typedef struct
00377 {
00378 const char *name;
00379
00380 int priv_size;
00381
00388 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
00389
00395 void (*uninit)(AVFilterContext *ctx);
00396
00404 int (*query_formats)(AVFilterContext *);
00405
00406 const AVFilterPad *inputs;
00407 const AVFilterPad *outputs;
00408 } AVFilter;
00409
00411 struct AVFilterContext
00412 {
00413 const AVClass *av_class;
00414
00415 AVFilter *filter;
00416
00417 char *name;
00418
00419 unsigned input_count;
00420 AVFilterPad *input_pads;
00421 AVFilterLink **inputs;
00422
00423 unsigned output_count;
00424 AVFilterPad *output_pads;
00425 AVFilterLink **outputs;
00426
00427 void *priv;
00428 };
00429
00437 struct AVFilterLink
00438 {
00439 AVFilterContext *src;
00440 unsigned int srcpad;
00441
00442 AVFilterContext *dst;
00443 unsigned int dstpad;
00444
00446 enum {
00447 AVLINK_UNINIT = 0,
00448 AVLINK_STARTINIT,
00449 AVLINK_INIT
00450 } init_state;
00451
00452 int w;
00453 int h;
00454 enum PixelFormat format;
00455
00461 AVFilterFormats *in_formats;
00462 AVFilterFormats *out_formats;
00463
00471 AVFilterPicRef *srcpic;
00472
00473 AVFilterPicRef *cur_pic;
00474 AVFilterPicRef *outpic;
00475 };
00476
00485 int avfilter_link(AVFilterContext *src, unsigned srcpad,
00486 AVFilterContext *dst, unsigned dstpad);
00487
00493 int avfilter_config_links(AVFilterContext *filter);
00494
00503 AVFilterPicRef *avfilter_get_video_buffer(AVFilterLink *link, int perms);
00504
00510 int avfilter_request_frame(AVFilterLink *link);
00511
00518 int avfilter_poll_frame(AVFilterLink *link);
00519
00528 void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref);
00529
00534 void avfilter_end_frame(AVFilterLink *link);
00535
00542 void avfilter_draw_slice(AVFilterLink *link, int y, int h);
00543
00545 void avfilter_register_all(void);
00546
00548 void avfilter_uninit(void);
00549
00557 void avfilter_register(AVFilter *filter);
00558
00565 AVFilter *avfilter_get_by_name(const char *name);
00566
00573 AVFilterContext *avfilter_open(AVFilter *filter, const char *inst_name);
00574
00584 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
00585
00590 void avfilter_destroy(AVFilterContext *filter);
00591
00600 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
00601 unsigned in, unsigned out);
00602
00615 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
00616 AVFilterPad **pads, AVFilterLink ***links,
00617 AVFilterPad *newpad);
00618
00620 static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
00621 AVFilterPad *p)
00622 {
00623 avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
00624 &f->input_pads, &f->inputs, p);
00625 }
00626
00628 static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
00629 AVFilterPad *p)
00630 {
00631 avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
00632 &f->output_pads, &f->outputs, p);
00633 }
00634
00635 #endif