[FFmpeg-devel] [PATCH 2/4] avutil/opt: check offset / constness correctness

Michael Niedermayer michaelni at gmx.at
Mon Apr 15 23:58:49 CEST 2013


On Mon, Apr 15, 2013 at 09:49:59PM +0200, Stefano Sabatini wrote:
> On date Saturday 2013-04-13 20:37:13 +0200, Michael Niedermayer encoded:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavutil/opt.c |    7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index b4d1d67..23f57b5 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -66,7 +66,7 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
> >      AVClass *class = *(AVClass**)obj;
> >  #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
> >      AVOption *o = last && last[1].name ? last + 1 : class->option;
> > -    if(o) {
> 
> > +    if(o && (o->name || o->help || o->offset || o->min || o->max || o->unit || o->default_val.i64)) {
> 
> nit: if_(o
> 
> why these additional checks?

it checks more cases with the asserts, is that usefull? no idea


> 
> >          int faulty = 0;
> >          if (o->type == AV_OPT_TYPE_DOUBLE || o->type == AV_OPT_TYPE_FLOAT) {
> >              faulty |= (o->min > o->default_val.dbl || o->default_val.dbl > o->max);
> > @@ -80,6 +80,11 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
> >              av_log(obj, AV_LOG_FATAL, "Invalid min/default/max combination in %s\n", o->name);
> >              av_assert2(0);
> >          }
> > +        if (   (o->offset && o->type == AV_OPT_TYPE_CONST && o->offset != last->offset)
> 
> what's o->offset != last->offset good for?

There are constants that use their parent fields offset, this code is
checking for them that way. Yes the code is messy/ugly ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130415/b064af8b/attachment.asc>


More information about the ffmpeg-devel mailing list