annotate i386/fft_3dn.c @ 3768:c540147303fa libavcodec

fix decoding of bastard1.rm (rv ver=0x10003001 ver0=0x8000000)
author michael
date Tue, 26 Sep 2006 20:24:13 +0000
parents a3d97c60ea07
children c8c591fe26f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
1 /*
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
2 * FFT/MDCT transform with 3DNow! optimizations
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
3 * Copyright (c) 2006 Zuxy MENG Jie, Loren Merritt
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
4 * Based on fft_sse.c copyright (c) 2002 Fabrice Bellard.
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
5 *
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
10 *
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
14 * Lesser General Public License for more details.
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
15 *
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
19 */
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
20 #include "../dsputil.h"
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
21
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
22 static const int p1m1[2] __attribute__((aligned(8))) =
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
23 { 0, 1 << 31 };
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
24
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
25 static const int m1p1[2] __attribute__((aligned(8))) =
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
26 { 1 << 31, 0 };
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
27
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
28 void ff_fft_calc_3dn(FFTContext *s, FFTComplex *z)
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
29 {
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
30 int ln = s->nbits;
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
31 long i, j;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
32 long nblocks, nloops;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
33 FFTComplex *p, *cptr;
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
34
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
35 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
36 /* FEMMS is not a must here but recommended by AMD */
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
37 "femms \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
38 "movq %0, %%mm7 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
39 ::"m"(*(s->inverse ? m1p1 : p1m1))
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
40 );
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
41
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
42 i = 8 << ln;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
43 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
44 "1: \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
45 "sub $32, %0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
46 "movq (%0,%1), %%mm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
47 "movq 16(%0,%1), %%mm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
48 "movq 8(%0,%1), %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
49 "movq 24(%0,%1), %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
50 "movq %%mm0, %%mm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
51 "movq %%mm1, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
52 "pfadd %%mm2, %%mm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
53 "pfadd %%mm3, %%mm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
54 "pfsub %%mm2, %%mm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
55 "pfsub %%mm3, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
56 "movq %%mm0, %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
57 "punpckldq %%mm5, %%mm6 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
58 "punpckhdq %%mm6, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
59 "movq %%mm4, %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
60 "pxor %%mm7, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
61 "pfadd %%mm1, %%mm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
62 "pfadd %%mm5, %%mm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
63 "pfsub %%mm1, %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
64 "pfsub %%mm5, %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
65 "movq %%mm0, (%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
66 "movq %%mm4, 8(%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
67 "movq %%mm2, 16(%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
68 "movq %%mm3, 24(%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
69 "jg 1b \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
70 :"+r"(i)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
71 :"r"(z)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
72 );
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
73 /* pass 2 .. ln-1 */
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
74
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
75 nblocks = 1 << (ln-3);
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
76 nloops = 1 << 2;
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
77 cptr = s->exptab1;
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
78 do {
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
79 p = z;
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
80 j = nblocks;
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
81 do {
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
82 i = nloops*8;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
83 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
84 "1: \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
85 "sub $16, %0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
86 "movq (%1,%0), %%mm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
87 "movq 8(%1,%0), %%mm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
88 "movq (%2,%0), %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
89 "movq 8(%2,%0), %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
90 "movq %%mm2, %%mm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
91 "movq %%mm3, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
92 "punpckldq %%mm2, %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
93 "punpckldq %%mm3, %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
94 "punpckhdq %%mm4, %%mm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
95 "punpckhdq %%mm5, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
96 "pfmul (%3,%0,2), %%mm2 \n\t" // cre*re cim*re
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
97 "pfmul 8(%3,%0,2), %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
98 "pfmul 16(%3,%0,2), %%mm4 \n\t" // -cim*im cre*im
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
99 "pfmul 24(%3,%0,2), %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
100 "pfadd %%mm2, %%mm4 \n\t" // cre*re-cim*im cim*re+cre*im
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
101 "pfadd %%mm3, %%mm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
102 "movq %%mm0, %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
103 "movq %%mm1, %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
104 "pfadd %%mm4, %%mm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
105 "pfadd %%mm5, %%mm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
106 "pfsub %%mm4, %%mm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
107 "pfsub %%mm5, %%mm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
108 "movq %%mm0, (%1,%0) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
109 "movq %%mm1, 8(%1,%0) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
110 "movq %%mm2, (%2,%0) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
111 "movq %%mm3, 8(%2,%0) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
112 "jg 1b \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
113 :"+r"(i)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
114 :"r"(p), "r"(p + nloops), "r"(cptr)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
115 );
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
116 p += nloops*2;
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
117 } while (--j);
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
118 cptr += nloops*2;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
119 nblocks >>= 1;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
120 nloops <<= 1;
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
121 } while (nblocks != 0);
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3175
diff changeset
122 asm volatile("femms");
3175
c20c181e0eca 3DNow! & Extended 3DNow! versions of FFT
corey
parents:
diff changeset
123 }