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/log.h"
00027 #include "libavutil/samplefmt.h"
00028 #include "libavutil/pixfmt.h"
00029 #include "libavutil/rational.h"
00030
00031 #define LIBAVFILTER_VERSION_MAJOR 2
00032 #define LIBAVFILTER_VERSION_MINOR 53
00033 #define LIBAVFILTER_VERSION_MICRO 0
00034
00035 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
00036 LIBAVFILTER_VERSION_MINOR, \
00037 LIBAVFILTER_VERSION_MICRO)
00038 #define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
00039 LIBAVFILTER_VERSION_MINOR, \
00040 LIBAVFILTER_VERSION_MICRO)
00041 #define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
00042
00043 #ifndef FF_API_OLD_VSINK_API
00044 #define FF_API_OLD_VSINK_API (LIBAVFILTER_VERSION_MAJOR < 3)
00045 #endif
00046 #ifndef FF_API_OLD_ALL_FORMATS_API
00047 #define FF_API_OLD_ALL_FORMATS_API (LIBAVFILTER_VERSION_MAJOR < 3)
00048 #endif
00049
00050 #include <stddef.h>
00051
00055 unsigned avfilter_version(void);
00056
00060 const char *avfilter_configuration(void);
00061
00065 const char *avfilter_license(void);
00066
00067
00068 typedef struct AVFilterContext AVFilterContext;
00069 typedef struct AVFilterLink AVFilterLink;
00070 typedef struct AVFilterPad AVFilterPad;
00071
00077 typedef struct AVFilterBuffer {
00078 uint8_t *data[8];
00079 int linesize[8];
00080
00081 unsigned refcount;
00082
00084 void *priv;
00091 void (*free)(struct AVFilterBuffer *buf);
00092
00093 int format;
00094 int w, h;
00095 } AVFilterBuffer;
00096
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 #define AV_PERM_NEG_LINESIZES 0x20
00103 #define AV_PERM_ALIGN 0x40
00104
00105 #define AVFILTER_ALIGN 16 //not part of ABI
00106
00112 typedef struct AVFilterBufferRefAudioProps {
00113 uint64_t channel_layout;
00114 int nb_samples;
00115 int sample_rate;
00116 int planar;
00117 } AVFilterBufferRefAudioProps;
00118
00124 typedef struct AVFilterBufferRefVideoProps {
00125 int w;
00126 int h;
00127 AVRational sample_aspect_ratio;
00128 int interlaced;
00129 int top_field_first;
00130 enum AVPictureType pict_type;
00131 int key_frame;
00132 } AVFilterBufferRefVideoProps;
00133
00142 typedef struct AVFilterBufferRef {
00143 AVFilterBuffer *buf;
00144 uint8_t *data[8];
00145 int linesize[8];
00146 int format;
00147
00153 int64_t pts;
00154 int64_t pos;
00155
00156 int perms;
00157
00158 enum AVMediaType type;
00159 AVFilterBufferRefVideoProps *video;
00160 AVFilterBufferRefAudioProps *audio;
00161 } AVFilterBufferRef;
00162
00166 static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
00167 {
00168
00169 dst->pts = src->pts;
00170 dst->pos = src->pos;
00171
00172 switch (src->type) {
00173 case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
00174 case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
00175 default: break;
00176 }
00177 }
00178
00188 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
00189
00196 void avfilter_unref_buffer(AVFilterBufferRef *ref);
00197
00238 typedef struct AVFilterFormats {
00239 unsigned format_count;
00240 int64_t *formats;
00241
00242 unsigned refcount;
00243 struct AVFilterFormats ***refs;
00244 } AVFilterFormats;
00245
00254 AVFilterFormats *avfilter_make_format_list(const int *fmts);
00255 AVFilterFormats *avfilter_make_format64_list(const int64_t *fmts);
00256
00265 int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
00266
00267 #if FF_API_OLD_ALL_FORMATS_API
00268
00271 attribute_deprecated
00272 AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
00273 #endif
00274
00278 AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type);
00279
00283 extern const int64_t avfilter_all_channel_layouts[];
00284
00288 AVFilterFormats *avfilter_make_all_channel_layouts(void);
00289
00293 AVFilterFormats *avfilter_make_all_packing_formats(void);
00294
00303 AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
00304
00317 void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
00318
00334 void avfilter_formats_unref(AVFilterFormats **ref);
00335
00349 void avfilter_formats_changeref(AVFilterFormats **oldref,
00350 AVFilterFormats **newref);
00351
00355 struct AVFilterPad {
00361 const char *name;
00362
00366 enum AVMediaType type;
00367
00375 int min_perms;
00376
00386 int rej_perms;
00387
00395 void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
00396
00403 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
00404
00411 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples);
00412
00420 void (*end_frame)(AVFilterLink *link);
00421
00428 void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
00429
00436 void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
00437
00447 int (*poll_frame)(AVFilterLink *link);
00448
00456 int (*request_frame)(AVFilterLink *link);
00457
00475 int (*config_props)(AVFilterLink *link);
00476 };
00477
00479 void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00480
00482 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00483
00485 void avfilter_default_end_frame(AVFilterLink *link);
00486
00488 void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00489
00491 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
00492 int perms, int w, int h);
00493
00495 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link,
00496 int perms, int nb_samples);
00497
00503 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00504 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00505 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
00506 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00507
00509 int avfilter_default_query_formats(AVFilterContext *ctx);
00510
00512 void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00513
00515 void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00516
00518 void avfilter_null_end_frame(AVFilterLink *link);
00519
00521 void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00522
00524 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
00525 int perms, int w, int h);
00526
00528 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link,
00529 int perms, int nb_samples);
00530
00535 typedef struct AVFilter {
00536 const char *name;
00537
00538 int priv_size;
00539
00546 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
00547
00553 void (*uninit)(AVFilterContext *ctx);
00554
00563 int (*query_formats)(AVFilterContext *);
00564
00565 const AVFilterPad *inputs;
00566 const AVFilterPad *outputs;
00567
00572 const char *description;
00573
00586 int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
00587 } AVFilter;
00588
00590 struct AVFilterContext {
00591 const AVClass *av_class;
00592
00593 AVFilter *filter;
00594
00595 char *name;
00596
00597 unsigned input_count;
00598 AVFilterPad *input_pads;
00599 AVFilterLink **inputs;
00600
00601 unsigned output_count;
00602 AVFilterPad *output_pads;
00603 AVFilterLink **outputs;
00604
00605 void *priv;
00606
00607 struct AVFilterCommand *command_queue;
00608 };
00609
00610 enum AVFilterPacking {
00611 AVFILTER_PACKED = 0,
00612 AVFILTER_PLANAR,
00613 };
00614
00622 struct AVFilterLink {
00623 AVFilterContext *src;
00624 AVFilterPad *srcpad;
00625
00626 AVFilterContext *dst;
00627 AVFilterPad *dstpad;
00628
00630 enum {
00631 AVLINK_UNINIT = 0,
00632 AVLINK_STARTINIT,
00633 AVLINK_INIT
00634 } init_state;
00635
00636 enum AVMediaType type;
00637
00638
00639 int w;
00640 int h;
00641 AVRational sample_aspect_ratio;
00642
00643 uint64_t channel_layout;
00644 #if LIBAVFILTER_VERSION_MAJOR < 3
00645 int64_t sample_rate;
00646 #else
00647 int sample_rate;
00648 #endif
00649 int planar;
00650
00651 int format;
00652
00660 AVFilterFormats *in_formats;
00661 AVFilterFormats *out_formats;
00662
00663 AVFilterFormats *in_chlayouts;
00664 AVFilterFormats *out_chlayouts;
00665 AVFilterFormats *in_packing;
00666 AVFilterFormats *out_packing;
00667
00675 AVFilterBufferRef *src_buf;
00676
00677 AVFilterBufferRef *cur_buf;
00678 AVFilterBufferRef *out_buf;
00679
00687 AVRational time_base;
00688
00689 struct AVFilterPool *pool;
00690 };
00691
00701 int avfilter_link(AVFilterContext *src, unsigned srcpad,
00702 AVFilterContext *dst, unsigned dstpad);
00703
00707 void avfilter_link_free(AVFilterLink **link);
00708
00715 int avfilter_config_links(AVFilterContext *filter);
00716
00728 AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
00729 int w, int h);
00730
00742 AVFilterBufferRef *
00743 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
00744 int w, int h, enum PixelFormat format);
00745
00756 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
00757 int nb_samples);
00758
00771 AVFilterBufferRef *
00772 avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
00773 int nb_samples, enum AVSampleFormat sample_fmt,
00774 uint64_t channel_layout, int planar);
00781 int avfilter_request_frame(AVFilterLink *link);
00782
00790 int avfilter_poll_frame(AVFilterLink *link);
00791
00801 void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00802
00808 void avfilter_end_frame(AVFilterLink *link);
00809
00825 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00826
00827 #define AVFILTER_CMD_FLAG_ONE 1
00828 #define AVFILTER_CMD_FLAG_FAST 2
00829
00830
00834 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
00835
00844 void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
00845
00847 void avfilter_register_all(void);
00848
00850 void avfilter_uninit(void);
00851
00862 int avfilter_register(AVFilter *filter);
00863
00871 AVFilter *avfilter_get_by_name(const char *name);
00872
00879 AVFilter **av_filter_next(AVFilter **filter);
00880
00890 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
00891
00902 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
00903
00909 void avfilter_free(AVFilterContext *filter);
00910
00920 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
00921 unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
00922
00936 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
00937 AVFilterPad **pads, AVFilterLink ***links,
00938 AVFilterPad *newpad);
00939
00941 static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
00942 AVFilterPad *p)
00943 {
00944 avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
00945 &f->input_pads, &f->inputs, p);
00946 }
00947
00949 static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
00950 AVFilterPad *p)
00951 {
00952 avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
00953 &f->output_pads, &f->outputs, p);
00954 }
00955
00956 #endif