FFmpeg
Loading...
Searching...
No Matches
avfilter_internal.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19/*
20 * APIs internal to the generic filter(graph) layer.
21 *
22 * MUST NOT be included by individual filters.
23 */
24
25#ifndef AVFILTER_AVFILTER_INTERNAL_H
26#define AVFILTER_AVFILTER_INTERNAL_H
27
28#include <stdint.h>
29
30#include "avfilter.h"
31#include "filters.h"
32#include "framepool.h"
33#include "framequeue.h"
34
35typedef struct FilterLinkInternal {
37
38 /**
39 * Pool of frames used for allocations.
40 */
42
43 /**
44 * Queue of frames waiting to be filtered.
45 */
47
48 /**
49 * Format and size of the video frames the link was configured with.
50 */
52
53 /**
54 * If set, the source filter can not generate a frame as is.
55 * The goal is to avoid repeatedly calling the request_frame() method on
56 * the same link.
57 */
59
60 /**
61 * Link input status.
62 * If not zero, all attempts of filter_frame will fail with the
63 * corresponding code.
64 */
66
67 /**
68 * Timestamp of the input status change.
69 */
71
72 /**
73 * Link output status.
74 * If not zero, all attempts of request_frame will fail with the
75 * corresponding code.
76 */
78
79 /**
80 * True if a frame is currently wanted on the output of this filter.
81 * Set when ff_request_frame() is called by the output,
82 * cleared when a frame is filtered.
83 */
85
86 /**
87 * Index in the age array.
88 */
90
91 /** stage of the initialization of the link properties (dimensions, etc) */
92 enum {
93 AVLINK_UNINIT = 0, ///< not started
94 AVLINK_STARTINIT, ///< started, but incomplete
95 AVLINK_INIT ///< complete
98
100{
101 return (FilterLinkInternal*)link;
102}
103
104typedef struct FFFilterContext {
105 /**
106 * The public AVFilterContext. See avfilter.h for it.
107 */
109
111
112 // AV_CLASS_STATE_FLAG_*
113 unsigned state_flags;
114
115 /**
116 * Ready status of the filter.
117 * A non-0 value means that the filter needs activating;
118 * a higher value suggests a more urgent activation.
119 */
120 unsigned ready;
121
122 /// parsed expression
123 struct AVExpr *enable;
124 /// variable values for the enable expression
125 double *var_values;
126
129
131{
132 return (FFFilterContext*)ctx;
133}
134
135typedef struct AVFilterCommand {
136 double time; ///< time expressed in seconds
137 char *command; ///< command
138 char *arg; ///< optional argument for the command
139 int flags;
142
143typedef struct FFFilterGraph {
144 /**
145 * The public AVFilterGraph. See avfilter.h for it.
146 */
148
151
153
154 void *thread;
158
160{
161 return (FFFilterGraph*)graph;
162}
163
164/**
165 * Update the position of a link in the age heap.
166 */
168 struct FilterLinkInternal *li);
169
170/**
171 * Allocate a new filter context and return it.
172 *
173 * @param filter what filter to create an instance of
174 * @param inst_name name to give to the new filter context
175 *
176 * @return newly created filter context or NULL on failure
177 */
178AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name);
179
180/**
181 * Remove a filter from a graph;
182 */
184
186
187/**
188 * Parse filter options into a dictionary.
189 *
190 * @param logctx context for logging
191 * @param priv_class a filter's private class for shorthand options or NULL
192 * @param options dictionary to store parsed options in
193 * @param args options string to parse
194 *
195 * @return a non-negative number on success, a negative error code on failure
196 */
197int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
198 AVDictionary **options, const char *args);
199
201
203
204/**
205 * Negotiate the media format, dimensions, etc of all inputs to a filter.
206 *
207 * @param filter the filter to negotiate the properties for its inputs
208 * @return zero on successful negotiation
209 */
211
212/* misc trace functions */
213
214#define FF_TPRINTF_START(ctx, func) ff_tlog(NULL, "%-16s: ", #func)
215
216#ifdef TRACE
217void ff_tlog_link(void *ctx, AVFilterLink *link, int end);
218#else
219#define ff_tlog_link(ctx, link, end) do { } while(0)
220#endif
221
222/**
223 * Run one round of processing on a filter graph.
224 */
226
227/**
228 * Process the commands queued in the link up to the time of the frame.
229 * Commands will trigger the process_command() callback.
230 * @return >= 0 or AVERROR code.
231 */
233
234#endif /* AVFILTER_AVFILTER_INTERNAL_H */
static AVFormatContext * ctx
Main libavfilter public API header.
AVFilterContext * ff_filter_alloc(const AVFilter *filter, const char *inst_name)
Allocate a new filter context and return it.
Definition avfilter.c:707
static FFFilterContext * fffilterctx(AVFilterContext *ctx)
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
Remove a filter from a graph;.
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
static FFFilterGraph * fffiltergraph(AVFilterGraph *graph)
static FilterLinkInternal * ff_link_internal(AVFilterLink *link)
int ff_filter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition avfilter.c:331
void ff_avfilter_graph_update_heap(AVFilterGraph *graph, struct FilterLinkInternal *li)
Update the position of a link in the age heap.
void ff_graph_thread_free(FFFilterGraph *graph)
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class, AVDictionary **options, const char *args)
Parse filter options into a dictionary.
Definition avfilter.c:861
int ff_graph_thread_init(FFFilterGraph *graph)
int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame)
Process the commands queued in the link up to the time of the frame.
Definition avfilter.c:1627
#define ff_tlog_link(ctx, link, end)
int ff_filter_activate(AVFilterContext *filter)
Definition avfilter.c:1455
long long int64_t
Definition coverity.c:34
static AVFrame * frame
int avfilter_execute_func(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
A function executing multiple jobs, possibly in parallel.
Definition avfilter.h:569
Describe the class of an AVClass context structure.
Definition log.h:76
Definition eval.c:171
struct AVFilterCommand * next
double time
time expressed in seconds
char * arg
optional argument for the command
char * command
command
An instance of a filter.
Definition avfilter.h:279
Filter definition.
Definition avfilter.h:221
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
struct AVFilterCommand * command_queue
struct AVExpr * enable
parsed expression
AVFilterContext p
The public AVFilterContext.
double * var_values
variable values for the enable expression
unsigned ready
Ready status of the filter.
avfilter_execute_func * execute
avfilter_execute_func * thread_execute
AVFilterGraph p
The public AVFilterGraph.
FFFrameQueueGlobal frame_queues
struct FilterLinkInternal ** sink_links
unsigned disable_auto_convert
Frame pool.
Definition framepool.h:32
Structure to hold global options and statistics for frame queues.
Definition framequeue.h:44
Queue of AVFrame pointers.
Definition framequeue.h:60
int64_t status_in_pts
Timestamp of the input status change.
int frame_wanted_out
True if a frame is currently wanted on the output of this filter.
int age_index
Index in the age array.
@ AVLINK_STARTINIT
started, but incomplete
@ AVLINK_UNINIT
not started
int status_in
Link input status.
FFFrameQueue fifo
Queue of frames waiting to be filtered.
enum FilterLinkInternal::@336377057131212365164072214263227110225222156364 init_state
stage of the initialization of the link properties (dimensions, etc)
int frame_blocked_in
If set, the source filter can not generate a frame as is.
FFFramePool frame_pool
Pool of frames used for allocations.
int cfg_format
Format and size of the video frames the link was configured with.
int status_out
Link output status.
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29