[FFmpeg-devel] [PATCH] vf_curves: add option to set all curves at once

Clément Bœsch ubitux at gmail.com
Tue Apr 9 23:21:52 CEST 2013


On Tue, Apr 09, 2013 at 11:04:49PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
>  libavfilter/vf_curves.c |   17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
> index 360dc72..f32e4ab 100644
> --- a/libavfilter/vf_curves.c
> +++ b/libavfilter/vf_curves.c
> @@ -31,7 +31,7 @@ struct keypoint {
>      struct keypoint *next;
>  };
>  
> -#define NB_COMP 3
> +#define NB_COMP 5 //RGBA All
>  
>  enum preset {
>      PRESET_NONE,
> @@ -64,6 +64,8 @@ static const AVOption curves_options[] = {
>      { "g",     "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
>      { "blue",  "set blue points coordinates",  OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
>      { "b",     "set blue points coordinates",  OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
> +    { "all",   "set all points coordinates",   OFFSET(comp_points_str[4]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },

> +    { "l",     "set all points coordinates",   OFFSET(comp_points_str[4]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },

I'm not sure that alias is really relevant.

>      { "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" },
>          { "color_negative",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE},       INT_MIN, INT_MAX, FLAGS, "preset_name" },
>          { "cross_process",      NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS},        INT_MIN, INT_MAX, FLAGS, "preset_name" },
> @@ -318,9 +320,18 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
>      int i, j, ret;
>      CurvesContext *curves = ctx->priv;
>      struct keypoint *comp_points[NB_COMP] = {0};
> +    char **pts = curves->comp_points_str;
> +
> +    if (pts[4]) {
> +        for (i = 0; i < 4; i++) {
> +            if (!pts[i])
> +                pts[i] = av_strdup(pts[4]);
> +            if (!pts[i])
> +                return AVERROR(ENOMEM);
> +        }
> +    }
>  
>      if (curves->preset != PRESET_NONE) {
> -        char **pts = curves->comp_points_str;
>          if (pts[0] || pts[1] || pts[2]) {
>              av_log(ctx, AV_LOG_ERROR, "It is not possible to mix a preset "
>                     "with explicit points placements\n");
> @@ -407,7 +418,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>          const uint8_t *srcp = src;
>  
>          for (x = 0; x < inlink->w; x++)
> -            for (i = 0; i < NB_COMP; i++, dstp++, srcp++)
> +            for (i = 0; i < 3; i++, dstp++, srcp++)

I think you need to change a few other NB_COMP entries; actually, it might
be wise to instead add a char *all pointer in the context, and dup it
in r, g and b when set.

[...]

Also, missing documentation update.

BTW, an alternative is to cumulate them. IIRC Gimp is doing such thing.

-- 
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/20130409/fd153f41/attachment.asc>


More information about the ffmpeg-devel mailing list