FFmpeg
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 "framequeue.h"
32 
33 typedef struct FilterLinkInternal {
35 
37 
38  /**
39  * Queue of frames waiting to be filtered.
40  */
42 
43  /**
44  * If set, the source filter can not generate a frame as is.
45  * The goal is to avoid repeatedly calling the request_frame() method on
46  * the same link.
47  */
49 
50  /**
51  * Link input status.
52  * If not zero, all attempts of filter_frame will fail with the
53  * corresponding code.
54  */
55  int status_in;
56 
57  /**
58  * Timestamp of the input status change.
59  */
60  int64_t status_in_pts;
61 
62  /**
63  * Link output status.
64  * If not zero, all attempts of request_frame will fail with the
65  * corresponding code.
66  */
68 
69  /**
70  * Index in the age array.
71  */
72  int age_index;
73 
74  /** stage of the initialization of the link properties (dimensions, etc) */
75  enum {
76  AVLINK_UNINIT = 0, ///< not started
77  AVLINK_STARTINIT, ///< started, but incomplete
78  AVLINK_INIT ///< complete
79  } init_state;
81 
83 {
84  return (FilterLinkInternal*)link;
85 }
86 
87 typedef struct AVFilterCommand {
88  double time; ///< time expressed in seconds
89  char *command; ///< command
90  char *arg; ///< optional argument for the command
91  int flags;
94 
95 typedef struct FFFilterGraph {
96  /**
97  * The public AVFilterGraph. See avfilter.h for it.
98  */
100 
103 
105 
106  void *thread;
109 } FFFilterGraph;
110 
112 {
113  return (FFFilterGraph*)graph;
114 }
115 
116 /**
117  * Update the position of a link in the age heap.
118  */
120  struct FilterLinkInternal *li);
121 
122 /**
123  * Allocate a new filter context and return it.
124  *
125  * @param filter what filter to create an instance of
126  * @param inst_name name to give to the new filter context
127  *
128  * @return newly created filter context or NULL on failure
129  */
130 AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name);
131 
132 /**
133  * Remove a filter from a graph;
134  */
136 
138 
139 /**
140  * Parse filter options into a dictionary.
141  *
142  * @param logctx context for logging
143  * @param priv_class a filter's private class for shorthand options or NULL
144  * @param options dictionary to store parsed options in
145  * @param args options string to parse
146  *
147  * @return a non-negative number on success, a negative error code on failure
148  */
149 int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
150  AVDictionary **options, const char *args);
151 
153 
155 
156 #endif /* AVFILTER_AVFILTER_INTERNAL_H */
ff_link_internal
static FilterLinkInternal * ff_link_internal(AVFilterLink *link)
Definition: avfilter_internal.h:82
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.
Definition: avfilter.c:834
FFFilterGraph
Definition: avfilter_internal.h:95
FFFilterGraph::sink_links
struct FilterLinkInternal ** sink_links
Definition: avfilter_internal.h:101
filter
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
Definition: filter_design.txt:228
AVDictionary
Definition: dict.c:34
FilterLinkInternal
Definition: avfilter_internal.h:33
FFFramePool
Frame pool.
Definition: framepool.c:31
AVFilterCommand::flags
int flags
Definition: avfilter_internal.h:91
FFFilterGraph::sink_links_count
int sink_links_count
Definition: avfilter_internal.h:102
FFFilterGraph::thread_execute
avfilter_execute_func * thread_execute
Definition: avfilter_internal.h:107
FFFrameQueueGlobal
Structure to hold global options and statistics for frame queues.
Definition: framequeue.h:46
link
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
Definition: filter_design.txt:23
FilterLinkInternal::AVLINK_STARTINIT
@ AVLINK_STARTINIT
started, but incomplete
Definition: avfilter_internal.h:77
ff_avfilter_graph_update_heap
void ff_avfilter_graph_update_heap(AVFilterGraph *graph, struct FilterLinkInternal *li)
Update the position of a link in the age heap.
Definition: avfiltergraph.c:1365
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
framequeue.h
fffiltergraph
static FFFilterGraph * fffiltergraph(AVFilterGraph *graph)
Definition: avfilter_internal.h:111
ff_filter_alloc
AVFilterContext * ff_filter_alloc(const AVFilter *filter, const char *inst_name)
Allocate a new filter context and return it.
Definition: avfilter.c:685
AVFilterGraph
Definition: avfilter.h:813
FilterLinkInternal::status_out
int status_out
Link output status.
Definition: avfilter_internal.h:67
ff_filter_activate
int ff_filter_activate(AVFilterContext *filter)
Definition: avfilter.c:1374
FFFrameQueue
Queue of AVFrame pointers.
Definition: framequeue.h:53
options
const OptionDef options[]
FilterLinkInternal::init_state
enum FilterLinkInternal::@264 init_state
stage of the initialization of the link properties (dimensions, etc)
FilterLinkInternal::age_index
int age_index
Index in the age array.
Definition: avfilter_internal.h:72
avfilter_execute_func
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:810
AVFilterCommand::next
struct AVFilterCommand * next
Definition: avfilter_internal.h:92
FFFilterGraph::frame_queues
FFFrameQueueGlobal frame_queues
Definition: avfilter_internal.h:108
FilterLinkInternal::AVLINK_INIT
@ AVLINK_INIT
complete
Definition: avfilter_internal.h:78
FilterLinkInternal::frame_blocked_in
int frame_blocked_in
If set, the source filter can not generate a frame as is.
Definition: avfilter_internal.h:48
FFFilterGraph::thread
void * thread
Definition: avfilter_internal.h:106
FFFilterGraph::disable_auto_convert
unsigned disable_auto_convert
Definition: avfilter_internal.h:104
AVFilterCommand
Definition: avfilter_internal.h:87
FilterLinkInternal::status_in
int status_in
Link input status.
Definition: avfilter_internal.h:55
AVFilter
Filter definition.
Definition: avfilter.h:166
ff_filter_graph_remove_filter
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
Remove a filter from a graph;.
Definition: avfiltergraph.c:98
avfilter.h
FilterLinkInternal::AVLINK_UNINIT
@ AVLINK_UNINIT
not started
Definition: avfilter_internal.h:76
AVFilterCommand::command
char * command
command
Definition: avfilter_internal.h:89
AVFilterCommand::arg
char * arg
optional argument for the command
Definition: avfilter_internal.h:90
FFFilterGraph::p
AVFilterGraph p
The public AVFilterGraph.
Definition: avfilter_internal.h:99
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
ff_graph_thread_free
void ff_graph_thread_free(FFFilterGraph *graph)
Definition: avfiltergraph.c:70
FilterLinkInternal::l
AVFilterLink l
Definition: avfilter_internal.h:34
ff_graph_thread_init
int ff_graph_thread_init(FFFilterGraph *graph)
Definition: avfiltergraph.c:74
FilterLinkInternal::frame_pool
struct FFFramePool * frame_pool
Definition: avfilter_internal.h:36
FilterLinkInternal::fifo
FFFrameQueue fifo
Queue of frames waiting to be filtered.
Definition: avfilter_internal.h:41
FilterLinkInternal::status_in_pts
int64_t status_in_pts
Timestamp of the input status change.
Definition: avfilter_internal.h:60
AVFilterCommand::time
double time
time expressed in seconds
Definition: avfilter_internal.h:88