Browse code

vf_curves: add option to set all curves at once

Reviewed-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/04/10 06:04:24
Showing 2 changed files
... ...
@@ -2385,6 +2385,11 @@ Set the key points for the red component.
2385 2385
 Set the key points for the green component.
2386 2386
 @item blue, b
2387 2387
 Set the key points for the blue component.
2388
+@item all
2389
+Set the key points for all components.
2390
+Can be used in addition to the other key points component
2391
+options. In this case, the unset component(s) will fallback on this
2392
+@option{all} setting.
2388 2393
 @item preset
2389 2394
 Select one of the available color presets. This option can not be used in
2390 2395
 addition to the @option{r}, @option{g}, @option{b} parameters.
... ...
@@ -52,6 +52,7 @@ typedef struct {
52 52
     const AVClass *class;
53 53
     enum preset preset;
54 54
     char *comp_points_str[NB_COMP];
55
+    char *comp_points_str_all;
55 56
     uint8_t graph[NB_COMP][256];
56 57
 } CurvesContext;
57 58
 
... ...
@@ -64,6 +65,7 @@ static const AVOption curves_options[] = {
64 64
     { "g",     "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
65 65
     { "blue",  "set blue points coordinates",  OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
66 66
     { "b",     "set blue points coordinates",  OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
67
+    { "all",   "set points coordinates for all components",   OFFSET(comp_points_str_all),AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
67 68
     { "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" },
68 69
         { "color_negative",     NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE},       INT_MIN, INT_MAX, FLAGS, "preset_name" },
69 70
         { "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)
318 318
     int i, j, ret;
319 319
     CurvesContext *curves = ctx->priv;
320 320
     struct keypoint *comp_points[NB_COMP] = {0};
321
+    char **pts = curves->comp_points_str;
322
+
323
+    if (curves->comp_points_str_all) {
324
+        for (i = 0; i < NB_COMP; i++) {
325
+            if (!pts[i])
326
+                pts[i] = av_strdup(curves->comp_points_str_all);
327
+            if (!pts[i])
328
+                return AVERROR(ENOMEM);
329
+        }
330
+    }
321 331
 
322 332
     if (curves->preset != PRESET_NONE) {
323
-        char **pts = curves->comp_points_str;
324 333
         if (pts[0] || pts[1] || pts[2]) {
325 334
             av_log(ctx, AV_LOG_ERROR, "It is not possible to mix a preset "
326 335
                    "with explicit points placements\n");