FFmpeg
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 FFmpeg.
6  *
7  * FFmpeg 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  * FFmpeg 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 FFmpeg; 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 
25 /**
26  * @file
27  * @ingroup lavfi
28  * Main libavfilter public API header
29  */
30 
31 /**
32  * @defgroup lavfi libavfilter
33  * Graph-based frame editing library.
34  *
35  * @{
36  */
37 
38 #include <stddef.h>
39 
40 #include "libavutil/avutil.h"
41 #include "libavutil/buffer.h"
42 #include "libavutil/dict.h"
43 #include "libavutil/frame.h"
44 #include "libavutil/log.h"
45 #include "libavutil/pixfmt.h"
46 #include "libavutil/rational.h"
47 
49 #ifndef HAVE_AV_CONFIG_H
50 /* When included as part of the ffmpeg build, only include the major version
51  * to avoid unnecessary rebuilds. When included externally, keep including
52  * the full version information. */
53 #include "libavfilter/version.h"
54 #endif
55 
56 /**
57  * Return the LIBAVFILTER_VERSION_INT constant.
58  */
59 unsigned avfilter_version(void);
60 
61 /**
62  * Return the libavfilter build-time configuration.
63  */
64 const char *avfilter_configuration(void);
65 
66 /**
67  * Return the libavfilter license.
68  */
69 const char *avfilter_license(void);
70 
71 typedef struct AVFilterLink AVFilterLink;
72 typedef struct AVFilterPad AVFilterPad;
73 typedef struct AVFilterFormats AVFilterFormats;
75 
76 /**
77  * Get the name of an AVFilterPad.
78  *
79  * @param pads an array of AVFilterPads
80  * @param pad_idx index of the pad in the array; it is the caller's
81  * responsibility to ensure the index is valid
82  *
83  * @return name of the pad_idx'th pad in pads
84  */
85 const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
86 
87 /**
88  * Get the type of an AVFilterPad.
89  *
90  * @param pads an array of AVFilterPads
91  * @param pad_idx index of the pad in the array; it is the caller's
92  * responsibility to ensure the index is valid
93  *
94  * @return type of the pad_idx'th pad in pads
95  */
96 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
97 
98 /**
99  * Get the hardware frames context of a filter link.
100  *
101  * @param link an AVFilterLink
102  *
103  * @return a ref-counted copy of the link's hw_frames_ctx field if there is
104  * a hardware frames context associated with the link or NULL otherwise.
105  * The returned AVBufferRef needs to be released with av_buffer_unref()
106  * when it is no longer used.
107  */
109 
110 /**
111  * Lists of formats / etc. supported by an end of a link.
112  *
113  * This structure is directly part of AVFilterLink, in two copies:
114  * one for the source filter, one for the destination filter.
115 
116  * These lists are used for negotiating the format to actually be used,
117  * which will be loaded into the format and channel_layout members of
118  * AVFilterLink, when chosen.
119  */
120 typedef struct AVFilterFormatsConfig {
121 
122  /**
123  * List of supported formats (pixel or sample).
124  */
126 
127  /**
128  * Lists of supported sample rates, only for audio.
129  */
131 
132  /**
133  * Lists of supported channel layouts, only for audio.
134  */
136 
137  /**
138  * Lists of supported YUV color metadata, only for YUV video.
139  */
140  AVFilterFormats *color_spaces; ///< AVColorSpace
141  AVFilterFormats *color_ranges; ///< AVColorRange
142 
143  /**
144  * List of supported alpha modes, only for video with an alpha channel.
145  */
146  AVFilterFormats *alpha_modes; ///< AVAlphaMode
147 
149 
150 /**
151  * The number of the filter inputs is not determined just by AVFilter.inputs.
152  * The filter might add additional inputs during initialization depending on the
153  * options supplied to it.
154  */
155 #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
156 /**
157  * The number of the filter outputs is not determined just by AVFilter.outputs.
158  * The filter might add additional outputs during initialization depending on
159  * the options supplied to it.
160  */
161 #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
162 /**
163  * The filter supports multithreading by splitting frames into multiple parts
164  * and processing them concurrently.
165  */
166 #define AVFILTER_FLAG_SLICE_THREADS (1 << 2)
167 /**
168  * The filter is a "metadata" filter - it does not modify the frame data in any
169  * way. It may only affect the metadata (i.e. those fields copied by
170  * av_frame_copy_props()).
171  *
172  * More precisely, this means:
173  * - video: the data of any frame output by the filter must be exactly equal to
174  * some frame that is received on one of its inputs. Furthermore, all frames
175  * produced on a given output must correspond to frames received on the same
176  * input and their order must be unchanged. Note that the filter may still
177  * drop or duplicate the frames.
178  * - audio: the data produced by the filter on any of its outputs (viewed e.g.
179  * as an array of interleaved samples) must be exactly equal to the data
180  * received by the filter on one of its inputs.
181  */
182 #define AVFILTER_FLAG_METADATA_ONLY (1 << 3)
183 
184 /**
185  * The filter can create hardware frames using AVFilterContext.hw_device_ctx.
186  */
187 #define AVFILTER_FLAG_HWDEVICE (1 << 4)
188 /**
189  * Some filters support a generic "enable" expression option that can be used
190  * to enable or disable a filter in the timeline. Filters supporting this
191  * option have this flag set. When the enable expression is false, the default
192  * no-op filter_frame() function is called in place of the filter_frame()
193  * callback defined on each input pad, thus the frame is passed unchanged to
194  * the next filters.
195  */
196 #define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC (1 << 16)
197 /**
198  * Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will
199  * have its filter_frame() callback(s) called as usual even when the enable
200  * expression is false. The filter will disable filtering within the
201  * filter_frame() callback(s) itself, for example executing code depending on
202  * the AVFilterContext->is_disabled value.
203  */
204 #define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL (1 << 17)
205 /**
206  * Handy mask to test whether the filter supports or no the timeline feature
207  * (internally or generically).
208  */
209 #define AVFILTER_FLAG_SUPPORT_TIMELINE (AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL)
210 
211 /**
212  * Filter definition. This defines the pads a filter contains, and all the
213  * callback functions used to interact with the filter.
214  */
215 typedef struct AVFilter {
216  /**
217  * Filter name. Must be non-NULL and unique among filters.
218  */
219  const char *name;
220 
221  /**
222  * A description of the filter. May be NULL.
223  *
224  * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
225  */
226  const char *description;
227 
228  /**
229  * List of static inputs.
230  *
231  * NULL if there are no (static) inputs. Instances of filters with
232  * AVFILTER_FLAG_DYNAMIC_INPUTS set may have more inputs than present in
233  * this list.
234  */
236 
237  /**
238  * List of static outputs.
239  *
240  * NULL if there are no (static) outputs. Instances of filters with
241  * AVFILTER_FLAG_DYNAMIC_OUTPUTS set may have more outputs than present in
242  * this list.
243  */
245 
246  /**
247  * A class for the private data, used to declare filter private AVOptions.
248  * This field is NULL for filters that do not declare any options.
249  *
250  * If this field is non-NULL, the first member of the filter private data
251  * must be a pointer to AVClass, which will be set by libavfilter generic
252  * code to this class.
253  */
255 
256  /**
257  * A combination of AVFILTER_FLAG_*
258  */
259  int flags;
260 } AVFilter;
261 
262 /**
263  * Get the number of elements in an AVFilter's inputs or outputs array.
264  */
265 unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output);
266 
267 /**
268  * Process multiple parts of the frame concurrently.
269  */
270 #define AVFILTER_THREAD_SLICE (1 << 0)
271 
272 /** An instance of a filter */
273 typedef struct AVFilterContext {
274  const AVClass *av_class; ///< needed for av_log() and filters common options
275 
276  const AVFilter *filter; ///< the AVFilter of which this is an instance
277 
278  char *name; ///< name of this filter instance
279 
280  AVFilterPad *input_pads; ///< array of input pads
281  AVFilterLink **inputs; ///< array of pointers to input links
282  unsigned nb_inputs; ///< number of input pads
283 
284  AVFilterPad *output_pads; ///< array of output pads
285  AVFilterLink **outputs; ///< array of pointers to output links
286  unsigned nb_outputs; ///< number of output pads
287 
288  void *priv; ///< private data for use by the filter
289 
290  struct AVFilterGraph *graph; ///< filtergraph this filter belongs to
291 
292  /**
293  * Type of multithreading being allowed/used. A combination of
294  * AVFILTER_THREAD_* flags.
295  *
296  * May be set by the caller before initializing the filter to forbid some
297  * or all kinds of multithreading for this filter. The default is allowing
298  * everything.
299  *
300  * When the filter is initialized, this field is combined using bit AND with
301  * AVFilterGraph.thread_type to get the final mask used for determining
302  * allowed threading types. I.e. a threading type needs to be set in both
303  * to be allowed.
304  *
305  * After the filter is initialized, libavfilter sets this field to the
306  * threading type that is actually used (0 for no multithreading).
307  */
309 
310  /**
311  * Max number of threads allowed in this filter instance.
312  * If <= 0, its value is ignored.
313  * Overrides global number of threads set per filter graph.
314  */
316 
317  char *enable_str; ///< enable expression string
318  /**
319  * MUST NOT be accessed from outside avfilter.
320  *
321  * the enabled state from the last expression evaluation
322  */
324 
325  /**
326  * For filters which will create hardware frames, sets the device the
327  * filter should create them in. All other filters will ignore this field:
328  * in particular, a filter which consumes or processes hardware frames will
329  * instead use the hw_frames_ctx field in AVFilterLink to carry the
330  * hardware context information.
331  *
332  * May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE
333  * before initializing the filter with avfilter_init_str() or
334  * avfilter_init_dict().
335  */
337 
338  /**
339  * Sets the number of extra hardware frames which the filter will
340  * allocate on its output links for use in following filters or by
341  * the caller.
342  *
343  * Some hardware filters require all frames that they will use for
344  * output to be defined in advance before filtering starts. For such
345  * filters, any hardware frame pools used for output must therefore be
346  * of fixed size. The extra frames set here are on top of any number
347  * that the filter needs internally in order to operate normally.
348  *
349  * This field must be set before the graph containing this filter is
350  * configured.
351  */
354 
355 /**
356  * A link between two filters. This contains pointers to the source and
357  * destination filters between which this link exists, and the indexes of
358  * the pads involved. In addition, this link also contains the parameters
359  * which have been negotiated and agreed upon between the filter, such as
360  * image dimensions, format, etc.
361  *
362  * Applications must not normally access the link structure directly.
363  * Use the buffersrc and buffersink API instead.
364  * In the future, access to the header may be reserved for filters
365  * implementation.
366  */
367 struct AVFilterLink {
368  AVFilterContext *src; ///< source filter
369  AVFilterPad *srcpad; ///< output pad on the source filter
370 
371  AVFilterContext *dst; ///< dest filter
372  AVFilterPad *dstpad; ///< input pad on the dest filter
373 
374  enum AVMediaType type; ///< filter media type
375 
376  int format; ///< agreed upon media format
377 
378  /* These parameters apply only to video */
379  int w; ///< agreed upon image width
380  int h; ///< agreed upon image height
381  AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
382  /**
383  * For non-YUV links, these are respectively set to fallback values (as
384  * appropriate for that colorspace).
385  *
386  * Note: This includes grayscale formats, as these are currently treated
387  * as forced full range always.
388  */
389  enum AVColorSpace colorspace; ///< agreed upon YUV color space
390  enum AVColorRange color_range; ///< agreed upon YUV color range
391 
392  /* These parameters apply only to audio */
393  int sample_rate; ///< samples per second
394  AVChannelLayout ch_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
395 
396  /**
397  * Define the time base used by the PTS of the frames/samples
398  * which will pass through this link.
399  * During the configuration stage, each filter is supposed to
400  * change only the output timebase, while the timebase of the
401  * input link is assumed to be an unchangeable property.
402  */
404 
407 
408  enum AVAlphaMode alpha_mode; ///< alpha mode (for videos with an alpha channel)
409 
410  /*****************************************************************
411  * All fields below this line are not part of the public API. They
412  * may not be used outside of libavfilter and can be changed and
413  * removed at will.
414  * New public fields should be added right above.
415  *****************************************************************
416  */
417 
418  /**
419  * Lists of supported formats / etc. supported by the input filter.
420  */
422 
423  /**
424  * Lists of supported formats / etc. supported by the output filter.
425  */
427 };
428 
429 /**
430  * Link two filters together.
431  *
432  * @param src the source filter
433  * @param srcpad index of the output pad on the source filter
434  * @param dst the destination filter
435  * @param dstpad index of the input pad on the destination filter
436  * @return zero on success
437  */
438 int avfilter_link(AVFilterContext *src, unsigned srcpad,
439  AVFilterContext *dst, unsigned dstpad);
440 
441 #define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
442 #define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
443 
444 /**
445  * Make the filter instance process a command.
446  * It is recommended to use avfilter_graph_send_command().
447  */
448 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
449 
450 /**
451  * Iterate over all registered filters.
452  *
453  * @param opaque a pointer where libavfilter will store the iteration state. Must
454  * point to NULL to start the iteration.
455  *
456  * @return the next registered filter or NULL when the iteration is
457  * finished
458  */
459 const AVFilter *av_filter_iterate(void **opaque);
460 
461 /**
462  * Get a filter definition matching the given name.
463  *
464  * @param name the filter name to find
465  * @return the filter definition, if any matching one is registered.
466  * NULL if none found.
467  */
468 const AVFilter *avfilter_get_by_name(const char *name);
469 
470 
471 /**
472  * Initialize a filter with the supplied parameters.
473  *
474  * @param ctx uninitialized filter context to initialize
475  * @param args Options to initialize the filter with. This must be a
476  * ':'-separated list of options in the 'key=value' form.
477  * May be NULL if the options have been set directly using the
478  * AVOptions API or there are no options that need to be set.
479  * @return 0 on success, a negative AVERROR on failure
480  */
481 int avfilter_init_str(AVFilterContext *ctx, const char *args);
482 
483 /**
484  * Initialize a filter with the supplied dictionary of options.
485  *
486  * @param ctx uninitialized filter context to initialize
487  * @param options An AVDictionary filled with options for this filter. On
488  * return this parameter will be destroyed and replaced with
489  * a dict containing options that were not found. This dictionary
490  * must be freed by the caller.
491  * May be NULL, then this function is equivalent to
492  * avfilter_init_str() with the second parameter set to NULL.
493  * @return 0 on success, a negative AVERROR on failure
494  *
495  * @note This function and avfilter_init_str() do essentially the same thing,
496  * the difference is in manner in which the options are passed. It is up to the
497  * calling code to choose whichever is more preferable. The two functions also
498  * behave differently when some of the provided options are not declared as
499  * supported by the filter. In such a case, avfilter_init_str() will fail, but
500  * this function will leave those extra options in the options AVDictionary and
501  * continue as usual.
502  */
504 
505 /**
506  * Free a filter context. This will also remove the filter from its
507  * filtergraph's list of filters.
508  *
509  * @param filter the filter to free
510  */
512 
513 /**
514  * Insert a filter in the middle of an existing link.
515  *
516  * @param link the link into which the filter should be inserted
517  * @param filt the filter to be inserted
518  * @param filt_srcpad_idx the input pad on the filter to connect
519  * @param filt_dstpad_idx the output pad on the filter to connect
520  * @return zero on success
521  */
523  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
524 
525 /**
526  * @return AVClass for AVFilterContext.
527  *
528  * @see av_opt_find().
529  */
530 const AVClass *avfilter_get_class(void);
531 
532 /**
533  * A function pointer passed to the @ref AVFilterGraph.execute callback to be
534  * executed multiple times, possibly in parallel.
535  *
536  * @param ctx the filter context the job belongs to
537  * @param arg an opaque parameter passed through from @ref
538  * AVFilterGraph.execute
539  * @param jobnr the index of the job being executed
540  * @param nb_jobs the total number of jobs
541  *
542  * @return 0 on success, a negative AVERROR on error
543  */
544 typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
545 
546 /**
547  * A function executing multiple jobs, possibly in parallel.
548  *
549  * @param ctx the filter context to which the jobs belong
550  * @param func the function to be called multiple times
551  * @param arg the argument to be passed to func
552  * @param ret a nb_jobs-sized array to be filled with return values from each
553  * invocation of func
554  * @param nb_jobs the number of jobs to execute
555  *
556  * @return 0 on success, a negative AVERROR on error
557  */
559  void *arg, int *ret, int nb_jobs);
560 
561 typedef struct AVFilterGraph {
564  unsigned nb_filters;
565 
566  char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
567 
568  /**
569  * Type of multithreading allowed for filters in this graph. A combination
570  * of AVFILTER_THREAD_* flags.
571  *
572  * May be set by the caller at any point, the setting will apply to all
573  * filters initialized after that. The default is allowing everything.
574  *
575  * When a filter in this graph is initialized, this field is combined using
576  * bit AND with AVFilterContext.thread_type to get the final mask used for
577  * determining allowed threading types. I.e. a threading type needs to be
578  * set in both to be allowed.
579  */
581 
582  /**
583  * Maximum number of threads used by filters in this graph. May be set by
584  * the caller before adding any filters to the filtergraph. Zero (the
585  * default) means that the number of threads is determined automatically.
586  */
588 
589  /**
590  * Opaque user data. May be set by the caller to an arbitrary value, e.g. to
591  * be used from callbacks like @ref AVFilterGraph.execute.
592  * Libavfilter will not touch this field in any way.
593  */
594  void *opaque;
595 
596  /**
597  * This callback may be set by the caller immediately after allocating the
598  * graph and before adding any filters to it, to provide a custom
599  * multithreading implementation.
600  *
601  * If set, filters with slice threading capability will call this callback
602  * to execute multiple jobs in parallel.
603  *
604  * If this field is left unset, libavfilter will use its internal
605  * implementation, which may or may not be multithreaded depending on the
606  * platform and build options.
607  */
609 
610  char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
611 
612  /**
613  * Sets the maximum number of buffered frames in the filtergraph combined.
614  *
615  * Zero means no limit. This field must be set before calling
616  * avfilter_graph_config().
617  */
619 } AVFilterGraph;
620 
621 /**
622  * Allocate a filter graph.
623  *
624  * @return the allocated filter graph on success or NULL.
625  */
627 
628 /**
629  * Create a new filter instance in a filter graph.
630  *
631  * @param graph graph in which the new filter will be used
632  * @param filter the filter to create an instance of
633  * @param name Name to give to the new instance (will be copied to
634  * AVFilterContext.name). This may be used by the caller to identify
635  * different filters, libavfilter itself assigns no semantics to
636  * this parameter. May be NULL.
637  *
638  * @return the context of the newly created filter instance (note that it is
639  * also retrievable directly through AVFilterGraph.filters or with
640  * avfilter_graph_get_filter()) on success or NULL on failure.
641  */
643  const AVFilter *filter,
644  const char *name);
645 
646 /**
647  * Get a filter instance identified by instance name from graph.
648  *
649  * @param graph filter graph to search through.
650  * @param name filter instance name (should be unique in the graph).
651  * @return the pointer to the found filter instance or NULL if it
652  * cannot be found.
653  */
655 
656 /**
657  * A convenience wrapper that allocates and initializes a filter in a single
658  * step. The filter instance is created from the filter filt and inited with the
659  * parameter args. opaque is currently ignored.
660  *
661  * In case of success put in *filt_ctx the pointer to the created
662  * filter instance, otherwise set *filt_ctx to NULL.
663  *
664  * @param name the instance name to give to the created filter instance
665  * @param graph_ctx the filter graph
666  * @return a negative AVERROR error code in case of failure, a non
667  * negative value otherwise
668  *
669  * @warning Since the filter is initialized after this function successfully
670  * returns, you MUST NOT set any further options on it. If you need to
671  * do that, call ::avfilter_graph_alloc_filter(), followed by setting
672  * the options, followed by ::avfilter_init_dict() instead of this
673  * function.
674  */
676  const char *name, const char *args, void *opaque,
677  AVFilterGraph *graph_ctx);
678 
679 /**
680  * Enable or disable automatic format conversion inside the graph.
681  *
682  * Note that format conversion can still happen inside explicitly inserted
683  * scale and aresample filters.
684  *
685  * @param flags any of the AVFILTER_AUTO_CONVERT_* constants
686  */
688 
689 enum {
690  AVFILTER_AUTO_CONVERT_ALL = 0, /**< all automatic conversions enabled */
691  AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */
692 };
693 
694 /**
695  * Check validity and configure all the links and formats in the graph.
696  *
697  * @param graphctx the filter graph
698  * @param log_ctx context used for logging
699  * @return >= 0 in case of success, a negative AVERROR code otherwise
700  */
701 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
702 
703 /**
704  * Free a graph, destroy its links, and set *graph to NULL.
705  * If *graph is NULL, do nothing.
706  */
707 void avfilter_graph_free(AVFilterGraph **graph);
708 
709 /**
710  * A linked-list of the inputs/outputs of the filter chain.
711  *
712  * This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(),
713  * where it is used to communicate open (unlinked) inputs and outputs from and
714  * to the caller.
715  * This struct specifies, per each not connected pad contained in the graph, the
716  * filter context and the pad index required for establishing a link.
717  */
718 typedef struct AVFilterInOut {
719  /** unique name for this input/output in the list */
720  char *name;
721 
722  /** filter context associated to this input/output */
724 
725  /** index of the filt_ctx pad to use for linking */
726  int pad_idx;
727 
728  /** next input/input in the list, NULL if this is the last */
730 } AVFilterInOut;
731 
732 /**
733  * Allocate a single AVFilterInOut entry.
734  * Must be freed with avfilter_inout_free().
735  * @return allocated AVFilterInOut on success, NULL on failure.
736  */
738 
739 /**
740  * Free the supplied list of AVFilterInOut and set *inout to NULL.
741  * If *inout is NULL, do nothing.
742  */
743 void avfilter_inout_free(AVFilterInOut **inout);
744 
745 /**
746  * Add a graph described by a string to a graph.
747  *
748  * @note The caller must provide the lists of inputs and outputs,
749  * which therefore must be known before calling the function.
750  *
751  * @note The inputs parameter describes inputs of the already existing
752  * part of the graph; i.e. from the point of view of the newly created
753  * part, they are outputs. Similarly the outputs parameter describes
754  * outputs of the already existing filters, which are provided as
755  * inputs to the parsed filters.
756  *
757  * @param graph the filter graph where to link the parsed graph context
758  * @param filters string to be parsed
759  * @param inputs linked list to the inputs of the graph
760  * @param outputs linked list to the outputs of the graph
761  * @return zero on success, a negative AVERROR code on error
762  */
763 int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
765  void *log_ctx);
766 
767 /**
768  * Add a graph described by a string to a graph.
769  *
770  * In the graph filters description, if the input label of the first
771  * filter is not specified, "in" is assumed; if the output label of
772  * the last filter is not specified, "out" is assumed.
773  *
774  * @param graph the filter graph where to link the parsed graph context
775  * @param filters string to be parsed
776  * @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
777  * If non-NULL, *inputs is updated to contain the list of open inputs
778  * after the parsing, should be freed with avfilter_inout_free().
779  * @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
780  * If non-NULL, *outputs is updated to contain the list of open outputs
781  * after the parsing, should be freed with avfilter_inout_free().
782  * @return non negative on success, a negative AVERROR code on error
783  */
784 int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters,
786  void *log_ctx);
787 
788 /**
789  * Add a graph described by a string to a graph.
790  *
791  * @param[in] graph the filter graph where to link the parsed graph context
792  * @param[in] filters string to be parsed
793  * @param[out] inputs a linked list of all free (unlinked) inputs of the
794  * parsed graph will be returned here. It is to be freed
795  * by the caller using avfilter_inout_free().
796  * @param[out] outputs a linked list of all free (unlinked) outputs of the
797  * parsed graph will be returned here. It is to be freed by the
798  * caller using avfilter_inout_free().
799  * @return zero on success, a negative AVERROR code on error
800  *
801  * @note This function returns the inputs and outputs that are left
802  * unlinked after parsing the graph and the caller then deals with
803  * them.
804  * @note This function makes no reference whatsoever to already
805  * existing parts of the graph and the inputs parameter will on return
806  * contain inputs of the newly parsed part of the graph. Analogously
807  * the outputs parameter will contain outputs of the newly created
808  * filters.
809  */
810 int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
813 
814 /**
815  * Parameters of a filter's input or output pad.
816  *
817  * Created as a child of AVFilterParams by avfilter_graph_segment_parse().
818  * Freed in avfilter_graph_segment_free().
819  */
820 typedef struct AVFilterPadParams {
821  /**
822  * An av_malloc()'ed string containing the pad label.
823  *
824  * May be av_free()'d and set to NULL by the caller, in which case this pad
825  * will be treated as unlabeled for linking.
826  * May also be replaced by another av_malloc()'ed string.
827  */
828  char *label;
830 
831 /**
832  * Parameters describing a filter to be created in a filtergraph.
833  *
834  * Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse().
835  * Freed in avfilter_graph_segment_free().
836  */
837 typedef struct AVFilterParams {
838  /**
839  * The filter context.
840  *
841  * Created by avfilter_graph_segment_create_filters() based on
842  * AVFilterParams.filter_name and instance_name.
843  *
844  * Callers may also create the filter context manually, then they should
845  * av_free() filter_name and set it to NULL. Such AVFilterParams instances
846  * are then skipped by avfilter_graph_segment_create_filters().
847  */
849 
850  /**
851  * Name of the AVFilter to be used.
852  *
853  * An av_malloc()'ed string, set by avfilter_graph_segment_parse(). Will be
854  * passed to avfilter_get_by_name() by
855  * avfilter_graph_segment_create_filters().
856  *
857  * Callers may av_free() this string and replace it with another one or
858  * NULL. If the caller creates the filter instance manually, this string
859  * MUST be set to NULL.
860  *
861  * When both AVFilterParams.filter an AVFilterParams.filter_name are NULL,
862  * this AVFilterParams instance is skipped by avfilter_graph_segment_*()
863  * functions.
864  */
865  char *filter_name;
866  /**
867  * Name to be used for this filter instance.
868  *
869  * An av_malloc()'ed string, may be set by avfilter_graph_segment_parse() or
870  * left NULL. The caller may av_free() this string and replace with another
871  * one or NULL.
872  *
873  * Will be used by avfilter_graph_segment_create_filters() - passed as the
874  * third argument to avfilter_graph_alloc_filter(), then freed and set to
875  * NULL.
876  */
878 
879  /**
880  * Options to be applied to the filter.
881  *
882  * Filled by avfilter_graph_segment_parse(). Afterwards may be freely
883  * modified by the caller.
884  *
885  * Will be applied to the filter by avfilter_graph_segment_apply_opts()
886  * with an equivalent of av_opt_set_dict2(filter, &opts, AV_OPT_SEARCH_CHILDREN),
887  * i.e. any unapplied options will be left in this dictionary.
888  */
890 
892  unsigned nb_inputs;
893 
895  unsigned nb_outputs;
897 
898 /**
899  * A filterchain is a list of filter specifications.
900  *
901  * Created as a child of AVFilterGraphSegment by avfilter_graph_segment_parse().
902  * Freed in avfilter_graph_segment_free().
903  */
904 typedef struct AVFilterChain {
906  size_t nb_filters;
907 } AVFilterChain;
908 
909 /**
910  * A parsed representation of a filtergraph segment.
911  *
912  * A filtergraph segment is conceptually a list of filterchains, with some
913  * supplementary information (e.g. format conversion flags).
914  *
915  * Created by avfilter_graph_segment_parse(). Must be freed with
916  * avfilter_graph_segment_free().
917  */
918 typedef struct AVFilterGraphSegment {
919  /**
920  * The filtergraph this segment is associated with.
921  * Set by avfilter_graph_segment_parse().
922  */
924 
925  /**
926  * A list of filter chain contained in this segment.
927  * Set in avfilter_graph_segment_parse().
928  */
930  size_t nb_chains;
931 
932  /**
933  * A string containing a colon-separated list of key=value options applied
934  * to all scale filters in this segment.
935  *
936  * May be set by avfilter_graph_segment_parse().
937  * The caller may free this string with av_free() and replace it with a
938  * different av_malloc()'ed string.
939  */
942 
943 /**
944  * Parse a textual filtergraph description into an intermediate form.
945  *
946  * This intermediate representation is intended to be modified by the caller as
947  * described in the documentation of AVFilterGraphSegment and its children, and
948  * then applied to the graph either manually or with other
949  * avfilter_graph_segment_*() functions. See the documentation for
950  * avfilter_graph_segment_apply() for the canonical way to apply
951  * AVFilterGraphSegment.
952  *
953  * @param graph Filter graph the parsed segment is associated with. Will only be
954  * used for logging and similar auxiliary purposes. The graph will
955  * not be actually modified by this function - the parsing results
956  * are instead stored in seg for further processing.
957  * @param graph_str a string describing the filtergraph segment
958  * @param flags reserved for future use, caller must set to 0 for now
959  * @param seg A pointer to the newly-created AVFilterGraphSegment is written
960  * here on success. The graph segment is owned by the caller and must
961  * be freed with avfilter_graph_segment_free() before graph itself is
962  * freed.
963  *
964  * @retval "non-negative number" success
965  * @retval "negative error code" failure
966  */
967 int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str,
968  int flags, AVFilterGraphSegment **seg);
969 
970 /**
971  * Create filters specified in a graph segment.
972  *
973  * Walk through the creation-pending AVFilterParams in the segment and create
974  * new filter instances for them.
975  * Creation-pending params are those where AVFilterParams.filter_name is
976  * non-NULL (and hence AVFilterParams.filter is NULL). All other AVFilterParams
977  * instances are ignored.
978  *
979  * For any filter created by this function, the corresponding
980  * AVFilterParams.filter is set to the newly-created filter context,
981  * AVFilterParams.filter_name and AVFilterParams.instance_name are freed and set
982  * to NULL.
983  *
984  * @param seg the filtergraph segment to process
985  * @param flags reserved for future use, caller must set to 0 for now
986  *
987  * @retval "non-negative number" Success, all creation-pending filters were
988  * successfully created
989  * @retval AVERROR_FILTER_NOT_FOUND some filter's name did not correspond to a
990  * known filter
991  * @retval "another negative error code" other failures
992  *
993  * @note Calling this function multiple times is safe, as it is idempotent.
994  */
996 
997 /**
998  * Apply parsed options to filter instances in a graph segment.
999  *
1000  * Walk through all filter instances in the graph segment that have option
1001  * dictionaries associated with them and apply those options with
1002  * av_opt_set_dict2(..., AV_OPT_SEARCH_CHILDREN). AVFilterParams.opts is
1003  * replaced by the dictionary output by av_opt_set_dict2(), which should be
1004  * empty (NULL) if all options were successfully applied.
1005  *
1006  * If any options could not be found, this function will continue processing all
1007  * other filters and finally return AVERROR_OPTION_NOT_FOUND (unless another
1008  * error happens). The calling program may then deal with unapplied options as
1009  * it wishes.
1010  *
1011  * Any creation-pending filters (see avfilter_graph_segment_create_filters())
1012  * present in the segment will cause this function to fail. AVFilterParams with
1013  * no associated filter context are simply skipped.
1014  *
1015  * @param seg the filtergraph segment to process
1016  * @param flags reserved for future use, caller must set to 0 for now
1017  *
1018  * @retval "non-negative number" Success, all options were successfully applied.
1019  * @retval AVERROR_OPTION_NOT_FOUND some options were not found in a filter
1020  * @retval "another negative error code" other failures
1021  *
1022  * @note Calling this function multiple times is safe, as it is idempotent.
1023  */
1025 
1026 /**
1027  * Initialize all filter instances in a graph segment.
1028  *
1029  * Walk through all filter instances in the graph segment and call
1030  * avfilter_init_dict(..., NULL) on those that have not been initialized yet.
1031  *
1032  * Any creation-pending filters (see avfilter_graph_segment_create_filters())
1033  * present in the segment will cause this function to fail. AVFilterParams with
1034  * no associated filter context or whose filter context is already initialized,
1035  * are simply skipped.
1036  *
1037  * @param seg the filtergraph segment to process
1038  * @param flags reserved for future use, caller must set to 0 for now
1039  *
1040  * @retval "non-negative number" Success, all filter instances were successfully
1041  * initialized
1042  * @retval "negative error code" failure
1043  *
1044  * @note Calling this function multiple times is safe, as it is idempotent.
1045  */
1047 
1048 /**
1049  * Link filters in a graph segment.
1050  *
1051  * Walk through all filter instances in the graph segment and try to link all
1052  * unlinked input and output pads. Any creation-pending filters (see
1053  * avfilter_graph_segment_create_filters()) present in the segment will cause
1054  * this function to fail. Disabled filters and already linked pads are skipped.
1055  *
1056  * Every filter output pad that has a corresponding AVFilterPadParams with a
1057  * non-NULL label is
1058  * - linked to the input with the matching label, if one exists;
1059  * - exported in the outputs linked list otherwise, with the label preserved.
1060  * Unlabeled outputs are
1061  * - linked to the first unlinked unlabeled input in the next non-disabled
1062  * filter in the chain, if one exists
1063  * - exported in the outputs linked list otherwise, with NULL label
1064  *
1065  * Similarly, unlinked input pads are exported in the inputs linked list.
1066  *
1067  * @param seg the filtergraph segment to process
1068  * @param flags reserved for future use, caller must set to 0 for now
1069  * @param[out] inputs a linked list of all free (unlinked) inputs of the
1070  * filters in this graph segment will be returned here. It
1071  * is to be freed by the caller using avfilter_inout_free().
1072  * @param[out] outputs a linked list of all free (unlinked) outputs of the
1073  * filters in this graph segment will be returned here. It
1074  * is to be freed by the caller using avfilter_inout_free().
1075  *
1076  * @retval "non-negative number" success
1077  * @retval "negative error code" failure
1078  *
1079  * @note Calling this function multiple times is safe, as it is idempotent.
1080  */
1084 
1085 /**
1086  * Apply all filter/link descriptions from a graph segment to the associated filtergraph.
1087  *
1088  * This functions is currently equivalent to calling the following in sequence:
1089  * - avfilter_graph_segment_create_filters();
1090  * - avfilter_graph_segment_apply_opts();
1091  * - avfilter_graph_segment_init();
1092  * - avfilter_graph_segment_link();
1093  * failing if any of them fails. This list may be extended in the future.
1094  *
1095  * Since the above functions are idempotent, the caller may call some of them
1096  * manually, then do some custom processing on the filtergraph, then call this
1097  * function to do the rest.
1098  *
1099  * @param seg the filtergraph segment to process
1100  * @param flags reserved for future use, caller must set to 0 for now
1101  * @param[out] inputs passed to avfilter_graph_segment_link()
1102  * @param[out] outputs passed to avfilter_graph_segment_link()
1103  *
1104  * @retval "non-negative number" success
1105  * @retval "negative error code" failure
1106  *
1107  * @note Calling this function multiple times is safe, as it is idempotent.
1108  */
1112 
1113 /**
1114  * Free the provided AVFilterGraphSegment and everything associated with it.
1115  *
1116  * @param seg double pointer to the AVFilterGraphSegment to be freed. NULL will
1117  * be written to this pointer on exit from this function.
1118  *
1119  * @note
1120  * The filter contexts (AVFilterParams.filter) are owned by AVFilterGraph rather
1121  * than AVFilterGraphSegment, so they are not freed.
1122  */
1124 
1125 /**
1126  * Send a command to one or more filter instances.
1127  *
1128  * @param graph the filter graph
1129  * @param target the filter(s) to which the command should be sent
1130  * "all" sends to all filters
1131  * otherwise it can be a filter or filter instance name
1132  * which will send the command to all matching filters.
1133  * @param cmd the command to send, for handling simplicity all commands must be alphanumeric only
1134  * @param arg the argument for the command
1135  * @param res a buffer with size res_size where the filter(s) can return a response.
1136  *
1137  * @returns >=0 on success otherwise an error code.
1138  * AVERROR(ENOSYS) on unsupported commands
1139  */
1140 int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags);
1141 
1142 /**
1143  * Queue a command for one or more filter instances.
1144  *
1145  * @param graph the filter graph
1146  * @param target the filter(s) to which the command should be sent
1147  * "all" sends to all filters
1148  * otherwise it can be a filter or filter instance name
1149  * which will send the command to all matching filters.
1150  * @param cmd the command to sent, for handling simplicity all commands must be alphanumeric only
1151  * @param arg the argument for the command
1152  * @param ts time at which the command should be sent to the filter
1153  *
1154  * @note As this executes commands after this function returns, no return code
1155  * from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported.
1156  */
1157 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts);
1158 
1159 
1160 /**
1161  * Dump a graph into a human-readable string representation.
1162  *
1163  * @param graph the graph to dump
1164  * @param options formatting options; currently ignored
1165  * @return a string, or NULL in case of memory allocation failure;
1166  * the string must be freed using av_free
1167  */
1168 char *avfilter_graph_dump(AVFilterGraph *graph, const char *options);
1169 
1170 /**
1171  * Request a frame on the oldest sink link.
1172  *
1173  * If the request returns AVERROR_EOF, try the next.
1174  *
1175  * Note that this function is not meant to be the sole scheduling mechanism
1176  * of a filtergraph, only a convenience function to help drain a filtergraph
1177  * in a balanced way under normal circumstances.
1178  *
1179  * Also note that AVERROR_EOF does not mean that frames did not arrive on
1180  * some of the sinks during the process.
1181  * When there are multiple sink links, in case the requested link
1182  * returns an EOF, this may cause a filter to flush pending frames
1183  * which are sent to another sink link, although unrequested.
1184  *
1185  * @return the return value of ff_request_frame(),
1186  * or AVERROR_EOF if all links returned AVERROR_EOF
1187  */
1189 
1190 /**
1191  * @}
1192  */
1193 
1194 #endif /* AVFILTER_AVFILTER_H */
flags
const SwsFlags flags[]
Definition: swscale.c:85
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:66
AVFilterGraph::execute
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:608
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AVFilterContext::nb_threads
int nb_threads
Max number of threads allowed in this filter instance.
Definition: avfilter.h:315
AVFilterFormatsConfig::samplerates
AVFilterFormats * samplerates
Lists of supported sample rates, only for audio.
Definition: avfilter.h:130
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
avfilter_filter_pad_count
unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
Get the number of elements in an AVFilter's inputs or outputs array.
Definition: avfilter.c:631
AVFilterGraph::nb_threads
int nb_threads
Maximum number of threads used by filters in this graph.
Definition: avfilter.h:587
avfilter_pad_get_name
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:988
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:135
AVFilterParams::instance_name
char * instance_name
Name to be used for this filter instance.
Definition: avfilter.h:877
avfilter_graph_segment_create_filters
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
Definition: graphparser.c:516
AVFilter::priv_class
const AVClass * priv_class
A class for the private data, used to declare filter private AVOptions.
Definition: avfilter.h:254
avfilter_action_func
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:544
rational.h
AVFilterContext::is_disabled
int is_disabled
MUST NOT be accessed from outside avfilter.
Definition: avfilter.h:323
AVFilterInOut::next
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:729
AVFilterContext::nb_outputs
unsigned nb_outputs
number of output pads
Definition: avfilter.h:286
AVFilterContext::av_class
const AVClass * av_class
needed for av_log() and filters common options
Definition: avfilter.h:274
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
AVFilterContext::hw_device_ctx
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
Definition: avfilter.h:336
AVDictionary
Definition: dict.c:32
AVFilterContext::output_pads
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:284
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:219
AVFilterParams::inputs
AVFilterPadParams ** inputs
Definition: avfilter.h:891
avfilter_graph_free
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:119
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
AVFilterParams::outputs
AVFilterPadParams ** outputs
Definition: avfilter.h:894
AVFILTER_AUTO_CONVERT_ALL
@ AVFILTER_AUTO_CONVERT_ALL
all automatic conversions enabled
Definition: avfilter.h:690
avfilter_graph_create_filter
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
A convenience wrapper that allocates and initializes a filter in a single step.
Definition: avfiltergraph.c:140
avfilter_graph_alloc_filter
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
Definition: avfiltergraph.c:167
avfilter_graph_segment_link
int avfilter_graph_segment_link(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Link filters in a graph segment.
Definition: graphparser.c:814
AVFilterContext::priv
void * priv
private data for use by the filter
Definition: avfilter.h:288
AVFilterContext::graph
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:290
AVFilterContext::enable_str
char * enable_str
enable expression string
Definition: avfilter.h:317
avfilter_graph_alloc
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:85
avfilter_insert_filter
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:282
av_filter_iterate
const AVFilter * av_filter_iterate(void **opaque)
Iterate over all registered filters.
Definition: allfilters.c:639
AVFilterContext::extra_hw_frames
int extra_hw_frames
Sets the number of extra hardware frames which the filter will allocate on its output links for use i...
Definition: avfilter.h:352
avfilter_graph_segment_free
void avfilter_graph_segment_free(AVFilterGraphSegment **seg)
Free the provided AVFilterGraphSegment and everything associated with it.
Definition: graphparser.c:276
AVFilterGraph::opaque
void * opaque
Opaque user data.
Definition: avfilter.h:594
avfilter_graph_segment_parse
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, int flags, AVFilterGraphSegment **seg)
Parse a textual filtergraph description into an intermediate form.
Definition: graphparser.c:460
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
avfilter_license
const char * avfilter_license(void)
Return the libavfilter license.
Definition: version.c:41
AVFilterContext::input_pads
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:280
avfilter_inout_free
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
Definition: graphparser.c:76
AVFilterChain::filters
AVFilterParams ** filters
Definition: avfilter.h:905
avfilter_process_command
int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags)
Make the filter instance process a command.
Definition: avfilter.c:610
filters
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
Definition: af_crystalizer.c:55
avfilter_graph_segment_init
int avfilter_graph_segment_init(AVFilterGraphSegment *seg, int flags)
Initialize all filter instances in a graph segment.
Definition: graphparser.c:616
AVFilter::flags
int flags
A combination of AVFILTER_FLAG_*.
Definition: avfilter.h:259
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
AVFilterGraph::aresample_swr_opts
char * aresample_swr_opts
swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
Definition: avfilter.h:610
AVFilterFormatsConfig::color_spaces
AVFilterFormats * color_spaces
Lists of supported YUV color metadata, only for YUV video.
Definition: avfilter.h:140
AVFilterPadParams::label
char * label
An av_malloc()'ed string containing the pad label.
Definition: avfilter.h:828
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
arg
const char * arg
Definition: jacosubdec.c:65
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:652
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
AVFilterContext::thread_type
int thread_type
Type of multithreading being allowed/used.
Definition: avfilter.h:308
avfilter_graph_config
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
Definition: avfiltergraph.c:1434
avfilter_graph_segment_apply
int avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Apply all filter/link descriptions from a graph segment to the associated filtergraph.
Definition: graphparser.c:882
AVFilterParams
Parameters describing a filter to be created in a filtergraph.
Definition: avfilter.h:837
AVFilter::outputs
const AVFilterPad * outputs
List of static outputs.
Definition: avfilter.h:244
avfilter_graph_set_auto_convert
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
Definition: avfiltergraph.c:162
AVFilterParams::filter
AVFilterContext * filter
The filter context.
Definition: avfilter.h:848
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFilterChain::nb_filters
size_t nb_filters
Definition: avfilter.h:906
AVFilterParams::filter_name
char * filter_name
Name of the AVFilter to be used.
Definition: avfilter.h:865
AVFilterGraph::filters
AVFilterContext ** filters
Definition: avfilter.h:563
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:281
AVFilterContext::name
char * name
name of this filter instance
Definition: avfilter.h:278
avfilter_link_get_hw_frames_ctx
AVBufferRef * avfilter_link_get_hw_frames_ctx(AVFilterLink *link)
Get the hardware frames context of a filter link.
Definition: avfilter.c:998
options
Definition: swscale.c:50
avfilter_inout_alloc
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
Definition: graphparser.c:71
avfilter_graph_get_filter
AVFilterContext * avfilter_graph_get_filter(AVFilterGraph *graph, const char *name)
Get a filter instance identified by instance name from graph.
Definition: avfiltergraph.c:286
avfilter_graph_request_oldest
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
Definition: avfiltergraph.c:1567
AVFilterGraphSegment::chains
AVFilterChain ** chains
A list of filter chain contained in this segment.
Definition: avfilter.h:929
AVFilterGraph
Definition: avfilter.h:561
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:244
avfilter_graph_parse2
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:138
AVFilterParams::nb_outputs
unsigned nb_outputs
Definition: avfilter.h:895
AVFilterFormatsConfig
Lists of formats / etc.
Definition: avfilter.h:120
AVFilterGraphSegment
A parsed representation of a filtergraph segment.
Definition: avfilter.h:918
AVFilterInOut::pad_idx
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:726
AVAlphaMode
AVAlphaMode
Correlation between the alpha channel and color values.
Definition: pixfmt.h:810
AVFilterGraph::scale_sws_opts
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:566
AVFilterContext::nb_inputs
unsigned nb_inputs
number of input pads
Definition: avfilter.h:282
AVFilterGraph::av_class
const AVClass * av_class
Definition: avfilter.h:562
AVMediaType
AVMediaType
Definition: avutil.h:198
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:319
AVFilterInOut::filter_ctx
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:723
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
avfilter_execute_func
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:558
avfilter_link
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:149
avfilter_graph_queue_command
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
Definition: avfiltergraph.c:1484
AVFilterGraphSegment::scale_sws_opts
char * scale_sws_opts
A string containing a colon-separated list of key=value options applied to all scale filters in this ...
Definition: avfilter.h:940
frame.h
AVFilter::description
const char * description
A description of the filter.
Definition: avfilter.h:226
buffer.h
AVFilterFormatsConfig::color_ranges
AVFilterFormats * color_ranges
AVColorRange.
Definition: avfilter.h:141
avfilter_init_str
int avfilter_init_str(AVFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:960
AVFilterParams::nb_inputs
unsigned nb_inputs
Definition: avfilter.h:892
log.h
AVFilterGraphSegment::graph
AVFilterGraph * graph
The filtergraph this segment is associated with.
Definition: avfilter.h:923
avfilter_graph_parse_ptr
int avfilter_graph_parse_ptr(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:920
AVColorSpace
AVColorSpace
YUV colorspace type.
Definition: pixfmt.h:700
version_major.h
AVFilterGraph::thread_type
int thread_type
Type of multithreading allowed for filters in this graph.
Definition: avfilter.h:580
filt
static const int8_t filt[NUMTAPS *2]
Definition: af_earwax.c:40
outputs
static const AVFilterPad outputs[]
Definition: af_aap.c:310
AVFilter
Filter definition.
Definition: avfilter.h:215
AVFILTER_AUTO_CONVERT_NONE
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
Definition: avfilter.h:691
ret
ret
Definition: filter_design.txt:187
pixfmt.h
avfilter_configuration
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
Definition: version.c:36
AVFilterParams::opts
AVDictionary * opts
Options to be applied to the filter.
Definition: avfilter.h:889
avfilter_graph_dump
char * avfilter_graph_dump(AVFilterGraph *graph, const char *options)
Dump a graph into a human-readable string representation.
Definition: graphdump.c:156
dict.h
avfilter_pad_get_type
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:993
avfilter_init_dict
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
Definition: avfilter.c:919
AVFilterChain
A filterchain is a list of filter specifications.
Definition: avfilter.h:904
version.h
AVFilterGraphSegment::nb_chains
size_t nb_chains
Definition: avfilter.h:930
AVFilterContext
An instance of a filter.
Definition: avfilter.h:273
avfilter_graph_parse
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:164
avutil.h
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:125
AVFilter::inputs
const AVFilterPad * inputs
List of static inputs.
Definition: avfilter.h:235
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:321
avfilter_free
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:800
AVFilterInOut::name
char * name
unique name for this input/output in the list
Definition: avfilter.h:720
AVFilterGraph::max_buffered_frames
unsigned max_buffered_frames
Sets the maximum number of buffered frames in the filtergraph combined.
Definition: avfilter.h:618
avfilter_graph_send_command
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
Definition: avfiltergraph.c:1454
avfilter_graph_segment_apply_opts
int avfilter_graph_segment_apply_opts(AVFilterGraphSegment *seg, int flags)
Apply parsed options to filter instances in a graph segment.
Definition: graphparser.c:586
AVFilterGraph::nb_filters
unsigned nb_filters
Definition: avfilter.h:564
AVFilterContext::filter
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:276
AVColorRange
AVColorRange
Visual content value range.
Definition: pixfmt.h:742
avfilter_version
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
Definition: version.c:30
avfilter_get_class
const AVClass * avfilter_get_class(void)
Definition: avfilter.c:1659
AVFilterInOut
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:718
src
#define src
Definition: vp8dsp.c:248
AVFilterFormatsConfig::alpha_modes
AVFilterFormats * alpha_modes
List of supported alpha modes, only for video with an alpha channel.
Definition: avfilter.h:146
AVFilterPadParams
Parameters of a filter's input or output pad.
Definition: avfilter.h:820
AVFilterContext::outputs
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:285