30 files changed, 578 insertions, 354 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -198,20 +198,37 @@ 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) ^ + 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; } 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -22,16 +22,11 @@ # 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 # endif # include "libmad_global.h" +# ifdef HAVE_SYS_TYPES_H # include <sys/types.h> +# endif # ifdef HAVE_SYS_WAIT_H @@ -43,7 +38,13 @@ # endif +# ifdef HAVE_FCNTL_H # include <fcntl.h> +# endif + # include <stdlib.h> + +# ifdef HAVE_ERRNO_H # include <errno.h> +# endif # include "stream.h" @@ -53,12 +54,16 @@ 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 *, @@ -87,4 +92,5 @@ void mad_decoder_init(struct mad_decoder *decoder, void *data, 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; @@ -93,7 +99,6 @@ int mad_decoder_finish(struct mad_decoder *decoder) close(decoder->async.in); - do { + do pid = waitpid(decoder->async.pid, &status, 0); - } while (pid == -1 && errno == EINTR); @@ -111,8 +116,10 @@ int mad_decoder_finish(struct mad_decoder *decoder) 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) @@ -122,7 +129,6 @@ enum mad_flow send_io(int fd, void const *data, size_t len) while (len) { - do { + do count = write(fd, ptr, len); - } while (count == -1 && errno == EINTR); @@ -144,7 +150,6 @@ enum mad_flow receive_io(int fd, void *buffer, size_t len) while (len) { - do { + do count = read(fd, ptr, len); - } while (count == -1 && errno == EINTR); @@ -282,4 +287,5 @@ enum mad_flow check_message(struct mad_decoder *decoder) return result; } +# endif static @@ -349,4 +355,5 @@ int run_sync(struct mad_decoder *decoder) while (1) { +# if defined(USE_ASYNC) if (decoder->mode == MAD_DECODER_MODE_ASYNC) { switch (check_message(decoder)) { @@ -360,4 +367,5 @@ int run_sync(struct mad_decoder *decoder) } } +# endif if (decoder->header_func) { @@ -410,5 +418,5 @@ int run_sync(struct mad_decoder *decoder) 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; @@ -451,4 +459,5 @@ int run_sync(struct mad_decoder *decoder) } +# if defined(USE_ASYNC) static int run_async(struct mad_decoder *decoder) @@ -512,4 +521,5 @@ int run_async(struct mad_decoder *decoder) return -1; } +# endif int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) @@ -524,5 +534,7 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) case MAD_DECODER_MODE_ASYNC: +# if defined(USE_ASYNC) run = run_async; +# endif break; } @@ -546,4 +558,5 @@ 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 || @@ -552,3 +565,6 @@ int mad_decoder_message(struct mad_decoder *decoder, 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -33,8 +33,8 @@ enum mad_decoder_mode { 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 */ }; @@ -60,5 +60,6 @@ struct mad_decoder { 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 *); @@ -70,5 +71,7 @@ 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 *, @@ -80,5 +83,6 @@ void mad_decoder_init(struct mad_decoder *, void *, 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); 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -35,4 +35,16 @@ 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 @@ -95,18 +107,29 @@ typedef unsigned long mad_fixed64lo_t; # 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 @@ -117,4 +140,27 @@ typedef unsigned long mad_fixed64lo_t; # 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 @@ -175,4 +221,5 @@ typedef unsigned long mad_fixed64lo_t; # define MAD_F_SCALEBITS MAD_F_FRACBITS +# endif /* --- ARM ----------------------------------------------------------------- */ @@ -218,4 +265,11 @@ typedef unsigned long mad_fixed64lo_t; : "%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; \ @@ -358,6 +412,10 @@ typedef unsigned long mad_fixed64lo_t; * Pre-rounding is required to stay within the limits of compliance. */ +# 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 /* ------------------------------------------------------------------------- */ @@ -381,4 +439,5 @@ typedef unsigned long mad_fixed64lo_t; # 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 @@ -388,4 +447,8 @@ typedef unsigned long mad_fixed64lo_t; # 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)) 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -374,5 +374,5 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream) /* 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; 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -46,5 +46,4 @@ enum mad_emphasis { }; -struct mad_frame { struct mad_header { enum mad_layer layer; /* audio layer (1, 2, or 3) */ @@ -63,5 +62,8 @@ struct mad_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) */ 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -35,6 +35,12 @@ */ -# define V(v, w, x, y, hlen) { { 1, hlen, v, w, x, y } } +# 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 @@ -101,6 +107,11 @@ union huffquad const hufftabB[] = { # undef PTR -# define V(x, y, hlen) { { 1, hlen, x, y } } +# 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 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -26,4 +26,9 @@ 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; @@ -32,4 +37,8 @@ union huffquad { unsigned short y : 1; } value; + unsigned short final : 1; +}; + +union huffpair { struct { unsigned short final : 1; @@ -37,8 +46,4 @@ union huffquad { unsigned short offset : 12; } ptr; - unsigned short final : 1; -}; - -union huffpair { struct { unsigned short final : 1; @@ -47,9 +52,4 @@ union huffpair { unsigned short y : 4; } value; - struct { - unsigned short final : 1; - unsigned short bits : 3; - unsigned short offset : 12; - } ptr; unsigned short final : 1; }; 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -28,5 +28,8 @@ # include <stdlib.h> # include <string.h> + +# ifdef HAVE_ASSERT_H # include <assert.h> +# endif # ifdef HAVE_LIMITS_H @@ -52,4 +55,9 @@ enum { }; +enum { + I_STEREO = 0x1, + MS_STEREO = 0x2 +}; + struct sideinfo { unsigned int main_data_begin; @@ -504,5 +512,5 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, { unsigned int ngr, gr, ch, i; - enum mad_error result = 0; + enum mad_error result = MAD_ERROR_NONE; *data_bitlen = 0; @@ -603,5 +611,5 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, ((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; @@ -644,5 +652,5 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, 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; @@ -776,4 +784,26 @@ unsigned int III_scalefactors(struct mad_bitptr *ptr, struct channel *channel, /* + * 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 @@ -857,21 +887,5 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) 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; @@ -885,7 +899,9 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) requantized = 0; } - else + else { + requantized += 1L << (-exp - 1); requantized >>= -exp; } + } else { if (exp >= 5) { @@ -1252,5 +1268,5 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], } - return 0; + return MAD_ERROR_NONE; } @@ -1267,12 +1283,16 @@ void III_reorder(mad_fixed_t xr[576], struct channel const *channel, { 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) { @@ -1281,8 +1301,13 @@ void III_reorder(mad_fixed_t xr[576], struct channel const *channel, } - 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]; @@ -1291,11 +1316,4 @@ void III_reorder(mad_fixed_t xr[576], struct channel const *channel, ++sbw[w]; } - - if (--f == 0) { - if (++w == 3) - w = 0; - - f = sfbwidth[++sfbi]; - } } @@ -1316,9 +1334,4 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], unsigned int sfbi, l, n, i; - enum { - i_stereo = 0x1, - ms_stereo = 0x2 - }; - if (granule->ch[0].block_type != granule->ch[1].block_type || @@ -1332,5 +1345,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], /* 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]; @@ -1388,5 +1401,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], for (i = 0; i < lower; ++i) - modes[i] = header->mode_extension & ~i_stereo; + modes[i] = header->mode_extension & ~I_STEREO; /* short blocks */ @@ -1395,5 +1408,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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; @@ -1418,5 +1431,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], for (i = 0; i < bound; ++i) - modes[i] = header->mode_extension & ~i_stereo; + modes[i] = header->mode_extension & ~I_STEREO; } @@ -1433,9 +1446,9 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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; } @@ -1469,5 +1482,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], n = sfbwidth[sfbi]; - if (!(modes[sfbi] & i_stereo)) + if (!(modes[sfbi] & I_STEREO)) continue; @@ -1475,5 +1488,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], if (is_pos >= 7) { /* illegal intensity position */ - modes[sfbi] &= ~i_stereo; + modes[sfbi] &= ~I_STEREO; continue; } @@ -1493,5 +1506,5 @@ 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; @@ -1503,5 +1516,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], n = sfbwidth[sfbi]; - if (modes[sfbi] != ms_stereo) + if (modes[sfbi] != MS_STEREO) continue; @@ -1518,5 +1531,5 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], } - return 0; + return MAD_ERROR_NONE; } @@ -1534,13 +1547,10 @@ void III_aliasreduce(mad_fixed_t xr[576], int 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) @@ -1550,10 +1560,10 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines) 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) } @@ -2142,5 +2152,5 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) */ static -int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, +enum mad_error III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, struct sideinfo *si, unsigned int nch) { @@ -2170,5 +2180,5 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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; @@ -2179,7 +2189,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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; } @@ -2195,5 +2205,5 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, } - 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; @@ -2203,5 +2213,5 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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; @@ -2217,5 +2227,5 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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) @@ -2301,5 +2311,5 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, } - return 0; + return MAD_ERROR_NONE; } 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -43,3 +43,16 @@ # 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -24,6 +24,6 @@ # 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)" 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 @@ -2,5 +2,5 @@ Files: plugins/codecs/libmadplugin.so.1.0.0 plugins/codecs/libmadplugin.so.1.0 p 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 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -55,5 +55,5 @@ void mad_stream_init(struct mad_stream *stream) stream->options = 0; - stream->error = 0; + stream->error = MAD_ERROR_NONE; } @@ -122,2 +122,39 @@ int mad_stream_sync(struct mad_stream *stream) 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -29,4 +29,6 @@ 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 */ @@ -81,9 +83,9 @@ struct mad_stream { 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 }; @@ -92,5 +94,6 @@ 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 *, @@ -100,3 +103,5 @@ 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -151,71 +151,67 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, # 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 @@ -328,5 +324,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t67 = t121 + t122; - t49 = (t67 << 1) - t32; + t49 = (t67 * 2) - t32; /* 3 */ hi[12][slot] = SHIFT(t49); @@ -344,5 +340,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t98 = t128 + t129; - t68 = (t98 << 1) - t49; + t68 = (t98 * 2) - t49; /* 5 */ hi[10][slot] = SHIFT(t68); @@ -353,5 +349,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t104 = t132 + t133; - t82 = (t104 << 1) - t58; + t82 = (t104 * 2) - t58; /* 6 */ hi[ 9][slot] = SHIFT(t82); @@ -362,7 +358,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -374,5 +370,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, /* 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); @@ -380,5 +376,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t146 = t144 + t145; - t88 = (t146 << 1) - t77; + t88 = (t146 * 2) - t77; /* 9 */ hi[ 6][slot] = SHIFT(t88); @@ -388,5 +384,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t150 = t148 + t149; - t105 = (t150 << 1) - t82; + t105 = (t150 * 2) - t82; /* 10 */ hi[ 5][slot] = SHIFT(t105); @@ -396,7 +392,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -406,13 +402,13 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -420,11 +416,11 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -432,26 +428,26 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -459,51 +455,51 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); /* @@ -527,4 +523,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, # 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) @@ -533,4 +530,5 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, # 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) @@ -590,6 +588,17 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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]); @@ -600,14 +609,4 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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)); @@ -620,6 +619,17 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, /* 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]); @@ -630,28 +640,8 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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]); @@ -662,4 +652,14 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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)); @@ -725,6 +725,17 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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]); @@ -735,14 +746,4 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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)); @@ -756,6 +757,17 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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]); @@ -766,14 +778,4 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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)); 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -26,4 +26,11 @@ # 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 */ @@ -32,10 +39,22 @@ struct mad_synth { 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 }; 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -27,5 +27,8 @@ # include <stdio.h> + +# ifdef HAVE_ASSERT_H # include <assert.h> +# endif # include "timer.h" @@ -151,66 +154,67 @@ unsigned long scale_rational(unsigned long numer, unsigned long 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; } @@ -244,6 +248,6 @@ void mad_timer_multiply(mad_timer_t *timer, signed long scalar) factor = scalar; if (scalar < 0) { - mad_timer_negate(timer); factor = -scalar; + mad_timer_negate(timer); } @@ -318,9 +322,9 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units) * 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; @@ -330,5 +334,5 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts) default: - return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, fracparts); + return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); } } @@ -378,10 +382,10 @@ void mad_timer_string(mad_timer_t timer, 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; 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -80,5 +80,5 @@ enum mad_units { }; -# 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); 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,4 +1,4 @@ /* - * mad - MPEG audio decoder + * libmad - MPEG audio decoder library * Copyright (C) 2000-2001 Robert Leslie * @@ -28,9 +28,9 @@ # 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 " |