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