vf_curves: add option to set all curves at once
Reviewed-by: ubitux Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@ -2385,6 +2385,11 @@ Set the key points for the red component.
|
|||||||
Set the key points for the green component.
|
Set the key points for the green component.
|
||||||
@item blue, b
|
@item blue, b
|
||||||
Set the key points for the blue component.
|
Set the key points for the blue component.
|
||||||
|
@item all
|
||||||
|
Set the key points for all components.
|
||||||
|
Can be used in addition to the other key points component
|
||||||
|
options. In this case, the unset component(s) will fallback on this
|
||||||
|
@option{all} setting.
|
||||||
@item preset
|
@item preset
|
||||||
Select one of the available color presets. This option can not be used in
|
Select one of the available color presets. This option can not be used in
|
||||||
addition to the @option{r}, @option{g}, @option{b} parameters.
|
addition to the @option{r}, @option{g}, @option{b} parameters.
|
||||||
|
@ -52,6 +52,7 @@ typedef struct {
|
|||||||
const AVClass *class;
|
const AVClass *class;
|
||||||
enum preset preset;
|
enum preset preset;
|
||||||
char *comp_points_str[NB_COMP];
|
char *comp_points_str[NB_COMP];
|
||||||
|
char *comp_points_str_all;
|
||||||
uint8_t graph[NB_COMP][256];
|
uint8_t graph[NB_COMP][256];
|
||||||
} CurvesContext;
|
} CurvesContext;
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ static const AVOption curves_options[] = {
|
|||||||
{ "g", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
|
{ "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 },
|
{ "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 },
|
{ "b", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
|
||||||
|
{ "all", "set points coordinates for all components", OFFSET(comp_points_str_all),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" },
|
{ "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" },
|
{ "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" },
|
{ "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;
|
int i, j, ret;
|
||||||
CurvesContext *curves = ctx->priv;
|
CurvesContext *curves = ctx->priv;
|
||||||
struct keypoint *comp_points[NB_COMP] = {0};
|
struct keypoint *comp_points[NB_COMP] = {0};
|
||||||
|
char **pts = curves->comp_points_str;
|
||||||
|
|
||||||
|
if (curves->comp_points_str_all) {
|
||||||
|
for (i = 0; i < NB_COMP; i++) {
|
||||||
|
if (!pts[i])
|
||||||
|
pts[i] = av_strdup(curves->comp_points_str_all);
|
||||||
|
if (!pts[i])
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (curves->preset != PRESET_NONE) {
|
if (curves->preset != PRESET_NONE) {
|
||||||
char **pts = curves->comp_points_str;
|
|
||||||
if (pts[0] || pts[1] || pts[2]) {
|
if (pts[0] || pts[1] || pts[2]) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "It is not possible to mix a preset "
|
av_log(ctx, AV_LOG_ERROR, "It is not possible to mix a preset "
|
||||||
"with explicit points placements\n");
|
"with explicit points placements\n");
|
||||||
|
Reference in New Issue
Block a user