[FFmpeg-cvslog] lavfi/framestep: switch to an AVOptions-based system

Paul B Mahol git at videolan.org
Thu Apr 11 02:32:27 CEST 2013


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Apr 11 00:03:23 2013 +0000| [f77db72965f834141a5c7cc405ff4b15b70eeacb] | committer: Paul B Mahol

lavfi/framestep: switch to an AVOptions-based system

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f77db72965f834141a5c7cc405ff4b15b70eeacb
---

 doc/filters.texi           |   10 +++++++---
 libavfilter/avfilter.c     |    1 +
 libavfilter/vf_framestep.c |   29 +++++++++++------------------
 3 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5f85ac0..c37529c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3216,10 +3216,14 @@ See also the @ref{setpts} filter.
 
 @section framestep
 
-Select one frame every N.
+Select one frame every N-th frame.
 
-This filter accepts in input a string representing a positive
-integer. Default argument is @code{1}.
+This filter accepts the following option:
+ at table @option
+ at item step
+Select frame after every @code{step} frames.
+Allowed values are positive integers higher than 0. Default value is @code{1}.
+ at end table
 
 @anchor{frei0r}
 @section frei0r
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index abf8cd6..9159b9e 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -677,6 +677,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
         !strcmp(filter->filter->name,  "field"     ) ||
         !strcmp(filter->filter->name,  "fieldorder") ||
         !strcmp(filter->filter->name,  "fps"       ) ||
+        !strcmp(filter->filter->name,  "framestep" ) ||
         !strcmp(filter->filter->name,  "frei0r"    ) ||
         !strcmp(filter->filter->name,  "frei0r_src") ||
         !strcmp(filter->filter->name,  "geq"       ) ||
diff --git a/libavfilter/vf_framestep.c b/libavfilter/vf_framestep.c
index ca68df6..50a0f50 100644
--- a/libavfilter/vf_framestep.c
+++ b/libavfilter/vf_framestep.c
@@ -23,32 +23,25 @@
  * Daniele Fornighieri <guru AT digitalfantasy it>.
  */
 
+#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,
 };



More information about the ffmpeg-cvslog mailing list