summaryrefslogtreecommitdiff
Side-by-side diff
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 @@
+
+ libmad - MPEG audio decoder library
+ Copyright (C) 2000-2001 Robert Leslie
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ If you would like to negotiate alternate licensing terms, you may do
+ so by contacting the author: Robert Leslie <rob@mars.org>
+
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -194,27 +194,44 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len,
* NAME: bit->crc()
* DESCRIPTION: compute CRC-check word
*/
unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len,
unsigned short init)
{
- register unsigned int crc, data;
+ register unsigned int crc;
-# if CHAR_BIT == 8
- for (crc = init; len >= 8; len -= 8) {
- crc = (crc << 8) ^
- crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+ for (crc = init; len >= 32; len -= 32) {
+ register unsigned long data;
+
+ data = mad_bit_read(&bitptr, 32);
+
+ crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff];
+ crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff];
+ crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff];
+ crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff];
+ }
+
+ switch (len / 8) {
+ case 3: crc = (crc << 8) ^
+ crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+ case 2: crc = (crc << 8) ^
+ crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+ case 1: crc = (crc << 8) ^
+ crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff];
+
+ len %= 8;
+
+ case 0: break;
}
-# else
- crc = init;
-# endif
while (len--) {
- data = mad_bit_read(&bitptr, 1) ^ (crc >> 15);
+ register unsigned int msb;
+
+ msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15);
crc <<= 1;
- if (data & 1)
+ if (msb & 1)
crc ^= CRC_POLY;
}
return crc & 0xffff;
}
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -17,52 +17,57 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
# ifdef HAVE_CONFIG_H
-# include "libmad_config.h"
-# else
-# ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-# endif
-# ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-# endif
+# include "libmad_config.h"
# endif
# include "libmad_global.h"
-# include <sys/types.h>
+# ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+# endif
# ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
# endif
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
-# include <fcntl.h>
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+
# include <stdlib.h>
-# include <errno.h>
+
+# ifdef HAVE_ERRNO_H
+# include <errno.h>
+# endif
# include "stream.h"
# include "frame.h"
# include "synth.h"
# include "decoder.h"
void mad_decoder_init(struct mad_decoder *decoder, void *data,
- enum mad_flow (*input_func)(void *, struct mad_stream *),
+ enum mad_flow (*input_func)(void *,
+ struct mad_stream *),
enum mad_flow (*header_func)(void *,
struct mad_header const *),
- enum mad_flow (*filter_func)(void *, struct mad_frame *),
+ enum mad_flow (*filter_func)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
enum mad_flow (*output_func)(void *,
struct mad_header const *,
struct mad_pcm *),
- enum mad_flow (*error_func)(void *, struct mad_stream *,
+ enum mad_flow (*error_func)(void *,
+ struct mad_stream *,
struct mad_frame *),
enum mad_flow (*message_func)(void *,
void *, unsigned int *))
{
decoder->mode = -1;
@@ -83,21 +88,21 @@ void mad_decoder_init(struct mad_decoder *decoder, void *data,
decoder->error_func = error_func;
decoder->message_func = message_func;
}
int mad_decoder_finish(struct mad_decoder *decoder)
{
+# if defined(USE_ASYNC)
if (decoder->mode == MAD_DECODER_MODE_ASYNC && decoder->async.pid) {
pid_t pid;
int status;
close(decoder->async.in);
- do {
+ do
pid = waitpid(decoder->async.pid, &status, 0);
- }
while (pid == -1 && errno == EINTR);
decoder->mode = -1;
close(decoder->async.out);
@@ -107,26 +112,27 @@ int mad_decoder_finish(struct mad_decoder *decoder)
if (pid == -1)
return -1;
return (!WIFEXITED(status) || WEXITSTATUS(status)) ? -1 : 0;
}
+# endif
return 0;
}
+# if defined(USE_ASYNC)
static
enum mad_flow send_io(int fd, void const *data, size_t len)
{
char const *ptr = data;
ssize_t count;
while (len) {
- do {
+ do
count = write(fd, ptr, len);
- }
while (count == -1 && errno == EINTR);
if (count == -1)
return MAD_FLOW_BREAK;
len -= count;
@@ -140,15 +146,14 @@ static
enum mad_flow receive_io(int fd, void *buffer, size_t len)
{
char *ptr = buffer;
ssize_t count;
while (len) {
- do {
+ do
count = read(fd, ptr, len);
- }
while (count == -1 && errno == EINTR);
if (count == -1)
return (errno == EAGAIN) ? MAD_FLOW_IGNORE : MAD_FLOW_BREAK;
else if (count == 0)
return MAD_FLOW_STOP;
@@ -278,12 +283,13 @@ enum mad_flow check_message(struct mad_decoder *decoder)
if (message)
free(message);
return result;
}
+# endif
static
enum mad_flow error_default(void *data, struct mad_stream *stream,
struct mad_frame *frame)
{
int *bad_last_frame = data;
@@ -345,23 +351,25 @@ int run_sync(struct mad_decoder *decoder)
continue;
case MAD_FLOW_CONTINUE:
break;
}
while (1) {
+# if defined(USE_ASYNC)
if (decoder->mode == MAD_DECODER_MODE_ASYNC) {
switch (check_message(decoder)) {
case MAD_FLOW_IGNORE:
case MAD_FLOW_CONTINUE:
break;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_STOP:
goto done;
}
}
+# endif
if (decoder->header_func) {
if (mad_header_decode(&frame->header, stream) == -1) {
if (!MAD_RECOVERABLE(stream->error))
break;
@@ -406,13 +414,13 @@ int run_sync(struct mad_decoder *decoder)
}
}
else
bad_last_frame = 0;
if (decoder->filter_func) {
- switch (decoder->filter_func(decoder->cb_data, frame)) {
+ switch (decoder->filter_func(decoder->cb_data, stream, frame)) {
case MAD_FLOW_STOP:
goto done;
case MAD_FLOW_BREAK:
goto fail;
case MAD_FLOW_IGNORE:
continue;
@@ -447,12 +455,13 @@ int run_sync(struct mad_decoder *decoder)
mad_frame_finish(frame);
mad_stream_finish(stream);
return result;
}
+# if defined(USE_ASYNC)
static
int run_async(struct mad_decoder *decoder)
{
pid_t pid;
int ptoc[2], ctop[2], flags;
@@ -508,25 +517,28 @@ int run_async(struct mad_decoder *decoder)
_exit(run_sync(decoder));
/* not reached */
return -1;
}
+# endif
int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
{
int result;
int (*run)(struct mad_decoder *) = 0;
switch (decoder->mode = mode) {
case MAD_DECODER_MODE_SYNC:
run = run_sync;
break;
case MAD_DECODER_MODE_ASYNC:
+# if defined(USE_ASYNC)
run = run_async;
+# endif
break;
}
if (run == 0)
return -1;
@@ -542,13 +554,17 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode)
return result;
}
int mad_decoder_message(struct mad_decoder *decoder,
void *message, unsigned int *len)
{
+# if defined(USE_ASYNC)
if (decoder->mode != MAD_DECODER_MODE_ASYNC ||
send(decoder->async.out, message, *len) != MAD_FLOW_CONTINUE ||
receive(decoder->async.in, &message, len) != MAD_FLOW_CONTINUE)
return -1;
return 0;
+# else
+ return -1;
+# endif
}
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -29,16 +29,16 @@
enum mad_decoder_mode {
MAD_DECODER_MODE_SYNC = 0,
MAD_DECODER_MODE_ASYNC
};
enum mad_flow {
- MAD_FLOW_CONTINUE = 0x0000,
- MAD_FLOW_STOP = 0x0010,
- MAD_FLOW_BREAK = 0x0011,
- MAD_FLOW_IGNORE = 0x0020
+ MAD_FLOW_CONTINUE = 0x0000, /* continue normally */
+ MAD_FLOW_STOP = 0x0010, /* stop decoding normally */
+ MAD_FLOW_BREAK = 0x0011, /* stop decoding and signal an error */
+ MAD_FLOW_IGNORE = 0x0020 /* ignore the current frame */
};
struct mad_decoder {
enum mad_decoder_mode mode;
int options;
@@ -56,32 +56,36 @@ struct mad_decoder {
} *sync;
void *cb_data;
enum mad_flow (*input_func)(void *, struct mad_stream *);
enum mad_flow (*header_func)(void *, struct mad_header const *);
- enum mad_flow (*filter_func)(void *, struct mad_frame *);
+ enum mad_flow (*filter_func)(void *,
+ struct mad_stream const *, struct mad_frame *);
enum mad_flow (*output_func)(void *,
struct mad_header const *, struct mad_pcm *);
enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *);
enum mad_flow (*message_func)(void *, void *, unsigned int *);
};
void mad_decoder_init(struct mad_decoder *, void *,
enum mad_flow (*)(void *, struct mad_stream *),
enum mad_flow (*)(void *, struct mad_header const *),
- enum mad_flow (*)(void *, struct mad_frame *),
+ enum mad_flow (*)(void *,
+ struct mad_stream const *,
+ struct mad_frame *),
enum mad_flow (*)(void *,
struct mad_header const *,
struct mad_pcm *),
enum mad_flow (*)(void *,
struct mad_stream *,
struct mad_frame *),
enum mad_flow (*)(void *, void *, unsigned int *));
int mad_decoder_finish(struct mad_decoder *);
-# define mad_decoder_options(decoder, opts) ((decoder)->options = (opts))
+# define mad_decoder_options(decoder, opts) \
+ ((void) ((decoder)->options = (opts)))
int mad_decoder_run(struct mad_decoder *, enum mad_decoder_mode);
int mad_decoder_message(struct mad_decoder *, void *, unsigned int *);
# endif
diff --git a/core/multimedia/opieplayer/libmad/fixed.c b/core/multimedia/opieplayer/libmad/fixed.c
index be5c94e..af1e87e 100644
--- a/core/multimedia/opieplayer/libmad/fixed.c
+++ b/core/multimedia/opieplayer/libmad/fixed.c
@@ -1,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -31,12 +31,24 @@ typedef unsigned int mad_fixed64lo_t;
typedef signed long mad_fixed_t;
typedef signed long mad_fixed64hi_t;
typedef unsigned long mad_fixed64lo_t;
# endif
+# if defined(_MSC_VER)
+# define mad_fixed64_t signed __int64
+# elif 1 || defined(__GNUC__)
+# define mad_fixed64_t signed long long
+# endif
+
+# if defined(FPM_FLOAT)
+typedef double mad_sample_t;
+# else
+typedef mad_fixed_t mad_sample_t;
+# endif
+
/*
* Fixed-point format: 0xABBBBBBB
* A == whole part (sign + 3 bits)
* B == fractional part (28 bits)
*
* Values are signed two's complement, so the effective range is:
@@ -91,65 +103,99 @@ typedef unsigned long mad_fixed64lo_t;
# define mad_f_fromint(x) ((x) << MAD_F_FRACBITS)
# define mad_f_add(x, y) ((x) + (y))
# define mad_f_sub(x, y) ((x) - (y))
-# if defined(FPM_64BIT)
+# if defined(FPM_FLOAT)
+# error "FPM_FLOAT not yet supported"
+
+# undef MAD_F
+# define MAD_F(x) mad_f_todouble(x)
+
+# define mad_f_mul(x, y) ((x) * (y))
+# define mad_f_scale64
+
+# undef ASO_ZEROCHECK
+
+# elif defined(FPM_64BIT)
/*
- * This version should be the most accurate if 64-bit (long long) types are
- * supported by the compiler, although it may not be the most efficient.
+ * This version should be the most accurate if 64-bit types are supported by
+ * the compiler, although it may not be the most efficient.
*/
# if defined(OPT_ACCURACY)
# define mad_f_mul(x, y) \
((mad_fixed_t) \
- ((((signed long long) (x) * (y)) + \
+ ((((mad_fixed64_t) (x) * (y)) + \
(1L << (MAD_F_SCALEBITS - 1))) >> MAD_F_SCALEBITS))
# else
# define mad_f_mul(x, y) \
- ((mad_fixed_t) (((signed long long) (x) * (y)) >> MAD_F_SCALEBITS))
+ ((mad_fixed_t) (((mad_fixed64_t) (x) * (y)) >> MAD_F_SCALEBITS))
# endif
# define MAD_F_SCALEBITS MAD_F_FRACBITS
/* --- Intel --------------------------------------------------------------- */
# elif defined(FPM_INTEL)
+# if defined(_MSC_VER)
+# pragma warning(push)
+# pragma warning(disable: 4035) /* no return value */
+static __forceinline
+mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
+{
+ enum {
+ fracbits = MAD_F_FRACBITS
+ };
+
+ __asm {
+ mov eax, x
+ imul y
+ shrd eax, edx, fracbits
+ }
+
+ /* implicit return of eax */
+}
+# pragma warning(pop)
+
+# define mad_f_mul mad_f_mul_inline
+# define mad_f_scale64
+# else
/*
* This Intel version is fast and accurate; the disposition of the least
* significant bit depends on OPT_ACCURACY via mad_f_scale64().
*/
-# define MAD_F_MLX(hi, lo, x, y) \
+# define MAD_F_MLX(hi, lo, x, y) \
asm ("imull %3" \
: "=a" (lo), "=d" (hi) \
: "%a" (x), "rm" (y) \
: "cc")
-# if defined(OPT_ACCURACY)
+# if defined(OPT_ACCURACY)
/*
* This gives best accuracy but is not very fast.
*/
-# define MAD_F_MLA(hi, lo, x, y) \
+# define MAD_F_MLA(hi, lo, x, y) \
({ mad_fixed64hi_t __hi; \
mad_fixed64lo_t __lo; \
MAD_F_MLX(__hi, __lo, (x), (y)); \
asm ("addl %2,%0\n\t" \
"adcl %3,%1" \
: "=rm" (lo), "=rm" (hi) \
: "r" (__lo), "r" (__hi), "0" (lo), "1" (hi) \
: "cc"); \
})
-# endif /* OPT_ACCURACY */
+# endif /* OPT_ACCURACY */
-# if defined(OPT_ACCURACY)
+# if defined(OPT_ACCURACY)
/*
* Surprisingly, this is faster than SHRD followed by ADC.
*/
-# define mad_f_scale64(hi, lo) \
+# define mad_f_scale64(hi, lo) \
({ mad_fixed64hi_t __hi_; \
mad_fixed64lo_t __lo_; \
mad_fixed_t __result; \
asm ("addl %4,%2\n\t" \
"adcl %5,%3" \
: "=rm" (__lo_), "=rm" (__hi_) \
@@ -159,24 +205,25 @@ typedef unsigned long mad_fixed64lo_t;
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (__lo_), "r" (__hi_), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
-# else
-# define mad_f_scale64(hi, lo) \
+# else
+# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("shrdl %3,%2,%1" \
: "=rm" (__result) \
: "0" (lo), "r" (hi), "I" (MAD_F_SCALEBITS) \
: "cc"); \
__result; \
})
-# endif /* OPT_ACCURACY */
+# endif /* OPT_ACCURACY */
-# define MAD_F_SCALEBITS MAD_F_FRACBITS
+# define MAD_F_SCALEBITS MAD_F_FRACBITS
+# endif
/* --- ARM ----------------------------------------------------------------- */
# elif defined(FPM_ARM)
/*
@@ -214,12 +261,19 @@ typedef unsigned long mad_fixed64lo_t;
# define MAD_F_MLA(hi, lo, x, y) \
asm ("smlal %0, %1, %2, %3" \
: "+r" (lo), "+r" (hi) \
: "%r" (x), "r" (y))
+# define MAD_F_MLN(hi, lo) \
+ asm ("rsbs %0, %2, #0\n\t" \
+ "rsc %1, %3, #0" \
+ : "=r" (lo), "=r" (hi) \
+ : "0" (lo), "1" (hi) \
+ : "cc")
+
# define mad_f_scale64(hi, lo) \
({ mad_fixed_t __result; \
asm ("movs %0, %1, lsr %3\n\t" \
"adc %0, %0, %2, lsl %4" \
: "=r" (__result) \
: "r" (lo), "r" (hi), \
@@ -354,14 +408,18 @@ typedef unsigned long mad_fixed64lo_t;
* should be taken when ordering operands.
*
* The scale factors are constant as this is not used with SSO.
*
* Pre-rounding is required to stay within the limits of compliance.
*/
-# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
+# if defined(OPT_SPEED)
+# define mad_f_mul(x, y) (((x) >> 12) * ((y) >> 16))
+# else
+# define mad_f_mul(x, y) ((((x) + (1L << 11)) >> 12) * \
(((y) + (1L << 15)) >> 16))
+# endif
/* ------------------------------------------------------------------------- */
# else
# error "no FPM selected"
# endif
@@ -377,19 +435,24 @@ typedef unsigned long mad_fixed64lo_t;
})
# endif
# if !defined(MAD_F_MLA)
# define MAD_F_ML0(hi, lo, x, y) ((lo) = mad_f_mul((x), (y)))
# define MAD_F_MLA(hi, lo, x, y) ((lo) += mad_f_mul((x), (y)))
+# define MAD_F_MLN(hi, lo) ((lo) = -(lo))
# define MAD_F_MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# endif
# if !defined(MAD_F_ML0)
# define MAD_F_ML0(hi, lo, x, y) MAD_F_MLX((hi), (lo), (x), (y))
# endif
+# if !defined(MAD_F_MLN)
+# define MAD_F_MLN(hi, lo) ((hi) = ((lo) = -(lo)) ? ~(hi) : -(hi))
+# endif
+
# if !defined(MAD_F_MLZ)
# define MAD_F_MLZ(hi, lo) mad_f_scale64((hi), (lo))
# endif
# if !defined(mad_f_scale64)
# if defined(OPT_ACCURACY)
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -370,13 +370,13 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
/* calculate frame duration */
mad_timer_set(&header->duration, 0,
32 * MAD_NSBSAMPLES(header), header->samplerate);
/* calculate free bit rate */
if (header->bitrate == 0) {
- if ((!stream->sync || !stream->freerate) &&
+ if ((stream->freerate == 0 || !stream->sync) &&
free_bitrate(stream, header) == -1)
goto fail;
header->bitrate = stream->freerate;
header->flags |= MAD_FLAG_FREEFORMAT;
}
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -42,30 +42,32 @@ enum mad_mode {
enum mad_emphasis {
MAD_EMPHASIS_NONE = 0, /* no emphasis */
MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */
MAD_EMPHASIS_CCITT_J_17 = 3 /* CCITT J.17 emphasis */
};
-struct mad_frame {
- struct mad_header {
- enum mad_layer layer; /* audio layer (1, 2, or 3) */
- enum mad_mode mode; /* channel mode (see above) */
- int mode_extension; /* additional mode info */
- enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
+struct mad_header {
+ enum mad_layer layer; /* audio layer (1, 2, or 3) */
+ enum mad_mode mode; /* channel mode (see above) */
+ int mode_extension; /* additional mode info */
+ enum mad_emphasis emphasis; /* de-emphasis to use (see above) */
+
+ unsigned long bitrate; /* stream bitrate (bps) */
+ unsigned int samplerate; /* sampling frequency (Hz) */
- unsigned long bitrate; /* stream bitrate (bps) */
- unsigned int samplerate; /* sampling frequency (Hz) */
+ unsigned short crc_check; /* frame CRC accumulator */
+ unsigned short crc_target; /* final target CRC checksum */
- unsigned short crc_check; /* frame CRC accumulator */
- unsigned short crc_target; /* final target CRC checksum */
+ int flags; /* flags (see below) */
+ int private_bits; /* private bits (see below) */
- int flags; /* flags (see below) */
- int private_bits; /* private bits (see below) */
+ mad_timer_t duration; /* audio playing time of frame */
+};
- mad_timer_t duration; /* audio playing time of frame */
- } header;
+struct mad_frame {
+ struct mad_header header; /* MPEG audio header */
int options; /* decoding options (from stream) */
mad_fixed_t sbsample[2][36][32]; /* synthesis subband filter samples */
mad_fixed_t (*overlap)[2][32][18]; /* Layer III block overlap data */
};
@@ -74,32 +76,32 @@ struct mad_frame {
# define MAD_NSBSAMPLES(header) \
((header)->layer == MAD_LAYER_I ? 12 : \
(((header)->layer == MAD_LAYER_III && \
((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36))
enum {
- MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
- MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
+ MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */
+ MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */
- MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
- MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
- MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
- MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
+ MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */
+ MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */
+ MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */
+ MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */
- MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
- MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
- MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
+ MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */
+ MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */
+ MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */
- MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
- MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
- MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
+ MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */
+ MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */
+ MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */
};
enum {
- MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
- MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
+ MAD_PRIVATE_HEADER = 0x0100, /* header private bit */
+ MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */
};
void mad_header_init(struct mad_header *);
# define mad_header_finish(header) /* nothing */
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -31,14 +31,20 @@
* These are the Huffman code words for Layer III.
* The data for these tables are derived from Table B.7 of ISO/IEC 11172-3.
*
* These tables support decoding up to 4 Huffman code bits at a time.
*/
-# define V(v, w, x, y, hlen) { { 1, hlen, v, w, x, y } }
-# define PTR(offs, bits) { ptr: { 0, bits, offs } }
+# if defined(__GNUC__)
+# define PTR(offs, bits) { ptr: { 0, bits, offs } }
+# define V(v, w, x, y, hlen) { value: { 1, hlen, v, w, x, y } }
+# else
+# define PTR(offs, bits) { { 0, bits, offs } }
+# define V(v, w, x, y, hlen) { { 1, hlen, (v << 0) | (w << 1) | \
+ (x << 2) | (y << 3) } }
+# endif
static
union huffquad const hufftabA[] = {
/* 0000 */ PTR(16, 2),
/* 0001 */ PTR(20, 2),
/* 0010 */ PTR(24, 1),
@@ -97,14 +103,19 @@ union huffquad const hufftabB[] = {
/* 1111 */ V(0, 0, 0, 0, 4)
};
# undef V
# undef PTR
-# define V(x, y, hlen) { { 1, hlen, x, y } }
-# define PTR(offs, bits) { ptr: { 0, bits, offs } }
+# if defined(__GNUC__)
+# define PTR(offs, bits) { ptr: { 0, bits, offs } }
+# define V(x, y, hlen) { value: { 1, hlen, x, y } }
+# else
+# define PTR(offs, bits) { { 0, bits, offs } }
+# define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } }
+# endif
static
union huffpair const hufftab0[] = {
/* */ V(0, 0, 0)
};
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -22,38 +22,38 @@
# ifndef LIBMAD_HUFFMAN_H
# define LIBMAD_HUFFMAN_H
union huffquad {
struct {
unsigned short final : 1;
+ unsigned short bits : 3;
+ unsigned short offset : 12;
+ } ptr;
+ struct {
+ unsigned short final : 1;
unsigned short hlen : 3;
unsigned short v : 1;
unsigned short w : 1;
unsigned short x : 1;
unsigned short y : 1;
} value;
+ unsigned short final : 1;
+};
+
+union huffpair {
struct {
unsigned short final : 1;
unsigned short bits : 3;
unsigned short offset : 12;
} ptr;
- unsigned short final : 1;
-};
-
-union huffpair {
struct {
unsigned short final : 1;
unsigned short hlen : 3;
unsigned short x : 4;
unsigned short y : 4;
} value;
- struct {
- unsigned short final : 1;
- unsigned short bits : 3;
- unsigned short offset : 12;
- } ptr;
unsigned short final : 1;
};
struct hufftable {
union huffpair const *table;
unsigned short linbits;
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -24,13 +24,16 @@
# endif
# include "libmad_global.h"
# include <stdlib.h>
# include <string.h>
-# include <assert.h>
+
+# ifdef HAVE_ASSERT_H
+# include <assert.h>
+# endif
# ifdef HAVE_LIMITS_H
# include <limits.h>
# else
# define CHAR_BIT 8
# endif
@@ -48,12 +51,17 @@ enum {
count1table_select = 0x01,
scalefac_scale = 0x02,
preflag = 0x04,
mixed_block_flag = 0x08
};
+enum {
+ I_STEREO = 0x1,
+ MS_STEREO = 0x2
+};
+
struct sideinfo {
unsigned int main_data_begin;
unsigned int private_bits;
unsigned char scfsi[2];
@@ -500,13 +508,13 @@ static
enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch,
int lsf, struct sideinfo *si,
unsigned int *data_bitlen,
unsigned int *priv_bitlen)
{
unsigned int ngr, gr, ch, i;
- enum mad_error result = 0;
+ enum mad_error result = MAD_ERROR_NONE;
*data_bitlen = 0;
*priv_bitlen = lsf ? ((nch == 1) ? 1 : 2) : ((nch == 1) ? 5 : 3);
si->main_data_begin = mad_bit_read(ptr, lsf ? 8 : 9);
si->private_bits = mad_bit_read(ptr, *priv_bitlen);
@@ -599,13 +607,13 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
start = *ptr;
scalefac_compress = channel->scalefac_compress;
index = (channel->block_type == 2) ?
((channel->flags & mixed_block_flag) ? 2 : 1) : 0;
- if (!((mode_extension & 0x1) && gr1ch)) {
+ if (!((mode_extension & I_STEREO) && gr1ch)) {
if (scalefac_compress < 400) {
slen[0] = (scalefac_compress >> 4) / 5;
slen[1] = (scalefac_compress >> 4) % 5;
slen[2] = (scalefac_compress % 16) >> 2;
slen[3] = scalefac_compress % 4;
@@ -640,13 +648,13 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr,
channel->scalefac[n++] = mad_bit_read(ptr, slen[part]);
}
while (n < 39)
channel->scalefac[n++] = 0;
}
- else { /* (mode_extension & 0x1) && gr1ch (i.e. ch == 1) */
+ else { /* (mode_extension & I_STEREO) && gr1ch (i.e. ch == 1) */
scalefac_compress >>= 1;
if (scalefac_compress < 180) {
slen[0] = scalefac_compress / 36;
slen[1] = (scalefac_compress % 36) / 6;
slen[2] = (scalefac_compress % 36) % 6;
@@ -772,12 +780,34 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel,
}
return mad_bit_length(&start, ptr);
}
/*
+ * The Layer III formula for requantization and scaling is defined by
+ * section 2.4.3.4.7.1 of ISO/IEC 11172-3, as follows:
+ *
+ * long blocks:
+ * xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
+ * 2^((1/4) * (global_gain - 210)) *
+ * 2^-(scalefac_multiplier *
+ * (scalefac_l[sfb] + preflag * pretab[sfb]))
+ *
+ * short blocks:
+ * xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
+ * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) *
+ * 2^-(scalefac_multiplier * scalefac_s[sfb][w])
+ *
+ * where:
+ * scalefac_multiplier = (scalefac_scale + 1) / 2
+ *
+ * The routines III_exponents() and III_requantize() facilitate this
+ * calculation.
+ */
+
+/*
* NAME: III_exponents()
* DESCRIPTION: calculate scalefactor exponents
*/
static
void III_exponents(struct channel const *channel,
unsigned char const *sfbwidth, signed int exponents[39])
@@ -853,42 +883,28 @@ static
mad_fixed_t III_requantize(unsigned int value, signed int exp)
{
mad_fixed_t requantized;
signed int frac;
struct fixedfloat const *power;
- /*
- * long blocks:
- * xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
- * 2^((1/4) * (global_gain - 210)) *
- * 2^-(scalefac_multiplier *
- * (scalefac_l[sfb] + preflag * pretab[sfb]))
- *
- * short blocks:
- * xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
- * 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) *
- * 2^-(scalefac_multiplier * scalefac_s[sfb][w])
- *
- * where:
- * scalefac_multiplier = (scalefac_scale + 1) / 2
- */
-
- frac = exp % 4;
+ frac = exp % 4; /* assumes sign(frac) == sign(exp) */
exp /= 4;
power = &rq_table[value];
requantized = power->mantissa;
exp += power->exponent;
if (exp < 0) {
if (-exp >= sizeof(mad_fixed_t) * CHAR_BIT) {
/* underflow */
requantized = 0;
}
- else
+ else {
+ requantized += 1L << (-exp - 1);
requantized >>= -exp;
+ }
}
else {
if (exp >= 5) {
/* overflow */
# if defined(DEBUG)
fprintf(stderr, "requantize overflow (%f * 2^%d)\n",
@@ -1248,13 +1264,13 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576],
xrptr[0] = 0;
xrptr[1] = 0;
xrptr += 2;
}
- return 0;
+ return MAD_ERROR_NONE;
}
# undef MASK
# undef MASK1BIT
/*
@@ -1263,43 +1279,45 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576],
*/
static
void III_reorder(mad_fixed_t xr[576], struct channel const *channel,
unsigned char const sfbwidth[39])
{
mad_fixed_t tmp[32][3][6];
- unsigned int sb, l, sfbi, f, w, sbw[3], sw[3];
+ unsigned int sb, l, f, w, sbw[3], sw[3];
/* this is probably wrong for 8000 Hz mixed blocks */
- if (channel->flags & mixed_block_flag)
- sb = 2, sfbi = 3 * 3;
- else
- sb = 0, sfbi = 0;
+ sb = 0;
+ if (channel->flags & mixed_block_flag) {
+ sb = 2;
+
+ l = 0;
+ while (l < 36)
+ l += *sfbwidth++;
+ }
for (w = 0; w < 3; ++w) {
sbw[w] = sb;
sw[w] = 0;
}
- f = sfbwidth[sfbi];
+ f = *sfbwidth++;
w = 0;
for (l = 18 * sb; l < 576; ++l) {
+ if (f-- == 0) {
+ f = *sfbwidth++ - 1;
+ w = (w + 1) % 3;
+ }
+
tmp[sbw[w]][w][sw[w]++] = xr[l];
if (sw[w] == 6) {
sw[w] = 0;
++sbw[w];
}
-
- if (--f == 0) {
- if (++w == 3)
- w = 0;
-
- f = sfbwidth[++sfbi];
- }
}
memcpy(&xr[18 * sb], &tmp[sb], (576 - 18 * sb) * sizeof(mad_fixed_t));
}
/*
@@ -1312,29 +1330,24 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
struct mad_header *header,
unsigned char const *sfbwidth)
{
short modes[39];
unsigned int sfbi, l, n, i;
- enum {
- i_stereo = 0x1,
- ms_stereo = 0x2
- };
-
if (granule->ch[0].block_type !=
granule->ch[1].block_type ||
(granule->ch[0].flags & mixed_block_flag) !=
(granule->ch[1].flags & mixed_block_flag))
return MAD_ERROR_BADSTEREO;
for (i = 0; i < 39; ++i)
modes[i] = header->mode_extension;
/* intensity stereo */
- if (header->mode_extension & i_stereo) {
+ if (header->mode_extension & I_STEREO) {
struct channel const *right_ch = &granule->ch[1];
mad_fixed_t const *right_xr = xr[1];
unsigned int is_pos;
header->flags |= MAD_FLAG_I_STEREO;
@@ -1384,20 +1397,20 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
if (max)
lower = start;
/* long blocks */
for (i = 0; i < lower; ++i)
- modes[i] = header->mode_extension & ~i_stereo;
+ modes[i] = header->mode_extension & ~I_STEREO;
/* short blocks */
w = 0;
for (i = start; i < max; ++i) {
if (i < bound[w])
- modes[i] = header->mode_extension & ~i_stereo;
+ modes[i] = header->mode_extension & ~I_STEREO;
w = (w + 1) % 3;
}
}
else { /* right_ch->block_type != 2 */
unsigned int bound;
@@ -1414,13 +1427,13 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
}
right_xr += n;
}
for (i = 0; i < bound; ++i)
- modes[i] = header->mode_extension & ~i_stereo;
+ modes[i] = header->mode_extension & ~I_STEREO;
}
/* now do the actual processing */
if (header->flags & MAD_FLAG_LSF_EXT) {
unsigned char const *illegal_pos = granule[1].ch[1].scalefac;
@@ -1429,17 +1442,17 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
/* intensity_scale */
lsf_scale = is_lsf_table[right_ch->scalefac_compress & 0x1];
for (sfbi = l = 0; l < 576; ++sfbi, l += n) {
n = sfbwidth[sfbi];
- if (!(modes[sfbi] & i_stereo))
+ if (!(modes[sfbi] & I_STEREO))
continue;
if (illegal_pos[sfbi]) {
- modes[sfbi] &= ~i_stereo;
+ modes[sfbi] &= ~I_STEREO;
continue;
}
is_pos = right_ch->scalefac[sfbi];
for (i = 0; i < n; ++i) {
@@ -1465,19 +1478,19 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
}
}
else { /* !(header->flags & MAD_FLAG_LSF_EXT) */
for (sfbi = l = 0; l < 576; ++sfbi, l += n) {
n = sfbwidth[sfbi];
- if (!(modes[sfbi] & i_stereo))
+ if (!(modes[sfbi] & I_STEREO))
continue;
is_pos = right_ch->scalefac[sfbi];
if (is_pos >= 7) { /* illegal intensity position */
- modes[sfbi] &= ~i_stereo;
+ modes[sfbi] &= ~I_STEREO;
continue;
}
for (i = 0; i < n; ++i) {
register mad_fixed_t left;
@@ -1489,23 +1502,23 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
}
}
}
/* middle/side stereo */
- if (header->mode_extension & ms_stereo) {
+ if (header->mode_extension & MS_STEREO) {
register mad_fixed_t invsqrt2;
header->flags |= MAD_FLAG_MS_STEREO;
invsqrt2 = root_table[3 + -2];
for (sfbi = l = 0; l < 576; ++sfbi, l += n) {
n = sfbwidth[sfbi];
- if (modes[sfbi] != ms_stereo)
+ if (modes[sfbi] != MS_STEREO)
continue;
for (i = 0; i < n; ++i) {
register mad_fixed_t m, s;
m = xr[0][l + i];
@@ -1514,13 +1527,13 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576],
xr[0][l + i] = mad_f_mul(m + s, invsqrt2); /* l = (m + s) / sqrt(2) */
xr[1][l + i] = mad_f_mul(m - s, invsqrt2); /* r = (m - s) / sqrt(2) */
}
}
}
- return 0;
+ return MAD_ERROR_NONE;
}
/*
* NAME: III_aliasreduce()
* DESCRIPTION: perform frequency line alias reduction
*/
@@ -1530,34 +1543,31 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
mad_fixed_t const *bound;
int i;
bound = &xr[lines];
for (xr += 18; xr < bound; xr += 18) {
for (i = 0; i < 8; ++i) {
- register mad_fixed_t *aptr, *bptr, a, b;
+ register mad_fixed_t a, b;
register mad_fixed64hi_t hi;
register mad_fixed64lo_t lo;
- aptr = &xr[-1 - i];
- bptr = &xr[ i];
-
- a = *aptr;
- b = *bptr;
+ a = xr[-1 - i];
+ b = xr[ i];
# if defined(ASO_ZEROCHECK)
if (a | b) {
# endif
MAD_F_ML0(hi, lo, a, cs[i]);
MAD_F_MLA(hi, lo, -b, ca[i]);
- *aptr = MAD_F_MLZ(hi, lo);
+ xr[-1 - i] = MAD_F_MLZ(hi, lo);
MAD_F_ML0(hi, lo, b, cs[i]);
MAD_F_MLA(hi, lo, a, ca[i]);
- *bptr = MAD_F_MLZ(hi, lo);
+ xr[ i] = MAD_F_MLZ(hi, lo);
# if defined(ASO_ZEROCHECK)
}
# endif
}
}
}
@@ -2138,14 +2148,14 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb)
/*
* NAME: III_decode()
* DESCRIPTION: decode frame main_data
*/
static
-int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
- struct sideinfo *si, unsigned int nch)
+enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
+ struct sideinfo *si, unsigned int nch)
{
struct mad_header *header = &frame->header;
unsigned int sfreqi, ngr, gr;
{
unsigned int sfreq;
@@ -2166,24 +2176,24 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
/* scalefactors, Huffman decoding, requantization */
ngr = (header->flags & MAD_FLAG_LSF_EXT) ? 1 : 2;
for (gr = 0; gr < ngr; ++gr) {
struct granule *granule = &si->gr[gr];
- unsigned char const *sfbwidth = 0;
+ unsigned char const *sfbwidth[2];
mad_fixed_t xr[2][576];
unsigned int ch;
enum mad_error error;
for (ch = 0; ch < nch; ++ch) {
struct channel *channel = &granule->ch[ch];
unsigned int part2_length;
- sfbwidth = sfbwidth_table[sfreqi].l;
+ sfbwidth[ch] = sfbwidth_table[sfreqi].l;
if (channel->block_type == 2) {
- sfbwidth = (channel->flags & mixed_block_flag) ?
+ sfbwidth[ch] = (channel->flags & mixed_block_flag) ?
sfbwidth_table[sfreqi].m : sfbwidth_table[sfreqi].s;
}
if (header->flags & MAD_FLAG_LSF_EXT) {
part2_length = III_scalefactors_lsf(ptr, channel,
ch == 0 ? 0 : &si->gr[1].ch[1],
@@ -2191,21 +2201,21 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
}
else {
part2_length = III_scalefactors(ptr, channel, &si->gr[0].ch[ch],
gr == 0 ? 0 : si->scfsi[ch]);
}
- error = III_huffdecode(ptr, xr[ch], channel, sfbwidth, part2_length);
+ error = III_huffdecode(ptr, xr[ch], channel, sfbwidth[ch], part2_length);
if (error)
return error;
}
/* joint stereo processing */
if (header->mode == MAD_MODE_JOINT_STEREO && header->mode_extension) {
- error = III_stereo(xr, granule, header, sfbwidth);
+ error = III_stereo(xr, granule, header, sfbwidth[0]);
if (error)
return error;
}
/* reordering, alias reduction, IMDCT, overlap-add, frequency inversion */
@@ -2213,13 +2223,13 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
struct channel const *channel = &granule->ch[ch];
mad_fixed_t (*sample)[32] = &frame->sbsample[ch][18 * gr];
unsigned int sb, l, i, sblimit;
mad_fixed_t output[36];
if (channel->block_type == 2) {
- III_reorder(xr[ch], channel, sfbwidth_table[sfreqi].s);
+ III_reorder(xr[ch], channel, sfbwidth[ch]);
# if !defined(OPT_STRICT)
/*
* According to ISO/IEC 11172-3, "Alias reduction is not applied for
* granules with block_type == 2 (short block)." However, other
* sources suggest alias reduction should indeed be performed on the
@@ -2297,13 +2307,13 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame,
if (sb & 1)
III_freqinver(sample, sb);
}
}
}
- return 0;
+ return MAD_ERROR_NONE;
}
/*
* NAME: layer->III()
* DESCRIPTION: decode a single Layer III frame
*/
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -39,7 +39,20 @@
# endif
# if defined(OPT_SPEED) && !defined(OPT_SSO)
# define OPT_SSO 1
# endif
+# if defined(HAVE_UNISTD_H) && defined(HAVE_WAITPID) && \
+ defined(HAVE_FCNTL) && defined(HAVE_PIPE) && defined(HAVE_FORK)
+# define USE_ASYNC
+# endif
+
+# if !defined(HAVE_ASSERT_H)
+# if defined(NDEBUG)
+# define assert(x) /* nothing */
+# else
+# define assert(x) do { if (!(x)) abort(); } while (0)
+# endif
+# endif
+
# 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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -20,14 +20,14 @@
*/
# ifndef LIBMAD_VERSION_H
# define LIBMAD_VERSION_H
# define MAD_VERSION_MAJOR 0
-# define MAD_VERSION_MINOR 13
-# define MAD_VERSION_PATCH 0
+# define MAD_VERSION_MINOR 14
+# define MAD_VERSION_PATCH 2
# define MAD_VERSION_EXTRA " (beta)"
# define MAD_VERSION_STRINGIZE(str) #str
# define MAD_VERSION_STRING(num) MAD_VERSION_STRINGIZE(num)
# define MAD_VERSION MAD_VERSION_STRING(MAD_VERSION_MAJOR) "." \
diff --git a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control
index 941047f..42ea6c7 100644
--- a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control
+++ b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control
@@ -1,9 +1,9 @@
Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 plugins/codecs/libmadplugin.so.1 plugins/codecs/libmadplugin.so
Priority: optional
Section: opie/plugins
-Maintainer: John Ryland <jryland@trolltech.com>
+Maintainer: Maximilian Reiss <max.reiss@gmx.de>
Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
Depends: opie-base ($QPE_VERSION)
Description: MP3 file plugin using libmad
Plugin to play MP3 files with the mediaplayer in the Opie environment.
diff --git a/core/multimedia/opieplayer/libmad/qc_table.dat b/core/multimedia/opieplayer/libmad/qc_table.dat
index 92b7f38..5d9ca96 100644
--- a/core/multimedia/opieplayer/libmad/qc_table.dat
+++ b/core/multimedia/opieplayer/libmad/qc_table.dat
@@ -1,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -51,13 +51,13 @@ void mad_stream_init(struct mad_stream *stream)
stream->anc_bitlen = 0;
stream->main_data = 0;
stream->md_len = 0;
stream->options = 0;
- stream->error = 0;
+ stream->error = MAD_ERROR_NONE;
}
/*
* NAME: stream->finish()
* DESCRIPTION: deallocate any dynamic memory associated with stream
*/
@@ -118,6 +118,43 @@ int mad_stream_sync(struct mad_stream *stream)
return -1;
mad_bit_init(&stream->ptr, ptr);
return 0;
}
+
+/*
+ * NAME: stream->errorstr()
+ * DESCRIPTION: return a string description of the current error condition
+ */
+char const *mad_stream_errorstr(struct mad_stream const *stream)
+{
+ switch (stream->error) {
+ case MAD_ERROR_NONE: return "no error";
+
+ case MAD_ERROR_BUFLEN: return "input buffer too small (or EOF)";
+ case MAD_ERROR_BUFPTR: return "invalid (null) buffer pointer";
+
+ case MAD_ERROR_NOMEM: return "not enough memory";
+
+ case MAD_ERROR_LOSTSYNC: return "lost synchronization";
+ case MAD_ERROR_BADLAYER: return "reserved header layer value";
+ case MAD_ERROR_BADBITRATE: return "forbidden bitrate value";
+ case MAD_ERROR_BADSAMPLERATE: return "reserved sample frequency value";
+ case MAD_ERROR_BADEMPHASIS: return "reserved emphasis value";
+
+ case MAD_ERROR_BADCRC: return "CRC check failed";
+ case MAD_ERROR_BADBITALLOC: return "forbidden bit allocation value";
+ case MAD_ERROR_BADSCALEFACTOR: return "bad scalefactor index";
+ case MAD_ERROR_BADFRAMELEN: return "bad frame length";
+ case MAD_ERROR_BADBIGVALUES: return "bad big_values count";
+ case MAD_ERROR_BADBLOCKTYPE: return "reserved block_type";
+ case MAD_ERROR_BADSCFSI: return "bad scalefactor selection info";
+ case MAD_ERROR_BADDATAPTR: return "bad main_data_begin pointer";
+ case MAD_ERROR_BADPART3LEN: return "bad audio data length";
+ case MAD_ERROR_BADHUFFTABLE: return "bad Huffman table select";
+ case MAD_ERROR_BADHUFFDATA: return "Huffman data overrun";
+ case MAD_ERROR_BADSTEREO: return "incompatible block_type for JS";
+ }
+
+ return 0;
+}
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -25,12 +25,14 @@
# include "bit.h"
# define MAD_BUFFER_GUARD 8
# define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD)
enum mad_error {
+ MAD_ERROR_NONE = 0x0000, /* no error */
+
MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */
MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */
MAD_ERROR_NOMEM = 0x0031, /* not enough memory */
MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */
@@ -77,26 +79,29 @@ struct mad_stream {
int options; /* decoding options (see below) */
enum mad_error error; /* error code (see above) */
};
enum {
MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */
- MAD_OPTION_HALFSAMPLERATE = 0x0002, /* generate PCM at 1/2 sample rate */
+ MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */
# if 0 /* not yet implemented */
MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */
MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */
- MAD_OPTION_SINGLECHANNEL = 0x0030, /* combine channels */
+ MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */
# endif
};
void mad_stream_init(struct mad_stream *);
void mad_stream_finish(struct mad_stream *);
-# define mad_stream_options(stream, opts) ((stream)->options = (opts))
+# define mad_stream_options(stream, opts) \
+ ((void) ((stream)->options = (opts)))
void mad_stream_buffer(struct mad_stream *,
unsigned char const *, unsigned long);
void mad_stream_skip(struct mad_stream *, unsigned long);
int mad_stream_sync(struct mad_stream *);
+char const *mad_stream_errorstr(struct mad_stream const *);
+
# 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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -147,79 +147,75 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
mad_fixed_t t168, t169, t170, t171, t172, t173, t174, t175;
mad_fixed_t t176;
/* costab[i] = cos(PI / (2 * 32) * i) */
# if defined(OPT_DCTO)
- enum {
- costab1 = MAD_F(0x7fd8878e),
- costab2 = MAD_F(0x7f62368f),
- costab3 = MAD_F(0x7e9d55fc),
- costab4 = MAD_F(0x7d8a5f40),
- costab5 = MAD_F(0x7c29fbee),
- costab6 = MAD_F(0x7a7d055b),
- costab7 = MAD_F(0x78848414),
- costab8 = MAD_F(0x7641af3d),
- costab9 = MAD_F(0x73b5ebd1),
- costab10 = MAD_F(0x70e2cbc6),
- costab11 = MAD_F(0x6dca0d14),
- costab12 = MAD_F(0x6a6d98a4),
- costab13 = MAD_F(0x66cf8120),
- costab14 = MAD_F(0x62f201ac),
- costab15 = MAD_F(0x5ed77c8a),
- costab16 = MAD_F(0x5a82799a),
- costab17 = MAD_F(0x55f5a4d2),
- costab18 = MAD_F(0x5133cc94),
- costab19 = MAD_F(0x4c3fdff4),
- costab20 = MAD_F(0x471cece7),
- costab21 = MAD_F(0x41ce1e65),
- costab22 = MAD_F(0x3c56ba70),
- costab23 = MAD_F(0x36ba2014),
- costab24 = MAD_F(0x30fbc54d),
- costab25 = MAD_F(0x2b1f34eb),
- costab26 = MAD_F(0x25280c5e),
- costab27 = MAD_F(0x1f19f97b),
- costab28 = MAD_F(0x18f8b83c),
- costab29 = MAD_F(0x12c8106f),
- costab30 = MAD_F(0x0c8bd35e),
- costab31 = MAD_F(0x0647d97c)
- };
+# define costab1 MAD_F(0x7fd8878e)
+# define costab2 MAD_F(0x7f62368f)
+# define costab3 MAD_F(0x7e9d55fc)
+# define costab4 MAD_F(0x7d8a5f40)
+# define costab5 MAD_F(0x7c29fbee)
+# define costab6 MAD_F(0x7a7d055b)
+# define costab7 MAD_F(0x78848414)
+# define costab8 MAD_F(0x7641af3d)
+# define costab9 MAD_F(0x73b5ebd1)
+# define costab10 MAD_F(0x70e2cbc6)
+# define costab11 MAD_F(0x6dca0d14)
+# define costab12 MAD_F(0x6a6d98a4)
+# define costab13 MAD_F(0x66cf8120)
+# define costab14 MAD_F(0x62f201ac)
+# define costab15 MAD_F(0x5ed77c8a)
+# define costab16 MAD_F(0x5a82799a)
+# define costab17 MAD_F(0x55f5a4d2)
+# define costab18 MAD_F(0x5133cc94)
+# define costab19 MAD_F(0x4c3fdff4)
+# define costab20 MAD_F(0x471cece7)
+# define costab21 MAD_F(0x41ce1e65)
+# define costab22 MAD_F(0x3c56ba70)
+# define costab23 MAD_F(0x36ba2014)
+# define costab24 MAD_F(0x30fbc54d)
+# define costab25 MAD_F(0x2b1f34eb)
+# define costab26 MAD_F(0x25280c5e)
+# define costab27 MAD_F(0x1f19f97b)
+# define costab28 MAD_F(0x18f8b83c)
+# define costab29 MAD_F(0x12c8106f)
+# define costab30 MAD_F(0x0c8bd35e)
+# define costab31 MAD_F(0x0647d97c)
# else
- enum {
- costab1 = MAD_F(0x0ffb10f2), /* 0.998795456 */
- costab2 = MAD_F(0x0fec46d2), /* 0.995184727 */
- costab3 = MAD_F(0x0fd3aac0), /* 0.989176510 */
- costab4 = MAD_F(0x0fb14be8), /* 0.980785280 */
- costab5 = MAD_F(0x0f853f7e), /* 0.970031253 */
- costab6 = MAD_F(0x0f4fa0ab), /* 0.956940336 */
- costab7 = MAD_F(0x0f109082), /* 0.941544065 */
- costab8 = MAD_F(0x0ec835e8), /* 0.923879533 */
- costab9 = MAD_F(0x0e76bd7a), /* 0.903989293 */
- costab10 = MAD_F(0x0e1c5979), /* 0.881921264 */
- costab11 = MAD_F(0x0db941a3), /* 0.857728610 */
- costab12 = MAD_F(0x0d4db315), /* 0.831469612 */
- costab13 = MAD_F(0x0cd9f024), /* 0.803207531 */
- costab14 = MAD_F(0x0c5e4036), /* 0.773010453 */
- costab15 = MAD_F(0x0bdaef91), /* 0.740951125 */
- costab16 = MAD_F(0x0b504f33), /* 0.707106781 */
- costab17 = MAD_F(0x0abeb49a), /* 0.671558955 */
- costab18 = MAD_F(0x0a267993), /* 0.634393284 */
- costab19 = MAD_F(0x0987fbfe), /* 0.595699304 */
- costab20 = MAD_F(0x08e39d9d), /* 0.555570233 */
- costab21 = MAD_F(0x0839c3cd), /* 0.514102744 */
- costab22 = MAD_F(0x078ad74e), /* 0.471396737 */
- costab23 = MAD_F(0x06d74402), /* 0.427555093 */
- costab24 = MAD_F(0x061f78aa), /* 0.382683432 */
- costab25 = MAD_F(0x0563e69d), /* 0.336889853 */
- costab26 = MAD_F(0x04a5018c), /* 0.290284677 */
- costab27 = MAD_F(0x03e33f2f), /* 0.242980180 */
- costab28 = MAD_F(0x031f1708), /* 0.195090322 */
- costab29 = MAD_F(0x0259020e), /* 0.146730474 */
- costab30 = MAD_F(0x01917a6c), /* 0.098017140 */
- costab31 = MAD_F(0x00c8fb30) /* 0.049067674 */
- };
+# define costab1 MAD_F(0x0ffb10f2) /* 0.998795456 */
+# define costab2 MAD_F(0x0fec46d2) /* 0.995184727 */
+# define costab3 MAD_F(0x0fd3aac0) /* 0.989176510 */
+# define costab4 MAD_F(0x0fb14be8) /* 0.980785280 */
+# define costab5 MAD_F(0x0f853f7e) /* 0.970031253 */
+# define costab6 MAD_F(0x0f4fa0ab) /* 0.956940336 */
+# define costab7 MAD_F(0x0f109082) /* 0.941544065 */
+# define costab8 MAD_F(0x0ec835e8) /* 0.923879533 */
+# define costab9 MAD_F(0x0e76bd7a) /* 0.903989293 */
+# define costab10 MAD_F(0x0e1c5979) /* 0.881921264 */
+# define costab11 MAD_F(0x0db941a3) /* 0.857728610 */
+# define costab12 MAD_F(0x0d4db315) /* 0.831469612 */
+# define costab13 MAD_F(0x0cd9f024) /* 0.803207531 */
+# define costab14 MAD_F(0x0c5e4036) /* 0.773010453 */
+# define costab15 MAD_F(0x0bdaef91) /* 0.740951125 */
+# define costab16 MAD_F(0x0b504f33) /* 0.707106781 */
+# define costab17 MAD_F(0x0abeb49a) /* 0.671558955 */
+# define costab18 MAD_F(0x0a267993) /* 0.634393284 */
+# define costab19 MAD_F(0x0987fbfe) /* 0.595699304 */
+# define costab20 MAD_F(0x08e39d9d) /* 0.555570233 */
+# define costab21 MAD_F(0x0839c3cd) /* 0.514102744 */
+# define costab22 MAD_F(0x078ad74e) /* 0.471396737 */
+# define costab23 MAD_F(0x06d74402) /* 0.427555093 */
+# define costab24 MAD_F(0x061f78aa) /* 0.382683432 */
+# define costab25 MAD_F(0x0563e69d) /* 0.336889853 */
+# define costab26 MAD_F(0x04a5018c) /* 0.290284677 */
+# define costab27 MAD_F(0x03e33f2f) /* 0.242980180 */
+# define costab28 MAD_F(0x031f1708) /* 0.195090322 */
+# define costab29 MAD_F(0x0259020e) /* 0.146730474 */
+# define costab30 MAD_F(0x01917a6c) /* 0.098017140 */
+# define costab31 MAD_F(0x00c8fb30) /* 0.049067674 */
# endif
t0 = in[0] + in[31]; t16 = MUL(in[0] - in[31], costab1);
t1 = in[15] + in[16]; t17 = MUL(in[15] - in[16], costab31);
t41 = t16 + t17;
@@ -324,13 +320,13 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
t121 = t83 + t84;
t122 = t85 + t86;
t67 = t121 + t122;
- t49 = (t67 << 1) - t32;
+ t49 = (t67 * 2) - t32;
/* 3 */ hi[12][slot] = SHIFT(t49);
t125 = t89 + t90;
t126 = t91 + t92;
@@ -340,174 +336,174 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
t128 = t94 + t95;
t129 = t96 + t97;
t98 = t128 + t129;
- t68 = (t98 << 1) - t49;
+ t68 = (t98 * 2) - t49;
/* 5 */ hi[10][slot] = SHIFT(t68);
t132 = t100 + t101;
t133 = t102 + t103;
t104 = t132 + t133;
- t82 = (t104 << 1) - t58;
+ t82 = (t104 * 2) - t58;
/* 6 */ hi[ 9][slot] = SHIFT(t82);
t136 = t106 + t107;
t137 = t108 + t109;
t110 = t136 + t137;
- t87 = (t110 << 1) - t67;
+ t87 = (t110 * 2) - t67;
- t77 = (t87 << 1) - t68;
+ t77 = (t87 * 2) - t68;
/* 7 */ hi[ 8][slot] = SHIFT(t77);
t141 = MUL(t69 - t70, costab8);
t142 = MUL(t71 - t72, costab24);
t143 = t141 + t142;
/* 8 */ hi[ 7][slot] = SHIFT(t143);
/* 24 */ lo[ 8][slot] =
- SHIFT((MUL(t141 - t142, costab16) << 1) - t143);
+ SHIFT((MUL(t141 - t142, costab16) * 2) - t143);
t144 = MUL(t73 - t74, costab8);
t145 = MUL(t75 - t76, costab24);
t146 = t144 + t145;
- t88 = (t146 << 1) - t77;
+ t88 = (t146 * 2) - t77;
/* 9 */ hi[ 6][slot] = SHIFT(t88);
t148 = MUL(t78 - t79, costab8);
t149 = MUL(t80 - t81, costab24);
t150 = t148 + t149;
- t105 = (t150 << 1) - t82;
+ t105 = (t150 * 2) - t82;
/* 10 */ hi[ 5][slot] = SHIFT(t105);
t152 = MUL(t83 - t84, costab8);
t153 = MUL(t85 - t86, costab24);
t154 = t152 + t153;
- t111 = (t154 << 1) - t87;
+ t111 = (t154 * 2) - t87;
- t99 = (t111 << 1) - t88;
+ t99 = (t111 * 2) - t88;
/* 11 */ hi[ 4][slot] = SHIFT(t99);
t157 = MUL(t89 - t90, costab8);
t158 = MUL(t91 - t92, costab24);
t159 = t157 + t158;
- t127 = (t159 << 1) - t93;
+ t127 = (t159 * 2) - t93;
/* 12 */ hi[ 3][slot] = SHIFT(t127);
- t160 = (MUL(t125 - t126, costab16) << 1) - t127;
+ t160 = (MUL(t125 - t126, costab16) * 2) - t127;
/* 20 */ lo[ 4][slot] = SHIFT(t160);
/* 28 */ lo[12][slot] =
- SHIFT((((MUL(t157 - t158, costab16) << 1) - t159) << 1) - t160);
+ SHIFT((((MUL(t157 - t158, costab16) * 2) - t159) * 2) - t160);
t161 = MUL(t94 - t95, costab8);
t162 = MUL(t96 - t97, costab24);
t163 = t161 + t162;
- t130 = (t163 << 1) - t98;
+ t130 = (t163 * 2) - t98;
- t112 = (t130 << 1) - t99;
+ t112 = (t130 * 2) - t99;
/* 13 */ hi[ 2][slot] = SHIFT(t112);
- t164 = (MUL(t128 - t129, costab16) << 1) - t130;
+ t164 = (MUL(t128 - t129, costab16) * 2) - t130;
t166 = MUL(t100 - t101, costab8);
t167 = MUL(t102 - t103, costab24);
t168 = t166 + t167;
- t134 = (t168 << 1) - t104;
+ t134 = (t168 * 2) - t104;
- t120 = (t134 << 1) - t105;
+ t120 = (t134 * 2) - t105;
/* 14 */ hi[ 1][slot] = SHIFT(t120);
- t135 = (MUL(t118 - t119, costab16) << 1) - t120;
+ t135 = (MUL(t118 - t119, costab16) * 2) - t120;
/* 18 */ lo[ 2][slot] = SHIFT(t135);
- t169 = (MUL(t132 - t133, costab16) << 1) - t134;
+ t169 = (MUL(t132 - t133, costab16) * 2) - t134;
- t151 = (t169 << 1) - t135;
+ t151 = (t169 * 2) - t135;
/* 22 */ lo[ 6][slot] = SHIFT(t151);
- t170 = (((MUL(t148 - t149, costab16) << 1) - t150) << 1) - t151;
+ t170 = (((MUL(t148 - t149, costab16) * 2) - t150) * 2) - t151;
/* 26 */ lo[10][slot] = SHIFT(t170);
/* 30 */ lo[14][slot] =
- SHIFT((((((MUL(t166 - t167, costab16) << 1) -
- t168) << 1) - t169) << 1) - t170);
+ SHIFT((((((MUL(t166 - t167, costab16) * 2) -
+ t168) * 2) - t169) * 2) - t170);
t171 = MUL(t106 - t107, costab8);
t172 = MUL(t108 - t109, costab24);
t173 = t171 + t172;
- t138 = (t173 << 1) - t110;
+ t138 = (t173 * 2) - t110;
- t123 = (t138 << 1) - t111;
+ t123 = (t138 * 2) - t111;
- t139 = (MUL(t121 - t122, costab16) << 1) - t123;
+ t139 = (MUL(t121 - t122, costab16) * 2) - t123;
- t117 = (t123 << 1) - t112;
+ t117 = (t123 * 2) - t112;
/* 15 */ hi[ 0][slot] = SHIFT(t117);
- t124 = (MUL(t115 - t116, costab16) << 1) - t117;
+ t124 = (MUL(t115 - t116, costab16) * 2) - t117;
/* 17 */ lo[ 1][slot] = SHIFT(t124);
- t131 = (t139 << 1) - t124;
+ t131 = (t139 * 2) - t124;
/* 19 */ lo[ 3][slot] = SHIFT(t131);
- t140 = (t164 << 1) - t131;
+ t140 = (t164 * 2) - t131;
/* 21 */ lo[ 5][slot] = SHIFT(t140);
- t174 = (MUL(t136 - t137, costab16) << 1) - t138;
+ t174 = (MUL(t136 - t137, costab16) * 2) - t138;
- t155 = (t174 << 1) - t139;
+ t155 = (t174 * 2) - t139;
- t147 = (t155 << 1) - t140;
+ t147 = (t155 * 2) - t140;
/* 23 */ lo[ 7][slot] = SHIFT(t147);
- t156 = (((MUL(t144 - t145, costab16) << 1) - t146) << 1) - t147;
+ t156 = (((MUL(t144 - t145, costab16) * 2) - t146) * 2) - t147;
/* 25 */ lo[ 9][slot] = SHIFT(t156);
- t175 = (((MUL(t152 - t153, costab16) << 1) - t154) << 1) - t155;
+ t175 = (((MUL(t152 - t153, costab16) * 2) - t154) * 2) - t155;
- t165 = (t175 << 1) - t156;
+ t165 = (t175 * 2) - t156;
/* 27 */ lo[11][slot] = SHIFT(t165);
- t176 = (((((MUL(t161 - t162, costab16) << 1) -
- t163) << 1) - t164) << 1) - t165;
+ t176 = (((((MUL(t161 - t162, costab16) * 2) -
+ t163) * 2) - t164) * 2) - t165;
/* 29 */ lo[13][slot] = SHIFT(t176);
/* 31 */ lo[15][slot] =
- SHIFT((((((((MUL(t171 - t172, costab16) << 1) -
- t173) << 1) - t174) << 1) - t175) << 1) - t176);
+ SHIFT((((((((MUL(t171 - t172, costab16) * 2) -
+ t173) * 2) - t174) * 2) - t175) * 2) - t176);
/*
* Totals:
* 80 multiplies
* 80 additions
* 119 subtractions
@@ -523,18 +519,20 @@ void dct32(mad_fixed_t const in[32], unsigned int slot,
# if defined(OPT_SSO)
# if MAD_F_FRACBITS != 28
# error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
# endif
# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
+# define MLN(hi, lo) ((lo) = -(lo))
# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define SHIFT(x) ((x) >> 2)
# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
# else
# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
+# define MLN(hi, lo) MAD_F_MLN((hi), (lo))
# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
# define SHIFT(x) (x)
# if defined(MAD_F_SCALEBITS)
# undef MAD_F_SCALEBITS
# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
# define PRESHIFT(x) (MAD_F(x) >> 12)
@@ -586,84 +584,86 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
fe = &(*filter)[0][ phase & 1][0];
fx = &(*filter)[0][~phase & 1][0];
fo = &(*filter)[1][~phase & 1][0];
Dptr = &D[0];
+ ptr = *Dptr + po;
+ ML0(hi, lo, (*fx)[0], ptr[ 0]);
+ MLA(hi, lo, (*fx)[1], ptr[14]);
+ MLA(hi, lo, (*fx)[2], ptr[12]);
+ MLA(hi, lo, (*fx)[3], ptr[10]);
+ MLA(hi, lo, (*fx)[4], ptr[ 8]);
+ MLA(hi, lo, (*fx)[5], ptr[ 6]);
+ MLA(hi, lo, (*fx)[6], ptr[ 4]);
+ MLA(hi, lo, (*fx)[7], ptr[ 2]);
+ MLN(hi, lo);
+
ptr = *Dptr + pe;
- ML0(hi, lo, (*fe)[0], ptr[ 0]);
+ MLA(hi, lo, (*fe)[0], ptr[ 0]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[7], ptr[ 2]);
- ptr = *Dptr + po;
- MLA(hi, lo, (*fx)[0], -ptr[ 0]);
- MLA(hi, lo, (*fx)[1], -ptr[14]);
- MLA(hi, lo, (*fx)[2], -ptr[12]);
- MLA(hi, lo, (*fx)[3], -ptr[10]);
- MLA(hi, lo, (*fx)[4], -ptr[ 8]);
- MLA(hi, lo, (*fx)[5], -ptr[ 6]);
- MLA(hi, lo, (*fx)[6], -ptr[ 4]);
- MLA(hi, lo, (*fx)[7], -ptr[ 2]);
-
*pcm1++ = SHIFT(MLZ(hi, lo));
pcm2 = pcm1 + 30;
for (sb = 1; sb < 16; ++sb) {
++fe;
++Dptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
+ ptr = *Dptr + po;
+ ML0(hi, lo, (*fo)[0], ptr[ 0]);
+ MLA(hi, lo, (*fo)[1], ptr[14]);
+ MLA(hi, lo, (*fo)[2], ptr[12]);
+ MLA(hi, lo, (*fo)[3], ptr[10]);
+ MLA(hi, lo, (*fo)[4], ptr[ 8]);
+ MLA(hi, lo, (*fo)[5], ptr[ 6]);
+ MLA(hi, lo, (*fo)[6], ptr[ 4]);
+ MLA(hi, lo, (*fo)[7], ptr[ 2]);
+ MLN(hi, lo);
+
ptr = *Dptr + pe;
- ML0(hi, lo, (*fe)[7], ptr[ 2]);
+ MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
- ptr = *Dptr + po;
- MLA(hi, lo, (*fo)[0], -ptr[ 0]);
- MLA(hi, lo, (*fo)[1], -ptr[14]);
- MLA(hi, lo, (*fo)[2], -ptr[12]);
- MLA(hi, lo, (*fo)[3], -ptr[10]);
- MLA(hi, lo, (*fo)[4], -ptr[ 8]);
- MLA(hi, lo, (*fo)[5], -ptr[ 6]);
- MLA(hi, lo, (*fo)[6], -ptr[ 4]);
- MLA(hi, lo, (*fo)[7], -ptr[ 2]);
-
*pcm1++ = SHIFT(MLZ(hi, lo));
- ptr = *Dptr - po;
- ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
- MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
- MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
- MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
- MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
- MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
- MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
- MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
-
ptr = *Dptr - pe;
- MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
+ ML0(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
+ ptr = *Dptr - po;
+ MLA(hi, lo, (*fo)[7], ptr[31 - 2]);
+ MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
+ MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
+ MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
+ MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
+ MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
+ MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
+ MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
+
*pcm2-- = SHIFT(MLZ(hi, lo));
++fo;
}
++Dptr;
@@ -721,63 +721,65 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame,
fe = &(*filter)[0][ phase & 1][0];
fx = &(*filter)[0][~phase & 1][0];
fo = &(*filter)[1][~phase & 1][0];
Dptr = &D[0];
+ ptr = *Dptr + po;
+ ML0(hi, lo, (*fx)[0], ptr[ 0]);
+ MLA(hi, lo, (*fx)[1], ptr[14]);
+ MLA(hi, lo, (*fx)[2], ptr[12]);
+ MLA(hi, lo, (*fx)[3], ptr[10]);
+ MLA(hi, lo, (*fx)[4], ptr[ 8]);
+ MLA(hi, lo, (*fx)[5], ptr[ 6]);
+ MLA(hi, lo, (*fx)[6], ptr[ 4]);
+ MLA(hi, lo, (*fx)[7], ptr[ 2]);
+ MLN(hi, lo);
+
ptr = *Dptr + pe;
- ML0(hi, lo, (*fe)[0], ptr[ 0]);
+ MLA(hi, lo, (*fe)[0], ptr[ 0]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[7], ptr[ 2]);
- ptr = *Dptr + po;
- MLA(hi, lo, (*fx)[0], -ptr[ 0]);
- MLA(hi, lo, (*fx)[1], -ptr[14]);
- MLA(hi, lo, (*fx)[2], -ptr[12]);
- MLA(hi, lo, (*fx)[3], -ptr[10]);
- MLA(hi, lo, (*fx)[4], -ptr[ 8]);
- MLA(hi, lo, (*fx)[5], -ptr[ 6]);
- MLA(hi, lo, (*fx)[6], -ptr[ 4]);
- MLA(hi, lo, (*fx)[7], -ptr[ 2]);
-
*pcm1++ = SHIFT(MLZ(hi, lo));
pcm2 = pcm1 + 14;
for (sb = 1; sb < 16; ++sb) {
++fe;
++Dptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
if (!(sb & 1)) {
+ ptr = *Dptr + po;
+ ML0(hi, lo, (*fo)[0], ptr[ 0]);
+ MLA(hi, lo, (*fo)[1], ptr[14]);
+ MLA(hi, lo, (*fo)[2], ptr[12]);
+ MLA(hi, lo, (*fo)[3], ptr[10]);
+ MLA(hi, lo, (*fo)[4], ptr[ 8]);
+ MLA(hi, lo, (*fo)[5], ptr[ 6]);
+ MLA(hi, lo, (*fo)[6], ptr[ 4]);
+ MLA(hi, lo, (*fo)[7], ptr[ 2]);
+ MLN(hi, lo);
+
ptr = *Dptr + pe;
- ML0(hi, lo, (*fe)[7], ptr[ 2]);
+ MLA(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
- ptr = *Dptr + po;
- MLA(hi, lo, (*fo)[0], -ptr[ 0]);
- MLA(hi, lo, (*fo)[1], -ptr[14]);
- MLA(hi, lo, (*fo)[2], -ptr[12]);
- MLA(hi, lo, (*fo)[3], -ptr[10]);
- MLA(hi, lo, (*fo)[4], -ptr[ 8]);
- MLA(hi, lo, (*fo)[5], -ptr[ 6]);
- MLA(hi, lo, (*fo)[6], -ptr[ 4]);
- MLA(hi, lo, (*fo)[7], -ptr[ 2]);
-
*pcm1++ = SHIFT(MLZ(hi, lo));
ptr = *Dptr - po;
ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -22,24 +22,43 @@
# ifndef LIBMAD_SYNTH_H
# define LIBMAD_SYNTH_H
# include "fixed.h"
# include "frame.h"
+struct mad_pcm {
+ unsigned int samplerate; /* sampling frequency (Hz) */
+ unsigned short channels; /* number of channels */
+ unsigned short length; /* number of samples per channel */
+ mad_fixed_t samples[2][1152]; /* PCM output samples [ch][sample] */
+};
+
struct mad_synth {
mad_fixed_t filter[2][2][2][16][8]; /* polyphase filterbank outputs */
/* [ch][eo][peo][s][v] */
unsigned int phase; /* current processing phase */
- struct mad_pcm {
- unsigned int samplerate; /* sampling frequency (Hz) */
- unsigned short channels; /* number of channels */
- unsigned short length; /* number of samples per channel */
- mad_fixed_t samples[2][1152]; /* PCM output samples */
- } pcm;
+ struct mad_pcm pcm; /* PCM output */
+};
+
+/* single channel PCM selector */
+enum {
+ MAD_PCM_CHANNEL_SINGLE = 0
+};
+
+/* dual channel PCM selector */
+enum {
+ MAD_PCM_CHANNEL_DUAL_1 = 0,
+ MAD_PCM_CHANNEL_DUAL_2 = 1
+};
+
+/* stereo PCM selector */
+enum {
+ MAD_PCM_CHANNEL_STEREO_LEFT = 0,
+ MAD_PCM_CHANNEL_STEREO_RIGHT = 1
};
void mad_synth_init(struct mad_synth *);
# define mad_synth_finish(synth) /* nothing */
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -23,13 +23,16 @@
# include "libmad_config.h"
# endif
# include "libmad_global.h"
# include <stdio.h>
-# include <assert.h>
+
+# ifdef HAVE_ASSERT_H
+# include <assert.h>
+# endif
# include "timer.h"
mad_timer_t const mad_timer_zero = { 0, 0 };
/*
@@ -147,74 +150,75 @@ unsigned long scale_rational(unsigned long numer, unsigned long denom,
return numer * scale / denom;
}
/*
* NAME: timer->set()
- * DESCRIPTION: set timer to specific value
+ * DESCRIPTION: set timer to specific (positive) value
*/
void mad_timer_set(mad_timer_t *timer, unsigned long seconds,
- unsigned long fraction, unsigned long fracparts)
+ unsigned long numer, unsigned long denom)
{
timer->seconds = seconds;
-
- if (fraction == 0)
- fracparts = 0;
- else if (fracparts == 0) {
- fracparts = fraction;
- fraction = 1;
+ if (numer >= denom && denom > 0) {
+ timer->seconds += numer / denom;
+ numer %= denom;
}
- switch (fracparts) {
+ switch (denom) {
case 0:
+ case 1:
timer->fraction = 0;
break;
case MAD_TIMER_RESOLUTION:
- timer->fraction = fraction;
+ timer->fraction = numer;
+ break;
+
+ case 1000:
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 1000);
break;
case 8000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 8000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 8000);
break;
case 11025:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 11025);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 11025);
break;
case 12000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 12000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 12000);
break;
case 16000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 16000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 16000);
break;
case 22050:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 22050);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 22050);
break;
case 24000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 24000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 24000);
break;
case 32000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 32000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 32000);
break;
case 44100:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 44100);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 44100);
break;
case 48000:
- timer->fraction = fraction * (MAD_TIMER_RESOLUTION / 48000);
+ timer->fraction = numer * (MAD_TIMER_RESOLUTION / 48000);
break;
default:
- timer->fraction =
- scale_rational(fraction, fracparts, MAD_TIMER_RESOLUTION);
+ timer->fraction = scale_rational(numer, denom, MAD_TIMER_RESOLUTION);
break;
}
if (timer->fraction >= MAD_TIMER_RESOLUTION)
reduce_timer(timer);
}
@@ -240,14 +244,14 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar)
{
mad_timer_t addend;
unsigned long factor;
factor = scalar;
if (scalar < 0) {
- mad_timer_negate(timer);
factor = -scalar;
+ mad_timer_negate(timer);
}
addend = *timer;
*timer = mad_timer_zero;
while (factor) {
@@ -314,25 +318,25 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
}
/*
* NAME: timer->fraction()
* DESCRIPTION: return fractional part of timer in arbitrary terms
*/
-unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts)
+unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
{
timer = mad_timer_abs(timer);
- switch (fracparts) {
+ switch (denom) {
case 0:
return MAD_TIMER_RESOLUTION / timer.fraction;
case MAD_TIMER_RESOLUTION:
return timer.fraction;
default:
- return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, fracparts);
+ return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom);
}
}
/*
* NAME: timer->string()
* DESCRIPTION: write a string representation of a timer using a template
@@ -374,18 +378,18 @@ void mad_timer_string(mad_timer_t timer,
case MAD_UNITS_30_FPS:
case MAD_UNITS_48_FPS:
case MAD_UNITS_50_FPS:
case MAD_UNITS_60_FPS:
case MAD_UNITS_75_FPS:
{
- unsigned long fracparts;
+ unsigned long denom;
- fracparts = MAD_TIMER_RESOLUTION / fracunits;
+ denom = MAD_TIMER_RESOLUTION / fracunits;
- frac = timer.fraction / fracparts;
- sub = scale_rational(timer.fraction % fracparts, fracparts, subparts);
+ frac = timer.fraction / denom;
+ sub = scale_rational(timer.fraction % denom, denom, subparts);
}
break;
case MAD_UNITS_23_976_FPS:
case MAD_UNITS_24_975_FPS:
case MAD_UNITS_29_97_FPS:
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -76,13 +76,13 @@ enum mad_units {
MAD_UNITS_29_97_FPS = -30,
MAD_UNITS_47_952_FPS = -48,
MAD_UNITS_49_95_FPS = -50,
MAD_UNITS_59_94_FPS = -60
};
-# define mad_timer_reset(timer) (*(timer) = mad_timer_zero)
+# define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
int mad_timer_compare(mad_timer_t, mad_timer_t);
# define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
void mad_timer_negate(mad_timer_t *);
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,8 +1,8 @@
/*
- * mad - MPEG audio decoder
+ * libmad - MPEG audio decoder library
* Copyright (C) 2000-2001 Robert Leslie
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
@@ -24,17 +24,17 @@
# endif
# include "libmad_global.h"
# include "libmad_version.h"
-char const mad_version[] = "MPEG Audio Decoder version " MAD_VERSION;
+char const mad_version[] = "MPEG Audio Decoder " MAD_VERSION;
char const mad_copyright[] = "Copyright (C) " MAD_PUBLISHYEAR " " MAD_AUTHOR;
char const mad_author[] = MAD_AUTHOR " <" MAD_EMAIL ">";
-char const mad_build[] =
+char const mad_build[] = ""
# if defined(FPM_64BIT)
"FPM_64BIT "
# elif defined(FPM_INTEL)
"FPM_INTEL "
# elif defined(FPM_ARM)
"FPM_ARM "