summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-04-19 16:08:55 (UTC)
committer harlekin <harlekin>2002-04-19 16:08:55 (UTC)
commit7ea4abeb652e6787e57a938e1ca028d25fd249ce (patch) (unidiff)
treeee08f2d9d6aaa8adb1c5f07f4124da8a61eb8cd5
parentcaa7ced77b9014526607f9f65c58aabe7e0ba631 (diff)
downloadopie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.zip
opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.gz
opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.bz2
new libmad version, less cpu usage
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/COPYRIGHT21
-rw-r--r--core/multimedia/opieplayer/libmad/D.dat2
-rw-r--r--core/multimedia/opieplayer/libmad/bit.c39
-rw-r--r--core/multimedia/opieplayer/libmad/bit.h2
-rw-r--r--core/multimedia/opieplayer/libmad/decoder.c60
-rw-r--r--core/multimedia/opieplayer/libmad/decoder.h20
-rw-r--r--core/multimedia/opieplayer/libmad/fixed.c2
-rw-r--r--core/multimedia/opieplayer/libmad/fixed.h97
-rw-r--r--core/multimedia/opieplayer/libmad/frame.c4
-rw-r--r--core/multimedia/opieplayer/libmad/frame.h60
-rw-r--r--core/multimedia/opieplayer/libmad/huffman.c21
-rw-r--r--core/multimedia/opieplayer/libmad/huffman.h20
-rw-r--r--core/multimedia/opieplayer/libmad/imdct_s.dat2
-rw-r--r--core/multimedia/opieplayer/libmad/layer12.c2
-rw-r--r--core/multimedia/opieplayer/libmad/layer12.h2
-rw-r--r--core/multimedia/opieplayer/libmad/layer3.c150
-rw-r--r--core/multimedia/opieplayer/libmad/layer3.h2
-rw-r--r--core/multimedia/opieplayer/libmad/libmad_global.h15
-rw-r--r--core/multimedia/opieplayer/libmad/libmad_version.h6
-rw-r--r--core/multimedia/opieplayer/libmad/opie-libmadplugin.control2
-rw-r--r--core/multimedia/opieplayer/libmad/qc_table.dat2
-rw-r--r--core/multimedia/opieplayer/libmad/rq_table.dat2
-rw-r--r--core/multimedia/opieplayer/libmad/sf_table.dat2
-rw-r--r--core/multimedia/opieplayer/libmad/stream.c41
-rw-r--r--core/multimedia/opieplayer/libmad/stream.h13
-rw-r--r--core/multimedia/opieplayer/libmad/synth.c328
-rw-r--r--core/multimedia/opieplayer/libmad/synth.h33
-rw-r--r--core/multimedia/opieplayer/libmad/timer.c66
-rw-r--r--core/multimedia/opieplayer/libmad/timer.h4
-rw-r--r--core/multimedia/opieplayer/libmad/version.c6
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -197,22 +197,39 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
197unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, 197unsigned 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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -20,19 +20,14 @@
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>
@@ -42,9 +37,15 @@
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"
@@ -52,14 +53,18 @@
52# include "decoder.h" 53# include "decoder.h"
53 54
54void mad_decoder_init(struct mad_decoder *decoder, void *data, 55void 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 *))
@@ -86,15 +91,15 @@ void mad_decoder_init(struct mad_decoder *decoder, void *data,
86 91
87int mad_decoder_finish(struct mad_decoder *decoder) 92int 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;
@@ -110,10 +115,12 @@ int mad_decoder_finish(struct mad_decoder *decoder)
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)
117static 124static
118enum mad_flow send_io(int fd, void const *data, size_t len) 125enum mad_flow send_io(int fd, void const *data, size_t len)
119{ 126{
@@ -121,9 +128,8 @@ enum mad_flow send_io(int fd, void const *data, size_t len)
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)
@@ -143,9 +149,8 @@ enum mad_flow receive_io(int fd, void *buffer, size_t len)
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)
@@ -281,6 +286,7 @@ enum mad_flow check_message(struct mad_decoder *decoder)
281 286
282 return result; 287 return result;
283} 288}
289# endif
284 290
285static 291static
286enum mad_flow error_default(void *data, struct mad_stream *stream, 292enum mad_flow error_default(void *data, struct mad_stream *stream,
@@ -348,6 +354,7 @@ int run_sync(struct mad_decoder *decoder)
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:
@@ -359,6 +366,7 @@ int run_sync(struct mad_decoder *decoder)
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) {
@@ -409,7 +417,7 @@ int run_sync(struct mad_decoder *decoder)
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:
@@ -450,6 +458,7 @@ int run_sync(struct mad_decoder *decoder)
450 return result; 458 return result;
451} 459}
452 460
461# if defined(USE_ASYNC)
453static 462static
454int run_async(struct mad_decoder *decoder) 463int run_async(struct mad_decoder *decoder)
455{ 464{
@@ -511,6 +520,7 @@ int run_async(struct mad_decoder *decoder)
511 /* not reached */ 520 /* not reached */
512 return -1; 521 return -1;
513} 522}
523# endif
514 524
515int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) 525int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
516{ 526{
@@ -523,7 +533,9 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
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
@@ -545,10 +557,14 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
545int mad_decoder_message(struct mad_decoder *decoder, 557int 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,5 +1,5 @@
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
@@ -32,10 +32,10 @@ enum mad_decoder_mode {
32}; 32};
33 33
34enum mad_flow { 34enum 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
41struct mad_decoder { 41struct mad_decoder {
@@ -59,7 +59,8 @@ struct mad_decoder {
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 *);
@@ -69,7 +70,9 @@ struct mad_decoder {
69void mad_decoder_init(struct mad_decoder *, void *, 70void 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 *),
@@ -79,7 +82,8 @@ void mad_decoder_init(struct mad_decoder *, void *,
79 enum mad_flow (*)(void *, void *, unsigned int *)); 82 enum mad_flow (*)(void *, void *, unsigned int *));
80int mad_decoder_finish(struct mad_decoder *); 83int 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
84int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode); 88int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
85int mad_decoder_message(struct mad_decoder *, void *, unsigned int *); 89int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -34,6 +34,18 @@ typedef signed long mad_fixed64hi_t;
34typedef unsigned long mad_fixed64lo_t; 34typedef 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)
44typedef double mad_sample_t;
45# else
46typedef 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)
@@ -94,20 +106,31 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -116,21 +139,44 @@ typedef unsigned long mad_fixed64lo_t;
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 */
145static __forceinline
146mad_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)); \
@@ -140,13 +186,13 @@ typedef unsigned long mad_fixed64lo_t;
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; \
@@ -162,8 +208,8 @@ typedef unsigned long mad_fixed64lo_t;
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) \
@@ -171,9 +217,10 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -217,6 +264,13 @@ typedef unsigned long mad_fixed64lo_t;
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" \
@@ -357,8 +411,12 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -380,6 +438,7 @@ typedef unsigned long mad_fixed64lo_t;
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
@@ -387,6 +446,10 @@ typedef unsigned long mad_fixed64lo_t;
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
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,5 +1,5 @@
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
@@ -373,7 +373,7 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
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
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,5 +1,5 @@
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
@@ -45,24 +45,26 @@ enum mad_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
48struct mad_frame { 48struct 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 */ 66struct 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
@@ -77,26 +79,26 @@ struct mad_frame {
77 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) 79 ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
78 80
79enum { 81enum {
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
97enum { 99enum {
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
102void mad_header_init(struct mad_header *); 104void mad_header_init(struct mad_header *);
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,5 +1,5 @@
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
@@ -34,8 +34,14 @@
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
40static 46static
41union huffquad const hufftabA[] = { 47union huffquad const hufftabA[] = {
@@ -100,8 +106,13 @@ union huffquad const hufftabB[] = {
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
106static 117static
107union huffpair const hufftab0[] = { 118union huffpair const hufftab0[] = {
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,5 +1,5 @@
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
@@ -25,32 +25,32 @@
25union huffquad { 25union 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
42union 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
42union 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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -27,7 +27,10 @@
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>
@@ -51,6 +54,11 @@ enum {
51 mixed_block_flag = 0x08 54 mixed_block_flag = 0x08
52}; 55};
53 56
57enum {
58 I_STEREO = 0x1,
59 MS_STEREO = 0x2
60};
61
54struct sideinfo { 62struct sideinfo {
55 unsigned int main_data_begin; 63 unsigned int main_data_begin;
56 unsigned int private_bits; 64 unsigned int private_bits;
@@ -503,7 +511,7 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch,
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);
@@ -602,7 +610,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
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;
@@ -643,7 +651,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
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) {
@@ -775,6 +783,28 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel,
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 */
@@ -856,23 +886,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp)
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];
@@ -884,8 +898,10 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp)
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) {
@@ -1251,7 +1267,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576],
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
@@ -1266,37 +1282,39 @@ 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));
@@ -1315,11 +1333,6 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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) !=
@@ -1331,7 +1344,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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;
@@ -1387,14 +1400,14 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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 }
@@ -1417,7 +1430,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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 */
@@ -1432,11 +1445,11 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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
@@ -1468,13 +1481,13 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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
@@ -1492,7 +1505,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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;
@@ -1502,7 +1515,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
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) {
@@ -1517,7 +1530,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
1517 } 1530 }
1518 } 1531 }
1519 1532
1520 return 0; 1533 return MAD_ERROR_NONE;
1521} 1534}
1522 1535
1523/* 1536/*
@@ -1533,15 +1546,12 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
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) {
@@ -1549,12 +1559,12 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
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
@@ -2141,8 +2151,8 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb)
2141 * DESCRIPTION:decode frame main_data 2151 * DESCRIPTION:decode frame main_data
2142 */ 2152 */
2143static 2153static
2144int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 2154enum 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;
@@ -2169,7 +2179,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
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;
@@ -2178,9 +2188,9 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
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
@@ -2194,7 +2204,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
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 }
@@ -2202,7 +2212,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
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 }
@@ -2216,7 +2226,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
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 /*
@@ -2300,7 +2310,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
2300 } 2310 }
2301 } 2311 }
2302 2312
2303 return 0; 2313 return MAD_ERROR_NONE;
2304} 2314}
2305 2315
2306/* 2316/*
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -42,4 +42,17 @@
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,5 +1,5 @@
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
@@ -23,8 +23,8 @@
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
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,7 +1,7 @@
1Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 plugins/codecs/libmadplugin.so.1 plugins/codecs/libmadplugin.so 1Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 plugins/codecs/libmadplugin.so.1 plugins/codecs/libmadplugin.so
2Priority: optional 2Priority: optional
3Section: opie/plugins 3Section: opie/plugins
4Maintainer: John Ryland <jryland@trolltech.com> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION) 7Depends: opie-base ($QPE_VERSION)
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,5 +1,5 @@
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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
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,5 +1,5 @@
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
@@ -54,7 +54,7 @@ void mad_stream_init(struct mad_stream *stream)
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/*
@@ -121,3 +121,40 @@ int mad_stream_sync(struct mad_stream *stream)
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 */
129char 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,5 +1,5 @@
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
@@ -28,6 +28,8 @@
28 # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD) 28 # define MAD_BUFFER_MDLEN(511 + 2048 + MAD_BUFFER_GUARD)
29 29
30enum mad_error { 30enum 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
@@ -80,18 +82,19 @@ struct mad_stream {
80 82
81enum { 83enum {
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
91void mad_stream_init(struct mad_stream *); 93void mad_stream_init(struct mad_stream *);
92void mad_stream_finish(struct mad_stream *); 94void 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
96void mad_stream_buffer(struct mad_stream *, 99void mad_stream_buffer(struct mad_stream *,
97 unsigned char const *, unsigned long); 100 unsigned char const *, unsigned long);
@@ -99,4 +102,6 @@ void mad_stream_skip(struct mad_stream *, unsigned long);
99 102
100int mad_stream_sync(struct mad_stream *); 103int mad_stream_sync(struct mad_stream *);
101 104
105char 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,5 +1,5 @@
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
@@ -150,73 +150,69 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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);
@@ -327,7 +323,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -343,7 +339,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -352,7 +348,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -361,9 +357,9 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -373,13 +369,13 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -387,7 +383,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -395,9 +391,9 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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
@@ -405,106 +401,106 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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:
@@ -526,12 +522,14 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
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)
@@ -589,8 +587,19 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
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]);
@@ -599,16 +608,6 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
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;
@@ -619,8 +618,19 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
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]);
@@ -629,30 +639,10 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
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]);
@@ -661,6 +651,16 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
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;
@@ -724,8 +724,19 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
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]);
@@ -734,16 +745,6 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
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;
@@ -755,8 +756,19 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
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]);
@@ -765,16 +777,6 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
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;
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,5 +1,5 @@
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
@@ -25,18 +25,37 @@
25# include "fixed.h" 25# include "fixed.h"
26# include "frame.h" 26# include "frame.h"
27 27
28struct 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
28struct mad_synth { 35struct 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 */ 45enum {
39 } pcm; 46 MAD_PCM_CHANNEL_SINGLE = 0
47};
48
49/* dual channel PCM selector */
50enum {
51 MAD_PCM_CHANNEL_DUAL_1 = 0,
52 MAD_PCM_CHANNEL_DUAL_2 = 1
53};
54
55/* stereo PCM selector */
56enum {
57 MAD_PCM_CHANNEL_STEREO_LEFT = 0,
58 MAD_PCM_CHANNEL_STEREO_RIGHT = 1
40}; 59};
41 60
42void mad_synth_init(struct mad_synth *); 61void mad_synth_init(struct mad_synth *);
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,5 +1,5 @@
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
@@ -26,7 +26,10 @@
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
@@ -150,68 +153,69 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom,
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 */
155void mad_timer_set(mad_timer_t *timer, unsigned long seconds, 158void 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
@@ -243,8 +247,8 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
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;
@@ -317,11 +321,11 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
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 */
320unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts) 324unsigned 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
@@ -329,7 +333,7 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts)
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
@@ -377,12 +381,12 @@ void mad_timer_string(mad_timer_t timer,
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
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,5 +1,5 @@
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
@@ -79,7 +79,7 @@ enum mad_units {
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
84int mad_timer_compare(mad_timer_t, mad_timer_t); 84int mad_timer_compare(mad_timer_t, mad_timer_t);
85 85
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,5 +1,5 @@
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
@@ -27,11 +27,11 @@
27 27
28# include "libmad_version.h" 28# include "libmad_version.h"
29 29
30char const mad_version[] = "MPEG Audio Decoder version " MAD_VERSION; 30char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION;
31char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR; 31char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR;
32char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">"; 32char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">";
33 33
34char const mad_build[] = 34char 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)