[PATCH 3/4] Make av_set_string3() check the list of named constants before to try to evaluate the string to set with ff_parse_and_eval_expr().

Stefano Sabatini stefano.sabatini-lala
Sat Apr 10 22:02:23 CEST 2010


Force the interpretation of the special values "default", "max",
"min", "none", "all" before to try to evaluate the expression.

This way it is not anymore required to silence the errors when parsing
the expression, and let to display these messages, which may help the
user to understand why the value could not be parsed.
---
 libavcodec/opt.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/opt.c b/libavcodec/opt.c
index 844c0ec..2a1f008 100644
--- a/libavcodec/opt.c
+++ b/libavcodec/opt.c
@@ -155,10 +155,7 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
                 buf[i]= val[i];
             buf[i]=0;
 
-            av_set_int(obj, "log_level_offset", AV_LOG_DEBUG - AV_LOG_QUIET);
-            d = ff_parse_and_eval_expr(buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, obj);
-            av_set_int(obj, "log_level_offset", 0);
-            if(isnan(d)) {
+            {
                 const AVOption *o_named= av_find_opt(obj, buf, o->unit, 0, 0);
                 if(o_named && o_named->type == FF_OPT_TYPE_CONST)
                     d= o_named->default_val;
@@ -168,8 +165,11 @@ int av_set_string3(void *obj, const char *name, const char *val, int alloc, cons
                 else if(!strcmp(buf, "none"   )) d= 0;
                 else if(!strcmp(buf, "all"    )) d= ~0;
                 else {
+                    d = ff_parse_and_eval_expr(buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, obj);
+                    if (isnan(d)) {
                     av_log(obj, AV_LOG_ERROR, "Unable to parse or evaluate option value \"%s\"\n", val);
                     return AVERROR(EINVAL);
+                    }
                 }
             }
             if(o->type == FF_OPT_TYPE_FLAGS){
-- 
1.7.0


--d6Gm4EdcadzBjdND--



More information about the ffmpeg-devel mailing list