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
83 83
84#define OFFSET(x) offsetof(TestSourceContext, x)84#define OFFSET(x) offsetof(TestSourceContext, x)
85#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM85#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
86 87
87#define SIZE_OPTIONS \88#define SIZE_OPTIONS \
88 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\89 { "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
181#if CONFIG_COLOR_FILTER182#if CONFIG_COLOR_FILTER
182 183
183static const AVOption color_options[] = {184static const AVOption color_options[] = {
184 { "color", "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 },
185 { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },186 { "c", "set color", OFFSET(color_rgba), AV_OPT_TYPE_COLOR, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGSR },
186 COMMON_OPTIONS187 COMMON_OPTIONS
187 { NULL }188 { NULL }
188};189};
@@ -236,20 +237,13 @@ static int color_process_command(AVFilterContext *ctx, const char *cmd, const ch · 47 unmodified lines
236 TestSourceContext *test = ctx->priv;237 TestSourceContext *test = ctx->priv;
237 int ret;238 int ret;
238 239
239 if (!strcmp(cmd, "color") || !strcmp(cmd, "c")) {240 ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
240 uint8_t color_rgba[4];241 if (ret < 0)
241 242 return ret;
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 }
251 243
252 return AVERROR(ENOSYS);244 ff_draw_color(&test->draw, &test->color, test->color_rgba);
245 test->draw_once_reset = 1;
246 return 0;
253}247}
254 248
255static const AVFilterPad color_outputs[] = {249static 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