diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-03-24 23:32:59 +0400 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-03-24 23:38:12 +0400 |
commit | 386dc9a3a8bc8e4c751a5725f9030955bfb5f2da (patch) | |
tree | c7d2294e3a2928866bb4ff9bb9620576ac9fcf01 /libavfilter/vf_thumbnail.c | |
parent | 3b811bcf674038ab298d5dd194992e4e4929d8f2 (diff) |
lavfi/thumbnail: add support for named options.
Diffstat (limited to 'libavfilter/vf_thumbnail.c')
-rw-r--r-- | libavfilter/vf_thumbnail.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c index b62bef6a0a..d32c6c7b29 100644 --- a/libavfilter/vf_thumbnail.c +++ b/libavfilter/vf_thumbnail.c @@ -27,6 +27,7 @@ * @see http://notbrainsurgery.livejournal.com/29773.html */ +#include "libavutil/opt.h" #include "avfilter.h" #include "internal.h" @@ -38,27 +39,27 @@ struct thumb_frame { }; typedef struct { + const AVClass *class; int n; ///< current frame int n_frames; ///< number of frames for analysis struct thumb_frame *frames; ///< the n_frames frames AVRational tb; ///< copy of the input timebase to ease access } ThumbContext; +#define OFFSET(x) offsetof(ThumbContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption thumbnail_options[] = { + { "n", "set the frames batch size", OFFSET(n_frames), AV_OPT_TYPE_INT, {.i64=100}, 2, INT_MAX, FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(thumbnail); + static av_cold int init(AVFilterContext *ctx, const char *args) { ThumbContext *thumb = ctx->priv; - if (!args) { - thumb->n_frames = 100; - } else { - int n = sscanf(args, "%d", &thumb->n_frames); - if (n != 1 || thumb->n_frames < 2) { - thumb->n_frames = 0; - av_log(ctx, AV_LOG_ERROR, - "Invalid number of frames specified (minimum is 2).\n"); - return AVERROR(EINVAL); - } - } thumb->frames = av_calloc(thumb->n_frames, sizeof(*thumb->frames)); if (!thumb->frames) { av_log(ctx, AV_LOG_ERROR, @@ -226,6 +227,8 @@ static const AVFilterPad thumbnail_outputs[] = { { NULL } }; +static const char *const shorthand[] = { "n", NULL }; + AVFilter avfilter_vf_thumbnail = { .name = "thumbnail", .description = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."), @@ -235,4 +238,6 @@ AVFilter avfilter_vf_thumbnail = { .query_formats = query_formats, .inputs = thumbnail_inputs, .outputs = thumbnail_outputs, + .priv_class = &thumbnail_class, + .shorthand = shorthand, }; |