2 * Filters implementation helper functions
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVFILTER_FILTERS_H
22 #define AVFILTER_FILTERS_H
25 * Filters implementation helper functions and internal structures
31 * Special return code when activate() did not do anything.
33 #define FFERROR_NOT_READY FFERRTAG('N','R','D','Y')
36 * A filter pad used for either input or output.
40 * Pad name. The name is unique among inputs and among outputs, but an
41 * input may have the same name as an output. This may be NULL if this
42 * pad has no need to ever be referenced by name.
49 enum AVMediaType type
;
52 * The filter expects writable frames from its input link,
53 * duplicating data buffers if needed.
57 #define AVFILTERPAD_FLAG_NEEDS_WRITABLE (1 << 0)
60 * The pad's name is allocated and should be freed generically.
62 #define AVFILTERPAD_FLAG_FREE_NAME (1 << 1)
65 * A combination of AVFILTERPAD_FLAG_* flags.
70 * Callback functions to get a video/audio buffers. If NULL,
71 * the filter system will use ff_default_get_video_buffer() for video
72 * and ff_default_get_audio_buffer() for audio.
74 * The state of the union is determined by type.
79 AVFrame
*(*video
)(AVFilterLink
*link
, int w
, int h
);
80 AVFrame
*(*audio
)(AVFilterLink
*link
, int nb_samples
);
84 * Filtering callback. This is where a filter receives a frame with
85 * audio/video data and should do its processing.
89 * @return >= 0 on success, a negative AVERROR on error. This function
90 * must ensure that frame is properly unreferenced on error if it
91 * hasn't been passed on to another filter.
93 int (*filter_frame
)(AVFilterLink
*link
, AVFrame
*frame
);
96 * Frame request callback. A call to this should result in some progress
97 * towards producing output over the given link. This should return zero
98 * on success, and another value on error.
102 int (*request_frame
)(AVFilterLink
*link
);
105 * Link configuration callback.
107 * For output pads, this should set the link properties such as
108 * width/height. This should NOT set the format property - that is
109 * negotiated between filters by the filter system using the
110 * query_formats() callback before this function is called.
112 * For input pads, this should check the properties of the link, and update
113 * the filter's internal state as necessary.
115 * For both input and output filters, this should return zero on success,
116 * and another value on error.
118 int (*config_props
)(AVFilterLink
*link
);
122 * Link properties exposed to filter code, but not external callers.
124 * Cf. AVFilterLink for public properties, FilterLinkInternal for
125 * properties private to the generic layer.
127 typedef struct FilterLink
{
131 * Graph the filter belongs to.
133 struct AVFilterGraph
*graph
;
136 * Current timestamp of the link, as defined by the most recent
137 * frame(s), in link time_base units.
142 * Current timestamp of the link, as defined by the most recent
143 * frame(s), in AV_TIME_BASE units.
145 int64_t current_pts_us
;
148 * Minimum number of samples to filter at once.
150 * May be set by the link destination filter in its config_props().
151 * If 0, all related fields are ignored.
156 * Maximum number of samples to filter at once. If filter_frame() is
157 * called with more samples, it will split them.
159 * May be set by the link destination filter in its config_props().
164 * Number of past frames sent through the link.
166 int64_t frame_count_in
, frame_count_out
;
169 * Number of past samples sent through the link.
171 int64_t sample_count_in
, sample_count_out
;
174 * Frame rate of the stream on the link, or 1/0 if unknown or variable.
176 * May be set by the link source filter in its config_props(); if left to
177 * 0/0, will be automatically copied from the first input of the source
178 * filter if it exists.
180 * Sources should set it to the best estimation of the real frame rate.
181 * If the source frame rate is unknown or variable, set this to 1/0.
182 * Filters should update it if necessary depending on their function.
183 * Sinks can use it to set a default output frame rate.
184 * It is similar to the r_frame_rate field in AVStream.
186 AVRational frame_rate
;
189 * For hwaccel pixel formats, this should be a reference to the
190 * AVHWFramesContext describing the frames.
192 * May be set by the link source filter in its config_props().
194 AVBufferRef
*hw_frames_ctx
;
197 static inline FilterLink
* ff_filter_link(AVFilterLink
*link
)
199 return (FilterLink
*)link
;
203 * The filter is aware of hardware frames, and any hardware frame context
204 * should not be automatically propagated through it.
206 #define FF_FILTER_FLAG_HWFRAME_AWARE (1 << 0)
209 * Find the index of a link.
211 * I.e. find i such that link == ctx->(in|out)puts[i]
213 #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
214 #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
216 enum FilterFormatsState
{
218 * The default value meaning that this filter supports all formats
219 * and (for audio) sample rates and channel layouts/counts as long
220 * as these properties agree for all inputs and outputs.
221 * This state is only allowed in case all inputs and outputs actually
222 * have the same type.
223 * The union is unused in this state.
225 * This value must always be zero (for default static initialization).
227 FF_FILTER_FORMATS_PASSTHROUGH
= 0,
228 FF_FILTER_FORMATS_QUERY_FUNC
, ///< formats.query active.
229 FF_FILTER_FORMATS_QUERY_FUNC2
, ///< formats.query_func2 active.
230 FF_FILTER_FORMATS_PIXFMT_LIST
, ///< formats.pixels_list active.
231 FF_FILTER_FORMATS_SAMPLEFMTS_LIST
, ///< formats.samples_list active.
232 FF_FILTER_FORMATS_SINGLE_PIXFMT
, ///< formats.pix_fmt active
233 FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
, ///< formats.sample_fmt active.
236 #define FILTER_QUERY_FUNC(func) \
237 .formats.query_func = func, \
238 .formats_state = FF_FILTER_FORMATS_QUERY_FUNC
239 #define FILTER_QUERY_FUNC2(func) \
240 .formats.query_func2 = func, \
241 .formats_state = FF_FILTER_FORMATS_QUERY_FUNC2
242 #define FILTER_PIXFMTS_ARRAY(array) \
243 .formats.pixels_list = array, \
244 .formats_state = FF_FILTER_FORMATS_PIXFMT_LIST
245 #define FILTER_SAMPLEFMTS_ARRAY(array) \
246 .formats.samples_list = array, \
247 .formats_state = FF_FILTER_FORMATS_SAMPLEFMTS_LIST
248 #define FILTER_PIXFMTS(...) \
249 FILTER_PIXFMTS_ARRAY(((const enum AVPixelFormat []) { __VA_ARGS__, AV_PIX_FMT_NONE }))
250 #define FILTER_SAMPLEFMTS(...) \
251 FILTER_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE }))
252 #define FILTER_SINGLE_PIXFMT(pix_fmt_) \
253 .formats.pix_fmt = pix_fmt_, \
254 .formats_state = FF_FILTER_FORMATS_SINGLE_PIXFMT
255 #define FILTER_SINGLE_SAMPLEFMT(sample_fmt_) \
256 .formats.sample_fmt = sample_fmt_, \
257 .formats_state = FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
259 #define FILTER_INOUTPADS(inout, array) \
261 .nb_ ## inout = FF_ARRAY_ELEMS(array)
262 #define FILTER_INPUTS(array) FILTER_INOUTPADS(inputs, (array))
263 #define FILTER_OUTPUTS(array) FILTER_INOUTPADS(outputs, (array))
265 typedef struct FFFilter
{
267 * The public AVFilter. See avfilter.h for it.
272 * The number of entries in the list of inputs.
277 * The number of entries in the list of outputs.
282 * This field determines the state of the formats union.
283 * It is an enum FilterFormatsState value.
285 uint8_t formats_state
;
288 * Filter pre-initialization function
290 * This callback will be called immediately after the filter context is
291 * allocated, to allow allocating and initing sub-objects.
293 * If this callback is not NULL, the uninit callback will be called on
294 * allocation failure.
296 * @return 0 on success,
297 * AVERROR code on failure (but the code will be
298 * dropped and treated as ENOMEM by the calling code)
300 int (*preinit
)(AVFilterContext
*ctx
);
303 * Filter initialization function.
305 * This callback will be called only once during the filter lifetime, after
306 * all the options have been set, but before links between filters are
307 * established and format negotiation is done.
309 * Basic filter initialization should be done here. Filters with dynamic
310 * inputs and/or outputs should create those inputs/outputs here based on
311 * provided options. No more changes to this filter's inputs/outputs can be
312 * done after this callback.
314 * This callback must not assume that the filter links exist or frame
315 * parameters are known.
317 * @ref AVFilter.uninit "uninit" is guaranteed to be called even if
318 * initialization fails, so this callback does not have to clean up on
321 * @return 0 on success, a negative AVERROR on failure
323 int (*init
)(AVFilterContext
*ctx
);
326 * Filter uninitialization function.
328 * Called only once right before the filter is freed. Should deallocate any
329 * memory held by the filter, release any buffer references, etc. It does
330 * not need to deallocate the AVFilterContext.priv memory itself.
332 * This callback may be called even if @ref AVFilter.init "init" was not
333 * called or failed, so it must be prepared to handle such a situation.
335 void (*uninit
)(AVFilterContext
*ctx
);
338 * The state of the following union is determined by formats_state.
339 * See the documentation of enum FilterFormatsState in internal.h.
343 * Query formats supported by the filter on its inputs and outputs.
345 * This callback is called after the filter is initialized (so the inputs
346 * and outputs are fixed), shortly before the format negotiation. This
347 * callback may be called more than once.
349 * This callback must set ::AVFilterLink's
350 * @ref AVFilterFormatsConfig.formats "outcfg.formats"
351 * on every input link and
352 * @ref AVFilterFormatsConfig.formats "incfg.formats"
353 * on every output link to a list of pixel/sample formats that the filter
354 * supports on that link.
355 * For video links, this filter may also set
356 * @ref AVFilterFormatsConfig.color_spaces "incfg.color_spaces"
358 * @ref AVFilterFormatsConfig.color_spaces "outcfg.color_spaces"
359 * and @ref AVFilterFormatsConfig.color_ranges "incfg.color_ranges"
361 * @ref AVFilterFormatsConfig.color_ranges "outcfg.color_ranges"
363 * For audio links, this filter must also set
364 * @ref AVFilterFormatsConfig.samplerates "incfg.samplerates"
366 * @ref AVFilterFormatsConfig.samplerates "outcfg.samplerates"
367 * and @ref AVFilterFormatsConfig.channel_layouts "incfg.channel_layouts"
369 * @ref AVFilterFormatsConfig.channel_layouts "outcfg.channel_layouts"
372 * This callback must never be NULL if the union is in this state.
374 * @return zero on success, a negative value corresponding to an
375 * AVERROR code otherwise
377 int (*query_func
)(AVFilterContext
*);
380 * Same as query_func(), except this function writes the results into
383 * @param cfg_in array of input format configurations with as many
384 * members as the filters has inputs (NULL when there are
386 * @param cfg_out array of output format configurations with as many
387 * members as the filters has outputs (NULL when there
390 int (*query_func2
)(const AVFilterContext
*,
391 struct AVFilterFormatsConfig
**cfg_in
,
392 struct AVFilterFormatsConfig
**cfg_out
);
394 * A pointer to an array of admissible pixel formats delimited
395 * by AV_PIX_FMT_NONE. The generic code will use this list
396 * to indicate that this filter supports each of these pixel formats,
397 * provided that all inputs and outputs use the same pixel format.
399 * In addition to that the generic code will mark all inputs
400 * and all outputs as supporting all color spaces and ranges, as
401 * long as all inputs and outputs use the same color space/range.
403 * This list must never be NULL if the union is in this state.
404 * The type of all inputs and outputs of filters using this must
405 * be AVMEDIA_TYPE_VIDEO.
407 const enum AVPixelFormat
*pixels_list
;
409 * Analogous to pixels, but delimited by AV_SAMPLE_FMT_NONE
410 * and restricted to filters that only have AVMEDIA_TYPE_AUDIO
411 * inputs and outputs.
413 * In addition to that the generic code will mark all inputs
414 * and all outputs as supporting all sample rates and every
415 * channel count and channel layout, as long as all inputs
416 * and outputs use the same sample rate and channel count/layout.
418 const enum AVSampleFormat
*samples_list
;
420 * Equivalent to { pix_fmt, AV_PIX_FMT_NONE } as pixels_list.
422 enum AVPixelFormat pix_fmt
;
424 * Equivalent to { sample_fmt, AV_SAMPLE_FMT_NONE } as samples_list.
426 enum AVSampleFormat sample_fmt
;
429 int priv_size
; ///< size of private data to allocate for the filter
431 int flags_internal
; ///< Additional flags for avfilter internal use only.
434 * Make the filter instance process a command.
436 * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
437 * @param arg the argument for the command
438 * @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.
439 * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
440 * time consuming then a filter should treat it like an unsupported command
442 * @returns >=0 on success otherwise an error code.
443 * AVERROR(ENOSYS) on unsupported commands
445 int (*process_command
)(AVFilterContext
*, const char *cmd
, const char *arg
, char *res
, int res_len
, int flags
);
448 * Filter activation function.
450 * Called when any processing is needed from the filter, instead of any
451 * filter_frame and request_frame on pads.
453 * The function must examine inlinks and outlinks and perform a single
454 * step of processing. If there is nothing to do, the function must do
455 * nothing and not return an error. If more steps are or may be
456 * possible, it must use ff_filter_set_ready() to schedule another
459 int (*activate
)(AVFilterContext
*ctx
);
462 static inline const FFFilter
*fffilter(const AVFilter
*f
)
464 return (const FFFilter
*)f
;
468 #define AVFILTER_DEFINE_CLASS_EXT(name, desc, options) \
469 static const AVClass name##_class = { \
470 .class_name = desc, \
471 .item_name = av_default_item_name, \
473 .version = LIBAVUTIL_VERSION_INT, \
474 .category = AV_CLASS_CATEGORY_FILTER, \
476 #define AVFILTER_DEFINE_CLASS(fname) \
477 AVFILTER_DEFINE_CLASS_EXT(fname, #fname, fname##_options)
479 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
480 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
481 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
484 * Mark a filter ready and schedule it for activation.
486 * This is automatically done when something happens to the filter (queued
487 * frame, status change, request on output).
488 * Filters implementing the activate callback can call it directly to
489 * perform one more round of processing later.
490 * It is also useful for filters reacting to external or asynchronous
493 void ff_filter_set_ready(AVFilterContext
*filter
, unsigned priority
);
496 * Get the number of frames available on the link.
497 * @return the number of frames available in the link fifo.
499 size_t ff_inlink_queued_frames(AVFilterLink
*link
);
502 * Test if a frame is available on the link.
503 * @return >0 if a frame is available
505 int ff_inlink_check_available_frame(AVFilterLink
*link
);
509 * Get the number of samples available on the link.
510 * @return the numer of samples available on the link.
512 int ff_inlink_queued_samples(AVFilterLink
*link
);
515 * Test if enough samples are available on the link.
516 * @return >0 if enough samples are available
517 * @note on EOF and error, min becomes 1
519 int ff_inlink_check_available_samples(AVFilterLink
*link
, unsigned min
);
522 * Take a frame from the link's FIFO and update the link's stats.
524 * If ff_inlink_check_available_frame() was previously called, the
525 * preferred way of expressing it is "av_assert1(ret);" immediately after
526 * ff_inlink_consume_frame(). Negative error codes must still be checked.
528 * @note May trigger process_command() and/or update is_disabled.
529 * @return >0 if a frame is available,
530 * 0 and set rframe to NULL if no frame available,
533 int ff_inlink_consume_frame(AVFilterLink
*link
, AVFrame
**rframe
);
536 * Take samples from the link's FIFO and update the link's stats.
538 * If ff_inlink_check_available_samples() was previously called, the
539 * preferred way of expressing it is "av_assert1(ret);" immediately after
540 * ff_inlink_consume_samples(). Negative error codes must still be checked.
542 * @note May trigger process_command() and/or update is_disabled.
543 * @return >0 if a frame is available,
544 * 0 and set rframe to NULL if no frame available,
547 int ff_inlink_consume_samples(AVFilterLink
*link
, unsigned min
, unsigned max
,
551 * Access a frame in the link fifo without consuming it.
552 * The first frame is numbered 0; the designated frame must exist.
553 * @return the frame at idx position in the link fifo.
555 AVFrame
*ff_inlink_peek_frame(AVFilterLink
*link
, size_t idx
);
558 * Make sure a frame is writable.
559 * This is similar to av_frame_make_writable() except it uses the link's
560 * buffer allocation callback, and therefore allows direct rendering.
562 int ff_inlink_make_frame_writable(AVFilterLink
*link
, AVFrame
**rframe
);
565 * Test and acknowledge the change of status on the link.
567 * Status means EOF or an error condition; a change from the normal (0)
568 * status to a non-zero status can be queued in a filter's input link, it
569 * becomes relevant after the frames queued in the link's FIFO are
570 * processed. This function tests if frames are still queued and if a queued
571 * status change has not yet been processed. In that case it performs basic
572 * treatment (updating the link's timestamp) and returns a positive value to
573 * let the filter do its own treatments (flushing...).
575 * Filters implementing the activate callback should call this function when
576 * they think it might succeed (usually after checking unsuccessfully for a
578 * Filters implementing the filter_frame and request_frame callbacks do not
579 * need to call that since the same treatment happens in ff_filter_frame().
581 * @param[out] rstatus new or current status
582 * @param[out] rpts current timestamp of the link in link time base
583 * @return >0 if status changed, <0 if status already acked, 0 otherwise
585 int ff_inlink_acknowledge_status(AVFilterLink
*link
, int *rstatus
, int64_t *rpts
);
588 * Mark that a frame is wanted on the link.
589 * Unlike ff_filter_frame(), it must not be called when the link has a
590 * non-zero status, and thus does not acknowledge it.
591 * Also it cannot fail.
593 void ff_inlink_request_frame(AVFilterLink
*link
);
596 * Set the status on an input link.
597 * Also discard all frames in the link's FIFO.
599 void ff_inlink_set_status(AVFilterLink
*link
, int status
);
602 * Test if a frame is wanted on an output link.
604 int ff_outlink_frame_wanted(AVFilterLink
*link
);
607 * Get the status on an output link.
609 int ff_outlink_get_status(AVFilterLink
*link
);
612 * Set the status field of a link from the source filter.
613 * The pts should reflect the timestamp of the status change,
614 * in link time base and relative to the frames timeline.
615 * In particular, for AVERROR_EOF, it should reflect the
616 * end time of the last frame.
618 void ff_avfilter_link_set_in_status(AVFilterLink
*link
, int status
, int64_t pts
);
621 * Set the status field of a link from the source filter.
622 * The pts should reflect the timestamp of the status change,
623 * in link time base and relative to the frames timeline.
624 * In particular, for AVERROR_EOF, it should reflect the
625 * end time of the last frame.
627 static inline void ff_outlink_set_status(AVFilterLink
*link
, int status
, int64_t pts
)
629 ff_avfilter_link_set_in_status(link
, status
, pts
);
633 * Forward the status on an output link to an input link.
634 * If the status is set, it will discard all queued frames and this macro
635 * will return immediately.
637 #define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink) do { \
638 int ret = ff_outlink_get_status(outlink); \
640 ff_inlink_set_status(inlink, ret); \
646 * Forward the status on an output link to all input links.
647 * If the status is set, it will discard all queued frames and this macro
648 * will return immediately.
650 #define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter) do { \
651 int ret = ff_outlink_get_status(outlink); \
654 for (i = 0; i < filter->nb_inputs; i++) \
655 ff_inlink_set_status(filter->inputs[i], ret); \
661 * Acknowledge the status on an input link and forward it to an output link.
662 * If the status is set, this macro will return immediately.
664 #define FF_FILTER_FORWARD_STATUS(inlink, outlink) do { \
667 if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
668 ff_outlink_set_status(outlink, status, pts); \
674 * Acknowledge the status on an input link and forward it to an output link.
675 * If the status is set, this macro will return immediately.
677 #define FF_FILTER_FORWARD_STATUS_ALL(inlink, filter) do { \
680 if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
682 for (i = 0; i < filter->nb_outputs; i++) \
683 ff_outlink_set_status(filter->outputs[i], status, pts); \
689 * Forward the frame_wanted_out flag from an output link to an input link.
690 * If the flag is set, this macro will return immediately.
692 #define FF_FILTER_FORWARD_WANTED(outlink, inlink) do { \
693 if (ff_outlink_frame_wanted(outlink)) { \
694 ff_inlink_request_frame(inlink); \
700 * Check for flow control between input and output.
701 * This is necessary for filters that may produce several output frames for
702 * a single input event, otherwise they may produce them all at once,
703 * causing excessive memory consumption.
705 int ff_inoutlink_check_flow(AVFilterLink
*inlink
, AVFilterLink
*outlink
);
708 * Perform any additional setup required for hardware frames.
710 * link->hw_frames_ctx must be set before calling this function.
711 * Inside link->hw_frames_ctx, the fields format, sw_format, width and
712 * height must be set. If dynamically allocated pools are not supported,
713 * then initial_pool_size must also be set, to the minimum hardware frame
714 * pool size necessary for the filter to work (taking into account any
715 * frames which need to stored for use in operations as appropriate). If
716 * default_pool_size is nonzero, then it will be used as the pool size if
717 * no other modification takes place (this can be used to preserve
720 int ff_filter_init_hw_frames(AVFilterContext
*avctx
, AVFilterLink
*link
,
721 int default_pool_size
);
724 * Generic processing of user supplied commands that are set
725 * in the same way as the filter options.
726 * NOTE: 'enable' option is handled separately, and not by
729 int ff_filter_process_command(AVFilterContext
*ctx
, const char *cmd
,
730 const char *arg
, char *res
, int res_len
, int flags
);
733 * Get number of threads for current filter instance.
734 * This number is always same or less than graph->nb_threads.
736 int ff_filter_get_nb_threads(AVFilterContext
*ctx
) av_pure
;
739 * Send a frame of data to the next filter.
741 * @param link the output link over which the data is being sent
742 * @param frame a reference to the buffer of data being sent. The
743 * receiving filter will free this reference when it no longer
744 * needs it or pass it on to the next filter.
746 * @return >= 0 on success, a negative AVERROR on error. The receiving filter
747 * is responsible for unreferencing frame in case of error.
749 int ff_filter_frame(AVFilterLink
*link
, AVFrame
*frame
);
752 * Request an input frame from the filter at the other end of the link.
754 * This function must not be used by filters using the activate callback,
755 * use ff_link_set_frame_wanted() instead.
757 * The input filter may pass the request on to its inputs, fulfill the
758 * request from an internal buffer or any other means specific to its function.
760 * When the end of a stream is reached AVERROR_EOF is returned and no further
761 * frames are returned after that.
763 * When a filter is unable to output a frame for example due to its sources
764 * being unable to do so or because it depends on external means pushing data
765 * into it then AVERROR(EAGAIN) is returned.
766 * It is important that a AVERROR(EAGAIN) return is returned all the way to the
767 * caller (generally eventually a user application) as this step may (but does
768 * not have to be) necessary to provide the input with the next frame.
770 * If a request is successful then some progress has been made towards
771 * providing a frame on the link (through ff_filter_frame()). A filter that
772 * needs several frames to produce one is allowed to return success if one
773 * more frame has been processed but no output has been produced yet. A
774 * filter is also allowed to simply forward a success return value.
776 * @param link the input link
777 * @return zero on success
778 * AVERROR_EOF on end of file
779 * AVERROR(EAGAIN) if the previous filter cannot output a frame
780 * currently and can neither guarantee that EOF has been reached.
782 int ff_request_frame(AVFilterLink
*link
);
785 * Append a new input/output pad to the filter's list of such pads.
787 * The *_free_name versions will set the AVFILTERPAD_FLAG_FREE_NAME flag
788 * ensuring that the name will be freed generically (even on insertion error).
790 int ff_append_inpad (AVFilterContext
*f
, AVFilterPad
*p
);
791 int ff_append_outpad(AVFilterContext
*f
, AVFilterPad
*p
);
792 int ff_append_inpad_free_name (AVFilterContext
*f
, AVFilterPad
*p
);
793 int ff_append_outpad_free_name(AVFilterContext
*f
, AVFilterPad
*p
);
796 * Tell if an integer is contained in the provided -1-terminated list of integers.
797 * This is useful for determining (for instance) if an AVPixelFormat is in an
798 * array of supported formats.
800 * @param fmt provided format
801 * @param fmts -1-terminated list of formats
802 * @return 1 if present, 0 if absent
804 int ff_fmt_is_in(int fmt
, const int *fmts
);
806 int ff_filter_execute(AVFilterContext
*ctx
, avfilter_action_func
*func
,
807 void *arg
, int *ret
, int nb_jobs
);
809 #endif /* AVFILTER_FILTERS_H */