From f77db72965f834141a5c7cc405ff4b15b70eeacb Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 11 Apr 2013 00:03:23 +0000 Subject: lavfi/framestep: switch to an AVOptions-based system Signed-off-by: Paul B Mahol --- libavfilter/vf_framestep.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'libavfilter/vf_framestep.c') diff --git a/libavfilter/vf_framestep.c b/libavfilter/vf_framestep.c index ca68df66dc..50a0f509ca 100644 --- a/libavfilter/vf_framestep.c +++ b/libavfilter/vf_framestep.c @@ -23,32 +23,25 @@ * Daniele Fornighieri . */ +#include "libavutil/opt.h" #include "avfilter.h" #include "internal.h" #include "video.h" typedef struct { + const AVClass *class; int frame_step, frame_count, frame_selected; } FrameStepContext; -static av_cold int init(AVFilterContext *ctx, const char *args) -{ - FrameStepContext *framestep = ctx->priv; - char *tailptr; - long int n = 1; - - if (args) { - n = strtol(args, &tailptr, 10); - if (*tailptr || n <= 0 || n >= INT_MAX) { - av_log(ctx, AV_LOG_ERROR, - "Invalid argument '%s', must be a positive integer <= INT_MAX\n", args); - return AVERROR(EINVAL); - } - } +#define OFFSET(x) offsetof(FrameStepContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM - framestep->frame_step = n; - return 0; -} +static const AVOption framestep_options[] = { + { "step", "set frame step", OFFSET(frame_step), AV_OPT_TYPE_INT, {.i64=1}, 1, INT_MAX, FLAGS}, + {NULL}, +}; + +AVFILTER_DEFINE_CLASS(framestep); static int config_output_props(AVFilterLink *outlink) { @@ -117,8 +110,8 @@ static const AVFilterPad framestep_outputs[] = { AVFilter avfilter_vf_framestep = { .name = "framestep", .description = NULL_IF_CONFIG_SMALL("Select one frame every N frames."), - .init = init, .priv_size = sizeof(FrameStepContext), + .priv_class = &framestep_class, .inputs = framestep_inputs, .outputs = framestep_outputs, }; -- cgit v1.2.3