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/buffer.h"
39 #include "libavutil/frame.h"
40 #include "libavutil/log.h"
41 #include "libavutil/samplefmt.h"
42 #include "libavutil/pixfmt.h"
43 #include "libavutil/rational.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 
74 int avfilter_pad_count(const AVFilterPad *pads);
75 
85 const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
86 
96 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
97 
103 #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
104 
109 #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
110 
114 #define AVFILTER_FLAG_SLICE_THREADS (1 << 2)
115 
120 typedef struct AVFilter {
124  const char *name;
125 
131  const char *description;
132 
149 
159 
163  int flags;
164 
165  /*****************************************************************
166  * All fields below this line are not part of the public API. They
167  * may not be used outside of libavfilter and can be changed and
168  * removed at will.
169  * New public fields should be added right above.
170  *****************************************************************
171  */
172 
195 
208 
220 
244 
245  int priv_size;
246 
251  struct AVFilter *next;
252 } AVFilter;
253 
257 #define AVFILTER_THREAD_SLICE (1 << 0)
258 
259 typedef struct AVFilterInternal AVFilterInternal;
260 
263  const AVClass *av_class;
264 
265  const AVFilter *filter;
266 
267  char *name;
268 
271  unsigned nb_inputs;
272 
275  unsigned nb_outputs;
276 
277  void *priv;
278 
280 
298 
302  AVFilterInternal *internal;
303 
312 };
313 
321 struct AVFilterLink {
324 
327 
328  enum AVMediaType type;
329 
330  /* These parameters apply only to video */
331  int w;
332  int h;
334  /* These two parameters apply only to audio */
335  uint64_t channel_layout;
337 
338  int format;
339 
348 
349  /*****************************************************************
350  * All fields below this line are not part of the public API. They
351  * may not be used outside of libavfilter and can be changed and
352  * removed at will.
353  * New public fields should be added right above.
354  *****************************************************************
355  */
363 
372 
381 
383  enum {
384  AVLINK_UNINIT = 0,
386  AVLINK_INIT
387  } init_state;
388 
400 
406 };
407 
417 int avfilter_link(AVFilterContext *src, unsigned srcpad,
418  AVFilterContext *dst, unsigned dstpad);
419 
427 
429 void avfilter_register_all(void);
430 
431 #if FF_API_OLD_FILTER_REGISTER
432 
434 void avfilter_uninit(void);
435 #endif
436 
448 
456 #if !FF_API_NOCONST_GET_NAME
457 const
458 #endif
459 AVFilter *avfilter_get_by_name(const char *name);
460 
466 const AVFilter *avfilter_next(const AVFilter *prev);
467 
468 #if FF_API_OLD_FILTER_REGISTER
469 
478 #endif
479 
480 #if FF_API_AVFILTER_OPEN
481 
492 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
493 #endif
494 
495 
496 #if FF_API_AVFILTER_INIT_FILTER
497 
508 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
509 #endif
510 
521 int avfilter_init_str(AVFilterContext *ctx, const char *args);
522 
544 
552 
563  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
564 
570 const AVClass *avfilter_get_class(void);
571 
573 
586 typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
587 
601  void *arg, int *ret, int nb_jobs);
602 
603 typedef struct AVFilterGraph {
606  unsigned nb_filters;
607 
610 
624 
631 
636 
642  void *opaque;
643 
657 } AVFilterGraph;
658 
665 
681  const AVFilter *filter,
682  const char *name);
683 
691 
692 #if FF_API_AVFILTER_OPEN
693 
704 #endif
705 
719 int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt,
720  const char *name, const char *args, void *opaque,
721  AVFilterGraph *graph_ctx);
722 
730 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
731 
736 void avfilter_graph_free(AVFilterGraph **graph);
737 
747 typedef struct AVFilterInOut {
749  char *name;
750 
753 
755  int pad_idx;
756 
759 } AVFilterInOut;
760 
767 
772 void avfilter_inout_free(AVFilterInOut **inout);
773 
783 int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
785  void *log_ctx);
786 
817 int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
820 
825 #endif /* AVFILTER_AVFILTER_H */
AVFilterContext ** filters
Definition: avfilter.h:605
int thread_type
Type of multithreading allowed for filters in this graph.
Definition: avfilter.h:623
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:508
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:71
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
Definition: graphparser.c:214
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:758
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:737
Libavfilter version macros.
int() avfilter_execute_func(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
A function executing multiple jobs, possibly in parallel.
Definition: avfilter.h:600
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in...
Definition: avfilter.h:311
external API header
int thread_type
Type of multithreading being allowed/used.
Definition: avfilter.h:297
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
Definition: avfilter.h:219
Macro definitions for various function/variable attributes.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:608
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:279
int(* init_dict)(AVFilterContext *ctx, AVDictionary **options)
Should be set instead of init by the filters that want to pass a dictionary of AVOptions to nested co...
Definition: avfilter.h:207
int priv_size
size of private data to allocate for the filter
Definition: avfilter.h:245
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:270
char * name
name of this filter instance
Definition: avfilter.h:267
avfilter_execute_func * execute
This callback may be set by the caller immediately after allocating the graph and before adding any f...
Definition: avfilter.h:656
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:77
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:273
const char * avfilter_license(void)
Return the libavfilter license.
Definition: avfilter.c:50
int flags
A combination of AVFILTER_FLAG_*.
Definition: avfilter.h:163
void avfilter_register_all(void)
Initialize the filter system.
Definition: allfilters.c:39
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
char * resample_lavr_opts
libavresample options to use for the auto-inserted resample filters
Definition: avfilter.h:609
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:630
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition: avfilter.c:147
const AVFilter * avfilter_next(const AVFilter *prev)
Iterate over all registered filters.
Definition: avfilter.c:323
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
Definition: graphparser.c:418
const OptionDef options[]
Definition: avconv_opt.c:2447
A filter pad used for either input or output.
Definition: internal.h:35
#define src
Definition: vp8dsp.c:254
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:269
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
Definition: avfilter.c:574
const AVClass * av_class
Definition: avfilter.h:604
unsigned nb_outputs
number of output pads
Definition: avfilter.h:275
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
Definition: avfilter.c:40
void * priv
private data for use by the filter
Definition: avfilter.h:277
void avfilter_uninit(void)
Definition: avfilter.c:334
reference-counted frame API
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: avfilter.c:299
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
Definition: mpegaudioenc.c:307
unsigned nb_inputs
number of input pads
Definition: avfilter.h:271
int() avfilter_action_func(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
A function pointer passed to the AVFilterGraph::execute callback to be executed multiple times...
Definition: avfilter.h:586
AVFormatContext * ctx
Definition: movenc.c:48
int(* init)(AVFilterContext *ctx)
Filter initialization function.
Definition: avfilter.h:194
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
Definition: avfilter.c:480
AVFilter ** av_filter_next(AVFilter **filter)
Definition: avfilter.c:329
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:752
int avfilter_init_str(AVFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:615
const AVFilterPad * inputs
List of inputs, terminated by a zeroed element.
Definition: avfilter.h:140
const AVClass * avfilter_get_class(void)
Definition: avfilter.c:812
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:747
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
Insert a filter in the middle of an existing link.
Definition: avfilter.c:110
const AVClass * priv_class
A class for the private data, used to declare filter private AVOptions.
Definition: avfilter.h:158
void(* func)(void)
Definition: checkasm.c:65
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx)
Add a graph described by a string to a graph.
Definition: graphparser.c:486
Describe the class of an AVClass context structure.
Definition: log.h:34
Filter definition.
Definition: avfilter.h:120
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:755
rational number numerator/denominator
Definition: rational.h:43
int(* query_formats)(AVFilterContext *)
Query formats supported by the filter on its inputs and outputs.
Definition: avfilter.h:243
struct AVFilter * next
Used by the filter registration system.
Definition: avfilter.h:251
AVMediaType
Definition: avutil.h:192
refcounted data buffer API
const char * name
Filter name.
Definition: avfilter.h:124
unsigned nb_filters
Definition: avfilter.h:606
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
Definition: avfilter.c:45
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:732
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:274
char * name
unique name for this input/output in the list
Definition: avfilter.h:749
#define attribute_deprecated
Definition: attributes.h:80
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
Definition: avfilter.c:580
A reference to a data buffer.
Definition: buffer.h:81
void * opaque
Opaque user data.
Definition: avfilter.h:642
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
Definition: graphparser.c:209
rational numbers
pixel format definitions
const char * description
A description of the filter.
Definition: avfilter.h:131
int avfilter_register(AVFilter *filter)
Register a filter.
Definition: avfilter.c:313
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
const AVClass * av_class
needed for av_log()
Definition: avfilter.h:263
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:262
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
Definition: avfilter.c:339
const AVFilterPad * outputs
List of outputs, terminated by a zeroed element.
Definition: avfilter.h:148
AVFilterContext * avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
Get a filter instance with name name from graph.
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:265