summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-08-08 16:42:36 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-08-08 16:49:53 +0200
commitdbf25b70ea7978ae9b237b4a970d965dc46058dd (patch)
tree04833cee5947e5b47d7b8a1ab0932b9ad5306c8c /libavfilter
parentbed63a5e98b1ba1f3bca6c81ea819666c2d81fde (diff)
lavfi/testsrc: set default value for option "color" to NULL and rework color setting logic
Fix bogus warnings of the kind: option 'color' is ignored with source 'testsrc' when the color value is not explicitely set and the filter is different from "color".
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vsrc_testsrc.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 30605789f8..a7e41e0892 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -82,8 +82,8 @@ static const AVOption options[] = {
{ "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX },
/* only used by color */
- { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX },
- { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX },
+ { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX },
+ { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX },
/* only used by testsrc */
{ "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX },
@@ -121,13 +121,17 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
ctx->filter->name);
}
- if (test->color_str && strcmp(ctx->filter->name, "color")) {
- av_log(ctx, AV_LOG_WARNING,
- "Option 'color' is ignored with source '%s'\n",
- ctx->filter->name);
+ if (test->color_str) {
+ if (!strcmp(ctx->filter->name, "color")) {
+ ret = av_parse_color(test->color_rgba, test->color_str, -1, ctx);
+ if (ret < 0)
+ return ret;
+ } else {
+ av_log(ctx, AV_LOG_WARNING,
+ "Option 'color' is ignored with source '%s'\n",
+ ctx->filter->name);
+ }
}
- if ((ret = av_parse_color(test->color_rgba, test->color_str, -1, ctx)) < 0)
- return ret;
test->time_base.num = frame_rate_q.den;
test->time_base.den = frame_rate_q.num;
@@ -226,6 +230,7 @@ static av_cold int color_init(AVFilterContext *ctx, const char *args)
test->class = &color_class;
test->fill_picture_fn = color_fill_picture;
test->draw_once = 1;
+ av_opt_set(test, "color", "black", 0);
return init(ctx, args);
}