Mercurial > libavcodec.hg
annotate i386/fft_sse.c @ 3711:4a5536551692 libavcodec
Swap back and forward motion vectors to achieve correct picture
author | kostya |
---|---|
date | Tue, 12 Sep 2006 04:35:11 +0000 |
parents | a3d97c60ea07 |
children | 2ec498208c6a |
rev | line source |
---|---|
781 | 1 /* |
2 * FFT/MDCT transform with SSE optimizations | |
3 * Copyright (c) 2002 Fabrice Bellard. | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
781 | 18 */ |
19 #include "../dsputil.h" | |
20 | |
3166
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
21 static const int p1p1p1m1[4] __attribute__((aligned(16))) = |
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
22 { 0, 0, 0, 1 << 31 }; |
781 | 23 |
3166
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
24 static const int p1p1m1p1[4] __attribute__((aligned(16))) = |
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
25 { 0, 0, 1 << 31, 0 }; |
968
64f1a11b5f86
added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents:
781
diff
changeset
|
26 |
3166
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
27 static const int p1p1m1m1[4] __attribute__((aligned(16))) = |
ab1273ffe275
use xorps instead of mulps to toggle the sign of a float, as suggested by Software Optimization Guide for AMD64 Processors.
gpoirier
parents:
3036
diff
changeset
|
28 { 0, 0, 1 << 31, 1 << 31 }; |
781 | 29 |
30 #if 0 | |
31 static void print_v4sf(const char *str, __m128 a) | |
32 { | |
33 float *p = (float *)&a; | |
34 printf("%s: %f %f %f %f\n", | |
35 str, p[0], p[1], p[2], p[3]); | |
36 } | |
37 #endif | |
38 | |
39 /* XXX: handle reverse case */ | |
1879
dd63cb7e5080
fft_*() renamed into ff_fft_*() patch by (Gildas Bazin <gbazin at altern dot org>)
michael
parents:
968
diff
changeset
|
40 void ff_fft_calc_sse(FFTContext *s, FFTComplex *z) |
781 | 41 { |
42 int ln = s->nbits; | |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
43 long i, j; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
44 long nblocks, nloops; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
45 FFTComplex *p, *cptr; |
781 | 46 |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
47 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
48 "movaps %0, %%xmm4 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
49 "movaps %1, %%xmm5 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
50 ::"m"(*p1p1m1m1), |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
51 "m"(*(s->inverse ? p1p1m1p1 : p1p1p1m1)) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
52 ); |
968
64f1a11b5f86
added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents:
781
diff
changeset
|
53 |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
54 i = 8 << ln; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
55 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
56 "1: \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
57 "sub $32, %0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
58 /* do the pass 0 butterfly */ |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
59 "movaps (%0,%1), %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
60 "movaps %%xmm0, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
61 "shufps $0x4E, %%xmm0, %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
62 "xorps %%xmm4, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
63 "addps %%xmm1, %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
64 "movaps 16(%0,%1), %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
65 "movaps %%xmm2, %%xmm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
66 "shufps $0x4E, %%xmm2, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
67 "xorps %%xmm4, %%xmm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
68 "addps %%xmm3, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
69 /* multiply third by -i */ |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
70 /* by toggling the sign bit */ |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
71 "shufps $0xB4, %%xmm2, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
72 "xorps %%xmm5, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
73 /* do the pass 1 butterfly */ |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
74 "movaps %%xmm0, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
75 "addps %%xmm2, %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
76 "subps %%xmm2, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
77 "movaps %%xmm0, (%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
78 "movaps %%xmm1, 16(%0,%1) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
79 "jg 1b \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
80 :"+r"(i) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
81 :"r"(z) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
82 ); |
781 | 83 /* pass 2 .. ln-1 */ |
84 | |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
85 nblocks = 1 << (ln-3); |
781 | 86 nloops = 1 << 2; |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
87 cptr = s->exptab1; |
781 | 88 do { |
89 p = z; | |
90 j = nblocks; | |
91 do { | |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
92 i = nloops*8; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
93 asm volatile( |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
94 "1: \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
95 "sub $16, %0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
96 "movaps (%2,%0), %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
97 "movaps (%1,%0), %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
98 "movaps %%xmm1, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
99 "shufps $0xA0, %%xmm1, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
100 "shufps $0xF5, %%xmm2, %%xmm2 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
101 "mulps (%3,%0,2), %%xmm1 \n\t" // cre*re cim*re |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
102 "mulps 16(%3,%0,2), %%xmm2 \n\t" // -cim*im cre*im |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
103 "addps %%xmm2, %%xmm1 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
104 "movaps %%xmm0, %%xmm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
105 "addps %%xmm1, %%xmm0 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
106 "subps %%xmm1, %%xmm3 \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
107 "movaps %%xmm0, (%1,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
108 "movaps %%xmm3, (%2,%0) \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
109 "jg 1b \n\t" |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
110 :"+r"(i) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
111 :"r"(p), "r"(p + nloops), "r"(cptr) |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
112 ); |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
113 p += nloops*2; |
781 | 114 } while (--j); |
3590
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
115 cptr += nloops*2; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
116 nblocks >>= 1; |
a3d97c60ea07
ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents:
3166
diff
changeset
|
117 nloops <<= 1; |
781 | 118 } while (nblocks != 0); |
119 } | |
968
64f1a11b5f86
added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents:
781
diff
changeset
|
120 |