History

avfilter/vsrc_testsrc: simplify color filter commands parsing

Paul B Mahol committed 6 years ago

Commit 09fd1b11 parent 94c0b271 file · +9 −15Browse files

Unified · Split

libavfilter/vsrc_testsrc.c+9−15
@@ -83,6 +83,7 @@ typedef struct TestSourceContext { · 82 unmodified lines
8383
8484 #define OFFSET(x) offsetof(TestSourceContext, x)
8585 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
86+#define FLAGSR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
8687
8788 #define SIZE_OPTIONS \
8889 { "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) · 92 unmodified lines
181182 #if CONFIG_COLOR_FILTER
182183
183184 static const AVOption color_options[] = {
184− { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
185− { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
185+ { "color", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGSR },
186+ { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGSR },
186187 COMMON_OPTIONS
187188 { NULL }
188189 };
@@ -236,20 +237,13 @@ static int color_process_command(AVFilterContext *ctx, const char *cmd, const ch · 47 unmodified lines
236237 TestSourceContext *test = ctx->priv;
237238 int ret;
238239
239− if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) {
240− uint8_t color_rgba[4];
241−
242− ret = av_parse_color(color_rgba, args, -1, ctx);
243− if (ret < 0)
244− return ret;
245−
246− memcpy(test->color_rgba, color_rgba, sizeof(color_rgba));
247− ff_draw_color(&test->draw, &test->color, test->color_rgba);
248− test->draw_once_reset = 1;
249− return 0;
250− }
240+ ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
241+ if (ret < 0)
242+ return ret;
251243
252− return AVERROR(ENOSYS);
244+ ff_draw_color(&test->draw, &test->color, test->color_rgba);
245+ test->draw_once_reset = 1;
246+ return 0;
253247 }
254248
255249 static const AVFilterPad color_outputs[] = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t