annotate liba52/imdct.c @ 3572:dc8fe516de8f

"I updatet codecs.html and translated whole new file: bugsreports.html. In all three files I set the charset encodding." Justyna Bia\263a <nell@skrzynka.pl>
author gabucino
date Mon, 17 Dec 2001 23:54:13 +0000
parents a501627fc6db
children 831860fada69
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1 /*
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
2 * imdct.c
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
3 * Copyright (C) 2000-2001 Michel Lespinasse <walken@zoy.org>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
5 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
6 * This file is part of a52dec, a free ATSC A-52 stream decoder.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
7 * See http://liba52.sourceforge.net/ for updates.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
8 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
9 * a52dec is free software; you can redistribute it and/or modify
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
12 * (at your option) any later version.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
13 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
14 * a52dec is distributed in the hope that it will be useful,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
17 * GNU General Public License for more details.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
18 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
22 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
23
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
24 #include "config.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
25
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
26 #include <math.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
27 #include <stdio.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
28 #ifndef M_PI
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
29 #define M_PI 3.1415926535897932384626433832795029
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
30 #endif
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
31 #include <inttypes.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
32
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
33 #include "a52.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34 #include "a52_internal.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35 #include "mm_accel.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
37 void (* imdct_256) (sample_t data[], sample_t delay[], sample_t bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
38 void (* imdct_512) (sample_t data[], sample_t delay[], sample_t bias);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
39
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
40 typedef struct complex_s {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
41 sample_t real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
42 sample_t imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
43 } complex_t;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
44
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
45
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
46 /* 128 point bit-reverse LUT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
47 static uint8_t bit_reverse_512[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
48 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
49 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
50 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
51 0x0c, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
52 0x02, 0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
53 0x0a, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
54 0x06, 0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
55 0x0e, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
56 0x01, 0x41, 0x21, 0x61, 0x11, 0x51, 0x31, 0x71,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
57 0x09, 0x49, 0x29, 0x69, 0x19, 0x59, 0x39, 0x79,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
58 0x05, 0x45, 0x25, 0x65, 0x15, 0x55, 0x35, 0x75,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
59 0x0d, 0x4d, 0x2d, 0x6d, 0x1d, 0x5d, 0x3d, 0x7d,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
60 0x03, 0x43, 0x23, 0x63, 0x13, 0x53, 0x33, 0x73,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
61 0x0b, 0x4b, 0x2b, 0x6b, 0x1b, 0x5b, 0x3b, 0x7b,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
62 0x07, 0x47, 0x27, 0x67, 0x17, 0x57, 0x37, 0x77,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
63 0x0f, 0x4f, 0x2f, 0x6f, 0x1f, 0x5f, 0x3f, 0x7f};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
64
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
65 static uint8_t bit_reverse_256[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
66 0x00, 0x20, 0x10, 0x30, 0x08, 0x28, 0x18, 0x38,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
67 0x04, 0x24, 0x14, 0x34, 0x0c, 0x2c, 0x1c, 0x3c,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
68 0x02, 0x22, 0x12, 0x32, 0x0a, 0x2a, 0x1a, 0x3a,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
69 0x06, 0x26, 0x16, 0x36, 0x0e, 0x2e, 0x1e, 0x3e,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
70 0x01, 0x21, 0x11, 0x31, 0x09, 0x29, 0x19, 0x39,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
71 0x05, 0x25, 0x15, 0x35, 0x0d, 0x2d, 0x1d, 0x3d,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
72 0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
73 0x07, 0x27, 0x17, 0x37, 0x0f, 0x2f, 0x1f, 0x3f};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
74
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
75 #ifdef HAVE_SSE
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
76 // NOTE: SSE needs 16byte alignment or it will segfault
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
77 static complex_t __attribute__((aligned(16))) buf[128];
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
78 static float __attribute__((aligned(16))) sseSinCos1a[256];
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
79 static float __attribute__((aligned(16))) sseSinCos1b[256];
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
80 static float __attribute__((aligned(16))) ps111_1[4]={1,1,1,-1};
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
81 //static float __attribute__((aligned(16))) sseW0[4];
3483390a902b sse opt
michael
parents: 3529
diff changeset
82 static float __attribute__((aligned(16))) sseW1[8];
3483390a902b sse opt
michael
parents: 3529
diff changeset
83 static float __attribute__((aligned(16))) sseW2[16];
3483390a902b sse opt
michael
parents: 3529
diff changeset
84 static float __attribute__((aligned(16))) sseW3[32];
3483390a902b sse opt
michael
parents: 3529
diff changeset
85 static float __attribute__((aligned(16))) sseW4[64];
3483390a902b sse opt
michael
parents: 3529
diff changeset
86 static float __attribute__((aligned(16))) sseW5[128];
3483390a902b sse opt
michael
parents: 3529
diff changeset
87 static float __attribute__((aligned(16))) sseW6[256];
3483390a902b sse opt
michael
parents: 3529
diff changeset
88 static float __attribute__((aligned(16))) *sseW[7]=
3483390a902b sse opt
michael
parents: 3529
diff changeset
89 {NULL /*sseW0*/,sseW1,sseW2,sseW3,sseW4,sseW5,sseW6};
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
90 static float __attribute__((aligned(16))) sseWindow[512];
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
91 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 static complex_t buf[128];
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
93 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
95 /* Twiddle factor LUT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
96 static complex_t w_1[1];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
97 static complex_t w_2[2];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
98 static complex_t w_4[4];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
99 static complex_t w_8[8];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
100 static complex_t w_16[16];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
101 static complex_t w_32[32];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
102 static complex_t w_64[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
103 static complex_t * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
104
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
105 /* Twiddle factors for IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
106 static sample_t xcos1[128];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
107 static sample_t xsin1[128];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
108 static sample_t xcos2[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
109 static sample_t xsin2[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
110
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
111 /* Windowing function for Modified DCT - Thank you acroread */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
112 sample_t imdct_window[] = {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
113 0.00014, 0.00024, 0.00037, 0.00051, 0.00067, 0.00086, 0.00107, 0.00130,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
114 0.00157, 0.00187, 0.00220, 0.00256, 0.00297, 0.00341, 0.00390, 0.00443,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
115 0.00501, 0.00564, 0.00632, 0.00706, 0.00785, 0.00871, 0.00962, 0.01061,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
116 0.01166, 0.01279, 0.01399, 0.01526, 0.01662, 0.01806, 0.01959, 0.02121,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117 0.02292, 0.02472, 0.02662, 0.02863, 0.03073, 0.03294, 0.03527, 0.03770,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
118 0.04025, 0.04292, 0.04571, 0.04862, 0.05165, 0.05481, 0.05810, 0.06153,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
119 0.06508, 0.06878, 0.07261, 0.07658, 0.08069, 0.08495, 0.08935, 0.09389,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
120 0.09859, 0.10343, 0.10842, 0.11356, 0.11885, 0.12429, 0.12988, 0.13563,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
121 0.14152, 0.14757, 0.15376, 0.16011, 0.16661, 0.17325, 0.18005, 0.18699,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
122 0.19407, 0.20130, 0.20867, 0.21618, 0.22382, 0.23161, 0.23952, 0.24757,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
123 0.25574, 0.26404, 0.27246, 0.28100, 0.28965, 0.29841, 0.30729, 0.31626,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
124 0.32533, 0.33450, 0.34376, 0.35311, 0.36253, 0.37204, 0.38161, 0.39126,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
125 0.40096, 0.41072, 0.42054, 0.43040, 0.44030, 0.45023, 0.46020, 0.47019,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
126 0.48020, 0.49022, 0.50025, 0.51028, 0.52031, 0.53033, 0.54033, 0.55031,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
127 0.56026, 0.57019, 0.58007, 0.58991, 0.59970, 0.60944, 0.61912, 0.62873,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
128 0.63827, 0.64774, 0.65713, 0.66643, 0.67564, 0.68476, 0.69377, 0.70269,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
129 0.71150, 0.72019, 0.72877, 0.73723, 0.74557, 0.75378, 0.76186, 0.76981,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
130 0.77762, 0.78530, 0.79283, 0.80022, 0.80747, 0.81457, 0.82151, 0.82831,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
131 0.83496, 0.84145, 0.84779, 0.85398, 0.86001, 0.86588, 0.87160, 0.87716,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
132 0.88257, 0.88782, 0.89291, 0.89785, 0.90264, 0.90728, 0.91176, 0.91610,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
133 0.92028, 0.92432, 0.92822, 0.93197, 0.93558, 0.93906, 0.94240, 0.94560,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
134 0.94867, 0.95162, 0.95444, 0.95713, 0.95971, 0.96217, 0.96451, 0.96674,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
135 0.96887, 0.97089, 0.97281, 0.97463, 0.97635, 0.97799, 0.97953, 0.98099,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
136 0.98236, 0.98366, 0.98488, 0.98602, 0.98710, 0.98811, 0.98905, 0.98994,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
137 0.99076, 0.99153, 0.99225, 0.99291, 0.99353, 0.99411, 0.99464, 0.99513,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
138 0.99558, 0.99600, 0.99639, 0.99674, 0.99706, 0.99736, 0.99763, 0.99788,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
139 0.99811, 0.99831, 0.99850, 0.99867, 0.99882, 0.99895, 0.99908, 0.99919,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
140 0.99929, 0.99938, 0.99946, 0.99953, 0.99959, 0.99965, 0.99969, 0.99974,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
141 0.99978, 0.99981, 0.99984, 0.99986, 0.99988, 0.99990, 0.99992, 0.99993,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
142 0.99994, 0.99995, 0.99996, 0.99997, 0.99998, 0.99998, 0.99998, 0.99999,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
143 0.99999, 0.99999, 0.99999, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
144 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000 };
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
145
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
146
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
147 static inline void swap_cmplx(complex_t *a, complex_t *b)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
148 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
149 complex_t tmp;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
150
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
151 tmp = *a;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
152 *a = *b;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153 *b = tmp;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
154 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
155
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
156
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
157
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
158 static inline complex_t cmplx_mult(complex_t a, complex_t b)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
159 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
160 complex_t ret;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
161
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
162 ret.real = a.real * b.real - a.imag * b.imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
163 ret.imag = a.real * b.imag + a.imag * b.real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
164
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
165 return ret;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
166 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
167
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168 void
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
169 imdct_do_512(sample_t data[],sample_t delay[], sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
171 int i,k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172 int p,q;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
173 int m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
174 int two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
175 int two_m_plus_one;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
176
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
177 sample_t tmp_a_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
178 sample_t tmp_a_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
179 sample_t tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
180 sample_t tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
181
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
182 sample_t *data_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
183 sample_t *delay_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
184 sample_t *window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
185
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
186 /* 512 IMDCT with source and dest data in 'data' */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
187
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
188 #ifdef HAVE_SSE
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
189 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
190 /* Bit reversed shuffling */
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
191 asm volatile(
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
192 "xorl %%esi, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
193 "leal bit_reverse_512, %%eax \n\t"
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
194 "movl $1008, %%edi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
195 "pushl %%ebp \n\t" //use ebp without telling gcc
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
196 ".balign 16 \n\t"
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
197 "1: \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
198 "movaps (%0, %%esi), %%xmm0 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
199 "movaps (%0, %%edi), %%xmm1 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
200 "shufps $0xA0, %%xmm0, %%xmm0 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
201 "shufps $0x5F, %%xmm1, %%xmm1 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
202 "mulps sseSinCos1a(%%esi), %%xmm0 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
203 "mulps sseSinCos1b(%%esi), %%xmm1 \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
204 "addps %%xmm1, %%xmm0 \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
205 "movzbl (%%eax), %%edx \n\t"
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
206 "movzbl 1(%%eax), %%ebp \n\t"
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
207 "movlps %%xmm0, (%1, %%edx,8) \n\t"
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
208 "movhps %%xmm0, (%1, %%ebp,8) \n\t"
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
209 "addl $16, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
210 "addl $2, %%eax \n\t" // avoid complex addressing for P4 crap
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
211 "subl $16, %%edi \n\t"
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
212 " jnc 1b \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
213 "popl %%ebp \n\t"//no we didnt touch ebp *g*
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
214 :: "b" (data), "c" (buf)
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
215 : "%esi", "%edi", "%eax", "%edx"
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
216 );
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
217 #else
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
218 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
219 for( i=0; i < 128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
220 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
221 buf[i].real = (data[256-2*i-1] * xcos1[i]) - (data[2*i] * xsin1[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
222 buf[i].imag = -1.0 * ((data[2*i] * xcos1[i]) + (data[256-2*i-1] * xsin1[i]));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
223 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
224
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
225 /* Bit reversed shuffling */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
226 for(i=0; i<128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
227 k = bit_reverse_512[i];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
228 if (k < i)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
229 swap_cmplx(&buf[i],&buf[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
230 }
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
231 #endif
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
232
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
233
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
234 /* FFT Merge */
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
235 /* unoptimized variant
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
236 for (m=1; m < 7; m++) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
237 if(m)
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
238 two_m = (1 << m);
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
239 else
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
240 two_m = 1;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
241
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
242 two_m_plus_one = (1 << (m+1));
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
243
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
244 for(i = 0; i < 128; i += two_m_plus_one) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
245 for(k = 0; k < two_m; k++) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
246 p = k + i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
247 q = p + two_m;
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
248 tmp_a_r = buf[p].real;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
249 tmp_a_i = buf[p].imag;
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
250 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
251 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
252 buf[p].real = tmp_a_r + tmp_b_r;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
253 buf[p].imag = tmp_a_i + tmp_b_i;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
254 buf[q].real = tmp_a_r - tmp_b_r;
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
255 buf[q].imag = tmp_a_i - tmp_b_i;
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
256 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
257 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
258 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
259 */
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
260
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
261 #ifdef HAVE_SSE
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
262 // Note w[0][0]={1,0}
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
263 asm volatile(
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
264 "xorps %%xmm1, %%xmm1 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
265 "xorps %%xmm2, %%xmm2 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
266 "movl %0, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
267 ".balign 16 \n\t"
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
268 "1: \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
269 "movlps (%%esi), %%xmm0 \n\t" //buf[p]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
270 "movlps 8(%%esi), %%xmm1\n\t" //buf[q]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
271 "movhps (%%esi), %%xmm0 \n\t" //buf[p]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
272 "movhps 8(%%esi), %%xmm2\n\t" //buf[q]
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
273 "addps %%xmm1, %%xmm0 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
274 "subps %%xmm2, %%xmm0 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
275 "movaps %%xmm0, (%%esi) \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
276 "addl $16, %%esi \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
277 "cmpl %1, %%esi \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
278 " jb 1b \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
279 :: "g" (buf), "r" (buf + 128)
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
280 : "%esi"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
281 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
282 #else
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
283 for(i = 0; i < 128; i += 2) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
284 tmp_a_r = buf[i].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
285 tmp_a_i = buf[i].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
286 tmp_b_r = buf[i+1].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
287 tmp_b_i = buf[i+1].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
288 buf[i].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
289 buf[i].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
290 buf[i+1].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
291 buf[i+1].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
292 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
293 #endif
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
294
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
295 // Note w[1]={{1,0}, {0,-1}}
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
296 #ifdef HAVE_SSE
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
297 asm volatile(
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
298 "movaps ps111_1, %%xmm7 \n\t" // 1,1,1,-1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
299 "movl %0, %%esi \n\t"
3529
a86166b495a6 sse opt
michael
parents: 3527
diff changeset
300 ".balign 16 \n\t"
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
301 "1: \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
302 "movaps 16(%%esi), %%xmm2 \n\t" //r2,i2,r3,i3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
303 "shufps $0xB4, %%xmm2, %%xmm2 \n\t" //r2,i2,i3,r3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
304 "mulps %%xmm7, %%xmm2 \n\t" //r2,i2,i3,-r3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
305 "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
306 "movaps (%%esi), %%xmm1 \n\t" //r0,i0,r1,i1
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
307 "addps %%xmm2, %%xmm0 \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
308 "subps %%xmm2, %%xmm1 \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
309 "movaps %%xmm0, (%%esi) \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
310 "movaps %%xmm1, 16(%%esi) \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
311 "addl $32, %%esi \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
312 "cmpl %1, %%esi \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
313 " jb 1b \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
314 :: "g" (buf), "r" (buf + 128)
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
315 : "%esi"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
316 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
317 #else
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
318 for(i = 0; i < 128; i += 4) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
319 tmp_a_r = buf[i].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
320 tmp_a_i = buf[i].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
321 tmp_b_r = buf[i+2].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
322 tmp_b_i = buf[i+2].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
323 buf[i].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
324 buf[i].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
325 buf[i+2].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
326 buf[i+2].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
327 tmp_a_r = buf[i+1].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
328 tmp_a_i = buf[i+1].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
329 tmp_b_r = buf[i+3].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
330 tmp_b_i = buf[i+3].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
331 buf[i+1].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
332 buf[i+1].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
333 buf[i+3].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
334 buf[i+3].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
335 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
336 #endif
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
337
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
338 #ifdef HAVE_SSE
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
339 /*
3483390a902b sse opt
michael
parents: 3529
diff changeset
340 Note sseW2+0={1,1,sqrt(2),sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
341 Note sseW2+16={0,0,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
342 Note sseW2+32={0,0,-sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
343 Note sseW2+48={1,-1,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
344 */
3483390a902b sse opt
michael
parents: 3529
diff changeset
345 asm volatile(
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
346 "movaps 48+sseW2, %%xmm6 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
347 "movaps 16+sseW2, %%xmm7 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
348 "xorps %%xmm5, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
349 "xorps %%xmm2, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
350 "movl %0, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
351 ".balign 16 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
352 "1: \n\t"
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
353 "movaps 32(%%esi), %%xmm2 \n\t" //r4,i4,r5,i5
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
354 "movaps 48(%%esi), %%xmm3 \n\t" //r6,i6,r7,i7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
355 "movaps sseW2, %%xmm4 \n\t" //r4,i4,r5,i5
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
356 "movaps 32+sseW2, %%xmm5 \n\t" //r6,i6,r7,i7
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
357 "mulps %%xmm2, %%xmm4 \n\t"
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
358 "mulps %%xmm3, %%xmm5 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
359 "shufps $0xB1, %%xmm2, %%xmm2 \n\t" //i4,r4,i5,r5
3483390a902b sse opt
michael
parents: 3529
diff changeset
360 "shufps $0xB1, %%xmm3, %%xmm3 \n\t" //i6,r6,i7,r7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
361 "mulps %%xmm6, %%xmm3 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
362 "mulps %%xmm7, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
363 "movaps (%%esi), %%xmm0 \n\t" //r0,i0,r1,i1
3483390a902b sse opt
michael
parents: 3529
diff changeset
364 "movaps 16(%%esi), %%xmm1 \n\t" //r2,i2,r3,i3
3483390a902b sse opt
michael
parents: 3529
diff changeset
365 "addps %%xmm4, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
366 "addps %%xmm5, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
367 "movaps %%xmm2, %%xmm4 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
368 "movaps %%xmm3, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
369 "addps %%xmm0, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
370 "addps %%xmm1, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
371 "subps %%xmm4, %%xmm0 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
372 "subps %%xmm5, %%xmm1 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
373 "movaps %%xmm2, (%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
374 "movaps %%xmm3, 16(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
375 "movaps %%xmm0, 32(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
376 "movaps %%xmm1, 48(%%esi) \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
377 "addl $64, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
378 "cmpl %1, %%esi \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
379 " jb 1b \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
380 :: "g" (buf), "r" (buf + 128)
3483390a902b sse opt
michael
parents: 3529
diff changeset
381 : "%esi"
3483390a902b sse opt
michael
parents: 3529
diff changeset
382 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
383 #else
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
384 for(i = 0; i < 128; i += 8) {
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
385 tmp_a_r = buf[i].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
386 tmp_a_i = buf[i].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
387 tmp_b_r = buf[i+4].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
388 tmp_b_i = buf[i+4].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
389 buf[i].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
390 buf[i].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
391 buf[i+4].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
392 buf[i+4].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
393 tmp_a_r = buf[1+i].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
394 tmp_a_i = buf[1+i].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
395 tmp_b_r = (buf[i+5].real + buf[i+5].imag) * w[2][1].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
396 tmp_b_i = (buf[i+5].imag - buf[i+5].real) * w[2][1].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
397 buf[1+i].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
398 buf[1+i].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
399 buf[i+5].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
400 buf[i+5].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
401 tmp_a_r = buf[i+2].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
402 tmp_a_i = buf[i+2].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
403 tmp_b_r = buf[i+6].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
404 tmp_b_i = - buf[i+6].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
405 buf[i+2].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
406 buf[i+2].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
407 buf[i+6].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
408 buf[i+6].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
409 tmp_a_r = buf[i+3].real;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
410 tmp_a_i = buf[i+3].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
411 tmp_b_r = (buf[i+7].real - buf[i+7].imag) * w[2][3].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
412 tmp_b_i = (buf[i+7].imag + buf[i+7].real) * w[2][3].imag;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
413 buf[i+3].real = tmp_a_r + tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
414 buf[i+3].imag = tmp_a_i + tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
415 buf[i+7].real = tmp_a_r - tmp_b_r;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
416 buf[i+7].imag = tmp_a_i - tmp_b_i;
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
417 }
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
418 #endif
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
419
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
420 #ifdef HAVE_SSE
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
421 for (m=3; m < 7; m++) {
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
422 two_m = (1 << m);
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
423 two_m_plus_one = two_m<<1;
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
424 asm volatile(
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
425 "movl %0, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
426 ".balign 16 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
427 "1: \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
428 "xorl %%edi, %%edi \n\t" // k
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
429 "leal (%%esi, %3), %%edx \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
430 "2: \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
431 "movaps (%%edx, %%edi), %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
432 "movaps (%4, %%edi, 2), %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
433 "mulps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
434 "shufps $0xB1, %%xmm1, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
435 "mulps 16(%4, %%edi, 2), %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
436 "movaps (%%esi, %%edi), %%xmm0 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
437 "addps %%xmm2, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
438 "movaps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
439 "addps %%xmm0, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
440 "subps %%xmm2, %%xmm0 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
441 "movaps %%xmm1, (%%esi, %%edi) \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
442 "movaps %%xmm0, (%%edx, %%edi) \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
443 "addl $16, %%edi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
444 "cmpl %3, %%edi \n\t" //FIXME (opt) count against 0
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
445 " jb 2b \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
446 "addl %2, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
447 "cmpl %1, %%esi \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
448 " jb 1b \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
449 :: "g" (buf), "m" (buf+128), "m" (two_m_plus_one<<3), "r" (two_m<<3),
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
450 "r" (sseW[m])
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
451 : "%esi", "%edi", "%edx"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
452 );
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
453 }
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
454
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
455 #else
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
456 for (m=3; m < 7; m++) {
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
457 two_m = (1 << m);
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
458
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
459 two_m_plus_one = two_m<<1;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
460
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
461 for(i = 0; i < 128; i += two_m_plus_one) {
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
462 for(k = 0; k < two_m; k++) {
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
463 int p = k + i;
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
464 int q = p + two_m;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
465 tmp_a_r = buf[p].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
466 tmp_a_i = buf[p].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
467 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
468 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
469 buf[p].real = tmp_a_r + tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
470 buf[p].imag = tmp_a_i + tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
471 buf[q].real = tmp_a_r - tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
472 buf[q].imag = tmp_a_i - tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
473 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
474 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
475 }
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
476 #endif
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
477
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
478 /* Post IFFT complex multiply plus IFFT complex conjugate*/
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
479 for( i=0; i < 128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
480 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
481 tmp_a_r = buf[i].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
482 tmp_a_i = -1.0 * buf[i].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
483 buf[i].real =(tmp_a_r * xcos1[i]) - (tmp_a_i * xsin1[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
484 buf[i].imag =(tmp_a_r * xsin1[i]) + (tmp_a_i * xcos1[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
485 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
486
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
487 data_ptr = data;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
488 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
489 window_ptr = imdct_window;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
490
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
491 /* Window and convert to real valued signal */
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
492 #ifdef HAVE_SSE
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
493 asm volatile(
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
494 "xorl %%edi, %%edi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
495 "xorl %%esi, %%esi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
496 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
497 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
498 ".balign 16 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
499 "1: \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
500 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
501 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
502 "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
503 "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ?
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
504 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
505 "mulps sseWindow(%%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
506 "addps (%2, %%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
507 "addps %%xmm2, %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
508 "movaps %%xmm0, (%1, %%esi) \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
509 "addl $16, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
510 "subl $16, %%edi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
511 "cmpl $512, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
512 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
513 :: "r" (buf+64), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
514 : "%esi", "%edi"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
515 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
516 data_ptr+=128;
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
517 delay_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
518 // window_ptr+=128;
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
519 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
520 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
521 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
522 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
523 }
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
524 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
525
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
526 #ifdef HAVE_SSE
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
527 asm volatile(
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
528 "movl $1024, %%edi \n\t" // 512
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
529 "xorl %%esi, %%esi \n\t" // 0
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
530 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
531 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
532 ".balign 16 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
533 "1: \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
534 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
535 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
536 "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
537 "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
538 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
539 "mulps 512+sseWindow(%%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
540 "addps (%2, %%esi), %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
541 "addps %%xmm2, %%xmm0 \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
542 "movaps %%xmm0, (%1, %%esi) \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
543 "addl $16, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
544 "subl $16, %%edi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
545 "cmpl $512, %%esi \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
546 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
547 :: "r" (buf), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
548 : "%esi", "%edi"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
549 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
550 data_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
551 // window_ptr+=128;
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
552 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
553 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
554 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
555 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
556 }
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
557 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
558
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
559 /* The trailing edge of the window goes into the delay line */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
560 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
561
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
562 #ifdef HAVE_SSE
a501627fc6db sse opt
michael
parents: 3552
diff changeset
563 asm volatile(
a501627fc6db sse opt
michael
parents: 3552
diff changeset
564 "xorl %%edi, %%edi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
565 "xorl %%esi, %%esi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
566 ".balign 16 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
567 "1: \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
568 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? ? A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
569 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? ? C
a501627fc6db sse opt
michael
parents: 3552
diff changeset
570 "movhps -16(%0, %%edi), %%xmm1 \n\t" // D ? ? C
a501627fc6db sse opt
michael
parents: 3552
diff changeset
571 "movhps -8(%0, %%edi), %%xmm0 \n\t" // B ? ? A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
572 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
573 "mulps 1024+sseWindow(%%esi), %%xmm0 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
574 "movaps %%xmm0, (%1, %%esi) \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
575 "addl $16, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
576 "subl $16, %%edi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
577 "cmpl $512, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
578 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
579 :: "r" (buf+64), "r" (delay_ptr)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
580 : "%esi", "%edi"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
581 );
a501627fc6db sse opt
michael
parents: 3552
diff changeset
582 delay_ptr+=128;
a501627fc6db sse opt
michael
parents: 3552
diff changeset
583 // window_ptr-=128;
a501627fc6db sse opt
michael
parents: 3552
diff changeset
584 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
585 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
586 *delay_ptr++ = -buf[64+i].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
587 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
588 }
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
589 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
590
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
591 #ifdef HAVE_SSE
a501627fc6db sse opt
michael
parents: 3552
diff changeset
592 asm volatile(
a501627fc6db sse opt
michael
parents: 3552
diff changeset
593 "movl $1024, %%edi \n\t" // 1024
a501627fc6db sse opt
michael
parents: 3552
diff changeset
594 "xorl %%esi, %%esi \n\t" // 0
a501627fc6db sse opt
michael
parents: 3552
diff changeset
595 ".balign 16 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
596 "1: \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
597 "movlps (%0, %%esi), %%xmm0 \n\t" // ? ? A ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
598 "movlps 8(%0, %%esi), %%xmm1 \n\t" // ? ? C ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
599 "movhps -16(%0, %%edi), %%xmm1 \n\t" // ? D C ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
600 "movhps -8(%0, %%edi), %%xmm0 \n\t" // ? B A ?
a501627fc6db sse opt
michael
parents: 3552
diff changeset
601 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
a501627fc6db sse opt
michael
parents: 3552
diff changeset
602 "mulps 1536+sseWindow(%%esi), %%xmm0 \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
603 "movaps %%xmm0, (%1, %%esi) \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
604 "addl $16, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
605 "subl $16, %%edi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
606 "cmpl $512, %%esi \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
607 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
608 :: "r" (buf), "r" (delay_ptr)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
609 : "%esi", "%edi"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
610 );
a501627fc6db sse opt
michael
parents: 3552
diff changeset
611 #else
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
612 for(i=0; i<64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
613 *delay_ptr++ = buf[i].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
614 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
615 }
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
616 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
617 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
618
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
619 void
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
620 imdct_do_256(sample_t data[],sample_t delay[],sample_t bias)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
621 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
622 int i,k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
623 int p,q;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
624 int m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
625 int two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
626 int two_m_plus_one;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
627
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
628 sample_t tmp_a_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
629 sample_t tmp_a_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
630 sample_t tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
631 sample_t tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
632
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
633 sample_t *data_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
634 sample_t *delay_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
635 sample_t *window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
636
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
637 complex_t *buf_1, *buf_2;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
638
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
639 buf_1 = &buf[0];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
640 buf_2 = &buf[64];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
641
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
642 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
643 for(k=0; k<64; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
644 /* X1[k] = X[2*k] */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
645 /* X2[k] = X[2*k+1] */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
646
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
647 p = 2 * (128-2*k-1);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
648 q = 2 * (2 * k);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
649
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
650 /* Z1[k] = (X1[128-2*k-1] + j * X1[2*k]) * (xcos2[k] + j * xsin2[k]); */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
651 buf_1[k].real = data[p] * xcos2[k] - data[q] * xsin2[k];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
652 buf_1[k].imag = -1.0f * (data[q] * xcos2[k] + data[p] * xsin2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
653 /* Z2[k] = (X2[128-2*k-1] + j * X2[2*k]) * (xcos2[k] + j * xsin2[k]); */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
654 buf_2[k].real = data[p + 1] * xcos2[k] - data[q + 1] * xsin2[k];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
655 buf_2[k].imag = -1.0f * ( data[q + 1] * xcos2[k] + data[p + 1] * xsin2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
656 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
657
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
658 /* IFFT Bit reversed shuffling */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
659 for(i=0; i<64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
660 k = bit_reverse_256[i];
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
661 if (k < i) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
662 swap_cmplx(&buf_1[i],&buf_1[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
663 swap_cmplx(&buf_2[i],&buf_2[k]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
664 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
665 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
666
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
667 /* FFT Merge */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
668 for (m=0; m < 6; m++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
669 two_m = (1 << m);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
670 two_m_plus_one = (1 << (m+1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
671
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
672 /* FIXME */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
673 if(m)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
674 two_m = (1 << m);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
675 else
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
676 two_m = 1;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
677
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
678 for(k = 0; k < two_m; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
679 for(i = 0; i < 64; i += two_m_plus_one) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
680 p = k + i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
681 q = p + two_m;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
682 /* Do block 1 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
683 tmp_a_r = buf_1[p].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
684 tmp_a_i = buf_1[p].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
685 tmp_b_r = buf_1[q].real * w[m][k].real - buf_1[q].imag * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
686 tmp_b_i = buf_1[q].imag * w[m][k].real + buf_1[q].real * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
687 buf_1[p].real = tmp_a_r + tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
688 buf_1[p].imag = tmp_a_i + tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
689 buf_1[q].real = tmp_a_r - tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
690 buf_1[q].imag = tmp_a_i - tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
691
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
692 /* Do block 2 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
693 tmp_a_r = buf_2[p].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
694 tmp_a_i = buf_2[p].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
695 tmp_b_r = buf_2[q].real * w[m][k].real - buf_2[q].imag * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
696 tmp_b_i = buf_2[q].imag * w[m][k].real + buf_2[q].real * w[m][k].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
697 buf_2[p].real = tmp_a_r + tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
698 buf_2[p].imag = tmp_a_i + tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
699 buf_2[q].real = tmp_a_r - tmp_b_r;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
700 buf_2[q].imag = tmp_a_i - tmp_b_i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
701 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
702 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
703 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
704
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
705 /* Post IFFT complex multiply */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
706 for( i=0; i < 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
707 /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
708 tmp_a_r = buf_1[i].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
709 tmp_a_i = -buf_1[i].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
710 buf_1[i].real =(tmp_a_r * xcos2[i]) - (tmp_a_i * xsin2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
711 buf_1[i].imag =(tmp_a_r * xsin2[i]) + (tmp_a_i * xcos2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
712 /* y2[n] = z2[n] * (xcos2[n] + j * xsin2[n]) ; */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
713 tmp_a_r = buf_2[i].real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
714 tmp_a_i = -buf_2[i].imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
715 buf_2[i].real =(tmp_a_r * xcos2[i]) - (tmp_a_i * xsin2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
716 buf_2[i].imag =(tmp_a_r * xsin2[i]) + (tmp_a_i * xcos2[i]);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
717 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
718
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
719 data_ptr = data;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
720 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
721 window_ptr = imdct_window;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
722
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
723 /* Window and convert to real valued signal */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
724 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
725 *data_ptr++ = -buf_1[i].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
726 *data_ptr++ = buf_1[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
727 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
728
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
729 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
730 *data_ptr++ = -buf_1[i].real * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
731 *data_ptr++ = buf_1[64-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
732 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
733
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
734 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
735
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
736 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
737 *delay_ptr++ = -buf_2[i].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
738 *delay_ptr++ = buf_2[64-i-1].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
739 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
740
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
741 for(i=0; i< 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
742 *delay_ptr++ = buf_2[i].imag * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
743 *delay_ptr++ = -buf_2[64-i-1].real * *--window_ptr;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
744 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
745 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
746
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
747 void imdct_init (uint32_t mm_accel)
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
748 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
749 #ifdef LIBA52_MLIB
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
750 if (mm_accel & MM_ACCEL_MLIB) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
751 fprintf (stderr, "Using mlib for IMDCT transform\n");
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
752 imdct_512 = imdct_do_512_mlib;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
753 imdct_256 = imdct_do_256_mlib;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
754 } else
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
755 #endif
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
756 {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
757 int i, j, k;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
758
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
759 fprintf (stderr, "No accelerated IMDCT transform found\n");
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
760
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
761 /* Twiddle factors to turn IFFT into IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
762 for (i = 0; i < 128; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
763 xcos1[i] = -cos ((M_PI / 2048) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
764 xsin1[i] = -sin ((M_PI / 2048) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
765 }
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
766 #ifdef HAVE_SSE
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
767 for (i = 0; i < 128; i++) {
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
768 sseSinCos1a[2*i+0]= -xsin1[i];
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
769 sseSinCos1a[2*i+1]= -xcos1[i];
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
770 sseSinCos1b[2*i+0]= xcos1[i];
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
771 sseSinCos1b[2*i+1]= -xsin1[i];
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
772 }
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
773 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
774
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
775 /* More twiddle factors to turn IFFT into IMDCT */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
776 for (i = 0; i < 64; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
777 xcos2[i] = -cos ((M_PI / 1024) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
778 xsin2[i] = -sin ((M_PI / 1024) * (8 * i + 1));
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
779 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
780
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
781 for (i = 0; i < 7; i++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
782 j = 1 << i;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
783 for (k = 0; k < j; k++) {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
784 w[i][k].real = cos (-M_PI * k / j);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
785 w[i][k].imag = sin (-M_PI * k / j);
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
786 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
787 }
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
788 #ifdef HAVE_SSE
3483390a902b sse opt
michael
parents: 3529
diff changeset
789 for (i = 1; i < 7; i++) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
790 j = 1 << i;
3483390a902b sse opt
michael
parents: 3529
diff changeset
791 for (k = 0; k < j; k+=2) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
792
3483390a902b sse opt
michael
parents: 3529
diff changeset
793 sseW[i][4*k + 0] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
794 sseW[i][4*k + 1] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
795 sseW[i][4*k + 2] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
796 sseW[i][4*k + 3] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
797
3483390a902b sse opt
michael
parents: 3529
diff changeset
798 sseW[i][4*k + 4] = -w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
799 sseW[i][4*k + 5] = w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
800 sseW[i][4*k + 6] = -w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
801 sseW[i][4*k + 7] = w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
802
3483390a902b sse opt
michael
parents: 3529
diff changeset
803 //we multiply more or less uninitalized numbers so we need to use exactly 0.0
3483390a902b sse opt
michael
parents: 3529
diff changeset
804 if(k==0)
3483390a902b sse opt
michael
parents: 3529
diff changeset
805 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
806 // sseW[i][4*k + 0]= sseW[i][4*k + 1]= 1.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
807 sseW[i][4*k + 4]= sseW[i][4*k + 5]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
808 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
809
3483390a902b sse opt
michael
parents: 3529
diff changeset
810 if(2*k == j)
3483390a902b sse opt
michael
parents: 3529
diff changeset
811 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
812 sseW[i][4*k + 0]= sseW[i][4*k + 1]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
813 // sseW[i][4*k + 4]= -(sseW[i][4*k + 5]= -1.0);
3483390a902b sse opt
michael
parents: 3529
diff changeset
814 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
815 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
816 }
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
817
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
818 for(i=0; i<128; i++)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
819 {
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
820 sseWindow[2*i+0]= -imdct_window[2*i+0];
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
821 sseWindow[2*i+1]= imdct_window[2*i+1];
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
822 }
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
823
a501627fc6db sse opt
michael
parents: 3552
diff changeset
824 for(i=0; i<64; i++)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
825 {
a501627fc6db sse opt
michael
parents: 3552
diff changeset
826 sseWindow[256 + 2*i+0]= -imdct_window[254 - 2*i+1];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
827 sseWindow[256 + 2*i+1]= imdct_window[254 - 2*i+0];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
828 sseWindow[384 + 2*i+0]= imdct_window[126 - 2*i+1];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
829 sseWindow[384 + 2*i+1]= -imdct_window[126 - 2*i+0];
a501627fc6db sse opt
michael
parents: 3552
diff changeset
830 }
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
831 #endif
3483390a902b sse opt
michael
parents: 3529
diff changeset
832
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
833 imdct_512 = imdct_do_512;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
834 imdct_256 = imdct_do_256;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
835 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
836 }