annotate liba52/imdct.c @ 19091:3e416bd2caed

raise default tuning timeout to 30 seconds in order to give enough time to less sensitive cards; better tuners won't tune slower
author nicodvb
date Fri, 14 Jul 2006 23:05:08 +0000
parents 0783dd397f74
children 6334c14b38eb
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
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
3 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
3394
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 *
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
6 * The ifft algorithms in this file have been largely inspired by Dan
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
7 * Bernstein's work, djbfft, available at http://cr.yp.to/djbfft.html
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
8 *
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
9 * This file is part of a52dec, a free ATSC A-52 stream decoder.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
10 * See http://liba52.sourceforge.net/ for updates.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
11 *
14991
07f1e7669772 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12303
diff changeset
12 * Modified for use with MPlayer, changes contained in liba52_changes.diff.
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18721
diff changeset
13 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
14991
07f1e7669772 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12303
diff changeset
14 * $Id$
07f1e7669772 Mark modified files as such to comply more closely with GPL ¡ø2a.
diego
parents: 12303
diff changeset
15 *
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
16 * a52dec is free software; you can redistribute it and/or modify
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
17 * it under the terms of the GNU General Public License as published by
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
18 * the Free Software Foundation; either version 2 of the License, or
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
19 * (at your option) any later version.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
20 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
21 * a52dec is distributed in the hope that it will be useful,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
24 * GNU General Public License for more details.
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
25 *
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
26 * You should have received a copy of the GNU General Public License
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
27 * along with this program; if not, write to the Free Software
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
29 *
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
30 * SSE optimizations from Michael Niedermayer (michaelni@gmx.at)
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
31 * 3DNOW optimizations from Nick Kurshev <nickols_k@mail.ru>
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
32 * michael did port them from libac3 (untested, perhaps totally broken)
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
33 * AltiVec optimizations from Romain Dolbeau (romain@dolbeau.org)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
34 */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
35
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
36 #include "config.h"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
37 #include "asmalign.h"
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
38
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
39 #include <math.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
40 #include <stdio.h>
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
41 #ifdef LIBA52_DJBFFT
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
42 #include <fftc4.h>
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
43 #endif
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
44 #ifndef M_PI
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
45 #define M_PI 3.1415926535897932384626433832795029
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
46 #endif
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
47 #include <inttypes.h>
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
48
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
49 #include "a52.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
50 #include "a52_internal.h"
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
51 #include "mm_accel.h"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
52 #include "mangle.h"
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
53
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
54 void (*a52_imdct_512) (sample_t * data, sample_t * delay, sample_t bias);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
55
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
56 #ifdef RUNTIME_CPUDETECT
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
57 #undef HAVE_3DNOWEX
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
58 #endif
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
59
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
60 typedef struct complex_s {
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
61 sample_t real;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
62 sample_t imag;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
63 } complex_t;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
64
12303
f881c918739b attribute_used patch by (VMiklos <mamajom at axelero dot hu>)
michael
parents: 9122
diff changeset
65 static const int pm128[128] attribute_used __attribute__((aligned(16))) =
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
66 {
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
67 0, 16, 32, 48, 64, 80, 96, 112, 8, 40, 72, 104, 24, 56, 88, 120,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
68 4, 20, 36, 52, 68, 84, 100, 116, 12, 28, 44, 60, 76, 92, 108, 124,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
69 2, 18, 34, 50, 66, 82, 98, 114, 10, 42, 74, 106, 26, 58, 90, 122,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
70 6, 22, 38, 54, 70, 86, 102, 118, 14, 46, 78, 110, 30, 62, 94, 126,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
71 1, 17, 33, 49, 65, 81, 97, 113, 9, 41, 73, 105, 25, 57, 89, 121,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
72 5, 21, 37, 53, 69, 85, 101, 117, 13, 29, 45, 61, 77, 93, 109, 125,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
73 3, 19, 35, 51, 67, 83, 99, 115, 11, 43, 75, 107, 27, 59, 91, 123,
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
74 7, 23, 39, 55, 71, 87, 103, 119, 15, 31, 47, 63, 79, 95, 111, 127
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
75 };
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
76
12303
f881c918739b attribute_used patch by (VMiklos <mamajom at axelero dot hu>)
michael
parents: 9122
diff changeset
77 static uint8_t attribute_used bit_reverse_512[] = {
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
78 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
79 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
80 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
81 0x0c, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
82 0x02, 0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
83 0x0a, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
84 0x06, 0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
85 0x0e, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
86 0x01, 0x41, 0x21, 0x61, 0x11, 0x51, 0x31, 0x71,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
87 0x09, 0x49, 0x29, 0x69, 0x19, 0x59, 0x39, 0x79,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
88 0x05, 0x45, 0x25, 0x65, 0x15, 0x55, 0x35, 0x75,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
89 0x0d, 0x4d, 0x2d, 0x6d, 0x1d, 0x5d, 0x3d, 0x7d,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
90 0x03, 0x43, 0x23, 0x63, 0x13, 0x53, 0x33, 0x73,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
91 0x0b, 0x4b, 0x2b, 0x6b, 0x1b, 0x5b, 0x3b, 0x7b,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
92 0x07, 0x47, 0x27, 0x67, 0x17, 0x57, 0x37, 0x77,
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
93 0x0f, 0x4f, 0x2f, 0x6f, 0x1f, 0x5f, 0x3f, 0x7f};
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
94
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
95 static uint8_t fftorder[] = {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
96 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
97 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
98 4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
99 252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
100 2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
101 10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
102 254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174,
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
103 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
104 };
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
105
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
106 static complex_t __attribute__((aligned(16))) buf[128];
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
107
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
108 /* Twiddle factor LUT */
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
109 static complex_t __attribute__((aligned(16))) w_1[1];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
110 static complex_t __attribute__((aligned(16))) w_2[2];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
111 static complex_t __attribute__((aligned(16))) w_4[4];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
112 static complex_t __attribute__((aligned(16))) w_8[8];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
113 static complex_t __attribute__((aligned(16))) w_16[16];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
114 static complex_t __attribute__((aligned(16))) w_32[32];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
115 static complex_t __attribute__((aligned(16))) w_64[64];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
116 static complex_t __attribute__((aligned(16))) * w[7] = {w_1, w_2, w_4, w_8, w_16, w_32, w_64};
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
117
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
118 /* Twiddle factors for IMDCT */
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
119 static sample_t __attribute__((aligned(16))) xcos1[128];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
120 static sample_t __attribute__((aligned(16))) xsin1[128];
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
121
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
122 #if defined(ARCH_X86) || defined(ARCH_X86_64)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
123 // NOTE: SSE needs 16byte alignment or it will segfault
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
124 //
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
125 static float __attribute__((aligned(16))) sseSinCos1c[256];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
126 static float __attribute__((aligned(16))) sseSinCos1d[256];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
127 static float attribute_used __attribute__((aligned(16))) ps111_1[4]={1,1,1,-1};
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
128 //static float __attribute__((aligned(16))) sseW0[4];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
129 static float __attribute__((aligned(16))) sseW1[8];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
130 static float __attribute__((aligned(16))) sseW2[16];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
131 static float __attribute__((aligned(16))) sseW3[32];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
132 static float __attribute__((aligned(16))) sseW4[64];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
133 static float __attribute__((aligned(16))) sseW5[128];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
134 static float __attribute__((aligned(16))) sseW6[256];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
135 static float __attribute__((aligned(16))) *sseW[7]=
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
136 {NULL /*sseW0*/,sseW1,sseW2,sseW3,sseW4,sseW5,sseW6};
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
137 static float __attribute__((aligned(16))) sseWindow[512];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
138 #endif
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
139
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
140 /* Root values for IFFT */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
141 static sample_t roots16[3];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
142 static sample_t roots32[7];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
143 static sample_t roots64[15];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
144 static sample_t roots128[31];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
145
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
146 /* Twiddle factors for IMDCT */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
147 static complex_t pre1[128];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
148 static complex_t post1[64];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
149 static complex_t pre2[64];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
150 static complex_t post2[32];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
151
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
152 static sample_t a52_imdct_window[256];
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
153
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
154 static void (* ifft128) (complex_t * buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
155 static void (* ifft64) (complex_t * buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
156
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
157 static inline void ifft2 (complex_t * buf)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
158 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
159 double r, i;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
160
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
161 r = buf[0].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
162 i = buf[0].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
163 buf[0].real += buf[1].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
164 buf[0].imag += buf[1].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
165 buf[1].real = r - buf[1].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
166 buf[1].imag = i - buf[1].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
167 }
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
168
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
169 static inline void ifft4 (complex_t * buf)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
170 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
171 double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
172
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
173 tmp1 = buf[0].real + buf[1].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
174 tmp2 = buf[3].real + buf[2].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
175 tmp3 = buf[0].imag + buf[1].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
176 tmp4 = buf[2].imag + buf[3].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
177 tmp5 = buf[0].real - buf[1].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
178 tmp6 = buf[0].imag - buf[1].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
179 tmp7 = buf[2].imag - buf[3].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
180 tmp8 = buf[3].real - buf[2].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
181
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
182 buf[0].real = tmp1 + tmp2;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
183 buf[0].imag = tmp3 + tmp4;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
184 buf[2].real = tmp1 - tmp2;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
185 buf[2].imag = tmp3 - tmp4;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
186 buf[1].real = tmp5 + tmp7;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
187 buf[1].imag = tmp6 + tmp8;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
188 buf[3].real = tmp5 - tmp7;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
189 buf[3].imag = tmp6 - tmp8;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
190 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
191
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
192 /* the basic split-radix ifft butterfly */
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
193
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
194 #define BUTTERFLY(a0,a1,a2,a3,wr,wi) do { \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
195 tmp5 = a2.real * wr + a2.imag * wi; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
196 tmp6 = a2.imag * wr - a2.real * wi; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
197 tmp7 = a3.real * wr - a3.imag * wi; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
198 tmp8 = a3.imag * wr + a3.real * wi; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
199 tmp1 = tmp5 + tmp7; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
200 tmp2 = tmp6 + tmp8; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
201 tmp3 = tmp6 - tmp8; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
202 tmp4 = tmp7 - tmp5; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
203 a2.real = a0.real - tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
204 a2.imag = a0.imag - tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
205 a3.real = a1.real - tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
206 a3.imag = a1.imag - tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
207 a0.real += tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
208 a0.imag += tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
209 a1.real += tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
210 a1.imag += tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
211 } while (0)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
212
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
213 /* split-radix ifft butterfly, specialized for wr=1 wi=0 */
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
214
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
215 #define BUTTERFLY_ZERO(a0,a1,a2,a3) do { \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
216 tmp1 = a2.real + a3.real; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
217 tmp2 = a2.imag + a3.imag; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
218 tmp3 = a2.imag - a3.imag; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
219 tmp4 = a3.real - a2.real; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
220 a2.real = a0.real - tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
221 a2.imag = a0.imag - tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
222 a3.real = a1.real - tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
223 a3.imag = a1.imag - tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
224 a0.real += tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
225 a0.imag += tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
226 a1.real += tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
227 a1.imag += tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
228 } while (0)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
229
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
230 /* split-radix ifft butterfly, specialized for wr=wi */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
231
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
232 #define BUTTERFLY_HALF(a0,a1,a2,a3,w) do { \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
233 tmp5 = (a2.real + a2.imag) * w; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
234 tmp6 = (a2.imag - a2.real) * w; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
235 tmp7 = (a3.real - a3.imag) * w; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
236 tmp8 = (a3.imag + a3.real) * w; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
237 tmp1 = tmp5 + tmp7; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
238 tmp2 = tmp6 + tmp8; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
239 tmp3 = tmp6 - tmp8; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
240 tmp4 = tmp7 - tmp5; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
241 a2.real = a0.real - tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
242 a2.imag = a0.imag - tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
243 a3.real = a1.real - tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
244 a3.imag = a1.imag - tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
245 a0.real += tmp1; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
246 a0.imag += tmp2; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
247 a1.real += tmp3; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
248 a1.imag += tmp4; \
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
249 } while (0)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
250
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
251 static inline void ifft8 (complex_t * buf)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
252 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
253 double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
254
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
255 ifft4 (buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
256 ifft2 (buf + 4);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
257 ifft2 (buf + 6);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
258 BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
259 BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]);
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
260 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
261
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
262 static void ifft_pass (complex_t * buf, sample_t * weight, int n)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
263 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
264 complex_t * buf1;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
265 complex_t * buf2;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
266 complex_t * buf3;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
267 double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
8254
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 4497
diff changeset
268 int i;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
269
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
270 buf++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
271 buf1 = buf + n;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
272 buf2 = buf + 2 * n;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
273 buf3 = buf + 3 * n;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
274
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
275 BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
276
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
277 i = n - 1;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
278
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
279 do {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
280 BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0], weight[n], weight[2*i]);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
281 buf++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
282 buf1++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
283 buf2++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
284 buf3++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
285 weight++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
286 } while (--i);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
287 }
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
288
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
289 static void ifft16 (complex_t * buf)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
290 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
291 ifft8 (buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
292 ifft4 (buf + 8);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
293 ifft4 (buf + 12);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
294 ifft_pass (buf, roots16 - 4, 4);
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
295 }
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
296
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
297 static void ifft32 (complex_t * buf)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
298 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
299 ifft16 (buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
300 ifft8 (buf + 16);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
301 ifft8 (buf + 24);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
302 ifft_pass (buf, roots32 - 8, 8);
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
303 }
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
304
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
305 static void ifft64_c (complex_t * buf)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
306 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
307 ifft32 (buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
308 ifft16 (buf + 32);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
309 ifft16 (buf + 48);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
310 ifft_pass (buf, roots64 - 16, 16);
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
311 }
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
312
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
313 static void ifft128_c (complex_t * buf)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
314 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
315 ifft32 (buf);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
316 ifft16 (buf + 32);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
317 ifft16 (buf + 48);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
318 ifft_pass (buf, roots64 - 16, 16);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
319
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
320 ifft32 (buf + 64);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
321 ifft32 (buf + 96);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
322 ifft_pass (buf, roots128 - 32, 32);
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
323 }
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
324
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
325 void imdct_do_512 (sample_t * data, sample_t * delay, sample_t bias)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
326 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
327 int i, k;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
328 sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
329 const sample_t * window = a52_imdct_window;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
330 complex_t buf[128];
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
331
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
332 for (i = 0; i < 128; i++) {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
333 k = fftorder[i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
334 t_r = pre1[i].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
335 t_i = pre1[i].imag;
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
336
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
337 buf[i].real = t_i * data[255-k] + t_r * data[k];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
338 buf[i].imag = t_r * data[255-k] - t_i * data[k];
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
339 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
340
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
341 ifft128 (buf);
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
342
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
343 /* Post IFFT complex multiply plus IFFT complex conjugate*/
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
344 /* Window and convert to real valued signal */
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
345 for (i = 0; i < 64; i++) {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
346 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
347 t_r = post1[i].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
348 t_i = post1[i].imag;
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
349
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
350 a_r = t_r * buf[i].real + t_i * buf[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
351 a_i = t_i * buf[i].real - t_r * buf[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
352 b_r = t_i * buf[127-i].real + t_r * buf[127-i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
353 b_i = t_r * buf[127-i].real - t_i * buf[127-i].imag;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
354
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
355 w_1 = window[2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
356 w_2 = window[255-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
357 data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
358 data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
359 delay[2*i] = a_i;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
360
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
361 w_1 = window[2*i+1];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
362 w_2 = window[254-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
363 data[2*i+1] = delay[2*i+1] * w_2 + b_r * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
364 data[254-2*i] = delay[2*i+1] * w_1 - b_r * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
365 delay[2*i+1] = b_i;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
366 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
367 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
368
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
369 #ifdef HAVE_ALTIVEC
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
370
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
371 #ifndef SYS_DARWIN
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
372 #include <altivec.h>
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
373 #endif
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
374
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
375 // used to build registers permutation vectors (vcprm)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
376 // the 's' are for words in the _s_econd vector
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
377 #define WORD_0 0x00,0x01,0x02,0x03
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
378 #define WORD_1 0x04,0x05,0x06,0x07
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
379 #define WORD_2 0x08,0x09,0x0a,0x0b
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
380 #define WORD_3 0x0c,0x0d,0x0e,0x0f
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
381 #define WORD_s0 0x10,0x11,0x12,0x13
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
382 #define WORD_s1 0x14,0x15,0x16,0x17
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
383 #define WORD_s2 0x18,0x19,0x1a,0x1b
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
384 #define WORD_s3 0x1c,0x1d,0x1e,0x1f
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
385
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
386 #ifdef SYS_DARWIN
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
387 #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d)
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
388 #else
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
389 #define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d}
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
390 #endif
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
391
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
392 // vcprmle is used to keep the same index as in the SSE version.
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
393 // it's the same as vcprm, with the index inversed
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
394 // ('le' is Little Endian)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
395 #define vcprmle(a,b,c,d) vcprm(d,c,b,a)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
396
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
397 // used to build inverse/identity vectors (vcii)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
398 // n is _n_egative, p is _p_ositive
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
399 #define FLOAT_n -1.
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
400 #define FLOAT_p 1.
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
401
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
402 #ifdef SYS_DARWIN
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
403 #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d)
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
404 #else
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
405 #define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d}
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
406 #endif
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
407
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
408 #ifdef SYS_DARWIN
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
409 #define FOUROF(a) (a)
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
410 #else
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
411 #define FOUROF(a) {a,a,a,a}
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
412 #endif
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
413
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
414
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
415 void
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
416 imdct_do_512_altivec(sample_t data[],sample_t delay[], sample_t bias)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
417 {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
418 int i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
419 int k;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
420 int p,q;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
421 int m;
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
422 long two_m;
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
423 long two_m_plus_one;
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
424
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
425 sample_t tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
426 sample_t tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
427 sample_t tmp_a_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
428 sample_t tmp_a_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
429
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
430 sample_t *data_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
431 sample_t *delay_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
432 sample_t *window_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
433
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
434 /* 512 IMDCT with source and dest data in 'data' */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
435
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
436 /* Pre IFFT complex multiply plus IFFT cmplx conjugate & reordering*/
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
437 for( i=0; i < 128; i++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
438 /* z[i] = (X[256-2*i-1] + j * X[2*i]) * (xcos1[i] + j * xsin1[i]) ; */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
439 int j= bit_reverse_512[i];
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
440 buf[i].real = (data[256-2*j-1] * xcos1[j]) - (data[2*j] * xsin1[j]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
441 buf[i].imag = -1.0 * ((data[2*j] * xcos1[j]) + (data[256-2*j-1] * xsin1[j]));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
442 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
443
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
444 /* 1. iteration */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
445 for(i = 0; i < 128; i += 2) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
446 #if 0
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
447 tmp_a_r = buf[i].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
448 tmp_a_i = buf[i].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
449 tmp_b_r = buf[i+1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
450 tmp_b_i = buf[i+1].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
451 buf[i].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
452 buf[i].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
453 buf[i+1].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
454 buf[i+1].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
455 #else
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
456 vector float temp, bufv;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
457
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
458 bufv = vec_ld(i << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
459 temp = vec_perm(bufv, bufv, vcprm(2,3,0,1));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
460 bufv = vec_madd(bufv, vcii(p,p,n,n), temp);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
461 vec_st(bufv, i << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
462 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
463 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
464
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
465 /* 2. iteration */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
466 // Note w[1]={{1,0}, {0,-1}}
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
467 for(i = 0; i < 128; i += 4) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
468 #if 0
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
469 tmp_a_r = buf[i].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
470 tmp_a_i = buf[i].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
471 tmp_b_r = buf[i+2].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
472 tmp_b_i = buf[i+2].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
473 buf[i].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
474 buf[i].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
475 buf[i+2].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
476 buf[i+2].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
477 tmp_a_r = buf[i+1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
478 tmp_a_i = buf[i+1].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
479 /* WARNING: im <-> re here ! */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
480 tmp_b_r = buf[i+3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
481 tmp_b_i = buf[i+3].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
482 buf[i+1].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
483 buf[i+1].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
484 buf[i+3].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
485 buf[i+3].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
486 #else
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
487 vector float buf01, buf23, temp1, temp2;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
488
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
489 buf01 = vec_ld((i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
490 buf23 = vec_ld((i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
491 buf23 = vec_perm(buf23,buf23,vcprm(0,1,3,2));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
492
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
493 temp1 = vec_madd(buf23, vcii(p,p,p,n), buf01);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
494 temp2 = vec_madd(buf23, vcii(n,n,n,p), buf01);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
495
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
496 vec_st(temp1, (i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
497 vec_st(temp2, (i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
498 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
499 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
500
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
501 /* 3. iteration */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
502 for(i = 0; i < 128; i += 8) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
503 #if 0
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
504 tmp_a_r = buf[i].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
505 tmp_a_i = buf[i].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
506 tmp_b_r = buf[i+4].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
507 tmp_b_i = buf[i+4].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
508 buf[i].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
509 buf[i].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
510 buf[i+4].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
511 buf[i+4].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
512 tmp_a_r = buf[1+i].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
513 tmp_a_i = buf[1+i].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
514 tmp_b_r = (buf[i+5].real + buf[i+5].imag) * w[2][1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
515 tmp_b_i = (buf[i+5].imag - buf[i+5].real) * w[2][1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
516 buf[1+i].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
517 buf[1+i].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
518 buf[i+5].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
519 buf[i+5].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
520 tmp_a_r = buf[i+2].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
521 tmp_a_i = buf[i+2].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
522 /* WARNING re <-> im & sign */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
523 tmp_b_r = buf[i+6].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
524 tmp_b_i = - buf[i+6].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
525 buf[i+2].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
526 buf[i+2].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
527 buf[i+6].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
528 buf[i+6].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
529 tmp_a_r = buf[i+3].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
530 tmp_a_i = buf[i+3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
531 tmp_b_r = (buf[i+7].real - buf[i+7].imag) * w[2][3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
532 tmp_b_i = (buf[i+7].imag + buf[i+7].real) * w[2][3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
533 buf[i+3].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
534 buf[i+3].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
535 buf[i+7].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
536 buf[i+7].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
537 #else
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
538 vector float buf01, buf23, buf45, buf67;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
539
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
540 buf01 = vec_ld((i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
541 buf23 = vec_ld((i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
542
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
543 tmp_b_r = (buf[i+5].real + buf[i+5].imag) * w[2][1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
544 tmp_b_i = (buf[i+5].imag - buf[i+5].real) * w[2][1].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
545 buf[i+5].real = tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
546 buf[i+5].imag = tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
547 tmp_b_r = (buf[i+7].real - buf[i+7].imag) * w[2][3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
548 tmp_b_i = (buf[i+7].imag + buf[i+7].real) * w[2][3].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
549 buf[i+7].real = tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
550 buf[i+7].imag = tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
551
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
552 buf23 = vec_ld((i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
553 buf45 = vec_ld((i + 4) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
554 buf67 = vec_ld((i + 6) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
555 buf67 = vec_perm(buf67, buf67, vcprm(1,0,2,3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
556
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
557 vec_st(vec_add(buf01, buf45), (i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
558 vec_st(vec_madd(buf67, vcii(p,n,p,p), buf23), (i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
559 vec_st(vec_sub(buf01, buf45), (i + 4) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
560 vec_st(vec_nmsub(buf67, vcii(p,n,p,p), buf23), (i + 6) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
561 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
562 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
563
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
564 /* 4-7. iterations */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
565 for (m=3; m < 7; m++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
566 two_m = (1 << m);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
567
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
568 two_m_plus_one = two_m<<1;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
569
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
570 for(i = 0; i < 128; i += two_m_plus_one) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
571 for(k = 0; k < two_m; k+=2) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
572 #if 0
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
573 int p = k + i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
574 int q = p + two_m;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
575 tmp_a_r = buf[p].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
576 tmp_a_i = buf[p].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
577 tmp_b_r =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
578 buf[q].real * w[m][k].real -
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
579 buf[q].imag * w[m][k].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
580 tmp_b_i =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
581 buf[q].imag * w[m][k].real +
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
582 buf[q].real * w[m][k].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
583 buf[p].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
584 buf[p].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
585 buf[q].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
586 buf[q].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
587
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
588 tmp_a_r = buf[(p + 1)].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
589 tmp_a_i = buf[(p + 1)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
590 tmp_b_r =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
591 buf[(q + 1)].real * w[m][(k + 1)].real -
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
592 buf[(q + 1)].imag * w[m][(k + 1)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
593 tmp_b_i =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
594 buf[(q + 1)].imag * w[m][(k + 1)].real +
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
595 buf[(q + 1)].real * w[m][(k + 1)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
596 buf[(p + 1)].real = tmp_a_r + tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
597 buf[(p + 1)].imag = tmp_a_i + tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
598 buf[(q + 1)].real = tmp_a_r - tmp_b_r;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
599 buf[(q + 1)].imag = tmp_a_i - tmp_b_i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
600 #else
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
601 int p = k + i;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
602 int q = p + two_m;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
603 vector float vecp, vecq, vecw, temp1, temp2, temp3, temp4;
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
604 const vector float vczero = (const vector float)FOUROF(0.);
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
605 // first compute buf[q] and buf[q+1]
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
606 vecq = vec_ld(q << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
607 vecw = vec_ld(0, (float*)&(w[m][k]));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
608 temp1 = vec_madd(vecq, vecw, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
609 temp2 = vec_perm(vecq, vecq, vcprm(1,0,3,2));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
610 temp2 = vec_madd(temp2, vecw, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
611 temp3 = vec_perm(temp1, temp2, vcprm(0,s0,2,s2));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
612 temp4 = vec_perm(temp1, temp2, vcprm(1,s1,3,s3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
613 vecq = vec_madd(temp4, vcii(n,p,n,p), temp3);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
614 // then butterfly with buf[p] and buf[p+1]
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
615 vecp = vec_ld(p << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
616
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
617 temp1 = vec_add(vecp, vecq);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
618 temp2 = vec_sub(vecp, vecq);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
619
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
620 vec_st(temp1, p << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
621 vec_st(temp2, q << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
622 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
623 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
624 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
625 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
626
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
627 /* Post IFFT complex multiply plus IFFT complex conjugate*/
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
628 for( i=0; i < 128; i+=4) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
629 /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
630 #if 0
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
631 tmp_a_r = buf[(i + 0)].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
632 tmp_a_i = -1.0 * buf[(i + 0)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
633 buf[(i + 0)].real =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
634 (tmp_a_r * xcos1[(i + 0)]) - (tmp_a_i * xsin1[(i + 0)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
635 buf[(i + 0)].imag =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
636 (tmp_a_r * xsin1[(i + 0)]) + (tmp_a_i * xcos1[(i + 0)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
637
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
638 tmp_a_r = buf[(i + 1)].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
639 tmp_a_i = -1.0 * buf[(i + 1)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
640 buf[(i + 1)].real =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
641 (tmp_a_r * xcos1[(i + 1)]) - (tmp_a_i * xsin1[(i + 1)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
642 buf[(i + 1)].imag =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
643 (tmp_a_r * xsin1[(i + 1)]) + (tmp_a_i * xcos1[(i + 1)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
644
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
645 tmp_a_r = buf[(i + 2)].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
646 tmp_a_i = -1.0 * buf[(i + 2)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
647 buf[(i + 2)].real =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
648 (tmp_a_r * xcos1[(i + 2)]) - (tmp_a_i * xsin1[(i + 2)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
649 buf[(i + 2)].imag =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
650 (tmp_a_r * xsin1[(i + 2)]) + (tmp_a_i * xcos1[(i + 2)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
651
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
652 tmp_a_r = buf[(i + 3)].real;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
653 tmp_a_i = -1.0 * buf[(i + 3)].imag;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
654 buf[(i + 3)].real =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
655 (tmp_a_r * xcos1[(i + 3)]) - (tmp_a_i * xsin1[(i + 3)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
656 buf[(i + 3)].imag =
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
657 (tmp_a_r * xsin1[(i + 3)]) + (tmp_a_i * xcos1[(i + 3)]);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
658 #else
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
659 vector float bufv_0, bufv_2, cosv, sinv, temp1, temp2;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
660 vector float temp0022, temp1133, tempCS01;
9122
5ba896a38d75 The two attached patches *should* allow for proper
arpi
parents: 9001
diff changeset
661 const vector float vczero = (const vector float)FOUROF(0.);
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
662
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
663 bufv_0 = vec_ld((i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
664 bufv_2 = vec_ld((i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
665
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
666 cosv = vec_ld(i << 2, xcos1);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
667 sinv = vec_ld(i << 2, xsin1);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
668
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
669 temp0022 = vec_perm(bufv_0, bufv_0, vcprm(0,0,2,2));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
670 temp1133 = vec_perm(bufv_0, bufv_0, vcprm(1,1,3,3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
671 tempCS01 = vec_perm(cosv, sinv, vcprm(0,s0,1,s1));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
672 temp1 = vec_madd(temp0022, tempCS01, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
673 tempCS01 = vec_perm(cosv, sinv, vcprm(s0,0,s1,1));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
674 temp2 = vec_madd(temp1133, tempCS01, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
675 bufv_0 = vec_madd(temp2, vcii(p,n,p,n), temp1);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
676
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
677 vec_st(bufv_0, (i + 0) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
678
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
679 /* idem with bufv_2 and high-order cosv/sinv */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
680
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
681 temp0022 = vec_perm(bufv_2, bufv_2, vcprm(0,0,2,2));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
682 temp1133 = vec_perm(bufv_2, bufv_2, vcprm(1,1,3,3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
683 tempCS01 = vec_perm(cosv, sinv, vcprm(2,s2,3,s3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
684 temp1 = vec_madd(temp0022, tempCS01, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
685 tempCS01 = vec_perm(cosv, sinv, vcprm(s2,2,s3,3));
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
686 temp2 = vec_madd(temp1133, tempCS01, vczero);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
687 bufv_2 = vec_madd(temp2, vcii(p,n,p,n), temp1);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
688
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
689 vec_st(bufv_2, (i + 2) << 3, (float*)buf);
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
690
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
691 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
692 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
693
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
694 data_ptr = data;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
695 delay_ptr = delay;
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
696 window_ptr = a52_imdct_window;
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
697
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
698 /* Window and convert to real valued signal */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
699 for(i=0; i< 64; i++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
700 *data_ptr++ = -buf[64+i].imag * *window_ptr++ + *delay_ptr++ + bias;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
701 *data_ptr++ = buf[64-i-1].real * *window_ptr++ + *delay_ptr++ + bias;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
702 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
703
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
704 for(i=0; i< 64; i++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
705 *data_ptr++ = -buf[i].real * *window_ptr++ + *delay_ptr++ + bias;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
706 *data_ptr++ = buf[128-i-1].imag * *window_ptr++ + *delay_ptr++ + bias;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
707 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
708
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
709 /* The trailing edge of the window goes into the delay line */
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
710 delay_ptr = delay;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
711
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
712 for(i=0; i< 64; i++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
713 *delay_ptr++ = -buf[64+i].real * *--window_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
714 *delay_ptr++ = buf[64-i-1].imag * *--window_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
715 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
716
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
717 for(i=0; i<64; i++) {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
718 *delay_ptr++ = buf[i].imag * *--window_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
719 *delay_ptr++ = -buf[128-i-1].real * *--window_ptr;
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
720 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
721 }
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
722 #endif
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
723
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
724
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
725 // Stuff below this line is borrowed from libac3
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
726 #include "srfftp.h"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
727 #if defined(ARCH_X86) || defined(ARCH_X86_64)
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
728 #ifndef HAVE_3DNOW
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
729 #define HAVE_3DNOW 1
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
730 #endif
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
731 #include "srfftp_3dnow.h"
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
732
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8254
diff changeset
733 const i_cmplx_t x_plus_minus_3dnow __attribute__ ((aligned (8))) = {{ 0x00000000UL, 0x80000000UL }};
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8254
diff changeset
734 const i_cmplx_t x_minus_plus_3dnow __attribute__ ((aligned (8))) = {{ 0x80000000UL, 0x00000000UL }};
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
735 const complex_t HSQRT2_3DNOW __attribute__ ((aligned (8))) = { 0.707106781188, 0.707106781188 };
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
736
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
737 #undef HAVE_3DNOWEX
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
738 #include "imdct_3dnow.h"
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
739 #define HAVE_3DNOWEX
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
740 #include "imdct_3dnow.h"
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
741
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
742 void
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
743 imdct_do_512_sse(sample_t data[],sample_t delay[], sample_t bias)
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
744 {
8254
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 4497
diff changeset
745 /* int i,k;
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 4497
diff changeset
746 int p,q;*/
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
747 int m;
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
748 long two_m;
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
749 long two_m_plus_one;
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
750 long two_m_plus_one_shl3;
15617
130dd060f723 one bugfix and a few gcc4 bug workaorunds by (Gianluigi Tiesi: mplayer, netfarm it)
michael
parents: 14991
diff changeset
751 complex_t *buf_offset;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
752
8254
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 4497
diff changeset
753 /* sample_t tmp_a_i;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
754 sample_t tmp_a_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
755 sample_t tmp_b_i;
8254
772d6d27fd66 warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents: 4497
diff changeset
756 sample_t tmp_b_r;*/
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
757
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
758 sample_t *data_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
759 sample_t *delay_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
760 sample_t *window_ptr;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
761
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
762 /* 512 IMDCT with source and dest data in 'data' */
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
763 /* see the c version (dct_do_512()), its allmost identical, just in C */
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
764
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
765 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
766 /* Bit reversed shuffling */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
767 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
768 "xor %%"REG_S", %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
769 "lea "MANGLE(bit_reverse_512)", %%"REG_a"\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
770 "mov $1008, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
771 "push %%"REG_BP" \n\t" //use ebp without telling gcc
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
772 ASMALIGN16
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
773 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
774 "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // XXXI
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
775 "movhps 8(%0, %%"REG_D"), %%xmm0 \n\t" // RXXI
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
776 "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // XXXi
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
777 "movhps (%0, %%"REG_D"), %%xmm1 \n\t" // rXXi
3584
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
778 "shufps $0x33, %%xmm1, %%xmm0 \n\t" // irIR
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
779 "movaps "MANGLE(sseSinCos1c)"(%%"REG_S"), %%xmm2\n\t"
3584
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
780 "mulps %%xmm0, %%xmm2 \n\t"
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
781 "shufps $0xB1, %%xmm0, %%xmm0 \n\t" // riRI
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
782 "mulps "MANGLE(sseSinCos1d)"(%%"REG_S"), %%xmm0\n\t"
3584
7c4046c04be3 removing unnecessary sse sin/cos LUT
michael
parents: 3581
diff changeset
783 "subps %%xmm0, %%xmm2 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
784 "movzb (%%"REG_a"), %%"REG_d" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
785 "movzb 1(%%"REG_a"), %%"REG_BP" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
786 "movlps %%xmm2, (%1, %%"REG_d", 8) \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
787 "movhps %%xmm2, (%1, %%"REG_BP", 8) \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
788 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
789 "add $2, %%"REG_a" \n\t" // avoid complex addressing for P4 crap
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
790 "sub $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
791 "jnc 1b \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
792 "pop %%"REG_BP" \n\t"//no we didnt touch ebp *g*
16189
72764c0dad8a Fixes segfault on IA-32 machines caused by the ASM patch for AMD-64 for a52.
gpoirier
parents: 16173
diff changeset
793 :: "b" (data), "c" (buf)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
794 : "%"REG_S, "%"REG_D, "%"REG_a, "%"REG_d
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
795 );
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
796
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
797
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
798 /* FFT Merge */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
799 /* unoptimized variant
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
800 for (m=1; m < 7; m++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
801 if(m)
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
802 two_m = (1 << m);
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
803 else
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
804 two_m = 1;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
805
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
806 two_m_plus_one = (1 << (m+1));
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
807
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
808 for(i = 0; i < 128; i += two_m_plus_one) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
809 for(k = 0; k < two_m; k++) {
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
810 p = k + i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
811 q = p + two_m;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
812 tmp_a_r = buf[p].real;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
813 tmp_a_i = buf[p].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
814 tmp_b_r = buf[q].real * w[m][k].real - buf[q].imag * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
815 tmp_b_i = buf[q].imag * w[m][k].real + buf[q].real * w[m][k].imag;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
816 buf[p].real = tmp_a_r + tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
817 buf[p].imag = tmp_a_i + tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
818 buf[q].real = tmp_a_r - tmp_b_r;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
819 buf[q].imag = tmp_a_i - tmp_b_i;
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
820 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
821 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
822 }
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
823 */
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
824
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
825 /* 1. iteration */
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
826 // Note w[0][0]={1,0}
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
827 asm volatile(
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
828 "xorps %%xmm1, %%xmm1 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
829 "xorps %%xmm2, %%xmm2 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
830 "mov %0, %%"REG_S" \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
831 ASMALIGN16
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
832 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
833 "movlps (%%"REG_S"), %%xmm0\n\t" //buf[p]
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
834 "movlps 8(%%"REG_S"), %%xmm1\n\t" //buf[q]
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
835 "movhps (%%"REG_S"), %%xmm0\n\t" //buf[p]
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
836 "movhps 8(%%"REG_S"), %%xmm2\n\t" //buf[q]
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
837 "addps %%xmm1, %%xmm0 \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
838 "subps %%xmm2, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
839 "movaps %%xmm0, (%%"REG_S")\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
840 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
841 "cmp %1, %%"REG_S" \n\t"
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
842 " jb 1b \n\t"
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
843 :: "g" (buf), "r" (buf + 128)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
844 : "%"REG_S
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
845 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
846
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
847 /* 2. iteration */
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
848 // Note w[1]={{1,0}, {0,-1}}
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
849 asm volatile(
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
850 "movaps "MANGLE(ps111_1)", %%xmm7\n\t" // 1,1,1,-1
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
851 "mov %0, %%"REG_S" \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
852 ASMALIGN16
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
853 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
854 "movaps 16(%%"REG_S"), %%xmm2 \n\t" //r2,i2,r3,i3
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
855 "shufps $0xB4, %%xmm2, %%xmm2 \n\t" //r2,i2,i3,r3
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
856 "mulps %%xmm7, %%xmm2 \n\t" //r2,i2,i3,-r3
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
857 "movaps (%%"REG_S"), %%xmm0 \n\t" //r0,i0,r1,i1
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
858 "movaps (%%"REG_S"), %%xmm1 \n\t" //r0,i0,r1,i1
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
859 "addps %%xmm2, %%xmm0 \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
860 "subps %%xmm2, %%xmm1 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
861 "movaps %%xmm0, (%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
862 "movaps %%xmm1, 16(%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
863 "add $32, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
864 "cmp %1, %%"REG_S" \n\t"
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
865 " jb 1b \n\t"
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
866 :: "g" (buf), "r" (buf + 128)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
867 : "%"REG_S
3512
1f166e420b15 a bit more SSE optimizations
michael
parents: 3508
diff changeset
868 );
3549
2e21accd86a8 cleanup
michael
parents: 3546
diff changeset
869
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
870 /* 3. iteration */
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
871 /*
3483390a902b sse opt
michael
parents: 3529
diff changeset
872 Note sseW2+0={1,1,sqrt(2),sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
873 Note sseW2+16={0,0,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
874 Note sseW2+32={0,0,-sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
875 Note sseW2+48={1,-1,sqrt(2),-sqrt(2))
3483390a902b sse opt
michael
parents: 3529
diff changeset
876 */
3483390a902b sse opt
michael
parents: 3529
diff changeset
877 asm volatile(
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
878 "movaps 48+"MANGLE(sseW2)", %%xmm6\n\t"
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
879 "movaps 16+"MANGLE(sseW2)", %%xmm7\n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
880 "xorps %%xmm5, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
881 "xorps %%xmm2, %%xmm2 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
882 "mov %0, %%"REG_S" \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
883 ASMALIGN16
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
884 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
885 "movaps 32(%%"REG_S"), %%xmm2 \n\t" //r4,i4,r5,i5
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
886 "movaps 48(%%"REG_S"), %%xmm3 \n\t" //r6,i6,r7,i7
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
887 "movaps "MANGLE(sseW2)", %%xmm4 \n\t" //r4,i4,r5,i5
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3908
diff changeset
888 "movaps 32+"MANGLE(sseW2)", %%xmm5\n\t" //r6,i6,r7,i7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
889 "mulps %%xmm2, %%xmm4 \n\t"
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
890 "mulps %%xmm3, %%xmm5 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
891 "shufps $0xB1, %%xmm2, %%xmm2 \n\t" //i4,r4,i5,r5
3483390a902b sse opt
michael
parents: 3529
diff changeset
892 "shufps $0xB1, %%xmm3, %%xmm3 \n\t" //i6,r6,i7,r7
3537
d7e5a32643c9 C optimizations
michael
parents: 3534
diff changeset
893 "mulps %%xmm6, %%xmm3 \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
894 "mulps %%xmm7, %%xmm2 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
895 "movaps (%%"REG_S"), %%xmm0 \n\t" //r0,i0,r1,i1
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
896 "movaps 16(%%"REG_S"), %%xmm1 \n\t" //r2,i2,r3,i3
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
897 "addps %%xmm4, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
898 "addps %%xmm5, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
899 "movaps %%xmm2, %%xmm4 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
900 "movaps %%xmm3, %%xmm5 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
901 "addps %%xmm0, %%xmm2 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
902 "addps %%xmm1, %%xmm3 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
903 "subps %%xmm4, %%xmm0 \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
904 "subps %%xmm5, %%xmm1 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
905 "movaps %%xmm2, (%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
906 "movaps %%xmm3, 16(%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
907 "movaps %%xmm0, 32(%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
908 "movaps %%xmm1, 48(%%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
909 "add $64, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
910 "cmp %1, %%"REG_S" \n\t"
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
911 " jb 1b \n\t"
3483390a902b sse opt
michael
parents: 3529
diff changeset
912 :: "g" (buf), "r" (buf + 128)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
913 : "%"REG_S
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
914 );
3508
b5220cf63fc3 some SSE optimizations
michael
parents: 3394
diff changeset
915
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
916 /* 4-7. iterations */
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
917 for (m=3; m < 7; m++) {
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
918 two_m = (1 << m);
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
919 two_m_plus_one = two_m<<1;
15617
130dd060f723 one bugfix and a few gcc4 bug workaorunds by (Gianluigi Tiesi: mplayer, netfarm it)
michael
parents: 14991
diff changeset
920 two_m_plus_one_shl3 = (two_m_plus_one<<3);
130dd060f723 one bugfix and a few gcc4 bug workaorunds by (Gianluigi Tiesi: mplayer, netfarm it)
michael
parents: 14991
diff changeset
921 buf_offset = buf+128;
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
922 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
923 "mov %0, %%"REG_S" \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
924 ASMALIGN16
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
925 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
926 "xor %%"REG_D", %%"REG_D" \n\t" // k
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
927 "lea (%%"REG_S", %3), %%"REG_d" \n\t"
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
928 "2: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
929 "movaps (%%"REG_d", %%"REG_D"), %%xmm1 \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
930 "movaps (%4, %%"REG_D", 2), %%xmm2 \n\t"
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
931 "mulps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
932 "shufps $0xB1, %%xmm1, %%xmm1 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
933 "mulps 16(%4, %%"REG_D", 2), %%xmm1 \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
934 "movaps (%%"REG_S", %%"REG_D"), %%xmm0 \n\t"
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
935 "addps %%xmm2, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
936 "movaps %%xmm1, %%xmm2 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
937 "addps %%xmm0, %%xmm1 \n\t"
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
938 "subps %%xmm2, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
939 "movaps %%xmm1, (%%"REG_S", %%"REG_D") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
940 "movaps %%xmm0, (%%"REG_d", %%"REG_D") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
941 "add $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
942 "cmp %3, %%"REG_D" \n\t" //FIXME (opt) count against 0
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
943 "jb 2b \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
944 "add %2, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
945 "cmp %1, %%"REG_S" \n\t"
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
946 " jb 1b \n\t"
15617
130dd060f723 one bugfix and a few gcc4 bug workaorunds by (Gianluigi Tiesi: mplayer, netfarm it)
michael
parents: 14991
diff changeset
947 :: "g" (buf), "m" (buf_offset), "m" (two_m_plus_one_shl3), "r" (two_m<<3),
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
948 "r" (sseW[m])
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
949 : "%"REG_S, "%"REG_D, "%"REG_d
3546
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
950 );
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
951 }
4e772a3c6b62 sse opt
michael
parents: 3537
diff changeset
952
3623
3f1c2c06d0d8 adding some comments
michael
parents: 3584
diff changeset
953 /* Post IFFT complex multiply plus IFFT complex conjugate*/
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
954 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
955 "mov $-1024, %%"REG_S" \n\t"
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
956 ASMALIGN16
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
957 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
958 "movaps (%0, %%"REG_S"), %%xmm0 \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
959 "movaps (%0, %%"REG_S"), %%xmm1 \n\t"
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
960 "shufps $0xB1, %%xmm0, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
961 "mulps 1024+"MANGLE(sseSinCos1c)"(%%"REG_S"), %%xmm1\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
962 "mulps 1024+"MANGLE(sseSinCos1d)"(%%"REG_S"), %%xmm0\n\t"
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
963 "addps %%xmm1, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
964 "movaps %%xmm0, (%0, %%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
965 "add $16, %%"REG_S" \n\t"
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
966 " jnz 1b \n\t"
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
967 :: "r" (buf+128)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
968 : "%"REG_S
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
969 );
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
970
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
971
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
972 data_ptr = data;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
973 delay_ptr = delay;
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
974 window_ptr = a52_imdct_window;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
975
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
976 /* Window and convert to real valued signal */
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
977 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
978 "xor %%"REG_D", %%"REG_D" \n\t" // 0
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
979 "xor %%"REG_S", %%"REG_S" \n\t" // 0
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
980 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
981 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
982 ASMALIGN16
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
983 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
984 "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? A ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
985 "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? C ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
986 "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // ? D C ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
987 "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // ? B A ?
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
988 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
989 "mulps "MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
990 "addps (%2, %%"REG_S"), %%xmm0 \n\t"
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
991 "addps %%xmm2, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
992 "movaps %%xmm0, (%1, %%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
993 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
994 "sub $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
995 "cmp $512, %%"REG_S" \n\t"
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
996 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
997 :: "r" (buf+64), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
998 : "%"REG_S, "%"REG_D
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
999 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1000 data_ptr+=128;
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1001 delay_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1002 // window_ptr+=128;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1003
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1004 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1005 "mov $1024, %%"REG_D" \n\t" // 512
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1006 "xor %%"REG_S", %%"REG_S" \n\t" // 0
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1007 "movss %3, %%xmm2 \n\t" // bias
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1008 "shufps $0x00, %%xmm2, %%xmm2 \n\t" // bias, bias, ...
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
1009 ASMALIGN16
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1010 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1011 "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? ? A
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1012 "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? ? C
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1013 "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // D ? ? C
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1014 "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // B ? ? A
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1015 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1016 "mulps 512+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1017 "addps (%2, %%"REG_S"), %%xmm0 \n\t"
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1018 "addps %%xmm2, %%xmm0 \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1019 "movaps %%xmm0, (%1, %%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1020 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1021 "sub $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1022 "cmp $512, %%"REG_S" \n\t"
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1023 " jb 1b \n\t"
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1024 :: "r" (buf), "r" (data_ptr), "r" (delay_ptr), "m" (bias)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1025 : "%"REG_S, "%"REG_D
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1026 );
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1027 data_ptr+=128;
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1028 // window_ptr+=128;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1029
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1030 /* The trailing edge of the window goes into the delay line */
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1031 delay_ptr = delay;
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1032
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1033 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1034 "xor %%"REG_D", %%"REG_D" \n\t" // 0
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1035 "xor %%"REG_S", %%"REG_S" \n\t" // 0
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
1036 ASMALIGN16
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1037 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1038 "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? ? A
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1039 "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? ? C
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1040 "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // D ? ? C
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1041 "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // B ? ? A
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1042 "shufps $0xCC, %%xmm1, %%xmm0 \n\t" // D C B A
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1043 "mulps 1024+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1044 "movaps %%xmm0, (%1, %%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1045 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1046 "sub $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1047 "cmp $512, %%"REG_S" \n\t"
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1048 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1049 :: "r" (buf+64), "r" (delay_ptr)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1050 : "%"REG_S, "%"REG_D
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1051 );
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1052 delay_ptr+=128;
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1053 // window_ptr-=128;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1054
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1055 asm volatile(
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1056 "mov $1024, %%"REG_D" \n\t" // 1024
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1057 "xor %%"REG_S", %%"REG_S" \n\t" // 0
18104
7b408d60de9e add support for intel mac. mp3lib is not fixed yet.
nplourde
parents: 16189
diff changeset
1058 ASMALIGN16
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1059 "1: \n\t"
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1060 "movlps (%0, %%"REG_S"), %%xmm0 \n\t" // ? ? A ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1061 "movlps 8(%0, %%"REG_S"), %%xmm1 \n\t" // ? ? C ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1062 "movhps -16(%0, %%"REG_D"), %%xmm1 \n\t" // ? D C ?
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1063 "movhps -8(%0, %%"REG_D"), %%xmm0 \n\t" // ? B A ?
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1064 "shufps $0x99, %%xmm1, %%xmm0 \n\t" // D C B A
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1065 "mulps 1536+"MANGLE(sseWindow)"(%%"REG_S"), %%xmm0\n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1066 "movaps %%xmm0, (%1, %%"REG_S") \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1067 "add $16, %%"REG_S" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1068 "sub $16, %%"REG_D" \n\t"
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1069 "cmp $512, %%"REG_S" \n\t"
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1070 " jb 1b \n\t"
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1071 :: "r" (buf), "r" (delay_ptr)
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1072 : "%"REG_S, "%"REG_D
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1073 );
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1074 }
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1075 #endif // ARCH_X86 || ARCH_X86_64
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1076
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1077 void a52_imdct_256(sample_t * data, sample_t * delay, sample_t bias)
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1078 {
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1079 int i, k;
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1080 sample_t t_r, t_i, a_r, a_i, b_r, b_i, c_r, c_i, d_r, d_i, w_1, w_2;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1081 const sample_t * window = a52_imdct_window;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1082 complex_t buf1[64], buf2[64];
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1083
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1084 /* Pre IFFT complex multiply plus IFFT cmplx conjugate */
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1085 for (i = 0; i < 64; i++) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1086 k = fftorder[i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1087 t_r = pre2[i].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1088 t_i = pre2[i].imag;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1089
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1090 buf1[i].real = t_i * data[254-k] + t_r * data[k];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1091 buf1[i].imag = t_r * data[254-k] - t_i * data[k];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1092
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1093 buf2[i].real = t_i * data[255-k] + t_r * data[k+1];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1094 buf2[i].imag = t_r * data[255-k] - t_i * data[k+1];
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1095 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1096
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1097 ifft64 (buf1);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1098 ifft64 (buf2);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1099
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1100 /* Post IFFT complex multiply */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1101 /* Window and convert to real valued signal */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1102 for (i = 0; i < 32; i++) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1103 /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1104 t_r = post2[i].real;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1105 t_i = post2[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1106
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1107 a_r = t_r * buf1[i].real + t_i * buf1[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1108 a_i = t_i * buf1[i].real - t_r * buf1[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1109 b_r = t_i * buf1[63-i].real + t_r * buf1[63-i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1110 b_i = t_r * buf1[63-i].real - t_i * buf1[63-i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1111
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1112 c_r = t_r * buf2[i].real + t_i * buf2[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1113 c_i = t_i * buf2[i].real - t_r * buf2[i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1114 d_r = t_i * buf2[63-i].real + t_r * buf2[63-i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1115 d_i = t_r * buf2[63-i].real - t_i * buf2[63-i].imag;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1116
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1117 w_1 = window[2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1118 w_2 = window[255-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1119 data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1120 data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1121 delay[2*i] = c_i;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1122
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1123 w_1 = window[128+2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1124 w_2 = window[127-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1125 data[128+2*i] = delay[127-2*i] * w_2 + a_i * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1126 data[127-2*i] = delay[127-2*i] * w_1 - a_i * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1127 delay[127-2*i] = c_r;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1128
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1129 w_1 = window[2*i+1];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1130 w_2 = window[254-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1131 data[2*i+1] = delay[2*i+1] * w_2 - b_i * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1132 data[254-2*i] = delay[2*i+1] * w_1 + b_i * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1133 delay[2*i+1] = d_r;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1134
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1135 w_1 = window[129+2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1136 w_2 = window[126-2*i];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1137 data[129+2*i] = delay[126-2*i] * w_2 + b_r * w_1 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1138 data[126-2*i] = delay[126-2*i] * w_1 - b_r * w_2 + bias;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1139 delay[126-2*i] = d_i;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1140 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1141 }
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1142
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1143 static double besselI0 (double x)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1144 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1145 double bessel = 1;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1146 int i = 100;
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1147
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1148 do
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1149 bessel = bessel * x / (i * i) + 1;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1150 while (--i);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1151 return bessel;
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1152 }
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1153
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1154 void a52_imdct_init (uint32_t mm_accel)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1155 {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1156 int i, j, k;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1157 double sum;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1158
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1159 /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1160 sum = 0;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1161 for (i = 0; i < 256; i++) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1162 sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1163 a52_imdct_window[i] = sum;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1164 }
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1165 sum++;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1166 for (i = 0; i < 256; i++)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1167 a52_imdct_window[i] = sqrt (a52_imdct_window[i] / sum);
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1168
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1169 for (i = 0; i < 3; i++)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1170 roots16[i] = cos ((M_PI / 8) * (i + 1));
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1171
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1172 for (i = 0; i < 7; i++)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1173 roots32[i] = cos ((M_PI / 16) * (i + 1));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1174
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1175 for (i = 0; i < 15; i++)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1176 roots64[i] = cos ((M_PI / 32) * (i + 1));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1177
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1178 for (i = 0; i < 31; i++)
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1179 roots128[i] = cos ((M_PI / 64) * (i + 1));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1180
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1181 for (i = 0; i < 64; i++) {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1182 k = fftorder[i] / 2 + 64;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1183 pre1[i].real = cos ((M_PI / 256) * (k - 0.25));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1184 pre1[i].imag = sin ((M_PI / 256) * (k - 0.25));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1185 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1186
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1187 for (i = 64; i < 128; i++) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1188 k = fftorder[i] / 2 + 64;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1189 pre1[i].real = -cos ((M_PI / 256) * (k - 0.25));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1190 pre1[i].imag = -sin ((M_PI / 256) * (k - 0.25));
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1191 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1192
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1193 for (i = 0; i < 64; i++) {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1194 post1[i].real = cos ((M_PI / 256) * (i + 0.5));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1195 post1[i].imag = sin ((M_PI / 256) * (i + 0.5));
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1196 }
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1197
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1198 for (i = 0; i < 64; i++) {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1199 k = fftorder[i] / 4;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1200 pre2[i].real = cos ((M_PI / 128) * (k - 0.25));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1201 pre2[i].imag = sin ((M_PI / 128) * (k - 0.25));
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1202 }
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1203
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1204 for (i = 0; i < 32; i++) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1205 post2[i].real = cos ((M_PI / 128) * (i + 0.5));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1206 post2[i].imag = sin ((M_PI / 128) * (i + 0.5));
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1207 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1208 for (i = 0; i < 128; i++) {
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1209 xcos1[i] = -cos ((M_PI / 2048) * (8 * i + 1));
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1210 xsin1[i] = -sin ((M_PI / 2048) * (8 * i + 1));
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1211 }
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1212 for (i = 0; i < 7; i++) {
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1213 j = 1 << i;
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1214 for (k = 0; k < j; k++) {
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1215 w[i][k].real = cos (-M_PI * k / j);
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1216 w[i][k].imag = sin (-M_PI * k / j);
3394
35b18ed357c2 imported from liba52 CVS
arpi
parents:
diff changeset
1217 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1218 }
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1219 #if defined(ARCH_X86) || defined(ARCH_X86_64)
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
1220 for (i = 0; i < 128; i++) {
3581
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1221 sseSinCos1c[2*i+0]= xcos1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1222 sseSinCos1c[2*i+1]= -xcos1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1223 sseSinCos1d[2*i+0]= xsin1[i];
8ddf654c4871 sse opt
michael
parents: 3579
diff changeset
1224 sseSinCos1d[2*i+1]= xsin1[i];
3527
5a88b21cfe8a sse opt
michael
parents: 3512
diff changeset
1225 }
3534
3483390a902b sse opt
michael
parents: 3529
diff changeset
1226 for (i = 1; i < 7; i++) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1227 j = 1 << i;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1228 for (k = 0; k < j; k+=2) {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1229
3483390a902b sse opt
michael
parents: 3529
diff changeset
1230 sseW[i][4*k + 0] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1231 sseW[i][4*k + 1] = w[i][k+0].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1232 sseW[i][4*k + 2] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1233 sseW[i][4*k + 3] = w[i][k+1].real;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1234
3483390a902b sse opt
michael
parents: 3529
diff changeset
1235 sseW[i][4*k + 4] = -w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1236 sseW[i][4*k + 5] = w[i][k+0].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1237 sseW[i][4*k + 6] = -w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1238 sseW[i][4*k + 7] = w[i][k+1].imag;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1239
3483390a902b sse opt
michael
parents: 3529
diff changeset
1240 //we multiply more or less uninitalized numbers so we need to use exactly 0.0
3483390a902b sse opt
michael
parents: 3529
diff changeset
1241 if(k==0)
3483390a902b sse opt
michael
parents: 3529
diff changeset
1242 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1243 // sseW[i][4*k + 0]= sseW[i][4*k + 1]= 1.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1244 sseW[i][4*k + 4]= sseW[i][4*k + 5]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1245 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1246
3483390a902b sse opt
michael
parents: 3529
diff changeset
1247 if(2*k == j)
3483390a902b sse opt
michael
parents: 3529
diff changeset
1248 {
3483390a902b sse opt
michael
parents: 3529
diff changeset
1249 sseW[i][4*k + 0]= sseW[i][4*k + 1]= 0.0;
3483390a902b sse opt
michael
parents: 3529
diff changeset
1250 // sseW[i][4*k + 4]= -(sseW[i][4*k + 5]= -1.0);
3483390a902b sse opt
michael
parents: 3529
diff changeset
1251 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1252 }
3483390a902b sse opt
michael
parents: 3529
diff changeset
1253 }
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1254
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1255 for(i=0; i<128; i++)
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1256 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1257 sseWindow[2*i+0]= -a52_imdct_window[2*i+0];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1258 sseWindow[2*i+1]= a52_imdct_window[2*i+1];
3552
9ff2e3801027 sse opt
michael
parents: 3549
diff changeset
1259 }
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1260
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1261 for(i=0; i<64; i++)
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1262 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1263 sseWindow[256 + 2*i+0]= -a52_imdct_window[254 - 2*i+1];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1264 sseWindow[256 + 2*i+1]= a52_imdct_window[254 - 2*i+0];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1265 sseWindow[384 + 2*i+0]= a52_imdct_window[126 - 2*i+1];
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1266 sseWindow[384 + 2*i+1]= -a52_imdct_window[126 - 2*i+0];
3553
a501627fc6db sse opt
michael
parents: 3552
diff changeset
1267 }
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1268 #endif
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1269 a52_imdct_512 = imdct_do_512;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1270 ifft128 = ifft128_c;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1271 ifft64 = ifft64_c;
3579
831860fada69 runtime cpu detection for the idct
michael
parents: 3553
diff changeset
1272
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1273 #if defined(ARCH_X86) || defined(ARCH_X86_64)
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1274 if(mm_accel & MM_ACCEL_X86_SSE)
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1275 {
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1276 fprintf (stderr, "Using SSE optimized IMDCT transform\n");
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1277 a52_imdct_512 = imdct_do_512_sse;
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1278 }
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1279 else
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1280 if(mm_accel & MM_ACCEL_X86_3DNOWEXT)
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1281 {
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1282 fprintf (stderr, "Using 3DNowEx optimized IMDCT transform\n");
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1283 a52_imdct_512 = imdct_do_512_3dnowex;
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1284 }
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1285 else
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1286 if(mm_accel & MM_ACCEL_X86_3DNOW)
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1287 {
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1288 fprintf (stderr, "Using 3DNow optimized IMDCT transform\n");
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1289 a52_imdct_512 = imdct_do_512_3dnow;
4497
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1290 }
d3aedd7db02c Restore K7 support
nick
parents: 4247
diff changeset
1291 else
16173
d6219ce521e9 liba52 asm optimizations ported to amd64
aurel
parents: 15617
diff changeset
1292 #endif // ARCH_X86 || ARCH_X86_64
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1293 #ifdef HAVE_ALTIVEC
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1294 if (mm_accel & MM_ACCEL_PPC_ALTIVEC)
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1295 {
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1296 fprintf(stderr, "Using AltiVec optimized IMDCT transform\n");
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1297 a52_imdct_512 = imdct_do_512_altivec;
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1298 }
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1299 else
9001
01a9cf43074c An AltiVec-enhanced IMDCT for liba52 (liba52/imdct.c)
arpi
parents: 8451
diff changeset
1300 #endif
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1301
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1302 #ifdef LIBA52_DJBFFT
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1303 if (mm_accel & MM_ACCEL_DJBFFT) {
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1304 fprintf (stderr, "Using djbfft for IMDCT transform\n");
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1305 ifft128 = (void (*) (complex_t *)) fftc4_un128;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1306 ifft64 = (void (*) (complex_t *)) fftc4_un64;
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1307 } else
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1308 #endif
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1309 {
18720
4bad7f00556e sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18104
diff changeset
1310 fprintf (stderr, "No accelerated IMDCT transform found\n");
18721
722ac20fac5f sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents: 18720
diff changeset
1311 }
3884
0410677eda4a ported 3dnow(ex) optimizations from libac3
michael
parents: 3720
diff changeset
1312 }