summaryrefslogtreecommitdiff
path: root/libavfilter/vsrc_testsrc.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-11-21 17:30:21 +0100
committerPaul B Mahol <onemda@gmail.com>2019-11-21 17:32:04 +0100
commit09fd1b18f041b725be6f78bc787140eb5cb25d2e (patch)
treebcbe995740a1cbac2d7f4ab4b6e5d40145e0c661 /libavfilter/vsrc_testsrc.c
parent94c0b27397873efb534ca3ee7cb0844619edb854 (diff)
avfilter/vsrc_testsrc: simplify color filter commands parsing
Diffstat (limited to 'libavfilter/vsrc_testsrc.c')
-rw-r--r--libavfilter/vsrc_testsrc.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 42d74577b7..3c9ddd5b16 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -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"}, CHAR_MIN, CHAR_MAX, FLAGSR },
+ { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, 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[] = {