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

Stefano Sabatini stefano.sabatini-lala
Sun Mar 30 23:58:07 CEST 2008


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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-ffmpeg-use-parse-number-or-die-02.patch
Type: text/x-diff
Size: 5969 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080330/97e3aad9/attachment.patch>



More information about the ffmpeg-devel mailing list