* 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 | !strcmp(filter->filter->name, "cellauto") || | 675 | !strcmp(filter->filter->name, "cellauto") || |
| 676 | !strcmp(filter->filter->name, "channelmap") || | 676 | !strcmp(filter->filter->name, "channelmap") || |
| 677 | !strcmp(filter->filter->name, "channelsplit") || | 677 | !strcmp(filter->filter->name, "channelsplit") || |
| 678 | !strcmp(filter->filter->name, "color" ) || | ||
| 678 | !strcmp(filter->filter->name, "colormatrix") || | 679 | !strcmp(filter->filter->name, "colormatrix") || |
| 679 | !strcmp(filter->filter->name, "crop" ) || | 680 | !strcmp(filter->filter->name, "crop" ) || |
| 680 | !strcmp(filter->filter->name, "cropdetect") || | 681 | !strcmp(filter->filter->name, "cropdetect") || |
| @@ -75,22 +75,31 @@ typedef struct { · 74 unmodified lines | |||
| 75 | #define OFFSET(x) offsetof(TestSourceContext, x) | 75 | #define OFFSET(x) offsetof(TestSourceContext, x) |
| 76 | #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM | 76 | #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM |
| 77 | 77 | ||
| 78 | static const AVOption options[] = { | 78 | #define COMMON_OPTIONS \ |
| 79 | { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 84 | { "d", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },\ |
| 85 | { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS }, | 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 | /* only used by color */ | 89 | /* only used by color */ |
| 88 | { "color", "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 }, |
| 89 | { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, 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 | /* only used by testsrc */ | 98 | /* only used by testsrc */ |
| 92 | { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, | 99 | { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, |
| 93 | { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, | 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 | { NULL }, | 103 | { NULL }, |
| 95 | }; | 104 | }; |
| 96 | 105 | ||
| @@ -99,8 +108,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 2 unmodified lines | |||
| 99 | TestSourceContext *test = ctx->priv; | 108 | TestSourceContext *test = ctx->priv; |
| 100 | int ret = 0; | 109 | int ret = 0; |
| 101 | 110 | ||
| 102 | av_opt_set_defaults(test); | ||
| 103 | |||
| 104 | if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) | 111 | if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) |
| 105 | return ret; | 112 | return ret; |
| 106 | 113 | ||
| @@ -200,7 +207,6 @@ static int request_frame(AVFilterLink *outlink) · 93 unmodified lines | |||
| 200 | 207 | ||
| 201 | #if CONFIG_COLOR_FILTER | 208 | #if CONFIG_COLOR_FILTER |
| 202 | 209 | ||
| 203 | #define color_options options | ||
| 204 | AVFILTER_DEFINE_CLASS(color); | 210 | AVFILTER_DEFINE_CLASS(color); |
| 205 | 211 | ||
| 206 | static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref) | 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 | static av_cold int color_init(AVFilterContext *ctx, const char *args) | 220 | static av_cold int color_init(AVFilterContext *ctx, const char *args) |
| 215 | { | 221 | { |
| 216 | TestSourceContext *test = ctx->priv; | 222 | TestSourceContext *test = ctx->priv; |
| 217 | test->class = &color_class; | ||
| 218 | test->fill_picture_fn = color_fill_picture; | 223 | test->fill_picture_fn = color_fill_picture; |
| 219 | test->draw_once = 1; | 224 | test->draw_once = 1; |
| 220 | av_opt_set(test, "color", "black", 0); | 225 | return init(ctx, NULL); |
| 221 | return init(ctx, args); | ||
| 222 | } | 226 | } |
| 223 | 227 | ||
| 224 | static int color_query_formats(AVFilterContext *ctx) | 228 | static int color_query_formats(AVFilterContext *ctx) |
| @@ -263,6 +267,7 @@ AVFilter avfilter_vsrc_color = { · 38 unmodified lines | |||
| 263 | .name = "color", | 267 | .name = "color", |
| 264 | .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), | 268 | .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), |
| 265 | 269 | ||
| 270 | .priv_class = &color_class, | ||
| 266 | .priv_size = sizeof(TestSourceContext), | 271 | .priv_size = sizeof(TestSourceContext), |
| 267 | .init = color_init, | 272 | .init = color_init, |
| 268 | .uninit = uninit, | 273 | .uninit = uninit, |
| @@ -270,7 +275,6 @@ AVFilter avfilter_vsrc_color = { · 1 unmodified line | |||
| 270 | .query_formats = color_query_formats, | 275 | .query_formats = color_query_formats, |
| 271 | .inputs = NULL, | 276 | .inputs = NULL, |
| 272 | .outputs = color_outputs, | 277 | .outputs = color_outputs, |
| 273 | .priv_class = &color_class, | ||
| 274 | }; | 278 | }; |
| 275 | 279 | ||
| 276 | #endif /* CONFIG_COLOR_FILTER */ | 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 | test->class = &nullsrc_class; | 293 | test->class = &nullsrc_class; |
| 290 | test->fill_picture_fn = nullsrc_fill_picture; | 294 | test->fill_picture_fn = nullsrc_fill_picture; |
| 295 | av_opt_set_defaults(test); | ||
| 291 | return init(ctx, args); | 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 | test->class = &testsrc_class; | 513 | test->class = &testsrc_class; |
| 509 | test->fill_picture_fn = test_fill_picture; | 514 | test->fill_picture_fn = test_fill_picture; |
| 515 | av_opt_set_defaults(test); | ||
| 510 | return init(ctx, args); | 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 | test->draw_once = 1; | 619 | test->draw_once = 1; |
| 614 | test->class = &rgbtestsrc_class; | 620 | test->class = &rgbtestsrc_class; |
| 615 | test->fill_picture_fn = rgbtest_fill_picture; | 621 | test->fill_picture_fn = rgbtest_fill_picture; |
| 622 | av_opt_set_defaults(test); | ||
| 616 | return init(ctx, args); | 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 | test->class = &smptebars_class; | 771 | test->class = &smptebars_class; |
| 765 | test->fill_picture_fn = smptebars_fill_picture; | 772 | test->fill_picture_fn = smptebars_fill_picture; |
| 766 | test->draw_once = 1; | 773 | test->draw_once = 1; |
| 774 | av_opt_set_defaults(test); | ||
| 767 | return init(ctx, args); | 775 | return init(ctx, args); |
| 768 | } | 776 | } |
| 769 | 777 | ||