[FFmpeg-cvslog] avfilter/af_biquads: add shortcut to set internal precision
Paul B Mahol
git at videolan.org
Sun Dec 6 15:53:34 EET 2020
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Dec 6 14:39:47 2020 +0100| [88b6ebdaceb4f01fafe5886775794bcffea5daca] | committer: Paul B Mahol
avfilter/af_biquads: add shortcut to set internal precision
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88b6ebdaceb4f01fafe5886775794bcffea5daca
---
doc/filters.texi | 135 +++++++++++++++++++++++++++++++++++++++++++++++
libavfilter/af_biquads.c | 107 ++++++++++++++++++++++++++++++++++++-
2 files changed, 240 insertions(+), 2 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 99fcae2650..3a31f72d79 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1719,6 +1719,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
@@ -2918,6 +2933,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
@@ -2990,6 +3020,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
@@ -3069,6 +3114,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
@@ -3136,6 +3196,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@section bs2b
@@ -3868,6 +3943,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Examples
@@ -4354,6 +4444,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
@@ -4689,6 +4794,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Examples
@@ -5895,6 +6015,21 @@ Set transform type of IIR filter.
@item tdii
@item latt
@end table
+
+ at item precision, r
+Set precison of filtering.
+ at table @option
+ at item auto
+Pick automatic sample format depending on surround filters.
+ at item s16
+Always use signed 16-bit.
+ at item s32
+Always use signed 32-bit.
+ at item f32
+Always use float 32-bit.
+ at item f64
+Always use float 64-bit.
+ at end table
@end table
@subsection Commands
diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index 3ec26d2a9d..edefe15d05 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -115,6 +115,7 @@ typedef struct BiquadsContext {
int poles;
int csg;
int transform_type;
+ int precision;
int bypass;
@@ -143,15 +144,20 @@ typedef struct BiquadsContext {
static int query_formats(AVFilterContext *ctx)
{
+ BiquadsContext *s = ctx->priv;
AVFilterFormats *formats;
AVFilterChannelLayouts *layouts;
- static const enum AVSampleFormat sample_fmts[] = {
+ static const enum AVSampleFormat auto_sample_fmts[] = {
AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_S32P,
AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_DBLP,
AV_SAMPLE_FMT_NONE
};
+ enum AVSampleFormat sample_fmts[] = {
+ AV_SAMPLE_FMT_S16P,
+ AV_SAMPLE_FMT_NONE
+ };
int ret;
layouts = ff_all_channel_counts();
@@ -161,7 +167,27 @@ static int query_formats(AVFilterContext *ctx)
if (ret < 0)
return ret;
- formats = ff_make_format_list(sample_fmts);
+ switch (s->precision) {
+ case 0:
+ sample_fmts[0] = AV_SAMPLE_FMT_S16P;
+ formats = ff_make_format_list(sample_fmts);
+ break;
+ case 1:
+ sample_fmts[0] = AV_SAMPLE_FMT_S32P;
+ formats = ff_make_format_list(sample_fmts);
+ break;
+ case 2:
+ sample_fmts[0] = AV_SAMPLE_FMT_FLTP;
+ formats = ff_make_format_list(sample_fmts);
+ break;
+ case 3:
+ sample_fmts[0] = AV_SAMPLE_FMT_DBLP;
+ formats = ff_make_format_list(sample_fmts);
+ break;
+ default:
+ formats = ff_make_format_list(auto_sample_fmts);
+ break;
+ }
if (!formats)
return AVERROR(ENOMEM);
ret = ff_set_common_formats(ctx, formats);
@@ -861,6 +887,13 @@ static const AVOption equalizer_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -893,6 +926,13 @@ static const AVOption bass_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -925,6 +965,13 @@ static const AVOption treble_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -956,6 +1003,13 @@ static const AVOption bandpass_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -986,6 +1040,13 @@ static const AVOption bandreject_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1018,6 +1079,13 @@ static const AVOption lowpass_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1050,6 +1118,13 @@ static const AVOption highpass_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1082,6 +1157,13 @@ static const AVOption allpass_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1114,6 +1196,13 @@ static const AVOption lowshelf_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1146,6 +1235,13 @@ static const AVOption highshelf_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
@@ -1171,6 +1267,13 @@ static const AVOption biquad_options[] = {
{"dii", "direct form II", 0, AV_OPT_TYPE_CONST, {.i64=DII}, 0, 0, AF, "transform_type"},
{"tdii", "transposed direct form II", 0, AV_OPT_TYPE_CONST, {.i64=TDII}, 0, 0, AF, "transform_type"},
{"latt", "lattice-ladder form", 0, AV_OPT_TYPE_CONST, {.i64=LATT}, 0, 0, AF, "transform_type"},
+ {"precision", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"r", "set filtering precision", OFFSET(precision), AV_OPT_TYPE_INT, {.i64=-1}, -1, 3, AF, "precision"},
+ {"auto", "automatic", 0, AV_OPT_TYPE_CONST, {.i64=-1}, 0, 0, AF, "precision"},
+ {"s16", "signed 16-bit", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, AF, "precision"},
+ {"s32", "signed 32-bit", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, AF, "precision"},
+ {"f32", "floating-point single", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, AF, "precision"},
+ {"f64", "floating-point double", 0, AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, AF, "precision"},
{NULL}
};
More information about the ffmpeg-cvslog
mailing list