From e2d2baece9230967d8f1d5fdb5259515c2fb03c7 Mon Sep 17 00:00:00 2001
From: Warren Dukes <warren.dukes@gmail.com>
Date: Thu, 4 Mar 2004 23:19:57 +0000
Subject: [PATCH] update to 0.15.1 of libmad and libid3tag

git-svn-id: https://svn.musicpd.org/mpd/trunk@196 09075e82-0dd4-0310-85a5-a0d7c8717e4f
---
 configure.ac                  |   2 +-
 src/libid3tag/CHANGES         |  12 +-
 src/libid3tag/COPYRIGHT       |   2 +-
 src/libid3tag/CREDITS         |   4 +-
 src/libid3tag/Makefile.am     |   8 +-
 src/libid3tag/README          |   4 +-
 src/libid3tag/TODO            |   4 +-
 src/libid3tag/VERSION         |   6 +-
 src/libid3tag/compat.gperf    |   4 +-
 src/libid3tag/compat.h        |   4 +-
 src/libid3tag/config.h.in     |   6 +-
 src/libid3tag/configure.ac    |   6 +-
 src/libid3tag/crc.c           |  10 +-
 src/libid3tag/crc.h           |   6 +-
 src/libid3tag/debug.c         |   4 +-
 src/libid3tag/debug.h         |   7 +-
 src/libid3tag/field.c         |  19 +++-
 src/libid3tag/field.h         |   4 +-
 src/libid3tag/file.c          |  11 +-
 src/libid3tag/file.h          |   4 +-
 src/libid3tag/frame.c         |   4 +-
 src/libid3tag/frame.h         |   4 +-
 src/libid3tag/frametype.gperf |   4 +-
 src/libid3tag/frametype.h     |   4 +-
 src/libid3tag/genre.c         |   4 +-
 src/libid3tag/genre.dat.in    |   4 +-
 src/libid3tag/genre.dat.sed   |   4 +-
 src/libid3tag/genre.h         |   4 +-
 src/libid3tag/global.h        |   4 +-
 src/libid3tag/id3tag.h        |   9 +-
 src/libid3tag/latin1.c        |   4 +-
 src/libid3tag/latin1.h        |   4 +-
 src/libid3tag/parse.c         |   4 +-
 src/libid3tag/parse.h         |   4 +-
 src/libid3tag/render.c        |   4 +-
 src/libid3tag/render.h        |   4 +-
 src/libid3tag/tag.c           |  10 +-
 src/libid3tag/tag.h           |   4 +-
 src/libid3tag/ucs4.c          |   4 +-
 src/libid3tag/ucs4.h          |   4 +-
 src/libid3tag/utf16.c         |   4 +-
 src/libid3tag/utf16.h         |   4 +-
 src/libid3tag/utf8.c          |   4 +-
 src/libid3tag/utf8.h          |   4 +-
 src/libid3tag/util.c          |   4 +-
 src/libid3tag/util.h          |   4 +-
 src/libid3tag/version.c       |   4 +-
 src/libid3tag/version.h       |   4 +-
 src/libmad/CHANGES            |  29 ++++-
 src/libmad/COPYRIGHT          |   2 +-
 src/libmad/CREDITS            |  20 +++-
 src/libmad/D.dat              |   4 +-
 src/libmad/Makefile.am        |   6 +-
 src/libmad/README             |   4 +-
 src/libmad/TODO               |   5 +-
 src/libmad/VERSION            |   8 +-
 src/libmad/bit.c              |   4 +-
 src/libmad/bit.h              |   4 +-
 src/libmad/config.h.in        |  10 +-
 src/libmad/configure.ac       |   7 +-
 src/libmad/decoder.c          |   4 +-
 src/libmad/decoder.h          |   4 +-
 src/libmad/fixed.c            |   4 +-
 src/libmad/fixed.h            |  21 +++-
 src/libmad/frame.c            |   7 +-
 src/libmad/frame.h            |   4 +-
 src/libmad/global.h           |   4 +-
 src/libmad/huffman.c          |  33 ++++--
 src/libmad/huffman.h          |   4 +-
 src/libmad/imdct_l_arm.S      |   2 +-
 src/libmad/imdct_s.dat        |   4 +-
 src/libmad/layer12.c          |  50 ++++++---
 src/libmad/layer12.h          |   4 +-
 src/libmad/layer3.c           | 204 +++++++++++++++++++++++++++++++++-
 src/libmad/layer3.h           |   4 +-
 src/libmad/mad.h.sed          |   4 +-
 src/libmad/minimad.c          |  14 +--
 src/libmad/qc_table.dat       |   4 +-
 src/libmad/rq_table.dat       |   4 +-
 src/libmad/sf_table.dat       |   4 +-
 src/libmad/stream.c           |   5 +-
 src/libmad/stream.h           |   5 +-
 src/libmad/synth.c            |   4 +-
 src/libmad/synth.h            |   4 +-
 src/libmad/timer.c            |   4 +-
 src/libmad/timer.h            |   4 +-
 src/libmad/version.c          |   4 +-
 src/libmad/version.h          |   8 +-
 88 files changed, 540 insertions(+), 234 deletions(-)

diff --git a/configure.ac b/configure.ac
index 26a03fec0..7030dfc6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl AC_INIT(src/main.c)
 dnl AM_INIT_AUTOMAKE(mpd, 0.10.0)
 
 AC_PREREQ(2.52)
-AC_INIT(mpd, 0.10.0, shank@mercury.chem.pitt.edu)
+AC_INIT(mpd, 0.10.1, shank@mercury.chem.pitt.edu)
 AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
 
 AC_PROG_CC
diff --git a/src/libid3tag/CHANGES b/src/libid3tag/CHANGES
index 4fcc0cd58..f2bfaff65 100644
--- a/src/libid3tag/CHANGES
+++ b/src/libid3tag/CHANGES
@@ -1,11 +1,19 @@
 
  libid3tag - ID3 tag manipulation library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: CHANGES,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: CHANGES,v 1.11 2004/02/17 02:04:10 rob Exp $
 
 ===============================================================================
 
+Version 0.15.1 (beta)
+
+  * Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2.
+
+  * Fixed a potential problem in file.c when writing empty ID3v2 tags.
+
+  * Added new id3_field_gettextencoding() API routine.
+
 Version 0.15.0 (beta)
 
   * Updated to autoconf 2.57, automake 1.7.5, libtool 1.4.3.
diff --git a/src/libid3tag/COPYRIGHT b/src/libid3tag/COPYRIGHT
index c492f8d7a..072f7e247 100644
--- a/src/libid3tag/COPYRIGHT
+++ b/src/libid3tag/COPYRIGHT
@@ -1,6 +1,6 @@
 
  libid3tag - ID3 tag manipulation library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
  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
diff --git a/src/libid3tag/CREDITS b/src/libid3tag/CREDITS
index 888e71f9e..755047547 100644
--- a/src/libid3tag/CREDITS
+++ b/src/libid3tag/CREDITS
@@ -1,8 +1,8 @@
 
  libid3tag - ID3 tag manipulation library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: CREDITS,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: CREDITS,v 1.2 2004/01/23 09:41:32 rob Exp $
 
 ===============================================================================
 
diff --git a/src/libid3tag/Makefile.am b/src/libid3tag/Makefile.am
index 9c22d0845..0b93cab01 100644
--- a/src/libid3tag/Makefile.am
+++ b/src/libid3tag/Makefile.am
@@ -1,6 +1,6 @@
 ##
 ## libid3tag - ID3 tag manipulation library
-## Copyright (C) 2000-2003 Underbit Technologies, Inc.
+## Copyright (C) 2000-2004 Underbit Technologies, Inc.
 ##
 ## 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
@@ -16,7 +16,7 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ##
-## $Id: Makefile.am,v 1.1 2003/08/14 03:57:13 shank Exp $
+## $Id: Makefile.am,v 1.26 2004/02/17 02:11:28 rob Exp $
 ##
 
 ## Process this file with automake to produce Makefile.in
@@ -63,9 +63,9 @@ noinst_HEADERS =	id3tag.h
 ##   6. If any interfaces have been removed since the last public release,
 ##      then set AGE to 0.
 
-version_current =	2
+version_current =	3
 version_revision =	0
-version_age =		2
+version_age =		3
 
 version_info =		$(version_current):$(version_revision):$(version_age)
 
diff --git a/src/libid3tag/README b/src/libid3tag/README
index 217232d44..c918d4348 100644
--- a/src/libid3tag/README
+++ b/src/libid3tag/README
@@ -1,8 +1,8 @@
 
  libid3tag - ID3 tag manipulation library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: README,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: README,v 1.5 2004/01/23 09:41:32 rob Exp $
 
 ===============================================================================
 
diff --git a/src/libid3tag/TODO b/src/libid3tag/TODO
index 36faa7724..6fdc4065e 100644
--- a/src/libid3tag/TODO
+++ b/src/libid3tag/TODO
@@ -1,8 +1,8 @@
 
  libid3tag - ID3 tag manipulation library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: TODO,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: TODO,v 1.2 2004/01/23 09:41:32 rob Exp $
 
 ===============================================================================
 
diff --git a/src/libid3tag/VERSION b/src/libid3tag/VERSION
index 936f63572..574a7327f 100644
--- a/src/libid3tag/VERSION
+++ b/src/libid3tag/VERSION
@@ -1,6 +1,6 @@
-0.15.0b
+0.15.1b
 configure.ac:24
-id3tag.h:334-337
-msvc++/config.h:57
+id3tag.h:338-341
+msvc++/config.h:59,65,71
 
 Makefile.am:63-65
diff --git a/src/libid3tag/compat.gperf b/src/libid3tag/compat.gperf
index 17eaac162..4e24613c5 100644
--- a/src/libid3tag/compat.gperf
+++ b/src/libid3tag/compat.gperf
@@ -1,7 +1,7 @@
 %{
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: compat.gperf,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: compat.gperf,v 1.11 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/compat.h b/src/libid3tag/compat.h
index 5d980eea4..8af71ecc2 100644
--- a/src/libid3tag/compat.h
+++ b/src/libid3tag/compat.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: compat.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: compat.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_COMPAT_H
diff --git a/src/libid3tag/config.h.in b/src/libid3tag/config.h.in
index ba35b4be9..b4f0f8997 100644
--- a/src/libid3tag/config.h.in
+++ b/src/libid3tag/config.h.in
@@ -72,8 +72,6 @@
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+   if it is not supported. */
 #undef inline
-#endif
diff --git a/src/libid3tag/configure.ac b/src/libid3tag/configure.ac
index 9923cd362..a0b0feeb1 100644
--- a/src/libid3tag/configure.ac
+++ b/src/libid3tag/configure.ac
@@ -1,7 +1,7 @@
 dnl -*- m4 -*-
 dnl
 dnl libid3tag - ID3 tag manipulation library
-dnl Copyright (C) 2000-2003 Underbit Technologies, Inc.
+dnl Copyright (C) 2000-2004 Underbit Technologies, Inc.
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -17,11 +17,11 @@ dnl You should have received a copy of the GNU General Public License
 dnl along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 dnl
-AC_REVISION([$Id: configure.ac,v 1.1 2003/08/14 03:57:13 shank Exp $])dnl
+AC_REVISION([$Id: configure.ac,v 1.12 2004/01/23 23:22:46 rob Exp $])dnl
 
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([ID3 Tag], [0.15.0b], [support@underbit.com], [libid3tag])
+AC_INIT([ID3 Tag], [0.15.1b], [support@underbit.com], [libid3tag])
 AC_PREREQ(2.53)
 
 AC_CONFIG_SRCDIR([id3tag.h])
diff --git a/src/libid3tag/crc.c b/src/libid3tag/crc.c
index 76e78ea45..742a5d8f4 100644
--- a/src/libid3tag/crc.c
+++ b/src/libid3tag/crc.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: crc.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: crc.c,v 1.11 2004/02/17 02:04:10 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -104,10 +104,10 @@ unsigned long const crc_table[256] = {
 };
 
 /*
- * NAME:	crc->calculate()
- * DESCRIPTION:	compute CRC-32 value (ISO 3309)
+ * NAME:	crc->compute()
+ * DESCRIPTION:	calculate CRC-32 value (ISO 3309)
  */
-unsigned long id3_crc_calculate(id3_byte_t const *data, id3_length_t length)
+unsigned long id3_crc_compute(id3_byte_t const *data, id3_length_t length)
 {
   register unsigned long crc;
 
diff --git a/src/libid3tag/crc.h b/src/libid3tag/crc.h
index 6ff639053..89a5a3953 100644
--- a/src/libid3tag/crc.h
+++ b/src/libid3tag/crc.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: crc.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: crc.h,v 1.8 2004/02/17 02:04:10 rob Exp $
  */
 
 # ifndef LIBID3TAG_CRC_H
@@ -24,6 +24,6 @@
 
 # include "id3tag.h"
 
-unsigned long id3_crc_calculate(id3_byte_t const *, id3_length_t);
+unsigned long id3_crc_compute(id3_byte_t const *, id3_length_t);
 
 # endif
diff --git a/src/libid3tag/debug.c b/src/libid3tag/debug.c
index 78b11bba3..d91a2c56e 100644
--- a/src/libid3tag/debug.c
+++ b/src/libid3tag/debug.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: debug.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: debug.c,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/debug.h b/src/libid3tag/debug.h
index dc5b4997c..a9b4ce064 100644
--- a/src/libid3tag/debug.h
+++ b/src/libid3tag/debug.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: debug.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: debug.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_DEBUG_H
@@ -25,8 +25,7 @@
 # include <stdlib.h>
 
 void *id3_debug_malloc(size_t, char const *, unsigned int);
-void *id3_debug_calloc(size_t, size_t,
-		       char const *file, unsigned int line);
+void *id3_debug_calloc(size_t, size_t, char const *, unsigned int);
 void *id3_debug_realloc(void *, size_t, char const *, unsigned int);
 void id3_debug_free(void *, char const *, unsigned int);
 
diff --git a/src/libid3tag/field.c b/src/libid3tag/field.c
index a7b413edb..f2ecc0fd4 100644
--- a/src/libid3tag/field.c
+++ b/src/libid3tag/field.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: field.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: field.c,v 1.16 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -749,6 +749,21 @@ signed long id3_field_getint(union id3_field const *field)
   return field->number.value;
 }
 
+/*
+ * NAME:	field->gettextencoding()
+ * DESCRIPTION:	return the value of a text encoding field
+ */
+enum id3_field_textencoding
+id3_field_gettextencoding(union id3_field const *field)
+{
+  assert(field);
+
+  if (field->type != ID3_FIELD_TYPE_TEXTENCODING)
+    return -1;
+
+  return field->number.value;
+}
+
 /*
  * NAME:	field->getlatin1()
  * DESCRIPTION:	return the value of a latin1 field
diff --git a/src/libid3tag/field.h b/src/libid3tag/field.h
index a3da578f7..2cf42b90a 100644
--- a/src/libid3tag/field.h
+++ b/src/libid3tag/field.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: field.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: field.h,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_FIELD_H
diff --git a/src/libid3tag/file.c b/src/libid3tag/file.c
index 02150c06b..9d7319a76 100644
--- a/src/libid3tag/file.c
+++ b/src/libid3tag/file.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: file.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: file.c,v 1.21 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -522,7 +522,7 @@ int v1_write(struct id3_file *file,
     if (fseek(file->iofile, (file->flags & ID3_FILE_FLAG_ID3V1) ? -128 : 0,
 	      SEEK_END) == -1 ||
 	(location = ftell(file->iofile)) == -1 ||
-	fwrite(data, 128, 1, file->iofile) == 0 ||
+	fwrite(data, 128, 1, file->iofile) != 1 ||
 	fflush(file->iofile) == EOF)
       return -1;
 
@@ -577,13 +577,14 @@ int v2_write(struct id3_file *file,
 {
   assert(!data || length > 0);
 
-  if (((file->ntags == 1 && !(file->flags & ID3_FILE_FLAG_ID3V1)) ||
+  if (data &&
+      ((file->ntags == 1 && !(file->flags & ID3_FILE_FLAG_ID3V1)) ||
        (file->ntags == 2 &&  (file->flags & ID3_FILE_FLAG_ID3V1))) &&
       file->tags[0].length == length) {
     /* easy special case: rewrite existing tag in-place */
 
     if (fseek(file->iofile, file->tags[0].location, SEEK_SET) == -1 ||
-	fwrite(data, length, 1, file->iofile) == 0 ||
+	fwrite(data, length, 1, file->iofile) != 1 ||
 	fflush(file->iofile) == EOF)
       return -1;
 
diff --git a/src/libid3tag/file.h b/src/libid3tag/file.h
index da67af241..032b189f8 100644
--- a/src/libid3tag/file.h
+++ b/src/libid3tag/file.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: file.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: file.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_FILE_H
diff --git a/src/libid3tag/frame.c b/src/libid3tag/frame.c
index aafd54e27..1c680d9e9 100644
--- a/src/libid3tag/frame.c
+++ b/src/libid3tag/frame.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frame.c,v 1.15 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/frame.h b/src/libid3tag/frame.h
index dfa9bb927..05c6b04b0 100644
--- a/src/libid3tag/frame.h
+++ b/src/libid3tag/frame.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frame.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_FRAME_H
diff --git a/src/libid3tag/frametype.gperf b/src/libid3tag/frametype.gperf
index 5158f77b9..1c8ff2ea3 100644
--- a/src/libid3tag/frametype.gperf
+++ b/src/libid3tag/frametype.gperf
@@ -1,7 +1,7 @@
 %{
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frametype.gperf,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frametype.gperf,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/frametype.h b/src/libid3tag/frametype.h
index 9ace41468..dd064b245 100644
--- a/src/libid3tag/frametype.h
+++ b/src/libid3tag/frametype.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frametype.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frametype.h,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_FRAMETYPE_H
diff --git a/src/libid3tag/genre.c b/src/libid3tag/genre.c
index dda381a03..32fccb197 100644
--- a/src/libid3tag/genre.c
+++ b/src/libid3tag/genre.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: genre.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: genre.c,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/genre.dat.in b/src/libid3tag/genre.dat.in
index 9a7ad9c4e..872de4097 100644
--- a/src/libid3tag/genre.dat.in
+++ b/src/libid3tag/genre.dat.in
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: genre.dat.in,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: genre.dat.in,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 /*
diff --git a/src/libid3tag/genre.dat.sed b/src/libid3tag/genre.dat.sed
index c65740334..b8be6c5e0 100644
--- a/src/libid3tag/genre.dat.sed
+++ b/src/libid3tag/genre.dat.sed
@@ -1,6 +1,6 @@
 #
 # libid3tag - ID3 tag manipulation library
-# Copyright (C) 2000-2003 Underbit Technologies, Inc.
+# Copyright (C) 2000-2004 Underbit Technologies, Inc.
 #
 # 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
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
-# $Id: genre.dat.sed,v 1.1 2003/08/14 03:57:13 shank Exp $
+# $Id: genre.dat.sed,v 1.10 2004/01/23 09:41:32 rob Exp $
 #
 
 1i\
diff --git a/src/libid3tag/genre.h b/src/libid3tag/genre.h
index bd4b906e7..56d538ae8 100644
--- a/src/libid3tag/genre.h
+++ b/src/libid3tag/genre.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: genre.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: genre.h,v 1.6 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_GENRE_H
diff --git a/src/libid3tag/global.h b/src/libid3tag/global.h
index 86924b112..377a5e6f6 100644
--- a/src/libid3tag/global.h
+++ b/src/libid3tag/global.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: global.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: global.h,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_GLOBAL_H
diff --git a/src/libid3tag/id3tag.h b/src/libid3tag/id3tag.h
index a862eaeb1..4f4c6819a 100644
--- a/src/libid3tag/id3tag.h
+++ b/src/libid3tag/id3tag.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -19,7 +19,7 @@
  * If you would like to negotiate alternate licensing terms, you may do
  * so by contacting: Underbit Technologies, Inc. <info@underbit.com>
  *
- * $Id: id3tag.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: id3tag.h,v 1.17 2004/01/23 23:22:46 rob Exp $
  */
 
 # ifndef LIBID3TAG_ID3TAG_H
@@ -300,6 +300,7 @@ int id3_field_setbinarydata(union id3_field *,
 			    id3_byte_t const *, id3_length_t);
 
 signed long id3_field_getint(union id3_field const *);
+enum id3_field_textencoding id3_field_gettextencoding(union id3_field const *);
 id3_latin1_t const *id3_field_getlatin1(union id3_field const *);
 id3_latin1_t const *id3_field_getfulllatin1(union id3_field const *);
 id3_ucs4_t const *id3_field_getstring(union id3_field const *);
@@ -336,7 +337,7 @@ id3_ucs4_t *id3_utf8_ucs4duplicate(id3_utf8_t const *);
 
 # define ID3_VERSION_MAJOR	0
 # define ID3_VERSION_MINOR	15
-# define ID3_VERSION_PATCH	0
+# define ID3_VERSION_PATCH	1
 # define ID3_VERSION_EXTRA	" (beta)"
 
 # define ID3_VERSION_STRINGIZE(str)	#str
@@ -347,7 +348,7 @@ id3_ucs4_t *id3_utf8_ucs4duplicate(id3_utf8_t const *);
 			ID3_VERSION_STRING(ID3_VERSION_PATCH)  \
 			ID3_VERSION_EXTRA
 
-# define ID3_PUBLISHYEAR	"2000-2003"
+# define ID3_PUBLISHYEAR	"2000-2004"
 # define ID3_AUTHOR		"Underbit Technologies, Inc."
 # define ID3_EMAIL		"info@underbit.com"
 
diff --git a/src/libid3tag/latin1.c b/src/libid3tag/latin1.c
index 12ecb9ed7..67b8199bc 100644
--- a/src/libid3tag/latin1.c
+++ b/src/libid3tag/latin1.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: latin1.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: latin1.c,v 1.10 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/latin1.h b/src/libid3tag/latin1.h
index 287dd6722..3604bbf0f 100644
--- a/src/libid3tag/latin1.h
+++ b/src/libid3tag/latin1.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: latin1.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: latin1.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_LATIN1_H
diff --git a/src/libid3tag/parse.c b/src/libid3tag/parse.c
index f3ddad865..86a3f219b 100644
--- a/src/libid3tag/parse.c
+++ b/src/libid3tag/parse.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: parse.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: parse.c,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/parse.h b/src/libid3tag/parse.h
index 20f79ad3d..5dfa23f31 100644
--- a/src/libid3tag/parse.h
+++ b/src/libid3tag/parse.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: parse.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: parse.h,v 1.6 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_PARSE_H
diff --git a/src/libid3tag/render.c b/src/libid3tag/render.c
index 29b8e8acc..668a487bf 100644
--- a/src/libid3tag/render.c
+++ b/src/libid3tag/render.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: render.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: render.c,v 1.11 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/render.h b/src/libid3tag/render.h
index 5fa8c17da..702605dd5 100644
--- a/src/libid3tag/render.h
+++ b/src/libid3tag/render.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: render.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: render.h,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_RENDER_H
diff --git a/src/libid3tag/tag.c b/src/libid3tag/tag.c
index 4c9ad1929..be4e8e777 100644
--- a/src/libid3tag/tag.c
+++ b/src/libid3tag/tag.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: tag.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: tag.c,v 1.20 2004/02/17 02:04:10 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -506,7 +506,7 @@ struct id3_tag *v2_parse(id3_byte_t const *ptr)
 
 	      crc = id3_parse_uint(&ehptr, 4);
 
-	      if (crc != id3_crc_calculate(ptr, end - ptr))
+	      if (crc != id3_crc_compute(ptr, end - ptr))
 		goto fail;
 
 	      tag->extendedflags |= ID3_TAG_EXTENDEDFLAG_CRCDATAPRESENT;
@@ -579,7 +579,7 @@ struct id3_tag *v2_parse(id3_byte_t const *ptr)
 	    crc = id3_parse_syncsafe(&ehptr, 5);
 	    ehptr += bytes - 5;
 
-	    if (crc != id3_crc_calculate(ptr, end - ptr))
+	    if (crc != id3_crc_compute(ptr, end - ptr))
 	      goto fail;
 	  }
 
@@ -895,7 +895,7 @@ id3_length_t id3_tag_render(struct id3_tag const *tag, id3_byte_t *buffer)
 
   if (crc_ptr) {
     id3_render_syncsafe(&crc_ptr,
-			id3_crc_calculate(frames_ptr, *ptr - frames_ptr), 5);
+			id3_crc_compute(frames_ptr, *ptr - frames_ptr), 5);
   }
 
   /* footer */
diff --git a/src/libid3tag/tag.h b/src/libid3tag/tag.h
index ebc90960f..2ce84d7cf 100644
--- a/src/libid3tag/tag.h
+++ b/src/libid3tag/tag.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: tag.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: tag.h,v 1.10 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_TAG_H
diff --git a/src/libid3tag/ucs4.c b/src/libid3tag/ucs4.c
index 7062e993a..15dace869 100644
--- a/src/libid3tag/ucs4.c
+++ b/src/libid3tag/ucs4.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: ucs4.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: ucs4.c,v 1.13 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/ucs4.h b/src/libid3tag/ucs4.h
index e1106dd1e..bfb325d5e 100644
--- a/src/libid3tag/ucs4.h
+++ b/src/libid3tag/ucs4.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: ucs4.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: ucs4.h,v 1.11 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_UCS4_H
diff --git a/src/libid3tag/utf16.c b/src/libid3tag/utf16.c
index 8b8f47934..70ee9d5a8 100644
--- a/src/libid3tag/utf16.c
+++ b/src/libid3tag/utf16.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: utf16.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: utf16.c,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/utf16.h b/src/libid3tag/utf16.h
index 6159d2bbc..b7be49c3b 100644
--- a/src/libid3tag/utf16.h
+++ b/src/libid3tag/utf16.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: utf16.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: utf16.h,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_UTF16_H
diff --git a/src/libid3tag/utf8.c b/src/libid3tag/utf8.c
index 76b08719b..4d8649a32 100644
--- a/src/libid3tag/utf8.c
+++ b/src/libid3tag/utf8.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: utf8.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: utf8.c,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/utf8.h b/src/libid3tag/utf8.h
index 98f1445a7..572bb2ab2 100644
--- a/src/libid3tag/utf8.h
+++ b/src/libid3tag/utf8.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: utf8.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: utf8.h,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_UTF8_H
diff --git a/src/libid3tag/util.c b/src/libid3tag/util.c
index a7ecc25f3..61ccccf6c 100644
--- a/src/libid3tag/util.c
+++ b/src/libid3tag/util.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: util.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: util.c,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/util.h b/src/libid3tag/util.h
index 12eb99390..4b895d237 100644
--- a/src/libid3tag/util.h
+++ b/src/libid3tag/util.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: util.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: util.h,v 1.6 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_UTIL_H
diff --git a/src/libid3tag/version.c b/src/libid3tag/version.c
index 7dfd97cce..d54b80aca 100644
--- a/src/libid3tag/version.c
+++ b/src/libid3tag/version.c
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: version.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: version.c,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libid3tag/version.h b/src/libid3tag/version.h
index e68a486a8..5eaa11f3c 100644
--- a/src/libid3tag/version.h
+++ b/src/libid3tag/version.h
@@ -1,6 +1,6 @@
 /*
  * libid3tag - ID3 tag manipulation library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: version.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: version.h,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBID3TAG_VERSION_H
diff --git a/src/libmad/CHANGES b/src/libmad/CHANGES
index 92f97678f..9291760b9 100644
--- a/src/libmad/CHANGES
+++ b/src/libmad/CHANGES
@@ -1,11 +1,28 @@
 
  libmad - MPEG audio decoder library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: CHANGES,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: CHANGES,v 1.14 2004/02/17 02:02:03 rob Exp $
 
 ===============================================================================
 
+Version 0.15.1 (beta)
+
+  * Updated to autoconf 2.59, automake 1.8.2, libtool 1.5.2.
+
+  * Replaced Layer III IMDCT routine with one based on a faster algorithm,
+    improving both speed and accuracy.
+
+  * Improved portability of the Huffman table initialization.
+
+  * Fixed a problem that could result in an assertion failure in layer3.c
+    due to an invalid Layer III free format bitrate.
+
+  * Improved the robustness of Layer II bitrate/mode combinations, and added
+    a new MAD_ERROR_BADMODE error enum. The allowability of low-bitrate
+    stereo streams is influenced by the --enable-strict-iso option to
+    `configure'.
+
 Version 0.15.0 (beta)
 
   * Updated to autoconf 2.57, automake 1.7.5, libtool 1.4.3.
@@ -98,7 +115,7 @@ Version 0.13.0 (beta)
   * Eliminated `+' from asm constraints under Intel for better compatibility
     with some compilers.
 
-  * Fixed a PIC-related problem in libmad/imdct_l_arm.S.
+  * Fixed a PIC-related problem in imdct_l_arm.S.
 
   * Eliminated a static variable to make libmad thread-safe.
 
@@ -196,9 +213,9 @@ Version 0.12.0 (alpha)
   * Further developed the async API; arbitrary messages can now be passed to
     the subsidiary decoding process.
 
-  * Streamlined libmad/timer.c and extended its interface. It now has
-    support for video frame/field lengths, including output support for
-    drop-frame encoding.
+  * Streamlined timer.c and extended its interface. It now has support for
+    video frame/field lengths, including output support for drop-frame
+    encoding.
 
   * Replaced many constant integer preprocessor defines with enums.
 
diff --git a/src/libmad/COPYRIGHT b/src/libmad/COPYRIGHT
index 1e923530b..ed91d2bac 100644
--- a/src/libmad/COPYRIGHT
+++ b/src/libmad/COPYRIGHT
@@ -1,6 +1,6 @@
 
  libmad - MPEG audio decoder library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
  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
diff --git a/src/libmad/CREDITS b/src/libmad/CREDITS
index 3a7003a04..72ec72eda 100644
--- a/src/libmad/CREDITS
+++ b/src/libmad/CREDITS
@@ -1,8 +1,8 @@
 
  libmad - MPEG audio decoder library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: CREDITS,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: CREDITS,v 1.5 2004/02/17 02:02:03 rob Exp $
 
 ===============================================================================
 
@@ -19,12 +19,20 @@ CONTRIBUTORS
       Anonymous
         2002/03/15: frame.c
           - Reported problem with use of reserved emphasis value.
+        2003/08/31: layer12.c
+          - Suggested support for certain disallowed bitrate/mode
+            combinations.
 
       Niek Albers <info@daansystems.com>
         2003/04/21: layer3.c
           - Reported runtime uninitialized use of `ptr' in designating
             ancillary bits after a decoding error.
 
+      Christian Biere <cbiere@users.sourceforge.net>
+        2003/02/01: frame.c
+          - Reported assertion failure in layer3.c due to an
+            invalid/unsupported Layer III free format bitrate.
+
       David Blythe <blythe@routefree.com>
         2001/01/30: fixed.h
           - Provided initial PowerPC fixed-point assembly.
@@ -33,6 +41,10 @@ CONTRIBUTORS
         2000/09/20: imdct_l_arm.S
           - Suggested patch for a.out compatibility.
 
+      Brian Cameron <Brian.Cameron@sun.com>
+        2003/07/02: huffman.c
+          - Suggested changes for improved portability.
+
       Joshua Haberman <joshua@haberman.com>
         2001/08/10: decoder.c, huffman.c
           - Suggested portability fixes.
@@ -41,6 +53,10 @@ CONTRIBUTORS
         2002/05/04: sf_table.dat, layer12.c
           - Reported problem with use of (missing) scalefactor index 63.
 
+      Felix von Leitner <felix-mad@fefe.de>
+        2003/01/21: fixed.h
+          - Suggested Intel scaling alternative for possible speedup.
+
       Andre McCurdy <armccurdy@yahoo.co.uk>
         2000/08/10: imdct_l_arm.S
           - ARM optimized assembly replacement for III_imdct_l().
diff --git a/src/libmad/D.dat b/src/libmad/D.dat
index c4ddbed5d..4a7fa4fa9 100644
--- a/src/libmad/D.dat
+++ b/src/libmad/D.dat
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: D.dat,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: D.dat,v 1.9 2004/01/23 09:41:32 rob Exp $
  */
 
 /*
diff --git a/src/libmad/Makefile.am b/src/libmad/Makefile.am
index ef8551bf3..833a02e75 100644
--- a/src/libmad/Makefile.am
+++ b/src/libmad/Makefile.am
@@ -1,6 +1,6 @@
 ##
 ## libmad - MPEG audio decoder library
-## Copyright (C) 2000-2003 Underbit Technologies, Inc.
+## Copyright (C) 2000-2004 Underbit Technologies, Inc.
 ##
 ## 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
@@ -16,7 +16,7 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ##
-## $Id: Makefile.am,v 1.1 2003/08/14 03:57:13 shank Exp $
+## $Id: Makefile.am,v 1.23 2004/02/17 02:02:03 rob Exp $
 ##
 
 ## Process this file with automake to produce Makefile.in
@@ -96,7 +96,7 @@ CLEANFILES =		mad.h
 ##      then set AGE to 0.
 
 version_current =	2
-version_revision =	0
+version_revision =	1
 version_age =		2
 
 version_info =		$(version_current):$(version_revision):$(version_age)
diff --git a/src/libmad/README b/src/libmad/README
index 2bf564c84..b3f15ea40 100644
--- a/src/libmad/README
+++ b/src/libmad/README
@@ -1,8 +1,8 @@
 
  libmad - MPEG audio decoder library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: README,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: README,v 1.4 2004/01/23 09:41:32 rob Exp $
 
 ===============================================================================
 
diff --git a/src/libmad/TODO b/src/libmad/TODO
index b3e8ba358..1ea107c24 100644
--- a/src/libmad/TODO
+++ b/src/libmad/TODO
@@ -1,8 +1,8 @@
 
  libmad - MPEG audio decoder library
- Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ Copyright (C) 2000-2004 Underbit Technologies, Inc.
 
- $Id: TODO,v 1.1 2003/08/14 03:57:13 shank Exp $
+ $Id: TODO,v 1.3 2004/02/05 09:02:39 rob Exp $
 
 ===============================================================================
 
@@ -57,7 +57,6 @@ libmad Layer I:
   - check frame length sanity
 
 libmad Layer II:
-  - check legal bitrate/mode combinations
   - check frame length sanity
 
 libmad Layer III:
diff --git a/src/libmad/VERSION b/src/libmad/VERSION
index a844b7b58..d4e8f64aa 100644
--- a/src/libmad/VERSION
+++ b/src/libmad/VERSION
@@ -1,7 +1,7 @@
-0.15.0b
+0.15.1b
 configure.ac:24
 version.h:25-28
-msvc++/config.h:115
-msvc++/mad.h:38-41
+msvc++/config.h:99,105,120
+msvc++/mad.h:41-44
 
-Makefile.am:89-91
+Makefile.am:98-100
diff --git a/src/libmad/bit.c b/src/libmad/bit.c
index 597422a22..c2bfb243c 100644
--- a/src/libmad/bit.c
+++ b/src/libmad/bit.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bit.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: bit.c,v 1.12 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/bit.h b/src/libmad/bit.h
index 6960727a2..5a51570b2 100644
--- a/src/libmad/bit.h
+++ b/src/libmad/bit.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bit.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: bit.h,v 1.12 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_BIT_H
diff --git a/src/libmad/config.h.in b/src/libmad/config.h.in
index ec79167a8..2a9671cd2 100644
--- a/src/libmad/config.h.in
+++ b/src/libmad/config.h.in
@@ -118,14 +118,16 @@
 /* Version number of package */
 #undef VERSION
 
+/* Define to 1 if your processor stores words with the most significant byte
+   first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+   if it is not supported. */
 #undef inline
-#endif
 
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
diff --git a/src/libmad/configure.ac b/src/libmad/configure.ac
index aaba8d044..568cd227c 100644
--- a/src/libmad/configure.ac
+++ b/src/libmad/configure.ac
@@ -1,7 +1,7 @@
 dnl -*- m4 -*-
 dnl
 dnl libmad - MPEG audio decoder library
-dnl Copyright (C) 2000-2003 Underbit Technologies, Inc.
+dnl Copyright (C) 2000-2004 Underbit Technologies, Inc.
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -17,11 +17,11 @@ dnl You should have received a copy of the GNU General Public License
 dnl along with this program; if not, write to the Free Software
 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 dnl
-AC_REVISION([$Id: configure.ac,v 1.1 2003/08/14 03:57:13 shank Exp $])dnl
+AC_REVISION([$Id: configure.ac,v 1.9 2004/01/23 09:41:32 rob Exp $])dnl
 
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([MPEG Audio Decoder], [0.15.0b], [support@underbit.com], [libmad])
+AC_INIT([MPEG Audio Decoder], [0.15.1b], [support@underbit.com], [libmad])
 AC_PREREQ(2.53)
 
 AC_CONFIG_SRCDIR([decoder.h])
@@ -212,6 +212,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 
 AC_C_CONST
 AC_C_INLINE
+AC_C_BIGENDIAN
 AC_TYPE_PID_T
 
 AC_CHECK_SIZEOF(int, 2)
diff --git a/src/libmad/decoder.c b/src/libmad/decoder.c
index 926e95c49..6d6df0db5 100644
--- a/src/libmad/decoder.c
+++ b/src/libmad/decoder.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: decoder.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: decoder.c,v 1.22 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/decoder.h b/src/libmad/decoder.h
index 6b1c8235f..f0ad758dd 100644
--- a/src/libmad/decoder.h
+++ b/src/libmad/decoder.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: decoder.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: decoder.h,v 1.17 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_DECODER_H
diff --git a/src/libmad/fixed.c b/src/libmad/fixed.c
index 21f2364e4..9785466f6 100644
--- a/src/libmad/fixed.c
+++ b/src/libmad/fixed.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: fixed.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: fixed.c,v 1.13 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/fixed.h b/src/libmad/fixed.h
index 241e7f95e..4b58abf56 100644
--- a/src/libmad/fixed.h
+++ b/src/libmad/fixed.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: fixed.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: fixed.h,v 1.38 2004/02/17 02:02:03 rob Exp $
  */
 
 # ifndef LIBMAD_FIXED_H
@@ -208,7 +208,22 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
 	    : "cc");  \
        __result;  \
     })
-#    else
+#   elif defined(OPT_INTEL)
+/*
+ * Alternate Intel scaling that may or may not perform better.
+ */
+#    define mad_f_scale64(hi, lo)  \
+    ({ mad_fixed_t __result;  \
+       asm ("shrl %3,%1\n\t"  \
+	    "shll %4,%2\n\t"  \
+	    "orl %2,%1"  \
+	    : "=rm" (__result)  \
+	    : "0" (lo), "r" (hi),  \
+	      "I" (MAD_F_SCALEBITS), "I" (32 - MAD_F_SCALEBITS)  \
+	    : "cc");  \
+       __result;  \
+    })
+#   else
 #    define mad_f_scale64(hi, lo)  \
     ({ mad_fixed_t __result;  \
        asm ("shrdl %3,%2,%1"  \
diff --git a/src/libmad/frame.c b/src/libmad/frame.c
index 8c3342e98..0cb3d0f33 100644
--- a/src/libmad/frame.c
+++ b/src/libmad/frame.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frame.c,v 1.29 2004/02/04 22:59:19 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -376,7 +376,8 @@ int mad_header_decode(struct mad_header *header, struct mad_stream *stream)
 
   /* calculate free bit rate */
   if (header->bitrate == 0) {
-    if ((stream->freerate == 0 || !stream->sync) &&
+    if ((stream->freerate == 0 || !stream->sync ||
+	 (header->layer == MAD_LAYER_III && stream->freerate > 640000)) &&
 	free_bitrate(stream, header) == -1)
       goto fail;
 
diff --git a/src/libmad/frame.h b/src/libmad/frame.h
index 5e5fe716d..3f5bf37ef 100644
--- a/src/libmad/frame.h
+++ b/src/libmad/frame.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: frame.h,v 1.20 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_FRAME_H
diff --git a/src/libmad/global.h b/src/libmad/global.h
index afd9a4809..a6debfd8b 100644
--- a/src/libmad/global.h
+++ b/src/libmad/global.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: global.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: global.h,v 1.11 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_GLOBAL_H
diff --git a/src/libmad/huffman.c b/src/libmad/huffman.c
index 2a52e9237..a230a9c10 100644
--- a/src/libmad/huffman.c
+++ b/src/libmad/huffman.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: huffman.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: huffman.c,v 1.10 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -34,13 +34,19 @@
  * These tables support decoding up to 4 Huffman code bits at a time.
  */
 
-# 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 } }
+# if defined(__GNUC__) ||  \
+    (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
+#  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) } }
+#  if defined(WORDS_BIGENDIAN)
+#   define V(v, w, x, y, hlen)	{ { 1, hlen, (v << 11) | (w << 10) |  \
+                                             (x <<  9) | (y <<  8) } }
+#  else
+#   define V(v, w, x, y, hlen)	{ { 1, hlen, (v <<  0) | (w <<  1) |  \
+                                             (x <<  2) | (y <<  3) } }
+#  endif
 # endif
 
 static
@@ -106,12 +112,17 @@ union huffquad const hufftabB[] = {
 # undef V
 # undef PTR
 
-# if defined(__GNUC__)
-#  define PTR(offs, bits)	{ ptr:   { 0, bits, offs } }
-#  define V(x, y, hlen)		{ value: { 1, hlen, x, y } }
+# if defined(__GNUC__) ||  \
+    (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
+#  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) } }
+#  if defined(WORDS_BIGENDIAN)
+#   define V(x, y, hlen)	{ { 1, hlen, (x << 8) | (y << 4) } }
+#  else
+#   define V(x, y, hlen)	{ { 1, hlen, (x << 0) | (y << 4) } }
+#  endif
 # endif
 
 static
diff --git a/src/libmad/huffman.h b/src/libmad/huffman.h
index e7099276a..6325db44a 100644
--- a/src/libmad/huffman.h
+++ b/src/libmad/huffman.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: huffman.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: huffman.h,v 1.11 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_HUFFMAN_H
diff --git a/src/libmad/imdct_l_arm.S b/src/libmad/imdct_l_arm.S
index 963792831..badec5bcb 100644
--- a/src/libmad/imdct_l_arm.S
+++ b/src/libmad/imdct_l_arm.S
@@ -22,7 +22,7 @@
 *
 *****************************************************************************
 *
-* $Id: imdct_l_arm.S,v 1.1 2003/08/14 03:57:13 shank Exp $
+* $Id: imdct_l_arm.S,v 1.7 2001/03/25 20:03:34 rob Rel $
 *
 * 2001/03/24:  Andre McCurdy <armccurdy@yahoo.co.uk>
 *   - Corrected PIC unsafe loading of address of 'imdct36_long_karray'
diff --git a/src/libmad/imdct_s.dat b/src/libmad/imdct_s.dat
index 73ea91f08..476710eaf 100644
--- a/src/libmad/imdct_s.dat
+++ b/src/libmad/imdct_s.dat
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: imdct_s.dat,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: imdct_s.dat,v 1.8 2004/01/23 09:41:32 rob Exp $
  */
 
   /*  0 */  {  MAD_F(0x09bd7ca0) /*  0.608761429 */,
diff --git a/src/libmad/layer12.c b/src/libmad/layer12.c
index d14122a85..6981f9ce1 100644
--- a/src/libmad/layer12.c
+++ b/src/libmad/layer12.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: layer12.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: layer12.c,v 1.17 2004/02/05 09:02:39 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -341,20 +341,44 @@ int mad_layer_II(struct mad_stream *stream, struct mad_frame *frame)
 
   if (header->flags & MAD_FLAG_LSF_EXT)
     index = 4;
+  else if (header->flags & MAD_FLAG_FREEFORMAT)
+    goto freeformat;
   else {
-    switch (nch == 2 ? header->bitrate / 2 : header->bitrate) {
-    case 32000:
-    case 48000:
+    unsigned long bitrate_per_channel;
+
+    bitrate_per_channel = header->bitrate;
+    if (nch == 2) {
+      bitrate_per_channel /= 2;
+
+# if defined(OPT_STRICT)
+      /*
+       * ISO/IEC 11172-3 allows only single channel mode for 32, 48, 56, and
+       * 80 kbps bitrates in Layer II, but some encoders ignore this
+       * restriction. We enforce it if OPT_STRICT is defined.
+       */
+      if (bitrate_per_channel <= 28000 || bitrate_per_channel == 40000) {
+	stream->error = MAD_ERROR_BADMODE;
+	return -1;
+      }
+# endif
+    }
+    else {  /* nch == 1 */
+      if (bitrate_per_channel > 192000) {
+	/*
+	 * ISO/IEC 11172-3 does not allow single channel mode for 224, 256,
+	 * 320, or 384 kbps bitrates in Layer II.
+	 */
+	stream->error = MAD_ERROR_BADMODE;
+	return -1;
+      }
+    }
+
+    if (bitrate_per_channel <= 48000)
       index = (header->samplerate == 32000) ? 3 : 2;
-      break;
-
-    case 56000:
-    case 64000:
-    case 80000:
+    else if (bitrate_per_channel <= 80000)
       index = 0;
-      break;
-
-    default:
+    else {
+    freeformat:
       index = (header->samplerate == 48000) ? 0 : 1;
     }
   }
diff --git a/src/libmad/layer12.h b/src/libmad/layer12.h
index 273d6ac79..e1c499696 100644
--- a/src/libmad/layer12.h
+++ b/src/libmad/layer12.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: layer12.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: layer12.h,v 1.10 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_LAYER12_H
diff --git a/src/libmad/layer3.c b/src/libmad/layer3.c
index e1b073c71..4e5d3fa02 100644
--- a/src/libmad/layer3.c
+++ b/src/libmad/layer3.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: layer3.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: layer3.c,v 1.43 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -1575,6 +1575,193 @@ void III_aliasreduce(mad_fixed_t xr[576], int lines)
 # if defined(ASO_IMDCT)
 void III_imdct_l(mad_fixed_t const [18], mad_fixed_t [36], unsigned int);
 # else
+#  if 1
+static
+void fastsdct(mad_fixed_t const x[9], mad_fixed_t y[18])
+{
+  mad_fixed_t a0,  a1,  a2,  a3,  a4,  a5,  a6,  a7,  a8,  a9,  a10, a11, a12;
+  mad_fixed_t a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25;
+  mad_fixed_t m0,  m1,  m2,  m3,  m4,  m5,  m6,  m7;
+
+  enum {
+    c0 =  MAD_F(0x1f838b8d),  /* 2 * cos( 1 * PI / 18) */
+    c1 =  MAD_F(0x1bb67ae8),  /* 2 * cos( 3 * PI / 18) */
+    c2 =  MAD_F(0x18836fa3),  /* 2 * cos( 4 * PI / 18) */
+    c3 =  MAD_F(0x1491b752),  /* 2 * cos( 5 * PI / 18) */
+    c4 =  MAD_F(0x0af1d43a),  /* 2 * cos( 7 * PI / 18) */
+    c5 =  MAD_F(0x058e86a0),  /* 2 * cos( 8 * PI / 18) */
+    c6 = -MAD_F(0x1e11f642)   /* 2 * cos(16 * PI / 18) */
+  };
+
+  a0 = x[3] + x[5];
+  a1 = x[3] - x[5];
+  a2 = x[6] + x[2];
+  a3 = x[6] - x[2];
+  a4 = x[1] + x[7];
+  a5 = x[1] - x[7];
+  a6 = x[8] + x[0];
+  a7 = x[8] - x[0];
+
+  a8  = a0  + a2;
+  a9  = a0  - a2;
+  a10 = a0  - a6;
+  a11 = a2  - a6;
+  a12 = a8  + a6;
+  a13 = a1  - a3;
+  a14 = a13 + a7;
+  a15 = a3  + a7;
+  a16 = a1  - a7;
+  a17 = a1  + a3;
+
+  m0 = mad_f_mul(a17, -c3);
+  m1 = mad_f_mul(a16, -c0);
+  m2 = mad_f_mul(a15, -c4);
+  m3 = mad_f_mul(a14, -c1);
+  m4 = mad_f_mul(a5,  -c1);
+  m5 = mad_f_mul(a11, -c6);
+  m6 = mad_f_mul(a10, -c5);
+  m7 = mad_f_mul(a9,  -c2);
+
+  a18 =     x[4] + a4;
+  a19 = 2 * x[4] - a4;
+  a20 = a19 + m5;
+  a21 = a19 - m5;
+  a22 = a19 + m6;
+  a23 = m4  + m2;
+  a24 = m4  - m2;
+  a25 = m4  + m1;
+
+  /* output to every other slot for convenience */
+
+  y[ 0] = a18 + a12;
+  y[ 2] = m0  - a25;
+  y[ 4] = m7  - a20;
+  y[ 6] = m3;
+  y[ 8] = a21 - m6;
+  y[10] = a24 - m1;
+  y[12] = a12 - 2 * a18;
+  y[14] = a23 + m0;
+  y[16] = a22 + m7;
+}
+
+static inline
+void sdctII(mad_fixed_t const x[18], mad_fixed_t X[18])
+{
+  mad_fixed_t tmp[9];
+  int i;
+
+  /* scale[i] = 2 * cos(PI * (2 * i + 1) / (2 * 18)) */
+  static mad_fixed_t const scale[9] = {
+    MAD_F(0x1fe0d3b4), MAD_F(0x1ee8dd47), MAD_F(0x1d007930),
+    MAD_F(0x1a367e59), MAD_F(0x16a09e66), MAD_F(0x125abcf8),
+    MAD_F(0x0d8616bc), MAD_F(0x08483ee1), MAD_F(0x02c9fad7)
+  };
+
+  /* divide the 18-point SDCT-II into two 9-point SDCT-IIs */
+
+  /* even input butterfly */
+
+  for (i = 0; i < 9; i += 3) {
+    tmp[i + 0] = x[i + 0] + x[18 - (i + 0) - 1];
+    tmp[i + 1] = x[i + 1] + x[18 - (i + 1) - 1];
+    tmp[i + 2] = x[i + 2] + x[18 - (i + 2) - 1];
+  }
+
+  fastsdct(tmp, &X[0]);
+
+  /* odd input butterfly and scaling */
+
+  for (i = 0; i < 9; i += 3) {
+    tmp[i + 0] = mad_f_mul(x[i + 0] - x[18 - (i + 0) - 1], scale[i + 0]);
+    tmp[i + 1] = mad_f_mul(x[i + 1] - x[18 - (i + 1) - 1], scale[i + 1]);
+    tmp[i + 2] = mad_f_mul(x[i + 2] - x[18 - (i + 2) - 1], scale[i + 2]);
+  }
+
+  fastsdct(tmp, &X[1]);
+
+  /* output accumulation */
+
+  for (i = 3; i < 18; i += 8) {
+    X[i + 0] -= X[(i + 0) - 2];
+    X[i + 2] -= X[(i + 2) - 2];
+    X[i + 4] -= X[(i + 4) - 2];
+    X[i + 6] -= X[(i + 6) - 2];
+  }
+}
+
+static inline
+void dctIV(mad_fixed_t const y[18], mad_fixed_t X[18])
+{
+  mad_fixed_t tmp[18];
+  int i;
+
+  /* scale[i] = 2 * cos(PI * (2 * i + 1) / (4 * 18)) */
+  static mad_fixed_t const scale[18] = {
+    MAD_F(0x1ff833fa), MAD_F(0x1fb9ea93), MAD_F(0x1f3dd120),
+    MAD_F(0x1e84d969), MAD_F(0x1d906bcf), MAD_F(0x1c62648b),
+    MAD_F(0x1afd100f), MAD_F(0x1963268b), MAD_F(0x1797c6a4),
+    MAD_F(0x159e6f5b), MAD_F(0x137af940), MAD_F(0x11318ef3),
+    MAD_F(0x0ec6a507), MAD_F(0x0c3ef153), MAD_F(0x099f61c5),
+    MAD_F(0x06ed12c5), MAD_F(0x042d4544), MAD_F(0x0165547c)
+  };
+
+  /* scaling */
+
+  for (i = 0; i < 18; i += 3) {
+    tmp[i + 0] = mad_f_mul(y[i + 0], scale[i + 0]);
+    tmp[i + 1] = mad_f_mul(y[i + 1], scale[i + 1]);
+    tmp[i + 2] = mad_f_mul(y[i + 2], scale[i + 2]);
+  }
+
+  /* SDCT-II */
+
+  sdctII(tmp, X);
+
+  /* scale reduction and output accumulation */
+
+  X[0] /= 2;
+  for (i = 1; i < 17; i += 4) {
+    X[i + 0] = X[i + 0] / 2 - X[(i + 0) - 1];
+    X[i + 1] = X[i + 1] / 2 - X[(i + 1) - 1];
+    X[i + 2] = X[i + 2] / 2 - X[(i + 2) - 1];
+    X[i + 3] = X[i + 3] / 2 - X[(i + 3) - 1];
+  }
+  X[17] = X[17] / 2 - X[16];
+}
+
+/*
+ * NAME:	imdct36
+ * DESCRIPTION:	perform X[18]->x[36] IMDCT using Szu-Wei Lee's fast algorithm
+ */
+static inline
+void imdct36(mad_fixed_t const x[18], mad_fixed_t y[36])
+{
+  mad_fixed_t tmp[18];
+  int i;
+
+  /* DCT-IV */
+
+  dctIV(x, tmp);
+
+  /* convert 18-point DCT-IV to 36-point IMDCT */
+
+  for (i =  0; i <  9; i += 3) {
+    y[i + 0] =  tmp[9 + (i + 0)];
+    y[i + 1] =  tmp[9 + (i + 1)];
+    y[i + 2] =  tmp[9 + (i + 2)];
+  }
+  for (i =  9; i < 27; i += 3) {
+    y[i + 0] = -tmp[36 - (9 + (i + 0)) - 1];
+    y[i + 1] = -tmp[36 - (9 + (i + 1)) - 1];
+    y[i + 2] = -tmp[36 - (9 + (i + 2)) - 1];
+  }
+  for (i = 27; i < 36; i += 3) {
+    y[i + 0] = -tmp[(i + 0) - 27];
+    y[i + 1] = -tmp[(i + 1) - 27];
+    y[i + 2] = -tmp[(i + 2) - 27];
+  }
+}
+#  else
 /*
  * NAME:	imdct36
  * DESCRIPTION:	perform X[18]->x[36] IMDCT
@@ -1865,6 +2052,7 @@ void imdct36(mad_fixed_t const X[18], mad_fixed_t x[36])
 
   x[26] = x[27] = MAD_F_MLZ(hi, lo) + t5;
 }
+#  endif
 
 /*
  * NAME:	III_imdct_l()
@@ -1929,7 +2117,11 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
     break;
 
   case 1:  /* start block */
-    for (i =  0; i < 18; ++i) z[i] = mad_f_mul(z[i], window_l[i]);
+    for (i =  0; i < 18; i += 3) {
+      z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]);
+      z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]);
+      z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]);
+    }
     /*  (i = 18; i < 24; ++i) z[i] unchanged */
     for (i = 24; i < 30; ++i) z[i] = mad_f_mul(z[i], window_s[i - 18]);
     for (i = 30; i < 36; ++i) z[i] = 0;
@@ -1939,7 +2131,11 @@ void III_imdct_l(mad_fixed_t const X[18], mad_fixed_t z[36],
     for (i =  0; i <  6; ++i) z[i] = 0;
     for (i =  6; i < 12; ++i) z[i] = mad_f_mul(z[i], window_s[i - 6]);
     /*  (i = 12; i < 18; ++i) z[i] unchanged */
-    for (i = 18; i < 36; ++i) z[i] = mad_f_mul(z[i], window_l[i]);
+    for (i = 18; i < 36; i += 3) {
+      z[i + 0] = mad_f_mul(z[i + 0], window_l[i + 0]);
+      z[i + 1] = mad_f_mul(z[i + 1], window_l[i + 1]);
+      z[i + 2] = mad_f_mul(z[i + 2], window_l[i + 2]);
+    }
     break;
   }
 }
diff --git a/src/libmad/layer3.h b/src/libmad/layer3.h
index 07ab47805..2504d461a 100644
--- a/src/libmad/layer3.h
+++ b/src/libmad/layer3.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: layer3.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: layer3.h,v 1.10 2004/01/23 09:41:32 rob Exp $
  */
 
 # ifndef LIBMAD_LAYER3_H
diff --git a/src/libmad/mad.h.sed b/src/libmad/mad.h.sed
index 2691b951e..702878547 100644
--- a/src/libmad/mad.h.sed
+++ b/src/libmad/mad.h.sed
@@ -1,6 +1,6 @@
 #
 # libmad - MPEG audio decoder library
-# Copyright (C) 2000-2003 Underbit Technologies, Inc.
+# Copyright (C) 2000-2004 Underbit Technologies, Inc.
 #
 # 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
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
-# $Id: mad.h.sed,v 1.1 2003/08/14 03:57:13 shank Exp $
+# $Id: mad.h.sed,v 1.9 2004/01/23 09:41:32 rob Exp $
 #
 
 /^\/\*$/{
diff --git a/src/libmad/minimad.c b/src/libmad/minimad.c
index bb4f7154a..ac412ae44 100644
--- a/src/libmad/minimad.c
+++ b/src/libmad/minimad.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: minimad.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: minimad.c,v 1.4 2004/01/23 09:41:32 rob Exp $
  */
 
 # include <stdio.h>
@@ -163,8 +163,8 @@ enum mad_flow output(void *data,
 /*
  * This is the error callback function. It is called whenever a decoding
  * error occurs. The error is indicated by stream->error; the list of
- * possible MAD_ERROR_* errors can be found in the mad.h (or
- * libmad/stream.h) header file.
+ * possible MAD_ERROR_* errors can be found in the mad.h (or stream.h)
+ * header file.
  */
 
 static
@@ -184,9 +184,9 @@ enum mad_flow error(void *data,
 }
 
 /*
- * This is the function called by main() above to perform all the
- * decoding. It instantiates a decoder object and configures it with the
- * input, output, and error callback functions above. A single call to
+ * This is the function called by main() above to perform all the decoding.
+ * It instantiates a decoder object and configures it with the input,
+ * output, and error callback functions above. A single call to
  * mad_decoder_run() continues until a callback function returns
  * MAD_FLOW_STOP (to stop decoding) or MAD_FLOW_BREAK (to stop decoding and
  * signal an error).
diff --git a/src/libmad/qc_table.dat b/src/libmad/qc_table.dat
index 67a159b25..35a22234f 100644
--- a/src/libmad/qc_table.dat
+++ b/src/libmad/qc_table.dat
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: qc_table.dat,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: qc_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 /*
diff --git a/src/libmad/rq_table.dat b/src/libmad/rq_table.dat
index 47010085f..059c4f318 100644
--- a/src/libmad/rq_table.dat
+++ b/src/libmad/rq_table.dat
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: rq_table.dat,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: rq_table.dat,v 1.7 2004/01/23 09:41:32 rob Exp $
  */
 
 /*
diff --git a/src/libmad/sf_table.dat b/src/libmad/sf_table.dat
index 2a234bf38..db1484a0e 100644
--- a/src/libmad/sf_table.dat
+++ b/src/libmad/sf_table.dat
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: sf_table.dat,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: sf_table.dat,v 1.7 2004/01/23 09:41:33 rob Exp $
  */
 
 /*
diff --git a/src/libmad/stream.c b/src/libmad/stream.c
index 1813019f6..8bb4d6a49 100644
--- a/src/libmad/stream.c
+++ b/src/libmad/stream.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: stream.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: stream.c,v 1.12 2004/02/05 09:02:39 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
@@ -145,6 +145,7 @@ char const *mad_stream_errorstr(struct mad_stream const *stream)
   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_BADMODE:	 return "bad bitrate/mode combination";
   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";
diff --git a/src/libmad/stream.h b/src/libmad/stream.h
index 337ae2305..8bff8b49d 100644
--- a/src/libmad/stream.h
+++ b/src/libmad/stream.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: stream.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: stream.h,v 1.20 2004/02/05 09:02:39 rob Exp $
  */
 
 # ifndef LIBMAD_STREAM_H
@@ -44,6 +44,7 @@ enum mad_error {
   MAD_ERROR_BADCRC	   = 0x0201,	/* CRC check failed */
   MAD_ERROR_BADBITALLOC	   = 0x0211,	/* forbidden bit allocation value */
   MAD_ERROR_BADSCALEFACTOR = 0x0221,	/* bad scalefactor index */
+  MAD_ERROR_BADMODE        = 0x0222,	/* bad bitrate/mode combination */
   MAD_ERROR_BADFRAMELEN	   = 0x0231,	/* bad frame length */
   MAD_ERROR_BADBIGVALUES   = 0x0232,	/* bad big_values count */
   MAD_ERROR_BADBLOCKTYPE   = 0x0233,	/* reserved block_type */
diff --git a/src/libmad/synth.c b/src/libmad/synth.c
index df6b52e41..1d28d438c 100644
--- a/src/libmad/synth.c
+++ b/src/libmad/synth.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: synth.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: synth.c,v 1.25 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/synth.h b/src/libmad/synth.h
index 223350100..8ae4bc95e 100644
--- a/src/libmad/synth.h
+++ b/src/libmad/synth.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: synth.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: synth.h,v 1.15 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifndef LIBMAD_SYNTH_H
diff --git a/src/libmad/timer.c b/src/libmad/timer.c
index c2819e2fd..4b909aba9 100644
--- a/src/libmad/timer.c
+++ b/src/libmad/timer.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: timer.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: timer.c,v 1.18 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/timer.h b/src/libmad/timer.h
index 7cee42c4a..eb4542bb9 100644
--- a/src/libmad/timer.h
+++ b/src/libmad/timer.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: timer.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifndef LIBMAD_TIMER_H
diff --git a/src/libmad/version.c b/src/libmad/version.c
index ce06888ba..e643fa71e 100644
--- a/src/libmad/version.c
+++ b/src/libmad/version.c
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: version.c,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: version.c,v 1.15 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifdef HAVE_CONFIG_H
diff --git a/src/libmad/version.h b/src/libmad/version.h
index 70f8cd76a..d215d4c10 100644
--- a/src/libmad/version.h
+++ b/src/libmad/version.h
@@ -1,6 +1,6 @@
 /*
  * libmad - MPEG audio decoder library
- * Copyright (C) 2000-2003 Underbit Technologies, Inc.
+ * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  *
  * 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
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: version.h,v 1.1 2003/08/14 03:57:13 shank Exp $
+ * $Id: version.h,v 1.26 2004/01/23 09:41:33 rob Exp $
  */
 
 # ifndef LIBMAD_VERSION_H
@@ -24,7 +24,7 @@
 
 # define MAD_VERSION_MAJOR	0
 # define MAD_VERSION_MINOR	15
-# define MAD_VERSION_PATCH	0
+# define MAD_VERSION_PATCH	1
 # define MAD_VERSION_EXTRA	" (beta)"
 
 # define MAD_VERSION_STRINGIZE(str)	#str
@@ -35,7 +35,7 @@
 				MAD_VERSION_STRING(MAD_VERSION_PATCH)  \
 				MAD_VERSION_EXTRA
 
-# define MAD_PUBLISHYEAR	"2000-2003"
+# define MAD_PUBLISHYEAR	"2000-2004"
 # define MAD_AUTHOR		"Underbit Technologies, Inc."
 # define MAD_EMAIL		"info@underbit.com"