[FFmpeg-cvslog] lavfi/testsrc: set default value for option "color" to NULL and rework color setting logic

Stefano Sabatini git at videolan.org
Wed Aug 8 16:51:55 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Wed Aug  8 16:42:36 2012 +0200| [dbf25b70ea7978ae9b237b4a970d965dc46058dd] | committer: Stefano Sabatini

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".

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dbf25b70ea7978ae9b237b4a970d965dc46058dd
---

 libavfilter/vsrc_testsrc.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 3060578..a7e41e0 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);
 }
 



More information about the ffmpeg-cvslog mailing list