[FFmpeg-devel] [PATCH] -fs parameter human friendly

Stefano Sabatini stefano.sabatini-lala
Wed Aug 20 01:36:30 CEST 2008


On date Monday 2008-08-11 23:43:53 +0200, Stefano Sabatini encoded:
> On date Monday 2008-08-11 21:23:24 +0200, Michael Niedermayer encoded:
> > On Mon, Aug 11, 2008 at 11:00:17AM +0200, Stefano Sabatini wrote:
> > > Hi all,
> > > 
> > > addresses issue 551. It exports the av_strtod() function to eval.h and
> > > uses it in ffmpeg.c (minor bump missing for easying the maintainance
> > > of the patch).
> > [...]
> > > +static int opt_limit_filesize(const char* opt, const char* arg)
> > > +{
> > > +    char *tail;
> > > +    limit_filesize = av_strtod(arg, &tail);
> > > +    if(*tail) {
> > > +        fprintf(stderr, "Invalid value for %s: %s\n", opt, arg);
> > > +        av_exit(1);
> > > +    }
> > > +    return 0;
> > > +}
> > > +
> > >  static const OptionDef options[] = {
> > >      /* main options */
> > >      { "L", OPT_EXIT, {(void*)show_license}, "show license" },
> > > @@ -3761,7 +3773,7 @@
> > >      { "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream[:syncfile:syncstream]" },
> > >      { "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "set meta data information of outfile from infile", "outfile:infile" },
> > >      { "t", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_time}, "record or transcode \"duration\" seconds of audio/video", "duration" },
> > > -    { "fs", HAS_ARG | OPT_INT64, {(void*)&limit_filesize}, "set the limit file size in bytes", "limit_size" }, //
> > > +    { "fs", OPT_FUNC2 | HAS_ARG, {(void*)opt_limit_filesize}, "set the limit file size", "limit_size" }, //
> > 
> > this is not a reasonable solution
> > 
> > fix OPT_INT64 instead
> 
> Yep, bright idea.
> 
> Regression test passed.
> 
> Regards.
> -- 
> FFmpeg = Fostering and Frightening Meaningful Proud Ecstatic Goblin

> Index: libavcodec/eval.h
> ===================================================================
> --- libavcodec/eval.h	(revision 14690)
> +++ libavcodec/eval.h	(working copy)
> @@ -84,4 +84,18 @@
>  double ff_parse_eval(AVEvalExpr * e, double *const_value, void *opaque);
>  void ff_eval_free(AVEvalExpr * e);
>  
> +/**
> + * Parses the value in \p name and returns its value as a double.
> + *
> + * @param name a string representing a number, may contain the the
> + * 'k', 'M', 'G', 'ki', 'Mi', 'Gi' and 'B' postfixes. This allows
> + * using f.e. kB, MiB, G and B as a postfix. Values are expressed in
> + * bits, unless the 'B' postfix is used, in this case the values are
> + * assumed to be in bytes.
> + * @param tail if non-NULL put at this address the pointer to the
> + * character just after the part of the string successfully parsed
> + * @return the value of the parsed string as a numer of bits
> + */
> +double av_strtod(const char *name, char **tail);
> +
>  #endif /* FFMPEG_EVAL_H */
> Index: libavcodec/eval.c
> ===================================================================
> --- libavcodec/eval.c	(revision 14690)
> +++ libavcodec/eval.c	(working copy)
> @@ -82,11 +82,7 @@
>      ['Y'-'E']=  24,
>  };
>  
> -/** strtod() function extended with 'k', 'M', 'G', 'ki', 'Mi', 'Gi' and 'B'
> - * postfixes.  This allows using f.e. kB, MiB, G and B as a postfix. This
> - * function assumes that the unit of numbers is bits not bytes.
> - */
> -static double av_strtod(const char *name, char **tail) {
> +double av_strtod(const char *name, char **tail) {
>      double d;
>      char *next;
>      d = strtod(name, &next);

> Index: cmdutils.c
> ===================================================================
> --- cmdutils.c	(revision 14695)
> +++ cmdutils.c	(working copy)
> @@ -29,6 +29,7 @@
>  #include "libavfilter/avfilter.h"
>  #include "libavdevice/avdevice.h"
>  #include "libavutil/avstring.h"
> +#include "libavcodec/eval.h"
>  #include "cmdutils.h"
>  #include "version.h"
>  #ifdef CONFIG_NETWORK
> @@ -42,7 +43,7 @@
>  {
>      char *tail;
>      const char *error;
> -    double d = strtod(numstr, &tail);
> +    double d = av_strtod(numstr, &tail);
>      if (*tail)
>          error= "Expected number for %s but found: %s\n";
>      else if (d < min || d > max)

Ping?
-- 
FFmpeg = Fiendish Fostering Majestic Picky Ecstatic Governor




More information about the ffmpeg-devel mailing list