[FFmpeg-devel] lavfi: introduce a new way of designing filters

Nicolas George george at nsup.org
Sat Dec 24 19:41:32 EET 2016


This rather long patch series introduces a new way of designing filters.

The series is rather long in number of patches, but each step is quite
simple and straightforward.

The new design is this: instead of having filter_frame and request_frame
on all pads, filters have a single callback, activate, and examine the
links' FIFOs and status to decide what they need to do and do it.

Note that a lot of filters already do it: filter_frame adds the frame to a
queue, request_frame detects EOF, and both call a common processing
function: the common processing function would become activate.

A lot of helper functions are there to make this as lightweight as
possible.

Each step passes FATE.

The API I intend for filter starts to be visible, therefore I would like
advice about how convenient and elegant people find it.

get_frame_internal() in buffersink after the last patch shows the kind of
structure I expect. But it is made more complicated because, except when
NO_REQUEST is set, it must also drive the whole graph.

Simpler cases would look like that:

    if (ff_link_consume_*(input, &frame)) {
	process_the(frame);
    } else if (ff_link_acknowledge_status(inlink)) {
	process_EOF();
    } else {
	mark_input_where_frames_are_needed();
    }

Or maybe add a "return 0" after mark_input_where_frames_are_needed() and
process both the frame and EOF after the conditions.


[PATCH 01/17] lavfi: add ff_link_acknowledge_status().
[PATCH 02/17] lavfi: export ff_filter_set_ready() to the library.
[PATCH 03/17] lavfi: implement ff_link_make_frame_writable().
[PATCH 04/17] lavfi: merge two variables after a recent commit.
[PATCH 05/17] lavfi: add ff_link_process_commands().
[PATCH 06/17] lavfi: add ff_link_process_timeline().
[PATCH 07/17] lavfi: pass min explicitly to samples_ready().
[PATCH 08/17] lavfi: add helpers to consume frames from link FIFOs.
[PATCH 09/17] lavfi: use the consume helpers in
[PATCH 10/17] lavfi: add AVFilter.activate.
[PATCH 11/17] lavfi: cosmetic: remove forward declaration.
[PATCH 12/17] lavfi: move ff_update_link_current_pts() into the
[PATCH 13/17] lavfi: add ff_link_set_frame_wanted().
[PATCH 14/17] lavfi: disallow ff_request_frame for filters using
[PATCH 15/17] lavfi: make two functions static.
[PATCH 16/17] lavfi: do not call ff_filter_frame() with activate.
[PATCH 17/17] lavfi/buffersink: move to the new design.


More information about the ffmpeg-devel mailing list