[FFmpeg-devel] [PATCH] cmdutils: simplify opt_cpucount()

James Almer jamrial at gmail.com
Sat Jul 17 03:26:16 EEST 2021


Signed-off-by: James Almer <jamrial at gmail.com>
---
 fftools/cmdutils.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6e875104fd..a3b6b78d50 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -856,28 +856,15 @@ int opt_cpuflags(void *optctx, const char *opt, const char *arg)
 
 int opt_cpucount(void *optctx, const char *opt, const char *arg)
 {
-    int ret;
-    int count;
-
-    static const AVOption opts[] = {
-        {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1, INT_MAX, NULL},
-        {NULL},
-    };
-    static const AVClass class = {
-        .class_name = "cpucount",
-        .item_name  = av_default_item_name,
-        .option     = opts,
-        .version    = LIBAVUTIL_VERSION_INT,
-    };
-    const AVClass *pclass = &class;
-
-    ret = av_opt_eval_int(&pclass, opts, arg, &count);
+    char *tail;
+    int64_t count;
 
-    if (!ret) {
-        av_force_cpu_count(count);
-    }
+    count = strtol(arg, &tail, 10);
+    if (*tail || count < -1 || count > INT_MAX)
+        return AVERROR(EINVAL);
 
-    return ret;
+    av_force_cpu_count(count);
+    return 0;
 }
 
 int opt_loglevel(void *optctx, const char *opt, const char *arg)
-- 
2.32.0



More information about the ffmpeg-devel mailing list