diff mbox series

[FFmpeg-devel,07/39] avfilter/af_biquads: Deduplicate AVClasses

Message ID AM7PR03MB66603D5A986C3B727037B9F48FD79@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 4ab80ac17e4673dd4eb172c9aacea3a37b1e99cf
Headers show
Series [FFmpeg-devel,01/39] avfilter/vf_maskedminmax: Simplify init | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 11, 2021, 11:40 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/af_biquads.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/af_biquads.c b/libavfilter/af_biquads.c
index c110734458..828af05b20 100644
--- a/libavfilter/af_biquads.c
+++ b/libavfilter/af_biquads.c
@@ -853,8 +853,7 @@  static const AVFilterPad outputs[] = {
 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
-#define DEFINE_BIQUAD_FILTER(name_, description_)                       \
-AVFILTER_DEFINE_CLASS(name_);                                           \
+#define DEFINE_BIQUAD_FILTER_2(name_, description_, priv_class_)        \
 static av_cold int name_##_init(AVFilterContext *ctx)                   \
 {                                                                       \
     BiquadsContext *s = ctx->priv;                                      \
@@ -865,17 +864,21 @@  static av_cold int name_##_init(AVFilterContext *ctx)                   \
 const AVFilter ff_af_##name_ = {                               \
     .name          = #name_,                             \
     .description   = NULL_IF_CONFIG_SMALL(description_), \
+    .priv_class    = &priv_class_##_class,               \
     .priv_size     = sizeof(BiquadsContext),             \
     .init          = name_##_init,                       \
     .uninit        = uninit,                             \
     .query_formats = query_formats,                      \
     FILTER_INPUTS(inputs),                               \
     FILTER_OUTPUTS(outputs),                             \
-    .priv_class    = &name_##_class,                     \
     .process_command = process_command,                  \
     .flags         = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, \
 }
 
+#define DEFINE_BIQUAD_FILTER(name, description)                         \
+    AVFILTER_DEFINE_CLASS(name);                                        \
+    DEFINE_BIQUAD_FILTER_2(name, description, name)
+
 #if CONFIG_EQUALIZER_FILTER
 static const AVOption equalizer_options[] = {
     {"frequency", "set central frequency", OFFSET(frequency), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 999999, FLAGS},
@@ -954,14 +957,13 @@  static const AVOption bass_lowshelf_options[] = {
     {NULL}
 };
 
+AVFILTER_DEFINE_CLASS_EXT(bass_lowshelf, "bass/lowshelf", bass_lowshelf_options);
 #if CONFIG_BASS_FILTER
-#define bass_options bass_lowshelf_options
-DEFINE_BIQUAD_FILTER(bass, "Boost or cut lower frequencies.");
+DEFINE_BIQUAD_FILTER_2(bass, "Boost or cut lower frequencies.", bass_lowshelf);
 #endif  /* CONFIG_BASS_FILTER */
 
 #if CONFIG_LOWSHELF_FILTER
-#define lowshelf_options bass_lowshelf_options
-DEFINE_BIQUAD_FILTER(lowshelf, "Apply a low shelf filter.");
+DEFINE_BIQUAD_FILTER_2(lowshelf, "Apply a low shelf filter.", bass_lowshelf);
 #endif  /* CONFIG_LOWSHELF_FILTER */
 #endif  /* CONFIG_BASS_FILTER || CONFIG LOWSHELF_FILTER */
 #if CONFIG_TREBLE_FILTER || CONFIG_HIGHSHELF_FILTER
@@ -1003,14 +1005,15 @@  static const AVOption treble_highshelf_options[] = {
     {NULL}
 };
 
+AVFILTER_DEFINE_CLASS_EXT(treble_highshelf, "treble/highshelf",
+                          treble_highshelf_options);
+
 #if CONFIG_TREBLE_FILTER
-#define treble_options treble_highshelf_options
-DEFINE_BIQUAD_FILTER(treble, "Boost or cut upper frequencies.");
+DEFINE_BIQUAD_FILTER_2(treble, "Boost or cut upper frequencies.", treble_highshelf);
 #endif  /* CONFIG_TREBLE_FILTER */
 
 #if CONFIG_HIGHSHELF_FILTER
-#define highshelf_options treble_highshelf_options
-DEFINE_BIQUAD_FILTER(highshelf, "Apply a high shelf filter.");
+DEFINE_BIQUAD_FILTER_2(highshelf, "Apply a high shelf filter.", treble_highshelf);
 #endif  /* CONFIG_HIGHSHELF_FILTER */
 #endif  /* CONFIG_TREBLE_FILTER || CONFIG_HIGHSHELF_FILTER */
 #if CONFIG_BANDPASS_FILTER