[FFmpeg-devel] [PATCH 1/2] Separate per-arch MDCT init from FFT init

Mans Rullgard mans
Tue Sep 15 23:22:35 CEST 2009


---
 libavcodec/arm/fft_init_arm.c |   16 +++++++++++-----
 libavcodec/dsputil.h          |    3 +++
 libavcodec/fft.c              |    3 ---
 libavcodec/mdct.c             |    7 +++++++
 libavcodec/x86/fft.c          |   26 ++++++++++++++++++++------
 5 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/libavcodec/arm/fft_init_arm.c b/libavcodec/arm/fft_init_arm.c
index 6bb3686..647cd06 100644
--- a/libavcodec/arm/fft_init_arm.c
+++ b/libavcodec/arm/fft_init_arm.c
@@ -30,10 +30,16 @@ void ff_mdct_calc_neon(MDCTContext *s, FFTSample *output, const FFTSample *input
 av_cold void ff_fft_init_arm(FFTContext *s)
 {
     if (HAVE_NEON) {
-        s->fft_permute  = ff_fft_permute_neon;
-        s->fft_calc     = ff_fft_calc_neon;
-        s->imdct_calc   = ff_imdct_calc_neon;
-        s->imdct_half   = ff_imdct_half_neon;
-        s->mdct_calc    = ff_mdct_calc_neon;
+        s->fft_permute = ff_fft_permute_neon;
+        s->fft_calc    = ff_fft_calc_neon;
+    }
+}
+
+av_cold void ff_mdct_init_arm(MDCTContext *s)
+{
+    if (HAVE_NEON) {
+        s->fft.imdct_calc = ff_imdct_calc_neon;
+        s->fft.imdct_half = ff_imdct_half_neon;
+        s->fft.mdct_calc  = ff_mdct_calc_neon;
     }
 }
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index d100d5f..fa2cb14 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -774,6 +774,9 @@ void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input);
 void ff_mdct_calc_c(MDCTContext *s, FFTSample *output, const FFTSample *input);
 void ff_mdct_end(MDCTContext *s);
 
+void ff_mdct_init_mmx(MDCTContext *s);
+void ff_mdct_init_neon(MDCTContext *s);
+
 /* Real Discrete Fourier Transform */
 
 enum RDFTransformType {
diff --git a/libavcodec/fft.c b/libavcodec/fft.c
index c827139..d9b5ded 100644
--- a/libavcodec/fft.c
+++ b/libavcodec/fft.c
@@ -82,9 +82,6 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
 
     s->fft_permute = ff_fft_permute_c;
     s->fft_calc    = ff_fft_calc_c;
-    s->imdct_calc  = ff_imdct_calc_c;
-    s->imdct_half  = ff_imdct_half_c;
-    s->mdct_calc   = ff_mdct_calc_c;
     s->exptab1     = NULL;
     s->split_radix = 1;
 
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index cb024ac..e19291a 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -89,6 +89,13 @@ av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale)
     if (!s->tsin)
         goto fail;
 
+    s->fft.imdct_calc = ff_imdct_calc_c;
+    s->fft.imdct_half = ff_imdct_half_c;
+    s->fft.mdct_calc  = ff_mdct_calc_c;
+
+    if (ARCH_ARM) ff_mdct_init_arm(s);
+    if (HAVE_MMX) ff_mdct_init_mmx(s);
+
     theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0);
     scale = sqrt(fabs(scale));
     for(i=0;i<n4;i++) {
diff --git a/libavcodec/x86/fft.c b/libavcodec/x86/fft.c
index 2c46c63..aacbaac 100644
--- a/libavcodec/x86/fft.c
+++ b/libavcodec/x86/fft.c
@@ -25,20 +25,34 @@ av_cold void ff_fft_init_mmx(FFTContext *s)
     int has_vectors = mm_support();
     if (has_vectors & FF_MM_SSE && HAVE_SSE) {
         /* SSE for P3/P4/K8 */
-        s->imdct_calc  = ff_imdct_calc_sse;
-        s->imdct_half  = ff_imdct_half_sse;
         s->fft_permute = ff_fft_permute_sse;
         s->fft_calc    = ff_fft_calc_sse;
     } else if (has_vectors & FF_MM_3DNOWEXT && HAVE_AMD3DNOWEXT) {
         /* 3DNowEx for K7 */
-        s->imdct_calc = ff_imdct_calc_3dn2;
-        s->imdct_half = ff_imdct_half_3dn2;
         s->fft_calc   = ff_fft_calc_3dn2;
     } else if (has_vectors & FF_MM_3DNOW && HAVE_AMD3DNOW) {
         /* 3DNow! for K6-2/3 */
-        s->imdct_calc = ff_imdct_calc_3dn;
-        s->imdct_half = ff_imdct_half_3dn;
         s->fft_calc   = ff_fft_calc_3dn;
     }
 #endif
 }
+
+av_cold void ff_mdct_init_mmx(MDCTContext *s)
+{
+#if HAVE_YASM
+    int has_vectors = mm_support();
+    if (has_vectors & FF_MM_SSE && HAVE_SSE) {
+        /* SSE for P3/P4/K8 */
+        s->fft.imdct_calc = ff_imdct_calc_sse;
+        s->fft.imdct_half = ff_imdct_half_sse;
+    } else if (has_vectors & FF_MM_3DNOWEXT && HAVE_AMD3DNOWEXT) {
+        /* 3DNowEx for K7 */
+        s->fft.imdct_calc = ff_imdct_calc_3dn2;
+        s->fft.imdct_half = ff_imdct_half_3dn2;
+    } else if (has_vectors & FF_MM_3DNOW && HAVE_AMD3DNOW) {
+        /* 3DNow! for K6-2/3 */
+        s->fft.imdct_calc = ff_imdct_calc_3dn;
+        s->fft.imdct_half = ff_imdct_half_3dn;
+    }
+#endif
+}
-- 
1.6.4.2




More information about the ffmpeg-devel mailing list