* 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
Showing the changes to libavfilter/af_aformat.c (1 of 4 files). Show all
Unified · Split
| @@ -59,17 +59,24 @@ AVFILTER_DEFINE_CLASS(aformat); · 58 unmodified lines | ||
| 59 | 59 | |
| 60 | 60 | #define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \ |
| 61 | 61 | 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 | + \ | |
| 63 | 71 | while (cur) { \ |
| 64 | 72 | type fmt; \ |
| 65 | − next = strchr(cur, ','); \ | |
| 73 | + next = strchr(cur, sep); \ | |
| 66 | 74 | if (next) \ |
| 67 | 75 | *next++ = 0; \ |
| 68 | 76 | \ |
| 69 | 77 | if ((fmt = get_fmt(cur)) == none) { \ |
| 70 | 78 | av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\ |
| 71 | − ret = AVERROR(EINVAL); \ | |
| 72 | − goto fail; \ | |
| 79 | + return AVERROR(EINVAL); \ | |
| 73 | 80 | } \ |
| 74 | 81 | add_to_list(&list, fmt); \ |
| 75 | 82 | \ |
| @@ -86,18 +93,6 @@ static int get_sample_rate(const char *samplerate) · 10 unmodified lines | ||
| 86 | 93 | static av_cold int init(AVFilterContext *ctx, const char *args) |
| 87 | 94 | { |
| 88 | 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 | 97 | PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, |
| 103 | 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 | 102 | ff_add_channel_layout, av_get_channel_layout, 0, |
| 108 | 103 | "channel layout"); |
| 109 | 104 | |
| 110 | −fail: | |
| 111 | − av_opt_free(s); | |
| 112 | − return ret; | |
| 105 | + return 0; | |
| 113 | 106 | } |
| 114 | 107 | |
| 115 | 108 | static int query_formats(AVFilterContext *ctx) |
| @@ -148,6 +141,7 @@ AVFilter avfilter_af_aformat = { · 32 unmodified lines | ||
| 148 | 141 | .init = init, |
| 149 | 142 | .query_formats = query_formats, |
| 150 | 143 | .priv_size = sizeof(AFormatContext), |
| 144 | + .priv_class = &aformat_class, | |
| 151 | 145 | |
| 152 | 146 | .inputs = avfilter_af_aformat_inputs, |
| 153 | 147 | .outputs = avfilter_af_aformat_outputs, |