mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
Merge commit 'b9dfee9fa259dfc885508179a359dccc9e7840bd'
* commit 'b9dfee9fa259dfc885508179a359dccc9e7840bd': vf_fade: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vf_fade.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
0c3d706bdb
@ -3036,27 +3036,23 @@ edgedetect=low=0.1:high=0.4
|
||||
|
||||
Apply fade-in/out effect to input video.
|
||||
|
||||
The filter accepts parameters as a list of @var{key}=@var{value}
|
||||
pairs, separated by ":". If the key of the first options is omitted,
|
||||
the arguments are interpreted according to the syntax
|
||||
@var{type}:@var{start_frame}:@var{nb_frames}.
|
||||
|
||||
A description of the accepted parameters follows.
|
||||
This filter accepts the following options:
|
||||
|
||||
@table @option
|
||||
@item type, t
|
||||
Specify if the effect type, can be either @code{in} for fade-in, or
|
||||
@code{out} for a fade-out effect. Default is @code{in}.
|
||||
The effect type -- can be either "in" for fade-in, or "out" for a fade-out
|
||||
effect.
|
||||
Default is @code{in}.
|
||||
|
||||
@item start_frame, s
|
||||
Specify the number of the start frame for starting to apply the fade
|
||||
effect. Default is 0.
|
||||
|
||||
@item nb_frames, n
|
||||
Specify the number of frames for which the fade effect has to last. At
|
||||
the end of the fade-in effect the output video will have the same
|
||||
intensity as the input video, at the end of the fade-out transition
|
||||
the output video will be completely black. Default is 25.
|
||||
The number of frames for which the fade effect has to last. At the end of the
|
||||
fade-in effect the output video will have the same intensity as the input video,
|
||||
at the end of the fade-out transition the output video will be completely black.
|
||||
Default is 25.
|
||||
|
||||
@item alpha
|
||||
If set to 1, fade only alpha channel, if one exists on the input.
|
||||
@ -3081,6 +3077,7 @@ fade=t=in:s=0:n=30
|
||||
Fade out last 45 frames of a 200-frame video:
|
||||
@example
|
||||
fade=out:155:45
|
||||
fade=type=out:start_frame=155:nb_frames=45
|
||||
@end example
|
||||
|
||||
@item
|
||||
|
@ -664,6 +664,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
|
||||
!strcmp(filter->filter->name, "delogo" ) ||
|
||||
!strcmp(filter->filter->name, "drawbox" ) ||
|
||||
!strcmp(filter->filter->name, "drawtext" ) ||
|
||||
!strcmp(filter->filter->name, "fade" ) ||
|
||||
!strcmp(filter->filter->name, "format") ||
|
||||
!strcmp(filter->filter->name, "noformat") ||
|
||||
!strcmp(filter->filter->name, "resample")
|
||||
|
@ -46,55 +46,40 @@
|
||||
#define U 1
|
||||
#define V 2
|
||||
|
||||
#define FADE_IN 0
|
||||
#define FADE_OUT 1
|
||||
|
||||
typedef struct {
|
||||
const AVClass *class;
|
||||
int type;
|
||||
int factor, fade_per_frame;
|
||||
unsigned int frame_index, start_frame, stop_frame, nb_frames;
|
||||
int start_frame, nb_frames;
|
||||
unsigned int frame_index, stop_frame;
|
||||
int hsub, vsub, bpp;
|
||||
unsigned int black_level, black_level_scaled;
|
||||
uint8_t is_packed_rgb;
|
||||
uint8_t rgba_map[4];
|
||||
int alpha;
|
||||
|
||||
char *type;
|
||||
} FadeContext;
|
||||
|
||||
#define OFFSET(x) offsetof(FadeContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
|
||||
static const AVOption fade_options[] = {
|
||||
{ "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{ "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_STRING, {.str = "in" }, CHAR_MIN, CHAR_MAX, FLAGS },
|
||||
{ "start_frame", "set expression of frame to start fading", OFFSET(start_frame), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, FLAGS },
|
||||
{ "s", "set expression of frame to start fading", OFFSET(start_frame), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, FLAGS },
|
||||
{ "nb_frames", "set expression for fade duration in frames", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64 = 25 }, 0, INT_MAX, FLAGS },
|
||||
{ "n", "set expression for fade duration in frames", OFFSET(nb_frames), AV_OPT_TYPE_INT, {.i64 = 25 }, 0, INT_MAX, FLAGS },
|
||||
{ "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS },
|
||||
{NULL},
|
||||
};
|
||||
|
||||
AVFILTER_DEFINE_CLASS(fade);
|
||||
|
||||
static av_cold int init(AVFilterContext *ctx, const char *args)
|
||||
{
|
||||
FadeContext *fade = ctx->priv;
|
||||
|
||||
fade->fade_per_frame = (1 << 16) / fade->nb_frames;
|
||||
if (!strcmp(fade->type, "in"))
|
||||
if (fade->type == FADE_IN) {
|
||||
fade->factor = 0;
|
||||
else if (!strcmp(fade->type, "out")) {
|
||||
} else if (fade->type == FADE_OUT) {
|
||||
fade->fade_per_frame = -fade->fade_per_frame;
|
||||
fade->factor = (1 << 16);
|
||||
} else {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Type argument must be 'in' or 'out' but '%s' was specified\n", fade->type);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
fade->stop_frame = fade->start_frame + fade->nb_frames;
|
||||
|
||||
av_log(ctx, AV_LOG_VERBOSE,
|
||||
"type:%s start_frame:%d nb_frames:%d alpha:%d\n",
|
||||
fade->type, fade->start_frame, fade->nb_frames, fade->alpha);
|
||||
fade->type == FADE_IN ? "in" : "out", fade->start_frame,
|
||||
fade->nb_frames, fade->alpha);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -212,6 +197,29 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
||||
return ff_filter_frame(inlink->dst->outputs[0], frame);
|
||||
}
|
||||
|
||||
|
||||
#define OFFSET(x) offsetof(FadeContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
|
||||
static const AVOption fade_options[] = {
|
||||
{ "type", "'in' or 'out' for fade-in/fade-out", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
|
||||
{ "t", "'in' or 'out' for fade-in/fade-out", OFFSET(type), AV_OPT_TYPE_INT, { .i64 = FADE_IN }, FADE_IN, FADE_OUT, FLAGS, "type" },
|
||||
{ "in", "fade-in", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_IN }, .unit = "type" },
|
||||
{ "out", "fade-out", 0, AV_OPT_TYPE_CONST, { .i64 = FADE_OUT }, .unit = "type" },
|
||||
{ "start_frame", "Number of the first frame to which to apply the effect.",
|
||||
OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
|
||||
{ "s", "Number of the first frame to which to apply the effect.",
|
||||
OFFSET(start_frame), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
|
||||
{ "nb_frames", "Number of frames to which the effect should be applied.",
|
||||
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
|
||||
{ "n", "Number of frames to which the effect should be applied.",
|
||||
OFFSET(nb_frames), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, FLAGS },
|
||||
{ "alpha", "fade alpha if it is available on the input", OFFSET(alpha), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FLAGS },
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
AVFILTER_DEFINE_CLASS(fade);
|
||||
|
||||
static const AVFilterPad avfilter_vf_fade_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
@ -232,17 +240,14 @@ static const AVFilterPad avfilter_vf_fade_outputs[] = {
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const char *const shorthand[] = { "type", "start_frame", "nb_frames", NULL };
|
||||
|
||||
AVFilter avfilter_vf_fade = {
|
||||
.name = "fade",
|
||||
.description = NULL_IF_CONFIG_SMALL("Fade in/out input video."),
|
||||
.init = init,
|
||||
.priv_size = sizeof(FadeContext),
|
||||
.priv_class = &fade_class,
|
||||
.query_formats = query_formats,
|
||||
|
||||
.inputs = avfilter_vf_fade_inputs,
|
||||
.outputs = avfilter_vf_fade_outputs,
|
||||
.priv_class = &fade_class,
|
||||
.shorthand = shorthand,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user