History

Merge remote-tracking branch 'richardpl/framestep'

* richardpl/framestep: lavfi/framestep: remove request_frame hack lavfi/framestep: switch to an AVOptions-based system

Michael Niedermayer committed 13 years ago

Commit 5e5ef6e2 parents f17651b 7c79ec63 files · +20 −39Browse files

Unified · Split

3 files
  1. doc/filters.texi +7 −3
  2. libavfilter/avfilter.c +1 −0
  3. libavfilter/vf_framestep.c +12 −36
doc/filters.texi+7−3
@@ -3212,10 +3212,14 @@ See also the @ref{setpts} filter. · 3211 unmodified lines
32123212
32133213 @section framestep
32143214
3215−Select one frame every N.
3215+Select one frame every N-th frame.
32163216
3217−This filter accepts in input a string representing a positive
3218−integer. Default argument is @code{1}.
3217+This filter accepts the following option:
3218+@table @option
3219+@item step
3220+Select frame after every @code{step} frames.
3221+Allowed values are positive integers higher than 0. Default value is @code{1}.
3222+@end table
32193223
32203224 @anchor{frei0r}
32213225 @section frei0r
libavfilter/avfilter.c+1−0
@@ -683,6 +683,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 682 unmodified lines
683683 !strcmp(filter->filter->name, "field" ) ||
684684 !strcmp(filter->filter->name, "fieldorder") ||
685685 !strcmp(filter->filter->name, "fps" ) ||
686+ !strcmp(filter->filter->name, "framestep" ) ||
686687 !strcmp(filter->filter->name, "frei0r" ) ||
687688 !strcmp(filter->filter->name, "frei0r_src") ||
688689 !strcmp(filter->filter->name, "geq" ) ||
libavfilter/vf_framestep.c+12−36
@@ -23,32 +23,25 @@ · 22 unmodified lines
2323 * Daniele Fornighieri <guru AT digitalfantasy it>.
2424 */
2525
26+#include "libavutil/opt.h"
2627 #include "avfilter.h"
2728 #include "internal.h"
2829 #include "video.h"
2930
3031 typedef struct {
31− int frame_step, frame_count, frame_selected;
32+ const AVClass *class;
33+ int frame_step, frame_count;
3234 } FrameStepContext;
3335
34−static av_cold int init(AVFilterContext *ctx, const char *args)
35−{
36− FrameStepContext *framestep = ctx->priv;
37− char *tailptr;
38− long int n = 1;
36+#define OFFSET(x) offsetof(FrameStepContext, x)
37+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
3938
40− if (args) {
41− n = strtol(args, &tailptr, 10);
42− if (*tailptr || n <= 0 || n >= INT_MAX) {
43− av_log(ctx, AV_LOG_ERROR,
44− "Invalid argument '%s', must be a positive integer <= INT_MAX\n", args);
45− return AVERROR(EINVAL);
46− }
47− }
39+static const AVOption framestep_options[] = {
40+ { "step", "set frame step", OFFSET(frame_step), AV_OPT_TYPE_INT, {.i64=1}, 1, INT_MAX, FLAGS},
41+ {NULL},
42+};
4843
49− framestep->frame_step = n;
50− return 0;
51−}
44+AVFILTER_DEFINE_CLASS(framestep);
5245
5346 static int config_output_props(AVFilterLink *outlink)
5447 {
@@ -56,6 +49,7 @@ static int config_output_props(AVFilterLink *outlink) · 1 unmodified line
5649 FrameStepContext *framestep = ctx->priv;
5750 AVFilterLink *inlink = ctx->inputs[0];
5851
52+ outlink->flags |= FF_LINK_FLAG_REQUEST_LOOP;
5953 outlink->frame_rate =
6054 av_div_q(inlink->frame_rate, (AVRational){framestep->frame_step, 1});
6155
@@ -71,34 +65,17 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *ref) · 9 unmodified lines
7165 FrameStepContext *framestep = inlink->dst->priv;
7266
7367 if (!(framestep->frame_count++ % framestep->frame_step)) {
74− framestep->frame_selected = 1;
7568 return ff_filter_frame(inlink->dst->outputs[0], ref);
7669 } else {
77− framestep->frame_selected = 0;
7870 av_frame_free(&ref);
7971 return 0;
8072 }
8173 }
8274
83−static int request_frame(AVFilterLink *outlink)
84−{
85− FrameStepContext *framestep = outlink->src->priv;
86− AVFilterLink *inlink = outlink->src->inputs[0];
87− int ret;
88−
89− framestep->frame_selected = 0;
90− do {
91− ret = ff_request_frame(inlink);
92− } while (!framestep->frame_selected && ret >= 0);
93−
94− return ret;
95−}
96−
9775 static const AVFilterPad framestep_inputs[] = {
9876 {
9977 .name = "default",
10078 .type = AVMEDIA_TYPE_VIDEO,
101− .get_video_buffer = ff_null_get_video_buffer,
10279 .filter_frame = filter_frame,
10380 },
10481 { NULL }
@@ -109,7 +86,6 @@ static const AVFilterPad framestep_outputs[] = { · 4 unmodified lines
10986 .name = "default",
11087 .type = AVMEDIA_TYPE_VIDEO,
11188 .config_props = config_output_props,
112− .request_frame = request_frame,
11389 },
11490 { NULL }
11591 };
@@ -117,8 +93,8 @@ static const AVFilterPad framestep_outputs[] = { · 1 unmodified line
11793 AVFilter avfilter_vf_framestep = {
11894 .name = "framestep",
11995 .description = NULL_IF_CONFIG_SMALL("Select one frame every N frames."),
120− .init = init,
12196 .priv_size = sizeof(FrameStepContext),
97+ .priv_class = &framestep_class,
12298 .inputs = framestep_inputs,
12399 .outputs = framestep_outputs,
124100 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t