Line |
Branch |
Exec |
Source |
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 "framequeue.h" |
33 |
|
|
|
34 |
|
|
typedef struct FilterLinkInternal { |
35 |
|
|
FilterLink l; |
36 |
|
|
|
37 |
|
|
struct FFFramePool *frame_pool; |
38 |
|
|
|
39 |
|
|
/** |
40 |
|
|
* Queue of frames waiting to be filtered. |
41 |
|
|
*/ |
42 |
|
|
FFFrameQueue fifo; |
43 |
|
|
|
44 |
|
|
/** |
45 |
|
|
* If set, the source filter can not generate a frame as is. |
46 |
|
|
* The goal is to avoid repeatedly calling the request_frame() method on |
47 |
|
|
* the same link. |
48 |
|
|
*/ |
49 |
|
|
int frame_blocked_in; |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* Link input status. |
53 |
|
|
* If not zero, all attempts of filter_frame will fail with the |
54 |
|
|
* corresponding code. |
55 |
|
|
*/ |
56 |
|
|
int status_in; |
57 |
|
|
|
58 |
|
|
/** |
59 |
|
|
* Timestamp of the input status change. |
60 |
|
|
*/ |
61 |
|
|
int64_t status_in_pts; |
62 |
|
|
|
63 |
|
|
/** |
64 |
|
|
* Link output status. |
65 |
|
|
* If not zero, all attempts of request_frame will fail with the |
66 |
|
|
* corresponding code. |
67 |
|
|
*/ |
68 |
|
|
int status_out; |
69 |
|
|
|
70 |
|
|
/** |
71 |
|
|
* True if a frame is currently wanted on the output of this filter. |
72 |
|
|
* Set when ff_request_frame() is called by the output, |
73 |
|
|
* cleared when a frame is filtered. |
74 |
|
|
*/ |
75 |
|
|
int frame_wanted_out; |
76 |
|
|
|
77 |
|
|
/** |
78 |
|
|
* Index in the age array. |
79 |
|
|
*/ |
80 |
|
|
int age_index; |
81 |
|
|
|
82 |
|
|
/** stage of the initialization of the link properties (dimensions, etc) */ |
83 |
|
|
enum { |
84 |
|
|
AVLINK_UNINIT = 0, ///< not started |
85 |
|
|
AVLINK_STARTINIT, ///< started, but incomplete |
86 |
|
|
AVLINK_INIT ///< complete |
87 |
|
|
} init_state; |
88 |
|
|
} FilterLinkInternal; |
89 |
|
|
|
90 |
|
28878873 |
static inline FilterLinkInternal *ff_link_internal(AVFilterLink *link) |
91 |
|
|
{ |
92 |
|
28878873 |
return (FilterLinkInternal*)link; |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
typedef struct FFFilterContext { |
96 |
|
|
/** |
97 |
|
|
* The public AVFilterContext. See avfilter.h for it. |
98 |
|
|
*/ |
99 |
|
|
AVFilterContext p; |
100 |
|
|
|
101 |
|
|
avfilter_execute_func *execute; |
102 |
|
|
|
103 |
|
|
// AV_CLASS_STATE_FLAG_* |
104 |
|
|
unsigned state_flags; |
105 |
|
|
|
106 |
|
|
/** |
107 |
|
|
* Ready status of the filter. |
108 |
|
|
* A non-0 value means that the filter needs activating; |
109 |
|
|
* a higher value suggests a more urgent activation. |
110 |
|
|
*/ |
111 |
|
|
unsigned ready; |
112 |
|
|
|
113 |
|
|
///< parsed expression |
114 |
|
|
struct AVExpr *enable; |
115 |
|
|
///< variable values for the enable expression |
116 |
|
|
double *var_values; |
117 |
|
|
|
118 |
|
|
struct AVFilterCommand *command_queue; |
119 |
|
|
} FFFilterContext; |
120 |
|
|
|
121 |
|
33687613 |
static inline FFFilterContext *fffilterctx(AVFilterContext *ctx) |
122 |
|
|
{ |
123 |
|
33687613 |
return (FFFilterContext*)ctx; |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
typedef struct AVFilterCommand { |
127 |
|
|
double time; ///< time expressed in seconds |
128 |
|
|
char *command; ///< command |
129 |
|
|
char *arg; ///< optional argument for the command |
130 |
|
|
int flags; |
131 |
|
|
struct AVFilterCommand *next; |
132 |
|
|
} AVFilterCommand; |
133 |
|
|
|
134 |
|
|
typedef struct FFFilterGraph { |
135 |
|
|
/** |
136 |
|
|
* The public AVFilterGraph. See avfilter.h for it. |
137 |
|
|
*/ |
138 |
|
|
AVFilterGraph p; |
139 |
|
|
|
140 |
|
|
struct FilterLinkInternal **sink_links; |
141 |
|
|
int sink_links_count; |
142 |
|
|
|
143 |
|
|
unsigned disable_auto_convert; |
144 |
|
|
|
145 |
|
|
void *thread; |
146 |
|
|
avfilter_execute_func *thread_execute; |
147 |
|
|
FFFrameQueueGlobal frame_queues; |
148 |
|
|
} FFFilterGraph; |
149 |
|
|
|
150 |
|
1317546 |
static inline FFFilterGraph *fffiltergraph(AVFilterGraph *graph) |
151 |
|
|
{ |
152 |
|
1317546 |
return (FFFilterGraph*)graph; |
153 |
|
|
} |
154 |
|
|
|
155 |
|
|
/** |
156 |
|
|
* Update the position of a link in the age heap. |
157 |
|
|
*/ |
158 |
|
|
void ff_avfilter_graph_update_heap(AVFilterGraph *graph, |
159 |
|
|
struct FilterLinkInternal *li); |
160 |
|
|
|
161 |
|
|
/** |
162 |
|
|
* Allocate a new filter context and return it. |
163 |
|
|
* |
164 |
|
|
* @param filter what filter to create an instance of |
165 |
|
|
* @param inst_name name to give to the new filter context |
166 |
|
|
* |
167 |
|
|
* @return newly created filter context or NULL on failure |
168 |
|
|
*/ |
169 |
|
|
AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name); |
170 |
|
|
|
171 |
|
|
/** |
172 |
|
|
* Remove a filter from a graph; |
173 |
|
|
*/ |
174 |
|
|
void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter); |
175 |
|
|
|
176 |
|
|
int ff_filter_activate(AVFilterContext *filter); |
177 |
|
|
|
178 |
|
|
/** |
179 |
|
|
* Parse filter options into a dictionary. |
180 |
|
|
* |
181 |
|
|
* @param logctx context for logging |
182 |
|
|
* @param priv_class a filter's private class for shorthand options or NULL |
183 |
|
|
* @param options dictionary to store parsed options in |
184 |
|
|
* @param args options string to parse |
185 |
|
|
* |
186 |
|
|
* @return a non-negative number on success, a negative error code on failure |
187 |
|
|
*/ |
188 |
|
|
int ff_filter_opt_parse(void *logctx, const AVClass *priv_class, |
189 |
|
|
AVDictionary **options, const char *args); |
190 |
|
|
|
191 |
|
|
int ff_graph_thread_init(FFFilterGraph *graph); |
192 |
|
|
|
193 |
|
|
void ff_graph_thread_free(FFFilterGraph *graph); |
194 |
|
|
|
195 |
|
|
/** |
196 |
|
|
* Negotiate the media format, dimensions, etc of all inputs to a filter. |
197 |
|
|
* |
198 |
|
|
* @param filter the filter to negotiate the properties for its inputs |
199 |
|
|
* @return zero on successful negotiation |
200 |
|
|
*/ |
201 |
|
|
int ff_filter_config_links(AVFilterContext *filter); |
202 |
|
|
|
203 |
|
|
/* misc trace functions */ |
204 |
|
|
|
205 |
|
|
#define FF_TPRINTF_START(ctx, func) ff_tlog(NULL, "%-16s: ", #func) |
206 |
|
|
|
207 |
|
|
#ifdef TRACE |
208 |
|
|
void ff_tlog_link(void *ctx, AVFilterLink *link, int end); |
209 |
|
|
#else |
210 |
|
|
#define ff_tlog_link(ctx, link, end) do { } while(0) |
211 |
|
|
#endif |
212 |
|
|
|
213 |
|
|
/** |
214 |
|
|
* Run one round of processing on a filter graph. |
215 |
|
|
*/ |
216 |
|
|
int ff_filter_graph_run_once(AVFilterGraph *graph); |
217 |
|
|
|
218 |
|
|
/** |
219 |
|
|
* Process the commands queued in the link up to the time of the frame. |
220 |
|
|
* Commands will trigger the process_command() callback. |
221 |
|
|
* @return >= 0 or AVERROR code. |
222 |
|
|
*/ |
223 |
|
|
int ff_inlink_process_commands(AVFilterLink *link, const AVFrame *frame); |
224 |
|
|
|
225 |
|
|
#endif /* AVFILTER_AVFILTER_INTERNAL_H */ |
226 |
|
|
|