diff options
author | Paul B Mahol <onemda@gmail.com> | 2013-03-26 12:12:53 +0000 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2013-03-26 13:23:42 +0000 |
commit | 8c5b37b4022dda5e7982a24a0cb54e934f0baeca (patch) | |
tree | a430e2149ded641c3d47a184447d08cd06eb60e2 | |
parent | 975efc8864a9fb994e8f3b70c2e4ed97ac7dd771 (diff) | |
download | ffmpeg-8c5b37b4022dda5e7982a24a0cb54e934f0baeca.tar.gz |
lavfi/life: make use of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavfilter/vsrc_life.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c index 584d4663d3..0474ef26b0 100644 --- a/libavfilter/vsrc_life.c +++ b/libavfilter/vsrc_life.c @@ -60,8 +60,7 @@ typedef struct { uint16_t stay_rule; ///< encode the behavior for filled cells uint16_t born_rule; ///< encode the behavior for empty cells uint64_t pts; - AVRational time_base; - char *rate; ///< video frame rate + AVRational frame_rate; double random_fill_ratio; uint32_t random_seed; int stitch; @@ -85,8 +84,8 @@ static const AVOption life_options[] = { { "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 }, { "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 }, - { "r", "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(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 }, { "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 }, @@ -224,7 +223,6 @@ static int init_pattern_from_file(AVFilterContext *ctx) static int init(AVFilterContext *ctx, const char *args) { LifeContext *life = ctx->priv; - AVRational frame_rate; int ret; life->class = &life_class; @@ -233,12 +231,6 @@ static int init(AVFilterContext *ctx, const char *args) if ((ret = av_set_options_string(life, args, "=", ":")) < 0) 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) av_opt_set(life, "size", "320x240", 0); @@ -262,9 +254,6 @@ static int init(AVFilterContext *ctx, const char *args) av_log(ctx, AV_LOG_WARNING, "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) { /* fill the grid randomly */ int i; @@ -293,7 +282,7 @@ static int init(AVFilterContext *ctx, const char *args) 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", - 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->random_seed); return 0; @@ -315,7 +304,7 @@ static int config_props(AVFilterLink *outlink) outlink->w = life->w; outlink->h = life->h; - outlink->time_base = life->time_base; + outlink->time_base = av_inv_q(life->frame_rate); return 0; } |