changeset 6503:311c95dddb16 libavcodec

clean up FFT SIMD selection
author mru
date Mon, 17 Mar 2008 19:22:28 +0000
parents 98e3db1d7ca4
children 978911ca654f
files fft.c
diffstat 1 files changed, 28 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/fft.c	Mon Mar 17 02:33:08 2008 +0000
+++ b/fft.c	Mon Mar 17 19:22:28 2008 +0000
@@ -34,6 +34,8 @@
 {
     int i, j, m, n;
     float alpha, c1, s1, s2;
+    int shuffle = 0;
+    int av_unused has_vectors;
 
     s->nbits = nbits;
     n = 1 << nbits;
@@ -59,32 +61,33 @@
     s->imdct_calc = ff_imdct_calc;
     s->exptab1 = NULL;
 
-    /* compute constant table for HAVE_SSE version */
-#if defined(HAVE_MMX) \
-    || (defined(HAVE_ALTIVEC) && !defined(ALTIVEC_USE_REFERENCE_C_CODE))
-    {
-        int has_vectors = mm_support();
+#ifdef HAVE_MMX
+    has_vectors = mm_support();
+    shuffle = 1;
+    if (has_vectors & MM_3DNOWEXT) {
+        /* 3DNowEx for K7/K8 */
+        s->imdct_calc = ff_imdct_calc_3dn2;
+        s->fft_calc = ff_fft_calc_3dn2;
+    } else if (has_vectors & MM_3DNOW) {
+        /* 3DNow! for K6-2/3 */
+        s->fft_calc = ff_fft_calc_3dn;
+    } else if (has_vectors & MM_SSE) {
+        /* SSE for P3/P4 */
+        s->imdct_calc = ff_imdct_calc_sse;
+        s->fft_calc = ff_fft_calc_sse;
+    } else {
+        shuffle = 0;
+    }
+#elif defined HAVE_ALTIVEC && !defined ALTIVEC_USE_REFERENCE_C_CODE
+    has_vectors = mm_support();
+    if (has_vectors & MM_ALTIVEC) {
+        s->fft_calc = ff_fft_calc_altivec;
+        shuffle = 1;
+    }
+#endif
 
-        if (has_vectors) {
-#if defined(HAVE_MMX)
-            if (has_vectors & MM_3DNOWEXT) {
-                /* 3DNowEx for K7/K8 */
-                s->imdct_calc = ff_imdct_calc_3dn2;
-                s->fft_calc = ff_fft_calc_3dn2;
-            } else if (has_vectors & MM_3DNOW) {
-                /* 3DNow! for K6-2/3 */
-                s->fft_calc = ff_fft_calc_3dn;
-            } else if (has_vectors & MM_SSE) {
-                /* SSE for P3/P4 */
-                s->imdct_calc = ff_imdct_calc_sse;
-                s->fft_calc = ff_fft_calc_sse;
-            }
-#else /* HAVE_MMX */
-            if (has_vectors & MM_ALTIVEC)
-                s->fft_calc = ff_fft_calc_altivec;
-#endif
-        }
-        if (s->fft_calc != ff_fft_calc_c) {
+    /* compute constant table for HAVE_SSE version */
+        if (shuffle) {
             int np, nblocks, np2, l;
             FFTComplex *q;
 
@@ -111,8 +114,6 @@
             } while (nblocks != 0);
             av_freep(&s->exptab);
         }
-    }
-#endif
 
     /* compute bit reverse table */