author | harlekin <harlekin> | 2002-04-19 16:08:55 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-19 16:08:55 (UTC) |
commit | 7ea4abeb652e6787e57a938e1ca028d25fd249ce (patch) (side-by-side diff) | |
tree | ee08f2d9d6aaa8adb1c5f07f4124da8a61eb8cd5 | |
parent | caa7ced77b9014526607f9f65c58aabe7e0ba631 (diff) | |
download | opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.zip opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.gz opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.bz2 |
new libmad version, less cpu usage
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,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/bit.c b/core/multimedia/opieplayer/libmad/bit.c index 2466c5f..4a4661b 100644 --- a/core/multimedia/opieplayer/libmad/bit.c +++ b/core/multimedia/opieplayer/libmad/bit.c @@ -1,5 +1,5 @@ /* - * 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 @@ -197,22 +197,39 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, 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; } diff --git a/core/multimedia/opieplayer/libmad/bit.h b/core/multimedia/opieplayer/libmad/bit.h index f315bc9..3448d40 100644 --- a/core/multimedia/opieplayer/libmad/bit.h +++ b/core/multimedia/opieplayer/libmad/bit.h @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/decoder.c b/core/multimedia/opieplayer/libmad/decoder.c index dcf7cf3..b2b6cbb 100644 --- a/core/multimedia/opieplayer/libmad/decoder.c +++ b/core/multimedia/opieplayer/libmad/decoder.c @@ -1,5 +1,5 @@ /* - * 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 @@ -20,19 +20,14 @@ */ # 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> @@ -42,9 +37,15 @@ # 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" @@ -52,14 +53,18 @@ # 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 *)) @@ -86,15 +91,15 @@ 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; int status; close(decoder->async.in); - do { + do pid = waitpid(decoder->async.pid, &status, 0); - } while (pid == -1 && errno == EINTR); decoder->mode = -1; @@ -110,10 +115,12 @@ 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) { @@ -121,9 +128,8 @@ enum mad_flow send_io(int fd, void const *data, size_t len) ssize_t count; while (len) { - do { + do count = write(fd, ptr, len); - } while (count == -1 && errno == EINTR); if (count == -1) @@ -143,9 +149,8 @@ enum mad_flow receive_io(int fd, void *buffer, size_t len) ssize_t count; while (len) { - do { + do count = read(fd, ptr, len); - } while (count == -1 && errno == EINTR); if (count == -1) @@ -281,6 +286,7 @@ enum mad_flow check_message(struct mad_decoder *decoder) return result; } +# endif static enum mad_flow error_default(void *data, struct mad_stream *stream, @@ -348,6 +354,7 @@ int run_sync(struct mad_decoder *decoder) } while (1) { +# if defined(USE_ASYNC) if (decoder->mode == MAD_DECODER_MODE_ASYNC) { switch (check_message(decoder)) { case MAD_FLOW_IGNORE: @@ -359,6 +366,7 @@ int run_sync(struct mad_decoder *decoder) goto done; } } +# endif if (decoder->header_func) { if (mad_header_decode(&frame->header, stream) == -1) { @@ -409,7 +417,7 @@ int run_sync(struct mad_decoder *decoder) 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: @@ -450,6 +458,7 @@ int run_sync(struct mad_decoder *decoder) return result; } +# if defined(USE_ASYNC) static int run_async(struct mad_decoder *decoder) { @@ -511,6 +520,7 @@ int run_async(struct mad_decoder *decoder) /* not reached */ return -1; } +# endif int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) { @@ -523,7 +533,9 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) break; case MAD_DECODER_MODE_ASYNC: +# if defined(USE_ASYNC) run = run_async; +# endif break; } @@ -545,10 +557,14 @@ int mad_decoder_run(struct mad_decoder *decoder, enum mad_decoder_mode mode) 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,5 +1,5 @@ /* - * 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 @@ -32,10 +32,10 @@ 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 */ }; struct mad_decoder { @@ -59,7 +59,8 @@ 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 *); enum mad_flow (*error_func)(void *, struct mad_stream *, struct mad_frame *); @@ -69,7 +70,9 @@ struct mad_decoder { 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 *), @@ -79,7 +82,8 @@ void mad_decoder_init(struct mad_decoder *, void *, 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 *); diff --git a/core/multimedia/opieplayer/libmad/fixed.c b/core/multimedia/opieplayer/libmad/fixed.c index be5c94e..af1e87e 100644 --- a/core/multimedia/opieplayer/libmad/fixed.c +++ b/core/multimedia/opieplayer/libmad/fixed.c @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/fixed.h b/core/multimedia/opieplayer/libmad/fixed.h index 00ade62..c9b98ca 100644 --- a/core/multimedia/opieplayer/libmad/fixed.h +++ b/core/multimedia/opieplayer/libmad/fixed.h @@ -1,5 +1,5 @@ /* - * 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 @@ -34,6 +34,18 @@ 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) @@ -94,20 +106,31 @@ typedef unsigned long mad_fixed64lo_t; # 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 @@ -116,21 +139,44 @@ 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 * 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)); \ @@ -140,13 +186,13 @@ typedef unsigned long mad_fixed64lo_t; : "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; \ @@ -162,8 +208,8 @@ typedef unsigned long mad_fixed64lo_t; : "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) \ @@ -171,9 +217,10 @@ typedef unsigned long mad_fixed64lo_t; : "cc"); \ __result; \ }) -# endif /* OPT_ACCURACY */ +# endif /* OPT_ACCURACY */ -# define MAD_F_SCALEBITS MAD_F_FRACBITS +# define MAD_F_SCALEBITS MAD_F_FRACBITS +# endif /* --- ARM ----------------------------------------------------------------- */ @@ -217,6 +264,13 @@ typedef unsigned long mad_fixed64lo_t; : "+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" \ @@ -357,8 +411,12 @@ typedef unsigned long mad_fixed64lo_t; * * 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 /* ------------------------------------------------------------------------- */ @@ -380,6 +438,7 @@ typedef unsigned long mad_fixed64lo_t; # 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 @@ -387,6 +446,10 @@ typedef unsigned long mad_fixed64lo_t; # 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 diff --git a/core/multimedia/opieplayer/libmad/frame.c b/core/multimedia/opieplayer/libmad/frame.c index 4ebb80c..bf15e7f 100644 --- a/core/multimedia/opieplayer/libmad/frame.c +++ b/core/multimedia/opieplayer/libmad/frame.c @@ -1,5 +1,5 @@ /* - * 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 @@ -373,7 +373,7 @@ 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,5 +1,5 @@ /* - * 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 @@ -45,24 +45,26 @@ enum mad_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) */ @@ -77,26 +79,26 @@ struct mad_frame { ((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 *); diff --git a/core/multimedia/opieplayer/libmad/huffman.c b/core/multimedia/opieplayer/libmad/huffman.c index 8ec9499..5ea6547 100644 --- a/core/multimedia/opieplayer/libmad/huffman.c +++ b/core/multimedia/opieplayer/libmad/huffman.c @@ -1,5 +1,5 @@ /* - * 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 @@ -34,8 +34,14 @@ * 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[] = { @@ -100,8 +106,13 @@ union huffquad const hufftabB[] = { # 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[] = { diff --git a/core/multimedia/opieplayer/libmad/huffman.h b/core/multimedia/opieplayer/libmad/huffman.h index 1801210..d051949 100644 --- a/core/multimedia/opieplayer/libmad/huffman.h +++ b/core/multimedia/opieplayer/libmad/huffman.h @@ -1,5 +1,5 @@ /* - * 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 @@ -25,32 +25,32 @@ 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; }; diff --git a/core/multimedia/opieplayer/libmad/imdct_s.dat b/core/multimedia/opieplayer/libmad/imdct_s.dat index 00d62eb..ed70446 100644 --- a/core/multimedia/opieplayer/libmad/imdct_s.dat +++ b/core/multimedia/opieplayer/libmad/imdct_s.dat @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/layer12.c b/core/multimedia/opieplayer/libmad/layer12.c index 41b17ca..d291174 100644 --- a/core/multimedia/opieplayer/libmad/layer12.c +++ b/core/multimedia/opieplayer/libmad/layer12.c @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/layer12.h b/core/multimedia/opieplayer/libmad/layer12.h index d2c81ac..c673726 100644 --- a/core/multimedia/opieplayer/libmad/layer12.h +++ b/core/multimedia/opieplayer/libmad/layer12.h @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/layer3.c b/core/multimedia/opieplayer/libmad/layer3.c index 194fc7e..03f13fe 100644 --- a/core/multimedia/opieplayer/libmad/layer3.c +++ b/core/multimedia/opieplayer/libmad/layer3.c @@ -1,5 +1,5 @@ /* - * 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 @@ -27,7 +27,10 @@ # include <stdlib.h> # include <string.h> -# include <assert.h> + +# ifdef HAVE_ASSERT_H +# include <assert.h> +# endif # ifdef HAVE_LIMITS_H # include <limits.h> @@ -51,6 +54,11 @@ enum { mixed_block_flag = 0x08 }; +enum { + I_STEREO = 0x1, + MS_STEREO = 0x2 +}; + struct sideinfo { unsigned int main_data_begin; unsigned int private_bits; @@ -503,7 +511,7 @@ enum mad_error III_sideinfo(struct mad_bitptr *ptr, unsigned int nch, 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); @@ -602,7 +610,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, 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; @@ -643,7 +651,7 @@ unsigned int III_scalefactors_lsf(struct mad_bitptr *ptr, 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) { @@ -775,6 +783,28 @@ 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 */ @@ -856,23 +886,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) 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]; @@ -884,8 +898,10 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) /* underflow */ requantized = 0; } - else + else { + requantized += 1L << (-exp - 1); requantized >>= -exp; + } } else { if (exp >= 5) { @@ -1251,7 +1267,7 @@ enum mad_error III_huffdecode(struct mad_bitptr *ptr, mad_fixed_t xr[576], xrptr += 2; } - return 0; + return MAD_ERROR_NONE; } # undef MASK @@ -1266,37 +1282,39 @@ 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)); @@ -1315,11 +1333,6 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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) != @@ -1331,7 +1344,7 @@ 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]; unsigned int is_pos; @@ -1387,14 +1400,14 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], /* 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; } @@ -1417,7 +1430,7 @@ 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; } /* now do the actual processing */ @@ -1432,11 +1445,11 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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; } @@ -1468,13 +1481,13 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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; } @@ -1492,7 +1505,7 @@ 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; @@ -1502,7 +1515,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], 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) { @@ -1517,7 +1530,7 @@ enum mad_error III_stereo(mad_fixed_t xr[2][576], } } - return 0; + return MAD_ERROR_NONE; } /* @@ -1533,15 +1546,12 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines) 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) { @@ -1549,12 +1559,12 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines) 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 @@ -2141,8 +2151,8 @@ void III_freqinver(mad_fixed_t sample[18][32], unsigned int sb) * 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; @@ -2169,7 +2179,7 @@ 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; enum mad_error error; @@ -2178,9 +2188,9 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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; } @@ -2194,7 +2204,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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; } @@ -2202,7 +2212,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, /* 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; } @@ -2216,7 +2226,7 @@ int III_decode(struct mad_bitptr *ptr, struct mad_frame *frame, 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) /* @@ -2300,7 +2310,7 @@ 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,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/libmad_global.h b/core/multimedia/opieplayer/libmad/libmad_global.h index f2a2a71..2c9c713 100644 --- a/core/multimedia/opieplayer/libmad/libmad_global.h +++ b/core/multimedia/opieplayer/libmad/libmad_global.h @@ -1,5 +1,5 @@ /* - * 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 @@ -42,4 +42,17 @@ # 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,5 +1,5 @@ /* - * 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 @@ -23,8 +23,8 @@ # 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 diff --git a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control index 941047f..42ea6c7 100644 --- a/core/multimedia/opieplayer/libmad/opie-libmadplugin.control +++ b/core/multimedia/opieplayer/libmad/opie-libmadplugin.control @@ -1,7 +1,7 @@ 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) diff --git a/core/multimedia/opieplayer/libmad/qc_table.dat b/core/multimedia/opieplayer/libmad/qc_table.dat index 92b7f38..5d9ca96 100644 --- a/core/multimedia/opieplayer/libmad/qc_table.dat +++ b/core/multimedia/opieplayer/libmad/qc_table.dat @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/rq_table.dat b/core/multimedia/opieplayer/libmad/rq_table.dat index b6d1634..803cf04 100644 --- a/core/multimedia/opieplayer/libmad/rq_table.dat +++ b/core/multimedia/opieplayer/libmad/rq_table.dat @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/sf_table.dat b/core/multimedia/opieplayer/libmad/sf_table.dat index 18e6202..bc368af 100644 --- a/core/multimedia/opieplayer/libmad/sf_table.dat +++ b/core/multimedia/opieplayer/libmad/sf_table.dat @@ -1,5 +1,5 @@ /* - * 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 diff --git a/core/multimedia/opieplayer/libmad/stream.c b/core/multimedia/opieplayer/libmad/stream.c index dea7b8e..4374de7 100644 --- a/core/multimedia/opieplayer/libmad/stream.c +++ b/core/multimedia/opieplayer/libmad/stream.c @@ -1,5 +1,5 @@ /* - * 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 @@ -54,7 +54,7 @@ void mad_stream_init(struct mad_stream *stream) stream->md_len = 0; stream->options = 0; - stream->error = 0; + stream->error = MAD_ERROR_NONE; } /* @@ -121,3 +121,40 @@ 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,5 +1,5 @@ /* - * 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 @@ -28,6 +28,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 */ @@ -80,18 +82,19 @@ 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 }; 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); @@ -99,4 +102,6 @@ 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,5 +1,5 @@ /* - * 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 @@ -150,73 +150,69 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, /* 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); @@ -327,7 +323,7 @@ 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); @@ -343,7 +339,7 @@ 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); @@ -352,7 +348,7 @@ 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); @@ -361,9 +357,9 @@ 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); @@ -373,13 +369,13 @@ 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); t145 = MUL(t75 - t76, costab24); t146 = t144 + t145; - t88 = (t146 << 1) - t77; + t88 = (t146 * 2) - t77; /* 9 */ hi[ 6][slot] = SHIFT(t88); @@ -387,7 +383,7 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, t149 = MUL(t80 - t81, costab24); t150 = t148 + t149; - t105 = (t150 << 1) - t82; + t105 = (t150 * 2) - t82; /* 10 */ hi[ 5][slot] = SHIFT(t105); @@ -395,9 +391,9 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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); @@ -405,106 +401,106 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, 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: @@ -526,12 +522,14 @@ void dct32(mad_fixed_t const in[32], unsigned int slot, # 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) @@ -589,8 +587,19 @@ 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]); MLA(hi, lo, (*fe)[3], ptr[10]); @@ -599,16 +608,6 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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; @@ -619,8 +618,19 @@ 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]); MLA(hi, lo, (*fe)[4], ptr[ 8]); @@ -629,30 +639,10 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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]); @@ -661,6 +651,16 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, 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; @@ -724,8 +724,19 @@ 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]); MLA(hi, lo, (*fe)[3], ptr[10]); @@ -734,16 +745,6 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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; @@ -755,8 +756,19 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, /* 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]); @@ -765,16 +777,6 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, 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; diff --git a/core/multimedia/opieplayer/libmad/synth.h b/core/multimedia/opieplayer/libmad/synth.h index 64f6a86..2c9d5c8 100644 --- a/core/multimedia/opieplayer/libmad/synth.h +++ b/core/multimedia/opieplayer/libmad/synth.h @@ -1,5 +1,5 @@ /* - * 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 @@ -25,18 +25,37 @@ # 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 *); diff --git a/core/multimedia/opieplayer/libmad/timer.c b/core/multimedia/opieplayer/libmad/timer.c index b30680c..299fe0b 100644 --- a/core/multimedia/opieplayer/libmad/timer.c +++ b/core/multimedia/opieplayer/libmad/timer.c @@ -1,5 +1,5 @@ /* - * 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 @@ -26,7 +26,10 @@ # include "libmad_global.h" # include <stdio.h> -# include <assert.h> + +# ifdef HAVE_ASSERT_H +# include <assert.h> +# endif # include "timer.h" @@ -150,68 +153,69 @@ 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; } @@ -243,8 +247,8 @@ 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); } addend = *timer; @@ -317,11 +321,11 @@ 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; @@ -329,7 +333,7 @@ unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long fracparts) return timer.fraction; default: - return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, fracparts); + return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); } } @@ -377,12 +381,12 @@ void mad_timer_string(mad_timer_t timer, 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; diff --git a/core/multimedia/opieplayer/libmad/timer.h b/core/multimedia/opieplayer/libmad/timer.h index 67fe16a..f8afb8e 100644 --- a/core/multimedia/opieplayer/libmad/timer.h +++ b/core/multimedia/opieplayer/libmad/timer.h @@ -1,5 +1,5 @@ /* - * 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 @@ -79,7 +79,7 @@ enum mad_units { 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); diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c index 413d54b..fb126f4 100644 --- a/core/multimedia/opieplayer/libmad/version.c +++ b/core/multimedia/opieplayer/libmad/version.c @@ -1,5 +1,5 @@ /* - * 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 @@ -27,11 +27,11 @@ # 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) |