diff options
author | Bernd Bleßmann <bb@it-entwicklung.de> | 2015-07-21 12:45:43 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-21 18:20:22 +0200 |
commit | 99ad832c7ea96587bde61f10d77e200f3d236da2 (patch) | |
tree | 97b5a5dc575c87c5a665e1e7657b83d07c3a44a9 | |
parent | d32547a24a3fcc8286b318353f43805838b84775 (diff) | |
download | ffmpeg-99ad832c7ea96587bde61f10d77e200f3d236da2.tar.gz |
libavfilter/vf_scale: implement process_command
Signed-off-by: Bernd Bleßmann <bb@it-entwicklung.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | doc/filters.texi | 13 | ||||
-rw-r--r-- | libavfilter/vf_scale.c | 43 |
2 files changed, 47 insertions, 9 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 2b0359d5bb..28aaef3e7e 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8906,6 +8906,19 @@ scale=w='min(500\, iw*3/2):h=-1' @end example @end itemize +@subsection Commands + +This filter supports the following commands: +@table @option +@item width, w +@item height, h +Set the output video dimension expression. +The command accepts the same syntax of the corresponding option. + +If the specified expression is not valid, it is kept at its current +value. +@end table + @section separatefields The @code{separatefields} takes a frame-based video input and splits diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 2a3d00808d..d4c0be26e4 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -544,6 +544,30 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + ScaleContext *scale = ctx->priv; + int ret; + + if ( !strcmp(cmd, "width") || !strcmp(cmd, "w") + || !strcmp(cmd, "height") || !strcmp(cmd, "h")) { + + int old_w = scale->w; + int old_h = scale->h; + AVFilterLink *outlink = ctx->outputs[0]; + + av_opt_set(scale, cmd, args, 0); + if ((ret = config_props(outlink)) < 0) { + scale->w = old_w; + scale->h = old_h; + } + } else + ret = AVERROR(ENOSYS); + + return ret; +} + static const AVClass *child_class_next(const AVClass *prev) { return prev ? NULL : sws_get_class(); @@ -610,13 +634,14 @@ static const AVFilterPad avfilter_vf_scale_outputs[] = { }; AVFilter ff_vf_scale = { - .name = "scale", - .description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."), - .init_dict = init_dict, - .uninit = uninit, - .query_formats = query_formats, - .priv_size = sizeof(ScaleContext), - .priv_class = &scale_class, - .inputs = avfilter_vf_scale_inputs, - .outputs = avfilter_vf_scale_outputs, + .name = "scale", + .description = NULL_IF_CONFIG_SMALL("Scale the input video size and/or convert the image format."), + .init_dict = init_dict, + .uninit = uninit, + .query_formats = query_formats, + .priv_size = sizeof(ScaleContext), + .priv_class = &scale_class, + .inputs = avfilter_vf_scale_inputs, + .outputs = avfilter_vf_scale_outputs, + .process_command = process_command, }; |