[FFmpeg-devel] [PATCH 2/4] avfilter/af_afir: split off fcmul_add into a DSP context

James Almer jamrial at gmail.com
Thu Jan 3 02:43:55 EET 2019


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavfilter/af_afir.c          | 15 ++++++++++-----
 libavfilter/af_afir.h          | 12 +++++++++---
 libavfilter/x86/af_afir_init.c |  2 +-
 3 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index c4baf63c02..c755dc1f6f 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -103,7 +103,7 @@ static int fir_quantum(AVFilterContext *ctx, AVFrame *out, int ch, int offset)
             const float *block = (const float *)seg->block->extended_data[ch] + i * seg->block_size;
             const FFTComplex *coeff = (const FFTComplex *)seg->coeff->extended_data[ch * !s->one2many] + coffset;
 
-            s->fcmul_add(sum, block, (const float *)coeff, seg->part_size);
+            s->afirdsp.fcmul_add(sum, block, (const float *)coeff, seg->part_size);
 
             if (j == 0)
                 j = seg->nb_partitions;
@@ -753,6 +753,14 @@ static int config_video(AVFilterLink *outlink)
     return 0;
 }
 
+void ff_afir_init(AudioFIRDSPContext *dsp)
+{
+    dsp->fcmul_add = fcmul_add_c;
+
+    if (ARCH_X86)
+        ff_afir_init_x86(dsp);
+}
+
 static av_cold int init(AVFilterContext *ctx)
 {
     AudioFIRContext *s = ctx->priv;
@@ -792,14 +800,11 @@ static av_cold int init(AVFilterContext *ctx)
         }
     }
 
-    s->fcmul_add = fcmul_add_c;
-
     s->fdsp = avpriv_float_dsp_alloc(0);
     if (!s->fdsp)
         return AVERROR(ENOMEM);
 
-    if (ARCH_X86)
-        ff_afir_init_x86(s);
+    ff_afir_init(&s->afirdsp);
 
     return 0;
 }
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index f9bec54b8c..f665c0ef80 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -53,6 +53,11 @@ typedef struct AudioFIRSegment {
     RDFTContext **rdft, **irdft;
 } AudioFIRSegment;
 
+typedef struct AudioFIRDSPContext {
+    void (*fcmul_add)(float *sum, const float *t, const float *c,
+                      ptrdiff_t len);
+} AudioFIRDSPContext;
+
 typedef struct AudioFIRContext {
     const AVClass *class;
 
@@ -87,11 +92,12 @@ typedef struct AudioFIRContext {
     int min_part_size;
     int64_t pts;
 
+    AudioFIRDSPContext afirdsp;
     AVFloatDSPContext *fdsp;
-    void (*fcmul_add)(float *sum, const float *t, const float *c,
-                      ptrdiff_t len);
+
 } AudioFIRContext;
 
-void ff_afir_init_x86(AudioFIRContext *s);
+void ff_afir_init(AudioFIRDSPContext *s);
+void ff_afir_init_x86(AudioFIRDSPContext *s);
 
 #endif /* AVFILTER_AFIR_H */
diff --git a/libavfilter/x86/af_afir_init.c b/libavfilter/x86/af_afir_init.c
index 6a652b9b83..29e6f976b2 100644
--- a/libavfilter/x86/af_afir_init.c
+++ b/libavfilter/x86/af_afir_init.c
@@ -25,7 +25,7 @@
 void ff_fcmul_add_sse3(float *sum, const float *t, const float *c,
                        ptrdiff_t len);
 
-av_cold void ff_afir_init_x86(AudioFIRContext *s)
+av_cold void ff_afir_init_x86(AudioFIRDSPContext *s)
 {
     int cpu_flags = av_get_cpu_flags();
 
-- 
2.20.1



More information about the ffmpeg-devel mailing list