FFmpeg
Macros | Enumerations | Functions | Variables
avfilter.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/frame.h"
#include "libavutil/hwcontext.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/samplefmt.h"
#include "framequeue.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "framepool.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Macros

#define FF_INTERNAL_FIELDS   1
 
#define OFFSET(x)   offsetof(AVFilterContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM
 
#define TFLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Enumerations

enum  {
  VAR_T, VAR_N, VAR_W, VAR_H,
  VAR_VARS_NB
}
 

Functions

static void tlog_ref (void *ctx, AVFrame *ref, int end)
 
static void command_queue_pop (AVFilterContext *filter)
 
static int append_pad (unsigned *count, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
 Append a new pad. More...
 
int ff_append_inpad (AVFilterContext *f, AVFilterPad *p)
 Append a new input/output pad to the filter's list of such pads. More...
 
int ff_append_inpad_free_name (AVFilterContext *f, AVFilterPad *p)
 
int ff_append_outpad (AVFilterContext *f, AVFilterPad *p)
 
int ff_append_outpad_free_name (AVFilterContext *f, AVFilterPad *p)
 
int avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
 Link two filters together. More...
 
void avfilter_link_free (AVFilterLink **link)
 Free the link in *link, and set its pointer to NULL. More...
 
static void update_link_current_pts (AVFilterLink *link, int64_t pts)
 
void ff_filter_set_ready (AVFilterContext *filter, unsigned priority)
 Mark a filter ready and schedule it for activation. More...
 
static void filter_unblock (AVFilterContext *filter)
 Clear frame_blocked_in on all outputs. More...
 
void ff_avfilter_link_set_in_status (AVFilterLink *link, int status, int64_t pts)
 Set the status field of a link from the source filter. More...
 
static void link_set_out_status (AVFilterLink *link, int status, int64_t pts)
 Set the status field of a link from the destination filter. More...
 
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. More...
 
int avfilter_config_links (AVFilterContext *filter)
 Negotiate the media format, dimensions, etc of all inputs to a filter. More...
 
int ff_request_frame (AVFilterLink *link)
 Request an input frame from the filter at the other end of the link. More...
 
static int64_t guess_status_pts (AVFilterContext *ctx, int status, AVRational link_time_base)
 
static int ff_request_frame_to_filter (AVFilterLink *link)
 
static int set_enable_expr (AVFilterContext *ctx, const char *expr)
 
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. More...
 
unsigned avfilter_filter_pad_count (const AVFilter *filter, int is_output)
 Get the number of elements in an AVFilter's inputs or outputs array. More...
 
static const char * default_filter_name (void *filter_ctx)
 
static void * filter_child_next (void *obj, void *prev)
 
static const AVClassfilter_child_class_iterate (void **iter)
 
static int default_execute (AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
 
AVFilterContextff_filter_alloc (const AVFilter *filter, const char *inst_name)
 Allocate a new filter context and return it. More...
 
static void free_link (AVFilterLink *link)
 
void avfilter_free (AVFilterContext *filter)
 Free a filter context. More...
 
int ff_filter_get_nb_threads (AVFilterContext *ctx)
 Get number of threads for current filter instance. More...
 
int ff_filter_opt_parse (void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
 Parse filter options into a dictionary. More...
 
int ff_filter_process_command (AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
 Generic processing of user supplied commands that are set in the same way as the filter options. More...
 
int avfilter_init_dict (AVFilterContext *ctx, AVDictionary **options)
 Initialize a filter with the supplied dictionary of options. More...
 
int avfilter_init_str (AVFilterContext *filter, const char *args)
 Initialize a filter with the supplied parameters. More...
 
const char * avfilter_pad_get_name (const AVFilterPad *pads, int pad_idx)
 Get the name of an AVFilterPad. More...
 
enum AVMediaType avfilter_pad_get_type (const AVFilterPad *pads, int pad_idx)
 Get the type of an AVFilterPad. More...
 
static int default_filter_frame (AVFilterLink *link, AVFrame *frame)
 
static int ff_filter_frame_framed (AVFilterLink *link, AVFrame *frame)
 
int ff_filter_frame (AVFilterLink *link, AVFrame *frame)
 Send a frame of data to the next filter. More...
 
static int samples_ready (AVFilterLink *link, unsigned min)
 
static int take_samples (AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
 
static int ff_filter_frame_to_filter (AVFilterLink *link)
 
static int forward_status_change (AVFilterContext *filter, AVFilterLink *in)
 
static int ff_filter_activate_default (AVFilterContext *filter)
 
int ff_filter_activate (AVFilterContext *filter)
 
int ff_inlink_acknowledge_status (AVFilterLink *link, int *rstatus, int64_t *rpts)
 Test and acknowledge the change of status on the link. More...
 
size_t ff_inlink_queued_frames (AVFilterLink *link)
 Get the number of frames available on the link. More...
 
int ff_inlink_check_available_frame (AVFilterLink *link)
 Test if a frame is available on the link. More...
 
int ff_inlink_queued_samples (AVFilterLink *link)
 
int ff_inlink_check_available_samples (AVFilterLink *link, unsigned min)
 Test if enough samples are available on the link. More...
 
static void consume_update (AVFilterLink *link, const AVFrame *frame)
 
int ff_inlink_consume_frame (AVFilterLink *link, AVFrame **rframe)
 Take a frame from the link's FIFO and update the link's stats. More...
 
int ff_inlink_consume_samples (AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
 Take samples from the link's FIFO and update the link's stats. More...
 
AVFrameff_inlink_peek_frame (AVFilterLink *link, size_t idx)
 Access a frame in the link fifo without consuming it. More...
 
int ff_inlink_make_frame_writable (AVFilterLink *link, AVFrame **rframe)
 Make sure a frame is writable. More...
 
int ff_inlink_process_commands (AVFilterLink *link, const AVFrame *frame)
 Process the commands queued in the link up to the time of the frame. More...
 
int ff_inlink_evaluate_timeline_at_frame (AVFilterLink *link, const AVFrame *frame)
 Evaluate the timeline expression of the link for the time and properties of the frame. More...
 
void ff_inlink_request_frame (AVFilterLink *link)
 Mark that a frame is wanted on the link. More...
 
void ff_inlink_set_status (AVFilterLink *link, int status)
 Set the status on an input link. More...
 
int ff_outlink_get_status (AVFilterLink *link)
 Get the status on an output link. More...
 
int ff_inoutlink_check_flow (AVFilterLink *inlink, AVFilterLink *outlink)
 Check for flow control between input and output. More...
 
const AVClassavfilter_get_class (void)
 
int ff_filter_init_hw_frames (AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
 Perform any additional setup required for hardware frames. More...
 

Variables

static const char *const var_names []
 
static const AVOption avfilter_options []
 
static const AVClass avfilter_class
 

Macro Definition Documentation

◆ FF_INTERNAL_FIELDS

#define FF_INTERNAL_FIELDS   1

Definition at line 37 of file avfilter.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(AVFilterContext, x)

Definition at line 607 of file avfilter.c.

◆ FLAGS

#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM

Definition at line 608 of file avfilter.c.

◆ TFLAGS

Definition at line 609 of file avfilter.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_T 
VAR_N 
VAR_W 
VAR_H 
VAR_VARS_NB 

Definition at line 505 of file avfilter.c.

Function Documentation

◆ tlog_ref()

static void tlog_ref ( void *  ctx,
AVFrame ref,
int  end 
)
static

Definition at line 48 of file avfilter.c.

Referenced by ff_filter_frame().

◆ command_queue_pop()

static void command_queue_pop ( AVFilterContext filter)
static

Definition at line 82 of file avfilter.c.

Referenced by avfilter_free(), and ff_inlink_process_commands().

◆ append_pad()

static int append_pad ( unsigned *  count,
AVFilterPad **  pads,
AVFilterLink ***  links,
AVFilterPad newpad 
)
static

Append a new pad.

Parameters
countPointer to the number of pads in the list
padsPointer to the pointer to the beginning of the list of pads
linksPointer to the pointer to the beginning of the list of links
newpadThe new pad to add. A copy is made when adding.
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 100 of file avfilter.c.

Referenced by ff_append_inpad(), and ff_append_outpad().

◆ ff_append_inpad()

int ff_append_inpad ( AVFilterContext f,
AVFilterPad p 
)

Append a new input/output pad to the filter's list of such pads.

The *_free_name versions will set the AVFILTERPAD_FLAG_FREE_NAME flag ensuring that the name will be freed generically (even on insertion error).

Definition at line 127 of file avfilter.c.

Referenced by decimate_init(), ff_append_inpad_free_name(), fieldmatch_init(), and init().

◆ ff_append_inpad_free_name()

int ff_append_inpad_free_name ( AVFilterContext f,
AVFilterPad p 
)

◆ ff_append_outpad()

int ff_append_outpad ( AVFilterContext f,
AVFilterPad p 
)

Definition at line 138 of file avfilter.c.

Referenced by ff_append_outpad_free_name(), and init().

◆ ff_append_outpad_free_name()

int ff_append_outpad_free_name ( AVFilterContext f,
AVFilterPad p 
)

Definition at line 143 of file avfilter.c.

Referenced by init(), movie_common_init(), parse_definition(), and split_init().

◆ update_link_current_pts()

static void update_link_current_pts ( AVFilterLink link,
int64_t  pts 
)
static

Definition at line 205 of file avfilter.c.

Referenced by consume_update(), ff_inlink_acknowledge_status(), and link_set_out_status().

◆ ff_filter_set_ready()

void ff_filter_set_ready ( AVFilterContext filter,
unsigned  priority 
)

Mark a filter ready and schedule it for activation.

This is automatically done when something happens to the filter (queued frame, status change, request on output). Filters implementing the activate callback can call it directly to perform one more round of processing later. It is also useful for filters reacting to external or asynchronous events.

Definition at line 216 of file avfilter.c.

Referenced by activate(), ff_avfilter_link_set_in_status(), ff_filter_frame(), ff_filter_frame_to_filter(), ff_inlink_request_frame(), ff_request_frame(), filter_frame(), forward_status_change(), link_set_out_status(), process_frame(), request_frame(), spatial_activate(), xfade_activate(), and xfade_opencl_activate().

◆ filter_unblock()

static void filter_unblock ( AVFilterContext filter)
static

Clear frame_blocked_in on all outputs.

This is necessary whenever something changes on input.

Definition at line 225 of file avfilter.c.

Referenced by ff_avfilter_link_set_in_status(), ff_filter_frame(), ff_filter_frame_to_filter(), and link_set_out_status().

◆ ff_avfilter_link_set_in_status()

void ff_avfilter_link_set_in_status ( AVFilterLink link,
int  status,
int64_t  pts 
)

Set the status field of a link from the source filter.

The pts should reflect the timestamp of the status change, in link time base and relative to the frames timeline. In particular, for AVERROR_EOF, it should reflect the end time of the last frame.

Definition at line 234 of file avfilter.c.

Referenced by av_buffersrc_close(), ff_outlink_set_status(), and ff_request_frame_to_filter().

◆ link_set_out_status()

static void link_set_out_status ( AVFilterLink link,
int  status,
int64_t  pts 
)
static

Set the status field of a link from the destination filter.

The pts should probably be left unset (AV_NOPTS_VALUE).

Definition at line 251 of file avfilter.c.

Referenced by ff_filter_frame_to_filter(), ff_inlink_set_status(), ff_request_frame(), and forward_status_change().

◆ ff_request_frame()

int ff_request_frame ( AVFilterLink link)

Request an input frame from the filter at the other end of the link.

This function must not be used by filters using the activate callback, use ff_link_set_frame_wanted() instead.

The input filter may pass the request on to its inputs, fulfill the request from an internal buffer or any other means specific to its function.

When the end of a stream is reached AVERROR_EOF is returned and no further frames are returned after that.

When a filter is unable to output a frame for example due to its sources being unable to do so or because it depends on external means pushing data into it then AVERROR(EAGAIN) is returned. It is important that a AVERROR(EAGAIN) return is returned all the way to the caller (generally eventually a user application) as this step may (but does not have to be) necessary to provide the input with the next frame.

If a request is successful then some progress has been made towards providing a frame on the link (through ff_filter_frame()). A filter that needs several frames to produce one is allowed to return success if one more frame has been processed but no output has been produced yet. A filter is also allowed to simply forward a success return value.

Parameters
linkthe input link
Returns
zero on success AVERROR_EOF on end of file AVERROR(EAGAIN) if the previous filter cannot output a frame currently and can neither guarantee that EOF has been reached.

Definition at line 431 of file avfilter.c.

Referenced by avfilter_graph_request_oldest(), deint_vaapi_request_frame(), ff_request_frame_to_filter(), ff_yadif_request_frame(), request_frame(), and request_frame_ref().

◆ guess_status_pts()

static int64_t guess_status_pts ( AVFilterContext ctx,
int  status,
AVRational  link_time_base 
)
static

Definition at line 456 of file avfilter.c.

Referenced by ff_request_frame_to_filter().

◆ ff_request_frame_to_filter()

static int ff_request_frame_to_filter ( AVFilterLink link)
static

Definition at line 474 of file avfilter.c.

Referenced by ff_filter_activate_default(), and forward_status_change().

◆ set_enable_expr()

static int set_enable_expr ( AVFilterContext ctx,
const char *  expr 
)
static

Definition at line 516 of file avfilter.c.

Referenced by avfilter_init_dict(), and avfilter_process_command().

◆ default_filter_name()

static const char* default_filter_name ( void *  filter_ctx)
static

Definition at line 582 of file avfilter.c.

◆ filter_child_next()

static void* filter_child_next ( void *  obj,
void *  prev 
)
static

Definition at line 588 of file avfilter.c.

◆ filter_child_class_iterate()

static const AVClass* filter_child_class_iterate ( void **  iter)
static

Definition at line 596 of file avfilter.c.

◆ default_execute()

static int default_execute ( AVFilterContext ctx,
avfilter_action_func func,
void *  arg,
int ret,
int  nb_jobs 
)
static

Definition at line 632 of file avfilter.c.

Referenced by ff_filter_alloc().

◆ ff_filter_alloc()

AVFilterContext* ff_filter_alloc ( const AVFilter filter,
const char *  inst_name 
)

Allocate a new filter context and return it.

Parameters
filterwhat filter to create an instance of
inst_namename to give to the new filter context
Returns
newly created filter context or NULL on failure

Definition at line 645 of file avfilter.c.

Referenced by avfilter_graph_alloc_filter().

◆ free_link()

static void free_link ( AVFilterLink link)
static

Definition at line 719 of file avfilter.c.

Referenced by avfilter_free().

◆ ff_filter_get_nb_threads()

int ff_filter_get_nb_threads ( AVFilterContext ctx)

◆ ff_filter_opt_parse()

int ff_filter_opt_parse ( void *  logctx,
const AVClass priv_class,
AVDictionary **  options,
const char *  args 
)

Parse filter options into a dictionary.

Parameters
logctxcontext for logging
priv_classa filter's private class for shorthand options or NULL
optionsdictionary to store parsed options in
argsoptions string to parse
Returns
a non-negative number on success, a negative error code on failure

Definition at line 793 of file avfilter.c.

Referenced by avfilter_init_str(), and filter_parse().

◆ ff_filter_process_command()

int ff_filter_process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  arg,
char *  res,
int  res_len,
int  flags 
)

Generic processing of user supplied commands that are set in the same way as the filter options.

NOTE: 'enable' option is handled separately, and not by this function.

Definition at line 851 of file avfilter.c.

Referenced by libplacebo_process_command(), oscilloscope_process_command(), pixscope_process_command(), and process_command().

◆ default_filter_frame()

static int default_filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 942 of file avfilter.c.

Referenced by ff_filter_frame_framed().

◆ ff_filter_frame_framed()

static int ff_filter_frame_framed ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 947 of file avfilter.c.

Referenced by ff_filter_frame_to_filter().

◆ ff_filter_frame()

int ff_filter_frame ( AVFilterLink link,
AVFrame frame 
)

Send a frame of data to the next filter.

Parameters
linkthe output link over which the data is being sent
framea reference to the buffer of data being sent. The receiving filter will free this reference when it no longer needs it or pass it on to the next filter.
Returns
>= 0 on success, a negative AVERROR on error. The receiving filter is responsible for unreferencing frame in case of error.

Definition at line 978 of file avfilter.c.

Referenced by activate(), addroi_filter_frame(), apply_filter(), audio_frame(), av_buffersrc_add_frame_flags(), avgblur_opencl_filter_frame(), avgblur_vulkan_filter_frame(), blend_frame(), blend_frame_for_dualinput(), blockdetect_filter_frame(), blur_frame(), blurdetect_filter_frame(), channelmap_filter_frame(), chromaber_vulkan_filter_frame(), compand_delay(), compand_drain(), compand_nodelay(), convolution_opencl_filter_frame(), create_frame(), cuda_bilateral_filter_frame(), cudachromakey_filter_frame(), cudacolorspace_filter_frame(), cudascale_filter_frame(), cudaupload_filter_frame(), ddagrab_request_frame(), decode_packet(), default_filter_frame(), deint_vaapi_filter_frame(), dnn_classify_activate(), dnn_classify_flush_frame(), dnn_detect_activate(), dnn_detect_flush_frame(), do_alphamerge(), do_blend(), do_convolve(), do_corr(), do_identity(), do_morpho(), do_psnr(), do_ssim(), do_ssim360(), do_vmaf(), draw_spatial(), end_last_frame(), extract_plane(), ff_qsvvpp_init(), ff_yadif_filter_frame(), filter(), filter_callback(), filter_frame(), filter_frame16(), filter_frame8(), filter_frame_ref(), fir_frame(), flip_bayer(), flush_frame(), forward_frame(), gblur_vulkan_filter_frame(), geq_filter_frame(), get_frame(), headphone_frame(), hwdownload_filter_frame(), hwmap_filter_frame(), hwupload_filter_frame(), iccdetect_filter_frame(), iccgen_filter_frame(), load_apply_palette(), misc_vaapi_filter_frame(), neighbor_opencl_filter_frame(), nlmeans_opencl_filter_frame(), nppscale_filter_frame(), nppscale_filter_frame_ref(), nppsharpen_filter_frame(), npptranspose_filter_frame(), oscilloscope_filter_frame(), output_frame(), output_single_frame(), overlay_cuda_blend(), overlay_opencl_blend(), overlay_vaapi_blend(), overlay_vulkan_blend(), pixscope_filter_frame(), plot_freqs(), plot_spectrum_column(), pp_filter_frame(), procamp_vaapi_filter_frame(), process_frame(), program_opencl_run(), push_frame(), push_samples(), remap_opencl_process_frame(), request_frame(), return_frame(), scale_vaapi_filter_frame(), scale_vt_filter_frame(), scale_vulkan_filter_frame(), send_silence(), shuffleplanes_filter_frame(), sierpinski_request_frame(), source_request_frame(), testsrc_vulkan_activate(), tonemap_opencl_filter_frame(), tonemap_vaapi_filter_frame(), transpose_opencl_filter_frame(), transpose_vaapi_filter_frame(), transpose_vt_filter_frame(), try_push_frame(), unsharp_opencl_filter_frame(), varblur_frame(), video_frame(), write_frame(), xfade_activate(), xfade_frame(), and xfade_opencl_activate().

◆ samples_ready()

static int samples_ready ( AVFilterLink link,
unsigned  min 
)
static

Definition at line 1036 of file avfilter.c.

Referenced by ff_filter_activate_default(), and take_samples().

◆ take_samples()

static int take_samples ( AVFilterLink link,
unsigned  min,
unsigned  max,
AVFrame **  rframe 
)
static

Definition at line 1043 of file avfilter.c.

Referenced by ff_inlink_consume_samples().

◆ ff_filter_frame_to_filter()

static int ff_filter_frame_to_filter ( AVFilterLink link)
static

Definition at line 1102 of file avfilter.c.

Referenced by ff_filter_activate_default().

◆ forward_status_change()

static int forward_status_change ( AVFilterContext filter,
AVFilterLink in 
)
static

Definition at line 1134 of file avfilter.c.

Referenced by ff_filter_activate_default().

◆ ff_filter_activate_default()

static int ff_filter_activate_default ( AVFilterContext filter)
static

Definition at line 1166 of file avfilter.c.

Referenced by ff_filter_activate().

◆ ff_filter_activate()

int ff_filter_activate ( AVFilterContext filter)

Definition at line 1322 of file avfilter.c.

Referenced by ff_filter_graph_run_once().

◆ ff_inlink_acknowledge_status()

int ff_inlink_acknowledge_status ( AVFilterLink link,
int rstatus,
int64_t *  rpts 
)

Test and acknowledge the change of status on the link.

Status means EOF or an error condition; a change from the normal (0) status to a non-zero status can be queued in a filter's input link, it becomes relevant after the frames queued in the link's FIFO are processed. This function tests if frames are still queued and if a queued status change has not yet been processed. In that case it performs basic treatment (updating the link's timestamp) and returns a positive value to let the filter do its own treatments (flushing...).

Filters implementing the activate callback should call this function when they think it might succeed (usually after checking unsuccessfully for a queued frame). Filters implementing the filter_frame and request_frame callbacks do not need to call that since the same treatment happens in ff_filter_frame().

Parameters
[out]rstatusnew or current status
[out]rptscurrent timestamp of the link in link time base
Returns
>0 if status changed, <0 if status already acked, 0 otherwise

Definition at line 1337 of file avfilter.c.

Referenced by activate(), consume_from_fifos(), dnn_classify_activate(), dnn_detect_activate(), forward_frame(), get_frame_internal(), handle_input(), request_frame(), xfade_activate(), and xfade_opencl_activate().

◆ ff_inlink_queued_frames()

size_t ff_inlink_queued_frames ( AVFilterLink link)

Get the number of frames available on the link.

Returns
the number of frames available in the link fifo.

Definition at line 1352 of file avfilter.c.

Referenced by activate(), create_frame(), filter_frame(), filter_have_queued(), and xfade_opencl_activate().

◆ ff_inlink_check_available_frame()

int ff_inlink_check_available_frame ( AVFilterLink link)

Test if a frame is available on the link.

Returns
>0 if a frame is available

Definition at line 1357 of file avfilter.c.

Referenced by activate(), ff_inlink_consume_frame(), ff_inoutlink_check_flow(), and xfade_activate().

◆ ff_inlink_queued_samples()

int ff_inlink_queued_samples ( AVFilterLink link)

◆ ff_inlink_check_available_samples()

int ff_inlink_check_available_samples ( AVFilterLink link,
unsigned  min 
)

Test if enough samples are available on the link.

Returns
>0 if enough samples are available
Note
on EOF and error, min becomes 1

Definition at line 1367 of file avfilter.c.

Referenced by activate(), check_ir(), and ff_inlink_consume_samples().

◆ consume_update()

static void consume_update ( AVFilterLink link,
const AVFrame frame 
)
static

Definition at line 1374 of file avfilter.c.

Referenced by ff_inlink_consume_frame(), and ff_inlink_consume_samples().

◆ ff_inlink_consume_frame()

int ff_inlink_consume_frame ( AVFilterLink link,
AVFrame **  rframe 
)

Take a frame from the link's FIFO and update the link's stats.

If ff_inlink_check_available_frame() was previously called, the preferred way of expressing it is "av_assert1(ret);" immediately after ff_inlink_consume_frame(). Negative error codes must still be checked.

Note
May trigger process_command() and/or update is_disabled.
Returns
>0 if a frame is available, 0 and set rframe to NULL if no frame available, or AVERROR code

Definition at line 1383 of file avfilter.c.

Referenced by activate(), consume_from_fifos(), dnn_classify_activate(), dnn_detect_activate(), ff_filter_frame_to_filter(), filter_frame(), forward_frame(), get_frame_internal(), handle_input(), read_frame(), spatial_activate(), xfade_activate(), and xfade_opencl_activate().

◆ ff_inlink_consume_samples()

int ff_inlink_consume_samples ( AVFilterLink link,
unsigned  min,
unsigned  max,
AVFrame **  rframe 
)

Take samples from the link's FIFO and update the link's stats.

If ff_inlink_check_available_samples() was previously called, the preferred way of expressing it is "av_assert1(ret);" immediately after ff_inlink_consume_samples(). Negative error codes must still be checked.

Note
May trigger process_command() and/or update is_disabled.
Returns
>0 if a frame is available, 0 and set rframe to NULL if no frame available, or AVERROR code

Definition at line 1402 of file avfilter.c.

Referenced by activate(), convert_coeffs(), ff_filter_frame_to_filter(), ff_inlink_consume_frame(), get_frame_internal(), and try_push_frame().

◆ ff_inlink_peek_frame()

AVFrame* ff_inlink_peek_frame ( AVFilterLink link,
size_t  idx 
)

Access a frame in the link fifo without consuming it.

The first frame is numbered 0; the designated frame must exist.

Returns
the frame at idx position in the link fifo.

Definition at line 1422 of file avfilter.c.

Referenced by activate(), xfade_activate(), and xfade_opencl_activate().

◆ ff_inlink_make_frame_writable()

int ff_inlink_make_frame_writable ( AVFilterLink link,
AVFrame **  rframe 
)

Make sure a frame is writable.

This is similar to av_frame_make_writable() except it uses the link's buffer allocation callback, and therefore allows direct rendering.

Definition at line 1427 of file avfilter.c.

Referenced by activate(), apply_palette(), ff_filter_frame_framed(), ff_framesync_dualinput_get_writable(), ff_framesync_get_frame(), filter_frame(), filter_frame16(), filter_frame8(), overlay_cuda_blend(), and plot_spectrum_column().

◆ ff_inlink_process_commands()

int ff_inlink_process_commands ( AVFilterLink link,
const AVFrame frame 
)

Process the commands queued in the link up to the time of the frame.

Commands will trigger the process_command() callback.

Returns
>= 0 or AVERROR code.

Definition at line 1467 of file avfilter.c.

Referenced by consume_update(), and ff_filter_frame_framed().

◆ ff_inlink_evaluate_timeline_at_frame()

int ff_inlink_evaluate_timeline_at_frame ( AVFilterLink link,
const AVFrame frame 
)

Evaluate the timeline expression of the link for the time and properties of the frame.

Returns
>0 if enabled, 0 if disabled
Note
It does not update link->dst->is_disabled.

Definition at line 1482 of file avfilter.c.

Referenced by consume_update(), and ff_filter_frame_framed().

◆ ff_inlink_request_frame()

void ff_inlink_request_frame ( AVFilterLink link)

Mark that a frame is wanted on the link.

Unlike ff_filter_frame(), it must not be called when the link has a non-zero status, and thus does not acknowledge it. Also it cannot fail.

Definition at line 1506 of file avfilter.c.

Referenced by activate(), check_ir(), consume_from_fifos(), filter_frame(), forward_frame(), get_frame_internal(), if(), libplacebo_activate(), request_samples(), spatial_activate(), xfade_activate(), and xfade_opencl_activate().

◆ ff_inlink_set_status()

void ff_inlink_set_status ( AVFilterLink link,
int  status 
)

Set the status on an input link.

Also discard all frames in the link's FIFO.

Definition at line 1514 of file avfilter.c.

Referenced by activate(), if(), and xfade_activate().

◆ ff_outlink_get_status()

int ff_outlink_get_status ( AVFilterLink link)

Get the status on an output link.

Definition at line 1529 of file avfilter.c.

Referenced by activate(), create_frame(), draw_items(), filter_frame(), filter_have_eof(), and xfade_opencl_activate().

◆ ff_inoutlink_check_flow()

int ff_inoutlink_check_flow ( AVFilterLink inlink,
AVFilterLink outlink 
)

Check for flow control between input and output.

This is necessary for filters that may produce several output frames for a single input event, otherwise they may produce them all at once, causing excessive memory consumption.

Definition at line 1534 of file avfilter.c.

Referenced by activate().

◆ ff_filter_init_hw_frames()

int ff_filter_init_hw_frames ( AVFilterContext avctx,
AVFilterLink link,
int  default_pool_size 
)

Perform any additional setup required for hardware frames.

link->hw_frames_ctx must be set before calling this function. Inside link->hw_frames_ctx, the fields format, sw_format, width and height must be set. If dynamically allocated pools are not supported, then initial_pool_size must also be set, to the minimum hardware frame pool size necessary for the filter to work (taking into account any frames which need to stored for use in operations as appropriate). If default_pool_size is nonzero, then it will be used as the pool size if no other modification takes place (this can be used to preserve compatibility).

Definition at line 1547 of file avfilter.c.

Referenced by config_output(), ff_vaapi_vpp_config_output(), scale_vt_config_output(), and transpose_vt_recreate_hw_ctx().

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"t",
"n",
"w",
"h",
}

Definition at line 494 of file avfilter.c.

Referenced by set_enable_expr().

◆ avfilter_options

const AVOption avfilter_options[]
static
Initial value:
= {
{ "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
{ .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" },
{ "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = FLAGS, .unit = "thread_type" },
{ "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = TFLAGS },
{ "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
{ .i64 = 0 }, 0, INT_MAX, FLAGS },
{ "extra_hw_frames", "Number of extra hardware frames to allocate for the user",
OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ NULL },
}

Definition at line 610 of file avfilter.c.

◆ avfilter_class

const AVClass avfilter_class
static
Initial value:
= {
.class_name = "AVFilter",
.item_name = default_filter_name,
.child_next = filter_child_next,
.child_class_iterate = filter_child_class_iterate,
}

Definition at line 622 of file avfilter.c.

Referenced by avfilter_get_class(), and ff_filter_alloc().

filter_child_class_iterate
static const AVClass * filter_child_class_iterate(void **iter)
Definition: avfilter.c:596
default_filter_name
static const char * default_filter_name(void *filter_ctx)
Definition: avfilter.c:582
AVFILTER_THREAD_SLICE
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
Definition: avfilter.h:392
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
OFFSET
#define OFFSET(x)
Definition: avfilter.c:607
avfilter_options
static const AVOption avfilter_options[]
Definition: avfilter.c:610
filter_child_next
static void * filter_child_next(void *obj, void *prev)
Definition: avfilter.c:588
AVClass::option
const struct AVOption * option
a pointer to the first option specified in the class if any or NULL
Definition: log.h:84
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
TFLAGS
#define TFLAGS
Definition: avfilter.c:609
FLAGS
#define FLAGS
Definition: avfilter.c:608
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234