diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-03-26 05:39:55 +0400 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-03-26 05:39:55 +0400 |
commit | 9371467d9d434356ebd2d8b4209ed487147056d9 (patch) | |
tree | 89ffbbacf17bf2775b57ba0698ec4f5a629776f8 /libavfilter/f_perms.c | |
parent | e600d0628ec2d23341a72e6b64311338208699cf (diff) |
lavfi/perms: add seed option.
Diffstat (limited to 'libavfilter/f_perms.c')
-rw-r--r-- | libavfilter/f_perms.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavfilter/f_perms.c b/libavfilter/f_perms.c index e3f974c0c0..2c3d62ccf8 100644 --- a/libavfilter/f_perms.c +++ b/libavfilter/f_perms.c @@ -34,6 +34,7 @@ enum mode { typedef struct { const AVClass *class; AVLFG lfg; + int64_t random_seed; enum mode mode; } PermsContext; @@ -47,6 +48,7 @@ static const AVOption options[] = { { "rw", "set all output frames writable", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_RW}, INT_MIN, INT_MAX, FLAGS, "mode" }, { "toggle", "switch permissions", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_TOGGLE}, INT_MIN, INT_MAX, FLAGS, "mode" }, { "random", "set permissions randomly", 0, AV_OPT_TYPE_CONST, {.i64 = MODE_RANDOM}, INT_MIN, INT_MAX, FLAGS, "mode" }, + { "seed", "set the seed for the random mode", OFFSET(random_seed), AV_OPT_TYPE_INT64, {.i64 = -1}, -1, UINT32_MAX, FLAGS }, { NULL } }; @@ -54,9 +56,15 @@ static av_cold int init(AVFilterContext *ctx, const char *args) { PermsContext *perms = ctx->priv; - // TODO: add a seed option - if (perms->mode == MODE_RANDOM) - av_lfg_init(&perms->lfg, av_get_random_seed()); + if (perms->mode == MODE_RANDOM) { + uint32_t seed; + + if (perms->random_seed == -1) + perms->random_seed = av_get_random_seed(); + seed = perms->random_seed; + av_log(ctx, AV_LOG_INFO, "random seed: 0x%08x\n", seed); + av_lfg_init(&perms->lfg, seed); + } return 0; } |