[FFmpeg-devel] [PATCH] mandelbrot: fix sscanf format string
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun Nov 13 12:56:37 CET 2011
On Sat, Nov 12, 2011 at 01:32:10PM +0100, Giorgio Vazzana wrote:
> Hello,
>
> I had to apply this patch in order to pass start_x, start_y and
> start_scale parameters to the filter.
> From ac969f52d295aece30a628bed79d93ebb3bb8034 Mon Sep 17 00:00:00 2001
> From: Giorgio Vazzana <mywing81 at gmail.com>
> Date: Sat, 12 Nov 2011 13:10:06 +0100
> Subject: [PATCH] mandelbrot: fix sscanf format string
>
> Replace ',' with ':'
> ---
> libavfilter/vsrc_mandelbrot.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/libavfilter/vsrc_mandelbrot.c b/libavfilter/vsrc_mandelbrot.c
> index 16a2e10..832325b 100644
> --- a/libavfilter/vsrc_mandelbrot.c
> +++ b/libavfilter/vsrc_mandelbrot.c
> @@ -66,7 +66,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
> mb->bailout=100;
> mb->outer= NORMALIZED_ITERATION_COUNT;
> if (args)
> - sscanf(args, "%127[^:]:%127[^:]:%d,%lf:%lf:%lf", frame_size, frame_rate, &mb->maxiter, &mb->start_x, &mb->start_y, &mb->start_scale);
> + sscanf(args, "%127[^:]:%127[^:]:%d:%lf:%lf:%lf", frame_size, frame_rate, &mb->maxiter, &mb->start_x, &mb->start_y, &mb->start_scale);
I don't have a good solution but I wanted to mention that it might be a
good idea to avoid special parsing functions and complex sscanf
expressions wherever possible.
The problem is that sscanf behaviour changes with setlocale and it is
near impossible to know if the argument parsing will still be possible
with the changed rules (',' vs. '.' as decimal separator for example).
And using complex sscanf expression also makes harder to use our own
replacement (though contrary to strcasecmp it's not a great solution
anyway since we'd probably have to provide a replacement sprintf for the
application, too).
More information about the ffmpeg-devel
mailing list