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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
@@ -184,37 +184,54 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, | |||
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,18 +1,18 @@ | |||
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 | * |
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,164 +1,169 @@ | |||
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) |
@@ -268,32 +273,33 @@ enum mad_flow check_message(struct mad_decoder *decoder) | |||
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 | ||
@@ -335,43 +341,45 @@ int run_sync(struct mad_decoder *decoder) | |||
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 | } |
@@ -396,33 +404,33 @@ int run_sync(struct mad_decoder *decoder) | |||
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)) { |
@@ -437,32 +445,33 @@ int run_sync(struct mad_decoder *decoder) | |||
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); |
@@ -498,57 +507,64 @@ int run_async(struct mad_decoder *decoder) | |||
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
@@ -21,32 +21,44 @@ | |||
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 |
@@ -81,112 +93,147 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 | * |
@@ -204,32 +251,39 @@ typedef unsigned long mad_fixed64lo_t; | |||
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) |
@@ -344,62 +398,71 @@ typedef unsigned long mad_fixed64lo_t; | |||
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 |
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,18 +1,18 @@ | |||
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 | * |
@@ -360,33 +360,33 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) | |||
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 && |
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,18 +1,18 @@ | |||
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 | * |
@@ -32,84 +32,86 @@ enum mad_layer { | |||
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,18 +1,18 @@ | |||
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 | * |
@@ -21,34 +21,40 @@ | |||
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), |
@@ -87,34 +93,39 @@ union huffquad const hufftabB[] = { | |||
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) |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
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,69 +1,77 @@ | |||
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; |
@@ -490,33 +498,33 @@ mad_fixed_t const is_lsf_table[2][15] = { | |||
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) { |
@@ -589,33 +597,33 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, | |||
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 | ||
@@ -630,33 +638,33 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, | |||
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; |
@@ -762,32 +770,54 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, | |||
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; |
@@ -843,62 +873,48 @@ void III_exponents(struct channel const *channel, | |||
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 | } |
@@ -1238,113 +1254,110 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], | |||
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) { |
@@ -1374,200 +1387,197 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], | |||
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]) |
@@ -2128,108 +2138,108 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) | |||
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 | ||
@@ -2287,33 +2297,33 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, | |||
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; |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
@@ -29,17 +29,30 @@ | |||
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,43 +1,43 @@ | |||
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[]; |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
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,18 +1,18 @@ | |||
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 | * |
@@ -41,33 +41,33 @@ void mad_stream_init(struct mad_stream *stream) | |||
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 | } |
@@ -108,16 +108,53 @@ int mad_stream_sync(struct mad_stream *stream) | |||
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,46 +1,48 @@ | |||
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 */ |
@@ -67,36 +69,39 @@ struct mad_stream { | |||
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,18 +1,18 @@ | |||
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 | * |
@@ -137,99 +137,95 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, | |||
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; |
@@ -314,237 +310,239 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, | |||
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 | ||
@@ -576,104 +574,106 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
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]); |
@@ -711,83 +711,85 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, | |||
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]); |
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,45 +1,48 @@ | |||
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; |
@@ -137,127 +140,128 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom, | |||
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() |
@@ -304,45 +308,45 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units) | |||
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 | ||
@@ -364,38 +368,38 @@ void mad_timer_string(mad_timer_t timer, | |||
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 | ||
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,18 +1,18 @@ | |||
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 | * |
@@ -66,33 +66,33 @@ enum mad_units { | |||
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); |
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,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 "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 | ||