FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions | Variables
avfilter.c File Reference
#include "libavutil/atomic.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/samplefmt.h"
#include "audio.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "libavutil/ffversion.h"

Go to the source code of this file.

Macros

#define LICENSE_PREFIX   "libavfilter license: "
 
#define OFFSET(x)   offsetof(AVFilterContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

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

Functions

static int ff_filter_frame_framed (AVFilterLink *link, AVFrame *frame)
 
void ff_tlog_ref (void *ctx, AVFrame *ref, int end)
 
unsigned avfilter_version (void)
 Return the LIBAVFILTER_VERSION_INT constant. More...
 
const char * avfilter_configuration (void)
 Return the libavfilter build-time configuration. More...
 
const char * avfilter_license (void)
 Return the libavfilter license. More...
 
void ff_command_queue_pop (AVFilterContext *filter)
 
int ff_insert_pad (unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
 Insert a new pad. More...
 
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...
 
int avfilter_link_get_channels (AVFilterLink *link)
 Get the number of channels of a link. 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...
 
void ff_avfilter_link_set_out_status (AVFilterLink *link, int status, int64_t pts)
 Set the status field of a link from the destination filter. More...
 
void avfilter_link_set_closed (AVFilterLink *link, int closed)
 Set the closed field of a link. 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...
 
void ff_tlog_link (void *ctx, AVFilterLink *link, int end)
 
int ff_request_frame (AVFilterLink *link)
 Request an input frame from the filter at the other end of the link. More...
 
int ff_request_frame_to_filter (AVFilterLink *link)
 
int ff_poll_frame (AVFilterLink *link)
 Poll a frame from the filter chain. More...
 
static int set_enable_expr (AVFilterContext *ctx, const char *expr)
 
void ff_update_link_current_pts (AVFilterLink *link, int64_t pts)
 
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...
 
const AVFilteravfilter_get_by_name (const char *name)
 Get a filter definition matching the given name. More...
 
int avfilter_register (AVFilter *filter)
 Register a filter. More...
 
const AVFilteravfilter_next (const AVFilter *prev)
 Iterate over all registered filters. More...
 
int avfilter_pad_count (const AVFilterPad *pads)
 Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. More...
 
static const char * default_filter_name (void *filter_ctx)
 
static voidfilter_child_next (void *obj, void *prev)
 
static const AVClassfilter_child_class_next (const AVClass *prev)
 
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...
 
static int process_options (AVFilterContext *ctx, AVDictionary **options, const char *args)
 
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_needs_framing (AVFilterLink *link, AVFrame *frame)
 
int ff_filter_frame (AVFilterLink *link, AVFrame *frame)
 Send a frame of data to the next filter. More...
 
const AVClassavfilter_get_class (void)
 

Variables

const char av_filter_ffversion [] = "FFmpeg version " FFMPEG_VERSION
 
static const char *const var_names []
 
static AVFilterfirst_filter
 
static AVFilter ** last_filter = &first_filter
 
static const AVOption avfilter_options []
 
static const AVClass avfilter_class
 

Macro Definition Documentation

#define LICENSE_PREFIX   "libavfilter license: "

Referenced by avfilter_license().

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

Definition at line 612 of file avfilter.c.

#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM

Definition at line 613 of file avfilter.c.

Enumeration Type Documentation

anonymous enum
Enumerator
VAR_T 
VAR_N 
VAR_POS 
VAR_W 
VAR_H 
VAR_VARS_NB 

Definition at line 432 of file avfilter.c.

Function Documentation

static int ff_filter_frame_framed ( AVFilterLink link,
AVFrame frame 
)
static
void ff_tlog_ref ( void ctx,
AVFrame ref,
int  end 
)

Definition at line 47 of file avfilter.c.

Referenced by ff_filter_frame().

void ff_command_queue_pop ( AVFilterContext filter)

Definition at line 92 of file avfilter.c.

Referenced by avfilter_free(), and ff_filter_frame_framed().

int ff_insert_pad ( unsigned  idx,
unsigned *  count,
size_t  padidx_off,
AVFilterPad **  pads,
AVFilterLink ***  links,
AVFilterPad newpad 
)

Insert a new pad.

Parameters
idxInsertion point. Pad is inserted at the end if this point is beyond the end of the list of pads.
countPointer to the number of pads in the list
padidx_offOffset within an AVFilterLink structure to the element to increment when inserting a new pad causes link numbering to change
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 101 of file avfilter.c.

Referenced by ff_insert_inpad(), and ff_insert_outpad().

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 183 of file avfilter.c.

Referenced by ff_request_frame_to_filter().

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

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

The pts should probably be left unset (AV_NOPTS_VALUE).

Definition at line 188 of file avfilter.c.

Referenced by avfilter_link_set_closed(), and ff_avfilter_link_set_in_status().

void ff_tlog_link ( void ctx,
AVFilterLink link,
int  end 
)
int ff_request_frame ( AVFilterLink link)

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

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 369 of file avfilter.c.

Referenced by av_buffersink_get_frame_flags(), avfilter_graph_request_oldest(), ff_framesync_request_frame(), ff_request_frame_to_filter(), join_request_frame(), request_frame(), request_frame_ref(), request_inlink(), request_samples(), and return_audio_frame().

int ff_request_frame_to_filter ( AVFilterLink link)

Definition at line 380 of file avfilter.c.

Referenced by ff_filter_graph_run_once().

int ff_poll_frame ( AVFilterLink link)

Poll a frame from the filter chain.

Parameters
linkthe input link
Returns
the number of immediately available frames, a negative number in case of error

Definition at line 405 of file avfilter.c.

Referenced by ff_poll_frame().

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

Definition at line 441 of file avfilter.c.

Referenced by avfilter_process_command(), and process_options().

void ff_update_link_current_pts ( AVFilterLink link,
int64_t  pts 
)

Definition at line 481 of file avfilter.c.

Referenced by ff_avfilter_link_set_out_status(), and ff_filter_frame_framed().

static const char* default_filter_name ( void filter_ctx)
static

Definition at line 577 of file avfilter.c.

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

Definition at line 583 of file avfilter.c.

static const AVClass* filter_child_class_next ( const AVClass prev)
static

Definition at line 591 of file avfilter.c.

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

Definition at line 634 of file avfilter.c.

Referenced by 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 647 of file avfilter.c.

Referenced by avfilter_graph_alloc_filter().

static void free_link ( AVFilterLink link)
static

Definition at line 723 of file avfilter.c.

Referenced by avfilter_free().

int ff_filter_get_nb_threads ( AVFilterContext ctx)

Get number of threads for current filter instance.

This number is always same or less than graph->nb_threads.

Definition at line 786 of file avfilter.c.

Referenced by apply_lut(), averageiir2d(), blend_frame(), config_input(), config_props(), filter(), filter_frame(), filter_frame16(), filter_frame8(), gaussianiir2d(), and nlmeans_plane().

static int process_options ( AVFilterContext ctx,
AVDictionary **  options,
const char *  args 
)
static

Definition at line 793 of file avfilter.c.

Referenced by avfilter_init_str().

static int default_filter_frame ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 1044 of file avfilter.c.

Referenced by ff_filter_frame_framed().

static int ff_filter_frame_needs_framing ( AVFilterLink link,
AVFrame frame 
)
static

Definition at line 1145 of file avfilter.c.

Referenced by 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 1189 of file avfilter.c.

Referenced by apply_filter(), channelmap_filter_frame(), compand_delay(), compand_nodelay(), cudaupload_filter_frame(), default_filter_frame(), end_last_frame(), filter(), filter_frame(), filter_frame16(), filter_frame8(), filter_frame_ref(), flush(), geq_filter_frame(), hwdownload_filter_frame(), hwupload_filter_frame(), movie_push_frame(), nppscale_filter_frame(), output_frame(), output_single_frame(), plot_freqs(), plot_spectrum_column(), pp_filter_frame(), process_frame(), process_work_frame(), push_frame(), push_samples(), request_frame(), return_audio_frame(), return_frame(), scale_vaapi_filter_frame(), send_silence(), shuffleplanes_filter_frame(), and try_push_frame().

Variable Documentation

const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION

Definition at line 43 of file avfilter.c.

const char* const var_names[]
static
Initial value:
= {
"t",
"n",
"pos",
"w",
"h",
}
#define NULL
Definition: coverity.c:32

Definition at line 423 of file avfilter.c.

Referenced by set_enable_expr().

AVFilter* first_filter
static

Definition at line 513 of file avfilter.c.

Referenced by avfilter_next().

AVFilter** last_filter = &first_filter
static
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 }, .unit = "thread_type" },
{ "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "threads", "Allowed number of threads", OFFSET(nb_threads), AV_OPT_TYPE_INT,
{ .i64 = 0 }, 0, INT_MAX, FLAGS },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
Definition: avfilter.h:302
#define FLAGS
Definition: avfilter.c:613
#define OFFSET(x)
Definition: avfilter.c:612

Definition at line 614 of file avfilter.c.

const AVClass avfilter_class
static
Initial value:
= {
.class_name = "AVFilter",
.item_name = default_filter_name,
.child_next = filter_child_next,
.child_class_next = filter_child_class_next,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const struct AVOption * option
a pointer to the first option specified in the class if any or NULL
Definition: log.h:85
static const char * default_filter_name(void *filter_ctx)
Definition: avfilter.c:577
static void * filter_child_next(void *obj, void *prev)
Definition: avfilter.c:583
static const AVOption avfilter_options[]
Definition: avfilter.c:614
static const AVClass * filter_child_class_next(const AVClass *prev)
Definition: avfilter.c:591

Definition at line 624 of file avfilter.c.

Referenced by avfilter_get_class(), and ff_filter_alloc().