Commit 8bafd83a authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '7bc1a883'

* commit '7bc1a883':
  vsrc_color: switch to an AVOptions-based system.

Conflicts:
	doc/filters.texi
	libavfilter/vsrc_color.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 7f2198a2 7bc1a883
...@@ -675,6 +675,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque ...@@ -675,6 +675,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
!strcmp(filter->filter->name, "cellauto") || !strcmp(filter->filter->name, "cellauto") ||
!strcmp(filter->filter->name, "channelmap") || !strcmp(filter->filter->name, "channelmap") ||
!strcmp(filter->filter->name, "channelsplit") || !strcmp(filter->filter->name, "channelsplit") ||
!strcmp(filter->filter->name, "color" ) ||
!strcmp(filter->filter->name, "colormatrix") || !strcmp(filter->filter->name, "colormatrix") ||
!strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "crop" ) ||
!strcmp(filter->filter->name, "cropdetect") || !strcmp(filter->filter->name, "cropdetect") ||
......
...@@ -75,22 +75,31 @@ typedef struct { ...@@ -75,22 +75,31 @@ typedef struct {
#define OFFSET(x) offsetof(TestSourceContext, x) #define OFFSET(x) offsetof(TestSourceContext, x)
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption options[] = { #define COMMON_OPTIONS \
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS }, { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS }, { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "320x240"}, 0, 0, FLAGS },\
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\
{ "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS }, { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, FLAGS },\
{ "duration", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, { "duration", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },\
{ "d", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS }, { "d", "set video duration", OFFSET(duration_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },\
{ "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS }, { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX, FLAGS },
static const AVOption color_options[] = {
/* only used by color */ /* only used by color */
{ "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, { "color", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
{ "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, { "c", "set color", OFFSET(color_str), AV_OPT_TYPE_STRING, {.str = "black"}, CHAR_MIN, CHAR_MAX, FLAGS },
COMMON_OPTIONS
{ NULL },
};
static const AVOption options[] = {
/* only used by testsrc */ /* only used by testsrc */
{ "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, { "decimals", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
{ "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS }, { "n", "set number of decimals to show", OFFSET(nb_decimals), AV_OPT_TYPE_INT, {.i64=0}, 0, 17, FLAGS },
COMMON_OPTIONS
{ NULL }, { NULL },
}; };
...@@ -99,8 +108,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args) ...@@ -99,8 +108,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
TestSourceContext *test = ctx->priv; TestSourceContext *test = ctx->priv;
int ret = 0; int ret = 0;
av_opt_set_defaults(test);
if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0) if ((ret = (av_set_options_string(test, args, "=", ":"))) < 0)
return ret; return ret;
...@@ -200,7 +207,6 @@ static int request_frame(AVFilterLink *outlink) ...@@ -200,7 +207,6 @@ static int request_frame(AVFilterLink *outlink)
#if CONFIG_COLOR_FILTER #if CONFIG_COLOR_FILTER
#define color_options options
AVFILTER_DEFINE_CLASS(color); AVFILTER_DEFINE_CLASS(color);
static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref) static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref)
...@@ -214,11 +220,9 @@ static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref) ...@@ -214,11 +220,9 @@ static void color_fill_picture(AVFilterContext *ctx, AVFrame *picref)
static av_cold int color_init(AVFilterContext *ctx, const char *args) static av_cold int color_init(AVFilterContext *ctx, const char *args)
{ {
TestSourceContext *test = ctx->priv; TestSourceContext *test = ctx->priv;
test->class = &color_class;
test->fill_picture_fn = color_fill_picture; test->fill_picture_fn = color_fill_picture;
test->draw_once = 1; test->draw_once = 1;
av_opt_set(test, "color", "black", 0); return init(ctx, NULL);
return init(ctx, args);
} }
static int color_query_formats(AVFilterContext *ctx) static int color_query_formats(AVFilterContext *ctx)
...@@ -263,6 +267,7 @@ AVFilter avfilter_vsrc_color = { ...@@ -263,6 +267,7 @@ AVFilter avfilter_vsrc_color = {
.name = "color", .name = "color",
.description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."), .description = NULL_IF_CONFIG_SMALL("Provide an uniformly colored input."),
.priv_class = &color_class,
.priv_size = sizeof(TestSourceContext), .priv_size = sizeof(TestSourceContext),
.init = color_init, .init = color_init,
.uninit = uninit, .uninit = uninit,
...@@ -270,7 +275,6 @@ AVFilter avfilter_vsrc_color = { ...@@ -270,7 +275,6 @@ AVFilter avfilter_vsrc_color = {
.query_formats = color_query_formats, .query_formats = color_query_formats,
.inputs = NULL, .inputs = NULL,
.outputs = color_outputs, .outputs = color_outputs,
.priv_class = &color_class,
}; };
#endif /* CONFIG_COLOR_FILTER */ #endif /* CONFIG_COLOR_FILTER */
...@@ -288,6 +292,7 @@ static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args) ...@@ -288,6 +292,7 @@ static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args)
test->class = &nullsrc_class; test->class = &nullsrc_class;
test->fill_picture_fn = nullsrc_fill_picture; test->fill_picture_fn = nullsrc_fill_picture;
av_opt_set_defaults(test);
return init(ctx, args); return init(ctx, args);
} }
...@@ -507,6 +512,7 @@ static av_cold int test_init(AVFilterContext *ctx, const char *args) ...@@ -507,6 +512,7 @@ static av_cold int test_init(AVFilterContext *ctx, const char *args)
test->class = &testsrc_class; test->class = &testsrc_class;
test->fill_picture_fn = test_fill_picture; test->fill_picture_fn = test_fill_picture;
av_opt_set_defaults(test);
return init(ctx, args); return init(ctx, args);
} }
...@@ -613,6 +619,7 @@ static av_cold int rgbtest_init(AVFilterContext *ctx, const char *args) ...@@ -613,6 +619,7 @@ static av_cold int rgbtest_init(AVFilterContext *ctx, const char *args)
test->draw_once = 1; test->draw_once = 1;
test->class = &rgbtestsrc_class; test->class = &rgbtestsrc_class;
test->fill_picture_fn = rgbtest_fill_picture; test->fill_picture_fn = rgbtest_fill_picture;
av_opt_set_defaults(test);
return init(ctx, args); return init(ctx, args);
} }
...@@ -764,6 +771,7 @@ static av_cold int smptebars_init(AVFilterContext *ctx, const char *args) ...@@ -764,6 +771,7 @@ static av_cold int smptebars_init(AVFilterContext *ctx, const char *args)
test->class = &smptebars_class; test->class = &smptebars_class;
test->fill_picture_fn = smptebars_fill_picture; test->fill_picture_fn = smptebars_fill_picture;
test->draw_once = 1; test->draw_once = 1;
av_opt_set_defaults(test);
return init(ctx, args); return init(ctx, args);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment