[FFmpeg-devel] Extending AVOption system
Mon Jun 9 16:45:05 CEST 2008
On date Sunday 2008-06-08 21:17:51 +0200, Michael Niedermayer encoded:
> On Sun, Jun 08, 2008 at 07:53:07PM +0200, Stefano Sabatini wrote:
> > On date Sunday 2008-06-08 15:40:01 +0200, Michael Niedermayer encoded:
> > > On Sun, Jun 08, 2008 at 10:38:31AM +0200, Stefano Sabatini wrote:
> > > > On date Saturday 2008-06-07 15:12:37 +0200, Michael Niedermayer encoded:
> > [...]
> > > > > Basically we need a fast and efficient way to make all the values
> > > > > from a struct and the AVOption constants available to eval() and that
> > > > > has to be alot faster than iterating over them once. It can surely be
> > > > > done, if someone volunteers to do the work i can think about how it
> > > > > can be done ...
> > > >
> > > > I'm interested, if you can elaborate more on this I can try to
> > > > implement it as time permits. If it can help I have already a naive
> > > > implementation of an hash container (which I'm going to post anyway on
> > > > the libavutil hash container thread).
> > >
> > > Get these darn hash tables out of your mind, they wont do any good here :)
> > > Ok heres a design suggestion, in no particular order:
> > >
> > > 1. Sort all AVOption table entries by name. (diego will love this as well)
> > >
> > > 2. in av_set_string() go over the string and look up all [a-z_]* via bsearch()
> > > in the avoptions array.
> > > for each replace the string by the literal numeric value of the constant
> > > from the AVOptions array, value from the struct or min/max/default of
> > > the current option.
> > > After that handle the string as it is currently.
> > Michael, eventual applications which work with non sorted arrays
> > won't work anymore with bsearch(), so I have to provide all the required
> > ifdeffery to keep backward compatibility, right?
> hmm, who is using AVOptions arrays outside lav* ?
Who can say? Anyway since we're indeed breaking backward compatibility
a major bump seems anyway the right thing to do (again: I can also
live without such a major bump if you prefer like this, just making my
Rethinking at it the major bump would be required in libavutil, since
we're requesting at some point these two things:
1) AVClass.option array has to be sorted
2) AVClass.option_count has to be correctly specified
If this is not true then the behaviour of the function which deal with
AVClass is undefined.
So this is my plan:
1) define in AVClass the option_count field, minor libavutil bump required
2) sort the options array
3) set in the various AVClasses the option_count field
4) *require* in AVClass that the option array are sorted and the
option_count is set to a meaningful value, bump libavutil major if
you agree, at this point libav* are already ready for the bump
5) use bsearch in av_opt_find
I already performed steps from 1 to 5 in my working copy and it seems
to work fine (regression test passed).
FFmpeg = Frightening Funny Multimedia Portable EniGma
More information about the ffmpeg-devel