annotate tremor/mdct.c @ 18001:a2683ee7cb5a

fix descrambling of asf file, where signed buffer could cause erroneous values to be filled in descrable variables, add misssing check for one of these variables and restore sign of these variables as insurance that these checks will work even in such case.
author iive
date Thu, 30 Mar 2006 23:06:18 +0000
parents 8631a3803289
children e83eef58b30a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14280
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
1 /********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
2 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
4 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
8 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
11 * *
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
12 ********************************************************************
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
13
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
14 function: normalized modified discrete cosine transform
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
15 power of two length transform only [64 <= n ]
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
16 last mod: $Id$
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
17
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
18 Original algorithm adapted long ago from _The use of multirate filter
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
19 banks for coding of high quality digital audio_, by T. Sporer,
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
20 K. Brandenburg and B. Edler, collection of the European Signal
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
21 Processing Conference (EUSIPCO), Amsterdam, June 1992, Vol.1, pp
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
22 211-214
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
23
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
24 The below code implements an algorithm that no longer looks much like
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
25 that presented in the paper, but the basic structure remains if you
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
26 dig deep enough to see it.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
27
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
28 This module DOES NOT INCLUDE code to generate/apply the window
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
29 function. Everybody has their own weird favorite including me... I
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
30 happen to like the properties of y=sin(.5PI*sin^2(x)), but others may
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
31 vehemently disagree.
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
32
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
33 ********************************************************************/
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
34
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
35 #include "ivorbiscodec.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
36 #include "os.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
37 #include "misc.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
38 #include "mdct.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
39 #include "mdct_lookup.h"
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
40
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
41
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
42 /* 8 point butterfly (in place) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
43 STIN void mdct_butterfly_8(DATA_TYPE *x){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
44
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
45 REG_TYPE r0 = x[4] + x[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
46 REG_TYPE r1 = x[4] - x[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
47 REG_TYPE r2 = x[5] + x[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
48 REG_TYPE r3 = x[5] - x[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
49 REG_TYPE r4 = x[6] + x[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
50 REG_TYPE r5 = x[6] - x[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
51 REG_TYPE r6 = x[7] + x[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
52 REG_TYPE r7 = x[7] - x[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
53
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
54 x[0] = r5 + r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
55 x[1] = r7 - r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
56 x[2] = r5 - r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
57 x[3] = r7 + r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
58 x[4] = r4 - r0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
59 x[5] = r6 - r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
60 x[6] = r4 + r0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
61 x[7] = r6 + r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
62 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
63 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
64
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
65 /* 16 point butterfly (in place, 4 register) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
66 STIN void mdct_butterfly_16(DATA_TYPE *x){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
67
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
68 REG_TYPE r0, r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
69
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
70 r0 = x[ 0] - x[ 8]; x[ 8] += x[ 0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
71 r1 = x[ 1] - x[ 9]; x[ 9] += x[ 1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
72 x[ 0] = MULT31((r0 + r1) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
73 x[ 1] = MULT31((r1 - r0) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
74 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
75
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
76 r0 = x[10] - x[ 2]; x[10] += x[ 2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
77 r1 = x[ 3] - x[11]; x[11] += x[ 3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
78 x[ 2] = r1; x[ 3] = r0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
79 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
80
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
81 r0 = x[12] - x[ 4]; x[12] += x[ 4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
82 r1 = x[13] - x[ 5]; x[13] += x[ 5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
83 x[ 4] = MULT31((r0 - r1) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
84 x[ 5] = MULT31((r0 + r1) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
85 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
86
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
87 r0 = x[14] - x[ 6]; x[14] += x[ 6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
88 r1 = x[15] - x[ 7]; x[15] += x[ 7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
89 x[ 6] = r0; x[ 7] = r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
90 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
91
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
92 mdct_butterfly_8(x);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
93 mdct_butterfly_8(x+8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
94 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
95
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
96 /* 32 point butterfly (in place, 4 register) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
97 STIN void mdct_butterfly_32(DATA_TYPE *x){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
98
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
99 REG_TYPE r0, r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
100
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
101 r0 = x[30] - x[14]; x[30] += x[14];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
102 r1 = x[31] - x[15]; x[31] += x[15];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
103 x[14] = r0; x[15] = r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
104 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
105
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
106 r0 = x[28] - x[12]; x[28] += x[12];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
107 r1 = x[29] - x[13]; x[29] += x[13];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
108 XNPROD31( r0, r1, cPI1_8, cPI3_8, &x[12], &x[13] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
109 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
110
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
111 r0 = x[26] - x[10]; x[26] += x[10];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
112 r1 = x[27] - x[11]; x[27] += x[11];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
113 x[10] = MULT31((r0 - r1) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
114 x[11] = MULT31((r0 + r1) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
115 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
116
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
117 r0 = x[24] - x[ 8]; x[24] += x[ 8];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
118 r1 = x[25] - x[ 9]; x[25] += x[ 9];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
119 XNPROD31( r0, r1, cPI3_8, cPI1_8, &x[ 8], &x[ 9] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
120 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
121
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
122 r0 = x[22] - x[ 6]; x[22] += x[ 6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
123 r1 = x[ 7] - x[23]; x[23] += x[ 7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
124 x[ 6] = r1; x[ 7] = r0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
125 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
126
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
127 r0 = x[ 4] - x[20]; x[20] += x[ 4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
128 r1 = x[ 5] - x[21]; x[21] += x[ 5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
129 XPROD31 ( r0, r1, cPI3_8, cPI1_8, &x[ 4], &x[ 5] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
130 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
131
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
132 r0 = x[ 2] - x[18]; x[18] += x[ 2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
133 r1 = x[ 3] - x[19]; x[19] += x[ 3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
134 x[ 2] = MULT31((r1 + r0) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
135 x[ 3] = MULT31((r1 - r0) , cPI2_8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
136 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
137
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
138 r0 = x[ 0] - x[16]; x[16] += x[ 0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
139 r1 = x[ 1] - x[17]; x[17] += x[ 1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
140 XPROD31 ( r0, r1, cPI1_8, cPI3_8, &x[ 0], &x[ 1] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
141 MB();
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
142
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
143 mdct_butterfly_16(x);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
144 mdct_butterfly_16(x+16);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
145 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
146
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
147 /* N/stage point generic N stage butterfly (in place, 2 register) */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
148 STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
149
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
150 LOOKUP_T *T = sincos_lookup0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
151 DATA_TYPE *x1 = x + points - 8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
152 DATA_TYPE *x2 = x + (points>>1) - 8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
153 REG_TYPE r0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
154 REG_TYPE r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
155
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
156 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
157 r0 = x1[6] - x2[6]; x1[6] += x2[6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
158 r1 = x2[7] - x1[7]; x1[7] += x2[7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
159 XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
160
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
161 r0 = x1[4] - x2[4]; x1[4] += x2[4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
162 r1 = x2[5] - x1[5]; x1[5] += x2[5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
163 XPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
164
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
165 r0 = x1[2] - x2[2]; x1[2] += x2[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
166 r1 = x2[3] - x1[3]; x1[3] += x2[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
167 XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
168
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
169 r0 = x1[0] - x2[0]; x1[0] += x2[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
170 r1 = x2[1] - x1[1]; x1[1] += x2[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
171 XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
172
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
173 x1-=8; x2-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
174 }while(T<sincos_lookup0+1024);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
175 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
176 r0 = x1[6] - x2[6]; x1[6] += x2[6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
177 r1 = x1[7] - x2[7]; x1[7] += x2[7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
178 XNPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
179
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
180 r0 = x1[4] - x2[4]; x1[4] += x2[4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
181 r1 = x1[5] - x2[5]; x1[5] += x2[5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
182 XNPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
183
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
184 r0 = x1[2] - x2[2]; x1[2] += x2[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
185 r1 = x1[3] - x2[3]; x1[3] += x2[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
186 XNPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
187
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
188 r0 = x1[0] - x2[0]; x1[0] += x2[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
189 r1 = x1[1] - x2[1]; x1[1] += x2[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
190 XNPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
191
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
192 x1-=8; x2-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
193 }while(T>sincos_lookup0);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
194 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
195 r0 = x2[6] - x1[6]; x1[6] += x2[6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
196 r1 = x2[7] - x1[7]; x1[7] += x2[7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
197 XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
198
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
199 r0 = x2[4] - x1[4]; x1[4] += x2[4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
200 r1 = x2[5] - x1[5]; x1[5] += x2[5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
201 XPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
202
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
203 r0 = x2[2] - x1[2]; x1[2] += x2[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
204 r1 = x2[3] - x1[3]; x1[3] += x2[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
205 XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
206
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
207 r0 = x2[0] - x1[0]; x1[0] += x2[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
208 r1 = x2[1] - x1[1]; x1[1] += x2[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
209 XPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
210
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
211 x1-=8; x2-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
212 }while(T<sincos_lookup0+1024);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
213 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
214 r0 = x1[6] - x2[6]; x1[6] += x2[6];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
215 r1 = x2[7] - x1[7]; x1[7] += x2[7];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
216 XNPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
217
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
218 r0 = x1[4] - x2[4]; x1[4] += x2[4];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
219 r1 = x2[5] - x1[5]; x1[5] += x2[5];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
220 XNPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
221
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
222 r0 = x1[2] - x2[2]; x1[2] += x2[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
223 r1 = x2[3] - x1[3]; x1[3] += x2[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
224 XNPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
225
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
226 r0 = x1[0] - x2[0]; x1[0] += x2[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
227 r1 = x2[1] - x1[1]; x1[1] += x2[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
228 XNPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
229
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
230 x1-=8; x2-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
231 }while(T>sincos_lookup0);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
232 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
233
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
234 STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
235
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
236 int stages=8-shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
237 int i,j;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
238
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
239 for(i=0;--stages>0;i++){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
240 for(j=0;j<(1<<i);j++)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
241 mdct_butterfly_generic(x+(points>>i)*j,points>>i,4<<(i+shift));
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
242 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
243
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
244 for(j=0;j<points;j+=32)
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
245 mdct_butterfly_32(x+j);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
246
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
247 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
248
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
249 static unsigned char bitrev[16]={0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
250
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
251 STIN int bitrev12(int x){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
252 return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
253 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
254
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
255 STIN void mdct_bitreverse(DATA_TYPE *x,int n,int step,int shift){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
256
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
257 int bit = 0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
258 DATA_TYPE *w0 = x;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
259 DATA_TYPE *w1 = x = w0+(n>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
260 LOOKUP_T *T = (step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
261 LOOKUP_T *Ttop = T+1024;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
262 DATA_TYPE r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
263
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
264 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
265 DATA_TYPE r3 = bitrev12(bit++);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
266 DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
267 DATA_TYPE *x1 = x + (r3>>shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
268
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
269 REG_TYPE r0 = x0[0] + x1[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
270 REG_TYPE r1 = x1[1] - x0[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
271
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
272 XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
273
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
274 w1 -= 4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
275
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
276 r0 = (x0[1] + x1[1])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
277 r1 = (x0[0] - x1[0])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
278 w0[0] = r0 + r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
279 w0[1] = r1 + r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
280 w1[2] = r0 - r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
281 w1[3] = r3 - r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
282
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
283 r3 = bitrev12(bit++);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
284 x0 = x + ((r3 ^ 0xfff)>>shift) -1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
285 x1 = x + (r3>>shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
286
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
287 r0 = x0[0] + x1[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
288 r1 = x1[1] - x0[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
289
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
290 XPROD32( r0, r1, T[1], T[0], &r2, &r3 ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
291
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
292 r0 = (x0[1] + x1[1])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
293 r1 = (x0[0] - x1[0])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
294 w0[2] = r0 + r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
295 w0[3] = r1 + r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
296 w1[0] = r0 - r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
297 w1[1] = r3 - r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
298
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
299 w0 += 4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
300 }while(T<Ttop);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
301 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
302 DATA_TYPE r3 = bitrev12(bit++);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
303 DATA_TYPE *x0 = x + ((r3 ^ 0xfff)>>shift) -1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
304 DATA_TYPE *x1 = x + (r3>>shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
305
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
306 REG_TYPE r0 = x0[0] + x1[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
307 REG_TYPE r1 = x1[1] - x0[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
308
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
309 T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
310
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
311 w1 -= 4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
312
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
313 r0 = (x0[1] + x1[1])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
314 r1 = (x0[0] - x1[0])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
315 w0[0] = r0 + r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
316 w0[1] = r1 + r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
317 w1[2] = r0 - r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
318 w1[3] = r3 - r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
319
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
320 r3 = bitrev12(bit++);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
321 x0 = x + ((r3 ^ 0xfff)>>shift) -1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
322 x1 = x + (r3>>shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
323
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
324 r0 = x0[0] + x1[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
325 r1 = x1[1] - x0[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
326
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
327 T-=step; XPROD32( r0, r1, T[0], T[1], &r2, &r3 );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
328
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
329 r0 = (x0[1] + x1[1])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
330 r1 = (x0[0] - x1[0])>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
331 w0[2] = r0 + r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
332 w0[3] = r1 + r3;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
333 w1[0] = r0 - r2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
334 w1[1] = r3 - r1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
335
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
336 w0 += 4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
337 }while(w0<w1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
338 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
339
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
340 void mdct_backward(int n, DATA_TYPE *in, DATA_TYPE *out){
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
341 int n2=n>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
342 int n4=n>>2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
343 DATA_TYPE *iX;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
344 DATA_TYPE *oX;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
345 LOOKUP_T *T;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
346 LOOKUP_T *V;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
347 int shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
348 int step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
349
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
350 for (shift=6;!(n&(1<<shift));shift++);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
351 shift=13-shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
352 step=2<<shift;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
353
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
354 /* rotate */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
355
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
356 iX = in+n2-7;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
357 oX = out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
358 T = sincos_lookup0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
359
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
360 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
361 oX-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
362 XPROD31( iX[4], iX[6], T[0], T[1], &oX[2], &oX[3] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
363 XPROD31( iX[0], iX[2], T[0], T[1], &oX[0], &oX[1] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
364 iX-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
365 }while(iX>=in+n4);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
366 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
367 oX-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
368 XPROD31( iX[4], iX[6], T[1], T[0], &oX[2], &oX[3] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
369 XPROD31( iX[0], iX[2], T[1], T[0], &oX[0], &oX[1] ); T-=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
370 iX-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
371 }while(iX>=in);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
372
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
373 iX = in+n2-8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
374 oX = out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
375 T = sincos_lookup0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
376
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
377 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
378 T+=step; XNPROD31( iX[6], iX[4], T[0], T[1], &oX[0], &oX[1] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
379 T+=step; XNPROD31( iX[2], iX[0], T[0], T[1], &oX[2], &oX[3] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
380 iX-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
381 oX+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
382 }while(iX>=in+n4);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
383 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
384 T-=step; XNPROD31( iX[6], iX[4], T[1], T[0], &oX[0], &oX[1] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
385 T-=step; XNPROD31( iX[2], iX[0], T[1], T[0], &oX[2], &oX[3] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
386 iX-=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
387 oX+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
388 }while(iX>=in);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
389
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
390 mdct_butterflies(out+n2,n2,shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
391 mdct_bitreverse(out,n,step,shift);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
392
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
393 /* rotate + window */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
394
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
395 step>>=2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
396 {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
397 DATA_TYPE *oX1=out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
398 DATA_TYPE *oX2=out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
399 DATA_TYPE *iX =out;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
400
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
401 switch(step) {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
402 default: {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
403 T=(step>=4)?(sincos_lookup0+(step>>1)):sincos_lookup1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
404 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
405 oX1-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
406 XPROD31( iX[0], -iX[1], T[0], T[1], &oX1[3], &oX2[0] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
407 XPROD31( iX[2], -iX[3], T[0], T[1], &oX1[2], &oX2[1] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
408 XPROD31( iX[4], -iX[5], T[0], T[1], &oX1[1], &oX2[2] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
409 XPROD31( iX[6], -iX[7], T[0], T[1], &oX1[0], &oX2[3] ); T+=step;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
410 oX2+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
411 iX+=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
412 }while(iX<oX1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
413 break;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
414 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
415
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
416 case 1: {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
417 /* linear interpolation between table values: offset=0.5, step=1 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
418 REG_TYPE t0,t1,v0,v1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
419 T = sincos_lookup0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
420 V = sincos_lookup1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
421 t0 = (*T++)>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
422 t1 = (*T++)>>1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
423 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
424 oX1-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
425
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
426 t0 += (v0 = (*V++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
427 t1 += (v1 = (*V++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
428 XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
429 v0 += (t0 = (*T++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
430 v1 += (t1 = (*T++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
431 XPROD31( iX[2], -iX[3], v0, v1, &oX1[2], &oX2[1] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
432 t0 += (v0 = (*V++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
433 t1 += (v1 = (*V++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
434 XPROD31( iX[4], -iX[5], t0, t1, &oX1[1], &oX2[2] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
435 v0 += (t0 = (*T++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
436 v1 += (t1 = (*T++)>>1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
437 XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
438
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
439 oX2+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
440 iX+=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
441 }while(iX<oX1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
442 break;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
443 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
444
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
445 case 0: {
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
446 /* linear interpolation between table values: offset=0.25, step=0.5 */
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
447 REG_TYPE t0,t1,v0,v1,q0,q1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
448 T = sincos_lookup0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
449 V = sincos_lookup1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
450 t0 = *T++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
451 t1 = *T++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
452 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
453 oX1-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
454
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
455 v0 = *V++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
456 v1 = *V++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
457 t0 += (q0 = (v0-t0)>>2);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
458 t1 += (q1 = (v1-t1)>>2);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
459 XPROD31( iX[0], -iX[1], t0, t1, &oX1[3], &oX2[0] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
460 t0 = v0-q0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
461 t1 = v1-q1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
462 XPROD31( iX[2], -iX[3], t0, t1, &oX1[2], &oX2[1] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
463
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
464 t0 = *T++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
465 t1 = *T++;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
466 v0 += (q0 = (t0-v0)>>2);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
467 v1 += (q1 = (t1-v1)>>2);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
468 XPROD31( iX[4], -iX[5], v0, v1, &oX1[1], &oX2[2] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
469 v0 = t0-q0;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
470 v1 = t1-q1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
471 XPROD31( iX[6], -iX[7], v0, v1, &oX1[0], &oX2[3] );
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
472
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
473 oX2+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
474 iX+=8;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
475 }while(iX<oX1);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
476 break;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
477 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
478 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
479
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
480 iX=out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
481 oX1=out+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
482 oX2=oX1;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
483
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
484 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
485 oX1-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
486 iX-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
487
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
488 oX2[0] = -(oX1[3] = iX[3]);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
489 oX2[1] = -(oX1[2] = iX[2]);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
490 oX2[2] = -(oX1[1] = iX[1]);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
491 oX2[3] = -(oX1[0] = iX[0]);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
492
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
493 oX2+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
494 }while(oX2<iX);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
495
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
496 iX=out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
497 oX1=out+n2+n4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
498 oX2=out+n2;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
499
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
500 do{
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
501 oX1-=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
502 oX1[0]= iX[3];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
503 oX1[1]= iX[2];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
504 oX1[2]= iX[1];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
505 oX1[3]= iX[0];
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
506 iX+=4;
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
507 }while(oX1>oX2);
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
508 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
509 }
8631a3803289 internal Tremor decoder for Ogg/Vorbis
henry
parents:
diff changeset
510