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

Michael Niedermayer michaelni
Wed Aug 20 01:43:17 CEST 2008


On Mon, Aug 11, 2008 at 11:43:53PM +0200, Stefano Sabatini wrote:
> 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

the the?


> + * 'k', 'M', 'G', 'ki', 'Mi', 'Gi' and 'B' postfixes. This allows
> + * using f.e. kB, MiB, G and B as a postfix.

<list> postfixes. This allows using f.e <list> postfix. 
what is this supposed to mean?


> + * Values are expressed in
> + * bits, unless the 'B' postfix is used, in this case the values are
> + * assumed to be in bytes.

what?


> + * @param tail if non-NULL put at this address the pointer to the
> + * character just after the part of the string successfully parsed

parse error


> + * @return the value of the parsed string as a numer of bits

numer!? 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) {

why didnt you just copy this?  :(((((((((((((((((


> +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)

i wonder if it would make sense to just use the whole expression evaluator
instead of av_strtod().
Actually i think this would be a great idea

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Frequently ignored awnser#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- 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/20080820/b3c3092b/attachment.pgp>



More information about the ffmpeg-devel mailing list