On 7/17/2021 2:22 PM, James Almer wrote:
On 7/17/2021 1:21 PM, Michael Niedermayer wrote:
This allows for example
"-cpucount cpu/2" to use half the available CPUs
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
---
fftools/cmdutils.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 6e875104fd..a902354669 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -859,11 +859,12 @@ 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},
+ AVOption opts[] = {
+ {"count", NULL, 0, AV_OPT_TYPE_INT, { .i64 = -1}, -1,
INT_MAX, 0, "val"},
+ {"cpu", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1}, 0, 0, 0,
"val"},
{NULL},
};
- static const AVClass class = {
+ const AVClass class = {
.class_name = "cpucount",
.item_name = av_default_item_name,
.option = opts,
@@ -871,6 +872,8 @@ int opt_cpucount(void *optctx, const char *opt,
const char *arg)
};
const AVClass *pclass = &class;
+ opts[1].default_val.i64 = av_cpu_count();
You could set this directly as the default value instead of -1 above.
Should be ok either way.
Actually, the "cpu" constant should be documented.
+
ret = av_opt_eval_int(&pclass, opts, arg, &count);
if (!ret) {
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".