History

lavfi/framesync2: implement "activate" design.

With this helper API, filters that used the first framesync helper API can easily be changed to use the new and more extensible design for filters with a single activate() callback.

Nicolas George committed 9 years ago

Commit 4e0e9ce1 parent ed1c8842 files · +82 −161Browse files

Showing the changes to libavfilter/framesync2.h (1 of 2 files). Show all

Unified · Split

libavfilter/framesync2.h+14−63
@@ -25,7 +25,6 @@ · 24 unmodified lines
25 25
26/*26/*
27 * TODO27 * TODO
28 * Callback-based API similar to dualinput.
29 * Export convenient options.28 * Export convenient options.
30 */29 */
31 30
@@ -41,16 +40,9 @@ · 9 unmodified lines
41 * situations where some stream extend beyond the beginning or the end of40 * situations where some stream extend beyond the beginning or the end of
42 * others can be configured.41 * others can be configured.
43 *42 *
44 * The basic working of this API is the following:43 * The basic working of this API is the following: set the on_event
45 *44 * callback, then call ff_framesync2_activate() from the filter's activate
46 * - When a frame is available on any input, add it using45 * callback.
47 * ff_framesync2_add_frame().
48 *
49 * - When a frame event is ready to be processed (i.e. after adding a frame
50 * or when requested on input):
51 * - call ff_framesync2_next();
52 * - if fs->frame_ready is true, process the frames;
53 * - call ff_framesync2_drop().
54 */46 */
55 47
56/**48/**
@@ -82,11 +74,6 @@ enum FFFrameSyncExtMode { · 25 unmodified lines
82 */74 */
83typedef struct FFFrameSyncIn {75typedef struct FFFrameSyncIn {
84 76
85 /**
86 * Queue of incoming AVFrame, and NULL to mark EOF
87 */
88 struct FFBufQueue queue;
89
90 /**77 /**
91 * Extrapolation mode for timestamps before the first frame78 * Extrapolation mode for timestamps before the first frame
92 */79 */
@@ -152,7 +139,11 @@ typedef struct FFFrameSyncIn { · 59 unmodified lines
152 */139 */
153typedef struct FFFrameSync {140typedef struct FFFrameSync {
154 const AVClass *class;141 const AVClass *class;
155 void *parent;142
143 /**
144 * Parent filter context.
145 */
146 AVFilterContext *parent;
156 147
157 /**148 /**
158 * Number of input streams149 * Number of input streams
@@ -213,11 +204,11 @@ typedef struct FFFrameSync { · 54 unmodified lines
213 * The entire structure is expected to be already set to 0.204 * The entire structure is expected to be already set to 0.
214 *205 *
215 * @param fs frame sync structure to initialize206 * @param fs frame sync structure to initialize
216 * @param parent parent object, used for logging207 * @param parent parent AVFilterContext object
217 * @param nb_in number of inputs208 * @param nb_in number of inputs
218 * @return >= 0 for success or a negative error code209 * @return >= 0 for success or a negative error code
219 */210 */
220int ff_framesync2_init(FFFrameSync *fs, void *parent, unsigned nb_in);211int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in);
221 212
222/**213/**
223 * Configure a frame sync structure.214 * Configure a frame sync structure.
@@ -233,29 +224,6 @@ int ff_framesync2_configure(FFFrameSync *fs); · 9 unmodified lines
233 */224 */
234void ff_framesync2_uninit(FFFrameSync *fs);225void ff_framesync2_uninit(FFFrameSync *fs);
235 226
236/**
237 * Add a frame to an input
238 *
239 * Typically called from the filter_frame() method.
240 *
241 * @param fs frame sync structure
242 * @param in index of the input
243 * @param frame input frame, or NULL for EOF
244 */
245int ff_framesync2_add_frame(FFFrameSync *fs, unsigned in, AVFrame *frame);
246
247/**
248 * Prepare the next frame event.
249 *
250 * The status of the operation can be found in fs->frame_ready and fs->eof.
251 */
252void ff_framesync2_next(FFFrameSync *fs);
253
254/**
255 * Drop the current frame event.
256 */
257void ff_framesync2_drop(FFFrameSync *fs);
258
259/**227/**
260 * Get the current frame in an input.228 * Get the current frame in an input.
261 *229 *
@@ -270,28 +238,11 @@ int ff_framesync2_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, · 8 unmodified lines
270 unsigned get);238 unsigned get);
271 239
272/**240/**
273 * Process one or several frame using the on_event callback.241 * Examine the frames in the filter's input and try to produce output.
274 *
275 * @return number of frames processed or negative error code
276 */
277int ff_framesync2_process_frame(FFFrameSync *fs, unsigned all);
278
279
280/**
281 * Accept a frame on a filter input.
282 *
283 * This function can be the complete implementation of all filter_frame
284 * methods of a filter using framesync.
285 */
286int ff_framesync2_filter_frame(FFFrameSync *fs, AVFilterLink *inlink,
287 AVFrame *in);
288
289/**
290 * Request a frame on the filter output.
291 *242 *
292 * This function can be the complete implementation of all filter_frame243 * This function can be the complete implementation of the activate
293 * methods of a filter using framesync if it has only one output.244 * method of a filter using framesync2.
294 */245 */
295int ff_framesync2_request_frame(FFFrameSync *fs, AVFilterLink *outlink);246int ff_framesync2_activate(FFFrameSync *fs);
296 247
297#endif /* AVFILTER_FRAMESYNC2_H */248#endif /* AVFILTER_FRAMESYNC2_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t