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 <stddef.h>
00026
00027 #include "libavutil/avutil.h"
00028 #include "libavutil/log.h"
00029 #include "libavutil/samplefmt.h"
00030 #include "libavutil/pixfmt.h"
00031 #include "libavutil/rational.h"
00032
00033 #include "libavfilter/version.h"
00034
00038 unsigned avfilter_version(void);
00039
00043 const char *avfilter_configuration(void);
00044
00048 const char *avfilter_license(void);
00049
00053 const AVClass *avfilter_get_class(void);
00054
00055 typedef struct AVFilterContext AVFilterContext;
00056 typedef struct AVFilterLink AVFilterLink;
00057 typedef struct AVFilterPad AVFilterPad;
00058 typedef struct AVFilterFormats AVFilterFormats;
00059
00065 typedef struct AVFilterBuffer {
00066 uint8_t *data[8];
00067
00082 uint8_t **extended_data;
00083 int linesize[8];
00084
00086 void *priv;
00093 void (*free)(struct AVFilterBuffer *buf);
00094
00095 int format;
00096 int w, h;
00097 unsigned refcount;
00098 } AVFilterBuffer;
00099
00100 #define AV_PERM_READ 0x01
00101 #define AV_PERM_WRITE 0x02
00102 #define AV_PERM_PRESERVE 0x04
00103 #define AV_PERM_REUSE 0x08
00104 #define AV_PERM_REUSE2 0x10
00105 #define AV_PERM_NEG_LINESIZES 0x20
00106 #define AV_PERM_ALIGN 0x40
00107
00108 #define AVFILTER_ALIGN 16 //not part of ABI
00109
00115 typedef struct AVFilterBufferRefAudioProps {
00116 uint64_t channel_layout;
00117 int nb_samples;
00118 int sample_rate;
00119 } AVFilterBufferRefAudioProps;
00120
00126 typedef struct AVFilterBufferRefVideoProps {
00127 int w;
00128 int h;
00129 AVRational sample_aspect_ratio;
00130 int interlaced;
00131 int top_field_first;
00132 enum AVPictureType pict_type;
00133 int key_frame;
00134 int qp_table_linesize;
00135 int qp_table_size;
00136 int8_t *qp_table;
00137 } AVFilterBufferRefVideoProps;
00138
00147 typedef struct AVFilterBufferRef {
00148 AVFilterBuffer *buf;
00149 uint8_t *data[8];
00150
00164 uint8_t **extended_data;
00165 int linesize[8];
00166
00167 AVFilterBufferRefVideoProps *video;
00168 AVFilterBufferRefAudioProps *audio;
00169
00175 int64_t pts;
00176 int64_t pos;
00177
00178 int format;
00179
00180 int perms;
00181
00182 enum AVMediaType type;
00183 } AVFilterBufferRef;
00184
00188 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
00189
00199 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
00200
00210 void avfilter_unref_buffer(AVFilterBufferRef *ref);
00211
00219 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
00220
00221 #if FF_API_AVFILTERPAD_PUBLIC
00222
00232 struct AVFilterPad {
00238 const char *name;
00239
00243 enum AVMediaType type;
00244
00256 int min_perms;
00257
00270 int rej_perms;
00271
00288 int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
00289
00296 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
00297
00304 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
00305 int nb_samples);
00306
00316 int (*end_frame)(AVFilterLink *link);
00317
00326 int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
00327
00338 int (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
00339
00349 int (*poll_frame)(AVFilterLink *link);
00350
00360 int (*request_frame)(AVFilterLink *link);
00361
00379 int (*config_props)(AVFilterLink *link);
00380
00387 int needs_fifo;
00388 };
00389 #endif
00390
00400 const char *avfilter_pad_get_name(AVFilterPad *pads, int pad_idx);
00401
00411 enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx);
00412
00417 typedef struct AVFilter {
00418 const char *name;
00419
00424 const char *description;
00425
00426 const AVFilterPad *inputs;
00427 const AVFilterPad *outputs;
00428
00429
00430
00431
00432
00433
00434
00435
00436
00441 int (*init)(AVFilterContext *ctx, const char *args);
00442
00448 void (*uninit)(AVFilterContext *ctx);
00449
00458 int (*query_formats)(AVFilterContext *);
00459
00460 int priv_size;
00461
00474 int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
00475
00481 int (*init_opaque)(AVFilterContext *ctx, const char *args, void *opaque);
00482
00483 const AVClass *priv_class;
00484 } AVFilter;
00485
00487 struct AVFilterContext {
00488 const AVClass *av_class;
00489
00490 AVFilter *filter;
00491
00492 char *name;
00493
00494 AVFilterPad *input_pads;
00495 AVFilterLink **inputs;
00496 #if FF_API_FOO_COUNT
00497 unsigned input_count;
00498 #endif
00499 unsigned nb_inputs;
00500
00501 AVFilterPad *output_pads;
00502 AVFilterLink **outputs;
00503 #if FF_API_FOO_COUNT
00504 unsigned output_count;
00505 #endif
00506 unsigned nb_outputs;
00507
00508 void *priv;
00509
00510 struct AVFilterCommand *command_queue;
00511 };
00512
00520 struct AVFilterLink {
00521 AVFilterContext *src;
00522 AVFilterPad *srcpad;
00523
00524 AVFilterContext *dst;
00525 AVFilterPad *dstpad;
00526
00527 enum AVMediaType type;
00528
00529
00530 int w;
00531 int h;
00532 AVRational sample_aspect_ratio;
00533
00534 uint64_t channel_layout;
00535 int sample_rate;
00536
00537 int format;
00538
00546 AVRational time_base;
00547
00548
00549
00550
00551
00552
00553
00554
00562 AVFilterFormats *in_formats;
00563 AVFilterFormats *out_formats;
00564
00569 AVFilterFormats *in_samplerates;
00570 AVFilterFormats *out_samplerates;
00571 struct AVFilterChannelLayouts *in_channel_layouts;
00572 struct AVFilterChannelLayouts *out_channel_layouts;
00573
00581 int request_samples;
00582
00584 enum {
00585 AVLINK_UNINIT = 0,
00586 AVLINK_STARTINIT,
00587 AVLINK_INIT
00588 } init_state;
00589
00597 AVFilterBufferRef *src_buf;
00598
00613 AVFilterBufferRef *cur_buf;
00614
00633 AVFilterBufferRef *out_buf;
00634
00635 struct AVFilterPool *pool;
00636
00640 struct AVFilterGraph *graph;
00641
00646 int64_t current_pts;
00647
00651 int age_index;
00652
00663 AVRational frame_rate;
00664
00668 AVFilterBufferRef *partial_buf;
00669
00674 int partial_buf_size;
00675
00683 int min_samples;
00684
00689 int max_samples;
00690
00698 AVFilterBufferRef *cur_buf_copy;
00699
00710 int closed;
00711 };
00712
00722 int avfilter_link(AVFilterContext *src, unsigned srcpad,
00723 AVFilterContext *dst, unsigned dstpad);
00724
00728 void avfilter_link_free(AVFilterLink **link);
00729
00733 void avfilter_link_set_closed(AVFilterLink *link, int closed);
00734
00741 int avfilter_config_links(AVFilterContext *filter);
00742
00754 AVFilterBufferRef *
00755 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
00756 int w, int h, enum PixelFormat format);
00757
00769 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
00770 int linesize,
00771 int perms,
00772 int nb_samples,
00773 enum AVSampleFormat sample_fmt,
00774 uint64_t channel_layout);
00775
00776
00777 #define AVFILTER_CMD_FLAG_ONE 1
00778 #define AVFILTER_CMD_FLAG_FAST 2
00779
00780
00784 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
00785
00787 void avfilter_register_all(void);
00788
00790 void avfilter_uninit(void);
00791
00802 int avfilter_register(AVFilter *filter);
00803
00811 AVFilter *avfilter_get_by_name(const char *name);
00812
00819 AVFilter **av_filter_next(AVFilter **filter);
00820
00830 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
00831
00842 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
00843
00849 void avfilter_free(AVFilterContext *filter);
00850
00860 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
00861 unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
00862
00863 #endif