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