[FFmpeg-devel] [PATCH] lavfi: add avfilter_get_class() and iteration callbacks

Stefano Sabatini stefasab at gmail.com
Sun Aug 12 12:10:50 CEST 2012

On date Friday 2012-08-10 01:44:54 +0200, Michael Niedermayer encoded:
> On Thu, Aug 09, 2012 at 10:58:21PM +0200, Stefano Sabatini wrote:
> > +static const AVClass *filter_child_class_next(const AVClass *prev)
> > +{
> > +    AVFilter **filter_ptr = NULL;
> > +
> > +    /* find the filter that corresponds to prev */
> > +    while (prev && (filter_ptr = av_filter_next(filter_ptr)))
> > +        if ((*filter_ptr)->priv_class == prev)
> > +            break;
> this is a bit fragile
> filter_ptr starts at NULL and will then iterate over an array of
> pointers but it will not become null again, thus if prev is not
> found it will crash

Fixed the test and added an additional check in case prev!=NULL and no
filter was found.

BTW note that I find this whole _child_class_next business rather
ugly, it imposes that two distinct contexts cannot share the same
class, requires O(N^2) time complexity for iteration, and I find the
adopted terminology and documentation overly confusing.

A simple iteration over the list of registered filters may be IMO much
simpler and flexible, but I'm retaining the logic for consistency with
how it is done for the other components.
FFmpeg = Foolish Foolish Mournful Pitiless Enhancing Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-lavfi-add-avfilter_get_class-and-iteration-callbacks.patch
Type: text/x-diff
Size: 2828 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120812/9c3fd634/attachment.bin>

More information about the ffmpeg-devel mailing list