]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vsrc_testsrc.c
avfilter/ebur128: prefer to use variable instead of type for sizeof
[ffmpeg] / libavfilter / vsrc_testsrc.c
index f06714807ffda7e8d8749c9f60ae059a2153f90c..e8c33b00a0d4a6e082b86efcdaa77ca6fa466958 100644 (file)
@@ -83,6 +83,7 @@ typedef struct TestSourceContext {
 
 #define OFFSET(x) offsetof(TestSourceContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
+#define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 #define SIZE_OPTIONS \
     { "size",     "set video size",     OFFSET(w),        AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
@@ -181,8 +182,8 @@ static int request_frame(AVFilterLink *outlink)
 #if CONFIG_COLOR_FILTER
 
 static const AVOption color_options[] = {
-    { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
-    { "c",     "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
+    { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR },
+    { "c",     "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, 0, 0, FLAGSR },
     COMMON_OPTIONS
     { NULL }
 };
@@ -236,20 +237,13 @@ static int color_process_command(AVFilterContext *ctx, const char *cmd, const ch
     TestSourceContext *test = ctx->priv;
     int ret;
 
-    if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) {
-        uint8_t color_rgba[4];
-
-        ret = av_parse_color(color_rgba, args, -1, ctx);
-        if (ret < 0)
-            return ret;
-
-        memcpy(test->color_rgba, color_rgba, sizeof(color_rgba));
-        ff_draw_color(&test->draw, &test->color, test->color_rgba);
-        test->draw_once_reset = 1;
-        return 0;
-    }
+    ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
+    if (ret < 0)
+        return ret;
 
-    return AVERROR(ENOSYS);
+    ff_draw_color(&test->draw, &test->color, test->color_rgba);
+    test->draw_once_reset = 1;
+    return 0;
 }
 
 static const AVFilterPad color_outputs[] = {
@@ -280,7 +274,7 @@ AVFilter ff_vsrc_color = {
 #if CONFIG_HALDCLUTSRC_FILTER
 
 static const AVOption haldclutsrc_options[] = {
-    { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 8, FLAGS },
+    { "level", "set level", OFFSET(level), AV_OPT_TYPE_INT, {.i64 = 6}, 2, 16, FLAGS },
     COMMON_OPTIONS_NOSIZE
     { NULL }
 };
@@ -968,10 +962,10 @@ AVFILTER_DEFINE_CLASS(rgbtestsrc);
 #define A 3
 
 static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
-                              int x, int y, int r, int g, int b, enum AVPixelFormat fmt,
+                              int x, int y, unsigned r, unsigned g, unsigned b, enum AVPixelFormat fmt,
                               uint8_t rgba_map[4])
 {
-    int32_t v;
+    uint32_t v;
     uint8_t *p;
 
     switch (fmt) {
@@ -991,7 +985,7 @@ static void rgbtest_put_pixel(uint8_t *dst, int dst_linesize,
     case AV_PIX_FMT_BGRA:
     case AV_PIX_FMT_ARGB:
     case AV_PIX_FMT_ABGR:
-        v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255 << (rgba_map[A]*8));
+        v = (r << (rgba_map[R]*8)) + (g << (rgba_map[G]*8)) + (b << (rgba_map[B]*8)) + (255U << (rgba_map[A]*8));
         p = dst + 4*x + y*dst_linesize;
         AV_WL32(p, v);
         break;