Libav
avfilter.h
Go to the documentation of this file.
1 /*
2  * filter layer
3  * Copyright (c) 2007 Bobby Bingham
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFILTER_AVFILTER_H
23 #define AVFILTER_AVFILTER_H
24 
36 #include "libavutil/attributes.h"
37 #include "libavutil/avutil.h"
38 #include "libavutil/frame.h"
39 #include "libavutil/log.h"
40 #include "libavutil/samplefmt.h"
41 #include "libavutil/pixfmt.h"
42 #include "libavutil/rational.h"
43 #include "libavcodec/avcodec.h"
44 
45 #include <stddef.h>
46 
47 #include "libavfilter/version.h"
48 
52 unsigned avfilter_version(void);
53 
57 const char *avfilter_configuration(void);
58 
62 const char *avfilter_license(void);
63 
64 
65 typedef struct AVFilterContext AVFilterContext;
66 typedef struct AVFilterLink AVFilterLink;
67 typedef struct AVFilterPad AVFilterPad;
68 typedef struct AVFilterFormats AVFilterFormats;
69 
70 #if FF_API_AVFILTERBUFFER
71 
76 typedef struct AVFilterBuffer {
77  uint8_t *data[8];
78 
93  uint8_t **extended_data;
94  int linesize[8];
95 
97  void *priv;
104  void (*free)(struct AVFilterBuffer *buf);
105 
106  int format;
107  int w, h;
108  unsigned refcount;
109 } AVFilterBuffer;
110 
111 #define AV_PERM_READ 0x01
112 #define AV_PERM_WRITE 0x02
113 #define AV_PERM_PRESERVE 0x04
114 #define AV_PERM_REUSE 0x08
115 #define AV_PERM_REUSE2 0x10
116 #define AV_PERM_NEG_LINESIZES 0x20
117 
118 
123 typedef struct AVFilterBufferRefAudioProps {
124  uint64_t channel_layout;
125  int nb_samples;
126  int sample_rate;
127  int planar;
128 } AVFilterBufferRefAudioProps;
129 
135 typedef struct AVFilterBufferRefVideoProps {
136  int w;
137  int h;
139  int interlaced;
140  int top_field_first;
141  enum AVPictureType pict_type;
142  int key_frame;
143 } AVFilterBufferRefVideoProps;
144 
153 typedef struct AVFilterBufferRef {
154  AVFilterBuffer *buf;
155  uint8_t *data[8];
156 
170  uint8_t **extended_data;
171  int linesize[8];
172 
173  AVFilterBufferRefVideoProps *video;
174  AVFilterBufferRefAudioProps *audio;
175 
181  int64_t pts;
182  int64_t pos;
183 
184  int format;
185 
186  int perms;
187 
188  enum AVMediaType type;
189 } AVFilterBufferRef;
190 
195 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
196 
207 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
208 
219 void avfilter_unref_buffer(AVFilterBufferRef *ref);
220 
229 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
230 #endif
231 
232 #if FF_API_AVFILTERPAD_PUBLIC
233 
241 struct AVFilterPad {
247  const char *name;
248 
252  enum AVMediaType type;
253 
261  attribute_deprecated int min_perms;
262 
272  attribute_deprecated int rej_perms;
273 
277  int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
278 
285  AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h);
286 
293  AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples);
294 
298  int (*end_frame)(AVFilterLink *link);
299 
303  int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
304 
315  int (*filter_frame)(AVFilterLink *link, AVFrame *frame);
316 
326  int (*poll_frame)(AVFilterLink *link);
327 
335  int (*request_frame)(AVFilterLink *link);
336 
351  int (*config_props)(AVFilterLink *link);
352 
359  int needs_fifo;
360 
367  int needs_writable;
368 };
369 #endif
370 
375 int avfilter_pad_count(const AVFilterPad *pads);
376 
386 const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
387 
397 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
398 
404 #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
405 
410 #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
411 
415 #define AVFILTER_FLAG_SLICE_THREADS (1 << 2)
416 
421 typedef struct AVFilter {
425  const char *name;
426 
432  const char *description;
433 
450 
460 
464  int flags;
465 
466  /*****************************************************************
467  * All fields below this line are not part of the public API. They
468  * may not be used outside of libavfilter and can be changed and
469  * removed at will.
470  * New public fields should be added right above.
471  *****************************************************************
472  */
473 
495  int (*init)(AVFilterContext *ctx);
496 
509 
521 
545 
546  int priv_size;
547 
552  struct AVFilter *next;
553 } AVFilter;
554 
558 #define AVFILTER_THREAD_SLICE (1 << 0)
559 
560 typedef struct AVFilterInternal AVFilterInternal;
561 
564  const AVClass *av_class;
565 
566  const AVFilter *filter;
567 
568  char *name;
569 
572 #if FF_API_FOO_COUNT
573  attribute_deprecated unsigned input_count;
574 #endif
575  unsigned nb_inputs;
576 
579 #if FF_API_FOO_COUNT
580  attribute_deprecated unsigned output_count;
581 #endif
582  unsigned nb_outputs;
583 
584  void *priv;
585 
587 
605 
609  AVFilterInternal *internal;
610 };
611 
619 struct AVFilterLink {
622 
625 
627 
628  /* These parameters apply only to video */
629  int w;
630  int h;
632  /* These two parameters apply only to audio */
633  uint64_t channel_layout;
635 
636  int format;
637 
646 
647  /*****************************************************************
648  * All fields below this line are not part of the public API. They
649  * may not be used outside of libavfilter and can be changed and
650  * removed at will.
651  * New public fields should be added right above.
652  *****************************************************************
653  */
661 
670 
679 
681  enum {
685  } init_state;
686 };
687 
697 int avfilter_link(AVFilterContext *src, unsigned srcpad,
698  AVFilterContext *dst, unsigned dstpad);
699 
707 
708 #if FF_API_AVFILTERBUFFER
709 
721 AVFilterBufferRef *
722 avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
723  int w, int h, enum AVPixelFormat format);
724 
737 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
738  int linesize,
739  int perms,
740  int nb_samples,
742  uint64_t channel_layout);
743 #endif
744 
746 void avfilter_register_all(void);
747 
748 #if FF_API_OLD_FILTER_REGISTER
749 
751 void avfilter_uninit(void);
752 #endif
753 
765 
773 #if !FF_API_NOCONST_GET_NAME
774 const
775 #endif
776 AVFilter *avfilter_get_by_name(const char *name);
777 
783 const AVFilter *avfilter_next(const AVFilter *prev);
784 
785 #if FF_API_OLD_FILTER_REGISTER
786 
794 AVFilter **av_filter_next(AVFilter **filter);
795 #endif
796 
797 #if FF_API_AVFILTER_OPEN
798 
809 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
810 #endif
811 
812 
813 #if FF_API_AVFILTER_INIT_FILTER
814 
825 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
826 #endif
827 
838 int avfilter_init_str(AVFilterContext *ctx, const char *args);
839 
861 
869 
880  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
881 
882 #if FF_API_AVFILTERBUFFER
883 
890 int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
891 
899 int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
900 #endif
901 
907 const AVClass *avfilter_get_class(void);
908 
910 
923 typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
924 
938  void *arg, int *ret, int nb_jobs);
939 
940 typedef struct AVFilterGraph {
942 #if FF_API_FOO_COUNT
944  unsigned filter_count;
945 #endif
947 #if !FF_API_FOO_COUNT
948  unsigned nb_filters;
949 #endif
950 
953 #if FF_API_FOO_COUNT
954  unsigned nb_filters;
955 #endif
956 
970 
977 
982 
988  void *opaque;
989 
1003 } AVFilterGraph;
1004 
1009 
1025  const AVFilter *filter,
1026  const char *name);
1027 
1035 
1036 #if FF_API_AVFILTER_OPEN
1037 
1047 int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
1048 #endif
1049 
1063 int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt,
1064  const char *name, const char *args, void *opaque,
1065  AVFilterGraph *graph_ctx);
1066 
1074 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
1075 
1080 void avfilter_graph_free(AVFilterGraph **graph);
1081 
1091 typedef struct AVFilterInOut {
1093  char *name;
1094 
1097 
1099  int pad_idx;
1100 
1103 } AVFilterInOut;
1104 
1111 
1116 void avfilter_inout_free(AVFilterInOut **inout);
1117 
1127 int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
1129  void *log_ctx);
1130 
1161 int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
1164 
1169 #endif /* AVFILTER_AVFILTER_H */