]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vsrc_testsrc.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vsrc_testsrc.c
index c047fe8e861dd512d4ae959e82f35eeb3c6f8dd0..0ced726f5e040c26750b9b4afc52bc45f0aee2af 100644 (file)
@@ -77,6 +77,7 @@ typedef struct TestSourceContext {
 
     /* only used by rgbtest */
     uint8_t rgba_map[4];
+    int complement;
     int depth;
 
     /* only used by haldclut */
@@ -265,7 +266,7 @@ static const AVFilterPad color_outputs[] = {
     {  NULL }
 };
 
-AVFilter ff_vsrc_color = {
+const AVFilter ff_vsrc_color = {
     .name            = "color",
     .description     = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
     .priv_class      = &color_class,
@@ -399,7 +400,7 @@ static const AVFilterPad haldclutsrc_outputs[] = {
     {  NULL }
 };
 
-AVFilter ff_vsrc_haldclutsrc = {
+const AVFilter ff_vsrc_haldclutsrc = {
     .name          = "haldclutsrc",
     .description   = NULL_IF_CONFIG_SMALL("Provide an identity Hald CLUT."),
     .priv_class    = &haldclutsrc_class,
@@ -437,7 +438,7 @@ static const AVFilterPad nullsrc_outputs[] = {
     { NULL },
 };
 
-AVFilter ff_vsrc_nullsrc = {
+const AVFilter ff_vsrc_nullsrc = {
     .name        = "nullsrc",
     .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."),
     .init        = nullsrc_init,
@@ -673,7 +674,7 @@ static const AVFilterPad avfilter_vsrc_testsrc_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_testsrc = {
+const AVFilter ff_vsrc_testsrc = {
     .name          = "testsrc",
     .description   = NULL_IF_CONFIG_SMALL("Generate test pattern."),
     .priv_size     = sizeof(TestSourceContext),
@@ -946,7 +947,7 @@ static const AVFilterPad avfilter_vsrc_testsrc2_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_testsrc2 = {
+const AVFilter ff_vsrc_testsrc2 = {
     .name          = "testsrc2",
     .description   = NULL_IF_CONFIG_SMALL("Generate another test pattern."),
     .priv_size     = sizeof(TestSourceContext),
@@ -963,7 +964,13 @@ AVFilter ff_vsrc_testsrc2 = {
 
 #if CONFIG_RGBTESTSRC_FILTER
 
-#define rgbtestsrc_options options
+static const AVOption rgbtestsrc_options[] = {
+    COMMON_OPTIONS
+    { "complement", "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
+    { "co",         "set complement colors", OFFSET(complement), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
+    { NULL }
+};
+
 AVFILTER_DEFINE_CLASS(rgbtestsrc);
 
 #define R 0
@@ -1009,6 +1016,7 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
         p[0] = b;
         p = dstp[2] + x + y * dst_linesizep[2];
         p[0] = r;
+        break;
     case AV_PIX_FMT_GBRP9:
     case AV_PIX_FMT_GBRP10:
     case AV_PIX_FMT_GBRP12:
@@ -1024,6 +1032,29 @@ static void rgbtest_put_pixel(uint8_t *dstp[4], int dst_linesizep[4],
     }
 }
 
+static void rgbtest_fill_picture_complement(AVFilterContext *ctx, AVFrame *frame)
+{
+    TestSourceContext *test = ctx->priv;
+    int x, y, w = frame->width, h = frame->height;
+
+    for (y = 0; y < h; y++) {
+         for (x = 0; x < w; x++) {
+             int c = (1 << FFMAX(test->depth, 8))*x/w;
+             int r = 0, g = 0, b = 0;
+
+             if      (6*y < h  ) r = c;
+             else if (6*y < 2*h) g = c, b = c;
+             else if (6*y < 3*h) g = c;
+             else if (6*y < 4*h) r = c, b = c;
+             else if (6*y < 5*h) b = c;
+             else                r = c, g = c;
+
+             rgbtest_put_pixel(frame->data, frame->linesize, x, y, r, g, b,
+                               ctx->outputs[0]->format, test->rgba_map);
+         }
+     }
+}
+
 static void rgbtest_fill_picture(AVFilterContext *ctx, AVFrame *frame)
 {
     TestSourceContext *test = ctx->priv;
@@ -1049,7 +1080,7 @@ static av_cold int rgbtest_init(AVFilterContext *ctx)
     TestSourceContext *test = ctx->priv;
 
     test->draw_once = 1;
-    test->fill_picture_fn = rgbtest_fill_picture;
+    test->fill_picture_fn = test->complement ? rgbtest_fill_picture_complement : rgbtest_fill_picture;
     return init(ctx);
 }
 
@@ -1091,7 +1122,7 @@ static const AVFilterPad avfilter_vsrc_rgbtestsrc_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_rgbtestsrc = {
+const AVFilter ff_vsrc_rgbtestsrc = {
     .name          = "rgbtestsrc",
     .description   = NULL_IF_CONFIG_SMALL("Generate RGB test pattern."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1267,7 +1298,7 @@ static const AVFilterPad avfilter_vsrc_yuvtestsrc_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_yuvtestsrc = {
+const AVFilter ff_vsrc_yuvtestsrc = {
     .name          = "yuvtestsrc",
     .description   = NULL_IF_CONFIG_SMALL("Generate YUV test pattern."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1444,7 +1475,7 @@ static av_cold int pal75bars_init(AVFilterContext *ctx)
     return init(ctx);
 }
 
-AVFilter ff_vsrc_pal75bars = {
+const AVFilter ff_vsrc_pal75bars = {
     .name          = "pal75bars",
     .description   = NULL_IF_CONFIG_SMALL("Generate PAL 75% color bars."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1491,7 +1522,7 @@ static av_cold int pal100bars_init(AVFilterContext *ctx)
     return init(ctx);
 }
 
-AVFilter ff_vsrc_pal100bars = {
+const AVFilter ff_vsrc_pal100bars = {
     .name          = "pal100bars",
     .description   = NULL_IF_CONFIG_SMALL("Generate PAL 100% color bars."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1559,7 +1590,7 @@ static av_cold int smptebars_init(AVFilterContext *ctx)
     return init(ctx);
 }
 
-AVFilter ff_vsrc_smptebars = {
+const AVFilter ff_vsrc_smptebars = {
     .name          = "smptebars",
     .description   = NULL_IF_CONFIG_SMALL("Generate SMPTE color bars."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1665,7 +1696,7 @@ static av_cold int smptehdbars_init(AVFilterContext *ctx)
     return init(ctx);
 }
 
-AVFilter ff_vsrc_smptehdbars = {
+const AVFilter ff_vsrc_smptehdbars = {
     .name          = "smptehdbars",
     .description   = NULL_IF_CONFIG_SMALL("Generate SMPTE HD color bars."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1743,7 +1774,7 @@ static const AVFilterPad avfilter_vsrc_allyuv_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_allyuv = {
+const AVFilter ff_vsrc_allyuv = {
     .name          = "allyuv",
     .description   = NULL_IF_CONFIG_SMALL("Generate all yuv colors."),
     .priv_size     = sizeof(TestSourceContext),
@@ -1820,7 +1851,7 @@ static const AVFilterPad avfilter_vsrc_allrgb_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vsrc_allrgb = {
+const AVFilter ff_vsrc_allrgb = {
     .name          = "allrgb",
     .description   = NULL_IF_CONFIG_SMALL("Generate all RGB colors."),
     .priv_size     = sizeof(TestSourceContext),