History

Merge commit 'b9dfee9fa259dfc885508179a359dccc9e7840bd'

* commit 'b9dfee9fa259dfc885508179a359dccc9e7840bd': vf_fade: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vf_fade.c

Michael Niedermayer committed 13 years ago

Commit 0c3d7062 parents d70b494 b9dfee93 files · +44 −41Browse files

Unified · Split

3 files
  1. doc/filters.texi +9 −12
  2. libavfilter/avfilter.c +1 −0
  3. libavfilter/vf_fade.c +34 −29
doc/filters.texi+9−12
@@ -3036,27 +3036,23 @@ edgedetect=low=0.1:high=0.4 · 3035 unmodified lines
3036 3036
3037Apply fade-in/out effect to input video.3037Apply fade-in/out effect to input video.
3038 3038
3039The filter accepts parameters as a list of @var{key}=@var{value}3039This filter accepts the following options:
3040pairs, separated by ":". If the key of the first options is omitted,
3041the arguments are interpreted according to the syntax
3042@var{type}:@var{start_frame}:@var{nb_frames}.
3043
3044A description of the accepted parameters follows.
3045 3040
3046@table @option3041@table @option
3047@item type, t3042@item type, t
3048Specify if the effect type, can be either @code{in} for fade-in, or3043The effect type -- can be either "in" for fade-in, or "out" for a fade-out
3049@code{out} for a fade-out effect. Default is @code{in}.3044effect.
3045Default is @code{in}.
3050 3046
3051@item start_frame, s3047@item start_frame, s
3052Specify the number of the start frame for starting to apply the fade3048Specify the number of the start frame for starting to apply the fade
3053effect. Default is 0.3049effect. Default is 0.
3054 3050
3055@item nb_frames, n3051@item nb_frames, n
3056Specify the number of frames for which the fade effect has to last. At3052The number of frames for which the fade effect has to last. At the end of the
3057the end of the fade-in effect the output video will have the same3053fade-in effect the output video will have the same intensity as the input video,
3058intensity as the input video, at the end of the fade-out transition3054at the end of the fade-out transition the output video will be completely black.
3059the output video will be completely black. Default is 25.3055Default is 25.
3060 3056
3061@item alpha3057@item alpha
3062If set to 1, fade only alpha channel, if one exists on the input.3058If set to 1, fade only alpha channel, if one exists on the input.
@@ -3081,6 +3077,7 @@ fade=t=in:s=0:n=30 · 18 unmodified lines
3081Fade out last 45 frames of a 200-frame video:3077Fade out last 45 frames of a 200-frame video:
3082@example3078@example
3083fade=out:155:453079fade=out:155:45
3080fade=type=out:start_frame=155:nb_frames=45
3084@end example3081@end example
3085 3082
3086@item3083@item
libavfilter/avfilter.c+1−0
@@ -664,6 +664,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 663 unmodified lines
664 !strcmp(filter->filter->name, "delogo" ) ||664 !strcmp(filter->filter->name, "delogo" ) ||
665 !strcmp(filter->filter->name, "drawbox" ) ||665 !strcmp(filter->filter->name, "drawbox" ) ||
666 !strcmp(filter->filter->name, "drawtext" ) ||666 !strcmp(filter->filter->name, "drawtext" ) ||
667 !strcmp(filter->filter->name, "fade" ) ||
667 !strcmp(filter->filter->name, "format") ||668 !strcmp(filter->filter->name, "format") ||
668 !strcmp(filter->filter->name, "noformat") ||669 !strcmp(filter->filter->name, "noformat") ||
669 !strcmp(filter->filter->name, "resample")670 !strcmp(filter->filter->name, "resample")
libavfilter/vf_fade.c+34−29
@@ -46,55 +46,40 @@ · 45 unmodified lines
46#define U 146#define U 1
47#define V 247#define V 2
48 48
49#define FADE_IN 0
50#define FADE_OUT 1
51
49typedef struct {52typedef struct {
50 const AVClass *class;53 const AVClass *class;
54 int type;
51 int factor, fade_per_frame;55 int factor, fade_per_frame;
52 unsigned int frame_index, start_frame, stop_frame, nb_frames;56 int start_frame, nb_frames;
57 unsigned int frame_index, stop_frame;
53 int hsub, vsub, bpp;58 int hsub, vsub, bpp;
54 unsigned int black_level, black_level_scaled;59 unsigned int black_level, black_level_scaled;
55 uint8_t is_packed_rgb;60 uint8_t is_packed_rgb;
56 uint8_t rgba_map[4];61 uint8_t rgba_map[4];
57 int alpha;62 int alpha;
58 63
59 char *type;
60} FadeContext;64} FadeContext;
61 65
62#define OFFSET(x) offsetof(FadeContext, x)
63#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
64
65static const AVOption fade_options[] = {
66 { "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX, FLAGS },
67 { "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX, FLAGS },
68 { "start_frame", "set expression of frame to start fading", OFFSET(start_frame), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, FLAGS },
69 { "s", "set expression of frame to start fading", OFFSET(start_frame), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, FLAGS },
70 { "nb_frames", "set expression for fade duration in frames", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64 = 25 }, 0, INT_MAX, FLAGS },
71 { "n", "set expression for fade duration in frames", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64 = 25 }, 0, INT_MAX, FLAGS },
72 { "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS },
73 {NULL},
74};
75
76AVFILTER_DEFINE_CLASS(fade);
77
78static av_cold int init(AVFilterContext *ctx, const char *args)66static av_cold int init(AVFilterContext *ctx, const char *args)
79{67{
80 FadeContext *fade = ctx->priv;68 FadeContext *fade = ctx->priv;
81 69
82 fade->fade_per_frame = (1 << 16) / fade->nb_frames;70 fade->fade_per_frame = (1 << 16) / fade->nb_frames;
83 if (!strcmp(fade->type, "in"))71 if (fade->type == FADE_IN) {
84 fade->factor = 0;72 fade->factor = 0;
85 else if (!strcmp(fade->type, "out")) {73 } else if (fade->type == FADE_OUT) {
86 fade->fade_per_frame = -fade->fade_per_frame;74 fade->fade_per_frame = -fade->fade_per_frame;
87 fade->factor = (1 << 16);75 fade->factor = (1 << 16);
88 } else {
89 av_log(ctx, AV_LOG_ERROR,
90 "Type argument must be 'in' or 'out' but '%s' was specified\n", fade->type);
91 return AVERROR(EINVAL);
92 }76 }
93 fade->stop_frame = fade->start_frame + fade->nb_frames;77 fade->stop_frame = fade->start_frame + fade->nb_frames;
94 78
95 av_log(ctx, AV_LOG_VERBOSE,79 av_log(ctx, AV_LOG_VERBOSE,
96 "type:%s start_frame:%d nb_frames:%d alpha:%d\n",80 "type:%s start_frame:%d nb_frames:%d alpha:%d\n",
97 fade->type, fade->start_frame, fade->nb_frames, fade->alpha);81 fade->type == FADE_IN ? "in" : "out", fade->start_frame,
82 fade->nb_frames, fade->alpha);
98 return 0;83 return 0;
99}84}
100 85
@@ -212,6 +197,29 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 111 unmodified lines
212 return ff_filter_frame(inlink->dst->outputs[0], frame);197 return ff_filter_frame(inlink->dst->outputs[0], frame);
213}198}
214 199
200
201#define OFFSET(x) offsetof(FadeContext, x)
202#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
203
204static const AVOption fade_options[] = {
205 { "type", "'in' or 'out' for fade-in/fade-out", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
206 { "t", "'in' or 'out' for fade-in/fade-out", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
207 { "in", "fade-in", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_IN }, .unit = "type" },
208 { "out", "fade-out", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_OUT }, .unit = "type" },
209 { "start_frame", "Number of the first frame to which to apply the effect.",
210 OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
211 { "s", "Number of the first frame to which to apply the effect.",
212 OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
213 { "nb_frames", "Number of frames to which the effect should be applied.",
214 OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
215 { "n", "Number of frames to which the effect should be applied.",
216 OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
217 { "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS },
218 { NULL },
219};
220
221AVFILTER_DEFINE_CLASS(fade);
222
215static const AVFilterPad avfilter_vf_fade_inputs[] = {223static const AVFilterPad avfilter_vf_fade_inputs[] = {
216 {224 {
217 .name = "default",225 .name = "default",
@@ -232,17 +240,14 @@ static const AVFilterPad avfilter_vf_fade_outputs[] = { · 14 unmodified lines
232 { NULL }240 { NULL }
233};241};
234 242
235static const char *const shorthand[] = { "type", "start_frame", "nb_frames", NULL };
236
237AVFilter avfilter_vf_fade = {243AVFilter avfilter_vf_fade = {
238 .name = "fade",244 .name = "fade",
239 .description = NULL_IF_CONFIG_SMALL("Fade in/out input video."),245 .description = NULL_IF_CONFIG_SMALL("Fade in/out input video."),
240 .init = init,246 .init = init,
241 .priv_size = sizeof(FadeContext),247 .priv_size = sizeof(FadeContext),
248 .priv_class = &fade_class,
242 .query_formats = query_formats,249 .query_formats = query_formats,
243 250
244 .inputs = avfilter_vf_fade_inputs,251 .inputs = avfilter_vf_fade_inputs,
245 .outputs = avfilter_vf_fade_outputs,252 .outputs = avfilter_vf_fade_outputs,
246 .priv_class = &fade_class,
247 .shorthand = shorthand,
248};253};

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