[Ffmpeg-devel] Re: r5954 broke fft on AMD cpus without sse and without mm3dnow.h

Loren Merritt lorenm
Wed Aug 9 17:19:00 CEST 2006


On Wed, 9 Aug 2006, Herv? W. wrote:

> On 09/08/06, Herv? W. <H.O.W.aka.V+ffmpeg at gmail.com> wrote:
>> [...]
>> Attached is a patch to fix it (again).
>
> But that patch might disable the additions from r5954.
> oops.

Does this work?

--Loren Merritt
-------------- next part --------------
Index: libavcodec/fft.c
===================================================================
--- libavcodec/fft.c	(revision 5954)
+++ libavcodec/fft.c	(working copy)
@@ -69,6 +69,31 @@
         has_vectors = mm_support() & MM_ALTIVEC;
 #endif
         if (has_vectors) {
+#if defined(HAVE_MMX)
+            if (has_vectors & MM_3DNOWEXT)
+                s->imdct_calc = ff_imdct_calc_3dn2;
+#ifdef HAVE_MM3DNOW
+            if (has_vectors & MM_3DNOWEXT)
+                /* 3DNowEx for Athlon(XP) */
+                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;
+#endif
+#ifdef HAVE_BUILTIN_VECTOR
+            if (has_vectors & MM_SSE2)
+                /* SSE for P4/K8 */
+                s->fft_calc = ff_fft_calc_sse;
+            else if ((has_vectors & MM_SSE) &&
+                     s->fft_calc == ff_fft_calc_c)
+                /* SSE for P3 */
+                s->fft_calc = ff_fft_calc_sse;
+#endif
+#else /* HAVE_MMX */
+            s->fft_calc = ff_fft_calc_altivec;
+#endif
+        }
+        if (s->fft_calc != ff_fft_calc_c) {
             int np, nblocks, np2, l;
             FFTComplex *q;
 
@@ -94,29 +119,6 @@
                 nblocks = nblocks >> 1;
             } while (nblocks != 0);
             av_freep(&s->exptab);
-#if defined(HAVE_MMX)
-            if (has_vectors & MM_3DNOWEXT)
-                s->imdct_calc = ff_imdct_calc_3dn2;
-#ifdef HAVE_MM3DNOW
-            if (has_vectors & MM_3DNOWEXT)
-                /* 3DNowEx for Athlon(XP) */
-                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;
-#endif
-#ifdef HAVE_BUILTIN_VECTOR
-            if (has_vectors & MM_SSE2)
-                /* SSE for P4/K8 */
-                s->fft_calc = ff_fft_calc_sse;
-            else if ((has_vectors & MM_SSE) &&
-                     s->fft_calc == ff_fft_calc_c)
-                /* SSE for P3 */
-                s->fft_calc = ff_fft_calc_sse;
-#endif
-#else /* HAVE_MMX */
-            s->fft_calc = ff_fft_calc_altivec;
-#endif
         }
     }
 #endif



More information about the ffmpeg-devel mailing list