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
689@table @option689@table @option
690 690
691@item sample_fmts691@item sample_fmts
692A comma-separated list of requested sample formats.692A '|'-separated list of requested sample formats.
693 693
694@item sample_rates694@item sample_rates
695A comma-separated list of requested sample rates.695A '|'-separated list of requested sample rates.
696 696
697@item channel_layouts697@item channel_layouts
698A comma-separated list of requested channel layouts.698A '|'-separated list of requested channel layouts.
699 699
700@end table700@end table
701 701
@@ -703,7 +703,7 @@ If a parameter is omitted, all values are allowed. · 1 unmodified line
703 703
704For example to force the output to either unsigned 8-bit or signed 16-bit stereo:704For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
705@example705@example
706aformat='sample_fmts=u8,s16:channel_layouts=stereo'706aformat=sample_fmts=u8|s16:channel_layouts=stereo
707@end example707@end example
708 708
709@section amerge709@section amerge
@@ -3173,8 +3173,14 @@ Convert the input video to one of the specified pixel formats. · 2463 unmodified lines
3173Libavfilter will try to pick one that is supported for the input to3173Libavfilter will try to pick one that is supported for the input to
3174the next filter.3174the next filter.
3175 3175
3176The filter accepts a list of pixel format names, separated by ":",3176This filter accepts the following parameters:
3177for example "yuv420p:monow:rgb24".3177@table @option
3178
3179@item pix_fmts
3180A '|'-separated list of pixel format names, for example
3181"pix_fmts=yuv420p|monow|rgb24".
3182
3183@end table
3178 3184
3179@subsection Examples3185@subsection Examples
3180 3186
@@ -3182,12 +3188,12 @@ for example "yuv420p:monow:rgb24". · 1 unmodified line
3182@item3188@item
3183Convert the input video to the format @var{yuv420p}3189Convert the input video to the format @var{yuv420p}
3184@example3190@example
3185format=yuv420p3191format=pix_fmts=yuv420p
3186@end example3192@end example
3187 3193
3188Convert the input video to any of the formats in the list3194Convert the input video to any of the formats in the list
3189@example3195@example
3190format=yuv420p:yuv444p:yuv410p3196format=pix_fmts=yuv420p|yuv444p|yuv410p
3191@end example3197@end example
3192@end itemize3198@end itemize
3193 3199
@@ -4072,8 +4078,14 @@ alpha component (if available). The default value in input is 0. · 878 unmodified lines
4072Force libavfilter not to use any of the specified pixel formats for the4078Force libavfilter not to use any of the specified pixel formats for the
4073input to the next filter.4079input to the next filter.
4074 4080
4075The filter accepts a list of pixel format names, separated by ":",4081This filter accepts the following parameters:
4076for example "yuv420p:monow:rgb24".4082@table @option
4083
4084@item pix_fmts
4085A '|'-separated list of pixel format names, for example
4086"pix_fmts=yuv420p|monow|rgb24".
4087
4088@end table
4077 4089
4078@subsection Examples4090@subsection Examples
4079 4091
@@ -4082,13 +4094,13 @@ for example "yuv420p:monow:rgb24". · 2 unmodified lines
4082Force libavfilter to use a format different from @var{yuv420p} for the4094Force libavfilter to use a format different from @var{yuv420p} for the
4083input to the vflip filter:4095input to the vflip filter:
4084@example4096@example
4085noformat=yuv420p,vflip4097noformat=pix_fmts=yuv420p,vflip
4086@end example4098@end example
4087 4099
4088@item4100@item
4089Convert the input video to any of the formats not contained in the list:4101Convert the input video to any of the formats not contained in the list:
4090@example4102@example
4091noformat=yuv420p:yuv444p:yuv410p4103noformat=yuv420p|yuv444p|yuv410p
4092@end example4104@end example
4093@end itemize4105@end itemize
4094 4106
libavfilter/af_aformat.c+13−19
@@ -59,17 +59,24 @@ AVFILTER_DEFINE_CLASS(aformat); · 58 unmodified lines
59 59
60#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \60#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \
61do { \61do { \
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 \
63 while (cur) { \71 while (cur) { \
64 type fmt; \72 type fmt; \
65 next = strchr(cur, ','); \73 next = strchr(cur, sep); \
66 if (next) \74 if (next) \
67 *next++ = 0; \75 *next++ = 0; \
68 \76 \
69 if ((fmt = get_fmt(cur)) == none) { \77 if ((fmt = get_fmt(cur)) == none) { \
70 av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\78 av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
71 ret = AVERROR(EINVAL); \79 return AVERROR(EINVAL); \
72 goto fail; \
73 } \80 } \
74 add_to_list(&list, fmt); \81 add_to_list(&list, fmt); \
75 \82 \
@@ -86,18 +93,6 @@ static int get_sample_rate(const char *samplerate) · 10 unmodified lines
86static av_cold int init(AVFilterContext *ctx, const char *args)93static av_cold int init(AVFilterContext *ctx, const char *args)
87{94{
88 AFormatContext *s = ctx->priv;95 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;
101 96
102 PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,97 PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
103 ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");98 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
107 ff_add_channel_layout, av_get_channel_layout, 0,102 ff_add_channel_layout, av_get_channel_layout, 0,
108 "channel layout");103 "channel layout");
109 104
110fail:105 return 0;
111 av_opt_free(s);
112 return ret;
113}106}
114 107
115static int query_formats(AVFilterContext *ctx)108static int query_formats(AVFilterContext *ctx)
@@ -148,6 +141,7 @@ AVFilter avfilter_af_aformat = { · 32 unmodified lines
148 .init = init,141 .init = init,
149 .query_formats = query_formats,142 .query_formats = query_formats,
150 .priv_size = sizeof(AFormatContext),143 .priv_size = sizeof(AFormatContext),
144 .priv_class = &aformat_class,
151 145
152 .inputs = avfilter_af_aformat_inputs,146 .inputs = avfilter_af_aformat_inputs,
153 .outputs = avfilter_af_aformat_outputs,147 .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
654 AVDictionaryEntry *e;654 AVDictionaryEntry *e;
655 int ret=0;655 int ret=0;
656 int anton_options =656 int anton_options =
657 !strcmp(filter->filter->name, "aformat") ||
658 !strcmp(filter->filter->name, "format") ||
659 !strcmp(filter->filter->name, "noformat") ||
657 !strcmp(filter->filter->name, "resample")660 !strcmp(filter->filter->name, "resample")
658 ;661 ;
659 662
@@ -675,6 +678,33 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 15 unmodified lines
675 ret = av_dict_parse_string(&options, args, "=", ":", 0);678 ret = av_dict_parse_string(&options, args, "=", ":", 0);
676 if (ret < 0)679 if (ret < 0)
677 goto fail;680 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
678 } else {708 } else {
679 ret = process_unnamed_options(filter, &options, args);709 ret = process_unnamed_options(filter, &options, args);
680 if (ret < 0)710 if (ret < 0)
libavfilter/vf_format.c+28−2
@@ -28,6 +28,8 @@ · 27 unmodified lines
28#include "libavutil/internal.h"28#include "libavutil/internal.h"
29#include "libavutil/mem.h"29#include "libavutil/mem.h"
30#include "libavutil/pixdesc.h"30#include "libavutil/pixdesc.h"
31#include "libavutil/opt.h"
32
31#include "avfilter.h"33#include "avfilter.h"
32#include "internal.h"34#include "internal.h"
33#include "formats.h"35#include "formats.h"
@@ -35,6 +37,8 @@ · 1 unmodified line
35#include "video.h"37#include "video.h"
36 38
37typedef struct {39typedef struct {
40 const AVClass *class;
41 char *pix_fmts;
38 /**42 /**
39 * List of flags telling if a given image format has been listed43 * List of flags telling if a given image format has been listed
40 * as argument to the filter.44 * as argument to the filter.
@@ -53,8 +57,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args) · 12 unmodified lines
53 enum AVPixelFormat pix_fmt;57 enum AVPixelFormat pix_fmt;
54 58
55 /* parse the list of formats */59 /* parse the list of formats */
56 for (cur = args; cur; cur = sep ? sep+1 : NULL) {60 for (cur = format->pix_fmts; cur; cur = sep ? sep + 1 : NULL) {
57 if (!(sep = strchr(cur, ':')))61 if (!(sep = strchr(cur, '|')))
58 pix_fmt_name_len = strlen(cur);62 pix_fmt_name_len = strlen(cur);
59 else63 else
60 pix_fmt_name_len = sep - cur;64 pix_fmt_name_len = sep - cur;
@@ -90,6 +94,12 @@ static AVFilterFormats *make_format_list(FormatContext *format, int flag) · 29 unmodified lines
90 return formats;94 return formats;
91}95}
92 96
97#define OFFSET(x) offsetof(FormatContext, x)
98static 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
93#if CONFIG_FORMAT_FILTER103#if CONFIG_FORMAT_FILTER
94static int query_formats_format(AVFilterContext *ctx)104static int query_formats_format(AVFilterContext *ctx)
95{105{
@@ -97,6 +107,13 @@ static int query_formats_format(AVFilterContext *ctx) · 1 unmodified line
97 return 0;107 return 0;
98}108}
99 109
110static 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
100static const AVFilterPad avfilter_vf_format_inputs[] = {117static const AVFilterPad avfilter_vf_format_inputs[] = {
101 {118 {
102 .name = "default",119 .name = "default",
@@ -123,6 +140,7 @@ AVFilter avfilter_vf_format = { · 20 unmodified lines
123 .query_formats = query_formats_format,140 .query_formats = query_formats_format,
124 141
125 .priv_size = sizeof(FormatContext),142 .priv_size = sizeof(FormatContext),
143 .priv_class = &format_class,
126 144
127 .inputs = avfilter_vf_format_inputs,145 .inputs = avfilter_vf_format_inputs,
128 .outputs = avfilter_vf_format_outputs,146 .outputs = avfilter_vf_format_outputs,
@@ -136,6 +154,13 @@ static int query_formats_noformat(AVFilterContext *ctx) · 7 unmodified lines
136 return 0;154 return 0;
137}155}
138 156
157static 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
139static const AVFilterPad avfilter_vf_noformat_inputs[] = {164static const AVFilterPad avfilter_vf_noformat_inputs[] = {
140 {165 {
141 .name = "default",166 .name = "default",
@@ -162,6 +187,7 @@ AVFilter avfilter_vf_noformat = { · 20 unmodified lines
162 .query_formats = query_formats_noformat,187 .query_formats = query_formats_noformat,
163 188
164 .priv_size = sizeof(FormatContext),189 .priv_size = sizeof(FormatContext),
190 .priv_class = &noformat_class,
165 191
166 .inputs = avfilter_vf_noformat_inputs,192 .inputs = avfilter_vf_noformat_inputs,
167 .outputs = avfilter_vf_noformat_outputs,193 .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