[FFmpeg-devel] [RFC] av_tree enumeration

Stefano Sabatini stefano.sabatini-lala
Sun Nov 15 13:20:22 CET 2009


On date Sunday 2009-11-15 01:48:05 +0100, Michael Niedermayer encoded:
> On Sun, Nov 15, 2009 at 01:07:07AM +0100, Stefano Sabatini wrote:
[...]
> > > 5)
> > > Use array of compile time constant size
> > 
> > How can we know how many elements the user is going to register?
> 
> You pick a number like 10+ count we have and increase it if someone
> has a reasonable complaint that it was too small for him.
> Also people should in general submit filters, codecs and (de)muxers
> to us not keep them private

Mans noted it is better or even necessary to keep the elements
unsorted, which makes less appealable the idea of a static array.

This way we still would have a slow O(n) next operation (unless we
change the API). An idea could be:

AVElement *elt;
AVElementIterator it;
it.reset();
while (elt = it.next())
      printf("%s\n", elt->name);

In this situation I don't have a strong opinion over the use of an
array versus a dinamically allocated list, with an array we have a
limited number of registered elements, with a list we need to free
memory and we may fail when trying to register elements due to memory
problems.

Regards.
-- 
FFmpeg = Furious and Forgiving Magnificient Plastic Evangelical Glue



More information about the ffmpeg-devel mailing list