[FFmpeg-devel] [PATCH] vf_curves: add option to set all curves at once
Michael Niedermayer
michaelni at gmx.at
Tue Apr 9 23:04:49 CEST 2013
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 },
{ "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++)
*dstp = curves->graph[i][*srcp];
dst += out->linesize[0];
src += in ->linesize[0];
--
1.7.9.5
More information about the ffmpeg-devel
mailing list