FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
avfiltergraph.c File Reference
#include "config.h"
#include <string.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "thread.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(AVFilterGraph, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define MERGE_DISPATCH(field, statement)
 
#define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format, unref_format)
 
#define CH_CENTER_PAIR   (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
 
#define CH_FRONT_PAIR   (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
 
#define CH_STEREO_PAIR   (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
 
#define CH_WIDE_PAIR   (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
 
#define CH_SIDE_PAIR   (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
 
#define CH_DIRECT_PAIR   (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
 
#define CH_BACK_PAIR   (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
 

Functions

void ff_graph_thread_free (AVFilterGraph *graph)
 
int ff_graph_thread_init (AVFilterGraph *graph)
 
AVFilterGraphavfilter_graph_alloc (void)
 Allocate a filter graph. More...
 
void ff_filter_graph_remove_filter (AVFilterGraph *graph, AVFilterContext *filter)
 Remove a filter from a graph;. More...
 
void avfilter_graph_free (AVFilterGraph **graph)
 Free a graph, destroy its links, and set *graph to NULL. More...
 
int avfilter_graph_create_filter (AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
 Create and add a filter instance into an existing graph. More...
 
void avfilter_graph_set_auto_convert (AVFilterGraph *graph, unsigned flags)
 Enable or disable automatic format conversion inside the graph. More...
 
AVFilterContextavfilter_graph_alloc_filter (AVFilterGraph *graph, const AVFilter *filter, const char *name)
 Create a new filter instance in a filter graph. More...
 
static int graph_check_validity (AVFilterGraph *graph, AVClass *log_ctx)
 Check for the validity of graph. More...
 
static int graph_config_links (AVFilterGraph *graph, AVClass *log_ctx)
 Configure all the links of graphctx. More...
 
AVFilterContextavfilter_graph_get_filter (AVFilterGraph *graph, const char *name)
 Get a filter instance identified by instance name from graph. More...
 
static void sanitize_channel_layouts (void *log, AVFilterChannelLayouts *l)
 
static int filter_query_formats (AVFilterContext *ctx)
 
static int formats_declared (AVFilterContext *f)
 
static AVFilterFormatsclone_filter_formats (AVFilterFormats *arg)
 
static int can_merge_formats (AVFilterFormats *a_arg, AVFilterFormats *b_arg, enum AVMediaType type, int is_sample_rate)
 
static int query_formats (AVFilterGraph *graph, AVClass *log_ctx)
 Perform one round of query_formats() and merging formats lists on the filter graph. More...
 
static int get_fmt_score (enum AVSampleFormat dst_fmt, enum AVSampleFormat src_fmt)
 
static enum AVSampleFormat find_best_sample_fmt_of_2 (enum AVSampleFormat dst_fmt1, enum AVSampleFormat dst_fmt2, enum AVSampleFormat src_fmt)
 
static int pick_format (AVFilterLink *link, AVFilterLink *ref)
 
static int reduce_formats_on_filter (AVFilterContext *filter)
 
static int reduce_formats (AVFilterGraph *graph)
 
static void swap_samplerates_on_filter (AVFilterContext *filter)
 
static void swap_samplerates (AVFilterGraph *graph)
 
static void swap_channel_layouts_on_filter (AVFilterContext *filter)
 
static void swap_channel_layouts (AVFilterGraph *graph)
 
static void swap_sample_fmts_on_filter (AVFilterContext *filter)
 
static void swap_sample_fmts (AVFilterGraph *graph)
 
static int pick_formats (AVFilterGraph *graph)
 
static int graph_config_formats (AVFilterGraph *graph, AVClass *log_ctx)
 Configure the formats of all the links in the graph. More...
 
static int graph_config_pointers (AVFilterGraph *graph, AVClass *log_ctx)
 
static int graph_insert_fifos (AVFilterGraph *graph, AVClass *log_ctx)
 
int avfilter_graph_config (AVFilterGraph *graphctx, void *log_ctx)
 Check validity and configure all the links and formats in the graph. More...
 
int avfilter_graph_send_command (AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
 Send a command to one or more filter instances. More...
 
int avfilter_graph_queue_command (AVFilterGraph *graph, const char *target, const char *command, const char *arg, int flags, double ts)
 Queue a command for one or more filter instances. More...
 
static void heap_bubble_up (AVFilterGraph *graph, AVFilterLink *link, int index)
 
static void heap_bubble_down (AVFilterGraph *graph, AVFilterLink *link, int index)
 
void ff_avfilter_graph_update_heap (AVFilterGraph *graph, AVFilterLink *link)
 Update the position of a link in the age heap. More...
 
int avfilter_graph_request_oldest (AVFilterGraph *graph)
 Request a frame on the oldest sink link. More...
 
static AVFilterLinkgraph_run_once_find_filter (AVFilterGraph *graph)
 
int ff_filter_graph_run_once (AVFilterGraph *graph)
 Run one round of processing on a filter graph. More...
 

Variables

static const AVOption filtergraph_options []
 
static const AVClass filtergraph_class
 
static const uint64_t ch_subst [][2]
 

Macro Definition Documentation

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

Definition at line 40 of file avfiltergraph.c.

Definition at line 41 of file avfiltergraph.c.

#define MERGE_DISPATCH (   field,
  statement 
)
Value:
if (!(link->in_ ## field && link->out_ ## field)) { \
count_delayed++; \
} else if (link->in_ ## field == link->out_ ## field) { \
count_already_merged++; \
} else if (!convert_needed) { \
count_merged++; \
statement \
}

Referenced by query_formats().

#define REDUCE_FORMATS (   fmt_type,
  list_type,
  list,
  var,
  nb,
  add_format,
  unref_format 
)

Definition at line 741 of file avfiltergraph.c.

Referenced by reduce_formats_on_filter().

Definition at line 892 of file avfiltergraph.c.

#define CH_FRONT_PAIR   (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)

Definition at line 893 of file avfiltergraph.c.

#define CH_STEREO_PAIR   (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)

Definition at line 894 of file avfiltergraph.c.

#define CH_WIDE_PAIR   (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)

Definition at line 895 of file avfiltergraph.c.

#define CH_SIDE_PAIR   (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)

Definition at line 896 of file avfiltergraph.c.

Definition at line 897 of file avfiltergraph.c.

#define CH_BACK_PAIR   (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)

Definition at line 898 of file avfiltergraph.c.

Function Documentation

void ff_graph_thread_free ( AVFilterGraph graph)

Definition at line 64 of file avfiltergraph.c.

Referenced by avfilter_graph_free().

int ff_graph_thread_init ( AVFilterGraph graph)

Definition at line 68 of file avfiltergraph.c.

Referenced by avfilter_graph_alloc_filter().

void ff_filter_graph_remove_filter ( AVFilterGraph graph,
AVFilterContext filter 
)

Remove a filter from a graph;.

Definition at line 94 of file avfiltergraph.c.

Referenced by avfilter_free().

static int graph_check_validity ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Check for the validity of graph.

A graph is considered valid if all its input and output pads are connected.

Returns
>= 0 in case of success, a negative value otherwise

Definition at line 221 of file avfiltergraph.c.

Referenced by avfilter_graph_config().

static int graph_config_links ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Configure all the links of graphctx.

Returns
>= 0 in case of success, a negative value otherwise

Definition at line 259 of file avfiltergraph.c.

Referenced by avfilter_graph_config().

static void sanitize_channel_layouts ( void log,
AVFilterChannelLayouts l 
)
static

Definition at line 287 of file avfiltergraph.c.

Referenced by filter_query_formats().

static int filter_query_formats ( AVFilterContext ctx)
static

Definition at line 302 of file avfiltergraph.c.

Referenced by query_formats().

static int formats_declared ( AVFilterContext f)
static

Definition at line 338 of file avfiltergraph.c.

Referenced by query_formats().

static AVFilterFormats* clone_filter_formats ( AVFilterFormats arg)
static

Definition at line 361 of file avfiltergraph.c.

Referenced by can_merge_formats().

static int can_merge_formats ( AVFilterFormats a_arg,
AVFilterFormats b_arg,
enum AVMediaType  type,
int  is_sample_rate 
)
static

Definition at line 374 of file avfiltergraph.c.

Referenced by query_formats().

static int query_formats ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Perform one round of query_formats() and merging formats lists on the filter graph.

Returns
>=0 if all links formats lists could be queried and merged; AVERROR(EAGAIN) some progress was made in the queries or merging and a later call may succeed; AVERROR(EIO) (may be changed) plus a log message if no progress was made and the negotiation is stuck; a negative error code if some other error happened

Definition at line 426 of file avfiltergraph.c.

Referenced by graph_config_formats().

static int get_fmt_score ( enum AVSampleFormat  dst_fmt,
enum AVSampleFormat  src_fmt 
)
static

Definition at line 632 of file avfiltergraph.c.

Referenced by find_best_sample_fmt_of_2().

static enum AVSampleFormat find_best_sample_fmt_of_2 ( enum AVSampleFormat  dst_fmt1,
enum AVSampleFormat  dst_fmt2,
enum AVSampleFormat  src_fmt 
)
static

Definition at line 655 of file avfiltergraph.c.

Referenced by pick_format().

static int pick_format ( AVFilterLink link,
AVFilterLink ref 
)
static

Definition at line 666 of file avfiltergraph.c.

Referenced by pick_formats().

static int reduce_formats_on_filter ( AVFilterContext filter)
static

Definition at line 778 of file avfiltergraph.c.

Referenced by reduce_formats().

static int reduce_formats ( AVFilterGraph graph)
static

Definition at line 828 of file avfiltergraph.c.

Referenced by graph_config_formats().

static void swap_samplerates_on_filter ( AVFilterContext filter)
static

Definition at line 845 of file avfiltergraph.c.

Referenced by swap_samplerates().

static void swap_samplerates ( AVFilterGraph graph)
static

Definition at line 884 of file avfiltergraph.c.

Referenced by graph_config_formats().

static void swap_channel_layouts_on_filter ( AVFilterContext filter)
static

Definition at line 926 of file avfiltergraph.c.

Referenced by swap_channel_layouts().

static void swap_channel_layouts ( AVFilterGraph graph)
static

Definition at line 1015 of file avfiltergraph.c.

Referenced by graph_config_formats().

static void swap_sample_fmts_on_filter ( AVFilterContext filter)
static

Definition at line 1023 of file avfiltergraph.c.

Referenced by swap_sample_fmts().

static void swap_sample_fmts ( AVFilterGraph graph)
static

Definition at line 1083 of file avfiltergraph.c.

Referenced by graph_config_formats().

static int pick_formats ( AVFilterGraph graph)
static

Definition at line 1092 of file avfiltergraph.c.

Referenced by graph_config_formats().

static int graph_config_formats ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Configure the formats of all the links in the graph.

Definition at line 1147 of file avfiltergraph.c.

Referenced by avfilter_graph_config().

static int graph_config_pointers ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Definition at line 1175 of file avfiltergraph.c.

Referenced by avfilter_graph_config().

static int graph_insert_fifos ( AVFilterGraph graph,
AVClass log_ctx 
)
static

Definition at line 1217 of file avfiltergraph.c.

Referenced by avfilter_graph_config().

static void heap_bubble_up ( AVFilterGraph graph,
AVFilterLink link,
int  index 
)
static

Definition at line 1331 of file avfiltergraph.c.

Referenced by ff_avfilter_graph_update_heap().

static void heap_bubble_down ( AVFilterGraph graph,
AVFilterLink link,
int  index 
)
static
void ff_avfilter_graph_update_heap ( AVFilterGraph graph,
AVFilterLink link 
)

Update the position of a link in the age heap.

Definition at line 1374 of file avfiltergraph.c.

Referenced by ff_update_link_current_pts().

static AVFilterLink* graph_run_once_find_filter ( AVFilterGraph graph)
static

Definition at line 1411 of file avfiltergraph.c.

Referenced by ff_filter_graph_run_once().

int ff_filter_graph_run_once ( AVFilterGraph graph)

Run one round of processing on a filter graph.

Definition at line 1432 of file avfiltergraph.c.

Referenced by av_buffersink_get_frame_flags(), and avfilter_graph_request_oldest().

Variable Documentation

const AVOption filtergraph_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" },
{ "threads", "Maximum number of threads", OFFSET(nb_threads),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
{"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) ,
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) ,
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AVFILTER_THREAD_SLICE
Process multiple parts of the frame concurrently.
Definition: avfilter.h:302
#define OFFSET(x)
Definition: avfiltergraph.c:40
#define FLAGS
Definition: avfiltergraph.c:41

Definition at line 42 of file avfiltergraph.c.

const AVClass filtergraph_class
static
Initial value:
= {
.class_name = "AVFilterGraph",
.item_name = av_default_item_name,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_default_item_name
static const AVOption filtergraph_options[]
Definition: avfiltergraph.c:42

Definition at line 55 of file avfiltergraph.c.

Referenced by avfilter_graph_alloc().

const uint64_t ch_subst[][2]
static