[FFmpeg-devel] [PATCH] Remove "Error parsing options string [...]" messages.

Stefano Sabatini stefasab at gmail.com
Thu Aug 9 01:11:36 CEST 2012


On date Thursday 2012-08-09 00:51:50 +0200, Clément Bœsch encoded:
> This reduces from 3 to 2 messages for the same syntax error in ffprobe,
> and from 4 to 3 in filters.
> ---
>  ffprobe.c                      | 24 ++++++------------------
>  libavfilter/af_aformat.c       |  4 +---
>  libavfilter/af_amix.c          |  4 +---
>  libavfilter/af_asetnsamples.c  |  4 +---
>  libavfilter/af_asyncts.c       |  4 +---
>  libavfilter/af_channelmap.c    |  4 +---
>  libavfilter/af_channelsplit.c  |  4 +---
>  libavfilter/af_join.c          |  4 +---
>  libavfilter/af_silencedetect.c |  4 +---
>  libavfilter/asrc_anullsrc.c    |  4 +---
>  libavfilter/asrc_flite.c       |  4 +---
>  libavfilter/avf_showwaves.c    |  4 +---
>  libavfilter/buffersrc.c        |  8 ++------
>  libavfilter/src_movie.c        |  4 +---
>  libavfilter/vf_ass.c           |  4 +---
>  libavfilter/vf_blackdetect.c   |  4 +---
>  libavfilter/vf_delogo.c        |  4 +---
>  libavfilter/vf_drawtext.c      |  4 +---
>  libavfilter/vsrc_cellauto.c    |  4 +---
>  libavfilter/vsrc_life.c        |  4 +---
>  libavfilter/vsrc_mandelbrot.c  |  4 +---
>  libavfilter/vsrc_mptestsrc.c   |  4 +---
>  libavfilter/vsrc_testsrc.c     |  4 +---
>  23 files changed, 29 insertions(+), 87 deletions(-)
> 
> diff --git a/ffprobe.c b/ffprobe.c
> index e1ad6a7..6de9eb3 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -457,10 +457,8 @@ static av_cold int default_init(WriterContext *wctx, const char *args, void *opa
>      av_opt_set_defaults(def);
>  
>      if (args &&
> -        (err = (av_set_options_string(def, args, "=", ":"))) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +        (err = (av_set_options_string(def, args, "=", ":"))) < 0)
>          return err;
> -    }
>  
>      return 0;

Makes sense (the rule of thumb is that if we provide a log context,
the called function should deal with error messages).

>  }
> @@ -650,10 +648,8 @@ static av_cold int compact_init(WriterContext *wctx, const char *args, void *opa
>      av_opt_set_defaults(compact);
>  
>      if (args &&
> -        (err = (av_set_options_string(compact, args, "=", ":"))) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +        (err = (av_set_options_string(compact, args, "=", ":"))) < 0)
>          return err;
> -    }
>      if (strlen(compact->item_sep_str) != 1) {
>          av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
>                 compact->item_sep_str);
> @@ -808,10 +804,8 @@ static av_cold int flat_init(WriterContext *wctx, const char *args, void *opaque
>      av_opt_set_defaults(flat);
>  
>      if (args &&
> -        (err = (av_set_options_string(flat, args, "=", ":"))) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +        (err = (av_set_options_string(flat, args, "=", ":"))) < 0)
>          return err;
> -    }
>      if (strlen(flat->sep_str) != 1) {
>          av_log(wctx, AV_LOG_ERROR, "Item separator '%s' specified, but must contain a single character\n",
>                 flat->sep_str);
> @@ -966,10 +960,8 @@ static av_cold int ini_init(WriterContext *wctx, const char *args, void *opaque)
>      ini->class = &ini_class;
>      av_opt_set_defaults(ini);
>  
> -    if (args && (err = av_set_options_string(ini, args, "=", ":")) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +    if (args && (err = av_set_options_string(ini, args, "=", ":")) < 0)
>          return err;
> -    }
>  
>      return 0;
>  }
> @@ -1125,10 +1117,8 @@ static av_cold int json_init(WriterContext *wctx, const char *args, void *opaque
>      av_opt_set_defaults(json);
>  
>      if (args &&
> -        (err = (av_set_options_string(json, args, "=", ":"))) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +        (err = (av_set_options_string(json, args, "=", ":"))) < 0)
>          return err;
> -    }
>  
>      json->item_sep       = json->compact ? ", " : ",\n";
>      json->item_start_end = json->compact ? " "  : "\n";
> @@ -1350,10 +1340,8 @@ static av_cold int xml_init(WriterContext *wctx, const char *args, void *opaque)
>      av_opt_set_defaults(xml);
>  
>      if (args &&
> -        (err = (av_set_options_string(xml, args, "=", ":"))) < 0) {
> -        av_log(wctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +        (err = (av_set_options_string(xml, args, "=", ":"))) < 0)
>          return err;
> -    }
>  
>      if (xml->xsd_strict) {
>          xml->fully_qualified = 1;
> diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c
> index 4e97942..6cf89ac 100644
> --- a/libavfilter/af_aformat.c
> +++ b/libavfilter/af_aformat.c
> @@ -94,10 +94,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
>      s->class = &aformat_class;
>      av_opt_set_defaults(s);
>  
> -    if ((ret = av_set_options_string(s, args, "=", ":")) < 0) {
> -        av_log(ctx, AV_LOG_ERROR, "Error parsing options string '%s'.\n", args);
> +    if ((ret = av_set_options_string(s, args, "=", ":")) < 0)
>          return ret;
> -    }

Note to self: all this could be factorized.

[...]
> diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
> index 6a4df1e..4e312c5 100644
> --- a/libavfilter/vsrc_mptestsrc.c
> +++ b/libavfilter/vsrc_mptestsrc.c
> @@ -266,10 +266,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
>      test->class = &mptestsrc_class;
>      av_opt_set_defaults(test);
>  
> -    if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) {
> -        av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +    if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0)
>          return ret;
> -    }
>  
>      if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0) {
>          av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate);
> diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
> index a7e41e0..9640fae 100644
> --- a/libavfilter/vsrc_testsrc.c
> +++ b/libavfilter/vsrc_testsrc.c
> @@ -100,10 +100,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
>  
>      av_opt_set_defaults(test);
>  
> -    if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) {
> -        av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
> +    if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0)
>          return ret;
> -    }

Note to self: all this could be factorized.

LGTM if my eyes don't betray me.
-- 
FFmpeg = Fancy and Fierce Multimedia Ponderous Everlasting Gorilla


More information about the ffmpeg-devel mailing list