af_aformat: switch to an AVOptions-based system.
This commit is contained in:
@@ -133,13 +133,13 @@ The filter accepts the following named parameters:
|
|||||||
@table @option
|
@table @option
|
||||||
|
|
||||||
@item sample_fmts
|
@item sample_fmts
|
||||||
A comma-separated list of requested sample formats.
|
A '|'-separated list of requested sample formats.
|
||||||
|
|
||||||
@item sample_rates
|
@item sample_rates
|
||||||
A comma-separated list of requested sample rates.
|
A '|'-separated list of requested sample rates.
|
||||||
|
|
||||||
@item channel_layouts
|
@item channel_layouts
|
||||||
A comma-separated list of requested channel layouts.
|
A '|'-separated list of requested channel layouts.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ If a parameter is omitted, all values are allowed.
|
|||||||
|
|
||||||
For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
|
For example to force the output to either unsigned 8-bit or signed 16-bit stereo:
|
||||||
@example
|
@example
|
||||||
aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
|
aformat=sample_fmts=u8|s16:channel_layouts=stereo
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@section amix
|
@section amix
|
||||||
|
|||||||
@@ -63,17 +63,24 @@ static const AVClass aformat_class = {
|
|||||||
|
|
||||||
#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \
|
#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \
|
||||||
do { \
|
do { \
|
||||||
char *next, *cur = str; \
|
char *next, *cur = str, sep; \
|
||||||
|
\
|
||||||
|
if (str && strchr(str, ',')) { \
|
||||||
|
av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "\
|
||||||
|
"separate %s.\n", desc); \
|
||||||
|
sep = ','; \
|
||||||
|
} else \
|
||||||
|
sep = '|'; \
|
||||||
|
\
|
||||||
while (cur) { \
|
while (cur) { \
|
||||||
type fmt; \
|
type fmt; \
|
||||||
next = strchr(cur, ','); \
|
next = strchr(cur, sep); \
|
||||||
if (next) \
|
if (next) \
|
||||||
*next++ = 0; \
|
*next++ = 0; \
|
||||||
\
|
\
|
||||||
if ((fmt = get_fmt(cur)) == none) { \
|
if ((fmt = get_fmt(cur)) == none) { \
|
||||||
av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
|
av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
|
||||||
ret = AVERROR(EINVAL); \
|
return AVERROR(EINVAL); \
|
||||||
goto fail; \
|
|
||||||
} \
|
} \
|
||||||
add_to_list(&list, fmt); \
|
add_to_list(&list, fmt); \
|
||||||
\
|
\
|
||||||
@@ -90,20 +97,6 @@ static int get_sample_rate(const char *samplerate)
|
|||||||
static av_cold int init(AVFilterContext *ctx, const char *args)
|
static av_cold int init(AVFilterContext *ctx, const char *args)
|
||||||
{
|
{
|
||||||
AFormatContext *s = ctx->priv;
|
AFormatContext *s = ctx->priv;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!args) {
|
|
||||||
av_log(ctx, AV_LOG_ERROR, "No parameters supplied.\n");
|
|
||||||
return AVERROR(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
|
PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
|
||||||
ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
|
ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
|
||||||
@@ -113,9 +106,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
|
|||||||
ff_add_channel_layout, av_get_channel_layout, 0,
|
ff_add_channel_layout, av_get_channel_layout, 0,
|
||||||
"channel layout");
|
"channel layout");
|
||||||
|
|
||||||
fail:
|
return 0;
|
||||||
av_opt_free(s);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_formats(AVFilterContext *ctx)
|
static int query_formats(AVFilterContext *ctx)
|
||||||
@@ -154,6 +145,7 @@ AVFilter avfilter_af_aformat = {
|
|||||||
.init = init,
|
.init = init,
|
||||||
.query_formats = query_formats,
|
.query_formats = query_formats,
|
||||||
.priv_size = sizeof(AFormatContext),
|
.priv_size = sizeof(AFormatContext),
|
||||||
|
.priv_class = &aformat_class,
|
||||||
|
|
||||||
.inputs = avfilter_af_aformat_inputs,
|
.inputs = avfilter_af_aformat_inputs,
|
||||||
.outputs = avfilter_af_aformat_outputs,
|
.outputs = avfilter_af_aformat_outputs,
|
||||||
|
|||||||
Reference in New Issue
Block a user