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.
Showing the changes to libavfilter/framesync2.h (1 of 2 files). Show all
Unified · Split
| @@ -25,7 +25,6 @@ · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | /* |
| 27 | 27 | * TODO |
| 28 | − * Callback-based API similar to dualinput. | |
| 29 | 28 | * Export convenient options. |
| 30 | 29 | */ |
| 31 | 30 | |
| @@ -41,16 +40,9 @@ · 9 unmodified lines | ||
| 41 | 40 | * situations where some stream extend beyond the beginning or the end of |
| 42 | 41 | * others can be configured. |
| 43 | 42 | * |
| 44 | − * The basic working of this API is the following: | |
| 45 | − * | |
| 46 | − * - When a frame is available on any input, add it using | |
| 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(). | |
| 43 | + * The basic working of this API is the following: set the on_event | |
| 44 | + * callback, then call ff_framesync2_activate() from the filter's activate | |
| 45 | + * callback. | |
| 54 | 46 | */ |
| 55 | 47 | |
| 56 | 48 | /** |
| @@ -82,11 +74,6 @@ enum FFFrameSyncExtMode { · 25 unmodified lines | ||
| 82 | 74 | */ |
| 83 | 75 | typedef struct FFFrameSyncIn { |
| 84 | 76 | |
| 85 | − /** | |
| 86 | − * Queue of incoming AVFrame, and NULL to mark EOF | |
| 87 | − */ | |
| 88 | − struct FFBufQueue queue; | |
| 89 | − | |
| 90 | 77 | /** |
| 91 | 78 | * Extrapolation mode for timestamps before the first frame |
| 92 | 79 | */ |
| @@ -152,7 +139,11 @@ typedef struct FFFrameSyncIn { · 59 unmodified lines | ||
| 152 | 139 | */ |
| 153 | 140 | typedef struct FFFrameSync { |
| 154 | 141 | const AVClass *class; |
| 155 | − void *parent; | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * Parent filter context. | |
| 145 | + */ | |
| 146 | + AVFilterContext *parent; | |
| 156 | 147 | |
| 157 | 148 | /** |
| 158 | 149 | * Number of input streams |
| @@ -213,11 +204,11 @@ typedef struct FFFrameSync { · 54 unmodified lines | ||
| 213 | 204 | * The entire structure is expected to be already set to 0. |
| 214 | 205 | * |
| 215 | 206 | * @param fs frame sync structure to initialize |
| 216 | − * @param parent parent object, used for logging | |
| 207 | + * @param parent parent AVFilterContext object | |
| 217 | 208 | * @param nb_in number of inputs |
| 218 | 209 | * @return >= 0 for success or a negative error code |
| 219 | 210 | */ |
| 220 | −int ff_framesync2_init(FFFrameSync *fs, void *parent, unsigned nb_in); | |
| 211 | +int ff_framesync2_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in); | |
| 221 | 212 | |
| 222 | 213 | /** |
| 223 | 214 | * Configure a frame sync structure. |
| @@ -233,29 +224,6 @@ int ff_framesync2_configure(FFFrameSync *fs); · 9 unmodified lines | ||
| 233 | 224 | */ |
| 234 | 225 | void 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 | − */ | |
| 245 | −int 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 | − */ | |
| 252 | −void ff_framesync2_next(FFFrameSync *fs); | |
| 253 | − | |
| 254 | −/** | |
| 255 | − * Drop the current frame event. | |
| 256 | − */ | |
| 257 | −void ff_framesync2_drop(FFFrameSync *fs); | |
| 258 | − | |
| 259 | 227 | /** |
| 260 | 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 | 238 | unsigned get); |
| 271 | 239 | |
| 272 | 240 | /** |
| 273 | − * Process one or several frame using the on_event callback. | |
| 274 | − * | |
| 275 | − * @return number of frames processed or negative error code | |
| 276 | − */ | |
| 277 | −int 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 | − */ | |
| 286 | −int ff_framesync2_filter_frame(FFFrameSync *fs, AVFilterLink *inlink, | |
| 287 | − AVFrame *in); | |
| 288 | − | |
| 289 | −/** | |
| 290 | − * Request a frame on the filter output. | |
| 241 | + * Examine the frames in the filter's input and try to produce output. | |
| 291 | 242 | * |
| 292 | − * This function can be the complete implementation of all filter_frame | |
| 293 | − * methods of a filter using framesync if it has only one output. | |
| 243 | + * This function can be the complete implementation of the activate | |
| 244 | + * method of a filter using framesync2. | |
| 294 | 245 | */ |
| 295 | −int ff_framesync2_request_frame(FFFrameSync *fs, AVFilterLink *outlink); | |
| 246 | +int ff_framesync2_activate(FFFrameSync *fs); | |
| 296 | 247 | |
| 297 | 248 | #endif /* AVFILTER_FRAMESYNC2_H */ |