[PATCH] Make all the numeric options accepts in input an expression which is evaluated through the eval API.

Stefano Sabatini stefano.sabatini-lala
Sat Jun 5 23:22:38 CEST 2010


Fix roundup issue #551.
---
 cmdutils.c                   |    8 ++++++--
 doc/fftools-common-opts.texi |    5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 2349b70..2b9df0e 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -36,6 +36,7 @@
 #include "libpostproc/postprocess.h"
 #include "libavutil/avstring.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/eval.h"
 #include "libavcodec/opt.h"
 #include "cmdutils.h"
 #include "version.h"
@@ -59,8 +60,11 @@ double parse_number_or_die(const char *context, const char *numstr, int type, do
     char *tail;
     const char *error;
     double d = strtod(numstr, &tail);
-    if (*tail)
-        error= "Expected number for %s but found: %s\n";
+    av_parse_and_eval_expr(&d, numstr,
+                           NULL, NULL, NULL, NULL, NULL, NULL,
+                           NULL, 0, NULL);
+    if (isnan(d))
+        error = "Error found when parsing expression for '%s': %s\n";
     else if (d < min || d > max)
         error= "The value for %s was %s which is not within %f - %f\n";
     else if(type == OPT_INT64 && (int64_t)d != d)
diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 4fc271d..b3e8951 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -1,3 +1,8 @@
+
+All the numerical options, if not specified otherwise, accepts in
+input an expression which is evaluated using the rules defined in the
+section "FFmpeg formula evaluator" of the @file{ffmpeg} manual page.
+
 @section Generic options
 
 These options are shared amongst the ff* tools.
-- 
1.7.1


--ZGiS0Q5IWpPtfppv--



More information about the ffmpeg-devel mailing list