History

Merge commit 'e67a87eac814c7805d18c983c43033a8a1bd62af'

* commit 'e67a87eac814c7805d18c983c43033a8a1bd62af': vf_(no)format: switch to an AVOptions-based system. af_aformat: switch to an AVOptions-based system. Conflicts: doc/filters.texi libavfilter/af_aformat.c

Michael Niedermayer committed 13 years ago

Commit 2a2a6432 parents 4513158 e67a87e4 files · +95 −33Browse files

Unified · Split

4 files
  1. doc/filters.texi +24 −12
  2. libavfilter/af_aformat.c +13 −19
  3. libavfilter/avfilter.c +30 −0
  4. libavfilter/vf_format.c +28 −2
doc/filters.texi+24−12
@@ -689,13 +689,13 @@ The filter accepts the following named parameters: · 688 unmodified lines
689689 @table @option
690690
691691 @item sample_fmts
692−A comma-separated list of requested sample formats.
692+A '|'-separated list of requested sample formats.
693693
694694 @item sample_rates
695−A comma-separated list of requested sample rates.
695+A '|'-separated list of requested sample rates.
696696
697697 @item channel_layouts
698−A comma-separated list of requested channel layouts.
698+A '|'-separated list of requested channel layouts.
699699
700700 @end table
701701
@@ -703,7 +703,7 @@ If a parameter is omitted, all values are allowed. · 1 unmodified line
703703
704704 For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
705705 @example
706−aformat='sample_fmts=u8,s16:channel_layouts=stereo'
706+aformat=sample_fmts=u8|s16:channel_layouts=stereo
707707 @end example
708708
709709 @section amerge
@@ -3173,8 +3173,14 @@ Convert the input video to one of the specified pixel formats. · 2463 unmodified lines
31733173 Libavfilter will try to pick one that is supported for the input to
31743174 the next filter.
31753175
3176−The filter accepts a list of pixel format names, separated by ":",
3177−for example "yuv420p:monow:rgb24".
3176+This filter accepts the following parameters:
3177+@table @option
3178+
3179+@item pix_fmts
3180+A '|'-separated list of pixel format names, for example
3181+"pix_fmts=yuv420p|monow|rgb24".
3182+
3183+@end table
31783184
31793185 @subsection Examples
31803186
@@ -3182,12 +3188,12 @@ for example "yuv420p:monow:rgb24". · 1 unmodified line
31823188 @item
31833189 Convert the input video to the format @var{yuv420p}
31843190 @example
3185−format=yuv420p
3191+format=pix_fmts=yuv420p
31863192 @end example
31873193
31883194 Convert the input video to any of the formats in the list
31893195 @example
3190−format=yuv420p:yuv444p:yuv410p
3196+format=pix_fmts=yuv420p|yuv444p|yuv410p
31913197 @end example
31923198 @end itemize
31933199
@@ -4072,8 +4078,14 @@ alpha component (if available). The default value in input is 0. · 878 unmodified lines
40724078 Force libavfilter not to use any of the specified pixel formats for the
40734079 input to the next filter.
40744080
4075−The filter accepts a list of pixel format names, separated by ":",
4076−for example "yuv420p:monow:rgb24".
4081+This filter accepts the following parameters:
4082+@table @option
4083+
4084+@item pix_fmts
4085+A '|'-separated list of pixel format names, for example
4086+"pix_fmts=yuv420p|monow|rgb24".
4087+
4088+@end table
40774089
40784090 @subsection Examples
40794091
@@ -4082,13 +4094,13 @@ for example "yuv420p:monow:rgb24". · 2 unmodified lines
40824094 Force libavfilter to use a format different from @var{yuv420p} for the
40834095 input to the vflip filter:
40844096 @example
4085−noformat=yuv420p,vflip
4097+noformat=pix_fmts=yuv420p,vflip
40864098 @end example
40874099
40884100 @item
40894101 Convert the input video to any of the formats not contained in the list:
40904102 @example
4091−noformat=yuv420p:yuv444p:yuv410p
4103+noformat=yuv420p|yuv444p|yuv410p
40924104 @end example
40934105 @end itemize
40944106
libavfilter/af_aformat.c+13−19
@@ -59,17 +59,24 @@ AVFILTER_DEFINE_CLASS(aformat); · 58 unmodified lines
5959
6060 #define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \
6161 do { \
62− char *next, *cur = str; \
62+ char *next, *cur = str, sep; \
63+ \
64+ if (str && strchr(str, ',')) { \
65+ av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "\
66+ "separate %s.\n", desc); \
67+ sep = ','; \
68+ } else \
69+ sep = '|'; \
70+ \
6371 while (cur) { \
6472 type fmt; \
65− next = strchr(cur, ','); \
73+ next = strchr(cur, sep); \
6674 if (next) \
6775 *next++ = 0; \
6876 \
6977 if ((fmt = get_fmt(cur)) == none) { \
7078 av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
71− ret = AVERROR(EINVAL); \
72− goto fail; \
79+ return AVERROR(EINVAL); \
7380 } \
7481 add_to_list(&list, fmt); \
7582 \
@@ -86,18 +93,6 @@ static int get_sample_rate(const char *samplerate) · 10 unmodified lines
8693 static av_cold int init(AVFilterContext *ctx, const char *args)
8794 {
8895 AFormatContext *s = ctx->priv;
89− int ret;
90−
91− if (!args) {
92− av_log(ctx, AV_LOG_ERROR, "No parameters supplied.\n");
93− return AVERROR(EINVAL);
94− }
95−
96− s->class = &aformat_class;
97− av_opt_set_defaults(s);
98−
99− if ((ret = av_set_options_string(s, args, "=", ":")) < 0)
100− return ret;
10196
10297 PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
10398 ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
@@ -107,9 +102,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 3 unmodified lines
107102 ff_add_channel_layout, av_get_channel_layout, 0,
108103 "channel layout");
109104
110−fail:
111− av_opt_free(s);
112− return ret;
105+ return 0;
113106 }
114107
115108 static int query_formats(AVFilterContext *ctx)
@@ -148,6 +141,7 @@ AVFilter avfilter_af_aformat = { · 32 unmodified lines
148141 .init = init,
149142 .query_formats = query_formats,
150143 .priv_size = sizeof(AFormatContext),
144+ .priv_class = &aformat_class,
151145
152146 .inputs = avfilter_af_aformat_inputs,
153147 .outputs = avfilter_af_aformat_outputs,
libavfilter/avfilter.c+30−0
@@ -654,6 +654,9 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 653 unmodified lines
654654 AVDictionaryEntry *e;
655655 int ret=0;
656656 int anton_options =
657+ !strcmp(filter->filter->name, "aformat") ||
658+ !strcmp(filter->filter->name, "format") ||
659+ !strcmp(filter->filter->name, "noformat") ||
657660 !strcmp(filter->filter->name, "resample")
658661 ;
659662
@@ -675,6 +678,33 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 15 unmodified lines
675678 ret = av_dict_parse_string(&options, args, "=", ":", 0);
676679 if (ret < 0)
677680 goto fail;
681+#if FF_API_OLD_FILTER_OPTS
682+ } else if (!strcmp(filter->filter->name, "format") ||
683+ !strcmp(filter->filter->name, "noformat")) {
684+ /* a hack for compatibility with the old syntax
685+ * replace colons with |s */
686+ char *copy = av_strdup(args);
687+ char *p = copy;
688+
689+ if (!copy) {
690+ ret = AVERROR(ENOMEM);
691+ goto fail;
692+ }
693+
694+ if (strchr(copy, ':')) {
695+ av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "
696+ "'|' to separate the list items.\n");
697+ }
698+
699+ while ((p = strchr(p, ':')))
700+ *p++ = '|';
701+
702+ ret = process_unnamed_options(filter, &options, copy);
703+ av_freep(&copy);
704+
705+ if (ret < 0)
706+ goto fail;
707+#endif
678708 } else {
679709 ret = process_unnamed_options(filter, &options, args);
680710 if (ret < 0)
libavfilter/vf_format.c+28−2
@@ -28,6 +28,8 @@ · 27 unmodified lines
2828 #include "libavutil/internal.h"
2929 #include "libavutil/mem.h"
3030 #include "libavutil/pixdesc.h"
31+#include "libavutil/opt.h"
32+
3133 #include "avfilter.h"
3234 #include "internal.h"
3335 #include "formats.h"
@@ -35,6 +37,8 @@ · 1 unmodified line
3537 #include "video.h"
3638
3739 typedef struct {
40+ const AVClass *class;
41+ char *pix_fmts;
3842 /**
3943 * List of flags telling if a given image format has been listed
4044 * as argument to the filter.
@@ -53,8 +57,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 12 unmodified lines
5357 enum AVPixelFormat pix_fmt;
5458
5559 /* parse the list of formats */
56− for (cur = args; cur; cur = sep ? sep+1 : NULL) {
57− if (!(sep = strchr(cur, ':')))
60+ for (cur = format->pix_fmts; cur; cur = sep ? sep + 1 : NULL) {
61+ if (!(sep = strchr(cur, '|')))
5862 pix_fmt_name_len = strlen(cur);
5963 else
6064 pix_fmt_name_len = sep - cur;
@@ -90,6 +94,12 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) · 29 unmodified lines
9094 return formats;
9195 }
9296
97+#define OFFSET(x) offsetof(FormatContext, x)
98+static const AVOption options[] = {
99+ { "pix_fmts", "A '|'-separated list of pixel formats", OFFSET(pix_fmts), AV_OPT_TYPE_STRING, .flags = AV_OPT_FLAG_VIDEO_PARAM },
100+ { NULL },
101+};
102+
93103 #if CONFIG_FORMAT_FILTER
94104 static int query_formats_format(AVFilterContext *ctx)
95105 {
@@ -97,6 +107,13 @@ static int query_formats_format(AVFilterContext *ctx) · 1 unmodified line
97107 return 0;
98108 }
99109
110+static const AVClass format_class = {
111+ .class_name = "format",
112+ .item_name = av_default_item_name,
113+ .option = options,
114+ .version = LIBAVUTIL_VERSION_INT,
115+};
116+
100117 static const AVFilterPad avfilter_vf_format_inputs[] = {
101118 {
102119 .name = "default",
@@ -123,6 +140,7 @@ AVFilter avfilter_vf_format = { · 20 unmodified lines
123140 .query_formats = query_formats_format,
124141
125142 .priv_size = sizeof(FormatContext),
143+ .priv_class = &format_class,
126144
127145 .inputs = avfilter_vf_format_inputs,
128146 .outputs = avfilter_vf_format_outputs,
@@ -136,6 +154,13 @@ static int query_formats_noformat(AVFilterContext *ctx) · 7 unmodified lines
136154 return 0;
137155 }
138156
157+static const AVClass noformat_class = {
158+ .class_name = "noformat",
159+ .item_name = av_default_item_name,
160+ .option = options,
161+ .version = LIBAVUTIL_VERSION_INT,
162+};
163+
139164 static const AVFilterPad avfilter_vf_noformat_inputs[] = {
140165 {
141166 .name = "default",
@@ -162,6 +187,7 @@ AVFilter avfilter_vf_noformat = { · 20 unmodified lines
162187 .query_formats = query_formats_noformat,
163188
164189 .priv_size = sizeof(FormatContext),
190+ .priv_class = &noformat_class,
165191
166192 .inputs = avfilter_vf_noformat_inputs,
167193 .outputs = avfilter_vf_noformat_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