[FFmpeg-devel] [PATCH] avfilter/buffersrc: switch to activate

Paul B Mahol onemda at gmail.com
Sat Nov 4 22:05:17 EET 2023


On Sat, Nov 4, 2023 at 8:07 PM Nicolas George <george at nsup.org> wrote:

> Paul B Mahol (12023-11-04):
> > From 31a6a78ebc3a3f8785ec7c8e5ffd4257c7eadec3 Mon Sep 17 00:00:00 2001
> > From: Paul B Mahol <onemda at gmail.com>
> > Date: Fri, 27 Oct 2023 14:26:50 +0200
> > Subject: [PATCH] avfilter/buffersrc: switch to activate
> >
> > Fixes error when caller keeps adding frames into filtergraph
> > that reached EOF by other means, for example EOF is signalled
> > by other filter in filtergraph or by buffersink.
>
> Filters with no more than one input and one output do not need to
> implement activate. If it seems they need, that indicates a bug in the
> framework. Then that bug needs to be found and fixed. This patch just
> adds code to work around it, it is not acceptable.
>

Sorry to hear your deep feelings and failed realizations for this topic and
in FFmpeg in general.
Certainly you are not, never was, and never will be central absolute
authority to say what is acceptable and what is not to do in FFmpeg code.

Now on technical side of story: buffersrc can be closed by calling
av_buffersrc_close().
And currently in master that is the only way how buffersrc can end
processing of sending more frames to filter chain.

There is possibility for filters in filtergraph to signal EOF back down
(backward) to buffersrc filter in filtergraph chain,
but that same thing is ignored by buffersrc filter. This patch address this
issue/bug.

Now why switch to .activate() is proper solution for buffersrc filter?
buffersrc filter uses request_frame(), and that one is used to count number
of failed requests when no frame is available for next filters in
filtergraph.
Inside request_frame() one can check only for EOF from inlinks, but as
buffersrc filter is source filter it have no inlinks.
Other function filter_frame() is not applicable to source filter types.

Also you forgot fact that buffersrc filter have 0 inputs and 1 output, so
to correct your claim, following holds:
Any filter with only one input and only one output of same media type is
not forced to use .activate().
Above may not hold if such 1->1 filter does modify timeline of frames.
(Drops/inserts frames/samples, like obvious example is fps filter)
Similar applies to buffersink filter, with 1 input and 0 outputs, by your
standards such filter do not need .activate(), which is obviously false.

For more insight into this subject and groundbreaking theory of filtering,
please do consult:

912969a33e313c57c906e87a7e2367b78a2160f4
lavfi/buffersink: move to the new design.

Note: the OOM happens even without split filter usage, which means its not
fault of .activate() in split filter code.



>
> --
>   Nicolas George
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list