[FFmpeg-devel] [PATCH] Enhance ffmpeg.c:opt_default()

Michael Niedermayer michaelni
Sat May 17 16:14:32 CEST 2008


On Sat, May 17, 2008 at 12:24:58PM +0200, Stefano Sabatini wrote:
> On date Friday 2008-05-16 18:24:11 +0200, Michael Niedermayer encoded:
> > On Fri, May 16, 2008 at 01:57:09AM +0200, Stefano Sabatini wrote:
> > > On date Thursday 2008-05-15 01:26:58 +0200, Michael Niedermayer encoded:
> [...]
> > > > av_set_string() should make it clear to the caller if an error happened
> > > > and the code should then not continue blindly.
> > > > These wraper and exit() functions really are ugly.
> > > > 
> > > > a "const char **error" argument instead of av_log() calls seems to be
> > > > an option.
> > > 
> > > Michael, do you prefer the attached solution? (yes I'll split it if
> > > you approve the general idea.)
> > > 
> > > I'm defining a new av_set_string2() with this signature:
> > > const AVOption *av_set_string2(void *obj, const char *name, const char *val, const char **error_ptr);
> > > 
> > > which returns the pointer to the option if found even if the value
> > > wasn't valid, in this case sets error_ptr to a static string
> > > containing an error message: this function uses uses the new
> > > av_set_number2().
> > > 
> > > In order to preserve the semantic of av_set_{double|q|int} I'm also
> > > keeping a function av_set_number() with the old semantic and
> > > signature.
> > > 
> > > Comments are welcome.
> [...]
> > > Index: libavcodec/avcodec.h
> > > ===================================================================
> > > --- libavcodec/avcodec.h	(revision 13158)
> > > +++ libavcodec/avcodec.h	(working copy)
> > > @@ -30,7 +30,7 @@
> > >  #include "libavutil/avutil.h"
> > >  
> > >  #define LIBAVCODEC_VERSION_MAJOR 51
> > > -#define LIBAVCODEC_VERSION_MINOR 56
> > > +#define LIBAVCODEC_VERSION_MINOR 57
> > >  #define LIBAVCODEC_VERSION_MICRO  0
> > >  
> > >  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> > > Index: libavcodec/opt.h
> > > ===================================================================
> > > --- libavcodec/opt.h	(revision 13158)
> > > +++ libavcodec/opt.h	(working copy)
> > > @@ -73,6 +73,7 @@
> > >  
> > >  const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
> > >  const AVOption *av_set_string(void *obj, const char *name, const char *val);
> > > +const AVOption *av_set_string2(void *obj, const char *name, const char *val, const char **error_ptr);
> > >  const AVOption *av_set_double(void *obj, const char *name, double n);
> > >  const AVOption *av_set_q(void *obj, const char *name, AVRational n);
> > >  const AVOption *av_set_int(void *obj, const char *name, int64_t n);
> > > Index: libavcodec/opt.c
> > > ===================================================================
> > > --- libavcodec/opt.c	(revision 13158)
> > > +++ libavcodec/opt.c	(working copy)
> > > @@ -25,6 +25,7 @@
> > >   * @author Michael Niedermayer <michaelni at gmx.at>
> > >   */
> > >  
> > > +#include <libavutil/avstring.h>
> > >  #include "avcodec.h"
> > >  #include "opt.h"
> > >  #include "eval.h"
> > > @@ -47,15 +48,19 @@
> > >      else                     return (*(AVClass**)obj)->option;
> > >  }
> > >  
> > > -static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
> > > +static const AVOption *av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const char **error_ptr){
> > >      const AVOption *o= av_find_opt(obj, name, NULL, 0, 0);
> > > +    static char error[128];
> > > +
> > 
> > rejected
> 
> Well I know it sucks like a solution, what about to allocate the error
> buffer and leave to the av_set_string2() user to free it?

RTFS eval.c

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080517/418afe47/attachment.pgp>



More information about the ffmpeg-devel mailing list