From 7c11c216690c11a4e578353fb05f0f64978eeaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 21:57:07 +0200 Subject: [PATCH 01/11] lavfi/thumbnail: switch to an AVOptions-based system. --- doc/filters.texi | 5 +---- libavfilter/avfilter.c | 1 + libavfilter/vf_thumbnail.c | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 03113cd387..11e33e698a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -5392,10 +5392,7 @@ Swap U & V plane. @section thumbnail Select the most representative frame in a given sequence of consecutive frames. -The filter accepts parameters as a list of @var{key}=@var{value} -pairs, separated by ":". If the key of the first options is omitted, -the arguments are interpreted according to the syntax -thumbnail[=@var{n}]. +The filter accepts the following options: @table @option @item n diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index addb7321e1..5fe6f1982f 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -681,6 +681,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "resample") || + !strcmp(filter->filter->name, "thumbnail") || // !strcmp(filter->filter->name, "scale" ) || 0 ; diff --git a/libavfilter/vf_thumbnail.c b/libavfilter/vf_thumbnail.c index d32c6c7b29..2cf702c7f7 100644 --- a/libavfilter/vf_thumbnail.c +++ b/libavfilter/vf_thumbnail.c @@ -227,8 +227,6 @@ static const AVFilterPad thumbnail_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "n", NULL }; - AVFilter avfilter_vf_thumbnail = { .name = "thumbnail", .description = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."), @@ -239,5 +237,4 @@ AVFilter avfilter_vf_thumbnail = { .inputs = thumbnail_inputs, .outputs = thumbnail_outputs, .priv_class = &thumbnail_class, - .shorthand = shorthand, }; From 1b1688bfc640ab73f05fbe99bfbb400dced5eef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:05:12 +0200 Subject: [PATCH 02/11] lavfi/silencedetect: switch to an AVOptions-based system. --- doc/filters.texi | 2 ++ libavfilter/af_silencedetect.c | 17 ----------------- libavfilter/avfilter.c | 1 + 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 11e33e698a..ce4019be0d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -1117,6 +1117,8 @@ minimum detected noise duration. The printed times and duration are expressed in seconds. +The filter accepts the following options: + @table @option @item duration, d Set silence duration until notification (default is 2 seconds). diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index dbd9f5ffd7..eb4718b268 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -54,22 +54,6 @@ static const AVOption silencedetect_options[] = { AVFILTER_DEFINE_CLASS(silencedetect); -static av_cold int init(AVFilterContext *ctx, const char *args) -{ - int ret; - SilenceDetectContext *silence = ctx->priv; - - silence->class = &silencedetect_class; - av_opt_set_defaults(silence); - - if ((ret = av_set_options_string(silence, args, "=", ":")) < 0) - return ret; - - av_opt_free(silence); - - return 0; -} - static char *get_metadata_val(AVFrame *insamples, const char *key) { AVDictionaryEntry *e = av_dict_get(insamples->metadata, key, NULL, 0); @@ -176,7 +160,6 @@ AVFilter avfilter_af_silencedetect = { .name = "silencedetect", .description = NULL_IF_CONFIG_SMALL("Detect silence."), .priv_size = sizeof(SilenceDetectContext), - .init = init, .query_formats = query_formats, .inputs = silencedetect_inputs, .outputs = silencedetect_outputs, diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 5fe6f1982f..a731ec5495 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -681,6 +681,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "resample") || + !strcmp(filter->filter->name, "silencedetect") || !strcmp(filter->filter->name, "thumbnail") || // !strcmp(filter->filter->name, "scale" ) || 0 From 4964ec2cd4822eb4d9b34e83b0a77c0592c7c192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:10:56 +0200 Subject: [PATCH 03/11] lavfi/showspectrum: switch to an AVOptions-based system. --- doc/filters.texi | 3 ++- libavfilter/avf_showspectrum.c | 15 --------------- libavfilter/avfilter.c | 1 + 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index ce4019be0d..561cdeeb0d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -7033,7 +7033,8 @@ do not have exactly the same duration in the first file. Convert input audio to a video output, representing the audio frequency spectrum. -The filter accepts the following named parameters: +The filter accepts the following options: + @table @option @item size, s Specify the video size for the output. Default value is @code{640x512}. diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 364ee6c378..058f22c919 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -97,20 +97,6 @@ static const struct { { 1, 1, 0, 0 } }; -static av_cold int init(AVFilterContext *ctx, const char *args) -{ - ShowSpectrumContext *showspectrum = ctx->priv; - int err; - - showspectrum->class = &showspectrum_class; - av_opt_set_defaults(showspectrum); - - if ((err = av_set_options_string(showspectrum, args, "=", ":")) < 0) - return err; - - return 0; -} - static av_cold void uninit(AVFilterContext *ctx) { ShowSpectrumContext *showspectrum = ctx->priv; @@ -505,7 +491,6 @@ static const AVFilterPad showspectrum_outputs[] = { AVFilter avfilter_avf_showspectrum = { .name = "showspectrum", .description = NULL_IF_CONFIG_SMALL("Convert input audio to a spectrum video output."), - .init = init, .uninit = uninit, .query_formats = query_formats, .priv_size = sizeof(ShowSpectrumContext), diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a731ec5495..130fccfaf2 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -681,6 +681,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "resample") || + !strcmp(filter->filter->name, "showspectrum") || !strcmp(filter->filter->name, "silencedetect") || !strcmp(filter->filter->name, "thumbnail") || // !strcmp(filter->filter->name, "scale" ) || From 5afd58fbb4571d8b9c81c7573c2a43d5ad15672a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:13:12 +0200 Subject: [PATCH 04/11] lavfi/ebur128: switch to an AVOptions-based system. --- doc/filters.texi | 2 +- libavfilter/avfilter.c | 1 + libavfilter/f_ebur128.c | 7 ------- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 561cdeeb0d..1155463712 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6845,7 +6845,7 @@ the momentary loudness (400 milliseconds). More information about the Loudness Recommendation EBU R128 on @url{http://tech.ebu.ch/loudness}. -The filter accepts the following named parameters: +The filter accepts the following options: @table @option diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 130fccfaf2..6ec944b467 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -664,6 +664,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "delogo" ) || !strcmp(filter->filter->name, "drawbox" ) || !strcmp(filter->filter->name, "drawtext" ) || + !strcmp(filter->filter->name, "ebur128" ) || !strcmp(filter->filter->name, "fade" ) || !strcmp(filter->filter->name, "fieldorder") || !strcmp(filter->filter->name, "fps" ) || diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 0c7f7714b4..2ff92a33c8 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -405,16 +405,9 @@ static struct hist_entry *get_histogram(void) static av_cold int init(AVFilterContext *ctx, const char *args) { - int ret; EBUR128Context *ebur128 = ctx->priv; AVFilterPad pad; - ebur128->class = &ebur128_class; - av_opt_set_defaults(ebur128); - - if ((ret = av_set_options_string(ebur128, args, "=", ":")) < 0) - return ret; - if (ebur128->loglevel != AV_LOG_INFO && ebur128->loglevel != AV_LOG_VERBOSE) { if (ebur128->do_video || ebur128->metadata) From 8388e1e2b343e25b3a7de31079557285b7353ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:15:10 +0200 Subject: [PATCH 05/11] lavfi/perms: switch to an AVOptions-based system. --- doc/filters.texi | 6 +----- libavfilter/avfilter.c | 2 ++ libavfilter/f_perms.c | 4 ---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 1155463712..796cdce929 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -6344,11 +6344,7 @@ Set read/write permissions for the output frames. These filters are mainly aimed at developers to test direct path in the following filter in the filtergraph. -The filters accept parameters as a list of @var{key}=@var{value} pairs, -separated by ":". If the key of the first options is omitted, the argument is -assumed to be the @var{mode}. - -A description of the accepted parameters follows. +The filters accept the following options: @table @option @item mode diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 6ec944b467..a7d05e47e0 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -681,6 +681,8 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "pad" ) || !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || + !strcmp(filter->filter->name, "perms") || + !strcmp(filter->filter->name, "aperms") || !strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "showspectrum") || !strcmp(filter->filter->name, "silencedetect") || diff --git a/libavfilter/f_perms.c b/libavfilter/f_perms.c index 9853eab4a5..33674170b6 100644 --- a/libavfilter/f_perms.c +++ b/libavfilter/f_perms.c @@ -111,8 +111,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) return ret; } -static const char *const shorthand[] = { "mode", NULL }; - #if CONFIG_APERMS_FILTER #define aperms_options options @@ -143,7 +141,6 @@ AVFilter avfilter_af_aperms = { .inputs = aperms_inputs, .outputs = aperms_outputs, .priv_class = &aperms_class, - .shorthand = shorthand, }; #endif /* CONFIG_APERMS_FILTER */ @@ -177,6 +174,5 @@ AVFilter avfilter_vf_perms = { .inputs = perms_inputs, .outputs = perms_outputs, .priv_class = &perms_class, - .shorthand = shorthand, }; #endif /* CONFIG_PERMS_FILTER */ From 8da1f1f2081c615852e036f3f8e45eee07ee3bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:18:20 +0200 Subject: [PATCH 06/11] lavfi/colormatrix: switch to an AVOptions-based system. --- doc/filters.texi | 6 +----- libavfilter/avfilter.c | 1 + libavfilter/vf_colormatrix.c | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 796cdce929..d5b7e68c8d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2102,12 +2102,8 @@ boxblur=luma_radius=min(h\,w)/10:luma_power=1:chroma_radius=min(cw\,ch)/10:chrom Convert color matrix. -The filter accepts parameters as a list of @var{key}=@var{value} -pairs, separated by ":". If the key of the first options is omitted, -the arguments are interpreted according to the syntax -@var{src}:@var{dst}. +The filter accepts the following options: -A description of the accepted options follows: @table @option @item src @item dst diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a7d05e47e0..0d76b985ab 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -659,6 +659,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "aformat") || !strcmp(filter->filter->name, "blackframe") || !strcmp(filter->filter->name, "boxblur" ) || + !strcmp(filter->filter->name, "colormatrix") || !strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "cropdetect") || !strcmp(filter->filter->name, "delogo" ) || diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c index c57be41559..a161c81809 100644 --- a/libavfilter/vf_colormatrix.c +++ b/libavfilter/vf_colormatrix.c @@ -375,8 +375,6 @@ static const AVFilterPad colormatrix_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "src", "dst", NULL }; - AVFilter avfilter_vf_colormatrix = { .name = "colormatrix", .description = NULL_IF_CONFIG_SMALL("Convert color matrix."), @@ -387,5 +385,4 @@ AVFilter avfilter_vf_colormatrix = { .inputs = colormatrix_inputs, .outputs = colormatrix_outputs, .priv_class = &colormatrix_class, - .shorthand = shorthand, }; From 34610e11e7d597d747d9b92e961e17c23ac5b4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:26:06 +0200 Subject: [PATCH 07/11] lavfi/curves: switch to an AVOptions-based system. --- doc/filters.texi | 32 ++++++++++++++------------------ libavfilter/avfilter.c | 1 + libavfilter/vf_curves.c | 18 ++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index d5b7e68c8d..c94e5123ad 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2369,30 +2369,15 @@ If there is no key point defined in @code{x=0}, the filter will automatically insert a @var{(0;0)} point. In the same way, if there is no key point defined in @code{x=1}, the filter will automatically insert a @var{(1;1)} point. -The filter accepts parameters as a list of @var{key}=@var{value} -pairs, separated by ":". If the key of the first options is omitted, -the arguments are interpreted according to the syntax -curves[=@var{preset}]. - -A description of the accepted parameters follows. +The filter accepts the following options: @table @option -@item red, r -Set the key points for the red component. -@item green, g -Set the key points for the green component. -@item blue, b -Set the key points for the blue component. -@item all -Set the key points for all components. -Can be used in addition to the other key points component -options. In this case, the unset component(s) will fallback on this -@option{all} setting. @item preset Select one of the available color presets. This option can not be used in addition to the @option{r}, @option{g}, @option{b} parameters. Available presets are: @table @samp +@item none @item color_negative @item cross_process @item darker @@ -2404,7 +2389,18 @@ Available presets are: @item strong_contrast @item vintage @end table -Default is unset. +Default is @code{none}. +@item red, r +Set the key points for the red component. +@item green, g +Set the key points for the green component. +@item blue, b +Set the key points for the blue component. +@item all +Set the key points for all components. +Can be used in addition to the other key points component +options. In this case, the unset component(s) will fallback on this +@option{all} setting. @end table To avoid some filtergraph syntax conflicts, each key points list need to be diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 0d76b985ab..8643992a4b 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -662,6 +662,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "colormatrix") || !strcmp(filter->filter->name, "crop" ) || !strcmp(filter->filter->name, "cropdetect") || + !strcmp(filter->filter->name, "curves" ) || !strcmp(filter->filter->name, "delogo" ) || !strcmp(filter->filter->name, "drawbox" ) || !strcmp(filter->filter->name, "drawtext" ) || diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c index 1f4e733c3d..5cd3f52c18 100644 --- a/libavfilter/vf_curves.c +++ b/libavfilter/vf_curves.c @@ -59,14 +59,8 @@ typedef struct { #define OFFSET(x) offsetof(CurvesContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption curves_options[] = { - { "red", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "r", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "green", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "g", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "blue", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "b", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, - { "all", "set points coordinates for all components", OFFSET(comp_points_str_all),AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, { "preset", "select a color curves preset", OFFSET(preset), AV_OPT_TYPE_INT, {.i64=PRESET_NONE}, PRESET_NONE, NB_PRESETS-1, FLAGS, "preset_name" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NONE}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, { "color_negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_COLOR_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, { "cross_process", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_CROSS_PROCESS}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, { "darker", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_DARKER}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, @@ -77,6 +71,13 @@ static const AVOption curves_options[] = { { "negative", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_NEGATIVE}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, { "strong_contrast", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_STRONG_CONTRAST}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, { "vintage", NULL, 0, AV_OPT_TYPE_CONST, {.i64=PRESET_VINTAGE}, INT_MIN, INT_MAX, FLAGS, "preset_name" }, + { "red", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "r", "set red points coordinates", OFFSET(comp_points_str[0]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "green", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "g", "set green points coordinates", OFFSET(comp_points_str[1]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "blue", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "b", "set blue points coordinates", OFFSET(comp_points_str[2]), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, + { "all", "set points coordinates for all components", OFFSET(comp_points_str_all),AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, { NULL } }; @@ -447,8 +448,6 @@ static const AVFilterPad curves_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "preset", NULL }; - AVFilter avfilter_vf_curves = { .name = "curves", .description = NULL_IF_CONFIG_SMALL("Adjust components curves."), @@ -458,5 +457,4 @@ AVFilter avfilter_vf_curves = { .inputs = curves_inputs, .outputs = curves_outputs, .priv_class = &curves_class, - .shorthand = shorthand, }; From 1cdb9f48dbc3601fc9ba007d344a7cd45da094d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:28:37 +0200 Subject: [PATCH 08/11] lavfi/edgedetect: switch to an AVOptions-based system. --- doc/filters.texi | 2 +- libavfilter/avfilter.c | 1 + libavfilter/vf_edgedetect.c | 7 ------- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index c94e5123ad..01380bc3f7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3008,7 +3008,7 @@ For more information about fontconfig, check: Detect and draw edges. The filter uses the Canny Edge Detection algorithm. -This filter accepts the following optional named parameters: +The filter accepts the following options: @table @option @item low, high diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 8643992a4b..b631326e00 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -667,6 +667,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "drawbox" ) || !strcmp(filter->filter->name, "drawtext" ) || !strcmp(filter->filter->name, "ebur128" ) || + !strcmp(filter->filter->name, "edgedetect") || !strcmp(filter->filter->name, "fade" ) || !strcmp(filter->filter->name, "fieldorder") || !strcmp(filter->filter->name, "fps" ) || diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c index fb137efa70..0f9610a5bb 100644 --- a/libavfilter/vf_edgedetect.c +++ b/libavfilter/vf_edgedetect.c @@ -52,15 +52,8 @@ AVFILTER_DEFINE_CLASS(edgedetect); static av_cold int init(AVFilterContext *ctx, const char *args) { - int ret; EdgeDetectContext *edgedetect = ctx->priv; - edgedetect->class = &edgedetect_class; - av_opt_set_defaults(edgedetect); - - if ((ret = av_set_options_string(edgedetect, args, "=", ":")) < 0) - return ret; - edgedetect->low_u8 = edgedetect->low * 255. + .5; edgedetect->high_u8 = edgedetect->high * 255. + .5; return 0; From f8eabab04d1b429bc0332c06a46ae3c344a4cb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:33:41 +0200 Subject: [PATCH 09/11] lavfi/geq: switch to an AVOptions-based system. --- doc/filters.texi | 6 +----- libavfilter/avfilter.c | 1 + libavfilter/vf_geq.c | 3 --- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 01380bc3f7..00a804a4b1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3302,11 +3302,7 @@ For more information see: @section geq -The filter takes one, two, three or four equations as parameter, separated by ':'. -The first equation is mandatory and applies to the luma plane. The two -following are respectively for chroma blue and chroma red planes. - -The filter syntax allows named parameters: +The filter accepts the following options: @table @option @item lum_expr diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index b631326e00..cd47f47d39 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -673,6 +673,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "fps" ) || !strcmp(filter->filter->name, "frei0r" ) || !strcmp(filter->filter->name, "frei0r_src") || + !strcmp(filter->filter->name, "geq" ) || !strcmp(filter->filter->name, "gradfun" ) || !strcmp(filter->filter->name, "hqdn3d" ) || !strcmp(filter->filter->name, "ocv" ) || diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c index a6b48e1665..64e8e5212f 100644 --- a/libavfilter/vf_geq.c +++ b/libavfilter/vf_geq.c @@ -228,8 +228,6 @@ static const AVFilterPad geq_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "lum_expr", "cb_expr", "cr_expr", "alpha_expr", NULL }; - AVFilter avfilter_vf_geq = { .name = "geq", .description = NULL_IF_CONFIG_SMALL("Apply generic equation to each pixel."), @@ -240,5 +238,4 @@ AVFilter avfilter_vf_geq = { .inputs = geq_inputs, .outputs = geq_outputs, .priv_class = &geq_class, - .shorthand = shorthand, }; From 8da1fff85a90b2fad1310e629ed2056d6c43f50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 22:43:25 +0200 Subject: [PATCH 10/11] lavfi/pp: switch to an AVOptions-based system. Also add and use the '|' separator instead of ':' since it's incompatible with the new option system... --- doc/filters.texi | 31 +++++++++++++++++++------------ libavfilter/avfilter.c | 1 + libavfilter/vf_pp.c | 18 ++++++++++++++---- libpostproc/postprocess.c | 2 +- libpostproc/version.h | 2 +- tests/lavfi-regression.sh | 4 ++-- 6 files changed, 38 insertions(+), 20 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 00a804a4b1..ed192189d3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4605,6 +4605,13 @@ Subfilters must be separated by '/' and can be disabled by prepending a '-'. Each subfilter and some options have a short and a long name that can be used interchangeably, i.e. dr/dering are the same. +The filters accept the following options: + +@table @option +@item subfilters +Set postprocessing subfilters string. +@end table + All subfilters share common options to determine their scope: @table @option @@ -4621,12 +4628,12 @@ Do luminance filtering only (no chrominance). Do chrominance filtering only (no luminance). @end table -These options can be appended after the subfilter name, separated by a ':'. +These options can be appended after the subfilter name, separated by a '|'. Available subfilters are: @table @option -@item hb/hdeblock[:difference[:flatness]] +@item hb/hdeblock[|difference[|flatness]] Horizontal deblocking filter @table @option @item difference @@ -4635,7 +4642,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}). Flatness threshold where lower values mean more deblocking (default: @code{39}). @end table -@item vb/vdeblock[:difference[:flatness]] +@item vb/vdeblock[|difference[|flatness]] Vertical deblocking filter @table @option @item difference @@ -4644,7 +4651,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}). Flatness threshold where lower values mean more deblocking (default: @code{39}). @end table -@item ha/hadeblock[:difference[:flatness]] +@item ha/hadeblock[|difference[|flatness]] Accurate horizontal deblocking filter @table @option @item difference @@ -4653,7 +4660,7 @@ Difference factor where higher values mean more deblocking (default: @code{32}). Flatness threshold where lower values mean more deblocking (default: @code{39}). @end table -@item va/vadeblock[:difference[:flatness]] +@item va/vadeblock[|difference[|flatness]] Accurate vertical deblocking filter @table @option @item difference @@ -4677,7 +4684,7 @@ Experimental vertical deblocking filter @item dr/dering Deringing filter -@item tn/tmpnoise[:threshold1[:threshold2[:threshold3]]], temporal noise reducer +@item tn/tmpnoise[|threshold1[|threshold2[|threshold3]]], temporal noise reducer @table @option @item threshold1 larger -> stronger filtering @@ -4717,7 +4724,7 @@ second line with a @code{(-1 4 2 4 -1)} filter. Vertically applied FIR lowpass deinterlacing filter that deinterlaces the given block by filtering all lines with a @code{(-1 2 6 2 -1)} filter. -@item fq/forceQuant[:quantizer] +@item fq/forceQuant[|quantizer] Overrides the quantizer table from the input with the constant quantizer you specify. @table @option @@ -4726,13 +4733,13 @@ Quantizer to use @end table @item de/default -Default pp filter combination (@code{hb:a,vb:a,dr:a}) +Default pp filter combination (@code{hb|a,vb|a,dr|a}) @item fa/fast -Fast pp filter combination (@code{h1:a,v1:a,dr:a}) +Fast pp filter combination (@code{h1|a,v1|a,dr|a}) @item ac -High quality pp filter combination (@code{ha:a:128:7,va:a,dr:a}) +High quality pp filter combination (@code{ha|a|128|7,va|a,dr|a}) @end table @subsection Examples @@ -4754,14 +4761,14 @@ pp=de/-al @item Apply default filters and temporal denoiser: @example -pp=default/tmpnoise:1:2:3 +pp=default/tmpnoise|1|2|3 @end example @item Apply deblocking on luminance only, and switch vertical deblocking on or off automatically depending on available CPU time: @example -pp=hb:y/vb:a +pp=hb|y/vb|a @end example @end itemize diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index cd47f47d39..13e9ac9098 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -686,6 +686,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "format") || !strcmp(filter->filter->name, "noformat") || !strcmp(filter->filter->name, "perms") || + !strcmp(filter->filter->name, "pp" ) || !strcmp(filter->filter->name, "aperms") || !strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "showspectrum") || diff --git a/libavfilter/vf_pp.c b/libavfilter/vf_pp.c index b7f35d3628..7dfb448790 100644 --- a/libavfilter/vf_pp.c +++ b/libavfilter/vf_pp.c @@ -31,21 +31,29 @@ #include "libpostproc/postprocess.h" typedef struct { + const AVClass *class; + char *subfilters; int mode_id; pp_mode *modes[PP_QUALITY_MAX + 1]; void *pp_ctx; } PPFilterContext; +#define OFFSET(x) offsetof(PPFilterContext, x) +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM +static const AVOption pp_options[] = { + { "subfilters", "set postprocess subfilters", OFFSET(subfilters), AV_OPT_TYPE_STRING, {.str="de"}, .flags = FLAGS }, + { NULL } +}; + +AVFILTER_DEFINE_CLASS(pp); + static av_cold int pp_init(AVFilterContext *ctx, const char *args) { int i; PPFilterContext *pp = ctx->priv; - if (!args || !*args) - args = "de"; - for (i = 0; i <= PP_QUALITY_MAX; i++) { - pp->modes[i] = pp_get_mode_by_name_and_quality(args, i); + pp->modes[i] = pp_get_mode_by_name_and_quality(pp->subfilters, i); if (!pp->modes[i]) return AVERROR_EXTERNAL; } @@ -171,4 +179,6 @@ AVFilter avfilter_vf_pp = { .inputs = pp_inputs, .outputs = pp_outputs, .process_command = pp_process_command, + .priv_class = &pp_class, + }; diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index facfd2cdd9..b34943f983 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -666,7 +666,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) char temp[GET_MODE_BUFFER_SIZE]; char *p= temp; static const char filterDelimiters[] = ",/"; - static const char optionDelimiters[] = ":"; + static const char optionDelimiters[] = ":|"; struct PPMode *ppMode; char *filterToken; diff --git a/libpostproc/version.h b/libpostproc/version.h index d0d3d431f8..111db44e01 100644 --- a/libpostproc/version.h +++ b/libpostproc/version.h @@ -29,7 +29,7 @@ #include "libavutil/avutil.h" #define LIBPOSTPROC_VERSION_MAJOR 52 -#define LIBPOSTPROC_VERSION_MINOR 2 +#define LIBPOSTPROC_VERSION_MINOR 3 #define LIBPOSTPROC_VERSION_MICRO 100 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \ diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh index bb023e4567..9076e4fbda 100755 --- a/tests/lavfi-regression.sh +++ b/tests/lavfi-regression.sh @@ -52,8 +52,8 @@ do_lavfi "overlay_yuv420" "split[m],scale=88:72,pad=96:80:4:4[o2];[m]fifo[o1 do_lavfi "overlay_yuv444" "split[m],scale=88:72,pad=96:80:4:4[o2];[m]fifo[o1],[o1][o2]overlay=240:16:format=yuv444" do_lavfi "pad" "pad=iw*1.5:ih*1.5:iw*0.3:ih*0.2" do_lavfi "pp" "pp=be/hb/vb/tn/l5/al" -do_lavfi "pp2" "pp=be/fq:16/h1/v1/lb" -do_lavfi "pp3" "pp=be/fq:8/ha:128:7/va/li" +do_lavfi "pp2" "pp=be/fq|16/h1/v1/lb" +do_lavfi "pp3" "pp=be/fq|8/ha|128|7/va/li" do_lavfi "pp4" "pp=be/ci" do_lavfi "pp5" "pp=md" do_lavfi "pp6" "pp=be/fd" From e2b0edb6ac9ca2713d8f3846dd0ca265815fa6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 10 Apr 2013 23:10:05 +0200 Subject: [PATCH 11/11] lavfi/subtitles: switch to an AVOptions-based system. --- doc/filters.texi | 3 +-- libavfilter/avfilter.c | 2 ++ libavfilter/vf_subtitles.c | 4 ---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index ed192189d3..49bc8b3b78 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -5322,8 +5322,7 @@ To enable compilation of this filter you need to configure FFmpeg with libavformat to convert the passed subtitles file to ASS (Advanced Substation Alpha) subtitles format. -This filter accepts the following named options, expressed as a -sequence of @var{key}=@var{value} pairs, separated by ":". +The filter accepts the following options: @table @option @item filename, f diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 13e9ac9098..1589cc961c 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -657,6 +657,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque int ret=0; int anton_options = !strcmp(filter->filter->name, "aformat") || + !strcmp(filter->filter->name, "ass") || !strcmp(filter->filter->name, "blackframe") || !strcmp(filter->filter->name, "boxblur" ) || !strcmp(filter->filter->name, "colormatrix") || @@ -691,6 +692,7 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque !strcmp(filter->filter->name, "resample") || !strcmp(filter->filter->name, "showspectrum") || !strcmp(filter->filter->name, "silencedetect") || + !strcmp(filter->filter->name, "subtitles") || !strcmp(filter->filter->name, "thumbnail") || // !strcmp(filter->filter->name, "scale" ) || 0 diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 8bca01ef83..5c1314f730 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -201,8 +201,6 @@ static const AVFilterPad ass_outputs[] = { { NULL } }; -static const char *const shorthand[] = { "filename", NULL }; - #if CONFIG_ASS_FILTER static const AVOption ass_options[] = { @@ -240,7 +238,6 @@ AVFilter avfilter_vf_ass = { .inputs = ass_inputs, .outputs = ass_outputs, .priv_class = &ass_class, - .shorthand = shorthand, }; #endif @@ -365,6 +362,5 @@ AVFilter avfilter_vf_subtitles = { .inputs = ass_inputs, .outputs = ass_outputs, .priv_class = &subtitles_class, - .shorthand = shorthand, }; #endif