From b8dddebf3e341631d02328144e8dd9e75091fc69 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Wed, 21 Jul 2010 17:14:13 +0000 Subject: [PATCH] Clarify logic and feedback of the init() function. Originally committed as revision 24385 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavfilter/vsrc_buffer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c index d6b0b40616..c48f04af58 100644 --- a/libavfilter/vsrc_buffer.c +++ b/libavfilter/vsrc_buffer.c @@ -62,12 +62,14 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { BufferSourceContext *c = ctx->priv; + int n = 0; - if (args && sscanf(args, "%d:%d:%d", &c->w, &c->h, &c->pix_fmt) == 3) - return 0; + if (!args || (n = sscanf(args, "%d:%d:%d", &c->w, &c->h, &c->pix_fmt)) != 3) { + av_log(ctx, AV_LOG_ERROR, "Expected 3 arguments, but only %d found in '%s'\n", n, args ? args : ""); + return AVERROR(EINVAL); + } - av_log(ctx, AV_LOG_ERROR, "init() expected 3 arguments:'%s'\n", args); - return -1; + return 0; } static int query_formats(AVFilterContext *ctx)