Mercurial > libavcodec.hg
annotate i386/fft_3dn.c @ 7100:a17b3a67a719 libavcodec
Simplify rotate_buffer()
author | vitor |
---|---|
date | Mon, 23 Jun 2008 19:59:42 +0000 |
parents | f7cbb7733146 |
children | a8a8205a9081 |
rev | line source |
---|---|
3175 | 1 /* |
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 | 4 * Based on fft_sse.c copyright (c) 2002 Fabrice Bellard. |
5 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
6 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
7 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
8 * FFmpeg is free software; you can redistribute it and/or |
3175 | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
11 * version 2.1 of the License, or (at your option) any later version. |
3175 | 12 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
13 * FFmpeg is distributed in the hope that it will be useful, |
3175 | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3590
diff
changeset
|
19 * License along with FFmpeg; if not, write to the Free Software |
3175 | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 */ | |
6763 | 22 |
23 #include "libavutil/x86_cpu.h" | |
24 #include "libavcodec/dsputil.h" | |
3175 | 25 |
26 static const int p1m1[2] __attribute__((aligned(8))) = | |
27 { 0, 1 << 31 }; | |
28 | |
29 static const int m1p1[2] __attribute__((aligned(8))) = | |
30 { 1 << 31, 0 }; | |
31 | |
32 void ff_fft_calc_3dn(FFTContext *s, FFTComplex *z) | |
33 { | |
34 int ln = s->nbits; | |
6755
33896780c612
Do not misuse long as the size of a register in x86.
ramiro
parents:
5010
diff
changeset
|
35 long j; |
33896780c612
Do not misuse long as the size of a register in x86.
ramiro
parents:
5010
diff
changeset
|
36 x86_reg i; |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
37 long nblocks, nloops; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
38 FFTComplex *p, *cptr; |
3175 | 39 |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
40 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
41 /* 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
|
42 "femms \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
43 "movq %0, %%mm7 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
44 ::"m"(*(s->inverse ? m1p1 : p1m1)) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
45 ); |
3175 | 46 |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
47 i = 8 << ln; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
48 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
49 "1: \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
50 "sub $32, %0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
51 "movq (%0,%1), %%mm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
52 "movq 16(%0,%1), %%mm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
53 "movq 8(%0,%1), %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
54 "movq 24(%0,%1), %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
55 "movq %%mm0, %%mm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
56 "movq %%mm1, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
57 "pfadd %%mm2, %%mm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
58 "pfadd %%mm3, %%mm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
59 "pfsub %%mm2, %%mm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
60 "pfsub %%mm3, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
61 "movq %%mm0, %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
62 "punpckldq %%mm5, %%mm6 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
63 "punpckhdq %%mm6, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
64 "movq %%mm4, %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
65 "pxor %%mm7, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
66 "pfadd %%mm1, %%mm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
67 "pfadd %%mm5, %%mm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
68 "pfsub %%mm1, %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
69 "pfsub %%mm5, %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
70 "movq %%mm0, (%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
71 "movq %%mm4, 8(%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
72 "movq %%mm2, 16(%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
73 "movq %%mm3, 24(%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
74 "jg 1b \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
75 :"+r"(i) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
76 :"r"(z) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
77 ); |
3175 | 78 /* pass 2 .. ln-1 */ |
79 | |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
80 nblocks = 1 << (ln-3); |
3175 | 81 nloops = 1 << 2; |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
82 cptr = s->exptab1; |
3175 | 83 do { |
84 p = z; | |
85 j = nblocks; | |
86 do { | |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
87 i = nloops*8; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
88 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
89 "1: \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
90 "sub $16, %0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
91 "movq (%1,%0), %%mm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
92 "movq 8(%1,%0), %%mm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
93 "movq (%2,%0), %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
94 "movq 8(%2,%0), %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
95 "movq %%mm2, %%mm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
96 "movq %%mm3, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
97 "punpckldq %%mm2, %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
98 "punpckldq %%mm3, %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
99 "punpckhdq %%mm4, %%mm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
100 "punpckhdq %%mm5, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
101 "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
|
102 "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
|
103 "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
|
104 "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
|
105 "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
|
106 "pfadd %%mm3, %%mm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
107 "movq %%mm0, %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
108 "movq %%mm1, %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
109 "pfadd %%mm4, %%mm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
110 "pfadd %%mm5, %%mm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
111 "pfsub %%mm4, %%mm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
112 "pfsub %%mm5, %%mm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
113 "movq %%mm0, (%1,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
114 "movq %%mm1, 8(%1,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
115 "movq %%mm2, (%2,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
116 "movq %%mm3, 8(%2,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
117 "jg 1b \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
118 :"+r"(i) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
119 :"r"(p), "r"(p + nloops), "r"(cptr) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
120 ); |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
121 p += nloops*2; |
3175 | 122 } while (--j); |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
123 cptr += nloops*2; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
124 nblocks >>= 1; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
125 nloops <<= 1; |
3175 | 126 } while (nblocks != 0); |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3175
diff
changeset
|
127 asm volatile("femms"); |
3175 | 128 } |