* commit '7bc1a883c9158bb6e383d86fc76bdf2541e9a9fe': vsrc_color: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/vsrc_color.c
Unified · Split
| @@ -675,6 +675,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 674 unmodified lines | ||
| 675 | 675 | !strcmp(filter->filter->name, "cellauto") || |
| 676 | 676 | !strcmp(filter->filter->name, "channelmap") || |
| 677 | 677 | !strcmp(filter->filter->name, "channelsplit") || |
| 678 | + !strcmp(filter->filter->name, "color" ) || | |
| 678 | 679 | !strcmp(filter->filter->name, "colormatrix") || |
| 679 | 680 | !strcmp(filter->filter->name, "crop" ) || |
| 680 | 681 | !strcmp(filter->filter->name, "cropdetect") || |
| @@ -75,22 +75,31 @@ typedef struct { · 74 unmodified lines | ||
| 75 | 75 | #define OFFSET(x) offsetof(TestSourceContext, x) |
| 76 | 76 | #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
| 77 | 77 | |
| 78 | −static const AVOption options[] = { | |
| 79 | − { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS }, | |
| 80 | − { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS }, | |
| 81 | − { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, | |
| 82 | − { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, | |
| 83 | − { "duration", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, | |
| 84 | − { "d", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, | |
| 78 | +#define COMMON_OPTIONS \ | |
| 79 | + { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\ | |
| 80 | + { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\ | |
| 81 | + { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\ | |
| 82 | + { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\ | |
| 83 | + { "duration", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },\ | |
| 84 | + { "d", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },\ | |
| 85 | 85 | { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS }, |
| 86 | 86 | |
| 87 | + | |
| 88 | +static const AVOption color_options[] = { | |
| 87 | 89 | /* only used by color */ |
| 88 | − { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, | |
| 89 | − { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, | |
| 90 | + { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS }, | |
| 91 | + { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS }, | |
| 90 | 92 | |
| 93 | + COMMON_OPTIONS | |
| 94 | + { NULL }, | |
| 95 | +}; | |
| 96 | + | |
| 97 | +static const AVOption options[] = { | |
| 91 | 98 | /* only used by testsrc */ |
| 92 | 99 | { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, |
| 93 | 100 | { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, |
| 101 | + | |
| 102 | + COMMON_OPTIONS | |
| 94 | 103 | { NULL }, |
| 95 | 104 | }; |
| 96 | 105 | |
| @@ -99,8 +108,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 2 unmodified lines | ||
| 99 | 108 | TestSourceContext *test = ctx->priv; |
| 100 | 109 | int ret = 0; |
| 101 | 110 | |
| 102 | − av_opt_set_defaults(test); | |
| 103 | − | |
| 104 | 111 | if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) |
| 105 | 112 | return ret; |
| 106 | 113 | |
| @@ -200,7 +207,6 @@ static int request_frame(AVFilterLink *outlink) · 93 unmodified lines | ||
| 200 | 207 | |
| 201 | 208 | #if CONFIG_COLOR_FILTER |
| 202 | 209 | |
| 203 | −#define color_options options | |
| 204 | 210 | AVFILTER_DEFINE_CLASS(color); |
| 205 | 211 | |
| 206 | 212 | static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref) |
| @@ -214,11 +220,9 @@ static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref) · 7 unmodified lines | ||
| 214 | 220 | static av_cold int color_init(AVFilterContext *ctx, const char *args) |
| 215 | 221 | { |
| 216 | 222 | TestSourceContext *test = ctx->priv; |
| 217 | − test->class = &color_class; | |
| 218 | 223 | test->fill_picture_fn = color_fill_picture; |
| 219 | 224 | test->draw_once = 1; |
| 220 | − av_opt_set(test, "color", "black", 0); | |
| 221 | − return init(ctx, args); | |
| 225 | + return init(ctx, NULL); | |
| 222 | 226 | } |
| 223 | 227 | |
| 224 | 228 | static int color_query_formats(AVFilterContext *ctx) |
| @@ -263,6 +267,7 @@ AVFilter avfilter_vsrc_color = { · 38 unmodified lines | ||
| 263 | 267 | .name = "color", |
| 264 | 268 | .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), |
| 265 | 269 | |
| 270 | + .priv_class = &color_class, | |
| 266 | 271 | .priv_size = sizeof(TestSourceContext), |
| 267 | 272 | .init = color_init, |
| 268 | 273 | .uninit = uninit, |
| @@ -270,7 +275,6 @@ AVFilter avfilter_vsrc_color = { · 1 unmodified line | ||
| 270 | 275 | .query_formats = color_query_formats, |
| 271 | 276 | .inputs = NULL, |
| 272 | 277 | .outputs = color_outputs, |
| 273 | − .priv_class = &color_class, | |
| 274 | 278 | }; |
| 275 | 279 | |
| 276 | 280 | #endif /* CONFIG_COLOR_FILTER */ |
| @@ -288,6 +292,7 @@ static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args) · 11 unmodified lines | ||
| 288 | 292 | |
| 289 | 293 | test->class = &nullsrc_class; |
| 290 | 294 | test->fill_picture_fn = nullsrc_fill_picture; |
| 295 | + av_opt_set_defaults(test); | |
| 291 | 296 | return init(ctx, args); |
| 292 | 297 | } |
| 293 | 298 | |
| @@ -507,6 +512,7 @@ static av_cold int test_init(AVFilterContext *ctx, const char *args) · 213 unmodified lines | ||
| 507 | 512 | |
| 508 | 513 | test->class = &testsrc_class; |
| 509 | 514 | test->fill_picture_fn = test_fill_picture; |
| 515 | + av_opt_set_defaults(test); | |
| 510 | 516 | return init(ctx, args); |
| 511 | 517 | } |
| 512 | 518 | |
| @@ -613,6 +619,7 @@ static av_cold int rgbtest_init(AVFilterContext *ctx, const char *args) · 100 unmodified lines | ||
| 613 | 619 | test->draw_once = 1; |
| 614 | 620 | test->class = &rgbtestsrc_class; |
| 615 | 621 | test->fill_picture_fn = rgbtest_fill_picture; |
| 622 | + av_opt_set_defaults(test); | |
| 616 | 623 | return init(ctx, args); |
| 617 | 624 | } |
| 618 | 625 | |
| @@ -764,6 +771,7 @@ static av_cold int smptebars_init(AVFilterContext *ctx, const char *args) · 145 unmodified lines | ||
| 764 | 771 | test->class = &smptebars_class; |
| 765 | 772 | test->fill_picture_fn = smptebars_fill_picture; |
| 766 | 773 | test->draw_once = 1; |
| 774 | + av_opt_set_defaults(test); | |
| 767 | 775 | return init(ctx, args); |
| 768 | 776 | } |
| 769 | 777 | |