[FFmpeg-devel] [RFC] av_tree enumeration
Stefano Sabatini
stefano.sabatini-lala
Sat Nov 14 16:39:24 CET 2009
On date Saturday 2009-11-14 12:22:58 +0100, Michael Niedermayer encoded:
> On Sat, Nov 14, 2009 at 03:00:58PM +1100, Peter Ross wrote:
> > On Sat, Nov 14, 2009 at 01:41:17AM +0100, Stefano Sabatini wrote:
> > > Hi all,
> > >
> > > I'm considering to use av_tree for storing elements of FFmpeg,
> > > e.g. filters, codecs etc.
> > [...]
> >
> > > Could someone explain how to use that function, and if it can be used
> > > to do this? I could try some guesswork, but it's faster if someone can
> > > give some hints about it.
> >
> > Um, call av_tree_enumerate with pointer to the tree and a callback
> > function. The callback function is invoked for every item in the tree.
> >
> > Example:
> >
> > int print_item(void *cntx, void *elem) {
> > Datatype *s = elem;
> > printf("%s\n", s->name);
> > return 0;
> > }
> >
> > av_tree_enumerate(tree, cntx, print_item);
> >
> > I am using a copy of tree.c/h in another project, and have made the following
> > (trivial) fixes to av_tree_enumerate().
> >
> > - enumerate the tree in ascending/left-to-right order
>
> suggestion implemented
>
>
> > - stop enumerating if the callback function returns < 0.
>
> I think that can be done through use of cmp() and opaque in my code with
> the advantage that if its not needed no extra return checks are needed
Further suggestion:
* Fix crash when t == NULL (see attached patch).
* There is no point into having the enu function return something, so
I'd say to change it from int enu(...) to void enu(...).
Regards.
--
FFmpeg = Funny and Forgiving Mystic Programmable Enchanting God
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tree-enumerate-fix.patch
Type: text/x-diff
Size: 685 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091114/0f046483/attachment.patch>
More information about the ffmpeg-devel
mailing list