Commit 8c5b37b4 authored by Paul B Mahol's avatar Paul B Mahol

lavfi/life: make use of AV_OPT_TYPE_VIDEO_RATE

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 975efc88
...@@ -60,8 +60,7 @@ typedef struct { ...@@ -60,8 +60,7 @@ typedef struct {
uint16_t stay_rule; ///< encode the behavior for filled cells uint16_t stay_rule; ///< encode the behavior for filled cells
uint16_t born_rule; ///< encode the behavior for empty cells uint16_t born_rule; ///< encode the behavior for empty cells
uint64_t pts; uint64_t pts;
AVRational time_base; AVRational frame_rate;
char *rate; ///< video frame rate
double random_fill_ratio; double random_fill_ratio;
uint32_t random_seed; uint32_t random_seed;
int stitch; int stitch;
...@@ -85,8 +84,8 @@ static const AVOption life_options[] = { ...@@ -85,8 +84,8 @@ static const AVOption life_options[] = {
{ "f", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, { "f", "set source file", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS }, { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS }, { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, FLAGS },
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS }, { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, FLAGS }, { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },
{ "rule", "set rule", OFFSET(rule_str), AV_OPT_TYPE_STRING, {.str = "B3/S23"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "rule", "set rule", OFFSET(rule_str), AV_OPT_TYPE_STRING, {.str = "B3/S23"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "random_fill_ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS }, { "random_fill_ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS },
{ "ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS }, { "ratio", "set fill ratio for filling initial grid randomly", OFFSET(random_fill_ratio), AV_OPT_TYPE_DOUBLE, {.dbl=1/M_PHI}, 0, 1, FLAGS },
...@@ -224,7 +223,6 @@ static int init_pattern_from_file(AVFilterContext *ctx) ...@@ -224,7 +223,6 @@ static int init_pattern_from_file(AVFilterContext *ctx)
static int init(AVFilterContext *ctx, const char *args) static int init(AVFilterContext *ctx, const char *args)
{ {
LifeContext *life = ctx->priv; LifeContext *life = ctx->priv;
AVRational frame_rate;
int ret; int ret;
life->class = &life_class; life->class = &life_class;
...@@ -233,12 +231,6 @@ static int init(AVFilterContext *ctx, const char *args) ...@@ -233,12 +231,6 @@ static int init(AVFilterContext *ctx, const char *args)
if ((ret = av_set_options_string(life, args, "=", ":")) < 0) if ((ret = av_set_options_string(life, args, "=", ":")) < 0)
return ret; return ret;
if ((ret = av_parse_video_rate(&frame_rate, life->rate)) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: %s\n", life->rate);
return AVERROR(EINVAL);
}
av_freep(&life->rate);
if (!life->w && !life->filename) if (!life->w && !life->filename)
av_opt_set(life, "size", "320x240", 0); av_opt_set(life, "size", "320x240", 0);
...@@ -262,9 +254,6 @@ static int init(AVFilterContext *ctx, const char *args) ...@@ -262,9 +254,6 @@ static int init(AVFilterContext *ctx, const char *args)
av_log(ctx, AV_LOG_WARNING, av_log(ctx, AV_LOG_WARNING,
"Mold color is set while mold isn't, ignoring the color.\n"); "Mold color is set while mold isn't, ignoring the color.\n");
life->time_base.num = frame_rate.den;
life->time_base.den = frame_rate.num;
if (!life->filename) { if (!life->filename) {
/* fill the grid randomly */ /* fill the grid randomly */
int i; int i;
...@@ -293,7 +282,7 @@ static int init(AVFilterContext *ctx, const char *args) ...@@ -293,7 +282,7 @@ static int init(AVFilterContext *ctx, const char *args)
av_log(ctx, AV_LOG_VERBOSE, av_log(ctx, AV_LOG_VERBOSE,
"s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d seed:%u\n", "s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d seed:%u\n",
life->w, life->h, frame_rate.num, frame_rate.den, life->w, life->h, life->frame_rate.num, life->frame_rate.den,
life->rule_str, life->stay_rule, life->born_rule, life->stitch, life->rule_str, life->stay_rule, life->born_rule, life->stitch,
life->random_seed); life->random_seed);
return 0; return 0;
...@@ -315,7 +304,7 @@ static int config_props(AVFilterLink *outlink) ...@@ -315,7 +304,7 @@ static int config_props(AVFilterLink *outlink)
outlink->w = life->w; outlink->w = life->w;
outlink->h = life->h; outlink->h = life->h;
outlink->time_base = life->time_base; outlink->time_base = av_inv_q(life->frame_rate);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment