3 * Copyright (c) 2007 Bobby Bingham
5 * This file is part of FFmpeg.
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.
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.
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
22 #ifndef AVFILTER_AVFILTER_H
23 #define AVFILTER_AVFILTER_H
25 #include "libavutil/avutil.h"
26 #include "libavutil/log.h"
27 #include "libavutil/samplefmt.h"
28 #include "libavutil/pixfmt.h"
29 #include "libavutil/rational.h"
30 #include "libavcodec/avcodec.h"
33 #ifndef FF_API_OLD_VSINK_API
34 #define FF_API_OLD_VSINK_API (LIBAVFILTER_VERSION_MAJOR < 3)
36 #ifndef FF_API_OLD_ALL_FORMATS_API
37 #define FF_API_OLD_ALL_FORMATS_API (LIBAVFILTER_VERSION_MAJOR < 3)
42 #include "libavfilter/version.h"
45 * Return the LIBAVFILTER_VERSION_INT constant.
47 unsigned avfilter_version(void);
50 * Return the libavfilter build-time configuration.
52 const char *avfilter_configuration(void);
55 * Return the libavfilter license.
57 const char *avfilter_license(void);
60 typedef struct AVFilterContext AVFilterContext;
61 typedef struct AVFilterLink AVFilterLink;
62 typedef struct AVFilterPad AVFilterPad;
63 typedef struct AVFilterFormats AVFilterFormats;
66 * A reference-counted buffer data type used by the filter system. Filters
67 * should not store pointers to this structure directly, but instead use the
68 * AVFilterBufferRef structure below.
70 typedef struct AVFilterBuffer {
71 uint8_t *data[8]; ///< buffer data for each plane/channel
72 int linesize[8]; ///< number of bytes per line
74 unsigned refcount; ///< number of references to this buffer
76 /** private data to be used by a custom free function */
79 * A pointer to the function to deallocate this buffer if the default
80 * function is not sufficient. This could, for example, add the memory
81 * back into a memory pool to be reused later without the overhead of
82 * reallocating it from scratch.
84 void (*free)(struct AVFilterBuffer *buf);
86 int format; ///< media format
87 int w, h; ///< width and height of the allocated buffer
90 * pointers to the data planes/channels.
92 * For video, this should simply point to data[].
94 * For planar audio, each channel has a separate data pointer, and
95 * linesize[0] contains the size of each channel buffer.
96 * For packed audio, there is just one data pointer, and linesize[0]
97 * contains the total size of the buffer for all channels.
99 * Note: Both data and extended_data will always be set, but for planar
100 * audio with more channels that can fit in data, extended_data must be used
101 * in order to access all channels.
103 uint8_t **extended_data;
106 #define AV_PERM_READ 0x01 ///< can read from the buffer
107 #define AV_PERM_WRITE 0x02 ///< can write to the buffer
108 #define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
109 #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
110 #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
111 #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
112 #define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned
114 #define AVFILTER_ALIGN 16 //not part of ABI
117 * Audio specific properties in a reference to an AVFilterBuffer. Since
118 * AVFilterBufferRef is common to different media formats, audio specific
119 * per reference properties must be separated out.
121 typedef struct AVFilterBufferRefAudioProps {
122 uint64_t channel_layout; ///< channel layout of audio buffer
123 int nb_samples; ///< number of audio samples per channel
124 int sample_rate; ///< audio buffer sample rate
126 int planar; ///< audio buffer - planar or packed
128 } AVFilterBufferRefAudioProps;
131 * Video specific properties in a reference to an AVFilterBuffer. Since
132 * AVFilterBufferRef is common to different media formats, video specific
133 * per reference properties must be separated out.
135 typedef struct AVFilterBufferRefVideoProps {
136 int w; ///< image width
137 int h; ///< image height
138 AVRational sample_aspect_ratio; ///< sample aspect ratio
139 int interlaced; ///< is frame interlaced
140 int top_field_first; ///< field order
141 enum AVPictureType pict_type; ///< picture type of the frame
142 int key_frame; ///< 1 -> keyframe, 0-> not
143 } AVFilterBufferRefVideoProps;
146 * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
147 * a buffer to, for example, crop image without any memcpy, the buffer origin
148 * and dimensions are per-reference properties. Linesize is also useful for
149 * image flipping, frame to field filters, etc, and so is also per-reference.
151 * TODO: add anything necessary for frame reordering
153 typedef struct AVFilterBufferRef {
154 AVFilterBuffer *buf; ///< the buffer that this is a reference to
155 uint8_t *data[8]; ///< picture/audio data for each plane
156 int linesize[8]; ///< number of bytes per line
157 int format; ///< media format
160 * presentation timestamp. The time unit may change during
161 * filtering, as it is specified in the link and the filter code
162 * may need to rescale the PTS accordingly.
165 int64_t pos; ///< byte position in stream, -1 if unknown
167 int perms; ///< permissions, see the AV_PERM_* flags
169 enum AVMediaType type; ///< media type of buffer data
170 AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
171 AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
174 * pointers to the data planes/channels.
176 * For video, this should simply point to data[].
178 * For planar audio, each channel has a separate data pointer, and
179 * linesize[0] contains the size of each channel buffer.
180 * For packed audio, there is just one data pointer, and linesize[0]
181 * contains the total size of the buffer for all channels.
183 * Note: Both data and extended_data will always be set, but for planar
184 * audio with more channels that can fit in data, extended_data must be used
185 * in order to access all channels.
187 uint8_t **extended_data;
191 * Copy properties of src to dst, without copying the actual data
193 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
196 * Add a new reference to a buffer.
198 * @param ref an existing reference to the buffer
199 * @param pmask a bitmask containing the allowable permissions in the new
201 * @return a new reference to the buffer with the same properties as the
202 * old, excluding any permissions denied by pmask
204 AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
207 * Remove a reference to a buffer. If this is the last reference to the
208 * buffer, the buffer itself is also automatically freed.
210 * @param ref reference to the buffer, may be NULL
212 void avfilter_unref_buffer(AVFilterBufferRef *ref);
215 * Remove a reference to a buffer and set the pointer to NULL.
216 * If this is the last reference to the buffer, the buffer itself
217 * is also automatically freed.
219 * @param ref pointer to the buffer reference
221 void avfilter_unref_bufferp(AVFilterBufferRef **ref);
223 #if FF_API_FILTERS_PUBLIC
225 * A list of supported formats for one end of a filter link. This is used
226 * during the format negotiation process to try to pick the best format to
227 * use to minimize the number of necessary conversions. Each filter gives a
228 * list of the formats supported by each input and output pad. The list
229 * given for each pad need not be distinct - they may be references to the
230 * same list of formats, as is often the case when a filter supports multiple
231 * formats, but will always output the same format as it is given in input.
233 * In this way, a list of possible input formats and a list of possible
234 * output formats are associated with each link. When a set of formats is
235 * negotiated over a link, the input and output lists are merged to form a
236 * new list containing only the common elements of each list. In the case
237 * that there were no common elements, a format conversion is necessary.
238 * Otherwise, the lists are merged, and all other links which reference
239 * either of the format lists involved in the merge are also affected.
241 * For example, consider the filter chain:
242 * filter (a) --> (b) filter (b) --> (c) filter
244 * where the letters in parenthesis indicate a list of formats supported on
245 * the input or output of the link. Suppose the lists are as follows:
250 * First, the first link's lists are merged, yielding:
251 * filter (a) --> (a) filter (a) --> (c) filter
253 * Notice that format list (b) now refers to the same list as filter list (a).
254 * Next, the lists for the second link are merged, yielding:
255 * filter (a) --> (a) filter (a) --> (a) filter
259 * Unfortunately, when the format lists at the two ends of a link are merged,
260 * we must ensure that all links which reference either pre-merge format list
261 * get updated as well. Therefore, we have the format list structure store a
262 * pointer to each of the pointers to itself.
263 * @addtogroup lavfi_deprecated
264 * @deprecated Those functions are only useful inside filters and
265 * user filters are not supported at this point.
268 struct AVFilterFormats {
269 unsigned format_count; ///< number of formats
270 int *formats; ///< list of media formats
272 unsigned refcount; ///< number of references to this list
273 struct AVFilterFormats ***refs; ///< references to this list
277 * Create a list of supported formats. This is intended for use in
278 * AVFilter->query_formats().
280 * @param fmts list of media formats, terminated by -1. If NULL an
281 * empty list is created.
282 * @return the format list, with no existing references
285 AVFilterFormats *avfilter_make_format_list(const int *fmts);
288 * Add fmt to the list of media formats contained in *avff.
289 * If *avff is NULL the function allocates the filter formats struct
290 * and puts its pointer in *avff.
292 * @return a non negative value in case of success, or a negative
293 * value corresponding to an AVERROR code in case of error
294 * @deprecated Use ff_all_formats() instead.
297 int avfilter_add_format(AVFilterFormats **avff, int64_t fmt);
299 AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
302 * Return a list of all formats supported by FFmpeg for the given media type.
304 AVFilterFormats *avfilter_make_all_formats(enum AVMediaType type);
307 * A list of all channel layouts supported by libavfilter.
309 extern const int64_t avfilter_all_channel_layouts[];
313 * Return a list of all audio packing formats.
315 AVFilterFormats *avfilter_make_all_packing_formats(void);
319 * Return a format list which contains the intersection of the formats of
320 * a and b. Also, all the references of a, all the references of b, and
321 * a and b themselves will be deallocated.
323 * If a and b do not share any common formats, neither is modified, and NULL
327 AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
330 * Add *ref as a new reference to formats.
331 * That is the pointers will point like in the ASCII art below:
333 * |formats |<--------.
334 * | ____ | ____|___________________
336 * | |* * | | | | | | AVFilterLink
337 * | |* *--------->|*ref|
338 * | |____| | | |____|
339 * |________| |________________________
342 void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
344 void avfilter_formats_unref(AVFilterFormats **ref);
346 void avfilter_formats_changeref(AVFilterFormats **oldref,
347 AVFilterFormats **newref);
349 * Helpers for query_formats() which set all links to the same list of
350 * formats/layouts. If there are no links hooked to this filter, the list
351 * of formats is freed.
354 void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
357 void avfilter_set_common_pixel_formats(AVFilterContext *ctx, AVFilterFormats *formats);
359 void avfilter_set_common_sample_formats(AVFilterContext *ctx, AVFilterFormats *formats);
361 void avfilter_set_common_channel_layouts(AVFilterContext *ctx, AVFilterFormats *formats);
364 void avfilter_set_common_packing_formats(AVFilterContext *ctx, AVFilterFormats *formats);
372 #if FF_API_AVFILTERPAD_PUBLIC
374 * A filter pad used for either input or output.
376 * See doc/filter_design.txt for details on how to implement the methods.
378 * @warning this struct might be removed from public API.
379 * users should call avfilter_pad_get_name() and avfilter_pad_get_type()
380 * to access the name and type fields; there should be no need to access
381 * any other fields from outside of libavfilter.
385 * Pad name. The name is unique among inputs and among outputs, but an
386 * input may have the same name as an output. This may be NULL if this
387 * pad has no need to ever be referenced by name.
394 enum AVMediaType type;
397 * Minimum required permissions on incoming buffers. Any buffer with
398 * insufficient permissions will be automatically copied by the filter
399 * system to a new buffer which provides the needed access permissions.
406 * Permissions which are not accepted on incoming buffers. Any buffer
407 * which has any of these permissions set will be automatically copied
408 * by the filter system to a new buffer which does not have those
409 * permissions. This can be used to easily disallow buffers with
417 * Callback called before passing the first slice of a new frame. If
418 * NULL, the filter layer will default to storing a reference to the
419 * picture inside the link structure.
421 * Input video pads only.
423 void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
426 * Callback function to get a video buffer. If NULL, the filter system will
427 * use avfilter_default_get_video_buffer().
429 * Input video pads only.
431 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
434 * Callback function to get an audio buffer. If NULL, the filter system will
435 * use avfilter_default_get_audio_buffer().
437 * Input audio pads only.
439 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
443 * Callback called after the slices of a frame are completely sent. If
444 * NULL, the filter layer will default to releasing the reference stored
445 * in the link structure during start_frame().
447 * Input video pads only.
449 void (*end_frame)(AVFilterLink *link);
452 * Slice drawing callback. This is where a filter receives video data
453 * and should do its processing.
455 * Input video pads only.
457 void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
460 * Samples filtering callback. This is where a filter receives audio data
461 * and should do its processing.
463 * Input audio pads only.
465 void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
468 * Frame poll callback. This returns the number of immediately available
469 * samples. It should return a positive value if the next request_frame()
470 * is guaranteed to return one frame (with no delay).
472 * Defaults to just calling the source poll_frame() method.
476 int (*poll_frame)(AVFilterLink *link);
479 * Frame request callback. A call to this should result in at least one
480 * frame being output over the given link. This should return zero on
481 * success, and another value on error.
482 * See ff_request_frame() for the error codes with a specific
487 int (*request_frame)(AVFilterLink *link);
490 * Link configuration callback.
492 * For output pads, this should set the following link properties:
493 * video: width, height, sample_aspect_ratio, time_base
494 * audio: sample_rate.
496 * This should NOT set properties such as format, channel_layout, etc which
497 * are negotiated between filters by the filter system using the
498 * query_formats() callback before this function is called.
500 * For input pads, this should check the properties of the link, and update
501 * the filter's internal state as necessary.
503 * For both input and output pads, this should return zero on success,
504 * and another value on error.
506 int (*config_props)(AVFilterLink *link);
509 * The filter expects a fifo to be inserted on its input link,
510 * typically because it has a delay.
519 * Get the name of an AVFilterPad.
521 * @param pads an array of AVFilterPads
522 * @param pad_idx index of the pad in the array it; is the caller's
523 * responsibility to ensure the index is valid
525 * @return name of the pad_idx'th pad in pads
527 const char *avfilter_pad_get_name(AVFilterPad *pads, int pad_idx);
530 * Get the type of an AVFilterPad.
532 * @param pads an array of AVFilterPads
533 * @param pad_idx index of the pad in the array; it is the caller's
534 * responsibility to ensure the index is valid
536 * @return type of the pad_idx'th pad in pads
538 enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx);
540 /** default handler for end_frame() for video inputs */
542 void avfilter_default_end_frame(AVFilterLink *link);
544 #if FF_API_FILTERS_PUBLIC
545 /** default handler for start_frame() for video inputs */
547 void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
549 /** default handler for draw_slice() for video inputs */
551 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
553 /** default handler for get_video_buffer() for video inputs */
555 AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
556 int perms, int w, int h);
558 /** Default handler for query_formats() */
560 int avfilter_default_query_formats(AVFilterContext *ctx);
563 #if FF_API_FILTERS_PUBLIC
564 /** start_frame() handler for filters which simply pass video along */
566 void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
568 /** draw_slice() handler for filters which simply pass video along */
570 void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
572 /** end_frame() handler for filters which simply pass video along */
574 void avfilter_null_end_frame(AVFilterLink *link);
576 /** get_video_buffer() handler for filters which simply pass video along */
578 AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
579 int perms, int w, int h);
583 * Filter definition. This defines the pads a filter contains, and all the
584 * callback functions used to interact with the filter.
586 typedef struct AVFilter {
587 const char *name; ///< filter name
589 int priv_size; ///< size of private data to allocate for the filter
592 * Filter initialization function. Args contains the user-supplied
593 * parameters. FIXME: maybe an AVOption-based system would be better?
594 * opaque is data provided by the code requesting creation of the filter,
595 * and is used to pass data to the filter.
597 int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
600 * Filter uninitialization function. Should deallocate any memory held
601 * by the filter, release any buffer references, etc. This does not need
602 * to deallocate the AVFilterContext->priv memory itself.
604 void (*uninit)(AVFilterContext *ctx);
607 * Queries formats/layouts supported by the filter and its pads, and sets
608 * the in_formats/in_chlayouts for links connected to its output pads,
609 * and out_formats/out_chlayouts for links connected to its input pads.
611 * @return zero on success, a negative value corresponding to an
612 * AVERROR code otherwise
614 int (*query_formats)(AVFilterContext *);
616 const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none
617 const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
620 * A description for the filter. You should use the
621 * NULL_IF_CONFIG_SMALL() macro to define it.
623 const char *description;
626 * Make the filter instance process a command.
628 * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
629 * @param arg the argument for the command
630 * @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.
631 * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
632 * time consuming then a filter should treat it like an unsupported command
634 * @returns >=0 on success otherwise an error code.
635 * AVERROR(ENOSYS) on unsupported commands
637 int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
640 /** An instance of a filter */
641 struct AVFilterContext {
642 const AVClass *av_class; ///< needed for av_log()
644 AVFilter *filter; ///< the AVFilter of which this is an instance
646 char *name; ///< name of this filter instance
649 unsigned input_count; ///< @deprecated use nb_inputs
651 AVFilterPad *input_pads; ///< array of input pads
652 AVFilterLink **inputs; ///< array of pointers to input links
655 unsigned output_count; ///< @deprecated use nb_outputs
657 AVFilterPad *output_pads; ///< array of output pads
658 AVFilterLink **outputs; ///< array of pointers to output links
660 void *priv; ///< private data for use by the filter
662 unsigned nb_inputs; ///< number of input pads
663 unsigned nb_outputs; ///< number of output pads
665 struct AVFilterCommand *command_queue;
669 enum AVFilterPacking {
676 * A link between two filters. This contains pointers to the source and
677 * destination filters between which this link exists, and the indexes of
678 * the pads involved. In addition, this link also contains the parameters
679 * which have been negotiated and agreed upon between the filter, such as
680 * image dimensions, format, etc.
682 struct AVFilterLink {
683 AVFilterContext *src; ///< source filter
684 AVFilterPad *srcpad; ///< output pad on the source filter
686 AVFilterContext *dst; ///< dest filter
687 AVFilterPad *dstpad; ///< input pad on the dest filter
689 /** stage of the initialization of the link properties (dimensions, etc) */
691 AVLINK_UNINIT = 0, ///< not started
692 AVLINK_STARTINIT, ///< started, but incomplete
693 AVLINK_INIT ///< complete
696 enum AVMediaType type; ///< filter media type
698 /* These parameters apply only to video */
699 int w; ///< agreed upon image width
700 int h; ///< agreed upon image height
701 AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
702 /* These parameters apply only to audio */
703 uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h)
704 #if FF_API_SAMPLERATE64
705 int64_t sample_rate; ///< samples per second
707 int sample_rate; ///< samples per second
710 int planar; ///< agreed upon packing mode of audio buffers. true if planar.
713 int format; ///< agreed upon media format
716 * Lists of formats and channel layouts supported by the input and output
717 * filters respectively. These lists are used for negotiating the format
718 * to actually be used, which will be loaded into the format and
719 * channel_layout members, above, when chosen.
722 AVFilterFormats *in_formats;
723 AVFilterFormats *out_formats;
726 AVFilterFormats *in_packing;
727 AVFilterFormats *out_packing;
731 * The buffer reference currently being sent across the link by the source
732 * filter. This is used internally by the filter system to allow
733 * automatic copying of buffers which do not have sufficient permissions
734 * for the destination. This should not be accessed directly by the
737 AVFilterBufferRef *src_buf;
739 AVFilterBufferRef *cur_buf;
740 AVFilterBufferRef *out_buf;
743 * Define the time base used by the PTS of the frames/samples
744 * which will pass through this link.
745 * During the configuration stage, each filter is supposed to
746 * change only the output timebase, while the timebase of the
747 * input link is assumed to be an unchangeable property.
749 AVRational time_base;
751 /*****************************************************************
752 * All fields below this line are not part of the public API. They
753 * may not be used outside of libavfilter and can be changed and
755 * New public fields should be added right above.
756 *****************************************************************
759 * Lists of channel layouts and sample rates used for automatic
762 AVFilterFormats *in_samplerates;
763 AVFilterFormats *out_samplerates;
764 struct AVFilterChannelLayouts *in_channel_layouts;
765 struct AVFilterChannelLayouts *out_channel_layouts;
768 * Audio only, the destination filter sets this to a non-zero value to
769 * request that buffers with the given number of samples should be sent to
770 * it. AVFilterPad.needs_fifo must also be set on the corresponding input
772 * Last buffer before EOF will be padded with silence.
776 struct AVFilterPool *pool;
779 * Graph the filter belongs to.
781 struct AVFilterGraph *graph;
784 * Current timestamp of the link, as defined by the most recent
785 * frame(s), in AV_TIME_BASE units.
790 * Index in the age array.
795 * Frame rate of the stream on the link, or 1/0 if unknown;
796 * if left to 0/0, will be automatically be copied from the first input
797 * of the source filter if it exists.
799 * Sources should set it to the best estimation of the real frame rate.
800 * Filters should update it if necessary depending on their function.
801 * Sinks can use it to set a default output frame rate.
802 * It is similar to the r_frae_rate field in AVStream.
804 AVRational frame_rate;
808 * Link two filters together.
810 * @param src the source filter
811 * @param srcpad index of the output pad on the source filter
812 * @param dst the destination filter
813 * @param dstpad index of the input pad on the destination filter
814 * @return zero on success
816 int avfilter_link(AVFilterContext *src, unsigned srcpad,
817 AVFilterContext *dst, unsigned dstpad);
820 * Free the link in *link, and set its pointer to NULL.
822 void avfilter_link_free(AVFilterLink **link);
825 * Negotiate the media format, dimensions, etc of all inputs to a filter.
827 * @param filter the filter to negotiate the properties for its inputs
828 * @return zero on successful negotiation
830 int avfilter_config_links(AVFilterContext *filter);
832 #if FF_API_FILTERS_PUBLIC
834 AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
839 * Create a buffer reference wrapped around an already allocated image
842 * @param data pointers to the planes of the image to reference
843 * @param linesize linesizes for the planes of the image to reference
844 * @param perms the required access permissions
845 * @param w the width of the image specified by the data and linesize arrays
846 * @param h the height of the image specified by the data and linesize arrays
847 * @param format the pixel format of the image specified by the data and linesize arrays
850 avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
851 int w, int h, enum PixelFormat format);
854 * Create an audio buffer reference wrapped around an already
855 * allocated samples buffer.
857 * @param data pointers to the samples plane buffers
858 * @param linesize linesize for the samples plane buffers
859 * @param perms the required access permissions
860 * @param nb_samples number of samples per channel
861 * @param sample_fmt the format of each sample in the buffer to allocate
862 * @param channel_layout the channel layout of the buffer
864 AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
868 enum AVSampleFormat sample_fmt,
869 uint64_t channel_layout);
871 #if FF_API_FILTERS_PUBLIC
873 * Request an input frame from the filter at the other end of the link.
875 * @param link the input link
876 * @return zero on success or a negative error code; in particular:
877 * AVERROR_EOF means that the end of frames have been reached;
878 * AVERROR(EAGAIN) means that no frame could be immediately
881 int avfilter_request_frame(AVFilterLink *link);
884 int avfilter_poll_frame(AVFilterLink *link);
887 void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
890 * Notify the next filter that the current frame has finished.
892 * @param link the output link the frame was sent over
895 void avfilter_end_frame(AVFilterLink *link);
897 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
900 #define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
901 #define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
904 * Make the filter instance process a command.
905 * It is recommended to use avfilter_graph_send_command().
907 int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
909 /** Initialize the filter system. Register all builtin filters. */
910 void avfilter_register_all(void);
912 /** Uninitialize the filter system. Unregister all filters. */
913 void avfilter_uninit(void);
916 * Register a filter. This is only needed if you plan to use
917 * avfilter_get_by_name later to lookup the AVFilter structure by name. A
918 * filter can still by instantiated with avfilter_open even if it is not
921 * @param filter the filter to register
922 * @return 0 if the registration was successful, a negative value
925 int avfilter_register(AVFilter *filter);
928 * Get a filter definition matching the given name.
930 * @param name the filter name to find
931 * @return the filter definition, if any matching one is registered.
932 * NULL if none found.
934 AVFilter *avfilter_get_by_name(const char *name);
937 * If filter is NULL, returns a pointer to the first registered filter pointer,
938 * if filter is non-NULL, returns the next pointer after filter.
939 * If the returned pointer points to NULL, the last registered filter
940 * was already reached.
942 AVFilter **av_filter_next(AVFilter **filter);
945 * Create a filter instance.
947 * @param filter_ctx put here a pointer to the created filter context
948 * on success, NULL on failure
949 * @param filter the filter to create an instance of
950 * @param inst_name Name to give to the new instance. Can be NULL for none.
951 * @return >= 0 in case of success, a negative error code otherwise
953 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
956 * Initialize a filter.
958 * @param filter the filter to initialize
959 * @param args A string of parameters to use when initializing the filter.
960 * The format and meaning of this string varies by filter.
961 * @param opaque Any extra non-string data needed by the filter. The meaning
962 * of this parameter varies by filter.
963 * @return zero on success
965 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
968 * Free a filter context.
970 * @param filter the filter to free
972 void avfilter_free(AVFilterContext *filter);
975 * Insert a filter in the middle of an existing link.
977 * @param link the link into which the filter should be inserted
978 * @param filt the filter to be inserted
979 * @param filt_srcpad_idx the input pad on the filter to connect
980 * @param filt_dstpad_idx the output pad on the filter to connect
981 * @return zero on success
983 int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
984 unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
986 #if FF_API_FILTERS_PUBLIC
988 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
989 AVFilterPad **pads, AVFilterLink ***links,
990 AVFilterPad *newpad);
993 void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
996 void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
1000 #endif /* AVFILTER_AVFILTER_H */