[FFmpeg-devel] [PATCH] lavfi: Add support to process_command in vf_eq.c

arwa arif arwaarif1994 at gmail.com
Wed Mar 11 06:25:07 CET 2015


On Tue, Mar 10, 2015 at 2:41 PM, Stefano Sabatini <stefasab at gmail.com>
wrote:

> On date Tuesday 2015-03-10 00:27:52 +0530, Arwa Arif encoded:
> > On Fri, Feb 20, 2015 at 5:41 AM, Stefano Sabatini <stefasab at gmail.com>
> > wrote:
> >
> > > On date Thursday 2015-02-19 17:13:15 +0530, Arwa Arif encoded:
> > > > Updated the patch.
> > >
> > > > From 66a8c9d03995c9e7c6ccc05fb9b20756f51c17f4 Mon Sep 17 00:00:00
> 2001
> > > > From: Arwa Arif <arwaarif1994 at gmail.com>
> > > > Date: Thu, 19 Feb 2015 01:26:44 +0530
> > > > Subject: [PATCH] Add process_command to eq.
> > > >
> > > > ---
> > > >  doc/filters.texi    |   35 +++++++++++
> > > >  libavfilter/vf_eq.c |  171
> > > +++++++++++++++++++++++++++++++++++++--------------
> > > >  libavfilter/vf_eq.h |   56 +++++++++++++++--
> > > >  3 files changed, 210 insertions(+), 52 deletions(-)
> > > >
> > > > diff --git a/doc/filters.texi b/doc/filters.texi
> > > > index 191b52f..e5bf3a2 100644
> > > > --- a/doc/filters.texi
> > > > +++ b/doc/filters.texi
> > > > @@ -4402,6 +4402,41 @@ Default is @code{1.0}.
> > > >
> > > >  @end table
> > > >
> > > > + at subsection Commands
> > > > +The filter supports the following commands:
> > > > +
> > > > + at table @option
> > > > + at item contrast
> > > > +Set the contrast expression.
> > > > +
> > > > + at item brightness
> > > > +Set the brightness expression.
> > > > +
> > > > + at item saturation
> > > > +Set the saturation expression.
> > > > +
> > > > + at item gamma
> > > > +Set the gamma expression.
> > > > +
> > > > + at item gamma_r
> > > > +Set the gamma_r expression.
> > > > +
> > > > + at item gamma_g
> > > > +Set gamma_g expression.
> > > > +
> > > > + at item gamma_b
> > > > +Set gamma_b expression.
> > > > +
> > > > + at item gamma_weight
> > > > +Set gamma_weight expression.
> > > > +
> > > > +The command accepts the same syntax of the corresponding option.
> > >
> > > What parameters do the expressions accept? Can you suggest some useful
> > > use-case? (And add useful examples in the docs?)
> > >
> > >
>
> > There are no parameters accepted by the expressions. I will add some
> > examples in the doc.
>
> Look how it is done in hue. In general an expression is useful if you
> want to express something in function of the time or the number of
> frame or something else.
>


So, I should add these options:
1. frame count
2. frame rate
3. timestamp expressed in seconds
4. timebase


>
> [...]
> > > > +    if (!strcmp(cmd, "contrast")) {
> > > > +        ret = set_expr(&eq->contrast_pexpr, args, cmd, ctx);
> > > > +        set_contrast(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "brightness")) {
> > > > +        ret = set_expr(&eq->brightness_pexpr, args, cmd, ctx);
> > > > +        set_brightness(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "saturation")) {
> > > > +        ret = set_expr(&eq->saturation_pexpr, args, cmd, ctx);
> > > > +        set_saturation(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "gamma")) {
> > > > +        ret = set_expr(&eq->gamma_pexpr, args, cmd, ctx);
> > > > +        set_gamma(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "gamma_r")) {
> > > > +        ret = set_expr(&eq->gamma_r_pexpr, args, cmd, ctx);
> > > > +        set_gamma(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "gamma_g")) {
> > > > +        ret = set_expr(&eq->gamma_g_pexpr, args, cmd, ctx);
> > > > +        set_gamma(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "gamma_b")) {
> > > > +        ret = set_expr(&eq->gamma_b_pexpr, args, cmd, ctx);
> > > > +        set_gamma(eq);
> > > > +        return ret;
> > > > +    }
> > > > +    else if (!strcmp(cmd, "gamma_weight")) {
> > > > +        ret = set_expr(&eq->gamma_weight_pexpr, args, cmd, ctx);
> > > > +        set_gamma(eq);
> > > > +        return ret;
> > >
> > > this can be probably factorized using a macro
> > >
> > >
>
> > Okay. I was going through other filters which use macros, can you explain
> > me the what is meant by the symbol ## in statement no.2 of the following
> > code snippet:
>
> ## is the concatenation operator. See for example:
> https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html


Okay. Thanks.


>
>
> > #define SET_SIZE_EXPR(name, opt_name) do {
> >         \
> >     ret = av_expr_parse_and_eval(&res, expr = rot->name##_expr_str,
> >        \
> >                                  var_names, rot->var_values,
> >         \
> >                                  func1_names, func1, NULL, NULL, rot, 0,
> > ctx);     \
> >     if (ret < 0 || isnan(res) || isinf(res) || res <= 0) {
> >         \
> >         av_log(ctx, AV_LOG_ERROR,
> >        \
> >                "Error parsing or evaluating expression for option %s: "
> >        \
> >                "invalid expression '%s' or non-positive or indefinite
> value
> > %f\n", \
> >                opt_name, expr, res);
> >         \
> >         return ret;
> >        \
> >     }
>
> Something like:
>
> #define SET_PARAM(param_name) \
>    if (!strcmp(cmd, param_name)) { \
>        ret = set_expr(&eq->param_name##_pexpr, args, cmd, ctx); \
>        set_##param_name(eq); \
>        return ret; \
>    }
>
> SET_PARAM(contrast);
> SET_PARAM(brightness);
> ...
>
> should probably work.
>
> [...]
> --
> FFmpeg = Faithful and Forgiving Multimedia Pacific Exploitable Gadget
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list