Commit e6f0cec8 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_acrossover: add precision option

parent 8b64d8d9
......@@ -557,6 +557,22 @@ Set input gain level. Allowed range is from 0 to 1. Default value is 1.
@item gains
Set output gain for each band. Default value is 1 for all bands.
@item precision
Set which precision to use when processing samples.
@table @option
@item auto
Auto pick internal sample format depending on other filters.
@item float
Always use single-floating point precision sample format.
@item double
Always use double-floating point precision sample format.
@end table
Default value is @code{auto}.
@end table
@subsection Examples
......
......@@ -58,6 +58,7 @@ typedef struct AudioCrossoverContext {
char *gains_str;
int order_opt;
float level_in;
int precision;
int order;
int filter_count;
......@@ -99,11 +100,52 @@ static const AVOption acrossover_options[] = {
{ "20th", "20th order (120 dB/8ve)",0, AV_OPT_TYPE_CONST, {.i64=9}, 0, 0, AF, "m" },
{ "level", "set input gain", OFFSET(level_in), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, AF },
{ "gain", "set output bands gain", OFFSET(gains_str), AV_OPT_TYPE_STRING, {.str="1.f"}, 0, 0, AF },
{ "precision", "set processing precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, AF, "precision" },
{ "auto", "set auto processing precision", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision" },
{ "float", "set single-floating point processing precision", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision" },
{ "double","set double-floating point processing precision", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision" },
{ NULL }
};
AVFILTER_DEFINE_CLASS(acrossover);
static int query_formats(AVFilterContext *ctx)
{
AudioCrossoverContext *s = ctx->priv;
static const enum AVSampleFormat auto_sample_fmts[] = {
AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_DBLP,
AV_SAMPLE_FMT_NONE
};
enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE
};
const enum AVSampleFormat *sample_fmts_list = sample_fmts;
int ret = ff_set_common_all_channel_counts(ctx);
if (ret < 0)
return ret;
switch (s->precision) {
case 0:
sample_fmts_list = auto_sample_fmts;
break;
case 1:
sample_fmts[0] = AV_SAMPLE_FMT_FLTP;
break;
case 2:
sample_fmts[0] = AV_SAMPLE_FMT_DBLP;
break;
default:
break;
}
ret = ff_set_common_formats_from_list(ctx, sample_fmts_list);
if (ret < 0)
return ret;
return ff_set_common_all_samplerates(ctx);
}
static int parse_gains(AVFilterContext *ctx)
{
AudioCrossoverContext *s = ctx->priv;
......@@ -586,7 +628,7 @@ const AVFilter ff_af_acrossover = {
.uninit = uninit,
FILTER_INPUTS(inputs),
.outputs = NULL,
FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP),
FILTER_QUERY_FUNC(query_formats),
.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
AVFILTER_FLAG_SLICE_THREADS,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment