[FFmpeg-devel] [PATCH] lavfi/rotate: add angle command

Clément Bœsch ubitux at gmail.com
Wed Jun 12 10:01:31 CEST 2013


On Tue, Jun 11, 2013 at 04:09:37PM +0200, Stefano Sabatini wrote:
> ---
>  doc/filters.texi        |   13 +++++++++++++
>  libavfilter/vf_rotate.c |   36 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 7e8fff9..c4ad494 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -5852,6 +5852,19 @@ rotate=2*PI*t:ow='min(iw,ih)/sqrt(2)':oh=ow
>  @end example
>  @end itemize
>  
> + at subsection Commands
> +
> +The filter supports the following commands:
> +
> + at table @option
> + at item a, angle
> +Set the angle 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.
> + at end table
> +
>  @section removelogo
>  
>  Suppress a TV station logo, using an image file to determine which
> diff --git a/libavfilter/vf_rotate.c b/libavfilter/vf_rotate.c
> index da294c3..ce31a7c 100644
> --- a/libavfilter/vf_rotate.c
> +++ b/libavfilter/vf_rotate.c
> @@ -425,6 +425,41 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>      return ff_filter_frame(outlink, out);
>  }
>  
> +static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
> +{
> +    int ret;
> +    AVExpr *old = NULL;
> +

> +    if (*pexpr)
> +        old = *pexpr;

That check is wrong (dereference in the if), or at best useless.

> +    ret = av_expr_parse(pexpr, expr, var_names,
> +                        NULL, NULL, NULL, NULL, 0, log_ctx);
> +    if (ret < 0) {
> +        av_log(log_ctx, AV_LOG_ERROR,
> +               "Error when evaluating the expression '%s' for %s\n",
> +               expr, option);
> +        *pexpr = old;
> +        return ret;
> +    }
> +
> +    av_expr_free(old);
> +    return 0;
> +}
> +
> +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
> +                           char *res, int res_len, int flags)
> +{
> +    RotContext *rot = ctx->priv;
> +    int ret;
> +
> +    if (!strcmp(cmd, "angle") || !strcmp(cmd, "a")) {
> +        ret = set_expr(&rot->angle_expr, args, cmd, ctx);
> +    } else
> +        ret = AVERROR(ENOSYS);
> +
> +    return ret;
> +}
> +
>  static const AVFilterPad rotate_inputs[] = {
>      {
>          .name         = "default",
> @@ -453,4 +488,5 @@ AVFilter avfilter_vf_rotate = {
>      .inputs      = rotate_inputs,
>      .outputs     = rotate_outputs,
>      .priv_class  = &rotate_class,
> +    .process_command = process_command,

Rest LGTM

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130612/74399e8c/attachment.asc>


More information about the ffmpeg-devel mailing list