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 #include "libavcodec/avcodec.h"
00031
00032
00033 #ifndef FF_API_OLD_VSINK_API
00034 #define FF_API_OLD_VSINK_API (LIBAVFILTER_VERSION_MAJOR < 3)
00035 #endif
00036 #ifndef FF_API_OLD_ALL_FORMATS_API
00037 #define FF_API_OLD_ALL_FORMATS_API (LIBAVFILTER_VERSION_MAJOR < 3)
00038 #endif
00039
00040 #include <stddef.h>
00041
00042 #include "libavfilter/version.h"
00043
00047 unsigned avfilter_version(void);
00048
00052 const char *avfilter_configuration(void);
00053
00057 const char *avfilter_license(void);
00058
00059
00060 typedef struct AVFilterContext AVFilterContext;
00061 typedef struct AVFilterLink AVFilterLink;
00062 typedef struct AVFilterPad AVFilterPad;
00063
00069 typedef struct AVFilterBuffer {
00070 uint8_t *data[8];
00071 int linesize[8];
00072
00073 unsigned refcount;
00074
00076 void *priv;
00083 void (*free)(struct AVFilterBuffer *buf);
00084
00085 int format;
00086 int w, h;
00087
00102 uint8_t **extended_data;
00103 } AVFilterBuffer;
00104
00105 #define AV_PERM_READ 0x01
00106 #define AV_PERM_WRITE 0x02
00107 #define AV_PERM_PRESERVE 0x04
00108 #define AV_PERM_REUSE 0x08
00109 #define AV_PERM_REUSE2 0x10
00110 #define AV_PERM_NEG_LINESIZES 0x20
00111 #define AV_PERM_ALIGN 0x40
00112
00113 #define AVFILTER_ALIGN 16 //not part of ABI
00114
00120 typedef struct AVFilterBufferRefAudioProps {
00121 uint64_t channel_layout;
00122 int nb_samples;
00123 int sample_rate;
00124 #if FF_API_PACKING
00125 int planar;
00126 #endif
00127 } AVFilterBufferRefAudioProps;
00128
00134 typedef struct AVFilterBufferRefVideoProps {
00135 int w;
00136 int h;
00137 AVRational sample_aspect_ratio;
00138 int interlaced;
00139 int top_field_first;
00140 enum AVPictureType pict_type;
00141 int key_frame;
00142 } AVFilterBufferRefVideoProps;
00143
00152 typedef struct AVFilterBufferRef {
00153 AVFilterBuffer *buf;
00154 uint8_t *data[8];
00155 int linesize[8];
00156 int format;
00157
00163 int64_t pts;
00164 int64_t pos;
00165
00166 int perms;
00167
00168 enum AVMediaType type;
00169 AVFilterBufferRefVideoProps *video;
00170 AVFilterBufferRefAudioProps *audio;
00171
00186 uint8_t **extended_data;
00187 } AVFilterBufferRef;
00188
00192 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
00193
00203 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
00204
00211 void avfilter_unref_buffer(AVFilterBufferRef *ref);
00212
00220 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
00221
00262 typedef struct AVFilterFormats {
00263 unsigned format_count;
00264 int *formats;
00265
00266 unsigned refcount;
00267 struct AVFilterFormats ***refs;
00268 } AVFilterFormats;
00269
00278 AVFilterFormats *avfilter_make_format_list(const int *fmts);
00279
00288 int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
00289
00290 #if FF_API_OLD_ALL_FORMATS_API
00291
00294 attribute_deprecated
00295 AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
00296 #endif
00297
00301 AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type);
00302
00306 extern const int64_t avfilter_all_channel_layouts[];
00307
00308 #if FF_API_PACKING
00309
00312 AVFilterFormats *avfilter_make_all_packing_formats(void);
00313 #endif
00314
00323 AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
00324
00337 void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
00338
00354 void avfilter_formats_unref(AVFilterFormats **ref);
00355
00369 void avfilter_formats_changeref(AVFilterFormats **oldref,
00370 AVFilterFormats **newref);
00371
00377 struct AVFilterPad {
00383 const char *name;
00384
00388 enum AVMediaType type;
00389
00397 int min_perms;
00398
00408 int rej_perms;
00409
00417 void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
00418
00425 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
00426
00433 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
00434 int nb_samples);
00435
00443 void (*end_frame)(AVFilterLink *link);
00444
00451 void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
00452
00459 void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
00460
00470 int (*poll_frame)(AVFilterLink *link);
00471
00481 int (*request_frame)(AVFilterLink *link);
00482
00500 int (*config_props)(AVFilterLink *link);
00501 };
00502
00503 #if FF_API_FILTERS_PUBLIC
00504
00505 attribute_deprecated
00506 void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00507
00509 attribute_deprecated
00510 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00511
00513 attribute_deprecated
00514 void avfilter_default_end_frame(AVFilterLink *link);
00515
00517 attribute_deprecated
00518 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
00519 int perms, int w, int h);
00520
00522 attribute_deprecated
00523 int avfilter_default_query_formats(AVFilterContext *ctx);
00524 #endif
00525
00531 void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00532 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00533 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00534 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
00535 #if FF_API_PACKING
00536 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
00537 #endif
00538
00539 #if FF_API_FILTERS_PUBLIC
00540
00541 attribute_deprecated
00542 void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00543
00545 attribute_deprecated
00546 void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00547
00549 attribute_deprecated
00550 void avfilter_null_end_frame(AVFilterLink *link);
00551
00553 attribute_deprecated
00554 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
00555 int perms, int w, int h);
00556 #endif
00557
00562 typedef struct AVFilter {
00563 const char *name;
00564
00565 int priv_size;
00566
00573 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
00574
00580 void (*uninit)(AVFilterContext *ctx);
00581
00590 int (*query_formats)(AVFilterContext *);
00591
00592 const AVFilterPad *inputs;
00593 const AVFilterPad *outputs;
00594
00599 const char *description;
00600
00613 int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
00614 } AVFilter;
00615
00617 struct AVFilterContext {
00618 const AVClass *av_class;
00619
00620 AVFilter *filter;
00621
00622 char *name;
00623
00624 unsigned input_count;
00625 AVFilterPad *input_pads;
00626 AVFilterLink **inputs;
00627
00628 unsigned output_count;
00629 AVFilterPad *output_pads;
00630 AVFilterLink **outputs;
00631
00632 void *priv;
00633
00634 struct AVFilterCommand *command_queue;
00635 };
00636
00637 #if FF_API_PACKING
00638 enum AVFilterPacking {
00639 AVFILTER_PACKED = 0,
00640 AVFILTER_PLANAR,
00641 };
00642 #endif
00643
00651 struct AVFilterLink {
00652 AVFilterContext *src;
00653 AVFilterPad *srcpad;
00654
00655 AVFilterContext *dst;
00656 AVFilterPad *dstpad;
00657
00659 enum {
00660 AVLINK_UNINIT = 0,
00661 AVLINK_STARTINIT,
00662 AVLINK_INIT
00663 } init_state;
00664
00665 enum AVMediaType type;
00666
00667
00668 int w;
00669 int h;
00670 AVRational sample_aspect_ratio;
00671
00672 uint64_t channel_layout;
00673 #if FF_API_SAMPLERATE64
00674 int64_t sample_rate;
00675 #else
00676 int sample_rate;
00677 #endif
00678 #if FF_API_PACKING
00679 int planar;
00680 #endif
00681
00682 int format;
00683
00691 AVFilterFormats *in_formats;
00692 AVFilterFormats *out_formats;
00693
00694 #if FF_API_PACKING
00695 AVFilterFormats *in_packing;
00696 AVFilterFormats *out_packing;
00697 #endif
00698
00706 AVFilterBufferRef *src_buf;
00707
00708 AVFilterBufferRef *cur_buf;
00709 AVFilterBufferRef *out_buf;
00710
00718 AVRational time_base;
00719
00720
00721
00722
00723
00724
00725
00726
00731 AVFilterFormats *in_samplerates;
00732 AVFilterFormats *out_samplerates;
00733 struct AVFilterChannelLayouts *in_channel_layouts;
00734 struct AVFilterChannelLayouts *out_channel_layouts;
00735
00736 struct AVFilterPool *pool;
00737
00741 struct AVFilterGraph *graph;
00742
00747 int64_t current_pts;
00748
00752 int age_index;
00753
00754 };
00755
00765 int avfilter_link(AVFilterContext *src, unsigned srcpad,
00766 AVFilterContext *dst, unsigned dstpad);
00767
00771 void avfilter_link_free(AVFilterLink **link);
00772
00779 int avfilter_config_links(AVFilterContext *filter);
00780
00792 AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
00793 int w, int h);
00794
00806 AVFilterBufferRef *
00807 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
00808 int w, int h, enum PixelFormat format);
00809
00821 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
00822 int linesize,
00823 int perms,
00824 int nb_samples,
00825 enum AVSampleFormat sample_fmt,
00826 uint64_t channel_layout);
00827
00837 int avfilter_request_frame(AVFilterLink *link);
00838
00846 int avfilter_poll_frame(AVFilterLink *link);
00847
00857 void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
00858
00864 void avfilter_end_frame(AVFilterLink *link);
00865
00881 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
00882
00883 #define AVFILTER_CMD_FLAG_ONE 1
00884 #define AVFILTER_CMD_FLAG_FAST 2
00885
00886
00890 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
00891
00893 void avfilter_register_all(void);
00894
00896 void avfilter_uninit(void);
00897
00908 int avfilter_register(AVFilter *filter);
00909
00917 AVFilter *avfilter_get_by_name(const char *name);
00918
00925 AVFilter **av_filter_next(AVFilter **filter);
00926
00936 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
00937
00948 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
00949
00955 void avfilter_free(AVFilterContext *filter);
00956
00966 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
00967 unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
00968
00982 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
00983 AVFilterPad **pads, AVFilterLink ***links,
00984 AVFilterPad *newpad);
00985
00987 static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
00988 AVFilterPad *p)
00989 {
00990 avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
00991 &f->input_pads, &f->inputs, p);
00992 }
00993
00995 static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
00996 AVFilterPad *p)
00997 {
00998 avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
00999 &f->output_pads, &f->outputs, p);
01000 }
01001
01002 #endif