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  * external API header
29  */
30 
31 /**
32  * @defgroup lavfi Libavfilter
33  * @{
34  */
35 
36 #include <stddef.h>
37 
38 #include "libavutil/avutil.h"
39 #include "libavutil/dict.h"
40 #include "libavutil/frame.h"
41 #include "libavutil/log.h"
42 #include "libavutil/samplefmt.h"
43 #include "libavutil/pixfmt.h"
44 #include "libavutil/rational.h"
45 
46 #include "libavfilter/version.h"
47 
48 /**
49  * Return the LIBAVFILTER_VERSION_INT constant.
50  */
51 unsigned avfilter_version(void);
52 
53 /**
54  * Return the libavfilter build-time configuration.
55  */
56 const char *avfilter_configuration(void);
57 
58 /**
59  * Return the libavfilter license.
60  */
61 const char *avfilter_license(void);
62 
64 typedef struct AVFilterLink AVFilterLink;
65 typedef struct AVFilterPad AVFilterPad;
67 
68 #if FF_API_AVFILTERBUFFER
69 /**
70  * A reference-counted buffer data type used by the filter system. Filters
71  * should not store pointers to this structure directly, but instead use the
72  * AVFilterBufferRef structure below.
73  */
74 typedef struct AVFilterBuffer {
75  uint8_t *data[8]; ///< buffer data for each plane/channel
76 
77  /**
78  * pointers to the data planes/channels.
79  *
80  * For video, this should simply point to data[].
81  *
82  * For planar audio, each channel has a separate data pointer, and
83  * linesize[0] contains the size of each channel buffer.
84  * For packed audio, there is just one data pointer, and linesize[0]
85  * contains the total size of the buffer for all channels.
86  *
87  * Note: Both data and extended_data will always be set, but for planar
88  * audio with more channels that can fit in data, extended_data must be used
89  * in order to access all channels.
90  */
91  uint8_t **extended_data;
92  int linesize[8]; ///< number of bytes per line
93 
94  /** private data to be used by a custom free function */
95  void *priv;
96  /**
97  * A pointer to the function to deallocate this buffer if the default
98  * function is not sufficient. This could, for example, add the memory
99  * back into a memory pool to be reused later without the overhead of
100  * reallocating it from scratch.
101  */
102  void (*free)(struct AVFilterBuffer *buf);
103 
104  int format; ///< media format
105  int w, h; ///< width and height of the allocated buffer
106  unsigned refcount; ///< number of references to this buffer
107 } AVFilterBuffer;
108 
109 #define AV_PERM_READ 0x01 ///< can read from the buffer
110 #define AV_PERM_WRITE 0x02 ///< can write to the buffer
111 #define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
112 #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
113 #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
114 #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
115 #define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned
116 
117 #define AVFILTER_ALIGN 16 //not part of ABI
118 
119 /**
120  * Audio specific properties in a reference to an AVFilterBuffer. Since
121  * AVFilterBufferRef is common to different media formats, audio specific
122  * per reference properties must be separated out.
123  */
124 typedef struct AVFilterBufferRefAudioProps {
125  uint64_t channel_layout; ///< channel layout of audio buffer
126  int nb_samples; ///< number of audio samples per channel
127  int sample_rate; ///< audio buffer sample rate
128  int channels; ///< number of channels (do not access directly)
129 } AVFilterBufferRefAudioProps;
130 
131 /**
132  * Video specific properties in a reference to an AVFilterBuffer. Since
133  * AVFilterBufferRef is common to different media formats, video specific
134  * per reference properties must be separated out.
135  */
136 typedef struct AVFilterBufferRefVideoProps {
137  int w; ///< image width
138  int h; ///< image height
139  AVRational sample_aspect_ratio; ///< sample aspect ratio
140  int interlaced; ///< is frame interlaced
141  int top_field_first; ///< field order
142  enum AVPictureType pict_type; ///< picture type of the frame
143  int key_frame; ///< 1 -> keyframe, 0-> not
144  int qp_table_linesize; ///< qp_table stride
145  int qp_table_size; ///< qp_table size
146  int8_t *qp_table; ///< array of Quantization Parameters
147 } AVFilterBufferRefVideoProps;
148 
149 /**
150  * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
151  * a buffer to, for example, crop image without any memcpy, the buffer origin
152  * and dimensions are per-reference properties. Linesize is also useful for
153  * image flipping, frame to field filters, etc, and so is also per-reference.
154  *
155  * TODO: add anything necessary for frame reordering
156  */
157 typedef struct AVFilterBufferRef {
158  AVFilterBuffer *buf; ///< the buffer that this is a reference to
159  uint8_t *data[8]; ///< picture/audio data for each plane
160  /**
161  * pointers to the data planes/channels.
162  *
163  * For video, this should simply point to data[].
164  *
165  * For planar audio, each channel has a separate data pointer, and
166  * linesize[0] contains the size of each channel buffer.
167  * For packed audio, there is just one data pointer, and linesize[0]
168  * contains the total size of the buffer for all channels.
169  *
170  * Note: Both data and extended_data will always be set, but for planar
171  * audio with more channels that can fit in data, extended_data must be used
172  * in order to access all channels.
173  */
174  uint8_t **extended_data;
175  int linesize[8]; ///< number of bytes per line
176 
177  AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
178  AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
179 
180  /**
181  * presentation timestamp. The time unit may change during
182  * filtering, as it is specified in the link and the filter code
183  * may need to rescale the PTS accordingly.
184  */
185  int64_t pts;
186  int64_t pos; ///< byte position in stream, -1 if unknown
187 
188  int format; ///< media format
189 
190  int perms; ///< permissions, see the AV_PERM_* flags
191 
192  enum AVMediaType type; ///< media type of buffer data
193 
194  AVDictionary *metadata; ///< dictionary containing metadata key=value tags
195 } AVFilterBufferRef;
196 
197 /**
198  * Copy properties of src to dst, without copying the actual data
199  */
201 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
202 
203 /**
204  * Add a new reference to a buffer.
205  *
206  * @param ref an existing reference to the buffer
207  * @param pmask a bitmask containing the allowable permissions in the new
208  * reference
209  * @return a new reference to the buffer with the same properties as the
210  * old, excluding any permissions denied by pmask
211  */
213 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
214 
215 /**
216  * Remove a reference to a buffer. If this is the last reference to the
217  * buffer, the buffer itself is also automatically freed.
218  *
219  * @param ref reference to the buffer, may be NULL
220  *
221  * @note it is recommended to use avfilter_unref_bufferp() instead of this
222  * function
223  */
225 void avfilter_unref_buffer(AVFilterBufferRef *ref);
226 
227 /**
228  * Remove a reference to a buffer and set the pointer to NULL.
229  * If this is the last reference to the buffer, the buffer itself
230  * is also automatically freed.
231  *
232  * @param ref pointer to the buffer reference
233  */
235 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
236 #endif
237 
238 /**
239  * Get the number of channels of a buffer reference.
240  */
242 int avfilter_ref_get_channels(AVFilterBufferRef *ref);
243 
244 #if FF_API_AVFILTERPAD_PUBLIC
245 /**
246  * A filter pad used for either input or output.
247  *
248  * See doc/filter_design.txt for details on how to implement the methods.
249  *
250  * @warning this struct might be removed from public API.
251  * users should call avfilter_pad_get_name() and avfilter_pad_get_type()
252  * to access the name and type fields; there should be no need to access
253  * any other fields from outside of libavfilter.
254  */
255 struct AVFilterPad {
256  /**
257  * Pad name. The name is unique among inputs and among outputs, but an
258  * input may have the same name as an output. This may be NULL if this
259  * pad has no need to ever be referenced by name.
260  */
261  const char *name;
262 
263  /**
264  * AVFilterPad type.
265  */
266  enum AVMediaType type;
267 
268  /**
269  * Input pads:
270  * Minimum required permissions on incoming buffers. Any buffer with
271  * insufficient permissions will be automatically copied by the filter
272  * system to a new buffer which provides the needed access permissions.
273  *
274  * Output pads:
275  * Guaranteed permissions on outgoing buffers. Any buffer pushed on the
276  * link must have at least these permissions; this fact is checked by
277  * asserts. It can be used to optimize buffer allocation.
278  */
279  attribute_deprecated int min_perms;
280 
281  /**
282  * Input pads:
283  * Permissions which are not accepted on incoming buffers. Any buffer
284  * which has any of these permissions set will be automatically copied
285  * by the filter system to a new buffer which does not have those
286  * permissions. This can be used to easily disallow buffers with
287  * AV_PERM_REUSE.
288  *
289  * Output pads:
290  * Permissions which are automatically removed on outgoing buffers. It
291  * can be used to optimize buffer allocation.
292  */
293  attribute_deprecated int rej_perms;
294 
295  /**
296  * @deprecated unused
297  */
298  int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
299 
300  /**
301  * Callback function to get a video buffer. If NULL, the filter system will
302  * use ff_default_get_video_buffer().
303  *
304  * Input video pads only.
305  */
306  AVFrame *(*get_video_buffer)(AVFilterLink *link, int w, int h);
307 
308  /**
309  * Callback function to get an audio buffer. If NULL, the filter system will
310  * use ff_default_get_audio_buffer().
311  *
312  * Input audio pads only.
313  */
314  AVFrame *(*get_audio_buffer)(AVFilterLink *link, int nb_samples);
315 
316  /**
317  * @deprecated unused
318  */
319  int (*end_frame)(AVFilterLink *link);
320 
321  /**
322  * @deprecated unused
323  */
324  int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
325 
326  /**
327  * Filtering callback. This is where a filter receives a frame with
328  * audio/video data and should do its processing.
329  *
330  * Input pads only.
331  *
332  * @return >= 0 on success, a negative AVERROR on error. This function
333  * must ensure that frame is properly unreferenced on error if it
334  * hasn't been passed on to another filter.
335  */
337 
338  /**
339  * Frame poll callback. This returns the number of immediately available
340  * samples. It should return a positive value if the next request_frame()
341  * is guaranteed to return one frame (with no delay).
342  *
343  * Defaults to just calling the source poll_frame() method.
344  *
345  * Output pads only.
346  */
347  int (*poll_frame)(AVFilterLink *link);
348 
349  /**
350  * Frame request callback. A call to this should result in at least one
351  * frame being output over the given link. This should return zero on
352  * success, and another value on error.
353  * See ff_request_frame() for the error codes with a specific
354  * meaning.
355  *
356  * Output pads only.
357  */
359 
360  /**
361  * Link configuration callback.
362  *
363  * For output pads, this should set the following link properties:
364  * video: width, height, sample_aspect_ratio, time_base
365  * audio: sample_rate.
366  *
367  * This should NOT set properties such as format, channel_layout, etc which
368  * are negotiated between filters by the filter system using the
369  * query_formats() callback before this function is called.
370  *
371  * For input pads, this should check the properties of the link, and update
372  * the filter's internal state as necessary.
373  *
374  * For both input and output pads, this should return zero on success,
375  * and another value on error.
376  */
377  int (*config_props)(AVFilterLink *link);
378 
379  /**
380  * The filter expects a fifo to be inserted on its input link,
381  * typically because it has a delay.
382  *
383  * input pads only.
384  */
385  int needs_fifo;
386 
387  int needs_writable;
388 };
389 #endif
390 
391 /**
392  * Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
393  * AVFilter.inputs/outputs).
394  */
395 int avfilter_pad_count(const AVFilterPad *pads);
396 
397 /**
398  * Get the name of an AVFilterPad.
399  *
400  * @param pads an array of AVFilterPads
401  * @param pad_idx index of the pad in the array it; is the caller's
402  * responsibility to ensure the index is valid
403  *
404  * @return name of the pad_idx'th pad in pads
405  */
406 const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
407 
408 /**
409  * Get the type of an AVFilterPad.
410  *
411  * @param pads an array of AVFilterPads
412  * @param pad_idx index of the pad in the array; it is the caller's
413  * responsibility to ensure the index is valid
414  *
415  * @return type of the pad_idx'th pad in pads
416  */
417 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
418 
419 /**
420  * The number of the filter inputs is not determined just by AVFilter.inputs.
421  * The filter might add additional inputs during initialization depending on the
422  * options supplied to it.
423  */
424 #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
425 /**
426  * The number of the filter outputs is not determined just by AVFilter.outputs.
427  * The filter might add additional outputs during initialization depending on
428  * the options supplied to it.
429  */
430 #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
431 
432 /**
433  * Filter definition. This defines the pads a filter contains, and all the
434  * callback functions used to interact with the filter.
435  */
436 typedef struct AVFilter {
437  const char *name; ///< filter name
438 
439  /**
440  * A description for the filter. You should use the
441  * NULL_IF_CONFIG_SMALL() macro to define it.
442  */
443  const char *description;
444 
445  const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none
446  const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
447 
448  /**
449  * A class for the private data, used to access filter private
450  * AVOptions.
451  */
453 
454  /**
455  * A combination of AVFILTER_FLAG_*
456  */
457  int flags;
458 
459  /*****************************************************************
460  * All fields below this line are not part of the public API. They
461  * may not be used outside of libavfilter and can be changed and
462  * removed at will.
463  * New public fields should be added right above.
464  *****************************************************************
465  */
466 
467  /**
468  * Filter initialization function. Called when all the options have been
469  * set.
470  */
471  int (*init)(AVFilterContext *ctx);
472 
473  /**
474  * Should be set instead of init by the filters that want to pass a
475  * dictionary of AVOptions to nested contexts that are allocated in
476  * init.
477  */
479 
480  /**
481  * Filter uninitialization function. Should deallocate any memory held
482  * by the filter, release any buffer references, etc. This does not need
483  * to deallocate the AVFilterContext->priv memory itself.
484  */
486 
487  /**
488  * Queries formats/layouts supported by the filter and its pads, and sets
489  * the in_formats/in_chlayouts for links connected to its output pads,
490  * and out_formats/out_chlayouts for links connected to its input pads.
491  *
492  * @return zero on success, a negative value corresponding to an
493  * AVERROR code otherwise
494  */
496 
497  int priv_size; ///< size of private data to allocate for the filter
498 
499  struct AVFilter *next;
500 
501  /**
502  * Make the filter instance process a command.
503  *
504  * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
505  * @param arg the argument for the command
506  * @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.
507  * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
508  * time consuming then a filter should treat it like an unsupported command
509  *
510  * @returns >=0 on success otherwise an error code.
511  * AVERROR(ENOSYS) on unsupported commands
512  */
513  int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
514 
515  /**
516  * Filter initialization function, alternative to the init()
517  * callback. Args contains the user-supplied parameters, opaque is
518  * used for providing binary data.
519  */
520  int (*init_opaque)(AVFilterContext *ctx, void *opaque);
521 } AVFilter;
522 
523 /** An instance of a filter */
525  const AVClass *av_class; ///< needed for av_log()
526 
527  const AVFilter *filter; ///< the AVFilter of which this is an instance
528 
529  char *name; ///< name of this filter instance
530 
531  AVFilterPad *input_pads; ///< array of input pads
532  AVFilterLink **inputs; ///< array of pointers to input links
533 #if FF_API_FOO_COUNT
534  unsigned input_count; ///< @deprecated use nb_inputs
535 #endif
536  unsigned nb_inputs; ///< number of input pads
537 
538  AVFilterPad *output_pads; ///< array of output pads
539  AVFilterLink **outputs; ///< array of pointers to output links
540 #if FF_API_FOO_COUNT
541  unsigned output_count; ///< @deprecated use nb_outputs
542 #endif
543  unsigned nb_outputs; ///< number of output pads
544 
545  void *priv; ///< private data for use by the filter
546 
547  struct AVFilterGraph *graph; ///< filtergraph this filter belongs to
548 
550 };
551 
552 /**
553  * A link between two filters. This contains pointers to the source and
554  * destination filters between which this link exists, and the indexes of
555  * the pads involved. In addition, this link also contains the parameters
556  * which have been negotiated and agreed upon between the filter, such as
557  * image dimensions, format, etc.
558  */
559 struct AVFilterLink {
560  AVFilterContext *src; ///< source filter
561  AVFilterPad *srcpad; ///< output pad on the source filter
562 
563  AVFilterContext *dst; ///< dest filter
564  AVFilterPad *dstpad; ///< input pad on the dest filter
565 
566  enum AVMediaType type; ///< filter media type
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  /* These parameters apply only to audio */
573  uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
574  int sample_rate; ///< samples per second
575 
576  int format; ///< agreed upon media format
577 
578  /**
579  * Define the time base used by the PTS of the frames/samples
580  * which will pass through this link.
581  * During the configuration stage, each filter is supposed to
582  * change only the output timebase, while the timebase of the
583  * input link is assumed to be an unchangeable property.
584  */
586 
587  /*****************************************************************
588  * All fields below this line are not part of the public API. They
589  * may not be used outside of libavfilter and can be changed and
590  * removed at will.
591  * New public fields should be added right above.
592  *****************************************************************
593  */
594  /**
595  * Lists of formats and channel layouts supported by the input and output
596  * filters respectively. These lists are used for negotiating the format
597  * to actually be used, which will be loaded into the format and
598  * channel_layout members, above, when chosen.
599  *
600  */
603 
604  /**
605  * Lists of channel layouts and sample rates used for automatic
606  * negotiation.
607  */
612 
613  /**
614  * Audio only, the destination filter sets this to a non-zero value to
615  * request that buffers with the given number of samples should be sent to
616  * it. AVFilterPad.needs_fifo must also be set on the corresponding input
617  * pad.
618  * Last buffer before EOF will be padded with silence.
619  */
621 
622  /** stage of the initialization of the link properties (dimensions, etc) */
623  enum {
624  AVLINK_UNINIT = 0, ///< not started
625  AVLINK_STARTINIT, ///< started, but incomplete
626  AVLINK_INIT ///< complete
627  } init_state;
628 
630 
631  /**
632  * Graph the filter belongs to.
633  */
635 
636  /**
637  * Current timestamp of the link, as defined by the most recent
638  * frame(s), in AV_TIME_BASE units.
639  */
640  int64_t current_pts;
641 
642  /**
643  * Index in the age array.
644  */
646 
647  /**
648  * Frame rate of the stream on the link, or 1/0 if unknown;
649  * if left to 0/0, will be automatically be copied from the first input
650  * of the source filter if it exists.
651  *
652  * Sources should set it to the best estimation of the real frame rate.
653  * Filters should update it if necessary depending on their function.
654  * Sinks can use it to set a default output frame rate.
655  * It is similar to the r_frame_rate field in AVStream.
656  */
658 
659  /**
660  * Buffer partially filled with samples to achieve a fixed/minimum size.
661  */
663 
664  /**
665  * Size of the partial buffer to allocate.
666  * Must be between min_samples and max_samples.
667  */
669 
670  /**
671  * Minimum number of samples to filter at once. If filter_frame() is
672  * called with fewer samples, it will accumulate them in partial_buf.
673  * This field and the related ones must not be changed after filtering
674  * has started.
675  * If 0, all related fields are ignored.
676  */
678 
679  /**
680  * Maximum number of samples to filter at once. If filter_frame() is
681  * called with more samples, it will split them.
682  */
684 
685  /**
686  * The buffer reference currently being received across the link by the
687  * destination filter. This is used internally by the filter system to
688  * allow automatic copying of buffers which do not have sufficient
689  * permissions for the destination. This should not be accessed directly
690  * by the filters.
691  */
692  AVFilterBufferRef *cur_buf_copy;
693 
694  /**
695  * True if the link is closed.
696  * If set, all attemps of start_frame, filter_frame or request_frame
697  * will fail with AVERROR_EOF, and if necessary the reference will be
698  * destroyed.
699  * If request_frame returns AVERROR_EOF, this flag is set on the
700  * corresponding link.
701  * It can be set also be set by either the source or the destination
702  * filter.
703  */
704  int closed;
705 
706  /**
707  * Number of channels.
708  */
709  int channels;
710 
711  /**
712  * True if a frame is being requested on the link.
713  * Used internally by the framework.
714  */
715  unsigned frame_requested;
716 
717  /**
718  * Link processing flags.
719  */
720  unsigned flags;
721 };
722 
723 /**
724  * Link two filters together.
725  *
726  * @param src the source filter
727  * @param srcpad index of the output pad on the source filter
728  * @param dst the destination filter
729  * @param dstpad index of the input pad on the destination filter
730  * @return zero on success
731  */
732 int avfilter_link(AVFilterContext *src, unsigned srcpad,
733  AVFilterContext *dst, unsigned dstpad);
734 
735 /**
736  * Free the link in *link, and set its pointer to NULL.
737  */
739 
740 /**
741  * Get the number of channels of a link.
742  */
744 
745 /**
746  * Set the closed field of a link.
747  */
748 void avfilter_link_set_closed(AVFilterLink *link, int closed);
749 
750 /**
751  * Negotiate the media format, dimensions, etc of all inputs to a filter.
752  *
753  * @param filter the filter to negotiate the properties for its inputs
754  * @return zero on successful negotiation
755  */
757 
758 #if FF_API_AVFILTERBUFFER
759 /**
760  * Create a buffer reference wrapped around an already allocated image
761  * buffer.
762  *
763  * @param data pointers to the planes of the image to reference
764  * @param linesize linesizes for the planes of the image to reference
765  * @param perms the required access permissions
766  * @param w the width of the image specified by the data and linesize arrays
767  * @param h the height of the image specified by the data and linesize arrays
768  * @param format the pixel format of the image specified by the data and linesize arrays
769  */
771 AVFilterBufferRef *
772 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
773  int w, int h, enum AVPixelFormat format);
774 
775 /**
776  * Create an audio buffer reference wrapped around an already
777  * allocated samples buffer.
778  *
779  * See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version
780  * that can handle unknown channel layouts.
781  *
782  * @param data pointers to the samples plane buffers
783  * @param linesize linesize for the samples plane buffers
784  * @param perms the required access permissions
785  * @param nb_samples number of samples per channel
786  * @param sample_fmt the format of each sample in the buffer to allocate
787  * @param channel_layout the channel layout of the buffer
788  */
790 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
791  int linesize,
792  int perms,
793  int nb_samples,
794  enum AVSampleFormat sample_fmt,
795  uint64_t channel_layout);
796 /**
797  * Create an audio buffer reference wrapped around an already
798  * allocated samples buffer.
799  *
800  * @param data pointers to the samples plane buffers
801  * @param linesize linesize for the samples plane buffers
802  * @param perms the required access permissions
803  * @param nb_samples number of samples per channel
804  * @param sample_fmt the format of each sample in the buffer to allocate
805  * @param channels the number of channels of the buffer
806  * @param channel_layout the channel layout of the buffer,
807  * must be either 0 or consistent with channels
808  */
810 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data,
811  int linesize,
812  int perms,
813  int nb_samples,
814  enum AVSampleFormat sample_fmt,
815  int channels,
816  uint64_t channel_layout);
817 
818 #endif
819 
820 
821 #define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
822 #define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
823 
824 /**
825  * Make the filter instance process a command.
826  * It is recommended to use avfilter_graph_send_command().
827  */
828 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
829 
830 /** Initialize the filter system. Register all builtin filters. */
831 void avfilter_register_all(void);
832 
833 #if FF_API_OLD_FILTER_REGISTER
834 /** Uninitialize the filter system. Unregister all filters. */
836 void avfilter_uninit(void);
837 #endif
838 
839 /**
840  * Register a filter. This is only needed if you plan to use
841  * avfilter_get_by_name later to lookup the AVFilter structure by name. A
842  * filter can still by instantiated with avfilter_graph_alloc_filter even if it
843  * is not registered.
844  *
845  * @param filter the filter to register
846  * @return 0 if the registration was successful, a negative value
847  * otherwise
848  */
850 
851 /**
852  * Get a filter definition matching the given name.
853  *
854  * @param name the filter name to find
855  * @return the filter definition, if any matching one is registered.
856  * NULL if none found.
857  */
858 AVFilter *avfilter_get_by_name(const char *name);
859 
860 /**
861  * Iterate over all registered filters.
862  * @return If prev is non-NULL, next registered filter after prev or NULL if
863  * prev is the last filter. If prev is NULL, return the first registered filter.
864  */
865 const AVFilter *avfilter_next(const AVFilter *prev);
866 
867 #if FF_API_OLD_FILTER_REGISTER
868 /**
869  * If filter is NULL, returns a pointer to the first registered filter pointer,
870  * if filter is non-NULL, returns the next pointer after filter.
871  * If the returned pointer points to NULL, the last registered filter
872  * was already reached.
873  * @deprecated use avfilter_next()
874  */
876 AVFilter **av_filter_next(AVFilter **filter);
877 #endif
878 
879 #if FF_API_AVFILTER_OPEN
880 /**
881  * Create a filter instance.
882  *
883  * @param filter_ctx put here a pointer to the created filter context
884  * on success, NULL on failure
885  * @param filter the filter to create an instance of
886  * @param inst_name Name to give to the new instance. Can be NULL for none.
887  * @return >= 0 in case of success, a negative error code otherwise
888  * @deprecated use avfilter_graph_alloc_filter() instead
889  */
891 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
892 #endif
893 
894 
895 #if FF_API_AVFILTER_INIT_FILTER
896 /**
897  * Initialize a filter.
898  *
899  * @param filter the filter to initialize
900  * @param args A string of parameters to use when initializing the filter.
901  * The format and meaning of this string varies by filter.
902  * @param opaque Any extra non-string data needed by the filter. The meaning
903  * of this parameter varies by filter.
904  * @return zero on success
905  */
907 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
908 #endif
909 
910 /**
911  * Initialize a filter with the supplied parameters.
912  *
913  * @param ctx uninitialized filter context to initialize
914  * @param args Options to initialize the filter with. This must be a
915  * ':'-separated list of options in the 'key=value' form.
916  * May be NULL if the options have been set directly using the
917  * AVOptions API or there are no options that need to be set.
918  * @return 0 on success, a negative AVERROR on failure
919  */
920 int avfilter_init_str(AVFilterContext *ctx, const char *args);
921 
922 /**
923  * Initialize a filter with the supplied dictionary of options.
924  *
925  * @param ctx uninitialized filter context to initialize
926  * @param options An AVDictionary filled with options for this filter. On
927  * return this parameter will be destroyed and replaced with
928  * a dict containing options that were not found. This dictionary
929  * must be freed by the caller.
930  * May be NULL, then this function is equivalent to
931  * avfilter_init_str() with the second parameter set to NULL.
932  * @return 0 on success, a negative AVERROR on failure
933  *
934  * @note This function and avfilter_init_str() do essentially the same thing,
935  * the difference is in manner in which the options are passed. It is up to the
936  * calling code to choose whichever is more preferable. The two functions also
937  * behave differently when some of the provided options are not declared as
938  * supported by the filter. In such a case, avfilter_init_str() will fail, but
939  * this function will leave those extra options in the options AVDictionary and
940  * continue as usual.
941  */
943 
944 /**
945  * Free a filter context. This will also remove the filter from its
946  * filtergraph's list of filters.
947  *
948  * @param filter the filter to free
949  */
951 
952 /**
953  * Insert a filter in the middle of an existing link.
954  *
955  * @param link the link into which the filter should be inserted
956  * @param filt the filter to be inserted
957  * @param filt_srcpad_idx the input pad on the filter to connect
958  * @param filt_dstpad_idx the output pad on the filter to connect
959  * @return zero on success
960  */
962  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
963 
964 #if FF_API_AVFILTERBUFFER
965 /**
966  * Copy the frame properties of src to dst, without copying the actual
967  * image data.
968  *
969  * @return 0 on success, a negative number on error.
970  */
972 int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
973 
974 /**
975  * Copy the frame properties and data pointers of src to dst, without copying
976  * the actual data.
977  *
978  * @return 0 on success, a negative number on error.
979  */
981 int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
982 #endif
983 
984 /**
985  * @return AVClass for AVFilterContext.
986  *
987  * @see av_opt_find().
988  */
989 const AVClass *avfilter_get_class(void);
990 
991 typedef struct AVFilterGraph {
993 #if FF_API_FOO_COUNT
995  unsigned filter_count_unused;
996 #endif
998 #if !FF_API_FOO_COUNT
999  unsigned nb_filters;
1000 #endif
1001 
1002  char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
1003  char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
1004 #if FF_API_FOO_COUNT
1005  unsigned nb_filters;
1006 #endif
1007  char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
1008 
1009  /**
1010  * Private fields
1011  *
1012  * The following fields are for internal use only.
1013  * Their type, offset, number and semantic can change without notice.
1014  */
1015 
1018 
1020 } AVFilterGraph;
1021 
1022 /**
1023  * Allocate a filter graph.
1024  */
1026 
1027 /**
1028  * Create a new filter instance in a filter graph.
1029  *
1030  * @param graph graph in which the new filter will be used
1031  * @param filter the filter to create an instance of
1032  * @param name Name to give to the new instance (will be copied to
1033  * AVFilterContext.name). This may be used by the caller to identify
1034  * different filters, libavfilter itself assigns no semantics to
1035  * this parameter. May be NULL.
1036  *
1037  * @return the context of the newly created filter instance (note that it is
1038  * also retrievable directly through AVFilterGraph.filters or with
1039  * avfilter_graph_get_filter()) on success or NULL or failure.
1040  */
1042  const AVFilter *filter,
1043  const char *name);
1044 
1045 /**
1046  * Get a filter instance with name name from graph.
1047  *
1048  * @return the pointer to the found filter instance or NULL if it
1049  * cannot be found.
1050  */
1052 
1053 #if FF_API_AVFILTER_OPEN
1054 /**
1055  * Add an existing filter instance to a filter graph.
1056  *
1057  * @param graphctx the filter graph
1058  * @param filter the filter to be added
1059  *
1060  * @deprecated use avfilter_graph_alloc_filter() to allocate a filter in a
1061  * filter graph
1062  */
1064 int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
1065 #endif
1066 
1067 /**
1068  * Create and add a filter instance into an existing graph.
1069  * The filter instance is created from the filter filt and inited
1070  * with the parameters args and opaque.
1071  *
1072  * In case of success put in *filt_ctx the pointer to the created
1073  * filter instance, otherwise set *filt_ctx to NULL.
1074  *
1075  * @param name the instance name to give to the created filter instance
1076  * @param graph_ctx the filter graph
1077  * @return a negative AVERROR error code in case of failure, a non
1078  * negative value otherwise
1079  */
1081  const char *name, const char *args, void *opaque,
1082  AVFilterGraph *graph_ctx);
1083 
1084 /**
1085  * Enable or disable automatic format conversion inside the graph.
1086  *
1087  * Note that format conversion can still happen inside explicitly inserted
1088  * scale and aresample filters.
1089  *
1090  * @param flags any of the AVFILTER_AUTO_CONVERT_* constants
1091  */
1092 void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags);
1093 
1094 enum {
1095  AVFILTER_AUTO_CONVERT_ALL = 0, /**< all automatic conversions enabled */
1096  AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */
1097 };
1098 
1099 /**
1100  * Check validity and configure all the links and formats in the graph.
1101  *
1102  * @param graphctx the filter graph
1103  * @param log_ctx context used for logging
1104  * @return 0 in case of success, a negative AVERROR code otherwise
1105  */
1106 int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
1107 
1108 /**
1109  * Free a graph, destroy its links, and set *graph to NULL.
1110  * If *graph is NULL, do nothing.
1111  */
1112 void avfilter_graph_free(AVFilterGraph **graph);
1113 
1114 /**
1115  * A linked-list of the inputs/outputs of the filter chain.
1116  *
1117  * This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(),
1118  * where it is used to communicate open (unlinked) inputs and outputs from and
1119  * to the caller.
1120  * This struct specifies, per each not connected pad contained in the graph, the
1121  * filter context and the pad index required for establishing a link.
1122  */
1123 typedef struct AVFilterInOut {
1124  /** unique name for this input/output in the list */
1125  char *name;
1126 
1127  /** filter context associated to this input/output */
1129 
1130  /** index of the filt_ctx pad to use for linking */
1131  int pad_idx;
1132 
1133  /** next input/input in the list, NULL if this is the last */
1135 } AVFilterInOut;
1136 
1137 /**
1138  * Allocate a single AVFilterInOut entry.
1139  * Must be freed with avfilter_inout_free().
1140  * @return allocated AVFilterInOut on success, NULL on failure.
1141  */
1143 
1144 /**
1145  * Free the supplied list of AVFilterInOut and set *inout to NULL.
1146  * If *inout is NULL, do nothing.
1147  */
1148 void avfilter_inout_free(AVFilterInOut **inout);
1149 
1150 /**
1151  * Add a graph described by a string to a graph.
1152  *
1153  * @param graph the filter graph where to link the parsed graph context
1154  * @param filters string to be parsed
1155  * @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
1156  * If non-NULL, *inputs is updated to contain the list of open inputs
1157  * after the parsing, should be freed with avfilter_inout_free().
1158  * @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
1159  * If non-NULL, *outputs is updated to contain the list of open outputs
1160  * after the parsing, should be freed with avfilter_inout_free().
1161  * @return non negative on success, a negative AVERROR code on error
1162  */
1163 int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
1165  void *log_ctx);
1166 
1167 /**
1168  * Add a graph described by a string to a graph.
1169  *
1170  * @param[in] graph the filter graph where to link the parsed graph context
1171  * @param[in] filters string to be parsed
1172  * @param[out] inputs a linked list of all free (unlinked) inputs of the
1173  * parsed graph will be returned here. It is to be freed
1174  * by the caller using avfilter_inout_free().
1175  * @param[out] outputs a linked list of all free (unlinked) outputs of the
1176  * parsed graph will be returned here. It is to be freed by the
1177  * caller using avfilter_inout_free().
1178  * @return zero on success, a negative AVERROR code on error
1179  *
1180  * @note the difference between avfilter_graph_parse2() and
1181  * avfilter_graph_parse() is that in avfilter_graph_parse(), the caller provides
1182  * the lists of inputs and outputs, which therefore must be known before calling
1183  * the function. On the other hand, avfilter_graph_parse2() \em returns the
1184  * inputs and outputs that are left unlinked after parsing the graph and the
1185  * caller then deals with them. Another difference is that in
1186  * avfilter_graph_parse(), the inputs parameter describes inputs of the
1187  * <em>already existing</em> part of the graph; i.e. from the point of view of
1188  * the newly created part, they are outputs. Similarly the outputs parameter
1189  * describes outputs of the already existing filters, which are provided as
1190  * inputs to the parsed filters.
1191  * avfilter_graph_parse2() takes the opposite approach -- it makes no reference
1192  * whatsoever to already existing parts of the graph and the inputs parameter
1193  * will on return contain inputs of the newly parsed part of the graph.
1194  * Analogously the outputs parameter will contain outputs of the newly created
1195  * filters.
1196  */
1197 int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
1200 
1201 /**
1202  * Send a command to one or more filter instances.
1203  *
1204  * @param graph the filter graph
1205  * @param target the filter(s) to which the command should be sent
1206  * "all" sends to all filters
1207  * otherwise it can be a filter or filter instance name
1208  * which will send the command to all matching filters.
1209  * @param cmd the command to sent, for handling simplicity all commands must be alphanumeric only
1210  * @param arg the argument for the command
1211  * @param res a buffer with size res_size where the filter(s) can return a response.
1212  *
1213  * @returns >=0 on success otherwise an error code.
1214  * AVERROR(ENOSYS) on unsupported commands
1215  */
1216 int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags);
1217 
1218 /**
1219  * Queue a command for one or more filter instances.
1220  *
1221  * @param graph the filter graph
1222  * @param target the filter(s) to which the command should be sent
1223  * "all" sends to all filters
1224  * otherwise it can be a filter or filter instance name
1225  * which will send the command to all matching filters.
1226  * @param cmd the command to sent, for handling simplicity all commands must be alphanummeric only
1227  * @param arg the argument for the command
1228  * @param ts time at which the command should be sent to the filter
1229  *
1230  * @note As this executes commands after this function returns, no return code
1231  * from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported.
1232  */
1233 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts);
1234 
1235 
1236 /**
1237  * Dump a graph into a human-readable string representation.
1238  *
1239  * @param graph the graph to dump
1240  * @param options formatting options; currently ignored
1241  * @return a string, or NULL in case of memory allocation failure;
1242  * the string must be freed using av_free
1243  */
1244 char *avfilter_graph_dump(AVFilterGraph *graph, const char *options);
1245 
1246 /**
1247  * Request a frame on the oldest sink link.
1248  *
1249  * If the request returns AVERROR_EOF, try the next.
1250  *
1251  * Note that this function is not meant to be the sole scheduling mechanism
1252  * of a filtergraph, only a convenience function to help drain a filtergraph
1253  * in a balanced way under normal circumstances.
1254  *
1255  * Also note that AVERROR_EOF does not mean that frames did not arrive on
1256  * some of the sinks during the process.
1257  * When there are multiple sink links, in case the requested link
1258  * returns an EOF, this may cause a filter to flush pending frames
1259  * which are sent to another sink link, although unrequested.
1260  *
1261  * @return the return value of ff_request_frame(),
1262  * or AVERROR_EOF if all links returned AVERROR_EOF
1263  */
1265 
1266 /**
1267  * @}
1268  */
1269 #endif /* AVFILTER_AVFILTER_H */
AVFilterContext ** filters
Definition: avfilter.h:997
const char * name
Definition: avisynth_c.h:675
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
void avfilter_link_set_closed(AVFilterLink *link, int closed)
Set the closed field of a link.
Definition: avfilter.c:160
int sink_links_count
Definition: avfilter.h:1017
This structure describes decoded (raw) audio or video data.
Definition: frame.h:76
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.
FIXME Range Coding of cr are ref
Definition: snow.txt:367
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:568
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
Definition: avfiltergraph.c:53
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
Definition: graphparser.c:175
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
Definition: avfilter.h:1134
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:842
Libavfilter version macros.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Definition: avfiltergraph.c:75
external API header
static int query_formats(AVFilterContext *ctx)
Definition: af_aconvert.c:73
void avfilter_unref_buffer(AVFilterBufferRef *ref)
output residual component w
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
Definition: avfilter.h:1002
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:547
int priv_size
size of private data to allocate for the filter
Definition: avfilter.h:497
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:532
char * name
name of this filter instance
Definition: avfilter.h:529
Public dictionary API.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:114
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:538
const char * avfilter_license(void)
Return the libavfilter license.
Definition: avfilter.c:78
uint8_t
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:334
static int poll_frame(AVFilterLink *link)
Definition: buffersrc.c:492
int flags
A combination of AVFILTER_FLAG_*.
Definition: avfilter.h:457
void avfilter_register_all(void)
Initialize the filter system.
Definition: allfilters.c:40
the mask is usually to keep the same permissions Filters should remove permissions on reference they give to output whenever necessary It can be automatically done by setting the rej_perms field on the output pad Here are a few guidelines corresponding to common then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
char * resample_lavr_opts
libavresample options to use for the auto-inserted resample filters
Definition: avfilter.h:1003
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition: avfilter.c:203
const AVFilter * avfilter_next(const AVFilter *prev)
Iterate over all registered filters.
Definition: avfilter.c:424
for audio filters
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:379
const OptionDef options[]
Definition: ffserver.c:4697
frame
Definition: stft.m:14
A filter pad used for either input or output.
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:531
all automatic conversions enabled
Definition: avfilter.h:1095
int avfilter_link_get_channels(AVFilterLink *link)
Get the number of channels of a link.
Definition: avfilter.c:155
const AVClass * av_class
Definition: avfilter.h:992
unsigned nb_outputs
number of output pads
Definition: avfilter.h:543
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
Definition: avfilter.c:68
struct AVFilterInOut AVFilterInOut
A linked-list of the inputs/outputs of the filter chain.
Spectrum Plot time data
void * priv
private data for use by the filter
Definition: avfilter.h:545
const char * arg
AVFilterLink ** sink_links
Private fields.
Definition: avfilter.h:1016
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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
Note except for filters that can have queued request_frame does not push and as a the filter_frame method will be called and do the work Legacy the filter_frame method was it was made of draw_slice(that could be called several times on distinct parts of the frame) and end_frame
static int config_props(AVFilterLink *link)
Definition: af_asyncts.c:83
static int request_frame(AVFilterLink *outlink)
Definition: af_amerge.c:172
unsigned nb_inputs
number of input pads
Definition: avfilter.h:536
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
Definition: af_aresample.c:46
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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 format(the sample packing is implied by the sample format) and sample rate.The lists are not just lists
all automatic conversions disabled
Definition: avfilter.h:1096
struct AVFilterGraph AVFilterGraph
static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: af_atempo.c:1141
AVFilterContext * filter_ctx
filter context associated to this input/output
Definition: avfilter.h:1128
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
A list of supported channel layouts.
Definition: formats.h:85
int avfilter_init_str(AVFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
Definition: avfilter.c:715
const AVFilterPad * inputs
NULL terminated list of inputs. NULL if none.
Definition: avfilter.h:445
struct AVFilter AVFilter
Filter definition.
const AVClass * avfilter_get_class(void)
Definition: avfilter.c:994
A linked-list of the inputs/outputs of the filter chain.
Definition: avfilter.h:1123
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:165
const AVClass * priv_class
A class for the private data, used to access filter private AVOptions.
Definition: avfilter.h:452
sample_rate
AVS_Value src
Definition: avisynth_c.h:523
typedef void(RENAME(mix_any_func_type))
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
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:378
void * buf
Definition: avisynth_c.h:594
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
BYTE int const BYTE int int int height
Definition: avisynth_c.h:713
Describe the class of an AVClass context structure.
Definition: log.h:50
Filter definition.
Definition: avfilter.h:436
int pad_idx
index of the filt_ctx pad to use for linking
Definition: avfilter.h:1131
rational number numerator/denominator
Definition: rational.h:43
struct AVFilter * next
Definition: avfilter.h:499
AVMediaType
Definition: avutil.h:141
const char * name
filter name
Definition: avfilter.h:437
AVPictureType
Definition: avutil.h:214
unsigned nb_filters
Definition: avfilter.h:999
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
Definition: avfilter.c:73
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:837
#define type
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:539
char * name
unique name for this input/output in the list
Definition: avfilter.h:1125
static const int8_t filt[NUMTAPS]
Definition: af_earwax.c:39
static int flags
Definition: cpu.c:23
int(* init_opaque)(AVFilterContext *ctx, void *opaque)
Filter initialization function, alternative to the init() callback.
Definition: avfilter.h:520
#define attribute_deprecated
Definition: attributes.h:90
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
Definition: avfilter.c:693
attribute_deprecated int avfilter_ref_get_channels(AVFilterBufferRef *ref)
Get the number of channels of a buffer reference.
Definition: audio.c:31
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
Definition: graphparser.c:170
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
rational numbers
struct AVFilterCommand * command_queue
Definition: avfilter.h:549
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
char * avfilter_graph_dump(AVFilterGraph *graph, const char *options)
Dump a graph into a human-readable string representation.
Definition: graphdump.c:153
function y
Definition: D.m:1
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.
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
Definition: af_aconvert.c:140
char * aresample_swr_opts
swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions ...
Definition: avfilter.h:1007
A Quick Description Of Rate Distortion Theory We want to encode a video
pixel format definitions
const char * description
A description for the filter.
Definition: avfilter.h:443
int avfilter_register(AVFilter *filter)
Register a filter.
Definition: avfilter.c:405
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
const AVClass * av_class
needed for av_log()
Definition: avfilter.h:525
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:524
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
Definition: avfilter.c:440
const AVFilterPad * outputs
NULL terminated list of outputs. NULL if none.
Definition: avfilter.h:446
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
AVFilterContext * avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
Get a filter instance with name name from graph.
Note except for filters that can have queued request_frame does not push and as a the filter_frame method will be called and do the work Legacy the filter_frame method was it was made of start_frame
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: avfilter.c:391
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
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
void avfilter_link_free(AVFilterLink **link)
Free the link in *link, and set its pointer to NULL.
Definition: avfilter.c:145
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:527
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
unsigned disable_auto_convert
Definition: avfilter.h:1019
MUSIC TECHNOLOGY GROUP UNIVERSITAT POMPEU FABRA Free Non Commercial Binary License Agreement UNIVERSITAT POMPEU OR INDICATING ACCEPTANCE BY SELECTING THE ACCEPT BUTTON ON ANY DOWNLOAD OR INSTALL YOU ACCEPT THE TERMS OF THE LICENSE SUMMARY TABLE Software MELODIA Melody Extraction vamp plug in Licensor Music Technology Group Universitat Pompeu Plaça de la Spain Permitted purposes Non commercial internal research and validation and educational purposes only All commercial uses in a production either internal or are prohibited by this license and require an additional commercial exploitation license TERMS AND CONDITIONS SOFTWARE Software means the software programs identified herein in binary any other machine readable any updates or error corrections provided by and any user programming guides and other documentation provided to you by UPF under this Agreement LICENSE Subject to the terms and conditions of this UPF grants you a royalty free
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:447