annotate i386/fft_sse.c @ 7540:5298e05f931d libavcodec

Synchronise code with AAC decoder in SoC
author superdump
date Mon, 11 Aug 2008 11:22:48 +0000
parents fc843d00867c
children a8a8205a9081
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
1 /*
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
2 * FFT/MDCT transform with SSE optimizations
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
3 * Copyright (c) 2002 Fabrice Bellard.
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
4 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3746
diff changeset
5 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3746
diff changeset
6 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3746
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
9 * 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: 3746
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
11 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3746
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
16 *
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
17 * 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: 3746
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
20 */
6763
f7cbb7733146 Use full path for #includes from another directory.
diego
parents: 6755
diff changeset
21
f7cbb7733146 Use full path for #includes from another directory.
diego
parents: 6755
diff changeset
22 #include "libavutil/x86_cpu.h"
f7cbb7733146 Use full path for #includes from another directory.
diego
parents: 6755
diff changeset
23 #include "libavcodec/dsputil.h"
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
24
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
25 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
26 { 0, 0, 0, 1 << 31 };
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
27
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
28 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
29 { 0, 0, 1 << 31, 0 };
968
64f1a11b5f86 added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents: 781
diff changeset
30
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
31 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
32 { 0, 0, 1 << 31, 1 << 31 };
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
33
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
34 static const int p1m1p1m1[4] __attribute__((aligned(16))) =
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
35 { 0, 1 << 31, 0, 1 << 31 };
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
36
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
37 static const int m1m1m1m1[4] __attribute__((aligned(16))) =
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
38 { 1 << 31, 1 << 31, 1 << 31, 1 << 31 };
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
39
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
40 #if 0
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
41 static void print_v4sf(const char *str, __m128 a)
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
42 {
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
43 float *p = (float *)&a;
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
44 printf("%s: %f %f %f %f\n",
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
45 str, p[0], p[1], p[2], p[3]);
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
46 }
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
47 #endif
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
48
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
49 /* 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
50 void ff_fft_calc_sse(FFTContext *s, FFTComplex *z)
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
51 {
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
52 int ln = s->nbits;
6755
33896780c612 Do not misuse long as the size of a register in x86.
ramiro
parents: 5117
diff changeset
53 x86_reg i;
33896780c612 Do not misuse long as the size of a register in x86.
ramiro
parents: 5117
diff changeset
54 long j;
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
55 long nblocks, nloops;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
56 FFTComplex *p, *cptr;
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
57
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
58 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
59 "movaps %0, %%xmm4 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
60 "movaps %1, %%xmm5 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
61 ::"m"(*p1p1m1m1),
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
62 "m"(*(s->inverse ? p1p1m1p1 : p1p1p1m1))
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
63 );
968
64f1a11b5f86 added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents: 781
diff changeset
64
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
65 i = 8 << ln;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
66 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
67 "1: \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
68 "sub $32, %0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
69 /* do the pass 0 butterfly */
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
70 "movaps (%0,%1), %%xmm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
71 "movaps %%xmm0, %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
72 "shufps $0x4E, %%xmm0, %%xmm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
73 "xorps %%xmm4, %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
74 "addps %%xmm1, %%xmm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
75 "movaps 16(%0,%1), %%xmm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
76 "movaps %%xmm2, %%xmm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
77 "shufps $0x4E, %%xmm2, %%xmm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
78 "xorps %%xmm4, %%xmm3 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
79 "addps %%xmm3, %%xmm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
80 /* multiply third by -i */
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
81 /* by toggling the sign bit */
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
82 "shufps $0xB4, %%xmm2, %%xmm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
83 "xorps %%xmm5, %%xmm2 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
84 /* do the pass 1 butterfly */
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
85 "movaps %%xmm0, %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
86 "addps %%xmm2, %%xmm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
87 "subps %%xmm2, %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
88 "movaps %%xmm0, (%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
89 "movaps %%xmm1, 16(%0,%1) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
90 "jg 1b \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
91 :"+r"(i)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
92 :"r"(z)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
93 );
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
94 /* pass 2 .. ln-1 */
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
95
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
96 nblocks = 1 << (ln-3);
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
97 nloops = 1 << 2;
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
98 cptr = s->exptab1;
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
99 do {
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
100 p = z;
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
101 j = nblocks;
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
102 do {
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
103 i = nloops*8;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
104 asm volatile(
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
105 "1: \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
106 "sub $32, %0 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
107 "movaps (%2,%0), %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
108 "movaps (%1,%0), %%xmm0 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
109 "movaps 16(%2,%0), %%xmm5 \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
110 "movaps 16(%1,%0), %%xmm4 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
111 "movaps %%xmm1, %%xmm2 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
112 "movaps %%xmm5, %%xmm6 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
113 "shufps $0xA0, %%xmm1, %%xmm1 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
114 "shufps $0xF5, %%xmm2, %%xmm2 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
115 "shufps $0xA0, %%xmm5, %%xmm5 \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
116 "shufps $0xF5, %%xmm6, %%xmm6 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
117 "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
118 "mulps 16(%3,%0,2), %%xmm2 \n\t" // -cim*im cre*im
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
119 "mulps 32(%3,%0,2), %%xmm5 \n\t" // cre*re cim*re
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
120 "mulps 48(%3,%0,2), %%xmm6 \n\t" // -cim*im cre*im
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
121 "addps %%xmm2, %%xmm1 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
122 "addps %%xmm6, %%xmm5 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
123 "movaps %%xmm0, %%xmm3 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
124 "movaps %%xmm4, %%xmm7 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
125 "addps %%xmm1, %%xmm0 \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
126 "subps %%xmm1, %%xmm3 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
127 "addps %%xmm5, %%xmm4 \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
128 "subps %%xmm5, %%xmm7 \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
129 "movaps %%xmm0, (%1,%0) \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
130 "movaps %%xmm3, (%2,%0) \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
131 "movaps %%xmm4, 16(%1,%0) \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
132 "movaps %%xmm7, 16(%2,%0) \n\t"
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
133 "jg 1b \n\t"
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
134 :"+r"(i)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
135 :"r"(p), "r"(p + nloops), "r"(cptr)
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
136 );
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
137 p += nloops*2;
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
138 } while (--j);
3590
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
139 cptr += nloops*2;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
140 nblocks >>= 1;
a3d97c60ea07 ff_fft_calc_3dn/3dn2/sse: convert intrinsics to inline asm.
lorenm
parents: 3166
diff changeset
141 nloops <<= 1;
781
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
142 } while (nblocks != 0);
6f5e87957bcb new generic FFT/MDCT code for audio codecs
bellard
parents:
diff changeset
143 }
968
64f1a11b5f86 added define for builtins use - inverse fix by Romain Dolbeau
bellard
parents: 781
diff changeset
144
7263
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
145 static void imdct_sse(MDCTContext *s, const FFTSample *input, FFTSample *tmp)
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
146 {
6755
33896780c612 Do not misuse long as the size of a register in x86.
ramiro
parents: 5117
diff changeset
147 x86_reg k;
7263
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
148 long n4, n2, n;
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
149 const uint16_t *revtab = s->fft.revtab;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
150 const FFTSample *tcos = s->tcos;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
151 const FFTSample *tsin = s->tsin;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
152 const FFTSample *in1, *in2;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
153 FFTComplex *z = (FFTComplex *)tmp;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
154
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
155 n = 1 << s->nbits;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
156 n2 = n >> 1;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
157 n4 = n >> 2;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
158
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
159 #ifdef ARCH_X86_64
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
160 asm volatile ("movaps %0, %%xmm8\n\t"::"m"(*p1m1p1m1));
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
161 #define P1M1P1M1 "%%xmm8"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
162 #else
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
163 #define P1M1P1M1 "%4"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
164 #endif
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
165
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
166 /* pre rotation */
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
167 in1 = input;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
168 in2 = input + n2 - 4;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
169
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
170 /* Complex multiplication */
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
171 for (k = 0; k < n4; k += 4) {
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
172 asm volatile (
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
173 "movaps %0, %%xmm0 \n\t" // xmm0 = r0 X r1 X : in2
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
174 "movaps %1, %%xmm3 \n\t" // xmm3 = X i1 X i0: in1
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
175 "movaps -16+1*%0, %%xmm4 \n\t" // xmm4 = r0 X r1 X : in2
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
176 "movaps 16+1*%1, %%xmm7 \n\t" // xmm7 = X i1 X i0: in1
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
177 "movlps %2, %%xmm1 \n\t" // xmm1 = X X R1 R0: tcos
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
178 "movlps %3, %%xmm2 \n\t" // xmm2 = X X I1 I0: tsin
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
179 "movlps 8+1*%2, %%xmm5 \n\t" // xmm5 = X X R1 R0: tcos
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
180 "movlps 8+1*%3, %%xmm6 \n\t" // xmm6 = X X I1 I0: tsin
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
181 "shufps $95, %%xmm0, %%xmm0 \n\t" // xmm0 = r1 r1 r0 r0
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
182 "shufps $160,%%xmm3, %%xmm3 \n\t" // xmm3 = i1 i1 i0 i0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
183 "shufps $95, %%xmm4, %%xmm4 \n\t" // xmm4 = r1 r1 r0 r0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
184 "shufps $160,%%xmm7, %%xmm7 \n\t" // xmm7 = i1 i1 i0 i0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
185 "unpcklps %%xmm2, %%xmm1 \n\t" // xmm1 = I1 R1 I0 R0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
186 "unpcklps %%xmm6, %%xmm5 \n\t" // xmm5 = I1 R1 I0 R0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
187 "movaps %%xmm1, %%xmm2 \n\t" // xmm2 = I1 R1 I0 R0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
188 "movaps %%xmm5, %%xmm6 \n\t" // xmm6 = I1 R1 I0 R0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
189 "xorps "P1M1P1M1", %%xmm2 \n\t" // xmm2 = -I1 R1 -I0 R0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
190 "xorps "P1M1P1M1", %%xmm6 \n\t" // xmm6 = -I1 R1 -I0 R0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
191 "mulps %%xmm1, %%xmm0 \n\t" // xmm0 = rI rR rI rR
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
192 "mulps %%xmm5, %%xmm4 \n\t" // xmm4 = rI rR rI rR
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
193 "shufps $177,%%xmm2, %%xmm2 \n\t" // xmm2 = R1 -I1 R0 -I0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
194 "shufps $177,%%xmm6, %%xmm6 \n\t" // xmm6 = R1 -I1 R0 -I0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
195 "mulps %%xmm2, %%xmm3 \n\t" // xmm3 = Ri -Ii Ri -Ii
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
196 "mulps %%xmm6, %%xmm7 \n\t" // xmm7 = Ri -Ii Ri -Ii
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
197 "addps %%xmm3, %%xmm0 \n\t" // xmm0 = result
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
198 "addps %%xmm7, %%xmm4 \n\t" // xmm4 = result
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
199 ::"m"(in2[-2*k]), "m"(in1[2*k]),
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
200 "m"(tcos[k]), "m"(tsin[k])
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
201 #ifndef ARCH_X86_64
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
202 ,"m"(*p1m1p1m1)
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
203 #endif
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
204 );
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
205 /* Should be in the same block, hack for gcc2.95 & gcc3 */
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
206 asm (
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
207 "movlps %%xmm0, %0 \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
208 "movhps %%xmm0, %1 \n\t"
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
209 "movlps %%xmm4, %2 \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
210 "movhps %%xmm4, %3 \n\t"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
211 :"=m"(z[revtab[k]]), "=m"(z[revtab[k + 1]]),
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
212 "=m"(z[revtab[k + 2]]), "=m"(z[revtab[k + 3]])
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
213 );
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
214 }
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
215
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
216 ff_fft_calc_sse(&s->fft, z);
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
217
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
218 #ifndef ARCH_X86_64
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
219 #undef P1M1P1M1
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
220 #define P1M1P1M1 "%3"
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
221 #endif
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
222
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
223 /* post rotation + reordering */
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
224 for (k = 0; k < n4; k += 4) {
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
225 asm (
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
226 "movaps %0, %%xmm0 \n\t" // xmm0 = i1 r1 i0 r0: z
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
227 "movaps 16+1*%0, %%xmm4 \n\t" // xmm4 = i1 r1 i0 r0: z
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
228 "movlps %1, %%xmm1 \n\t" // xmm1 = X X R1 R0: tcos
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
229 "movlps 8+1*%1, %%xmm5 \n\t" // xmm5 = X X R1 R0: tcos
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
230 "movaps %%xmm0, %%xmm3 \n\t" // xmm3 = i1 r1 i0 r0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
231 "movaps %%xmm4, %%xmm7 \n\t" // xmm7 = i1 r1 i0 r0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
232 "movlps %2, %%xmm2 \n\t" // xmm2 = X X I1 I0: tsin
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
233 "movlps 8+1*%2, %%xmm6 \n\t" // xmm6 = X X I1 I0: tsin
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
234 "shufps $160,%%xmm0, %%xmm0 \n\t" // xmm0 = r1 r1 r0 r0
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
235 "shufps $245,%%xmm3, %%xmm3 \n\t" // xmm3 = i1 i1 i0 i0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
236 "shufps $160,%%xmm4, %%xmm4 \n\t" // xmm4 = r1 r1 r0 r0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
237 "shufps $245,%%xmm7, %%xmm7 \n\t" // xmm7 = i1 i1 i0 i0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
238 "unpcklps %%xmm2, %%xmm1 \n\t" // xmm1 = I1 R1 I0 R0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
239 "unpcklps %%xmm6, %%xmm5 \n\t" // xmm5 = I1 R1 I0 R0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
240 "movaps %%xmm1, %%xmm2 \n\t" // xmm2 = I1 R1 I0 R0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
241 "movaps %%xmm5, %%xmm6 \n\t" // xmm6 = I1 R1 I0 R0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
242 "xorps "P1M1P1M1", %%xmm2 \n\t" // xmm2 = -I1 R1 -I0 R0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
243 "mulps %%xmm1, %%xmm0 \n\t" // xmm0 = rI rR rI rR
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
244 "xorps "P1M1P1M1", %%xmm6 \n\t" // xmm6 = -I1 R1 -I0 R0
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
245 "mulps %%xmm5, %%xmm4 \n\t" // xmm4 = rI rR rI rR
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
246 "shufps $177,%%xmm2, %%xmm2 \n\t" // xmm2 = R1 -I1 R0 -I0
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
247 "shufps $177,%%xmm6, %%xmm6 \n\t" // xmm6 = R1 -I1 R0 -I0
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
248 "mulps %%xmm2, %%xmm3 \n\t" // xmm3 = Ri -Ii Ri -Ii
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
249 "mulps %%xmm6, %%xmm7 \n\t" // xmm7 = Ri -Ii Ri -Ii
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
250 "addps %%xmm3, %%xmm0 \n\t" // xmm0 = result
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
251 "addps %%xmm7, %%xmm4 \n\t" // xmm4 = result
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
252 "movaps %%xmm0, %0 \n\t"
5117
524faa5eabd1 work around issues with the old version of Gnu Assembler shipped on
gpoirier
parents: 5010
diff changeset
253 "movaps %%xmm4, 16+1*%0\n\t"
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
254 :"+m"(z[k])
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
255 :"m"(tcos[k]), "m"(tsin[k])
5000
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
256 #ifndef ARCH_X86_64
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
257 ,"m"(*p1m1p1m1)
743a8b12b7de Faster SSE FFT/MDCT, patch by Zuxy Meng %zuxy P meng A gmail P com%
gpoirier
parents: 3947
diff changeset
258 #endif
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
259 );
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
260 }
7263
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
261 }
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
262
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
263 void ff_imdct_calc_sse(MDCTContext *s, FFTSample *output,
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
264 const FFTSample *input, FFTSample *tmp)
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
265 {
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
266 x86_reg k;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
267 long n8, n2, n;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
268 FFTComplex *z = (FFTComplex *)tmp;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
269
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
270 n = 1 << s->nbits;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
271 n2 = n >> 1;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
272 n8 = n >> 3;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
273
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
274 imdct_sse(s, input, tmp);
3746
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
275
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
276 /*
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
277 Mnemonics:
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
278 0 = z[k].re
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
279 1 = z[k].im
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
280 2 = z[k + 1].re
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
281 3 = z[k + 1].im
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
282 4 = z[-k - 2].re
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
283 5 = z[-k - 2].im
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
284 6 = z[-k - 1].re
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
285 7 = z[-k - 1].im
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
286 */
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
287 k = 16-n;
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
288 asm volatile("movaps %0, %%xmm7 \n\t"::"m"(*m1m1m1m1));
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
289 asm volatile(
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
290 "1: \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
291 "movaps -16(%4,%0), %%xmm1 \n\t" // xmm1 = 4 5 6 7 = z[-2-k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
292 "neg %0 \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
293 "movaps (%4,%0), %%xmm0 \n\t" // xmm0 = 0 1 2 3 = z[k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
294 "xorps %%xmm7, %%xmm0 \n\t" // xmm0 = -0 -1 -2 -3
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
295 "movaps %%xmm0, %%xmm2 \n\t" // xmm2 = -0 -1 -2 -3
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
296 "shufps $141,%%xmm1, %%xmm0 \n\t" // xmm0 = -1 -3 4 6
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
297 "shufps $216,%%xmm1, %%xmm2 \n\t" // xmm2 = -0 -2 5 7
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
298 "shufps $156,%%xmm0, %%xmm0 \n\t" // xmm0 = -1 6 -3 4 !
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
299 "shufps $156,%%xmm2, %%xmm2 \n\t" // xmm2 = -0 7 -2 5 !
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
300 "movaps %%xmm0, (%1,%0) \n\t" // output[2*k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
301 "movaps %%xmm2, (%2,%0) \n\t" // output[n2+2*k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
302 "neg %0 \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
303 "shufps $27, %%xmm0, %%xmm0 \n\t" // xmm0 = 4 -3 6 -1
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
304 "xorps %%xmm7, %%xmm0 \n\t" // xmm0 = -4 3 -6 1 !
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
305 "shufps $27, %%xmm2, %%xmm2 \n\t" // xmm2 = 5 -2 7 -0 !
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
306 "movaps %%xmm0, -16(%2,%0) \n\t" // output[n2-4-2*k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
307 "movaps %%xmm2, -16(%3,%0) \n\t" // output[n-4-2*k]
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
308 "add $16, %0 \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
309 "jle 1b \n\t"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
310 :"+r"(k)
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
311 :"r"(output), "r"(output+n2), "r"(output+n), "r"(z+n8)
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
312 :"memory"
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
313 );
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
314 }
2ec498208c6a sse implementation of imdct.
lorenm
parents: 3590
diff changeset
315
7263
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
316 void ff_imdct_half_sse(MDCTContext *s, FFTSample *output,
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
317 const FFTSample *input, FFTSample *tmp)
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
318 {
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
319 x86_reg j, k;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
320 long n8, n4, n;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
321 FFTComplex *z = (FFTComplex *)tmp;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
322
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
323 n = 1 << s->nbits;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
324 n4 = n >> 2;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
325 n8 = n >> 3;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
326
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
327 imdct_sse(s, input, tmp);
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
328
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
329 j = -n;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
330 k = n-16;
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
331 asm volatile("movaps %0, %%xmm7 \n\t"::"m"(*m1m1m1m1));
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
332 asm volatile(
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
333 "1: \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
334 "movaps (%3,%1), %%xmm0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
335 "movaps (%3,%0), %%xmm1 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
336 "xorps %%xmm7, %%xmm0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
337 "movaps %%xmm0, %%xmm2 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
338 "shufps $141,%%xmm1, %%xmm0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
339 "shufps $216,%%xmm1, %%xmm2 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
340 "shufps $54, %%xmm0, %%xmm0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
341 "shufps $156,%%xmm2, %%xmm2 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
342 "xorps %%xmm7, %%xmm0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
343 "movaps %%xmm2, (%2,%1) \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
344 "movaps %%xmm0, (%2,%0) \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
345 "sub $16, %1 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
346 "add $16, %0 \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
347 "jl 1b \n\t"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
348 :"+r"(j), "+r"(k)
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
349 :"r"(output+n4), "r"(z+n8)
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
350 :"memory"
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
351 );
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
352 }
fc843d00867c exploit mdct symmetry
lorenm
parents: 6763
diff changeset
353