[FFmpeg-devel] [PATCH] Make ffmpeg use parse_number_or_die instead of atoi

Michael Niedermayer michaelni
Thu Apr 3 01:11:46 CEST 2008


On Sun, Mar 30, 2008 at 11:58:07PM +0200, Stefano Sabatini wrote:
> On date Friday 2008-03-21 01:08:34 +0100, Stefano Sabatini encoded:
> > On date Friday 2008-03-07 01:34:07 +0100, Stefano Sabatini encoded:
> > > Hi,
> > > 
> > > as in $subject,
> > > 
> > > improves error management, diagnostic and reduces code size.
> > > 
> > > Note:
> > > 
> > > -    video_qscale = atof(arg);
> > > +    video_qscale = parse_number_or_die("qscale", arg, OPT_FLOAT, -1.0/0.0, 1.0/0.0);
> > >      if (video_qscale <= 0 ||
> > >          video_qscale > 255) {
> > >          fprintf(stderr, "qscale must be > 0.0 and <= 255\n");
> > > 
> > > I didn't do:
> > > video_qscale = parse_number_or_die("qscale", arg, OPT_FLOAT, nextafter(0,1), 255)
> > > 
> > > because the resulting message for an error of the kind:
> > > ffmpeg -qscale 0
> > > 
> > > would result as: 
> > > "The value for qscale was 0 which is not within 0 - 255"
> > > 
> > > which is indeed quite confusing. Anyway the code for opt_qscale is
> > > going to be removed soon with the libavilter inclusion.
> > [...]
> > 
> > Two weeks interval passed... ping!
> > 
> > Please let me know if you're interested in this.
> [...]
> 
> Hi, new ping (sorry for insisting, yes I know there are other
> priorities in this period, just resending in the case it got missed).
> 
> If you prefer I can split this patch into many pieces.
> 
> Here it is an example of the new implemented behaviour:
> ffmpeg -qscale foo
> [...]
> Expected number for qscale but found: foo
> 
> ffmpeg -qdiff -1
> [...]
> The value for qdiff was -1 which is not within 1.000000 - 31.000000
> 
> ffmpeg -strict foo
> [...]
> Expected number for strict but found: foo
> 
> ffmpeg -top -2
> [...]
> The value for top was -2 which is not within -1.000000 - 1.000000
> 
> ffmpeg -pass foo
> Expected number for pass but found: foo
> 
> ffmpeg -pass -2
> The value for pass was -2 which is not within 1.000000 - 2.000000
> 
> ffmpeg -v foo
> Expected number for v but found: foo
> 
> ffmpeg -croptop -1
> [...]
> The value for croptop was -1 which is not within 0.000000 - 2147483647.000000
> 
> Next step is to pass context to the various opt_ function like in
> r12559.
> 
> Best regards.
> -- 
> Stefano Sabatini
> Linux user number 337176 (see http://counter.li.org)

> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c	(revision 12631)
> +++ ffmpeg.c	(working copy)
> @@ -2173,12 +2173,12 @@
>  
>  static void opt_me_threshold(const char *arg)
>  {
> -    me_threshold = atoi(arg);
> +    me_threshold = parse_number_or_die("me_threshold", arg, OPT_INT64, INT_MIN, INT_MAX);
>  }
>  

>  static void opt_verbose(const char *arg)
>  {
> -    verbose = atoi(arg);
> +    verbose = parse_number_or_die("v", arg, OPT_INT64, 0, INT_MAX);
>      av_log_set_level(verbose);
>  }
>  

and negative ones ...

anyway, this patch could be split
also many of the changes are to code which will be removed. Eithe because it
should be handled through AVOption or through AVFilter

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- 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/20080403/e2f462f9/attachment.pgp>



More information about the ffmpeg-devel mailing list