X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Faf_aformat.c;h=9bc6f5bc58ee4d030700b5b2cc54be964af6f24c;hb=67a6dac7c18caecb418f7590a484dcbfcad869ab;hp=cdd5d12d9c640a9a216f1877420ba19899c17e11;hpb=75f8f702217fdeae9e2868c7ba80c03f9ec0958a;p=ffmpeg diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index cdd5d12d9c6..9bc6f5bc58e 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -25,6 +25,7 @@ #include "libavutil/audioconvert.h" #include "libavutil/avstring.h" +#include "libavutil/common.h" #include "libavutil/opt.h" #include "audio.h" @@ -46,20 +47,15 @@ typedef struct AFormatContext { #define OFFSET(x) offsetof(AFormatContext, x) #define A AV_OPT_FLAG_AUDIO_PARAM -static const AVOption options[] = { - { "sample_fmts", "A comma-separated list of sample formats.", OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A }, - { "sample_rates", "A comma-separated list of sample rates.", OFFSET(sample_rates_str), AV_OPT_TYPE_STRING, .flags = A }, - { "channel_layouts", "A comma-separated list of channel layouts.", OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A }, +#define F AV_OPT_FLAG_FILTERING_PARAM +static const AVOption aformat_options[] = { + { "sample_fmts", "A comma-separated list of sample formats.", OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A|F }, + { "sample_rates", "A comma-separated list of sample rates.", OFFSET(sample_rates_str), AV_OPT_TYPE_STRING, .flags = A|F }, + { "channel_layouts", "A comma-separated list of channel layouts.", OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A|F }, { NULL }, }; -static const AVClass aformat_class = { - .class_name = "aformat filter", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, - .category = AV_CLASS_CATEGORY_FILTER, -}; +AVFILTER_DEFINE_CLASS(aformat); #define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \ do { \ @@ -87,7 +83,7 @@ static int get_sample_rate(const char *samplerate) return FFMAX(ret, 0); } -static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int init(AVFilterContext *ctx, const char *args) { AFormatContext *s = ctx->priv; int ret; @@ -100,10 +96,8 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) s->class = &aformat_class; av_opt_set_defaults(s); - if ((ret = av_set_options_string(s, args, "=", ":")) < 0) { - av_log(ctx, AV_LOG_ERROR, "Error parsing options string '%s'.\n", args); + if ((ret = av_set_options_string(s, args, "=", ":")) < 0) return ret; - } PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); @@ -139,11 +133,11 @@ AVFilter avfilter_af_aformat = { .query_formats = query_formats, .priv_size = sizeof(AFormatContext), - .inputs = (AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_AUDIO, - .filter_samples = ff_null_filter_samples }, - { .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_AUDIO}, - { .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_AUDIO, }, + { .name = NULL}}, + .outputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_AUDIO}, + { .name = NULL}}, + .priv_class = &aformat_class, };