30 files changed, 625 insertions, 401 deletions
diff --git a/core/multimedia/opieplayer/libmad/COPYRIGHT b/core/multimedia/opieplayer/libmad/COPYRIGHT new file mode 100644 index 0000000..f30a707 --- a/dev/null +++ b/core/multimedia/opieplayer/libmad/COPYRIGHT | |||
@@ -0,0 +1,21 @@ | |||
1 | |||
2 | libmad - MPEG audio decoder library | ||
3 | Copyright (C) 2000-2001 Robert Leslie | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | |||
19 | If you would like to negotiate alternate licensing terms, you may do | ||
20 | so by contacting the author: Robert Leslie <rob@mars.org> | ||
21 | |||
diff --git a/core/multimedia/opieplayer/libmad/D.dat b/core/multimedia/opieplayer/libmad/D.dat index f33d30c..c3ee74c 100644 --- a/core/multimedia/opieplayer/libmad/D.dat +++ b/core/multimedia/opieplayer/libmad/D.dat | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * These are the coefficients for the subband synthesis window. This is a | 23 | * These are the coefficients for the subband synthesis window. This is a |
24 | * reordered version of Table B.3 from ISO/IEC 11172-3. | 24 | * reordered version of Table B.3 from ISO/IEC 11172-3. |
25 | * | 25 | * |
26 | * Every value is parameterized so that shift optimizations can be made at | 26 | * Every value is parameterized so that shift optimizations can be made at |
27 | * compile-time. For example, every value can be right-shifted 12 bits to | 27 | * compile-time. For example, every value can be right-shifted 12 bits to |
28 | * minimize multiply instruction times without any loss of accuracy. | 28 | * minimize multiply instruction times without any loss of accuracy. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | { PRESHIFT(0x00000000) /* 0.000000000 */,/* 0 */ | 31 | { PRESHIFT(0x00000000) /* 0.000000000 */,/* 0 */ |
32 | -PRESHIFT(0x0001d000) /* -0.000442505 */, | 32 | -PRESHIFT(0x0001d000) /* -0.000442505 */, |
33 | PRESHIFT(0x000d5000) /* 0.003250122 */, | 33 | PRESHIFT(0x000d5000) /* 0.003250122 */, |
34 | -PRESHIFT(0x001cb000) /* -0.007003784 */, | 34 | -PRESHIFT(0x001cb000) /* -0.007003784 */, |
35 | PRESHIFT(0x007f5000) /* 0.031082153 */, | 35 | PRESHIFT(0x007f5000) /* 0.031082153 */, |
36 | -PRESHIFT(0x01421000) /* -0.078628540 */, | 36 | -PRESHIFT(0x01421000) /* -0.078628540 */, |
37 | PRESHIFT(0x019ae000) /* 0.100311279 */, | 37 | PRESHIFT(0x019ae000) /* 0.100311279 */, |
38 | -PRESHIFT(0x09271000) /* -0.572036743 */, | 38 | -PRESHIFT(0x09271000) /* -0.572036743 */, |
39 | PRESHIFT(0x1251e000) /* 1.144989014 */, | 39 | PRESHIFT(0x1251e000) /* 1.144989014 */, |
40 | PRESHIFT(0x09271000) /* 0.572036743 */, | 40 | PRESHIFT(0x09271000) /* 0.572036743 */, |
41 | PRESHIFT(0x019ae000) /* 0.100311279 */, | 41 | PRESHIFT(0x019ae000) /* 0.100311279 */, |
42 | PRESHIFT(0x01421000) /* 0.078628540 */, | 42 | PRESHIFT(0x01421000) /* 0.078628540 */, |
43 | PRESHIFT(0x007f5000) /* 0.031082153 */, | 43 | PRESHIFT(0x007f5000) /* 0.031082153 */, |
44 | PRESHIFT(0x001cb000) /* 0.007003784 */, | 44 | PRESHIFT(0x001cb000) /* 0.007003784 */, |
45 | PRESHIFT(0x000d5000) /* 0.003250122 */, | 45 | PRESHIFT(0x000d5000) /* 0.003250122 */, |
46 | PRESHIFT(0x0001d000) /* 0.000442505 */, | 46 | PRESHIFT(0x0001d000) /* 0.000442505 */, |
47 | 47 | ||
48 | PRESHIFT(0x00000000) /* 0.000000000 */, | 48 | PRESHIFT(0x00000000) /* 0.000000000 */, |
49 | -PRESHIFT(0x0001d000) /* -0.000442505 */, | 49 | -PRESHIFT(0x0001d000) /* -0.000442505 */, |
50 | PRESHIFT(0x000d5000) /* 0.003250122 */, | 50 | PRESHIFT(0x000d5000) /* 0.003250122 */, |
diff --git a/core/multimedia/opieplayer/libmad/bit.c b/core/multimedia/opieplayer/libmad/bit.c index 2466c5f..4a4661b 100644 --- a/core/multimedia/opieplayer/libmad/bit.c +++ b/core/multimedia/opieplayer/libmad/bit.c | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # ifdef HAVE_LIMITS_H | 28 | # ifdef HAVE_LIMITS_H |
29 | # include <limits.h> | 29 | # include <limits.h> |
30 | # else | 30 | # else |
31 | # define CHAR_BIT 8 | 31 | # define CHAR_BIT 8 |
32 | # endif | 32 | # endif |
33 | 33 | ||
34 | # include "bit.h" | 34 | # include "bit.h" |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * This is the lookup table for computing the CRC-check word. | 37 | * This is the lookup table for computing the CRC-check word. |
38 | * As described in section 2.4.3.1 and depicted in Figure A.9 | 38 | * As described in section 2.4.3.1 and depicted in Figure A.9 |
39 | * of ISO/IEC 11172-3, the generator polynomial is: | 39 | * of ISO/IEC 11172-3, the generator polynomial is: |
40 | * | 40 | * |
41 | * G(X) = X^16 + X^15 + X^2 + 1 | 41 | * G(X) = X^16 + X^15 + X^2 + 1 |
42 | */ | 42 | */ |
43 | static | 43 | static |
44 | unsigned short const crc_table[256] = { | 44 | unsigned short const crc_table[256] = { |
45 | 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, | 45 | 0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, |
46 | 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, | 46 | 0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022, |
47 | 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, | 47 | 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072, |
48 | 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, | 48 | 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, |
49 | 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, | 49 | 0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, |
50 | 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, | 50 | 0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1, |
@@ -152,69 +152,86 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) | |||
152 | /* remaining bits in current byte */ | 152 | /* remaining bits in current byte */ |
153 | 153 | ||
154 | value = bitptr->cache & ((1 << bitptr->left) - 1); | 154 | value = bitptr->cache & ((1 << bitptr->left) - 1); |
155 | len -= bitptr->left; | 155 | len -= bitptr->left; |
156 | 156 | ||
157 | bitptr->byte++; | 157 | bitptr->byte++; |
158 | bitptr->left = CHAR_BIT; | 158 | bitptr->left = CHAR_BIT; |
159 | 159 | ||
160 | /* more bytes */ | 160 | /* more bytes */ |
161 | 161 | ||
162 | while (len >= CHAR_BIT) { | 162 | while (len >= CHAR_BIT) { |
163 | value = (value << CHAR_BIT) | *bitptr->byte++; | 163 | value = (value << CHAR_BIT) | *bitptr->byte++; |
164 | len -= CHAR_BIT; | 164 | len -= CHAR_BIT; |
165 | } | 165 | } |
166 | 166 | ||
167 | if (len > 0) { | 167 | if (len > 0) { |
168 | bitptr->cache = *bitptr->byte; | 168 | bitptr->cache = *bitptr->byte; |
169 | 169 | ||
170 | value = (value << len) | (bitptr->cache >> (CHAR_BIT - len)); | 170 | value = (value << len) | (bitptr->cache >> (CHAR_BIT - len)); |
171 | bitptr->left -= len; | 171 | bitptr->left -= len; |
172 | } | 172 | } |
173 | 173 | ||
174 | return value; | 174 | return value; |
175 | } | 175 | } |
176 | 176 | ||
177 | # if 0 | 177 | # if 0 |
178 | /* | 178 | /* |
179 | * NAME:bit->write() | 179 | * NAME:bit->write() |
180 | * DESCRIPTION:write an arbitrary number of bits | 180 | * DESCRIPTION:write an arbitrary number of bits |
181 | */ | 181 | */ |
182 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, | 182 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, |
183 | unsigned long value) | 183 | unsigned long value) |
184 | { | 184 | { |
185 | unsigned char *ptr; | 185 | unsigned char *ptr; |
186 | 186 | ||
187 | ptr = (unsigned char *) bitptr->byte; | 187 | ptr = (unsigned char *) bitptr->byte; |
188 | 188 | ||
189 | /* ... */ | 189 | /* ... */ |
190 | } | 190 | } |
191 | # endif | 191 | # endif |
192 | 192 | ||
193 | /* | 193 | /* |
194 | * NAME:bit->crc() | 194 | * NAME:bit->crc() |
195 | * DESCRIPTION:compute CRC-check word | 195 | * DESCRIPTION:compute CRC-check word |
196 | */ | 196 | */ |
197 | unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, | 197 | unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, |
198 | unsigned short init) | 198 | unsigned short init) |
199 | { | 199 | { |
200 | register unsigned int crc, data; | 200 | register unsigned int crc; |
201 | 201 | ||
202 | # if CHAR_BIT == 8 | 202 | for (crc = init; len >= 32; len -= 32) { |
203 | for (crc = init; len >= 8; len -= 8) { | 203 | register unsigned long data; |
204 | crc = (crc << 8) ^ | 204 | |
205 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | 205 | data = mad_bit_read(&bitptr, 32); |
206 | |||
207 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff]; | ||
208 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff]; | ||
209 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff]; | ||
210 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff]; | ||
211 | } | ||
212 | |||
213 | switch (len / 8) { | ||
214 | case 3: crc = (crc << 8) ^ | ||
215 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
216 | case 2: crc = (crc << 8) ^ | ||
217 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
218 | case 1: crc = (crc << 8) ^ | ||
219 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
220 | |||
221 | len %= 8; | ||
222 | |||
223 | case 0: break; | ||
206 | } | 224 | } |
207 | # else | ||
208 | crc = init; | ||
209 | # endif | ||
210 | 225 | ||
211 | while (len--) { | 226 | while (len--) { |
212 | data = mad_bit_read(&bitptr, 1) ^ (crc >> 15); | 227 | register unsigned int msb; |
228 | |||
229 | msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15); | ||
213 | 230 | ||
214 | crc <<= 1; | 231 | crc <<= 1; |
215 | if (data & 1) | 232 | if (msb & 1) |
216 | crc ^= CRC_POLY; | 233 | crc ^= CRC_POLY; |
217 | } | 234 | } |
218 | 235 | ||
219 | return crc & 0xffff; | 236 | return crc & 0xffff; |
220 | } | 237 | } |
diff --git a/core/multimedia/opieplayer/libmad/bit.h b/core/multimedia/opieplayer/libmad/bit.h index f315bc9..3448d40 100644 --- a/core/multimedia/opieplayer/libmad/bit.h +++ b/core/multimedia/opieplayer/libmad/bit.h | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_BIT_H | 22 | # ifndef LIBMAD_BIT_H |
23 | # define LIBMAD_BIT_H | 23 | # define LIBMAD_BIT_H |
24 | 24 | ||
25 | struct mad_bitptr { | 25 | struct mad_bitptr { |
26 | unsigned char const *byte; | 26 | unsigned char const *byte; |
27 | unsigned short cache; | 27 | unsigned short cache; |
28 | unsigned short left; | 28 | unsigned short left; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); | 31 | void mad_bit_init(struct mad_bitptr *, unsigned char const *); |
32 | 32 | ||
33 | # define mad_bit_finish(bitptr) /* nothing */ | 33 | # define mad_bit_finish(bitptr) /* nothing */ |
34 | 34 | ||
35 | unsigned int mad_bit_length(struct mad_bitptr const *, | 35 | unsigned int mad_bit_length(struct mad_bitptr const *, |
36 | struct mad_bitptr const *); | 36 | struct mad_bitptr const *); |
37 | 37 | ||
38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left) | 38 | # define mad_bit_bitsleft(bitptr) ((bitptr)->left) |
39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); | 39 | unsigned char const *mad_bit_nextbyte(struct mad_bitptr const *); |
40 | 40 | ||
41 | void mad_bit_skip(struct mad_bitptr *, unsigned int); | 41 | void mad_bit_skip(struct mad_bitptr *, unsigned int); |
42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); | 42 | unsigned long mad_bit_read(struct mad_bitptr *, unsigned int); |
43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); | 43 | void mad_bit_write(struct mad_bitptr *, unsigned int, unsigned long); |
44 | 44 | ||
45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); | 45 | unsigned short mad_bit_crc(struct mad_bitptr, unsigned int, unsigned short); |
46 | 46 | ||
47 | # endif | 47 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/decoder.c b/core/multimedia/opieplayer/libmad/decoder.c index dcf7cf3..b2b6cbb 100644 --- a/core/multimedia/opieplayer/libmad/decoder.c +++ b/core/multimedia/opieplayer/libmad/decoder.c | |||
@@ -1,196 +1,201 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # else | ||
25 | # ifndef WEXITSTATUS | ||
26 | # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) | ||
27 | # endif | ||
28 | # ifndef WIFEXITED | ||
29 | # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) | ||
30 | # endif | ||
31 | # endif | 24 | # endif |
32 | 25 | ||
33 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
34 | 27 | ||
35 | # include <sys/types.h> | 28 | # ifdef HAVE_SYS_TYPES_H |
29 | # include <sys/types.h> | ||
30 | # endif | ||
36 | 31 | ||
37 | # ifdef HAVE_SYS_WAIT_H | 32 | # ifdef HAVE_SYS_WAIT_H |
38 | # include <sys/wait.h> | 33 | # include <sys/wait.h> |
39 | # endif | 34 | # endif |
40 | 35 | ||
41 | # ifdef HAVE_UNISTD_H | 36 | # ifdef HAVE_UNISTD_H |
42 | # include <unistd.h> | 37 | # include <unistd.h> |
43 | # endif | 38 | # endif |
44 | 39 | ||
45 | # include <fcntl.h> | 40 | # ifdef HAVE_FCNTL_H |
41 | # include <fcntl.h> | ||
42 | # endif | ||
43 | |||
46 | # include <stdlib.h> | 44 | # include <stdlib.h> |
47 | # include <errno.h> | 45 | |
46 | # ifdef HAVE_ERRNO_H | ||
47 | # include <errno.h> | ||
48 | # endif | ||
48 | 49 | ||
49 | # include "stream.h" | 50 | # include "stream.h" |
50 | # include "frame.h" | 51 | # include "frame.h" |
51 | # include "synth.h" | 52 | # include "synth.h" |
52 | # include "decoder.h" | 53 | # include "decoder.h" |
53 | 54 | ||
54 | void mad_decoder_init(struct mad_decoder *decoder, void *data, | 55 | void mad_decoder_init(struct mad_decoder *decoder, void *data, |
55 | enum mad_flow (*input_func)(void *, struct mad_stream *), | 56 | enum mad_flow (*input_func)(void *, |
57 | struct mad_stream *), | ||
56 | enum mad_flow (*header_func)(void *, | 58 | enum mad_flow (*header_func)(void *, |
57 | struct mad_header const *), | 59 | struct mad_header const *), |
58 | enum mad_flow (*filter_func)(void *, struct mad_frame *), | 60 | enum mad_flow (*filter_func)(void *, |
61 | struct mad_stream const *, | ||
62 | struct mad_frame *), | ||
59 | enum mad_flow (*output_func)(void *, | 63 | enum mad_flow (*output_func)(void *, |
60 | struct mad_header const *, | 64 | struct mad_header const *, |
61 | struct mad_pcm *), | 65 | struct mad_pcm *), |
62 | enum mad_flow (*error_func)(void *, struct mad_stream *, | 66 | enum mad_flow (*error_func)(void *, |
67 | struct mad_stream *, | ||
63 | struct mad_frame *), | 68 | struct mad_frame *), |
64 | enum mad_flow (*message_func)(void *, | 69 | enum mad_flow (*message_func)(void *, |
65 | void *, unsigned int *)) | 70 | void *, unsigned int *)) |
66 | { | 71 | { |
67 | decoder->mode = -1; | 72 | decoder->mode = -1; |
68 | 73 | ||
69 | decoder->options = 0; | 74 | decoder->options = 0; |
70 | 75 | ||
71 | decoder->async.pid = 0; | 76 | decoder->async.pid = 0; |
72 | decoder->async.in = -1; | 77 | decoder->async.in = -1; |
73 | decoder->async.out = -1; | 78 | decoder->async.out = -1; |
74 | 79 | ||
75 | decoder->sync = 0; | 80 | decoder->sync = 0; |
76 | 81 | ||
77 | decoder->cb_data = data; | 82 | decoder->cb_data = data; |
78 | 83 | ||
79 | decoder->input_func = input_func; | 84 | decoder->input_func = input_func; |
80 | decoder->header_func = header_func; | 85 | decoder->header_func = header_func; |
81 | decoder->filter_func = filter_func; | 86 | decoder->filter_func = filter_func; |
82 | decoder->output_func = output_func; | 87 | decoder->output_func = output_func; |
83 | decoder->error_func = error_func; | 88 | decoder->error_func = error_func; |
84 | decoder->message_func = message_func; | 89 | decoder->message_func = message_func; |
85 | } | 90 | } |
86 | 91 | ||
87 | int mad_decoder_finish(struct mad_decoder *decoder) | 92 | int mad_decoder_finish(struct mad_decoder *decoder) |
88 | { | 93 | { |
94 | # if defined(USE_ASYNC) | ||
89 | if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) { | 95 | if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) { |
90 | pid_t pid; | 96 | pid_t pid; |
91 | int status; | 97 | int status; |
92 | 98 | ||
93 | close(decoder->async.in); | 99 | close(decoder->async.in); |
94 | 100 | ||
95 | do { | 101 | do |
96 | pid = waitpid(decoder->async.pid, &status, 0); | 102 | pid = waitpid(decoder->async.pid, &status, 0); |
97 | } | ||
98 | while (pid == -1 && errno == EINTR); | 103 | while (pid == -1 && errno == EINTR); |
99 | 104 | ||
100 | decoder->mode = -1; | 105 | decoder->mode = -1; |
101 | 106 | ||
102 | close(decoder->async.out); | 107 | close(decoder->async.out); |
103 | 108 | ||
104 | decoder->async.pid = 0; | 109 | decoder->async.pid = 0; |
105 | decoder->async.in = -1; | 110 | decoder->async.in = -1; |
106 | decoder->async.out = -1; | 111 | decoder->async.out = -1; |
107 | 112 | ||
108 | if (pid == -1) | 113 | if (pid == -1) |
109 | return -1; | 114 | return -1; |
110 | 115 | ||
111 | return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0; | 116 | return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0; |
112 | } | 117 | } |
118 | # endif | ||
113 | 119 | ||
114 | return 0; | 120 | return 0; |
115 | } | 121 | } |
116 | 122 | ||
123 | # if defined(USE_ASYNC) | ||
117 | static | 124 | static |
118 | enum mad_flow send_io(int fd, void const *data, size_t len) | 125 | enum mad_flow send_io(int fd, void const *data, size_t len) |
119 | { | 126 | { |
120 | char const *ptr = data; | 127 | char const *ptr = data; |
121 | ssize_t count; | 128 | ssize_t count; |
122 | 129 | ||
123 | while (len) { | 130 | while (len) { |
124 | do { | 131 | do |
125 | count = write(fd, ptr, len); | 132 | count = write(fd, ptr, len); |
126 | } | ||
127 | while (count == -1 && errno == EINTR); | 133 | while (count == -1 && errno == EINTR); |
128 | 134 | ||
129 | if (count == -1) | 135 | if (count == -1) |
130 | return MAD_FLOW_BREAK; | 136 | return MAD_FLOW_BREAK; |
131 | 137 | ||
132 | len -= count; | 138 | len -= count; |
133 | ptr += count; | 139 | ptr += count; |
134 | } | 140 | } |
135 | 141 | ||
136 | return MAD_FLOW_CONTINUE; | 142 | return MAD_FLOW_CONTINUE; |
137 | } | 143 | } |
138 | 144 | ||
139 | static | 145 | static |
140 | enum mad_flow receive_io(int fd, void *buffer, size_t len) | 146 | enum mad_flow receive_io(int fd, void *buffer, size_t len) |
141 | { | 147 | { |
142 | char *ptr = buffer; | 148 | char *ptr = buffer; |
143 | ssize_t count; | 149 | ssize_t count; |
144 | 150 | ||
145 | while (len) { | 151 | while (len) { |
146 | do { | 152 | do |
147 | count = read(fd, ptr, len); | 153 | count = read(fd, ptr, len); |
148 | } | ||
149 | while (count == -1 && errno == EINTR); | 154 | while (count == -1 && errno == EINTR); |
150 | 155 | ||
151 | if (count == -1) | 156 | if (count == -1) |
152 | return (errno == EAGAIN) ? MAD_FLOW_IGNORE : MAD_FLOW_BREAK; | 157 | return (errno == EAGAIN) ? MAD_FLOW_IGNORE : MAD_FLOW_BREAK; |
153 | else if (count == 0) | 158 | else if (count == 0) |
154 | return MAD_FLOW_STOP; | 159 | return MAD_FLOW_STOP; |
155 | 160 | ||
156 | len -= count; | 161 | len -= count; |
157 | ptr += count; | 162 | ptr += count; |
158 | } | 163 | } |
159 | 164 | ||
160 | return MAD_FLOW_CONTINUE; | 165 | return MAD_FLOW_CONTINUE; |
161 | } | 166 | } |
162 | 167 | ||
163 | static | 168 | static |
164 | enum mad_flow receive_io_blocking(int fd, void *buffer, size_t len) | 169 | enum mad_flow receive_io_blocking(int fd, void *buffer, size_t len) |
165 | { | 170 | { |
166 | int flags, blocking; | 171 | int flags, blocking; |
167 | enum mad_flow result; | 172 | enum mad_flow result; |
168 | 173 | ||
169 | flags = fcntl(fd, F_GETFL); | 174 | flags = fcntl(fd, F_GETFL); |
170 | if (flags == -1) | 175 | if (flags == -1) |
171 | return MAD_FLOW_BREAK; | 176 | return MAD_FLOW_BREAK; |
172 | 177 | ||
173 | blocking = flags & ~O_NONBLOCK; | 178 | blocking = flags & ~O_NONBLOCK; |
174 | 179 | ||
175 | if (blocking != flags && | 180 | if (blocking != flags && |
176 | fcntl(fd, F_SETFL, blocking) == -1) | 181 | fcntl(fd, F_SETFL, blocking) == -1) |
177 | return MAD_FLOW_BREAK; | 182 | return MAD_FLOW_BREAK; |
178 | 183 | ||
179 | result = receive_io(fd, buffer, len); | 184 | result = receive_io(fd, buffer, len); |
180 | 185 | ||
181 | if (flags != blocking && | 186 | if (flags != blocking && |
182 | fcntl(fd, F_SETFL, flags) == -1) | 187 | fcntl(fd, F_SETFL, flags) == -1) |
183 | return MAD_FLOW_BREAK; | 188 | return MAD_FLOW_BREAK; |
184 | 189 | ||
185 | return result; | 190 | return result; |
186 | } | 191 | } |
187 | 192 | ||
188 | static | 193 | static |
189 | enum mad_flow send(int fd, void const *message, unsigned int size) | 194 | enum mad_flow send(int fd, void const *message, unsigned int size) |
190 | { | 195 | { |
191 | enum mad_flow result; | 196 | enum mad_flow result; |
192 | 197 | ||
193 | /* send size */ | 198 | /* send size */ |
194 | 199 | ||
195 | result = send_io(fd, &size, sizeof(size)); | 200 | result = send_io(fd, &size, sizeof(size)); |
196 | 201 | ||
@@ -236,319 +241,330 @@ enum mad_flow receive(int fd, void **message, unsigned int *size) | |||
236 | } | 241 | } |
237 | 242 | ||
238 | /* throw away remainder of message */ | 243 | /* throw away remainder of message */ |
239 | 244 | ||
240 | while (actual && result == MAD_FLOW_CONTINUE) { | 245 | while (actual && result == MAD_FLOW_CONTINUE) { |
241 | char sink[256]; | 246 | char sink[256]; |
242 | unsigned int len; | 247 | unsigned int len; |
243 | 248 | ||
244 | len = actual > sizeof(sink) ? sizeof(sink) : actual; | 249 | len = actual > sizeof(sink) ? sizeof(sink) : actual; |
245 | 250 | ||
246 | result = receive_io_blocking(fd, sink, len); | 251 | result = receive_io_blocking(fd, sink, len); |
247 | 252 | ||
248 | actual -= len; | 253 | actual -= len; |
249 | } | 254 | } |
250 | } | 255 | } |
251 | 256 | ||
252 | return result; | 257 | return result; |
253 | } | 258 | } |
254 | 259 | ||
255 | static | 260 | static |
256 | enum mad_flow check_message(struct mad_decoder *decoder) | 261 | enum mad_flow check_message(struct mad_decoder *decoder) |
257 | { | 262 | { |
258 | enum mad_flow result; | 263 | enum mad_flow result; |
259 | void *message = 0; | 264 | void *message = 0; |
260 | unsigned int size; | 265 | unsigned int size; |
261 | 266 | ||
262 | result = receive(decoder->async.in, &message, &size); | 267 | result = receive(decoder->async.in, &message, &size); |
263 | 268 | ||
264 | if (result == MAD_FLOW_CONTINUE) { | 269 | if (result == MAD_FLOW_CONTINUE) { |
265 | if (decoder->message_func == 0) | 270 | if (decoder->message_func == 0) |
266 | size = 0; | 271 | size = 0; |
267 | else { | 272 | else { |
268 | result = decoder->message_func(decoder->cb_data, message, &size); | 273 | result = decoder->message_func(decoder->cb_data, message, &size); |
269 | 274 | ||
270 | if (result == MAD_FLOW_IGNORE || | 275 | if (result == MAD_FLOW_IGNORE || |
271 | result == MAD_FLOW_BREAK) | 276 | result == MAD_FLOW_BREAK) |
272 | size = 0; | 277 | size = 0; |
273 | } | 278 | } |
274 | 279 | ||
275 | if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) | 280 | if (send(decoder->async.out, message, size) != MAD_FLOW_CONTINUE) |
276 | result = MAD_FLOW_BREAK; | 281 | result = MAD_FLOW_BREAK; |
277 | } | 282 | } |
278 | 283 | ||
279 | if (message) | 284 | if (message) |
280 | free(message); | 285 | free(message); |
281 | 286 | ||
282 | return result; | 287 | return result; |
283 | } | 288 | } |
289 | # endif | ||
284 | 290 | ||
285 | static | 291 | static |
286 | enum mad_flow error_default(void *data, struct mad_stream *stream, | 292 | enum mad_flow error_default(void *data, struct mad_stream *stream, |
287 | struct mad_frame *frame) | 293 | struct mad_frame *frame) |
288 | { | 294 | { |
289 | int *bad_last_frame = data; | 295 | int *bad_last_frame = data; |
290 | 296 | ||
291 | switch (stream->error) { | 297 | switch (stream->error) { |
292 | case MAD_ERROR_BADCRC: | 298 | case MAD_ERROR_BADCRC: |
293 | if (*bad_last_frame) | 299 | if (*bad_last_frame) |
294 | mad_frame_mute(frame); | 300 | mad_frame_mute(frame); |
295 | else | 301 | else |
296 | *bad_last_frame = 1; | 302 | *bad_last_frame = 1; |
297 | 303 | ||
298 | return MAD_FLOW_IGNORE; | 304 | return MAD_FLOW_IGNORE; |
299 | 305 | ||
300 | default: | 306 | default: |
301 | return MAD_FLOW_CONTINUE; | 307 | return MAD_FLOW_CONTINUE; |
302 | } | 308 | } |
303 | } | 309 | } |
304 | 310 | ||
305 | static | 311 | static |
306 | int run_sync(struct mad_decoder *decoder) | 312 | int run_sync(struct mad_decoder *decoder) |
307 | { | 313 | { |
308 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); | 314 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); |
309 | void *error_data; | 315 | void *error_data; |
310 | int bad_last_frame = 0; | 316 | int bad_last_frame = 0; |
311 | struct mad_stream *stream; | 317 | struct mad_stream *stream; |
312 | struct mad_frame *frame; | 318 | struct mad_frame *frame; |
313 | struct mad_synth *synth; | 319 | struct mad_synth *synth; |
314 | int result = 0; | 320 | int result = 0; |
315 | 321 | ||
316 | if (decoder->input_func == 0) | 322 | if (decoder->input_func == 0) |
317 | return 0; | 323 | return 0; |
318 | 324 | ||
319 | if (decoder->error_func) { | 325 | if (decoder->error_func) { |
320 | error_func = decoder->error_func; | 326 | error_func = decoder->error_func; |
321 | error_data = decoder->cb_data; | 327 | error_data = decoder->cb_data; |
322 | } | 328 | } |
323 | else { | 329 | else { |
324 | error_func = error_default; | 330 | error_func = error_default; |
325 | error_data = &bad_last_frame; | 331 | error_data = &bad_last_frame; |
326 | } | 332 | } |
327 | 333 | ||
328 | stream = &decoder->sync->stream; | 334 | stream = &decoder->sync->stream; |
329 | frame = &decoder->sync->frame; | 335 | frame = &decoder->sync->frame; |
330 | synth = &decoder->sync->synth; | 336 | synth = &decoder->sync->synth; |
331 | 337 | ||
332 | mad_stream_init(stream); | 338 | mad_stream_init(stream); |
333 | mad_frame_init(frame); | 339 | mad_frame_init(frame); |
334 | mad_synth_init(synth); | 340 | mad_synth_init(synth); |
335 | 341 | ||
336 | mad_stream_options(stream, decoder->options); | 342 | mad_stream_options(stream, decoder->options); |
337 | 343 | ||
338 | do { | 344 | do { |
339 | switch (decoder->input_func(decoder->cb_data, stream)) { | 345 | switch (decoder->input_func(decoder->cb_data, stream)) { |
340 | case MAD_FLOW_STOP: | 346 | case MAD_FLOW_STOP: |
341 | goto done; | 347 | goto done; |
342 | case MAD_FLOW_BREAK: | 348 | case MAD_FLOW_BREAK: |
343 | goto fail; | 349 | goto fail; |
344 | case MAD_FLOW_IGNORE: | 350 | case MAD_FLOW_IGNORE: |
345 | continue; | 351 | continue; |
346 | case MAD_FLOW_CONTINUE: | 352 | case MAD_FLOW_CONTINUE: |
347 | break; | 353 | break; |
348 | } | 354 | } |
349 | 355 | ||
350 | while (1) { | 356 | while (1) { |
357 | # if defined(USE_ASYNC) | ||
351 | if (decoder->mode == MAD_DECODER_MODE_ASYNC) { | 358 | if (decoder->mode == MAD_DECODER_MODE_ASYNC) { |
352 | switch (check_message(decoder)) { | 359 | switch (check_message(decoder)) { |
353 | case MAD_FLOW_IGNORE: | 360 | case MAD_FLOW_IGNORE: |
354 | case MAD_FLOW_CONTINUE: | 361 | case MAD_FLOW_CONTINUE: |
355 | break; | 362 | break; |
356 | case MAD_FLOW_BREAK: | 363 | case MAD_FLOW_BREAK: |
357 | goto fail; | 364 | goto fail; |
358 | case MAD_FLOW_STOP: | 365 | case MAD_FLOW_STOP: |
359 | goto done; | 366 | goto done; |
360 | } | 367 | } |
361 | } | 368 | } |
369 | # endif | ||
362 | 370 | ||
363 | if (decoder->header_func) { | 371 | if (decoder->header_func) { |
364 | if (mad_header_decode(&frame->header, stream) == -1) { | 372 | if (mad_header_decode(&frame->header, stream) == -1) { |
365 | if (!MAD_RECOVERABLE(stream->error)) | 373 | if (!MAD_RECOVERABLE(stream->error)) |
366 | break; | 374 | break; |
367 | 375 | ||
368 | switch (error_func(error_data, stream, frame)) { | 376 | switch (error_func(error_data, stream, frame)) { |
369 | case MAD_FLOW_STOP: | 377 | case MAD_FLOW_STOP: |
370 | goto done; | 378 | goto done; |
371 | case MAD_FLOW_BREAK: | 379 | case MAD_FLOW_BREAK: |
372 | goto fail; | 380 | goto fail; |
373 | case MAD_FLOW_IGNORE: | 381 | case MAD_FLOW_IGNORE: |
374 | case MAD_FLOW_CONTINUE: | 382 | case MAD_FLOW_CONTINUE: |
375 | default: | 383 | default: |
376 | continue; | 384 | continue; |
377 | } | 385 | } |
378 | } | 386 | } |
379 | 387 | ||
380 | switch (decoder->header_func(decoder->cb_data, &frame->header)) { | 388 | switch (decoder->header_func(decoder->cb_data, &frame->header)) { |
381 | case MAD_FLOW_STOP: | 389 | case MAD_FLOW_STOP: |
382 | goto done; | 390 | goto done; |
383 | case MAD_FLOW_BREAK: | 391 | case MAD_FLOW_BREAK: |
384 | goto fail; | 392 | goto fail; |
385 | case MAD_FLOW_IGNORE: | 393 | case MAD_FLOW_IGNORE: |
386 | continue; | 394 | continue; |
387 | case MAD_FLOW_CONTINUE: | 395 | case MAD_FLOW_CONTINUE: |
388 | break; | 396 | break; |
389 | } | 397 | } |
390 | } | 398 | } |
391 | 399 | ||
392 | if (mad_frame_decode(frame, stream) == -1) { | 400 | if (mad_frame_decode(frame, stream) == -1) { |
393 | if (!MAD_RECOVERABLE(stream->error)) | 401 | if (!MAD_RECOVERABLE(stream->error)) |
394 | break; | 402 | break; |
395 | 403 | ||
396 | switch (error_func(error_data, stream, frame)) { | 404 | switch (error_func(error_data, stream, frame)) { |
397 | case MAD_FLOW_STOP: | 405 | case MAD_FLOW_STOP: |
398 | goto done; | 406 | goto done; |
399 | case MAD_FLOW_BREAK: | 407 | case MAD_FLOW_BREAK: |
400 | goto fail; | 408 | goto fail; |
401 | case MAD_FLOW_IGNORE: | 409 | case MAD_FLOW_IGNORE: |
402 | break; | 410 | break; |
403 | case MAD_FLOW_CONTINUE: | 411 | case MAD_FLOW_CONTINUE: |
404 | default: | 412 | default: |
405 | continue; | 413 | continue; |
406 | } | 414 | } |
407 | } | 415 | } |
408 | else | 416 | else |
409 | bad_last_frame = 0; | 417 | bad_last_frame = 0; |
410 | 418 | ||
411 | if (decoder->filter_func) { | 419 | if (decoder->filter_func) { |
412 | switch (decoder->filter_func(decoder->cb_data, frame)) { | 420 | switch (decoder->filter_func(decoder->cb_data, stream, frame)) { |
413 | case MAD_FLOW_STOP: | 421 | case MAD_FLOW_STOP: |
414 | goto done; | 422 | goto done; |
415 | case MAD_FLOW_BREAK: | 423 | case MAD_FLOW_BREAK: |
416 | goto fail; | 424 | goto fail; |
417 | case MAD_FLOW_IGNORE: | 425 | case MAD_FLOW_IGNORE: |
418 | continue; | 426 | continue; |
419 | case MAD_FLOW_CONTINUE: | 427 | case MAD_FLOW_CONTINUE: |
420 | break; | 428 | break; |
421 | } | 429 | } |
422 | } | 430 | } |
423 | 431 | ||
424 | mad_synth_frame(synth, frame); | 432 | mad_synth_frame(synth, frame); |
425 | 433 | ||
426 | if (decoder->output_func) { | 434 | if (decoder->output_func) { |
427 | switch (decoder->output_func(decoder->cb_data, | 435 | switch (decoder->output_func(decoder->cb_data, |
428 | &frame->header, &synth->pcm)) { | 436 | &frame->header, &synth->pcm)) { |
429 | case MAD_FLOW_STOP: | 437 | case MAD_FLOW_STOP: |
430 | goto done; | 438 | goto done; |
431 | case MAD_FLOW_BREAK: | 439 | case MAD_FLOW_BREAK: |
432 | goto fail; | 440 | goto fail; |
433 | case MAD_FLOW_IGNORE: | 441 | case MAD_FLOW_IGNORE: |
434 | case MAD_FLOW_CONTINUE: | 442 | case MAD_FLOW_CONTINUE: |
435 | break; | 443 | break; |
436 | } | 444 | } |
437 | } | 445 | } |
438 | } | 446 | } |
439 | } | 447 | } |
440 | while (stream->error == MAD_ERROR_BUFLEN); | 448 | while (stream->error == MAD_ERROR_BUFLEN); |
441 | 449 | ||
442 | fail: | 450 | fail: |
443 | result = -1; | 451 | result = -1; |
444 | 452 | ||
445 | done: | 453 | done: |
446 | mad_synth_finish(synth); | 454 | mad_synth_finish(synth); |
447 | mad_frame_finish(frame); | 455 | mad_frame_finish(frame); |
448 | mad_stream_finish(stream); | 456 | mad_stream_finish(stream); |
449 | 457 | ||
450 | return result; | 458 | return result; |
451 | } | 459 | } |
452 | 460 | ||
461 | # if defined(USE_ASYNC) | ||
453 | static | 462 | static |
454 | int run_async(struct mad_decoder *decoder) | 463 | int run_async(struct mad_decoder *decoder) |
455 | { | 464 | { |
456 | pid_t pid; | 465 | pid_t pid; |
457 | int ptoc[2], ctop[2], flags; | 466 | int ptoc[2], ctop[2], flags; |
458 | 467 | ||
459 | if (pipe(ptoc) == -1) | 468 | if (pipe(ptoc) == -1) |
460 | return -1; | 469 | return -1; |
461 | 470 | ||
462 | if (pipe(ctop) == -1) { | 471 | if (pipe(ctop) == -1) { |
463 | close(ptoc[0]); | 472 | close(ptoc[0]); |
464 | close(ptoc[1]); | 473 | close(ptoc[1]); |
465 | return -1; | 474 | return -1; |
466 | } | 475 | } |
467 | 476 | ||
468 | flags = fcntl(ptoc[0], F_GETFL); | 477 | flags = fcntl(ptoc[0], F_GETFL); |
469 | if (flags == -1 || | 478 | if (flags == -1 || |
470 | fcntl(ptoc[0], F_SETFL, flags | O_NONBLOCK) == -1) { | 479 | fcntl(ptoc[0], F_SETFL, flags | O_NONBLOCK) == -1) { |
471 | close(ctop[0]); | 480 | close(ctop[0]); |
472 | close(ctop[1]); | 481 | close(ctop[1]); |
473 | close(ptoc[0]); | 482 | close(ptoc[0]); |
474 | close(ptoc[1]); | 483 | close(ptoc[1]); |
475 | return -1; | 484 | return -1; |
476 | } | 485 | } |
477 | 486 | ||
478 | pid = fork(); | 487 | pid = fork(); |
479 | if (pid == -1) { | 488 | if (pid == -1) { |
480 | close(ctop[0]); | 489 | close(ctop[0]); |
481 | close(ctop[1]); | 490 | close(ctop[1]); |
482 | close(ptoc[0]); | 491 | close(ptoc[0]); |
483 | close(ptoc[1]); | 492 | close(ptoc[1]); |
484 | return -1; | 493 | return -1; |
485 | } | 494 | } |
486 | 495 | ||
487 | decoder->async.pid = pid; | 496 | decoder->async.pid = pid; |
488 | 497 | ||
489 | if (pid) { | 498 | if (pid) { |
490 | /* parent */ | 499 | /* parent */ |
491 | 500 | ||
492 | close(ptoc[0]); | 501 | close(ptoc[0]); |
493 | close(ctop[1]); | 502 | close(ctop[1]); |
494 | 503 | ||
495 | decoder->async.in = ctop[0]; | 504 | decoder->async.in = ctop[0]; |
496 | decoder->async.out = ptoc[1]; | 505 | decoder->async.out = ptoc[1]; |
497 | 506 | ||
498 | return 0; | 507 | return 0; |
499 | } | 508 | } |
500 | 509 | ||
501 | /* child */ | 510 | /* child */ |
502 | 511 | ||
503 | close(ptoc[1]); | 512 | close(ptoc[1]); |
504 | close(ctop[0]); | 513 | close(ctop[0]); |
505 | 514 | ||
506 | decoder->async.in = ptoc[0]; | 515 | decoder->async.in = ptoc[0]; |
507 | decoder->async.out = ctop[1]; | 516 | decoder->async.out = ctop[1]; |
508 | 517 | ||
509 | _exit(run_sync(decoder)); | 518 | _exit(run_sync(decoder)); |
510 | 519 | ||
511 | /* not reached */ | 520 | /* not reached */ |
512 | return -1; | 521 | return -1; |
513 | } | 522 | } |
523 | # endif | ||
514 | 524 | ||
515 | int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) | 525 | int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) |
516 | { | 526 | { |
517 | int result; | 527 | int result; |
518 | int (*run)(struct mad_decoder *) = 0; | 528 | int (*run)(struct mad_decoder *) = 0; |
519 | 529 | ||
520 | switch (decoder->mode = mode) { | 530 | switch (decoder->mode = mode) { |
521 | case MAD_DECODER_MODE_SYNC: | 531 | case MAD_DECODER_MODE_SYNC: |
522 | run = run_sync; | 532 | run = run_sync; |
523 | break; | 533 | break; |
524 | 534 | ||
525 | case MAD_DECODER_MODE_ASYNC: | 535 | case MAD_DECODER_MODE_ASYNC: |
536 | # if defined(USE_ASYNC) | ||
526 | run = run_async; | 537 | run = run_async; |
538 | # endif | ||
527 | break; | 539 | break; |
528 | } | 540 | } |
529 | 541 | ||
530 | if (run == 0) | 542 | if (run == 0) |
531 | return -1; | 543 | return -1; |
532 | 544 | ||
533 | decoder->sync = malloc(sizeof(*decoder->sync)); | 545 | decoder->sync = malloc(sizeof(*decoder->sync)); |
534 | if (decoder->sync == 0) | 546 | if (decoder->sync == 0) |
535 | return -1; | 547 | return -1; |
536 | 548 | ||
537 | result = run(decoder); | 549 | result = run(decoder); |
538 | 550 | ||
539 | free(decoder->sync); | 551 | free(decoder->sync); |
540 | decoder->sync = 0; | 552 | decoder->sync = 0; |
541 | 553 | ||
542 | return result; | 554 | return result; |
543 | } | 555 | } |
544 | 556 | ||
545 | int mad_decoder_message(struct mad_decoder *decoder, | 557 | int mad_decoder_message(struct mad_decoder *decoder, |
546 | void *message, unsigned int *len) | 558 | void *message, unsigned int *len) |
547 | { | 559 | { |
560 | # if defined(USE_ASYNC) | ||
548 | if (decoder->mode != MAD_DECODER_MODE_ASYNC || | 561 | if (decoder->mode != MAD_DECODER_MODE_ASYNC || |
549 | send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE || | 562 | send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE || |
550 | receive(decoder->async.in, &message, len) != MAD_FLOW_CONTINUE) | 563 | receive(decoder->async.in, &message, len) != MAD_FLOW_CONTINUE) |
551 | return -1; | 564 | return -1; |
552 | 565 | ||
553 | return 0; | 566 | return 0; |
567 | # else | ||
568 | return -1; | ||
569 | # endif | ||
554 | } | 570 | } |
diff --git a/core/multimedia/opieplayer/libmad/decoder.h b/core/multimedia/opieplayer/libmad/decoder.h index dbacc1a..f34150d 100644 --- a/core/multimedia/opieplayer/libmad/decoder.h +++ b/core/multimedia/opieplayer/libmad/decoder.h | |||
@@ -1,87 +1,91 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_DECODER_H | 22 | # ifndef LIBMAD_DECODER_H |
23 | # define LIBMAD_DECODER_H | 23 | # define LIBMAD_DECODER_H |
24 | 24 | ||
25 | # include "stream.h" | 25 | # include "stream.h" |
26 | # include "frame.h" | 26 | # include "frame.h" |
27 | # include "synth.h" | 27 | # include "synth.h" |
28 | 28 | ||
29 | enum mad_decoder_mode { | 29 | enum mad_decoder_mode { |
30 | MAD_DECODER_MODE_SYNC = 0, | 30 | MAD_DECODER_MODE_SYNC = 0, |
31 | MAD_DECODER_MODE_ASYNC | 31 | MAD_DECODER_MODE_ASYNC |
32 | }; | 32 | }; |
33 | 33 | ||
34 | enum mad_flow { | 34 | enum mad_flow { |
35 | MAD_FLOW_CONTINUE = 0x0000, | 35 | MAD_FLOW_CONTINUE = 0x0000,/* continue normally */ |
36 | MAD_FLOW_STOP = 0x0010, | 36 | MAD_FLOW_STOP = 0x0010,/* stop decoding normally */ |
37 | MAD_FLOW_BREAK = 0x0011, | 37 | MAD_FLOW_BREAK = 0x0011,/* stop decoding and signal an error */ |
38 | MAD_FLOW_IGNORE = 0x0020 | 38 | MAD_FLOW_IGNORE = 0x0020/* ignore the current frame */ |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct mad_decoder { | 41 | struct mad_decoder { |
42 | enum mad_decoder_mode mode; | 42 | enum mad_decoder_mode mode; |
43 | 43 | ||
44 | int options; | 44 | int options; |
45 | 45 | ||
46 | struct { | 46 | struct { |
47 | long pid; | 47 | long pid; |
48 | int in; | 48 | int in; |
49 | int out; | 49 | int out; |
50 | } async; | 50 | } async; |
51 | 51 | ||
52 | struct { | 52 | struct { |
53 | struct mad_stream stream; | 53 | struct mad_stream stream; |
54 | struct mad_frame frame; | 54 | struct mad_frame frame; |
55 | struct mad_synth synth; | 55 | struct mad_synth synth; |
56 | } *sync; | 56 | } *sync; |
57 | 57 | ||
58 | void *cb_data; | 58 | void *cb_data; |
59 | 59 | ||
60 | enum mad_flow (*input_func)(void *, struct mad_stream *); | 60 | enum mad_flow (*input_func)(void *, struct mad_stream *); |
61 | enum mad_flow (*header_func)(void *, struct mad_header const *); | 61 | enum mad_flow (*header_func)(void *, struct mad_header const *); |
62 | enum mad_flow (*filter_func)(void *, struct mad_frame *); | 62 | enum mad_flow (*filter_func)(void *, |
63 | struct mad_stream const *, struct mad_frame *); | ||
63 | enum mad_flow (*output_func)(void *, | 64 | enum mad_flow (*output_func)(void *, |
64 | struct mad_header const *, struct mad_pcm *); | 65 | struct mad_header const *, struct mad_pcm *); |
65 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); | 66 | enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); |
66 | enum mad_flow (*message_func)(void *, void *, unsigned int *); | 67 | enum mad_flow (*message_func)(void *, void *, unsigned int *); |
67 | }; | 68 | }; |
68 | 69 | ||
69 | void mad_decoder_init(struct mad_decoder *, void *, | 70 | void mad_decoder_init(struct mad_decoder *, void *, |
70 | enum mad_flow (*)(void *, struct mad_stream *), | 71 | enum mad_flow (*)(void *, struct mad_stream *), |
71 | enum mad_flow (*)(void *, struct mad_header const *), | 72 | enum mad_flow (*)(void *, struct mad_header const *), |
72 | enum mad_flow (*)(void *, struct mad_frame *), | 73 | enum mad_flow (*)(void *, |
74 | struct mad_stream const *, | ||
75 | struct mad_frame *), | ||
73 | enum mad_flow (*)(void *, | 76 | enum mad_flow (*)(void *, |
74 | struct mad_header const *, | 77 | struct mad_header const *, |
75 | struct mad_pcm *), | 78 | struct mad_pcm *), |
76 | enum mad_flow (*)(void *, | 79 | enum mad_flow (*)(void *, |
77 | struct mad_stream *, | 80 | struct mad_stream *, |
78 | struct mad_frame *), | 81 | struct mad_frame *), |
79 | enum mad_flow (*)(void *, void *, unsigned int *)); | 82 | enum mad_flow (*)(void *, void *, unsigned int *)); |
80 | int mad_decoder_finish(struct mad_decoder *); | 83 | int mad_decoder_finish(struct mad_decoder *); |
81 | 84 | ||
82 | # define mad_decoder_options(decoder, opts) ((decoder)->options = (opts)) | 85 | # define mad_decoder_options(decoder, opts) \ |
86 | ((void) ((decoder)->options = (opts))) | ||
83 | 87 | ||
84 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); | 88 | int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); |
85 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); | 89 | int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); |
86 | 90 | ||
87 | # endif | 91 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/fixed.c b/core/multimedia/opieplayer/libmad/fixed.c index be5c94e..af1e87e 100644 --- a/core/multimedia/opieplayer/libmad/fixed.c +++ b/core/multimedia/opieplayer/libmad/fixed.c | |||
@@ -1,37 +1,37 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include "fixed.h" | 28 | # include "fixed.h" |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * NAME:fixed->abs() | 31 | * NAME:fixed->abs() |
32 | * DESCRIPTION:return absolute value of a fixed-point number | 32 | * DESCRIPTION:return absolute value of a fixed-point number |
33 | */ | 33 | */ |
34 | mad_fixed_t mad_f_abs(mad_fixed_t x) | 34 | mad_fixed_t mad_f_abs(mad_fixed_t x) |
35 | { | 35 | { |
36 | return x < 0 ? -x : x; | 36 | return x < 0 ? -x : x; |
37 | } | 37 | } |
diff --git a/core/multimedia/opieplayer/libmad/fixed.h b/core/multimedia/opieplayer/libmad/fixed.h index 00ade62..c9b98ca 100644 --- a/core/multimedia/opieplayer/libmad/fixed.h +++ b/core/multimedia/opieplayer/libmad/fixed.h | |||
@@ -1,267 +1,321 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_FIXED_H | 22 | # ifndef LIBMAD_FIXED_H |
23 | # define LIBMAD_FIXED_H | 23 | # define LIBMAD_FIXED_H |
24 | 24 | ||
25 | # if SIZEOF_INT >= 4 | 25 | # if SIZEOF_INT >= 4 |
26 | typedef signed int mad_fixed_t; | 26 | typedef signed int mad_fixed_t; |
27 | 27 | ||
28 | typedef signed int mad_fixed64hi_t; | 28 | typedef signed int mad_fixed64hi_t; |
29 | typedef unsigned int mad_fixed64lo_t; | 29 | typedef unsigned int mad_fixed64lo_t; |
30 | # else | 30 | # else |
31 | typedef signed long mad_fixed_t; | 31 | typedef signed long mad_fixed_t; |
32 | 32 | ||
33 | typedef signed long mad_fixed64hi_t; | 33 | typedef signed long mad_fixed64hi_t; |
34 | typedef unsigned long mad_fixed64lo_t; | 34 | typedef unsigned long mad_fixed64lo_t; |
35 | # endif | 35 | # endif |
36 | 36 | ||
37 | # if defined(_MSC_VER) | ||
38 | # define mad_fixed64_t signed __int64 | ||
39 | # elif 1 || defined(__GNUC__) | ||
40 | # define mad_fixed64_t signed long long | ||
41 | # endif | ||
42 | |||
43 | # if defined(FPM_FLOAT) | ||
44 | typedef double mad_sample_t; | ||
45 | # else | ||
46 | typedef mad_fixed_t mad_sample_t; | ||
47 | # endif | ||
48 | |||
37 | /* | 49 | /* |
38 | * Fixed-point format: 0xABBBBBBB | 50 | * Fixed-point format: 0xABBBBBBB |
39 | * A == whole part (sign + 3 bits) | 51 | * A == whole part (sign + 3 bits) |
40 | * B == fractional part (28 bits) | 52 | * B == fractional part (28 bits) |
41 | * | 53 | * |
42 | * Values are signed two's complement, so the effective range is: | 54 | * Values are signed two's complement, so the effective range is: |
43 | * 0x80000000 to 0x7fffffff | 55 | * 0x80000000 to 0x7fffffff |
44 | * -8.0 to +7.9999999962747097015380859375 | 56 | * -8.0 to +7.9999999962747097015380859375 |
45 | * | 57 | * |
46 | * The smallest representable value is: | 58 | * The smallest representable value is: |
47 | * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) | 59 | * 0x00000001 == 0.0000000037252902984619140625 (i.e. about 3.725e-9) |
48 | * | 60 | * |
49 | * 28 bits of fractional accuracy represent about | 61 | * 28 bits of fractional accuracy represent about |
50 | * 8.6 digits of decimal accuracy. | 62 | * 8.6 digits of decimal accuracy. |
51 | * | 63 | * |
52 | * Fixed-point numbers can be added or subtracted as normal | 64 | * Fixed-point numbers can be added or subtracted as normal |
53 | * integers, but multiplication requires shifting the 64-bit result | 65 | * integers, but multiplication requires shifting the 64-bit result |
54 | * from 56 fractional bits back to 28 (and rounding.) | 66 | * from 56 fractional bits back to 28 (and rounding.) |
55 | * | 67 | * |
56 | * Changing the definition of MAD_F_FRACBITS is only partially | 68 | * Changing the definition of MAD_F_FRACBITS is only partially |
57 | * supported, and must be done with care. | 69 | * supported, and must be done with care. |
58 | */ | 70 | */ |
59 | 71 | ||
60 | # define MAD_F_FRACBITS 28 | 72 | # define MAD_F_FRACBITS 28 |
61 | 73 | ||
62 | # if MAD_F_FRACBITS == 28 | 74 | # if MAD_F_FRACBITS == 28 |
63 | # define MAD_F(x) ((mad_fixed_t) (x##L)) | 75 | # define MAD_F(x) ((mad_fixed_t) (x##L)) |
64 | # else | 76 | # else |
65 | # if MAD_F_FRACBITS < 28 | 77 | # if MAD_F_FRACBITS < 28 |
66 | # warning "MAD_F_FRACBITS < 28" | 78 | # warning "MAD_F_FRACBITS < 28" |
67 | # define MAD_F(x) ((mad_fixed_t) \ | 79 | # define MAD_F(x) ((mad_fixed_t) \ |
68 | (((x##L) + \ | 80 | (((x##L) + \ |
69 | (1L << (28 - MAD_F_FRACBITS - 1))) >> \ | 81 | (1L << (28 - MAD_F_FRACBITS - 1))) >> \ |
70 | (28 - MAD_F_FRACBITS))) | 82 | (28 - MAD_F_FRACBITS))) |
71 | # elif MAD_F_FRACBITS > 28 | 83 | # elif MAD_F_FRACBITS > 28 |
72 | # error "MAD_F_FRACBITS > 28 not currently supported" | 84 | # error "MAD_F_FRACBITS > 28 not currently supported" |
73 | # define MAD_F(x) ((mad_fixed_t) \ | 85 | # define MAD_F(x) ((mad_fixed_t) \ |
74 | ((x##L) << (MAD_F_FRACBITS - 28))) | 86 | ((x##L) << (MAD_F_FRACBITS - 28))) |
75 | # endif | 87 | # endif |
76 | # endif | 88 | # endif |
77 | 89 | ||
78 | # define MAD_F_MIN ((mad_fixed_t) -0x80000000L) | 90 | # define MAD_F_MIN ((mad_fixed_t) -0x80000000L) |
79 | # define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) | 91 | # define MAD_F_MAX ((mad_fixed_t) +0x7fffffffL) |
80 | 92 | ||
81 | # define MAD_F_ONE MAD_F(0x10000000) | 93 | # define MAD_F_ONE MAD_F(0x10000000) |
82 | 94 | ||
83 | # define mad_f_tofixed(x)((mad_fixed_t) \ | 95 | # define mad_f_tofixed(x)((mad_fixed_t) \ |
84 | ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) | 96 | ((x) * (double) (1L << MAD_F_FRACBITS) + 0.5)) |
85 | # define mad_f_todouble(x)((double) \ | 97 | # define mad_f_todouble(x)((double) \ |
86 | ((x) / (double) (1L << MAD_F_FRACBITS))) | 98 | ((x) / (double) (1L << MAD_F_FRACBITS))) |
87 | 99 | ||
88 | # define mad_f_intpart(x)((x) >> MAD_F_FRACBITS) | 100 | # define mad_f_intpart(x)((x) >> MAD_F_FRACBITS) |
89 | # define mad_f_fracpart(x)((x) & ((1L << MAD_F_FRACBITS) - 1)) | 101 | # define mad_f_fracpart(x)((x) & ((1L << MAD_F_FRACBITS) - 1)) |
90 | /* (x should be positive) */ | 102 | /* (x should be positive) */ |
91 | 103 | ||
92 | # define mad_f_fromint(x)((x) << MAD_F_FRACBITS) | 104 | # define mad_f_fromint(x)((x) << MAD_F_FRACBITS) |
93 | 105 | ||
94 | # define mad_f_add(x, y)((x) + (y)) | 106 | # define mad_f_add(x, y)((x) + (y)) |
95 | # define mad_f_sub(x, y)((x) - (y)) | 107 | # define mad_f_sub(x, y)((x) - (y)) |
96 | 108 | ||
97 | # if defined(FPM_64BIT) | 109 | # if defined(FPM_FLOAT) |
110 | # error "FPM_FLOAT not yet supported" | ||
111 | |||
112 | # undef MAD_F | ||
113 | # define MAD_F(x) mad_f_todouble(x) | ||
114 | |||
115 | # define mad_f_mul(x, y)((x) * (y)) | ||
116 | # define mad_f_scale64 | ||
117 | |||
118 | # undef ASO_ZEROCHECK | ||
119 | |||
120 | # elif defined(FPM_64BIT) | ||
98 | 121 | ||
99 | /* | 122 | /* |
100 | * This version should be the most accurate if 64-bit (long long) types are | 123 | * This version should be the most accurate if 64-bit types are supported by |
101 | * supported by the compiler, although it may not be the most efficient. | 124 | * the compiler, although it may not be the most efficient. |
102 | */ | 125 | */ |
103 | # if defined(OPT_ACCURACY) | 126 | # if defined(OPT_ACCURACY) |
104 | # define mad_f_mul(x, y) \ | 127 | # define mad_f_mul(x, y) \ |
105 | ((mad_fixed_t) \ | 128 | ((mad_fixed_t) \ |
106 | ((((signed long long) (x) * (y)) + \ | 129 | ((((mad_fixed64_t) (x) * (y)) + \ |
107 | (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) | 130 | (1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS)) |
108 | # else | 131 | # else |
109 | # define mad_f_mul(x, y) \ | 132 | # define mad_f_mul(x, y) \ |
110 | ((mad_fixed_t) (((signed long long) (x) * (y)) >> MAD_F_SCALEBITS)) | 133 | ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS)) |
111 | # endif | 134 | # endif |
112 | 135 | ||
113 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 136 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
114 | 137 | ||
115 | /* --- Intel --------------------------------------------------------------- */ | 138 | /* --- Intel --------------------------------------------------------------- */ |
116 | 139 | ||
117 | # elif defined(FPM_INTEL) | 140 | # elif defined(FPM_INTEL) |
118 | 141 | ||
142 | # if defined(_MSC_VER) | ||
143 | # pragma warning(push) | ||
144 | # pragma warning(disable: 4035) /* no return value */ | ||
145 | static __forceinline | ||
146 | mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y) | ||
147 | { | ||
148 | enum { | ||
149 | fracbits = MAD_F_FRACBITS | ||
150 | }; | ||
151 | |||
152 | __asm { | ||
153 | mov eax, x | ||
154 | imul y | ||
155 | shrd eax, edx, fracbits | ||
156 | } | ||
157 | |||
158 | /* implicit return of eax */ | ||
159 | } | ||
160 | # pragma warning(pop) | ||
161 | |||
162 | # define mad_f_mul mad_f_mul_inline | ||
163 | # define mad_f_scale64 | ||
164 | # else | ||
119 | /* | 165 | /* |
120 | * This Intel version is fast and accurate; the disposition of the least | 166 | * This Intel version is fast and accurate; the disposition of the least |
121 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). | 167 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
122 | */ | 168 | */ |
123 | # define MAD_F_MLX(hi, lo, x, y) \ | 169 | # define MAD_F_MLX(hi, lo, x, y) \ |
124 | asm ("imull %3" \ | 170 | asm ("imull %3" \ |
125 | : "=a" (lo), "=d" (hi) \ | 171 | : "=a" (lo), "=d" (hi) \ |
126 | : "%a" (x), "rm" (y) \ | 172 | : "%a" (x), "rm" (y) \ |
127 | : "cc") | 173 | : "cc") |
128 | 174 | ||
129 | # if defined(OPT_ACCURACY) | 175 | # if defined(OPT_ACCURACY) |
130 | /* | 176 | /* |
131 | * This gives best accuracy but is not very fast. | 177 | * This gives best accuracy but is not very fast. |
132 | */ | 178 | */ |
133 | # define MAD_F_MLA(hi, lo, x, y) \ | 179 | # define MAD_F_MLA(hi, lo, x, y) \ |
134 | ({ mad_fixed64hi_t __hi; \ | 180 | ({ mad_fixed64hi_t __hi; \ |
135 | mad_fixed64lo_t __lo; \ | 181 | mad_fixed64lo_t __lo; \ |
136 | MAD_F_MLX(__hi, __lo, (x), (y)); \ | 182 | MAD_F_MLX(__hi, __lo, (x), (y)); \ |
137 | asm ("addl %2,%0\n\t" \ | 183 | asm ("addl %2,%0\n\t" \ |
138 | "adcl %3,%1" \ | 184 | "adcl %3,%1" \ |
139 | : "=rm" (lo), "=rm" (hi) \ | 185 | : "=rm" (lo), "=rm" (hi) \ |
140 | : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ | 186 | : "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \ |
141 | : "cc"); \ | 187 | : "cc"); \ |
142 | }) | 188 | }) |
143 | # endif /* OPT_ACCURACY */ | 189 | # endif /* OPT_ACCURACY */ |
144 | 190 | ||
145 | # if defined(OPT_ACCURACY) | 191 | # if defined(OPT_ACCURACY) |
146 | /* | 192 | /* |
147 | * Surprisingly, this is faster than SHRD followed by ADC. | 193 | * Surprisingly, this is faster than SHRD followed by ADC. |
148 | */ | 194 | */ |
149 | # define mad_f_scale64(hi, lo) \ | 195 | # define mad_f_scale64(hi, lo) \ |
150 | ({ mad_fixed64hi_t __hi_; \ | 196 | ({ mad_fixed64hi_t __hi_; \ |
151 | mad_fixed64lo_t __lo_; \ | 197 | mad_fixed64lo_t __lo_; \ |
152 | mad_fixed_t __result; \ | 198 | mad_fixed_t __result; \ |
153 | asm ("addl %4,%2\n\t" \ | 199 | asm ("addl %4,%2\n\t" \ |
154 | "adcl %5,%3" \ | 200 | "adcl %5,%3" \ |
155 | : "=rm" (__lo_), "=rm" (__hi_) \ | 201 | : "=rm" (__lo_), "=rm" (__hi_) \ |
156 | : "0" (lo), "1" (hi), \ | 202 | : "0" (lo), "1" (hi), \ |
157 | "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ | 203 | "ir" (1L << (MAD_F_SCALEBITS - 1)), "ir" (0) \ |
158 | : "cc"); \ | 204 | : "cc"); \ |
159 | asm ("shrdl %3,%2,%1" \ | 205 | asm ("shrdl %3,%2,%1" \ |
160 | : "=rm" (__result) \ | 206 | : "=rm" (__result) \ |
161 | : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ | 207 | : "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \ |
162 | : "cc"); \ | 208 | : "cc"); \ |
163 | __result; \ | 209 | __result; \ |
164 | }) | 210 | }) |
165 | # else | 211 | # else |
166 | # define mad_f_scale64(hi, lo) \ | 212 | # define mad_f_scale64(hi, lo) \ |
167 | ({ mad_fixed_t __result; \ | 213 | ({ mad_fixed_t __result; \ |
168 | asm ("shrdl %3,%2,%1" \ | 214 | asm ("shrdl %3,%2,%1" \ |
169 | : "=rm" (__result) \ | 215 | : "=rm" (__result) \ |
170 | : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ | 216 | : "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \ |
171 | : "cc"); \ | 217 | : "cc"); \ |
172 | __result; \ | 218 | __result; \ |
173 | }) | 219 | }) |
174 | # endif /* OPT_ACCURACY */ | 220 | # endif /* OPT_ACCURACY */ |
175 | 221 | ||
176 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 222 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
223 | # endif | ||
177 | 224 | ||
178 | /* --- ARM ----------------------------------------------------------------- */ | 225 | /* --- ARM ----------------------------------------------------------------- */ |
179 | 226 | ||
180 | # elif defined(FPM_ARM) | 227 | # elif defined(FPM_ARM) |
181 | 228 | ||
182 | /* | 229 | /* |
183 | * This ARM V4 version is as accurate as FPM_64BIT but much faster. The | 230 | * This ARM V4 version is as accurate as FPM_64BIT but much faster. The |
184 | * least significant bit is properly rounded at no CPU cycle cost! | 231 | * least significant bit is properly rounded at no CPU cycle cost! |
185 | */ | 232 | */ |
186 | # if 1 | 233 | # if 1 |
187 | /* | 234 | /* |
188 | * There's a bug somewhere, possibly in the compiler, that sometimes makes | 235 | * There's a bug somewhere, possibly in the compiler, that sometimes makes |
189 | * this necessary instead of the default implementation via MAD_F_MLX and | 236 | * this necessary instead of the default implementation via MAD_F_MLX and |
190 | * mad_f_scale64. It may be related to the use (or lack) of | 237 | * mad_f_scale64. It may be related to the use (or lack) of |
191 | * -finline-functions and/or -fstrength-reduce. | 238 | * -finline-functions and/or -fstrength-reduce. |
192 | * | 239 | * |
193 | * This is also apparently faster than MAD_F_MLX/mad_f_scale64. | 240 | * This is also apparently faster than MAD_F_MLX/mad_f_scale64. |
194 | */ | 241 | */ |
195 | # define mad_f_mul(x, y) \ | 242 | # define mad_f_mul(x, y) \ |
196 | ({ mad_fixed64hi_t __hi; \ | 243 | ({ mad_fixed64hi_t __hi; \ |
197 | mad_fixed64lo_t __lo; \ | 244 | mad_fixed64lo_t __lo; \ |
198 | mad_fixed_t __result; \ | 245 | mad_fixed_t __result; \ |
199 | asm ("smull%0, %1, %3, %4\n\t" \ | 246 | asm ("smull%0, %1, %3, %4\n\t" \ |
200 | "movs%0, %0, lsr %5\n\t" \ | 247 | "movs%0, %0, lsr %5\n\t" \ |
201 | "adc%2, %0, %1, lsl %6" \ | 248 | "adc%2, %0, %1, lsl %6" \ |
202 | : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ | 249 | : "=&r" (__lo), "=&r" (__hi), "=r" (__result) \ |
203 | : "%r" (x), "r" (y), \ | 250 | : "%r" (x), "r" (y), \ |
204 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ | 251 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ |
205 | : "cc"); \ | 252 | : "cc"); \ |
206 | __result; \ | 253 | __result; \ |
207 | }) | 254 | }) |
208 | # endif | 255 | # endif |
209 | 256 | ||
210 | # define MAD_F_MLX(hi, lo, x, y) \ | 257 | # define MAD_F_MLX(hi, lo, x, y) \ |
211 | asm ("smull%0, %1, %2, %3" \ | 258 | asm ("smull%0, %1, %2, %3" \ |
212 | : "=&r" (lo), "=&r" (hi) \ | 259 | : "=&r" (lo), "=&r" (hi) \ |
213 | : "%r" (x), "r" (y)) | 260 | : "%r" (x), "r" (y)) |
214 | 261 | ||
215 | # define MAD_F_MLA(hi, lo, x, y) \ | 262 | # define MAD_F_MLA(hi, lo, x, y) \ |
216 | asm ("smlal%0, %1, %2, %3" \ | 263 | asm ("smlal%0, %1, %2, %3" \ |
217 | : "+r" (lo), "+r" (hi) \ | 264 | : "+r" (lo), "+r" (hi) \ |
218 | : "%r" (x), "r" (y)) | 265 | : "%r" (x), "r" (y)) |
219 | 266 | ||
267 | # define MAD_F_MLN(hi, lo) \ | ||
268 | asm ("rsbs%0, %2, #0\n\t" \ | ||
269 | "rsc%1, %3, #0" \ | ||
270 | : "=r" (lo), "=r" (hi) \ | ||
271 | : "0" (lo), "1" (hi) \ | ||
272 | : "cc") | ||
273 | |||
220 | # define mad_f_scale64(hi, lo) \ | 274 | # define mad_f_scale64(hi, lo) \ |
221 | ({ mad_fixed_t __result; \ | 275 | ({ mad_fixed_t __result; \ |
222 | asm ("movs%0, %1, lsr %3\n\t" \ | 276 | asm ("movs%0, %1, lsr %3\n\t" \ |
223 | "adc%0, %0, %2, lsl %4" \ | 277 | "adc%0, %0, %2, lsl %4" \ |
224 | : "=r" (__result) \ | 278 | : "=r" (__result) \ |
225 | : "r" (lo), "r" (hi), \ | 279 | : "r" (lo), "r" (hi), \ |
226 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ | 280 | "M" (MAD_F_SCALEBITS), "M" (32 - MAD_F_SCALEBITS) \ |
227 | : "cc"); \ | 281 | : "cc"); \ |
228 | __result; \ | 282 | __result; \ |
229 | }) | 283 | }) |
230 | 284 | ||
231 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 285 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
232 | 286 | ||
233 | /* --- MIPS ---------------------------------------------------------------- */ | 287 | /* --- MIPS ---------------------------------------------------------------- */ |
234 | 288 | ||
235 | # elif defined(FPM_MIPS) | 289 | # elif defined(FPM_MIPS) |
236 | 290 | ||
237 | /* | 291 | /* |
238 | * This MIPS version is fast and accurate; the disposition of the least | 292 | * This MIPS version is fast and accurate; the disposition of the least |
239 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). | 293 | * significant bit depends on OPT_ACCURACY via mad_f_scale64(). |
240 | */ | 294 | */ |
241 | # define MAD_F_MLX(hi, lo, x, y) \ | 295 | # define MAD_F_MLX(hi, lo, x, y) \ |
242 | asm ("mult%2,%3" \ | 296 | asm ("mult%2,%3" \ |
243 | : "=l" (lo), "=h" (hi) \ | 297 | : "=l" (lo), "=h" (hi) \ |
244 | : "%r" (x), "r" (y)) | 298 | : "%r" (x), "r" (y)) |
245 | 299 | ||
246 | # if defined(HAVE_MADD_ASM) | 300 | # if defined(HAVE_MADD_ASM) |
247 | # define MAD_F_MLA(hi, lo, x, y) \ | 301 | # define MAD_F_MLA(hi, lo, x, y) \ |
248 | asm ("madd%2,%3" \ | 302 | asm ("madd%2,%3" \ |
249 | : "+l" (lo), "+h" (hi) \ | 303 | : "+l" (lo), "+h" (hi) \ |
250 | : "%r" (x), "r" (y)) | 304 | : "%r" (x), "r" (y)) |
251 | # elif defined(HAVE_MADD16_ASM) | 305 | # elif defined(HAVE_MADD16_ASM) |
252 | /* | 306 | /* |
253 | * This loses significant accuracy due to the 16-bit integer limit in the | 307 | * This loses significant accuracy due to the 16-bit integer limit in the |
254 | * multiply/accumulate instruction. | 308 | * multiply/accumulate instruction. |
255 | */ | 309 | */ |
256 | # define MAD_F_ML0(hi, lo, x, y) \ | 310 | # define MAD_F_ML0(hi, lo, x, y) \ |
257 | asm ("mult%2,%3" \ | 311 | asm ("mult%2,%3" \ |
258 | : "=l" (lo), "=h" (hi) \ | 312 | : "=l" (lo), "=h" (hi) \ |
259 | : "%r" ((x) >> 12), "r" ((y) >> 16)) | 313 | : "%r" ((x) >> 12), "r" ((y) >> 16)) |
260 | # define MAD_F_MLA(hi, lo, x, y) \ | 314 | # define MAD_F_MLA(hi, lo, x, y) \ |
261 | asm ("madd16%2,%3" \ | 315 | asm ("madd16%2,%3" \ |
262 | : "+l" (lo), "+h" (hi) \ | 316 | : "+l" (lo), "+h" (hi) \ |
263 | : "%r" ((x) >> 12), "r" ((y) >> 16)) | 317 | : "%r" ((x) >> 12), "r" ((y) >> 16)) |
264 | # define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) | 318 | # define MAD_F_MLZ(hi, lo) ((mad_fixed_t) (lo)) |
265 | # endif | 319 | # endif |
266 | 320 | ||
267 | # if defined(OPT_SPEED) | 321 | # if defined(OPT_SPEED) |
@@ -312,102 +366,111 @@ typedef unsigned long mad_fixed64lo_t; | |||
312 | 366 | ||
313 | # if defined(OPT_ACCURACY) | 367 | # if defined(OPT_ACCURACY) |
314 | /* | 368 | /* |
315 | * This is accurate and ~2 - 2.5 times slower than the unrounded version. | 369 | * This is accurate and ~2 - 2.5 times slower than the unrounded version. |
316 | * | 370 | * |
317 | * The __volatile__ improves the generated code by another 5% (fewer spills | 371 | * The __volatile__ improves the generated code by another 5% (fewer spills |
318 | * to memory); eventually they should be removed. | 372 | * to memory); eventually they should be removed. |
319 | */ | 373 | */ |
320 | # define mad_f_scale64(hi, lo) \ | 374 | # define mad_f_scale64(hi, lo) \ |
321 | ({ mad_fixed_t __result; \ | 375 | ({ mad_fixed_t __result; \ |
322 | mad_fixed64hi_t __hi_; \ | 376 | mad_fixed64hi_t __hi_; \ |
323 | mad_fixed64lo_t __lo_; \ | 377 | mad_fixed64lo_t __lo_; \ |
324 | asm __volatile__ ("addc %0, %2, %4\n\t" \ | 378 | asm __volatile__ ("addc %0, %2, %4\n\t" \ |
325 | "addze %1, %3" \ | 379 | "addze %1, %3" \ |
326 | : "=r" (__lo_), "=r" (__hi_) \ | 380 | : "=r" (__lo_), "=r" (__hi_) \ |
327 | : "r" (lo), "r" (hi), "r" (1 << (MAD_F_SCALEBITS - 1))); \ | 381 | : "r" (lo), "r" (hi), "r" (1 << (MAD_F_SCALEBITS - 1))); \ |
328 | asm __volatile__ ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ | 382 | asm __volatile__ ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ |
329 | "rlwimi %0, %1,32-%3,%3,31" \ | 383 | "rlwimi %0, %1,32-%3,%3,31" \ |
330 | : "=&r" (__result) \ | 384 | : "=&r" (__result) \ |
331 | : "r" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS)); \ | 385 | : "r" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS)); \ |
332 | __result; \ | 386 | __result; \ |
333 | }) | 387 | }) |
334 | # else | 388 | # else |
335 | # define mad_f_scale64(hi, lo) \ | 389 | # define mad_f_scale64(hi, lo) \ |
336 | ({ mad_fixed_t __result; \ | 390 | ({ mad_fixed_t __result; \ |
337 | asm ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ | 391 | asm ("rlwinm %0, %2,32-%3,0,%3-1\n\t" \ |
338 | "rlwimi %0, %1,32-%3,%3,31" \ | 392 | "rlwimi %0, %1,32-%3,%3,31" \ |
339 | : "=r" (__result) \ | 393 | : "=r" (__result) \ |
340 | : "r" (lo), "r" (hi), "I" (MAD_F_SCALEBITS)); \ | 394 | : "r" (lo), "r" (hi), "I" (MAD_F_SCALEBITS)); \ |
341 | __result; \ | 395 | __result; \ |
342 | }) | 396 | }) |
343 | # endif /* OPT_ACCURACY */ | 397 | # endif /* OPT_ACCURACY */ |
344 | 398 | ||
345 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 399 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
346 | 400 | ||
347 | /* --- Default ------------------------------------------------------------- */ | 401 | /* --- Default ------------------------------------------------------------- */ |
348 | 402 | ||
349 | # elif defined(FPM_DEFAULT) | 403 | # elif defined(FPM_DEFAULT) |
350 | 404 | ||
351 | /* | 405 | /* |
352 | * This version is the most portable but it loses significant accuracy. | 406 | * This version is the most portable but it loses significant accuracy. |
353 | * Furthermore, accuracy is biased against the second argument, so care | 407 | * Furthermore, accuracy is biased against the second argument, so care |
354 | * should be taken when ordering operands. | 408 | * should be taken when ordering operands. |
355 | * | 409 | * |
356 | * The scale factors are constant as this is not used with SSO. | 410 | * The scale factors are constant as this is not used with SSO. |
357 | * | 411 | * |
358 | * Pre-rounding is required to stay within the limits of compliance. | 412 | * Pre-rounding is required to stay within the limits of compliance. |
359 | */ | 413 | */ |
360 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ | 414 | # if defined(OPT_SPEED) |
415 | # define mad_f_mul(x, y)(((x) >> 12) * ((y) >> 16)) | ||
416 | # else | ||
417 | # define mad_f_mul(x, y)((((x) + (1L << 11)) >> 12) * \ | ||
361 | (((y) + (1L << 15)) >> 16)) | 418 | (((y) + (1L << 15)) >> 16)) |
419 | # endif | ||
362 | 420 | ||
363 | /* ------------------------------------------------------------------------- */ | 421 | /* ------------------------------------------------------------------------- */ |
364 | 422 | ||
365 | # else | 423 | # else |
366 | # error "no FPM selected" | 424 | # error "no FPM selected" |
367 | # endif | 425 | # endif |
368 | 426 | ||
369 | /* default implementations */ | 427 | /* default implementations */ |
370 | 428 | ||
371 | # if !defined(mad_f_mul) | 429 | # if !defined(mad_f_mul) |
372 | # define mad_f_mul(x, y) \ | 430 | # define mad_f_mul(x, y) \ |
373 | ({ mad_fixed64hi_t __hi; \ | 431 | ({ mad_fixed64hi_t __hi; \ |
374 | mad_fixed64lo_t __lo; \ | 432 | mad_fixed64lo_t __lo; \ |
375 | MAD_F_MLX(__hi, __lo, (x), (y)); \ | 433 | MAD_F_MLX(__hi, __lo, (x), (y)); \ |
376 | mad_f_scale64(__hi, __lo); \ | 434 | mad_f_scale64(__hi, __lo); \ |
377 | }) | 435 | }) |
378 | # endif | 436 | # endif |
379 | 437 | ||
380 | # if !defined(MAD_F_MLA) | 438 | # if !defined(MAD_F_MLA) |
381 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) | 439 | # define MAD_F_ML0(hi, lo, x, y)((lo) = mad_f_mul((x), (y))) |
382 | # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y))) | 440 | # define MAD_F_MLA(hi, lo, x, y)((lo) += mad_f_mul((x), (y))) |
441 | # define MAD_F_MLN(hi, lo) ((lo) = -(lo)) | ||
383 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) | 442 | # define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) |
384 | # endif | 443 | # endif |
385 | 444 | ||
386 | # if !defined(MAD_F_ML0) | 445 | # if !defined(MAD_F_ML0) |
387 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) | 446 | # define MAD_F_ML0(hi, lo, x, y)MAD_F_MLX((hi), (lo), (x), (y)) |
388 | # endif | 447 | # endif |
389 | 448 | ||
449 | # if !defined(MAD_F_MLN) | ||
450 | # define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi)) | ||
451 | # endif | ||
452 | |||
390 | # if !defined(MAD_F_MLZ) | 453 | # if !defined(MAD_F_MLZ) |
391 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) | 454 | # define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo)) |
392 | # endif | 455 | # endif |
393 | 456 | ||
394 | # if !defined(mad_f_scale64) | 457 | # if !defined(mad_f_scale64) |
395 | # if defined(OPT_ACCURACY) | 458 | # if defined(OPT_ACCURACY) |
396 | # define mad_f_scale64(hi, lo) \ | 459 | # define mad_f_scale64(hi, lo) \ |
397 | ((((mad_fixed_t) \ | 460 | ((((mad_fixed_t) \ |
398 | (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ | 461 | (((hi) << (32 - (MAD_F_SCALEBITS - 1))) | \ |
399 | ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) | 462 | ((lo) >> (MAD_F_SCALEBITS - 1)))) + 1) >> 1) |
400 | # else | 463 | # else |
401 | # define mad_f_scale64(hi, lo) \ | 464 | # define mad_f_scale64(hi, lo) \ |
402 | ((mad_fixed_t) \ | 465 | ((mad_fixed_t) \ |
403 | (((hi) << (32 - MAD_F_SCALEBITS)) | \ | 466 | (((hi) << (32 - MAD_F_SCALEBITS)) | \ |
404 | ((lo) >> MAD_F_SCALEBITS))) | 467 | ((lo) >> MAD_F_SCALEBITS))) |
405 | # endif | 468 | # endif |
406 | # define MAD_F_SCALEBITS MAD_F_FRACBITS | 469 | # define MAD_F_SCALEBITS MAD_F_FRACBITS |
407 | # endif | 470 | # endif |
408 | 471 | ||
409 | /* miscellaneous C routines */ | 472 | /* miscellaneous C routines */ |
410 | 473 | ||
411 | mad_fixed_t mad_f_abs(mad_fixed_t); | 474 | mad_fixed_t mad_f_abs(mad_fixed_t); |
412 | 475 | ||
413 | # endif | 476 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/frame.c b/core/multimedia/opieplayer/libmad/frame.c index 4ebb80c..bf15e7f 100644 --- a/core/multimedia/opieplayer/libmad/frame.c +++ b/core/multimedia/opieplayer/libmad/frame.c | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include <stdlib.h> | 28 | # include <stdlib.h> |
29 | 29 | ||
30 | # include "bit.h" | 30 | # include "bit.h" |
31 | # include "stream.h" | 31 | # include "stream.h" |
32 | # include "frame.h" | 32 | # include "frame.h" |
33 | # include "timer.h" | 33 | # include "timer.h" |
34 | # include "layer12.h" | 34 | # include "layer12.h" |
35 | # include "layer3.h" | 35 | # include "layer3.h" |
36 | 36 | ||
37 | static | 37 | static |
38 | unsigned long const bitrate_table[5][15] = { | 38 | unsigned long const bitrate_table[5][15] = { |
39 | /* MPEG-1 */ | 39 | /* MPEG-1 */ |
40 | { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ | 40 | { 0, 32000, 64000, 96000, 128000, 160000, 192000, 224000, /* Layer I */ |
41 | 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, | 41 | 256000, 288000, 320000, 352000, 384000, 416000, 448000 }, |
42 | { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ | 42 | { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer II */ |
43 | 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, | 43 | 128000, 160000, 192000, 224000, 256000, 320000, 384000 }, |
44 | { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ | 44 | { 0, 32000, 40000, 48000, 56000, 64000, 80000, 96000, /* Layer III */ |
45 | 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, | 45 | 112000, 128000, 160000, 192000, 224000, 256000, 320000 }, |
46 | 46 | ||
47 | /* MPEG-2 LSF */ | 47 | /* MPEG-2 LSF */ |
48 | { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ | 48 | { 0, 32000, 48000, 56000, 64000, 80000, 96000, 112000, /* Layer I */ |
49 | 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, | 49 | 128000, 144000, 160000, 176000, 192000, 224000, 256000 }, |
50 | { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ | 50 | { 0, 8000, 16000, 24000, 32000, 40000, 48000, 56000, /* Layers */ |
@@ -328,97 +328,97 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) | |||
328 | 328 | ||
329 | sync: | 329 | sync: |
330 | /* synchronize */ | 330 | /* synchronize */ |
331 | if (stream->sync) { | 331 | if (stream->sync) { |
332 | if (end - ptr < MAD_BUFFER_GUARD) { | 332 | if (end - ptr < MAD_BUFFER_GUARD) { |
333 | stream->next_frame = ptr; | 333 | stream->next_frame = ptr; |
334 | 334 | ||
335 | stream->error = MAD_ERROR_BUFLEN; | 335 | stream->error = MAD_ERROR_BUFLEN; |
336 | goto fail; | 336 | goto fail; |
337 | } | 337 | } |
338 | else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { | 338 | else if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { |
339 | /* mark point where frame sync word was expected */ | 339 | /* mark point where frame sync word was expected */ |
340 | stream->this_frame = ptr; | 340 | stream->this_frame = ptr; |
341 | stream->next_frame = ptr + 1; | 341 | stream->next_frame = ptr + 1; |
342 | 342 | ||
343 | stream->error = MAD_ERROR_LOSTSYNC; | 343 | stream->error = MAD_ERROR_LOSTSYNC; |
344 | goto fail; | 344 | goto fail; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | else { | 347 | else { |
348 | mad_bit_init(&stream->ptr, ptr); | 348 | mad_bit_init(&stream->ptr, ptr); |
349 | 349 | ||
350 | if (mad_stream_sync(stream) == -1) { | 350 | if (mad_stream_sync(stream) == -1) { |
351 | if (end - stream->next_frame >= MAD_BUFFER_GUARD) | 351 | if (end - stream->next_frame >= MAD_BUFFER_GUARD) |
352 | stream->next_frame = end - MAD_BUFFER_GUARD; | 352 | stream->next_frame = end - MAD_BUFFER_GUARD; |
353 | 353 | ||
354 | stream->error = MAD_ERROR_BUFLEN; | 354 | stream->error = MAD_ERROR_BUFLEN; |
355 | goto fail; | 355 | goto fail; |
356 | } | 356 | } |
357 | 357 | ||
358 | ptr = mad_bit_nextbyte(&stream->ptr); | 358 | ptr = mad_bit_nextbyte(&stream->ptr); |
359 | } | 359 | } |
360 | 360 | ||
361 | /* begin processing */ | 361 | /* begin processing */ |
362 | stream->this_frame = ptr; | 362 | stream->this_frame = ptr; |
363 | stream->next_frame = ptr + 1; /* possibly bogus sync word */ | 363 | stream->next_frame = ptr + 1; /* possibly bogus sync word */ |
364 | 364 | ||
365 | mad_bit_init(&stream->ptr, stream->this_frame); | 365 | mad_bit_init(&stream->ptr, stream->this_frame); |
366 | 366 | ||
367 | if (decode_header(header, stream) == -1) | 367 | if (decode_header(header, stream) == -1) |
368 | goto fail; | 368 | goto fail; |
369 | 369 | ||
370 | /* calculate frame duration */ | 370 | /* calculate frame duration */ |
371 | mad_timer_set(&header->duration, 0, | 371 | mad_timer_set(&header->duration, 0, |
372 | 32 * MAD_NSBSAMPLES(header), header->samplerate); | 372 | 32 * MAD_NSBSAMPLES(header), header->samplerate); |
373 | 373 | ||
374 | /* calculate free bit rate */ | 374 | /* calculate free bit rate */ |
375 | if (header->bitrate == 0) { | 375 | if (header->bitrate == 0) { |
376 | if ((!stream->sync || !stream->freerate) && | 376 | if ((stream->freerate == 0 || !stream->sync) && |
377 | free_bitrate(stream, header) == -1) | 377 | free_bitrate(stream, header) == -1) |
378 | goto fail; | 378 | goto fail; |
379 | 379 | ||
380 | header->bitrate = stream->freerate; | 380 | header->bitrate = stream->freerate; |
381 | header->flags |= MAD_FLAG_FREEFORMAT; | 381 | header->flags |= MAD_FLAG_FREEFORMAT; |
382 | } | 382 | } |
383 | 383 | ||
384 | /* calculate beginning of next frame */ | 384 | /* calculate beginning of next frame */ |
385 | pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; | 385 | pad_slot = (header->flags & MAD_FLAG_PADDING) ? 1 : 0; |
386 | 386 | ||
387 | if (header->layer == MAD_LAYER_I) | 387 | if (header->layer == MAD_LAYER_I) |
388 | N = ((12 * header->bitrate / header->samplerate) + pad_slot) * 4; | 388 | N = ((12 * header->bitrate / header->samplerate) + pad_slot) * 4; |
389 | else { | 389 | else { |
390 | unsigned int slots_per_frame; | 390 | unsigned int slots_per_frame; |
391 | 391 | ||
392 | slots_per_frame = (header->layer == MAD_LAYER_III && | 392 | slots_per_frame = (header->layer == MAD_LAYER_III && |
393 | (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; | 393 | (header->flags & MAD_FLAG_LSF_EXT)) ? 72 : 144; |
394 | 394 | ||
395 | N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot; | 395 | N = (slots_per_frame * header->bitrate / header->samplerate) + pad_slot; |
396 | } | 396 | } |
397 | 397 | ||
398 | /* verify there is enough data left in buffer to decode this frame */ | 398 | /* verify there is enough data left in buffer to decode this frame */ |
399 | if (N + MAD_BUFFER_GUARD > end - stream->this_frame) { | 399 | if (N + MAD_BUFFER_GUARD > end - stream->this_frame) { |
400 | stream->next_frame = stream->this_frame; | 400 | stream->next_frame = stream->this_frame; |
401 | 401 | ||
402 | stream->error = MAD_ERROR_BUFLEN; | 402 | stream->error = MAD_ERROR_BUFLEN; |
403 | goto fail; | 403 | goto fail; |
404 | } | 404 | } |
405 | 405 | ||
406 | stream->next_frame = stream->this_frame + N; | 406 | stream->next_frame = stream->this_frame + N; |
407 | 407 | ||
408 | if (!stream->sync) { | 408 | if (!stream->sync) { |
409 | /* check that a valid frame header follows this frame */ | 409 | /* check that a valid frame header follows this frame */ |
410 | 410 | ||
411 | ptr = stream->next_frame; | 411 | ptr = stream->next_frame; |
412 | if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { | 412 | if (!(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) { |
413 | ptr = stream->next_frame = stream->this_frame + 1; | 413 | ptr = stream->next_frame = stream->this_frame + 1; |
414 | goto sync; | 414 | goto sync; |
415 | } | 415 | } |
416 | 416 | ||
417 | stream->sync = 1; | 417 | stream->sync = 1; |
418 | } | 418 | } |
419 | 419 | ||
420 | header->flags |= MAD_FLAG_INCOMPLETE; | 420 | header->flags |= MAD_FLAG_INCOMPLETE; |
421 | 421 | ||
422 | return 0; | 422 | return 0; |
423 | 423 | ||
424 | fail: | 424 | fail: |
diff --git a/core/multimedia/opieplayer/libmad/frame.h b/core/multimedia/opieplayer/libmad/frame.h index e88d0c8..3b8e454 100644 --- a/core/multimedia/opieplayer/libmad/frame.h +++ b/core/multimedia/opieplayer/libmad/frame.h | |||
@@ -1,115 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_FRAME_H | 22 | # ifndef LIBMAD_FRAME_H |
23 | # define LIBMAD_FRAME_H | 23 | # define LIBMAD_FRAME_H |
24 | 24 | ||
25 | # include "fixed.h" | 25 | # include "fixed.h" |
26 | # include "timer.h" | 26 | # include "timer.h" |
27 | # include "stream.h" | 27 | # include "stream.h" |
28 | 28 | ||
29 | enum mad_layer { | 29 | enum mad_layer { |
30 | MAD_LAYER_I = 1, /* Layer I */ | 30 | MAD_LAYER_I = 1, /* Layer I */ |
31 | MAD_LAYER_II = 2, /* Layer II */ | 31 | MAD_LAYER_II = 2, /* Layer II */ |
32 | MAD_LAYER_III = 3 /* Layer III */ | 32 | MAD_LAYER_III = 3 /* Layer III */ |
33 | }; | 33 | }; |
34 | 34 | ||
35 | enum mad_mode { | 35 | enum mad_mode { |
36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ | 36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ |
37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ | 37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ |
38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ | 38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ |
39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ | 39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ |
40 | }; | 40 | }; |
41 | 41 | ||
42 | enum mad_emphasis { | 42 | enum mad_emphasis { |
43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ | 43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ |
44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ | 44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ |
45 | MAD_EMPHASIS_CCITT_J_17 = 3 /* CCITT J.17 emphasis */ | 45 | MAD_EMPHASIS_CCITT_J_17 = 3 /* CCITT J.17 emphasis */ |
46 | }; | 46 | }; |
47 | 47 | ||
48 | struct mad_frame { | 48 | struct mad_header { |
49 | struct mad_header { | 49 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ |
50 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ | 50 | enum mad_mode mode; /* channel mode (see above) */ |
51 | enum mad_mode mode; /* channel mode (see above) */ | 51 | int mode_extension; /* additional mode info */ |
52 | int mode_extension; /* additional mode info */ | 52 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ |
53 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ | 53 | |
54 | unsigned long bitrate; /* stream bitrate (bps) */ | ||
55 | unsigned int samplerate; /* sampling frequency (Hz) */ | ||
54 | 56 | ||
55 | unsigned long bitrate; /* stream bitrate (bps) */ | 57 | unsigned short crc_check; /* frame CRC accumulator */ |
56 | unsigned int samplerate; /* sampling frequency (Hz) */ | 58 | unsigned short crc_target; /* final target CRC checksum */ |
57 | 59 | ||
58 | unsigned short crc_check; /* frame CRC accumulator */ | 60 | int flags; /* flags (see below) */ |
59 | unsigned short crc_target; /* final target CRC checksum */ | 61 | int private_bits; /* private bits (see below) */ |
60 | 62 | ||
61 | int flags; /* flags (see below) */ | 63 | mad_timer_t duration; /* audio playing time of frame */ |
62 | int private_bits; /* private bits (see below) */ | 64 | }; |
63 | 65 | ||
64 | mad_timer_t duration; /* audio playing time of frame */ | 66 | struct mad_frame { |
65 | } header; | 67 | struct mad_header header; /* MPEG audio header */ |
66 | 68 | ||
67 | int options; /* decoding options (from stream) */ | 69 | int options; /* decoding options (from stream) */ |
68 | 70 | ||
69 | mad_fixed_t sbsample[2][36][32];/* synthesis subband filter samples */ | 71 | mad_fixed_t sbsample[2][36][32];/* synthesis subband filter samples */ |
70 | mad_fixed_t (*overlap)[2][32][18];/* Layer III block overlap data */ | 72 | mad_fixed_t (*overlap)[2][32][18];/* Layer III block overlap data */ |
71 | }; | 73 | }; |
72 | 74 | ||
73 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) | 75 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) |
74 | # define MAD_NSBSAMPLES(header) \ | 76 | # define MAD_NSBSAMPLES(header) \ |
75 | ((header)->layer == MAD_LAYER_I ? 12 : \ | 77 | ((header)->layer == MAD_LAYER_I ? 12 : \ |
76 | (((header)->layer == MAD_LAYER_III && \ | 78 | (((header)->layer == MAD_LAYER_III && \ |
77 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) | 79 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) |
78 | 80 | ||
79 | enum { | 81 | enum { |
80 | MAD_FLAG_NPRIVATE_III = 0x0007,/* number of Layer III private bits */ | 82 | MAD_FLAG_NPRIVATE_III = 0x0007,/* number of Layer III private bits */ |
81 | MAD_FLAG_INCOMPLETE = 0x0008,/* header but not data is decoded */ | 83 | MAD_FLAG_INCOMPLETE = 0x0008,/* header but not data is decoded */ |
82 | 84 | ||
83 | MAD_FLAG_PROTECTION = 0x0010,/* frame has CRC protection */ | 85 | MAD_FLAG_PROTECTION = 0x0010,/* frame has CRC protection */ |
84 | MAD_FLAG_COPYRIGHT = 0x0020,/* frame is copyright */ | 86 | MAD_FLAG_COPYRIGHT = 0x0020,/* frame is copyright */ |
85 | MAD_FLAG_ORIGINAL = 0x0040,/* frame is original (else copy) */ | 87 | MAD_FLAG_ORIGINAL = 0x0040,/* frame is original (else copy) */ |
86 | MAD_FLAG_PADDING = 0x0080,/* frame has additional slot */ | 88 | MAD_FLAG_PADDING = 0x0080,/* frame has additional slot */ |
87 | 89 | ||
88 | MAD_FLAG_I_STEREO = 0x0100,/* uses intensity joint stereo */ | 90 | MAD_FLAG_I_STEREO = 0x0100,/* uses intensity joint stereo */ |
89 | MAD_FLAG_MS_STEREO = 0x0200,/* uses middle/side joint stereo */ | 91 | MAD_FLAG_MS_STEREO = 0x0200,/* uses middle/side joint stereo */ |
90 | MAD_FLAG_FREEFORMAT = 0x0400,/* uses free format bitrate */ | 92 | MAD_FLAG_FREEFORMAT = 0x0400,/* uses free format bitrate */ |
91 | 93 | ||
92 | MAD_FLAG_LSF_EXT = 0x1000,/* lower sampling freq. extension */ | 94 | MAD_FLAG_LSF_EXT = 0x1000,/* lower sampling freq. extension */ |
93 | MAD_FLAG_MC_EXT = 0x2000,/* multichannel audio extension */ | 95 | MAD_FLAG_MC_EXT = 0x2000,/* multichannel audio extension */ |
94 | MAD_FLAG_MPEG_2_5_EXT = 0x4000/* MPEG 2.5 (unofficial) extension */ | 96 | MAD_FLAG_MPEG_2_5_EXT = 0x4000/* MPEG 2.5 (unofficial) extension */ |
95 | }; | 97 | }; |
96 | 98 | ||
97 | enum { | 99 | enum { |
98 | MAD_PRIVATE_HEADER = 0x0100,/* header private bit */ | 100 | MAD_PRIVATE_HEADER = 0x0100,/* header private bit */ |
99 | MAD_PRIVATE_III = 0x001f/* Layer III private bits (up to 5) */ | 101 | MAD_PRIVATE_III = 0x001f/* Layer III private bits (up to 5) */ |
100 | }; | 102 | }; |
101 | 103 | ||
102 | void mad_header_init(struct mad_header *); | 104 | void mad_header_init(struct mad_header *); |
103 | 105 | ||
104 | # define mad_header_finish(header) /* nothing */ | 106 | # define mad_header_finish(header) /* nothing */ |
105 | 107 | ||
106 | int mad_header_decode(struct mad_header *, struct mad_stream *); | 108 | int mad_header_decode(struct mad_header *, struct mad_stream *); |
107 | 109 | ||
108 | void mad_frame_init(struct mad_frame *); | 110 | void mad_frame_init(struct mad_frame *); |
109 | void mad_frame_finish(struct mad_frame *); | 111 | void mad_frame_finish(struct mad_frame *); |
110 | 112 | ||
111 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); | 113 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); |
112 | 114 | ||
113 | void mad_frame_mute(struct mad_frame *); | 115 | void mad_frame_mute(struct mad_frame *); |
114 | 116 | ||
115 | # endif | 117 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/huffman.c b/core/multimedia/opieplayer/libmad/huffman.c index 8ec9499..5ea6547 100644 --- a/core/multimedia/opieplayer/libmad/huffman.c +++ b/core/multimedia/opieplayer/libmad/huffman.c | |||
@@ -1,152 +1,163 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include "huffman.h" | 28 | # include "huffman.h" |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * These are the Huffman code words for Layer III. | 31 | * These are the Huffman code words for Layer III. |
32 | * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. | 32 | * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. |
33 | * | 33 | * |
34 | * These tables support decoding up to 4 Huffman code bits at a time. | 34 | * These tables support decoding up to 4 Huffman code bits at a time. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | # define V(v, w, x, y, hlen){ { 1, hlen, v, w, x, y } } | 37 | # if defined(__GNUC__) |
38 | # define PTR(offs, bits){ ptr: { 0, bits, offs } } | 38 | # define PTR(offs, bits){ ptr: { 0, bits, offs } } |
39 | # define V(v, w, x, y, hlen){ value: { 1, hlen, v, w, x, y } } | ||
40 | # else | ||
41 | # define PTR(offs, bits){ { 0, bits, offs } } | ||
42 | # define V(v, w, x, y, hlen){ { 1, hlen, (v << 0) | (w << 1) | \ | ||
43 | (x << 2) | (y << 3) } } | ||
44 | # endif | ||
39 | 45 | ||
40 | static | 46 | static |
41 | union huffquad const hufftabA[] = { | 47 | union huffquad const hufftabA[] = { |
42 | /* 0000 */ PTR(16, 2), | 48 | /* 0000 */ PTR(16, 2), |
43 | /* 0001 */ PTR(20, 2), | 49 | /* 0001 */ PTR(20, 2), |
44 | /* 0010 */ PTR(24, 1), | 50 | /* 0010 */ PTR(24, 1), |
45 | /* 0011 */ PTR(26, 1), | 51 | /* 0011 */ PTR(26, 1), |
46 | /* 0100 */ V(0, 0, 1, 0, 4), | 52 | /* 0100 */ V(0, 0, 1, 0, 4), |
47 | /* 0101 */ V(0, 0, 0, 1, 4), | 53 | /* 0101 */ V(0, 0, 0, 1, 4), |
48 | /* 0110 */ V(0, 1, 0, 0, 4), | 54 | /* 0110 */ V(0, 1, 0, 0, 4), |
49 | /* 0111 */ V(1, 0, 0, 0, 4), | 55 | /* 0111 */ V(1, 0, 0, 0, 4), |
50 | /* 1000 */ V(0, 0, 0, 0, 1), | 56 | /* 1000 */ V(0, 0, 0, 0, 1), |
51 | /* 1001 */ V(0, 0, 0, 0, 1), | 57 | /* 1001 */ V(0, 0, 0, 0, 1), |
52 | /* 1010 */ V(0, 0, 0, 0, 1), | 58 | /* 1010 */ V(0, 0, 0, 0, 1), |
53 | /* 1011 */ V(0, 0, 0, 0, 1), | 59 | /* 1011 */ V(0, 0, 0, 0, 1), |
54 | /* 1100 */ V(0, 0, 0, 0, 1), | 60 | /* 1100 */ V(0, 0, 0, 0, 1), |
55 | /* 1101 */ V(0, 0, 0, 0, 1), | 61 | /* 1101 */ V(0, 0, 0, 0, 1), |
56 | /* 1110 */ V(0, 0, 0, 0, 1), | 62 | /* 1110 */ V(0, 0, 0, 0, 1), |
57 | /* 1111 */ V(0, 0, 0, 0, 1), | 63 | /* 1111 */ V(0, 0, 0, 0, 1), |
58 | 64 | ||
59 | /* 0000 ... */ | 65 | /* 0000 ... */ |
60 | /* 00 */ V(1, 0, 1, 1, 2),/* 16 */ | 66 | /* 00 */ V(1, 0, 1, 1, 2),/* 16 */ |
61 | /* 01 */ V(1, 1, 1, 1, 2), | 67 | /* 01 */ V(1, 1, 1, 1, 2), |
62 | /* 10 */ V(1, 1, 0, 1, 2), | 68 | /* 10 */ V(1, 1, 0, 1, 2), |
63 | /* 11 */ V(1, 1, 1, 0, 2), | 69 | /* 11 */ V(1, 1, 1, 0, 2), |
64 | 70 | ||
65 | /* 0001 ... */ | 71 | /* 0001 ... */ |
66 | /* 00 */ V(0, 1, 1, 1, 2),/* 20 */ | 72 | /* 00 */ V(0, 1, 1, 1, 2),/* 20 */ |
67 | /* 01 */ V(0, 1, 0, 1, 2), | 73 | /* 01 */ V(0, 1, 0, 1, 2), |
68 | /* 10 */ V(1, 0, 0, 1, 1), | 74 | /* 10 */ V(1, 0, 0, 1, 1), |
69 | /* 11 */ V(1, 0, 0, 1, 1), | 75 | /* 11 */ V(1, 0, 0, 1, 1), |
70 | 76 | ||
71 | /* 0010 ... */ | 77 | /* 0010 ... */ |
72 | /* 0 */ V(0, 1, 1, 0, 1),/* 24 */ | 78 | /* 0 */ V(0, 1, 1, 0, 1),/* 24 */ |
73 | /* 1 */ V(0, 0, 1, 1, 1), | 79 | /* 1 */ V(0, 0, 1, 1, 1), |
74 | 80 | ||
75 | /* 0011 ... */ | 81 | /* 0011 ... */ |
76 | /* 0 */ V(1, 0, 1, 0, 1),/* 26 */ | 82 | /* 0 */ V(1, 0, 1, 0, 1),/* 26 */ |
77 | /* 1 */ V(1, 1, 0, 0, 1) | 83 | /* 1 */ V(1, 1, 0, 0, 1) |
78 | }; | 84 | }; |
79 | 85 | ||
80 | static | 86 | static |
81 | union huffquad const hufftabB[] = { | 87 | union huffquad const hufftabB[] = { |
82 | /* 0000 */ V(1, 1, 1, 1, 4), | 88 | /* 0000 */ V(1, 1, 1, 1, 4), |
83 | /* 0001 */ V(1, 1, 1, 0, 4), | 89 | /* 0001 */ V(1, 1, 1, 0, 4), |
84 | /* 0010 */ V(1, 1, 0, 1, 4), | 90 | /* 0010 */ V(1, 1, 0, 1, 4), |
85 | /* 0011 */ V(1, 1, 0, 0, 4), | 91 | /* 0011 */ V(1, 1, 0, 0, 4), |
86 | /* 0100 */ V(1, 0, 1, 1, 4), | 92 | /* 0100 */ V(1, 0, 1, 1, 4), |
87 | /* 0101 */ V(1, 0, 1, 0, 4), | 93 | /* 0101 */ V(1, 0, 1, 0, 4), |
88 | /* 0110 */ V(1, 0, 0, 1, 4), | 94 | /* 0110 */ V(1, 0, 0, 1, 4), |
89 | /* 0111 */ V(1, 0, 0, 0, 4), | 95 | /* 0111 */ V(1, 0, 0, 0, 4), |
90 | /* 1000 */ V(0, 1, 1, 1, 4), | 96 | /* 1000 */ V(0, 1, 1, 1, 4), |
91 | /* 1001 */ V(0, 1, 1, 0, 4), | 97 | /* 1001 */ V(0, 1, 1, 0, 4), |
92 | /* 1010 */ V(0, 1, 0, 1, 4), | 98 | /* 1010 */ V(0, 1, 0, 1, 4), |
93 | /* 1011 */ V(0, 1, 0, 0, 4), | 99 | /* 1011 */ V(0, 1, 0, 0, 4), |
94 | /* 1100 */ V(0, 0, 1, 1, 4), | 100 | /* 1100 */ V(0, 0, 1, 1, 4), |
95 | /* 1101 */ V(0, 0, 1, 0, 4), | 101 | /* 1101 */ V(0, 0, 1, 0, 4), |
96 | /* 1110 */ V(0, 0, 0, 1, 4), | 102 | /* 1110 */ V(0, 0, 0, 1, 4), |
97 | /* 1111 */ V(0, 0, 0, 0, 4) | 103 | /* 1111 */ V(0, 0, 0, 0, 4) |
98 | }; | 104 | }; |
99 | 105 | ||
100 | # undef V | 106 | # undef V |
101 | # undef PTR | 107 | # undef PTR |
102 | 108 | ||
103 | # define V(x, y, hlen) { { 1, hlen, x, y } } | 109 | # if defined(__GNUC__) |
104 | # define PTR(offs, bits){ ptr: { 0, bits, offs } } | 110 | # define PTR(offs, bits){ ptr: { 0, bits, offs } } |
111 | # define V(x, y, hlen) { value: { 1, hlen, x, y } } | ||
112 | # else | ||
113 | # define PTR(offs, bits){ { 0, bits, offs } } | ||
114 | # define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } } | ||
115 | # endif | ||
105 | 116 | ||
106 | static | 117 | static |
107 | union huffpair const hufftab0[] = { | 118 | union huffpair const hufftab0[] = { |
108 | /* */ V(0, 0, 0) | 119 | /* */ V(0, 0, 0) |
109 | }; | 120 | }; |
110 | 121 | ||
111 | static | 122 | static |
112 | union huffpair const hufftab1[] = { | 123 | union huffpair const hufftab1[] = { |
113 | /* 000 */ V(1, 1, 3), | 124 | /* 000 */ V(1, 1, 3), |
114 | /* 001 */ V(0, 1, 3), | 125 | /* 001 */ V(0, 1, 3), |
115 | /* 010 */ V(1, 0, 2), | 126 | /* 010 */ V(1, 0, 2), |
116 | /* 011 */ V(1, 0, 2), | 127 | /* 011 */ V(1, 0, 2), |
117 | /* 100 */ V(0, 0, 1), | 128 | /* 100 */ V(0, 0, 1), |
118 | /* 101 */ V(0, 0, 1), | 129 | /* 101 */ V(0, 0, 1), |
119 | /* 110 */ V(0, 0, 1), | 130 | /* 110 */ V(0, 0, 1), |
120 | /* 111 */ V(0, 0, 1) | 131 | /* 111 */ V(0, 0, 1) |
121 | }; | 132 | }; |
122 | 133 | ||
123 | static | 134 | static |
124 | union huffpair const hufftab2[] = { | 135 | union huffpair const hufftab2[] = { |
125 | /* 000 */ PTR(8, 3), | 136 | /* 000 */ PTR(8, 3), |
126 | /* 001 */ V(1, 1, 3), | 137 | /* 001 */ V(1, 1, 3), |
127 | /* 010 */ V(0, 1, 3), | 138 | /* 010 */ V(0, 1, 3), |
128 | /* 011 */ V(1, 0, 3), | 139 | /* 011 */ V(1, 0, 3), |
129 | /* 100 */ V(0, 0, 1), | 140 | /* 100 */ V(0, 0, 1), |
130 | /* 101 */ V(0, 0, 1), | 141 | /* 101 */ V(0, 0, 1), |
131 | /* 110 */ V(0, 0, 1), | 142 | /* 110 */ V(0, 0, 1), |
132 | /* 111 */ V(0, 0, 1), | 143 | /* 111 */ V(0, 0, 1), |
133 | 144 | ||
134 | /* 000 ... */ | 145 | /* 000 ... */ |
135 | /* 000 */ V(2, 2, 3),/* 8 */ | 146 | /* 000 */ V(2, 2, 3),/* 8 */ |
136 | /* 001 */ V(0, 2, 3), | 147 | /* 001 */ V(0, 2, 3), |
137 | /* 010 */ V(1, 2, 2), | 148 | /* 010 */ V(1, 2, 2), |
138 | /* 011 */ V(1, 2, 2), | 149 | /* 011 */ V(1, 2, 2), |
139 | /* 100 */ V(2, 1, 2), | 150 | /* 100 */ V(2, 1, 2), |
140 | /* 101 */ V(2, 1, 2), | 151 | /* 101 */ V(2, 1, 2), |
141 | /* 110 */ V(2, 0, 2), | 152 | /* 110 */ V(2, 0, 2), |
142 | /* 111 */ V(2, 0, 2) | 153 | /* 111 */ V(2, 0, 2) |
143 | }; | 154 | }; |
144 | 155 | ||
145 | static | 156 | static |
146 | union huffpair const hufftab3[] = { | 157 | union huffpair const hufftab3[] = { |
147 | /* 000 */ PTR(8, 3), | 158 | /* 000 */ PTR(8, 3), |
148 | /* 001 */ V(1, 0, 3), | 159 | /* 001 */ V(1, 0, 3), |
149 | /* 010 */ V(1, 1, 2), | 160 | /* 010 */ V(1, 1, 2), |
150 | /* 011 */ V(1, 1, 2), | 161 | /* 011 */ V(1, 1, 2), |
151 | /* 100 */ V(0, 1, 2), | 162 | /* 100 */ V(0, 1, 2), |
152 | /* 101 */ V(0, 1, 2), | 163 | /* 101 */ V(0, 1, 2), |
diff --git a/core/multimedia/opieplayer/libmad/huffman.h b/core/multimedia/opieplayer/libmad/huffman.h index 1801210..d051949 100644 --- a/core/multimedia/opieplayer/libmad/huffman.h +++ b/core/multimedia/opieplayer/libmad/huffman.h | |||
@@ -1,66 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_HUFFMAN_H | 22 | # ifndef LIBMAD_HUFFMAN_H |
23 | # define LIBMAD_HUFFMAN_H | 23 | # define LIBMAD_HUFFMAN_H |
24 | 24 | ||
25 | union huffquad { | 25 | union huffquad { |
26 | struct { | 26 | struct { |
27 | unsigned short final : 1; | 27 | unsigned short final : 1; |
28 | unsigned short bits : 3; | ||
29 | unsigned short offset : 12; | ||
30 | } ptr; | ||
31 | struct { | ||
32 | unsigned short final : 1; | ||
28 | unsigned short hlen : 3; | 33 | unsigned short hlen : 3; |
29 | unsigned short v : 1; | 34 | unsigned short v : 1; |
30 | unsigned short w : 1; | 35 | unsigned short w : 1; |
31 | unsigned short x : 1; | 36 | unsigned short x : 1; |
32 | unsigned short y : 1; | 37 | unsigned short y : 1; |
33 | } value; | 38 | } value; |
39 | unsigned short final : 1; | ||
40 | }; | ||
41 | |||
42 | union huffpair { | ||
34 | struct { | 43 | struct { |
35 | unsigned short final : 1; | 44 | unsigned short final : 1; |
36 | unsigned short bits : 3; | 45 | unsigned short bits : 3; |
37 | unsigned short offset : 12; | 46 | unsigned short offset : 12; |
38 | } ptr; | 47 | } ptr; |
39 | unsigned short final : 1; | ||
40 | }; | ||
41 | |||
42 | union huffpair { | ||
43 | struct { | 48 | struct { |
44 | unsigned short final : 1; | 49 | unsigned short final : 1; |
45 | unsigned short hlen : 3; | 50 | unsigned short hlen : 3; |
46 | unsigned short x : 4; | 51 | unsigned short x : 4; |
47 | unsigned short y : 4; | 52 | unsigned short y : 4; |
48 | } value; | 53 | } value; |
49 | struct { | ||
50 | unsigned short final : 1; | ||
51 | unsigned short bits : 3; | ||
52 | unsigned short offset : 12; | ||
53 | } ptr; | ||
54 | unsigned short final : 1; | 54 | unsigned short final : 1; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | struct hufftable { | 57 | struct hufftable { |
58 | union huffpair const *table; | 58 | union huffpair const *table; |
59 | unsigned short linbits; | 59 | unsigned short linbits; |
60 | unsigned short startbits; | 60 | unsigned short startbits; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | extern union huffquad const *const mad_huff_quad_table[2]; | 63 | extern union huffquad const *const mad_huff_quad_table[2]; |
64 | extern struct hufftable const mad_huff_pair_table[32]; | 64 | extern struct hufftable const mad_huff_pair_table[32]; |
65 | 65 | ||
66 | # endif | 66 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/imdct_s.dat b/core/multimedia/opieplayer/libmad/imdct_s.dat index 00d62eb..ed70446 100644 --- a/core/multimedia/opieplayer/libmad/imdct_s.dat +++ b/core/multimedia/opieplayer/libmad/imdct_s.dat | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, | 22 | /* 0 */ { MAD_F(0x09bd7ca0) /* 0.608761429 */, |
23 | -MAD_F(0x0ec835e8) /* -0.923879533 */, | 23 | -MAD_F(0x0ec835e8) /* -0.923879533 */, |
24 | -MAD_F(0x0216a2a2) /* -0.130526192 */, | 24 | -MAD_F(0x0216a2a2) /* -0.130526192 */, |
25 | MAD_F(0x0fdcf549) /* 0.991444861 */, | 25 | MAD_F(0x0fdcf549) /* 0.991444861 */, |
26 | -MAD_F(0x061f78aa) /* -0.382683432 */, | 26 | -MAD_F(0x061f78aa) /* -0.382683432 */, |
27 | -MAD_F(0x0cb19346) /* -0.793353340 */ }, | 27 | -MAD_F(0x0cb19346) /* -0.793353340 */ }, |
28 | 28 | ||
29 | /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, | 29 | /* 6 */ { -MAD_F(0x0cb19346) /* -0.793353340 */, |
30 | MAD_F(0x061f78aa) /* 0.382683432 */, | 30 | MAD_F(0x061f78aa) /* 0.382683432 */, |
31 | MAD_F(0x0fdcf549) /* 0.991444861 */, | 31 | MAD_F(0x0fdcf549) /* 0.991444861 */, |
32 | MAD_F(0x0216a2a2) /* 0.130526192 */, | 32 | MAD_F(0x0216a2a2) /* 0.130526192 */, |
33 | -MAD_F(0x0ec835e8) /* -0.923879533 */, | 33 | -MAD_F(0x0ec835e8) /* -0.923879533 */, |
34 | -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, | 34 | -MAD_F(0x09bd7ca0) /* -0.608761429 */ }, |
35 | 35 | ||
36 | /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, | 36 | /* 1 */ { MAD_F(0x061f78aa) /* 0.382683432 */, |
37 | -MAD_F(0x0ec835e8) /* -0.923879533 */, | 37 | -MAD_F(0x0ec835e8) /* -0.923879533 */, |
38 | MAD_F(0x0ec835e8) /* 0.923879533 */, | 38 | MAD_F(0x0ec835e8) /* 0.923879533 */, |
39 | -MAD_F(0x061f78aa) /* -0.382683432 */, | 39 | -MAD_F(0x061f78aa) /* -0.382683432 */, |
40 | -MAD_F(0x061f78aa) /* -0.382683432 */, | 40 | -MAD_F(0x061f78aa) /* -0.382683432 */, |
41 | MAD_F(0x0ec835e8) /* 0.923879533 */ }, | 41 | MAD_F(0x0ec835e8) /* 0.923879533 */ }, |
42 | 42 | ||
43 | /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, | 43 | /* 7 */ { -MAD_F(0x0ec835e8) /* -0.923879533 */, |
44 | -MAD_F(0x061f78aa) /* -0.382683432 */, | 44 | -MAD_F(0x061f78aa) /* -0.382683432 */, |
45 | MAD_F(0x061f78aa) /* 0.382683432 */, | 45 | MAD_F(0x061f78aa) /* 0.382683432 */, |
46 | MAD_F(0x0ec835e8) /* 0.923879533 */, | 46 | MAD_F(0x0ec835e8) /* 0.923879533 */, |
47 | MAD_F(0x0ec835e8) /* 0.923879533 */, | 47 | MAD_F(0x0ec835e8) /* 0.923879533 */, |
48 | MAD_F(0x061f78aa) /* 0.382683432 */ }, | 48 | MAD_F(0x061f78aa) /* 0.382683432 */ }, |
49 | 49 | ||
50 | /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, | 50 | /* 2 */ { MAD_F(0x0216a2a2) /* 0.130526192 */, |
diff --git a/core/multimedia/opieplayer/libmad/layer12.c b/core/multimedia/opieplayer/libmad/layer12.c index 41b17ca..d291174 100644 --- a/core/multimedia/opieplayer/libmad/layer12.c +++ b/core/multimedia/opieplayer/libmad/layer12.c | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # ifdef HAVE_LIMITS_H | 28 | # ifdef HAVE_LIMITS_H |
29 | # include <limits.h> | 29 | # include <limits.h> |
30 | # else | 30 | # else |
31 | # define CHAR_BIT 8 | 31 | # define CHAR_BIT 8 |
32 | # endif | 32 | # endif |
33 | 33 | ||
34 | # include "fixed.h" | 34 | # include "fixed.h" |
35 | # include "bit.h" | 35 | # include "bit.h" |
36 | # include "stream.h" | 36 | # include "stream.h" |
37 | # include "frame.h" | 37 | # include "frame.h" |
38 | # include "layer12.h" | 38 | # include "layer12.h" |
39 | 39 | ||
40 | /* | 40 | /* |
41 | * scalefactor table | 41 | * scalefactor table |
42 | * used in both Layer I and Layer II decoding | 42 | * used in both Layer I and Layer II decoding |
43 | */ | 43 | */ |
44 | static | 44 | static |
45 | mad_fixed_t const sf_table[63] = { | 45 | mad_fixed_t const sf_table[63] = { |
46 | # include "sf_table.dat" | 46 | # include "sf_table.dat" |
47 | }; | 47 | }; |
48 | 48 | ||
49 | /* --- Layer I ------------------------------------------------------------- */ | 49 | /* --- Layer I ------------------------------------------------------------- */ |
50 | 50 | ||
diff --git a/core/multimedia/opieplayer/libmad/layer12.h b/core/multimedia/opieplayer/libmad/layer12.h index d2c81ac..c673726 100644 --- a/core/multimedia/opieplayer/libmad/layer12.h +++ b/core/multimedia/opieplayer/libmad/layer12.h | |||
@@ -1,31 +1,31 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_LAYER12_H | 22 | # ifndef LIBMAD_LAYER12_H |
23 | # define LIBMAD_LAYER12_H | 23 | # define LIBMAD_LAYER12_H |
24 | 24 | ||
25 | # include "stream.h" | 25 | # include "stream.h" |
26 | # include "frame.h" | 26 | # include "frame.h" |
27 | 27 | ||
28 | int mad_layer_I(struct mad_stream *, struct mad_frame *); | 28 | int mad_layer_I(struct mad_stream *, struct mad_frame *); |
29 | int mad_layer_II(struct mad_stream *, struct mad_frame *); | 29 | int mad_layer_II(struct mad_stream *, struct mad_frame *); |
30 | 30 | ||
31 | # endif | 31 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/layer3.c b/core/multimedia/opieplayer/libmad/layer3.c index 194fc7e..03f13fe 100644 --- a/core/multimedia/opieplayer/libmad/layer3.c +++ b/core/multimedia/opieplayer/libmad/layer3.c | |||
@@ -1,101 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include <stdlib.h> | 28 | # include <stdlib.h> |
29 | # include <string.h> | 29 | # include <string.h> |
30 | # include <assert.h> | 30 | |
31 | # ifdef HAVE_ASSERT_H | ||
32 | # include <assert.h> | ||
33 | # endif | ||
31 | 34 | ||
32 | # ifdef HAVE_LIMITS_H | 35 | # ifdef HAVE_LIMITS_H |
33 | # include <limits.h> | 36 | # include <limits.h> |
34 | # else | 37 | # else |
35 | # define CHAR_BIT 8 | 38 | # define CHAR_BIT 8 |
36 | # endif | 39 | # endif |
37 | 40 | ||
38 | # include "fixed.h" | 41 | # include "fixed.h" |
39 | # include "bit.h" | 42 | # include "bit.h" |
40 | # include "stream.h" | 43 | # include "stream.h" |
41 | # include "frame.h" | 44 | # include "frame.h" |
42 | # include "huffman.h" | 45 | # include "huffman.h" |
43 | # include "layer3.h" | 46 | # include "layer3.h" |
44 | 47 | ||
45 | /* --- Layer III ----------------------------------------------------------- */ | 48 | /* --- Layer III ----------------------------------------------------------- */ |
46 | 49 | ||
47 | enum { | 50 | enum { |
48 | count1table_select = 0x01, | 51 | count1table_select = 0x01, |
49 | scalefac_scale = 0x02, | 52 | scalefac_scale = 0x02, |
50 | preflag = 0x04, | 53 | preflag = 0x04, |
51 | mixed_block_flag = 0x08 | 54 | mixed_block_flag = 0x08 |
52 | }; | 55 | }; |
53 | 56 | ||
57 | enum { | ||
58 | I_STEREO = 0x1, | ||
59 | MS_STEREO = 0x2 | ||
60 | }; | ||
61 | |||
54 | struct sideinfo { | 62 | struct sideinfo { |
55 | unsigned int main_data_begin; | 63 | unsigned int main_data_begin; |
56 | unsigned int private_bits; | 64 | unsigned int private_bits; |
57 | 65 | ||
58 | unsigned char scfsi[2]; | 66 | unsigned char scfsi[2]; |
59 | 67 | ||
60 | struct granule { | 68 | struct granule { |
61 | struct channel { | 69 | struct channel { |
62 | /* from side info */ | 70 | /* from side info */ |
63 | unsigned short part2_3_length; | 71 | unsigned short part2_3_length; |
64 | unsigned short big_values; | 72 | unsigned short big_values; |
65 | unsigned short global_gain; | 73 | unsigned short global_gain; |
66 | unsigned short scalefac_compress; | 74 | unsigned short scalefac_compress; |
67 | 75 | ||
68 | unsigned char flags; | 76 | unsigned char flags; |
69 | unsigned char block_type; | 77 | unsigned char block_type; |
70 | unsigned char table_select[3]; | 78 | unsigned char table_select[3]; |
71 | unsigned char subblock_gain[3]; | 79 | unsigned char subblock_gain[3]; |
72 | unsigned char region0_count; | 80 | unsigned char region0_count; |
73 | unsigned char region1_count; | 81 | unsigned char region1_count; |
74 | 82 | ||
75 | /* from main_data */ | 83 | /* from main_data */ |
76 | unsigned char scalefac[39];/* scalefac_l and/or scalefac_s */ | 84 | unsigned char scalefac[39];/* scalefac_l and/or scalefac_s */ |
77 | } ch[2]; | 85 | } ch[2]; |
78 | } gr[2]; | 86 | } gr[2]; |
79 | }; | 87 | }; |
80 | 88 | ||
81 | /* | 89 | /* |
82 | * scalefactor bit lengths | 90 | * scalefactor bit lengths |
83 | * derived from section 2.4.2.7 of ISO/IEC 11172-3 | 91 | * derived from section 2.4.2.7 of ISO/IEC 11172-3 |
84 | */ | 92 | */ |
85 | static | 93 | static |
86 | struct { | 94 | struct { |
87 | unsigned char slen1; | 95 | unsigned char slen1; |
88 | unsigned char slen2; | 96 | unsigned char slen2; |
89 | } const sflen_table[16] = { | 97 | } const sflen_table[16] = { |
90 | { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, | 98 | { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, |
91 | { 3, 0 }, { 1, 1 }, { 1, 2 }, { 1, 3 }, | 99 | { 3, 0 }, { 1, 1 }, { 1, 2 }, { 1, 3 }, |
92 | { 2, 1 }, { 2, 2 }, { 2, 3 }, { 3, 1 }, | 100 | { 2, 1 }, { 2, 2 }, { 2, 3 }, { 3, 1 }, |
93 | { 3, 2 }, { 3, 3 }, { 4, 2 }, { 4, 3 } | 101 | { 3, 2 }, { 3, 3 }, { 4, 2 }, { 4, 3 } |
94 | }; | 102 | }; |
95 | 103 | ||
96 | /* | 104 | /* |
97 | * number of LSF scalefactor band values | 105 | * number of LSF scalefactor band values |
98 | * derived from section 2.4.3.2 of ISO/IEC 13818-3 | 106 | * derived from section 2.4.3.2 of ISO/IEC 13818-3 |
99 | */ | 107 | */ |
100 | static | 108 | static |
101 | unsigned char const nsfb_table[6][3][4] = { | 109 | unsigned char const nsfb_table[6][3][4] = { |
@@ -458,97 +466,97 @@ mad_fixed_t const is_table[7] = { | |||
458 | static | 466 | static |
459 | mad_fixed_t const is_lsf_table[2][15] = { | 467 | mad_fixed_t const is_lsf_table[2][15] = { |
460 | { | 468 | { |
461 | MAD_F(0x0d744fcd) /* 0.840896415 */, | 469 | MAD_F(0x0d744fcd) /* 0.840896415 */, |
462 | MAD_F(0x0b504f33) /* 0.707106781 */, | 470 | MAD_F(0x0b504f33) /* 0.707106781 */, |
463 | MAD_F(0x09837f05) /* 0.594603558 */, | 471 | MAD_F(0x09837f05) /* 0.594603558 */, |
464 | MAD_F(0x08000000) /* 0.500000000 */, | 472 | MAD_F(0x08000000) /* 0.500000000 */, |
465 | MAD_F(0x06ba27e6) /* 0.420448208 */, | 473 | MAD_F(0x06ba27e6) /* 0.420448208 */, |
466 | MAD_F(0x05a8279a) /* 0.353553391 */, | 474 | MAD_F(0x05a8279a) /* 0.353553391 */, |
467 | MAD_F(0x04c1bf83) /* 0.297301779 */, | 475 | MAD_F(0x04c1bf83) /* 0.297301779 */, |
468 | MAD_F(0x04000000) /* 0.250000000 */, | 476 | MAD_F(0x04000000) /* 0.250000000 */, |
469 | MAD_F(0x035d13f3) /* 0.210224104 */, | 477 | MAD_F(0x035d13f3) /* 0.210224104 */, |
470 | MAD_F(0x02d413cd) /* 0.176776695 */, | 478 | MAD_F(0x02d413cd) /* 0.176776695 */, |
471 | MAD_F(0x0260dfc1) /* 0.148650889 */, | 479 | MAD_F(0x0260dfc1) /* 0.148650889 */, |
472 | MAD_F(0x02000000) /* 0.125000000 */, | 480 | MAD_F(0x02000000) /* 0.125000000 */, |
473 | MAD_F(0x01ae89fa) /* 0.105112052 */, | 481 | MAD_F(0x01ae89fa) /* 0.105112052 */, |
474 | MAD_F(0x016a09e6) /* 0.088388348 */, | 482 | MAD_F(0x016a09e6) /* 0.088388348 */, |
475 | MAD_F(0x01306fe1) /* 0.074325445 */ | 483 | MAD_F(0x01306fe1) /* 0.074325445 */ |
476 | }, { | 484 | }, { |
477 | MAD_F(0x0b504f33) /* 0.707106781 */, | 485 | MAD_F(0x0b504f33) /* 0.707106781 */, |
478 | MAD_F(0x08000000) /* 0.500000000 */, | 486 | MAD_F(0x08000000) /* 0.500000000 */, |
479 | MAD_F(0x05a8279a) /* 0.353553391 */, | 487 | MAD_F(0x05a8279a) /* 0.353553391 */, |
480 | MAD_F(0x04000000) /* 0.250000000 */, | 488 | MAD_F(0x04000000) /* 0.250000000 */, |
481 | MAD_F(0x02d413cd) /* 0.176776695 */, | 489 | MAD_F(0x02d413cd) /* 0.176776695 */, |
482 | MAD_F(0x02000000) /* 0.125000000 */, | 490 | MAD_F(0x02000000) /* 0.125000000 */, |
483 | MAD_F(0x016a09e6) /* 0.088388348 */, | 491 | MAD_F(0x016a09e6) /* 0.088388348 */, |
484 | MAD_F(0x01000000) /* 0.062500000 */, | 492 | MAD_F(0x01000000) /* 0.062500000 */, |
485 | MAD_F(0x00b504f3) /* 0.044194174 */, | 493 | MAD_F(0x00b504f3) /* 0.044194174 */, |
486 | MAD_F(0x00800000) /* 0.031250000 */, | 494 | MAD_F(0x00800000) /* 0.031250000 */, |
487 | MAD_F(0x005a827a) /* 0.022097087 */, | 495 | MAD_F(0x005a827a) /* 0.022097087 */, |
488 | MAD_F(0x00400000) /* 0.015625000 */, | 496 | MAD_F(0x00400000) /* 0.015625000 */, |
489 | MAD_F(0x002d413d) /* 0.011048543 */, | 497 | MAD_F(0x002d413d) /* 0.011048543 */, |
490 | MAD_F(0x00200000) /* 0.007812500 */, | 498 | MAD_F(0x00200000) /* 0.007812500 */, |
491 | MAD_F(0x0016a09e) /* 0.005524272 */ | 499 | MAD_F(0x0016a09e) /* 0.005524272 */ |
492 | } | 500 | } |
493 | }; | 501 | }; |
494 | 502 | ||
495 | /* | 503 | /* |
496 | * NAME:III_sideinfo() | 504 | * NAME:III_sideinfo() |
497 | * DESCRIPTION:decode frame side information from a bitstream | 505 | * DESCRIPTION:decode frame side information from a bitstream |
498 | */ | 506 | */ |
499 | static | 507 | static |
500 | enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, | 508 | enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, |
501 | int lsf, struct sideinfo *si, | 509 | int lsf, struct sideinfo *si, |
502 | unsigned int *data_bitlen, | 510 | unsigned int *data_bitlen, |
503 | unsigned int *priv_bitlen) | 511 | unsigned int *priv_bitlen) |
504 | { | 512 | { |
505 | unsigned int ngr, gr, ch, i; | 513 | unsigned int ngr, gr, ch, i; |
506 | enum mad_error result = 0; | 514 | enum mad_error result = MAD_ERROR_NONE; |
507 | 515 | ||
508 | *data_bitlen = 0; | 516 | *data_bitlen = 0; |
509 | *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); | 517 | *priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3); |
510 | 518 | ||
511 | si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9); | 519 | si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9); |
512 | si->private_bits = mad_bit_read(ptr, *priv_bitlen); | 520 | si->private_bits = mad_bit_read(ptr, *priv_bitlen); |
513 | 521 | ||
514 | ngr = 1; | 522 | ngr = 1; |
515 | if (!lsf) { | 523 | if (!lsf) { |
516 | ngr = 2; | 524 | ngr = 2; |
517 | 525 | ||
518 | for (ch = 0; ch < nch; ++ch) | 526 | for (ch = 0; ch < nch; ++ch) |
519 | si->scfsi[ch] = mad_bit_read(ptr, 4); | 527 | si->scfsi[ch] = mad_bit_read(ptr, 4); |
520 | } | 528 | } |
521 | 529 | ||
522 | for (gr = 0; gr < ngr; ++gr) { | 530 | for (gr = 0; gr < ngr; ++gr) { |
523 | struct granule *granule = &si->gr[gr]; | 531 | struct granule *granule = &si->gr[gr]; |
524 | 532 | ||
525 | for (ch = 0; ch < nch; ++ch) { | 533 | for (ch = 0; ch < nch; ++ch) { |
526 | struct channel *channel = &granule->ch[ch]; | 534 | struct channel *channel = &granule->ch[ch]; |
527 | 535 | ||
528 | channel->part2_3_length = mad_bit_read(ptr, 12); | 536 | channel->part2_3_length = mad_bit_read(ptr, 12); |
529 | channel->big_values = mad_bit_read(ptr, 9); | 537 | channel->big_values = mad_bit_read(ptr, 9); |
530 | channel->global_gain = mad_bit_read(ptr, 8); | 538 | channel->global_gain = mad_bit_read(ptr, 8); |
531 | channel->scalefac_compress = mad_bit_read(ptr, lsf ? 9 : 4); | 539 | channel->scalefac_compress = mad_bit_read(ptr, lsf ? 9 : 4); |
532 | 540 | ||
533 | *data_bitlen += channel->part2_3_length; | 541 | *data_bitlen += channel->part2_3_length; |
534 | 542 | ||
535 | if (channel->big_values > 288 && result == 0) | 543 | if (channel->big_values > 288 && result == 0) |
536 | result = MAD_ERROR_BADBIGVALUES; | 544 | result = MAD_ERROR_BADBIGVALUES; |
537 | 545 | ||
538 | channel->flags = 0; | 546 | channel->flags = 0; |
539 | 547 | ||
540 | /* window_switching_flag */ | 548 | /* window_switching_flag */ |
541 | if (mad_bit_read(ptr, 1)) { | 549 | if (mad_bit_read(ptr, 1)) { |
542 | channel->block_type = mad_bit_read(ptr, 2); | 550 | channel->block_type = mad_bit_read(ptr, 2); |
543 | 551 | ||
544 | if (channel->block_type == 0 && result == 0) | 552 | if (channel->block_type == 0 && result == 0) |
545 | result = MAD_ERROR_BADBLOCKTYPE; | 553 | result = MAD_ERROR_BADBLOCKTYPE; |
546 | 554 | ||
547 | if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) | 555 | if (!lsf && channel->block_type == 2 && si->scfsi[ch] && result == 0) |
548 | result = MAD_ERROR_BADSCFSI; | 556 | result = MAD_ERROR_BADSCFSI; |
549 | 557 | ||
550 | channel->region0_count = 7; | 558 | channel->region0_count = 7; |
551 | channel->region1_count = 36; | 559 | channel->region1_count = 36; |
552 | 560 | ||
553 | if (mad_bit_read(ptr, 1)) | 561 | if (mad_bit_read(ptr, 1)) |
554 | channel->flags |= mixed_block_flag; | 562 | channel->flags |= mixed_block_flag; |
@@ -557,138 +565,138 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, | |||
557 | 565 | ||
558 | for (i = 0; i < 2; ++i) | 566 | for (i = 0; i < 2; ++i) |
559 | channel->table_select[i] = mad_bit_read(ptr, 5); | 567 | channel->table_select[i] = mad_bit_read(ptr, 5); |
560 | 568 | ||
561 | # if defined(DEBUG) | 569 | # if defined(DEBUG) |
562 | channel->table_select[2] = 4; /* not used */ | 570 | channel->table_select[2] = 4; /* not used */ |
563 | # endif | 571 | # endif |
564 | 572 | ||
565 | for (i = 0; i < 3; ++i) | 573 | for (i = 0; i < 3; ++i) |
566 | channel->subblock_gain[i] = mad_bit_read(ptr, 3); | 574 | channel->subblock_gain[i] = mad_bit_read(ptr, 3); |
567 | } | 575 | } |
568 | else { | 576 | else { |
569 | channel->block_type = 0; | 577 | channel->block_type = 0; |
570 | 578 | ||
571 | for (i = 0; i < 3; ++i) | 579 | for (i = 0; i < 3; ++i) |
572 | channel->table_select[i] = mad_bit_read(ptr, 5); | 580 | channel->table_select[i] = mad_bit_read(ptr, 5); |
573 | 581 | ||
574 | channel->region0_count = mad_bit_read(ptr, 4); | 582 | channel->region0_count = mad_bit_read(ptr, 4); |
575 | channel->region1_count = mad_bit_read(ptr, 3); | 583 | channel->region1_count = mad_bit_read(ptr, 3); |
576 | } | 584 | } |
577 | 585 | ||
578 | /* [preflag,] scalefac_scale, count1table_select */ | 586 | /* [preflag,] scalefac_scale, count1table_select */ |
579 | channel->flags |= mad_bit_read(ptr, lsf ? 2 : 3); | 587 | channel->flags |= mad_bit_read(ptr, lsf ? 2 : 3); |
580 | } | 588 | } |
581 | } | 589 | } |
582 | 590 | ||
583 | return result; | 591 | return result; |
584 | } | 592 | } |
585 | 593 | ||
586 | /* | 594 | /* |
587 | * NAME:III_scalefactors_lsf() | 595 | * NAME:III_scalefactors_lsf() |
588 | * DESCRIPTION:decode channel scalefactors for LSF from a bitstream | 596 | * DESCRIPTION:decode channel scalefactors for LSF from a bitstream |
589 | */ | 597 | */ |
590 | static | 598 | static |
591 | unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, | 599 | unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, |
592 | struct channel *channel, | 600 | struct channel *channel, |
593 | struct channel *gr1ch, int mode_extension) | 601 | struct channel *gr1ch, int mode_extension) |
594 | { | 602 | { |
595 | struct mad_bitptr start; | 603 | struct mad_bitptr start; |
596 | unsigned int scalefac_compress, index, slen[4], part, n, i; | 604 | unsigned int scalefac_compress, index, slen[4], part, n, i; |
597 | unsigned char const *nsfb; | 605 | unsigned char const *nsfb; |
598 | 606 | ||
599 | start = *ptr; | 607 | start = *ptr; |
600 | 608 | ||
601 | scalefac_compress = channel->scalefac_compress; | 609 | scalefac_compress = channel->scalefac_compress; |
602 | index = (channel->block_type == 2) ? | 610 | index = (channel->block_type == 2) ? |
603 | ((channel->flags & mixed_block_flag) ? 2 : 1) : 0; | 611 | ((channel->flags & mixed_block_flag) ? 2 : 1) : 0; |
604 | 612 | ||
605 | if (!((mode_extension & 0x1) && gr1ch)) { | 613 | if (!((mode_extension & I_STEREO) && gr1ch)) { |
606 | if (scalefac_compress < 400) { | 614 | if (scalefac_compress < 400) { |
607 | slen[0] = (scalefac_compress >> 4) / 5; | 615 | slen[0] = (scalefac_compress >> 4) / 5; |
608 | slen[1] = (scalefac_compress >> 4) % 5; | 616 | slen[1] = (scalefac_compress >> 4) % 5; |
609 | slen[2] = (scalefac_compress % 16) >> 2; | 617 | slen[2] = (scalefac_compress % 16) >> 2; |
610 | slen[3] = scalefac_compress % 4; | 618 | slen[3] = scalefac_compress % 4; |
611 | 619 | ||
612 | nsfb = nsfb_table[0][index]; | 620 | nsfb = nsfb_table[0][index]; |
613 | } | 621 | } |
614 | else if (scalefac_compress < 500) { | 622 | else if (scalefac_compress < 500) { |
615 | scalefac_compress -= 400; | 623 | scalefac_compress -= 400; |
616 | 624 | ||
617 | slen[0] = (scalefac_compress >> 2) / 5; | 625 | slen[0] = (scalefac_compress >> 2) / 5; |
618 | slen[1] = (scalefac_compress >> 2) % 5; | 626 | slen[1] = (scalefac_compress >> 2) % 5; |
619 | slen[2] = scalefac_compress % 4; | 627 | slen[2] = scalefac_compress % 4; |
620 | slen[3] = 0; | 628 | slen[3] = 0; |
621 | 629 | ||
622 | nsfb = nsfb_table[1][index]; | 630 | nsfb = nsfb_table[1][index]; |
623 | } | 631 | } |
624 | else { | 632 | else { |
625 | scalefac_compress -= 500; | 633 | scalefac_compress -= 500; |
626 | 634 | ||
627 | slen[0] = scalefac_compress / 3; | 635 | slen[0] = scalefac_compress / 3; |
628 | slen[1] = scalefac_compress % 3; | 636 | slen[1] = scalefac_compress % 3; |
629 | slen[2] = 0; | 637 | slen[2] = 0; |
630 | slen[3] = 0; | 638 | slen[3] = 0; |
631 | 639 | ||
632 | channel->flags |= preflag; | 640 | channel->flags |= preflag; |
633 | 641 | ||
634 | nsfb = nsfb_table[2][index]; | 642 | nsfb = nsfb_table[2][index]; |
635 | } | 643 | } |
636 | 644 | ||
637 | n = 0; | 645 | n = 0; |
638 | for (part = 0; part < 4; ++part) { | 646 | for (part = 0; part < 4; ++part) { |
639 | for (i = 0; i < nsfb[part]; ++i) | 647 | for (i = 0; i < nsfb[part]; ++i) |
640 | channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); | 648 | channel->scalefac[n++] = mad_bit_read(ptr, slen[part]); |
641 | } | 649 | } |
642 | 650 | ||
643 | while (n < 39) | 651 | while (n < 39) |
644 | channel->scalefac[n++] = 0; | 652 | channel->scalefac[n++] = 0; |
645 | } | 653 | } |
646 | else { /* (mode_extension & 0x1) && gr1ch (i.e. ch == 1) */ | 654 | else { /* (mode_extension & I_STEREO) && gr1ch (i.e. ch == 1) */ |
647 | scalefac_compress >>= 1; | 655 | scalefac_compress >>= 1; |
648 | 656 | ||
649 | if (scalefac_compress < 180) { | 657 | if (scalefac_compress < 180) { |
650 | slen[0] = scalefac_compress / 36; | 658 | slen[0] = scalefac_compress / 36; |
651 | slen[1] = (scalefac_compress % 36) / 6; | 659 | slen[1] = (scalefac_compress % 36) / 6; |
652 | slen[2] = (scalefac_compress % 36) % 6; | 660 | slen[2] = (scalefac_compress % 36) % 6; |
653 | slen[3] = 0; | 661 | slen[3] = 0; |
654 | 662 | ||
655 | nsfb = nsfb_table[3][index]; | 663 | nsfb = nsfb_table[3][index]; |
656 | } | 664 | } |
657 | else if (scalefac_compress < 244) { | 665 | else if (scalefac_compress < 244) { |
658 | scalefac_compress -= 180; | 666 | scalefac_compress -= 180; |
659 | 667 | ||
660 | slen[0] = (scalefac_compress % 64) >> 4; | 668 | slen[0] = (scalefac_compress % 64) >> 4; |
661 | slen[1] = (scalefac_compress % 16) >> 2; | 669 | slen[1] = (scalefac_compress % 16) >> 2; |
662 | slen[2] = scalefac_compress % 4; | 670 | slen[2] = scalefac_compress % 4; |
663 | slen[3] = 0; | 671 | slen[3] = 0; |
664 | 672 | ||
665 | nsfb = nsfb_table[4][index]; | 673 | nsfb = nsfb_table[4][index]; |
666 | } | 674 | } |
667 | else { | 675 | else { |
668 | scalefac_compress -= 244; | 676 | scalefac_compress -= 244; |
669 | 677 | ||
670 | slen[0] = scalefac_compress / 3; | 678 | slen[0] = scalefac_compress / 3; |
671 | slen[1] = scalefac_compress % 3; | 679 | slen[1] = scalefac_compress % 3; |
672 | slen[2] = 0; | 680 | slen[2] = 0; |
673 | slen[3] = 0; | 681 | slen[3] = 0; |
674 | 682 | ||
675 | nsfb = nsfb_table[5][index]; | 683 | nsfb = nsfb_table[5][index]; |
676 | } | 684 | } |
677 | 685 | ||
678 | n = 0; | 686 | n = 0; |
679 | for (part = 0; part < 4; ++part) { | 687 | for (part = 0; part < 4; ++part) { |
680 | unsigned int max, is_pos; | 688 | unsigned int max, is_pos; |
681 | 689 | ||
682 | max = (1 << slen[part]) - 1; | 690 | max = (1 << slen[part]) - 1; |
683 | 691 | ||
684 | for (i = 0; i < nsfb[part]; ++i) { | 692 | for (i = 0; i < nsfb[part]; ++i) { |
685 | is_pos = mad_bit_read(ptr, slen[part]); | 693 | is_pos = mad_bit_read(ptr, slen[part]); |
686 | 694 | ||
687 | channel->scalefac[n] = is_pos; | 695 | channel->scalefac[n] = is_pos; |
688 | gr1ch->scalefac[n++] = (is_pos == max); | 696 | gr1ch->scalefac[n++] = (is_pos == max); |
689 | } | 697 | } |
690 | } | 698 | } |
691 | 699 | ||
692 | while (n < 39) { | 700 | while (n < 39) { |
693 | channel->scalefac[n] = 0; | 701 | channel->scalefac[n] = 0; |
694 | gr1ch->scalefac[n++] = 0; /* apparently not illegal */ | 702 | gr1ch->scalefac[n++] = 0; /* apparently not illegal */ |
@@ -730,207 +738,215 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, | |||
730 | nsfb = 1 * 3; | 738 | nsfb = 1 * 3; |
731 | while (nsfb--) | 739 | while (nsfb--) |
732 | channel->scalefac[sfbi++] = 0; | 740 | channel->scalefac[sfbi++] = 0; |
733 | } | 741 | } |
734 | else { /* channel->block_type != 2 */ | 742 | else { /* channel->block_type != 2 */ |
735 | if (scfsi & 0x8) { | 743 | if (scfsi & 0x8) { |
736 | for (sfbi = 0; sfbi < 6; ++sfbi) | 744 | for (sfbi = 0; sfbi < 6; ++sfbi) |
737 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; | 745 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; |
738 | } | 746 | } |
739 | else { | 747 | else { |
740 | for (sfbi = 0; sfbi < 6; ++sfbi) | 748 | for (sfbi = 0; sfbi < 6; ++sfbi) |
741 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); | 749 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); |
742 | } | 750 | } |
743 | 751 | ||
744 | if (scfsi & 0x4) { | 752 | if (scfsi & 0x4) { |
745 | for (sfbi = 6; sfbi < 11; ++sfbi) | 753 | for (sfbi = 6; sfbi < 11; ++sfbi) |
746 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; | 754 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; |
747 | } | 755 | } |
748 | else { | 756 | else { |
749 | for (sfbi = 6; sfbi < 11; ++sfbi) | 757 | for (sfbi = 6; sfbi < 11; ++sfbi) |
750 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); | 758 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen1); |
751 | } | 759 | } |
752 | 760 | ||
753 | if (scfsi & 0x2) { | 761 | if (scfsi & 0x2) { |
754 | for (sfbi = 11; sfbi < 16; ++sfbi) | 762 | for (sfbi = 11; sfbi < 16; ++sfbi) |
755 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; | 763 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; |
756 | } | 764 | } |
757 | else { | 765 | else { |
758 | for (sfbi = 11; sfbi < 16; ++sfbi) | 766 | for (sfbi = 11; sfbi < 16; ++sfbi) |
759 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); | 767 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); |
760 | } | 768 | } |
761 | 769 | ||
762 | if (scfsi & 0x1) { | 770 | if (scfsi & 0x1) { |
763 | for (sfbi = 16; sfbi < 21; ++sfbi) | 771 | for (sfbi = 16; sfbi < 21; ++sfbi) |
764 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; | 772 | channel->scalefac[sfbi] = gr0ch->scalefac[sfbi]; |
765 | } | 773 | } |
766 | else { | 774 | else { |
767 | for (sfbi = 16; sfbi < 21; ++sfbi) | 775 | for (sfbi = 16; sfbi < 21; ++sfbi) |
768 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); | 776 | channel->scalefac[sfbi] = mad_bit_read(ptr, slen2); |
769 | } | 777 | } |
770 | 778 | ||
771 | channel->scalefac[21] = 0; | 779 | channel->scalefac[21] = 0; |
772 | } | 780 | } |
773 | 781 | ||
774 | return mad_bit_length(&start, ptr); | 782 | return mad_bit_length(&start, ptr); |
775 | } | 783 | } |
776 | 784 | ||
777 | /* | 785 | /* |
786 | * The Layer III formula for requantization and scaling is defined by | ||
787 | * section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows: | ||
788 | * | ||
789 | * long blocks: | ||
790 | * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * | ||
791 | * 2^((1/4) * (global_gain - 210)) * | ||
792 | * 2^-(scalefac_multiplier * | ||
793 | * (scalefac_l[sfb] + preflag * pretab[sfb])) | ||
794 | * | ||
795 | * short blocks: | ||
796 | * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * | ||
797 | * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) * | ||
798 | * 2^-(scalefac_multiplier * scalefac_s[sfb][w]) | ||
799 | * | ||
800 | * where: | ||
801 | * scalefac_multiplier = (scalefac_scale + 1) / 2 | ||
802 | * | ||
803 | * The routines III_exponents() and III_requantize() facilitate this | ||
804 | * calculation. | ||
805 | */ | ||
806 | |||
807 | /* | ||
778 | * NAME:III_exponents() | 808 | * NAME:III_exponents() |
779 | * DESCRIPTION:calculate scalefactor exponents | 809 | * DESCRIPTION:calculate scalefactor exponents |
780 | */ | 810 | */ |
781 | static | 811 | static |
782 | void III_exponents(struct channel const *channel, | 812 | void III_exponents(struct channel const *channel, |
783 | unsigned char const *sfbwidth, signed int exponents[39]) | 813 | unsigned char const *sfbwidth, signed int exponents[39]) |
784 | { | 814 | { |
785 | signed int gain; | 815 | signed int gain; |
786 | unsigned int scalefac_multiplier, sfbi; | 816 | unsigned int scalefac_multiplier, sfbi; |
787 | 817 | ||
788 | gain = (signed int) channel->global_gain - 210; | 818 | gain = (signed int) channel->global_gain - 210; |
789 | scalefac_multiplier = (channel->flags & scalefac_scale) ? 2 : 1; | 819 | scalefac_multiplier = (channel->flags & scalefac_scale) ? 2 : 1; |
790 | 820 | ||
791 | if (channel->block_type == 2) { | 821 | if (channel->block_type == 2) { |
792 | unsigned int l; | 822 | unsigned int l; |
793 | signed int gain0, gain1, gain2; | 823 | signed int gain0, gain1, gain2; |
794 | 824 | ||
795 | sfbi = l = 0; | 825 | sfbi = l = 0; |
796 | 826 | ||
797 | if (channel->flags & mixed_block_flag) { | 827 | if (channel->flags & mixed_block_flag) { |
798 | unsigned int premask; | 828 | unsigned int premask; |
799 | 829 | ||
800 | premask = (channel->flags & preflag) ? ~0 : 0; | 830 | premask = (channel->flags & preflag) ? ~0 : 0; |
801 | 831 | ||
802 | /* long block subbands 0-1 */ | 832 | /* long block subbands 0-1 */ |
803 | 833 | ||
804 | while (l < 36) { | 834 | while (l < 36) { |
805 | exponents[sfbi] = gain - | 835 | exponents[sfbi] = gain - |
806 | (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) << | 836 | (signed int) ((channel->scalefac[sfbi] + (pretab[sfbi] & premask)) << |
807 | scalefac_multiplier); | 837 | scalefac_multiplier); |
808 | 838 | ||
809 | l += sfbwidth[sfbi++]; | 839 | l += sfbwidth[sfbi++]; |
810 | } | 840 | } |
811 | } | 841 | } |
812 | 842 | ||
813 | /* this is probably wrong for 8000 Hz short/mixed blocks */ | 843 | /* this is probably wrong for 8000 Hz short/mixed blocks */ |
814 | 844 | ||
815 | gain0 = gain - 8 * (signed int) channel->subblock_gain[0]; | 845 | gain0 = gain - 8 * (signed int) channel->subblock_gain[0]; |
816 | gain1 = gain - 8 * (signed int) channel->subblock_gain[1]; | 846 | gain1 = gain - 8 * (signed int) channel->subblock_gain[1]; |
817 | gain2 = gain - 8 * (signed int) channel->subblock_gain[2]; | 847 | gain2 = gain - 8 * (signed int) channel->subblock_gain[2]; |
818 | 848 | ||
819 | while (l < 576) { | 849 | while (l < 576) { |
820 | exponents[sfbi + 0] = gain0 - | 850 | exponents[sfbi + 0] = gain0 - |
821 | (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier); | 851 | (signed int) (channel->scalefac[sfbi + 0] << scalefac_multiplier); |
822 | exponents[sfbi + 1] = gain1 - | 852 | exponents[sfbi + 1] = gain1 - |
823 | (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier); | 853 | (signed int) (channel->scalefac[sfbi + 1] << scalefac_multiplier); |
824 | exponents[sfbi + 2] = gain2 - | 854 | exponents[sfbi + 2] = gain2 - |
825 | (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier); | 855 | (signed int) (channel->scalefac[sfbi + 2] << scalefac_multiplier); |
826 | 856 | ||
827 | l += 3 * sfbwidth[sfbi]; | 857 | l += 3 * sfbwidth[sfbi]; |
828 | sfbi += 3; | 858 | sfbi += 3; |
829 | } | 859 | } |
830 | } | 860 | } |
831 | else { /* channel->block_type != 2 */ | 861 | else { /* channel->block_type != 2 */ |
832 | if (channel->flags & preflag) { | 862 | if (channel->flags & preflag) { |
833 | for (sfbi = 0; sfbi < 22; ++sfbi) { | 863 | for (sfbi = 0; sfbi < 22; ++sfbi) { |
834 | exponents[sfbi] = gain - | 864 | exponents[sfbi] = gain - |
835 | (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) << | 865 | (signed int) ((channel->scalefac[sfbi] + pretab[sfbi]) << |
836 | scalefac_multiplier); | 866 | scalefac_multiplier); |
837 | } | 867 | } |
838 | } | 868 | } |
839 | else { | 869 | else { |
840 | for (sfbi = 0; sfbi < 22; ++sfbi) { | 870 | for (sfbi = 0; sfbi < 22; ++sfbi) { |
841 | exponents[sfbi] = gain - | 871 | exponents[sfbi] = gain - |
842 | (signed int) (channel->scalefac[sfbi] << scalefac_multiplier); | 872 | (signed int) (channel->scalefac[sfbi] << scalefac_multiplier); |
843 | } | 873 | } |
844 | } | 874 | } |
845 | } | 875 | } |
846 | } | 876 | } |
847 | 877 | ||
848 | /* | 878 | /* |
849 | * NAME:III_requantize() | 879 | * NAME:III_requantize() |
850 | * DESCRIPTION:requantize one (positive) value | 880 | * DESCRIPTION:requantize one (positive) value |
851 | */ | 881 | */ |
852 | static | 882 | static |
853 | mad_fixed_t III_requantize(unsigned int value, signed int exp) | 883 | mad_fixed_t III_requantize(unsigned int value, signed int exp) |
854 | { | 884 | { |
855 | mad_fixed_t requantized; | 885 | mad_fixed_t requantized; |
856 | signed int frac; | 886 | signed int frac; |
857 | struct fixedfloat const *power; | 887 | struct fixedfloat const *power; |
858 | 888 | ||
859 | /* | 889 | frac = exp % 4; /* assumes sign(frac) == sign(exp) */ |
860 | * long blocks: | ||
861 | * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * | ||
862 | * 2^((1/4) * (global_gain - 210)) * | ||
863 | * 2^-(scalefac_multiplier * | ||
864 | * (scalefac_l[sfb] + preflag * pretab[sfb])) | ||
865 | * | ||
866 | * short blocks: | ||
867 | * xr[i] = sign(is[i]) * abs(is[i])^(4/3) * | ||
868 | * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) * | ||
869 | * 2^-(scalefac_multiplier * scalefac_s[sfb][w]) | ||
870 | * | ||
871 | * where: | ||
872 | * scalefac_multiplier = (scalefac_scale + 1) / 2 | ||
873 | */ | ||
874 | |||
875 | frac = exp % 4; | ||
876 | exp /= 4; | 890 | exp /= 4; |
877 | 891 | ||
878 | power = &rq_table[value]; | 892 | power = &rq_table[value]; |
879 | requantized = power->mantissa; | 893 | requantized = power->mantissa; |
880 | exp += power->exponent; | 894 | exp += power->exponent; |
881 | 895 | ||
882 | if (exp < 0) { | 896 | if (exp < 0) { |
883 | if (-exp >= sizeof(mad_fixed_t) * CHAR_BIT) { | 897 | if (-exp >= sizeof(mad_fixed_t) * CHAR_BIT) { |
884 | /* underflow */ | 898 | /* underflow */ |
885 | requantized = 0; | 899 | requantized = 0; |
886 | } | 900 | } |
887 | else | 901 | else { |
902 | requantized += 1L << (-exp - 1); | ||
888 | requantized >>= -exp; | 903 | requantized >>= -exp; |
904 | } | ||
889 | } | 905 | } |
890 | else { | 906 | else { |
891 | if (exp >= 5) { | 907 | if (exp >= 5) { |
892 | /* overflow */ | 908 | /* overflow */ |
893 | # if defined(DEBUG) | 909 | # if defined(DEBUG) |
894 | fprintf(stderr, "requantize overflow (%f * 2^%d)\n", | 910 | fprintf(stderr, "requantize overflow (%f * 2^%d)\n", |
895 | mad_f_todouble(requantized), exp); | 911 | mad_f_todouble(requantized), exp); |
896 | # endif | 912 | # endif |
897 | requantized = MAD_F_MAX; | 913 | requantized = MAD_F_MAX; |
898 | } | 914 | } |
899 | else | 915 | else |
900 | requantized <<= exp; | 916 | requantized <<= exp; |
901 | } | 917 | } |
902 | 918 | ||
903 | return frac ? mad_f_mul(requantized, root_table[3 + frac]) : requantized; | 919 | return frac ? mad_f_mul(requantized, root_table[3 + frac]) : requantized; |
904 | } | 920 | } |
905 | 921 | ||
906 | /* we must take care that sz >= bits and sz < sizeof(long) lest bits == 0 */ | 922 | /* we must take care that sz >= bits and sz < sizeof(long) lest bits == 0 */ |
907 | # define MASK(cache, sz, bits)\ | 923 | # define MASK(cache, sz, bits)\ |
908 | (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) | 924 | (((cache) >> ((sz) - (bits))) & ((1 << (bits)) - 1)) |
909 | # define MASK1BIT(cache, sz) \ | 925 | # define MASK1BIT(cache, sz) \ |
910 | ((cache) & (1 << ((sz) - 1))) | 926 | ((cache) & (1 << ((sz) - 1))) |
911 | 927 | ||
912 | /* | 928 | /* |
913 | * NAME:III_huffdecode() | 929 | * NAME:III_huffdecode() |
914 | * DESCRIPTION:decode Huffman code words of one channel of one granule | 930 | * DESCRIPTION:decode Huffman code words of one channel of one granule |
915 | */ | 931 | */ |
916 | static | 932 | static |
917 | enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], | 933 | enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], |
918 | struct channel *channel, | 934 | struct channel *channel, |
919 | unsigned char const *sfbwidth, | 935 | unsigned char const *sfbwidth, |
920 | unsigned int part2_length) | 936 | unsigned int part2_length) |
921 | { | 937 | { |
922 | signed int exponents[39], exp; | 938 | signed int exponents[39], exp; |
923 | signed int const *expptr; | 939 | signed int const *expptr; |
924 | struct mad_bitptr peek; | 940 | struct mad_bitptr peek; |
925 | signed int bits_left, cachesz; | 941 | signed int bits_left, cachesz; |
926 | register mad_fixed_t *xrptr; | 942 | register mad_fixed_t *xrptr; |
927 | mad_fixed_t const *sfbound; | 943 | mad_fixed_t const *sfbound; |
928 | register unsigned long bitcache; | 944 | register unsigned long bitcache; |
929 | 945 | ||
930 | bits_left = (signed) channel->part2_3_length - (signed) part2_length; | 946 | bits_left = (signed) channel->part2_3_length - (signed) part2_length; |
931 | if (bits_left < 0) | 947 | if (bits_left < 0) |
932 | return MAD_ERROR_BADPART3LEN; | 948 | return MAD_ERROR_BADPART3LEN; |
933 | 949 | ||
934 | III_exponents(channel, sfbwidth, exponents); | 950 | III_exponents(channel, sfbwidth, exponents); |
935 | 951 | ||
936 | peek = *ptr; | 952 | peek = *ptr; |
@@ -1206,400 +1222,394 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], | |||
1206 | } | 1222 | } |
1207 | 1223 | ||
1208 | ++expptr; | 1224 | ++expptr; |
1209 | } | 1225 | } |
1210 | 1226 | ||
1211 | /* x (0..1) */ | 1227 | /* x (0..1) */ |
1212 | 1228 | ||
1213 | xrptr[0] = quad->value.x ? | 1229 | xrptr[0] = quad->value.x ? |
1214 | (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; | 1230 | (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; |
1215 | 1231 | ||
1216 | /* y (0..1) */ | 1232 | /* y (0..1) */ |
1217 | 1233 | ||
1218 | xrptr[1] = quad->value.y ? | 1234 | xrptr[1] = quad->value.y ? |
1219 | (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; | 1235 | (MASK1BIT(bitcache, cachesz--) ? -requantized : requantized) : 0; |
1220 | 1236 | ||
1221 | xrptr += 2; | 1237 | xrptr += 2; |
1222 | } | 1238 | } |
1223 | 1239 | ||
1224 | if (cachesz + bits_left < 0) { | 1240 | if (cachesz + bits_left < 0) { |
1225 | # if 0 && defined(DEBUG) | 1241 | # if 0 && defined(DEBUG) |
1226 | fprintf(stderr, "huffman count1 overrun (%d bits)\n", | 1242 | fprintf(stderr, "huffman count1 overrun (%d bits)\n", |
1227 | -(cachesz + bits_left)); | 1243 | -(cachesz + bits_left)); |
1228 | # endif | 1244 | # endif |
1229 | 1245 | ||
1230 | /* technically the bitstream is misformatted, but apparently | 1246 | /* technically the bitstream is misformatted, but apparently |
1231 | some encoders are just a bit sloppy with stuffing bits */ | 1247 | some encoders are just a bit sloppy with stuffing bits */ |
1232 | 1248 | ||
1233 | xrptr -= 4; | 1249 | xrptr -= 4; |
1234 | } | 1250 | } |
1235 | } | 1251 | } |
1236 | 1252 | ||
1237 | assert(-bits_left <= MAD_BUFFER_GUARD * CHAR_BIT); | 1253 | assert(-bits_left <= MAD_BUFFER_GUARD * CHAR_BIT); |
1238 | 1254 | ||
1239 | # if 0 && defined(DEBUG) | 1255 | # if 0 && defined(DEBUG) |
1240 | if (bits_left < 0) | 1256 | if (bits_left < 0) |
1241 | fprintf(stderr, "read %d bits too many\n", -bits_left); | 1257 | fprintf(stderr, "read %d bits too many\n", -bits_left); |
1242 | else if (cachesz + bits_left > 0) | 1258 | else if (cachesz + bits_left > 0) |
1243 | fprintf(stderr, "%d stuffing bits\n", cachesz + bits_left); | 1259 | fprintf(stderr, "%d stuffing bits\n", cachesz + bits_left); |
1244 | # endif | 1260 | # endif |
1245 | 1261 | ||
1246 | /* rzero */ | 1262 | /* rzero */ |
1247 | while (xrptr < &xr[576]) { | 1263 | while (xrptr < &xr[576]) { |
1248 | xrptr[0] = 0; | 1264 | xrptr[0] = 0; |
1249 | xrptr[1] = 0; | 1265 | xrptr[1] = 0; |
1250 | 1266 | ||
1251 | xrptr += 2; | 1267 | xrptr += 2; |
1252 | } | 1268 | } |
1253 | 1269 | ||
1254 | return 0; | 1270 | return MAD_ERROR_NONE; |
1255 | } | 1271 | } |
1256 | 1272 | ||
1257 | # undef MASK | 1273 | # undef MASK |
1258 | # undef MASK1BIT | 1274 | # undef MASK1BIT |
1259 | 1275 | ||
1260 | /* | 1276 | /* |
1261 | * NAME:III_reorder() | 1277 | * NAME:III_reorder() |
1262 | * DESCRIPTION:reorder frequency lines of a short block into subband order | 1278 | * DESCRIPTION:reorder frequency lines of a short block into subband order |
1263 | */ | 1279 | */ |
1264 | static | 1280 | static |
1265 | void III_reorder(mad_fixed_t xr[576], struct channel const *channel, | 1281 | void III_reorder(mad_fixed_t xr[576], struct channel const *channel, |
1266 | unsigned char const sfbwidth[39]) | 1282 | unsigned char const sfbwidth[39]) |
1267 | { | 1283 | { |
1268 | mad_fixed_t tmp[32][3][6]; | 1284 | mad_fixed_t tmp[32][3][6]; |
1269 | unsigned int sb, l, sfbi, f, w, sbw[3], sw[3]; | 1285 | unsigned int sb, l, f, w, sbw[3], sw[3]; |
1270 | 1286 | ||
1271 | /* this is probably wrong for 8000 Hz mixed blocks */ | 1287 | /* this is probably wrong for 8000 Hz mixed blocks */ |
1272 | 1288 | ||
1273 | if (channel->flags & mixed_block_flag) | 1289 | sb = 0; |
1274 | sb = 2, sfbi = 3 * 3; | 1290 | if (channel->flags & mixed_block_flag) { |
1275 | else | 1291 | sb = 2; |
1276 | sb = 0, sfbi = 0; | 1292 | |
1293 | l = 0; | ||
1294 | while (l < 36) | ||
1295 | l += *sfbwidth++; | ||
1296 | } | ||
1277 | 1297 | ||
1278 | for (w = 0; w < 3; ++w) { | 1298 | for (w = 0; w < 3; ++w) { |
1279 | sbw[w] = sb; | 1299 | sbw[w] = sb; |
1280 | sw[w] = 0; | 1300 | sw[w] = 0; |
1281 | } | 1301 | } |
1282 | 1302 | ||
1283 | f = sfbwidth[sfbi]; | 1303 | f = *sfbwidth++; |
1284 | w = 0; | 1304 | w = 0; |
1285 | 1305 | ||
1286 | for (l = 18 * sb; l < 576; ++l) { | 1306 | for (l = 18 * sb; l < 576; ++l) { |
1307 | if (f-- == 0) { | ||
1308 | f = *sfbwidth++ - 1; | ||
1309 | w = (w + 1) % 3; | ||
1310 | } | ||
1311 | |||
1287 | tmp[sbw[w]][w][sw[w]++] = xr[l]; | 1312 | tmp[sbw[w]][w][sw[w]++] = xr[l]; |
1288 | 1313 | ||
1289 | if (sw[w] == 6) { | 1314 | if (sw[w] == 6) { |
1290 | sw[w] = 0; | 1315 | sw[w] = 0; |
1291 | ++sbw[w]; | 1316 | ++sbw[w]; |
1292 | } | 1317 | } |
1293 | |||
1294 | if (--f == 0) { | ||
1295 | if (++w == 3) | ||
1296 | w = 0; | ||
1297 | |||
1298 | f = sfbwidth[++sfbi]; | ||
1299 | } | ||
1300 | } | 1318 | } |
1301 | 1319 | ||
1302 | memcpy(&xr[18 * sb], &tmp[sb], (576 - 18 * sb) * sizeof(mad_fixed_t)); | 1320 | memcpy(&xr[18 * sb], &tmp[sb], (576 - 18 * sb) * sizeof(mad_fixed_t)); |
1303 | } | 1321 | } |
1304 | 1322 | ||
1305 | /* | 1323 | /* |
1306 | * NAME:III_stereo() | 1324 | * NAME:III_stereo() |
1307 | * DESCRIPTION:perform joint stereo processing on a granule | 1325 | * DESCRIPTION:perform joint stereo processing on a granule |
1308 | */ | 1326 | */ |
1309 | static | 1327 | static |
1310 | enum mad_error III_stereo(mad_fixed_t xr[2][576], | 1328 | enum mad_error III_stereo(mad_fixed_t xr[2][576], |
1311 | struct granule const *granule, | 1329 | struct granule const *granule, |
1312 | struct mad_header *header, | 1330 | struct mad_header *header, |
1313 | unsigned char const *sfbwidth) | 1331 | unsigned char const *sfbwidth) |
1314 | { | 1332 | { |
1315 | short modes[39]; | 1333 | short modes[39]; |
1316 | unsigned int sfbi, l, n, i; | 1334 | unsigned int sfbi, l, n, i; |
1317 | 1335 | ||
1318 | enum { | ||
1319 | i_stereo = 0x1, | ||
1320 | ms_stereo = 0x2 | ||
1321 | }; | ||
1322 | |||
1323 | if (granule->ch[0].block_type != | 1336 | if (granule->ch[0].block_type != |
1324 | granule->ch[1].block_type || | 1337 | granule->ch[1].block_type || |
1325 | (granule->ch[0].flags & mixed_block_flag) != | 1338 | (granule->ch[0].flags & mixed_block_flag) != |
1326 | (granule->ch[1].flags & mixed_block_flag)) | 1339 | (granule->ch[1].flags & mixed_block_flag)) |
1327 | return MAD_ERROR_BADSTEREO; | 1340 | return MAD_ERROR_BADSTEREO; |
1328 | 1341 | ||
1329 | for (i = 0; i < 39; ++i) | 1342 | for (i = 0; i < 39; ++i) |
1330 | modes[i] = header->mode_extension; | 1343 | modes[i] = header->mode_extension; |
1331 | 1344 | ||
1332 | /* intensity stereo */ | 1345 | /* intensity stereo */ |
1333 | 1346 | ||
1334 | if (header->mode_extension & i_stereo) { | 1347 | if (header->mode_extension & I_STEREO) { |
1335 | struct channel const *right_ch = &granule->ch[1]; | 1348 | struct channel const *right_ch = &granule->ch[1]; |
1336 | mad_fixed_t const *right_xr = xr[1]; | 1349 | mad_fixed_t const *right_xr = xr[1]; |
1337 | unsigned int is_pos; | 1350 | unsigned int is_pos; |
1338 | 1351 | ||
1339 | header->flags |= MAD_FLAG_I_STEREO; | 1352 | header->flags |= MAD_FLAG_I_STEREO; |
1340 | 1353 | ||
1341 | /* first determine which scalefactor bands are to be processed */ | 1354 | /* first determine which scalefactor bands are to be processed */ |
1342 | 1355 | ||
1343 | if (right_ch->block_type == 2) { | 1356 | if (right_ch->block_type == 2) { |
1344 | unsigned int lower, start, max, bound[3], w; | 1357 | unsigned int lower, start, max, bound[3], w; |
1345 | 1358 | ||
1346 | lower = start = max = bound[0] = bound[1] = bound[2] = 0; | 1359 | lower = start = max = bound[0] = bound[1] = bound[2] = 0; |
1347 | 1360 | ||
1348 | sfbi = l = 0; | 1361 | sfbi = l = 0; |
1349 | 1362 | ||
1350 | if (right_ch->flags & mixed_block_flag) { | 1363 | if (right_ch->flags & mixed_block_flag) { |
1351 | while (l < 36) { | 1364 | while (l < 36) { |
1352 | n = sfbwidth[sfbi++]; | 1365 | n = sfbwidth[sfbi++]; |
1353 | 1366 | ||
1354 | for (i = 0; i < n; ++i) { | 1367 | for (i = 0; i < n; ++i) { |
1355 | if (right_xr[i]) { | 1368 | if (right_xr[i]) { |
1356 | lower = sfbi; | 1369 | lower = sfbi; |
1357 | break; | 1370 | break; |
1358 | } | 1371 | } |
1359 | } | 1372 | } |
1360 | 1373 | ||
1361 | right_xr += n; | 1374 | right_xr += n; |
1362 | l += n; | 1375 | l += n; |
1363 | } | 1376 | } |
1364 | 1377 | ||
1365 | start = sfbi; | 1378 | start = sfbi; |
1366 | } | 1379 | } |
1367 | 1380 | ||
1368 | w = 0; | 1381 | w = 0; |
1369 | while (l < 576) { | 1382 | while (l < 576) { |
1370 | n = sfbwidth[sfbi++]; | 1383 | n = sfbwidth[sfbi++]; |
1371 | 1384 | ||
1372 | for (i = 0; i < n; ++i) { | 1385 | for (i = 0; i < n; ++i) { |
1373 | if (right_xr[i]) { | 1386 | if (right_xr[i]) { |
1374 | max = bound[w] = sfbi; | 1387 | max = bound[w] = sfbi; |
1375 | break; | 1388 | break; |
1376 | } | 1389 | } |
1377 | } | 1390 | } |
1378 | 1391 | ||
1379 | right_xr += n; | 1392 | right_xr += n; |
1380 | l += n; | 1393 | l += n; |
1381 | w = (w + 1) % 3; | 1394 | w = (w + 1) % 3; |
1382 | } | 1395 | } |
1383 | 1396 | ||
1384 | if (max) | 1397 | if (max) |
1385 | lower = start; | 1398 | lower = start; |
1386 | 1399 | ||
1387 | /* long blocks */ | 1400 | /* long blocks */ |
1388 | 1401 | ||
1389 | for (i = 0; i < lower; ++i) | 1402 | for (i = 0; i < lower; ++i) |
1390 | modes[i] = header->mode_extension & ~i_stereo; | 1403 | modes[i] = header->mode_extension & ~I_STEREO; |
1391 | 1404 | ||
1392 | /* short blocks */ | 1405 | /* short blocks */ |
1393 | 1406 | ||
1394 | w = 0; | 1407 | w = 0; |
1395 | for (i = start; i < max; ++i) { | 1408 | for (i = start; i < max; ++i) { |
1396 | if (i < bound[w]) | 1409 | if (i < bound[w]) |
1397 | modes[i] = header->mode_extension & ~i_stereo; | 1410 | modes[i] = header->mode_extension & ~I_STEREO; |
1398 | 1411 | ||
1399 | w = (w + 1) % 3; | 1412 | w = (w + 1) % 3; |
1400 | } | 1413 | } |
1401 | } | 1414 | } |
1402 | else { /* right_ch->block_type != 2 */ | 1415 | else { /* right_ch->block_type != 2 */ |
1403 | unsigned int bound; | 1416 | unsigned int bound; |
1404 | 1417 | ||
1405 | bound = 0; | 1418 | bound = 0; |
1406 | for (sfbi = l = 0; l < 576; l += n) { | 1419 | for (sfbi = l = 0; l < 576; l += n) { |
1407 | n = sfbwidth[sfbi++]; | 1420 | n = sfbwidth[sfbi++]; |
1408 | 1421 | ||
1409 | for (i = 0; i < n; ++i) { | 1422 | for (i = 0; i < n; ++i) { |
1410 | if (right_xr[i]) { | 1423 | if (right_xr[i]) { |
1411 | bound = sfbi; | 1424 | bound = sfbi; |
1412 | break; | 1425 | break; |
1413 | } | 1426 | } |
1414 | } | 1427 | } |
1415 | 1428 | ||
1416 | right_xr += n; | 1429 | right_xr += n; |
1417 | } | 1430 | } |
1418 | 1431 | ||
1419 | for (i = 0; i < bound; ++i) | 1432 | for (i = 0; i < bound; ++i) |
1420 | modes[i] = header->mode_extension & ~i_stereo; | 1433 | modes[i] = header->mode_extension & ~I_STEREO; |
1421 | } | 1434 | } |
1422 | 1435 | ||
1423 | /* now do the actual processing */ | 1436 | /* now do the actual processing */ |
1424 | 1437 | ||
1425 | if (header->flags & MAD_FLAG_LSF_EXT) { | 1438 | if (header->flags & MAD_FLAG_LSF_EXT) { |
1426 | unsigned char const *illegal_pos = granule[1].ch[1].scalefac; | 1439 | unsigned char const *illegal_pos = granule[1].ch[1].scalefac; |
1427 | mad_fixed_t const *lsf_scale; | 1440 | mad_fixed_t const *lsf_scale; |
1428 | 1441 | ||
1429 | /* intensity_scale */ | 1442 | /* intensity_scale */ |
1430 | lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1]; | 1443 | lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1]; |
1431 | 1444 | ||
1432 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { | 1445 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { |
1433 | n = sfbwidth[sfbi]; | 1446 | n = sfbwidth[sfbi]; |
1434 | 1447 | ||
1435 | if (!(modes[sfbi] & i_stereo)) | 1448 | if (!(modes[sfbi] & I_STEREO)) |
1436 | continue; | 1449 | continue; |
1437 | 1450 | ||
1438 | if (illegal_pos[sfbi]) { | 1451 | if (illegal_pos[sfbi]) { |
1439 | modes[sfbi] &= ~i_stereo; | 1452 | modes[sfbi] &= ~I_STEREO; |
1440 | continue; | 1453 | continue; |
1441 | } | 1454 | } |
1442 | 1455 | ||
1443 | is_pos = right_ch->scalefac[sfbi]; | 1456 | is_pos = right_ch->scalefac[sfbi]; |
1444 | 1457 | ||
1445 | for (i = 0; i < n; ++i) { | 1458 | for (i = 0; i < n; ++i) { |
1446 | register mad_fixed_t left; | 1459 | register mad_fixed_t left; |
1447 | 1460 | ||
1448 | left = xr[0][l + i]; | 1461 | left = xr[0][l + i]; |
1449 | 1462 | ||
1450 | if (is_pos == 0) | 1463 | if (is_pos == 0) |
1451 | xr[1][l + i] = left; | 1464 | xr[1][l + i] = left; |
1452 | else { | 1465 | else { |
1453 | register mad_fixed_t opposite; | 1466 | register mad_fixed_t opposite; |
1454 | 1467 | ||
1455 | opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]); | 1468 | opposite = mad_f_mul(left, lsf_scale[(is_pos - 1) / 2]); |
1456 | 1469 | ||
1457 | if (is_pos & 1) { | 1470 | if (is_pos & 1) { |
1458 | xr[0][l + i] = opposite; | 1471 | xr[0][l + i] = opposite; |
1459 | xr[1][l + i] = left; | 1472 | xr[1][l + i] = left; |
1460 | } | 1473 | } |
1461 | else | 1474 | else |
1462 | xr[1][l + i] = opposite; | 1475 | xr[1][l + i] = opposite; |
1463 | } | 1476 | } |
1464 | } | 1477 | } |
1465 | } | 1478 | } |
1466 | } | 1479 | } |
1467 | else { /* !(header->flags & MAD_FLAG_LSF_EXT) */ | 1480 | else { /* !(header->flags & MAD_FLAG_LSF_EXT) */ |
1468 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { | 1481 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { |
1469 | n = sfbwidth[sfbi]; | 1482 | n = sfbwidth[sfbi]; |
1470 | 1483 | ||
1471 | if (!(modes[sfbi] & i_stereo)) | 1484 | if (!(modes[sfbi] & I_STEREO)) |
1472 | continue; | 1485 | continue; |
1473 | 1486 | ||
1474 | is_pos = right_ch->scalefac[sfbi]; | 1487 | is_pos = right_ch->scalefac[sfbi]; |
1475 | 1488 | ||
1476 | if (is_pos >= 7) { /* illegal intensity position */ | 1489 | if (is_pos >= 7) { /* illegal intensity position */ |
1477 | modes[sfbi] &= ~i_stereo; | 1490 | modes[sfbi] &= ~I_STEREO; |
1478 | continue; | 1491 | continue; |
1479 | } | 1492 | } |
1480 | 1493 | ||
1481 | for (i = 0; i < n; ++i) { | 1494 | for (i = 0; i < n; ++i) { |
1482 | register mad_fixed_t left; | 1495 | register mad_fixed_t left; |
1483 | 1496 | ||
1484 | left = xr[0][l + i]; | 1497 | left = xr[0][l + i]; |
1485 | 1498 | ||
1486 | xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]); | 1499 | xr[0][l + i] = mad_f_mul(left, is_table[ is_pos]); |
1487 | xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]); | 1500 | xr[1][l + i] = mad_f_mul(left, is_table[6 - is_pos]); |
1488 | } | 1501 | } |
1489 | } | 1502 | } |
1490 | } | 1503 | } |
1491 | } | 1504 | } |
1492 | 1505 | ||
1493 | /* middle/side stereo */ | 1506 | /* middle/side stereo */ |
1494 | 1507 | ||
1495 | if (header->mode_extension & ms_stereo) { | 1508 | if (header->mode_extension & MS_STEREO) { |
1496 | register mad_fixed_t invsqrt2; | 1509 | register mad_fixed_t invsqrt2; |
1497 | 1510 | ||
1498 | header->flags |= MAD_FLAG_MS_STEREO; | 1511 | header->flags |= MAD_FLAG_MS_STEREO; |
1499 | 1512 | ||
1500 | invsqrt2 = root_table[3 + -2]; | 1513 | invsqrt2 = root_table[3 + -2]; |
1501 | 1514 | ||
1502 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { | 1515 | for (sfbi = l = 0; l < 576; ++sfbi, l += n) { |
1503 | n = sfbwidth[sfbi]; | 1516 | n = sfbwidth[sfbi]; |
1504 | 1517 | ||
1505 | if (modes[sfbi] != ms_stereo) | 1518 | if (modes[sfbi] != MS_STEREO) |
1506 | continue; | 1519 | continue; |
1507 | 1520 | ||
1508 | for (i = 0; i < n; ++i) { | 1521 | for (i = 0; i < n; ++i) { |
1509 | register mad_fixed_t m, s; | 1522 | register mad_fixed_t m, s; |
1510 | 1523 | ||
1511 | m = xr[0][l + i]; | 1524 | m = xr[0][l + i]; |
1512 | s = xr[1][l + i]; | 1525 | s = xr[1][l + i]; |
1513 | 1526 | ||
1514 | xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */ | 1527 | xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */ |
1515 | xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */ | 1528 | xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */ |
1516 | } | 1529 | } |
1517 | } | 1530 | } |
1518 | } | 1531 | } |
1519 | 1532 | ||
1520 | return 0; | 1533 | return MAD_ERROR_NONE; |
1521 | } | 1534 | } |
1522 | 1535 | ||
1523 | /* | 1536 | /* |
1524 | * NAME:III_aliasreduce() | 1537 | * NAME:III_aliasreduce() |
1525 | * DESCRIPTION:perform frequency line alias reduction | 1538 | * DESCRIPTION:perform frequency line alias reduction |
1526 | */ | 1539 | */ |
1527 | static | 1540 | static |
1528 | void III_aliasreduce(mad_fixed_t xr[576], int lines) | 1541 | void III_aliasreduce(mad_fixed_t xr[576], int lines) |
1529 | { | 1542 | { |
1530 | mad_fixed_t const *bound; | 1543 | mad_fixed_t const *bound; |
1531 | int i; | 1544 | int i; |
1532 | 1545 | ||
1533 | bound = &xr[lines]; | 1546 | bound = &xr[lines]; |
1534 | for (xr += 18; xr < bound; xr += 18) { | 1547 | for (xr += 18; xr < bound; xr += 18) { |
1535 | for (i = 0; i < 8; ++i) { | 1548 | for (i = 0; i < 8; ++i) { |
1536 | register mad_fixed_t *aptr, *bptr, a, b; | 1549 | register mad_fixed_t a, b; |
1537 | register mad_fixed64hi_t hi; | 1550 | register mad_fixed64hi_t hi; |
1538 | register mad_fixed64lo_t lo; | 1551 | register mad_fixed64lo_t lo; |
1539 | 1552 | ||
1540 | aptr = &xr[-1 - i]; | 1553 | a = xr[-1 - i]; |
1541 | bptr = &xr[ i]; | 1554 | b = xr[ i]; |
1542 | |||
1543 | a = *aptr; | ||
1544 | b = *bptr; | ||
1545 | 1555 | ||
1546 | # if defined(ASO_ZEROCHECK) | 1556 | # if defined(ASO_ZEROCHECK) |
1547 | if (a | b) { | 1557 | if (a | b) { |
1548 | # endif | 1558 | # endif |
1549 | MAD_F_ML0(hi, lo, a, cs[i]); | 1559 | MAD_F_ML0(hi, lo, a, cs[i]); |
1550 | MAD_F_MLA(hi, lo, -b, ca[i]); | 1560 | MAD_F_MLA(hi, lo, -b, ca[i]); |
1551 | 1561 | ||
1552 | *aptr = MAD_F_MLZ(hi, lo); | 1562 | xr[-1 - i] = MAD_F_MLZ(hi, lo); |
1553 | 1563 | ||
1554 | MAD_F_ML0(hi, lo, b, cs[i]); | 1564 | MAD_F_ML0(hi, lo, b, cs[i]); |
1555 | MAD_F_MLA(hi, lo, a, ca[i]); | 1565 | MAD_F_MLA(hi, lo, a, ca[i]); |
1556 | 1566 | ||
1557 | *bptr = MAD_F_MLZ(hi, lo); | 1567 | xr[ i] = MAD_F_MLZ(hi, lo); |
1558 | # if defined(ASO_ZEROCHECK) | 1568 | # if defined(ASO_ZEROCHECK) |
1559 | } | 1569 | } |
1560 | # endif | 1570 | # endif |
1561 | } | 1571 | } |
1562 | } | 1572 | } |
1563 | } | 1573 | } |
1564 | 1574 | ||
1565 | # if defined(ASO_IMDCT) | 1575 | # if defined(ASO_IMDCT) |
1566 | void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int); | 1576 | void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int); |
1567 | # else | 1577 | # else |
1568 | /* | 1578 | /* |
1569 | * NAME:imdct36 | 1579 | * NAME:imdct36 |
1570 | * DESCRIPTION:perform X[18]->x[36] IMDCT | 1580 | * DESCRIPTION:perform X[18]->x[36] IMDCT |
1571 | */ | 1581 | */ |
1572 | static inline | 1582 | static inline |
1573 | void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) | 1583 | void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36]) |
1574 | { | 1584 | { |
1575 | mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; | 1585 | mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; |
1576 | mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; | 1586 | mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; |
1577 | register mad_fixed64hi_t hi; | 1587 | register mad_fixed64hi_t hi; |
1578 | register mad_fixed64lo_t lo; | 1588 | register mad_fixed64lo_t lo; |
1579 | 1589 | ||
1580 | MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); | 1590 | MAD_F_ML0(hi, lo, X[4], MAD_F(0x0ec835e8)); |
1581 | MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); | 1591 | MAD_F_MLA(hi, lo, X[13], MAD_F(0x061f78aa)); |
1582 | 1592 | ||
1583 | t6 = MAD_F_MLZ(hi, lo); | 1593 | t6 = MAD_F_MLZ(hi, lo); |
1584 | 1594 | ||
1585 | MAD_F_MLA(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x061f78aa)); | 1595 | MAD_F_MLA(hi, lo, (t14 = X[1] - X[10]), -MAD_F(0x061f78aa)); |
1586 | MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), -MAD_F(0x0ec835e8)); | 1596 | MAD_F_MLA(hi, lo, (t15 = X[7] + X[16]), -MAD_F(0x0ec835e8)); |
1587 | 1597 | ||
1588 | t0 = MAD_F_MLZ(hi, lo); | 1598 | t0 = MAD_F_MLZ(hi, lo); |
1589 | 1599 | ||
1590 | MAD_F_MLA(hi, lo, (t8 = X[0] - X[11] - X[12]), MAD_F(0x0216a2a2)); | 1600 | MAD_F_MLA(hi, lo, (t8 = X[0] - X[11] - X[12]), MAD_F(0x0216a2a2)); |
1591 | MAD_F_MLA(hi, lo, (t9 = X[2] - X[9] - X[14]), MAD_F(0x09bd7ca0)); | 1601 | MAD_F_MLA(hi, lo, (t9 = X[2] - X[9] - X[14]), MAD_F(0x09bd7ca0)); |
1592 | MAD_F_MLA(hi, lo, (t10 = X[3] - X[8] - X[15]), -MAD_F(0x0cb19346)); | 1602 | MAD_F_MLA(hi, lo, (t10 = X[3] - X[8] - X[15]), -MAD_F(0x0cb19346)); |
1593 | MAD_F_MLA(hi, lo, (t11 = X[5] - X[6] - X[17]), -MAD_F(0x0fdcf549)); | 1603 | MAD_F_MLA(hi, lo, (t11 = X[5] - X[6] - X[17]), -MAD_F(0x0fdcf549)); |
1594 | 1604 | ||
1595 | x[7] = MAD_F_MLZ(hi, lo); | 1605 | x[7] = MAD_F_MLZ(hi, lo); |
1596 | x[10] = -x[7]; | 1606 | x[10] = -x[7]; |
1597 | 1607 | ||
1598 | MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); | 1608 | MAD_F_ML0(hi, lo, t8, -MAD_F(0x0cb19346)); |
1599 | MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); | 1609 | MAD_F_MLA(hi, lo, t9, MAD_F(0x0fdcf549)); |
1600 | MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); | 1610 | MAD_F_MLA(hi, lo, t10, MAD_F(0x0216a2a2)); |
1601 | MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); | 1611 | MAD_F_MLA(hi, lo, t11, -MAD_F(0x09bd7ca0)); |
1602 | 1612 | ||
1603 | x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; | 1613 | x[19] = x[34] = MAD_F_MLZ(hi, lo) - t0; |
1604 | 1614 | ||
1605 | t12 = X[0] - X[3] + X[8] - X[11] - X[12] + X[15]; | 1615 | t12 = X[0] - X[3] + X[8] - X[11] - X[12] + X[15]; |
@@ -2096,256 +2106,256 @@ void III_overlap_z(mad_fixed_t overlap[18], | |||
2096 | } | 2106 | } |
2097 | # else | 2107 | # else |
2098 | for (i = 0; i < 18; ++i) { | 2108 | for (i = 0; i < 18; ++i) { |
2099 | sample[i][sb] = overlap[i]; | 2109 | sample[i][sb] = overlap[i]; |
2100 | overlap[i] = 0; | 2110 | overlap[i] = 0; |
2101 | } | 2111 | } |
2102 | # endif | 2112 | # endif |
2103 | } | 2113 | } |
2104 | 2114 | ||
2105 | /* | 2115 | /* |
2106 | * NAME:III_freqinver() | 2116 | * NAME:III_freqinver() |
2107 | * DESCRIPTION:perform subband frequency inversion for odd sample lines | 2117 | * DESCRIPTION:perform subband frequency inversion for odd sample lines |
2108 | */ | 2118 | */ |
2109 | static | 2119 | static |
2110 | void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) | 2120 | void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) |
2111 | { | 2121 | { |
2112 | unsigned int i; | 2122 | unsigned int i; |
2113 | 2123 | ||
2114 | # if 1 || defined(ASO_INTERLEAVE1) || defined(ASO_INTERLEAVE2) | 2124 | # if 1 || defined(ASO_INTERLEAVE1) || defined(ASO_INTERLEAVE2) |
2115 | { | 2125 | { |
2116 | register mad_fixed_t tmp1, tmp2; | 2126 | register mad_fixed_t tmp1, tmp2; |
2117 | 2127 | ||
2118 | tmp1 = sample[1][sb]; | 2128 | tmp1 = sample[1][sb]; |
2119 | tmp2 = sample[3][sb]; | 2129 | tmp2 = sample[3][sb]; |
2120 | 2130 | ||
2121 | for (i = 1; i < 13; i += 4) { | 2131 | for (i = 1; i < 13; i += 4) { |
2122 | sample[i + 0][sb] = -tmp1; | 2132 | sample[i + 0][sb] = -tmp1; |
2123 | tmp1 = sample[i + 4][sb]; | 2133 | tmp1 = sample[i + 4][sb]; |
2124 | sample[i + 2][sb] = -tmp2; | 2134 | sample[i + 2][sb] = -tmp2; |
2125 | tmp2 = sample[i + 6][sb]; | 2135 | tmp2 = sample[i + 6][sb]; |
2126 | } | 2136 | } |
2127 | 2137 | ||
2128 | sample[13][sb] = -tmp1; | 2138 | sample[13][sb] = -tmp1; |
2129 | tmp1 = sample[17][sb]; | 2139 | tmp1 = sample[17][sb]; |
2130 | sample[15][sb] = -tmp2; | 2140 | sample[15][sb] = -tmp2; |
2131 | sample[17][sb] = -tmp1; | 2141 | sample[17][sb] = -tmp1; |
2132 | } | 2142 | } |
2133 | # else | 2143 | # else |
2134 | for (i = 1; i < 18; i += 2) | 2144 | for (i = 1; i < 18; i += 2) |
2135 | sample[i][sb] = -sample[i][sb]; | 2145 | sample[i][sb] = -sample[i][sb]; |
2136 | # endif | 2146 | # endif |
2137 | } | 2147 | } |
2138 | 2148 | ||
2139 | /* | 2149 | /* |
2140 | * NAME:III_decode() | 2150 | * NAME:III_decode() |
2141 | * DESCRIPTION:decode frame main_data | 2151 | * DESCRIPTION:decode frame main_data |
2142 | */ | 2152 | */ |
2143 | static | 2153 | static |
2144 | int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, | 2154 | enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, |
2145 | struct sideinfo *si, unsigned int nch) | 2155 | struct sideinfo *si, unsigned int nch) |
2146 | { | 2156 | { |
2147 | struct mad_header *header = &frame->header; | 2157 | struct mad_header *header = &frame->header; |
2148 | unsigned int sfreqi, ngr, gr; | 2158 | unsigned int sfreqi, ngr, gr; |
2149 | 2159 | ||
2150 | { | 2160 | { |
2151 | unsigned int sfreq; | 2161 | unsigned int sfreq; |
2152 | 2162 | ||
2153 | sfreq = header->samplerate; | 2163 | sfreq = header->samplerate; |
2154 | if (header->flags & MAD_FLAG_MPEG_2_5_EXT) | 2164 | if (header->flags & MAD_FLAG_MPEG_2_5_EXT) |
2155 | sfreq *= 2; | 2165 | sfreq *= 2; |
2156 | 2166 | ||
2157 | /* 48000 => 0, 44100 => 1, 32000 => 2, | 2167 | /* 48000 => 0, 44100 => 1, 32000 => 2, |
2158 | 24000 => 3, 22050 => 4, 16000 => 5 */ | 2168 | 24000 => 3, 22050 => 4, 16000 => 5 */ |
2159 | sfreqi = ((sfreq >> 7) & 0x000f) + | 2169 | sfreqi = ((sfreq >> 7) & 0x000f) + |
2160 | ((sfreq >> 15) & 0x0001) - 8; | 2170 | ((sfreq >> 15) & 0x0001) - 8; |
2161 | 2171 | ||
2162 | if (header->flags & MAD_FLAG_MPEG_2_5_EXT) | 2172 | if (header->flags & MAD_FLAG_MPEG_2_5_EXT) |
2163 | sfreqi += 3; | 2173 | sfreqi += 3; |
2164 | } | 2174 | } |
2165 | 2175 | ||
2166 | /* scalefactors, Huffman decoding, requantization */ | 2176 | /* scalefactors, Huffman decoding, requantization */ |
2167 | 2177 | ||
2168 | ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2; | 2178 | ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2; |
2169 | 2179 | ||
2170 | for (gr = 0; gr < ngr; ++gr) { | 2180 | for (gr = 0; gr < ngr; ++gr) { |
2171 | struct granule *granule = &si->gr[gr]; | 2181 | struct granule *granule = &si->gr[gr]; |
2172 | unsigned char const *sfbwidth = 0; | 2182 | unsigned char const *sfbwidth[2]; |
2173 | mad_fixed_t xr[2][576]; | 2183 | mad_fixed_t xr[2][576]; |
2174 | unsigned int ch; | 2184 | unsigned int ch; |
2175 | enum mad_error error; | 2185 | enum mad_error error; |
2176 | 2186 | ||
2177 | for (ch = 0; ch < nch; ++ch) { | 2187 | for (ch = 0; ch < nch; ++ch) { |
2178 | struct channel *channel = &granule->ch[ch]; | 2188 | struct channel *channel = &granule->ch[ch]; |
2179 | unsigned int part2_length; | 2189 | unsigned int part2_length; |
2180 | 2190 | ||
2181 | sfbwidth = sfbwidth_table[sfreqi].l; | 2191 | sfbwidth[ch] = sfbwidth_table[sfreqi].l; |
2182 | if (channel->block_type == 2) { | 2192 | if (channel->block_type == 2) { |
2183 | sfbwidth = (channel->flags & mixed_block_flag) ? | 2193 | sfbwidth[ch] = (channel->flags & mixed_block_flag) ? |
2184 | sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s; | 2194 | sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s; |
2185 | } | 2195 | } |
2186 | 2196 | ||
2187 | if (header->flags & MAD_FLAG_LSF_EXT) { | 2197 | if (header->flags & MAD_FLAG_LSF_EXT) { |
2188 | part2_length = III_scalefactors_lsf(ptr, channel, | 2198 | part2_length = III_scalefactors_lsf(ptr, channel, |
2189 | ch == 0 ? 0 : &si->gr[1].ch[1], | 2199 | ch == 0 ? 0 : &si->gr[1].ch[1], |
2190 | header->mode_extension); | 2200 | header->mode_extension); |
2191 | } | 2201 | } |
2192 | else { | 2202 | else { |
2193 | part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], | 2203 | part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch], |
2194 | gr == 0 ? 0 : si->scfsi[ch]); | 2204 | gr == 0 ? 0 : si->scfsi[ch]); |
2195 | } | 2205 | } |
2196 | 2206 | ||
2197 | error = III_huffdecode(ptr, xr[ch], channel, sfbwidth, part2_length); | 2207 | error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length); |
2198 | if (error) | 2208 | if (error) |
2199 | return error; | 2209 | return error; |
2200 | } | 2210 | } |
2201 | 2211 | ||
2202 | /* joint stereo processing */ | 2212 | /* joint stereo processing */ |
2203 | 2213 | ||
2204 | if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) { | 2214 | if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) { |
2205 | error = III_stereo(xr, granule, header, sfbwidth); | 2215 | error = III_stereo(xr, granule, header, sfbwidth[0]); |
2206 | if (error) | 2216 | if (error) |
2207 | return error; | 2217 | return error; |
2208 | } | 2218 | } |
2209 | 2219 | ||
2210 | /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */ | 2220 | /* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */ |
2211 | 2221 | ||
2212 | for (ch = 0; ch < nch; ++ch) { | 2222 | for (ch = 0; ch < nch; ++ch) { |
2213 | struct channel const *channel = &granule->ch[ch]; | 2223 | struct channel const *channel = &granule->ch[ch]; |
2214 | mad_fixed_t (*sample)[32] = &frame->sbsample[ch][18 * gr]; | 2224 | mad_fixed_t (*sample)[32] = &frame->sbsample[ch][18 * gr]; |
2215 | unsigned int sb, l, i, sblimit; | 2225 | unsigned int sb, l, i, sblimit; |
2216 | mad_fixed_t output[36]; | 2226 | mad_fixed_t output[36]; |
2217 | 2227 | ||
2218 | if (channel->block_type == 2) { | 2228 | if (channel->block_type == 2) { |
2219 | III_reorder(xr[ch], channel, sfbwidth_table[sfreqi].s); | 2229 | III_reorder(xr[ch], channel, sfbwidth[ch]); |
2220 | 2230 | ||
2221 | # if !defined(OPT_STRICT) | 2231 | # if !defined(OPT_STRICT) |
2222 | /* | 2232 | /* |
2223 | * According to ISO/IEC 11172-3, "Alias reduction is not applied for | 2233 | * According to ISO/IEC 11172-3, "Alias reduction is not applied for |
2224 | * granules with block_type == 2 (short block)." However, other | 2234 | * granules with block_type == 2 (short block)." However, other |
2225 | * sources suggest alias reduction should indeed be performed on the | 2235 | * sources suggest alias reduction should indeed be performed on the |
2226 | * lower two subbands of mixed blocks. Most other implementations do | 2236 | * lower two subbands of mixed blocks. Most other implementations do |
2227 | * this, so by default we will too. | 2237 | * this, so by default we will too. |
2228 | */ | 2238 | */ |
2229 | if (channel->flags & mixed_block_flag) | 2239 | if (channel->flags & mixed_block_flag) |
2230 | III_aliasreduce(xr[ch], 36); | 2240 | III_aliasreduce(xr[ch], 36); |
2231 | # endif | 2241 | # endif |
2232 | } | 2242 | } |
2233 | else | 2243 | else |
2234 | III_aliasreduce(xr[ch], 576); | 2244 | III_aliasreduce(xr[ch], 576); |
2235 | 2245 | ||
2236 | l = 0; | 2246 | l = 0; |
2237 | 2247 | ||
2238 | /* subbands 0-1 */ | 2248 | /* subbands 0-1 */ |
2239 | 2249 | ||
2240 | if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) { | 2250 | if (channel->block_type != 2 || (channel->flags & mixed_block_flag)) { |
2241 | unsigned int block_type; | 2251 | unsigned int block_type; |
2242 | 2252 | ||
2243 | block_type = channel->block_type; | 2253 | block_type = channel->block_type; |
2244 | if (channel->flags & mixed_block_flag) | 2254 | if (channel->flags & mixed_block_flag) |
2245 | block_type = 0; | 2255 | block_type = 0; |
2246 | 2256 | ||
2247 | /* long blocks */ | 2257 | /* long blocks */ |
2248 | for (sb = 0; sb < 2; ++sb, l += 18) { | 2258 | for (sb = 0; sb < 2; ++sb, l += 18) { |
2249 | III_imdct_l(&xr[ch][l], output, block_type); | 2259 | III_imdct_l(&xr[ch][l], output, block_type); |
2250 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); | 2260 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); |
2251 | } | 2261 | } |
2252 | } | 2262 | } |
2253 | else { | 2263 | else { |
2254 | /* short blocks */ | 2264 | /* short blocks */ |
2255 | for (sb = 0; sb < 2; ++sb, l += 18) { | 2265 | for (sb = 0; sb < 2; ++sb, l += 18) { |
2256 | III_imdct_s(&xr[ch][l], output); | 2266 | III_imdct_s(&xr[ch][l], output); |
2257 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); | 2267 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); |
2258 | } | 2268 | } |
2259 | } | 2269 | } |
2260 | 2270 | ||
2261 | III_freqinver(sample, 1); | 2271 | III_freqinver(sample, 1); |
2262 | 2272 | ||
2263 | /* (nonzero) subbands 2-31 */ | 2273 | /* (nonzero) subbands 2-31 */ |
2264 | 2274 | ||
2265 | i = 576; | 2275 | i = 576; |
2266 | while (i > 36 && xr[ch][i - 1] == 0) | 2276 | while (i > 36 && xr[ch][i - 1] == 0) |
2267 | --i; | 2277 | --i; |
2268 | 2278 | ||
2269 | sblimit = 32 - (576 - i) / 18; | 2279 | sblimit = 32 - (576 - i) / 18; |
2270 | 2280 | ||
2271 | if (channel->block_type != 2) { | 2281 | if (channel->block_type != 2) { |
2272 | /* long blocks */ | 2282 | /* long blocks */ |
2273 | for (sb = 2; sb < sblimit; ++sb, l += 18) { | 2283 | for (sb = 2; sb < sblimit; ++sb, l += 18) { |
2274 | III_imdct_l(&xr[ch][l], output, channel->block_type); | 2284 | III_imdct_l(&xr[ch][l], output, channel->block_type); |
2275 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); | 2285 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); |
2276 | 2286 | ||
2277 | if (sb & 1) | 2287 | if (sb & 1) |
2278 | III_freqinver(sample, sb); | 2288 | III_freqinver(sample, sb); |
2279 | } | 2289 | } |
2280 | } | 2290 | } |
2281 | else { | 2291 | else { |
2282 | /* short blocks */ | 2292 | /* short blocks */ |
2283 | for (sb = 2; sb < sblimit; ++sb, l += 18) { | 2293 | for (sb = 2; sb < sblimit; ++sb, l += 18) { |
2284 | III_imdct_s(&xr[ch][l], output); | 2294 | III_imdct_s(&xr[ch][l], output); |
2285 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); | 2295 | III_overlap(output, (*frame->overlap)[ch][sb], sample, sb); |
2286 | 2296 | ||
2287 | if (sb & 1) | 2297 | if (sb & 1) |
2288 | III_freqinver(sample, sb); | 2298 | III_freqinver(sample, sb); |
2289 | } | 2299 | } |
2290 | } | 2300 | } |
2291 | 2301 | ||
2292 | /* remaining (zero) subbands */ | 2302 | /* remaining (zero) subbands */ |
2293 | 2303 | ||
2294 | for (sb = sblimit; sb < 32; ++sb) { | 2304 | for (sb = sblimit; sb < 32; ++sb) { |
2295 | III_overlap_z((*frame->overlap)[ch][sb], sample, sb); | 2305 | III_overlap_z((*frame->overlap)[ch][sb], sample, sb); |
2296 | 2306 | ||
2297 | if (sb & 1) | 2307 | if (sb & 1) |
2298 | III_freqinver(sample, sb); | 2308 | III_freqinver(sample, sb); |
2299 | } | 2309 | } |
2300 | } | 2310 | } |
2301 | } | 2311 | } |
2302 | 2312 | ||
2303 | return 0; | 2313 | return MAD_ERROR_NONE; |
2304 | } | 2314 | } |
2305 | 2315 | ||
2306 | /* | 2316 | /* |
2307 | * NAME:layer->III() | 2317 | * NAME:layer->III() |
2308 | * DESCRIPTION:decode a single Layer III frame | 2318 | * DESCRIPTION:decode a single Layer III frame |
2309 | */ | 2319 | */ |
2310 | int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) | 2320 | int mad_layer_III(struct mad_stream *stream, struct mad_frame *frame) |
2311 | { | 2321 | { |
2312 | struct mad_header *header = &frame->header; | 2322 | struct mad_header *header = &frame->header; |
2313 | unsigned int nch, priv_bitlen, next_md_begin = 0; | 2323 | unsigned int nch, priv_bitlen, next_md_begin = 0; |
2314 | unsigned int si_len, data_bitlen, md_len; | 2324 | unsigned int si_len, data_bitlen, md_len; |
2315 | unsigned int frame_space, frame_used, frame_free; | 2325 | unsigned int frame_space, frame_used, frame_free; |
2316 | struct mad_bitptr ptr; | 2326 | struct mad_bitptr ptr; |
2317 | struct sideinfo si; | 2327 | struct sideinfo si; |
2318 | enum mad_error error; | 2328 | enum mad_error error; |
2319 | int result = 0; | 2329 | int result = 0; |
2320 | 2330 | ||
2321 | /* allocate Layer III dynamic structures */ | 2331 | /* allocate Layer III dynamic structures */ |
2322 | 2332 | ||
2323 | if (stream->main_data == 0) { | 2333 | if (stream->main_data == 0) { |
2324 | stream->main_data = malloc(MAD_BUFFER_MDLEN); | 2334 | stream->main_data = malloc(MAD_BUFFER_MDLEN); |
2325 | if (stream->main_data == 0) { | 2335 | if (stream->main_data == 0) { |
2326 | stream->error = MAD_ERROR_NOMEM; | 2336 | stream->error = MAD_ERROR_NOMEM; |
2327 | return -1; | 2337 | return -1; |
2328 | } | 2338 | } |
2329 | } | 2339 | } |
2330 | 2340 | ||
2331 | if (frame->overlap == 0) { | 2341 | if (frame->overlap == 0) { |
2332 | frame->overlap = calloc(2 * 32 * 18, sizeof(mad_fixed_t)); | 2342 | frame->overlap = calloc(2 * 32 * 18, sizeof(mad_fixed_t)); |
2333 | if (frame->overlap == 0) { | 2343 | if (frame->overlap == 0) { |
2334 | stream->error = MAD_ERROR_NOMEM; | 2344 | stream->error = MAD_ERROR_NOMEM; |
2335 | return -1; | 2345 | return -1; |
2336 | } | 2346 | } |
2337 | } | 2347 | } |
2338 | 2348 | ||
2339 | nch = MAD_NCHANNELS(header); | 2349 | nch = MAD_NCHANNELS(header); |
2340 | si_len = (header->flags & MAD_FLAG_LSF_EXT) ? | 2350 | si_len = (header->flags & MAD_FLAG_LSF_EXT) ? |
2341 | (nch == 1 ? 9 : 17) : (nch == 1 ? 17 : 32); | 2351 | (nch == 1 ? 9 : 17) : (nch == 1 ? 17 : 32); |
2342 | 2352 | ||
2343 | /* check frame sanity */ | 2353 | /* check frame sanity */ |
2344 | 2354 | ||
2345 | if (stream->next_frame - mad_bit_nextbyte(&stream->ptr) < | 2355 | if (stream->next_frame - mad_bit_nextbyte(&stream->ptr) < |
2346 | (signed int) si_len) { | 2356 | (signed int) si_len) { |
2347 | stream->error = MAD_ERROR_BADFRAMELEN; | 2357 | stream->error = MAD_ERROR_BADFRAMELEN; |
2348 | stream->md_len = 0; | 2358 | stream->md_len = 0; |
2349 | return -1; | 2359 | return -1; |
2350 | } | 2360 | } |
2351 | 2361 | ||
diff --git a/core/multimedia/opieplayer/libmad/layer3.h b/core/multimedia/opieplayer/libmad/layer3.h index 1fd83e2..c1a5c69 100644 --- a/core/multimedia/opieplayer/libmad/layer3.h +++ b/core/multimedia/opieplayer/libmad/layer3.h | |||
@@ -1,30 +1,30 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_LAYER3_H | 22 | # ifndef LIBMAD_LAYER3_H |
23 | # define LIBMAD_LAYER3_H | 23 | # define LIBMAD_LAYER3_H |
24 | 24 | ||
25 | # include "stream.h" | 25 | # include "stream.h" |
26 | # include "frame.h" | 26 | # include "frame.h" |
27 | 27 | ||
28 | int mad_layer_III(struct mad_stream *, struct mad_frame *); | 28 | int mad_layer_III(struct mad_stream *, struct mad_frame *); |
29 | 29 | ||
30 | # endif | 30 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/libmad_global.h b/core/multimedia/opieplayer/libmad/libmad_global.h index f2a2a71..2c9c713 100644 --- a/core/multimedia/opieplayer/libmad/libmad_global.h +++ b/core/multimedia/opieplayer/libmad/libmad_global.h | |||
@@ -1,45 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_GLOBAL_H | 22 | # ifndef LIBMAD_GLOBAL_H |
23 | # define LIBMAD_GLOBAL_H | 23 | # define LIBMAD_GLOBAL_H |
24 | 24 | ||
25 | /* conditional debugging */ | 25 | /* conditional debugging */ |
26 | 26 | ||
27 | # if defined(DEBUG) && defined(NDEBUG) | 27 | # if defined(DEBUG) && defined(NDEBUG) |
28 | # error "cannot define both DEBUG and NDEBUG" | 28 | # error "cannot define both DEBUG and NDEBUG" |
29 | # endif | 29 | # endif |
30 | 30 | ||
31 | # if defined(DEBUG) | 31 | # if defined(DEBUG) |
32 | # include <stdio.h> | 32 | # include <stdio.h> |
33 | # endif | 33 | # endif |
34 | 34 | ||
35 | /* conditional features */ | 35 | /* conditional features */ |
36 | 36 | ||
37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY) | 37 | # if defined(OPT_SPEED) && defined(OPT_ACCURACY) |
38 | # error "cannot optimize for both speed and accuracy" | 38 | # error "cannot optimize for both speed and accuracy" |
39 | # endif | 39 | # endif |
40 | 40 | ||
41 | # if defined(OPT_SPEED) && !defined(OPT_SSO) | 41 | # if defined(OPT_SPEED) && !defined(OPT_SSO) |
42 | # define OPT_SSO 1 | 42 | # define OPT_SSO 1 |
43 | # endif | 43 | # endif |
44 | 44 | ||
45 | # if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \ | ||
46 | defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK) | ||
47 | # define USE_ASYNC | ||
48 | # endif | ||
49 | |||
50 | # if !defined(HAVE_ASSERT_H) | ||
51 | # if defined(NDEBUG) | ||
52 | # define assert(x)/* nothing */ | ||
53 | # else | ||
54 | # define assert(x)do { if (!(x)) abort(); } while (0) | ||
55 | # endif | ||
56 | # endif | ||
57 | |||
45 | # endif | 58 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/libmad_version.h b/core/multimedia/opieplayer/libmad/libmad_version.h index f8ee1fa..9e684a7 100644 --- a/core/multimedia/opieplayer/libmad/libmad_version.h +++ b/core/multimedia/opieplayer/libmad/libmad_version.h | |||
@@ -1,47 +1,47 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_VERSION_H | 22 | # ifndef LIBMAD_VERSION_H |
23 | # define LIBMAD_VERSION_H | 23 | # define LIBMAD_VERSION_H |
24 | 24 | ||
25 | # define MAD_VERSION_MAJOR0 | 25 | # define MAD_VERSION_MAJOR0 |
26 | # define MAD_VERSION_MINOR13 | 26 | # define MAD_VERSION_MINOR14 |
27 | # define MAD_VERSION_PATCH0 | 27 | # define MAD_VERSION_PATCH2 |
28 | # define MAD_VERSION_EXTRA" (beta)" | 28 | # define MAD_VERSION_EXTRA" (beta)" |
29 | 29 | ||
30 | # define MAD_VERSION_STRINGIZE(str)#str | 30 | # define MAD_VERSION_STRINGIZE(str)#str |
31 | # define MAD_VERSION_STRING(num)MAD_VERSION_STRINGIZE(num) | 31 | # define MAD_VERSION_STRING(num)MAD_VERSION_STRINGIZE(num) |
32 | 32 | ||
33 | # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ | 33 | # define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \ |
34 | MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ | 34 | MAD_VERSION_STRING(MAD_VERSION_MINOR) "." \ |
35 | MAD_VERSION_STRING(MAD_VERSION_PATCH) \ | 35 | MAD_VERSION_STRING(MAD_VERSION_PATCH) \ |
36 | MAD_VERSION_EXTRA | 36 | MAD_VERSION_EXTRA |
37 | 37 | ||
38 | # define MAD_PUBLISHYEAR"2000-2001" | 38 | # define MAD_PUBLISHYEAR"2000-2001" |
39 | # define MAD_AUTHOR "Robert Leslie" | 39 | # define MAD_AUTHOR "Robert Leslie" |
40 | # define MAD_EMAIL "rob@mars.org" | 40 | # define MAD_EMAIL "rob@mars.org" |
41 | 41 | ||
42 | extern char const mad_version[]; | 42 | extern char const mad_version[]; |
43 | extern char const mad_copyright[]; | 43 | extern char const mad_copyright[]; |
44 | extern char const mad_author[]; | 44 | extern char const mad_author[]; |
45 | extern char const mad_build[]; | 45 | extern char const mad_build[]; |
46 | 46 | ||
47 | # endif | 47 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control index 941047f..42ea6c7 100644 --- a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control +++ b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 plugins/codecs/libmadplugin.so.1 plugins/codecs/libmadplugin.so | 1 | Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 plugins/codecs/libmadplugin.so.1 plugins/codecs/libmadplugin.so |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/plugins | 3 | Section: opie/plugins |
4 | Maintainer: John Ryland <jryland@trolltech.com> | 4 | Maintainer: Maximilian Reiss <max.reiss@gmx.de> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: MP3 file plugin using libmad | 8 | Description: MP3 file plugin using libmad |
9 | Plugin to play MP3 files with the mediaplayer in the Opie environment. | 9 | Plugin to play MP3 files with the mediaplayer in the Opie environment. |
diff --git a/core/multimedia/opieplayer/libmad/qc_table.dat b/core/multimedia/opieplayer/libmad/qc_table.dat index 92b7f38..5d9ca96 100644 --- a/core/multimedia/opieplayer/libmad/qc_table.dat +++ b/core/multimedia/opieplayer/libmad/qc_table.dat | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * These are the Layer II classes of quantization. | 23 | * These are the Layer II classes of quantization. |
24 | * The table is derived from Table B.4 of ISO/IEC 11172-3. | 24 | * The table is derived from Table B.4 of ISO/IEC 11172-3. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | { 3, 2, 5, | 27 | { 3, 2, 5, |
28 | MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, | 28 | MAD_F(0x15555555) /* 1.33333333333 => 1.33333333209, e 0.00000000124 */, |
29 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, | 29 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, |
30 | { 5, 3, 7, | 30 | { 5, 3, 7, |
31 | MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, | 31 | MAD_F(0x1999999a) /* 1.60000000000 => 1.60000000149, e -0.00000000149 */, |
32 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, | 32 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, |
33 | { 7, 0, 3, | 33 | { 7, 0, 3, |
34 | MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, | 34 | MAD_F(0x12492492) /* 1.14285714286 => 1.14285714179, e 0.00000000107 */, |
35 | MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, | 35 | MAD_F(0x04000000) /* 0.25000000000 => 0.25000000000, e 0.00000000000 */ }, |
36 | { 9, 4, 10, | 36 | { 9, 4, 10, |
37 | MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, | 37 | MAD_F(0x1c71c71c) /* 1.77777777777 => 1.77777777612, e 0.00000000165 */, |
38 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, | 38 | MAD_F(0x08000000) /* 0.50000000000 => 0.50000000000, e 0.00000000000 */ }, |
39 | { 15, 0, 4, | 39 | { 15, 0, 4, |
40 | MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, | 40 | MAD_F(0x11111111) /* 1.06666666666 => 1.06666666642, e 0.00000000024 */, |
41 | MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, | 41 | MAD_F(0x02000000) /* 0.12500000000 => 0.12500000000, e 0.00000000000 */ }, |
42 | { 31, 0, 5, | 42 | { 31, 0, 5, |
43 | MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, | 43 | MAD_F(0x10842108) /* 1.03225806452 => 1.03225806355, e 0.00000000097 */, |
44 | MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, | 44 | MAD_F(0x01000000) /* 0.06250000000 => 0.06250000000, e 0.00000000000 */ }, |
45 | { 63, 0, 6, | 45 | { 63, 0, 6, |
46 | MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, | 46 | MAD_F(0x10410410) /* 1.01587301587 => 1.01587301493, e 0.00000000094 */, |
47 | MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, | 47 | MAD_F(0x00800000) /* 0.03125000000 => 0.03125000000, e 0.00000000000 */ }, |
48 | { 127, 0, 7, | 48 | { 127, 0, 7, |
49 | MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, | 49 | MAD_F(0x10204081) /* 1.00787401575 => 1.00787401572, e 0.00000000003 */, |
50 | MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, | 50 | MAD_F(0x00400000) /* 0.01562500000 => 0.01562500000, e 0.00000000000 */ }, |
diff --git a/core/multimedia/opieplayer/libmad/rq_table.dat b/core/multimedia/opieplayer/libmad/rq_table.dat index b6d1634..803cf04 100644 --- a/core/multimedia/opieplayer/libmad/rq_table.dat +++ b/core/multimedia/opieplayer/libmad/rq_table.dat | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * This is the lookup table used to compute x^(4/3) for Layer III | 23 | * This is the lookup table used to compute x^(4/3) for Layer III |
24 | * requantization. To maintain the best possible accuracy, the value is | 24 | * requantization. To maintain the best possible accuracy, the value is |
25 | * stored as a normalized mantissa with exponent. The requantization | 25 | * stored as a normalized mantissa with exponent. The requantization |
26 | * algorithm recombines these parts with appropriate scaling. | 26 | * algorithm recombines these parts with appropriate scaling. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* 0 */ { MAD_F(0x00000000) /* 0.000000000 */, 0 }, | 29 | /* 0 */ { MAD_F(0x00000000) /* 0.000000000 */, 0 }, |
30 | /* 1 */ { MAD_F(0x04000000) /* 0.250000000 */, 2 }, | 30 | /* 1 */ { MAD_F(0x04000000) /* 0.250000000 */, 2 }, |
31 | /* 2 */ { MAD_F(0x050a28be) /* 0.314980262 */, 3 }, | 31 | /* 2 */ { MAD_F(0x050a28be) /* 0.314980262 */, 3 }, |
32 | /* 3 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 4 }, | 32 | /* 3 */ { MAD_F(0x0453a5cd) /* 0.270421794 */, 4 }, |
33 | /* 4 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 4 }, | 33 | /* 4 */ { MAD_F(0x06597fa9) /* 0.396850263 */, 4 }, |
34 | /* 5 */ { MAD_F(0x04466275) /* 0.267183742 */, 5 }, | 34 | /* 5 */ { MAD_F(0x04466275) /* 0.267183742 */, 5 }, |
35 | /* 6 */ { MAD_F(0x05738c72) /* 0.340710111 */, 5 }, | 35 | /* 6 */ { MAD_F(0x05738c72) /* 0.340710111 */, 5 }, |
36 | /* 7 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 5 }, | 36 | /* 7 */ { MAD_F(0x06b1fc81) /* 0.418453696 */, 5 }, |
37 | /* 8 */ { MAD_F(0x04000000) /* 0.250000000 */, 6 }, | 37 | /* 8 */ { MAD_F(0x04000000) /* 0.250000000 */, 6 }, |
38 | /* 9 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 6 }, | 38 | /* 9 */ { MAD_F(0x04ae20d7) /* 0.292511788 */, 6 }, |
39 | /* 10 */ { MAD_F(0x0562d694) /* 0.336630420 */, 6 }, | 39 | /* 10 */ { MAD_F(0x0562d694) /* 0.336630420 */, 6 }, |
40 | /* 11 */ { MAD_F(0x061dae96) /* 0.382246578 */, 6 }, | 40 | /* 11 */ { MAD_F(0x061dae96) /* 0.382246578 */, 6 }, |
41 | /* 12 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 6 }, | 41 | /* 12 */ { MAD_F(0x06de47f4) /* 0.429267841 */, 6 }, |
42 | /* 13 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 6 }, | 42 | /* 13 */ { MAD_F(0x07a44f7a) /* 0.477614858 */, 6 }, |
43 | /* 14 */ { MAD_F(0x0437be65) /* 0.263609310 */, 7 }, | 43 | /* 14 */ { MAD_F(0x0437be65) /* 0.263609310 */, 7 }, |
44 | /* 15 */ { MAD_F(0x049fc824) /* 0.289009227 */, 7 }, | 44 | /* 15 */ { MAD_F(0x049fc824) /* 0.289009227 */, 7 }, |
45 | 45 | ||
46 | /* 16 */ { MAD_F(0x050a28be) /* 0.314980262 */, 7 }, | 46 | /* 16 */ { MAD_F(0x050a28be) /* 0.314980262 */, 7 }, |
47 | /* 17 */ { MAD_F(0x0576c6f5) /* 0.341498336 */, 7 }, | 47 | /* 17 */ { MAD_F(0x0576c6f5) /* 0.341498336 */, 7 }, |
48 | /* 18 */ { MAD_F(0x05e58c0b) /* 0.368541759 */, 7 }, | 48 | /* 18 */ { MAD_F(0x05e58c0b) /* 0.368541759 */, 7 }, |
49 | /* 19 */ { MAD_F(0x06566361) /* 0.396090870 */, 7 }, | 49 | /* 19 */ { MAD_F(0x06566361) /* 0.396090870 */, 7 }, |
50 | /* 20 */ { MAD_F(0x06c93a2e) /* 0.424127753 */, 7 }, | 50 | /* 20 */ { MAD_F(0x06c93a2e) /* 0.424127753 */, 7 }, |
diff --git a/core/multimedia/opieplayer/libmad/sf_table.dat b/core/multimedia/opieplayer/libmad/sf_table.dat index 18e6202..bc368af 100644 --- a/core/multimedia/opieplayer/libmad/sf_table.dat +++ b/core/multimedia/opieplayer/libmad/sf_table.dat | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * These are the scalefactor values for Layer I and Layer II. | 23 | * These are the scalefactor values for Layer I and Layer II. |
24 | * The values are from Table B.1 of ISO/IEC 11172-3. | 24 | * The values are from Table B.1 of ISO/IEC 11172-3. |
25 | * | 25 | * |
26 | * There is some error introduced by the 32-bit fixed-point representation; | 26 | * There is some error introduced by the 32-bit fixed-point representation; |
27 | * the amount of error is shown. For 16-bit PCM output, this shouldn't be | 27 | * the amount of error is shown. For 16-bit PCM output, this shouldn't be |
28 | * too much of a problem. | 28 | * too much of a problem. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */ | 31 | MAD_F(0x20000000), /* 2.000000000000 => 2.000000000000, e 0.000000000000 */ |
32 | MAD_F(0x1965fea5), /* 1.587401051968 => 1.587401051074, e 0.000000000894 */ | 32 | MAD_F(0x1965fea5), /* 1.587401051968 => 1.587401051074, e 0.000000000894 */ |
33 | MAD_F(0x1428a2fa), /* 1.259921049895 => 1.259921051562, e -0.000000001667 */ | 33 | MAD_F(0x1428a2fa), /* 1.259921049895 => 1.259921051562, e -0.000000001667 */ |
34 | MAD_F(0x10000000), /* 1.000000000000 => 1.000000000000, e 0.000000000000 */ | 34 | MAD_F(0x10000000), /* 1.000000000000 => 1.000000000000, e 0.000000000000 */ |
35 | MAD_F(0x0cb2ff53), /* 0.793700525984 => 0.793700527400, e -0.000000001416 */ | 35 | MAD_F(0x0cb2ff53), /* 0.793700525984 => 0.793700527400, e -0.000000001416 */ |
36 | MAD_F(0x0a14517d), /* 0.629960524947 => 0.629960525781, e -0.000000000833 */ | 36 | MAD_F(0x0a14517d), /* 0.629960524947 => 0.629960525781, e -0.000000000833 */ |
37 | MAD_F(0x08000000), /* 0.500000000000 => 0.500000000000, e 0.000000000000 */ | 37 | MAD_F(0x08000000), /* 0.500000000000 => 0.500000000000, e 0.000000000000 */ |
38 | MAD_F(0x06597fa9), /* 0.396850262992 => 0.396850261837, e 0.000000001155 */ | 38 | MAD_F(0x06597fa9), /* 0.396850262992 => 0.396850261837, e 0.000000001155 */ |
39 | 39 | ||
40 | MAD_F(0x050a28be), /* 0.314980262474 => 0.314980261028, e 0.000000001446 */ | 40 | MAD_F(0x050a28be), /* 0.314980262474 => 0.314980261028, e 0.000000001446 */ |
41 | MAD_F(0x04000000), /* 0.250000000000 => 0.250000000000, e 0.000000000000 */ | 41 | MAD_F(0x04000000), /* 0.250000000000 => 0.250000000000, e 0.000000000000 */ |
42 | MAD_F(0x032cbfd5), /* 0.198425131496 => 0.198425132781, e -0.000000001285 */ | 42 | MAD_F(0x032cbfd5), /* 0.198425131496 => 0.198425132781, e -0.000000001285 */ |
43 | MAD_F(0x0285145f), /* 0.157490131237 => 0.157490130514, e 0.000000000723 */ | 43 | MAD_F(0x0285145f), /* 0.157490131237 => 0.157490130514, e 0.000000000723 */ |
44 | MAD_F(0x02000000), /* 0.125000000000 => 0.125000000000, e 0.000000000000 */ | 44 | MAD_F(0x02000000), /* 0.125000000000 => 0.125000000000, e 0.000000000000 */ |
45 | MAD_F(0x01965fea), /* 0.099212565748 => 0.099212564528, e 0.000000001220 */ | 45 | MAD_F(0x01965fea), /* 0.099212565748 => 0.099212564528, e 0.000000001220 */ |
46 | MAD_F(0x01428a30), /* 0.078745065618 => 0.078745067120, e -0.000000001501 */ | 46 | MAD_F(0x01428a30), /* 0.078745065618 => 0.078745067120, e -0.000000001501 */ |
47 | MAD_F(0x01000000), /* 0.062500000000 => 0.062500000000, e 0.000000000000 */ | 47 | MAD_F(0x01000000), /* 0.062500000000 => 0.062500000000, e 0.000000000000 */ |
48 | 48 | ||
49 | MAD_F(0x00cb2ff5), /* 0.049606282874 => 0.049606282264, e 0.000000000610 */ | 49 | MAD_F(0x00cb2ff5), /* 0.049606282874 => 0.049606282264, e 0.000000000610 */ |
50 | MAD_F(0x00a14518), /* 0.039372532809 => 0.039372533560, e -0.000000000751 */ | 50 | MAD_F(0x00a14518), /* 0.039372532809 => 0.039372533560, e -0.000000000751 */ |
diff --git a/core/multimedia/opieplayer/libmad/stream.c b/core/multimedia/opieplayer/libmad/stream.c index dea7b8e..4374de7 100644 --- a/core/multimedia/opieplayer/libmad/stream.c +++ b/core/multimedia/opieplayer/libmad/stream.c | |||
@@ -1,123 +1,160 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include <stdlib.h> | 28 | # include <stdlib.h> |
29 | 29 | ||
30 | # include "bit.h" | 30 | # include "bit.h" |
31 | # include "stream.h" | 31 | # include "stream.h" |
32 | 32 | ||
33 | /* | 33 | /* |
34 | * NAME:stream->init() | 34 | * NAME:stream->init() |
35 | * DESCRIPTION:initialize stream struct | 35 | * DESCRIPTION:initialize stream struct |
36 | */ | 36 | */ |
37 | void mad_stream_init(struct mad_stream *stream) | 37 | void mad_stream_init(struct mad_stream *stream) |
38 | { | 38 | { |
39 | stream->buffer = 0; | 39 | stream->buffer = 0; |
40 | stream->bufend = 0; | 40 | stream->bufend = 0; |
41 | stream->skiplen = 0; | 41 | stream->skiplen = 0; |
42 | 42 | ||
43 | stream->sync = 0; | 43 | stream->sync = 0; |
44 | stream->freerate = 0; | 44 | stream->freerate = 0; |
45 | 45 | ||
46 | stream->this_frame = 0; | 46 | stream->this_frame = 0; |
47 | stream->next_frame = 0; | 47 | stream->next_frame = 0; |
48 | mad_bit_init(&stream->ptr, 0); | 48 | mad_bit_init(&stream->ptr, 0); |
49 | 49 | ||
50 | mad_bit_init(&stream->anc_ptr, 0); | 50 | mad_bit_init(&stream->anc_ptr, 0); |
51 | stream->anc_bitlen = 0; | 51 | stream->anc_bitlen = 0; |
52 | 52 | ||
53 | stream->main_data = 0; | 53 | stream->main_data = 0; |
54 | stream->md_len = 0; | 54 | stream->md_len = 0; |
55 | 55 | ||
56 | stream->options = 0; | 56 | stream->options = 0; |
57 | stream->error = 0; | 57 | stream->error = MAD_ERROR_NONE; |
58 | } | 58 | } |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * NAME:stream->finish() | 61 | * NAME:stream->finish() |
62 | * DESCRIPTION:deallocate any dynamic memory associated with stream | 62 | * DESCRIPTION:deallocate any dynamic memory associated with stream |
63 | */ | 63 | */ |
64 | void mad_stream_finish(struct mad_stream *stream) | 64 | void mad_stream_finish(struct mad_stream *stream) |
65 | { | 65 | { |
66 | if (stream->main_data) { | 66 | if (stream->main_data) { |
67 | free(stream->main_data); | 67 | free(stream->main_data); |
68 | stream->main_data = 0; | 68 | stream->main_data = 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | mad_bit_finish(&stream->anc_ptr); | 71 | mad_bit_finish(&stream->anc_ptr); |
72 | mad_bit_finish(&stream->ptr); | 72 | mad_bit_finish(&stream->ptr); |
73 | } | 73 | } |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * NAME:stream->buffer() | 76 | * NAME:stream->buffer() |
77 | * DESCRIPTION:set stream buffer pointers | 77 | * DESCRIPTION:set stream buffer pointers |
78 | */ | 78 | */ |
79 | void mad_stream_buffer(struct mad_stream *stream, | 79 | void mad_stream_buffer(struct mad_stream *stream, |
80 | unsigned char const *buffer, unsigned long length) | 80 | unsigned char const *buffer, unsigned long length) |
81 | { | 81 | { |
82 | stream->buffer = buffer; | 82 | stream->buffer = buffer; |
83 | stream->bufend = buffer + length; | 83 | stream->bufend = buffer + length; |
84 | 84 | ||
85 | stream->this_frame = buffer; | 85 | stream->this_frame = buffer; |
86 | stream->next_frame = buffer; | 86 | stream->next_frame = buffer; |
87 | 87 | ||
88 | stream->sync = 1; | 88 | stream->sync = 1; |
89 | 89 | ||
90 | mad_bit_init(&stream->ptr, buffer); | 90 | mad_bit_init(&stream->ptr, buffer); |
91 | } | 91 | } |
92 | 92 | ||
93 | /* | 93 | /* |
94 | * NAME:stream->skip() | 94 | * NAME:stream->skip() |
95 | * DESCRIPTION:arrange to skip bytes before the next frame | 95 | * DESCRIPTION:arrange to skip bytes before the next frame |
96 | */ | 96 | */ |
97 | void mad_stream_skip(struct mad_stream *stream, unsigned long length) | 97 | void mad_stream_skip(struct mad_stream *stream, unsigned long length) |
98 | { | 98 | { |
99 | stream->skiplen += length; | 99 | stream->skiplen += length; |
100 | } | 100 | } |
101 | 101 | ||
102 | /* | 102 | /* |
103 | * NAME:stream->sync() | 103 | * NAME:stream->sync() |
104 | * DESCRIPTION:locate the next stream sync word | 104 | * DESCRIPTION:locate the next stream sync word |
105 | */ | 105 | */ |
106 | int mad_stream_sync(struct mad_stream *stream) | 106 | int mad_stream_sync(struct mad_stream *stream) |
107 | { | 107 | { |
108 | register unsigned char const *ptr, *end; | 108 | register unsigned char const *ptr, *end; |
109 | 109 | ||
110 | ptr = mad_bit_nextbyte(&stream->ptr); | 110 | ptr = mad_bit_nextbyte(&stream->ptr); |
111 | end = stream->bufend; | 111 | end = stream->bufend; |
112 | 112 | ||
113 | while (ptr < end - 1 && | 113 | while (ptr < end - 1 && |
114 | !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) | 114 | !(ptr[0] == 0xff && (ptr[1] & 0xe0) == 0xe0)) |
115 | ++ptr; | 115 | ++ptr; |
116 | 116 | ||
117 | if (end - ptr < MAD_BUFFER_GUARD) | 117 | if (end - ptr < MAD_BUFFER_GUARD) |
118 | return -1; | 118 | return -1; |
119 | 119 | ||
120 | mad_bit_init(&stream->ptr, ptr); | 120 | mad_bit_init(&stream->ptr, ptr); |
121 | 121 | ||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | |||
125 | /* | ||
126 | * NAME:stream->errorstr() | ||
127 | * DESCRIPTION:return a string description of the current error condition | ||
128 | */ | ||
129 | char const *mad_stream_errorstr(struct mad_stream const *stream) | ||
130 | { | ||
131 | switch (stream->error) { | ||
132 | case MAD_ERROR_NONE: return "no error"; | ||
133 | |||
134 | case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)"; | ||
135 | case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer"; | ||
136 | |||
137 | case MAD_ERROR_NOMEM: return "not enough memory"; | ||
138 | |||
139 | case MAD_ERROR_LOSTSYNC: return "lost synchronization"; | ||
140 | case MAD_ERROR_BADLAYER: return "reserved header layer value"; | ||
141 | case MAD_ERROR_BADBITRATE: return "forbidden bitrate value"; | ||
142 | case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value"; | ||
143 | case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value"; | ||
144 | |||
145 | case MAD_ERROR_BADCRC: return "CRC check failed"; | ||
146 | case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value"; | ||
147 | case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index"; | ||
148 | case MAD_ERROR_BADFRAMELEN: return "bad frame length"; | ||
149 | case MAD_ERROR_BADBIGVALUES: return "bad big_values count"; | ||
150 | case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type"; | ||
151 | case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info"; | ||
152 | case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer"; | ||
153 | case MAD_ERROR_BADPART3LEN: return "bad audio data length"; | ||
154 | case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select"; | ||
155 | case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun"; | ||
156 | case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS"; | ||
157 | } | ||
158 | |||
159 | return 0; | ||
160 | } | ||
diff --git a/core/multimedia/opieplayer/libmad/stream.h b/core/multimedia/opieplayer/libmad/stream.h index cf3280e..08e6dc5 100644 --- a/core/multimedia/opieplayer/libmad/stream.h +++ b/core/multimedia/opieplayer/libmad/stream.h | |||
@@ -1,102 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_STREAM_H | 22 | # ifndef LIBMAD_STREAM_H |
23 | # define LIBMAD_STREAM_H | 23 | # define LIBMAD_STREAM_H |
24 | 24 | ||
25 | # include "bit.h" | 25 | # include "bit.h" |
26 | 26 | ||
27 | # define MAD_BUFFER_GUARD8 | 27 | # define MAD_BUFFER_GUARD8 |
28 | # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD) | 28 | # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD) |
29 | 29 | ||
30 | enum mad_error { | 30 | enum mad_error { |
31 | MAD_ERROR_NONE = 0x0000,/* no error */ | ||
32 | |||
31 | MAD_ERROR_BUFLEN = 0x0001,/* input buffer too small (or EOF) */ | 33 | MAD_ERROR_BUFLEN = 0x0001,/* input buffer too small (or EOF) */ |
32 | MAD_ERROR_BUFPTR = 0x0002,/* invalid (null) buffer pointer */ | 34 | MAD_ERROR_BUFPTR = 0x0002,/* invalid (null) buffer pointer */ |
33 | 35 | ||
34 | MAD_ERROR_NOMEM = 0x0031,/* not enough memory */ | 36 | MAD_ERROR_NOMEM = 0x0031,/* not enough memory */ |
35 | 37 | ||
36 | MAD_ERROR_LOSTSYNC = 0x0101,/* lost synchronization */ | 38 | MAD_ERROR_LOSTSYNC = 0x0101,/* lost synchronization */ |
37 | MAD_ERROR_BADLAYER = 0x0102,/* reserved header layer value */ | 39 | MAD_ERROR_BADLAYER = 0x0102,/* reserved header layer value */ |
38 | MAD_ERROR_BADBITRATE = 0x0103,/* forbidden bitrate value */ | 40 | MAD_ERROR_BADBITRATE = 0x0103,/* forbidden bitrate value */ |
39 | MAD_ERROR_BADSAMPLERATE = 0x0104,/* reserved sample frequency value */ | 41 | MAD_ERROR_BADSAMPLERATE = 0x0104,/* reserved sample frequency value */ |
40 | MAD_ERROR_BADEMPHASIS = 0x0105,/* reserved emphasis value */ | 42 | MAD_ERROR_BADEMPHASIS = 0x0105,/* reserved emphasis value */ |
41 | 43 | ||
42 | MAD_ERROR_BADCRC = 0x0201,/* CRC check failed */ | 44 | MAD_ERROR_BADCRC = 0x0201,/* CRC check failed */ |
43 | MAD_ERROR_BADBITALLOC = 0x0211,/* forbidden bit allocation value */ | 45 | MAD_ERROR_BADBITALLOC = 0x0211,/* forbidden bit allocation value */ |
44 | MAD_ERROR_BADSCALEFACTOR = 0x0221,/* bad scalefactor index */ | 46 | MAD_ERROR_BADSCALEFACTOR = 0x0221,/* bad scalefactor index */ |
45 | MAD_ERROR_BADFRAMELEN = 0x0231,/* bad frame length */ | 47 | MAD_ERROR_BADFRAMELEN = 0x0231,/* bad frame length */ |
46 | MAD_ERROR_BADBIGVALUES = 0x0232,/* bad big_values count */ | 48 | MAD_ERROR_BADBIGVALUES = 0x0232,/* bad big_values count */ |
47 | MAD_ERROR_BADBLOCKTYPE = 0x0233,/* reserved block_type */ | 49 | MAD_ERROR_BADBLOCKTYPE = 0x0233,/* reserved block_type */ |
48 | MAD_ERROR_BADSCFSI = 0x0234,/* bad scalefactor selection info */ | 50 | MAD_ERROR_BADSCFSI = 0x0234,/* bad scalefactor selection info */ |
49 | MAD_ERROR_BADDATAPTR = 0x0235,/* bad main_data_begin pointer */ | 51 | MAD_ERROR_BADDATAPTR = 0x0235,/* bad main_data_begin pointer */ |
50 | MAD_ERROR_BADPART3LEN = 0x0236,/* bad audio data length */ | 52 | MAD_ERROR_BADPART3LEN = 0x0236,/* bad audio data length */ |
51 | MAD_ERROR_BADHUFFTABLE = 0x0237,/* bad Huffman table select */ | 53 | MAD_ERROR_BADHUFFTABLE = 0x0237,/* bad Huffman table select */ |
52 | MAD_ERROR_BADHUFFDATA = 0x0238,/* Huffman data overrun */ | 54 | MAD_ERROR_BADHUFFDATA = 0x0238,/* Huffman data overrun */ |
53 | MAD_ERROR_BADSTEREO = 0x0239/* incompatible block_type for JS */ | 55 | MAD_ERROR_BADSTEREO = 0x0239/* incompatible block_type for JS */ |
54 | }; | 56 | }; |
55 | 57 | ||
56 | # define MAD_RECOVERABLE(error)((error) & 0xff00) | 58 | # define MAD_RECOVERABLE(error)((error) & 0xff00) |
57 | 59 | ||
58 | struct mad_stream { | 60 | struct mad_stream { |
59 | unsigned char const *buffer; /* input bitstream buffer */ | 61 | unsigned char const *buffer; /* input bitstream buffer */ |
60 | unsigned char const *bufend; /* end of buffer */ | 62 | unsigned char const *bufend; /* end of buffer */ |
61 | unsigned long skiplen; /* bytes to skip before next frame */ | 63 | unsigned long skiplen; /* bytes to skip before next frame */ |
62 | 64 | ||
63 | int sync; /* stream sync found */ | 65 | int sync; /* stream sync found */ |
64 | unsigned long freerate; /* free bitrate (fixed) */ | 66 | unsigned long freerate; /* free bitrate (fixed) */ |
65 | 67 | ||
66 | unsigned char const *this_frame;/* start of current frame */ | 68 | unsigned char const *this_frame;/* start of current frame */ |
67 | unsigned char const *next_frame;/* start of next frame */ | 69 | unsigned char const *next_frame;/* start of next frame */ |
68 | struct mad_bitptr ptr; /* current processing bit pointer */ | 70 | struct mad_bitptr ptr; /* current processing bit pointer */ |
69 | 71 | ||
70 | struct mad_bitptr anc_ptr; /* ancillary bits pointer */ | 72 | struct mad_bitptr anc_ptr; /* ancillary bits pointer */ |
71 | unsigned int anc_bitlen; /* number of ancillary bits */ | 73 | unsigned int anc_bitlen; /* number of ancillary bits */ |
72 | 74 | ||
73 | unsigned char (*main_data)[MAD_BUFFER_MDLEN]; | 75 | unsigned char (*main_data)[MAD_BUFFER_MDLEN]; |
74 | /* Layer III main_data() */ | 76 | /* Layer III main_data() */ |
75 | unsigned int md_len; /* bytes in main_data */ | 77 | unsigned int md_len; /* bytes in main_data */ |
76 | 78 | ||
77 | int options; /* decoding options (see below) */ | 79 | int options; /* decoding options (see below) */ |
78 | enum mad_error error; /* error code (see above) */ | 80 | enum mad_error error; /* error code (see above) */ |
79 | }; | 81 | }; |
80 | 82 | ||
81 | enum { | 83 | enum { |
82 | MAD_OPTION_IGNORECRC = 0x0001,/* ignore CRC errors */ | 84 | MAD_OPTION_IGNORECRC = 0x0001,/* ignore CRC errors */ |
83 | MAD_OPTION_HALFSAMPLERATE = 0x0002,/* generate PCM at 1/2 sample rate */ | 85 | MAD_OPTION_HALFSAMPLERATE = 0x0002/* generate PCM at 1/2 sample rate */ |
84 | # if 0 /* not yet implemented */ | 86 | # if 0 /* not yet implemented */ |
85 | MAD_OPTION_LEFTCHANNEL = 0x0010,/* decode left channel only */ | 87 | MAD_OPTION_LEFTCHANNEL = 0x0010,/* decode left channel only */ |
86 | MAD_OPTION_RIGHTCHANNEL = 0x0020,/* decode right channel only */ | 88 | MAD_OPTION_RIGHTCHANNEL = 0x0020,/* decode right channel only */ |
87 | MAD_OPTION_SINGLECHANNEL = 0x0030,/* combine channels */ | 89 | MAD_OPTION_SINGLECHANNEL = 0x0030/* combine channels */ |
88 | # endif | 90 | # endif |
89 | }; | 91 | }; |
90 | 92 | ||
91 | void mad_stream_init(struct mad_stream *); | 93 | void mad_stream_init(struct mad_stream *); |
92 | void mad_stream_finish(struct mad_stream *); | 94 | void mad_stream_finish(struct mad_stream *); |
93 | 95 | ||
94 | # define mad_stream_options(stream, opts) ((stream)->options = (opts)) | 96 | # define mad_stream_options(stream, opts) \ |
97 | ((void) ((stream)->options = (opts))) | ||
95 | 98 | ||
96 | void mad_stream_buffer(struct mad_stream *, | 99 | void mad_stream_buffer(struct mad_stream *, |
97 | unsigned char const *, unsigned long); | 100 | unsigned char const *, unsigned long); |
98 | void mad_stream_skip(struct mad_stream *, unsigned long); | 101 | void mad_stream_skip(struct mad_stream *, unsigned long); |
99 | 102 | ||
100 | int mad_stream_sync(struct mad_stream *); | 103 | int mad_stream_sync(struct mad_stream *); |
101 | 104 | ||
105 | char const *mad_stream_errorstr(struct mad_stream const *); | ||
106 | |||
102 | # endif | 107 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/synth.c b/core/multimedia/opieplayer/libmad/synth.c index e1914c9..cf3c1d5 100644 --- a/core/multimedia/opieplayer/libmad/synth.c +++ b/core/multimedia/opieplayer/libmad/synth.c | |||
@@ -1,50 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include "fixed.h" | 28 | # include "fixed.h" |
29 | # include "frame.h" | 29 | # include "frame.h" |
30 | # include "synth.h" | 30 | # include "synth.h" |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * NAME:synth->init() | 33 | * NAME:synth->init() |
34 | * DESCRIPTION:initialize synth struct | 34 | * DESCRIPTION:initialize synth struct |
35 | */ | 35 | */ |
36 | void mad_synth_init(struct mad_synth *synth) | 36 | void mad_synth_init(struct mad_synth *synth) |
37 | { | 37 | { |
38 | mad_synth_mute(synth); | 38 | mad_synth_mute(synth); |
39 | 39 | ||
40 | synth->phase = 0; | 40 | synth->phase = 0; |
41 | 41 | ||
42 | synth->pcm.samplerate = 0; | 42 | synth->pcm.samplerate = 0; |
43 | synth->pcm.channels = 0; | 43 | synth->pcm.channels = 0; |
44 | synth->pcm.length = 0; | 44 | synth->pcm.length = 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * NAME:synth->mute() | 48 | * NAME:synth->mute() |
49 | * DESCRIPTION:zero all polyphase filterbank values, resetting synthesis | 49 | * DESCRIPTION:zero all polyphase filterbank values, resetting synthesis |
50 | */ | 50 | */ |
@@ -105,163 +105,159 @@ void mad_synth_mute(struct mad_synth *synth) | |||
105 | # if defined(OPT_SPEED) && defined(MAD_F_MLX) | 105 | # if defined(OPT_SPEED) && defined(MAD_F_MLX) |
106 | # define OPT_DCTO | 106 | # define OPT_DCTO |
107 | # define MUL(x, y) \ | 107 | # define MUL(x, y) \ |
108 | ({ mad_fixed64hi_t hi; \ | 108 | ({ mad_fixed64hi_t hi; \ |
109 | mad_fixed64lo_t lo; \ | 109 | mad_fixed64lo_t lo; \ |
110 | MAD_F_MLX(hi, lo, (x), (y)); \ | 110 | MAD_F_MLX(hi, lo, (x), (y)); \ |
111 | hi << (32 - MAD_F_SCALEBITS - 3); \ | 111 | hi << (32 - MAD_F_SCALEBITS - 3); \ |
112 | }) | 112 | }) |
113 | # else | 113 | # else |
114 | # undef OPT_DCTO | 114 | # undef OPT_DCTO |
115 | # define MUL(x, y) mad_f_mul((x), (y)) | 115 | # define MUL(x, y) mad_f_mul((x), (y)) |
116 | # endif | 116 | # endif |
117 | 117 | ||
118 | /* | 118 | /* |
119 | * NAME:dct32() | 119 | * NAME:dct32() |
120 | * DESCRIPTION:perform fast in[32]->out[32] DCT | 120 | * DESCRIPTION:perform fast in[32]->out[32] DCT |
121 | */ | 121 | */ |
122 | static | 122 | static |
123 | void dct32(mad_fixed_t const in[32], unsigned int slot, | 123 | void dct32(mad_fixed_t const in[32], unsigned int slot, |
124 | mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) | 124 | mad_fixed_t lo[16][8], mad_fixed_t hi[16][8]) |
125 | { | 125 | { |
126 | mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; | 126 | mad_fixed_t t0, t1, t2, t3, t4, t5, t6, t7; |
127 | mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; | 127 | mad_fixed_t t8, t9, t10, t11, t12, t13, t14, t15; |
128 | mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23; | 128 | mad_fixed_t t16, t17, t18, t19, t20, t21, t22, t23; |
129 | mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31; | 129 | mad_fixed_t t24, t25, t26, t27, t28, t29, t30, t31; |
130 | mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39; | 130 | mad_fixed_t t32, t33, t34, t35, t36, t37, t38, t39; |
131 | mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47; | 131 | mad_fixed_t t40, t41, t42, t43, t44, t45, t46, t47; |
132 | mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55; | 132 | mad_fixed_t t48, t49, t50, t51, t52, t53, t54, t55; |
133 | mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63; | 133 | mad_fixed_t t56, t57, t58, t59, t60, t61, t62, t63; |
134 | mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71; | 134 | mad_fixed_t t64, t65, t66, t67, t68, t69, t70, t71; |
135 | mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79; | 135 | mad_fixed_t t72, t73, t74, t75, t76, t77, t78, t79; |
136 | mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87; | 136 | mad_fixed_t t80, t81, t82, t83, t84, t85, t86, t87; |
137 | mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95; | 137 | mad_fixed_t t88, t89, t90, t91, t92, t93, t94, t95; |
138 | mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103; | 138 | mad_fixed_t t96, t97, t98, t99, t100, t101, t102, t103; |
139 | mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111; | 139 | mad_fixed_t t104, t105, t106, t107, t108, t109, t110, t111; |
140 | mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119; | 140 | mad_fixed_t t112, t113, t114, t115, t116, t117, t118, t119; |
141 | mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127; | 141 | mad_fixed_t t120, t121, t122, t123, t124, t125, t126, t127; |
142 | mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135; | 142 | mad_fixed_t t128, t129, t130, t131, t132, t133, t134, t135; |
143 | mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143; | 143 | mad_fixed_t t136, t137, t138, t139, t140, t141, t142, t143; |
144 | mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151; | 144 | mad_fixed_t t144, t145, t146, t147, t148, t149, t150, t151; |
145 | mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159; | 145 | mad_fixed_t t152, t153, t154, t155, t156, t157, t158, t159; |
146 | mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167; | 146 | mad_fixed_t t160, t161, t162, t163, t164, t165, t166, t167; |
147 | mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175; | 147 | mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175; |
148 | mad_fixed_t t176; | 148 | mad_fixed_t t176; |
149 | 149 | ||
150 | /* costab[i] = cos(PI / (2 * 32) * i) */ | 150 | /* costab[i] = cos(PI / (2 * 32) * i) */ |
151 | 151 | ||
152 | # if defined(OPT_DCTO) | 152 | # if defined(OPT_DCTO) |
153 | enum { | 153 | # define costab1MAD_F(0x7fd8878e) |
154 | costab1 = MAD_F(0x7fd8878e), | 154 | # define costab2MAD_F(0x7f62368f) |
155 | costab2 = MAD_F(0x7f62368f), | 155 | # define costab3MAD_F(0x7e9d55fc) |
156 | costab3 = MAD_F(0x7e9d55fc), | 156 | # define costab4MAD_F(0x7d8a5f40) |
157 | costab4 = MAD_F(0x7d8a5f40), | 157 | # define costab5MAD_F(0x7c29fbee) |
158 | costab5 = MAD_F(0x7c29fbee), | 158 | # define costab6MAD_F(0x7a7d055b) |
159 | costab6 = MAD_F(0x7a7d055b), | 159 | # define costab7MAD_F(0x78848414) |
160 | costab7 = MAD_F(0x78848414), | 160 | # define costab8MAD_F(0x7641af3d) |
161 | costab8 = MAD_F(0x7641af3d), | 161 | # define costab9MAD_F(0x73b5ebd1) |
162 | costab9 = MAD_F(0x73b5ebd1), | 162 | # define costab10MAD_F(0x70e2cbc6) |
163 | costab10 = MAD_F(0x70e2cbc6), | 163 | # define costab11MAD_F(0x6dca0d14) |
164 | costab11 = MAD_F(0x6dca0d14), | 164 | # define costab12MAD_F(0x6a6d98a4) |
165 | costab12 = MAD_F(0x6a6d98a4), | 165 | # define costab13MAD_F(0x66cf8120) |
166 | costab13 = MAD_F(0x66cf8120), | 166 | # define costab14MAD_F(0x62f201ac) |
167 | costab14 = MAD_F(0x62f201ac), | 167 | # define costab15MAD_F(0x5ed77c8a) |
168 | costab15 = MAD_F(0x5ed77c8a), | 168 | # define costab16MAD_F(0x5a82799a) |
169 | costab16 = MAD_F(0x5a82799a), | 169 | # define costab17MAD_F(0x55f5a4d2) |
170 | costab17 = MAD_F(0x55f5a4d2), | 170 | # define costab18MAD_F(0x5133cc94) |
171 | costab18 = MAD_F(0x5133cc94), | 171 | # define costab19MAD_F(0x4c3fdff4) |
172 | costab19 = MAD_F(0x4c3fdff4), | 172 | # define costab20MAD_F(0x471cece7) |
173 | costab20 = MAD_F(0x471cece7), | 173 | # define costab21MAD_F(0x41ce1e65) |
174 | costab21 = MAD_F(0x41ce1e65), | 174 | # define costab22MAD_F(0x3c56ba70) |
175 | costab22 = MAD_F(0x3c56ba70), | 175 | # define costab23MAD_F(0x36ba2014) |
176 | costab23 = MAD_F(0x36ba2014), | 176 | # define costab24MAD_F(0x30fbc54d) |
177 | costab24 = MAD_F(0x30fbc54d), | 177 | # define costab25MAD_F(0x2b1f34eb) |
178 | costab25 = MAD_F(0x2b1f34eb), | 178 | # define costab26MAD_F(0x25280c5e) |
179 | costab26 = MAD_F(0x25280c5e), | 179 | # define costab27MAD_F(0x1f19f97b) |
180 | costab27 = MAD_F(0x1f19f97b), | 180 | # define costab28MAD_F(0x18f8b83c) |
181 | costab28 = MAD_F(0x18f8b83c), | 181 | # define costab29MAD_F(0x12c8106f) |
182 | costab29 = MAD_F(0x12c8106f), | 182 | # define costab30MAD_F(0x0c8bd35e) |
183 | costab30 = MAD_F(0x0c8bd35e), | 183 | # define costab31MAD_F(0x0647d97c) |
184 | costab31 = MAD_F(0x0647d97c) | ||
185 | }; | ||
186 | # else | 184 | # else |
187 | enum { | 185 | # define costab1MAD_F(0x0ffb10f2) /* 0.998795456 */ |
188 | costab1 = MAD_F(0x0ffb10f2), /* 0.998795456 */ | 186 | # define costab2MAD_F(0x0fec46d2) /* 0.995184727 */ |
189 | costab2 = MAD_F(0x0fec46d2), /* 0.995184727 */ | 187 | # define costab3MAD_F(0x0fd3aac0) /* 0.989176510 */ |
190 | costab3 = MAD_F(0x0fd3aac0), /* 0.989176510 */ | 188 | # define costab4MAD_F(0x0fb14be8) /* 0.980785280 */ |
191 | costab4 = MAD_F(0x0fb14be8), /* 0.980785280 */ | 189 | # define costab5MAD_F(0x0f853f7e) /* 0.970031253 */ |
192 | costab5 = MAD_F(0x0f853f7e), /* 0.970031253 */ | 190 | # define costab6MAD_F(0x0f4fa0ab) /* 0.956940336 */ |
193 | costab6 = MAD_F(0x0f4fa0ab), /* 0.956940336 */ | 191 | # define costab7MAD_F(0x0f109082) /* 0.941544065 */ |
194 | costab7 = MAD_F(0x0f109082), /* 0.941544065 */ | 192 | # define costab8MAD_F(0x0ec835e8) /* 0.923879533 */ |
195 | costab8 = MAD_F(0x0ec835e8), /* 0.923879533 */ | 193 | # define costab9MAD_F(0x0e76bd7a) /* 0.903989293 */ |
196 | costab9 = MAD_F(0x0e76bd7a), /* 0.903989293 */ | 194 | # define costab10MAD_F(0x0e1c5979) /* 0.881921264 */ |
197 | costab10 = MAD_F(0x0e1c5979), /* 0.881921264 */ | 195 | # define costab11MAD_F(0x0db941a3) /* 0.857728610 */ |
198 | costab11 = MAD_F(0x0db941a3), /* 0.857728610 */ | 196 | # define costab12MAD_F(0x0d4db315) /* 0.831469612 */ |
199 | costab12 = MAD_F(0x0d4db315), /* 0.831469612 */ | 197 | # define costab13MAD_F(0x0cd9f024) /* 0.803207531 */ |
200 | costab13 = MAD_F(0x0cd9f024), /* 0.803207531 */ | 198 | # define costab14MAD_F(0x0c5e4036) /* 0.773010453 */ |
201 | costab14 = MAD_F(0x0c5e4036), /* 0.773010453 */ | 199 | # define costab15MAD_F(0x0bdaef91) /* 0.740951125 */ |
202 | costab15 = MAD_F(0x0bdaef91), /* 0.740951125 */ | 200 | # define costab16MAD_F(0x0b504f33) /* 0.707106781 */ |
203 | costab16 = MAD_F(0x0b504f33), /* 0.707106781 */ | 201 | # define costab17MAD_F(0x0abeb49a) /* 0.671558955 */ |
204 | costab17 = MAD_F(0x0abeb49a), /* 0.671558955 */ | 202 | # define costab18MAD_F(0x0a267993) /* 0.634393284 */ |
205 | costab18 = MAD_F(0x0a267993), /* 0.634393284 */ | 203 | # define costab19MAD_F(0x0987fbfe) /* 0.595699304 */ |
206 | costab19 = MAD_F(0x0987fbfe), /* 0.595699304 */ | 204 | # define costab20MAD_F(0x08e39d9d) /* 0.555570233 */ |
207 | costab20 = MAD_F(0x08e39d9d), /* 0.555570233 */ | 205 | # define costab21MAD_F(0x0839c3cd) /* 0.514102744 */ |
208 | costab21 = MAD_F(0x0839c3cd), /* 0.514102744 */ | 206 | # define costab22MAD_F(0x078ad74e) /* 0.471396737 */ |
209 | costab22 = MAD_F(0x078ad74e), /* 0.471396737 */ | 207 | # define costab23MAD_F(0x06d74402) /* 0.427555093 */ |
210 | costab23 = MAD_F(0x06d74402), /* 0.427555093 */ | 208 | # define costab24MAD_F(0x061f78aa) /* 0.382683432 */ |
211 | costab24 = MAD_F(0x061f78aa), /* 0.382683432 */ | 209 | # define costab25MAD_F(0x0563e69d) /* 0.336889853 */ |
212 | costab25 = MAD_F(0x0563e69d), /* 0.336889853 */ | 210 | # define costab26MAD_F(0x04a5018c) /* 0.290284677 */ |
213 | costab26 = MAD_F(0x04a5018c), /* 0.290284677 */ | 211 | # define costab27MAD_F(0x03e33f2f) /* 0.242980180 */ |
214 | costab27 = MAD_F(0x03e33f2f), /* 0.242980180 */ | 212 | # define costab28MAD_F(0x031f1708) /* 0.195090322 */ |
215 | costab28 = MAD_F(0x031f1708), /* 0.195090322 */ | 213 | # define costab29MAD_F(0x0259020e) /* 0.146730474 */ |
216 | costab29 = MAD_F(0x0259020e), /* 0.146730474 */ | 214 | # define costab30MAD_F(0x01917a6c) /* 0.098017140 */ |
217 | costab30 = MAD_F(0x01917a6c), /* 0.098017140 */ | 215 | # define costab31MAD_F(0x00c8fb30) /* 0.049067674 */ |
218 | costab31 = MAD_F(0x00c8fb30) /* 0.049067674 */ | ||
219 | }; | ||
220 | # endif | 216 | # endif |
221 | 217 | ||
222 | t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); | 218 | t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1); |
223 | t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31); | 219 | t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31); |
224 | 220 | ||
225 | t41 = t16 + t17; | 221 | t41 = t16 + t17; |
226 | t59 = MUL(t16 - t17, costab2); | 222 | t59 = MUL(t16 - t17, costab2); |
227 | t33 = t0 + t1; | 223 | t33 = t0 + t1; |
228 | t50 = MUL(t0 - t1, costab2); | 224 | t50 = MUL(t0 - t1, costab2); |
229 | 225 | ||
230 | t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15); | 226 | t2 = in[7] + in[24]; t18 = MUL(in[7] - in[24], costab15); |
231 | t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17); | 227 | t3 = in[8] + in[23]; t19 = MUL(in[8] - in[23], costab17); |
232 | 228 | ||
233 | t42 = t18 + t19; | 229 | t42 = t18 + t19; |
234 | t60 = MUL(t18 - t19, costab30); | 230 | t60 = MUL(t18 - t19, costab30); |
235 | t34 = t2 + t3; | 231 | t34 = t2 + t3; |
236 | t51 = MUL(t2 - t3, costab30); | 232 | t51 = MUL(t2 - t3, costab30); |
237 | 233 | ||
238 | t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7); | 234 | t4 = in[3] + in[28]; t20 = MUL(in[3] - in[28], costab7); |
239 | t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25); | 235 | t5 = in[12] + in[19]; t21 = MUL(in[12] - in[19], costab25); |
240 | 236 | ||
241 | t43 = t20 + t21; | 237 | t43 = t20 + t21; |
242 | t61 = MUL(t20 - t21, costab14); | 238 | t61 = MUL(t20 - t21, costab14); |
243 | t35 = t4 + t5; | 239 | t35 = t4 + t5; |
244 | t52 = MUL(t4 - t5, costab14); | 240 | t52 = MUL(t4 - t5, costab14); |
245 | 241 | ||
246 | t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9); | 242 | t6 = in[4] + in[27]; t22 = MUL(in[4] - in[27], costab9); |
247 | t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23); | 243 | t7 = in[11] + in[20]; t23 = MUL(in[11] - in[20], costab23); |
248 | 244 | ||
249 | t44 = t22 + t23; | 245 | t44 = t22 + t23; |
250 | t62 = MUL(t22 - t23, costab18); | 246 | t62 = MUL(t22 - t23, costab18); |
251 | t36 = t6 + t7; | 247 | t36 = t6 + t7; |
252 | t53 = MUL(t6 - t7, costab18); | 248 | t53 = MUL(t6 - t7, costab18); |
253 | 249 | ||
254 | t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3); | 250 | t8 = in[1] + in[30]; t24 = MUL(in[1] - in[30], costab3); |
255 | t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29); | 251 | t9 = in[14] + in[17]; t25 = MUL(in[14] - in[17], costab29); |
256 | 252 | ||
257 | t45 = t24 + t25; | 253 | t45 = t24 + t25; |
258 | t63 = MUL(t24 - t25, costab6); | 254 | t63 = MUL(t24 - t25, costab6); |
259 | t37 = t8 + t9; | 255 | t37 = t8 + t9; |
260 | t54 = MUL(t8 - t9, costab6); | 256 | t54 = MUL(t8 - t9, costab6); |
261 | 257 | ||
262 | t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13); | 258 | t10 = in[6] + in[25]; t26 = MUL(in[6] - in[25], costab13); |
263 | t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19); | 259 | t11 = in[9] + in[22]; t27 = MUL(in[9] - in[22], costab19); |
264 | 260 | ||
265 | t46 = t26 + t27; | 261 | t46 = t26 + t27; |
266 | t64 = MUL(t26 - t27, costab26); | 262 | t64 = MUL(t26 - t27, costab26); |
267 | t38 = t10 + t11; | 263 | t38 = t10 + t11; |
@@ -282,544 +278,550 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, | |||
282 | t66 = MUL(t30 - t31, costab22); | 278 | t66 = MUL(t30 - t31, costab22); |
283 | t40 = t14 + t15; | 279 | t40 = t14 + t15; |
284 | t57 = MUL(t14 - t15, costab22); | 280 | t57 = MUL(t14 - t15, costab22); |
285 | 281 | ||
286 | t69 = t33 + t34; t89 = MUL(t33 - t34, costab4); | 282 | t69 = t33 + t34; t89 = MUL(t33 - t34, costab4); |
287 | t70 = t35 + t36; t90 = MUL(t35 - t36, costab28); | 283 | t70 = t35 + t36; t90 = MUL(t35 - t36, costab28); |
288 | t71 = t37 + t38; t91 = MUL(t37 - t38, costab12); | 284 | t71 = t37 + t38; t91 = MUL(t37 - t38, costab12); |
289 | t72 = t39 + t40; t92 = MUL(t39 - t40, costab20); | 285 | t72 = t39 + t40; t92 = MUL(t39 - t40, costab20); |
290 | t73 = t41 + t42; t94 = MUL(t41 - t42, costab4); | 286 | t73 = t41 + t42; t94 = MUL(t41 - t42, costab4); |
291 | t74 = t43 + t44; t95 = MUL(t43 - t44, costab28); | 287 | t74 = t43 + t44; t95 = MUL(t43 - t44, costab28); |
292 | t75 = t45 + t46; t96 = MUL(t45 - t46, costab12); | 288 | t75 = t45 + t46; t96 = MUL(t45 - t46, costab12); |
293 | t76 = t47 + t48; t97 = MUL(t47 - t48, costab20); | 289 | t76 = t47 + t48; t97 = MUL(t47 - t48, costab20); |
294 | 290 | ||
295 | t78 = t50 + t51; t100 = MUL(t50 - t51, costab4); | 291 | t78 = t50 + t51; t100 = MUL(t50 - t51, costab4); |
296 | t79 = t52 + t53; t101 = MUL(t52 - t53, costab28); | 292 | t79 = t52 + t53; t101 = MUL(t52 - t53, costab28); |
297 | t80 = t54 + t55; t102 = MUL(t54 - t55, costab12); | 293 | t80 = t54 + t55; t102 = MUL(t54 - t55, costab12); |
298 | t81 = t56 + t57; t103 = MUL(t56 - t57, costab20); | 294 | t81 = t56 + t57; t103 = MUL(t56 - t57, costab20); |
299 | 295 | ||
300 | t83 = t59 + t60; t106 = MUL(t59 - t60, costab4); | 296 | t83 = t59 + t60; t106 = MUL(t59 - t60, costab4); |
301 | t84 = t61 + t62; t107 = MUL(t61 - t62, costab28); | 297 | t84 = t61 + t62; t107 = MUL(t61 - t62, costab28); |
302 | t85 = t63 + t64; t108 = MUL(t63 - t64, costab12); | 298 | t85 = t63 + t64; t108 = MUL(t63 - t64, costab12); |
303 | t86 = t65 + t66; t109 = MUL(t65 - t66, costab20); | 299 | t86 = t65 + t66; t109 = MUL(t65 - t66, costab20); |
304 | 300 | ||
305 | t113 = t69 + t70; | 301 | t113 = t69 + t70; |
306 | t114 = t71 + t72; | 302 | t114 = t71 + t72; |
307 | 303 | ||
308 | /* 0 */ hi[15][slot] = SHIFT(t113 + t114); | 304 | /* 0 */ hi[15][slot] = SHIFT(t113 + t114); |
309 | /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16)); | 305 | /* 16 */ lo[ 0][slot] = SHIFT(MUL(t113 - t114, costab16)); |
310 | 306 | ||
311 | t115 = t73 + t74; | 307 | t115 = t73 + t74; |
312 | t116 = t75 + t76; | 308 | t116 = t75 + t76; |
313 | 309 | ||
314 | t32 = t115 + t116; | 310 | t32 = t115 + t116; |
315 | 311 | ||
316 | /* 1 */ hi[14][slot] = SHIFT(t32); | 312 | /* 1 */ hi[14][slot] = SHIFT(t32); |
317 | 313 | ||
318 | t118 = t78 + t79; | 314 | t118 = t78 + t79; |
319 | t119 = t80 + t81; | 315 | t119 = t80 + t81; |
320 | 316 | ||
321 | t58 = t118 + t119; | 317 | t58 = t118 + t119; |
322 | 318 | ||
323 | /* 2 */ hi[13][slot] = SHIFT(t58); | 319 | /* 2 */ hi[13][slot] = SHIFT(t58); |
324 | 320 | ||
325 | t121 = t83 + t84; | 321 | t121 = t83 + t84; |
326 | t122 = t85 + t86; | 322 | t122 = t85 + t86; |
327 | 323 | ||
328 | t67 = t121 + t122; | 324 | t67 = t121 + t122; |
329 | 325 | ||
330 | t49 = (t67 << 1) - t32; | 326 | t49 = (t67 * 2) - t32; |
331 | 327 | ||
332 | /* 3 */ hi[12][slot] = SHIFT(t49); | 328 | /* 3 */ hi[12][slot] = SHIFT(t49); |
333 | 329 | ||
334 | t125 = t89 + t90; | 330 | t125 = t89 + t90; |
335 | t126 = t91 + t92; | 331 | t126 = t91 + t92; |
336 | 332 | ||
337 | t93 = t125 + t126; | 333 | t93 = t125 + t126; |
338 | 334 | ||
339 | /* 4 */ hi[11][slot] = SHIFT(t93); | 335 | /* 4 */ hi[11][slot] = SHIFT(t93); |
340 | 336 | ||
341 | t128 = t94 + t95; | 337 | t128 = t94 + t95; |
342 | t129 = t96 + t97; | 338 | t129 = t96 + t97; |
343 | 339 | ||
344 | t98 = t128 + t129; | 340 | t98 = t128 + t129; |
345 | 341 | ||
346 | t68 = (t98 << 1) - t49; | 342 | t68 = (t98 * 2) - t49; |
347 | 343 | ||
348 | /* 5 */ hi[10][slot] = SHIFT(t68); | 344 | /* 5 */ hi[10][slot] = SHIFT(t68); |
349 | 345 | ||
350 | t132 = t100 + t101; | 346 | t132 = t100 + t101; |
351 | t133 = t102 + t103; | 347 | t133 = t102 + t103; |
352 | 348 | ||
353 | t104 = t132 + t133; | 349 | t104 = t132 + t133; |
354 | 350 | ||
355 | t82 = (t104 << 1) - t58; | 351 | t82 = (t104 * 2) - t58; |
356 | 352 | ||
357 | /* 6 */ hi[ 9][slot] = SHIFT(t82); | 353 | /* 6 */ hi[ 9][slot] = SHIFT(t82); |
358 | 354 | ||
359 | t136 = t106 + t107; | 355 | t136 = t106 + t107; |
360 | t137 = t108 + t109; | 356 | t137 = t108 + t109; |
361 | 357 | ||
362 | t110 = t136 + t137; | 358 | t110 = t136 + t137; |
363 | 359 | ||
364 | t87 = (t110 << 1) - t67; | 360 | t87 = (t110 * 2) - t67; |
365 | 361 | ||
366 | t77 = (t87 << 1) - t68; | 362 | t77 = (t87 * 2) - t68; |
367 | 363 | ||
368 | /* 7 */ hi[ 8][slot] = SHIFT(t77); | 364 | /* 7 */ hi[ 8][slot] = SHIFT(t77); |
369 | 365 | ||
370 | t141 = MUL(t69 - t70, costab8); | 366 | t141 = MUL(t69 - t70, costab8); |
371 | t142 = MUL(t71 - t72, costab24); | 367 | t142 = MUL(t71 - t72, costab24); |
372 | t143 = t141 + t142; | 368 | t143 = t141 + t142; |
373 | 369 | ||
374 | /* 8 */ hi[ 7][slot] = SHIFT(t143); | 370 | /* 8 */ hi[ 7][slot] = SHIFT(t143); |
375 | /* 24 */ lo[ 8][slot] = | 371 | /* 24 */ lo[ 8][slot] = |
376 | SHIFT((MUL(t141 - t142, costab16) << 1) - t143); | 372 | SHIFT((MUL(t141 - t142, costab16) * 2) - t143); |
377 | 373 | ||
378 | t144 = MUL(t73 - t74, costab8); | 374 | t144 = MUL(t73 - t74, costab8); |
379 | t145 = MUL(t75 - t76, costab24); | 375 | t145 = MUL(t75 - t76, costab24); |
380 | t146 = t144 + t145; | 376 | t146 = t144 + t145; |
381 | 377 | ||
382 | t88 = (t146 << 1) - t77; | 378 | t88 = (t146 * 2) - t77; |
383 | 379 | ||
384 | /* 9 */ hi[ 6][slot] = SHIFT(t88); | 380 | /* 9 */ hi[ 6][slot] = SHIFT(t88); |
385 | 381 | ||
386 | t148 = MUL(t78 - t79, costab8); | 382 | t148 = MUL(t78 - t79, costab8); |
387 | t149 = MUL(t80 - t81, costab24); | 383 | t149 = MUL(t80 - t81, costab24); |
388 | t150 = t148 + t149; | 384 | t150 = t148 + t149; |
389 | 385 | ||
390 | t105 = (t150 << 1) - t82; | 386 | t105 = (t150 * 2) - t82; |
391 | 387 | ||
392 | /* 10 */ hi[ 5][slot] = SHIFT(t105); | 388 | /* 10 */ hi[ 5][slot] = SHIFT(t105); |
393 | 389 | ||
394 | t152 = MUL(t83 - t84, costab8); | 390 | t152 = MUL(t83 - t84, costab8); |
395 | t153 = MUL(t85 - t86, costab24); | 391 | t153 = MUL(t85 - t86, costab24); |
396 | t154 = t152 + t153; | 392 | t154 = t152 + t153; |
397 | 393 | ||
398 | t111 = (t154 << 1) - t87; | 394 | t111 = (t154 * 2) - t87; |
399 | 395 | ||
400 | t99 = (t111 << 1) - t88; | 396 | t99 = (t111 * 2) - t88; |
401 | 397 | ||
402 | /* 11 */ hi[ 4][slot] = SHIFT(t99); | 398 | /* 11 */ hi[ 4][slot] = SHIFT(t99); |
403 | 399 | ||
404 | t157 = MUL(t89 - t90, costab8); | 400 | t157 = MUL(t89 - t90, costab8); |
405 | t158 = MUL(t91 - t92, costab24); | 401 | t158 = MUL(t91 - t92, costab24); |
406 | t159 = t157 + t158; | 402 | t159 = t157 + t158; |
407 | 403 | ||
408 | t127 = (t159 << 1) - t93; | 404 | t127 = (t159 * 2) - t93; |
409 | 405 | ||
410 | /* 12 */ hi[ 3][slot] = SHIFT(t127); | 406 | /* 12 */ hi[ 3][slot] = SHIFT(t127); |
411 | 407 | ||
412 | t160 = (MUL(t125 - t126, costab16) << 1) - t127; | 408 | t160 = (MUL(t125 - t126, costab16) * 2) - t127; |
413 | 409 | ||
414 | /* 20 */ lo[ 4][slot] = SHIFT(t160); | 410 | /* 20 */ lo[ 4][slot] = SHIFT(t160); |
415 | /* 28 */ lo[12][slot] = | 411 | /* 28 */ lo[12][slot] = |
416 | SHIFT((((MUL(t157 - t158, costab16) << 1) - t159) << 1) - t160); | 412 | SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160); |
417 | 413 | ||
418 | t161 = MUL(t94 - t95, costab8); | 414 | t161 = MUL(t94 - t95, costab8); |
419 | t162 = MUL(t96 - t97, costab24); | 415 | t162 = MUL(t96 - t97, costab24); |
420 | t163 = t161 + t162; | 416 | t163 = t161 + t162; |
421 | 417 | ||
422 | t130 = (t163 << 1) - t98; | 418 | t130 = (t163 * 2) - t98; |
423 | 419 | ||
424 | t112 = (t130 << 1) - t99; | 420 | t112 = (t130 * 2) - t99; |
425 | 421 | ||
426 | /* 13 */ hi[ 2][slot] = SHIFT(t112); | 422 | /* 13 */ hi[ 2][slot] = SHIFT(t112); |
427 | 423 | ||
428 | t164 = (MUL(t128 - t129, costab16) << 1) - t130; | 424 | t164 = (MUL(t128 - t129, costab16) * 2) - t130; |
429 | 425 | ||
430 | t166 = MUL(t100 - t101, costab8); | 426 | t166 = MUL(t100 - t101, costab8); |
431 | t167 = MUL(t102 - t103, costab24); | 427 | t167 = MUL(t102 - t103, costab24); |
432 | t168 = t166 + t167; | 428 | t168 = t166 + t167; |
433 | 429 | ||
434 | t134 = (t168 << 1) - t104; | 430 | t134 = (t168 * 2) - t104; |
435 | 431 | ||
436 | t120 = (t134 << 1) - t105; | 432 | t120 = (t134 * 2) - t105; |
437 | 433 | ||
438 | /* 14 */ hi[ 1][slot] = SHIFT(t120); | 434 | /* 14 */ hi[ 1][slot] = SHIFT(t120); |
439 | 435 | ||
440 | t135 = (MUL(t118 - t119, costab16) << 1) - t120; | 436 | t135 = (MUL(t118 - t119, costab16) * 2) - t120; |
441 | 437 | ||
442 | /* 18 */ lo[ 2][slot] = SHIFT(t135); | 438 | /* 18 */ lo[ 2][slot] = SHIFT(t135); |
443 | 439 | ||
444 | t169 = (MUL(t132 - t133, costab16) << 1) - t134; | 440 | t169 = (MUL(t132 - t133, costab16) * 2) - t134; |
445 | 441 | ||
446 | t151 = (t169 << 1) - t135; | 442 | t151 = (t169 * 2) - t135; |
447 | 443 | ||
448 | /* 22 */ lo[ 6][slot] = SHIFT(t151); | 444 | /* 22 */ lo[ 6][slot] = SHIFT(t151); |
449 | 445 | ||
450 | t170 = (((MUL(t148 - t149, costab16) << 1) - t150) << 1) - t151; | 446 | t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151; |
451 | 447 | ||
452 | /* 26 */ lo[10][slot] = SHIFT(t170); | 448 | /* 26 */ lo[10][slot] = SHIFT(t170); |
453 | /* 30 */ lo[14][slot] = | 449 | /* 30 */ lo[14][slot] = |
454 | SHIFT((((((MUL(t166 - t167, costab16) << 1) - | 450 | SHIFT((((((MUL(t166 - t167, costab16) * 2) - |
455 | t168) << 1) - t169) << 1) - t170); | 451 | t168) * 2) - t169) * 2) - t170); |
456 | 452 | ||
457 | t171 = MUL(t106 - t107, costab8); | 453 | t171 = MUL(t106 - t107, costab8); |
458 | t172 = MUL(t108 - t109, costab24); | 454 | t172 = MUL(t108 - t109, costab24); |
459 | t173 = t171 + t172; | 455 | t173 = t171 + t172; |
460 | 456 | ||
461 | t138 = (t173 << 1) - t110; | 457 | t138 = (t173 * 2) - t110; |
462 | 458 | ||
463 | t123 = (t138 << 1) - t111; | 459 | t123 = (t138 * 2) - t111; |
464 | 460 | ||
465 | t139 = (MUL(t121 - t122, costab16) << 1) - t123; | 461 | t139 = (MUL(t121 - t122, costab16) * 2) - t123; |
466 | 462 | ||
467 | t117 = (t123 << 1) - t112; | 463 | t117 = (t123 * 2) - t112; |
468 | 464 | ||
469 | /* 15 */ hi[ 0][slot] = SHIFT(t117); | 465 | /* 15 */ hi[ 0][slot] = SHIFT(t117); |
470 | 466 | ||
471 | t124 = (MUL(t115 - t116, costab16) << 1) - t117; | 467 | t124 = (MUL(t115 - t116, costab16) * 2) - t117; |
472 | 468 | ||
473 | /* 17 */ lo[ 1][slot] = SHIFT(t124); | 469 | /* 17 */ lo[ 1][slot] = SHIFT(t124); |
474 | 470 | ||
475 | t131 = (t139 << 1) - t124; | 471 | t131 = (t139 * 2) - t124; |
476 | 472 | ||
477 | /* 19 */ lo[ 3][slot] = SHIFT(t131); | 473 | /* 19 */ lo[ 3][slot] = SHIFT(t131); |
478 | 474 | ||
479 | t140 = (t164 << 1) - t131; | 475 | t140 = (t164 * 2) - t131; |
480 | 476 | ||
481 | /* 21 */ lo[ 5][slot] = SHIFT(t140); | 477 | /* 21 */ lo[ 5][slot] = SHIFT(t140); |
482 | 478 | ||
483 | t174 = (MUL(t136 - t137, costab16) << 1) - t138; | 479 | t174 = (MUL(t136 - t137, costab16) * 2) - t138; |
484 | 480 | ||
485 | t155 = (t174 << 1) - t139; | 481 | t155 = (t174 * 2) - t139; |
486 | 482 | ||
487 | t147 = (t155 << 1) - t140; | 483 | t147 = (t155 * 2) - t140; |
488 | 484 | ||
489 | /* 23 */ lo[ 7][slot] = SHIFT(t147); | 485 | /* 23 */ lo[ 7][slot] = SHIFT(t147); |
490 | 486 | ||
491 | t156 = (((MUL(t144 - t145, costab16) << 1) - t146) << 1) - t147; | 487 | t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147; |
492 | 488 | ||
493 | /* 25 */ lo[ 9][slot] = SHIFT(t156); | 489 | /* 25 */ lo[ 9][slot] = SHIFT(t156); |
494 | 490 | ||
495 | t175 = (((MUL(t152 - t153, costab16) << 1) - t154) << 1) - t155; | 491 | t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155; |
496 | 492 | ||
497 | t165 = (t175 << 1) - t156; | 493 | t165 = (t175 * 2) - t156; |
498 | 494 | ||
499 | /* 27 */ lo[11][slot] = SHIFT(t165); | 495 | /* 27 */ lo[11][slot] = SHIFT(t165); |
500 | 496 | ||
501 | t176 = (((((MUL(t161 - t162, costab16) << 1) - | 497 | t176 = (((((MUL(t161 - t162, costab16) * 2) - |
502 | t163) << 1) - t164) << 1) - t165; | 498 | t163) * 2) - t164) * 2) - t165; |
503 | 499 | ||
504 | /* 29 */ lo[13][slot] = SHIFT(t176); | 500 | /* 29 */ lo[13][slot] = SHIFT(t176); |
505 | /* 31 */ lo[15][slot] = | 501 | /* 31 */ lo[15][slot] = |
506 | SHIFT((((((((MUL(t171 - t172, costab16) << 1) - | 502 | SHIFT((((((((MUL(t171 - t172, costab16) * 2) - |
507 | t173) << 1) - t174) << 1) - t175) << 1) - t176); | 503 | t173) * 2) - t174) * 2) - t175) * 2) - t176); |
508 | 504 | ||
509 | /* | 505 | /* |
510 | * Totals: | 506 | * Totals: |
511 | * 80 multiplies | 507 | * 80 multiplies |
512 | * 80 additions | 508 | * 80 additions |
513 | * 119 subtractions | 509 | * 119 subtractions |
514 | * 49 shifts (not counting SSO) | 510 | * 49 shifts (not counting SSO) |
515 | */ | 511 | */ |
516 | } | 512 | } |
517 | 513 | ||
518 | # undef MUL | 514 | # undef MUL |
519 | # undef SHIFT | 515 | # undef SHIFT |
520 | 516 | ||
521 | /* third SSO shift and/or D[] optimization preshift */ | 517 | /* third SSO shift and/or D[] optimization preshift */ |
522 | 518 | ||
523 | # if defined(OPT_SSO) | 519 | # if defined(OPT_SSO) |
524 | # if MAD_F_FRACBITS != 28 | 520 | # if MAD_F_FRACBITS != 28 |
525 | # error "MAD_F_FRACBITS must be 28 to use OPT_SSO" | 521 | # error "MAD_F_FRACBITS must be 28 to use OPT_SSO" |
526 | # endif | 522 | # endif |
527 | # define ML0(hi, lo, x, y)((lo) = (x) * (y)) | 523 | # define ML0(hi, lo, x, y)((lo) = (x) * (y)) |
528 | # define MLA(hi, lo, x, y)((lo) += (x) * (y)) | 524 | # define MLA(hi, lo, x, y)((lo) += (x) * (y)) |
525 | # define MLN(hi, lo) ((lo) = -(lo)) | ||
529 | # define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) | 526 | # define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo)) |
530 | # define SHIFT(x) ((x) >> 2) | 527 | # define SHIFT(x) ((x) >> 2) |
531 | # define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) | 528 | # define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14) |
532 | # else | 529 | # else |
533 | # define ML0(hi, lo, x, y)MAD_F_ML0((hi), (lo), (x), (y)) | 530 | # define ML0(hi, lo, x, y)MAD_F_ML0((hi), (lo), (x), (y)) |
534 | # define MLA(hi, lo, x, y)MAD_F_MLA((hi), (lo), (x), (y)) | 531 | # define MLA(hi, lo, x, y)MAD_F_MLA((hi), (lo), (x), (y)) |
532 | # define MLN(hi, lo) MAD_F_MLN((hi), (lo)) | ||
535 | # define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) | 533 | # define MLZ(hi, lo) MAD_F_MLZ((hi), (lo)) |
536 | # define SHIFT(x) (x) | 534 | # define SHIFT(x) (x) |
537 | # if defined(MAD_F_SCALEBITS) | 535 | # if defined(MAD_F_SCALEBITS) |
538 | # undef MAD_F_SCALEBITS | 536 | # undef MAD_F_SCALEBITS |
539 | # define MAD_F_SCALEBITS(MAD_F_FRACBITS - 12) | 537 | # define MAD_F_SCALEBITS(MAD_F_FRACBITS - 12) |
540 | # define PRESHIFT(x) (MAD_F(x) >> 12) | 538 | # define PRESHIFT(x) (MAD_F(x) >> 12) |
541 | # else | 539 | # else |
542 | # define PRESHIFT(x) MAD_F(x) | 540 | # define PRESHIFT(x) MAD_F(x) |
543 | # endif | 541 | # endif |
544 | # endif | 542 | # endif |
545 | 543 | ||
546 | static | 544 | static |
547 | mad_fixed_t const D[17][32] = { | 545 | mad_fixed_t const D[17][32] = { |
548 | # include "D.dat" | 546 | # include "D.dat" |
549 | }; | 547 | }; |
550 | 548 | ||
551 | # if defined(ASO_SYNTH) | 549 | # if defined(ASO_SYNTH) |
552 | void synth_full(struct mad_synth *, struct mad_frame const *, | 550 | void synth_full(struct mad_synth *, struct mad_frame const *, |
553 | unsigned int, unsigned int); | 551 | unsigned int, unsigned int); |
554 | # else | 552 | # else |
555 | /* | 553 | /* |
556 | * NAME:synth->full() | 554 | * NAME:synth->full() |
557 | * DESCRIPTION:perform full frequency PCM synthesis | 555 | * DESCRIPTION:perform full frequency PCM synthesis |
558 | */ | 556 | */ |
559 | static | 557 | static |
560 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | 558 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, |
561 | unsigned int nch, unsigned int ns) | 559 | unsigned int nch, unsigned int ns) |
562 | { | 560 | { |
563 | unsigned int phase, ch, s, sb, pe, po; | 561 | unsigned int phase, ch, s, sb, pe, po; |
564 | mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; | 562 | mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; |
565 | mad_fixed_t const (*sbsample)[36][32]; | 563 | mad_fixed_t const (*sbsample)[36][32]; |
566 | register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; | 564 | register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; |
567 | register mad_fixed_t const (*Dptr)[32], *ptr; | 565 | register mad_fixed_t const (*Dptr)[32], *ptr; |
568 | register mad_fixed64hi_t hi; | 566 | register mad_fixed64hi_t hi; |
569 | register mad_fixed64lo_t lo; | 567 | register mad_fixed64lo_t lo; |
570 | 568 | ||
571 | for (ch = 0; ch < nch; ++ch) { | 569 | for (ch = 0; ch < nch; ++ch) { |
572 | sbsample = &frame->sbsample[ch]; | 570 | sbsample = &frame->sbsample[ch]; |
573 | filter = &synth->filter[ch]; | 571 | filter = &synth->filter[ch]; |
574 | phase = synth->phase; | 572 | phase = synth->phase; |
575 | pcm1 = synth->pcm.samples[ch]; | 573 | pcm1 = synth->pcm.samples[ch]; |
576 | 574 | ||
577 | for (s = 0; s < ns; ++s) { | 575 | for (s = 0; s < ns; ++s) { |
578 | dct32((*sbsample)[s], phase >> 1, | 576 | dct32((*sbsample)[s], phase >> 1, |
579 | (*filter)[0][phase & 1], (*filter)[1][phase & 1]); | 577 | (*filter)[0][phase & 1], (*filter)[1][phase & 1]); |
580 | 578 | ||
581 | pe = phase & ~1; | 579 | pe = phase & ~1; |
582 | po = ((phase - 1) & 0xf) | 1; | 580 | po = ((phase - 1) & 0xf) | 1; |
583 | 581 | ||
584 | /* calculate 32 samples */ | 582 | /* calculate 32 samples */ |
585 | 583 | ||
586 | fe = &(*filter)[0][ phase & 1][0]; | 584 | fe = &(*filter)[0][ phase & 1][0]; |
587 | fx = &(*filter)[0][~phase & 1][0]; | 585 | fx = &(*filter)[0][~phase & 1][0]; |
588 | fo = &(*filter)[1][~phase & 1][0]; | 586 | fo = &(*filter)[1][~phase & 1][0]; |
589 | 587 | ||
590 | Dptr = &D[0]; | 588 | Dptr = &D[0]; |
591 | 589 | ||
590 | ptr = *Dptr + po; | ||
591 | ML0(hi, lo, (*fx)[0], ptr[ 0]); | ||
592 | MLA(hi, lo, (*fx)[1], ptr[14]); | ||
593 | MLA(hi, lo, (*fx)[2], ptr[12]); | ||
594 | MLA(hi, lo, (*fx)[3], ptr[10]); | ||
595 | MLA(hi, lo, (*fx)[4], ptr[ 8]); | ||
596 | MLA(hi, lo, (*fx)[5], ptr[ 6]); | ||
597 | MLA(hi, lo, (*fx)[6], ptr[ 4]); | ||
598 | MLA(hi, lo, (*fx)[7], ptr[ 2]); | ||
599 | MLN(hi, lo); | ||
600 | |||
592 | ptr = *Dptr + pe; | 601 | ptr = *Dptr + pe; |
593 | ML0(hi, lo, (*fe)[0], ptr[ 0]); | 602 | MLA(hi, lo, (*fe)[0], ptr[ 0]); |
594 | MLA(hi, lo, (*fe)[1], ptr[14]); | 603 | MLA(hi, lo, (*fe)[1], ptr[14]); |
595 | MLA(hi, lo, (*fe)[2], ptr[12]); | 604 | MLA(hi, lo, (*fe)[2], ptr[12]); |
596 | MLA(hi, lo, (*fe)[3], ptr[10]); | 605 | MLA(hi, lo, (*fe)[3], ptr[10]); |
597 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | 606 | MLA(hi, lo, (*fe)[4], ptr[ 8]); |
598 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | 607 | MLA(hi, lo, (*fe)[5], ptr[ 6]); |
599 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | 608 | MLA(hi, lo, (*fe)[6], ptr[ 4]); |
600 | MLA(hi, lo, (*fe)[7], ptr[ 2]); | 609 | MLA(hi, lo, (*fe)[7], ptr[ 2]); |
601 | 610 | ||
602 | ptr = *Dptr + po; | ||
603 | MLA(hi, lo, (*fx)[0], -ptr[ 0]); | ||
604 | MLA(hi, lo, (*fx)[1], -ptr[14]); | ||
605 | MLA(hi, lo, (*fx)[2], -ptr[12]); | ||
606 | MLA(hi, lo, (*fx)[3], -ptr[10]); | ||
607 | MLA(hi, lo, (*fx)[4], -ptr[ 8]); | ||
608 | MLA(hi, lo, (*fx)[5], -ptr[ 6]); | ||
609 | MLA(hi, lo, (*fx)[6], -ptr[ 4]); | ||
610 | MLA(hi, lo, (*fx)[7], -ptr[ 2]); | ||
611 | |||
612 | *pcm1++ = SHIFT(MLZ(hi, lo)); | 611 | *pcm1++ = SHIFT(MLZ(hi, lo)); |
613 | 612 | ||
614 | pcm2 = pcm1 + 30; | 613 | pcm2 = pcm1 + 30; |
615 | 614 | ||
616 | for (sb = 1; sb < 16; ++sb) { | 615 | for (sb = 1; sb < 16; ++sb) { |
617 | ++fe; | 616 | ++fe; |
618 | ++Dptr; | 617 | ++Dptr; |
619 | 618 | ||
620 | /* D[32 - sb][i] == -D[sb][31 - i] */ | 619 | /* D[32 - sb][i] == -D[sb][31 - i] */ |
621 | 620 | ||
621 | ptr = *Dptr + po; | ||
622 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | ||
623 | MLA(hi, lo, (*fo)[1], ptr[14]); | ||
624 | MLA(hi, lo, (*fo)[2], ptr[12]); | ||
625 | MLA(hi, lo, (*fo)[3], ptr[10]); | ||
626 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | ||
627 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | ||
628 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | ||
629 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | ||
630 | MLN(hi, lo); | ||
631 | |||
622 | ptr = *Dptr + pe; | 632 | ptr = *Dptr + pe; |
623 | ML0(hi, lo, (*fe)[7], ptr[ 2]); | 633 | MLA(hi, lo, (*fe)[7], ptr[ 2]); |
624 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | 634 | MLA(hi, lo, (*fe)[6], ptr[ 4]); |
625 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | 635 | MLA(hi, lo, (*fe)[5], ptr[ 6]); |
626 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | 636 | MLA(hi, lo, (*fe)[4], ptr[ 8]); |
627 | MLA(hi, lo, (*fe)[3], ptr[10]); | 637 | MLA(hi, lo, (*fe)[3], ptr[10]); |
628 | MLA(hi, lo, (*fe)[2], ptr[12]); | 638 | MLA(hi, lo, (*fe)[2], ptr[12]); |
629 | MLA(hi, lo, (*fe)[1], ptr[14]); | 639 | MLA(hi, lo, (*fe)[1], ptr[14]); |
630 | MLA(hi, lo, (*fe)[0], ptr[ 0]); | 640 | MLA(hi, lo, (*fe)[0], ptr[ 0]); |
631 | 641 | ||
632 | ptr = *Dptr + po; | ||
633 | MLA(hi, lo, (*fo)[0], -ptr[ 0]); | ||
634 | MLA(hi, lo, (*fo)[1], -ptr[14]); | ||
635 | MLA(hi, lo, (*fo)[2], -ptr[12]); | ||
636 | MLA(hi, lo, (*fo)[3], -ptr[10]); | ||
637 | MLA(hi, lo, (*fo)[4], -ptr[ 8]); | ||
638 | MLA(hi, lo, (*fo)[5], -ptr[ 6]); | ||
639 | MLA(hi, lo, (*fo)[6], -ptr[ 4]); | ||
640 | MLA(hi, lo, (*fo)[7], -ptr[ 2]); | ||
641 | |||
642 | *pcm1++ = SHIFT(MLZ(hi, lo)); | 642 | *pcm1++ = SHIFT(MLZ(hi, lo)); |
643 | 643 | ||
644 | ptr = *Dptr - po; | ||
645 | ML0(hi, lo, (*fo)[7], ptr[31 - 2]); | ||
646 | MLA(hi, lo, (*fo)[6], ptr[31 - 4]); | ||
647 | MLA(hi, lo, (*fo)[5], ptr[31 - 6]); | ||
648 | MLA(hi, lo, (*fo)[4], ptr[31 - 8]); | ||
649 | MLA(hi, lo, (*fo)[3], ptr[31 - 10]); | ||
650 | MLA(hi, lo, (*fo)[2], ptr[31 - 12]); | ||
651 | MLA(hi, lo, (*fo)[1], ptr[31 - 14]); | ||
652 | MLA(hi, lo, (*fo)[0], ptr[31 - 16]); | ||
653 | |||
654 | ptr = *Dptr - pe; | 644 | ptr = *Dptr - pe; |
655 | MLA(hi, lo, (*fe)[0], ptr[31 - 16]); | 645 | ML0(hi, lo, (*fe)[0], ptr[31 - 16]); |
656 | MLA(hi, lo, (*fe)[1], ptr[31 - 14]); | 646 | MLA(hi, lo, (*fe)[1], ptr[31 - 14]); |
657 | MLA(hi, lo, (*fe)[2], ptr[31 - 12]); | 647 | MLA(hi, lo, (*fe)[2], ptr[31 - 12]); |
658 | MLA(hi, lo, (*fe)[3], ptr[31 - 10]); | 648 | MLA(hi, lo, (*fe)[3], ptr[31 - 10]); |
659 | MLA(hi, lo, (*fe)[4], ptr[31 - 8]); | 649 | MLA(hi, lo, (*fe)[4], ptr[31 - 8]); |
660 | MLA(hi, lo, (*fe)[5], ptr[31 - 6]); | 650 | MLA(hi, lo, (*fe)[5], ptr[31 - 6]); |
661 | MLA(hi, lo, (*fe)[6], ptr[31 - 4]); | 651 | MLA(hi, lo, (*fe)[6], ptr[31 - 4]); |
662 | MLA(hi, lo, (*fe)[7], ptr[31 - 2]); | 652 | MLA(hi, lo, (*fe)[7], ptr[31 - 2]); |
663 | 653 | ||
654 | ptr = *Dptr - po; | ||
655 | MLA(hi, lo, (*fo)[7], ptr[31 - 2]); | ||
656 | MLA(hi, lo, (*fo)[6], ptr[31 - 4]); | ||
657 | MLA(hi, lo, (*fo)[5], ptr[31 - 6]); | ||
658 | MLA(hi, lo, (*fo)[4], ptr[31 - 8]); | ||
659 | MLA(hi, lo, (*fo)[3], ptr[31 - 10]); | ||
660 | MLA(hi, lo, (*fo)[2], ptr[31 - 12]); | ||
661 | MLA(hi, lo, (*fo)[1], ptr[31 - 14]); | ||
662 | MLA(hi, lo, (*fo)[0], ptr[31 - 16]); | ||
663 | |||
664 | *pcm2-- = SHIFT(MLZ(hi, lo)); | 664 | *pcm2-- = SHIFT(MLZ(hi, lo)); |
665 | 665 | ||
666 | ++fo; | 666 | ++fo; |
667 | } | 667 | } |
668 | 668 | ||
669 | ++Dptr; | 669 | ++Dptr; |
670 | 670 | ||
671 | ptr = *Dptr + po; | 671 | ptr = *Dptr + po; |
672 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | 672 | ML0(hi, lo, (*fo)[0], ptr[ 0]); |
673 | MLA(hi, lo, (*fo)[1], ptr[14]); | 673 | MLA(hi, lo, (*fo)[1], ptr[14]); |
674 | MLA(hi, lo, (*fo)[2], ptr[12]); | 674 | MLA(hi, lo, (*fo)[2], ptr[12]); |
675 | MLA(hi, lo, (*fo)[3], ptr[10]); | 675 | MLA(hi, lo, (*fo)[3], ptr[10]); |
676 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | 676 | MLA(hi, lo, (*fo)[4], ptr[ 8]); |
677 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | 677 | MLA(hi, lo, (*fo)[5], ptr[ 6]); |
678 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | 678 | MLA(hi, lo, (*fo)[6], ptr[ 4]); |
679 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | 679 | MLA(hi, lo, (*fo)[7], ptr[ 2]); |
680 | 680 | ||
681 | *pcm1 = SHIFT(-MLZ(hi, lo)); | 681 | *pcm1 = SHIFT(-MLZ(hi, lo)); |
682 | pcm1 += 16; | 682 | pcm1 += 16; |
683 | 683 | ||
684 | phase = (phase + 1) % 16; | 684 | phase = (phase + 1) % 16; |
685 | } | 685 | } |
686 | } | 686 | } |
687 | } | 687 | } |
688 | # endif | 688 | # endif |
689 | 689 | ||
690 | /* | 690 | /* |
691 | * NAME:synth->half() | 691 | * NAME:synth->half() |
692 | * DESCRIPTION:perform half frequency PCM synthesis | 692 | * DESCRIPTION:perform half frequency PCM synthesis |
693 | */ | 693 | */ |
694 | static | 694 | static |
695 | void synth_half(struct mad_synth *synth, struct mad_frame const *frame, | 695 | void synth_half(struct mad_synth *synth, struct mad_frame const *frame, |
696 | unsigned int nch, unsigned int ns) | 696 | unsigned int nch, unsigned int ns) |
697 | { | 697 | { |
698 | unsigned int phase, ch, s, sb, pe, po; | 698 | unsigned int phase, ch, s, sb, pe, po; |
699 | mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; | 699 | mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8]; |
700 | mad_fixed_t const (*sbsample)[36][32]; | 700 | mad_fixed_t const (*sbsample)[36][32]; |
701 | register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; | 701 | register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8]; |
702 | register mad_fixed_t const (*Dptr)[32], *ptr; | 702 | register mad_fixed_t const (*Dptr)[32], *ptr; |
703 | register mad_fixed64hi_t hi; | 703 | register mad_fixed64hi_t hi; |
704 | register mad_fixed64lo_t lo; | 704 | register mad_fixed64lo_t lo; |
705 | 705 | ||
706 | for (ch = 0; ch < nch; ++ch) { | 706 | for (ch = 0; ch < nch; ++ch) { |
707 | sbsample = &frame->sbsample[ch]; | 707 | sbsample = &frame->sbsample[ch]; |
708 | filter = &synth->filter[ch]; | 708 | filter = &synth->filter[ch]; |
709 | phase = synth->phase; | 709 | phase = synth->phase; |
710 | pcm1 = synth->pcm.samples[ch]; | 710 | pcm1 = synth->pcm.samples[ch]; |
711 | 711 | ||
712 | for (s = 0; s < ns; ++s) { | 712 | for (s = 0; s < ns; ++s) { |
713 | dct32((*sbsample)[s], phase >> 1, | 713 | dct32((*sbsample)[s], phase >> 1, |
714 | (*filter)[0][phase & 1], (*filter)[1][phase & 1]); | 714 | (*filter)[0][phase & 1], (*filter)[1][phase & 1]); |
715 | 715 | ||
716 | pe = phase & ~1; | 716 | pe = phase & ~1; |
717 | po = ((phase - 1) & 0xf) | 1; | 717 | po = ((phase - 1) & 0xf) | 1; |
718 | 718 | ||
719 | /* calculate 16 samples */ | 719 | /* calculate 16 samples */ |
720 | 720 | ||
721 | fe = &(*filter)[0][ phase & 1][0]; | 721 | fe = &(*filter)[0][ phase & 1][0]; |
722 | fx = &(*filter)[0][~phase & 1][0]; | 722 | fx = &(*filter)[0][~phase & 1][0]; |
723 | fo = &(*filter)[1][~phase & 1][0]; | 723 | fo = &(*filter)[1][~phase & 1][0]; |
724 | 724 | ||
725 | Dptr = &D[0]; | 725 | Dptr = &D[0]; |
726 | 726 | ||
727 | ptr = *Dptr + po; | ||
728 | ML0(hi, lo, (*fx)[0], ptr[ 0]); | ||
729 | MLA(hi, lo, (*fx)[1], ptr[14]); | ||
730 | MLA(hi, lo, (*fx)[2], ptr[12]); | ||
731 | MLA(hi, lo, (*fx)[3], ptr[10]); | ||
732 | MLA(hi, lo, (*fx)[4], ptr[ 8]); | ||
733 | MLA(hi, lo, (*fx)[5], ptr[ 6]); | ||
734 | MLA(hi, lo, (*fx)[6], ptr[ 4]); | ||
735 | MLA(hi, lo, (*fx)[7], ptr[ 2]); | ||
736 | MLN(hi, lo); | ||
737 | |||
727 | ptr = *Dptr + pe; | 738 | ptr = *Dptr + pe; |
728 | ML0(hi, lo, (*fe)[0], ptr[ 0]); | 739 | MLA(hi, lo, (*fe)[0], ptr[ 0]); |
729 | MLA(hi, lo, (*fe)[1], ptr[14]); | 740 | MLA(hi, lo, (*fe)[1], ptr[14]); |
730 | MLA(hi, lo, (*fe)[2], ptr[12]); | 741 | MLA(hi, lo, (*fe)[2], ptr[12]); |
731 | MLA(hi, lo, (*fe)[3], ptr[10]); | 742 | MLA(hi, lo, (*fe)[3], ptr[10]); |
732 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | 743 | MLA(hi, lo, (*fe)[4], ptr[ 8]); |
733 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | 744 | MLA(hi, lo, (*fe)[5], ptr[ 6]); |
734 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | 745 | MLA(hi, lo, (*fe)[6], ptr[ 4]); |
735 | MLA(hi, lo, (*fe)[7], ptr[ 2]); | 746 | MLA(hi, lo, (*fe)[7], ptr[ 2]); |
736 | 747 | ||
737 | ptr = *Dptr + po; | ||
738 | MLA(hi, lo, (*fx)[0], -ptr[ 0]); | ||
739 | MLA(hi, lo, (*fx)[1], -ptr[14]); | ||
740 | MLA(hi, lo, (*fx)[2], -ptr[12]); | ||
741 | MLA(hi, lo, (*fx)[3], -ptr[10]); | ||
742 | MLA(hi, lo, (*fx)[4], -ptr[ 8]); | ||
743 | MLA(hi, lo, (*fx)[5], -ptr[ 6]); | ||
744 | MLA(hi, lo, (*fx)[6], -ptr[ 4]); | ||
745 | MLA(hi, lo, (*fx)[7], -ptr[ 2]); | ||
746 | |||
747 | *pcm1++ = SHIFT(MLZ(hi, lo)); | 748 | *pcm1++ = SHIFT(MLZ(hi, lo)); |
748 | 749 | ||
749 | pcm2 = pcm1 + 14; | 750 | pcm2 = pcm1 + 14; |
750 | 751 | ||
751 | for (sb = 1; sb < 16; ++sb) { | 752 | for (sb = 1; sb < 16; ++sb) { |
752 | ++fe; | 753 | ++fe; |
753 | ++Dptr; | 754 | ++Dptr; |
754 | 755 | ||
755 | /* D[32 - sb][i] == -D[sb][31 - i] */ | 756 | /* D[32 - sb][i] == -D[sb][31 - i] */ |
756 | 757 | ||
757 | if (!(sb & 1)) { | 758 | if (!(sb & 1)) { |
759 | ptr = *Dptr + po; | ||
760 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | ||
761 | MLA(hi, lo, (*fo)[1], ptr[14]); | ||
762 | MLA(hi, lo, (*fo)[2], ptr[12]); | ||
763 | MLA(hi, lo, (*fo)[3], ptr[10]); | ||
764 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | ||
765 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | ||
766 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | ||
767 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | ||
768 | MLN(hi, lo); | ||
769 | |||
758 | ptr = *Dptr + pe; | 770 | ptr = *Dptr + pe; |
759 | ML0(hi, lo, (*fe)[7], ptr[ 2]); | 771 | MLA(hi, lo, (*fe)[7], ptr[ 2]); |
760 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | 772 | MLA(hi, lo, (*fe)[6], ptr[ 4]); |
761 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | 773 | MLA(hi, lo, (*fe)[5], ptr[ 6]); |
762 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | 774 | MLA(hi, lo, (*fe)[4], ptr[ 8]); |
763 | MLA(hi, lo, (*fe)[3], ptr[10]); | 775 | MLA(hi, lo, (*fe)[3], ptr[10]); |
764 | MLA(hi, lo, (*fe)[2], ptr[12]); | 776 | MLA(hi, lo, (*fe)[2], ptr[12]); |
765 | MLA(hi, lo, (*fe)[1], ptr[14]); | 777 | MLA(hi, lo, (*fe)[1], ptr[14]); |
766 | MLA(hi, lo, (*fe)[0], ptr[ 0]); | 778 | MLA(hi, lo, (*fe)[0], ptr[ 0]); |
767 | 779 | ||
768 | ptr = *Dptr + po; | ||
769 | MLA(hi, lo, (*fo)[0], -ptr[ 0]); | ||
770 | MLA(hi, lo, (*fo)[1], -ptr[14]); | ||
771 | MLA(hi, lo, (*fo)[2], -ptr[12]); | ||
772 | MLA(hi, lo, (*fo)[3], -ptr[10]); | ||
773 | MLA(hi, lo, (*fo)[4], -ptr[ 8]); | ||
774 | MLA(hi, lo, (*fo)[5], -ptr[ 6]); | ||
775 | MLA(hi, lo, (*fo)[6], -ptr[ 4]); | ||
776 | MLA(hi, lo, (*fo)[7], -ptr[ 2]); | ||
777 | |||
778 | *pcm1++ = SHIFT(MLZ(hi, lo)); | 780 | *pcm1++ = SHIFT(MLZ(hi, lo)); |
779 | 781 | ||
780 | ptr = *Dptr - po; | 782 | ptr = *Dptr - po; |
781 | ML0(hi, lo, (*fo)[7], ptr[31 - 2]); | 783 | ML0(hi, lo, (*fo)[7], ptr[31 - 2]); |
782 | MLA(hi, lo, (*fo)[6], ptr[31 - 4]); | 784 | MLA(hi, lo, (*fo)[6], ptr[31 - 4]); |
783 | MLA(hi, lo, (*fo)[5], ptr[31 - 6]); | 785 | MLA(hi, lo, (*fo)[5], ptr[31 - 6]); |
784 | MLA(hi, lo, (*fo)[4], ptr[31 - 8]); | 786 | MLA(hi, lo, (*fo)[4], ptr[31 - 8]); |
785 | MLA(hi, lo, (*fo)[3], ptr[31 - 10]); | 787 | MLA(hi, lo, (*fo)[3], ptr[31 - 10]); |
786 | MLA(hi, lo, (*fo)[2], ptr[31 - 12]); | 788 | MLA(hi, lo, (*fo)[2], ptr[31 - 12]); |
787 | MLA(hi, lo, (*fo)[1], ptr[31 - 14]); | 789 | MLA(hi, lo, (*fo)[1], ptr[31 - 14]); |
788 | MLA(hi, lo, (*fo)[0], ptr[31 - 16]); | 790 | MLA(hi, lo, (*fo)[0], ptr[31 - 16]); |
789 | 791 | ||
790 | ptr = *Dptr - pe; | 792 | ptr = *Dptr - pe; |
791 | MLA(hi, lo, (*fe)[0], ptr[31 - 16]); | 793 | MLA(hi, lo, (*fe)[0], ptr[31 - 16]); |
792 | MLA(hi, lo, (*fe)[1], ptr[31 - 14]); | 794 | MLA(hi, lo, (*fe)[1], ptr[31 - 14]); |
793 | MLA(hi, lo, (*fe)[2], ptr[31 - 12]); | 795 | MLA(hi, lo, (*fe)[2], ptr[31 - 12]); |
794 | MLA(hi, lo, (*fe)[3], ptr[31 - 10]); | 796 | MLA(hi, lo, (*fe)[3], ptr[31 - 10]); |
795 | MLA(hi, lo, (*fe)[4], ptr[31 - 8]); | 797 | MLA(hi, lo, (*fe)[4], ptr[31 - 8]); |
796 | MLA(hi, lo, (*fe)[5], ptr[31 - 6]); | 798 | MLA(hi, lo, (*fe)[5], ptr[31 - 6]); |
797 | MLA(hi, lo, (*fe)[6], ptr[31 - 4]); | 799 | MLA(hi, lo, (*fe)[6], ptr[31 - 4]); |
798 | MLA(hi, lo, (*fe)[7], ptr[31 - 2]); | 800 | MLA(hi, lo, (*fe)[7], ptr[31 - 2]); |
799 | 801 | ||
800 | *pcm2-- = SHIFT(MLZ(hi, lo)); | 802 | *pcm2-- = SHIFT(MLZ(hi, lo)); |
801 | } | 803 | } |
802 | 804 | ||
803 | ++fo; | 805 | ++fo; |
804 | } | 806 | } |
805 | 807 | ||
806 | ++Dptr; | 808 | ++Dptr; |
807 | 809 | ||
808 | ptr = *Dptr + po; | 810 | ptr = *Dptr + po; |
809 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | 811 | ML0(hi, lo, (*fo)[0], ptr[ 0]); |
810 | MLA(hi, lo, (*fo)[1], ptr[14]); | 812 | MLA(hi, lo, (*fo)[1], ptr[14]); |
811 | MLA(hi, lo, (*fo)[2], ptr[12]); | 813 | MLA(hi, lo, (*fo)[2], ptr[12]); |
812 | MLA(hi, lo, (*fo)[3], ptr[10]); | 814 | MLA(hi, lo, (*fo)[3], ptr[10]); |
813 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | 815 | MLA(hi, lo, (*fo)[4], ptr[ 8]); |
814 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | 816 | MLA(hi, lo, (*fo)[5], ptr[ 6]); |
815 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | 817 | MLA(hi, lo, (*fo)[6], ptr[ 4]); |
816 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | 818 | MLA(hi, lo, (*fo)[7], ptr[ 2]); |
817 | 819 | ||
818 | *pcm1 = SHIFT(-MLZ(hi, lo)); | 820 | *pcm1 = SHIFT(-MLZ(hi, lo)); |
819 | pcm1 += 8; | 821 | pcm1 += 8; |
820 | 822 | ||
821 | phase = (phase + 1) % 16; | 823 | phase = (phase + 1) % 16; |
822 | } | 824 | } |
823 | } | 825 | } |
824 | } | 826 | } |
825 | 827 | ||
diff --git a/core/multimedia/opieplayer/libmad/synth.h b/core/multimedia/opieplayer/libmad/synth.h index 64f6a86..2c9d5c8 100644 --- a/core/multimedia/opieplayer/libmad/synth.h +++ b/core/multimedia/opieplayer/libmad/synth.h | |||
@@ -1,50 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_SYNTH_H | 22 | # ifndef LIBMAD_SYNTH_H |
23 | # define LIBMAD_SYNTH_H | 23 | # define LIBMAD_SYNTH_H |
24 | 24 | ||
25 | # include "fixed.h" | 25 | # include "fixed.h" |
26 | # include "frame.h" | 26 | # include "frame.h" |
27 | 27 | ||
28 | struct mad_pcm { | ||
29 | unsigned int samplerate; /* sampling frequency (Hz) */ | ||
30 | unsigned short channels; /* number of channels */ | ||
31 | unsigned short length; /* number of samples per channel */ | ||
32 | mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */ | ||
33 | }; | ||
34 | |||
28 | struct mad_synth { | 35 | struct mad_synth { |
29 | mad_fixed_t filter[2][2][2][16][8];/* polyphase filterbank outputs */ | 36 | mad_fixed_t filter[2][2][2][16][8];/* polyphase filterbank outputs */ |
30 | /* [ch][eo][peo][s][v] */ | 37 | /* [ch][eo][peo][s][v] */ |
31 | 38 | ||
32 | unsigned int phase; /* current processing phase */ | 39 | unsigned int phase; /* current processing phase */ |
33 | 40 | ||
34 | struct mad_pcm { | 41 | struct mad_pcm pcm; /* PCM output */ |
35 | unsigned int samplerate; /* sampling frequency (Hz) */ | 42 | }; |
36 | unsigned short channels; /* number of channels */ | 43 | |
37 | unsigned short length; /* number of samples per channel */ | 44 | /* single channel PCM selector */ |
38 | mad_fixed_t samples[2][1152];/* PCM output samples */ | 45 | enum { |
39 | } pcm; | 46 | MAD_PCM_CHANNEL_SINGLE = 0 |
47 | }; | ||
48 | |||
49 | /* dual channel PCM selector */ | ||
50 | enum { | ||
51 | MAD_PCM_CHANNEL_DUAL_1 = 0, | ||
52 | MAD_PCM_CHANNEL_DUAL_2 = 1 | ||
53 | }; | ||
54 | |||
55 | /* stereo PCM selector */ | ||
56 | enum { | ||
57 | MAD_PCM_CHANNEL_STEREO_LEFT = 0, | ||
58 | MAD_PCM_CHANNEL_STEREO_RIGHT = 1 | ||
40 | }; | 59 | }; |
41 | 60 | ||
42 | void mad_synth_init(struct mad_synth *); | 61 | void mad_synth_init(struct mad_synth *); |
43 | 62 | ||
44 | # define mad_synth_finish(synth) /* nothing */ | 63 | # define mad_synth_finish(synth) /* nothing */ |
45 | 64 | ||
46 | void mad_synth_mute(struct mad_synth *); | 65 | void mad_synth_mute(struct mad_synth *); |
47 | 66 | ||
48 | void mad_synth_frame(struct mad_synth *, struct mad_frame const *); | 67 | void mad_synth_frame(struct mad_synth *, struct mad_frame const *); |
49 | 68 | ||
50 | # endif | 69 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/timer.c b/core/multimedia/opieplayer/libmad/timer.c index b30680c..299fe0b 100644 --- a/core/multimedia/opieplayer/libmad/timer.c +++ b/core/multimedia/opieplayer/libmad/timer.c | |||
@@ -1,77 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include <stdio.h> | 28 | # include <stdio.h> |
29 | # include <assert.h> | 29 | |
30 | # ifdef HAVE_ASSERT_H | ||
31 | # include <assert.h> | ||
32 | # endif | ||
30 | 33 | ||
31 | # include "timer.h" | 34 | # include "timer.h" |
32 | 35 | ||
33 | mad_timer_t const mad_timer_zero = { 0, 0 }; | 36 | mad_timer_t const mad_timer_zero = { 0, 0 }; |
34 | 37 | ||
35 | /* | 38 | /* |
36 | * NAME:timer->compare() | 39 | * NAME:timer->compare() |
37 | * DESCRIPTION:indicate relative order of two timers | 40 | * DESCRIPTION:indicate relative order of two timers |
38 | */ | 41 | */ |
39 | int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) | 42 | int mad_timer_compare(mad_timer_t timer1, mad_timer_t timer2) |
40 | { | 43 | { |
41 | signed long diff; | 44 | signed long diff; |
42 | 45 | ||
43 | diff = timer1.seconds - timer2.seconds; | 46 | diff = timer1.seconds - timer2.seconds; |
44 | if (diff < 0) | 47 | if (diff < 0) |
45 | return -1; | 48 | return -1; |
46 | else if (diff > 0) | 49 | else if (diff > 0) |
47 | return +1; | 50 | return +1; |
48 | 51 | ||
49 | diff = timer1.fraction - timer2.fraction; | 52 | diff = timer1.fraction - timer2.fraction; |
50 | if (diff < 0) | 53 | if (diff < 0) |
51 | return -1; | 54 | return -1; |
52 | else if (diff > 0) | 55 | else if (diff > 0) |
53 | return +1; | 56 | return +1; |
54 | 57 | ||
55 | return 0; | 58 | return 0; |
56 | } | 59 | } |
57 | 60 | ||
58 | /* | 61 | /* |
59 | * NAME:timer->negate() | 62 | * NAME:timer->negate() |
60 | * DESCRIPTION:invert the sign of a timer | 63 | * DESCRIPTION:invert the sign of a timer |
61 | */ | 64 | */ |
62 | void mad_timer_negate(mad_timer_t *timer) | 65 | void mad_timer_negate(mad_timer_t *timer) |
63 | { | 66 | { |
64 | timer->seconds = -timer->seconds; | 67 | timer->seconds = -timer->seconds; |
65 | 68 | ||
66 | if (timer->fraction) { | 69 | if (timer->fraction) { |
67 | timer->seconds -= 1; | 70 | timer->seconds -= 1; |
68 | timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; | 71 | timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; |
69 | } | 72 | } |
70 | } | 73 | } |
71 | 74 | ||
72 | /* | 75 | /* |
73 | * NAME:timer->abs() | 76 | * NAME:timer->abs() |
74 | * DESCRIPTION:return the absolute value of a timer | 77 | * DESCRIPTION:return the absolute value of a timer |
75 | */ | 78 | */ |
76 | mad_timer_t mad_timer_abs(mad_timer_t timer) | 79 | mad_timer_t mad_timer_abs(mad_timer_t timer) |
77 | { | 80 | { |
@@ -105,329 +108,330 @@ unsigned long gcd(unsigned long num1, unsigned long num2) | |||
105 | tmp = num2; | 108 | tmp = num2; |
106 | num2 = num1 % num2; | 109 | num2 = num1 % num2; |
107 | num1 = tmp; | 110 | num1 = tmp; |
108 | } | 111 | } |
109 | 112 | ||
110 | return num1; | 113 | return num1; |
111 | } | 114 | } |
112 | 115 | ||
113 | /* | 116 | /* |
114 | * NAME:reduce_rational() | 117 | * NAME:reduce_rational() |
115 | * DESCRIPTION:convert rational expression to lowest terms | 118 | * DESCRIPTION:convert rational expression to lowest terms |
116 | */ | 119 | */ |
117 | static | 120 | static |
118 | void reduce_rational(unsigned long *numer, unsigned long *denom) | 121 | void reduce_rational(unsigned long *numer, unsigned long *denom) |
119 | { | 122 | { |
120 | unsigned long factor; | 123 | unsigned long factor; |
121 | 124 | ||
122 | factor = gcd(*numer, *denom); | 125 | factor = gcd(*numer, *denom); |
123 | 126 | ||
124 | assert(factor != 0); | 127 | assert(factor != 0); |
125 | 128 | ||
126 | *numer /= factor; | 129 | *numer /= factor; |
127 | *denom /= factor; | 130 | *denom /= factor; |
128 | } | 131 | } |
129 | 132 | ||
130 | /* | 133 | /* |
131 | * NAME:scale_rational() | 134 | * NAME:scale_rational() |
132 | * DESCRIPTION:solve numer/denom == ?/scale avoiding overflowing | 135 | * DESCRIPTION:solve numer/denom == ?/scale avoiding overflowing |
133 | */ | 136 | */ |
134 | static | 137 | static |
135 | unsigned long scale_rational(unsigned long numer, unsigned long denom, | 138 | unsigned long scale_rational(unsigned long numer, unsigned long denom, |
136 | unsigned long scale) | 139 | unsigned long scale) |
137 | { | 140 | { |
138 | reduce_rational(&numer, &denom); | 141 | reduce_rational(&numer, &denom); |
139 | reduce_rational(&scale, &denom); | 142 | reduce_rational(&scale, &denom); |
140 | 143 | ||
141 | assert(denom != 0); | 144 | assert(denom != 0); |
142 | 145 | ||
143 | if (denom < scale) | 146 | if (denom < scale) |
144 | return numer * (scale / denom) + numer * (scale % denom) / denom; | 147 | return numer * (scale / denom) + numer * (scale % denom) / denom; |
145 | if (denom < numer) | 148 | if (denom < numer) |
146 | return scale * (numer / denom) + scale * (numer % denom) / denom; | 149 | return scale * (numer / denom) + scale * (numer % denom) / denom; |
147 | 150 | ||
148 | return numer * scale / denom; | 151 | return numer * scale / denom; |
149 | } | 152 | } |
150 | 153 | ||
151 | /* | 154 | /* |
152 | * NAME:timer->set() | 155 | * NAME:timer->set() |
153 | * DESCRIPTION:set timer to specific value | 156 | * DESCRIPTION:set timer to specific (positive) value |
154 | */ | 157 | */ |
155 | void mad_timer_set(mad_timer_t *timer, unsigned long seconds, | 158 | void mad_timer_set(mad_timer_t *timer, unsigned long seconds, |
156 | unsigned long fraction, unsigned long fracparts) | 159 | unsigned long numer, unsigned long denom) |
157 | { | 160 | { |
158 | timer->seconds = seconds; | 161 | timer->seconds = seconds; |
159 | 162 | if (numer >= denom && denom > 0) { | |
160 | if (fraction == 0) | 163 | timer->seconds += numer / denom; |
161 | fracparts = 0; | 164 | numer %= denom; |
162 | else if (fracparts == 0) { | ||
163 | fracparts = fraction; | ||
164 | fraction = 1; | ||
165 | } | 165 | } |
166 | 166 | ||
167 | switch (fracparts) { | 167 | switch (denom) { |
168 | case 0: | 168 | case 0: |
169 | case 1: | ||
169 | timer->fraction = 0; | 170 | timer->fraction = 0; |
170 | break; | 171 | break; |
171 | 172 | ||
172 | case MAD_TIMER_RESOLUTION: | 173 | case MAD_TIMER_RESOLUTION: |
173 | timer->fraction = fraction; | 174 | timer->fraction = numer; |
175 | break; | ||
176 | |||
177 | case 1000: | ||
178 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 1000); | ||
174 | break; | 179 | break; |
175 | 180 | ||
176 | case 8000: | 181 | case 8000: |
177 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 8000); | 182 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 8000); |
178 | break; | 183 | break; |
179 | 184 | ||
180 | case 11025: | 185 | case 11025: |
181 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 11025); | 186 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 11025); |
182 | break; | 187 | break; |
183 | 188 | ||
184 | case 12000: | 189 | case 12000: |
185 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 12000); | 190 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 12000); |
186 | break; | 191 | break; |
187 | 192 | ||
188 | case 16000: | 193 | case 16000: |
189 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 16000); | 194 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 16000); |
190 | break; | 195 | break; |
191 | 196 | ||
192 | case 22050: | 197 | case 22050: |
193 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 22050); | 198 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 22050); |
194 | break; | 199 | break; |
195 | 200 | ||
196 | case 24000: | 201 | case 24000: |
197 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 24000); | 202 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 24000); |
198 | break; | 203 | break; |
199 | 204 | ||
200 | case 32000: | 205 | case 32000: |
201 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 32000); | 206 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 32000); |
202 | break; | 207 | break; |
203 | 208 | ||
204 | case 44100: | 209 | case 44100: |
205 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 44100); | 210 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 44100); |
206 | break; | 211 | break; |
207 | 212 | ||
208 | case 48000: | 213 | case 48000: |
209 | timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 48000); | 214 | timer->fraction = numer * (MAD_TIMER_RESOLUTION / 48000); |
210 | break; | 215 | break; |
211 | 216 | ||
212 | default: | 217 | default: |
213 | timer->fraction = | 218 | timer->fraction = scale_rational(numer, denom, MAD_TIMER_RESOLUTION); |
214 | scale_rational(fraction, fracparts, MAD_TIMER_RESOLUTION); | ||
215 | break; | 219 | break; |
216 | } | 220 | } |
217 | 221 | ||
218 | if (timer->fraction >= MAD_TIMER_RESOLUTION) | 222 | if (timer->fraction >= MAD_TIMER_RESOLUTION) |
219 | reduce_timer(timer); | 223 | reduce_timer(timer); |
220 | } | 224 | } |
221 | 225 | ||
222 | /* | 226 | /* |
223 | * NAME:timer->add() | 227 | * NAME:timer->add() |
224 | * DESCRIPTION:add one timer to another | 228 | * DESCRIPTION:add one timer to another |
225 | */ | 229 | */ |
226 | void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) | 230 | void mad_timer_add(mad_timer_t *timer, mad_timer_t incr) |
227 | { | 231 | { |
228 | timer->seconds += incr.seconds; | 232 | timer->seconds += incr.seconds; |
229 | timer->fraction += incr.fraction; | 233 | timer->fraction += incr.fraction; |
230 | 234 | ||
231 | if (timer->fraction >= MAD_TIMER_RESOLUTION) | 235 | if (timer->fraction >= MAD_TIMER_RESOLUTION) |
232 | reduce_timer(timer); | 236 | reduce_timer(timer); |
233 | } | 237 | } |
234 | 238 | ||
235 | /* | 239 | /* |
236 | * NAME:timer->multiply() | 240 | * NAME:timer->multiply() |
237 | * DESCRIPTION:multiply a timer by a scalar value | 241 | * DESCRIPTION:multiply a timer by a scalar value |
238 | */ | 242 | */ |
239 | void mad_timer_multiply(mad_timer_t *timer, signed long scalar) | 243 | void mad_timer_multiply(mad_timer_t *timer, signed long scalar) |
240 | { | 244 | { |
241 | mad_timer_t addend; | 245 | mad_timer_t addend; |
242 | unsigned long factor; | 246 | unsigned long factor; |
243 | 247 | ||
244 | factor = scalar; | 248 | factor = scalar; |
245 | if (scalar < 0) { | 249 | if (scalar < 0) { |
246 | mad_timer_negate(timer); | ||
247 | factor = -scalar; | 250 | factor = -scalar; |
251 | mad_timer_negate(timer); | ||
248 | } | 252 | } |
249 | 253 | ||
250 | addend = *timer; | 254 | addend = *timer; |
251 | *timer = mad_timer_zero; | 255 | *timer = mad_timer_zero; |
252 | 256 | ||
253 | while (factor) { | 257 | while (factor) { |
254 | if (factor & 1) | 258 | if (factor & 1) |
255 | mad_timer_add(timer, addend); | 259 | mad_timer_add(timer, addend); |
256 | 260 | ||
257 | mad_timer_add(&addend, addend); | 261 | mad_timer_add(&addend, addend); |
258 | factor >>= 1; | 262 | factor >>= 1; |
259 | } | 263 | } |
260 | } | 264 | } |
261 | 265 | ||
262 | /* | 266 | /* |
263 | * NAME:timer->count() | 267 | * NAME:timer->count() |
264 | * DESCRIPTION:return timer value in selected units | 268 | * DESCRIPTION:return timer value in selected units |
265 | */ | 269 | */ |
266 | signed long mad_timer_count(mad_timer_t timer, enum mad_units units) | 270 | signed long mad_timer_count(mad_timer_t timer, enum mad_units units) |
267 | { | 271 | { |
268 | switch (units) { | 272 | switch (units) { |
269 | case MAD_UNITS_HOURS: | 273 | case MAD_UNITS_HOURS: |
270 | return timer.seconds / 60 / 60; | 274 | return timer.seconds / 60 / 60; |
271 | 275 | ||
272 | case MAD_UNITS_MINUTES: | 276 | case MAD_UNITS_MINUTES: |
273 | return timer.seconds / 60; | 277 | return timer.seconds / 60; |
274 | 278 | ||
275 | case MAD_UNITS_SECONDS: | 279 | case MAD_UNITS_SECONDS: |
276 | return timer.seconds; | 280 | return timer.seconds; |
277 | 281 | ||
278 | case MAD_UNITS_DECISECONDS: | 282 | case MAD_UNITS_DECISECONDS: |
279 | case MAD_UNITS_CENTISECONDS: | 283 | case MAD_UNITS_CENTISECONDS: |
280 | case MAD_UNITS_MILLISECONDS: | 284 | case MAD_UNITS_MILLISECONDS: |
281 | 285 | ||
282 | case MAD_UNITS_8000_HZ: | 286 | case MAD_UNITS_8000_HZ: |
283 | case MAD_UNITS_11025_HZ: | 287 | case MAD_UNITS_11025_HZ: |
284 | case MAD_UNITS_12000_HZ: | 288 | case MAD_UNITS_12000_HZ: |
285 | case MAD_UNITS_16000_HZ: | 289 | case MAD_UNITS_16000_HZ: |
286 | case MAD_UNITS_22050_HZ: | 290 | case MAD_UNITS_22050_HZ: |
287 | case MAD_UNITS_24000_HZ: | 291 | case MAD_UNITS_24000_HZ: |
288 | case MAD_UNITS_32000_HZ: | 292 | case MAD_UNITS_32000_HZ: |
289 | case MAD_UNITS_44100_HZ: | 293 | case MAD_UNITS_44100_HZ: |
290 | case MAD_UNITS_48000_HZ: | 294 | case MAD_UNITS_48000_HZ: |
291 | 295 | ||
292 | case MAD_UNITS_24_FPS: | 296 | case MAD_UNITS_24_FPS: |
293 | case MAD_UNITS_25_FPS: | 297 | case MAD_UNITS_25_FPS: |
294 | case MAD_UNITS_30_FPS: | 298 | case MAD_UNITS_30_FPS: |
295 | case MAD_UNITS_48_FPS: | 299 | case MAD_UNITS_48_FPS: |
296 | case MAD_UNITS_50_FPS: | 300 | case MAD_UNITS_50_FPS: |
297 | case MAD_UNITS_60_FPS: | 301 | case MAD_UNITS_60_FPS: |
298 | case MAD_UNITS_75_FPS: | 302 | case MAD_UNITS_75_FPS: |
299 | return timer.seconds * (signed long) units + | 303 | return timer.seconds * (signed long) units + |
300 | (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, | 304 | (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, |
301 | units); | 305 | units); |
302 | 306 | ||
303 | case MAD_UNITS_23_976_FPS: | 307 | case MAD_UNITS_23_976_FPS: |
304 | case MAD_UNITS_24_975_FPS: | 308 | case MAD_UNITS_24_975_FPS: |
305 | case MAD_UNITS_29_97_FPS: | 309 | case MAD_UNITS_29_97_FPS: |
306 | case MAD_UNITS_47_952_FPS: | 310 | case MAD_UNITS_47_952_FPS: |
307 | case MAD_UNITS_49_95_FPS: | 311 | case MAD_UNITS_49_95_FPS: |
308 | case MAD_UNITS_59_94_FPS: | 312 | case MAD_UNITS_59_94_FPS: |
309 | return (mad_timer_count(timer, -units) + 1) * 1000 / 1001; | 313 | return (mad_timer_count(timer, -units) + 1) * 1000 / 1001; |
310 | } | 314 | } |
311 | 315 | ||
312 | /* unsupported units */ | 316 | /* unsupported units */ |
313 | return 0; | 317 | return 0; |
314 | } | 318 | } |
315 | 319 | ||
316 | /* | 320 | /* |
317 | * NAME:timer->fraction() | 321 | * NAME:timer->fraction() |
318 | * DESCRIPTION:return fractional part of timer in arbitrary terms | 322 | * DESCRIPTION:return fractional part of timer in arbitrary terms |
319 | */ | 323 | */ |
320 | unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts) | 324 | unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) |
321 | { | 325 | { |
322 | timer = mad_timer_abs(timer); | 326 | timer = mad_timer_abs(timer); |
323 | 327 | ||
324 | switch (fracparts) { | 328 | switch (denom) { |
325 | case 0: | 329 | case 0: |
326 | return MAD_TIMER_RESOLUTION / timer.fraction; | 330 | return MAD_TIMER_RESOLUTION / timer.fraction; |
327 | 331 | ||
328 | case MAD_TIMER_RESOLUTION: | 332 | case MAD_TIMER_RESOLUTION: |
329 | return timer.fraction; | 333 | return timer.fraction; |
330 | 334 | ||
331 | default: | 335 | default: |
332 | return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, fracparts); | 336 | return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); |
333 | } | 337 | } |
334 | } | 338 | } |
335 | 339 | ||
336 | /* | 340 | /* |
337 | * NAME:timer->string() | 341 | * NAME:timer->string() |
338 | * DESCRIPTION:write a string representation of a timer using a template | 342 | * DESCRIPTION:write a string representation of a timer using a template |
339 | */ | 343 | */ |
340 | void mad_timer_string(mad_timer_t timer, | 344 | void mad_timer_string(mad_timer_t timer, |
341 | char *dest, char const *format, enum mad_units units, | 345 | char *dest, char const *format, enum mad_units units, |
342 | enum mad_units fracunits, unsigned long subparts) | 346 | enum mad_units fracunits, unsigned long subparts) |
343 | { | 347 | { |
344 | unsigned long hours, minutes, seconds, sub; | 348 | unsigned long hours, minutes, seconds, sub; |
345 | unsigned int frac; | 349 | unsigned int frac; |
346 | 350 | ||
347 | timer = mad_timer_abs(timer); | 351 | timer = mad_timer_abs(timer); |
348 | 352 | ||
349 | seconds = timer.seconds; | 353 | seconds = timer.seconds; |
350 | frac = sub = 0; | 354 | frac = sub = 0; |
351 | 355 | ||
352 | switch (fracunits) { | 356 | switch (fracunits) { |
353 | case MAD_UNITS_HOURS: | 357 | case MAD_UNITS_HOURS: |
354 | case MAD_UNITS_MINUTES: | 358 | case MAD_UNITS_MINUTES: |
355 | case MAD_UNITS_SECONDS: | 359 | case MAD_UNITS_SECONDS: |
356 | break; | 360 | break; |
357 | 361 | ||
358 | case MAD_UNITS_DECISECONDS: | 362 | case MAD_UNITS_DECISECONDS: |
359 | case MAD_UNITS_CENTISECONDS: | 363 | case MAD_UNITS_CENTISECONDS: |
360 | case MAD_UNITS_MILLISECONDS: | 364 | case MAD_UNITS_MILLISECONDS: |
361 | 365 | ||
362 | case MAD_UNITS_8000_HZ: | 366 | case MAD_UNITS_8000_HZ: |
363 | case MAD_UNITS_11025_HZ: | 367 | case MAD_UNITS_11025_HZ: |
364 | case MAD_UNITS_12000_HZ: | 368 | case MAD_UNITS_12000_HZ: |
365 | case MAD_UNITS_16000_HZ: | 369 | case MAD_UNITS_16000_HZ: |
366 | case MAD_UNITS_22050_HZ: | 370 | case MAD_UNITS_22050_HZ: |
367 | case MAD_UNITS_24000_HZ: | 371 | case MAD_UNITS_24000_HZ: |
368 | case MAD_UNITS_32000_HZ: | 372 | case MAD_UNITS_32000_HZ: |
369 | case MAD_UNITS_44100_HZ: | 373 | case MAD_UNITS_44100_HZ: |
370 | case MAD_UNITS_48000_HZ: | 374 | case MAD_UNITS_48000_HZ: |
371 | 375 | ||
372 | case MAD_UNITS_24_FPS: | 376 | case MAD_UNITS_24_FPS: |
373 | case MAD_UNITS_25_FPS: | 377 | case MAD_UNITS_25_FPS: |
374 | case MAD_UNITS_30_FPS: | 378 | case MAD_UNITS_30_FPS: |
375 | case MAD_UNITS_48_FPS: | 379 | case MAD_UNITS_48_FPS: |
376 | case MAD_UNITS_50_FPS: | 380 | case MAD_UNITS_50_FPS: |
377 | case MAD_UNITS_60_FPS: | 381 | case MAD_UNITS_60_FPS: |
378 | case MAD_UNITS_75_FPS: | 382 | case MAD_UNITS_75_FPS: |
379 | { | 383 | { |
380 | unsigned long fracparts; | 384 | unsigned long denom; |
381 | 385 | ||
382 | fracparts = MAD_TIMER_RESOLUTION / fracunits; | 386 | denom = MAD_TIMER_RESOLUTION / fracunits; |
383 | 387 | ||
384 | frac = timer.fraction / fracparts; | 388 | frac = timer.fraction / denom; |
385 | sub = scale_rational(timer.fraction % fracparts, fracparts, subparts); | 389 | sub = scale_rational(timer.fraction % denom, denom, subparts); |
386 | } | 390 | } |
387 | break; | 391 | break; |
388 | 392 | ||
389 | case MAD_UNITS_23_976_FPS: | 393 | case MAD_UNITS_23_976_FPS: |
390 | case MAD_UNITS_24_975_FPS: | 394 | case MAD_UNITS_24_975_FPS: |
391 | case MAD_UNITS_29_97_FPS: | 395 | case MAD_UNITS_29_97_FPS: |
392 | case MAD_UNITS_47_952_FPS: | 396 | case MAD_UNITS_47_952_FPS: |
393 | case MAD_UNITS_49_95_FPS: | 397 | case MAD_UNITS_49_95_FPS: |
394 | case MAD_UNITS_59_94_FPS: | 398 | case MAD_UNITS_59_94_FPS: |
395 | /* drop-frame encoding */ | 399 | /* drop-frame encoding */ |
396 | /* N.B. this is only well-defined for MAD_UNITS_29_97_FPS */ | 400 | /* N.B. this is only well-defined for MAD_UNITS_29_97_FPS */ |
397 | { | 401 | { |
398 | unsigned long frame, cycle, d, m; | 402 | unsigned long frame, cycle, d, m; |
399 | 403 | ||
400 | frame = mad_timer_count(timer, fracunits); | 404 | frame = mad_timer_count(timer, fracunits); |
401 | 405 | ||
402 | cycle = -fracunits * 60 * 10 - (10 - 1) * 2; | 406 | cycle = -fracunits * 60 * 10 - (10 - 1) * 2; |
403 | 407 | ||
404 | d = frame / cycle; | 408 | d = frame / cycle; |
405 | m = frame % cycle; | 409 | m = frame % cycle; |
406 | frame += (10 - 1) * 2 * d; | 410 | frame += (10 - 1) * 2 * d; |
407 | if (m > 2) | 411 | if (m > 2) |
408 | frame += 2 * ((m - 2) / (cycle / 10)); | 412 | frame += 2 * ((m - 2) / (cycle / 10)); |
409 | 413 | ||
410 | frac = frame % -fracunits; | 414 | frac = frame % -fracunits; |
411 | seconds = frame / -fracunits; | 415 | seconds = frame / -fracunits; |
412 | } | 416 | } |
413 | break; | 417 | break; |
414 | } | 418 | } |
415 | 419 | ||
416 | switch (units) { | 420 | switch (units) { |
417 | case MAD_UNITS_HOURS: | 421 | case MAD_UNITS_HOURS: |
418 | minutes = seconds / 60; | 422 | minutes = seconds / 60; |
419 | hours = minutes / 60; | 423 | hours = minutes / 60; |
420 | 424 | ||
421 | sprintf(dest, format, | 425 | sprintf(dest, format, |
422 | hours, | 426 | hours, |
423 | (unsigned int) (minutes % 60), | 427 | (unsigned int) (minutes % 60), |
424 | (unsigned int) (seconds % 60), | 428 | (unsigned int) (seconds % 60), |
425 | frac, sub); | 429 | frac, sub); |
426 | break; | 430 | break; |
427 | 431 | ||
428 | case MAD_UNITS_MINUTES: | 432 | case MAD_UNITS_MINUTES: |
429 | minutes = seconds / 60; | 433 | minutes = seconds / 60; |
430 | 434 | ||
431 | sprintf(dest, format, | 435 | sprintf(dest, format, |
432 | minutes, | 436 | minutes, |
433 | (unsigned int) (seconds % 60), | 437 | (unsigned int) (seconds % 60), |
diff --git a/core/multimedia/opieplayer/libmad/timer.h b/core/multimedia/opieplayer/libmad/timer.h index 67fe16a..f8afb8e 100644 --- a/core/multimedia/opieplayer/libmad/timer.h +++ b/core/multimedia/opieplayer/libmad/timer.h | |||
@@ -1,100 +1,100 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifndef LIBMAD_TIMER_H | 22 | # ifndef LIBMAD_TIMER_H |
23 | # define LIBMAD_TIMER_H | 23 | # define LIBMAD_TIMER_H |
24 | 24 | ||
25 | typedef struct { | 25 | typedef struct { |
26 | signed long seconds; /* whole seconds */ | 26 | signed long seconds; /* whole seconds */ |
27 | unsigned long fraction;/* 1/MAD_TIMER_RESOLUTION seconds */ | 27 | unsigned long fraction;/* 1/MAD_TIMER_RESOLUTION seconds */ |
28 | } mad_timer_t; | 28 | } mad_timer_t; |
29 | 29 | ||
30 | extern mad_timer_t const mad_timer_zero; | 30 | extern mad_timer_t const mad_timer_zero; |
31 | 31 | ||
32 | # define MAD_TIMER_RESOLUTION352800000UL | 32 | # define MAD_TIMER_RESOLUTION352800000UL |
33 | 33 | ||
34 | enum mad_units { | 34 | enum mad_units { |
35 | MAD_UNITS_HOURS = -2, | 35 | MAD_UNITS_HOURS = -2, |
36 | MAD_UNITS_MINUTES = -1, | 36 | MAD_UNITS_MINUTES = -1, |
37 | MAD_UNITS_SECONDS = 0, | 37 | MAD_UNITS_SECONDS = 0, |
38 | 38 | ||
39 | /* metric units */ | 39 | /* metric units */ |
40 | 40 | ||
41 | MAD_UNITS_DECISECONDS = 10, | 41 | MAD_UNITS_DECISECONDS = 10, |
42 | MAD_UNITS_CENTISECONDS = 100, | 42 | MAD_UNITS_CENTISECONDS = 100, |
43 | MAD_UNITS_MILLISECONDS = 1000, | 43 | MAD_UNITS_MILLISECONDS = 1000, |
44 | 44 | ||
45 | /* audio sample units */ | 45 | /* audio sample units */ |
46 | 46 | ||
47 | MAD_UNITS_8000_HZ = 8000, | 47 | MAD_UNITS_8000_HZ = 8000, |
48 | MAD_UNITS_11025_HZ = 11025, | 48 | MAD_UNITS_11025_HZ = 11025, |
49 | MAD_UNITS_12000_HZ = 12000, | 49 | MAD_UNITS_12000_HZ = 12000, |
50 | 50 | ||
51 | MAD_UNITS_16000_HZ = 16000, | 51 | MAD_UNITS_16000_HZ = 16000, |
52 | MAD_UNITS_22050_HZ = 22050, | 52 | MAD_UNITS_22050_HZ = 22050, |
53 | MAD_UNITS_24000_HZ = 24000, | 53 | MAD_UNITS_24000_HZ = 24000, |
54 | 54 | ||
55 | MAD_UNITS_32000_HZ = 32000, | 55 | MAD_UNITS_32000_HZ = 32000, |
56 | MAD_UNITS_44100_HZ = 44100, | 56 | MAD_UNITS_44100_HZ = 44100, |
57 | MAD_UNITS_48000_HZ = 48000, | 57 | MAD_UNITS_48000_HZ = 48000, |
58 | 58 | ||
59 | /* video frame/field units */ | 59 | /* video frame/field units */ |
60 | 60 | ||
61 | MAD_UNITS_24_FPS = 24, | 61 | MAD_UNITS_24_FPS = 24, |
62 | MAD_UNITS_25_FPS = 25, | 62 | MAD_UNITS_25_FPS = 25, |
63 | MAD_UNITS_30_FPS = 30, | 63 | MAD_UNITS_30_FPS = 30, |
64 | MAD_UNITS_48_FPS = 48, | 64 | MAD_UNITS_48_FPS = 48, |
65 | MAD_UNITS_50_FPS = 50, | 65 | MAD_UNITS_50_FPS = 50, |
66 | MAD_UNITS_60_FPS = 60, | 66 | MAD_UNITS_60_FPS = 60, |
67 | 67 | ||
68 | /* CD audio frames */ | 68 | /* CD audio frames */ |
69 | 69 | ||
70 | MAD_UNITS_75_FPS = 75, | 70 | MAD_UNITS_75_FPS = 75, |
71 | 71 | ||
72 | /* video drop-frame units */ | 72 | /* video drop-frame units */ |
73 | 73 | ||
74 | MAD_UNITS_23_976_FPS = -24, | 74 | MAD_UNITS_23_976_FPS = -24, |
75 | MAD_UNITS_24_975_FPS = -25, | 75 | MAD_UNITS_24_975_FPS = -25, |
76 | MAD_UNITS_29_97_FPS = -30, | 76 | MAD_UNITS_29_97_FPS = -30, |
77 | MAD_UNITS_47_952_FPS = -48, | 77 | MAD_UNITS_47_952_FPS = -48, |
78 | MAD_UNITS_49_95_FPS = -50, | 78 | MAD_UNITS_49_95_FPS = -50, |
79 | MAD_UNITS_59_94_FPS = -60 | 79 | MAD_UNITS_59_94_FPS = -60 |
80 | }; | 80 | }; |
81 | 81 | ||
82 | # define mad_timer_reset(timer)(*(timer) = mad_timer_zero) | 82 | # define mad_timer_reset(timer)((void) (*(timer) = mad_timer_zero)) |
83 | 83 | ||
84 | int mad_timer_compare(mad_timer_t, mad_timer_t); | 84 | int mad_timer_compare(mad_timer_t, mad_timer_t); |
85 | 85 | ||
86 | # define mad_timer_sign(timer)mad_timer_compare((timer), mad_timer_zero) | 86 | # define mad_timer_sign(timer)mad_timer_compare((timer), mad_timer_zero) |
87 | 87 | ||
88 | void mad_timer_negate(mad_timer_t *); | 88 | void mad_timer_negate(mad_timer_t *); |
89 | mad_timer_t mad_timer_abs(mad_timer_t); | 89 | mad_timer_t mad_timer_abs(mad_timer_t); |
90 | 90 | ||
91 | void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); | 91 | void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long); |
92 | void mad_timer_add(mad_timer_t *, mad_timer_t); | 92 | void mad_timer_add(mad_timer_t *, mad_timer_t); |
93 | void mad_timer_multiply(mad_timer_t *, signed long); | 93 | void mad_timer_multiply(mad_timer_t *, signed long); |
94 | 94 | ||
95 | signed long mad_timer_count(mad_timer_t, enum mad_units); | 95 | signed long mad_timer_count(mad_timer_t, enum mad_units); |
96 | unsigned long mad_timer_fraction(mad_timer_t, unsigned long); | 96 | unsigned long mad_timer_fraction(mad_timer_t, unsigned long); |
97 | void mad_timer_string(mad_timer_t, char *, char const *, | 97 | void mad_timer_string(mad_timer_t, char *, char const *, |
98 | enum mad_units, enum mad_units, unsigned long); | 98 | enum mad_units, enum mad_units, unsigned long); |
99 | 99 | ||
100 | # endif | 100 | # endif |
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c index 413d54b..fb126f4 100644 --- a/core/multimedia/opieplayer/libmad/version.c +++ b/core/multimedia/opieplayer/libmad/version.c | |||
@@ -1,82 +1,82 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
27 | 27 | ||
28 | # include "libmad_version.h" | 28 | # include "libmad_version.h" |
29 | 29 | ||
30 | char const mad_version[] = "MPEG Audio Decoder version " MAD_VERSION; | 30 | char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION; |
31 | char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; | 31 | char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; |
32 | char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; | 32 | char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; |
33 | 33 | ||
34 | char const mad_build[] = | 34 | char const mad_build[] = "" |
35 | # if defined(FPM_64BIT) | 35 | # if defined(FPM_64BIT) |
36 | "FPM_64BIT " | 36 | "FPM_64BIT " |
37 | # elif defined(FPM_INTEL) | 37 | # elif defined(FPM_INTEL) |
38 | "FPM_INTEL " | 38 | "FPM_INTEL " |
39 | # elif defined(FPM_ARM) | 39 | # elif defined(FPM_ARM) |
40 | "FPM_ARM " | 40 | "FPM_ARM " |
41 | # elif defined(FPM_MIPS) | 41 | # elif defined(FPM_MIPS) |
42 | "FPM_MIPS " | 42 | "FPM_MIPS " |
43 | # elif defined(FPM_SPARC) | 43 | # elif defined(FPM_SPARC) |
44 | "FPM_SPARC " | 44 | "FPM_SPARC " |
45 | # elif defined(FPM_PPC) | 45 | # elif defined(FPM_PPC) |
46 | "FPM_PPC " | 46 | "FPM_PPC " |
47 | # elif defined(FPM_DEFAULT) | 47 | # elif defined(FPM_DEFAULT) |
48 | "FPM_DEFAULT " | 48 | "FPM_DEFAULT " |
49 | # endif | 49 | # endif |
50 | 50 | ||
51 | # if defined(ASO_IMDCT) | 51 | # if defined(ASO_IMDCT) |
52 | "ASO_IMDCT " | 52 | "ASO_IMDCT " |
53 | # endif | 53 | # endif |
54 | # if defined(ASO_INTERLEAVE1) | 54 | # if defined(ASO_INTERLEAVE1) |
55 | "ASO_INTERLEAVE1 " | 55 | "ASO_INTERLEAVE1 " |
56 | # endif | 56 | # endif |
57 | # if defined(ASO_INTERLEAVE2) | 57 | # if defined(ASO_INTERLEAVE2) |
58 | "ASO_INTERLEAVE2 " | 58 | "ASO_INTERLEAVE2 " |
59 | # endif | 59 | # endif |
60 | # if defined(ASO_ZEROCHECK) | 60 | # if defined(ASO_ZEROCHECK) |
61 | "ASO_ZEROCHECK " | 61 | "ASO_ZEROCHECK " |
62 | # endif | 62 | # endif |
63 | 63 | ||
64 | # if defined(OPT_SPEED) | 64 | # if defined(OPT_SPEED) |
65 | "OPT_SPEED " | 65 | "OPT_SPEED " |
66 | # elif defined(OPT_ACCURACY) | 66 | # elif defined(OPT_ACCURACY) |
67 | "OPT_ACCURACY " | 67 | "OPT_ACCURACY " |
68 | # endif | 68 | # endif |
69 | 69 | ||
70 | # if defined(OPT_SSO) | 70 | # if defined(OPT_SSO) |
71 | "OPT_SSO " | 71 | "OPT_SSO " |
72 | # endif | 72 | # endif |
73 | 73 | ||
74 | # if defined(OPT_DCTO) /* never defined here */ | 74 | # if defined(OPT_DCTO) /* never defined here */ |
75 | "OPT_DCTO " | 75 | "OPT_DCTO " |
76 | # endif | 76 | # endif |
77 | 77 | ||
78 | # if defined(OPT_STRICT) | 78 | # if defined(OPT_STRICT) |
79 | "OPT_STRICT " | 79 | "OPT_STRICT " |
80 | # endif | 80 | # endif |
81 | 81 | ||
82 | # if defined(EXPERIMENTAL) | 82 | # if defined(EXPERIMENTAL) |